{"lang": "Mono C#", "source_code": "\ufeffusing System;\n\nnamespace _750A\n{\n class Program\n {\n static void Main(string[] args)\n {\n string str = Console.ReadLine();\n int index = str.IndexOf(' ');\n int n = Convert.ToInt32(str.Substring(0, index));\n int k = Convert.ToInt32(str.Substring(index));\n\n int time = 240 - k;\n int count = 0;\n\n for(int i = 1; i <= n; i++)\n {\n if (time - i * 5 >= 0)\n {\n count++;\n time -= i * 5;\n }\n else break;\n }\n\n Console.WriteLine(count);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "math", "implementation", "binary search"], "code_uid": "581c2f9c559f400f9b36059d830ef6b9", "src_uid": "41e554bc323857be7b8483ee358a35e2", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\n\nnamespace Task2\n{\n class Program\n {\n static void Main(string[] args)\n {\n string str = Console.ReadLine();\n string[] s = str.Split(' ');\n int n = Convert.ToInt32(s[0]);\n int k = Convert.ToInt32(s[1]);\n\n int time = 240 - k;\n int i;\n for (i = 1; i <= n; i++)\n {\n int task = i * 5;\n if (time - task < 0)\n {\n break;\n }\n\n else\n {\n time -= task;\n\n }\n }\n i--;\n Console.WriteLine(i);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "math", "implementation", "binary search"], "code_uid": "40243fcc0a19231a344d8b04e6b8098e", "src_uid": "41e554bc323857be7b8483ee358a35e2", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeff using System;\n using System.IO;\n using System.Numerics;\n using System.Collections.Generic;\n\n namespace con2\n {\n class Program\n {\n static void Main(string[] args)\n {\n //Console.SetIn(new StreamReader(\"input.txt\"));\n\n solve_262A();\n }\n \n public static void solve_262A()\n {\n string[] nm = Console.ReadLine().Split(' ');\n \n int n = Convert.ToInt32(nm[0]);\n int m = Convert.ToInt32(nm[1]);\n \n int bought = n;\n int max = n;\n int step = bought;\n while (step > 0)\n {\n step = bought / m;\n max += step;\n bought = step + (bought - step * m);\n \n }\n Console.WriteLine(max);\n }\n\n public static void solve_cf579C()\n {\n long n = Convert.ToInt32(Console.ReadLine());\n string[] test = Console.ReadLine().Split(' ');\n \n //test what happens if we calculate gcd of 0 and a number: gcd(0, 6);\n long min = 0;//Convert.ToInt64(test[0]);\n for (int i = 0; i < n; ++i)\n {\n long cur = Convert.ToInt64(test[i]);\n //test if the order of arguments changes the output of gcd\n //gcd(cur, min) or gcd(min, cur)\n min = gcd(min, cur);\n \n }\n \n long count = getDividersImproved1(min);\n \n Console.WriteLine(count);\n }\n \n public static long gcd(long a, long b)\n {\n if (b == 0)\n {\n return a;\n }\n return gcd(b, a % b);\n }\n \n public static long getDividersImproved1(long n)\n { \n long count = 0;\n //check why changing type from int to long makes it faster.\n for (long factor = 1; factor * factor <= n; ++factor)\n {\n if (n % factor == 0)\n {\n count++;\n //test if we can just check factor not to be equal to factor after divison: n / factor\n if (factor != n / factor)\n {\n count++;\n }\n }\n }\n \n return count;\n }\n \n public static List getDividersImproved2(long n)\n {\n List result = new List();\n \n for (int factor = 1; factor * factor <= n; ++factor)\n {\n if (n % factor == 0)\n {\n result.Add(factor);\n //test if we can just check factor not to be equal to factor after divison: n / factor\n if (factor != n / factor)\n {\n result.Add(n / factor);\n }\n }\n }\n \n return result;\n }\n \n public static List getDividersImproved(long n)\n {\n List result = new List();\n \n result.Add(1);\n for (long factor = 2; factor <= Math.Sqrt(n); ++factor)\n {\n if (n % factor == 0)\n {\n result.Add(factor);\n result.Add(n / factor);\n }\n }\n \n if (n > 1)\n {\n result.Add(n);\n }\n \n return result;\n }\n }\n }\n", "lang_cluster": "C#", "tags": ["brute force", "math", "implementation"], "code_uid": "1dfec1474596a5b530bddf60447e22d9", "src_uid": "42b25b7335ec01794fbb1d4086aa9dd0", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nnamespace ConsoleApp1\n{\n class Program\n {\n static void Main(string[] args)\n {\n var str = Console.ReadLine().Split(' ');\n var n = Int32.Parse(str[0]);\n var m = Int32.Parse(str[1]);\n var res = n;\n while (true)\n {\n res += n / m;\n n = (n / m) + n % m;\n if (n < m)\n break;\n } \n \n Console.WriteLine(res);\n }\n }\n}\n\n", "lang_cluster": "C#", "tags": ["brute force", "math", "implementation"], "code_uid": "c4b9e8822eda40bdcc8f1dd53cc334e2", "src_uid": "42b25b7335ec01794fbb1d4086aa9dd0", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\n\nnamespace ConsoleApplication3\n{\n class Program\n {\n static void Main(string[] args)\n {\n double n, m, a;\n string s = Console.ReadLine();\n n = Convert.ToDouble(s.Split(' ')[0]);\n m = Convert.ToDouble(s.Split(' ')[1]);\n a = Convert.ToDouble(s.Split(' ')[2]);\n double modN = n % a;\n double modM = m % a;\n if (n > a && modN == 0)\n n += modN;\n else if (n > a && modN != 0)\n n += a - modN;\n else\n n = a;\n if (m > a && modM==0)\n m += modM;\n else if(m > a && modM != 0)\n m += a - modM;\n else\n m = a;\n\n Console.WriteLine(Convert.ToInt64(Math.Ceiling((m*n)/(a*a))));\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math"], "code_uid": "c7f7f1c95f11547785d00a7083ca6569", "src_uid": "ef971874d8c4da37581336284b688517", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\n\nnamespace CodeForces\n{\n class Program\n {\n static void Main(string[] args)\n {\n var line = Console.ReadLine().Split(' ');\n double n = 0, m = 0, a = 0;\n double.TryParse(line[0], out n);\n double.TryParse(line[1], out m);\n double.TryParse(line[2], out a);\n double flagSquare = 0;\n\n double square = n * m;\n\n flagSquare = Math.Ceiling(n / a) * Math.Ceiling(m / a);\n\n Finish:\n Console.WriteLine((long)flagSquare);\n\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math"], "code_uid": "afc87d7ce93a2f64f655a0a37b507d81", "src_uid": "ef971874d8c4da37581336284b688517", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\n class Program\n {\n static void Main(string[] args)\n {\n Console.Write(int.Parse(Console.ReadLine()) % 2 == 0?\"Mahmoud\": \"Ehab\");\n }\n }\n", "lang_cluster": "C#", "tags": ["math", "games"], "code_uid": "926db1ae0e57b26f9a093bcce07c98d5", "src_uid": "5e74750f44142624e6da41d4b35beb9a", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace Elephant\n{\n class Program\n {\n static void Main(string[] args)\n {\n\n int n = int.Parse(Console.ReadLine());\n\n if ((n % 2) == 0)\n {\n Console.WriteLine(\"Mahmoud\");\n }\n else\n {\n Console.WriteLine(\"Ehab\");\n }\n\n }\n }\n}", "lang_cluster": "C#", "tags": ["math", "games"], "code_uid": "e6d896c159217805ededb40bb355e264", "src_uid": "5e74750f44142624e6da41d4b35beb9a", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Linq;\nusing System.Collections;\nusing System.Collections.Generic;\n\nnamespace csharp\n{\n static class Solver\n {\n static void Main(string[] args)\n {\n var val = ReadInts().ToList();\n val.Sort();\n\n if (val[0] + val[1] > val[2] || val[1] + val[2] > val[3]) Console.WriteLine(\"TRIANGLE\");\n else if (val[0] + val[1] < val[2] && val[1] + val[2] < val[3]) Console.WriteLine(\"IMPOSSIBLE\");\n else Console.WriteLine(\"SEGMENT\"); \n }\n\n private static IEnumerable ReadInts() => Console.ReadLine().Split(' ').Select(int.Parse); \n private static int ReadInt() => int.Parse(Console.ReadLine());\n private static void Print(this IEnumerable items, string separator) \n => Console.WriteLine(string.Join(separator, items.Select(i => i.ToString()).ToArray())); \n \n private class SDictionary : Dictionary\n {\n public new TValue this[TKey key]\n {\n get { return base.TryGetValue(key, out var value) ? value : default(TValue); }\n set { base[key] = value; }\n }\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "geometry"], "code_uid": "2adc301b1cf3f2121a8414a8075e0b20", "src_uid": "8f5df9a41e6e100aa65b9fc1d26e447a", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\n\nclass X{\n\tpublic static void Main(String[] args){\n\t\tList list = (new List(System.Console.ReadLine().Split(\" \".ToCharArray()))).ConvertAll(delegate(string s){ return Int32.Parse(s);});\n\t\tlist.Sort();\n\t\tlist.Reverse();\n\t\tif(\n\t\t\t(list[0] < list[1] + list[2]) ||\n\t\t\t(list[1] < list[2] + list[3])\n\t\t){\n\t\t\tSystem.Console.WriteLine(\"TRIANGLE\");\n\t\t\treturn;\n\t\t}\n\t\tif(\n\t\t\t(list[0] == list[1] + list[2]) ||\n\t\t\t(list[1] == list[2] + list[3])\n\t\t){\n\t\t\tSystem.Console.WriteLine(\"SEGMENT\");\n\t\t\treturn;\n\t\t}\n\t\t\n\t\tSystem.Console.WriteLine(\"IMPOSSIBLE\");\n\t\treturn;\t\t\n\t\t\n\t}\n}", "lang_cluster": "C#", "tags": ["brute force", "geometry"], "code_uid": "3e66852aa1d914f0684dbe3a27d75503", "src_uid": "8f5df9a41e6e100aa65b9fc1d26e447a", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Globalization;\nusing System.IO;\nusing System.Linq;\nusing System.Text;\nusing System.Numerics;\npublic class Codeforces\n{\n protected static TextReader reader;\n protected static TextWriter writer;\n static object Solve()\n {\n var n = ReadLong();\n var k = ReadLong();\n var l = 0L;\n var s = 0L;\n long i = 0;\n for (i = n - (n / k); i < n; i++)\n {\n s = i;\n l = i;\n while (l > 0)\n {\n l /= k;\n s += l;\n }\n if (s >= n)\n {\n break;\n }\n }\n Write(i);\n return null;\n }\n static void Main()\n {\n reader = new StreamReader(Console.OpenStandardInput(1024 * 10), System.Text.Encoding.ASCII, false, 1024 * 10);\n writer = new StreamWriter(Console.OpenStandardOutput(1024 * 10), System.Text.Encoding.ASCII, 1024 * 10);\n try\n {\n object result = Solve();\n if (result != null)\n writer.WriteLine(result);\n }\n catch (Exception ex)\n {\n Console.WriteLine(ex);\n throw;\n }\n reader.Close();\n writer.Close();\n }\n #region Read / Write\n\n private static Queue currentLineTokens = new Queue();\n\n private static string[] ReadAndSplitLine()\n {\n return reader.ReadLine().Split(new[] { ' ', '\\t' }, StringSplitOptions.RemoveEmptyEntries);\n }\n\n public static string ReadToken()\n {\n while (currentLineTokens.Count == 0)\n currentLineTokens = new Queue(ReadAndSplitLine());\n return currentLineTokens.Dequeue();\n }\n\n public static int ReadInt()\n {\n return int.Parse(ReadToken());\n }\n\n public static long ReadLong()\n {\n return long.Parse(ReadToken());\n }\n\n public static double ReadDouble()\n {\n return double.Parse(ReadToken(), CultureInfo.InvariantCulture);\n }\n\n public static int[] ReadIntArray()\n {\n return ReadAndSplitLine().Select(int.Parse).ToArray();\n }\n\n public static long[] ReadLongArray()\n {\n return ReadAndSplitLine().Select(long.Parse).ToArray();\n }\n\n public static double[] ReadDoubleArray()\n {\n return ReadAndSplitLine().Select(s => double.Parse(s, CultureInfo.InvariantCulture)).ToArray();\n }\n public static int[][] ReadIntMatrix(int numberOfRows)\n {\n int[][] matrix = new int[numberOfRows][];\n for (int i = 0; i < numberOfRows; i++)\n matrix[i] = ReadIntArray();\n return matrix;\n }\n public static int[][] ReadAndTransposeIntMatrix(int numberOfRows)\n {\n int[][] matrix = ReadIntMatrix(numberOfRows);\n int[][] ret = new int[matrix[0].Length][];\n for (int i = 0; i < ret.Length; i++)\n {\n ret[i] = new int[numberOfRows];\n for (int j = 0; j < numberOfRows; j++)\n ret[i][j] = matrix[j][i];\n }\n return ret;\n }\n\n public static string[] ReadLines(int quantity)\n {\n string[] lines = new string[quantity];\n for (int i = 0; i < quantity; i++)\n lines[i] = reader.ReadLine().Trim();\n return lines;\n }\n public static void WriteArray(IEnumerable array)\n {\n writer.WriteLine(string.Join(\" \", array));\n }\n\n public static void Write(params T[] array)\n {\n WriteArray(array);\n }\n\n public static void WriteLines(IEnumerable array)\n {\n foreach (var a in array)\n writer.WriteLine(a);\n }\n static int Next()\n {\n int c;\n int res = 0;\n do\n {\n c = reader.Read();\n if (c == -1)\n return res;\n } while (c != '-' && (c < '0' || c > '9'));\n int sign = 1;\n if (c == '-')\n {\n sign = -1;\n c = reader.Read();\n }\n res = c - '0';\n while (true)\n {\n c = reader.Read();\n if (c < '0' || c > '9')\n return res * sign;\n res *= 10;\n res += c - '0';\n }\n }\n #endregion\n}", "lang_cluster": "C#", "tags": ["implementation", "binary search"], "code_uid": "40cef8a0ec5bab18e9f891a55c586d6d", "src_uid": "41dfc86d341082dd96e089ac5433dc04", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nclass Test {\n static void Main() {\n string [] str = Console.ReadLine().Split();\n int n = int.Parse(str[0]);\n int k = int.Parse(str[1]);\n double v = n/2.0;\n double len = n/2.0;\n int min = n;\n while(len>0.001){\n int con = 0;\n int i = 0;\n int cv = (int)(v);\n while(true){\n int tmp = (int)(Math.Pow(k,i));\n if(cv/tmp>0){\n con += cv/tmp;\n }else{\n break;\n }\n i++;\n }\n if(con>=n){\n if(cv Convert.ToInt32(x)).ToArray();\n int n,k,l,c,d,p,nl,np;\n n = Aux[0];\n k = Aux[1];\n l = Aux[2];\n c = Aux[3];\n d = Aux[4];\n p = Aux[5];\n nl = Aux[6];\n np = Aux[7];\n int Aux1 = (k*l)/nl;\n int Aux2 = c * d;\n int Aux3 = p / np;\n Console.WriteLine(Math.Min(Math.Min(Aux1,Aux2),Aux3)/n);\n \n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "implementation"], "code_uid": "2f1fafee4aadc21641110d28047f5a91", "src_uid": "67410b7d36b9d2e6a97ca5c7cff317c1", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace _119A\n{\n\tclass Program\n\t{\n\t\tstatic void Main(string[] args)\n\t\t{\n\t\t\tint[] a = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);\n\t\t\tConsole.WriteLine(P(a[0], a[1], a[2]) ? 1 : 0);\n\t\t}\n\t\tstatic bool P(int a, int b, int c)\n\t\t{\n\t\t\twhile (true)\n\t\t\t{\n\t\t\t\tint gcd = GCD(a, c);\n\t\t\t\tc -= gcd;\n\t\t\t\tif (c == 0)\n\t\t\t\t{\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t\tgcd = GCD(b, c);\n\t\t\t\tc -= gcd;\n\t\t\t\tif (c == 0)\n\t\t\t\t{\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tstatic int GCD(int a, int b)\n\t\t{\n\t\t\tint t;\n\t\t\twhile (b != 0)\n\t\t\t{\n\t\t\t\tt = a % b;\n\t\t\t\ta = b;\n\t\t\t\tb = t;\n\t\t\t}\n\t\t\treturn a;\n\t\t}\n\t}\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "17a0c824f5fb31a09f23a0e7be7f6bfa", "src_uid": "0bd6fbb6b0a2e7e5f080a70553149ac2", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "namespace o\n{\n using System;\n\n class Program\n {\n public static int Nod(int a, int b)\n {\n int temp;\n if (b > a)\n {\n temp = b;\n b = a;\n a = temp;\n }\n while (true)\n {\n if (a % b == 0)\n {\n return b;\n }\n else\n {\n temp = b;\n b = a % b;\n a = temp;\n }\n }\n }\n\n static void Main(string[] args)\n {\n string d = Console.ReadLine();\n string[] q = d.Split(' ');\n int a = int.Parse(q[0]);\n int b = int.Parse(q[1]);\n int n = int.Parse(q[2]);\n int nod;\n while(true)\n {\n if (n == 0)\n {\n Console.WriteLine(\"1\");\n break;\n }\n nod = Nod(a, n);\n if (n >= nod)\n {\n n -= nod;\n }\n else\n {\n Console.WriteLine(\"1\");\n break;\n }\n\n if (n == 0)\n {\n Console.WriteLine(\"0\");\n break;\n }\n nod = Nod(b, n);\n if (n >= nod)\n {\n n -= nod;\n }\n else\n {\n Console.WriteLine(\"0\");\n break;\n }\n }\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "20cb4c7770a48e0564cf7ed2bb5f28db", "src_uid": "0bd6fbb6b0a2e7e5f080a70553149ac2", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\n\nnamespace codeforce146AAAAA\n{\n class Program\n {\n static void Main(string[] args)\n {\n int n = Convert.ToInt32(Console.ReadLine());\n var s = new StringBuilder(Console.ReadLine());\n\n bool t = true;\n int sum1 = 0;\n int sum2 = 0;\n \n for (int i = 0; i < s.Length; i++)\n if (s[i] != '7' && s[i] != '4') t = false;\n else\n {\n for (int j = 0; j < s.Length / 2; j++)\n sum1 += Convert.ToInt32(s[j].ToString());\n for (int j = s.Length / 2; j < s.Length; j++)\n sum2 += Convert.ToInt32(s[j].ToString());\n }\n\n if ((t == true) && (sum1 == sum2)) Console.WriteLine(\"YES\"); else Console.WriteLine(\"NO\");\n\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "c41593c7b8c850ec13bd19937eb67d93", "src_uid": "435b6d48f99d90caab828049a2c9e2a7", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace lucky\n{\n class Test\n {\n static void Main()\n {\n int l = Convert.ToInt16(Console.ReadLine());\n if(l%2!=0)\n {\n Console.WriteLine(\"NO\");\n return;\n }\n string number = Console.ReadLine();\n int n=number.Length;\n int left=0, right = 0;\n if(n%2==0 && n==l )\n {\n for(int i=0;i<=n/2-1;i++)\n {\n if(number[i]=='7' || number[i]=='4')\n {\n left = (Convert.ToInt16(number[i])-48) + left;\n }\n else\n {\n Console.WriteLine(\"NO\");\n return;\n }\n }\n for (int i = n/2; i < n;i++)\n {\n if (number[i] == '7' || number[i] == '4')\n {\n right = (Convert.ToInt16(number[i])-48) + right;\n }\n else\n {\n Console.WriteLine(\"NO\");\n return;\n }\n }\n if(left==right)\n {\n Console.WriteLine(\"YES\");\n }\n else\n {\n Console.WriteLine(\"NO\");\n return;\n }\n }\n }\n }\n}", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "2b280175eb933cd5c865cf055ce0d499", "src_uid": "435b6d48f99d90caab828049a2c9e2a7", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace ConsoleApplication2\n{\n class Program\n {\n static void Main(string[] args)\n {\n double s = 0,m=0,n=0,u=10000000;\n int x = int.Parse(Console.ReadLine());\n string[] arr = Console.ReadLine().Split();\n int a = int.Parse(arr[x-1]);\n int[] q = new int[x];\n for (int i = 0; i < x; i++)\n {\n q[i]=int.Parse(arr[i]);\n }\n if (x<=1)\n {\n if (q[x-1]==15)\n {\n Console.WriteLine(\"DOWN\");\n }\n else if (q[x - 1] == 0)\n {\n Console.WriteLine(\"UP\");\n\n }\n else\n {\n Console.WriteLine(-1);\n\n }\n }\n else\n {\n if (q[x-2] > q[x-1])\n {\n if (q[x - 1] == 0)\n {\n Console.WriteLine(\"UP\");\n\n }\n else\n {\n Console.WriteLine(\"DOWN\");\n\n }\n }\n else if (q[x-2] < q[x-1])\n {\n if (q[x-1]==15)\n {\n Console.WriteLine(\"DOWN\");\n\n }\n else\n {\n Console.WriteLine(\"UP\");\n\n }\n }\n\n }\n \n \n }\n }\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "62f6fd55f3f7d370ba4f164beafdf086", "src_uid": "8330d9fea8d50a79741507b878da0a75", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.IO;\nusing System.Collections.Generic;\nusing System.Globalization;\nusing System.Linq;\n\n\nclass Program\n{\n\n\n\n\n //////////////////////////////////////////////////\n void Solution()\n {\n var n = ri;\n var a = ria(n);\n\n if (a[n - 1] == 15)\n {\n wln(\"DOWN\");\n return;\n }\n\n if (a[n - 1] == 0)\n {\n wln(\"UP\");\n return;\n }\n\n if (n == 1)\n {\n wln(-1);\n return;\n }\n\n if (a[n - 1] > a[n - 2])\n {\n wln(\"UP\");\n return;\n }\n\n if (a[n - 1] < a[n - 2])\n {\n wln(\"DOWN\");\n return;\n }\n\n }\n //////////////////////////////////////////////////\n\n static void swap(ref T o1, ref T o2) { var o = o1; o1 = o2; o2 = o; }\n\n static void wln() { Console.WriteLine(); }\n static void wln(T o) { Console.WriteLine(o); }\n static void wsp(T o) { Console.Write(o + \" \"); }\n static void wrt(T o) { Console.Write(o); }\n\n static void wln(double o) { Console.WriteLine(string.Format(CultureInfo.InvariantCulture, \"{0:F12}\", o)); }\n static void wsp(double o) { Console.Write(string.Format(CultureInfo.InvariantCulture, \"{0:F12} \", o)); }\n static void wrt(double o) { Console.Write(string.Format(CultureInfo.InvariantCulture, \"{0:F12}\", o)); }\n\n static long gcd(long a, long b) { return (b != 0) ? gcd(b, a % b) : a; }\n static long lcm(long a, long b) { return a / gcd(a, b) * b; }\n\n int ri\n {\n get\n {\n _read(); while (_str[_ind] == ' ') ++_ind;\n int sign = 1; if (_str[_ind] == '-') { sign = -1; ++_ind; }\n int p = 0;\n while (_ind < _count && _str[_ind] != ' ') p = p * 10 + _str[_ind++] - '0';\n while (_ind < _count && _str[_ind] == ' ') ++_ind; return p * sign;\n }\n }\n long rl\n {\n get\n {\n _read(); while (_str[_ind] == ' ') ++_ind;\n int sign = 1; if (_str[_ind] == '-') { sign = -1; ++_ind; }\n long p = 0;\n while (_ind < _count && _str[_ind] != ' ') p = p * 10 + _str[_ind++] - '0';\n while (_ind < _count && _str[_ind] == ' ') ++_ind; return p * sign;\n }\n }\n double rd\n {\n get\n {\n _read(); while (_str[_ind] == ' ') ++_ind; int sign = 1; if (_str[_ind] == '-') { sign = -1; ++_ind; }\n long p = 0, q = 1; while (_ind < _count && _str[_ind] != ' ' && _str[_ind] != '.') p = p * 10 + _str[_ind++] - '0';\n if (_ind < _count && _str[_ind] == '.') { ++_ind; while (_ind < _count && _str[_ind] != ' ') { p = p * 10 + _str[_ind++] - '0'; q *= 10; } }\n while (_ind < _count && _str[_ind] == ' ') ++_ind; return (double)p / q * sign;\n }\n }\n string rs\n {\n get\n {\n _read(); while (_ind < _count && _str[_ind] == ' ') ++_ind;\n var tmp = _str.IndexOf(' ', _ind);\n if (tmp == -1) { _count = 0; _ind = 0; return _str.Substring(_ind); }\n var s = _str.Substring(_ind, tmp - _ind); _ind = tmp + 1;\n while (_ind < _count && _str[_ind] == ' ') ++_ind; return s;\n }\n }\n\n int[] ria(int n)\n {\n var res = new int[n];\n for (int k = 0; k < n;)\n {\n var s = Console.ReadLine(); var m = s.Length;\n for (int i = 0; i < m && k < n; ++i)\n {\n while (i < m && s[i] == ' ') ++i; if (i == m) break; int sign = 1; if (s[i] == '-') { sign = -1; ++i; }\n int p = 0; while (i < m && s[i] != ' ') p = p * 10 + s[i++] - '0'; res[k++] = p * sign;\n }\n }\n _count = 0; _ind = 0; return res;\n }\n long[] rla(int n)\n {\n var res = new long[n];\n for (int k = 0; k < n;)\n {\n var s = Console.ReadLine(); var m = s.Length;\n for (int i = 0; i < m && k < n; ++i)\n {\n while (i < m && s[i] == ' ') ++i; if (i == m) break; int sign = 1; if (s[i] == '-') { sign = -1; ++i; }\n long p = 0; while (i < m && s[i] != ' ') p = p * 10 + s[i++] - '0'; res[k++] = p * sign;\n }\n }\n _count = 0; _ind = 0; return res;\n }\n double[] rda(int n)\n {\n var res = new double[n];\n for (int k = 0; k < n;)\n {\n var s = Console.ReadLine(); var m = s.Length;\n for (int i = 0; i < m && k < n; ++i)\n {\n while (i < m && s[i] == ' ') ++i; if (i == m) break; int sign = 1; if (s[i] == '-') { sign = -1; ++i; }\n long p = 0, q = 1; while (i < m && s[i] != ' ' && s[i] != '.') p = p * 10 + s[i++] - '0';\n if (i < m && s[i] == '.') { ++i; while (i < m && s[i] != ' ') { p = p * 10 + s[i++] - '0'; q *= 10; } }\n res[k++] = (double)p / q * sign;\n }\n }\n _count = 0; _ind = 0; return res;\n }\n string[] rsa(int n) { var res = new string[n]; for (int k = 0; k < n; ++k) res[k] = Console.ReadLine(); _count = 0; _ind = 0; return res; }\n string _str = null; int _count = 0; int _ind = 0;\n void _read() { if (_ind == _count) { _str = Console.ReadLine(); _count = _str.Length; _ind = 0; } }\n static void Main() { new Program().Solution(); }\n}", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "de29d27adbf28ed7d86b9d1077b7248d", "src_uid": "8330d9fea8d50a79741507b878da0a75", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System.Linq;\nusing static System.Console;\n\nnamespace task\n{\n class Program\n {\n static void Main(string[] args)\n {\n \n var data = ReadLine().Split(' ').Select(long.Parse).ToArray();\n var n = data[0];\n var k = data[1];\n var res = n / k;\n WriteLine(res % 2 == 1? \"YES\" : \"NO\");\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "games"], "code_uid": "05f15edae17eb85d79fd939f102ec270", "src_uid": "05fd61dd0b1f50f154eec85d8cfaad50", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.IO;\n\nnamespace ProjectContest\n{\n class Test\n {\n static void Main()\n {\n var nk = Array.ConvertAll(Console.ReadLine().Split(), Convert.ToInt64);\n long n = nk[0], k = nk[1];\n if (n % k == 0)\n Console.WriteLine(n / k % 2 == 1 ? \"YES\" : \"NO\");\n else\n Console.WriteLine(n / k % 2 == 0 ? \"NO\" : \"YES\");\n }\n }\n}", "lang_cluster": "C#", "tags": ["math", "games"], "code_uid": "469fba4d3ac9534f0ddff994853434f8", "src_uid": "05fd61dd0b1f50f154eec85d8cfaad50", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.IO;\nusing System.Text;\n\nnamespace Email_address\n{\n internal class Program\n {\n private static readonly StreamReader reader = new StreamReader(Console.OpenStandardInput(1024*10), Encoding.ASCII, false, 1024*10);\n private static readonly StreamWriter writer = new StreamWriter(Console.OpenStandardOutput(1024*10), Encoding.ASCII, 1024*10);\n\n private static void Main(string[] args)\n {\n string s = reader.ReadLine();\n\n bool at = true;\n writer.Write(s[0]);\n for (int i = 1; i < s.Length; i++)\n {\n if (s[i] == 'd' && i + 3 < s.Length && s[i + 1] == 'o' && s[i + 2] == 't')\n {\n writer.Write('.');\n i += 2;\n }\n else if (at && s[i] == 'a' && i + 2 < s.Length && s[i + 1] == 't')\n {\n at = false;\n writer.Write('@');\n i++;\n }\n else\n writer.Write(s[i]);\n }\n\n\n writer.Flush();\n }\n }\n}", "lang_cluster": "C#", "tags": ["expression parsing", "implementation"], "code_uid": "caf888451ba1a06e25e97ac4d41dbafd", "src_uid": "a11c9679d8e2dca51be17d466202df6e", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Text;\n\nnamespace Task_41C\n{\n class Program\n {\n static void Main(string[] args)\n {\n \n StringBuilder builder = new StringBuilder(Console.ReadLine());\n bool alreadyMet = false;\n for (int i = 1; i < builder.Length - 2; i++)\n {\n if (!alreadyMet && builder[i] == 'a' && builder[i + 1] == 't' && i != builder.Length-2)\n {\n builder.Replace(\"at\", \"@\", i, 2);\n alreadyMet = true;\n }\n else if (i != builder.Length - 3 && builder.ToString().Substring(i, 3).Equals(\"dot\"))\n builder.Replace(\"dot\", \".\", i, 3);\n }\n\n Console.WriteLine(builder.ToString());\n\n }\n }\n}", "lang_cluster": "C#", "tags": ["expression parsing", "implementation"], "code_uid": "d180dd599bd5987c2d044df3f498bdbd", "src_uid": "a11c9679d8e2dca51be17d466202df6e", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace BuyShovel\n{\n class Program\n {\n static void Main(string[] args)\n {\n string[] line = Console.ReadLine().Split(' ');\n int k = Convert.ToInt32(line[0]);\n int r = Convert.ToInt32(line[1]);\n\n for (int i = 1; i <= 9; i++)\n {\n if ((i * k - r) % 10 == 0 || (i*k % 10==0))\n {\n Console.WriteLine(i);\n \n return;\n }\n }\n Console.WriteLine(10);\n \n }\n\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "math", "constructive algorithms", "implementation"], "code_uid": "69f0e1ad26bce7ee74b4de46d9bc70f2", "src_uid": "18cd1cd809df4744bb7bcd7cad94e2d3", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\n\nnamespace Code\n{\n class Program\n {\n static void Main(string[] args)\n {\n string[] input = Console.ReadLine().Split(' ');\n int price = int.Parse(input[0]);\n int nominal = int.Parse(input[1]);\n int i = 0;\n int total = price;\n while(total % 10 != 0 && (total - nominal) % 10 != 0)\n {\n i++;\n total = price * i;\n }\n if (i == 0)\n i++;\n Console.WriteLine(i);\n } \n }\n}", "lang_cluster": "C#", "tags": ["brute force", "math", "constructive algorithms", "implementation"], "code_uid": "04fe1f71367c1e6780b7f7e93c2b979d", "src_uid": "18cd1cd809df4744bb7bcd7cad94e2d3", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.IO;\nusing System.Linq;\n\nnamespace ConsoleApplication1\n{\n class Program\n {\n private static void MyMain()\n {\n var str1 = RLine();\n var str2 = RLine();\n\n var result = new char[str1.Length];\n for (int i = 0; i < str1.Length; i++)\n {\n result[i] = (str1[i] == '1' ^ str2[i] == '1') == true ? '1' : '0';\n }\n WLine(new string(result));\n }\n\n\n static void Main()\n {\n#if !HOME\n MyMain();\n#else\n var tmp = Console.In;\n Console.SetIn(new StreamReader(\"in.txt\"));\n while (Console.In.Peek() > 0)\n {\n MyMain();\n }\n Console.In.Close();\n Console.SetIn(tmp);\n Console.ReadKey();\n#endif\n }\n\n #region Utils\n static string RLine()\n {\n return Console.ReadLine();\n }\n\n static int RInt()\n {\n var str = Console.ReadLine();\n return Convert.ToInt32(str);\n }\n\n static int[] RInts()\n {\n return Array.ConvertAll(Console.ReadLine().Split(' '), s => Convert.ToInt32(s));\n }\n\n static void RInts(out int a, out int b)\n {\n var ints = RInts();\n a = ints[0];\n b = ints[1];\n }\n\n static void WLine(T s)\n {\n Console.WriteLine(s);\n }\n #endregion\n }\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "944dd020e7b4a5f9cc6f3ff6a8d9bbdb", "src_uid": "3714b7596a6b48ca5b7a346f60d90549", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\n\nnamespace ConsoleApp5\n{\n public class Program\n {\n static void Main()\n {\n var a = Console.ReadLine();\n var b = Console.ReadLine();\n var res = \"\";\n for (int i = 0; i < a.Length; i++)\n res += (a[i] == b[i] ? \"0\" : \"1\");\n\n Console.WriteLine(res);\n }\n }\n}", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "e2f0d8708ce110c1dad03ff17a45242d", "src_uid": "3714b7596a6b48ca5b7a346f60d90549", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\n\nnamespace ConsoleApplication1\n{\n internal class Program\n {\n private static void Main(string[] args)\n {\n var n = int.Parse(Console.ReadLine());\n\n var a = new int[n, 2];\n\n var k = 0;\n\n for (var i = 0; i < n; i++)\n {\n var t = Console.ReadLine().Split(' ');\n\n a[i, 0] = int.Parse(t[0]);\n a[i, 1] = int.Parse(t[1]);\n }\n\n for (var i = 0; i < n; i++)\n {\n for (var j = 0; j < n; j++)\n {\n if (a[i, 0] == a[j, 1])\n k++;\n }\n }\n\n Console.WriteLine(k);\n }\n }\n}", "lang_cluster": "C#", "tags": ["brute force"], "code_uid": "4db3e043f01c3ee03d5f355f1fbbfc31", "src_uid": "745f81dcb4f23254bf6602f9f389771b", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\n\nnamespace BulkaProga\n{\n class Program\n {\n static void Main(string[] args)\n {\n int count = int.Parse(Console.ReadLine());\n int res = 0;\n int[] home = new int[count];\n int[] uhome = new int[count];\n for (int i = 0; i < count; ++i)\n {\n string[] lines = Console.ReadLine().Split(' ');\n home[i] = int.Parse(lines[0]);\n uhome[i] = int.Parse(lines[1]);\n }\n for (int i = 0; i < count; ++i)\n {\n res += uhome.Count(x => x == home[i]);\n }\n Console.WriteLine(res);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force"], "code_uid": "bd20602d36292674032a0ce2f7a68246", "src_uid": "745f81dcb4f23254bf6602f9f389771b", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nclass Program\n{\n static void Main()\n {\n string s = Console.ReadLine()\n .Replace(\"5\", \"4\")\n .Replace(\"6\", \"3\")\n .Replace(\"7\", \"2\")\n .Replace(\"8\", \"1\");\n Console.WriteLine(s[0] + s.Substring(1).Replace(\"9\", \"0\"));\n }\n}", "lang_cluster": "C#", "tags": ["greedy", "implementation"], "code_uid": "acfb019f4730eace70458b0b40ff6ea0", "src_uid": "d5de5052b4e9bbdb5359ac6e05a18b61", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Globalization;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace innameofcocok\n{\n class Program\n {\n static char Invert(char c)\n {\n return ((c < '0' + '9' - c) ? c : (char)('0' + '9' - c));\n }\n static void Main(string[] args)\n {\n var s = Console.ReadLine();\n var ans = \"\";\n\n if (s[0] == '9')\n ans += '9';\n else\n {\n ans += Invert(s[0]);\n }\n\n for (var i = 1; i < s.Length; i++)\n ans += Invert(s[i]);\n\n Console.WriteLine(ans);\n }\n\n }\n}\n", "lang_cluster": "C#", "tags": ["greedy", "implementation"], "code_uid": "a6718fadd1298b1cb5744eaecb54693d", "src_uid": "d5de5052b4e9bbdb5359ac6e05a18b61", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections;\nusing System.Collections.Generic;\nclass Solution\n{\n static void Main(string[] args)\n {\n int len = Convert.ToInt32(Console.ReadLine());\n string s = Console.ReadLine();\n string output = string.Empty;\n output += s[0];\n for (int i = 1; i < s.Length; i++)\n {\n int val = i * (i + 1) / 2;\n if (len-1 >= val) output += s[val];\n else break;\n }\n Console.Write(output);\n }\n}", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "dd0efa0609035226866d7159e303098e", "src_uid": "08e8c0c37b223f6aae01d5609facdeaf", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using static System.Console;\nclass a\n{\n static void Main()\n {\n ReadLine();\n var a = ReadLine();\n var r = \"\";\n int t = -1;\n for (int i = 1; t < a.Length-1; i++) r += a[t+=i];\n WriteLine(r);\n }\n}", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "00b0b9e48078a14d2e33f1387e58db49", "src_uid": "08e8c0c37b223f6aae01d5609facdeaf", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace Domino_piling\n{\n class Program\n {\n static void Main(string[] args)\n {\n\n string line = Console.ReadLine();\n double m = int.Parse(line.Split(' ')[0]);\n double n= int.Parse(line.Split(' ')[1]);\n\n Console.WriteLine(Math.Floor(m*n/2));\n\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "greedy"], "code_uid": "af2378523b4d1a6be1be1c4276bdbbce", "src_uid": "e840e7bfe83764bee6186fcf92a1b5cd", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": ".NET Core C#", "source_code": "\ufeffusing System;\n\nnamespace CF_Domino_piling\n{\n class Program\n {\n static void Main(string[] args)\n {\n var line1 = Console.ReadLine().Split(' ');\n var m = int.Parse(line1[0]);\n var n = int.Parse(line1[1]);\n if (m % 2 == 0 || n % 2 == 0)\n {\n Console.WriteLine((m * n) / 2);\n } else\n {\n Console.WriteLine(((m * n) - 1) / 2);\n }\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "greedy"], "code_uid": "5e3aa9a36ce2d9693d3c8ac8cdaf9666", "src_uid": "e840e7bfe83764bee6186fcf92a1b5cd", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\n class Program\n { \n static void Main(string[] args)\n {\n char[] input = Console.In.ReadToEnd().Split(new char[] { '\\n', '\\r'}, StringSplitOptions.RemoveEmptyEntries)[1].ToCharArray();\n Stack stack = new Stack();\n stack.Push(input.Length);\n {\n int lim = (int)Math.Sqrt(input.Length);\n for (int i = 2; i <= lim; ++i)\n {\n if (input.Length % i == 0)\n {\n stack.Push(input.Length / i);\n char temp;\n for (int j = 0, c = i-1; j < c;)\n {\n temp = input[j];\n input[j++] = input[c];\n input[c--] = temp;\n }\n }\n }\n if (stack.Peek() == lim) stack.Pop();\n {\n char temp;\n while (stack.Count > 0)\n {\n for (int j = 0, c = stack.Pop()-1; j < c;)\n {\n temp = input[j];\n input[j++] = input[c];\n input[c--] = temp;\n }\n }\n }\n }\n Console.WriteLine(new string(input));\n }\n }", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "30075e614278179ddd5baf3fe4a1dcf8", "src_uid": "1b0b2ee44c63cb0634cb63f2ad65cdd3", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\n\nnamespace Task\n{\n class Program\n {\n public static bool NextPermutation(List perm)\n {\n for (int i = perm.Count - 2; i >= 0; i--)\n {\n if (perm[i] < perm[i + 1])\n {\n int min = i + 1;\n for (int j = min; j < perm.Count; j++)\n if (perm[j] > perm[i] && perm[j] < perm[min])\n min = j;\n\n int tmp = perm[i];\n perm[i] = perm[min];\n perm[min] = tmp;\n perm.Reverse(i + 1, perm.Count - i - 1);\n return true;\n }\n }\n\n return false;\n }\n\n static void Main(string[] args)\n {\n int n = int.Parse(Console.ReadLine());\n\n //var inpMas = Console.ReadLine().Split(' ').Select(item => char.Parse(item)).ToList();\n var str = Console.ReadLine().Trim().ToCharArray().ToList();\n //int n = inpMas[0];\n //int k = inpMas[1];\n //inpMas = Console.ReadLine().Split(' ').Select(item => int.Parse(item)).ToList();\n\n for (int div = 2; div <= n; div++)\n {\n if (n % div == 0)\n str.Reverse(0, div);\n }\n\n Console.WriteLine(new string(str.ToArray()));\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "354c0c12ea326f920925b4437f170e27", "src_uid": "1b0b2ee44c63cb0634cb63f2ad65cdd3", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace codingGuru\n{\n class Program\n {\n static void Main(string[] args)\n {\n ProblemB();\n }\n static private void ProblemA()\n {\n Console.ReadLine();\n string str = Console.ReadLine();\n int anton = (from char c in str where c == 'A' select 1).Sum();\n int danik = str.Length - anton; \n //print answer \n if(anton > danik) Console.WriteLine(\"Anton\");\n else if(danik > anton)Console.WriteLine(\"Danik\");\n else Console.WriteLine(\"Friendship\");\n \n }\n static private void ProblemB()\n {\n int[] nums = (from string s in Console.ReadLine().Split(' ') select Convert.ToInt32(s)).ToArray();\n int large256 = new int[] { nums[0], nums[2], nums[3] }.Min();\n int small32 = Math.Min(nums[1], nums[0] - large256);\n Console.WriteLine(256*large256 + 32*small32);\n }\n \n \n }\n}\n", "lang_cluster": "C#", "tags": ["math", "greedy", "implementation", "brute force"], "code_uid": "8e7c1593b0baa60a7616f59644841de4", "src_uid": "082b31cc156a7ba1e0a982f07ecc207e", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\n\npublic class Program\n{\n\tpublic static void Main()\n\t{\n\t\tint[] k = Console.ReadLine().Split().Select(int.Parse).ToArray();\n\t\tint C256 = new[] { k[0], k[2], k[3] }.Min();\n\t\tk[0] -= C256;\n\t\tint C32 = Math.Min(k[0], k[1]);\n\t\tvar X = 256 * C256 + 32 * C32;\n\t\tk[0] += C256;\t// reset\n\t\tC32 = Math.Min(k[0], k[1]);\n\t\tk[0] -= C32;\n\t\tC256 = new[] { k[0], k[2], k[3] }.Min();\n\t\tvar Y = 256 * C256 + 32 * C32;\n\t\tConsole.WriteLine(Math.Max(X, Y));\n\t}\n}", "lang_cluster": "C#", "tags": ["math", "greedy", "implementation", "brute force"], "code_uid": "b52cd9e9f5a131cf21b1a46fa5f9d18f", "src_uid": "082b31cc156a7ba1e0a982f07ecc207e", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\n\nclass Program {\n\n\tpublic static void Main (string [] args)\n\t{\n\t\tint n = Convert.ToInt32 (Console.ReadLine ());\n\t\tint[][] a = new int[n][];\n\t\tchar[] delimiters = {' '};\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tstring[] row = Console.ReadLine ().Split(delimiters, StringSplitOptions.RemoveEmptyEntries);\n\t\t\ta[i] = new int[n];\n\t\t\tfor (int j = 0; j < n; j++) {\n\t\t\t\ta[i][j] = Convert.ToInt32 (row[j]);\n\t\t\t}\n\t\t}\n\t\t\n\t\tint sum = 0;\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tsum += a[i][i];\n\t\t}\t\t\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tsum += a[i][n - i - 1];\n\t\t}\n\t\tint middle = n / 2;\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tsum += a[i][middle];\n\t\t}\n\t\tfor (int j = 0; j < n; j++) {\n\t\t\tsum += a[middle][j];\n\t\t}\n\t\tsum -= 3 * a[middle][middle];\n\t\tConsole.WriteLine (\"{0}\", sum);\n\t}\n}", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "56abc005a7d6e7d4a949529cfbc2eed0", "src_uid": "5ebfad36e56d30c58945c5800139b880", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\n\nnamespace Codeforces._20120421\n{\n public class A\n {\n public static void Main()\n {\n int n = int.Parse(Console.ReadLine());\n\n List> m = new List>();\n\n for (int i = 0; i < n; ++i)\n m.Add(Console.ReadLine().Split(' ').Select(t => int.Parse(t)).ToList());\n\n int ret = 0;\n\n for (int i = 0; i < n; ++i)\n for (int j = 0; j < n; ++j)\n if (i == j || i == n / 2 || j == n / 2 || ((i + j) == n - 1))\n ret += m[i][j];\n\n Console.WriteLine(ret);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "b7253b7471316799c40bf8c63f906543", "src_uid": "5ebfad36e56d30c58945c5800139b880", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\n\nnamespace csharp\n{\n class Program\n {\n static void Main(string[] args)\n {\n var line = Console.ReadLine().Split('+').Select(int.Parse).ToList();\n\n\n line.Sort();\n\n for (int i = 0; i < line.Count; i++)\n {\n Console.Write(line[i]);\n\n if(line.Count != i + 1){\n Console.Write('+');\n }\n }\n \n \n }\n }\n}\n", "lang_cluster": "C#", "tags": ["sortings", "strings", "implementation", "greedy"], "code_uid": "23b74b7b2f85fb2c7abb01006a139930", "src_uid": "76c7312733ef9d8278521cf09d3ccbc8", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\n\nnamespace ConsoleApplication14\n{\n class Program\n {\n static void Main(string[] args)\n {\n int[] numbers = Console.ReadLine().Split('+').Select(int.Parse).ToArray();\n\n for (int i = 0; i < numbers.Length; i++)\n {\n int max = i;\n for (int j = i; j< numbers.Length; j++)\n {\n if (numbers[j] < numbers[i])\n {\n max = j;\n\n int temp = numbers[j];\n numbers[j] = numbers[i];\n numbers[i] = temp;\n }\n }\n }\n\n for (int i = 0; i < numbers.Length; i++)\n {\n if (i != numbers.Length - 1)\n Console.Write(numbers[i] + \"+\");\n else\n Console.WriteLine(numbers[i]);\n }\n\n Console.ReadLine();\n\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["sortings", "strings", "implementation", "greedy"], "code_uid": "9354d0b8d0714b42bdd09a451ff1287d", "src_uid": "76c7312733ef9d8278521cf09d3ccbc8", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\n//using System.Collections.Generic;\n//using System.Linq;\n//using System.Text;\n//using System.Threading.Tasks;\n\nnamespace ConsoleApp_B1\n{\n class Program\n {\n static void Main(string[] args)\n {\n int b = int.Parse(Console.ReadLine()); //\u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043c\u0430\u043b\u044c\u0447\u0438\u043a\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u0440\u0438\u0435\u0445\u0430\u043b\u0438 \u043d\u0430 \u043e\u043b\u0438\u043c\u043f\u0438\u0430\u0434\u0443\n int g = int.Parse(Console.ReadLine()); //\u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0434\u0435\u0432\u043e\u0447\u0435\u043a, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u0440\u0438\u0435\u0445\u0430\u043b\u0438 \u043d\u0430 \u043e\u043b\u0438\u043c\u043f\u0438\u0430\u0434\u0443\n int n = int.Parse(Console.ReadLine()); //\u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0443\u0447\u0430\u0441\u0442\u043d\u0438\u043a\u043e\u0432 \u0432 \u0442\u0443\u0440\u043d\u0438\u0440\u0435\n int b_max; // \u043c\u0430\u043a\u0441. \u043a\u043e\u043b-\u0432\u043e \u043c\u0430\u043b\u044c\u0447\u0438\u043a\u043e\u0432 - \u0443\u0447\u0430\u0441\u0442\u043d\u0438\u043a\u043e\u0432 \u0442\u0443\u0440\u043d\u0438\u0440\u0430\n int g_max; // \u043c\u0430\u043a\u0441. \u043a\u043e\u043b-\u0432\u043e \u0434\u0435\u0432\u043e\u0447\u0435\u043a - \u0443\u0447\u0430\u0441\u0442\u043d\u0438\u0446 \u0442\u0443\u0440\u043d\u0438\u0440\u0430\n int count_min; //\u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043a\u043e\u043b\u043e\u0434\n\n //timestamp\n //Console.WriteLine(\"{0}\", DateTime.UtcNow.ToString(\"yyyy-MM-dd HH:mm:ss.fff\"));\n\n b_max = Math.Min(b, n); // \u043c\u0430\u043a\u0441. \u043a\u043e\u043b-\u0432\u043e \u043c\u0430\u043b\u044c\u0447\u0438\u043a\u043e\u0432 - \u0443\u0447\u0430\u0441\u0442\u043d\u0438\u043a\u043e\u0432 \u0442\u0443\u0440\u043d\u0438\u0440\u0430 \n g_max = Math.Min(g, n); // \u043c\u0430\u043a\u0441. \u043a\u043e\u043b-\u0432\u043e \u0434\u0435\u0432\u043e\u0447\u0435\u043a - \u0443\u0447\u0430\u0441\u0442\u043d\u0438\u0446 \u0442\u0443\u0440\u043d\u0438\u0440\u0430\n count_min = b_max + g_max - n + 1;\n\n Console.WriteLine(\"{0}\", count_min);\n\n //timestamp\n //Console.WriteLine(\"{0}\", DateTime.UtcNow.ToString(\"yyyy-MM-dd HH:mm:ss.fff\"));\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "math"], "code_uid": "2e8a5f20c0298ea12a018e83ad052a87", "src_uid": "9266a69e767df299569986151852e7b1", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace ConsoleApplication2\n{\n class Program\n {\n static void Main(string[] args)\n {\n Int64 b, g, n, res;\n res = 0;\n // var line = Console.ReadLine().Split(new[] { ' ' });\n // n = Convert.ToInt32(line[0]);\n // e = Convert.ToInt32(line[1]);\n // d = Convert.ToInt32(line[2]);\n b = Int64.Parse(Console.ReadLine());\n g = Int64.Parse(Console.ReadLine());\n n = Int64.Parse(Console.ReadLine());\n if (n < b && n < g)\n res = n + 1;\n else\n if (n > b && n > g && ((b+g) != n))\n {\n Int64 x1 = Math.Max(b, g);\n Int64 x2 = Math.Min(b, g);\n res = n - x2;\n res = x1 - res + 1;\n }\n else\n if ((b + g) != n && n <= b || n <= g)\n {\n Int64 minx = Math.Min(b, g);\n res = minx + 1;\n }\n else\n res = 1;\n Console.WriteLine(res);\n }\n }\n}", "lang_cluster": "C#", "tags": ["brute force", "math"], "code_uid": "a8e23427456ffaf16054e5c01a120725", "src_uid": "9266a69e767df299569986151852e7b1", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace ConsoleApplication1\n{\n class Program\n {\n static void Main(string[] args)\n {\n string s;\n Console.ReadLine() ;\n s = Console.ReadLine();\n string[] st;\n string otv = null;\n int rez = 0,dl = 0;\n st = s.Split('W');\n for (int i = 0; i < st.Length; i++)\n {\n for (int j = 0; j <= st[i].Length - 1; j++)\n {\n rez++;\n }\n if (rez != 0)\n {\n\n otv = otv +Convert.ToString(rez);\n if(i != st.Length-1)\n {\n otv = otv + ' ';\n }\n rez = 0;\n dl = st.Length;\n }\n \n\n }\n int osh = 0;\n for (int i = 0; i < st.Length-1; i++)\n {\n if(st[i] == \"\")\n {\n osh++;\n }\n\n }\n if(dl == 0)\n {\n Console.WriteLine(dl);\n }\n else\n {\n if (s[s.Length - 1] == 'B')\n {\n\n Console.WriteLine(dl-osh);\n }\n else\n {\n\n Console.WriteLine(dl - 1-osh);\n\n }\n }\n\n Console.WriteLine(otv);\n Console.ReadLine();\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "9c324dc9aa98305b1d74a28005f74f32", "src_uid": "e4b3a2707ba080b93a152f4e6e983973", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\n\nnamespace CodeForces\n{\n class Program\n {\n public static void Main()\n {\n var n = int.Parse(Console.ReadLine());\n var codes = new List();\n var count = 0;\n\n for (int i = 0; i < n; i++)\n {\n switch((char)Console.Read())\n {\n case 'B':\n count++;\n break;\n\n case 'W':\n if (count != 0)\n {\n codes.Add(count);\n count = 0;\n }\n break;\n }\n }\n\n if (count != 0)\n {\n codes.Add(count);\n count = 0;\n }\n\n if (codes.Any())\n {\n Console.WriteLine(codes.Count);\n Console.WriteLine(string.Join(\" \", codes));\n }\n else\n {\n Console.Write(0);\n }\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "526f9b4deae46a6321ee7a20bf01c766", "src_uid": "e4b3a2707ba080b93a152f4e6e983973", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Globalization;\nusing System.IO;\nusing System.Linq;\nusing System.Text;\n\nnamespace Codeforces\n{\n public class Solution\n {\n public void Execute()\n {\n var s = ReadLine();\n for (var i = 0; i < s.Length; ++i)\n {\n if(!Check(s[i]))\n {\n if(s[i] != 'n')\n {\n if(i + 1 == s.Length || !Check(s[i+1]))\n {\n WriteLine(\"NO\");\n return;\n }\n }\n }\n }\n WriteLine(\"YES\");\n }\n\n private bool Check(char c)\n {\n return c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u';\n }\n\n private StreamReader reader;\n private StreamWriter writer;\n\n public Solution(StreamReader reader, StreamWriter writer)\n {\n this.reader = reader;\n this.writer = writer;\n }\n\n private string ReadLine() => reader.ReadLine();\n private int ReadInt() => int.Parse(ReadLine());\n private long ReadLong() => long.Parse(ReadLine());\n private double ReadDouble() => double.Parse(ReadLine());\n private string[] Split(char c = ' ') => ReadLine().Split(c);\n private int[] ReadInts(char c = ' ') => Split(c).Select(int.Parse).ToArray();\n private long[] ReadLongs(char c = ' ') => Split(c).Select(long.Parse).ToArray();\n private double[] ReadDoubles(char c = ' ') => Split(c).Select(double.Parse).ToArray();\n\n private void Write(string s) => writer.Write(s);\n private void WriteLine(string s) => writer.WriteLine(s);\n }\n\n public class Program\n {\n public static void Main(string[] args)\n {\n CultureInfo.DefaultThreadCurrentCulture = CultureInfo.InvariantCulture;\n StreamReader reader = null;\n StreamWriter writer = null;\n MemoryStream output = null;\n\n var (test, name) = TestMode(args);\n \n if(test)\n {\n reader = new StreamReader($\"in{name}.txt\");\n output = new MemoryStream();\n writer = new StreamWriter(output);\n }\n else\n {\n reader = new StreamReader(Console.OpenStandardInput());\n writer = new StreamWriter(Console.OpenStandardOutput());\n }\n new Solution(reader, writer).Execute();\n writer.Flush();\n if(test)\n {\n var expect = new StreamReader($\"out{name}.txt\").ReadToEnd();\n var actual = Encoding.UTF8.GetString(output.ToArray());\n Console.WriteLine(actual);\n Console.WriteLine(actual.TrimEnd() == expect.TrimEnd() ? $\"Test {name} passed.\" : $\"Test {name} failed.\");\n }\n }\n\n private static (bool, string) TestMode(string[] args)\n {\n if(args.Length > 1 && args.First() == \"test\")\n {\n return (true, args[1]);\n }\n return (false, null);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["strings", "implementation"], "code_uid": "a8ba3739a1885708a9b9088b3f5e948f", "src_uid": "a83144ba7d4906b7692456f27b0ef7d4", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.IO;\nusing System.Collections.Generic;\nusing System.Globalization;\nusing System.Linq;\nusing System.Text;\n\nclass Program\n{\n bool check(char ch)\n {\n return ch == 'a' || ch == 'o' || ch == 'u' || ch == 'i' || ch == 'e';\n }\n\n //////////////////////////////////////////////////\n void Solution()\n {\n var s = rs;\n var n = s.Length;\n bool res = true;\n for (int i = 1; i < n; i++)\n {\n if (!check(s[i - 1]))\n {\n if (check(s[i]))\n {\n }\n else\n {\n if (s[i - 1] == 'n')\n {\n }\n else\n {\n wln(\"NO\");\n return;\n }\n }\n }\n else\n {\n }\n }\n if (check(s[n - 1]) || s[n - 1] == 'n')\n {\n wln(\"YES\");\n }\n else\n wln(\"NO\");\n }\n //////////////////////////////////////////////////\n\n void swap(ref T o1, ref T o2) { var o = o1; o1 = o2; o2 = o; }\n long gcd(long a, long b) => (b != 0) ? gcd(b, a % b) : a;\n long lcm(long a, long b) => a / gcd(a, b) * b;\n\n StringBuilder _sb = new StringBuilder();\n void wln() { _sb.AppendLine(); }\n void wln(T o) { _sb.AppendLine(o.ToString()); }\n void wsp(T o) { _sb.Append(o).Append(\" \"); }\n void wrt(T o) { _sb.Append(o); }\n\n void wln(double o) { _sb.AppendLine(string.Format(CultureInfo.InvariantCulture, \"{0:F12}\", o)); }\n void wsp(double o) { _sb.Append(string.Format(CultureInfo.InvariantCulture, \"{0:F12} \", o)); }\n void wrt(double o) { _sb.Append(string.Format(CultureInfo.InvariantCulture, \"{0:F12}\", o)); }\n\n int ri\n {\n get\n {\n _read(); while (_str[_ind] == ' ') ++_ind;\n int sign = 1; if (_str[_ind] == '-') { sign = -1; ++_ind; }\n int p = 0;\n while (_ind < _count && _str[_ind] != ' ') p = p * 10 + _str[_ind++] - '0';\n while (_ind < _count && _str[_ind] == ' ') ++_ind; return p * sign;\n }\n }\n long rl\n {\n get\n {\n _read(); while (_str[_ind] == ' ') ++_ind;\n int sign = 1; if (_str[_ind] == '-') { sign = -1; ++_ind; }\n long p = 0;\n while (_ind < _count && _str[_ind] != ' ') p = p * 10 + _str[_ind++] - '0';\n while (_ind < _count && _str[_ind] == ' ') ++_ind; return p * sign;\n }\n }\n double rd\n {\n get\n {\n _read(); while (_str[_ind] == ' ') ++_ind; int sign = 1; if (_str[_ind] == '-') { sign = -1; ++_ind; }\n long p = 0, q = 1; while (_ind < _count && _str[_ind] != ' ' && _str[_ind] != '.') p = p * 10 + _str[_ind++] - '0';\n if (_ind < _count && _str[_ind] == '.') { ++_ind; while (_ind < _count && _str[_ind] != ' ') { p = p * 10 + _str[_ind++] - '0'; q *= 10; } }\n while (_ind < _count && _str[_ind] == ' ') ++_ind; return (double)p / q * sign;\n }\n }\n string rs\n {\n get\n {\n _read(); while (_ind < _count && _str[_ind] == ' ') ++_ind;\n var tmp = _str.IndexOf(' ', _ind);\n if (tmp == -1) { var res = _str.Substring(_ind); _count = 0; _ind = 0; return res; }\n var s = _str.Substring(_ind, tmp - _ind); _ind = tmp + 1;\n while (_ind < _count && _str[_ind] == ' ') ++_ind; return s;\n }\n }\n\n int[] ria(int n)\n {\n var res = new int[n];\n for (int k = 0; k < n;)\n {\n var s = Console.ReadLine(); var m = s.Length;\n for (int i = 0; i < m && k < n; ++i)\n {\n while (i < m && s[i] == ' ') ++i; if (i == m) break; int sign = 1; if (s[i] == '-') { sign = -1; ++i; }\n int p = 0; while (i < m && s[i] != ' ') p = p * 10 + s[i++] - '0'; res[k++] = p * sign;\n }\n }\n _count = 0; _ind = 0; return res;\n }\n long[] rla(int n)\n {\n var res = new long[n];\n for (int k = 0; k < n;)\n {\n var s = Console.ReadLine(); var m = s.Length;\n for (int i = 0; i < m && k < n; ++i)\n {\n while (i < m && s[i] == ' ') ++i; if (i == m) break; int sign = 1; if (s[i] == '-') { sign = -1; ++i; }\n long p = 0; while (i < m && s[i] != ' ') p = p * 10 + s[i++] - '0'; res[k++] = p * sign;\n }\n }\n _count = 0; _ind = 0; return res;\n }\n double[] rda(int n)\n {\n var res = new double[n];\n for (int k = 0; k < n;)\n {\n var s = Console.ReadLine(); var m = s.Length;\n for (int i = 0; i < m && k < n; ++i)\n {\n while (i < m && s[i] == ' ') ++i; if (i == m) break; int sign = 1; if (s[i] == '-') { sign = -1; ++i; }\n long p = 0, q = 1; while (i < m && s[i] != ' ' && s[i] != '.') p = p * 10 + s[i++] - '0';\n if (i < m && s[i] == '.') { ++i; while (i < m && s[i] != ' ') { p = p * 10 + s[i++] - '0'; q *= 10; } }\n res[k++] = (double)p / q * sign;\n }\n }\n _count = 0; _ind = 0; return res;\n }\n string[] rsa(int n) { var res = new string[n]; for (int k = 0; k < n; ++k) res[k] = Console.ReadLine(); _count = 0; _ind = 0; return res; }\n string _str = null; int _count = 0; int _ind = 0;\n void _read() { if (_ind == _count) { _str = Console.ReadLine(); _count = _str.Length; _ind = 0; } }\n static void Main(string[] args) { new Program().Main(); }\n void Main()\n {\n //Console.SetIn(new StreamReader(\"input.txt\"));\n //Console.SetOut(new StreamWriter(\"output.txt\"));\n Solution();\n Console.Write(_sb);\n //Console.In.Close();\n //Console.Out.Close();\n }\n}", "lang_cluster": "C#", "tags": ["strings", "implementation"], "code_uid": "853ef7a312d315ff3c4b5db0ad88d831", "src_uid": "a83144ba7d4906b7692456f27b0ef7d4", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\n\nnamespace A_Grasshopper_and_string\n{\n class Program\n {\n static void Main(string[] args)\n {\n string input = Console.ReadLine();\n int currentStep = 1;\n int maxStep = 1;\n\n foreach (char c in input)\n {\n switch (c)\n {\n case 'A': currentStep = 1; break;\n case 'O': currentStep = 1; break;\n case 'U': currentStep = 1; break;\n case 'I': currentStep = 1; break;\n case 'E': currentStep = 1; break;\n case 'Y': currentStep = 1; break;\n default: currentStep++; maxStep = Math.Max(maxStep, currentStep); break;\n }\n } \n Console.WriteLine(maxStep);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "71a8d951c0872e041e848eb3c259820f", "src_uid": "1fc7e939cdeb015fe31f3cf1c0982fee", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.IO;\n\nnamespace ConsoleApplication7\n{\n class Program\n {\n static bool isVoel(char x)\n {\n if (x == 'A')\n {\n return true;\n }\n if (x == 'E')\n {\n return true;\n }\n if (x == 'I')\n {\n return true;\n }\n if (x == 'O')\n {\n return true;\n }\n if (x == 'U')\n {\n return true;\n }\n if (x == 'Y')\n {\n return true;\n }\n return false;\n }\n\n static void Main(string[] args)\n {\n\n string a = Console.ReadLine();\n\n int res = 0, x = 0;\n\n for (int i = 0; i < a.Length; i++)\n {\n if (isVoel(a[i]))\n {\n res = Math.Max(res, x + 1);\n x = 0;\n }\n else\n {\n x++;\n }\n }\n\n res = Math.Max(res, x + 1);\n\n Console.WriteLine(res);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "91d5ae32cbf535740c2fe7eb374710c2", "src_uid": "1fc7e939cdeb015fe31f3cf1c0982fee", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nnamespace MainProgram \n{\n\n class Program\n {\n static void Main(string[] args)\n {\n var yr = int.Parse(Console.ReadLine());\n \n var c = FindYear(yr);\n Console.WriteLine(c);\n } \n \n static int FindYear(int startYear)\n {\n var year = startYear + 1;\n while(true)\n {\n var a1 = year / 1000;\n var a2 = year / 100 % 10;\n var a3 = year / 10 % 10;\n var a4 = year % 10;\n year++;\n \n if(!(a1 == a2 || a1 == a3 || a1 == a4 || a2 == a3 || a2 == a4|| a3 == a4))\n {\n return a1 * 1000 + a2 * 100 + a3 * 10 + a4;\n }\n \n }\n return startYear;\n }\n }\n}", "lang_cluster": "C#", "tags": ["brute force"], "code_uid": "8610513fdebdc9bcdc2e89ce5ab33885", "src_uid": "d62dabfbec52675b7ed7b582ad133acd", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace Competitive\n{\n class Program\n {\n\n\n static void Main(string[] args)\n {\n var n = int.Parse(Console.ReadLine()) + 1;\n\n while (n.ToString().Distinct().Count() != 4)\n {\n n++;\n }\n\n Console.WriteLine(n);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force"], "code_uid": "1f4c8e4402694cbd1590d9d6c36149d7", "src_uid": "d62dabfbec52675b7ed7b582ad133acd", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nnamespace ConsoleApplication2\n{\n class Program\n {\n \n static void Main(string[] args)\n {\n int n=Convert.ToInt32(Console.ReadLine());\n long ans = (1 + n) * n / 2;\n int kol = 1;\n for (int i = n-2; i >0; i--)\n {\n ans += kol * i;\n kol++;\n }\n Console.WriteLine(ans);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "implementation"], "code_uid": "51f0e9d7961c15b4b91e7656ea6362f7", "src_uid": "6df251ac8bf27427a24bc23d64cb9884", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeff\ufeff\ufeff\ufeff\ufeffusing System;\n\ufeff\ufeff\ufeffusing System.Collections.Generic;\n\ufeff\ufeff\ufeff\ufeffusing System.Globalization;\n\ufeff\ufeff\ufeff\ufeffusing System.IO;\n\ufeff\ufeff\ufeffusing System.Linq;\n\ufeff\ufeff\ufeffusing System.Text;\n\ufeff\ufeff\ufeff\ufeffusing System.Threading;\n\nnamespace CF {\n class Program {\n\n static void Main(string[] args) {\n\n Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;\n\n#if DEBUG\n TextReader reader = new StreamReader(\"../../input.txt\");\n TextWriter writer = Console.Out;\n#else\n\t\t\tTextReader reader = Console.In;\n TextWriter writer = Console.Out;\n#endif\n\n var n = reader.Read();\n\n long count = 0;\n int attempCost = 1;\n int knownLength = n;\n\n while (n > 1) {\n count += attempCost * (n - 1);\n attempCost++;\n n--;\n }\n count += knownLength;\n \n\n Console.WriteLine(count);\n \n \n\n#if DEBUG\n Console.ReadKey();\n#endif\n }\n\n \n\n }\n\n\n #region template\n class Pair {\n public Pair(T1 first, T2 second) {\n First = first;\n Second = second;\n }\n public T1 First { get; set; }\n public T2 Second { get; set; }\n public override string ToString() {\n return \"{\" + First + \" \" + Second + \"}\";\n }\n \n }\n\n static class ReaderExtensions {\n\n public static string ReadToken(this TextReader reader) {\n int val;\n var builder = new StringBuilder();\n while (true) {\n val = reader.Read();\n if (val == ' ' || val == -1) {\n if (builder.Length == 0) continue;\n break;\n }\n if (val == 13) {\n reader.Read();\n if (builder.Length == 0) continue;\n break;\n }\n builder.Append((char)val);\n }\n return builder.ToString();\n }\n\n public static T Read(this TextReader reader) {\n return (T)Convert.ChangeType(reader.ReadToken(), typeof(T));\n }\n\n public static T[] ReadArr(this TextReader reader) {\n return reader.ReadLine()\n .Split(' ').Select(str =>\n (T)Convert.ChangeType(str, typeof(T))\n ).ToArray();\n }\n\n }\n\n static class LinqExtensions {\n /// Value / Index\n public static IEnumerable> SelectIndexes(this IEnumerable collection) {\n return collection.Select((v, i) => new Pair(v, i));\n }\n public static IEnumerable SelectValues(this IEnumerable> collection) {\n return collection.Select(p => p.First);\n }\n public static void AddRepeatedRange(this IDictionary> dictionary, \n Func> generator, IEnumerable> sourceCollection ) {\n foreach (var pair in sourceCollection) {\n if (!dictionary.ContainsKey(pair.First)) {\n dictionary[pair.First] = generator();\n }\n dictionary[pair.First].Add(pair.Second);\n }\n }\n public static T Second(this IEnumerable collection) {\n return collection.Skip(1).First();\n }\n }\n\n static class OutputExtensions {\n public static void WriteBySeparatorLine(this IEnumerable list, string sep = \" \") {\n foreach (var v in list) {\n Console.Write(v);\n Console.Write(sep);\n }\n Console.WriteLine();\n }\n }\n\n #endregion \n}", "lang_cluster": "C#", "tags": ["math", "implementation"], "code_uid": "782c087bfaf3d8835d1b9cb4cd3acdf5", "src_uid": "6df251ac8bf27427a24bc23d64cb9884", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.IO;\nusing System.Threading;\nusing System.Runtime.CompilerServices;\nusing System.Text;\nusing System.Diagnostics;\nusing System.Numerics;\nusing static System.Console;\nusing static System.Convert;\nusing static System.Math;\nusing static Template;\nusing Pi = Pair;\n\nclass Solver\n{\n public Scanner sc;\n public void Solve()\n {\n long N, M;int A, B;\n sc.Make(out N, out M, out A, out B);\n Console.WriteLine(Min(N%M*B,(M-N%M)%M*A));\n }\n}\n\n#region Template\npublic static class Template\n{\n static void Main(string[] args)\n {\n Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });\n var sol = new Solver() { sc = new Scanner() };\n //var th = new Thread(sol.Solve, 1 << 26);th.Start();th.Join();\n sol.Solve();\n Console.Out.Flush();\n }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static bool chmin(ref T a, T b) where T : IComparable { if (a.CompareTo(b) > 0) { a = b; return true; } return false; }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static bool chmax(ref T a, T b) where T : IComparable { if (a.CompareTo(b) < 0) { a = b; return true; } return false; }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static void swap(ref T a, ref T b) { var t = b; b = a; a = t; }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static void swap(this IList A, int i, int j) { var t = A[i]; A[i] = A[j]; A[j] = t; }\n public static T[] Create(int n, Func f) { var rt = new T[n]; for (var i = 0; i < rt.Length; ++i) rt[i] = f(); return rt; }\n public static T[] Create(int n, Func f) { var rt = new T[n]; for (var i = 0; i < rt.Length; ++i) rt[i] = f(i); return rt; }\n public static IEnumerable Shuffle(this IEnumerable A) => A.OrderBy(v => Guid.NewGuid());\n public static int CompareTo(this T[] A, T[] B, Comparison cmp = null) { cmp = cmp ?? Comparer.Default.Compare; for (var i = 0; i < Min(A.Length, B.Length); i++) { int c = cmp(A[i], B[i]); if (c > 0) return 1; else if (c < 0) return -1; } if (A.Length == B.Length) return 0; if (A.Length > B.Length) return 1; else return -1; }\n public static int ArgMax(this IList A, Comparison cmp = null) { cmp = cmp ?? Comparer.Default.Compare; T max = A[0]; int rt = 0; for (int i = 1; i < A.Count; i++) if (cmp(max, A[i]) < 0) { max = A[i]; rt = i; } return rt; }\n public static T PopBack(this List A) { var v = A[A.Count - 1]; A.RemoveAt(A.Count - 1); return v; }\n public static void Fail(T s) { Console.WriteLine(s); Console.Out.Close(); Environment.Exit(0); }\n}\npublic class Scanner\n{\n public string Str => Console.ReadLine().Trim();\n public int Int => int.Parse(Str);\n public long Long => long.Parse(Str);\n public double Double => double.Parse(Str);\n public int[] ArrInt => Str.Split(' ').Select(int.Parse).ToArray();\n public long[] ArrLong => Str.Split(' ').Select(long.Parse).ToArray();\n public char[][] Grid(int n) => Create(n, () => Str.ToCharArray());\n public int[] ArrInt1D(int n) => Create(n, () => Int);\n public long[] ArrLong1D(int n) => Create(n, () => Long);\n public int[][] ArrInt2D(int n) => Create(n, () => ArrInt);\n public long[][] ArrLong2D(int n) => Create(n, () => ArrLong);\n private Queue q = new Queue();\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public T Next() { if (q.Count == 0) foreach (var item in Str.Split(' ')) q.Enqueue(item); while (q.Peek() == \"\") q.Dequeue(); return (T)Convert.ChangeType(q.Dequeue(), typeof(T)); }\n public void Make(out T1 v1) => v1 = Next();\n public void Make(out T1 v1, out T2 v2) { v1 = Next(); v2 = Next(); }\n public void Make(out T1 v1, out T2 v2, out T3 v3) { Make(out v1, out v2); v3 = Next(); }\n public void Make(out T1 v1, out T2 v2, out T3 v3, out T4 v4) { Make(out v1, out v2, out v3); v4 = Next(); }\n public void Make(out T1 v1, out T2 v2, out T3 v3, out T4 v4, out T5 v5) { Make(out v1, out v2, out v3, out v4); v5 = Next(); }\n public void Make(out T1 v1, out T2 v2, out T3 v3, out T4 v4, out T5 v5, out T6 v6) { Make(out v1, out v2, out v3, out v4, out v5); v6 = Next(); }\n public void Make(out T1 v1, out T2 v2, out T3 v3, out T4 v4, out T5 v5, out T6 v6, out T7 v7) { Make(out v1, out v2, out v3, out v4, out v5, out v6); v7 = Next(); }\n //public (T1, T2) Make() { Make(out T1 v1, out T2 v2); return (v1, v2); }\n //public (T1, T2, T3) Make() { Make(out T1 v1, out T2 v2, out T3 v3); return (v1, v2, v3); }\n //public (T1, T2, T3, T4) Make() { Make(out T1 v1, out T2 v2, out T3 v3, out T4 v4); return (v1, v2, v3, v4); }\n}\npublic class Pair : IComparable>\n{\n public T1 v1;\n public T2 v2;\n public Pair() { }\n public Pair(T1 v1, T2 v2)\n { this.v1 = v1; this.v2 = v2; }\n\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public int CompareTo(Pair p)\n {\n var c = Comparer.Default.Compare(v1, p.v1);\n if (c == 0)\n c = Comparer.Default.Compare(v2, p.v2);\n return c;\n }\n public override string ToString() => $\"{v1.ToString()} {v2.ToString()}\";\n public void Deconstruct(out T1 a, out T2 b) { a = v1; b = v2; }\n\n public static implicit operator Pair((T1 f, T2 s) p) => new Pair(p.f, p.s);\n}\n\npublic class Pair : Pair, IComparable>\n{\n public T3 v3;\n public Pair() : base() { }\n public Pair(T1 v1, T2 v2, T3 v3) : base(v1, v2)\n { this.v3 = v3; }\n\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public int CompareTo(Pair p)\n {\n var c = base.CompareTo(p);\n if (c == 0)\n c = Comparer.Default.Compare(v3, p.v3);\n return c;\n }\n public override string ToString() => $\"{base.ToString()} {v3.ToString()}\";\n public void Deconstruct(out T1 a, out T2 b, out T3 c) { Deconstruct(out a, out b); c = v3; }\n\n public static implicit operator Pair((T1 f, T2 s, T3 t) p) => new Pair(p.f, p.s, p.t);\n}\n#endregion", "lang_cluster": "C#", "tags": ["math", "implementation"], "code_uid": "06ea828dd2235fc38785e419255d6584", "src_uid": "c05d753b35545176ad468b99ff13aa39", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.IO;\n\nclass Test\n{\n\tstatic Stream stdin = Console.OpenStandardInput();\n\tstatic byte[] buf = new byte[16 << 10];\n\tstatic int cap = 1;\n\tstatic int pos = 1;\n\tpublic static byte nextByte()\n\t{\n\t\tif (cap == 0) return 0;\n\t\tif (pos == cap)\n\t\t{\n\t\t\tcap = stdin.Read(buf, 0, 16 << 10);\n\t\t\tif (cap == 0) return 0;\n\t\t\tpos = 0;\n\t\t}\n\t\treturn buf[pos++];\n\t}\n\tpublic static long nextInt()\n\t{\n\t\tbyte c = nextByte();\n\t\twhile ((c < '0' || c > '9') && c != '-') c= nextByte();\n\t\tlong sign = 1;\n\t\tif (c == '-')\n\t\t{\n\t\t\tc = nextByte();\n\t\t\tsign = -1;\n\t\t}\n\t\tlong res = 0;\n\t\twhile (c >= '0' && c <= '9')\n\t\t{\n\t\t\tres = res * 10 + c - '0';\n\t\t\tc = nextByte();\n\t\t}\n\t\treturn res * sign;\n\t}\n\tpublic static double nextDouble()\n\t{\n\t\tbyte c = nextByte();\n\t\twhile ((c < '0' || c > '9') && c != '-' && c != '.') c= nextByte();\n\t\tdouble sign = 1;\n\t\tif (c == '-')\n\t\t{\n\t\t\tsign = -1;\n\t\t\tc = nextByte();\n\t\t}\n\t\tint p = -1;\n\t\tlong res = 0;\n\t\twhile (c >= '0' && c <= '9' || c == '.')\n\t\t{\n\t\t\tif (c == '.') p = 0;\n\t\t\telse\n\t\t\t{\n\t\t\t\tres = res * 10 + c - '0';\n\t\t\t\tif (p != -1) ++p;\n\t\t\t}\n\t\t\tc = nextByte();\n\t\t}\n\t\tif (p != -1) sign *= Math.Pow(10.0, -p);\n\t\treturn sign * (double)res;\n\t}\n\n\n\tpublic static void Main()\n\t{\n\t\tlong n = nextInt();\n\t\tlong m = nextInt();\n\t\tlong a = nextInt();\n\t\tlong b = nextInt();\n\n\t\tlong make = (m - n % m) % m;\n\t\tlong brake = n % m;\n\n\t\tif (a * make < b * brake) Console.WriteLine(a * make);\n\t\telse Console.WriteLine(b * brake);\n\t}\n}", "lang_cluster": "C#", "tags": ["math", "implementation"], "code_uid": "cc0b8811cbb6025665ff995f1827d0dc", "src_uid": "c05d753b35545176ad468b99ff13aa39", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections;\nusing System.Collections.Generic;\nusing System.Globalization;\nusing System.Linq;\nusing System.Runtime.InteropServices;\nusing System.Text;\nusing System.Threading.Tasks;\nusing System.Threading;\n\nnamespace CF253\n{\n class D\n {\n readonly int[] _bad = { ' ', '\\r', '\\n', -1 };\n\n private string NextToken()\n {\n var sb = new StringBuilder();\n int i;\n\n while (Array.IndexOf(_bad, (i = Console.Read())) != -1)\n {\n }\n sb.Append((char)i);\n\n while (Array.IndexOf(_bad, (i = Console.Read())) == -1)\n {\n sb.Append((char)i);\n }\n return sb.ToString();\n }\n\n int NextInt()\n {\n return int.Parse(NextToken());\n }\n\n void run()\n {\n var n = NextInt();\n if (n > 2 && n % 2 == 0)\n Console.Write(\"YES\");\n else\n Console.Write(\"NO\");\n }\n static void Main(string[] args)\n {\n// Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(\"en-US\");\n new D().run();\n }\n }\n}", "lang_cluster": "C#", "tags": ["brute force", "math"], "code_uid": "ab1beea756065ff78294a34a70ed3ef7", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": " class Program\n {\n static void Main(string[] args)\n {\n int w;\n w = int.Parse(System.Console.ReadLine());\n if(w%2 ==0 && w!=2)\n System.Console.WriteLine(\"YES\");\n else\n System.Console.WriteLine(\"NO\");\n\n }\n}", "lang_cluster": "C#", "tags": ["brute force", "math"], "code_uid": "9f0057020d67e767558759b3a1d3e2aa", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\n\n\n\t\t\t\t\t\npublic class Program\n{\n\t\n\tpublic static void Main()\n\t{\t\n\tint[] arr;\n\tarr = Array.ConvertAll(Console.ReadLine().Trim().Split(' '),Convert.ToInt32);\n Array.Sort(arr, new Comparison( (i1, i2) => i2.CompareTo(i1))); \n\n\t\t\n int somme=0;\n\tfor(int i=0;i=0)\n\t\t\t\t\tpart=part-arr[i];\t\t\n\t\t\t}\n\t\t\tif(part==0)\n\t\t\tConsole.WriteLine(\"YES\");\t\n\t\t\telse\n\t\t\tConsole.WriteLine(\"NO\");\n\t\t}\n\t\t\n\t\t\n\t}\n}", "lang_cluster": "C#", "tags": ["brute force", "implementation"], "code_uid": "6e3ae99a908bccbb19237d1fadb8af93", "src_uid": "5a623c49cf7effacfb58bc82f8eaff37", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Linq;\n\nnamespace CodeForces\n{\n class Program\n {\n\n static void Main(string[] args)\n {\n int[] mas = Console.ReadLine().Split(' ').Select(x => Convert.ToInt32(x)).ToArray();\n Array.Sort(mas);\n bool b = mas[0] + mas[3] == mas[1] + mas[2] || mas[0] + mas[1] + mas[2] == mas[3];\n Console.WriteLine(b? \"YES\":\"NO\");\n\n }\n\n }\n}", "lang_cluster": "C#", "tags": ["brute force", "implementation"], "code_uid": "089c3f74e24b49720d9a28ce1e465879", "src_uid": "5a623c49cf7effacfb58bc82f8eaff37", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\n\nnamespace The_Circumference_of_the_Circle\n{\n internal class Program\n {\n private static void Main(string[] args)\n {\n //string[] line = Console.ReadLine().Split();\n //int n = int.Parse(line[0]);\n //int m = int.Parse(line[1]);\n\n //int[] citiesW = new int[n];\n //int index = 0;\n //for (int i = 0; i < m; i++)\n //{\n // line = Console.ReadLine().Split();\n // int max = 0;\n // for (int j = 0; j < n; j++)\n // {\n // if (int.Parse(line[j]) > max)\n // {\n // max = int.Parse(line[j]);\n // index = j;\n // }\n // }\n // citiesW[index]++;\n //}\n\n //int max2 = 0;\n //index = 0;\n //for (int i = 0; i < n; i++)\n //{\n // if (citiesW[i] > max2)\n // {\n // max2 = citiesW[i];\n // index = i;\n // }\n //}\n\n //Console.WriteLine(index + 1);\n\n string[] line = Console.ReadLine().Split();\n int n = int.Parse(line[0]);\n int m = int.Parse(line[1]);\n\n if (n == 1)\n {\n Console.WriteLine(1);\n return;\n }\n\n int low = m - 1;\n int ab = n - m;\n int res;\n if (ab > low)\n res = m + 1;\n else res = m - 1;\n Console.WriteLine(res);\n }\n }\n}", "lang_cluster": "C#", "tags": ["constructive algorithms", "games", "math", "greedy", "implementation"], "code_uid": "cea2cbfb0f85198c55ea45785392961f", "src_uid": "f6a80c0f474cae1e201032e1df10e9f7", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace Simple_Game\n{\n class Program\n {\n static void Main(string[] args)\n {\n string x = Console.ReadLine();\n int[] nandm = x.Split(' ').Select(int.Parse).ToArray();\n int answer;\n if (nandm[0]==1)\n {\n answer = 1;\n }\n else if (nandm[0] - nandm[1] > nandm[1] - 1)\n {\n answer = nandm[1] + 1;\n }\n else if (nandm[0] - nandm[1] < nandm[1] - 1)\n {\n answer = nandm[1] - 1;\n\n }\n else\n answer = nandm[1] - 1;\n Console.WriteLine(answer);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["constructive algorithms", "games", "math", "greedy", "implementation"], "code_uid": "5a1221e82c45aa6a3a804503cf46666b", "src_uid": "f6a80c0f474cae1e201032e1df10e9f7", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\n\nnamespace CodeForces\n{\n class Program\n {\n static void Main(string[] args)\n {\n string lines = Console.ReadLine();\n\n string result = \"NO\";\n\n for (int i = 0; i < lines.Length; i++)\n {\n if (lines[i] == 'H' || lines[i] == 'Q' || lines[i] == '9')\n {\n result = \"YES\";\n break;\n }\n }\n\n Console.WriteLine(result);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "4d95ddd0e23e74bb324e9328f940ae91", "src_uid": "1baf894c1c7d5aeea01129c7900d3c12", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\n\nnamespace A.HQ9_\n{\n class Program\n {\n static void Main(string[] args)\n {\n string input;\n bool flage = false; \n input= Console.ReadLine();\n for (int i = 0; i < input.Length; i++)\n {\n if ((input[i] == 'H') | (input[i] == 'Q') | (input[i] == '9'))\n {\n flage = true;\n Console.WriteLine(\"YES\");\n break;\n }\n\n }\n\n if (flage == false)\n {\n Console.WriteLine(\"NO\");\n }\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "9ed9962b6075aa321b541b3276dfe091", "src_uid": "1baf894c1c7d5aeea01129c7900d3c12", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Text;\nusing System.Collections.Generic;\nusing System.Collections;\nclass Problem\n{\n static void Main()\n {\n var s = Array.ConvertAll( Console.ReadLine().Split(), Convert.ToInt32 );\n int kq = 0;\n Array.Sort( s );\n for(int i = 0 ; i < s.Length-1 ; i++)\n if(s[i] == s[i + 1])\n kq++;\n Console.WriteLine( kq );\n }\n}", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "4c3947fce95b3281976a3fb20bfdd928", "src_uid": "38c4864937e57b35d3cce272f655e20f", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Text;\n\nnamespace CodeForces.PRACTICE\n{\n // Is your horseshoe on the other hoof? (implementation)\n class _228A\n {\n static void Main(string[] args)\n {\n string[] ss = Console.ReadLine().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);\n HashSet hash = new HashSet();\n for (int i = 0; i < ss.Length; i++)\n hash.Add(int.Parse(ss[i]));\n Console.WriteLine(4 - hash.Count);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "c1079f2100f7c43112170e6fab156949", "src_uid": "38c4864937e57b35d3cce272f655e20f", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\n class Program\n {\n static void Main(string[] args)\n {\n int[] data;\n {\n string[] input = Console.In.ReadLine().Split(new char[] { ' ', '\\n', '\\r', '\\t' }, StringSplitOptions.RemoveEmptyEntries);\n data = new int[3];\n for (int i = 0; i < 3; ++i)\n data[i] = int.Parse(input[i]);\n }\n if (data[2] <= data[1]) Console.WriteLine(data[2]);\n else if (data[0] < data[2])\n Console.WriteLine(data[1]-(data[2]-data[0]));\n else Console.WriteLine(data[1]);\n }\n }", "lang_cluster": "C#", "tags": ["math", "implementation"], "code_uid": "1815182d3c189156d001be629e4ecd7c", "src_uid": "7e614526109a2052bfe7934381e7f6c2", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.CodeDom;\nusing System.Collections.Generic;\nusing System.ComponentModel.Design.Serialization;\nusing System.Globalization;\nusing System.IO;\nusing System.Linq;\nusing System.Numerics;\nusing System.Text;\nusing System.Threading;\n\nnamespace Codeforces\n{\n class Program : IDisposable\n {\n private static readonly TextReader textReader = new StreamReader(Console.OpenStandardInput());\n private static readonly TextWriter textWriter = new StreamWriter(Console.OpenStandardOutput());\n\n\n private void Solve()\n {\n var s = Console.ReadLine().Split(' ');\n var n = int.Parse(s[0]);\n var k = int.Parse(s[1]);\n var t = int.Parse(s[2]);\n\n if (t <= k)\n {\n Console.WriteLine(t);\n return;\n }\n if (t > k && t <= n)\n {\n Console.WriteLine(k);\n return;\n }\n Console.WriteLine(n+k-t);\n }\n\n int BinarySearch(int[] arr, int q)\n {\n var l = 0;\n var r = arr.Length - 1;\n //int med = -1;\n while (l <= r)\n {\n var med = l + (r - l) / 2;\n if (arr[med] == q)\n {\n return med;\n }\n if (q < arr[med])\n {\n r = med - 1;\n }\n else\n {\n l = med + 1;\n }\n }\n return -1;\n }\n\n\n static void Main(string[] args)\n {\n var p = new Program();\n p.Solve();\n //Console.ReadLine();\n //p.Dispose();\n //////////////////////////////\n }\n\n #region Helpers\n\n private static int ReadInt()\n {\n return int.Parse(textReader.ReadLine());\n }\n\n private static long ReadLong()\n {\n return long.Parse(textReader.ReadLine());\n }\n\n private static int[] ReadIntArray()\n {\n return textReader.ReadLine().Split(' ').Select(int.Parse).ToArray();\n }\n #endregion\n\n public void Dispose()\n {\n textReader.Close();\n textWriter.Close();\n }\n }\n\n //class Trie\n //{\n // public TrieNode root;\n\n // public Trie()\n // {\n // root = new TrieNode();\n // }\n\n // public void Insert(string s)\n // {\n // var current = root;\n // for (int i = 0; i < s.Length; i++)\n // {\n // var ch = s[i];\n // if (!current.Children.ContainsKey(ch))\n // current.Children.Add(ch, new TrieNode());\n // current = current.Children[ch];\n // }\n // current.IsEnd = true;\n // }\n\n // public bool Search(string word)\n // {\n // var current = root;\n // for (int i = 0; i < word.Length; i++)\n // {\n // var ch = word[i];\n // if (!current.Children.ContainsKey(ch))\n // return false;\n // current = current.Children[ch];\n // }\n // return current.IsEnd;\n // }\n //}\n\n //class TrieNode\n //{\n // public Dictionary Children { get; set; }\n // public bool IsEnd { get; set; }\n\n // public TrieNode()\n // {\n // Children = new Dictionary();\n // IsEnd = false;\n // }\n\n \n //}\n}\n\n\n", "lang_cluster": "C#", "tags": ["math", "implementation"], "code_uid": "5ff0160562e4af7c6382efc8df5d4924", "src_uid": "7e614526109a2052bfe7934381e7f6c2", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Text;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Numerics;\n\nnamespace WarmingUpC_Sharp\n{\n class Program\n { \n static void Main(string[] args)\n {\n int[] input = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);\n int n = input[0], m = input[1];\n int ans = (((n + 1) / 2) + m - 1) / m * m;\n Console.WriteLine(ans > n ? -1 : ans);\n }\n }\n}", "lang_cluster": "C#", "tags": ["math", "implementation"], "code_uid": "06c3e84e80442f202f7909c407e2de5e", "src_uid": "0fa526ebc0b4fa3a5866c7c5b3a4656f", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeff#if DEBUG\nusing System.Reflection;\nusing System.Threading.Tasks;\n#endif\n\nusing System;\nusing System.Collections.Generic;\nusing System.IO;\nusing System.Linq;\nusing System.Text;\n\n\nnamespace dr1\n{\n class Program\n {\n static string _inputFilename = \"input.txt\";\n static string _outputFilename = \"output.txt\";\n#if DEBUG\n static bool _useFileInput = false;\n#else\n static bool _useFileInput = false;\n#endif\n\n static void Main(string[] args)\n {\n StreamWriter file = null;\n if (_useFileInput)\n {\n Console.SetIn(File.OpenText(_inputFilename));\n file = new StreamWriter(_outputFilename);\n Console.SetOut(file);\n }\n\n#if DEBUG\n\t\t\tif (!_useFileInput)\n\t\t\t{\n\t\t\t\tConsole.SetIn(getInput());\n\t\t\t}\n#endif\n\n try\n {\n solution();\n }\n finally\n {\n if (_useFileInput)\n {\n file.Close();\n }\n }\n }\n\n static void solution()\n {\n #region SOLUTION\n var d = readIntArray();\n var n = d[0];\n var m = d[1];\n\n var dc = n / 2;\n var min = n / 2 + n % 2;\n var rem = min % m;\n if (rem == 0)\n {\n Console.WriteLine(min);\n return;\n }\n\n var need = m - rem;\n if (need > dc)\n {\n Console.WriteLine(-1);\n return;\n }\n\n var count = min + need;\n Console.WriteLine(count);\n //var n = readInt();\n //var m = readInt();\n\n //var a = readIntArray();\n //var b = readIntArray();\n #endregion\n }\n\n static int readInt()\n {\n return int.Parse(Console.ReadLine());\n }\n\n static long readLong()\n {\n return long.Parse(Console.ReadLine());\n }\n\n static int[] readIntArray()\n {\n return Console.ReadLine().Split(' ').Where(i => !string.IsNullOrEmpty(i)).Select(i => int.Parse(i)).ToArray();\n }\n\n static long[] readLongArray()\n {\n return Console.ReadLine().Split(' ').Where(i => !string.IsNullOrEmpty(i)).Select(i => long.Parse(i)).ToArray();\n }\n\n#if DEBUG\n\t\tstatic StreamReader getInput()\n\t\t{\n\t\t\tvar resName = Assembly.GetCallingAssembly().GetManifestResourceNames()[0];\n\t\t\tvar resource = Assembly.GetCallingAssembly().GetManifestResourceStream(resName);\n\n\t\t\treturn new StreamReader(resource);\n\t\t}\n#endif\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "implementation"], "code_uid": "5a794b180fbe3c4987003f96900b8886", "src_uid": "0fa526ebc0b4fa3a5866c7c5b3a4656f", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.IO;\nusing System.Linq;\nusing System.Runtime.InteropServices;\nusing System.Text;\n\nnamespace codeforces\n{\n\tclass Program\n\t{\n\t\tpublic const int Osn = 1000000007;\n\n\t\tpublic class Pair\n\t\t{\n\t\t\tpublic long First;\n\n\t\t\tpublic long Second;\n\t\t}\n\n\t\tpublic class PairComparer : IComparer\n\t\t{\n\t\t\tpublic int Compare(Pair x, Pair y)\n\t\t\t{\n\t\t\t\tif (x.First < y.First || (x.First == y.First && x.Second > y.Second))\n\t\t\t\t\treturn -1;\n\t\t\t\treturn 1;\n\t\t\t}\n\t\t}\n\n\t\tpublic static long GetGcd(long a, long b)\n\t\t{\n\t\t\twhile (true)\n\t\t\t{\n\t\t\t\tif (b == 0)\n\t\t\t\t\treturn a;\n\t\t\t\tvar a1 = a;\n\t\t\t\ta = b;\n\t\t\t\tb = a1 % b;\n\n\t\t\t}\n\t\t}\n\n\t\tpublic static void WriteYesNo(bool x, string yes = \"YES\", string no = \"NO\")\n\t\t{\n\t\t\tif (x)\n\t\t\t\tConsole.WriteLine(yes);\n\t\t\telse\n\t\t\t{\n\t\t\t\tConsole.WriteLine(no);\n\t\t\t}\n\t\t}\n\n\t\tpublic static string ReadString()\n\t\t{\n\t\t\treturn Console.ReadLine();\n\t\t}\n\n\t\tpublic static List ReadListOfInts()\n\t\t{\n\t\t\tvar s = Console.ReadLine();\n\t\t\treturn s.Split(' ').Select(int.Parse).ToList();\n\t\t}\n\n\t\tpublic static List ReadListOfLongs()\n\t\t{\n\t\t\tvar s = Console.ReadLine();\n\t\t\treturn s.Split(' ').Select(long.Parse).ToList();\n\t\t}\n\n\t\tpublic static int ReadInt()\n\t\t{\n\t\t\tvar s = Console.ReadLine();\n\t\t\treturn int.Parse(s);\n\t\t}\n\n\t\tpublic static long ReadLong()\n\t\t{\n\t\t\tvar s = Console.ReadLine();\n\t\t\treturn long.Parse(s);\n\t\t}\n\n\t\tpublic class Vertex\n\t\t{\n\t\t\tpublic int Was;\n\n\t\t\tpublic List Edges;\n\t\t}\n\n\t\tpublic static List Graph = new List();\n\n\n\t\tpublic static bool Dfs(int u)\n\t\t{\n\t\t\tif (Graph[u].Was == 1) return true;\n\t\t\tif (Graph[u].Was == 2) return false;\n\t\t\tGraph[u].Was = 1;\n\t\t\tforeach (var t in Graph[u].Edges)\n\t\t\t{\n\t\t\t\tif (Dfs(t)) return true;\n\t\t\t}\n\n\t\t\tGraph[u].Was = 2;\n\t\t\treturn false;\n\t\t}\n\n\t\tpublic static bool IsPrime(long x)\n\t\t{\n\t\t\tfor (var j = 2; j * j <= x; ++j)\n\t\t\t\tif (x % j == 0)\n\t\t\t\t\treturn false;\n\t\t\treturn true;\n\t\t}\n\n\t\tpublic class LinkedVertex\n\t\t{\n\t\t\tpublic int Next;\n\n\t\t\tpublic int Prev;\n\n\t\t\tpublic int Value;\n\t\t}\n\n\n\t\tpublic static int BinarySearch(List list, int value)\n\t\t{\n\t\t\tvar l = -1;\n\t\t\tvar r = list.Count;\n\t\t\twhile (r - l > 1)\n\t\t\t{\n\t\t\t\tvar m = (r + l) / 2;\n\t\t\t\tif (list[m] >= value)\n\t\t\t\t\tr = m;\n\t\t\t\telse\n\t\t\t\t\tl = m;\n\t\t\t}\n\n\t\t\treturn r;\n\t\t}\n\n\t\tpublic static Dictionary mp = new Dictionary(); \n\t\tpublic static long Go(long u, long v, long w)\n\t\t{\n\t\t\tlong ans = 0; \n\t\t\twhile (u != v)\n\t\t\t\tif (u > v)\n\t\t\t\t{\n\t\t\t\t\tif (!mp.ContainsKey(u))\n\t\t\t\t\t\tmp.Add(u, 0);\n\t\t\t\t\tans += mp[u];\n\t\t\t\t\tmp[u] += w;\n\t\t\t\t\tu /= 2;\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tif (!mp.ContainsKey(v))\n\t\t\t\t\t\tmp.Add(v, 0);\n\t\t\t\t\tans += mp[v];\n\t\t\t\t\tmp[v] += w;\n\t\t\t\t\tv /= 2;\n\t\t\t\t} \n\t\t\treturn ans;\n\t\t}\n\n\t\tpublic static int GetAns(int x, int pow)\n\t\t{\n\t\t\tif (pow == 0)\n\t\t\t\treturn 1;\n\t\t\tif (pow % 2 == 1)\n\t\t\t\treturn (GetAns(x, pow - 1) * 8) % 10;\n\t\t\tvar t = GetAns(x, pow / 2);\n\t\t\treturn (t * t) % 10;\n\t\t}\n\n\t\tpublic static int ans = 0;\n\t\tpublic static int move = 0;\n\t\tpublic static bool good = false; \n\t\tpublic static int[] x = { 0, 0, 0 };\n\n\t\tpublic static void solve(int a, int b, int c, int n)\n\t\t{\n\t\t\tif (ans != 0)\n\t\t\t\treturn;\n\t\t\tif (n > 0)\n\t\t\t{\n\t\t\t\tsolve(a, c, b, n - 1);\n\t\t\t\tmove++;\n\t\t\t\tx[a]--;\n\t\t\t\tx[b]++;\n\t\t\t\tif (x[a] == x[b] && x[b] == x[c] && ans == 0)\n\t\t\t\t{\n\t\t\t\t\tans = move;\n\t\t\t\t}\n\t\t\t\tsolve(c, b, a, n - 1);\n\t\t\t}\n\t\t}\n\n\t\tprivate static void Main()\n\t\t{\n/*\t\t\tvar input = new StreamReader(\"input.txt\");\n\t\t\tvar output = new StreamWriter(\"output.txt\");*/\n\t\t\tvar s = ReadString();\n\t\t\tvar min = 'a';\n\t\t\tvar good = true;\n\t\t\tfor (var i = 0; i < s.Length; ++i)\n\t\t\t{\n\t\t\t\tif (s[i] > min)\n\t\t\t\t{\n\t\t\t\t\tgood = false;\n\t\t\t\t}\n\t\t\t\tif (s[i] == min)\n\t\t\t\t{\n\t\t\t\t\tmin = (char)(((int)min) + 1);\n\t\t\t\t}\n\t\t\t}\n\t\t\tWriteYesNo(good);\n\t\t\tConsole.ReadLine();\n\t\t\t/*\t\t\tinput.Close();\n\t\t\toutput.Close();*/\n\t\t}\n\t}\n}\n", "lang_cluster": "C#", "tags": ["greedy", "strings", "implementation"], "code_uid": "dfbaac618deaa8f9cfdd02d88118024a", "src_uid": "c4551f66a781b174f95865fa254ca972", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Globalization;\nusing System.IO;\nusing System.Linq;\nusing System.Text;\nusing System.Text.RegularExpressions;\nusing System.Threading;\n\nnamespace Olymp\n{\n public class ProblemSolver\n {\n private Tokenizer input;\n\n public void Solve()\n {\n var s = input.NextToken();\n var c = 'a';\n if (s[0] != c)\n {\n Console.Write(\"NO\");\n return;\n }\n for (int i = 0; i < s.Length; i++)\n {\n if (s[i] > c + 1)\n {\n Console.Write(\"NO\");\n return;\n }\n else if (s[i] > c)\n {\n c = s[i];\n }\n }\n Console.Write(\"YES\");\n }\n\n public ProblemSolver(TextReader input)\n {\n this.input = new Tokenizer(input);\n }\n }\n\n #region Service classes\n\n public class Tokenizer\n {\n private TextReader reader;\n\n public int NextInt()\n {\n var c = SkipWS();\n if (c == -1)\n throw new EndOfStreamException();\n bool isNegative = false;\n if (c == '-' || c == '+')\n {\n isNegative = c == '-';\n c = this.reader.Read();\n if (c == -1)\n throw new InvalidOperationException();\n }\n if (!char.IsDigit((char)c))\n throw new InvalidOperationException();\n int result = (char)c - '0';\n c = this.reader.Read();\n while (c > 0 && !char.IsWhiteSpace((char)c))\n {\n if (!char.IsDigit((char)c))\n throw new InvalidOperationException();\n result = result * 10 + (char)c - '0';\n c = this.reader.Read();\n }\n if (isNegative)\n result = -result;\n return result;\n }\n\n public string ReadLine()\n {\n return reader.ReadLine();\n }\n\n public long NextLong()\n {\n return long.Parse(this.NextToken());\n }\n\n public double NextDouble()\n {\n return double.Parse(this.NextToken(), CultureInfo.InvariantCulture);\n }\n\n public int[] ReadIntArray(int n)\n {\n int[] a = new int[n];\n for (int i = 0; i < n; i++)\n a[i] = NextInt();\n return a;\n }\n\n public long[] ReadLongArray(int n)\n {\n long[] a = new long[n];\n for (int i = 0; i < n; i++)\n a[i] = NextLong();\n return a;\n }\n\n public double[] ReadDoubleArray(int n)\n {\n double[] a = new double[n];\n for (int i = 0; i < n; i++)\n a[i] = NextDouble();\n return a;\n }\n\n public string NextToken()\n {\n var c = SkipWS();\n if (c == -1)\n return null;\n var sb = new StringBuilder();\n while (c > 0 && !char.IsWhiteSpace((char)c))\n {\n sb.Append((char)c);\n c = this.reader.Read();\n }\n return sb.ToString();\n }\n\n private int SkipWS()\n {\n int c = this.reader.Read();\n if (c == -1)\n return c;\n while (c > 0 && char.IsWhiteSpace((char)c))\n c = this.reader.Read();\n return c;\n }\n\n public Tokenizer(TextReader reader)\n {\n this.reader = reader;\n }\n }\n\n class Program\n {\n public static void Main(string[] args)\n {\n var solver = new ProblemSolver(Console.In);\n solver.Solve();\n }\n }\n\n #endregion\n}", "lang_cluster": "C#", "tags": ["greedy", "strings", "implementation"], "code_uid": "ae0ced1f77b8ab63e7fa05b3489fb1ee", "src_uid": "c4551f66a781b174f95865fa254ca972", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "/*\ncsc -debug A.cs && mono --debug A.exe <<< \"5 1 4 3 2\"\n*/\n\nusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading;\nusing System.Reflection;\n\npublic class HelloWorld {\n public static void SolveCodeForces() {\n var n = cin.NextInt();\n var a = cin.NextInt() - 1;\n var x = cin.NextInt() - 1;\n var b = cin.NextInt() - 1;\n var y = cin.NextInt() - 1;\n\n for (var t = 0; t <= n+5; t++) {\n if (a == b) {\n System.Console.WriteLine(\"YES\");\n return;\n }\n if (a == x || b == y) break;\n a = (a + 1) % n;\n b = (b + n - 1) % n;\n }\n System.Console.WriteLine(\"NO\");\n }\n\n static Scanner cin = new Scanner();\n static StringBuilder cout = new StringBuilder();\n\n static public void Main () {\n SolveCodeForces();\n // IncreaseStack(SolveCodeForces);\n // System.Console.Write(cout.ToString());\n }\n\n public static void IncreaseStack(ThreadStart action, int stackSize = 128000000)\n {\n var thread = new Thread(action, stackSize);\n thread.Start();\n thread.Join();\n }\n}\n\npublic static class Helpers {\n public static T[] CreateArray(int length, Func itemCreate) {\n var result = new T[length];\n for (var i = 0; i < result.Length; i++)\n result[i] = itemCreate(i);\n return result;\n }\n}\n\npublic class Scanner\n{\n private string[] line = new string[0];\n private int index = 0;\n\n public string Next() {\n if (line.Length <= index) {\n line = Console.ReadLine().Split(' ');\n index = 0;\n }\n var res = line[index];\n index++;\n return res;\n }\n\n public int NextInt() {\n return int.Parse(Next());\n }\n\n public long NextLong() {\n return long.Parse(Next());\n }\n\n public ulong NextUlong() {\n return ulong.Parse(Next());\n }\n\n public string[] Array() {\n line = Console.ReadLine().Split(' ');\n index = line.Length;\n return line;\n }\n\n public int[] IntArray(int emptyPrefixLen = 0) {\n var array = Array();\n var result = new int[emptyPrefixLen + array.Length];\n for (int i = 0; i < array.Length; i++)\n result[emptyPrefixLen + i] = int.Parse(array[i]);\n return result;\n }\n\n public long[] LongArray() {\n var array = Array();\n var result = new long[array.Length];\n for (int i = 0; i < array.Length; i++)\n result[i] = long.Parse(array[i]);\n return result;\n }\n\n public ulong[] UlongArray() {\n var array = Array();\n var result = new ulong[array.Length];\n for (int i = 0; i < array.Length; i++)\n result[i] = ulong.Parse(array[i]);\n return result;\n }\n}", "lang_cluster": "C#", "tags": ["math", "implementation"], "code_uid": "46b08f5c106b54b1f96dda6582f3d870", "src_uid": "5b889751f82c9f32f223cdee0c0095e4", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System.Collections.Generic;\nusing System.Collections;\nusing System.ComponentModel;\nusing System.Diagnostics.CodeAnalysis;\nusing System.Globalization;\nusing System.IO;\nusing System.Linq;\nusing System.Reflection;\nusing System.Runtime.Serialization;\nusing System.Text.RegularExpressions;\nusing System.Text;\nusing System;\nusing System.Numerics;\n\nclass Solution\n{\n\n static int? getVal(char c)\n {\n if (c >= 'a' && c <= 'f')\n return 10 + (c - 'a');\n if (c >= 'A' && c <= 'F')\n return 10 + (c - 'A');\n if (c >= '0' && c <= '9')\n return c - '0';\n return null;\n }\n\n static char? convert(char? A, char? B)\n {\n if (A == null || B == null)\n return null;\n var x = getVal(A.Value);\n var y = getVal(B.Value);\n if (x == null || y == null)\n return null;\n var res = x.Value * 16 + y.Value;\n return (char)res;\n }\n\n static void Main(string[] args)\n {\n var nm = Array.ConvertAll(Console.ReadLine().Trim().Split(), int.Parse);\n var n = nm[0];\n var a = nm[1];\n var x = nm[2];\n var b = nm[3];\n var y = nm[4];\n for (int i = 0; i < n; i++)\n {\n var c1 = (a - 1 + i) % n;\n var c2 = (b - 1 - i) % n;\n c2 = c2 < 0 ? c2 + n : c2;\n if (c1 == c2 )\n {\n Console.WriteLine(\"YES\");\n return;\n }\n if (c1 == x - 1 || c2 == y - 1)\n {\n Console.WriteLine(\"NO\");\n return;\n }\n }\n }\n}", "lang_cluster": "C#", "tags": ["math", "implementation"], "code_uid": "c7f66023c97de8126807f03320fd8051", "src_uid": "5b889751f82c9f32f223cdee0c0095e4", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Globalization;\nusing System.Linq;\nusing System.Text;\nusing System.Text.RegularExpressions;\nusing System.Threading;\n\nnamespace Codeforces\n{\n class \u0410\n {\n private static ThreadStart s_threadStart = new \u0410().Go;\n private static bool s_time = false;\n\n private void Go()\n {\n long a = GetLong();\n long b = GetLong();\n long x = 0;\n long t;\n\n while (a != 0 && b != 0)\n {\n if (a > b) { t = a; a = b; b = t; }\n x += (b / a);\n t = b % a;\n b = a;\n a = t;\n }\n\n Wl(x);\n }\n\n #region Template\n\n public static void Main(string[] args)\n {\n System.Diagnostics.Stopwatch timer = new System.Diagnostics.Stopwatch();\n Thread main = new Thread(new ThreadStart(s_threadStart), 200 * 1024 * 1024);\n timer.Start();\n main.Start();\n main.Join();\n timer.Stop();\n if (s_time)\n Wl(timer.ElapsedMilliseconds);\n }\n\n private static IEnumerator ioEnum;\n private static string GetString()\n {\n while (ioEnum == null || !ioEnum.MoveNext())\n {\n ioEnum = Console.ReadLine().Split().AsEnumerable().GetEnumerator();\n }\n\n return ioEnum.Current;\n }\n\n private static int GetInt()\n {\n return int.Parse(GetString());\n }\n\n private static long GetLong()\n {\n return long.Parse(GetString());\n }\n\n private static double GetDouble()\n {\n return double.Parse(GetString());\n }\n\n private static List GetIntArr(int n)\n {\n List ret = new List(n);\n for (int i = 0; i < n; i++)\n {\n ret.Add(GetInt());\n }\n return ret;\n }\n\n private static void Wl(T o)\n {\n if (o is double)\n {\n Wld((o as double?).Value, \"\");\n }\n else if (o is float)\n {\n Wld((o as float?).Value, \"\");\n }\n else\n Console.WriteLine(o.ToString());\n }\n\n private static void Wl(IEnumerable enumerable)\n {\n Wl(string.Join(\" \", enumerable.Select(e => e.ToString()).ToArray()));\n }\n\n private static void Wld(double d, string format)\n {\n Wl(d.ToString(format, CultureInfo.InvariantCulture));\n }\n\n #endregion\n }\n}", "lang_cluster": "C#", "tags": ["math", "number theory"], "code_uid": "8a511aa5e36805520330ac2ac31e6ca6", "src_uid": "792efb147f3668a84c866048361970f8", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.IO;\nusing System.Web;\nusing System.Net;\nusing System.Collections;\nusing System.Threading;\n\nnamespace ConsoleApplication1 {\n class Program {\n static void Main( string[] args ) {\n long a = ReadLong();\n long b = ReadLong();\n long count = 0;\n while ( a != 0 && b != 0 ) {\n if ( a < b ) {\n long c = a;\n a = b;\n b = c;\n }\n\n count += a / b;\n a %= b;\n }\n\n Console.WriteLine(count);\n }\n\n static int _current = -1;\n static string[] _words = null;\n static long ReadLong() {\n if ( _current == -1 ) {\n _words = Console.ReadLine().Split(new char[] { ' ', '\\r', '\\n' }, StringSplitOptions.RemoveEmptyEntries);\n _current = 0;\n }\n\n long value = long.Parse(_words[_current]);\n if ( _current == _words.Length - 1 )\n _current = -1;\n else\n _current++;\n\n return value;\n }\n }\n}", "lang_cluster": "C#", "tags": ["math", "number theory"], "code_uid": "81ae0452c0fa85f4a67bfdafa652137a", "src_uid": "792efb147f3668a84c866048361970f8", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace a\n{\n class Program\n {\n static void Main(string[] args)\n {\n var s = Console.ReadLine();\n var l = Console.ReadLine().Split();\n for (var i = 0; i < l.Length; i++)\n {\n if (l[i][0] == s[0] || l[i][1] == s[1])\n {\n Console.WriteLine(\"YES\");\n //Console.ReadKey();\n return;\n } \n }\n\n Console.WriteLine(\"NO\");\n //Console.ReadKey();\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "implementation"], "code_uid": "c514d6d97499675437bb82e08532477f", "src_uid": "699444eb6366ad12bc77e7ac2602d74b", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": ".NET Core C#", "source_code": "\ufeffusing System;\n\nnamespace codeforce_1097A\n{\n class Program\n {\n static void Main(string[] args)\n {\n\n string str1 = Console.ReadLine();\n\n string str2 = Console.ReadLine();\n\n if (str2.Contains(str1[1])||str2.Contains(str1[0]))\n Console.WriteLine(\"YES\");\n else\n Console.WriteLine(\"NO\");\n\n\n \n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "implementation"], "code_uid": "1d6302faff0c75f8ca7052c8046659c6", "src_uid": "699444eb6366ad12bc77e7ac2602d74b", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace CodeForces\n{\n class Program\n {\n static void Main(string[] args)\n {\n int n = Convert.ToInt32(Console.ReadLine());\n string nums = Console.ReadLine();\n var res = new List();\n foreach (var i in nums.Split(' ').Select(s => Convert.ToInt32(s)))\n {\n if (!res.Contains(i))\n res.Add(i);\n if (res.Count > 3)\n break;\n }\n if (res.Count == 1)\n Console.WriteLine(0);\n else if (res.Count == 2)\n {\n if (Math.Abs(res[0] - res[1]) % 2 == 0)\n Console.WriteLine(Math.Abs(res[0] - res[1]) / 2);\n else\n Console.WriteLine(Math.Abs(res[0] - res[1]));\n }\n else if (res.Count == 3)\n {\n int maxVal = res.Max();\n int minVal = res.Min();\n res.Remove(maxVal);\n res.Remove(minVal);\n if (maxVal + minVal == 2 * res[0])\n Console.WriteLine(res[0] - minVal);\n else\n Console.WriteLine(-1);\n }\n else\n Console.WriteLine(-1);\n }\n }\n}", "lang_cluster": "C#", "tags": ["math"], "code_uid": "bb3019e558be916b12ba78117d6482f0", "src_uid": "d486a88939c132848a7efdf257b9b066", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.IO;\nusing System.Linq;\n\nclass Program\n{\n const string inputPath = \"input.txt\";\n const string outPath = \"output.txt\";\n static void Main(string[] args)\n {\n // var inputText = File.ReadAllLines(inputPath);\n // var stringN = inputText[0].Split(' ');\n // var stringNums = inputText[1].Split(' ');\n\n var stringN = Console.ReadLine();\n var stringNums = Console.ReadLine().Split(' ');\n\n int n = int.Parse(stringN);\n\n List nums = new List();\n HashSet hasNums = new HashSet();\n\n foreach (var num in stringNums)\n {\n hasNums.Add(int.Parse(num));\n }\n\n if (hasNums.Count > 3)\n {\n System.Console.WriteLine(-1);\n }\n else\n {\n nums = hasNums.ToList();\n nums.Sort();\n if (nums.Count == 3)\n {\n if (nums[2] - nums[1] == nums[1] - nums[0])\n {\n System.Console.WriteLine(nums[1] - nums[0]);\n }\n else\n {\n System.Console.WriteLine(-1);\n }\n }\n else if (nums.Count == 2)\n {\n if ((nums[1] - nums[0]) % 2 == 0)\n {\n System.Console.WriteLine((nums[1] - nums[0]) / 2);\n }\n else\n {\n System.Console.WriteLine(nums[1] - nums[0]);\n }\n }\n else if (nums.Count == 1)\n {\n System.Console.WriteLine(0);\n }\n else\n {\n System.Console.WriteLine(-1);\n }\n\n // Console.ReadLine();\n }\n }\n}", "lang_cluster": "C#", "tags": ["math"], "code_uid": "5cb05b3171f5d8ee24883e10141cc841", "src_uid": "d486a88939c132848a7efdf257b9b066", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.IO;\n\nnamespace Codeforce\n{\n\n class Printer\n {\n StringBuilder sb;\n\n public Printer()\n {\n sb = new StringBuilder();\n }\n\n public void WriteLine(string s)\n {\n sb.AppendLine(s);\n }\n\n public void Write(string s)\n {\n sb.Append(s);\n }\n\n public void Print()\n {\n Console.Write(sb);\n }\n }\n\n class Program\n {\n static StreamReader input = new StreamReader(Console.OpenStandardInput());\n //static StreamWriter output = new StreamWriter(Console.OpenStandardOutput());\n\n static int nextInt()\n {\n int t = input.Read();\n while ((t < '0' || t > '9' || t < 'A' || t > 'Z') && t != '-') t = input.Read();\n if (t >= 'A' && t <= 'Z')\n return t;\n int sign = 1;\n if (t == '-')\n {\n sign = -1;\n t = input.Read();\n }\n int x = 0;\n while (t >= '0' && t <= '9')\n {\n x *= 10;\n x += t - '0';\n t = input.Read();\n }\n return x * sign;\n }\n \n static int[] parseInt(string s)\n {\n string[] temp = s.Split(' ');\n int[] res = new int[temp.Length];\n for (int i = 0; i < temp.Length; i++)\n {\n res[i] = Convert.ToInt32(temp[i]);\n }\n return res;\n }\n \n\n static void Main(string[] args)\n {\n Printer printer = new Printer();\n\n int n = Convert.ToInt32(Console.ReadLine());\n\n List res = new List();\n\n Queue Q = new Queue();\n\n Q.Enqueue(\"1\");\n\n while (Q.Count > 0)\n {\n string tmp = Q.Dequeue();\n res.Add(Convert.ToInt32(tmp));\n\n string tmp1 = tmp + \"1\", tmp2 = tmp + \"0\";\n\n if (tmp1.Length < 11 && Convert.ToInt64(tmp1) <= n)\n Q.Enqueue(tmp1);\n if (tmp2.Length < 11 && Convert.ToInt64(tmp2) <= n)\n Q.Enqueue(tmp2);\n }\n\n Console.WriteLine(res.Count);\n\n printer.Print();\n\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "math", "implementation"], "code_uid": "bc73f822969428ab10787b32a31b5bb0", "src_uid": "64a842f9a41f85a83b7d65bfbe21b6cb", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "//#define RegExpScanner\nusing System;\nusing System.Linq;\nusing System.Text;\nusing System.Diagnostics;\nusing System.Collections.Generic;\n//using System.Text.RegularExpressions;\n\n//Codeforces 9C.\u0427\u0438\u0441\u043b\u0430 \u0425\u0435\u043a\u0441\u0430\u0434\u0435\u0441\u0438\u043c\u0430\u043b\n\nnamespace CodeForces\n{\n class Program\n {\n\n [Conditional(\"DEBUG\")]\n void OnDebug()\n {\n }\n\n\n private void solve()\n {\n int x = 999;\n string s = cin.Scan();\n for (int i = 0; i < s.Length; i++)\n {\n if (s[i] > '1') { x = i; break; }\n }\n \n var m = s.Select((e, idx) => (e - '0') >= 1 | (idx >= x) ? 1 : 0).Aggregate((ac, i) => (ac << 1) | i);\n Console.WriteLine(m);\n }\n\n static void Main()\n {\n new Program().solve();\n#if DEBUG\n Console.ReadKey(true);\n#endif\n }\n\n static T[] ga(int n, Func f)\n {\n var a = new T[n];\n for (int i = 0; i < n; ++i) a[i] = f(i);\n return a;\n }\n }\n}\n\n\nclass cin\n{\n private static readonly System.IO.StreamReader reader = new System.IO.StreamReader(Console.OpenStandardInput(1024 * 16), Encoding.ASCII, false, 1024 * 10);\n\n static int read() { return reader.Read(); }\n\n public static string Scan()\n {\n int c;\n StringBuilder sb = new StringBuilder();\n do c = read(); while (c < 33 || c > 126);\n for (; c >= 33 && c <= 126; c = read()) sb.Append((char)c);\n return sb.ToString();\n }\n\n public static uint gu()\n {\n return gu(read());\n }\n\n static uint gu(int first)\n {\n uint u = 0;\n for (int c = first; c != -1; c = read())\n {\n if (!char.IsDigit((char)c)) return u;\n u = 10 * u + (uint)c - '0';\n }\n\n throw new System.IO.IOException();\n }\n\n public static int gi()\n {\n for (int c = read(); c != -1; c = read())\n {\n switch ((char)c)\n {\n case '-':\n read();\n return -(int)gu(read());\n\n default:\n if (char.IsDigit((char)c)) return (int)gu(c);\n break;\n }\n }\n\n throw new System.IO.IOException();\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "math", "implementation"], "code_uid": "411d9ffb345ac70e47db22324d96bb85", "src_uid": "64a842f9a41f85a83b7d65bfbe21b6cb", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.IO;\nusing System.Text;\n\nnamespace The_Big_Race\n{\n internal class Program\n {\n private static readonly StreamReader reader = new StreamReader(Console.OpenStandardInput(1024*10), Encoding.ASCII, false, 1024*10);\n private static readonly StreamWriter writer = new StreamWriter(Console.OpenStandardOutput(1024*10), Encoding.ASCII, 1024*10);\n\n private static void Main(string[] args)\n {\n long t = Next();\n long w = Next();\n long b = Next();\n\n long min = Math.Min(w, b);\n long max = Math.Max(w, b);\n long g = Gcd(w, b);\n long count = min - 1;\n if (w == b || t < min)\n count = t;\n else if (t/min >= max/g)\n {\n long d = min/g*max;\n long cnt = t/d - 1;\n\n count += cnt*(min);\n\n long tt = (cnt + 1)*d;\n\n count += Math.Min(t - tt + 1, min);\n }\n\n\n g = Gcd(count, t);\n writer.Write(count/g);\n writer.Write('/');\n writer.WriteLine(t/g);\n writer.Flush();\n }\n\n public static long Gcd(long a, long b)\n {\n return b == 0 ? a : Gcd(b, a%b);\n }\n\n private static long Next()\n {\n int c;\n long res = 0;\n do\n {\n c = reader.Read();\n if (c == -1)\n return res;\n } while (c < '0' || c > '9');\n res = c - '0';\n while (true)\n {\n c = reader.Read();\n if (c < '0' || c > '9')\n return res;\n res *= 10;\n res += c - '0';\n }\n }\n }\n}", "lang_cluster": "C#", "tags": ["math"], "code_uid": "089aa4e77efd5975718bbf19de6798e0", "src_uid": "7a1d8ca25bce0073c4eb5297b94501b5", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\n\nnamespace _292C\n{\n class Program\n {\n static void Main(string[] args)\n {\n string[] input = Console.ReadLine().Split(' ');\n long t = long.Parse(input[0]);\n long w = long.Parse(input[1]);\n long b = long.Parse(input[2]);\n\n long min = (w > b) ? b : w;\n if (t < min)\n Console.WriteLine(\"1/1\");\n else\n {\n long nok = NOK(w, b, t+1);\n long extra = (t / nok) * nok + min - t - 1;\n if ((extra < 0) || (nok == 1))\n extra = 0;\n long count = (t / nok + 1) * min - 1 - extra;\n if (count == 0)\n {\n Console.WriteLine(\"0/1\");\n return;\n }\n\n long NOD = NOD_Evclid(t, count);\n t /= NOD;\n count /= NOD;\n\n Console.WriteLine(count.ToString() + \"/\" + t.ToString());\n Console.ReadLine();\n\n }\n }\n static long NOK(long a, long b, long def)\n {\n long min, max;\n if (a > b)\n {\n min = b;\n max = a;\n }\n else\n {\n min = a;\n max = b;\n }\n\n a = min / NOD_Evclid(max, min);\n if (def / max >= a)\n return a * max;\n else\n return def;\n }\n static long NOD_Evclid(long a, long b) // a>b !\n {\n //https://ru.wikipedia.org/wiki/\u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c_\u0415\u0432\u043a\u043b\u0438\u0434\u0430\n long r = a % b;\n while (r != 0)\n {\n a = b;\n b = r;\n r = a % b;\n }\n return b;\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math"], "code_uid": "10a205929b7cde18331135c8c00d7919", "src_uid": "7a1d8ca25bce0073c4eb5297b94501b5", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Text;\nusing System.Collections.Generic;\nusing System.Linq;\nclass Solve{\n public Solve(){}\n StringBuilder sb;\n public static int Main(){\n new Solve().Run();\n return 0;\n }\n void Run(){\n sb = new StringBuilder();\n Calc();\n Console.Write(sb.ToString());\n }\n void Calc(){\n int N = int.Parse(Console.ReadLine());\n int[] A = new int[6];\n for(int i=5;i>=0;i--){\n A[i] = N % 10;\n N /= 10;\n }\n int count;\n if(A[0] + A[1] + A[2] == A[3] + A[4] + A[5]){\n count = 0;\n }\n else{\n int diff;\n int[] B = new int[6];\n if(A[0] + A[1] + A[2] > A[3] + A[4] + A[5]){\n diff = (A[0] + A[1] + A[2]) - (A[3] + A[4] + A[5]);\n for(int i=0;i<6;i++){\n B[i] = i < 3 ? A[i] : 9 - A[i];\n }\n }\n else{\n diff = - (A[0] + A[1] + A[2]) + (A[3] + A[4] + A[5]);\n for(int i=0;i<6;i++){\n B[i] = i >= 3 ? A[i] : 9 - A[i];\n }\n }\n Array.Sort(B);\n int c = 0;\n count = 0;\n for(int i=5;i>=0;i--){\n c += B[i];\n count++;\n if(diff <= c){\n break;\n }\n }\n }\n sb.Append(count+\"\\n\");\n }\n}", "lang_cluster": "C#", "tags": ["brute force", "greedy", "implementation"], "code_uid": "7ee3618e3c34d7bfb2373e225ce47df6", "src_uid": "09601fd1742ffdc9f822950f1d3e8494", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace ConsoleApplication13\n{\n class Program\n {\n static void Main(string[] args)\n {\n string s = Console.ReadLine();\n int[] array = new int[6];\n for (int i = 0; i < 6; i++)\n {\n int.TryParse(s[i].ToString(), out array[i]);\n }\n\n int sum1 = array[0] + array[1] + array[2];\n int sum2 = array[3] + array[4] + array[5];\n if (sum2 > sum1)\n {\n int[] result = { 9 - array[0], 9 - array[1], 9 - array[2], array[3], array[4], array[5] };\n Array.Sort(result);\n int sum = sum2 - sum1;\n {\n int answer = 1;\n for (int i = 0; i < 6; i++)\n {\n if (sum > result[5 - i]) { answer++; sum -= result[5 - i]; } else break;\n }\n Console.WriteLine(answer);\n }\n }\n if (sum1 > sum2)\n {\n int[] result = {array[0], array[1], array[2], 9-array[3], 9-array[4], 9-array[5] };\n Array.Sort(result);\n int sum = sum1 - sum2;\n {\n int answer = 1;\n for (int i = 0; i < 6; i++)\n {\n if (sum > result[5 - i]) { answer++; sum -= result[5 - i]; } else break;\n }\n Console.WriteLine(answer);\n }\n }\n if (sum1 == sum2) Console.WriteLine(0);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "greedy", "implementation"], "code_uid": "fec0d21bd4b359f61b1a6ef2de550c87", "src_uid": "09601fd1742ffdc9f822950f1d3e8494", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Text;\n\nnamespace CodeForcesProblems\n{\n class A577MultiplicationTable\n {\n public static void Main()\n {\n //while(true)\n //{\n string[] a = Console.ReadLine().Split(' ');\n var n = int.Parse(a[0]);\n var x = int.Parse(a[1]);\n double j = 0;\n var count = 0;\n for(int i =1;i<=n;i++)\n {\n j = x / i;\n if (x % i == 0 && i<=n && j<=n)\n count++;\n }\n\n Console.WriteLine(count);\n //}\n }\n }\n}", "lang_cluster": "C#", "tags": ["implementation", "number theory"], "code_uid": "c7451d4dcde7e2c2e5007189bf93da9f", "src_uid": "c4b139eadca94201596f1305b2f76496", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Linq;\n\nclass A577 {\n public static void Main() {\n var line = Console.ReadLine().Split();\n var n = int.Parse(line[0]);\n var x = int.Parse(line[1]);\n Console.WriteLine(Enumerable.Range(1, n).Count(k => \n x / k <= n && x % k == 0\n ));\n }\n}\n", "lang_cluster": "C#", "tags": ["implementation", "number theory"], "code_uid": "c4edfa951264556e5f8be3215a87bb7f", "src_uid": "c4b139eadca94201596f1305b2f76496", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.IO;\nusing System.Text;\n\nnamespace Multiplication_Table\n{\n internal class Program\n {\n private static readonly StreamReader reader = new StreamReader(Console.OpenStandardInput(1024*10), Encoding.ASCII, false, 1024*10);\n private static readonly StreamWriter writer = new StreamWriter(Console.OpenStandardOutput(1024*10), Encoding.ASCII, 1024*10);\n\n private static void Main(string[] args)\n {\n int n = Next();\n\n for (int i = 1; i < n; i++)\n {\n for (int j = 1; j < n; j++)\n {\n writer.Write(ConvertToString(i*j, n));\n writer.Write(' ');\n }\n writer.WriteLine();\n }\n\n writer.Flush();\n }\n\n private static string ConvertToString(int i, int b)\n {\n var st = new Stack();\n while (i > 0)\n {\n st.Push(i%b);\n i /= b;\n }\n var bb = new StringBuilder();\n foreach (int j in st)\n {\n bb.Append((char) (j + '0'));\n }\n return bb.ToString();\n }\n\n private static int Next()\n {\n int c;\n int res = 0;\n do\n {\n c = reader.Read();\n if (c == -1)\n return res;\n } while (c < '0' || c > '9');\n res = c - '0';\n while (true)\n {\n c = reader.Read();\n if (c < '0' || c > '9')\n return res;\n res *= 10;\n res += c - '0';\n }\n }\n }\n}", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "47e7faf7a89d470150f4ce59b4fe1cf7", "src_uid": "a705144ace798d6b41068aa284d99050", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Text;\n\nnamespace _39h\n{\n class Program\n {\n\n static string ToPos(Int32 k, Int32 pos)\n {\n string result = \"\";\n while (k > 0)\n {\n result = (k % pos).ToString() + result;\n k = k / pos;\n }\n return result;\n }\n\n\n static void PrintMatr(Int32[,] arr, Int32 pos)\n {\n if (pos == 10)\n {\n for (int i = 0; i < 9; i++)\n {\n for (int j = 0; j < 9; j++)\n {\n Console.Write(arr[i, j].ToString()+\" \");\n }\n Console.WriteLine();\n }\n }\n else\n {\n for (int i = 0; i < pos-1; i++)\n {\n for (int j = 0; j < pos-1; j++)\n {\n Console.Write(ToPos(arr[i, j], pos)+ \" \");\n }\n Console.WriteLine();\n }\n }\n }\n static void Main(string[] args)\n {\n Int32 pos = 0;\n pos = Convert.ToInt32(Console.ReadLine());\n Int32[,] arr = new Int32[9, 9];\n for(int i = 1;i<10;i++)\n for (int j = 1; j < 10; j++)\n {\n arr[i-1, j-1] = i * j;\n }\n PrintMatr(arr, pos);\n //Console.ReadLine();\n //\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "590cbad0702d55ed96f405c70f3e950d", "src_uid": "a705144ace798d6b41068aa284d99050", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace test_file2\n{\n class Program\n {\n static void Main(string[] args)\n {\n int[] nk = Console.ReadLine().Split().Select(int.Parse).ToArray();\n\n int n = nk[0];\n int k = nk[1];\n \n List score = Console.ReadLine().Split().Select(int.Parse).ToList();\n \n int count = 0;\n \n for (int i = 0; i < n; i++)\n {\n if (score[i] >= score[k - 1])\n {\n if (score[i] > 0) \n {\n count++;\n }\n }\n }\n \n Console.WriteLine(count);\n\n Console.Read();\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "0d384f70256347c32403caae62e9565a", "src_uid": "193ec1226ffe07522caf63e84a7d007f", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\nusing System.Collections.ObjectModel;\n\n\nnamespace ConsoleApplicationTest\n{\n class Program\n {\n static void Main(string[] args)\n {\n Int32 output = 0;\n string[] y_temp = Console.ReadLine().Split(' ');\n Int32 part=Convert.ToInt32(y_temp[0]);\n Int32 k = Convert.ToInt32(y_temp[1]);\n if (part < 1 || part > 50) { throw new Exception(\"Out of range\"); }\n if (k > part) { throw new Exception(\"Out of range\"); }\n string[] x_temp = Console.ReadLine().Split(' ');\n List score= Array.ConvertAll(x_temp, Int32.Parse).ToList();\n if (score.Count != part) { throw new Exception(\"Out of range\"); }\n List scoreDesc=score.OrderByDescending(x=>x).ToList();\n if (!score.SequenceEqual(scoreDesc)) { throw new Exception(\"Out of range\"); }\n if (part == k) { output=score.FindLastIndex(x => x > 0) + 1; }\n else {\n for (Int32 i = k; i < part; i++)\n {\n if (score[k - 1] == 0) { output = score.FindLastIndex(x => x > 0) + 1; break; }\n if (i == part - 1) { if (score[i] == score[k - 1]) { output = part; } }\n if (score[i] != score[k - 1])\n {\n output = i;\n break;\n }\n }\n \n }\n Console.WriteLine(output);\n }\n }\n}", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "041971eb74ede89a719cdcf1ff9eaee6", "src_uid": "193ec1226ffe07522caf63e84a7d007f", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Text.RegularExpressions;\n\nnamespace Codeforces\n{\n class Codeforces\n {\n public static void Main(string[] args)\n {\n if (Regex.IsMatch(Console.ReadLine(), \"0{7,}|1{7,}\"))\n {\n Console.Write(\"YES\");\n }\n\n else\n {\n Console.Write(\"NO\");\n }\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["strings", "implementation"], "code_uid": "22f9fe9ae1087288699856eb4ebf5d89", "src_uid": "ed9a763362abc6ed40356731f1036b38", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\n\nnamespace ConsoleApplication2\n{\n class Program\n {\n static void Main(string[] args)\n {\n string input = Console.ReadLine();\n int count = 0;\n for (int i = 0; i < 2; i++)\n {\n string m= Convert.ToString(i);\n string patern = m+m+m+m+m+m+m;\n int n = 0;\n while ((n = input.IndexOf(patern, n)) != -1)\n {\n n += patern.Length;\n count++;\n } \n }\n if (count > 0)\n {\n Console.WriteLine(\"YES\");\n }\n else\n {\n Console.WriteLine(\"NO\");\n }\n }\n }\n}", "lang_cluster": "C#", "tags": ["strings", "implementation"], "code_uid": "d520067e10b09d429f6e8b903bec3b17", "src_uid": "ed9a763362abc6ed40356731f1036b38", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\n\nnamespace Exams\n{\n class Program\n {\n private static int n;\n\n private static int k;\n\n static void Main(string[] args)\n {\n int[] values = Console.ReadLine().Split(' ').Select(s => Convert.ToInt32(s)).ToArray();\n n = values[0];\n k = values[1];\n\n int result = Solve();\n Console.Out.WriteLine(result);\n }\n\n private static int Solve()\n {\n for(int i2 = 0; i2 <= n; i2++)\n {\n for(int i3 = 0; i3 <= n - i2; i3++)\n {\n for(int i4 = 0; i4 <= n - i3 - i2;i4++)\n {\n int i5 = n - i4 - i3 - i2;\n int sum = 2 * i2 + 3 * i3 + 4 * i4 + 5 * i5;\n\n if (sum == k)\n {\n// Console.Out.WriteLine(\"{4} = 2 * {0} + 3 * {1} + 4 * {2} + 5 * {3}\", i2, i3, i4, i5, sum);\n\n return i2;\n }\n }\n }\n }\n\n throw new ArgumentException(\"no possibility to pass exam\");\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "implementation"], "code_uid": "7aa4d9eeed3512ed5f8ed706fdbc2af0", "src_uid": "5a5e46042c3f18529a03cb5c868df7e8", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Text;\nusing System.IO;\n\nnamespace ConsoleApplication1\n{\n class Scanner\n {\n public Scanner(Stream inputStream)\n {\n m_inputStreamReader = new StreamReader(inputStream);\n }\n\n\n public int NextInt()\n {\n return Int32.Parse(NextToken());\n }\n\n public long NextLong()\n {\n return Int64.Parse(NextToken());\n }\n\n public double NextDouble()\n {\n return Double.Parse(NextToken());\n }\n\n public string NextLine()\n {\n return m_inputStreamReader.ReadLine();\n }\n\n public char NextChar()\n {\n return (char)m_inputStreamReader.Read();\n }\n\n \n private string NextToken()\n {\n char nextChar = (char)0;\n while (IsDelimeter(nextChar))\n {\n nextChar = NextChar();\n }\n\n string result = \"\";\n while (!IsDelimeter(nextChar))\n {\n result += nextChar;\n nextChar = NextChar();\n }\n\n return result;\n }\n\n private bool IsDelimeter(char c)\n {\n return c <= 32;\n }\n private StreamReader m_inputStreamReader;\n }\n class cf110a\n {\n private static bool IsLucky(int n)\n {\n if(n < 4) return false;\n while (n > 0)\n {\n int d = n % 10;\n if (d != 4 && d != 7)\n return false;\n n /= 10;\n }\n return true;\n }\n private static bool IsAlmostLucky(int n)\n {\n for (int x = 1; x <= n; ++x)\n if (n % x == 0 && IsLucky(x))\n return true;\n return false;\n }\n public static void Main()\n {\n var input = new Scanner(Console.OpenStandardInput());\n int n = input.NextInt();\n int sum = input.NextInt();\n int ans = Int32.MaxValue;\n for(int num5 = 0; num5 <= n; ++num5)\n for(int num4 = 0; num4 <= n; ++num4)\n for(int num3 = 0; num3 <= n; ++num3)\n for (int num2 = 0; num2 <= n; ++num2)\n {\n if (num5 + num4 + num3 + num2 != n)\n continue;\n int s = num5 * 5 + num4 * 4 + num3 * 3 + num2 * 2;\n if (s == sum && num2 < ans)\n ans = num2;\n }\n Console.WriteLine(ans);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "implementation"], "code_uid": "39f282b658cbe7a49e095ef3b40e18c3", "src_uid": "5a5e46042c3f18529a03cb5c868df7e8", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace Elephant\n{\n class Program\n {\n static void Main(string[] args)\n {\n here: int x = int.Parse(Console.ReadLine());\n if(x<1||x>1000000)\n {\n goto here;\n }\n int sum = 0;\n for(int i=x;i>0;i--)\n {\n \n if(x>=5)\n {\n x = x - 5;\n sum=sum+1; \n }\n else if(x<5&& x>0)\n {\n sum++;\n break;\n }\n\n }\n Console.WriteLine(sum);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math"], "code_uid": "8835282098c39106651d6f782658b252", "src_uid": "4b3d65b1b593829e92c852be213922b6", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nclass Program\n{\n static void Main()\n {\n uint steps=0,n = uint.Parse(Console.ReadLine());\n if (n % 10 > 5) { steps += 2; n -= n % 10; }\n if(n%10<5 && n % 10 != 0) { steps += 1; n -= n % 10; }\n Console.WriteLine(steps+n/5);\n }\n}\n", "lang_cluster": "C#", "tags": ["math"], "code_uid": "6af16b559e84eea117251890ba45ac7a", "src_uid": "4b3d65b1b593829e92c852be213922b6", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace _318A\n{\n class Program\n {\n static void Main(string[] args)\n {\n Int64[] arr = Console.ReadLine().Split(' ').Select(Int64.Parse).ToArray();\n Int64 count = 0;\n //var array1 = new int[arr[0]];\n //int j = 0;\n //for(int i = 0; i tmp = new List();\n\n string[] input = Console.ReadLine().Split(' ');\n\n for (int i = 0; i < input.Length; i++)\n {\n tmp.Add(Convert.ToInt32(input[i]));\n }\n tmp.Sort();\n\n Console.WriteLine((tmp[1] - tmp[0]) + (tmp[2] - tmp[1]));\n //Console.ReadLine();\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "sortings", "implementation"], "code_uid": "712f593d5612d93b98a296753f8d0f08", "src_uid": "7bffa6e8d2d21bbb3b7f4aec109b3319", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\n\nnamespace A\n{\n class MainClass\n {\n public static void Main(string[] args)\n {\n int[] line = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();\n Array.Sort(line);\n int distance = 300;\n for (int i = line[0]; i <= line[2];i++)\n {\n int temp = Math.Abs(line[0] - i) + Math.Abs(line[1] - i) + Math.Abs(line[2] - i);\n if (distance > temp)\n distance = temp;\n }\n Console.WriteLine(distance);\n\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "sortings", "implementation"], "code_uid": "be83a02bef7d4bfc18801ecc9d883277", "src_uid": "7bffa6e8d2d21bbb3b7f4aec109b3319", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace Generate_Login\n{\n class Program\n {\n static void Main(string[] args)\n {\n\n string line = Console.ReadLine();\n\n string[] input = line.Split(' ');\n string firstName = input[0];\n string lastName = input[1];\n\n List x = new List();\n\n for (int i = 0; i < firstName.Length; i++)\n {\n for (int j = 0; j < lastName.Length; j++)\n {\n string str = firstName.Substring(0, i + 1);\n string str1 = lastName.Substring(0, j + 1);\n x.Add(str + str1);\n }\n }\n\n string minimum = x[0];\n\n foreach (string str in x)\n {\n if (String.Compare(str, minimum) < 0)\n {\n minimum = str;\n }\n }\n\n Console.WriteLine(minimum);\n }\n }\n\n}\n \n\n\n", "lang_cluster": "C#", "tags": ["brute force", "sortings", "greedy"], "code_uid": "bc8866dcaa5f48228e23ca219f5f6a8e", "src_uid": "aed892f2bda10b6aee10dcb834a63709", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace \u0413\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u044f_\u043b\u043e\u0433\u0438\u043d\u0430\n{\n class Program\n {\n static void Main(string[] args)\n {\n string[] input = Console.ReadLine().Split();\n string name = input[0];\n string surname = input[1];\n\n string p1_login = \"\";\n List logins = new List();\n for (int i = 0; i < name.Length; i++)\n {\n string p2_login = \"\";\n p1_login += name[i];\n for (int j = 0; j < surname.Length; j++)\n {\n p2_login += surname[j];\n logins.Add(p1_login + p2_login);\n }\n }\n\n logins.Sort();\n Console.WriteLine(logins[0]);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "sortings", "greedy"], "code_uid": "9ee08921ac84da0bcea86de4ab0ea974", "src_uid": "aed892f2bda10b6aee10dcb834a63709", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Globalization;\nusing System.IO;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Diagnostics;\n\nnamespace Codeforces\n{\n class Program : ProgramBase\n {\n private const long commonMod = 1000000007;\n\n static void Main(string[] args)\n {\n var p = new Program();\n\n var x = p.Solve();\n p.Out(x);\n }\n object Solve()\n {\n var n = ReadLong();\n var m = ReadLong();\n long i = 0;\n while(n <= m)\n {\n n *= 3;\n m *= 2;\n i++;\n }\n return i;\n\n }\n\n long BS(long remain, long l, long r)\n {\n if (r - l == 1)\n return r;\n var half = (l + r) / 2;\n var sum = half * (half + 1) / 2;\n if (sum < remain)\n return BS(remain, half, r);\n return BS(remain, l, half);\n }\n\n \n\n class Pair\n {\n public long Val;\n public long Rem;\n public long Count1;\n public long Len;\n }\n\n Node FindDeepest(Node current, long target, Node bad)\n {\n Node result = null;\n for (int i = 0; i < current.Children.Count; i++)\n {\n if (current.Children[i] == bad)\n continue;\n result = FindDeepest(current.Children[i], target, bad);\n if (result != null)\n {\n break;\n }\n }\n if (current.parent != -1 && result == null && current.sum == target)\n return current;\n return result;\n }\n\n long CalcSum(Node current)\n {\n var sum = current.t;\n for (int i = 0; i < current.Children.Count; i++)\n {\n sum += CalcSum(current.Children[i]);\n }\n current.sum = sum;\n return sum;\n }\n\n class Node {\n public long parent;\n public long index;\n public long t;\n public long sum;\n public List Children;\n }\n }\n\n \n abstract class ProgramBase\n {\n bool? prod = null;\n StreamReader f;\n Queue tokens;\n protected string FileName { private get; set; }\n\n protected string Read()\n {\n if (f == null)\n f = string.IsNullOrEmpty(FileName)\n ? new StreamReader(Console.OpenStandardInput(1024*10), Encoding.ASCII, false, 1024 * 10)\n : new StreamReader((GetProd() ? \"\" : \"c:\\\\dev\\\\\") + FileName);\n return f.ReadLine();\n }\n\n protected string ReadToken()\n {\n if (tokens == null || tokens.Count == 0)\n tokens = new Queue(Read().Split(' '));\n return tokens.Dequeue();\n }\n\n protected long ReadLong() { return long.Parse(ReadToken()); }\n\n protected long[] ReadLongs()\n {\n var s = Read();\n if (s == \"\")\n return new long[0];\n //var i = s.IndexOf(' ');\n //return new[] { long.Parse(s.Substring(0, i)), long.Parse(s.Substring(i + 1)) };\n var tokens = s.Split(' ');\n var result = new long[tokens.Length];\n for (int i = 0; i < tokens.Length; i++)\n result[i] = long.Parse(tokens[i]);\n return result;\n }\n\n public void Out(object r)\n {\n if (string.IsNullOrEmpty(FileName))\n Console.WriteLine(r);\n else if (GetProd())\n File.WriteAllText(FileName, r.ToString());\n else\n Console.WriteLine(r);\n }\n\n private bool GetProd()\n {\n\n if (!prod.HasValue)\n try\n {\n prod = Environment.MachineName != \"RENADEEN-W7\";\n }\n catch (Exception)\n {\n prod = true;\n }\n return prod.Value;\n }\n }\n\n public static class Huj\n {\n public static T MinBy(this IEnumerable source, Func func) where T : class\n {\n T result = null;\n var min = double.MaxValue;\n foreach (var item in source)\n {\n var current = func(item);\n if (min > current)\n {\n min = current;\n result = item;\n }\n }\n return result;\n }\n\n public static T MaxBy(this IEnumerable source, Func func, T defaultValue = default(T))\n {\n T result = defaultValue;\n var max = double.MinValue;\n foreach (var item in source)\n {\n var current = func(item);\n if (max < current)\n {\n max = current;\n result = item;\n }\n }\n return result;\n }\n\n public static string JoinStrings(this IEnumerable s, string d) { return string.Join(d, s.ToArray()); }\n\n public static string JoinStrings(this IEnumerable s, string d) { return s.Select(x => x.ToString()).JoinStrings(d); }\n public static string JoinStrings(this IEnumerable s, string d) { return s.Select(x => x.ToString()).JoinStrings(d); }\n }\n}", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "6dcf6e6e36689fbbe26a66c815bfe82b", "src_uid": "a1583b07a9d093e887f73cc5c29e444a", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\n\nnamespace ConsoleApp9\n{\n class Program\n {\n static void Main(string[] args)\n {\n var word = Console.ReadLine().Split(' ');\n\n var a = int.Parse(word[0]);\n var b = int.Parse(word[1]);\n var year = 0;\n\n while (a <= b) {\n a *= 3;\n b *= 2;\n year++;\n }\n Console.WriteLine(year);\n Console.ReadLine();\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "88e062d3ce7c6b8613a138224df8e8da", "src_uid": "a1583b07a9d093e887f73cc5c29e444a", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\nusing System.Text.RegularExpressions;\nusing System.IO;\nusing System.Numerics;\nusing System.Globalization;\nusing System.Threading;\n\n\nnamespace probleme {\n class Program {\n static void Main(string[] args) {\n //Console.SetIn(new StreamReader(\"file.txt\"));\n string[] s = Console.ReadLine().Split(' ');\n int n = int.Parse(s[0]), bx = int.Parse(s[1]);\n long x = 0;\n int[] vx = Array.ConvertAll(Console.ReadLine().Split(' '), tz => int.Parse(tz));\n for (int i = 0; i < n; i++) {\n x *= bx;\n x += vx[i];\n }\n s = Console.ReadLine().Split(' ');\n int m = int.Parse(s[0]), by = int.Parse(s[1]);\n long y = 0;\n int[] vy = Array.ConvertAll(Console.ReadLine().Split(' '), tz => int.Parse(tz));\n for (int i = 0; i < m; i++) {\n y *= by;\n y += vy[i];\n }\n if (x == y) {\n Console.Write('=');\n } else if (x < y) {\n Console.Write('<');\n } else {\n Console.Write('>');\n }\n //Console.ReadKey();\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "implementation"], "code_uid": "139dcd1d1957b18f36f15f924b7effef", "src_uid": "d6ab5f75a7bee28f0af2bf168a0b2e67", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Linq;\n\nnamespace CSharp\n{\n public class _602A\n {\n public static void Main()\n {\n ulong x = Read();\n ulong y = Read();\n\n Console.WriteLine(x > y ? '>' : x < y ? '<' : '=');\n }\n\n private static ulong Read()\n {\n uint b = uint.Parse(Console.ReadLine().Split().Last());\n\n ulong n = 0;\n foreach (uint d in Console.ReadLine().Split().Select(token => uint.Parse(token)))\n {\n n = n * b + d;\n }\n\n return n;\n }\n }\n}", "lang_cluster": "C#", "tags": ["brute force", "implementation"], "code_uid": "15a5d3d4fe01ace1ec6608760d2296c7", "src_uid": "d6ab5f75a7bee28f0af2bf168a0b2e67", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\n\nnamespace Ladder4\n{\n class Prob16\n {\n static void Main(string[] args)\n {\n int [] input = Console.ReadLine().Split(' ').Select(alias => int.Parse(alias)).ToArray();\n int [] puzzles = Console.ReadLine().Split(' ').Select(alias => int.Parse(alias)).ToArray();\n List mins = new List();\n int x = input[0];\n Array.Sort(puzzles);\n if (input[0] == puzzles.Length)\n Console.WriteLine(puzzles[puzzles.Length - 1] - puzzles[0]);\n else\n {\n for (int i = 0; i <= puzzles.Length - input[0]; i++)\n {\n int difference = puzzles[x - 1] - puzzles[i];\n mins.Add(difference);\n x++;\n }\n int output = 999999999;\n for (int j = 0; j < mins.Count; j++)\n output = Math.Min(output, mins[j]);\n Console.WriteLine(output);\n }\n //while (true) ;\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["greedy"], "code_uid": "215e4f1b04219de9aea14801d34c785e", "src_uid": "7830aabb0663e645d54004063746e47f", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\n\nnamespace _337A\n{\n class Program\n {\n static void Main(string[] args)\n {\n string[] input = Console.ReadLine().Split(' ');\n int n = int.Parse(input[0]);\n int m = int.Parse(input[1]);\n input = Console.ReadLine().Split(' ');\n int[] numbers = new int[m];\n for (int i = 0; i < m; i++)\n {\n numbers[i] = int.Parse(input[i]);\n }\n for (int i = 0; i < m; i++)\n { \n for (int j = i + 1; j < m; j++)\n {\n if (numbers[i] > numbers[j])\n {\n int temp = numbers[i];\n numbers[i] = numbers[j];\n numbers[j] = temp;\n }\n }\n }\n int min = 10000;\n for (int i = 0; i <= m - n; i++)\n {\n int cur = numbers[i + n - 1] - numbers[i];\n if (cur < min) min = cur;\n }\n Console.WriteLine(min);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["greedy"], "code_uid": "528c4c1834f604ff0b08bf079339f00c", "src_uid": "7830aabb0663e645d54004063746e47f", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\n\nnamespace teh_2\n{\n class Program\n {\n static void Main(string[] args)\n {\n string[] InputString = Console.ReadLine().Split();\n int[] Array = new int[6];\n int SumAll = 0;\n for (int i = 0; i < 6; i++)\n {\n Array[i] = Convert.ToInt32(InputString[i]);\n SumAll += Array[i];\n }\n if (SumAll % 2 == 1)\n {\n Console.WriteLine(\"NO\");\n return;\n }\n else\n {\n for (int i = 0; i < 6; i++)\n {\n for (int j = i + 1; j < 6; j++)\n {\n for (int p = j + 1; p < 6; p++)\n {\n if (Array[i] + Array[j] + Array[p] == SumAll / 2)\n {\n Console.WriteLine(\"YES\");\n return;\n }\n }\n }\n }\n }\n Console.WriteLine(\"NO\");\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force"], "code_uid": "21e1e50ad6a5a68b9e8f236d4ed3ff70", "src_uid": "2acf686862a34c337d1d2cbc0ac3fd11", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nnamespace _886A\n{\n internal class Program\n {\n public static void Main(string[] args)\n {\n int[] a = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);\n bool result = false;\n for (int i = 0; i < 6; i++)\n for (int j = i + 1; j < 6; j++)\n for (int k = j + 1; k < 6; k++)\n {\n int sum1 = a[i] + a[j] + a[k], sum2 = 0;\n for (int x = 0; x < 6; x++)\n if (x != i && x != j && x != k)\n sum2 += a[x];\n if (sum1 == sum2)\n result = true;\n }\n Console.WriteLine(result ? \"YES\" : \"NO\");\n }\n }\n}", "lang_cluster": "C#", "tags": ["brute force"], "code_uid": "c9bab17e20f0526e03aca9f3868a2ba6", "src_uid": "2acf686862a34c337d1d2cbc0ac3fd11", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeff#if DEBUG\nusing System.Reflection;\nusing System.Threading.Tasks;\n#endif\n\nusing System;\nusing System.Collections.Generic;\nusing System.IO;\nusing System.Linq;\nusing System.Text;\nusing System.Numerics;\nusing System.Globalization;\n\n\nnamespace ed16\n{\n class Program\n {\n static string _inputFilename = \"input.txt\";\n static string _outputFilename = \"output.txt\";\n static bool _useFileInput = false;\n\n\n static void Main(string[] args)\n {\n StreamWriter file = null;\n#if DEBUG\n\t\t\tConsole.SetIn(getInput());\n#else\n if (_useFileInput)\n {\n Console.SetIn(File.OpenText(_inputFilename));\n file = new StreamWriter(_outputFilename);\n Console.SetOut(file);\n }\n#endif\n\n try\n {\n solution();\n }\n finally\n {\n if (_useFileInput)\n {\n file.Close();\n }\n }\n }\n\n static void solution()\n {\n #region SOLUTION\n var s = Console.ReadLine();\n var f = (int)s[0] - 96;\n var line = int.Parse(s.Substring(1, 1));\n if (line > 1 && line < 8 && f > 1 && f < 8)\n {\n Console.WriteLine(8);\n return;\n }\n\n if ((f == 1 && (line == 1 || line == 8)) || (f == 8 && (line == 1 || line == 8)))\n {\n Console.WriteLine(3);\n return;\n }\n\n Console.WriteLine(5);\n //var n = readInt();\n //var m = readInt();\n\n //var a = readIntArray();\n //var b = readIntArray();\n #endregion\n }\n\n static int readInt()\n {\n return int.Parse(Console.ReadLine());\n }\n\n static long readLong()\n {\n return long.Parse(Console.ReadLine());\n }\n\n static int[] readIntArray()\n {\n return Console.ReadLine().Split(' ').Where(i => !string.IsNullOrEmpty(i)).Select(i => int.Parse(i)).ToArray();\n }\n\n static long[] readLongArray()\n {\n return Console.ReadLine().Split(' ').Where(i => !string.IsNullOrEmpty(i)).Select(i => long.Parse(i)).ToArray();\n }\n\n#if DEBUG\n\t\tstatic StreamReader getInput()\n\t\t{\n\t\t\tvar resName = Assembly.GetCallingAssembly().GetManifestResourceNames()[0];\n\t\t\tvar resource = Assembly.GetCallingAssembly().GetManifestResourceStream(resName);\n\n\t\t\treturn new StreamReader(resource);\n\t\t}\n#endif\n }\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "0f909abc3a9094f54a0d810c3acb6ba9", "src_uid": "6994331ca6282669cbb7138eb7e55e01", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\n\nnamespace CSharp\n{\n public class _710A\n {\n public static void Main()\n {\n string cd = Console.ReadLine();\n\n int count = 0;\n\n for (int i = -1; i <= 1; i++)\n {\n for (int j = -1; j <= 1; j++)\n {\n char c = (char)(cd[0] + i);\n char d = (char)(cd[1] + j);\n\n if (c >= 'a' && c <= 'h' && d >= '1' && d <= '8' && cd != new string(new char[] { c, d }))\n {\n count++;\n }\n }\n }\n\n Console.WriteLine(count);\n }\n }\n}", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "90b8fe5fab3c5ff2398d615d3b2c33f6", "src_uid": "6994331ca6282669cbb7138eb7e55e01", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Linq;\nusing System.Collections.Generic;\n\nnamespace Task55A\n{\n class Program\n {\n static void Main(string[] args)\n {\n int n = int.Parse(Console.ReadLine());\n int ct = 0;\n int omit = 0;\n int sit = 1;\n HashSet container = new HashSet() { sit };\n string ans = \"NO\";\n while (true)\n {\n if (container.Count == n)\n {\n ans = \"YES\";\n break;\n }\n else if (omit > 2 * n)\n break;\n\n\n\n sit += omit;\n if (sit > n) sit %= n;\n container.Add(sit);\n omit++;\n\n }\n Console.WriteLine(ans);\n //Console.ReadKey();\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "implementation"], "code_uid": "d2b01ab5a0876e9ef7ab985484b0079b", "src_uid": "4bd174a997707ed3a368bd0f2424590f", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\n\nnamespace ProgrammingContest.Codeforces.Round51\n{\n class A\n {\n static bool check(int n)\n {\n bool[] used = new bool[n];\n for (int i = 0, j = 1; j<100000;i=(i+j)%n, j++)\n used[i] = true;\n for (int i = 0; i < n; i++)\n if (!used[i])\n return false;\n return true;\n }\n public static void Main()\n {\n int n = int.Parse(Console.ReadLine());\n //for (int n = 1; n <= 1000; n++)\n {\n bool[] used = new bool[n];\n for (int i = 0, j = 1; !used[i]; j++)\n {\n used[i] = true;\n //Console.WriteLine(i);\n i = (i + j) % n;\n }\n //Console.WriteLine(check(n));\n bool ok = true;\n for (int i = 0; i < n; i++)\n if (!used[i])\n {\n ok = false;\n //Console.WriteLine(\"NO\");\n //return;\n }\n //Console.WriteLine(\"YES\");\n Console.WriteLine( ok ? \"YES\":\"NO\");\n }\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "implementation"], "code_uid": "54fe5439be9136320cec1afd7f53454f", "src_uid": "4bd174a997707ed3a368bd0f2424590f", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\n\nnamespace myApp {\n class Program {\n static void Main (string[] args) {\n int n = Convert.ToInt32(Console.ReadLine());\n int[] a = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);\n Array.Sort(a);\n Array.ForEach(a, x => Console.Write(x + \" \"));\n }\n }\n}", "lang_cluster": "C#", "tags": ["sortings", "implementation", "greedy"], "code_uid": "0c5c99521c6344e617d2f308af14953d", "src_uid": "ae20712265d4adf293e75d016b4b82d8", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\n//using System.Collections.Generic;\n//using System.Linq;\n//using System.Text;\n//using System.Threading.Tasks;\n\nnamespace Problem405A {\n class Program {\n static void Main(string[] args) {\n int columns = Convert.ToInt32(Console.ReadLine());\n string[] input1 = Console.ReadLine().Split(' ');\n int[] columnsInState1 = new int[columns];\n for (int i = 0; i < columns; i++) {\n columnsInState1[i] = Convert.ToInt32(input1[i]);\n }\n\n int[] sortedColumns = new int[columns];\n \n for (int i = 0; i < columns; i++) {\n int minTmp = int.MaxValue;\n int minTmpIndex = 0;\n for (int j = 0; j < columns; j++) {\n int actColumn = columnsInState1[j];\n if (actColumn < minTmp) {\n minTmp = actColumn;\n minTmpIndex = j;\n }\n }\n sortedColumns[i] = minTmp;\n columnsInState1[minTmpIndex] = int.MaxValue;\n }\n\n for (int i = 0; i < columns; i++) {\n Console.Write(sortedColumns[i]);\n Console.Write(' ');\n }\n Console.Write(Environment.NewLine);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["sortings", "implementation", "greedy"], "code_uid": "806c56066cc70d76de6e4716d4682868", "src_uid": "ae20712265d4adf293e75d016b4b82d8", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Text;\n\nnamespace Szzz\n{\n class Program\n {\n static void Main(string[] args)\n {\n string s = Console.ReadLine();\n\n int n = 0;\n\n foreach(char a in s)\n {\n if(a == 'a')\n {\n n++;\n }\n }\n if (n > s.Length / 2)\n {\n Console.WriteLine(s.Length);\n }\n else\n {\n Console.WriteLine(n * 2 - 1);\n }\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["strings", "implementation"], "code_uid": "36b2f398079312f25b29b6efdb86b177", "src_uid": "84cb9ad2ae3ba7e912920d7feb4f6219", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections;\nusing System.Collections.Generic;\nusing System.Linq;\n\nnamespace ConsoleApp2\n{\n class Program\n {\n static void Main(string[] args)\n {\n string s = Console.ReadLine();\n var a = s.Count(c => c == 'a');\n var res = a - 1;\n Console.WriteLine(Math.Min(s.Length, res + a));\n\n //int n = Convert.ToInt32(Console.ReadLine());\n //int k = 0;\n //for (int i = 1; i < n; i++)\n //{\n // if (n % i == 0)\n // k++;\n //}\n //Console.WriteLine(k);\n\n //string str = Console.ReadLine();\n //string[] s = str.Split(' ');\n\n //int a = Convert.ToInt32(s[0]);\n //int b = Convert.ToInt32(s[1]);\n //int i = 0;\n //while (a <= b)\n //{\n // a *= 3;\n // b *= 2;\n // i++;\n //}\n //Console.WriteLine(i);\n\n //string str = Console.ReadLine();\n //string[] s = str.Split(' ');\n\n //int n = Convert.ToInt32(s[0]);\n //int m = Convert.ToInt32(s[1]);\n //int k = Convert.ToInt32(s[2]);\n\n //if (m < n || k < n)\n //{\n // Console.WriteLine(\"No\");\n //}\n //else\n //{\n // Console.WriteLine(\"Yes\");\n //}\n\n\n //string str = Console.ReadLine();\n //string[] s = str.Split(' ');\n //int t = Convert.ToInt32(str);\n\n //string a = \"I hate\";\n //string b = \" that I love\";\n //string c = \" that I hate\";\n\n //for (int i = 0; i < t-1; i++)\n //{\n // if (i % 2 == 1)\n // {\n // a += c;\n // }\n // else if( i % 2 == 0)\n // {\n // a += b;\n // }\n //}\n // Console.WriteLine($\"{a} it\");\n\n\n\n //int n = Convert.ToInt32(Console.ReadLine());\n //int a = n % 2;\n //if (a == 0)\n //{\n // Console.WriteLine(\"Mahmoud\");\n //}\n //else\n //{\n // Console.WriteLine(\"Ehab\");\n //}\n\n //string str = Console.ReadLine();\n //string[] s = str.Split(' ');\n\n //int n = Convert.ToInt32(s[0]);\n //int k = Convert.ToInt32(s[1]);\n\n //int count = 0;\n //while (count < k)\n //{\n // if (n % 10 == 0)\n // {\n // n = n / 10;\n // }\n // else\n // {\n // n = n - 1;\n // }\n // count++;\n //}\n //Console.WriteLine(n);\n\n\n //string[] s = Console.ReadLine().Split(' ');\n //int x = int.Parse(s[0]);\n //int y = int.Parse(s[1]);\n //int z = int.Parse(s[2]);\n\n //if ((x + y >= z) && (y + z >= x) && (x + z >= y))\n //{\n // Console.WriteLine(\"YES\");\n //}\n //else\n //{\n // Console.WriteLine(\"NO\");\n //}\n\n //int x = Convert.ToInt32(Console.ReadLine());\n\n // int count = 0;\n\n // count += x / 100;\n // x %= 100;\n // count += x / 20;\n // x %= 20;\n // count += x / 10;\n // x %= 10;\n // count += x / 5;\n // x %= 5;\n // count += x;\n\n //Console.WriteLine(count);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["strings", "implementation"], "code_uid": "a07b43fc8f416d282eb2bd8cb0b112c5", "src_uid": "84cb9ad2ae3ba7e912920d7feb4f6219", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "namespace Problem1\n{\n\tusing System;\n\tusing System.Text;\n\tusing System.Linq;\n\n\tpublic static class Program\n\t{\n\t\tstatic void Main(string[] args)\n\t\t{\n\t\t\t// Cases\n\t\t\t// d1, d3, d2\n\t\t\t// d1, d3, d3, d1\n\t\t\t// d2, d3, d3, d2\n\t\t\t// d1, d1, d2, d2\n\t\t\t\n\t\t\tint[] l = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();\n\n\t\t\tConsole.WriteLine(new[]\n\t\t\t{\n\t\t\t\tl[0] + l[2] + l[1],\n\t\t\t\tl[0] + l[2] + l[2] + l[0],\n\t\t\t\tl[1] + l[2] + l[2] + l[1],\n\t\t\t\tl[0] + l[0] + l[1] + l[1],\n\t\t\t}\n\t\t\t.Min());\n\t\t}\n\t}\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "ae1312b66e3cfcbcb049879a4182bdc3", "src_uid": "26cd7954a21866dbb2824d725473673e", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Linq;\npublic class CF\n{\n public static void Main()\n {\n var ds = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();\n int d1 = ds[0];\n int d2 = ds[1];\n int d3 = ds[2];\n int p1 = d1 + d1 + d2 + d2;\n int p2 = d1 + d1 + d3 + d3;\n int p3 = d2 + d2 + d3 + d3;\n int p4 = d1 + d2 + d3;\n Console.Write(Math.Min(Math.Min(Math.Min(p1,p2),p3),p4));\n //Console.ReadKey();\n }\n}", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "254fad390ccfdb34d4f5753c3fe48c27", "src_uid": "26cd7954a21866dbb2824d725473673e", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Linq;\n\nnamespace CSharp\n{\n public class _478C\n {\n public static void Main()\n {\n long[] counts = Console.ReadLine().Split().Select(token => long.Parse(token)).ToArray();\n\n long sum = counts.Sum();\n long max = counts.Max();\n\n Console.WriteLine(2 * sum >= 3 * max ? sum / 3 : sum - max);\n }\n }\n}", "lang_cluster": "C#", "tags": ["greedy"], "code_uid": "206f041123b959b1be6e5aa766c487de", "src_uid": "bae7cbcde19114451b8712d6361d2b01", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Globalization;\nusing System.IO;\nusing System.Linq;\n\n// (\u3065\u00b0\u03c9\u00b0)\u3065\uff90\u2605\u309c\u30fb\u3002\u3002\u30fb\u309c\u309c\u30fb\u3002\u3002\u30fb\u309c\u2606\u309c\u30fb\u3002\u3002\u30fb\u309c\u309c\u30fb\u3002\u3002\u30fb\u309c\npublic class Solver\n{\n public object Solve()\n {\n var a = ReadLongArray();\n Array.Sort(a);\n long x = Math.Min(a[2] - a[1], a[0]);\n a[1] += x;\n a[0] -= x;\n\n a[1] += a[0] / 2;\n a[2] += (a[0] + 1) / 2;\n\n return Math.Min(a[1], (a[1] + a[2]) / 3);\n\n return null;\n }\n\n #region Main\n\n protected static TextReader reader;\n protected static TextWriter writer;\n\n static void Main()\n {\n#if DEBUG\n reader = new StreamReader(\"..\\\\..\\\\input.txt\");\n writer = Console.Out;\n //writer = new StreamWriter(\"..\\\\..\\\\output.txt\");\n#else\n reader = new StreamReader(Console.OpenStandardInput());\n writer = new StreamWriter(Console.OpenStandardOutput());\n// reader = new StreamReader(\"army.in\");\n// writer = new StreamWriter(\"army.out\");\n#endif\n try\n {\n object result = new Solver().Solve();\n if (result != null)\n writer.WriteLine(result);\n }\n catch (Exception ex)\n {\n#if DEBUG\n Console.WriteLine(ex);\n#else\n Console.WriteLine(ex);\n throw;\n#endif\n }\n reader.Close();\n writer.Close();\n }\n\n #endregion\n\n #region Read / Write\n\n private static Queue currentLineTokens = new Queue();\n\n private static string[] ReadAndSplitLine()\n {\n return reader.ReadLine().Split(new[] { ' ', '\\t' }, StringSplitOptions.RemoveEmptyEntries);\n }\n\n public static string ReadToken()\n {\n while (currentLineTokens.Count == 0)\n currentLineTokens = new Queue(ReadAndSplitLine());\n return currentLineTokens.Dequeue();\n }\n\n public static int ReadInt()\n {\n return int.Parse(ReadToken());\n }\n\n public static long ReadLong()\n {\n return long.Parse(ReadToken());\n }\n\n public static double ReadDouble()\n {\n return double.Parse(ReadToken(), CultureInfo.InvariantCulture);\n }\n\n public static int[] ReadIntArray()\n {\n return ReadAndSplitLine().Select(int.Parse).ToArray();\n }\n\n public static long[] ReadLongArray()\n {\n return ReadAndSplitLine().Select(long.Parse).ToArray();\n }\n\n public static double[] ReadDoubleArray()\n {\n return ReadAndSplitLine().Select(s => double.Parse(s, CultureInfo.InvariantCulture)).ToArray();\n }\n\n public static int[][] ReadIntMatrix(int numberOfRows)\n {\n int[][] matrix = new int[numberOfRows][];\n for (int i = 0; i < numberOfRows; i++)\n matrix[i] = ReadIntArray();\n return matrix;\n }\n\n public static int[][] ReadAndTransposeIntMatrix(int numberOfRows)\n {\n int[][] matrix = ReadIntMatrix(numberOfRows);\n int[][] ret = new int[matrix[0].Length][];\n for (int i = 0; i < ret.Length; i++)\n {\n ret[i] = new int[numberOfRows];\n for (int j = 0; j < numberOfRows; j++)\n ret[i][j] = matrix[j][i];\n }\n return ret;\n }\n\n public static string[] ReadLines(int quantity)\n {\n string[] lines = new string[quantity];\n for (int i = 0; i < quantity; i++)\n lines[i] = reader.ReadLine().Trim();\n return lines;\n }\n\n public static void WriteArray(IEnumerable array)\n {\n writer.WriteLine(string.Join(\" \", array));\n }\n\n public static void Write(params T[] array)\n {\n WriteArray(array);\n }\n\n public static void WriteLines(IEnumerable array)\n {\n foreach (var a in array)\n writer.WriteLine(a);\n }\n\n #endregion\n}", "lang_cluster": "C#", "tags": ["greedy"], "code_uid": "ea917798354a3a9fe6e0d0e9cf8f2816", "src_uid": "bae7cbcde19114451b8712d6361d2b01", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace CF_399A\n{\n class Program\n {\n static void Main()\n {\n int n, p, k;\n var input = Console.ReadLine().Split(' ');\n n = int.Parse(input[0]);\n p = int.Parse(input[1]);\n k = int.Parse(input[2]);\n string output = \"\";\n if (p > n || p < 1)\n {\n return;\n }\n if (p > k + 1)\n {\n output += \"<< \";\n for(int i= p - k; i < p; i++)\n {\n output += i + \" \";\n }\n\n }\n else\n {\n for (int i = 1; i < p; i++)\n {\n output += i + \" \";\n }\n }\n\n output += $\"({p})\";\n\n if(p < n - k)\n {\n for (int i = p+1; i <= p+k; i++)\n {\n output += \" \" + i;\n }\n output += \" >>\";\n }\n else\n {\n for (int i = p+1; i <= n; i++)\n {\n output += \" \" + i;\n }\n }\n\n Console.WriteLine(output);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "d9cf5e46fcf41a948a89ea4971255562", "src_uid": "526e2cce272e42a3220e33149b1c9c84", "difficulty": null, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Globalization;\nusing System.IO;\nusing System.Text;\n\nnamespace Pages\n{\n internal class Program\n {\n private static readonly StreamReader reader = new StreamReader(Console.OpenStandardInput(1024*10), Encoding.ASCII, false, 1024*10);\n private static readonly StreamWriter writer = new StreamWriter(Console.OpenStandardOutput(1024*10), Encoding.ASCII, 1024*10);\n\n private static void Main(string[] args)\n {\n int n = Next();\n int p = Next();\n int k = Next();\n\n int first = p - k;\n bool ok = false;\n if (first > 1)\n {\n writer.Write(\"<<\");\n ok = true;\n }\n for (int i = Math.Max(1, first); i < p; i++)\n {\n if (ok)\n writer.Write(' ');\n writer.Write(i);\n ok = true;\n }\n\n if (ok)\n writer.Write(' ');\n writer.Write('(');\n writer.Write(p);\n writer.Write(')');\n\n first = Math.Min(n, p + k);\n for (int i = p + 1; i <= first; i++)\n {\n writer.Write(' ');\n writer.Write(i);\n }\n\n if (first!=n)\n {\n writer.Write(\" >>\");\n }\n \n writer.Flush();\n }\n\n private static int Next()\n {\n int c;\n int res = 0;\n do\n {\n c = reader.Read();\n if (c == -1)\n return res;\n } while (c < '0' || c > '9');\n res = c - '0';\n while (true)\n {\n c = reader.Read();\n if (c < '0' || c > '9')\n return res;\n res *= 10;\n res += c - '0';\n }\n }\n }\n}", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "ef4e7062ed2d6743c50fff0483b7f6dd", "src_uid": "526e2cce272e42a3220e33149b1c9c84", "difficulty": null, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "#define Online\n\nusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Numerics;\nusing System.Text;\nusing System.IO;\nusing System.Threading;\n\nnamespace CF\n{\n delegate double F(double x);\n delegate decimal Fdec(decimal x);\n\n\n class Program\n {\n\n static void Main(string[] args)\n {\n\n#if FileIO\n StreamReader sr = new StreamReader(\"input.txt\");\n StreamWriter sw = new StreamWriter(\"output.txt\");\n Console.SetIn(sr);\n Console.SetOut(sw);\n#endif\n\n A();\n\n#if Online\n Console.ReadLine();\n#endif\n\n#if FileIO\n sr.Close();\n sw.Close();\n#endif\n }\n\n static void A()\n {\n int n = ReadInt();\n if (n >= 0)\n {\n Console.WriteLine(n);\n }\n else\n {\n string _n = n.ToString();\n if (_n.Length == 3 && _n[2].Equals('0'))\n {\n Console.WriteLine(0);\n return;\n }\n if (_n[_n.Length - 1] >= _n[_n.Length - 2])\n {\n for (int i = 0; i < _n.Length - 1; i++)\n {\n Console.Write(_n[i]);\n }\n }\n else\n {\n for (int i = 0; i < _n.Length - 2; i++)\n {\n Console.Write(_n[i]);\n }\n Console.Write(_n[_n.Length - 1]);\n }\n }\n }\n\n static void B()\n {\n\n }\n\n static void C()\n {\n\n }\n\n static void D()\n {\n\n }\n\n static void E()\n {\n\n }\n\n static string[] ReadArray()\n {\n return Console.ReadLine().Split(' ');\n }\n\n static int ReadInt()\n {\n return int.Parse(Console.ReadLine());\n }\n\n static string ReadLine()\n {\n return Console.ReadLine();\n }\n }\n\n public static class MyMath\n {\n public static long BinPow(long a, long n, long mod)\n {\n long res = 1;\n while (n > 0)\n {\n if ((n & 1) == 1)\n {\n res = (res * a) % mod;\n }\n a = (a * a) % mod;\n n >>= 1;\n }\n return res;\n }\n\n public static long GCD(long a, long b)\n {\n while (b != 0) b = a % (a = b);\n return a;\n }\n\n public static int GCD(int a, int b)\n {\n while (b != 0) b = a % (a = b);\n return a;\n }\n\n public static long LCM(long a, long b)\n {\n return (a * b) / GCD(a, b);\n }\n\n public static int LCM(int a, int b)\n {\n return (a * b) / GCD(a, b);\n }\n }\n\n class Edge\n {\n public int a;\n public int b;\n public int w;\n\n public Edge(int a, int b, int w)\n {\n this.a = a;\n this.b = b;\n this.w = w;\n }\n }\n\n class Graph\n {\n public List[] g;\n public int[] color; //0-white, 1-gray, 2-black\n public int[] o; //open\n public int[] c; //close\n public int[] p;\n public int[] d;\n public List e;\n public Stack ans = new Stack();\n public Graph(int n)\n {\n g = new List[n + 1];\n for (int i = 0; i <= n; i++)\n g[i] = new List();\n color = new int[n + 1];\n o = new int[n + 1];\n c = new int[n + 1];\n p = new int[n + 1];\n d = new int[n + 1];\n }\n\n const int white = 0;\n const int gray = 1;\n const int black = 2;\n\n public bool DFS(int u, ref int time)\n {\n color[u] = gray;\n time++;\n o[u] = time;\n for (int i = 0; i < g[u].Count; i++)\n {\n int v = g[u][i];\n if (color[v] == gray)\n {\n return true;\n }\n if (color[v] == white)\n {\n p[v] = u;\n if (DFS(v, ref time)) return true;\n }\n }\n color[u] = black;\n ans.Push(u);\n c[u] = time;\n time++;\n return false;\n }\n }\n\n static class GraphUtils\n {\n const int white = 0;\n const int gray = 1;\n const int black = 2;\n\n public static void BFS(int s, Graph g)\n {\n Queue q = new Queue();\n q.Enqueue(s);\n while (q.Count != 0)\n {\n int u = q.Dequeue();\n for (int i = 0; i < g.g[u].Count; i++)\n {\n int v = g.g[u][i];\n if (g.color[v] == white)\n {\n g.color[v] = gray;\n g.d[v] = g.d[u] + 1;\n g.p[v] = u;\n q.Enqueue(v);\n }\n }\n g.color[u] = black;\n }\n }\n\n public static bool DFS(int u, ref int time, Graph g, Stack st)\n {\n g.color[u] = gray;\n time++;\n g.o[u] = time;\n for (int i = 0; i < g.g[u].Count; i++)\n {\n int v = g.g[u][i];\n if (g.color[v] == gray)\n {\n return true;\n }\n if (g.color[v] == white)\n {\n g.p[v] = u;\n if (DFS(v, ref time, g, st)) return true;\n }\n }\n g.color[u] = black;\n st.Push(u);\n g.c[u] = time;\n time++;\n return false;\n }\n\n public static void FordBellman(int u, Graph g)\n {\n int n = g.g.Length;\n for (int i = 0; i <= n; i++)\n {\n g.d[i] = int.MaxValue;\n g.p[i] = 0;\n }\n\n g.d[u] = 0;\n\n for (int i = 0; i < n - 1; i++)\n {\n for (int j = 0; j < g.e.Count; j++)\n {\n if (g.d[g.e[j].a] != int.MaxValue)\n {\n if (g.d[g.e[j].a] + g.e[j].w < g.d[g.e[j].b])\n {\n g.d[g.e[j].b] = g.d[g.e[j].a] + g.e[j].w;\n g.p[g.e[j].b] = g.e[j].a;\n }\n }\n }\n }\n }\n }\n\n static class ArrayUtils\n {\n public static int BinarySearch(int[] a, int val)\n {\n int left = 0;\n int right = a.Length - 1;\n int mid;\n\n while (left < right)\n {\n mid = left + ((right - left) >> 1);\n if (val <= a[mid])\n {\n right = mid;\n }\n else\n {\n left = mid + 1;\n }\n }\n\n if (a[left] == val)\n return left;\n else\n return -1;\n }\n\n public static double Bisection(F f, double left, double right, double eps)\n {\n double mid;\n while (right - left > eps)\n {\n mid = left + ((right - left) / 2d);\n if (Math.Sign(f(mid)) != Math.Sign(f(left)))\n right = mid;\n else\n left = mid;\n }\n return (left + right) / 2d;\n }\n\n\n public static decimal TernarySearchDec(Fdec f, decimal eps, decimal l, decimal r, bool isMax)\n {\n decimal m1, m2;\n while (r - l > eps)\n {\n m1 = l + (r - l) / 3m;\n m2 = r - (r - l) / 3m;\n if (f(m1) < f(m2))\n if (isMax)\n l = m1;\n else\n r = m2;\n else\n if (isMax)\n r = m2;\n else\n l = m1;\n }\n return r;\n }\n\n public static double TernarySearch(F f, double eps, double l, double r, bool isMax)\n {\n double m1, m2;\n while (r - l > eps)\n {\n m1 = l + (r - l) / 3d;\n m2 = r - (r - l) / 3d;\n if (f(m1) < f(m2))\n if (isMax)\n l = m1;\n else\n r = m2;\n else\n if (isMax)\n r = m2;\n else\n l = m1;\n }\n return r;\n }\n\n public static void Merge(T[] A, int p, int q, int r, T[] L, T[] R, Comparison comp)\n {\n for (int i = p; i <= q; i++)\n L[i] = A[i];\n for (int i = q + 1; i <= r; i++)\n R[i] = A[i];\n\n for (int k = p, i = p, j = q + 1; k <= r; k++)\n {\n if (i > q)\n {\n for (; k <= r; k++, j++)\n A[k] = R[j];\n return;\n }\n if (j > r)\n {\n for (; k <= r; k++, i++)\n A[k] = L[i];\n return;\n }\n if (comp(L[i], R[j]) <= 0)\n {\n A[k] = L[i];\n i++;\n }\n else\n {\n A[k] = R[j];\n j++;\n }\n }\n }\n\n public static void Merge_Sort(T[] A, int p, int r, T[] L, T[] R, Comparison comp)\n {\n if (p >= r) return;\n int q = p + ((r - p) >> 1);\n Merge_Sort(A, p, q, L, R, comp);\n Merge_Sort(A, q + 1, r, L, R, comp);\n Merge(A, p, q, r, L, R, comp);\n }\n\n public static void Merge(T[] A, int p, int q, int r, T[] L, T[] R) where T : IComparable\n {\n for (int i = p; i <= q; i++)\n L[i] = A[i];\n for (int i = q + 1; i <= r; i++)\n R[i] = A[i];\n\n for (int k = p, i = p, j = q + 1; k <= r; k++)\n {\n if (i > q)\n {\n for (; k <= r; k++, j++)\n A[k] = R[j];\n return;\n }\n if (j > r)\n {\n for (; k <= r; k++, i++)\n A[k] = L[i];\n return;\n }\n if (L[i].CompareTo(R[j]) <= 0)\n {\n A[k] = L[i];\n i++;\n }\n else\n {\n A[k] = R[j];\n j++;\n }\n }\n }\n\n public static void Merge_Sort(T[] A, int p, int r, T[] L, T[] R) where T : IComparable\n {\n if (p >= r) return;\n int q = p + ((r - p) >> 1);\n Merge_Sort(A, p, q, L, R);\n Merge_Sort(A, q + 1, r, L, R);\n Merge(A, p, q, r, L, R);\n }\n\n static void Shake(T[] a)\n {\n Random rnd = new Random(Environment.TickCount);\n T temp;\n int b, c;\n for (int i = 0; i < a.Length; i++)\n {\n b = rnd.Next(0, a.Length);\n c = rnd.Next(0, a.Length);\n temp = a[b];\n a[b] = a[c];\n a[c] = temp;\n }\n }\n }\n}", "lang_cluster": "C#", "tags": ["implementation", "number theory"], "code_uid": "c83aee0531f0909e33c20cad1121ea52", "src_uid": "4b0a8798a6d53351226d4f06e3356b1e", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\n\nnamespace SolvingAlgorithms\n{\n class Program\n {\n static void Main(string[] args)\n {\n String input = Console.ReadLine();\n long inp = Convert.ToInt64(input);\n long output = 0;\n Char[] inpC = new Char[input.Length];\n for (int i = 0; i < inpC.Length; i++)\n {\n inpC[i] = input[i];\n }\n\n if (inp > 0)\n {\n output = inp;\n }\n else if (inp >= -10)\n {\n output = 0;\n }\n else\n {\n int q= input.Length;\n int a = Convert.ToInt32(input.Remove(q - 1,1));\n int b = Convert.ToInt32(input.Remove(q - 2,1));\n if (a > b)\n {\n output = a;\n }\n else\n output = b;\n\n }\n\n Console.WriteLine(output);\n \n\n \n }\n }\n}", "lang_cluster": "C#", "tags": ["implementation", "number theory"], "code_uid": "ed4154655dc9bc5447e7b1ecfb485c9b", "src_uid": "4b0a8798a6d53351226d4f06e3356b1e", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Linq;\nusing System.Collections.Generic;\nusing System.Text;\n\nnamespace CodeForces.PRACTICE\n{\n // Vanya and Books (implementation, math)\n class _552B\n {\n public static long NumberOfDigits(int n)\n {\n long num = n, res = 0, p = 1, len = 1;\n while (num > 9) { res += 9 * p * len; num /= 10; p *= 10; len++; }\n res += (n - p + 1) * len;\n return res;\n }\n\n // !!!\n public static long NumberOfDigitsNew(int n)\n {\n long res = 0;\n for (long i = 1; i <= n; i *= 10)\n res += n - i + 1;\n return res;\n }\n\n static void Main(string[] args)\n {\n int n = int.Parse(Console.ReadLine());\n Console.WriteLine(NumberOfDigitsNew(n));\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "implementation"], "code_uid": "2e1e66c652302c07851f400062c27a08", "src_uid": "4e652ccb40632bf4b9dd95b9f8ae1ec9", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Collections;\nusing System.Linq;\nusing System.Text;\nusing System.IO;\n\n\nnamespace ConsoleApplication1\n{\n class Program\n {\n static long N, cnt_dig, cnt = 1;\n\n\n public static void Main()\n {\n N = Convert.ToInt32(Console.ReadLine());\n\n\n for (int i = 1; i <= 1000000000; i*=10)\n {\n if (N < i)\n break;\n\n else if (N >= i && N < i * 10)\n cnt_dig += (N - i + 1) * cnt;\n\n else if (N >= i * 10)\n cnt_dig += (i * 10 - i) * cnt;\n\n ++cnt;\n }\n\n\n Console.WriteLine(cnt_dig);\n // Console.ReadKey();\n }\n }\n\n}\n\n", "lang_cluster": "C#", "tags": ["math", "implementation"], "code_uid": "06eb710f49ec7d2bed64ed75e13068a9", "src_uid": "4e652ccb40632bf4b9dd95b9f8ae1ec9", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeff#region imports\nusing System;\nusing System.Collections.Generic;\nusing System.ComponentModel;\nusing System.Diagnostics;\nusing System.Globalization;\nusing System.IO;\nusing System.Linq;\nusing System.Numerics;\nusing System.Runtime.CompilerServices;\nusing System.Runtime.InteropServices;\n\n#endregion\n\nnamespace CodeForces\n{\n class Problem\n {\n const bool IsContest = true;\n\n private void Solve()\n {\n var length = _.NextInt();\n var sum = _.NextInt();\n _.WriteLine(MinNumber(length, sum) + \" \" + MaxNumber(length, sum));\n\n }\n\n private string MaxNumber(int length, int sum)\n {\n if (sum == 0)\n {\n return length == 1 ? \"0\" : \"-1\";\n }\n\n var maxSum = length * 9;\n if (sum > maxSum) return \"-1\";\n var ans = \"\";\n \n\n while (sum > 0)\n {\n var t = Math.Min(sum, 9);\n ans += t;\n sum -= t;\n }\n return ans.PadRight(length, '0');\n }\n\n private string MinNumber(int length, int sum)\n {\n if (sum == 0)\n {\n return length == 1 ? \"0\" : \"-1\";\n }\n\n var maxSum = length * 9;\n if (sum > maxSum) return \"-1\";\n\n\n var ans = \"\";\n var mustBreak = false;\n while (sum > 0 && !mustBreak)\n {\n var t = Math.Min(sum, 9);\n if (sum - t == 0 && length > 1)\n {\n t--;\n mustBreak = true;\n }\n ans = t + ans;\n length--;\n sum -= t;\n }\n while (length > 1)\n {\n ans = '0' + ans;\n length--;\n }\n if (sum > 0)\n {\n ans = sum + ans;\n }\n return ans;\n }\n\n #region shit\n private readonly InOut _ = new InOut(IsContest);\n static void Main(string[] args)\n {\n var p = new Problem();\n p.Solve();\n p._.Close();\n }\n }\n class InOut\n {\n private const string InputFile = \"input.txt\";\n private const string OutputFile = \"output.txt\";\n public StreamWriter Cout { get; private set; }\n public StreamReader Cin { get; private set; }\n private void SetConsoleIo()\n {\n Cin = new StreamReader(new BufferedStream(Console.OpenStandardInput()));\n Cout = new StreamWriter(new BufferedStream(Console.OpenStandardOutput()));\n }\n private void SetFileIo(string inputFile, string outputFile) { Cin = new StreamReader(inputFile); Cout = new StreamWriter(outputFile); }\n public InOut() { SetConsoleIo(); }\n public InOut(string inputFile, string outputFile) { SetFileIo(inputFile, outputFile); }\n public InOut(bool isContest) { if (isContest) SetConsoleIo(); else SetFileIo(InputFile, OutputFile); }\n public void WriteLine(object x) { Cout.WriteLine(x); }\n public void Close() { Cin.Close(); Cout.Close(); }\n public void WriteLine(string format, params object[] args) { Cout.WriteLine(format, args); }\n private int _pos;\n private string[] _tokens;\n\n private string[] NextStringArray() { return Cin.ReadLine().Split(\" \\t\".ToCharArray(), StringSplitOptions.RemoveEmptyEntries); }\n public string NextToken()\n {\n while (_tokens == null || _pos == _tokens.Length)\n {\n // ReSharper disable once PossibleNullReferenceException\n _tokens = NextStringArray();\n _pos = 0;\n }\n return _tokens[_pos++];\n }\n public int NextInt() { return int.Parse(NextToken()); }\n public long NextLong() { return long.Parse(NextToken()); }\n public double NextDouble() { return double.Parse(NextToken(), CultureInfo.InvariantCulture); }\n public int[] NextIntArray() { return NextStringArray().Select(int.Parse).ToArray(); }\n public long[] NextLongArray() { return NextStringArray().Select(long.Parse).ToArray(); }\n #endregion\n }\n}", "lang_cluster": "C#", "tags": ["greedy", "dp", "implementation"], "code_uid": "e4650a8855ad7680671e4caf35391a33", "src_uid": "75d062cece5a2402920d6706c655cad7", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\n\nnamespace \u0434\u043b\u0438\u043d\u0430_\u0438_\u0441\u0443\u043c\u043c\u0430\n{\n class Program\n {\n static int numberLength;\n static int symbolsSum;\n\n static void Main(string[] args)\n {\n string str = Console.ReadLine();\n string[] strArr = str.Split(' ');\n numberLength = int.Parse(strArr[0]); // \u0414\u043b\u0438\u043d\u0430 \u0447\u0438\u0441\u043b\u0430\n symbolsSum = int.Parse(strArr[1]); // \u0421\u0443\u043c\u043c\u0430 \u0446\u0438\u0444\u0440\n\n Console.WriteLine(GetMin() + \" \" + GetMaximum());\n /*\n 100\n n = 3 \u041d\u0443\u043b\u0435\u0439 = n - 1\n s = 15\n 10059 -> 90000 \n */\n // 10059\n }\n\n static string GetMin()\n {\n // 1 0\n if (numberLength == 1 && symbolsSum == 0)\n return \"0\";\n\n if (9 * numberLength < symbolsSum || symbolsSum == 0)\n {\n return \"-1\";\n }\n // 5 \n // 3\n\n // 30000\n int[] symbols = new int[numberLength];\n\n int currentSymbolsSum = symbolsSum;\n\n int i = numberLength - 1;\n // 3 0\n for (; i >= 0; i--)\n {\n if (currentSymbolsSum > 9)\n {\n symbols[i] = 9;\n currentSymbolsSum -= symbols[i];\n }\n else\n {\n symbols[i] = currentSymbolsSum;\n break;\n }\n }\n if (symbols[0] == 0)\n {\n symbols[0] = 1;\n symbols[i] = symbols[i] - 1;\n }\n\n return string.Join(\"\", symbols);\n }\n\n static string GetMaximum()\n {\n if (numberLength == 1 && symbolsSum == 0)\n return \"0\";\n\n if (9 * numberLength < symbolsSum || symbolsSum == 0)\n {\n return \"-1\";\n }\n int[] symbols = new int[numberLength];\n // symbols[0] = 9. symbols[1] = 0. symbols[2] = 0\n // numberLength = 3\n // currentSymbolsSum = 25\n // 960\n // currentSymbolsSum = 6\n int currentSymbolsSum = symbolsSum;\n for (int i = 0; i < numberLength; i++)\n {\n if (currentSymbolsSum >= 9)\n {\n symbols[i] = 9;\n currentSymbolsSum -= symbols[i];\n }\n else\n {\n symbols[i] = currentSymbolsSum;\n break;\n }\n }\n return string.Join(\"\", symbols);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["greedy", "dp", "implementation"], "code_uid": "79722c02158f7421ec1ac3d5f2cdcd68", "src_uid": "75d062cece5a2402920d6706c655cad7", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\n\nnamespace ConsoleApp1\n{\n class Program\n {\n static void Main(string[] args)\n {\n int n = Convert.ToInt32(Console.ReadLine());\n int k = 0;\n for (int i = 1; i <= n/2; i++)\n {\n if ( (n - i) % i == 0)\n {\n k++;\n }\n }\n\n\n\n Console.WriteLine(k);\n }\n }\n}", "lang_cluster": "C#", "tags": ["brute force", "implementation"], "code_uid": "636adaa9a2a79e64b5270fd10132efcb", "src_uid": "89f6c1659e5addbf909eddedb785d894", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\n\nclass A935 {\n public static void Main() {\n var n = int.Parse(Console.ReadLine());\n Console.WriteLine(Divisor.Of(n, new OpsInt()).Count() - 1);\n }\n\n // Snippet: Divisor\n class Divisor {\n public static IEnumerable Of(T n, IOps ops) {\n var i = ops.One();\n for (; ops.Less(ops.Mul(i, i), n); i = ops.Inc(i))\n if (ops.IsZero(ops.Mod(n, i))) {\n yield return i;\n yield return ops.Div(n, i);\n }\n if (ops.Eq(ops.Mul(i, i), n)) yield return i;\n }\n }\n\n // Snippet: IOps\n interface IOps {\n T From(int a);\n T Zero();\n T One();\n T MinusOne();\n T MinValue();\n T MaxValue();\n\n bool IsEven(T a);\n bool IsOne(T a);\n bool IsZero(T a);\n int Sign(T a);\n\n T Inc(T a);\n T Dec(T a);\n T Abs(T a);\n T Add(T a1, T a2);\n T Sub(T a1, T a2);\n T Mul(T a1, T a2);\n T Div(T a1, T a2);\n T Mod(T a1, T a2);\n T Shl(T a1, int a2);\n T Shr(T a1, int a2);\n T Max(T a1, T a2);\n T Min(T a1, T a2);\n\n bool Less(T a1, T a2);\n bool Eq(T a1, T a2);\n }\n\n // Snippet: OpsInt\n class OpsInt : IOps {\n public int From(int a) { return a; }\n public int Zero() { return 0; }\n public int One() { return 1; }\n public int MinusOne() { return -1; }\n public int MinValue() { return int.MinValue; }\n public int MaxValue() { return int.MaxValue; }\n\n public bool IsEven(int a) { return (a & 1) == 0; }\n public bool IsOne(int a) { return a == 1; }\n public bool IsZero(int a) { return a == 0; }\n public int Sign(int a) { return a; }\n\n public int Inc(int a) { return a + 1; }\n public int Dec(int a) { return a - 1; }\n public int Abs(int a) { return Math.Abs(a); }\n public int Add(int a1, int a2) { return a1 + a2; }\n public int Sub(int a1, int a2) { return a1 - a2; }\n public int Mul(int a1, int a2) { return a1 * a2; }\n public int Div(int a1, int a2) { return a1 / a2; }\n public int Mod(int a1, int a2) { return a1 % a2; }\n public int Shl(int a1, int a2) { return a1 << a2; }\n public int Shr(int a1, int a2) { return a2 >> a2; }\n public int Max(int a1, int a2) { return Math.Max(a1, a2); }\n public int Min(int a1, int a2) { return Math.Min(a1, a2); }\n\n public bool Less(int a1, int a2) { return a1 < a2; }\n public bool Eq(int a1, int a2) { return a1 == a2; }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "implementation"], "code_uid": "82eefbdcde5631a16382e61e36bc2abb", "src_uid": "89f6c1659e5addbf909eddedb785d894", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeff\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\nusing System.Text.RegularExpressions;\nusing System.IO;\nusing System.Numerics;\nusing System.Globalization;\nusing System.Threading;\n\n\nnamespace probleme {\n class Program {\n static void Main(string[] args) {\n\n //Console.SetIn(new StreamReader(\"file.in\"));\n /*\n FileStream filestream = new FileStream(\"out.txt\", FileMode.Create);\n var streamwriter = new StreamWriter(filestream);\n streamwriter.AutoFlush = true;\n Console.SetOut(streamwriter);\n */\n\n int n = int.Parse(Console.ReadLine());\n int[] v = Array.ConvertAll(Console.ReadLine().Split(' '), ts => int.Parse(ts));\n Array.Sort(v);\n int aux = v[0];\n v[0] = v[n - 1];\n v[n - 1] = aux;\n for (int i = 0; i < n; i++) {\n Console.Write(\"{0} \", v[i]);\n }\n\n //Console.ReadKey();\n }\n }\n}", "lang_cluster": "C#", "tags": ["sortings", "constructive algorithms", "implementation"], "code_uid": "076bcdca4b9561aeda7bc001f3bfeb10", "src_uid": "4408eba2c5c0693e6b70bdcbe2dda2f4", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\n\nnamespace CodeForces\n{\n class DifferenceRow\n {\n static void Main()\n {\n Run();\n }\n static void Run()\n {\n int n = int.Parse(Console.ReadLine());\n string[] str = Console.ReadLine().Split();\n List p = new List();\n for (int i = 0; i < n; i++)\n {\n int num = int.Parse(str[i]);\n p.Add(num);\n }\n p.Sort();\n int pCount = p.Count;\n StringBuilder sb = new StringBuilder();\n sb.AppendFormat(\"{0} \", p.Last());\n for (int i = 1; i < pCount - 1; i++)\n sb.AppendFormat(\"{0} \", p[i]);\n sb.AppendFormat(\"{0} \", p.First());\n Console.WriteLine(sb.ToString().TrimEnd());\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["sortings", "constructive algorithms", "implementation"], "code_uid": "e6463f53d90d2697df87611783dfeaff", "src_uid": "4408eba2c5c0693e6b70bdcbe2dda2f4", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Linq;\n\nnamespace CodeForce1\n{\n class Program\n {\n static void Main(string[] args)\n {\n string matrix = Console.ReadLine();\n matrix = new string(matrix.Distinct().ToArray());\n if (matrix.Length % 2 != 0)\n {\n Console.WriteLine(\"IGNORE HIM!\");\n }\n else\n {\n Console.WriteLine(\"CHAT WITH HER!\");\n }\n Console.Read();\n }\n }\n}", "lang_cluster": "C#", "tags": ["brute force", "strings", "implementation"], "code_uid": "304813608d69146e5bbeb63c13ee5e5a", "src_uid": "a8c14667b94b40da087501fd4bdd7818", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\n\nclass Program\n{\n static bool Identification(string line)\n {\n int[] arr = new int['z' - 'a' + 1];\n int count = 0;\n for (int i = 0; i < line.Length; i++)\n if (arr[line[i] - 'a'] != 1)\n {\n arr[line[i] - 'a'] = 1;\n count++;\n }\n if (count % 2 == 1)\n return false;\n else\n return true;\n }\n\n static void Main()\n {\n if (Identification(Console.ReadLine()))\n Console.WriteLine(\"CHAT WITH HER!\");\n else\n Console.WriteLine(\"IGNORE HIM!\");\n\n }\n}", "lang_cluster": "C#", "tags": ["brute force", "strings", "implementation"], "code_uid": "376cef104cbf6e39079c2ba9cd08b734", "src_uid": "a8c14667b94b40da087501fd4bdd7818", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace A.Greg_s_Workout\n{\n class Program\n {\n static void Main(string[] args)\n {\n int n = int.Parse(Console.ReadLine());\n int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();\n int chest = 0;\n int biceps = 0;\n int back = 0;\n for(int i=0;i li = new List();\n li.Add(chest); li.Add(biceps); li.Add(back);\n li.Sort();\n if(li[2]==chest)\n {\n Console.WriteLine(\"chest\");\n }\n else if (li[2] == back)\n {\n Console.WriteLine(\"back\");\n }\n else if (li[2] == biceps)\n {\n Console.WriteLine(\"biceps\");\n }\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "6fc34e67a8d815a14af3e501c7ae6561", "src_uid": "579021de624c072f5e0393aae762117e", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.IO;\nusing System.Linq;\n\nclass Program\n{\n static char[] SPACE = new[] { ' ' };\n\n static void Main(string[] args)\n {\n#if DEBUG\n using (var input = new StreamReader(\"input.txt\"))\n using (var output = new StreamWriter(\"output.txt\"))\n {\n Console.SetIn(input);\n Console.SetOut(output);\n\n int n = 0;\n do\n {\n Console.WriteLine();\n Console.WriteLine(\"Sample {0}\", ++n);\n Prog();\n } while (Console.ReadLine() == string.Empty);\n }\n#else\n Prog();\n#endif\n }\n\n static int __ptr = 0;\n static string[] __input;\n static int NextInt()\n {\n return int.Parse(__input[__ptr++]);\n }\n static long NextLong()\n {\n return long.Parse(__input[__ptr++]);\n }\n static void ReadTokens(int n)\n {\n __ptr = 0;\n __input = Console.ReadLine().Split(SPACE, n);\n }\n\n //\n\n static void Prog()\n {\n ReadTokens(1);\n int n = NextInt();\n\n int[] r = new int[3];\n\n ReadTokens(n);\n for (int i = 0; i < n; i++)\n r[i % 3] += NextInt();\n\n int max = Math.Max(Math.Max(r[0], r[1]), r[2]);\n if (max == r[0]) Console.WriteLine(\"chest\");\n else if (max == r[1]) Console.WriteLine(\"biceps\");\n else if (max == r[2]) Console.WriteLine(\"back\");\n }\n\n}\n\n\n\n\n\n\n\n\n\n\n\n\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "9c7b676db0c2ee6e6a68412b0e3fb203", "src_uid": "579021de624c072f5e0393aae762117e", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": ".NET Core C#", "source_code": "using System;\n\nnamespace NearlyLuckyNumber\n{\n class Program\n {\n static void Main(string[] args)\n {\n string line = Console.ReadLine();\n\n int luckyCounters = 0;\n\n for (int i = 0; i < line.Length; i++)\n {\n if (line[i] == '4' || line[i] == '7')\n {\n luckyCounters++;\n }\n }\n\n string luckyString = luckyCounters.ToString();\n int j = 0;\n\n while (j < luckyString.Length && (luckyString[j] == '4' || luckyString[j] == '7'))\n {\n j++;\n }\n\n if (j < luckyString.Length)\n {\n Console.WriteLine(\"NO\");\n }\n else\n {\n Console.WriteLine(\"YES\");\n }\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "cf5a59af466124c3cd440de90b7120a6", "src_uid": "33b73fd9e7f19894ea08e98b790d07f1", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace Code\n{\n class Program\n {\n static void Main(string[] args)\n {\n string input = Console.ReadLine();\n bool flag = true;\n int count = 0;\n string count_str = \"\";\n for (int i = 0; i < input.Length; i++)\n {\n if (input[i].ToString() == \"7\" || input[i].ToString() == \"4\")\n count++;\n }\n count_str = count.ToString();\n\n for (int i = 0; i < count_str.Length; i++)\n {\n if (count_str[i].ToString() == \"7\" || count_str[i].ToString() == \"4\")\n flag = true;\n else\n {\n flag = false;\n break;\n }\n }\n\n if (flag)\n Console.WriteLine(\"YES\");\n else\n Console.WriteLine(\"NO\");\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "eddf9e06895a1c4c2bfcc164f075b81f", "src_uid": "33b73fd9e7f19894ea08e98b790d07f1", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\n\nnamespace C_Candies\n{\n class Program\n {\n static void Main(string[] args)\n {\n long n = long.Parse(Console.ReadLine());\n\n Console.WriteLine(binarySearch(n) + 1);\n }\n\n static long binarySearch(long total) {\n long low = 1;\n long high = total;\n\t\t while (low <= high) {\n\t\t\t long middle = (low + high) / 2;\n\n\t\t\t if (canEat(middle, total)) {\n\t\t\t\t high = middle - 1;\n\t\t\t }\n\t\t\t else {\n\t\t\t\t low = middle + 1;\n\t\t\t }\n\t\t }\n\n\t\t return high;\n\t }\n\n static bool canEat(long k, long total)\n {\n long eatenA = 0;\n long eatenB = 0;\n long current = total;\n\n while(current > 0)\n {\n eatenA += Math.Min(k, current);\n current = Math.Max(current - k, 0);\n eatenB += current / 10;\n current -= current / 10;\n }\n\n if(total % 2 == 0)\n {\n return eatenA >= total / 2;\n }\n else\n {\n return eatenA > total / 2;\n }\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["implementation", "binary search"], "code_uid": "1eb2e3642b64abfc1c3885d6f755ff49", "src_uid": "db1a50da538fa82038f8db6104d2ab93", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections;\nusing System.Collections.Generic;\nusing System.Diagnostics;\nusing System.Globalization;\nusing System.IO;\nusing System.Linq;\nusing System.Text;\n\nnamespace Task\n{\n class Program\n {\n #region Read / Write\n protected static TextReader reader;\n protected static TextWriter writer;\n private static Queue currentLineTokens = new Queue();\n private static string[] ReadAndSplitLine() { return reader.ReadLine().Split(new[] { ' ', '\\t', }, StringSplitOptions.RemoveEmptyEntries); }\n public static string ReadToken() { while (currentLineTokens.Count == 0) currentLineTokens = new Queue(ReadAndSplitLine()); return currentLineTokens.Dequeue(); }\n public static int ReadInt() { return int.Parse(ReadToken()); }\n public static long ReadLong() { return long.Parse(ReadToken()); }\n public static double ReadDouble() { return double.Parse(ReadToken(), CultureInfo.InvariantCulture); }\n public static int[] ReadIntArray() { return ReadAndSplitLine().Select(int.Parse).ToArray(); }\n public static long[] ReadLongArray() { return ReadAndSplitLine().Select(long.Parse).ToArray(); }\n public static double[] ReadDoubleArray() { return ReadAndSplitLine().Select(s => double.Parse(s, CultureInfo.InvariantCulture)).ToArray(); }\n public static int[][] ReadIntMatrix(int numberOfRows) { int[][] matrix = new int[numberOfRows][]; for (int i = 0; i < numberOfRows; i++) matrix[i] = ReadIntArray(); return matrix; }\n public static int[][] ReadAndTransposeIntMatrix(int numberOfRows)\n {\n int[][] matrix = ReadIntMatrix(numberOfRows); int[][] ret = new int[matrix[0].Length][];\n for (int i = 0; i < ret.Length; i++) { ret[i] = new int[numberOfRows]; for (int j = 0; j < numberOfRows; j++) ret[i][j] = matrix[j][i]; }\n return ret;\n }\n public static string[] ReadLines(int quantity) { string[] lines = new string[quantity]; for (int i = 0; i < quantity; i++) lines[i] = reader.ReadLine().Trim(); return lines; }\n public static void WriteArray(IEnumerable array) { writer.WriteLine(string.Join(\" \", array)); }\n public static void Write(params object[] array) { WriteArray(array); }\n public static void WriteLines(IEnumerable array) { foreach (var a in array) writer.WriteLine(a); }\n private class SDictionary : Dictionary\n {\n public new TValue this[TKey key]\n {\n get { return ContainsKey(key) ? base[key] : default(TValue); }\n set { base[key] = value; }\n }\n }\n private static T[] Init(int size) where T : new() { var ret = new T[size]; for (int i = 0; i < size; i++) ret[i] = new T(); return ret; }\n #endregion=\n\n public static bool NextPermutation(List perm)\n {\n for (int i = perm.Count - 2; i >= 0; i--)\n {\n if (perm[i] < perm[i + 1])\n {\n int min = i + 1;\n for (int j = min; j < perm.Count; j++)\n if (perm[j] > perm[i] && perm[j] < perm[min])\n min = j;\n\n int tmp = perm[i];\n perm[i] = perm[min];\n perm[min] = tmp;\n perm.Reverse(i + 1, perm.Count - i - 1);\n return true;\n }\n }\n\n return false;\n }\n\n public static long CalcEkler(long n, long k)\n {\n long ans = 0;\n while (n > 0)\n {\n long min = Math.Min(k, n);\n ans += min;\n n -= min;\n\n n -= n / 10;\n }\n\n return ans;\n }\n\n static void Main(string[] args)\n {\n long i = 0;\n long ans = 0;\n reader = new StreamReader(Console.OpenStandardInput());\n writer = new StreamWriter(Console.OpenStandardOutput());\n\n long n = ReadLong();\n long needEkler = n / 2 + (n & 1);\n\n long l = 1;\n long r = n;\n long k = n / 2;\n ans = k;\n do\n {\n k = (l + r) / 2;\n long calcedEkler = CalcEkler(n, k);\n if (calcedEkler >= needEkler)\n {\n ans = k;\n r = k - 1;\n }\n else\n {\n l = k + 1;\n }\n } while (l <= r);\n\n Write(ans);\n reader.Close();\n writer.Close();\n }\n }\n}", "lang_cluster": "C#", "tags": ["implementation", "binary search"], "code_uid": "b29dc141598a2b106616de9d905471fb", "src_uid": "db1a50da538fa82038f8db6104d2ab93", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace CodeForces\n{\n class Program\n {\n static void Main(string[] args)\n {\n string input = Console.ReadLine();\n string[] tokens = input.Split(' ');\n int x = int.Parse(tokens[0]);\n\n int output = 0;\n if (tokens[2] == \"week\")\n {\n if (x == 5 || x == 6)\n {\n output = 53;\n }\n else\n {\n output = 52;\n }\n }\n else\n {\n if (x <= 29)\n {\n output = 12;\n }\n else if (x == 30)\n {\n output = 11;\n }\n else\n {\n output = 7;\n }\n }\n\n Console.WriteLine(output);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "64e927399574b0423ac571fa2374f965", "src_uid": "9b8543c1ae3666e6c163d268fdbeef6b", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace Pr1\n{\n class Program\n {\n static void Main()\n {\n string[] a=Console.ReadLine().Split(' ');\n int n=Convert.ToInt32(a[0]);\n if(a[2]==\"week\")\n {\n if(n==5||n==6)\n Console.Write(53);\n else\n Console.Write(52);\n }\n else\n {\n if(n==30)\n Console.Write(11);\n else if(n==31)\n Console.Write(7);\n else\n Console.Write(12);\n }\n }\n }\n}", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "16ae710ae7e3fc289731aae67e5580cb", "src_uid": "9b8543c1ae3666e6c163d268fdbeef6b", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nclass Program\n {\n static void Main(string[] args)\n {\n int n = int.Parse(Console.ReadLine());\n Console.WriteLine(n / 3 * 2 + (n % 3 == 0 ? 0 : 1));\n }\n }", "lang_cluster": "C#", "tags": ["math"], "code_uid": "e9dd4d1cc79dfb41ab63b65cdbe42d8e", "src_uid": "a993069e35b35ae158d35d6fe166aaef", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\n\nnamespace _348_1\n{\n class Program\n {\n static void Main(string[] args)\n {\n int n = Convert.ToInt32(Console.ReadLine());\n int kol = 0;\n if (n == 2) Console.WriteLine(1);\n else\n {\n //if (n % 2 != 0) { kol++; n--; }\n while (n > 0)\n {\n n-=2;\n kol++;\n if (n > 0) { kol++; n --; }\n else break;\n }\n Console.WriteLine(kol);\n }\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math"], "code_uid": "a37ac2a9752539378f17cd8eb9720c22", "src_uid": "a993069e35b35ae158d35d6fe166aaef", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeff#if DEBUG\nusing System.Reflection;\nusing System.Threading.Tasks;\n#endif\n\nusing System;\nusing System.Collections.Generic;\nusing System.IO;\nusing System.Linq;\nusing System.Text;\nusing System.Numerics;\nusing System.Globalization;\n\n\nnamespace _10_c\n{\n class Program\n {\n static string _inputFilename = \"input.txt\";\n static string _outputFilename = \"output.txt\";\n static bool _useFileInput = false;\n\n\n static void Main(string[] args)\n {\n StreamWriter file = null;\n#if DEBUG\n\t\t\tConsole.SetIn(getInput());\n#else\n if (_useFileInput)\n {\n Console.SetIn(File.OpenText(_inputFilename));\n file = new StreamWriter(_outputFilename);\n Console.SetOut(file);\n }\n#endif\n\n try\n {\n solution();\n }\n finally\n {\n if (_useFileInput)\n {\n file.Close();\n }\n }\n }\n\n static void solution()\n {\n #region SOLUTION\n var n = readInt();\n var cs = new long[10];\n var vs = new long[n + 1];\n for (int i = 1; i < n + 1; i++)\n {\n vs[i] = getSum(i);\n cs[vs[i]]++;\n }\n\n var total = 0L;\n for (int i = 1; i < 10; i++)\n {\n for (int j = 1; j < 10; j++)\n {\n var next = getSum(i * j);\n var val = cs[i] * cs[j];\n //if (i == j)\n //{\n // val = cs[i] * cs[i - 1] / 2;\n //}\n\n if (val * cs[next] > 0)\n {\n total += val * cs[next];\n }\n \n }\n }\n\n //total += (cs[1] * (cs[1] - 1) / 2);\n //total += (cs[2] * cs[1]);\n //total += (cs[3] * cs[1]);\n //total += (cs[4] * cs[1] + cs[2] * (cs[2] - 1) / 2);\n //total += (cs[5] * cs[1]);\n //total += (cs[6] * cs[1] + cs[3] * cs[2]);\n //total += (cs[7] * cs[1]);\n //total += (cs[8] * cs[1] + cs[2] * cs[4]);\n //total += (cs[9] * cs[1] + cs[3] * (cs[3] - 1) / 2);\n\n var remc = 0L;\n for (int i = 1; i < n + 1; i++)\n {\n remc += n / i;\n }\n //for (int i = 1; i < n + 1; i++)\n //{\n // var end = (int)Math.Floor(Math.Sqrt(i));\n // for (int j = 1; j <= end; j++)\n // {\n // var rem = i % j;\n // var another = i / j;\n // if (rem == 0)\n // {\n // if (another == j)\n // {\n // remc++;\n // }\n // else\n // {\n // remc += 2;\n // }\n \n // }\n // }\n //}\n\n total -= remc;\n Console.WriteLine(total);\n\n //var n = readInt();\n //var m = readInt();\n\n //var a = readIntArray();\n //var b = readIntArray();\n #endregion\n }\n\n static int getSum(int a)\n {\n if (a < 10)\n {\n return a;\n }\n\n var val = a;\n var sum = 0;\n while (true)\n {\n sum += (val % 10);\n val /= 10;\n if (val == 0)\n {\n break;\n }\n }\n\n return getSum(sum);\n }\n\n static int readInt()\n {\n return int.Parse(Console.ReadLine());\n }\n\n static long readLong()\n {\n return long.Parse(Console.ReadLine());\n }\n\n static int[] readIntArray()\n {\n return Console.ReadLine().Split(' ').Where(i => !string.IsNullOrEmpty(i)).Select(i => int.Parse(i)).ToArray();\n }\n\n static long[] readLongArray()\n {\n return Console.ReadLine().Split(' ').Where(i => !string.IsNullOrEmpty(i)).Select(i => long.Parse(i)).ToArray();\n }\n\n#if DEBUG\n\t\tstatic StreamReader getInput()\n\t\t{\n\t\t\tvar resName = Assembly.GetCallingAssembly().GetManifestResourceNames()[0];\n\t\t\tvar resource = Assembly.GetCallingAssembly().GetManifestResourceStream(resName);\n\n\t\t\treturn new StreamReader(resource);\n\t\t}\n#endif\n }\n}\n", "lang_cluster": "C#", "tags": ["number theory"], "code_uid": "9b53bf678b82c487cc8433d0e6897960", "src_uid": "fc133fe6353089a0ebee08dec919f608", "difficulty": 2000.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\n\npublic class Solution {\n\n static int n;\n static int[] c;\n static int[] f;\n \n static int calc(int x) {\n if(x < 10) return x;\n else {\n int s = 0 ;\n while(x > 0) {\n s += x % 10;\n x /= 10;\n }\n return calc(s);\n }\n }\n \n public static void Main() {\n n = int.Parse(Console.ReadLine());\n c = new int[10];\n f = new int[1000];\n for(int i=1;i<1000;++i) f[i] = calc(i);\n for(int i=1;i<=n;++i) {\n int z = 0;\n if(i < 1000) z = f[i];\n else {\n int s = 0;\n int x = i;\n while(x > 0) {\n s += x % 10;\n x /= 10;\n }\n z = f[s];\n }\n ++c[z];\n }\n long res = 0;\n for(int i=1;i<10;++i) \n for(int j=1;j<10;++j) {\n res += (long)c[i] * c[j] * c[f[i*j]];\n }\n for(int i=1;i<=n;++i) {\n for(int j=1;i*j<=n;++j)\n --res;\n }\n Console.WriteLine(res);\n }\n}\n", "lang_cluster": "C#", "tags": ["number theory"], "code_uid": "b25e439ac9b5357da63bb89cce14bea2", "src_uid": "fc133fe6353089a0ebee08dec919f608", "difficulty": 2000.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Linq;\n\nnamespace CodeForces {\n class Program {\n static void Main (string[] args) {\n int n = int.Parse (Console.ReadLine ());\n\n int[] lucky = { 4, 7, 47, 74, 444, 474, 477, 744, 774 };\n if (lucky.Any (x => n % x == 0)) {\n System.Console.WriteLine (\"YES\");\n } else {\n System.Console.WriteLine (\"NO\");\n }\n\n }\n }\n}", "lang_cluster": "C#", "tags": ["brute force", "number theory"], "code_uid": "7f995c0f539dc14cf01bfed4da8b8061", "src_uid": "78cf8bc7660dbd0602bf6e499bc6bb0d", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "//Rextester.Program.Main is the entry point for your code. Don't change it.\n//Compiler version 4.0.30319.17929 for Microsoft (R) .NET Framework 4.5\n\nusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text.RegularExpressions;\n\nnamespace Rextester\n{\n public class Program\n {\n public static void Main(string[] args)\n {\n bool b = false , bb = false;\n\t\t\tstring s;\n\t\t\tint x; \n\t\t\ts = Console.ReadLine();\n\t\t\tx = int.Parse(s);\n\t\t\tif(x % 4 == 0 || x % 7 == 0 || x == 799 || x == 94|| x == 141)\n\t\t\t{\n\t\t\t\tConsole.WriteLine(\"YES\");\n\t\t\t\tbb = true;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n \t\t for(int i = 0 ; i < s.Length ; i++)\n \t\t\t{\n \t\t\t\tif(s[i] == '4' || s[i] == '7')\n \t\t\t\t\tcontinue;\n \t\t\t\telse\n \t\t\t\t{\n \t\t\t\t b = true;\n \t\t\t\t\tConsole.WriteLine(\"NO\");\n \t\t\t\t\tbreak;\n \t\t\t\t}\n \t\t\t}\n\t\t\t}\n if(b != true && bb == false)\n Console.WriteLine(\"YES\");\n \n }\n }\n}", "lang_cluster": "C#", "tags": ["brute force", "number theory"], "code_uid": "5370de2cba164e55a3b5ecd1897acd36", "src_uid": "78cf8bc7660dbd0602bf6e499bc6bb0d", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace ConsoleApp18\n{\n class Program\n {\n static void Main(string[] args)\n {\n int a = Convert.ToInt32(Console.ReadLine());\n string[] b = Console.ReadLine().Split(' ');\n int[] mass = new int[b.Length];\n\n for (int i = 0; i < b.Length; i++)\n {\n mass[i] = Convert.ToInt32(b[i]);\n }\n\n int sum = mass.Sum();\n int k = mass.Max();\n\n int newsum = 0;\n\n do\n {\n newsum = 0;\n for (int i = 0; i < mass.Length; i++)\n {\n if (k - mass[i] > 0)\n {\n newsum += k - mass[i];\n }\n }\n\n k++;\n } while (newsum <= sum);\n\n k--;\n Console.WriteLine(k);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "implementation"], "code_uid": "28e93e1be62393a8010716fd3fee7145", "src_uid": "d215b3541d6d728ad01b166aae64faa2", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace C\n{\n class Program\n {\n static void Main(string[] args)\n {\n int n = int.Parse(Console.ReadLine());\n int k = 0, a;\n int AU = 0, AL = 0;\n string[] s = Console.ReadLine().Split(' ');\n for (int i = 0; i < n; i++)\n {\n a = int.Parse(s[i]);\n if (a > k)\n k = a;\n AL += a;\n }\n AU = k * n - AL;\n while(AU<=AL)\n {\n k++;\n AU += n;\n }\n Console.WriteLine(k);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "implementation"], "code_uid": "c1aad52ff4f04ddf1348c2fc8a387000", "src_uid": "d215b3541d6d728ad01b166aae64faa2", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Reflection;\n\nnamespace Olympo\n{\n\n class Program\n {\n\n static long[] buildFact(long n, long M)\n {\n var res = new long[n + 1];\n res[0] = 1;\n for(long i = 1; i <= n; i++)\n {\n res[i] = (res[i - 1] * i) % M;\n }\n\n return res;\n }\n\n static long axar(long a, long b, long M)\n {\n a = a % M;\n if (b == 0)\n return 1;\n long res = b % 2 == 0 ? 1 : a;\n var rec = axar(a, b >> 1, M);\n res = (((rec * rec) % M) * res) % M;\n return res;\n }\n\n static long[] buildInv(long n, long M, long[] fact)\n {\n var res = new long[n + 1];\n res[0] = 1;\n for (long i = 1; i <= n; i++)\n {\n res[i] = axar(fact[i], M - 2, M);\n }\n\n return res;\n }\n\n static long getC(long n, long k, long M, long[] fact, long[] inv)\n {\n if (n < k) return 0;\n return (((fact[n] * inv[k]) % M) * inv[n - k]) % M;\n }\n\n static void Main(string[] args)\n {\n var inputs = Console.ReadLine().Split(' ').Select(long.Parse).ToList();\n long n = inputs[0], k = inputs[1];\n long M = 998244353l;\n var f = buildFact(n, M);\n var inv = buildInv(n, M, f);\n var res = 0l;\n for(long i=1;i <= n; i++)\n res = (res + getC( n / i - 1, k-1, M, f, inv ) ) % M;\n Console.WriteLine(res);\n }\n }\n}\n\n", "lang_cluster": "C#", "tags": ["math", "combinatorics", "number theory"], "code_uid": "ff7ab89391b880a00bfe3b11a3a6a918", "src_uid": "8e8eb64a047cb970a549ee870c3d280d", "difficulty": 2000.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Linq;\nusing CompLib.Mathematics;\nusing CompLib.Util;\n\npublic class Program\n{\n int N;\n int K;\n public void Solve()\n {\n var sc = new Scanner();\n N = sc.NextInt();\n K = sc.NextInt();\n ModInt[] f = new ModInt[500000];\n f[0] = 1;\n for (int i = 1; i < 500000; i++)\n {\n f[i] = f[i - 1] * i;\n }\n // \u9577\u3055K\u306e\u914d\u5217\u304c\u3042\u308b\u3000\u5404\u8981\u7d20 1<= a_i <=n\n\n // \u4efb\u610f\u306e\u975e\u8ca0\u6574\u6570x\u306b\u3064\u3044\u3066 x % a_i ... \u3092a\u3092\u4e26\u3073\u66ff\u3048\u3066\u3082\u540c\u3058\u306b\u306a\u308ba\u3092\u5b89\u5b9a\u3068\u3088\u3076\n ModInt ans = 0;\n for (int min = 1; min <= N; min++)\n {\n if (min * K > N) break;\n\n int d = (N - min * K) / min;\n\n // d\u3092K\u500b\u306b\u5206\u3051\u308b\n\n // d+K-1 C K-1\n var tmp = f[d + K - 1] * ModInt.Inverse(f[d] * f[K - 1]);\n\n // Console.WriteLine($\"{d} {tmp}\");\n ans += tmp;\n }\n\n Console.WriteLine(ans);\n }\n\n public static void Main(string[] args) => new Program().Solve();\n}\n\n// https://bitbucket.org/camypaper/complib\nnamespace CompLib.Mathematics\n{\n #region ModInt\n /// \n /// [0,) \u307e\u3067\u306e\u5024\u3092\u53d6\u308b\u3088\u3046\u306a\u6570\n /// \n public struct ModInt\n {\n /// \n /// \u5270\u4f59\u3092\u53d6\u308b\u5024\uff0e\n /// \n public const long Mod = 998244353;\n\n /// \n /// \u5b9f\u969b\u306e\u6570\u5024\uff0e\n /// \n public long num;\n /// \n /// \u5024\u304c \u3067\u3042\u308b\u3088\u3046\u306a\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u3092\u69cb\u7bc9\u3057\u307e\u3059\uff0e\n /// \n /// \u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u304c\u6301\u3064\u5024\n /// \u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u306e\u554f\u984c\u4e0a\uff0c\u30b3\u30f3\u30b9\u30c8\u30e9\u30af\u30bf\u5185\u3067\u306f\u5270\u4f59\u3092\u53d6\u308a\u307e\u305b\u3093\uff0e\u305d\u306e\u305f\u3081\uff0c \u2208 [0,) \u3092\u6e80\u305f\u3059\u3088\u3046\u306a \u3092\u6e21\u3057\u3066\u304f\u3060\u3055\u3044\uff0e\u3053\u306e\u30b3\u30f3\u30b9\u30c8\u30e9\u30af\u30bf\u306f O(1) \u3067\u5b9f\u884c\u3055\u308c\u307e\u3059\uff0e\n public ModInt(long n) { num = n; }\n /// \n /// \u3053\u306e\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u306e\u6570\u5024\u3092\u6587\u5b57\u5217\u306b\u5909\u63db\u3057\u307e\u3059\uff0e\n /// \n /// [0,) \u306e\u7bc4\u56f2\u5185\u306e\u6574\u6570\u3092 10 \u9032\u8868\u8a18\u3057\u305f\u3082\u306e\uff0e\n public override string ToString() { return num.ToString(); }\n public static ModInt operator +(ModInt l, ModInt r) { l.num += r.num; if (l.num >= Mod) l.num -= Mod; return l; }\n public static ModInt operator -(ModInt l, ModInt r) { l.num -= r.num; if (l.num < 0) l.num += Mod; return l; }\n public static ModInt operator *(ModInt l, ModInt r) { return new ModInt(l.num * r.num % Mod); }\n public static implicit operator ModInt(long n) { n %= Mod; if (n < 0) n += Mod; return new ModInt(n); }\n\n /// \n /// \u4e0e\u3048\u3089\u308c\u305f 2 \u3064\u306e\u6570\u5024\u304b\u3089\u3079\u304d\u5270\u4f59\u3092\u8a08\u7b97\u3057\u307e\u3059\uff0e\n /// \n /// \u3079\u304d\u4e57\u306e\u5e95\n /// \u3079\u304d\u6307\u6570\n /// \u7e70\u308a\u8fd4\u3057\u4e8c\u4e57\u6cd5\u306b\u3088\u308a O(N log N) \u3067\u5b9f\u884c\u3055\u308c\u307e\u3059\uff0e\n public static ModInt Pow(ModInt v, long k) { return Pow(v.num, k); }\n\n /// \n /// \u4e0e\u3048\u3089\u308c\u305f 2 \u3064\u306e\u6570\u5024\u304b\u3089\u3079\u304d\u5270\u4f59\u3092\u8a08\u7b97\u3057\u307e\u3059\uff0e\n /// \n /// \u3079\u304d\u4e57\u306e\u5e95\n /// \u3079\u304d\u6307\u6570\n /// \u7e70\u308a\u8fd4\u3057\u4e8c\u4e57\u6cd5\u306b\u3088\u308a O(N log N) \u3067\u5b9f\u884c\u3055\u308c\u307e\u3059\uff0e\n public static ModInt Pow(long v, long k)\n {\n long ret = 1;\n for (k %= Mod - 1; k > 0; k >>= 1, v = v * v % Mod)\n if ((k & 1) == 1) ret = ret * v % Mod;\n return new ModInt(ret);\n }\n /// \n /// \u4e0e\u3048\u3089\u308c\u305f\u6570\u306e\u9006\u5143\u3092\u8a08\u7b97\u3057\u307e\u3059\uff0e\n /// \n /// \u9006\u5143\u3092\u53d6\u308b\u5bfe\u8c61\u3068\u306a\u308b\u6570\n /// \u9006\u5143\u3068\u306a\u308b\u3088\u3046\u306a\u5024\n /// \u6cd5\u304c\u7d20\u6570\u3067\u3042\u308b\u3053\u3068\u3092\u4eee\u5b9a\u3057\u3066\uff0c\u30d5\u30a7\u30eb\u30de\u30fc\u306e\u5c0f\u5b9a\u7406\u306b\u5f93\u3063\u3066\u9006\u5143\u3092 O(log N) \u3067\u8a08\u7b97\u3057\u307e\u3059\uff0e\n public static ModInt Inverse(ModInt v) { return Pow(v, Mod - 2); }\n }\n #endregion\n #region Binomial Coefficient\n public class BinomialCoefficient\n {\n public ModInt[] fact, ifact;\n public BinomialCoefficient(int n)\n {\n fact = new ModInt[n + 1];\n ifact = new ModInt[n + 1];\n fact[0] = 1;\n for (int i = 1; i <= n; i++)\n fact[i] = fact[i - 1] * i;\n ifact[n] = ModInt.Inverse(fact[n]);\n for (int i = n - 1; i >= 0; i--)\n ifact[i] = ifact[i + 1] * (i + 1);\n ifact[0] = ifact[1];\n }\n public ModInt this[int n, int r]\n {\n get\n {\n if (n < 0 || n >= fact.Length || r < 0 || r > n) return 0;\n return fact[n] * ifact[n - r] * ifact[r];\n }\n }\n public ModInt RepeatedCombination(int n, int k)\n {\n if (k == 0) return 1;\n return this[n + k - 1, k];\n }\n }\n #endregion\n}\n\n\nnamespace CompLib.Util\n{\n using System;\n using System.Linq;\n\n class Scanner\n {\n private string[] _line;\n private int _index;\n private const char Separator = ' ';\n\n public Scanner()\n {\n _line = new string[0];\n _index = 0;\n }\n\n public string Next()\n {\n while (_index >= _line.Length)\n {\n _line = Console.ReadLine().Split(Separator);\n _index = 0;\n }\n\n return _line[_index++];\n }\n\n public int NextInt() => int.Parse(Next());\n public long NextLong() => long.Parse(Next());\n public double NextDouble() => double.Parse(Next());\n public decimal NextDecimal() => decimal.Parse(Next());\n public char NextChar() => Next()[0];\n public char[] NextCharArray() => Next().ToCharArray();\n\n public string[] Array()\n {\n _line = Console.ReadLine().Split(Separator);\n _index = _line.Length;\n return _line;\n }\n\n public int[] IntArray() => Array().Select(int.Parse).ToArray();\n public long[] LongArray() => Array().Select(long.Parse).ToArray();\n public double[] DoubleArray() => Array().Select(double.Parse).ToArray();\n public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "combinatorics", "number theory"], "code_uid": "8179a106a25e4f16ae84044eb1cf5a9e", "src_uid": "8e8eb64a047cb970a549ee870c3d280d", "difficulty": 2000.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace Algorithm_Study_Sharp\n{\n class Program\n {\n static void Main(string[] args)\n {\n int before = 0, after = 0, count = 0;\n int[] inputArray = Array.ConvertAll(Console.ReadLine().Split((char)32), int.Parse);\n before = inputArray[0];\n after = inputArray[1];\n\n if (before >= after)\n {\n Console.WriteLine(before - after);\n }\n else\n {\n while (after != before)\n {\n if ((after % 2) != 0)\n {\n after++;\n }\n else if (after < before)\n {\n after++;\n }\n else\n {\n after /= 2;\n }\n count++;\n }\n\n Console.WriteLine(count);\n\n }\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["dfs and similar", "shortest paths", "math", "graphs", "greedy", "implementation"], "code_uid": "975c6b0820a193bff8f0b95cc9066e65", "src_uid": "861f8edd2813d6d3a5ff7193a804486f", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\n\nnamespace q520b\n{\n class Program\n {\n\tenum Op { R, B };\n\n static void Main(string[] args)\n {\n\t var inputFirstLine = Console.ReadLine().Split(' ');\n\t var n = int.Parse(inputFirstLine[0]);\n\t var m = int.Parse(inputFirstLine[1]);\n\t // \ube68\uac04 \ubc84\ud2bc: \uc22b\uc790\uc5d0 2\ub97c \uacf1\ud55c\ub2e4\n\t // \ud30c\ub780 \ubc84\ud2bc: \uc22b\uc790\uc5d0\uc11c 1\uc744 \ube80\ub2e4\n\t // \ub514\uc2a4\ud50c\ub808\uc774: \ud604\uc7ac \uc22b\uc790\ub97c \ucd9c\ub825\ud55c\ub2e4\n\t // n\uc5d0\uc11c m\uc744 \ub9cc\ub4e4\uae30 \uc704\ud55c \ucd5c\uc18c\ud55c\uc758 \ubc84\ud2bc \ub204\ub984 \ud68c\uc218?\n\t \n\t if (n >= m)\n\t {\n\t\t// \uac10\uc18c\ud558\ub294 \ubc84\ud2bc\uc740 \ub2e8 \ud558\ub098\uc774\uace0,\n\t\t// \uc22b\uc790\ub97c \uc99d\uac00\uc2dc\ucf1c 0\uc73c\ub85c \ub418\ub3cc\ub9b4 \ubc29\ubc95\uc740 \uc5c6\uc73c\ubbc0\ub85c\n\t\tConsole.WriteLine(\"{0}\", n - m);\n\t }\n\t else\n\t {\n\t\t// \ubb38\uc81c\ub294 \uc22b\uc790\ub97c \uc99d\uac00\uc2dc\ud0a4\ub294 \ubd80\ubd84\uc5d0 \uc788\ub2e4\n\t\t// DFS \ubc84\uc804\uc740 Program_DFS.cs.bak \ucc38\uace0. \ub300\uc2e4\ud328\ud568\n\n\t\t// \ubc1c\uc0c1\uc744 \ubc14\uafd4, \uc5ed\uc73c\ub85c m\uc5d0\uc11c n\uc73c\ub85c \ubcc0\ud654\uc2dc\ud0a4\ub824\uba74 \uc5b4\ub5bb\uac8c\n\t\t// \uacc4\uc0b0\ud574\uc57c\ud560\uc9c0\ub97c \uc0dd\uac01\ud574\ubcf4\uc790\n\t\t// X\uac00 \uc9dd\uc218\ub77c\uba74 \ubc18\ub4dc\uc2dc \uc774\uc804 \uc5f0\uc0b0\uc5d0\uc11c X' * 2\uac00 \uc774\ub8e8\uc5b4\uc9d0\n\t\t// X\uac00 \ud640\uc218\ub77c\uba74 \ubc18\ub4dc\uc2dc \uc774\uc804 \uc5f0\uc0b0\uc5d0\uc11c X' - 1\uc774 \uc774\ub8e8\uc5b4\uc9d0\n\t\t// \uc989, \uc774 \ub450 \uc6d0\ub9ac\ub97c \uac70\uafb8\ub85c \uc801\uc6a9\ud558\uc5ec \uc6d0\ub798 \uc22b\uc790\ub97c \uad6c\ud558\uc790\n\n\t\tvar steps = 0;\n\t\tvar i = m; // m\uc740 \uace0\uc815, m\uc744 \uc790\uc720\uc790\uc7ac\ub85c \ubc14\uafc0 i\ub85c \ubcf5\uc0ac\n\n\t\twhile (n != i)\n\t\t{\n\t\t if (n < i)\n\t\t {\n\t\t\t// \uc5ec\uc804\ud788 \ucd94\uac00 \uc5f0\uc0b0(\ub098\ub217\uc148)\uc774 \uac00\ub2a5\ud568\n\t\t\tif (i%2 == 0)\n\t\t\t{\n\t\t\t i /= 2; // *= 2\uc758 \uc5ed\uc6d0\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t i += 1; // -= 1\uc758 \uc5ed\uc6d0\n\t\t\t}\n\n\t\t\tsteps++;\n\t\t }\n\t\t else\n\t\t {\n\t\t\t// \ub098\ub20c \uc218 \uc5c6\uc73c\ubbc0\ub85c \ub354\ud574\uc11c \ubaa9\ud45c\uc218\ub85c \ub418\ub3cc\ub9bc\n\t\t\tsteps += n - i;\n\t\t\t\n\t\t\t// \uadf8\ub9ac\uace0 \ub8e8\ud504 \uc885\ub8cc\ub97c \uc704\ud574,\n\t\t\ti = n;\n\t\t }\n\t\t}\n\n\t\tConsole.WriteLine(\"{0}\", steps);\n\t }\n }\n } \n}\n", "lang_cluster": "C#", "tags": ["dfs and similar", "shortest paths", "math", "graphs", "greedy", "implementation"], "code_uid": "d9aead4227b4d784677674383cf6c2a4", "src_uid": "861f8edd2813d6d3a5ff7193a804486f", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace ConsoleApp2\n{\n class Program\n {\n static void Main(string[] args)\n {\n \n\n string str = Console.ReadLine();\n string[] srt = str.Split(' ');\n int s = Convert.ToInt32(srt[0]);\n int v1 = Convert.ToInt32(srt[1]);\n int v2 = Convert.ToInt32(srt[2]);\n int t1 = Convert.ToInt32(srt[3]);\n int t2 = Convert.ToInt32(srt[4]);\n int x1 = 0;\n int x2 = 0;\n x1 = t1 + (s * v1) + t1;\n x2 = t2 + (s * v2) + t2;\n if (x1 < x2)\n {\n Console.WriteLine(\"First\");\n }\n else if (x2 < x1)\n {\n Console.WriteLine(\"Second\");\n }\n else\n {\n Console.WriteLine(\"Friendship\");\n }\n //Console.Read();\n }\n }\n}", "lang_cluster": "C#", "tags": ["math"], "code_uid": "e3bda26de64b655d37b6c8702d510a28", "src_uid": "10226b8efe9e3c473239d747b911a1ef", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.IO;\nusing System.Globalization;\nusing System.Threading;\n\nnamespace ACM\n{\n class Program\n {\n protected static StreamReader reader;\n protected static StreamWriter writer;\n\n static void Swap(ref T x, ref T y)\n {\n T t = y;\n y = x;\n x = t;\n }\n\n public static bool NextPermutation(T[] elements) where T : IComparable\n {\n var count = elements.Length;\n var done = true;\n\n for (var i = count - 1; i > 0; i--)\n {\n var curr = elements[i];\n if (curr.CompareTo(elements[i - 1]) < 0) continue;\n done = false;\n var prev = elements[i - 1];\n var currIndex = i;\n for (var j = i + 1; j < count; j++)\n {\n var tmp = elements[j];\n\n if (tmp.CompareTo(curr) < 0 && tmp.CompareTo(prev) > 0)\n {\n curr = tmp;\n currIndex = j;\n }\n }\n\n elements[currIndex] = prev;\n elements[i - 1] = curr;\n\n for (var j = count - 1; j > i; j--, i++)\n {\n var tmp = elements[j];\n elements[j] = elements[i];\n elements[i] = tmp;\n }\n break;\n }\n return done;\n }\n\n public static int[] GetArr()\n {\n return reader.ReadLine().Split(' ').ToList().Select(r => int.Parse(r)).ToArray();\n }\n\n public static long[] GetLongArr()\n {\n return reader.ReadLine().Split(' ').ToList().Select(r => long.Parse(r)).ToArray();\n }\n\n public static int GetInt()\n {\n return int.Parse(reader.ReadLine());\n }\n\n public static long GetLong()\n {\n return long.Parse(reader.ReadLine());\n }\n\n public static int[,] GetMatrix(int n, int m)\n {\n int[,] a = new int[n, m];\n for (int i = 0; i < n; i++)\n {\n int[] x = GetArr();\n for (int j = 0; j < m; j++)\n a[i, j] = x[j];\n }\n return a;\n }\n\n public static void PrintArr(int[] a)\n {\n for (int i = 0; i < a.Count(); i++)\n writer.Write(a[i] + \" \");\n writer.WriteLine();\n }\n \n static void Main()\n {\n reader = new StreamReader(Console.OpenStandardInput());\n writer = new StreamWriter(Console.OpenStandardOutput());\n int[] f = GetArr();\n int s = f[0];\n int v1 = f[1];\n int v2 = f[2];\n int t1 = f[3];\n int t2 = f[4];\n //reader = new StreamReader(File.OpenRead(\"D:\\\\ACM\\\\input.txt\"));\n //writer = new StreamWriter(File.OpenWrite(\"D:\\\\ACM\\\\output.txt\"));\n //var dt = DateTime.UtcNow;\n if (v1 * s + 2 * t1 < v2 * s + 2 * t2) writer.WriteLine(\"First\");\n if (v1 * s + 2 * t1 > v2 * s + 2 * t2) writer.WriteLine(\"Second\");\n if (v1 * s + 2 * t1 == v2 * s + 2 * t2) writer.WriteLine(\"Friendship\"); \n \n writer.Flush();\n //Console.WriteLine(DateTime.UtcNow - dt); \n }\n }\n} ", "lang_cluster": "C#", "tags": ["math"], "code_uid": "1d59248032b9191986cc3cd893d86ede", "src_uid": "10226b8efe9e3c473239d747b911a1ef", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "// Problem: 796A - Buying A House\n// Author: Gusztav Szmolik\n\nusing System;\n\nnamespace Buying_A_House\n\t{\n\tclass Program\n\t\t{\n\t\tstatic int Main ()\n\t\t\t{\n\t\t\tstring[] tmp = Console.ReadLine().Split();\n\t\t\tif (tmp.Length != 3)\n\t\t\t\treturn -1;\n\t\t\tushort n = 0;\n\t\t\tif (!UInt16.TryParse(tmp[0], out n))\n\t\t\t\treturn -1;\n\t\t\tushort m = 0;\n\t\t\tif (!UInt16.TryParse(tmp[1], out m))\n\t\t\t\treturn -1;\n\t\t\tushort k = 0;\n\t\t\tif (!UInt16.TryParse(tmp[2], out k))\n\t\t\t\treturn -1;\n\t\t\tif (n < 2 || n > 100 || m < 1 || m > n || k < 1 || k > 100)\n\t\t\t\treturn -1;\n\t\t\ttmp = Console.ReadLine().Split();\n\t\t\tif (tmp.Length != n)\n\t\t\t\treturn -1;\n\t\t\tushort[] a = new ushort[n];\n\t\t\tushort mm = Convert.ToUInt16 (m-1);\n\t\t\tbool possiblePurchase = false;\n\t\t\tushort minHouses = Convert.ToUInt16 (n-1);\n\t\t\tushort houses;\n\t\t\tfor (ushort i = 0; i < n; i++)\n\t\t\t\t{\n\t\t\t\tif (!UInt16.TryParse(tmp[i], out a[i]))\n\t\t\t\t\treturn -1;\n\t\t\t\tif (i == mm && a[i] != 0)\n\t\t\t\t\treturn -1;\n\t\t\t\tif (a[i] != 0 && a[i] <= k)\n\t\t\t\t\t{\n\t\t\t\t\tpossiblePurchase = true;\n\t\t\t\t\thouses = (i < mm ? Convert.ToUInt16(mm-i) : Convert.ToUInt16(i-mm));\n\t\t\t\t\tif (houses < minHouses)\n\t\t\t\t\t\tminHouses = houses;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\tif (!possiblePurchase)\n\t\t\t\treturn -1;\n\t\t\tConsole.WriteLine (minHouses*10);\n\t\t\treturn 0;\n\t\t\t}\n\t\t}\n\t}\n", "lang_cluster": "C#", "tags": ["brute force", "implementation"], "code_uid": "3e3ad5d77283c26c1828e8f9c28e85fb", "src_uid": "57860e9a5342a29257ce506063d37624", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Globalization;\nusing System.IO;\nusing System.Linq;\nusing System.Numerics;\nusing System.Text;\n\nnamespace ConsoleApplication1.CodeForces\n{\n class _403\n {\n private static int Next()\n {\n int c;\n int res = 0;\n do\n {\n c = reader.Read();\n if (c == -1)\n return res;\n } while (c < '0' || c > '9');\n res = c - '0';\n while (true)\n {\n c = reader.Read();\n if (c < '0' || c > '9')\n return res;\n res *= 10;\n res += c - '0';\n }\n }\n private static readonly StreamReader reader = new StreamReader(Console.OpenStandardInput(1024 * 10), Encoding.ASCII, false, 1024 * 10);\n private static readonly StreamWriter writer = new StreamWriter(Console.OpenStandardOutput(1024 * 10), Encoding.ASCII, 1024 * 10);\n\n static void Main(String[] args)\n {\n var line = Console.ReadLine().Split(' ' ).Select(int.Parse).ToList();\n var n = line[0];\n var m = line[1] -1;\n var k = line[2];\n \n var data = Console.ReadLine().Split(' ').Select(int.Parse).ToList();\n\n var min = int.MaxValue;\n\n for(var i = 0; i < data.Count; i++)\n {\n if(data[i] == 0 || data[i] > k)\n {\n continue;\n }\n\n if(min > Math.Abs(i - m) )\n {\n min = Math.Abs(i - m);\n }\n }\n\n var result = 0;\n Console.WriteLine(min * 10);\n }\n }\n}", "lang_cluster": "C#", "tags": ["brute force", "implementation"], "code_uid": "8bdd7dfec08956061ee44a6df69b6267", "src_uid": "57860e9a5342a29257ce506063d37624", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.IO;\nusing System.Threading;\nusing System.Runtime.CompilerServices;\nusing System.Text;\nusing System.Diagnostics;\nusing System.Numerics;\nusing static System.Console;\nusing static System.Convert;\nusing static System.Math;\nusing static Template;\n\nclass Solver\n{\n public Scanner sc;\n public void Solve()\n {\n int N, K;\n sc.Make(out N, out K);\n var dp = Create(N + 1, () => new ModInt[N + 1]);\n var newdp = Create(N + 1, () => new ModInt[N + 1]);\n dp[1][1] = 2;\n for (int i = 1; i < N; i++)\n {\n for (int j = 1; j < N+1; j++)\n {\n for (int k = 1; k < j+1; k++)\n {\n newdp[j][k] = dp[j][k - 1];\n if (j == k) newdp[j][k] += dp[j - 1][k - 1];\n newdp[j][1] += dp[j][k];\n }\n }\n swap(ref dp, ref newdp);\n }\n var ct = new ModInt[N + 1];\n for (int i = 0; i <= N; i++)\n for (int j = 0; j <= i; j++)\n ct[i] += dp[i][j];\n ModInt res = 0;\n for(int i = 1; i <= Min(K-1,N); i++)\n {\n var seg = new DualSegmentTree(N, 0, (a, b) => a + b);\n seg.Update(0, Min(N, (K - 1) / i), 1);\n for (int j = 0; j < N - 1; j++)\n seg.Update(j + 1, Min(j + 1 + (K - 1) / i,N), seg.Query(j));\n res += seg.Query(N - 1)*ct[i];\n }\n Console.WriteLine(res);\n }\n}\n\npublic struct ModInt\n{\n //public const long MOD = (int)1e9 + 7;\n public const long MOD = 998244353;\n public long Value { get; set; }\n public ModInt(long n = 0) { Value = n; }\n private static ModInt[] fac, inv, facinv;\n public override string ToString() => Value.ToString();\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static ModInt operator +(ModInt l, ModInt r)\n {\n l.Value += r.Value;\n if (l.Value >= MOD) l.Value -= MOD;\n return l;\n }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static ModInt operator -(ModInt l, ModInt r)\n {\n l.Value -= r.Value;\n if (l.Value < 0) l.Value += MOD;\n return l;\n }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static ModInt operator *(ModInt l, ModInt r) => new ModInt(l.Value * r.Value % MOD);\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static ModInt operator /(ModInt l, ModInt r) => l * Pow(r, MOD - 2);\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static implicit operator long(ModInt l) => l.Value;\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static implicit operator ModInt(long n)\n {\n n %= MOD; if (n < 0) n += MOD;\n return new ModInt(n);\n }\n\n public static ModInt Pow(ModInt m, long n)\n {\n if (n == 0) return 1;\n if (n % 2 == 0) return Pow(m * m, n >> 1);\n else return Pow(m * m, n >> 1) * m;\n }\n\n public static void Build(int n)\n {\n fac = new ModInt[n + 1];\n facinv = new ModInt[n + 1];\n inv = new ModInt[n + 1];\n inv[1] = fac[0] = fac[1] = facinv[0] = facinv[1] = 1;\n for (var i = 2; i <= n; i++)\n {\n fac[i] = fac[i - 1] * i;\n inv[i] = MOD - inv[MOD % i] * (MOD / i);\n facinv[i] = facinv[i - 1] * inv[i];\n }\n }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static ModInt Fac(int n) => fac[n];\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static ModInt Inv(int n) => inv[n];\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static ModInt FacInv(int n) => facinv[n];\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static ModInt Comb(int n, int r)\n {\n if (n < r) return 0;\n if (n == r) return 1;\n return fac[n] * facinv[r] * facinv[n - r];\n }\n public static ModInt Perm(int n, int r)\n {\n if (n < r) return 0;\n return fac[n] * facinv[n - r];\n }\n\n}\n\npublic class DualSegmentTree\n{\n protected readonly T[] data;\n protected readonly int size;\n protected readonly Func merge;\n protected readonly T idT;\n\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n protected int Parent(int i)\n => (i - 1) >> 1;\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n protected int Left(int i)\n => (i << 1) + 1;\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n protected int Right(int i)\n => (i + 1) << 1;\n public T this[int i]\n {\n get { return data[i + size - 1]; }\n set { data[i + size - 1] = value; }\n }\n\n public DualSegmentTree(int N, T idT, Func merge)\n {\n this.merge = merge;\n this.size = 1;\n this.idT = idT;\n while (size < N)\n size <<= 1;\n data = new T[2 * this.size - 1];\n for (var i = 0; i < 2 * size - 1; i++)\n data[i] = idT;\n }\n public void Update(int left, int right, T value, int k = 0, int l = 0, int r = -1)\n {\n if (r == -1) r = size;\n if (r <= left || right <= l) return;\n if (left <= l && r <= right) data[k] = merge(data[k], value);\n else\n {\n Update(left, right, value, Left(k), l, (l + r) >> 1);\n Update(left, right, value, Right(k), (l + r) >> 1, r);\n }\n }\n public T Query(int i)\n {\n i += size - 1;\n var value = merge(idT, data[i]);\n while (i > 0)\n {\n i = Parent(i);\n value = merge(value, data[i]);\n }\n return value;\n }\n\n public int Find(int st, Func check)\n {\n var x = idT;\n return Find(st, check, ref x, 0, 0, size);\n }\n private int Find(int st, Func check, ref T x, int k, int l, int r)\n {\n if (l + 1 == r)\n { x = merge(x, data[k]); return check(x) ? k - size + 1 : -1; }\n var m = (l + r) >> 1;\n if (m <= st) return Find(st, check, ref x, Right(k), m, r);\n if (st <= l && !check(merge(x, data[k])))\n { x = merge(x, data[k]); return -1; }\n var xl = Find(st, check, ref x, Left(k), l, m);\n if (xl >= 0) return xl;\n return Find(st, check, ref x, Right(k), m, r);\n }\n}\n#region Template\npublic static class Template\n{\n static void Main(string[] args)\n {\n Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });\n var sol = new Solver() { sc = new Scanner() };\n //var th = new Thread(sol.Solve, 1 << 26);th.Start();th.Join();\n sol.Solve();\n Console.Out.Flush();\n }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static bool chmin(ref T a, T b) where T : IComparable { if (a.CompareTo(b) > 0) { a = b; return true; } return false; }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static bool chmax(ref T a, T b) where T : IComparable { if (a.CompareTo(b) < 0) { a = b; return true; } return false; }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static void swap(ref T a, ref T b) { var t = b; b = a; a = t; }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static void swap(this IList A, int i, int j) { var t = A[i]; A[i] = A[j]; A[j] = t; }\n public static T[] Create(int n, Func f) { var rt = new T[n]; for (var i = 0; i < rt.Length; ++i) rt[i] = f(); return rt; }\n public static T[] Create(int n, Func f) { var rt = new T[n]; for (var i = 0; i < rt.Length; ++i) rt[i] = f(i); return rt; }\n public static void Out(this IList A, out T a) => a = A[0];\n public static void Out(this IList A, out T a, out T b) { a = A[0]; b = A[1]; }\n public static void Out(this IList A, out T a, out T b, out T c) { A.Out(out a, out b); c = A[2]; }\n public static void Out(this IList A, out T a, out T b, out T c, out T d) { A.Out(out a, out b, out c); d = A[3]; }\n public static string Concat(this IEnumerable A, string sp) => string.Join(sp, A);\n public static char ToChar(this int s, char begin = '0') => (char)(s + begin);\n public static IEnumerable Shuffle(this IEnumerable A) => A.OrderBy(v => Guid.NewGuid());\n public static int CompareTo(this T[] A, T[] B, Comparison cmp = null) { cmp = cmp ?? Comparer.Default.Compare; for (var i = 0; i < Min(A.Length, B.Length); i++) { int c = cmp(A[i], B[i]); if (c > 0) return 1; else if (c < 0) return -1; } if (A.Length == B.Length) return 0; if (A.Length > B.Length) return 1; else return -1; }\n public static int ArgMax(this IList A, Comparison cmp = null) { cmp = cmp ?? Comparer.Default.Compare; T max = A[0]; int rt = 0; for (int i = 1; i < A.Count; i++) if (cmp(max, A[i]) < 0) { max = A[i]; rt = i; } return rt; }\n public static T PopBack(this List A) { var v = A[A.Count - 1]; A.RemoveAt(A.Count - 1); return v; }\n public static void Fail(T s) { Console.WriteLine(s); Console.Out.Close(); Environment.Exit(0); }\n}\npublic class Scanner\n{\n public string Str => Console.ReadLine().Trim();\n public int Int => int.Parse(Str);\n public long Long => long.Parse(Str);\n public double Double => double.Parse(Str);\n public int[] ArrInt => Str.Split(' ').Select(int.Parse).ToArray();\n public long[] ArrLong => Str.Split(' ').Select(long.Parse).ToArray();\n public char[][] Grid(int n) => Create(n, () => Str.ToCharArray());\n public int[] ArrInt1D(int n) => Create(n, () => Int);\n public long[] ArrLong1D(int n) => Create(n, () => Long);\n public int[][] ArrInt2D(int n) => Create(n, () => ArrInt);\n public long[][] ArrLong2D(int n) => Create(n, () => ArrLong);\n private Queue q = new Queue();\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public T Next() { if (q.Count == 0) foreach (var item in Str.Split(' ')) q.Enqueue(item); return (T)Convert.ChangeType(q.Dequeue(), typeof(T)); }\n public void Make(out T1 v1) => v1 = Next();\n public void Make(out T1 v1, out T2 v2) { v1 = Next(); v2 = Next(); }\n public void Make(out T1 v1, out T2 v2, out T3 v3) { Make(out v1, out v2); v3 = Next(); }\n public void Make(out T1 v1, out T2 v2, out T3 v3, out T4 v4) { Make(out v1, out v2, out v3); v4 = Next(); }\n public void Make(out T1 v1, out T2 v2, out T3 v3, out T4 v4, out T5 v5) { Make(out v1, out v2, out v3, out v4); v5 = Next(); }\n public void Make(out T1 v1, out T2 v2, out T3 v3, out T4 v4, out T5 v5, out T6 v6) { Make(out v1, out v2, out v3, out v4, out v5); v6 = Next(); }\n public void Make(out T1 v1, out T2 v2, out T3 v3, out T4 v4, out T5 v5, out T6 v6, out T7 v7) { Make(out v1, out v2, out v3, out v4, out v5, out v6); v7 = Next(); }\n public (T1, T2) Make() { Make(out T1 v1, out T2 v2); return (v1, v2); }\n public (T1, T2, T3) Make() { Make(out T1 v1, out T2 v2, out T3 v3); return (v1, v2, v3); }\n public (T1, T2, T3, T4) Make() { Make(out T1 v1, out T2 v2, out T3 v3, out T4 v4); return (v1, v2, v3, v4); }\n}\n\n#endregion", "lang_cluster": "C#", "tags": ["math", "dp", "combinatorics"], "code_uid": "97124b01ee268b2a9ef3525b96bb7358", "src_uid": "77177b1a2faf0ba4ca1f4d77632b635b", "difficulty": 2100.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nclass Solution\n{\n public static void Main(string[] args)\n {\n int n = Convert.ToInt32(Console.ReadLine());\n string inp = \"\";\n char[][] array = new char[4][];\n char count = '1';\n int temp = 0, flag = 0;\n for (int i = 0; i < 4; i++)\n {\n inp = Console.ReadLine();\n array[i] = inp.ToCharArray();\n }\n while (count < 58)\n {\n for (int j = 0; j < 4; j++)\n {\n for (int k = 0; k < 4; k++)\n {\n if (array[j][k] == count)\n temp++;\n }\n }\n if (temp > (2 * n))\n {\n flag = 1;\n break;\n }\n temp = 0;\n count++;\n }\n if (flag != 1)\n Console.WriteLine(\"YES\");\n else\n Console.WriteLine(\"NO\");\n }\n}", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "d97fc61542621fef49b1b2722ab63970", "src_uid": "5fdaf8ee7763cb5815f49c0c38398f16", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\n\nnamespace codeforces\n{\n\tclass Program\n\t{\n\t\tpublic const int Osn = 1000000007;\n\n\t\tpublic class Pair\n\t\t{\n\t\t\tpublic int First;\n\n\t\t\tpublic int Second;\n\t\t}\n\n\t\tpublic class PairComparer : IComparer\n\t\t{\n\t\t\tpublic int Compare(Pair x, Pair y)\n\t\t\t{\n\t\t\t\tif (x.First > y.First || (x.First == y.First && x.Second < y.Second))\n\t\t\t\t\treturn -1;\n\t\t\t\treturn 1;\n\t\t\t}\n\t\t}\n\n\t\tpublic static long GetGcd(long a, long b)\n\t\t{\n\t\t\twhile (true)\n\t\t\t{\n\t\t\t\tif (b == 0)\n\t\t\t\t\treturn a;\n\t\t\t\tvar a1 = a;\n\t\t\t\ta = b;\n\t\t\t\tb = a1 % b;\n\t\t\t}\n\t\t}\n\n\t\tpublic static void WriteYesNo(bool x, string yes = \"YES\", string no = \"NO\")\n\t\t{\n\t\t\tif (x)\n\t\t\t\tConsole.WriteLine(yes);\n\t\t\telse\n\t\t\t{\n\t\t\t\tConsole.WriteLine(no);\n\t\t\t}\n\t\t}\n\n\t\tpublic static string ReadString()\n\t\t{\n\t\t\treturn Console.ReadLine();\n\t\t}\n\n\t\tpublic static List ReadListOfInts()\n\t\t{\n\t\t\tvar s = Console.ReadLine();\n\t\t\treturn s.Split(' ').Select(int.Parse).ToList();\n\t\t}\n\n\t\tpublic static List ReadListOfLongs()\n\t\t{\n\t\t\tvar s = Console.ReadLine();\n\t\t\treturn s.Split(' ').Select(long.Parse).ToList();\n\t\t}\n\n\t\tpublic static int ReadInt()\n\t\t{\n\t\t\tvar s = Console.ReadLine();\n\t\t\treturn int.Parse(s);\n\t\t}\n\n\t\tpublic static long ReadLong()\n\t\t{\n\t\t\tvar s = Console.ReadLine();\n\t\t\treturn long.Parse(s);\n\t\t}\n\n\t\tprivate static void Main()\n\t\t{\n\t\t\tvar k = ReadInt();\n\t\t\tvar f = new List { ReadString(), ReadString(), ReadString(), ReadString() };\n\t\t\tvar can = true;\n\t\t\tfor (var i = '1'; i <= '9'; ++i)\n\t\t\t{\n\t\t\t\tvar ct = 0;\n\t\t\t\tfor (var j = 0; j < 4; ++j)\n\t\t\t\t\tct += f[j].Count(x => x == i);\n\t\t\t\tif (ct > 2 * k)\n\t\t\t\t\tcan = false;\n\t\t\t}\n\t\t\tWriteYesNo(can);\n\t\t\tConsole.ReadLine();\n\t\t}\n\t}\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "34d7754eab13f56ff11685c1cfee11ff", "src_uid": "5fdaf8ee7763cb5815f49c0c38398f16", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace Codeforces\n{\n class Functions\n {\n public static int ReadInt()\n {\n return int.Parse(Console.ReadLine());\n }\n\n public static string ReadLine()\n {\n return Console.ReadLine();\n }\n\n public static string[] ReadLineWithSplit(char split)\n {\n return Console.ReadLine().Split(split);\n }\n\n public static string[] ReadLines(int count)\n {\n string[] lines = new string[count];\n for (int x = 0; x < count; x++)\n {\n lines[x] = ReadLine();\n }\n return lines;\n }\n public static string ReverseInts(string s)\n {\n string[] charArray = s.Split(' ');\n Array.Reverse(charArray);\n return charArray.Aggregate(\"\", (current, s1) => current + (s1 + \" \"));\n }\n }\n\n class Program\n {\n private static void Main()\n {\n string[] lines = Functions.ReadLines(8);\n int[] counts = new int[8];\n var strokes = 0;\n var vert = 0;\n\n for (var i = 0; i < 8; i++)\n { \n foreach (char c in lines[i])\n {\n if (c == 'B')\n counts[i]++;\n }\n if (counts[i] == 8)\n strokes++;\n else \n vert = counts[i];\n }\n\n strokes += vert;\n Console.WriteLine(strokes.ToString());\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "constructive algorithms"], "code_uid": "a77bae61e247466e5a6620d97db1cc3b", "src_uid": "8b6ae2190413b23f47e2958a7d4e7bc0", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\n\nnamespace Codeforces\n{\n class Program\n {\n static void Main(string[] args)\n {\n string[] board = new string[8];\n int count = 0;\n bool x = false;\n for (int i = 0; i < board.Length; i++)\n board[i] = Console.ReadLine();\n for (int i = 0; i < board.Length; i++)\n {\n if (board[i].StartsWith(\"B\") && !board[i].Contains(\"W\"))\n {\n count++;\n }\n if(board[i].Contains(\"B\") && i < 1)\n {\n for (int a = 0; a < board[i].Length; a++)\n {\n if (board[i][a].ToString() == \"B\")\n {\n int tot = 0;\n for (int c = 0; c < board.Length; c++)\n {\n if (board[c][a].ToString() == \"B\")\n tot++;\n }\n if (tot == 8)\n count++;\n }\n }\n }\n }\n if (count == 16)\n count = 8;\n Console.WriteLine(count);\n Console.ReadLine();\n }\n }\n}", "lang_cluster": "C#", "tags": ["brute force", "constructive algorithms"], "code_uid": "549b95b4fa22f7bdf67692dcb2d136e2", "src_uid": "8b6ae2190413b23f47e2958a7d4e7bc0", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffnamespace CodeForcesCSharp\n{\n using System;\n using System.Collections.Generic;\n using System.Linq;\n\n public class _439_A___DevuTheSingerAndChuruTheJoker\n {\n private static string zString() { return Console.ReadLine(); }\n private static List zStrings() { return zString().Split(\" \".ToArray(), StringSplitOptions.RemoveEmptyEntries).ToList(); }\n private static int zInt() { return int.Parse(Console.ReadLine()); }\n private static List zInts() { List tmpList = new List(); zStrings().ForEach(i => tmpList.Add(int.Parse(i))); return tmpList; }\n private static long zLong() { return long.Parse(Console.ReadLine()); }\n private static List zLongs() { List tmpList = new List(); zStrings().ForEach(i => tmpList.Add(long.Parse(i))); return tmpList; }\n private static void Wait() { Console.ReadLine(); }\n\n static void Main(string[] args)\n {\n List nAndD = zInts();\n int numberOfSongs = nAndD.ElementAt(0);\n int eventDuration = nAndD.ElementAt(1);\n\n List songTimes = zInts();\n\n int timeForDevu = songTimes.Sum() + (songTimes.Count - 1) * 10;\n if (timeForDevu > eventDuration)\n {\n Console.WriteLine(\"-1\");\n }\n else\n {\n int timeForChuru = eventDuration - songTimes.Sum();\n int jokes = timeForChuru / 5;\n\n Console.WriteLine(jokes);\n }\n\n#if DEBUG\n Wait();\n#endif\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["greedy", "implementation"], "code_uid": "5d9000a0aca2cb342398c46dd248b92b", "src_uid": "b16f5f5c4eeed2a3700506003e8ea8ea", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.IO;\nusing System.Linq;\n\nnamespace Tournir251\n{\n\tpublic class ProgramA\n\t{\n\n\t\tpublic static void Main(string[] args)\n\t\t{\n\t\t\tnew ProgramA().run();\n\t\t}\n\n\t\tpublic void run()\n\t\t{\n\t\t\tusing (TextReader input = Console.In)\n\t\t\t{\n\t\t\t\tint[] numbers = input.ReadLine().Split(' ').Select(stringNumber => int.Parse(stringNumber)).ToArray();\n\t\t\t\tint n = numbers[0], d = numbers[1];\n\t\t\t\tint[] t = input.ReadLine().Split(' ').Select(stringNumber => int.Parse(stringNumber)).ToArray();\n\n\t\t\t\tint k = (t.Length - 1) * 2;\n\t\t\t\tint time = t.Sum() + k * 5;\n\t\t\t\tConsole.WriteLine(time <= d ? k + (d - time) / 5 : -1);\n\n\t\t\t}\n\t\t}\n\n\t}\n}", "lang_cluster": "C#", "tags": ["greedy", "implementation"], "code_uid": "4fe26d53f074dc349d74b24edfd848f1", "src_uid": "b16f5f5c4eeed2a3700506003e8ea8ea", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace ebonyAndIvory\n{\n class Program\n {\n static void Main(string[] args)\n {\n string input = Console.ReadLine();\n int a = Convert.ToInt32(input.Split()[0]);\n int b = Convert.ToInt32(input.Split()[1]);\n int c = Convert.ToInt32(input.Split()[2]);\n int aranan = 0;\n\n \n \n for (int i = 0; i <= 5000 ; i++)\n {\n for (int j = 0; j <= 5000 ; j++)\n {\n aranan = i * a + j * b;\n if (aranan == c)\n {\n Console.WriteLine(\"Yes\");\n return;\n }\n else if (aranan >= 10000)\n {\n break;\n }\n }\n }\n Console.WriteLine(\"No\");\n \n \n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "math", "number theory"], "code_uid": "171ece13ebb75f1a64c94582e66524c7", "src_uid": "e66ecb0021a34042885442b336f3d911", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\n\nnamespace Olymp\n{\n public class ProblemSolver\n {\n public void Solve()\n {\n string[] input = Console.ReadLine().Split();\n int a = int.Parse(input[0]);\n int b = int.Parse(input[1]);\n int c = int.Parse(input[2]);\n int n = c / a;\n for (int i = 0; i <= n; i++)\n {\n int x = c - i * a;\n int j = x / b;\n if(a * i + b * j == c)\n {\n Console.Write(\"Yes\");\n return;\n }\n }\n Console.Write(\"No\");\n }\n }\n\n class Program\n {\n public static void Main(string[] args)\n {\n var solver = new ProblemSolver();\n solver.Solve();\n }\n }\n}", "lang_cluster": "C#", "tags": ["brute force", "math", "number theory"], "code_uid": "e8633f0a505af3ea69783b2993bd8d77", "src_uid": "e66ecb0021a34042885442b336f3d911", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.IO;\nusing System.Text;\n\nnamespace The_number_of_positions\n{\n internal class Program\n {\n private static readonly StreamReader reader = new StreamReader(Console.OpenStandardInput(1024*10), Encoding.ASCII, false, 1024*10);\n private static readonly StreamWriter writer = new StreamWriter(Console.OpenStandardOutput(1024*10), Encoding.ASCII, 1024*10);\n\n private static void Main(string[] args)\n {\n int n = Next();\n int a = Next() + 1;\n int b = Next();\n int pos = Math.Max(a, n - b);\n\n writer.WriteLine(n - pos + 1);\n writer.Flush();\n }\n\n private static int Next()\n {\n int c;\n int res = 0;\n do\n {\n c = reader.Read();\n if (c == -1)\n return res;\n } while (c < '0' || c > '9');\n res = c - '0';\n while (true)\n {\n c = reader.Read();\n if (c < '0' || c > '9')\n return res;\n res *= 10;\n res += c - '0';\n }\n }\n }\n}", "lang_cluster": "C#", "tags": ["math"], "code_uid": "6cc190e0c17e547030622530402d8900", "src_uid": "51a072916bff600922a77da0c4582180", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "/*\n\n */\nusing System;\nusing System.Collections.Generic;\nusing System.Globalization;\nusing System.IO;\nusing System.Linq;\nusing System.Text;\nusing System.Threading;\nusing System.Diagnostics;\n\npublic class Solver\n{\n public void Solve()\n {\n Trace.WriteLine(\"hello world!\");\n int n = ReadInt();\n int a = ReadInt();\n int b = ReadInt();\n int m = n - Math.Max(a+1, n-b) + 1;\n Write(m);\n }\n\n #region Main\n\n protected static TextReader reader;\n protected static TextWriter writer;\n static void Main()\n {\n#if DEBUG\n Trace.Listeners.Add(new TextWriterTraceListener(Console.Out));\n // reader = new StreamReader(\"..\\..\\input.txt\");\n reader = new StreamReader(Console.OpenStandardInput());\n writer = Console.Out;\n //writer = new StreamWriter(\"..\\..\\output.txt\");\n#else\n reader = new StreamReader(Console.OpenStandardInput());\n writer = new StreamWriter(Console.OpenStandardOutput());\n //reader = new StreamReader(\"input.txt\");\n //writer = new StreamWriter(\"output.txt\");\n#endif\n try\n {\n new Solver().Solve();\n //var thread = new Thread(new Solver().Solve, 1024 * 1024 * 128);\n //thread.Start();\n //thread.Join();\n }\n catch \n {\n#if DEBUG\n // Console.WriteLine(ex);\n#else\n throw;\n#endif\n }\n reader.Close();\n writer.Close();\n }\n\n #endregion\n\n #region Read / Write\n private static Queue currentLineTokens = new Queue();\n private static string[] ReadAndSplitLine() { return reader.ReadLine().Split(new[] { ' ', '\\t', }, StringSplitOptions.RemoveEmptyEntries); }\n public static string ReadToken() { while (currentLineTokens.Count == 0)currentLineTokens = new Queue(ReadAndSplitLine()); return currentLineTokens.Dequeue(); }\n public static int ReadInt() { return int.Parse(ReadToken()); }\n public static long ReadLong() { return long.Parse(ReadToken()); }\n public static double ReadDouble() { return double.Parse(ReadToken(), CultureInfo.InvariantCulture); }\n public static int[] ReadIntArray() { return ReadAndSplitLine().Select(int.Parse).ToArray(); }\n public static long[] ReadLongArray() { return ReadAndSplitLine().Select(long.Parse).ToArray(); }\n public static double[] ReadDoubleArray() { return ReadAndSplitLine().Select(s => double.Parse(s, CultureInfo.InvariantCulture)).ToArray(); }\n public static int[][] ReadIntMatrix(int numberOfRows) { int[][] matrix = new int[numberOfRows][]; for (int i = 0; i < numberOfRows; i++)matrix[i] = ReadIntArray(); return matrix; }\n public static int[][] ReadAndTransposeIntMatrix(int numberOfRows)\n {\n int[][] matrix = ReadIntMatrix(numberOfRows); int[][] ret = new int[matrix[0].Length][];\n for (int i = 0; i < ret.Length; i++) { ret[i] = new int[numberOfRows]; for (int j = 0; j < numberOfRows; j++)ret[i][j] = matrix[j][i]; } return ret;\n }\n public static string[] ReadLines(int quantity) { string[] lines = new string[quantity]; for (int i = 0; i < quantity; i++)lines[i] = reader.ReadLine().Trim(); return lines; }\n public static void WriteArray(IEnumerable array) { writer.WriteLine(string.Join(\" \", array)); }\n public static void Write(params object[] array) { WriteArray(array); }\n public static void WriteLines(IEnumerable array) { foreach (var a in array)writer.WriteLine(a); }\n private class SDictionary : Dictionary\n {\n public new TValue this[TKey key]\n {\n get { return ContainsKey(key) ? base[key] : default(TValue); }\n set { base[key] = value; }\n }\n }\n private static T[] Init(int size) where T : new() { var ret = new T[size]; for (int i = 0; i < size; i++)ret[i] = new T(); return ret; }\n #endregion\n}\n", "lang_cluster": "C#", "tags": ["math"], "code_uid": "d05d081510cf120df3a883125dc857da", "src_uid": "51a072916bff600922a77da0c4582180", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\n\nnamespace ProgA\n{\n class Program\n {\n static long counter;\n static long n;\n static List a;\n\n\n static void Main(string[] args)\n {\n counter = 0;\n a = new List();\n n = long.Parse(Console.ReadLine());\n\n long i = 1;\n while (counter < n)\n {\n counter += a.Count + 1;\n a.Add(i++);\n }\n\n Console.WriteLine(a[a.Count - (int)(counter - n) - 1]);\n }\n }\n}", "lang_cluster": "C#", "tags": ["math", "implementation"], "code_uid": "c31ae6399303f79288c5db5b9ce967f4", "src_uid": "1db5631847085815461c617854b08ee5", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nclass some\n{\n\tpublic static void Main()\n\t{\n\t\tlong t=long.Parse(Console.ReadLine());\n\t\tlong count=0;\n\t\tfor(long kk=1;kk<=t;kk++)\n\t\t{\n\t\t\tif(count+kk>=t)\n\t\t\tfor(long j=1;j<=kk;j++)\n\t\t\t{\n\t\t\t\tcount++;\n\t\t\t\tif(count==t){Console.WriteLine(j);break;}\n\t\t\t}\n\t\t\tif(count==t)break;\n\t\t\tcount+=kk;\n\t\t}\n\t\t\n\t}\n}\n\n", "lang_cluster": "C#", "tags": ["math", "implementation"], "code_uid": "0d3e89b08c918145d1179a4077fb476a", "src_uid": "1db5631847085815461c617854b08ee5", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace A.String_Task\n{\n class Program\n {\n static void Main(string[] args)\n {\n string omar = Console.ReadLine();\n omar = omar.ToLower();\n char[] vowels = \"auioey\".ToCharArray();\n for( int i=0;i= 2 * x && (num - 2 * x) % 4 == 0)\n {\n Console.WriteLine(n);\n break;\n }\n }\n }\n }\n\n //\n\n\n\n\n\n string[] inputLine = new string[0];\n int inputInd = 0;\n string nextLine()\n {\n return Console.ReadLine();\n }\n void readInput()\n {\n if (inputInd != inputLine.Length)\n throw new Exception();\n inputInd = 0;\n inputLine = Console.ReadLine().Split();\n\n }\n int nextInt()\n {\n if (inputInd == inputLine.Length)\n readInput();\n return int.Parse(inputLine[inputInd++]);\n }\n long nextLong()\n {\n if (inputInd == inputLine.Length)\n readInput();\n return long.Parse(inputLine[inputInd++]);\n }\n double nextDouble()\n {\n if (inputInd == inputLine.Length)\n readInput();\n return double.Parse(inputLine[inputInd++]);\n }\n string nextString()\n {\n if (inputInd == inputLine.Length)\n readInput();\n return inputLine[inputInd++];\n }\n static void Main(string[] args)\n {\n new Program().solve();\n }\n}\n\n\n", "lang_cluster": "C#", "tags": ["math"], "code_uid": "e55b65e6d2bc926ce4997379067f96bd", "src_uid": "18644c9df41b9960594fdca27f1d2fec", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace Codeforces\n{\n class Program\n {\n \n static void Main(string[] args)\n {\n\n long x = long.Parse(Console.ReadLine());\n \n long i = Math.Abs(x);\n \n long c = 0, ans = -1;\n \n while (ans == -1){\n \n long s = (c * (c + 1)) / 2;\n \n if (-s <= i && i <= s && i % 2 == s % 2){\n \n ans = c;\n \n }\n \n c++;\n \n }\n \n Console.WriteLine(ans);\n\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math"], "code_uid": "e6ee3607f031de91d1f38d81ea54ef4e", "src_uid": "18644c9df41b9960594fdca27f1d2fec", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\n\nnamespace ConsoleApplication17\n{\n class Program\n {\n static void Main(string[] args)\n {\n var init = Console.ReadLine().Split(' ');\n\n var n = int.Parse(init[0]);\n var m = int.Parse(init[1]);\n var a = int.Parse(init[2]);\n var b = int.Parse(init[3]);\n\n var minCost = n % m == 0 ? (n/m) * b : ((n/m) + 1) * b;\n\n for (int i = 0; i < n; i++)\n {\n var cost1 = a * i + ((n - i) / m) * b + ((n - i) - ((n - i)/m) * m) * a;\n minCost = Math.Min(minCost, cost1);\n }\n\n Console.WriteLine(minCost);\n Console.ReadLine();\n\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "f2ce7111dd863f957821b48aaa26d9f4", "src_uid": "faa343ad6028c5a069857a38fa19bb24", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": ".NET Core C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Data;\nusing System.Diagnostics.CodeAnalysis;\nusing System.Linq;\nusing System.Text;\n\nnamespace Codeforces\n{\n class Program\n {\n private static string readString() => Console.ReadLine();\n private static T readValue() => (T)Convert.ChangeType(readString(), typeof(T));\n private static string[] readStrings(char delimiter = ' ') => readString().Split(delimiter);\n private static T[] readValues(char delimiter = ' ') => readStrings(delimiter: delimiter).Select(x => (T)Convert.ChangeType(x, typeof(T))).ToArray();\n private static void write(T s) => Console.WriteLine(s);\n\n private static int binarySearch(List list, T target) where T : IComparable\n {\n int l = 0, r = list.Count - 1;\n while (l <= r)\n {\n var m = (int)Math.Floor((double)(l + r) / 2);\n if (list[m].CompareTo(target) <= 0)\n if (m == r || list[m + 1].CompareTo(target) > 0)\n return m;\n else\n l = m + 1;\n else\n r = m - 1;\n }\n return -1;\n }\n\n private static int quickSortPartition(List list, int left, int right) where T : IComparable\n {\n T pivot = list[left];\n while (true)\n {\n while (list[left].CompareTo(pivot) < 0)\n left++;\n while (list[right].CompareTo(pivot) > 0)\n right--;\n if (left < right)\n {\n if (list[left].CompareTo(list[right]) == 0)\n return right;\n\n T temp = list[left];\n list[left] = list[right];\n list[right] = temp;\n }\n else\n return right;\n }\n }\n private static void quickSort(List list, int left, int right) where T : IComparable\n {\n if (left < right)\n {\n int pivot = quickSortPartition(list, left, right);\n if (pivot > 1)\n quickSort(list, left, pivot - 1);\n if (pivot + 1 < right)\n quickSort(list, pivot + 1, right);\n }\n }\n private static void quickSort(List list) where T : IComparable => quickSort(list, 0, list.Count - 1);\n\n private static void watermelon()\n {\n var w = readValue();\n write(w >= 4 && w % 2 == 0 ? \"YES\" : \"NO\");\n }\n private static void wayTooLongWords()\n {\n var words = new List();\n\n var n = readValue();\n for (int i = 0; i < n; ++i)\n words.Add(readString());\n\n foreach (var word in words)\n write(word.Length <= 10 ? word : $\"{word.First()}{word.Length - 2}{word.Last()}\");\n }\n private static void team()\n {\n int solve = 0;\n\n var n = readValue();\n for (int i = 0; i < n; ++i)\n if (readValues().Where(x => x == 1).Count() > 1)\n ++solve;\n\n write(solve);\n }\n private static void football()\n {\n var positions = readString();\n for (int i = 6; i < positions.Length; ++i)\n if (positions.Substring(i - 6, 6) == (positions[i] == '0' ? \"000000\" : \"111111\"))\n {\n write(\"YES\");\n return;\n }\n write(\"NO\");\n }\n private static void theatreSquare()\n {\n var sizes = readValues();\n write((long)Math.Ceiling((double)sizes[0] / (double)sizes[2]) * (long)Math.Ceiling((double)sizes[1] / (double)sizes[2]));\n }\n private static void stringTask()\n {\n var Vowels = new HashSet { 'a', 'o', 'y', 'e', 'u', 'i' };\n var sb = new StringBuilder();\n var s = readString().ToLower();\n foreach (var c in s)\n if (!Vowels.Contains(c))\n {\n sb.Append('.');\n sb.Append(c);\n }\n\n write(sb.ToString());\n }\n private static void taxi()\n {\n int taxis = 0;\n var groups = new Dictionary { { 1, 0 }, { 2, 0 }, { 3, 0 } };\n\n readValue();\n var groupSizes = readValues();\n foreach (var size in groupSizes)\n if (size == 4)\n ++taxis;\n else\n groups[size] = groups[size] + 1;\n\n taxis += groups[3];\n groups[1] = groups[1] - Math.Min(groups[1], groups[3]);\n\n taxis += groups[2] / 2;\n if (groups[2] % 2 == 1)\n {\n ++taxis;\n groups[1] = groups[1] - 2;\n }\n\n if (groups[1] > 0)\n taxis += (int)Math.Ceiling((double)groups[1] / 4.0);\n\n write(taxis);\n }\n private static void fancyFence()\n {\n var a = readValue();\n for (double i = 3.0; ; i += 1.0)\n {\n var x = (double)(i - 2.0) * 180.0 / i;\n if (a <= x)\n {\n write(a < x ? \"NO\" : \"YES\");\n break;\n }\n }\n }\n private static void interestingDrink()\n {\n readString();\n var prices = readValues().OrderBy(x => x).ToList();\n var days = readValue();\n for (int i = 0; i < days; ++i)\n write(binarySearch(prices, readValue()) + 1);\n }\n private static void compilationErrors()\n {\n readString();\n Dictionary errors = readValues().GroupBy(x => x).ToDictionary(x => x.Key, x => x.Count()), errors1 = new Dictionary();\n foreach (var error in readValues())\n {\n if (errors[error] > 1)\n errors[error] = errors[error] - 1;\n else\n errors.Remove(error);\n\n if (errors1.TryGetValue(error, out var count))\n errors1[error] = count + 1;\n else\n errors1.Add(error, 1);\n }\n write(errors.First().Key);\n\n foreach (var error in readValues())\n if (errors1[error] > 1)\n errors1[error] = errors1[error] - 1;\n else\n errors1.Remove(error);\n write(errors1.First().Key);\n }\n private static void doubleCola()\n {\n var idToName = new Dictionary { { 0, \"Sheldon\" }, { 1, \"Leonard\" }, { 2, \"Penny\" }, { 3, \"Rajesh\" }, { 4, \"Howard\" } };\n int n = readValue(), i = 1;\n for (; n > i * 5; i *= 2)\n n -= i * 5;\n write(idToName[(n - 1) / i]);\n }\n private static void ilyaAndQueries()\n {\n var dic = new Dictionary();\n var list = new List>();\n\n var s = readString();\n int start = 0, dicStart = 0;\n for (int j = 0; j < s.Length - 1; ++j)\n if (s[j] != s[j + 1])\n {\n if (start < j)\n {\n list.Add(new Tuple(start + 1, j + 1));\n for (; dicStart < j + 1; ++dicStart)\n dic.Add(dicStart, list.Count - 1);\n }\n start = j + 1;\n }\n if (start < s.Length - 1)\n {\n list.Add(new Tuple(start + 1, s.Length));\n for (; dicStart < s.Length; ++dicStart)\n dic.Add(dicStart, list.Count - 1);\n }\n\n var m = readValue();\n for (int j = 0; j < m; ++j)\n {\n var q = readValues();\n int l = q[0], r = q[1], result = 0;\n if (dic.TryGetValue(l, out var i))\n for (; i < list.Count && r >= list[i].Item1; ++i)\n if (l < list[i].Item2)\n result += Math.Min(r, list[i].Item2) - Math.Max(l, list[i].Item1);\n write(result);\n }\n }\n private static void twoTeamsComposing()\n {\n var n = readValue();\n var skills = readValues().GroupBy(x => x).ToDictionary(x => x.Key, x => x.Count());\n }\n #region Laptop\n private class Laptop\n {\n internal int Price { get; private set; }\n internal int Quality { get; private set; }\n internal Laptop(int[] values)\n {\n Price = values[0];\n Quality = values[1];\n }\n }\n private class Laptop_Comparer_Price : Comparer\n {\n public override int Compare([AllowNull] Laptop x, [AllowNull] Laptop y) => x.Price - y.Price;\n }\n private class Laptop_Comparer_Quality : Comparer\n {\n public override int Compare([AllowNull] Laptop x, [AllowNull] Laptop y) => x.Quality - y.Quality;\n }\n private static void laptops()\n {\n List prices = new List(), qualities = new List();\n var n = readValue();\n for (int i = 0; i < n; ++i)\n {\n var laptop = new Laptop(readValues());\n prices.Add(laptop);\n qualities.Add(laptop);\n }\n\n for (int i = 0; i < n; ++i)\n if (prices[i] != qualities[i])\n {\n write(\"Happy Alex\");\n return;\n }\n write(\"Poor Alex\");\n }\n #endregion\n private static void fence()\n {\n int k = readValues()[1], minI = 0, currentH = 0;\n int[] h = readValues();\n\n for (int i = 0; i < k; ++i)\n currentH += h[i];\n var minH = currentH;\n\n for (int i = 1; i < h.Length - k + 1; ++i)\n {\n currentH = currentH - h[i - 1] + h[i + k - 1];\n if (minH > currentH)\n {\n minH = currentH;\n minI = i;\n }\n }\n\n write(minI + 1);\n }\n #region serejaAndSuffixes\n private class SerejaL : IComparable\n {\n internal int L { get; private set; }\n internal int Result;\n internal SerejaL(int l)\n {\n L = l;\n }\n\n public int CompareTo(object obj) => L - ((SerejaL)obj).L;\n }\n private static void serejaGetLs(int m, out List listDistinct, out List listOrdered)\n {\n listDistinct = new List();\n listOrdered = new List();\n var dic = new Dictionary();\n for (int i = 0; i < m; ++i)\n {\n var l = readValue() - 1;\n if (!dic.TryGetValue(l, out var item))\n {\n item = new SerejaL(l);\n dic.Add(l, item);\n listDistinct.Add(item);\n }\n listOrdered.Add(item);\n }\n quickSort(listDistinct);\n }\n private static void serejaAndSuffixes()\n {\n var m = readValues()[1];\n var a = readValues();\n serejaGetLs(m, out var listDistinct, out var listOrdered);\n\n var distinct = new HashSet();\n for (int i = listDistinct.Count - 1, j = a.Length - 1; i >= 0; --i)\n {\n for (; j >= listDistinct[i].L; --j)\n if (!distinct.Contains(a[j]))\n distinct.Add(a[j]);\n\n listDistinct[i].Result = distinct.Count;\n }\n\n foreach (var item in listOrdered)\n write(item.Result);\n }\n #endregion\n private static void bowWowTimetable()\n {\n string s = readString(), r = \"1\";\n int i = 1;\n for (; r.Length < s.Length; ++i, r = r + \"00\") ;\n if (r.Length > s.Length || !s.Substring(1).Contains('1'))\n write(i - 1);\n else\n write(i);\n }\n private static void digits()\n {\n readString();\n var numbers = readValues().GroupBy(x => x).ToDictionary(x => x.Key, x => x.Count());\n if (!numbers.ContainsKey(0))\n {\n write(-1);\n return;\n }\n }\n private static void lifeWithoutZeros()\n {\n long a = readValue(), b = readValue(), c = a + b;\n write(Convert.ToInt64(a.ToString().Replace(\"0\", \"\")) + Convert.ToInt64(b.ToString().Replace(\"0\", \"\")) == Convert.ToInt64(c.ToString().Replace(\"0\", \"\")) ? \"YES\" : \"NO\");\n }\n private static void permutation()\n {\n var n = readValue();\n var a = readValues();\n write(n - a.Where(x => x <= n).Distinct().Count());\n }\n private static void hamsterFarm()\n {\n var n = readValues()[0];\n var k = readValues();\n int bestI = 0;\n for (int i = 1; i < k.Length; ++i)\n if (n % k[i] < n % k[bestI])\n bestI = i;\n write($\"{bestI + 1} {n / k[bestI]}\");\n }\n private static void shellGame()\n {\n int n = readValue(), x = readValue();\n if (x == 1)\n {\n if (n % 2 == 1)\n x = 0;\n else\n x = 2;\n --n;\n }\n for (int i = n % 6; i > 0; --i)\n if (i % 2 == 1)\n {\n if (x == 0)\n x = 1;\n else if (x == 1)\n x = 0;\n }\n else if (x == 1)\n x = 2;\n else if (x == 2)\n x = 1;\n write(x);\n }\n private static void ACM_ICPC()\n {\n int[] a = readValues(), score = new int[2], members = new int[2];\n for (int i1 = 0; i1 < 2; ++i1)\n {\n score[i1] = a[0];\n members[i1] = 1;\n for (int i2 = 0; i2 < 2; ++i2)\n {\n score[i2] += a[1];\n members[i2] += 1;\n for (int i3 = 0; i3 < 2; ++i3)\n {\n score[i3] += a[2];\n members[i3] += 1;\n for (int i4 = 0; i4 < 2; ++i4)\n if (members[i4] < 3)\n {\n score[i4] += a[3];\n members[i4] += 1;\n for (int i5 = 0; i5 < 2; ++i5)\n if (members[i5] < 3)\n {\n score[i5] += a[4];\n members[i5] += 1;\n for (int i6 = 0; i6 < 2; ++i6)\n if (members[i6] < 3)\n {\n score[i6] += a[5];\n members[i6] += 1;\n if (score[0] == score[1])\n {\n write(\"YES\");\n return;\n }\n score[i6] -= a[5];\n members[i6] -= 1;\n }\n score[i5] -= a[4];\n members[i5] -= 1;\n }\n score[i4] -= a[3];\n members[i4] -= 1;\n }\n score[i3] -= a[2];\n members[i3] -= 1;\n }\n score[i2] -= a[1];\n members[i2] -= 1;\n }\n score[i1] = 0;\n members[i1] = 0;\n }\n write(\"NO\");\n }\n private static void mex()\n {\n var x = readValues()[1];\n var n = readValues();\n write(x - n.Count(y => y < x) + (n.Contains(x) ? 1 : 0));\n }\n private static void minimumProduct()\n {\n var input = readValues();\n int a = input[0], b = input[1], x = input[2], y = input[3], n = input[4], minA = Math.Min(a - x, n), minB = Math.Min(b - y, n);\n if (a - minA <= b - minB)\n {\n a -= minA;\n n -= minA;\n }\n else\n {\n b -= minB;\n n -= minB;\n }\n\n if (n > 0)\n if (a > x)\n a -= Math.Min(a - x, n);\n else if (b > y)\n b -= Math.Min(b - y, n);\n\n write((long)a * (long)b);\n }\n private static void shovelsAndSwords()\n {\n var input = readValues();\n int a = input[0], b = input[1], result = 0;\n if (a > b)\n {\n var min = Math.Min(a - b, b);\n a -= min * 2;\n b -= min;\n result += min;\n }\n else if (b > a)\n {\n var min = Math.Min(b - a, a);\n a -= min;\n b -= min * 2;\n result += min;\n }\n int d = Math.Min(a / 3, b / 3);\n a -= d * 3;\n b -= d * 3;\n result += d * 2;\n if (a > 0 && b > 0 && (a > 1 || b > 1))\n ++result;\n write(result);\n }\n private static void matrixGame()\n {\n var input = readValues();\n int n = input[0], m = input[1];\n HashSet claimedRows = new HashSet(), claimedColumns = new HashSet();\n for (int i = 0; i < n; ++i)\n {\n input = readValues();\n for (int j = 0; j < m; ++j)\n if (input[j] == 1)\n {\n if (!claimedRows.Contains(i))\n claimedRows.Add(i);\n if (!claimedColumns.Contains(j))\n claimedColumns.Add(j);\n }\n }\n write(Math.Min(n - claimedRows.Count, m - claimedColumns.Count) % 2 == 0 ? \"Vivek\" : \"Ashish\");\n }\n private static void cinemaLine()\n {\n readString();\n var clerk = new Dictionary { { 25, 0 }, { 50, 0 } };\n foreach (var a in readValues())\n switch (a)\n {\n case 25:\n clerk[25] += 1;\n break;\n case 50:\n if (clerk[25] > 0)\n {\n clerk[25] -= 1;\n clerk[50] += 1;\n }\n else\n {\n write(\"NO\");\n return;\n }\n break;\n default: // 100\n if (clerk[50] > 0 && clerk[25] > 0)\n {\n clerk[25] -= 1;\n clerk[50] -= 1;\n }\n else if (clerk[25] > 2)\n clerk[25] -= 3;\n else\n {\n write(\"NO\");\n return;\n }\n break;\n }\n write(\"YES\");\n }\n private static void kindAnton()\n {\n readString();\n int[] a = readValues(), b = readValues();\n bool positive1 = false, negative1 = false;\n HashSet positive = new HashSet(), negative = new HashSet();\n for (int i = 0; i < a.Length; ++i)\n {\n int diff = b[i] - a[i];\n if (((diff > 0 && !positive1) || (diff < 0 && !negative1)) && !(diff > 0 ? positive : negative).Any(x => diff % x == 0))\n {\n write(\"NO\");\n return;\n }\n if (a[i] > 0)\n {\n if (!positive1)\n if (a[i] == 1)\n {\n positive1 = true;\n if (negative1)\n {\n write(\"YES\");\n return;\n }\n }\n else if (!positive.Contains(a[i]))\n positive.Add(a[i]);\n }\n else if (a[i] < 0 && !negative1)\n if (a[i] == -1)\n {\n negative1 = true;\n if (positive1)\n {\n write(\"YES\");\n return;\n }\n }\n else if (!negative.Contains(a[i]))\n negative.Add(a[i]);\n }\n write(\"YES\");\n }\n private static void staircases()\n {\n var input = readValues();\n int n = input[0], mn = input[1];\n if (mn == 0)\n {\n write(\"YES\");\n return;\n }\n var m = readValues().OrderBy(x => x).ToList();\n if (m[0] == 1 || m[m.Count - 1] == n)\n {\n write(\"NO\");\n return;\n }\n for (int i = 0; i < m.Count - 2; ++i)\n if (m[i] == m[i + 1] - 1 && m[i] == m[i + 2] - 2)\n {\n write(\"NO\");\n return;\n }\n write(\"YES\");\n }\n private static void blownGarland()\n {\n var colors = new Dictionary { { 'R', 0 }, { 'Y', 0 }, { 'B', 0 }, { 'G', 0 } };\n var s = readString();\n\n var colorPerPosition = new char[4];\n foreach (var color in colors)\n colorPerPosition[s.IndexOf(color.Key) % 4] = color.Key;\n\n for (int i = 0; i < s.Length; ++i)\n if (s[i] == '!')\n colors[colorPerPosition[i % 4]] += 1;\n\n write($\"{colors['R']} {colors['B']} {colors['Y']} {colors['G']}\");\n }\n private static void mikeAndFax()\n {\n var s = readString();\n int k = readValue();\n\n if (s.Length % k != 0)\n {\n write(\"NO\");\n return;\n }\n\n int size = s.Length / k;\n for (int i = 0; i < s.Length; i += size)\n for (int j1 = i + size / 2 - 1, j2 = i + size / 2 + size % 2; j1 >= i; --j1, ++j2)\n if (s[j1] != s[j2])\n {\n write(\"NO\");\n return;\n }\n\n write(\"YES\");\n }\n #region weirdRounding\n private static bool weirdRounding_Recursion(string ns, int kp, int d)\n {\n if (d > 0)\n for (int i = ns[1] == '0' && ns.Length > 2 ? 1 : 0; i < ns.Length; ++i)\n {\n string nsNew = ns.Remove(i, 1);\n int n = Convert.ToInt32(nsNew);\n if (n % kp == 0 || weirdRounding_Recursion(nsNew, kp, d - 1))\n return true;\n }\n return false;\n }\n private static void weirdRounding()\n {\n var input = readStrings();\n string ns = input[0];\n int n = Convert.ToInt32(ns), k = Convert.ToInt32(input[1]), kp = (int)Math.Pow(10, k);\n\n if (n < kp)\n write(ns.Length - 1);\n else if (n % kp == 0)\n write(0);\n else\n for (int d = 1; d < ns.Length; ++d)\n if (weirdRounding_Recursion(ns, kp, d))\n {\n write(d);\n return;\n }\n }\n #endregion\n private static void wilburArray()\n {\n readString();\n int[] b = readValues();\n long result = Math.Abs(b[0]);\n for (int i = 1; i < b.Length; ++i)\n result += Math.Abs(b[i] - b[i - 1]);\n write(result);\n }\n private static void zuhairStrings()\n {\n int k = readValues()[1];\n var s = readString();\n var result = new Dictionary();\n\n for (int i = 0; i < s.Length - k + 1;)\n {\n int j = i + 1;\n for (; j < i + k && s[i] == s[j]; ++j) ;\n if (j == i + k)\n if (!result.ContainsKey(s[i]))\n result.Add(s[i], 1);\n else\n result[s[i]] += 1;\n i = j;\n }\n\n write(result.Count > 0 ? result.Max(x => x.Value) : 0);\n }\n private static void artfulExpedient()\n {\n var n = readValue();\n int[] x = readValues(), y = readValues();\n var numbers = x.Union(y).ToHashSet();\n var resultEven = true;\n\n for (int i = 0; i < n; ++i)\n for (int j = 0; j < n; ++j)\n if (numbers.Contains(x[i] ^ y[j]))\n resultEven = !resultEven;\n\n write(resultEven ? \"Karen\" : \"Koyomi\");\n }\n private static void ebonyIvory()\n {\n var input = readValues();\n int a = input[0], b = input[1], c = input[2];\n if (a < b)\n {\n var t = a;\n a = b;\n b = t;\n }\n for (; c >= 0; c -= a)\n if (c % b == 0)\n {\n write(\"Yes\");\n return;\n }\n write(\"No\");\n }\n #region Lala Land Apple Trees\n private class LalaLand_AppleTree : IComparable\n {\n private int coordinate;\n internal int Apples { get; private set; }\n internal LalaLand_AppleTree(int coordinate, int apples)\n {\n this.coordinate = coordinate;\n Apples = apples;\n }\n public int CompareTo(object obj) => coordinate - ((LalaLand_AppleTree)obj).coordinate;\n }\n private static void lalaLandAppleTrees()\n {\n var n = readValue();\n List right = new List(), left = new List();\n for (int i = 0; i < n; ++i)\n {\n var input = readValues();\n if (input[0] > 0)\n right.Add(new LalaLand_AppleTree(input[0], input[1]));\n else\n left.Add(new LalaLand_AppleTree(-input[0], input[1]));\n }\n\n if (Math.Abs(right.Count - left.Count) < 2)\n write(right.Sum(x => x.Apples) + left.Sum(x => x.Apples));\n else\n {\n quickSort(right);\n quickSort(left);\n if (right.Count > left.Count)\n write(right.GetRange(0, left.Count + 1).Sum(x => x.Apples) + (left.Count > 0 ? left.Sum(x => x.Apples) : 0));\n else\n write((right.Count > 0 ? right.Sum(x => x.Apples) : 0) + left.GetRange(0, right.Count + 1).Sum(x => x.Apples));\n }\n }\n #endregion\n private static void lanterns()\n {\n int l = readValues()[1], d = 0;\n var a = readValues().Distinct().ToList();\n quickSort(a);\n for (int i = 0; i < a.Count - 1; ++i)\n {\n var diff = a[i + 1] - a[i];\n if (diff > d)\n d = diff;\n }\n if (a[0] > 0 && a[a.Count - 1] < l)\n write(Math.Max(Math.Max(a[0] - 0, l - a[a.Count - 1]), d / 2.0));\n else if (a[0] > 0)\n write(Math.Max(a[0] - 0, d / 2.0));\n else if (a[a.Count - 1] < l)\n write(Math.Max(l - a[a.Count - 1], d / 2.0));\n else\n write((double)d / 2.0);\n }\n private static void cheapTravel()\n {\n var input = readValues();\n int n = input[0], m = input[1], a = input[2], b = input[3];\n if (b >= a * m)\n write(n * a);\n else\n write((n / m) * b + ((n % m) * a < b ? (n % m) * a : b));\n }\n\n static void Main(string[] args)\n {\n //var t = readValue();\n //for (int i = 0; i < t; ++i)\n cheapTravel();\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "aea2add4f17523fbc8700bf22bf8ddac", "src_uid": "faa343ad6028c5a069857a38fa19bb24", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace ConsoleApplication24\n{\n class Program\n {\n static void Main(string[] args)\n {\n int a = Convert.ToInt32(Console.ReadLine());\n int b = Convert.ToInt32(Console.ReadLine());\n int c = Convert.ToInt32(Console.ReadLine());\n b = b / 2;\n c = c / 4;\n int x = Math.Min(a, b);\n x = Math.Min(x, c);\n Console.WriteLine(x*7);\n\n }\n }\n}\n\n \n \n\n\n", "lang_cluster": "C#", "tags": ["math", "implementation"], "code_uid": "df7f04c68cffe032ffa9e86ae1481bb6", "src_uid": "82a4a60eac90765fb62f2a77d2305c01", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace ConsoleApplication13\n{\n class Program\n {\n static void Main(string[] args)\n {\n\n {\n int z = 0;\n int a = int.Parse(Console.ReadLine());\n int b = int.Parse(Console.ReadLine());\n int c = int.Parse(Console.ReadLine());\n while (a != 0 && b >= 2 && c >= 4)\n {\n a--;\n b = b - 2;\n c = c - 4;\n z += 7;\n }\n Console.WriteLine(z);\n \n }\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "implementation"], "code_uid": "f3a4edc04d11b7641fdf4910a39fbc22", "src_uid": "82a4a60eac90765fb62f2a77d2305c01", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.IO;\nusing System.Collections;\nusing System.Collections.Generic;\n\nnamespace G4\n{\n class Program\n {\n static void Main(string[] args)\n {\n int[] Steps = new int[10];\n Steps[0] = 1;\n for (int i = 1; i < 10; i++)\n {\n Steps[i] = Steps[i - 1] * 10;\n }\n\n int n = int.Parse(Console.ReadLine());\n int[] a = new int[n];\n string[] sin = Console.ReadLine().Split(' ');\n for (int i = 0; i < n;i++)\n {\n a[i] = int.Parse(sin[i]);\n }\n\n Array.Sort(a);\n\n int count = 0;\n\n if (a[0] != 0)\n {\n count++;\n }\n\n for (int i = 1; i < n; i++)\n {\n if (a[i] != a[i-1])\n {\n count++;\n }\n }\n\n Console.Write(count);\n }\n }\n}", "lang_cluster": "C#", "tags": ["sortings", "implementation"], "code_uid": "e013fc49e748b9610dee6112379aff4a", "src_uid": "3b520c15ea9a11b16129da30dcfb5161", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Diagnostics;\n\nnamespace CF\n{\n public static class FromConsole\n {\n public static T To(this string input) where T : IConvertible\n {\n return (T)Convert.ChangeType(input, typeof(T));\n }\n\n public static T[] ToArrayOf(this string input, char? delimiter = null) where T : IConvertible\n {\n IEnumerable sequence = delimiter == null ? input.Select(x => x.ToString()) : input.Split(delimiter.Value);\n\n return sequence.Select(x => x.ToString().To()).ToArray();\n }\n\n public static T[] ToArrayOf(int count) where T : IConvertible\n {\n T[] output = new T[count];\n\n for (int i = 0; i < count; i++)\n {\n output[i] = Console.ReadLine().To();\n }\n\n return output;\n }\n\n public static T[] ToArrayOf(T value, int count)\n {\n return Enumerable.Repeat(value, count).ToArray();\n }\n\n public static T[][] ToMatrixOf(int n, char? delimiter = null) where T : IConvertible\n {\n T[][] output = new T[n][];\n\n for (int i = 0; i < n; i++)\n {\n output[i] = Console.ReadLine().ToArrayOf(delimiter);\n }\n\n return output;\n }\n\n public static T[][] ToMatrixOf(T value, int n, int m)\n {\n T[][] output = new T[n][];\n\n for (int i = 0; i < n; i++)\n {\n output[i] = ToArrayOf(value, m);\n }\n\n return output;\n }\n\n public static Tuple IndexOf(this T[][] input, params T[] targets)\n {\n for (int i = 0; i < input.Length; i++)\n {\n for (int j = 0; j < input[0].Length; j++)\n {\n if (targets.Any(x => x.Equals(input[i][j])))\n {\n return new Tuple(i, j);\n }\n }\n }\n\n return new Tuple(-1, -1);\n }\n\n public static void AddToList(this Dictionary> input, T k, U v)\n {\n if (input.ContainsKey(k))\n {\n input[k].Add(v);\n }\n else\n {\n input.Add(k, new List() { v });\n }\n }\n\n public static void AddAndIncrement(this Dictionary input, T k)\n {\n if (input.ContainsKey(k))\n {\n input[k]++;\n }\n else\n {\n input.Add(k, 1);\n }\n }\n\n public static string ToBinary(this long input)\n {\n return Convert.ToString(input, 2);\n }\n\n public static long ToDecimal(this string input)\n {\n return Convert.ToInt32(input, 2);\n }\n\n public static long Binomial(long n, long k)\n {\n long r = 1;\n long d;\n if (k > n) return 0;\n for (d = 1; d <= k; d++)\n {\n r *= n--;\n r /= d;\n }\n return r;\n }\n }\n\n class Program\n {\n static void Main(string[] args)\n {\n int n = Console.ReadLine().To();\n int[] scores = Console.ReadLine().ToArrayOf(' ');\n\n Console.WriteLine(scores.Where(x => x > 0).Distinct().Count());\n //Console.ReadKey();\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["sortings", "implementation"], "code_uid": "f3e84a85cb37e2cf3359cb4342d011ba", "src_uid": "3b520c15ea9a11b16129da30dcfb5161", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace ConsoleApplication5\n{\n class Program\n {\n static void Main(string[] args)\n {\n var n = double.Parse(Console.ReadLine()) - 1;\n var k = Math.Floor(Math.Log(n / 5 + 1, 2));\n var geomSumm = -5*(1 - Math.Pow(2,k));\n var nModGeomSumm = n - geomSumm;\n var need = (int)nModGeomSumm / (int)Math.Pow(2,k);\n switch (need)\n {\n case 0:\n Console.WriteLine(\"Sheldon\");\n break;\n case 1:\n Console.WriteLine(\"Leonard\");\n break;\n case 2:\n Console.WriteLine(\"Penny\");\n break;\n case 3:\n Console.WriteLine(\"Rajesh\");\n break;\n case 4:\n Console.WriteLine(\"Howard\");\n break;\n }\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "implementation"], "code_uid": "cd99f61fd65f2aa79314a0b757d360ad", "src_uid": "023b169765e81d896cdc1184e5a82b22", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\n\nnamespace ConsoleApplication1\n{\n class Program\n {\n static void Main(string[] args)\n {\n double a = 0;\n double b = 0;\n string c = \"\";\n bool d = true;\n double i = 1;\n double n = double.Parse(Console.ReadLine());\n while( d == true)\n {\n a += i * 5;\n if (a >= n)\n {\n b = (n - (a-i*5));\n if (b / i <= 1 && b / i > 0)\n c = \"Sheldon\";\n else if (b / i <= 2 && b / i > 1)\n c = \"Leonard\";\n else if (b / i <= 3 && b / i > 2)\n c = \"Penny\";\n else if (b / i <= 4 && b / i > 3)\n c = \"Rajesh\";\n else if (b / i <= 5 && b / i > 4)\n c = \"Howard\";\n d = false;\n }\n i = i*2;\n }\n\n Console.WriteLine(c);\n\n Console.ReadLine();\n }\n }\n}", "lang_cluster": "C#", "tags": ["math", "implementation"], "code_uid": "3c0cb0c8d3e95827d4e1c8a70005a1a4", "src_uid": "023b169765e81d896cdc1184e5a82b22", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\n//using System.Collections.Generic;\n//using System.Linq;\n//using System.Text;\n//using System.Threading.Tasks;\n\nnamespace Problem379A {\n class Program {\n static void Main(string[] args) {\n string[] input = Console.ReadLine().Split(' ');\n int candles = Convert.ToInt32(input[0]);\n int newCandleRequirement = Convert.ToInt32(input[1]);\n\n int hours = 0;\n int newCandles = 0;\n int oldCandles = 0;\n\n while (candles != 0) {\n hours += candles;\n\n newCandles = candles / newCandleRequirement;\n oldCandles += (candles - newCandles*newCandleRequirement);\n\n candles = newCandles;\n if (oldCandles >= newCandleRequirement) {\n candles++;\n oldCandles -= newCandleRequirement;\n }\n }\n\n Console.WriteLine(hours);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "17bf4c83c1a38a9e759ac11626d9d764", "src_uid": "a349094584d3fdc6b61e39bffe96dece", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\n\nnamespace Main\n{\n\tclass MainClass\n\t{\n\t\tpublic static void Main (string[] args)\n\t\t{\t\n\t\t\tstring[] map = Console.ReadLine ().Split (' ');\n\t\t\tint a = Convert.ToInt32 (map[0]);\n\t\t\tint b = Convert.ToInt32 (map[1]);\n\n\t\t\tint t = 0;\n\t\t\tint p = 0;\n\n\t\t\twhile (a > 0) {\n\t\t\t\tt++;\n\t\t\t\tp++;\n\t\t\t\ta--;\n\t\t\t\tif (p % b == 0){\n\t\t\t\t\ta++;\n\t\t\t\t\tp = 0;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tConsole.WriteLine (t);\n\t\t}\n\t}\n}", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "e2402e1b843f855f36c6e637065d932a", "src_uid": "a349094584d3fdc6b61e39bffe96dece", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Linq;\nusing System.Collections.Generic;\nusing System.Text;\n\n\nnamespace MakeCalendar\n{\n public static class MainClass\n {\n\n static int ReadIntLine()\n {\n return int.Parse(Console.ReadLine());\n }\n\n static void ReadInt(ref int a)\n {\n a = ReadIntArrayLine()[0];\n }\n\n static void ReadInts(ref int a, ref int b)\n {\n var x = ReadIntArrayLine();\n a = x[0]; b = x[1];\n }\n\n\n\n static void ReadInts(ref int a, ref int b, ref int c)\n {\n var x = ReadIntArrayLine();\n a = x[0]; b = x[1]; c = x[2];\n }\n\n static void ReadInts(ref int a, ref int b, ref int c, ref int d)\n {\n var x = ReadIntArrayLine();\n a = x[0]; b = x[1]; c = x[2]; d = x[3];\n }\n\n\n static int[] ReadIntArrayLine()\n {\n char[] sep = { ' ' };\n return Console.ReadLine().Split(sep, StringSplitOptions.RemoveEmptyEntries).Select(x => int.Parse(x)).ToArray();\n }\n\n static void PrintLn(object obj)\n {\n Console.WriteLine(obj.ToString());\n }\n\n public static string Reverse(string s)\n {\n char[] charArray = s.ToCharArray();\n Array.Reverse(charArray);\n return new string(charArray);\n }\n\n\n public static void PrintLnCollection(IEnumerable col)\n {\n PrintLn(string.Join(\" \", col));\n }\n\n public static string ReadLine()\n {\n return Console.ReadLine();\n }\n\n\n public static string MySubstring(this string str, int start, int finish)\n {\n return str.Substring(start, finish - start + 1);\n }\n\n\n public static bool IsInRange(this int a, int lb, int ub)\n {\n return (a >= lb) && (a <= ub);\n }\n\n //----------------------------------------------------------------------------\n\n\n static Mat mult(Mat m1, Mat m2, int p)\n {\n var res = new Mat();\n\n res.a = (m1.a * m2.a + m1.b * m2.c)%p;\n res.b = (m1.a * m2.b + m1.b * m2.d)%p;\n res.c = (m1.c * m2.a + m1.d * m2.c)%p;\n res.d = (m1.c * m2.b + m1.d * m2.d)%p;\n\n return res;\n }\n\n static Mat pow(Mat m, int n, int p)\n {\n if (n == 0)\n return new Mat() {a=1,c=0,d=1,b=0 };\n\n var temp = pow(m, n / 2,p);\n if (n % 2 == 0)\n return mult(temp, temp,p);\n else\n return mult(m, mult(temp, temp,p),p);\n }\n\n\n static void Main(string[] args)\n {\n int x = 0, y = 0;\n int n = 0;\n\n ReadInts(ref x, ref y);\n n = ReadIntLine();\n\n decimal ans;\n if (n==1)\n ans = x;\n else if (n==2)\n ans = y;\n else\n {\n var m = new Mat(){a=1,b=-1,c=1,d=0};\n var t = pow(m, n - 2, 1000000007);\n ans = (y * t.a + x * t.b) % 1000000007;\n }\n\n\n if (ans < 0) ans += 1000000007;\n PrintLn(ans);\n \n }\n \n \n\n\n }\n\n class Mat\n {\n public decimal a;\n public decimal b;\n public decimal c;\n public decimal d;\n }\n}", "lang_cluster": "C#", "tags": ["math", "implementation"], "code_uid": "661d54ce2eddad0930a458239c6f51c6", "src_uid": "2ff85140e3f19c90e587ce459d64338b", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "#define TRACE\n#undef DEBUG\n/*\nAuthor: w1ld [dog] inbox [dot] ru\n\n */\nusing System;\nusing System.Collections.Generic;\nusing System.Globalization;\nusing System.IO;\nusing System.Linq;\nusing System.Text;\nusing System.Threading;\nusing System.Diagnostics;\nusing static System.Math;\n\npublic class Solver\n{\n public void Solve()\n {\n // f3 = f2 - f1\n // f4 = f3 - f2\n // f5 = f4 - f3\n // ...\n // fn = f{n-1} - f{n-2}\n // fn = f{n-2} - f{n-3} - (f{n-3} - f{n-4}) \n // fn = f{n-2} - 2*f{n-3} + f{n-4}\n // fn = f{n-3} - fn-4 - 2*(f{n-4} - fn-5) + f{n-5} - f(n-6)\n // fn = f{n-3} - fn-4 - 2*(f{n-4} - fn-5) + f{n-5} - f(n-6)\n //\n // f1 \n // f2 \n // f3 = f2 - f1\n // f4 = -f1\n // f5 = -f2\n // f6 = -f2 + f1\n // f7 = f1\n // f8 = f2\n // f9 = f2 - f1\n // ... \n // \n // n%6\n // 1 = f1\n // 2 = f2\n // ... \n //\n //\n\n const long MOD = (int)(1e9 + 7);\n\n long x = ReadInt();\n long y = ReadInt();\n int n = ReadInt();\n Action MWrite = (a) => Write((a%MOD) < 0 ? (a%MOD)+MOD : a%MOD);\n switch (n % 6)\n {\n case 1:\n MWrite(x);\n break;\n case 2:\n MWrite(y);\n break;\n case 3:\n MWrite(y - x);\n break;\n case 4:\n MWrite(-x);\n break;\n case 5:\n MWrite(-y);\n break;\n case 0:\n MWrite(-y + x);\n break;\n default:\n throw new Exception();\n }\n }\n\n #region Main\n\n protected static TextReader reader;\n protected static TextWriter writer;\n static void Main()\n {\n Debug.Listeners.Clear();\n Debug.Listeners.Add(new ConsoleTraceListener());\n Trace.Listeners.Clear();\n Trace.Listeners.Add(new ConsoleTraceListener());\n\n reader = new StreamReader(Console.OpenStandardInput());\n writer = new StreamWriter(Console.OpenStandardOutput());\n new Solver().Solve();\n reader.Close();\n writer.Close();\n }\n\n #endregion\n\n #region Read / Write\n private static Queue currentLineTokens = new Queue();\n private static string[] ReadAndSplitLine() { return reader.ReadLine().Split(new[] { ' ', '\\t', }, StringSplitOptions.RemoveEmptyEntries); }\n public static string ReadToken() { while (currentLineTokens.Count == 0)currentLineTokens = new Queue(ReadAndSplitLine()); return currentLineTokens.Dequeue(); }\n public static int ReadInt() { return int.Parse(ReadToken()); }\n public static long ReadLong() { return long.Parse(ReadToken()); }\n public static double ReadDouble() { return double.Parse(ReadToken(), CultureInfo.InvariantCulture); }\n public static int[] ReadIntArray() { return ReadAndSplitLine().Select(int.Parse).ToArray(); }\n public static long[] ReadLongArray() { return ReadAndSplitLine().Select(long.Parse).ToArray(); }\n public static double[] ReadDoubleArray() { return ReadAndSplitLine().Select(s => double.Parse(s, CultureInfo.InvariantCulture)).ToArray(); }\n public static int[][] ReadIntMatrix(int numberOfRows) { int[][] matrix = new int[numberOfRows][]; for (int i = 0; i < numberOfRows; i++)matrix[i] = ReadIntArray(); return matrix; }\n public static int[][] ReadAndTransposeIntMatrix(int numberOfRows)\n {\n int[][] matrix = ReadIntMatrix(numberOfRows); int[][] ret = new int[matrix[0].Length][];\n for (int i = 0; i < ret.Length; i++) { ret[i] = new int[numberOfRows]; for (int j = 0; j < numberOfRows; j++)ret[i][j] = matrix[j][i]; } return ret;\n }\n public static string[] ReadLines(int quantity) { string[] lines = new string[quantity]; for (int i = 0; i < quantity; i++)lines[i] = reader.ReadLine().Trim(); return lines; }\n public static void WriteArray(IEnumerable array) { writer.WriteLine(string.Join(\" \", array)); }\n public static void Write(params object[] array) { WriteArray(array); }\n public static void WriteLines(IEnumerable array) { foreach (var a in array)writer.WriteLine(a); }\n private class SDictionary : Dictionary\n {\n public new TValue this[TKey key]\n {\n get { return ContainsKey(key) ? base[key] : default(TValue); }\n set { base[key] = value; }\n }\n }\n private static T[] Init(int size) where T : new() { var ret = new T[size]; for (int i = 0; i < size; i++)ret[i] = new T(); return ret; }\n #endregion\n}\n", "lang_cluster": "C#", "tags": ["math", "implementation"], "code_uid": "56f81763977cb55c7d1d0b7aaa42127e", "src_uid": "2ff85140e3f19c90e587ce459d64338b", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace N4\n{\n class Program\n {\n static void Main(string[] args)\n {\n string n, s;\n int pos = 0;\n byte count;\n\n s = \"4\";\n\n // Console.Write(\"\u0412\u0432\u0435\u0434\u0438\u0442\u0435 \u0447\u0438\u0441\u043b\u043e \u0438\u0437 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438: \");\n n = Console.ReadLine();\n\n for (int i = 1; i < n.Length; i++)\n {\n pos += (int)Math.Pow(2, i);\n s += \"4\";\n }\n\n count = (byte)s.Length;\n\n while (true)\n {\n pos++;\n\n if (int.Parse(n) == int.Parse(s)) break;\n\n if (s[count - 1] == '4')\n {\n s = s.Remove(count - 1);\n s += \"7\";\n }\n else\n {\n for (int i = count - 1; i >= 0; i--)\n {\n if (s[i] == '4')\n { \n s = s.Remove(i);\n s += \"7\"; \n \n while (s.Length < count)\n s += \"4\";\n\n break;\n }\n }\n }\n\n }\n\n // Console.Write(\"\u041d\u043e\u043c\u0435\u0440 \u0447\u0438\u0441\u043b\u0430 {0} - {1}.\", n, pos);\n Console.Write(pos);\n // Console.ReadLine();\n\n \n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "implementation", "combinatorics", "bitmasks"], "code_uid": "cda785281bd34aa15e341d18f3b7efaf", "src_uid": "6a10bfe8b3da9c11167e136b3c6fb2a3", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\n class Program\n {\n static void Main(string[] args)\n {\n double result = 0;\n char[] input = Console.ReadLine().ToCharArray();\n result += Math.Pow(2D, input.Length);\n {\n double pow = 1D, crr = pow;\n for (int i = input.Length - 1; i >= 0; --i, pow*=2D)\n {\n crr = ((input[i] == '4') ? '0' : '1') - 48D;\n result += crr * pow;\n }\n }\n Console.WriteLine(--result);\n }\n }", "lang_cluster": "C#", "tags": ["brute force", "implementation", "combinatorics", "bitmasks"], "code_uid": "362917d83446b0033a5554fb09d809b0", "src_uid": "6a10bfe8b3da9c11167e136b3c6fb2a3", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace ConsoleApplication4\n{\n class Program\n {\n static void Main(string[] args)\n\n {\n string[,] lines = new string[8, 8];\n string input;\n\n for (int i = 0; i < 8; i++)\n {\n input = Console.ReadLine();\n for (int j = 0; j < 8; j++)\n {\n lines[i, j] = input[j] + \"\";\n }\n }\n\n\n\n int white = 0;\n int black = 0;\n\n\n for (int i = 0; i < 8; i++)\n {\n for (int j = 0; j < 8; j++)\n {\n switch (lines[i, j])\n {\n case \"Q\":\n white += 9;\n break;\n case \"R\":\n white += 5;\n break;\n case \"B\":\n white += 3;\n break;\n case \"N\":\n white += 3;\n break;\n case \"P\":\n white += 1;\n break;\n case \"q\":\n black += 9;\n break;\n case \"r\":\n black += 5;\n break;\n case \"b\":\n black += 3;\n break;\n case \"n\":\n black += 3;\n break;\n case \"p\":\n black += 1;\n break;\n\n }\n\n }\n }\n\n if (black > white)\n {\n Console.WriteLine(\"Black\");\n }\n else if (black == white)\n {\n Console.WriteLine(\"Draw\");\n }\n else\n {\n Console.WriteLine(\"White\");\n\n }\n\n }\n }\n}\n\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "a6cc132f5857cb3c712c420beba63988", "src_uid": "44bed0ca7a8fb42fb72c1584d39a4442", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\n\nnamespace ConsoleApplication1\n{\n class Program\n {\n static void Main(string[] args)\n {\n string[,] k = new string[8, 8];\n string g;\n int black = 0, white = 0;\n for (int i = 0; i < 8; i++)\n {\n g = Console.ReadLine();\n for (int j = 0; j < 8; j++)\n {\n k[i, j] = g[j].ToString();\n }\n }\n for (int i = 0; i < 8; i++)\n {\n for (int j = 0; j < 8; j++)\n {\n\n switch (k[i,j])\n {\n case \"Q\":\n {\n white += 9;\n break;\n }\n case \"R\":\n {\n white += 5;\n break;\n }\n case \"B\":\n {\n white += 3;\n break;\n }\n case \"N\":\n {\n white += 3;\n break;\n }\n case \"P\":\n {\n white += 1;\n break;\n }\n case \"q\":\n {\n black += 9;\n break;\n }\n case \"r\":\n {\n black += 5;\n break;\n }\n case \"b\":\n {\n black += 3;\n break;\n }\n case \"n\":\n {\n black += 3;\n break;\n }\n case \"p\":\n {\n black += 1;\n break;\n }\n }\n }\n\n }\n if (white > black)\n {\n Console.Write(\"White\");\n }\n else if (black > white)\n {\n Console.Write(\"Black\");\n }\n else\n {\n Console.Write(\"Draw\");\n }\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "098a481135780a6dc5067b0a1a6db6dc", "src_uid": "44bed0ca7a8fb42fb72c1584d39a4442", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\nusing System.IO;\n\nnamespace ConsoleApp2\n{\n class Program\n {\n class element\n {\n public int index;\n public int count;\n }\n static int f(List Even, List Odd, ref int CountEven, ref int CountOdd, int count)\n {\n int i = 0;\n int c = 0;\n while (i < Even.Count && Even[i] <= CountEven)\n {\n CountEven -= Even[i]; i++;\n c++;\n }\n count += (Even.Count - c) * 2;\n i = 0; c = 0;\n while (i < Odd.Count && Odd[i] <= CountOdd)\n {\n CountOdd -= Odd[i]; i++;\n c++;\n }\n count += (Odd.Count - c) * 2;\n return count;\n }\n static void Main(string[] args)\n {\n int n = int.Parse(Console.ReadLine());\n if(n==1)\n {\n Console.WriteLine(0);\n return;\n }\n string[] str = Console.ReadLine().Split();\n int[] a = new int[n];\n int count = 0;\n int CountOdd = (n + 1) / 2, CountEven = n / 2;\n for (int i = 0; i < n; i++)\n {\n a[i] = int.Parse(str[i]);\n if (a[i] != 0)\n {\n if (a[i] % 2 == 1)\n CountOdd--;\n else\n CountEven--;\n }\n }\n int FirstEven = -1, FirstOdd = -1, LastEven = -1, LastOdd = -1;\n int CountZero = 0;\n List Even = new List();\n List Odd = new List();\n for (int i = -1; i < n - 1; i++)\n {\n if (a[i + 1] == 0)\n {\n int first = i;\n CountZero = 0;\n for (++i; i < n && a[i] == 0; i++)\n CountZero++;\n if (first == -1 && i == n)\n {\n Console.WriteLine(1);\n return;\n }\n if (first == -1)\n {\n if (a[i] % 2 == 0)\n FirstEven = CountZero;\n else\n FirstOdd = CountZero;\n i--;\n continue;\n }\n if (i == n)\n {\n if (a[first] % 2 == 0)\n LastEven = CountZero;\n else\n LastOdd = CountZero;\n i--;\n continue;\n }\n if (a[first] % 2 == a[i] % 2)\n {\n\n if (a[first] % 2 == 0)\n Even.Add(CountZero);\n else\n Odd.Add(CountZero);\n }\n else\n count++;\n i--;\n }\n else\n {\n if (i >= 0 && i + 1 < n)\n {\n if (a[i] % 2 != a[i + 1] % 2)\n count++;\n }\n }\n }\n Even.Sort();\n Odd.Sort();\n count = f(Even, Odd, ref CountEven, ref CountOdd, count);\n\n if (FirstEven != -1)\n {\n if (CountEven >= FirstEven)\n CountEven -= FirstEven;\n else\n count++;\n }\n if (FirstOdd != -1)\n {\n if (CountOdd >= FirstOdd)\n CountOdd -= FirstOdd;\n else\n count++;\n }\n if (LastEven != -1)\n {\n if (CountEven >= LastEven)\n CountEven -= LastEven;\n else\n count++;\n }\n if (LastOdd != -1)\n {\n if (CountOdd >= LastOdd)\n CountOdd -= LastOdd;\n else\n count++;\n }\n\n Console.WriteLine(count);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["sortings", "dp", "greedy"], "code_uid": "976ccc8c077bfed040249aa1391935fe", "src_uid": "90db6b6548512acfc3da162144169dba", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Linq;\n\nclass C\n{\n\tstatic int[] Read() => Console.ReadLine().Split().Select(int.Parse).ToArray();\n\tstatic void Main()\n\t{\n\t\tvar n = int.Parse(Console.ReadLine());\n\t\tvar p = Read();\n\n\t\tvar even = n / 2;\n\t\tvar odd = (n + 1) / 2;\n\t\tvar max = 1 << 20;\n\n\t\tvar dp = new int[n + 1, even + 1, 2];\n\t\tfor (int i = 0; i <= n; i++)\n\t\t\tfor (int j = 0; j <= even; j++)\n\t\t\t\tfor (int k = 0; k < 2; k++)\n\t\t\t\t\tdp[i, j, k] = max;\n\t\tdp[0, 0, 0] = 0;\n\t\tdp[0, 0, 1] = 0;\n\n\t\tfor (int i = 1; i <= n; i++)\n\t\t{\n\t\t\tvar v = p[i - 1];\n\t\t\tvar e_max = Math.Min(i, even);\n\t\t\tvar e_min = Math.Max(i - odd, 0);\n\n\t\t\tfor (int j = e_min; j <= e_max; j++)\n\t\t\t{\n\t\t\t\tif ((v == 0 || v % 2 == 0) && j > 0)\n\t\t\t\t\tdp[i, j, 0] = Math.Min(dp[i - 1, j - 1, 0], dp[i - 1, j - 1, 1] + 1);\n\t\t\t\tif (v == 0 || v % 2 == 1)\n\t\t\t\t\tdp[i, j, 1] = Math.Min(dp[i - 1, j, 0] + 1, dp[i - 1, j, 1]);\n\t\t\t}\n\t\t}\n\t\tConsole.WriteLine(Math.Min(dp[n, even, 0], dp[n, even, 1]));\n\t}\n}\n", "lang_cluster": "C#", "tags": ["sortings", "dp", "greedy"], "code_uid": "966673785c27929546614473423139ba", "src_uid": "90db6b6548512acfc3da162144169dba", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\n\nnamespace G.GangUp\n{\n internal static class Program\n {\n public static void Main(string[] args)\n {\n var nmkcd = Console.ReadLine().Split();\n var n = int.Parse(nmkcd[0]);\n var m = int.Parse(nmkcd[1]);\n var k = int.Parse(nmkcd[2]);\n var c = int.Parse(nmkcd[3]);\n var d = int.Parse(nmkcd[4]);\n \n var solver = new Solver(n, m, k, c, d);\n solver.Init();\n\n var memberHomes = Console.ReadLine().Split().GroupBy(int.Parse);\n foreach (var memberHome in memberHomes)\n solver.AddMemberHome(memberHome.Key - 1, memberHome.Count());\n \n for (var i = 0; i < m; i++)\n {\n var xy = Console.ReadLine().Split();\n var x = int.Parse(xy[0]) - 1;\n var y = int.Parse(xy[1]) - 1;\n \n solver.AddEdge(x, y);\n solver.AddEdge(y, x);\n }\n \n for (var i = 0; i < k; i++)\n solver.IncreaseFlow();\n\n Console.WriteLine(solver.TotalCost);\n }\n }\n\n internal sealed class Solver\n {\n private static readonly Edge FakeEdge = new Edge();\n \n private readonly int _n, _m, _k, _c, _d;\n private readonly int _maxTime;\n private readonly Node _start, _sink;\n private readonly Node[,] _nodes;\n private readonly List[] _nodeEdges;\n \n private readonly int[] _bestCosts;\n private readonly Edge[] _bestMoves;\n private readonly bool[] _isInQueue;\n private readonly Queue _bestPathSearchQueue;\n\n public Solver(int n, int m, int k, int c, int d)\n {\n _n = n;\n _m = m;\n _k = k;\n _c = c;\n _d = d;\n\n _maxTime = k + m;\n _nodes = new Node[n, _maxTime];\n\n _start = new Node() {Id = _nodes.Length};\n _sink = new Node() {Id = _nodes.Length + 1};\n\n var allNodesCount = _nodes.Length + 2;\n \n _nodeEdges = new List[allNodesCount];\n _bestCosts = new int[allNodesCount];\n _bestMoves = new Edge[allNodesCount];\n _isInQueue = new bool[allNodesCount];\n _bestPathSearchQueue = new Queue(allNodesCount);\n \n for (var i = 0; i < allNodesCount; i++)\n _nodeEdges[i] = new List();\n }\n \n public int TotalCost { get; private set; }\n\n public void Init()\n {\n var nodeId = 0;\n for (var node = 0; node < _n; node++)\n for (var time = 0; time < _maxTime; time++)\n _nodes[node, time] = new Node() { Id = nodeId++ };\n\n for (var time = 0; time < _maxTime; time++)\n AddEdgePair(_nodes[0, time], _sink, time * _c, _k);\n\n for (var node = 0; node < _n; node++)\n {\n var from = _nodes[node, 0];\n for (var time = 1; time < _maxTime; time++)\n {\n var to = _nodes[node, time];\n AddEdgePair(from, to, 0, _k);\n from = to;\n }\n }\n \n _isInQueue[_sink.Id] = true;\n }\n\n public void AddMemberHome(int home, int count)\n {\n _nodeEdges[_start.Id].Add(new Edge()\n {\n From = _start,\n To = _nodes[home, 0],\n Cost = 0,\n ResidualCapacity = count,\n Paired = FakeEdge,\n });\n }\n\n public void AddEdge(int from, int to)\n {\n for (var time = 0; time < _maxTime - 1; time++)\n {\n var nodeFrom = _nodes[from, time];\n var nodeTo = _nodes[to, time + 1];\n \n for (int people = 0, cost = 1; people < _k; people++, cost += 2)\n AddEdgePair(nodeFrom, nodeTo, cost * _d, 1);\n }\n }\n\n public void IncreaseFlow()\n {\n FindBestPath();\n CommitBestPath();\n TotalCost += _bestCosts[_sink.Id];\n }\n\n private void FindBestPath()\n {\n for (var i = 0; i < _bestCosts.Length; i++)\n _bestCosts[i] = int.MaxValue;\n \n _bestCosts[_start.Id] = 0;\n _bestPathSearchQueue.Enqueue(_start);\n \n while (_bestPathSearchQueue.Count > 0)\n {\n var node = _bestPathSearchQueue.Dequeue();\n var costToNode = _bestCosts[node.Id];\n \n foreach (var edge in _nodeEdges[node.Id])\n {\n if (edge.ResidualCapacity == 0)\n continue;\n \n var possibleCost = costToNode + edge.Cost;\n if (possibleCost >= _bestCosts[edge.To.Id])\n continue;\n \n _bestCosts[edge.To.Id] = possibleCost;\n _bestMoves[edge.To.Id] = edge;\n if (_isInQueue[edge.To.Id])\n continue;\n \n _isInQueue[edge.To.Id] = true;\n _bestPathSearchQueue.Enqueue(edge.To);\n }\n \n _isInQueue[node.Id] = false;\n }\n }\n\n private void CommitBestPath()\n {\n var cur = _bestMoves[_sink.Id];\n while (cur != null)\n {\n cur.ResidualCapacity--;\n cur.Paired.ResidualCapacity++;\n cur = _bestMoves[cur.From.Id];\n }\n }\n\n private void AddEdgePair(Node from, Node to, int cost, int capacity)\n {\n var forwardEdge = new Edge()\n {\n From = from,\n To = to,\n Cost = cost,\n ResidualCapacity = capacity,\n };\n\n var reverseEdge = new Edge()\n {\n From = to,\n To = from,\n Cost = -cost,\n ResidualCapacity = 0,\n };\n\n forwardEdge.Paired = reverseEdge;\n reverseEdge.Paired = forwardEdge;\n \n _nodeEdges[from.Id].Add(forwardEdge);\n _nodeEdges[to.Id].Add(reverseEdge);\n }\n }\n\n internal struct Node\n {\n public int Id { get; set; }\n public override string ToString() => Id.ToString();\n }\n\n internal sealed class Edge\n {\n public Node From { get; set; }\n public Node To { get; set; }\n public int Cost { get; set; }\n public int ResidualCapacity { get; set; }\n public Edge Paired { get; set; }\n }\n}", "lang_cluster": "C#", "tags": ["flows", "graphs"], "code_uid": "75c56ed47d2ec42ea2ee240784352777", "src_uid": "2d0aa75f2e63c4fb8c98742ac8cd821c", "difficulty": 2500.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Linq;\n \nclass Program\n{\n private static void Main()\n {\n int result = 0;\n var knw = ConsoleReadLineAsArrayOfIntegers();\n int k = knw[0];\n int n = knw[1];\n int w = knw[2];\n \n int totalPrice = 0;\n for(int i = 0; i < w; i++)\n {\n totalPrice += k * (i + 1);\n }\n if (totalPrice <= n){\n Console.WriteLine(\"0\");\n return;\n }\n result = totalPrice - n;\n Console.WriteLine(\"\" + result);\n } \n \n private static int[] ConsoleReadLineAsArrayOfIntegers()\n {\n return Console.ReadLine().Split(' ').Select(n => Convert.ToInt32(n)).ToArray();\n }\n \n private static int ConsoleReadLineAsInteger()\n {\n return Convert.ToInt32(Console.ReadLine());\n }\n \n private static void ConsoleWriteLine(string line)\n {\n Console.WriteLine(line);\n }\n}", "lang_cluster": "C#", "tags": ["brute force", "math", "implementation"], "code_uid": "2d7a711da342b3ef6784a0797105b0bf", "src_uid": "e87d9798107734a885fd8263e1431347", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace problem\n{\n class Program\n {\n static void Main(string[] args)\n {\n string[] tokens = Console.ReadLine().Split();\n int k = int.Parse(tokens[0]);\n long n = int.Parse(tokens[1]);\n int w = int.Parse(tokens[2]);\n long totaldollar = 0;\n\n for(int i=1;i<=w;i++)\n {\n totaldollar += i * k;\n }\n long borrow=0;\n if (totaldollar > n)\n borrow = totaldollar - n;\n else\n borrow = 0;\n Console.WriteLine(borrow);\n\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "math", "implementation"], "code_uid": "9446184095c9f62e44a54f0ee06ace57", "src_uid": "e87d9798107734a885fd8263e1431347", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Security.Cryptography.X509Certificates;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace ConsoleApplication1\n{\n class Program\n {\n static void Main(string[] args)\n {\n Console.ReadLine();\n var text = Console.ReadLine().ToLower().Select(c=>(int)c).ToList();\n var total = 0;\n for (int i = 0; i < 26; i++)\n {\n if (text.Contains(97 + i))\n {\n total++;\n }\n }\n Console.WriteLine(total == 26 ? \"YES\" : \"NO\");\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["strings", "implementation"], "code_uid": "445fcbb3ee60b85f5ed51fb5064fe7bd", "src_uid": "f13eba0a0fb86e20495d218fc4ad532d", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\n\n class Program\n {\n static void Main(string[] args)\n {\n Dictionary result = new Dictionary();\n int n = 0;\n string readLine = Console.ReadLine();\n if (int.TryParse(readLine, out n))\n {\n string word = Console.ReadLine();\n word = word.ToLower();\n for(int i=0; i < n; i++)\n {\n int value;\n if (result.TryGetValue(word[i], out value))\n {\n result[word[i]] = value + 1;\n } \n else\n {\n result.Add(word[i], 1);\n }\n }\n\n \n if (result.Count >= 26)\n {\n Console.WriteLine(\"YES\");\n }\n else\n Console.WriteLine(\"NO\");\n }\n\n }\n }\n\n", "lang_cluster": "C#", "tags": ["strings", "implementation"], "code_uid": "6b9de48d3ee745f1a987054986a3b351", "src_uid": "f13eba0a0fb86e20495d218fc4ad532d", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Collections;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace CodeForces\n{\n\tpublic class Program\n\t{\n\t\tpublic static void Main(string[] args)\n\t\t{\n\t\t\tstring k1 = Console.ReadLine();\n\t\t\tstring[] p1 = k1.Split(null);\n\t\t\tint n = int.Parse(p1[0]);\n\t\t\tint q = int.Parse(p1[1]);\n\n\t\t\tstring[] a = new string[q];\n\t\t\tchar[] b = new char[q];\n\n\t\t\tfor (int i = 0; i < q; i++)\n\t\t\t{\n\t\t\t\tstring k = Console.ReadLine();\n\t\t\t\tstring[] p = k.Split(null);\n\t\t\t\ta[i] = p[0];\n\t\t\t\tb[i] = p[1].ToCharArray()[0];\n\t\t\t}\n\n\t\t\tint oper = n - 1;\n\t\t\tint[] start = new int[6];\n\t\t\tstart[0] = 1;\n\t\t\tfor (int i = 0; i < oper; i++)\n\t\t\t{\n\t\t\t\tint[] next = new int[6];\n\n\t\t\t\tfor (int j = 0; j < 6; j++)\n\t\t\t\t{\n\t\t\t\t\tif (start[j] != 0)\n\t\t\t\t\t{\n\t\t\t\t\t\tfor (int k = 0; k < b.Length; k++)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tif (b[k] - 'a' == j)\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tnext[a[k].ToCharArray()[0] - 'a'] += start[j];\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tstart = next;\n\t\t\t}\n\t\t\tConsole.Write(start.Sum());\n\t\t}\n\n\t}\n}\n", "lang_cluster": "C#", "tags": ["dfs and similar", "strings", "dp", "brute force"], "code_uid": "13e1b3b22d1f636ee4f8ef84869216e4", "src_uid": "c42abec29bfd17de3f43385fa6bea534", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Globalization;\nusing System.IO;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace Codeforces\n{\n class Program\n {\n\n static void Main(string[] args)\n {\n //#if DEBUG\n StreamReader reader = new StreamReader(Console.OpenStandardInput(32768), Encoding.ASCII, false, 32768);\n StreamWriter writer = new StreamWriter(Console.OpenStandardOutput(32768), Encoding.ASCII, 32768);\n //#else\n // StreamReader streamReader = new StreamReader(Console.OpenStandardInput(32768), Encoding.ASCII, false, 32768);\n // StreamWriter writer = new StreamWriter(Console.OpenStandardOutput(32768), Encoding.ASCII, 32768);\n //#endif\n InputReader input = new InputReader(reader);\n\n\n int n = input.NextInt();\n int q = input.NextInt();\n Dictionary> dic = new Dictionary>();\n while (q-- > 0)\n {\n string s1 = input.Next();\n string s2 = input.Next();\n\n if (!dic.ContainsKey(s2))\n {\n dic.Add(s2, new List());\n }\n dic[s2].Add(s1.Substring(0, 1));\n }\n List list = new List();\n list.Add(\"a\");\n for (int i = 1; i < n; i++)\n {\n List L = new List();\n bool find = false;\n foreach (string s in list)\n {\n if (dic.ContainsKey(s))\n {\n find = true;\n L.AddRange(dic[s]);\n }\n }\n if (!find)\n {\n writer.WriteLine(0); \n writer.Close();\n return;\n }\n list = new List(L);\n }\n writer.WriteLine(list.Count);\n\n\n#if DEBUG\n Console.BackgroundColor = ConsoleColor.White;\n Console.ForegroundColor = ConsoleColor.Black;\n#endif\n writer.Close();\n reader.Close();\n }\n\n private static string Rev(string p)\n {\n string s = \"\";\n for (int i = p.Length - 1; i >= 0; i--)\n {\n s += p[i];\n }\n return s;\n }\n }\n\n // this class is copy\n class InputReader\n {\n private char[] _inbuf;\n private int _lenbuf = 0, _ptrbuf = 0;\n private StreamReader _reader;\n\n public InputReader(StreamReader reader)\n {\n _reader = reader;\n _inbuf = new char[1024];\n _lenbuf = 0;\n _ptrbuf = 0;\n }\n\n private int ReadByte()\n {\n if (_lenbuf == -1)\n throw new Exception();\n if (_ptrbuf >= _lenbuf)\n {\n _ptrbuf = 0;\n try\n {\n _lenbuf = _reader.Read(_inbuf, 0, 1024);\n }\n catch (IOException e)\n {\n throw e;\n }\n if (_lenbuf <= 0)\n return -1;\n }\n return _inbuf[_ptrbuf++];\n }\n\n private bool IsSpaceChar(int c)\n {\n return !(c >= 33 && c <= 126);\n }\n\n private int Skip()\n {\n int b;\n while ((b = ReadByte()) != -1 && IsSpaceChar(b)) ;\n return b;\n }\n\n public int NextInt()\n {\n return int.Parse(this.Next());\n }\n\n public long NextLong()\n {\n return long.Parse(this.Next());\n }\n\n public string Next()\n {\n var b = Skip();\n var sb = new StringBuilder();\n while (!(IsSpaceChar(b)))\n {\n sb.Append((char)b);\n b = ReadByte();\n }\n return sb.ToString();\n }\n\n public double NextDouble()\n {\n return double.Parse(Next(), CultureInfo.InvariantCulture);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["dfs and similar", "strings", "dp", "brute force"], "code_uid": "a27b11f30f1d71d079b73ab90a537b01", "src_uid": "c42abec29bfd17de3f43385fa6bea534", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace Round_277\n{\n class Program\n {\n static void Main(string[] args)\n {\n FunctionCalc fc = new FunctionCalc();\n fc.Test();\n }\n\n }\n class FunctionCalc\n {\n long Sum(long a1,long an,long n)\n {\n return (a1 + an) * n / 2;\n }\n long Calc(long n)\n {\n if (n == 1) return -1;\n if (n == 2) return 1;\n if(n%2==0)\n {\n return Sum(2, n, n / 2) - Sum(1, n - 1, n / 2);\n }\n else\n {\n return Sum(2, n - 1, (n - 1) / 2) - Sum(1, n, (n + 1) / 2);\n }\n }\n long Calc2(long n)\n {\n long sum = 0;\n for(long i=1;i<=n;i++)\n {\n if (i % 2 == 0) sum += i;\n else sum -= i;\n }\n return sum;\n }\n long Calc3(long n)\n {\n if (n % 2 == 0) return n / 2;\n else return -(n + 1) / 2;\n }\n public void Test()\n {\n long n = long.Parse(Console.ReadLine());\n Console.WriteLine(Calc3(n));\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "implementation"], "code_uid": "8842701ac2b5f60b0c33725bea874142", "src_uid": "689e7876048ee4eb7479e838c981f068", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace A.\u041f\u043e\u0434\u0441\u0447\u0451\u0442_\u0444\u0443\u043d\u043a\u0446\u0438\u0438\n{\n class Program\n {\n static void Main(string[] args)\n {\n long n = long.Parse(Console.ReadLine());\n\n Console.WriteLine(fun(n));\n Console.ReadLine();\n }\n\n static long fun(long n)\n {\n if (n % 2 == 0)\n return n / 2;\n else\n return -n / 2 - 1;\n }\n }\n}", "lang_cluster": "C#", "tags": ["math", "implementation"], "code_uid": "55f69e73eb030f2c5f6ad6cbdaa62a20", "src_uid": "689e7876048ee4eb7479e838c981f068", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": ".NET Core C#", "source_code": "using System;\nclass HelloWorld {\n static void Main(string [] args) {\n string s = Console.ReadLine();\n string str = Console.ReadLine();\n string s1 = s.ToLower();\n string str1=str.ToLower();\n var res = String.Compare(s1,str1);\n if (res>0)\n {\n \n Console.WriteLine('1');\n }\n else if (res<0)\n {\n Console.WriteLine(\"-1\");\n }\n else\n {\n Console.WriteLine('0');\n }\n}\n }", "lang_cluster": "C#", "tags": ["strings", "implementation"], "code_uid": "47e92962b8c28b2f07435a94f9b039e2", "src_uid": "ffeae332696a901813677bd1033cf01e", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\n\nnamespace Strings\n{\n class Program {\n static void Main(string[] args){\n string firstWord = Console.ReadLine();\n string secondWord = Console.ReadLine();\n\n firstWord = firstWord.ToLower();\n secondWord = secondWord.ToLower();\n\n int charCompareResult = 0;\n for (int i = 0; i< firstWord.Length; i++){\n charCompareResult = firstWord[i] - secondWord[i];\n if (charCompareResult != 0){\n Console.Write(Math.Sign(charCompareResult));\n break;\n } \n }\n if (charCompareResult == 0){\n Console.Write(0);\n }\n\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["strings", "implementation"], "code_uid": "c41d22361e11c24b0d9d086ae3af88e9", "src_uid": "ffeae332696a901813677bd1033cf01e", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\n\nnamespace ConsoleApplication1\n{\n class Program\n {\n internal static void MyMain()\n {\n int[] ints = RInts();\n var all = ints.GroupBy(a => a).Select(a => a.Count()).OrderBy(a => a).Reverse().ToList();\n if (all[0] >= 4)\n {\n if ((all.Count >= 2 && all[1] >= 2) || all[0] == 6)\n {\n WLine(\"Elephant\");\n return;\n }\n else if (all[1] == 1 && all[0] == 5 || (all[0] == 4 && all[1] == 1 && all[2] >= 1))\n {\n WLine(\"Bear\");\n return;\n }\n else {\n WLine(\"Elien\");\n return;\n }\n }\n else {\n WLine(\"Alien\");\n }\n \n }\n\n class Dragon\n {\n public int lvl { get; set; }\n public int exp { get; set; }\n }\n\n static void Main()\n {\n#if !HOME\n MyMain();\n#else\n Secret.Run();\n#endif\n }\n\n #region Utils\n static string RLine()\n {\n return Console.ReadLine();\n }\n\n static int RInt()\n {\n var str = Console.ReadLine();\n return Convert.ToInt32(str);\n }\n static int[] RInts()\n {\n return Array.ConvertAll(Console.ReadLine().Split(' '), s => Convert.ToInt32(s));\n }\n static void RInts(out int a, out int b)\n {\n var ints = RInts();\n a = ints[0];\n b = ints[1];\n }\n static void RLongs(out long a, out long b)\n {\n var ints = Array.ConvertAll(Console.ReadLine().Split(' '), s => Convert.ToInt64(s));\n a = ints[0];\n b = ints[1];\n }\n public static void WLine(T s)\n {\n Console.WriteLine(s);\n }\n #endregion\n }\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "8af01e064c12ee5442aaa66f040fd8f7", "src_uid": "43308fa25e8578fd9f25328e715d4dd6", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\n\nclass Solver\n{\n void Solve()\n {\n var a = sc.IntArray(6);\n var h = new int[10];\n foreach (var x in a)\n h[x]++;\n for (int i = 1; i < 10; i++)\n {\n if (h[i] == 4)\n {\n\n for (int j = 1; j < 10; j++)\n {\n if (i == j)\n continue;\n if (h[j] == 2)\n {\n Printer.PrintLine(Elephant=>1);\n return;\n }\n \n }\n Printer.PrintLine(Bear=>1);\n return;\n }\n if (h[i] == 5)\n {\n Printer.PrintLine(Bear=>1);\n return;\n }\n if (h[i] == 6)\n {\n Printer.PrintLine(Elephant=>1);\n return;\n }\n\n }\n Printer.PrintLine(Alien => 1);\n }\n static void Main()\n {\n#if DEBUG\n var oStream = new System.IO.FileStream(\"debug.txt\", System.IO.FileMode.Create, System.IO.FileAccess.Write);\n var iStream = new System.IO.FileStream(\"input.txt\", System.IO.FileMode.Open, System.IO.FileAccess.Read, System.IO.FileShare.ReadWrite);\n Console.SetIn(new System.IO.StreamReader(iStream));\n System.Diagnostics.Debug.AutoFlush = true;\n System.Diagnostics.Debug.Listeners.Add(new System.Diagnostics.TextWriterTraceListener(new System.IO.StreamWriter(oStream, System.Text.Encoding.UTF8)));\n try\n {\n#endif\n var solver = new Solver();\n solver.Solve();\n#if DEBUG\n }\n catch (Exception ex)\n {\n Console.WriteLine(ex.Message);\n Console.WriteLine(ex.StackTrace);\n }\n Console.ReadKey(true);\n#endif\n }\n _Scanner sc = new _Scanner(Console.In);\n\n}\nstatic public class Printer\n{\n static readonly private System.IO.TextWriter writer;\n static readonly private System.Globalization.CultureInfo info;\n static string Separator { get; set; }\n static Printer()\n {\n writer = Console.Out;\n info = System.Globalization.CultureInfo.InvariantCulture;\n Separator = \" \";\n }\n\n static public void Print(int num) { writer.Write(num.ToString(info)); }\n static public void Print(int num, string format) { writer.Write(num.ToString(format, info)); }\n static public void Print(long num) { writer.Write(num.ToString(info)); }\n static public void Print(long num, string format) { writer.Write(num.ToString(format, info)); }\n static public void Print(double num) { writer.Write(num.ToString(info)); }\n static public void Print(double num, string format) { writer.Write(num.ToString(format, info)); }\n static public void Print(string str) { writer.Write(str); }\n static public void Print(string format, params object[] arg) { writer.Write(format, arg); }\n static public void Print(IEnumerable sources) { writer.Write(sources.AsString()); }\n static public void Print(System.Linq.Expressions.Expression> expression)\n {\n var p = expression.Parameters[0];\n writer.WriteLine(p.Name);\n\n }\n\n static public void Print(params object[] arg)\n {\n var res = new System.Text.StringBuilder();\n foreach (var x in arg)\n {\n res.AppendFormat(info, \"{0}\", x);\n if (!string.IsNullOrEmpty(Separator))\n res.Append(Separator);\n }\n writer.Write(res.ToString(0, res.Length - Separator.Length));\n }\n static public void Print(IEnumerable sources)\n {\n var res = new System.Text.StringBuilder();\n foreach (var x in sources)\n {\n res.AppendFormat(info, \"{0}\", x);\n if (string.IsNullOrEmpty(Separator))\n res.Append(Separator);\n }\n writer.Write(res.ToString(0, res.Length - Separator.Length));\n\n }\n static public void PrintLine(int num) { writer.WriteLine(num.ToString(info)); }\n static public void PrintLine(int num, string format) { writer.WriteLine(num.ToString(format, info)); }\n static public void PrintLine(long num) { writer.WriteLine(num.ToString(info)); }\n static public void PrintLine(long num, string format) { writer.WriteLine(num.ToString(format, info)); }\n static public void PrintLine(double num) { writer.WriteLine(num.ToString(info)); }\n static public void PrintLine(double num, string format) { writer.WriteLine(num.ToString(format, info)); }\n static public void PrintLine(string str) { writer.WriteLine(str); }\n static public void PrintLine(string format, params object[] arg) { writer.WriteLine(format, arg); }\n static public void PrintLine(IEnumerable sources) { writer.WriteLine(sources.AsString()); }\n static public void PrintLine(System.Linq.Expressions.Expression> expression)\n {\n var p = expression.Parameters[0];\n writer.WriteLine(p.Name);\n\n }\n static public void PrintLine(params object[] arg)\n {\n var res = new System.Text.StringBuilder();\n foreach (var x in arg)\n {\n res.AppendFormat(info, \"{0}\", x);\n if (!string.IsNullOrEmpty(Separator))\n res.Append(Separator);\n }\n writer.WriteLine(res.ToString(0, res.Length - Separator.Length));\n }\n static public void PrintLine(IEnumerable sources)\n {\n var res = new System.Text.StringBuilder();\n foreach (var x in sources)\n {\n res.AppendFormat(info, \"{0}\", x);\n if (!string.IsNullOrEmpty(Separator))\n res.Append(Separator);\n }\n writer.WriteLine(res.ToString(0, res.Length - Separator.Length));\n }\n}\npublic class _Scanner\n{\n readonly private System.Globalization.CultureInfo info;\n readonly System.IO.TextReader reader;\n string[] buffer = new string[0];\n int position;\n\n public char[] Separator { get; set; }\n public _Scanner(System.IO.TextReader reader, string separator = null, System.Globalization.CultureInfo info = null)\n {\n if (reader == null)\n throw new ArgumentNullException(\"reader\");\n this.reader = reader;\n if (string.IsNullOrEmpty(separator))\n separator = \" \";\n this.Separator = separator.ToCharArray();\n this.info = info ?? System.Globalization.CultureInfo.InvariantCulture;\n }\n public string Scan()\n {\n if (this.position < this.buffer.Length)\n return this.buffer[this.position++];\n this.buffer = this.reader.ReadLine().Split(this.Separator, StringSplitOptions.RemoveEmptyEntries);\n this.position = 0;\n return this.buffer[this.position++];\n }\n\n public string[] ScanToEndLine()\n {\n if (this.position >= this.buffer.Length)\n return this.reader.ReadLine().Split(this.Separator, StringSplitOptions.RemoveEmptyEntries);\n var size = this.buffer.Length - this.position;\n var ar = new string[size];\n Array.Copy(this.buffer, position, ar, 0, size);\n return ar;\n\n }\n\n public string ScanLine()\n {\n if (this.position >= this.buffer.Length)\n return this.reader.ReadLine();\n else\n {\n var sb = new System.Text.StringBuilder();\n for (; this.position < buffer.Length; this.position++)\n {\n sb.Append(this.buffer[this.position]);\n sb.Append(' ');\n }\n return sb.ToString();\n }\n }\n public string[] ScanArray(int length)\n {\n var ar = new string[length];\n for (int i = 0; i < length; i++)\n {\n ar[i] = this.Scan();\n }\n return ar;\n }\n\n public int Integer()\n {\n return int.Parse(this.Scan(), info);\n }\n public long Long()\n {\n return long.Parse(this.Scan(), info);\n }\n public double Double()\n {\n return double.Parse(this.Scan(), info);\n }\n public double Double(string str)\n {\n return double.Parse(str, info);\n }\n\n public int[] IntArray(int length)\n {\n var a = new int[length];\n for (int i = 0; i < length; i++)\n a[i] = this.Integer();\n return a;\n }\n public long[] LongArray(int length)\n {\n var a = new long[length];\n for (int i = 0; i < length; i++)\n a[i] = this.Long();\n return a;\n }\n public double[] DoubleArray(int length)\n {\n var a = new double[length];\n for (int i = 0; i < length; i++)\n a[i] = this.Double();\n return a;\n }\n\n}\nstatic public partial class EnumerableEx\n{\n static public string AsString(this IEnumerable source)\n {\n return new string(source.ToArray());\n }\n static public T[] EnumerateArray(this int count, Func selector)\n {\n var ret = new T[count];\n for (int i = 0; i < count; i++)\n ret[i] = selector(i);\n return ret;\n }\n}\n//*/", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "d9289f163ab5b89e09a06ddf6f814fd2", "src_uid": "43308fa25e8578fd9f25328e715d4dd6", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace ConsoleApplication1\n{\n class Program\n {\n static void Main(string[] args)\n {\n var a = int.Parse(Console.ReadLine());\n for (int i = a; i < 1112; i++)\n {\n var s = SummDigits(i);\n if (s%4 == 0)\n {\n Console.WriteLine(i);\n return;\n }\n }\n }\n\n static int SummDigits(int n)\n {\n var s = 0;\n while (n > 0)\n {\n s += n%10;\n n /= 10;\n }\n\n return s;\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "8bf70e441c6727936e809d3cce9233a5", "src_uid": "bb6fb9516b2c55d1ee47a30d423562d7", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": ".NET Core C#", "source_code": "using System;\nnamespace Codeforces\n{\n\t\n public class Program \n {\n public static void Main()\n {\n int a = int.Parse(Console.ReadLine());\n while((Sum(a) % 4) != 0) a++;\n Console.WriteLine(a);\n }\n \n static public int Sum(int a)\n {\n \tint sum=0;\n \twhile(a>0)\n \t{\n \t\tsum+=a%10;\n \t\ta/=10;\n \t}\n \treturn sum;\n }\n }\n}", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "1473736c95c02b889af96ae40aaf4d1d", "src_uid": "bb6fb9516b2c55d1ee47a30d423562d7", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\n\n\nnamespace ConsoleApplication3\n{\n class Program\n {\n static void Main(string[] args)\n {\n int n = int.Parse(Console.ReadLine());\n string[] pokemons = { \"vaporeon\", \"jolteon\", \"flareon\", \"espeon\", \"umbreon\", \"leafeon\", \"glaceon\", \"sylveon\" };\n string input = Console.ReadLine();\n\n for (int i = 0; i < pokemons.Length; i++)\n if (pokemons[i].Length == input.Length)\n for (int j = 0; j < input.Length; j++)\n if (input[j] == '.' || pokemons[i][j] == input[j])\n if ( j == input.Length - 1) \n {Console.WriteLine(pokemons[i]); return;}\n else continue;\n else break;\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "strings", "implementation"], "code_uid": "705b02b155c95c3d68fda81bb9a20ced", "src_uid": "ec3d15ff198d1e4ab9fd04dd3b12e6c0", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace ConsoleApplication1\n{\n public class Program\n {\n public static void Main()\n {\n int length;\n string input;\n string[] pokemon = { \"jolteon\", \"flareon\", \"umbreon\", \"leafeon\", \"glaceon\", \"sylveon\" };\n int[] SimilarityFactor = { 0, 0, 0, 0, 0, 0 };\n\n length = Convert.ToInt32(Console.ReadLine());\n input = Console.ReadLine();\n\n if (length == 6)\n Console.WriteLine(\"espeon\");\n else if (length == 8)\n Console.WriteLine(\"vaporeon\");\n else\n {\n for (int i = 0; i < 4; ++i)\n {\n if (input[i] == '.')\n goto Next;\n for (int j = 0; j < 6; ++j)\n if (input[i] == pokemon[j][i])\n ++SimilarityFactor[j];\n Next: ;\n }\n Console.WriteLine(pokemon[Array.IndexOf(SimilarityFactor, SimilarityFactor.Max())]);\n }\n }\n }\n}\n\n", "lang_cluster": "C#", "tags": ["brute force", "strings", "implementation"], "code_uid": "18c17879284cdae09464c03cdfbdcd19", "src_uid": "ec3d15ff198d1e4ab9fd04dd3b12e6c0", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\npublic class Program\n {\n public static void Main(string[] args)\n {\n Console.WriteLine(\"25\");\n }\n }", "lang_cluster": "C#", "tags": ["number theory"], "code_uid": "efec787f8b465eccfc2627c754118ce9", "src_uid": "dcaff75492eafaf61d598779d6202c9d", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nclass Codeforces_630A\n{\n static void Main()\n {\n string n = Console.ReadLine();\n Console.Write(25);\n }\n}", "lang_cluster": "C#", "tags": ["number theory"], "code_uid": "6261f3b5b8e903b9d1ad35095ec5fd09", "src_uid": "dcaff75492eafaf61d598779d6202c9d", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.IO;\nusing System.Web;\nusing System.Net;\nusing System.Collections;\n\nnamespace ConsoleApplication1 {\n class Program {\n static void Main( string[] args ) {\n int n = ReadInt();\n int sumx = 0;\n int sumy = 0;\n bool flag = false;\n\n for ( int i = 0; i < n; i++ ) {\n int x = ReadInt();\n int y = ReadInt();\n sumx += x;\n sumy += y;\n if ( x % 2 != y % 2 )\n flag = true;\n }\n\n if ( sumx % 2 == 0 && sumy % 2 == 0)\n Console.Write(0);\n else if ( flag && n > 1 && ((sumx + sumy) % 2 == 0))\n Console.Write(1);\n else\n Console.Write(-1);\n }\n\n static int _current = -1;\n static string[] _words = null;\n static int ReadInt() {\n if ( _current == -1 ) {\n _words = Console.ReadLine().Split(new char[] { ' ', '\\r', '\\n' }, StringSplitOptions.RemoveEmptyEntries);\n _current = 0;\n }\n\n int value = int.Parse(_words[_current].Replace('.', ','));\n if ( _current == _words.Length - 1 )\n _current = -1;\n else\n _current++;\n\n return value;\n }\n }\n}", "lang_cluster": "C#", "tags": ["math", "implementation"], "code_uid": "7b4be2df65d11a275e16390b9f5d94dd", "src_uid": "f9bc04aed2b84c7dd288749ac264bb43", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\n\nnamespace Task_8\n{\n\tclass MainClass\n\t{\n\t\tpublic static void Main(string[] args)\n\t\t{\n\t\t\tint bones = 0;\n\t\t\tstring str;\n\t\t//\tConsole.WriteLine(\"\u0412\u0432\u0435\u0434\u0438\u0442\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043a\u043e\u0441\u0442\u0435\u0439 \u0434\u043e\u043c\u0438\u043d\u043e:\");\n\t\t\tbones = int.Parse(Console.ReadLine());\n\t\t\tint result = -1;\n\t\t\tint sum_x = 0, sum_y = 0;\n\t\t\tint[,] array = new int[2, bones];\n\t\t//\tConsole.WriteLine(\"\u0412\u0432\u0435\u0434\u0438\u0442\u0435 \u043f\u043e\u043f\u0430\u0440\u043d\u043e \u0447\u0435\u0440\u0435\u0437 \u043f\u0440\u043e\u0431\u0435\u043b \u0432\u0435\u0440\u0445\u043d\u0438\u0435 \u0438 \u043d\u0438\u0436\u043d\u0438\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043a\u043e\u0441\u0442\u0435\u0439\");\n\t\t\tfor (int i = 0; i < bones; i++)\n\t\t\t{\n\t\t\t//\tConsole.Write(\"\u0412\u0432\u0435\u0434\u0438\u0442\u0435 \" + (i + 1) + \" \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \");\n\t\t\t\tstr = Console.ReadLine();\n\t\t\t\tString[] str_mas = str.Split(' ');\n\t\t\t\tarray[0, i] = int.Parse(str_mas[0]);\n\t\t\t\tarray[1, i] = int.Parse(str_mas[1]);\n\t\t\t}\n\t\t\t//\u043f\u0440\u043e\u0441\u0443\u043c\u043c\u0438\u0440\u0443\u0435\u043c \u043a\u0430\u0436\u0434\u0443\u044e \u0441\u0442\u043e\u0440\u043e\u043d\u0443 \u0434\u043e\u043c\u0438\u043d\u043e\u0448\u0435\u043a\n\t\t\tfor (int i = 0; i < bones; i++)\n\t\t\t{\n\t\t\t\tsum_x += array[0, i];\n\t\t\t\tsum_y += array[1, i];\n\t\t\t}\n\t\t\t//\u0437\u0430\u0434\u0430\u0447\u0430 \u0431\u0443\u0434\u0435\u0442 \u0438\u043c\u0435\u0442\u044c \u0440\u0435\u0448\u0435\u043d\u0438\u0435. \u043a\u043e\u0433\u0434\u0430 \u0441\u0443\u043c\u043c\u0430 \u043a\u0430\u0436\u0434\u043e\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u044b \u043d\u0435\u0447\u0435\u0442\u043d\u0430\u044f. \u0421\u043c\u0435\u043d\u0430 \u0447\u0435\u0442/\u043d\u0435\u0447\u0435\u0442 \u0441\u0443\u043c\u043c \u0441\u0442\u043e\u0440\u043e\u043d \u0432\u043e\u0437\u043d\u043e\u0436\u043d\u0430 \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u0438\n\t\t\t//\u0440\u0430\u0437\u0432\u043e\u0440\u043e\u0442\u0435 \u043a\u043e\u0441\u0442\u0438 \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043e\u0434\u043d\u043e \u0447\u0438\u0441\u043b\u043e \u0447\u0435\u0442\u043d\u043e\u0435, \u0434\u0440\u0443\u0433\u043e\u0435-\u043d\u0435\u0447\u0435\u0442\u043d\u043e\u0435.\n\t\t\tif (sum_x % 2 ==0 && sum_y % 2 == 0)\n\t\t\t{\n\t\t\t\t//\u0437\u0430\u0434\u0430\u0447\u0430 \u0438\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e \u0440\u0435\u0448\u0435\u043d\u0430.\n\t\t\t\tresult = 0;\n\t\t\t}\n\t\t\tif ((sum_x % 2) != (sum_y % 2))\n\t\t\t{\n\t\t\t\t//\u0437\u0430\u0434\u0430\u0447\u0430 \u043d\u0435 \u0438\u043c\u0435\u0435\u0442 \u0440\u0435\u0448\u0435\u043d\u0438\u044f, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043e\u0434\u043d\u0430 \u0438\u0437 \u0441\u0442\u043e\u0440\u043e\u043d \u0447\u0435\u0442\u043d\u0430\u044f, \u0430 \u0434\u0440\u0443\u0433\u0430\u044f-\u043d\u0435\u0442. \u041f\u0440\u0438 \u0440\u0430\u0437\u0432\u043e\u0440\u043e\u0442\u0435 \u043a\u043e\u0441\u0442\u0438 \u0441 \u0447\u0435\u0442\u043d\u044b\u043c \u0438 \u043d\u0435\u0447\u0435\u0442\u043d\u044b\u043c \u0447\u0438\u0441\u043b\u043e\u043c,\n\t\t\t\t//\u0435\u0442\u043d\u043e\u0441\u0442\u044c \u043e\u0431\u0449\u0438\u0438\u0445 \u0441\u0443\u043c\u043c \u043f\u043e \u0441\u0442\u043e\u0440\u043e\u043d\u0430\u043c \u0438\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u0443\u0435\u0442\u0441\u044f.\n\t\t\t\tresult = -1;\n\t\t\t}\n\t\t\t//\u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u043c \u0440\u0435\u0448\u0435\u043d\u0438\u0435\u043c \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0442\u043e\u0442 \u0441\u043b\u0443\u0447\u0430\u0439, \u043a\u043e\u0433\u0434\u0430 \u0441\u0443\u043c\u043c\u044b \u043f\u043e \u043e\u0431\u0435\u0438\u043c \u0441\u0442\u043e\u0440\u043e\u043d\u0430\u043c \u043d\u0435\u0447\u0435\u0442\u043d\u044b\u0435, \u0438 \u043f\u0440\u0438\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u043a\u043e\u0441\u0442\u044c \u0441 \u0447\u0435\u0442/\u043d\u0435\u0447\u0435\u0442 \u0447\u0438\u0441\u043b\u0430\u043c\u043c\u0438.\n\t\t\tif (sum_x % 2 == 1 && sum_y % 2 == 1)\n\t\t\t{\n\t\t\t\tfor (int i = 0; i < bones; i++)\n\t\t\t\t{\n\t\t\t\t\tif (array[0, i] % 2 != array[1, i] % 2)\n\t\t\t\t\t{\n\t\t\t\t\t\tresult = 1;\n\t\t\t//\t\t\tConsole.WriteLine(\"\u041d\u0443\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0432\u0435\u0440\u043d\u0443\u0442\u044c \" + (i+1) + \" \u043a\u043e\u0441\u0442\u044c\");\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t\tresult = -1;\n\t\t\t\t}\n\t\t\t}\n\t\t\tConsole.WriteLine(result);\n\t\t\t//str = Console.ReadLine();\n\t\t\t//String[] str_mas = str.Split(' ');\n\t\t}\n\t}\n}\n", "lang_cluster": "C#", "tags": ["math", "implementation"], "code_uid": "039dff0039fa6fbbdba35e2ba49d86cd", "src_uid": "f9bc04aed2b84c7dd288749ac264bb43", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeff#define LOCALa\n\nusing System;\nusing System.Collections.Generic;\nusing System.Dynamic;\nusing System.IO;\nusing System.Linq;\nusing System.Security.Cryptography;\nusing System.Text;\nusing System.Threading;\nusing System.Xml.Serialization;\n\nnamespace Algorytmy\n{\n class Program\n {\n static void Main(string[] args)\n {\n var l = Console.ReadLine().Split(' ');\n int V = int.Parse(l[0]);\n int N = int.Parse(l[1]);\n\n for (int i = 0; i < N; i++)\n if (V % 10 == 0)\n V /= 10;\n else\n V--;\n Console.WriteLine(V);\n }\n }\n /*class Program1\n {\n public Program1()\n {\n#if LOCAL\n CIN.ReadInputFile(\"input1\");\n#endif\n //int V = CIN.Get();\n //int N = CIN.Get();\n var l = Console.ReadLine().Split(' ');\n int V = int.Parse(l[0]);\n int N = int.Parse(l[1]);\n\n for (int i = 0; i < N; i++)\n if (V % 10 == 0) \n V /= 10;\n else \n V--;\n Console.WriteLine(V);\n }\n }*/\n#if LOCAL\n //get imput data\n class CIN\n {\n static Queue data = new Queue();\n public static void ReadInputFile(string path)\n {\n try\n {\n foreach (var line in File.ReadAllLines(path))\n foreach (var word in line.Split())\n data.Enqueue(word);\n }\n catch\n {\n\n }\n }\n static void ReadLine()\n {\n foreach (var word in Console.ReadLine().Split())\n data.Enqueue(word);\n }\n public static int Get()\n {\n return GetInt();\n }\n public static int GetInt()\n {\n if (data.Count == 0) ReadLine();\n return int.Parse(data.Dequeue());\n }\n public static float GetFloat()\n {\n if (data.Count == 0) ReadLine();\n return float.Parse(data.Dequeue());\n }\n public static double GetDouble()\n {\n if (data.Count == 0) ReadLine();\n return double.Parse(data.Dequeue());\n }\n public static string GetString()\n {\n if (data.Count == 0) ReadLine();\n return data.Dequeue();\n }\n }\n\n //fill array with value\n class MEM\n {\n public static void Set(ref int[] array, int value)\n {\n Set(ref array, value, array.Length);\n }\n public static void Set(ref int[] array, int value, int size)\n {\n for (int i = 0; i < size; ++i)\n array[i] = value;\n }\n public static void Set(ref int[,] array, int value)\n {\n for (int i = 0; i < array.GetLength(0); ++i)\n for (int j = 0; j < array.GetLength(1); ++j)\n array[i, j] = value;\n }\n }\n #endif\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "8db3b92602ff392434127a7961741457", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Linq;\n\nnamespace CodeForcesTest\n{\n class Program\n {\n static void Main(string[] args)\n {\n string input = Console.ReadLine();\n\n int[] inputs = input.Split(' ').Select(int.Parse).ToArray();\n\n int i = 0;\n while (i < inputs[1])\n {\n inputs[0] = inputs[0] % 10 == 0 ? inputs[0] / 10 : inputs[0] - 1;\n i++;\n }\n\n Console.WriteLine(inputs[0]);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "33c3872ca88b2be71e6fa21fc571f32d", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace ConsoleApplication1\n{\n\n class Compare\n {\n private void IncAB(ref int a, ref int b)\n {\n a++;\n b++;\n }\n\n\n private bool CompareAB(int A, int B)\n {\n if (A != B)\n {\n return false;\n }\n else\n {\n return true;\n }\n }\n\n public bool compares(int[] Player1, int[] Player2, int n)\n {\n int key;\n int p = 0;\n bool equil;\n for (int i = 0; i < n; ++i)\n {\n equil = true;\n key = i;\n p = 0;\n while ((key < n) && (equil))\n {\n equil = CompareAB(Player1[key], Player2[p]);\n IncAB(ref key, ref p);\n }\n key = 0;\n while ((key < i) && (equil))\n {\n equil = CompareAB(Player1[key], Player2[p]);\n IncAB(ref key, ref p);\n }\n if (equil)\n {\n return true;\n }\n }\n return false;\n }\n }\n\n\n\n\n\n\n\n class ConsoleOutPut\n {\n public void No_Yes(bool answer)\n {\n if (answer)\n {\n Console.WriteLine(\"YES\");\n }\n else\n {\n Console.WriteLine(\"NO\");\n }\n }\n }\n\n\n class Program\n {\n static void Main(string[] args)\n {\n string[] temp = Console.ReadLine().Split(new char[] { ' ' }, 2);\n int n = Convert.ToInt32(temp[0]);\n int L = Convert.ToInt32(temp[1]);\n int[] Player1 = new int[n];\n int[] Player2 = new int[n];\n string[] temp1 = Console.ReadLine().Split(new char[] { ' ' }, n);\n string[] temp2 = Console.ReadLine().Split(new char[] { ' ' }, n);\n for (int i = 0; i < n; i++)\n {\n Player1[i] = Convert.ToInt32(temp1[i]);\n Player2[i] = Convert.ToInt32(temp2[i]);\n }\n Compare Sasha_Kefa = new Compare();\n ConsoleOutPut WriteAnswer = new ConsoleOutPut();\n int[] Player1Points = new int[n];\n int[] Player2Points = new int[n];\n for (int i = 0; i < n - 1; ++i)\n {\n Player1Points[i] = Player1[i + 1] - Player1[i];\n Player2Points[i] = Player2[i + 1] - Player2[i];\n }\n Player1Points[n - 1] = (L - Player1[n - 1]) + Player1[0];\n Player2Points[n - 1] = (L - Player2[n - 1]) + Player2[0];\n WriteAnswer.No_Yes(Sasha_Kefa.compares(Player1Points, Player2Points, n));\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "math", "implementation"], "code_uid": "5db8f522fbfdaded1a59035a7cc361ff", "src_uid": "3d931684ca11fe6141c6461e85d91d63", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Linq;\n\nnamespace B_DashaAndFriends\n{\n class Program\n {\n\n static string Get(int[] nums, int length)\n {\n var aMoved = new[] { 0 }.Concat(nums.Skip(1).Select(d => d - nums[0])).Concat(new [] {length});\n\n var diffs = aMoved.Zip(aMoved.Skip(1), (a, b) => b - a).ToArray();\n \n var aString = string.Join(\"\", diffs);\n\n return aString;\n }\n\n static void Main()\n {\n var nums =\n Console.ReadLine()\n .Split(new[] { \" \" }, StringSplitOptions.RemoveEmptyEntries)\n .Select(int.Parse)\n .ToArray();\n\n var obstacles = nums[0];\n var length = nums[1];\n\n var aDistances = Console.ReadLine()\n .Split(new[] { \" \" }, StringSplitOptions.RemoveEmptyEntries)\n .Select(int.Parse)\n .ToArray();\n\n var bDistances = Console.ReadLine()\n .Split(new[] { \" \" }, StringSplitOptions.RemoveEmptyEntries)\n .Select(int.Parse)\n .ToArray();\n\n var aMoved = new[] {0}.Concat(aDistances.Skip(1).Select(d => d - aDistances[0]));\n var bMoved = new[] {0}.Concat(aDistances.Skip(1).Select(d => d - aDistances[0]));\n\n\n\n var aString = Get(aDistances, length);\n var bString = Get(bDistances, length);\n\n Console.WriteLine((aString + aString).Contains(bString) ? \"YES\" : \"NO\");\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "math", "implementation"], "code_uid": "a6527e39dae0904fddf66e9a3311a9c0", "src_uid": "3d931684ca11fe6141c6461e85d91d63", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "// ac\n\nusing System;\nusing System.Collections.Generic;\nusing System.Text;\nusing System.IO;\nusing System.Threading;\nusing System.Diagnostics;\nusing System.Globalization;\nusing System.Text.RegularExpressions;\nusing System.Linq;\n\nnamespace sar_cs\n{\n static class Helpers\n {\n // Mono lacks this override of string.Join()\n public static string Join(this IEnumerable objs, string sep)\n {\n var sb = new StringBuilder();\n foreach (var s in objs) { if (sb.Length != 0) sb.Append(sep); sb.Append(s); }\n return sb.ToString();\n }\n\n public static string AsString(this double a, int digits)\n {\n return a.ToString(\"F\" + digits, CultureInfo.InvariantCulture);\n }\n\n public static Stopwatch SW = Stopwatch.StartNew();\n }\n\n public class Program\n {\n #region Helpers\n\n public class Parser\n {\n const int BufSize = 8000;\n TextReader s;\n char[] buf = new char[BufSize];\n int bufPos;\n int bufDataSize;\n bool eos; // eos read to buffer\n int lastChar = -2;\n int nextChar = -2;\n StringBuilder sb = new StringBuilder();\n\n void FillBuf()\n {\n if (eos) return;\n bufDataSize = s.Read(buf, 0, BufSize);\n if (bufDataSize == 0) eos = true;\n bufPos = 0;\n }\n\n int Read()\n {\n if (nextChar != -2)\n {\n lastChar = nextChar;\n nextChar = -2;\n }\n else\n {\n if (bufPos == bufDataSize) FillBuf();\n if (eos) lastChar = -1;\n else lastChar = buf[bufPos++];\n }\n return lastChar;\n }\n\n void Back()\n {\n if (lastChar == -2) throw new Exception(); // no chars were ever read\n nextChar = lastChar;\n }\n\n public Parser()\n {\n s = Console.In;\n }\n\n public int ReadInt()\n {\n int res = 0;\n int sign = -1;\n int c;\n do { c = Read(); } while (c >= 0 && char.IsWhiteSpace((char)c));\n if (c == '-') { sign = 1; c = Read(); }\n int len = 0;\n while (c >= 0 && !char.IsWhiteSpace((char)c))\n {\n if ((uint)(c -= 48) >= 10) throw new FormatException();\n len++;\n res = checked(res * 10 - c);\n c = Read();\n }\n if (len == 0) throw new FormatException();\n Back();\n return checked(res * sign);\n }\n\n public long ReadLong()\n {\n long res = 0;\n int sign = -1;\n int c;\n do { c = Read(); } while (c >= 0 && char.IsWhiteSpace((char)c));\n if (c == '-')\n {\n sign = 1;\n c = Read();\n }\n int len = 0;\n\n while (c >= 0 && !char.IsWhiteSpace((char)c))\n {\n if ((uint)(c -= 48) >= 10) throw new FormatException();\n len++;\n res = checked(res * 10 - c);\n c = Read();\n }\n if (len == 0) throw new FormatException();\n Back();\n return checked(res * sign);\n }\n\n public int ReadLnInt()\n {\n int res = ReadInt(); ReadLine(); return res;\n }\n\n public long ReadLnLong()\n {\n long res = ReadLong(); ReadLine(); return res;\n }\n\n public double ReadDouble()\n {\n int c;\n do { c = Read(); } while (c >= 0 && char.IsWhiteSpace((char)c));\n\n int sign = 1;\n if (c == '-') { sign = -1; c = Read(); }\n\n sb.Length = 0;\n while (c >= 0 && !char.IsWhiteSpace((char)c))\n {\n sb.Append((char)c); c = Read();\n }\n\n Back();\n var res = double.Parse(sb.ToString(), CultureInfo.InvariantCulture);\n return res * sign;\n }\n\n public string ReadLine()\n {\n int c = Read();\n sb.Length = 0;\n while (c != -1 && c != 13 && c != 10)\n {\n sb.Append((char)c); c = Read();\n }\n if (c == 13) { c = Read(); if (c != 10) Back(); }\n return sb.ToString();\n }\n\n public bool SeekEOF\n {\n get\n {\n L0:\n int c = Read();\n if (c == -1) return true;\n if (char.IsWhiteSpace((char)c)) goto L0;\n Back();\n return false;\n }\n }\n\n public int[] ReadIntArr(int n)\n {\n var a = new int[n]; for (int i = 0; i < n; i++) a[i] = ReadInt(); return a;\n }\n\n public long[] ReadLongArr(int n)\n {\n var a = new long[n]; for (int i = 0; i < n; i++) a[i] = ReadLong(); return a;\n }\n }\n\n static void pe() { Console.WriteLine(\"???\"); Environment.Exit(0); }\n\n static void re() { Environment.Exit(55); }\n\n static void Swap(ref T a, ref T b)\n {\n T t = a; a = b; b = t;\n }\n\n #endregion Helpers\n\n static StringBuilder sb = new StringBuilder();\n static Random rand = new Random(5);\n\n static int[] fcache;\n\n static int f(int n, int[] abc)\n {\n if (n < 0) return -1;\n if (n == 0) return 0;\n if (fcache[n] == -2)\n {\n int best = -1;\n foreach (var l in abc)\n {\n int t = f(n - l, abc);\n if (t >= 0) best = Math.Max(best, t);\n }\n fcache[n] = best < 0 ? -1 : best + 1;\n }\n return fcache[n];\n }\n\n static void Main(string[] args)\n {\n //sar_cs_structs.FenwickTree.Test(); return;\n //Console.SetIn(File.OpenText(\"_input\"));\n var parser = new Parser();\n while (!parser.SeekEOF)\n {\n int n = parser.ReadInt();\n var abc = parser.ReadIntArr(3);\n\n fcache = new int[n+1];\n for (int i = 0; i < fcache.Length; i++) fcache[i] = -2;\n Console.WriteLine(f(n, abc));\n }\n }\n }\n}", "lang_cluster": "C#", "tags": ["brute force", "dp"], "code_uid": "6f70b345184ba9897a67e97f97f78fdb", "src_uid": "062a171cc3ea717ea95ede9d7a1c3a43", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Linq;\n\npublic class Program\n{\n public static void Main(string[] args)\n {\n int[] lines = Console.ReadLine().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(i => int.Parse(i)).ToArray();\n int n = lines[0];\n lines[0] = -1;\n Array.Sort(lines);\n\n int count = 1;\n\n if (n % lines[1] == 0)\n {\n Console.WriteLine(n/ lines[1]);\n }\n else\n {\n for (int i = 0; i < n; i++)\n {\n for (int j = 0; j < n; j++)\n {\n for (int k = 0; k < n; k++)\n {\n if (i * lines[1] + j * lines[2] + k * lines[3] == n)\n {\n if ((i + j + k) > count)\n {\n count = i + j + k;\n continue;\n }\n }\n else\n {\n if (i * lines[1] + j * lines[2] + k * lines[3] > n)\n {\n break;\n }\n }\n }\n }\n }\n\n Console.WriteLine(count);\n }\n }\n}\n\n", "lang_cluster": "C#", "tags": ["brute force", "dp"], "code_uid": "c2c47a2b51ed770093da76de61bee130", "src_uid": "062a171cc3ea717ea95ede9d7a1c3a43", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.IO;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace _218a\n{\n\tclass Program\n\t{\n\t\tstatic void Main(string[] args)\n\t\t{\n\t\t\t//Console.SetIn(File.OpenText(\"in.txt\"));\n\t\t\tvar d = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();\n\t\t\tvar n = d[0];\n\t\t\tvar k = d[1];\n\t\t\tvar a = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();\n\n\t\t\tvar size = n / k;\n\t\t\tvar change = 0;\n\t\t\tfor (int i = 0; i < k; i++)\n\t\t\t{\n\t\t\t\tvar s = i;\n\t\t\t\tvar c1 = 0;\n\t\t\t\tvar c2 = 0;\n\t\t\t\twhile (s <= n - 1)\n\t\t\t\t{\n\t\t\t\t\tif (a[s] == 1)\n\t\t\t\t\t{\n\t\t\t\t\t\tc1++;\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\tc2++;\n\t\t\t\t\t}\n\n\t\t\t\t\ts += k;\n\t\t\t\t}\n\n\t\t\t\tchange += Math.Min(c1, c2);\n\t\t\t}\n\n\t\t\tConsole.WriteLine(change);\n\t\t}\n\t}\n}\n", "lang_cluster": "C#", "tags": ["math", "greedy", "implementation"], "code_uid": "dbebdb4803fbf2d7223ff30c00e8f8a9", "src_uid": "5f94c2ecf1cf8fdbb6117cab801ed281", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\n\n\nnamespace Codeforces_Round_218_2\n{\n\n\n class TaskA\n {\n static void Main(string[] args)\n {\n int n, k;\n string s = Console.ReadLine();\n string[] str = s.Split(' ');\n n = int.Parse(str[0]);\n k = int.Parse(str[1]);\n \n int[] a = new int[n];\n s = Console.ReadLine();\n str = s.Split(' ');\n\n for (int i = 0; i < n; i++)\n a[i] = int.Parse(str[i]);\n\n int nk = n / k;\n int[] dif = new int[k];\n for (int i = 0; i < nk; i++)\n {\n for (int j = 0; j < k; j++)\n {\n //Console.WriteLine(\"Comparing a[{0}] with 2. k={1}, i={2}, j={3}\", k * i + j, k, i, j);\n if (a[k * i + j] == 2)\n {\n dif[j]++;\n //Console.WriteLine(\"dif[{0}]={1}\", j, dif[j]);\n }\n }\n }\n\n int changes = 0;\n for (int i = 0; i < k; i++)\n {\n if (dif[i] > nk / 2)\n dif[i] = nk - dif[i];\n \n changes += dif[i];\n }\n\n Console.WriteLine(changes);\n }\n }\n}", "lang_cluster": "C#", "tags": ["math", "greedy", "implementation"], "code_uid": "b3baff7e91e4acfd19f4791e5745f8cf", "src_uid": "5f94c2ecf1cf8fdbb6117cab801ed281", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Linq;\nusing System.Collections.Generic;\n\nnamespace olymp2\n{\n\tclass MainClass\n\t{\n\t\tpublic static void Main(string[] args)\n\t\t{\n\t\t\tint k = Convert.ToInt32(Console.ReadLine());\n\t\t\tint[] input = Console.ReadLine()\n\t\t\t\t\t\t\t\t .Split(new char[] { ' ' })\n\t\t\t\t\t\t\t\t .Select(x => Convert.ToInt32(x))\n\t\t\t\t\t\t\t\t .ToArray();\n\t\t\tint HH = input[0];\n\t\t\tint MM = input[1];\n\n\t\t\tint btn = 0;\n\t\t\twhile (HH % 10 != 7 && MM % 10 != 7)\n\t\t\t{\n\t\t\t\tif (MM - k < 0)\n\t\t\t\t{\n\t\t\t\t\tMM = 60 + MM - k;\n\t\t\t\t\tHH--;\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tMM -= k;\n\t\t\t\t}\n\t\t\t\tif (HH < 0)\n\t\t\t\t{\n\t\t\t\t\tHH = 23;\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tbtn++;\n\t\t\t}\n\n\t\t\tConsole.WriteLine(btn);\n\n\t\t}\n\t}\n}", "lang_cluster": "C#", "tags": ["brute force", "math", "implementation"], "code_uid": "830e119e2e2eac1fc30d5661ed9321f7", "src_uid": "5ecd569e02e0164a5da9ff549fca3ceb", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace jamieandalarmsnooze\n{\n class Program\n {\n static void Main(string[] args)\n {\n int x = Int32.Parse(Console.ReadLine());\n string[] input = Console.ReadLine().Split(' ');\n int hh = Int32.Parse(input[0]);\n int mm = Int32.Parse(input[1]);\n if (hh == 07 || hh == 17 || mm == 07 || mm == 17 || mm == 27 || mm == 37 || mm == 47 || mm == 57)\n Console.WriteLine(\"0\");\n else\n {\n int time = hh * 60 + mm;\n for(int i=0; ;i++)\n {\n int h = time / 60;\n int m = time % 60;\n time = (time - x + 1440) % 1440;\n if(h/10==7||h%10==7||m/10==7||m%10==7)\n {\n Console.WriteLine(i);\n break;\n }\n\n }\n \n }\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "math", "implementation"], "code_uid": "8c6a898f00b6a794731836018d10476c", "src_uid": "5ecd569e02e0164a5da9ff549fca3ceb", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Text;\nusing System.Text.RegularExpressions;\n\nnamespace A_DieRoll\n{\n class Program\n {\n static void Main(string[] args)\n {\n string[] cases = Console.ReadLine().Split(' ');\n int max = Math.Max(int.Parse(cases[0]), int.Parse(cases[1]));\n int wins = 0;\n while (max <= 6)\n {\n max++;\n wins++;\n }\n switch (wins)\n {\n case 1:\n Console.WriteLine(\"1/6\");\n break;\n case 2:\n Console.WriteLine(\"1/3\");\n break;\n case 3:\n Console.WriteLine(\"1/2\");\n break;\n case 4:\n Console.WriteLine(\"2/3\");\n break;\n case 5:\n Console.WriteLine(\"5/6\");\n break;\n case 6:\n Console.WriteLine(\"1/1\");\n break;\n }\n Console.ReadLine();\n }\n }\n}", "lang_cluster": "C#", "tags": ["math", "probabilities"], "code_uid": "16ed77b6e8d5bdfc85f11392a61b1509", "src_uid": "f97eb4ecffb6cbc8679f0c621fd59414", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nnamespace Practice\n{\n class Program\n {\n static void Main(string[] args)\n {\n\n int[] attemps = GetInts();\n\n SolveProblem(attemps);\n Console.ReadLine();\n }\n\n static void SolveProblem(int [] attemps)\n {\n int num = (6 - ((Math.Max(attemps [0], attemps [1]))-1));\n int denum = 6;\n\n if (num == 6)\n {\n Console.WriteLine(\"1/1\");\n }else\n {\n int df = gcd(num, denum);\n Console.WriteLine(\"{0}/{1}\", num /= df, denum /= df);\n }\n }\n\n static int gcd (int a, int b)\n {\n if (a == 0)\n {\n return b;\n }else if (b == 0)\n {\n return a;\n }\n\n return a > b ? gcd (a & b, b) : gcd (a , b % a);\n }\n static int[] GetInts()\n {\n string[] s = (Console.ReadLine()).Split(' ');\n int[] integers = new int[s.Length];\n for (int i = 0; i < s.Length; i++)\n {\n integers[i] = int.Parse(s[i]);\n }\n return integers;\n }\n\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "probabilities"], "code_uid": "fde70cddc32e1b0dd639a35ba074a0e5", "src_uid": "f97eb4ecffb6cbc8679f0c621fd59414", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections;\nusing System.Collections.Generic;\nusing System.Diagnostics;\nusing System.IO;\nusing System.Linq;\nusing System.Numerics;\nusing System.Text;\nusing System.Text.RegularExpressions;\nusing System.Threading.Tasks;\nusing MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;\nusing MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;\n\n\npublic static class P\n{\n static void Main()\n {\n /*\n Bitmap bitmap = new Bitmap(@\"Secret.DESKTOP + \\fuck.png\");\n var gran = bitmap.Height / 64;\n for (int y = 0; y < 64; y++)\n {\n for (int x = 0; x < 64; x++)\n {\n if (bitmap.GetPixel(x * gran + gran / 2, y * gran + gran / 2).R <= 128) Console.Write('.');\n else Console.Write('#');\n }\n Console.WriteLine();\n }\n */\n string s = @\"..........................#.#.######.#..........................\n......................#.###.#.#.#..#.#####......................\n....................###.#...#...##.#....#..#....................\n.................####.#.#.#####....####.#.###.#.................\n................##......#.#.....####....#.#.#.##................\n..............#..##.#####.###.###.#..#.##...#..#.#..............\n.............###..#..#......#.#...####..##.##.##.##.............\n...........######.##.##.###.###.###....##..#..#...###...........\n..........############....#.....#...#.##..##.##.#..###..........\n.........####################.#######..####..##########.........\n........################################################........\n.......##################################################.......\n.......##################################################.......\n......####################################################......\n.....######################################################.....\n.....######################################################.....\n....########################################################....\n...##########################################################...\n.....########################################################...\n.......############...#..##############...#.#.#############.....\n..##.....#########..#...###############.#.......########........\n..####.....#####...##.#...###############.##.##..#.##.......##..\n.#######.....#...###..###..###########.#..#...##.........######.\n.#########.....#..#..##.##...#########.##.#####..#....#########.\n.############.##.###.....###..#######...#..#....###.###########.\n.#########.....#...###.###...########.#.#####.#...#..#.########.\n############.###.#..#..#...#..######..#..#....##.###...#########\n###########...#..#.##.###.###.####.#.###.####..###...#.#########\n###########.######.####....#..#.#....#.#..#.####...###.#########\n###########.....#..#..###.###...#.#.##.##.#..#...#..#..#########\n############.##.####.##.###...#.###.....####.#.######.##########\n###########...###..#..#...###.#..###.####..#.###...#...#########\n#############.....##.###.##.###.##.....#..##.##..#...#.#########\n##############.##.#....#.#....#.#..#.#.##.#...##.##.############\n############....####.#.#.#.#.####.##.#..#.###..###...###########\n#############.#..#...###...####...#..##....#..##...#############\n################...###...#.##.##.##.##..#.###.#..#..############\n##################...#.######.....#######...#...################\n.################..#....#####.#.###########...#..##############.\n.##############################....############################.\n.###########################.#..#.#############################.\n.#########################.#...################################.\n..########################...#...#############################..\n..#######..###################.###############################..\n...#######.#.################...#####################.#######...\n...#######...#...###########..#.###########.#####.#....######...\n...#######.#.#.#..#.#...##.#.##..#.#..#.##...##.....#.#######...\n....########...##.....#.......##...##......#.#..###.########....\n.....#######.#..####.####.###..###....###.#####.#.#########.....\n.....##########.#..#..#...#.####.###.##.#.....#...#########.....\n......########....##.##.#....#...#.#....###.#...##########......\n.......#########.##...#####.##.#.#...#.##...#############.......\n.......#########..###..#.#...###...#.###..#...###########.......\n........#########...####...###.##.####.####.############........\n.........#########.##....#.#......#....#.##############.........\n..........############.#.####.##.##.#.##..############..........\n...........#############....####....#....############...........\n.............####################.#################.............\n..............####################################..............\n................################################................\n.................##############################.................\n....................########################....................\n......................####################......................\n..........................############..........................\";\n var hw = Console.ReadLine().Split().Select(int.Parse).ToArray();\n var h = hw[0];\n var w = hw[1];\n Console.WriteLine(s.Split('\\n')[h][w] == '.' ? \"OUT\" : \"IN\");\n }\n}\n", "lang_cluster": "C#", "tags": ["dfs and similar", "geometry", "implementation"], "code_uid": "85bf4cfcb041f515da820a6e32a58285", "src_uid": "879ac20ae5d3e7f1002afe907d9887df", "difficulty": null, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nnamespace _784E\n{\n class Program\n {\n static void Main(string[] args)\n {\n bool a1 = Console.ReadLine() == \"1\";\n bool a2 = Console.ReadLine() == \"1\";\n bool a3 = Console.ReadLine() == \"1\";\n bool a4 = Console.ReadLine() == \"1\";\n bool b1 = a1 ^ a2;\n bool b2 = a3 | a4;\n bool b3 = a2 & a3;\n bool b4 = a1 ^ a4;\n bool c1 = b1 & b2;\n bool c2 = b3 | b4;\n bool result = c1 ^ c2;\n Console.WriteLine(result ? \"1\" : \"0\");\n }\n }\n}", "lang_cluster": "C#", "tags": ["brute force", "implementation"], "code_uid": "9cd3ab5d4b3bba04259e2ed633485d29", "src_uid": "879ac20ae5d3e7f1002afe907d9887df", "difficulty": 2000.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.IO;\n\nnamespace ConsoleApplication1\n{\n class vccup1\n {\n static void Main(string[] args)\n {\n //Console.SetIn(new StreamReader(@\"D:\\Sergey\\Code\\1.txt\"));\n\n string[] strParams = Console.ReadLine().Split(new char[] { ' ' }); \n int n = int.Parse(strParams[0]);\n int c = int.Parse(strParams[1]);\n\n //var a = new List();\n strParams = Console.ReadLine().Split(new char[] { ' ' });\n string[] strParams2 = Console.ReadLine().Split(new char[] { ' ' }); \n \n int[] p = new int[n];\n int[] t = new int[n];\n for (int i = 0; i < n; i++)\n {\n p[i] = int.Parse(strParams[i]);\n t[i] = int.Parse(strParams2[i]);\n }\n\n int r1 = 0, r2 = 0;\n long s1 = 0, s2 = 0;\n long r = 0;\n for (int i = 0; i < n; i++)\n {\n r1 += t[i];\n s1 += Math.Max(0, p[i] - c * r1);\n\n r2 += t[n - 1 - i];\n s2 += Math.Max(0, p[n - 1 - i] - c * r2); \n }\n\n if (s1 > s2)\n Console.WriteLine(\"Limak\");\n else if (s1 < s2)\n Console.WriteLine(\"Radewoosh\");\n else\n Console.WriteLine(\"Tie\");\n }//main\n }\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "01b00966d10faafb22540b5075ce95fd", "src_uid": "8c704de75ab85f9e2c04a926143c8b4a", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Linq;\nusing System.Collections.Generic;\nusing System.Text;\n\nnamespace algorithms_700_01\n{\n class Program\n {\n static void Main()\n {\n var array = Console.ReadLine().Split(new char[] { ' ' }).Select(x => int.Parse(x)).ToArray();\n var minuteCost = array[1];\n var scores = Console.ReadLine().Split(new char[] { ' ' }).Select(x => int.Parse(x)).ToArray();\n var times = Console.ReadLine().Split(new char[] { ' ' }).Select(x => int.Parse(x)).ToArray();\n int limakPoints = 0, limakTime = 0;\n int radewooshPoints = 0, radewooshTime = 0;\n for (int i = 0; i < scores.Length; i++)\n {\n limakTime += times[i];\n limakPoints += Math.Max(0, scores[i] - minuteCost * limakTime);\n radewooshTime += times[scores.Length - i - 1];\n radewooshPoints += Math.Max(0, scores[scores.Length - i - 1] - minuteCost * radewooshTime);\n }\n if (limakPoints > radewooshPoints)\n Console.WriteLine(\"Limak\");\n else if (limakPoints < radewooshPoints)\n Console.WriteLine(\"Radewoosh\");\n else\n Console.WriteLine(\"Tie\");\n }\n }\n}", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "e7857e58e68d4f4c41b8a62f5610dc99", "src_uid": "8c704de75ab85f9e2c04a926143c8b4a", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\n\nclass Program\n{\n static void Main()\n {\n string[] input = Console.ReadLine().Split();\n\n int result = int.Parse(input[0]);\n int time = int.Parse(input[1]);\n int cost1 = int.Parse(input[2]);\n int cost2 = int.Parse(input[3]);\n int lose1 = int.Parse(input[4]);\n int lose2 = int.Parse(input[5]);\n\n bool answer = (result == 0);\n\n for (int time1 = 0; time1 < time && !answer; time1++)\n {\n int points1 = cost1 - time1 * lose1;\n if (points1 == result)\n answer = true;\n\n for (int time2 = 0; time2 < time && !answer; time2++)\n {\n int points2 = cost2 - time2 * lose2;\n if (points2 == result || points1 + points2 == result)\n answer = true;\n }\n }\n\n if (answer)\n Console.WriteLine(\"YES\");\n else\n Console.WriteLine(\"NO\");\n }\n}", "lang_cluster": "C#", "tags": ["brute force", "implementation"], "code_uid": "cf9cf4d56bacbd9cf7e3ebdf7d735158", "src_uid": "f98168cdd72369303b82b5a7ac45c3af", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.IO;\n\nnamespace UpSolve\n{\n class Program\n {\n#if DEBUG\n static TextReader In = new StreamReader(\"../../input.txt\");\n static TextWriter Out = new StreamWriter(\"../../output.txt\");\n#else\n static TextReader In = Console.In;\n static TextWriter Out = Console.Out;\n#endif\n\n\n\n static void Main(string[] args) {\n int x, t, a, b, da, db;\n string[] tokens = In.ReadLine().Split();\n x = int.Parse(tokens[0]);\n t = int.Parse(tokens[1]);\n a = int.Parse(tokens[2]);\n b = int.Parse(tokens[3]);\n da = int.Parse(tokens[4]);\n db = int.Parse(tokens[5]);\n\n for (int i = 0; i <= t; i++)\n {\n for (int j = 0; j <= t; j++)\n {\n int q = i == t ? 0 : a - da*i;\n int w = j == t ? 0 : b - db*j;\n\n if (q + w == x)\n {\n Out.WriteLine(\"YES\");\n Out.Close();\n return;\n }\n }\n }\n\n Out.WriteLine(\"NO\");\n Out.Close();\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "implementation"], "code_uid": "15a82d4ee382c9c6c9a50cf1b07e03e6", "src_uid": "f98168cdd72369303b82b5a7ac45c3af", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\n\nclass Program\n{\n static void Main()\n {\n var row = 1;\n var result = 0;\n while (true)\n {\n var line = Console.ReadLine().Replace(\" \", \"\");\n var col = line.IndexOf(\"1\");\n if (col >= 0)\n {\n result = Math.Abs(3 - row) + Math.Abs(3 - (col + 1));\n break;\n }\n row++;\n }\n Console.WriteLine(result);\n }\n}", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "1d4d00f63d69ac782982fd4819228253", "src_uid": "8ba7cedc3f6ae478a0bb3f902440c8e9", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\n\nnamespace ConsoleApp9\n{\n class Program\n {\n static void Main(string[] args)\n {\n var res = 0;\n var liste = new List();\n\n for (var i = 1; i <= 5; i++)\n {\n var array = Console.ReadLine().Trim().Split(' ');\n liste.Clear();\n\n foreach (var q in array) { liste.Add(int.Parse(q)); }\n\n if (liste.Contains(1))\n {\n res += Math.Abs(i - 3);\n res += Math.Abs(2 - liste.IndexOf(1));\n }\n }\n\n Console.WriteLine(res);\n Console.ReadLine();\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "572a6b16679396ca2dd292793cab1151", "src_uid": "8ba7cedc3f6ae478a0bb3f902440c8e9", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\nusing System.IO;\n\nnamespace Learning\n{\n class Program\n {\n static bool s_multiTest = false;\n static void Main(string[] args)\n {\n var o = Console.Out;\n var nTest = 1;\n if (s_multiTest)\n {\n nTest = NextInt();\n }\n\n for (int testId = 1; testId <= nTest; testId++)\n {\n Solve(testId, o);\n }\n Console.ReadLine();\n }\n\n private static void Solve(int testId, TextWriter o)\n {\n var p = new int[4];\n for (var i = 0; i < 4; ++i)\n p[i] = NextInt();\n var from = NextInt();\n var to = NextInt();\n var ans = 0;\n for (var cur = from; cur <= to; cur++)\n {\n var can = 0;\n int val = cur;\n for (int i = 0; i < 4; i++)\n {\n for (int j = 0; j < 4; j++)\n {\n if (j == i)\n continue;\n for (int k = 0; k < 4; k++)\n {\n if (k == i || k == j)\n continue;\n\n for (int l = 0; l < 4; l++)\n {\n if (l == i || l == j || l == k)\n continue;\n val = val % p[i] % p[j] % p[k] % p[l];\n if (val == cur)\n can++;\n }\n }\n }\n }\n if (can >= 7)\n ans++;\n }\n o.WriteLine(ans);\n }\n\n static int s_index = 0;\n static string[] s_tokens;\n private static string Next()\n {\n while (s_tokens == null || s_index == s_tokens.Length)\n {\n s_tokens = Console.ReadLine().Split(' ').ToArray();\n s_index = 0;\n }\n return s_tokens[s_index++];\n }\n\n private static int NextInt()\n {\n return Int32.Parse(Next());\n }\n\n private static long NextLong()\n {\n return Int64.Parse(Next());\n }\n }\n}", "lang_cluster": "C#", "tags": ["implementation", "number theory"], "code_uid": "bac0331c93a438474953795ed341fe67", "src_uid": "63b9dc70e6ad83d89a487ffebe007b0a", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.IO;\n\nnamespace pro\n{\n class Program\n {\n static void Main(string[] args)\n {\n string[] sp = Console.ReadLine().Split();\n int[] p = new int[4];\n p[0] = int.Parse(sp[0]);\n p[1] = int.Parse(sp[1]);\n p[2] = int.Parse(sp[2]);\n p[3] = int.Parse(sp[3]);\n int a = int.Parse(sp[4]);\n int b = int.Parse(sp[5]);\n \n int answer = 0; \n for (int i = a; i <= b; i++)\n {\n int k = 0;\nif (mod(i, p[0], p[1], p[2], p[3]) == i) k ++;\nif (mod(i, p[0], p[1], p[3], p[2]) == i) k ++;\nif (mod(i, p[0], p[2], p[1], p[3]) == i) k ++;\nif (mod(i, p[0], p[2], p[3], p[1]) == i) k ++;\nif (mod(i, p[0], p[3], p[2], p[1]) == i) k ++;\nif (mod(i, p[0], p[3], p[1], p[2]) == i) k ++;\n\nif (mod(i, p[1], p[0], p[2], p[3]) == i) k ++;\nif (mod(i, p[1], p[0], p[3], p[2]) == i) k ++;\nif (mod(i, p[1], p[2], p[0], p[3]) == i) k ++;\nif (mod(i, p[1], p[2], p[3], p[0]) == i) k ++;\nif (mod(i, p[1], p[3], p[2], p[0]) == i) k ++;\nif (mod(i, p[1], p[3], p[0], p[2]) == i) k ++;\n\nif (mod(i, p[2], p[1], p[0], p[3]) == i) k ++;\nif (mod(i, p[2], p[1], p[3], p[0]) == i) k ++;\nif (mod(i, p[2], p[0], p[1], p[3]) == i) k ++;\nif (mod(i, p[2], p[0], p[3], p[1]) == i) k ++;\nif (mod(i, p[2], p[3], p[0], p[1]) == i) k ++;\nif (mod(i, p[2], p[3], p[1], p[0]) == i) k ++;\n\nif (mod(i, p[3], p[1], p[2], p[0]) == i) k ++;\nif (mod(i, p[3], p[1], p[0], p[2]) == i) k ++;\nif (mod(i, p[3], p[2], p[1], p[0]) == i) k ++;\nif (mod(i, p[3], p[2], p[0], p[1]) == i) k ++;\nif (mod(i, p[3], p[0], p[2], p[1]) == i) k ++;\nif (mod(i, p[3], p[0], p[1], p[2]) == i) k ++; \n \n if (k >= 7) answer++;\n\n }\n Console.WriteLine(answer);\n }\n \n static int mod(int x, int p1, int p2, int p3, int p4)\n {\n return (((x % p1) % p2) % p3) % p4;\n } \n \n }\n}", "lang_cluster": "C#", "tags": ["implementation", "number theory"], "code_uid": "fced2636ecba4233bbcb4212ea3a632e", "src_uid": "63b9dc70e6ad83d89a487ffebe007b0a", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Diagnostics;\nusing System.IO;\nusing System.Linq;\n\nnamespace Codeforces\n{\n\tinternal class Template\n\t{\n\t\tprivate void Solve()\n\t\t{\n\t\t var n = cin.NextInt();\n\t\t if (n%2 == 1 || n < 6)\n\t\t {\n\t\t Console.WriteLine(0);\n\t\t return;\n\t\t }\n\t\t n /= 2;\n\t\t n = (n- 1) / 2;\n Console.WriteLine(n);\n\t\t}\n\n\t\tprivate static readonly Scanner cin = new Scanner();\n\n\t\tprivate static void Main()\n\t\t{\n#if DEBUG\n\t\t\tvar inputText = File.ReadAllText(@\"..\\..\\input.txt\");\n\t\t\tvar testCases = inputText.Split(new[] { \"input\" }, StringSplitOptions.RemoveEmptyEntries);\n\t\t\tvar consoleOut = Console.Out;\n\t\t\tfor (var i = 0; i < testCases.Length; i++)\n\t\t\t{\n\t\t\t\tvar parts = testCases[i].Split(new[] { \"output\" }, StringSplitOptions.RemoveEmptyEntries);\n\t\t\t\tConsole.SetIn(new StringReader(parts[0].Trim()));\n\t\t\t\tvar stringWriter = new StringWriter();\n\t\t\t\tConsole.SetOut(stringWriter);\n\t\t\t\tvar sw = Stopwatch.StartNew();\n\t\t\t\tnew Template().Solve();\n\t\t\t\tsw.Stop();\n\t\t\t\tvar output = stringWriter.ToString();\n\n\t\t\t\tConsole.SetOut(consoleOut);\n\t\t\t\tvar color = ConsoleColor.Green;\n\t\t\t\tvar status = \"Passed\";\n\t\t\t\tif (parts[1].Trim() != output.Trim())\n\t\t\t\t{\n\t\t\t\t\tcolor = ConsoleColor.Red;\n\t\t\t\t\tstatus = \"Failed\";\n\t\t\t\t}\n\t\t\t\tConsole.ForegroundColor = color;\n\t\t\t\tConsole.WriteLine(\"Test {0} {1} in {2}ms\", i + 1, status, sw.ElapsedMilliseconds);\n\t\t\t}\n\t\t\tConsole.ReadLine();\n\t\t\tConsole.ReadKey();\n#else\n\t\t\tnew Template().Solve();\n\t\t\tConsole.ReadLine();\n#endif\n\t\t}\n\t}\n\n\tinternal class Scanner\n\t{\n\t\tprivate string[] s = new string[0];\n\t\tprivate int i;\n\t\tprivate readonly char[] cs = { ' ' };\n\n\t\tpublic string NextString()\n\t\t{\n\t\t\tif (i < s.Length) return s[i++];\n\t\t\tvar line = Console.ReadLine() ?? string.Empty;\n\t\t\ts = line.Split(cs, StringSplitOptions.RemoveEmptyEntries);\n\t\t\ti = 1;\n\t\t\treturn s.First();\n\t\t}\n\n\t\tpublic double NextDouble()\n\t\t{\n\t\t\treturn double.Parse(NextString());\n\t\t}\n\n\t\tpublic int NextInt()\n\t\t{\n\t\t\treturn int.Parse(NextString());\n\t\t}\n\n\t\tpublic long NextLong()\n\t\t{\n\t\t\treturn long.Parse(NextString());\n\t\t}\n\t}\n}", "lang_cluster": "C#", "tags": ["math", "combinatorics"], "code_uid": "229f967bf8d76b4d581ab01369012f0f", "src_uid": "32b59d23f71800bc29da74a3fe2e2b37", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nnamespace test1cs\n{\n class Program\n {\n static void Main(string[] args)\n {\n int sum = 0;\n int x = int.Parse(Console.ReadLine());\n int b = x / 2;\n for (int i = 1; i()\n {\n return (T)Convert.ChangeType(Console.ReadLine(), typeof(T));\n }\n\n public static List ReadList(char[] delimiters = null)\n {\n var line = Read();\n var split = line.Split(delimiters ?? new[] { ' ' });\n var list = split.Select(item => (T)Convert.ChangeType(item, typeof(T))).ToList();\n return list;\n }\n\n public static List> ReadIndexedList(char[] delimiters = null)\n {\n var line = Read();\n var split = line.Split(delimiters ?? new[] { ' ' });\n var list = split.Select((item, index) => new KeyValuePair(index + 1, (T)Convert.ChangeType(item, typeof(T)))).ToList();\n return list;\n }\n\n\n public static void ReadFromFile()\n {\n Console.SetIn(new StreamReader(@\"..\\..\\input.txt\"));\n }\n\n ///////////////////////////////////\n \n\n static void Main(string[] args)\n {\n try\n {\n var list = ReadList();\n int r = list[0];\n int g = list[1];\n int b = list[2];\n\n int rr = (int) Math.Ceiling(r/2d);\n int gg = (int) Math.Ceiling(g / 2d);\n int bb = (int) Math.Ceiling(b / 2d);\n \n int res = 30 + Max(0 + (rr - 1)*3 , 1 + (gg - 1)*3 , 2 + (bb - 1)*3);\n Console.WriteLine(res);\n }\n catch\n {\n Console.Write(\"ERROR\");\n }\n }\n\n private static int Max(int i, int i1, int i2)\n {\n return Math.Max(Math.Max(i, i1), i2);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "greedy"], "code_uid": "594e4f697bcd166fed077e04df774480", "src_uid": "a45daac108076102da54e07e1e2a37d7", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\n\nclass ProblemA\n{\n static void Main(string[] args)\n {\n string[] tokens = Console.ReadLine().Split(' ');\n int r = int.Parse(tokens[0]), g = int.Parse(tokens[1]), b = int.Parse(tokens[2]);\n Console.WriteLine(30 + Math.Max(((r + 1) / 2 - 1) * 3, Math.Max(1 + ((g + 1) / 2 - 1) * 3, 2 + ((b + 1) / 2 - 1) * 3)));\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "greedy"], "code_uid": "815da48ae3fb229d56d4fbad157de708", "src_uid": "a45daac108076102da54e07e1e2a37d7", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing Math = System.Math;\nusing Dec = System.Decimal;\nusing System.Globalization;\nusing System.Linq;\n\nnamespace taskA\n{\n\tclass newDecimal {\n\tprivate \n\t\t\tInt64 Z, F, kol;\n\tpublic newDecimal(decimal t, Int64 Kol) {\n\t\t\tkol = Kol;\n\t\t\tZ = Dec.ToInt64 (t);\n\t\t\tInt64 p = 1;\n\t\t\tfor (int i = 0; i < kol; i ++)\n\t\t\t\tp *= 10L;\t\t\n\t\t\tF = Dec.ToInt64 ((t - Z) * p);\n\t\t}\n\t\tpublic void print () {\n\t\t\tConsole.Write (\"{0}.\", Z);\n\t\t\tint sz = F.ToString ().Length;\n\t\t\tfor (int i = 0; i < kol - sz; i ++) \n\t\t\t\tConsole.Write (0);\n\t\t\tConsole.Write (F);\n\t\t}\n\t}\n\n\tclass MainClass\n\t{\n\t\tpublic static void Main(string[] args) {\n\t\t\tint n = int.Parse (Console.ReadLine());\n\t\t\tlong ans = ((1L << n) - 1L) << 1;\n\t\t\tConsole.WriteLine(ans);\n\t\t}\n\t}\n}\n", "lang_cluster": "C#", "tags": ["math", "combinatorics"], "code_uid": "29fd3c7f9c0340fc030c8c3ee0e8d50b", "src_uid": "f1b43baa14d4c262ba616d892525dfde", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\n\nnamespace C\n{\n class Program\n {\n static void Main(string[] args)\n {\n int n = Int32.Parse(Console.ReadLine()); ulong ans = 0;\n for(int i = 1; i<= n; i++)\n ans+=(ulong)Math.Pow(2, i);\n Console.Write(ans);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "combinatorics"], "code_uid": "d482c2663c2946de2946ed1150478d01", "src_uid": "f1b43baa14d4c262ba616d892525dfde", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Linq;\n\nnamespace problemsets_for_codeforces\n{\n class Program\n {\n static void Main(string[] args)\n {\n //watermelon\n //byte w = byte.Parse(Console.ReadLine());\n //if (w%2==0&&w!=2)\n // Console.WriteLine(\"YES\");\n //else\n // Console.WriteLine(\"NO\");\n\n\n\n //byte n = byte.Parse(Console.ReadLine()); string[] words = new string[n];\n //for (byte i = 0; i 10)\n // {\n // Console.WriteLine(\"{0}{1}{2}\", word[0], word.Length - 2, word[word.Length - 1]);\n // }\n // else\n // Console.WriteLine(word);\n //}\n\n\n\n //string word = Console.ReadLine().ToLower();char[] wordArray = new char[word.Length];byte count = 0;\n //foreach (char ch in word) {\n // if(ch != 'a' && ch != 'o' && ch != 'y' && ch != 'e'&& ch != 'u' && ch != 'i') {\n // wordArray[count] = ch;\n // count++;\n // } \n //}\n //for (int x =0; x < count; x++)\n //{\n // Console.Write(\".{0}\", wordArray[x]);\n //}\n\n\n //string s1 = Console.ReadLine().ToLower(), s2 = Console.ReadLine().ToLower();\n ////int x1 = 0, x2 = 0;\n ////foreach (char c in s1)\n //// x1 += Convert.ToInt32(c);\n ////foreach (char c in s2)\n //// x2 += Convert.ToInt32(c);\n ////if (x1 > x2)\n //// Console.WriteLine(1);\n ////else if (x1 == x2)\n //// Console.WriteLine(0);\n ////else\n //// Console.WriteLine(-1);\n //for (int count = 0; count < s1.Length; count++)\n //{\n // if (s1[count] > s2[count])\n // {\n // Console.WriteLine(1);\n // break;\n // }\n // else if(s2[count] > s1[count])\n // {\n // Console.WriteLine(-1);\n // break;\n // }\n //}\n //if (s1 == s2)\n // Console.WriteLine(0);\n //}\n\n\n\n\n //string sum = Console.ReadLine(); int numberCount = 0;\n ////count numbers\n //for (int x = 0; x < sum.Length; x++)\n //{\n // //if (x < sum.Length - 1 && sum[x + 1] != '+' && sum[x] != '+')\n // //{\n // // numberCount++;\n // // x++;\n // //}\n // if(sum[x] != '+')\n // numberCount++;\n //}\n\n ////get numbers\n //int[] numbers = new int[numberCount];\n //numberCount = 0;\n //for (int x = 0; x < sum.Length; x++)\n //{\n // //if (x < sum.Length - 1 && sum[x + 1] != '+' && sum[x] != '+')\n // //{\n // // numbers[numberCount] = int.Parse(sum[x].ToString() + sum[x + 1].ToString());\n // // numberCount++;\n // // x++;\n // //}\n // if(sum[x] != '+')\n // {\n // numbers[numberCount] = int.Parse(sum[x].ToString());\n // numberCount++;\n // }\n //}\n\n ////sort numbers\n //Array.Sort(numbers);\n ////print\n //Console.Write(numbers[0]);\n //for(int x = 1; x< numbers.Length; x++)\n //{\n // Console.Write(\"+\" + numbers[x]);\n //}\n\n\n ////read input\n //Byte n = Byte.Parse(Console.ReadLine());\n //UInt32[] a = new UInt32[n];UInt32 sum1 = 0, sum2 = 0;\n //string x = Console.ReadLine();\n //for (int i = 0; i < n; i++) {\n // a[i] = Convert.ToUInt32(x.Split(' ')[i]);\n // sum1 += a[i];\n //}\n\n ////sort\n //Array.Sort(a);\n\n //for(int i = 0; i < n; i++)\n //{\n // sum1 -= a[i];\n // sum2 += a[i];\n // if (sum2 > sum1)\n // {\n // i++;\n // Console.WriteLine(i);\n // break;\n\n\n\n\n //string s = Console.ReadLine().ToLower();\n //int letter = 1;\n //for(int i = 0; i < s.Length; i++)\n //{\n // switch (letter)\n // {\n // case 1:\n // if (s[i] == 'h')\n // letter++;\n // break;\n // case 2:\n // if (s[i] == 'e')\n // letter++;\n // else if (s[i] == 'h')\n // break;\n // else\n // letter = 0;\n // break;\n // case 3:\n // if (s[i] == 'l' && s[i + 1] != 'l' && i < s.Length - 1)\n // letter++;\n // else if (s[i] == 'e' || s[i] == 'l')\n // break;\n // else\n // letter = 0;\n // break;\n // case 4:\n // if (s[i] == 'o')\n // {\n // Console.WriteLine(\"YES\");\n // i = s.Length;\n // }\n // else\n // letter = 0;\n // break;\n // default:\n // Console.WriteLine(\"NO\");\n // i = s.Length;\n // break;\n // }\n //}\n\n\n char[] s = Console.ReadLine().ToLower().ToCharArray(); string hello = \"hello\";\n for(int sInd = 0,helloIndex = 0; sInd < s.Length; sInd++)\n {\n if (helloIndex < 5 && s[sInd] == hello[helloIndex])\n helloIndex++;\n else\n s[sInd] = '0';\n }\n string s2 = \"\";\n for(int sInd = 0; sInd < s.Length; sInd++)\n {\n if (s[sInd] != '0')\n s2 += Convert.ToString(s[sInd]);\n }\n Console.WriteLine(hello == s2 ? \"YES\" : \"NO\");\n\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["greedy", "strings"], "code_uid": "187524d28b3767fae11ad10fb4d249d4", "src_uid": "c5d19dc8f2478ee8d9cba8cc2e4cd838", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\npublic class Program\n{\n public static void Main()\n {\n var input = Console.ReadLine();\n var expected = \"hello\";\n \n int lastIndex = -1;\n \n for(int i = 0; i < expected.Length; ++i)\n {\n lastIndex = input.IndexOf(expected[i], ++lastIndex);\n if(lastIndex == -1) break;\n }\n \n\t\tif(lastIndex == -1)\n\t\t{\n\t\t\tConsole.WriteLine(\"NO\");\n\t\t}\n\t\telse\n\t\t{\n \tConsole.WriteLine(\"YES\");\n\t\t}\n }\n}", "lang_cluster": "C#", "tags": ["greedy", "strings"], "code_uid": "32340f4a2e34f5f744564a00a9dcb9ca", "src_uid": "c5d19dc8f2478ee8d9cba8cc2e4cd838", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Linq;\nusing System.Collections.Generic;\n\nnamespace CodeForces\n{\n\tclass Program\n\t{\n\t\tstatic void Main(string[] args)\n\t\t{\n\t\t\tread();\n\t\t\tvar vals = readMany().ToList();\n\n\t\t\tint current = 0;\n\t\t\tforeach (int min in vals)\n\t\t\t{\n\t\t\t\tif (min - current > 15)\n\t\t\t\t{\n\t\t\t\t\tConsole.WriteLine(current + 15);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tcurrent = min;\n\t\t\t\t}\n\t\t\t}\n\t\t\tConsole.WriteLine(Math.Min(current + 15, 90));\n\t\t}\n\n\t\tprivate delegate void o(string format, params object[] args);\n\t\tprivate static o Output;\n\n\t\tprivate static T read()\n\t\t{\n\t\t\treturn (T)Convert.ChangeType(Console.ReadLine(), typeof(T));\n\t\t}\n\n\t\tprivate static string read()\n\t\t{\n\t\t\treturn Console.ReadLine();\n\t\t}\n\n\t\tprivate static T[] readMany()\n\t\t{\n\t\t\treturn readMany(' ');\n\t\t}\n\n\t\tprivate static _[] readMany<_>(params char[] ___)\n\t\t{\n\t\t\treturn read().Split(___).Select(__ => (_)Convert.ChangeType(__, typeof(_))).ToArray();\n\t\t}\n\n\t\tprivate static string[] readMany()\n\t\t{\n\t\t\treturn readMany();\n\t\t}\n\n\t\tprivate static T[][] readField(int height, Func map)\n\t\t{\n\t\t\tT[][] res = new T[height][];\n\t\t\tfor (int _ = 0; _ < height; _++)\n\t\t\t{\n\t\t\t\tres[_] = read().Select(c => map(c)).ToArray();\n\t\t\t}\n\t\t\treturn res;\n\t\t}\n\n\t\tprivate static char[][] readField(int height)\n\t\t{\n\t\t\treturn readField(height, c => c);\n\t\t}\n\n\t\tprivate static T[][] readField(int height, Dictionary dic)\n\t\t{\n\t\t\treturn readField(height, c => dic[c]);\n\t\t}\n\n\t\tstatic Func DP(Func f)\n\t\t{\n\t\t\tvar cache = new Dictionary, TResult>();\n\t\t\treturn (t1) =>\n\t\t\t{\n\t\t\t\tvar key = Tuple.Create(t1);\n\t\t\t\tif (!cache.ContainsKey(key))\n\t\t\t\t\tcache.Add(key, f(t1));\n\t\t\t\treturn cache[key];\n\t\t\t};\n\t\t}\n\n\t\tstatic Func DP(Func f)\n\t\t{\n\t\t\tvar cache = new Dictionary, TResult>();\n\t\t\treturn (t1, t2) =>\n\t\t\t{\n\t\t\t\tvar key = Tuple.Create(t1, t2);\n\t\t\t\tif (!cache.ContainsKey(key))\n\t\t\t\t\tcache.Add(key, f(t1, t2));\n\t\t\t\treturn cache[key];\n\t\t\t};\n\t\t}\n\n\t\tstatic Func DP(Func f)\n\t\t{\n\t\t\tvar cache = new Dictionary, TResult>();\n\t\t\treturn (t1, t2, t3) =>\n\t\t\t{\n\t\t\t\tvar key = Tuple.Create(t1, t2, t3);\n\t\t\t\tif (!cache.ContainsKey(key))\n\t\t\t\t\tcache.Add(key, f(t1, t2, t3));\n\t\t\t\treturn cache[key];\n\t\t\t};\n\t\t}\n\n\t\tstatic Func DP(Func f)\n\t\t{\n\t\t\tvar cache = new Dictionary, TResult>();\n\t\t\treturn (t1, t2, t3, t4) =>\n\t\t\t{\n\t\t\t\tvar key = Tuple.Create(t1, t2, t3, t4);\n\t\t\t\tif (!cache.ContainsKey(key))\n\t\t\t\t\tcache.Add(key, f(t1, t2, t3, t4));\n\t\t\t\treturn cache[key];\n\t\t\t};\n\t\t}\n\n\t\tstatic IEnumerable range(long first, long last, long step = 1)\n\t\t{\n\t\t\tfor (long i = first; i <= last; i += step)\n\t\t\t{\n\t\t\t\tyield return i;\n\t\t\t}\n\t\t}\n\n\t\tstatic IEnumerable range(int first, int last, int step = 1)\n\t\t{\n\t\t\tfor (int i = first; i <= last; i += step)\n\t\t\t{\n\t\t\t\tyield return i;\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic static class ExtensionMethods\n\t{\n\t\tpublic static IEnumerable Cartesian(this IEnumerable first, IEnumerable second, Func collector)\n\t\t{\n\t\t\treturn first.SelectMany(f => second.Select(s => collector(f, s)));\n\t\t}\n\n\t\tpublic static IEnumerable> Cartesian(this IEnumerable first, IEnumerable second)\n\t\t{\n\t\t\treturn first.Cartesian(second, Tuple.Create);\n\t\t}\n\n\t\tpublic static IEnumerable> Cartesian(this IEnumerable> first, IEnumerable second)\n\t\t{\n\t\t\treturn first.Cartesian(second, (x, y) => Tuple.Create(x.Item1, x.Item2, y));\n\t\t}\n\n\t\tpublic static IEnumerable> Cartesian(this IEnumerable> first, IEnumerable second)\n\t\t{\n\t\t\treturn first.Cartesian(second, (x, y) => Tuple.Create(x.Item1, x.Item2, x.Item3, y));\n\t\t}\n\n\t\tpublic static IEnumerable> Cartesian(this IEnumerable> first, IEnumerable second)\n\t\t{\n\t\t\treturn first.Cartesian(second, (x, y) => Tuple.Create(x.Item1, x.Item2, x.Item3, x.Item4, y));\n\t\t}\n\n\t\tpublic static IEnumerable> Pow(this IEnumerable it, int num)\n\t\t{\n\t\t\tIEnumerable> res = it.Select(x => new[] { x });\n\t\t\tfor (int i = 0; i < num - 1; i++)\n\t\t\t{\n\t\t\t\tres = res.Cartesian(it, (sofar, n) => sofar.Concat(new[] { n }));\n\t\t\t}\n\t\t\treturn res;\n\t\t}\n\n\t\tpublic static IEnumerable Demask(this IEnumerable> inp)\n\t\t{\n\t\t\tforeach (var pair in inp)\n\t\t\t{\n\t\t\t\tif (pair.Item2)\n\t\t\t\t{\n\t\t\t\t\tyield return pair.Item1;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tpublic static IEnumerable> Combinations(this IEnumerable it)\n\t\t{\n\t\t\tforeach (var conf in new[] { true, false }.Pow(it.Count()))\n\t\t\t{\n\t\t\t\tyield return it.Zip(conf, Tuple.Create).Demask();\n\t\t\t}\n\t\t}\n\n\t\tprivate static IEnumerable single(T it)\n\t\t{\n\t\t\tyield return it;\n\t\t}\n\n\t\tprivate static IEnumerable ExceptSingle(this IEnumerable first, T it, IEqualityComparer comp = null)\n\t\t{\n\t\t\tcomp = comp ?? EqualityComparer.Default;\n\t\t\tbool seen = false;\n\t\t\tforeach (T a in first)\n\t\t\t{\n\t\t\t\tif (seen)\n\t\t\t\t{\n\t\t\t\t\tyield return a;\n\t\t\t\t}\n\t\t\t\telse if (comp.Equals(a, it))\n\t\t\t\t{\n\t\t\t\t\tseen = true;\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tyield return a;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tpublic static IEnumerable> Permutations(this IEnumerable it)\n\t\t{\n\t\t\tif (it.Count() < 2)\n\t\t\t{\n\t\t\t\tyield return it;\n\t\t\t\tyield break;\n\t\t\t}\n\n\t\t\tforeach (T first in it)\n\t\t\t{\n\t\t\t\tforeach (IEnumerable part in Permutations(it.ExceptSingle(first)))\n\t\t\t\t{\n\t\t\t\t\tyield return single(first).Concat(part);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "77489eab3cabda2ffcec036f0c683140", "src_uid": "5031b15e220f0ff6cc1dd3731ecdbf27", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace Codeforces673A\n{\n class Program\n {\n static void Main(string[] args)\n {\n string inp = Console.ReadLine();\n int n = Convert.ToInt32(inp);\n string inp2 = Console.ReadLine() + \" 90\";\n string[] str = inp2.Split(' ');\n int outp = 90;\n\n int prev_min = 0;\n foreach (string s in str)\n {\n int minute = Convert.ToInt32(s);\n if (minute - prev_min > 15)\n {\n outp = prev_min + 15;\n }\n else\n {\n prev_min = minute;\n }\n }\n outp = outp > 90 ? 90 : outp;\n\n Console.WriteLine(outp);\n //inp = Console.ReadLine();\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "f61fb9ca4d046bb28b6f13eb8c38ef94", "src_uid": "5031b15e220f0ff6cc1dd3731ecdbf27", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\n\nnamespace ConsoleApp\n{\n class Program\n {\n static void Main()\n {\n var n = Reader.ReadIntArgs();\n var s = Console.ReadLine();\n\n int cnt = 0;\n int ans = 0;\n\n for (int i = 0; i < s.Length; i++)\n {\n if (s[i] == 'x')\n {\n cnt++;\n }\n else\n {\n ans += cnt > 2 ? cnt - 2 : 0;\n cnt = 0;\n }\n }\n\n ans += cnt > 2 ? cnt - 2 : 0;\n\n Console.WriteLine(ans);\n }\n\n static bool IsPol(string s)\n {\n int l = 0;\n int r = s.Length - 1;\n\n while (l < r)\n {\n if (s[l] != s[r])\n return false;\n\n l++;\n r--;\n }\n\n return true;\n }\n }\n\n static class Reader\n {\n public static List ReadIntArgs()\n {\n return ReadArgs(int.Parse);\n }\n\n public static List ReadLongArgs()\n {\n return ReadArgs(long.Parse);\n }\n\n private static List ReadArgs(Func parser)\n {\n return Console.ReadLine().Split().Select(parser).ToList();\n }\n\n public static int ReadIntValue()\n {\n return ReadValue(int.Parse);\n }\n\n public static long ReadLongValue()\n {\n return ReadValue(long.Parse);\n }\n\n private static T ReadValue(Func parser)\n {\n return parser(Console.ReadLine());\n }\n }\n}", "lang_cluster": "C#", "tags": ["greedy", "strings"], "code_uid": "0e8ca65251803c22fb7b2a7c08f8df1d", "src_uid": "8de14db41d0acee116bd5d8079cb2b02", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace A.Anton_and_Polyhedrons\n{\n class Program\n {\n static void Main(string[] args)\n {\n int n = Int32.Parse(Console.ReadLine());\n string s = Console.ReadLine();\n\n int cont = 0;\n int sum = 0;\n for (int i = 0; i < n; i++)\n {\n if(s[i] == 'x')\n {\n cont++;\n }\n else\n {\n if (cont <= 2)\n {\n cont = 0;\n continue;\n }\n cont -= 2;\n sum +=cont;\n cont = 0;\n }\n\n }\n if(cont > 2)\n {\n cont -= 2;\n sum += cont;\n cont = 0;\n }\n Console.WriteLine(sum);\n Console.ReadLine();\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["greedy", "strings"], "code_uid": "a78d85258569a50348bcf07c76607866", "src_uid": "8de14db41d0acee116bd5d8079cb2b02", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\n\nclass Program\n{\n\tstatic void Main(string[] args)\n\t{\n\t var ss = Console.ReadLine().Trim().Split(' ');\n var n = int.Parse(ss[0]);\n var m = int.Parse(ss[1]);\n var GL = true;\n var HF = false;\n\t\tstring s = Console.ReadLine();\n\t\tfor (int i=0; i+m+1<=n; i++)\n\t\t{\n\t\t var ok = false;\n\t\t for (int j=0; j<=m; j++)\n\t if (s[i+j] != 'N')\n\t\t ok = true;\n\t\t\tif (!ok)\n\t\t\t GL = false;\n\t\t}\n\t\tfor (int i=0; i+m<=n; i++)\n\t\t{\n\t\t var ok = true;\n\t\t for (int j=0; j mx1) {\n mx1 = cur1;\n }\n if (cur2 > mx2) {\n mx2 = cur2;\n }\n }\n cur2 = 0;\n mx2 = 1;\n if (mx1 > k) {\n mx2 = 0;\n }\n for (var i = 0; i <= n - k; i++) {\n cur1 = 1;\n if ((i == 0 || (i > 0 && str[i - 1] != 'N')) && (i + k == n || (i + k < n && str[i + k] != 'N'))) { \n for (var j = 0; j < k; j++) {\n if (str[i + j] == 'Y') {\n cur1 = 0;\n }\n }\n if (cur1 == 1) {\n cur2 = 1;\n }\n }\n }\n if (mx2 == 0) {\n Console.WriteLine(\"NO\");\n }\n else if (cur2 == 1) {\n Console.WriteLine(\"YES\");\n }\n else {\n Console.WriteLine(\"NO\");\n }\n }\n\n}", "lang_cluster": "C#", "tags": ["dp"], "code_uid": "09422dc950627902971d61203e34b358", "src_uid": "5bd578d3da5837c259b222336a194d12", "difficulty": 2000.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nnamespace _893B\n{\n internal class Program\n {\n public static void Main(string[] args)\n {\n long n = long.Parse(Console.ReadLine());\n long result = 0;\n for (int j = 1; j < 25; j++)\n {\n long num = ((1L << j) - 1L) * (1L << (j - 1));\n if (num <= n && n % num == 0 && num > result)\n result = num;\n }\n Console.WriteLine(result);\n }\n }\n}", "lang_cluster": "C#", "tags": ["brute force", "implementation"], "code_uid": "150c124e0af30d02b5c3b517ca7a59ba", "src_uid": "339246a1be81aefe19290de0d1aead84", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Linq;\n\nnamespace CSharp\n{\n class _893B\n {\n public static void Main()\n {\n int n = int.Parse(Console.ReadLine());\n Console.WriteLine(Enumerable.Range(1, n).Where(d => n % d == 0 && IsBeautiful(d)).Max());\n }\n\n private static bool IsBeautiful(int n)\n {\n string binary = Convert.ToString(n, 2);\n int k = binary.Length / 2;\n return binary.Take(k + 1).All(c => c == '1') && binary.Reverse().Take(k).All(c => c == '0');\n }\n }\n}", "lang_cluster": "C#", "tags": ["brute force", "implementation"], "code_uid": "81525b553c164abf3b490bb1dd7e3d7a", "src_uid": "339246a1be81aefe19290de0d1aead84", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.IO;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace ConsoleApp1\n{\n class Program\n {\n static void Main(string[] args)\n {\n int[] mouth = new int[] { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };\n\n int total = 1;\n\n string line = Console.ReadLine();\n\n int m = int.Parse(line.Split(' ')[0]),\n d = int.Parse(line.Split(' ')[1]);\n\n d = mouth[m] - (8 - d);\n\n //Console.WriteLine(\"{0} {1}\", d, (decimal)d/7);\n total += (int)Math.Ceiling((decimal)d / 7);\n\n Console.WriteLine(total);\n\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "implementation"], "code_uid": "6311b3cf1bf345c79e5f4f874bb1d413", "src_uid": "5b969b6f564df6f71e23d4adfb2ded74", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\n\nnamespace Number760A {\n class Program {\n static void Main(string[] args) {\n var mas = Console.ReadLine().Split(' ');\n Int32 numberMonth = Int32.Parse(mas[0]);\n Int32 numberWeekDays = Int32.Parse(mas[1]);\n Int32 days = GetCountDays(numberMonth) - 8 + numberWeekDays;\n Int32 mod = days % 7 == 0 ? 0 : 1;\n Console.WriteLine((Int32)(days / 7.0) + mod + 1);\n }\n\n static Int32 GetCountDays(Int32 m) {\n if(m == 1 || m == 3 || m == 5 || m == 7 || m == 8 || m == 10 || m == 12)\n return 31;\n if(m == 4 || m == 6 || m == 9 || m == 11)\n return 30;\n return 28;\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "implementation"], "code_uid": "8fb1ed1ee2fb5982bc9571ec346414c1", "src_uid": "5b969b6f564df6f71e23d4adfb2ded74", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "/*\nAuthor : Shivakkumar K R\nFile name : 313_Div2_ProbB.cs\n*/\nusing System;\nusing System.Collections;\nusing System.Linq;\nusing System.Text;\nusing System.IO;\npublic class _313_Div2_ProbB {\n\tstatic int max(int a, int b)\n\t{\n\t\treturn Math.Max(a, b);\n\t}\n\tstatic void swap(ref T a, ref T b) {\n\t\tT c = a;\n\t\ta = b;\n\t\tb = c;\n\t}\n\tstatic void Main(string [] args) {\n\t\t//Console.SetIn(new StreamReader(File.OpenRead(\"C://Users//Shiva//Desktop//313_Div2_ProbB.txt\")));\n\t\tvar input = Console.ReadLine().Split(new char[] {});\n\t\tint a = int.Parse(input[0]), b = int.Parse(input[1]);\n\t\tinput = Console.ReadLine().Split(new char[] {});\n\t\tint c = int.Parse(input[0]), d = int.Parse(input[1]);\n\t\tinput = Console.ReadLine().Split(new char[] {});\n\t\tint e = int.Parse(input[0]), f = int.Parse(input[1]);\n\n\t\tfor (int i = 0; i < 4; i++) {\n\t\t\tif ((a >= (c + e) && b >= d && b >= f) || (b >= (d + f) && a >= c && a >= e)) {\n\t\t\t\tConsole.WriteLine(\"YES\"); return;\n\t\t\t}\n\t\t\tif (i % 2 == 0) swap(ref c, ref d);\n\t\t\tswap(ref e, ref f);\n\t\t}\n\n\t\tConsole.WriteLine(\"NO\");\n\t}\n}\n", "lang_cluster": "C#", "tags": ["constructive algorithms", "implementation"], "code_uid": "9f562fea9c66199ec98f589a37611ff0", "src_uid": "2ff30d9c4288390fd7b5b37715638ad9", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace _560B_Gerald_is_into_Art\n{\n class Program\n {\n static void Main(string[] args)\n {\n string[] board = Console.ReadLine().Split();\n string[] painting1 = Console.ReadLine().Split();\n string[] painting2 = Console.ReadLine().Split();\n\n int a1 = int.Parse(board[0]);\n int b1 = int.Parse(board[1]);\n\n int a2 = int.Parse(painting1[0]);\n int b2 = int.Parse(painting1[1]);\n\n int a3 = int.Parse(painting2[0]);\n int b3 = int.Parse(painting2[1]);\n\n bool fits = false;\n\n // naast elkaar op zijde a1\n\n if (a1 >= a2 + a3 && !fits)\n {\n if (b1 >= Math.Max(b2, b3))\n {\n Console.WriteLine(\"YES\");\n fits = true;\n }\n }\n\n if (a1 >= a2 + b3 && !fits)\n {\n if (b1 >= Math.Max(b2, a3))\n {\n Console.WriteLine(\"YES\");\n fits = true;\n }\n }\n\n if (a1 >= b2 + a3 && !fits)\n {\n if (b1 >= Math.Max(a2, b3))\n {\n Console.WriteLine(\"YES\");\n fits = true;\n }\n }\n\n if (a1 >= b2 + b3 && !fits)\n {\n if (b1 >= Math.Max(a2, a3))\n {\n Console.WriteLine(\"YES\");\n fits = true;\n }\n }\n\n // naast elkaar op zijde b1\n\n if (b1 >= a2 + a3 && !fits)\n {\n if (a1 >= Math.Max(b2, b3))\n {\n Console.WriteLine(\"YES\");\n fits = true;\n }\n }\n\n if (b1 >= a2 + b3 && !fits)\n {\n if (a1 >= Math.Max(b2, a3))\n {\n Console.WriteLine(\"YES\");\n fits = true;\n }\n }\n\n if (b1 >= b2 + a3 && !fits)\n {\n if (a1 >= Math.Max(a2, b3))\n {\n Console.WriteLine(\"YES\");\n fits = true;\n }\n }\n\n if (b1 >= b2 + b3 && !fits)\n {\n if (a1 >= Math.Max(a2, a3))\n {\n Console.WriteLine(\"YES\");\n fits = true;\n }\n }\n\n // If nothing fits\n\n if (!fits)\n Console.WriteLine(\"NO\");\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["constructive algorithms", "implementation"], "code_uid": "2b97983806e201e5e7bb0d4373e67add", "src_uid": "2ff30d9c4288390fd7b5b37715638ad9", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\n\nnamespace myApp {\n class Program {\n static void Main (string[] args) {\n int[] a = new int[5];\n for(int i = 0; i < 5; i++)\n a[i] = int.Parse(Console.ReadLine());\n bool[] harmed = new bool[a[4]+1];\n int rs = 0;\n for(int i = 0; i < 4; i++){\n if(a[i] == 1){\n rs = a[4]; break;\n }\n for(int j = 1; j * a[i] <= a[4]; j++)\n if(!harmed[j*a[i]]) {\n harmed[j*a[i]] = true;\n rs++;\n }\n }\n Console.WriteLine(rs);\n }\n }\n}", "lang_cluster": "C#", "tags": ["math", "constructive algorithms", "implementation"], "code_uid": "e4cc4d864ed265d6fa6c67333c725ca6", "src_uid": "46bfdec9bfc1e91bd2f5022f3d3c8ce7", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nnamespace problems\n{\n internal class _148A\n {\n private static void Main(string[] args)\n {\n var k = int.Parse(Console.ReadLine());\n var l = int.Parse(Console.ReadLine());\n var m = int.Parse(Console.ReadLine());\n var n = int.Parse(Console.ReadLine());\n var d = int.Parse(Console.ReadLine());\n int result=0;\n Calc(new[] { k, l, m, n }, 0, new List(),d, ref result);\n\n //int result = d / k + d / l + d / m + d / n\n // - d / lcm(k, m) - d / lcm(k, l) - d / lcm(k, n) - d / lcm(l, m) - d / lcm(n, m) - d / lcm(l, n)\n // + d / lcm(k, l, n) + d / lcm(k,l, m) + d / lcm(m, l, n) + d / lcm(k, m, n)\n // - d / lcm(k, l, m, n);\n Console.WriteLine(result);\n }\n\n private static void Calc(int[] array, int at, List subset,int d, ref int result)\n {\n if (at == array.Length && subset.Count > 0)\n { \n result += d * ((subset.Count % 2 == 0) ? -1 : 1) / lcm(subset);\n return; \n }\n else if(at a)\n {\n var res = 1;\n foreach (int el in a)\n { \n res = lcm(res, el); \n }\n return res;\n }\n }\n}", "lang_cluster": "C#", "tags": ["math", "constructive algorithms", "implementation"], "code_uid": "b66edb6782cfb49a1a30cc43604a79d0", "src_uid": "46bfdec9bfc1e91bd2f5022f3d3c8ce7", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\nnamespace ConsoleApplication3\n{\n class Program\n {\n static void Main(string[] args)\n {\n try\n {\n string s = Console.ReadLine();\n s = s.Replace(\"VK\",\"*\");\n int c = 0;\n // Console.WriteLine(s);\n for (int i = 0; i < s.Length; i++)\n {\n if (s[i] == '*')\n c++;\n }\n if (s.IndexOf(\"VV\") != -1 || s.IndexOf(\"KK\") != -1)\n c++;\n Console.WriteLine(c);\n Console.ReadKey();\n }\n catch { }\n }\n \n }\n}", "lang_cluster": "C#", "tags": ["brute force"], "code_uid": "c2ebc967241c69d0dc4284142c6ef6dc", "src_uid": "578bae0fe6634882227ac371ebb38fc9", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\n\nnamespace Lab1cs\n{\n class Program\n {\n \n\n static void Main(string[] args)\n {\n string s;\n s = Console.ReadLine();\n int i = 0, k = 0, j = 0, k1 = 0;\n for (i = 0; i < s.Length - 1; i++)\n {\n\n if (s.Substring(i, 2) == \"VK\")\n { k++; i++; }\n }\n\n if (s.Contains(\"VV\"))\n {\n for (i = 0; i < s.Length - 1; i++)\n {\n string ss = s;\n if (ss.Substring(i, 2) == \"VV\")\n {\n ss = ss.Remove(i + 1, 1);\n ss = ss.Insert(i + 1, \"K\");\n\n for (j = 0; j < s.Length - 1; j++)\n {\n\n if (ss.Substring(j, 2) == \"VK\")\n { k1++; j++; }\n }\n if (k1 > k)\n k = k1;\n k1 = 0;\n }\n }\n }\n\n if (s.Contains(\"KK\"))\n {\n for (i = 0; i < s.Length - 1; i++)\n {\n string ss = s;\n if (ss.Substring(i, 2) == \"KK\")\n {\n ss = ss.Remove(i, 1);\n ss = ss.Insert(i, \"V\");\n\n for (j = 0; j < s.Length - 1; j++)\n {\n\n if (ss.Substring(j, 2) == \"VK\")\n { k1++; j++; }\n }\n if (k1 > k)\n k = k1;\n k1 = 0;\n }\n }\n }\n Console.Write(k);\n // Console.ReadKey();\n\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force"], "code_uid": "00c62379719508813d0a9c25b7c23e41", "src_uid": "578bae0fe6634882227ac371ebb38fc9", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "C# 10", "source_code": "using System;\r\nusing System.Collections;\r\nusing System.Collections.Generic;\r\nusing System.Linq;\r\n\r\npublic sealed class CodeForces\r\n{\r\n private static void Main()\r\n {\r\n int t = int.Parse(Console.ReadLine());\r\n for (int i = 0; i < t; i++)\r\n {\r\n int n = int.Parse(Console.ReadLine());\r\n Console.WriteLine(Solve(n));\r\n }\r\n }\r\n\r\n private static int Solve(int n)\r\n {\r\n return (int)Math.Pow(2, n) - 1;\r\n }\r\n}", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "8e8197705968bbeaada8d798d4b59bbe", "src_uid": "d5e66e34601cad6d78c3f02898fa09f4", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "C# 8", "source_code": "using System;\r\nusing System.Collections.Generic;\r\nusing System.Text;\r\n\r\nnamespace Codeforces\r\n{\r\n internal class Program1651A\r\n {\r\n static void Main()\r\n {\r\n int c = int.Parse(Console.ReadLine());\r\n while (c-- > 0)\r\n {\r\n int n = int.Parse(Console.ReadLine());\r\n Console.WriteLine(Math.Pow(2, n) - 1);\r\n }\r\n\r\n }\r\n }\r\n}", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "58d81ef548c867c332325c13fb7f65a9", "src_uid": "d5e66e34601cad6d78c3f02898fa09f4", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\n\nnamespace CodeForcesRound256\n{\n class A\n {\n static void Main(string[] args)\n {\n List c = ReadIntegers();\n List m = ReadIntegers();\n int n = ReadInteger();\n int cups = c.Sum();\n int medals = m.Sum();\n\n int shelvesForCups = cups / 5;\n if (cups % 5 > 0) shelvesForCups++;\n\n int shelvesForMedals = medals / 10;\n if (medals % 10 > 0) shelvesForMedals++;\n\n if (shelvesForMedals + shelvesForCups > n)\n Console.WriteLine(\"NO\");\n else\n Console.WriteLine(\"YES\");\n }\n\n private static string ReadLine() { return Console.ReadLine(); }\n private static List ReadStrings() { return ReadLine().Split(\" \".ToArray(), StringSplitOptions.RemoveEmptyEntries).ToList(); }\n private static int ReadInteger() { return int.Parse(Console.ReadLine()); }\n private static List ReadIntegers() { List tmpList = new List(); ReadStrings().ForEach(i => tmpList.Add(int.Parse(i))); return tmpList; }\n private static long ReadLong() { return long.Parse(Console.ReadLine()); }\n private static List ReadLongs() { List tmpList = new List(); ReadStrings().ForEach(i => tmpList.Add(long.Parse(i))); return tmpList; }\n }\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "1e90bc6be8310d918f9dcbbbce0e6b29", "src_uid": "fe6301816dea7d9cea1c3a06a7d1ea7e", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": " using System;\n\n namespace Issue_448A\n {\n class Program\n {\n public static void Main(string[] args) {\n const byte Places = 3;\n\n var cups = new int[Places];\n var medals = new int[Places];\n\n for (int i = 0; i < Places; ++i) {\n cups[i] = ReadInt();\n }\n\n for (int i = 0; i < Places; ++i) {\n medals[i] = ReadInt();\n }\n\n var shelfs_count = ReadInt();\n\n var required_shelfs = \n cups[0] / 5 + \n cups[1] / 5 +\n cups[2] / 5 +\n (cups[0] % 5 + cups[1] % 5 + cups[2] % 5) / 5 +\n (((cups[0] % 5 + cups[1] % 5 + cups[2] % 5) % 5) > 0 ? 1 : 0) +\n medals[0] / 10 +\n medals[1] / 10 +\n medals[2] / 10 +\n (medals[0] % 10 + medals[1] % 10 + medals[2] % 10) / 10 +\n ((((medals[0] % 10 + medals[1] % 10 + medals[2] % 10) % 10) % 10) > 0 ? 1 : 0);\n\n Console.WriteLine(required_shelfs <= shelfs_count ? \"YES\" : \"NO\");\n }\n\n private static bool IsInputError = false;\n private static bool IsEndOfLine = false;\n\n private static int ReadInt() {\n const int zeroCode = (int) '0';\n\n var result = 0;\n var isNegative = false;\n var symbol = Console.Read();\n IsInputError = false;\n IsEndOfLine = false;\n\n while (symbol == ' ') {\n symbol = Console.Read();\n }\n\n if (symbol == '-') {\n isNegative = true;\n symbol = Console.Read();\n }\n\n for ( ;\n (symbol != -1) && (symbol != ' ');\n symbol = Console.Read()\n ) {\n var digit = symbol - zeroCode;\n \n // if symbol == \\n\n if (symbol == 13) {\n // skip next \\r symbol\n Console.Read();\n IsEndOfLine = true;\n break;\n }\n\n if (digit < 10 && digit >= 0) {\n var cache1 = result << 1;\n var cache2 = cache1 << 2;\n result = cache1 + cache2 + digit;\n } else {\n IsInputError = true;\n break;\n }\n }\n\n return isNegative ? ~result + 1 : result;\n }\n }\n }", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "60091369ec4d08a97f87466dc782fedf", "src_uid": "fe6301816dea7d9cea1c3a06a7d1ea7e", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace ConsoleApplication2\n{\n class Program\n {\n static void Main(string[] args)\n {\n\n int t = int.Parse(Console.ReadLine());\n for (int i = 0; i < t; i++)\n {\n\n\n int x = int.Parse(Console.ReadLine());\n if (x==1 || x==2 ||x==4 ||x==5 || x==8 ||x==11)\n {\n\n Console.WriteLine(\"NO\");\n\n }\n else\n {\n Console.WriteLine(\"YES\");\n }\n }\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["greedy", "implementation"], "code_uid": "fe9be1cb7302bde72656e6ae83f53d94", "src_uid": "cfd1182be98fb5f0c426f8b68e48d452", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\n\nnamespace AlgoTasks\n{\n class Program\n {\n static void Main(string[] args)\n {\n short n = short.Parse(Console.ReadLine());\n //2\n //6\n //5\n //yes\n //no\n\n for (short i = 0; i < n; i++)\n {\n short x = short.Parse(Console.ReadLine());\n bool yes = false;\n\n short t = x;\n while(t >= 7)\n {\n if (t % 7 == 0 || t % 3 == 0)\n {\n yes = true;\n break;\n }\n t -= 3;\n }\n\n t = x;\n while (t >= 3)\n {\n if (t % 7 == 0 || t % 3 == 0)\n {\n yes = true;\n break;\n }\n t -= 7;\n }\n\n if (yes)\n Console.WriteLine(\"YES\");\n else\n Console.WriteLine(\"NO\");\n }\n }\n }\n} \n\n", "lang_cluster": "C#", "tags": ["greedy", "implementation"], "code_uid": "07abe2dcf9da8563d6e07ff02a3f5934", "src_uid": "cfd1182be98fb5f0c426f8b68e48d452", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace Codeforces1305A\n{\n class Program\n {\n static void Main(string[] args)\n { \n int n = int.Parse(Console.ReadLine());\n\n string read;\n read = Console.ReadLine();\n List ArrayA = new List();\n ArrayA = (read.Split(' ').ToList()).Select(s => int.Parse(s)).ToList();\n\n HashSet hashit = new HashSet();\n\n for(int i = n-1;i>=0;i--)\n {\n if(!hashit.Contains(ArrayA[i]))\n {\n hashit.Add(ArrayA[i]);\n }\n }\n Console.WriteLine(hashit.Count);\n Console.WriteLine(String.Join(\" \",hashit.Reverse().ToList()));\n\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "c683f0a43f530160eb87a99775c951a3", "src_uid": "1b9d3dfcc2353eac20b84c75c27fab5a", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\n\nnamespace _978A\n{\n public static class Program\n {\n public static void Main(string[] args)\n {\n var n = rl();\n var arr = rlai();\n var res = new List();\n var hs = new HashSet();\n\n for (var i = arr.Length - 1; i >= 0; i--)\n {\n if (!hs.Contains(arr[i]))\n {\n hs.Add(arr[i]);\n res.Insert(0, arr[i]);\n }\n }\n\n wl(res.Count);\n wla(res.ToArray());\n }\n\n private static T rl() { return (T)Convert.ChangeType(Console.ReadLine(), typeof(T)); }\n private static T[] rla(char sep = ' ') { return Console.ReadLine().Split(sep).Select(s => (T)Convert.ChangeType(s, typeof(T))).ToArray(); }\n private static int[] rlai(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), int.Parse); }\n private static long[] rlal(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), long.Parse); }\n private static string[] rlas(char sep = ' ') { return Console.ReadLine().Split(sep); }\n private static List rll(char sep = ' ') { return Console.ReadLine().Split(sep).Select(s => (T)Convert.ChangeType(s, typeof(T))).ToList(); }\n private static T rn(char sep = ' ') { var b = new StringBuilder(); while (true) { var c = (char)Console.In.Read(); if (c == sep || c == '\\n') break; b.Append(c); } return (T)Convert.ChangeType(b.ToString(), typeof(T)); }\n private static void wl(object o) { Console.WriteLine(o); }\n private static void wla(int[] arr, string sep = \" \") { Console.WriteLine(string.Join(sep, arr)); }\n private static void wla(long[] arr, string sep = \" \") { Console.WriteLine(string.Join(sep, arr)); }\n private static void wla(string[] arr, string sep = \" \") { Console.WriteLine(string.Join(sep, arr)); }\n private static void w(object o) { Console.Write(o); }\n private static void wn(object o, string sep = \" \") { Console.Write(o + sep); }\n }\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "4f2529b963bc5237a69717a38997d426", "src_uid": "1b9d3dfcc2353eac20b84c75c27fab5a", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeff// Submitted by Stratholme @ Macau\nusing System;\nusing System.IO;\nusing System.Collections.Generic;\nusing CCF_XOI;\n\nnamespace CodeForces\n{\n\tclass CF456C\n\t{\n\t\tpublic void Solve(XOI xoi)\n\t\t{\n\t\t\tint N, i, j, k, ans;\n\t\t\tlong[] hash = new long[2];\n\t\t\tList[] K = new List[2];\n\t\t\tHashSet> comb = new HashSet>();\n\n\t\t\tN = xoi.ReadInt();\n\t\t\tfor (i = 0; i < 2; i++)\n\t\t\t{\n\t\t\t\tK[i] = new List();\n\t\t\t\tk = xoi.ReadInt();\n\t\t\t\tfor (j = 0; j < k; j++)\n\t\t\t\t\tK[i].Add(xoi.ReadInt());\n\t\t\t}\n\n\t\t\tfor (ans = 0; ; ans++)\n\t\t\t{\n\t\t\t\tif (K[0].Count == 0) { k = 2; break; }\n\t\t\t\tif (K[1].Count == 0) { k = 1; break; }\n\n\t\t\t\tk = (K[0][0] > K[1][0] ? 0 : 1);\n\t\t\t\tK[k].Add(K[1 - k][0]);\n\t\t\t\tK[k].Add(K[k][0]);\n\t\t\t\tK[k].RemoveAt(0);\n\t\t\t\tK[1 - k].RemoveAt(0);\n\n\t\t\t\tfor (i = 0; i < 2; i++)\n\t\t\t\t{\n\t\t\t\t\tfor (j = 0, hash[i] = 0; j < N; j++)\n\t\t\t\t\t{\n\t\t\t\t\t\thash[i] *= 11;\n\t\t\t\t\t\tif (j < K[i].Count)\n\t\t\t\t\t\t\thash[i] += K[i][j];\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (!comb.Add(Tuple.Create(hash[0], hash[1])))\n\t\t\t\t{\n\t\t\t\t\tans = -1;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (ans == -1)\n\t\t\t\txoi.o.WriteLine(\"-1\");\n\t\t\telse\n\t\t\t\txoi.o.WriteLine(\"{0} {1}\", ans, k);\n\t\t}\n\t}\n\n\tclass CodeForcesMain\n\t{\n\t\tstatic void Main(string[] args)\n\t\t{\n\t\t\t(new CF456C()).Solve(new XOI());\n\t\t}\n\t}\n}\n\nnamespace CCF_XOI\n{\t// version 2014.06.20\n\tclass XOI\n\t{\n\t\tprotected StreamReader sr;\n\t\tpublic StreamWriter o;\n\t\tprotected Queue buf = new Queue();\n\t\tpublic bool EOF = false;\n\n\t\tpublic XOI()\n\t\t{\n\t\t\tthis.sr = new StreamReader(Console.OpenStandardInput());\n\t\t\tthis.o = new StreamWriter(Console.OpenStandardOutput());\n\t\t\tthis.o.AutoFlush = true;\n\t\t}\n\n\t\tpublic XOI(string in_path, string out_path)\n\t\t{\n\t\t\tthis.sr = new StreamReader(in_path);\n\t\t\tthis.o = new StreamWriter(out_path);\n\t\t\tthis.o.AutoFlush = true;\n\t\t}\n\n\t\tpublic int ReadInt()\n\t\t{\n\t\t\tstring s = this.GetNext();\n\t\t\tif (s == null) return -1;\n\t\t\telse return Int32.Parse(s);\n\t\t}\n\n\t\tpublic long ReadLong()\n\t\t{\n\t\t\tstring s = this.GetNext();\n\t\t\tif (s == null) return -1;\n\t\t\telse return Int64.Parse(s);\n\t\t}\n\n\t\tpublic double ReadDouble()\n\t\t{\n\t\t\tstring s = this.GetNext();\n\t\t\tif (s == null) return -1;\n\t\t\telse return Double.Parse(s, System.Globalization.CultureInfo.InvariantCulture);\n\t\t}\n\n\t\tpublic string ReadString()\n\t\t{\n\t\t\tstring s = this.GetNext();\n\t\t\treturn (s == null ? null : s);\n\t\t}\n\n\t\tpublic string ReadLine()\n\t\t{\t// I will ignore current buffer and read a new line\n\t\t\tstring s = \"\";\n\t\t\twhile (s == \"\" && !this.EOF)\n\t\t\t{\n\t\t\t\ts = sr.ReadLine();\n\t\t\t\tthis.EOF = (s == null);\n\t\t\t}\n\t\t\treturn (this.EOF ? null : s);\n\t\t}\n\n\t\tprotected string GetNext()\n\t\t{\n\t\t\tif (buf.Count == 0)\n\t\t\t{\n\t\t\t\twhile (buf.Count == 0 && !this.EOF)\n\t\t\t\t{\n\t\t\t\t\tstring s = sr.ReadLine();\n\t\t\t\t\tif (s == null)\n\t\t\t\t\t\tthis.EOF = true;\n\t\t\t\t\telse\n\t\t\t\t\t\tforeach (string ss in s.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries))\n\t\t\t\t\t\t\tbuf.Enqueue(ss);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn (this.EOF ? null : buf.Dequeue());\n\t\t}\n\t}\n}\n", "lang_cluster": "C#", "tags": ["dfs and similar", "brute force", "games"], "code_uid": "743ac659033a78076403f16e1c74368a", "src_uid": "f587b1867754e6958c3d7e0fe368ec6e", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeff// Submitted by Silithus @ Macau\nusing System;\nusing System.IO;\nusing System.Collections.Generic;\nusing CCF_XOI;\n\nnamespace CodeForces\n{\n\tclass CF456C\n\t{\n\t\tpublic void Solve(XOI xoi)\n\t\t{\n\t\t\tint N, i, j, k, ans;\n\t\t\tlong[] hash = new long[2];\n\t\t\tList[] K = new List[2];\n\t\t\tHashSet> comb = new HashSet>();\n\n\t\t\tN = xoi.ReadInt();\n\t\t\tfor (i = 0; i < 2; i++)\n\t\t\t{\n\t\t\t\tK[i] = new List();\n\t\t\t\tk = xoi.ReadInt();\n\t\t\t\tfor (j = 0; j < k; j++)\n\t\t\t\t\tK[i].Add(xoi.ReadInt());\n\t\t\t}\n\n\t\t\tfor (ans = 0; ; ans++)\n\t\t\t{\n\t\t\t\tif (K[0].Count == 0) { k = 2; break; }\n\t\t\t\tif (K[1].Count == 0) { k = 1; break; }\n\n\t\t\t\tk = (K[0][0] > K[1][0] ? 0 : 1);\n\t\t\t\tK[k].Add(K[1 - k][0]);\n\t\t\t\tK[k].Add(K[k][0]);\n\t\t\t\tK[k].RemoveAt(0);\n\t\t\t\tK[1 - k].RemoveAt(0);\n\n\t\t\t\tfor (i = 0; i < 2; i++)\n\t\t\t\t{\n\t\t\t\t\tfor (j = 0, hash[i] = 0; j < N; j++)\n\t\t\t\t\t{\n\t\t\t\t\t\thash[i] *= 11;\n\t\t\t\t\t\tif (j < K[i].Count)\n\t\t\t\t\t\t\thash[i] += K[i][j];\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (!comb.Add(Tuple.Create(hash[0], hash[1])))\n\t\t\t\t{\n\t\t\t\t\tans = -1;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (ans == -1)\n\t\t\t\txoi.o.WriteLine(\"-1\");\n\t\t\telse\n\t\t\t\txoi.o.WriteLine(\"{0} {1}\", ans, k);\n\t\t}\n\t}\n\n\tclass CodeForcesMain\n\t{\n\t\tstatic void Main(string[] args)\n\t\t{\n\t\t\t(new CF456C()).Solve(new XOI());\n\t\t}\n\t}\n}\n\nnamespace CCF_XOI\n{\t// version 2014.06.20\n\tclass XOI\n\t{\n\t\tprotected StreamReader sr;\n\t\tpublic StreamWriter o;\n\t\tprotected Queue buf = new Queue();\n\t\tpublic bool EOF = false;\n\n\t\tpublic XOI()\n\t\t{\n\t\t\tthis.sr = new StreamReader(Console.OpenStandardInput());\n\t\t\tthis.o = new StreamWriter(Console.OpenStandardOutput());\n\t\t\tthis.o.AutoFlush = true;\n\t\t}\n\n\t\tpublic XOI(string in_path, string out_path)\n\t\t{\n\t\t\tthis.sr = new StreamReader(in_path);\n\t\t\tthis.o = new StreamWriter(out_path);\n\t\t\tthis.o.AutoFlush = true;\n\t\t}\n\n\t\tpublic int ReadInt()\n\t\t{\n\t\t\tstring s = this.GetNext();\n\t\t\tif (s == null) return -1;\n\t\t\telse return Int32.Parse(s);\n\t\t}\n\n\t\tpublic long ReadLong()\n\t\t{\n\t\t\tstring s = this.GetNext();\n\t\t\tif (s == null) return -1;\n\t\t\telse return Int64.Parse(s);\n\t\t}\n\n\t\tpublic double ReadDouble()\n\t\t{\n\t\t\tstring s = this.GetNext();\n\t\t\tif (s == null) return -1;\n\t\t\telse return Double.Parse(s, System.Globalization.CultureInfo.InvariantCulture);\n\t\t}\n\n\t\tpublic string ReadString()\n\t\t{\n\t\t\tstring s = this.GetNext();\n\t\t\treturn (s == null ? null : s);\n\t\t}\n\n\t\tpublic string ReadLine()\n\t\t{\t// I will ignore current buffer and read a new line\n\t\t\tstring s = \"\";\n\t\t\twhile (s == \"\" && !this.EOF)\n\t\t\t{\n\t\t\t\ts = sr.ReadLine();\n\t\t\t\tthis.EOF = (s == null);\n\t\t\t}\n\t\t\treturn (this.EOF ? null : s);\n\t\t}\n\n\t\tprotected string GetNext()\n\t\t{\n\t\t\tif (buf.Count == 0)\n\t\t\t{\n\t\t\t\twhile (buf.Count == 0 && !this.EOF)\n\t\t\t\t{\n\t\t\t\t\tstring s = sr.ReadLine();\n\t\t\t\t\tif (s == null)\n\t\t\t\t\t\tthis.EOF = true;\n\t\t\t\t\telse\n\t\t\t\t\t\tforeach (string ss in s.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries))\n\t\t\t\t\t\t\tbuf.Enqueue(ss);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn (this.EOF ? null : buf.Dequeue());\n\t\t}\n\t}\n}\n", "lang_cluster": "C#", "tags": ["dfs and similar", "brute force", "games"], "code_uid": "921b8826399621b31f762c4b9bd4ee35", "src_uid": "f587b1867754e6958c3d7e0fe368ec6e", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\n\nnamespace ConsoleApplication2\n{\n class Program\n {\n public static int[] criba = new int[60],primos = new int[60];\n public static int pP = 0;\n\n static void Main(string[] args)\n {\n cribad();\n bool y = false;\n int[] nm = Console.ReadLine().Split().Select(x => Convert.ToInt32(x)).ToArray();\n for (int i = 0; i < primos.Length; i++)\n {\n if (primos[i] == nm[0] && primos[i + 1] == nm[1])\n {\n y = true;\n break;\n }\n }\n Console.Write(y ? \"YES\":\"NO\");\n Console.Read();\n }\n\n public static void cribad()\n {\n int i, j;\n for (i = 2; i < 60; i++)\n {\n if (criba[i] != 1)\n {\n primos[pP++] = i;\n for (j = i * i; j < 60; j += i)\n criba[j] = 1;\n }\n }\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force"], "code_uid": "0eb63e5ea0f61296e931ca1791436267", "src_uid": "9d52ff51d747bb59aa463b6358258865", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\n\nnamespace capp\n{\n class Program\n {\n static void Main(string[] args)\n {\n int[] data = Array.ConvertAll(Console.ReadLine().Split(' '), x => int.Parse(x));\n int n = data[0];\n int m = data[1];\n for (int i = n + 1; i n)\n Console.WriteLine(\"YES\");\n else\n Console.WriteLine(\"NO\");\n\n }\n\n static bool IsSimple(int a)\n {\n for (int i = 2; i < a - 1; i++)\n if (a % i == 0)\n return false;\n return true;\n }\n }\n\n\n}\n", "lang_cluster": "C#", "tags": ["brute force"], "code_uid": "d79e56abed216b5dc8cf35bded1484c7", "src_uid": "9d52ff51d747bb59aa463b6358258865", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.IO;\nusing System.Collections;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Globalization;\n\nnamespace ConsoleApplication1\n{\n class Program\n {\n const int N = 101;\n const int K = 51;\n const int INF = 1000 * 1000 * 1000;\n private static void solve()\n {\n int a = GetInt();\n int b = GetInt();\n int win = 0, lose = 0, draw = 0;\n for (int i = 1; i <= 6; ++i)\n {\n if (Math.Abs(a - i) < Math.Abs(b - i))\n win++;\n else if (Math.Abs(a - i) > Math.Abs(b - i))\n lose++;\n else\n draw++;\n }\n Console.WriteLine(win + \" \" + draw + \" \" + lose);\n }\n public static void Main()\n {\n solve();\n }\n\n\n\n private static int pos = 0;\n private static string[] st;\n private static string GetString()\n {\n if (st == null || pos == st.Length)\n {\n st = Console.ReadLine().Split(' ');\n pos = 0;\n }\n return st[pos++];\n }\n private static int GetInt()\n {\n return int.Parse(GetString());\n }\n private static double GetDouble()\n {\n return double.Parse(GetString(), CultureInfo.InvariantCulture);\n }\n private static long GetLong()\n {\n return long.Parse(GetString());\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force"], "code_uid": "e4f73b4a6536d6a16109f1fa616f1fee", "src_uid": "504b8aae3a3abedf873a3b8b127c5dd8", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\nusing System.Text.RegularExpressions;\nusing System.IO;\nusing System.Numerics;\nusing System.Globalization;\nusing System.Threading;\n\n\nnamespace probleme {\n class Program {\n static void Main(string[] args) {\n //Console.SetIn(new StreamReader(\"file.txt\"));\n string[] s = Console.ReadLine().Split(' ');\n int a = int.Parse(s[0]), b = int.Parse(s[1]);\n if (a == b) {\n Console.WriteLine(\"0 6 0\");\n } else if (a < b) {\n int med = (a + b) / 2;\n if ((b - a) % 2 == 0) {\n Console.WriteLine(\"{0} {1} {2}\", med - 1, 1, 6 - med);\n } else {\n Console.WriteLine(\"{0} {1} {2}\", med, 0, 6 - med);\n }\n } else {\n int med = (a + b) / 2;\n if ((a - b) % 2 == 0) {\n Console.WriteLine(\"{0} {1} {2}\", 6 - med, 1, med - 1);\n } else {\n Console.WriteLine(\"{0} {1} {2}\", 6 - med, 0, med);\n }\n }\n // Console.ReadKey();\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force"], "code_uid": "cb06dd622c4ca3e4020ac10ef4dcdf2d", "src_uid": "504b8aae3a3abedf873a3b8b127c5dd8", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\n\nnamespace ConsoleApplication78\n{\n class Program\n {\n static public long res = 0;\n static void Main(string[] args)\n {\n var a = Console.ReadLine().Split().Select(q => long.Parse(q)).ToArray();\n gcd(a[0], a[1]);\n Console.WriteLine(res);\n }\n static public long gcd(long x, long y)\n {\n if (y == 0) return x;\n res += x / y;\n return gcd(y, x % y);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "implementation"], "code_uid": "1797da25014b45afd0e29ffb0656ed76", "src_uid": "ce698a0eb3f5b82de58feb177ce43b83", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace A.\u0418\u0433\u0440\u0430_\u0441_\u0431\u0443\u043c\u0430\u0433\u043e\u0439\n{\n class Program\n {\n static void Main(string[] args)\n {\n var mas = Console.ReadLine().Split().Select(long.Parse).ToArray();\n long a = mas[0];\n long b = mas[1];\n long k = 0;\n\n while(a != 0 & b != 0)\n {\n if (a >= b)\n {\n k += a / b;\n a = a % b;\n }\n else //if (b > a)\n {\n k += b / a; \n b = b % a;\n }\n }\n\n Console.WriteLine(k);\n Console.ReadLine();\n }\n }\n}", "lang_cluster": "C#", "tags": ["math", "implementation"], "code_uid": "9ddc88822df1cb052c0208c934468b77", "src_uid": "ce698a0eb3f5b82de58feb177ce43b83", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\n\nclass TEST{\n\tstatic void Main(){\n\t\tSol mySol =new Sol();\n\t\tmySol.Solve();\n\t}\n}\n\nclass Sol{\n\tlong gcd(long a, long b){ return a == 0 ? b : gcd(b % a, a);}\n\tpublic void Solve(){\ntry{\nchecked{\n\t\t\n\t\tlong mo = N * K;\n\t\tList X = new List(){\n\t\t\tA, (mo - A) % mo\n\t\t};\n\t\tlong ma = -1, mi = (long) 1e18;\n\t\tforeach(var s in X){\n\t\t\tfor(int i=0;iint.Parse(e));}\n\tstatic long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}\n\tstatic double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}\n}\n", "lang_cluster": "C#", "tags": ["brute force", "math"], "code_uid": "bc0fed6862341858c6294568d3074669", "src_uid": "5bb4adff1b332f43144047955eefba0c", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nclass Program\n{\n\tstatic void Main(string[] args)\n\t{\n\t\tstring[] str = Console.ReadLine().Split();\n\t\tlong N = long.Parse(str[0]);\n\t\tlong K = long.Parse(str[1]);\n\t\tstring[] str2 = Console.ReadLine().Split();\n\t\tlong A = long.Parse(str2[0]);\n\t\tlong B = long.Parse(str2[1]);\n\t\tlong min = 999999999999999;\n\t\tlong max = 0;\n\t\tfor(var i=0;i 0 && !char.IsWhiteSpace((char)c))\n {\n if (!char.IsDigit((char)c))\n throw new InvalidOperationException();\n result = result * 10 + (char)c - '0';\n c = this.reader.Read();\n }\n if (isNegative)\n result = -result;\n return result;\n }\n\n public string ReadLine()\n {\n return reader.ReadLine();\n }\n\n public long NextLong()\n {\n return long.Parse(this.NextToken());\n }\n\n public double NextDouble()\n {\n return double.Parse(this.NextToken(), CultureInfo.InvariantCulture);\n }\n\n public int[] ReadIntArray(int n)\n {\n int[] a = new int[n];\n for (int i = 0; i < n; i++)\n a[i] = NextInt();\n return a;\n }\n\n public long[] ReadLongArray(int n)\n {\n long[] a = new long[n];\n for (int i = 0; i < n; i++)\n a[i] = NextLong();\n return a;\n }\n\n public double[] ReadDoubleArray(int n)\n {\n double[] a = new double[n];\n for (int i = 0; i < n; i++)\n a[i] = NextDouble();\n return a;\n }\n\n public string NextToken()\n {\n var c = SkipWS();\n if (c == -1)\n return null;\n var sb = new StringBuilder();\n while (c > 0 && !char.IsWhiteSpace((char)c))\n {\n sb.Append((char)c);\n c = this.reader.Read();\n }\n return sb.ToString();\n }\n\n private int SkipWS()\n {\n int c = this.reader.Read();\n if (c == -1)\n return c;\n while (c > 0 && char.IsWhiteSpace((char)c))\n c = this.reader.Read();\n return c;\n }\n\n public Tokenizer(TextReader reader)\n {\n this.reader = reader;\n }\n }\n\n class Program\n {\n public static void Main(string[] args)\n {\n var solver = new ProblemSolver(Console.In);\n solver.Solve();\n }\n }\n\n #endregion\n}", "lang_cluster": "C#", "tags": ["math", "implementation", "number theory"], "code_uid": "59c0986ecedd2c5e544da7d7f4b83ae0", "src_uid": "4b51b99d1dea367bf37dc5ead08ca48f", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeff//\n// 742A Codeforces\nusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\nusing System.IO;\nnamespace ConsoleApplication1\n{\n class Program\n {\n static void Main(string[] args)\n {\n int n,op;\n n = Convert.ToInt32(Console.ReadLine());\n op = n % 4;\n if(n == 0)\n {\n Console.WriteLine(\"1\\n\");\n return;\n }\n switch (op)\n {\n case 0:\n Console.WriteLine(\"6\\n\");\n break;\n case 1:\n Console.WriteLine(\"8\\n\");\n break;\n case 2:\n Console.WriteLine(\"4\\n\");\n break;\n case 3:\n Console.WriteLine(\"2\\n\");\n break;\n default:\n Console.WriteLine(\"\\n\");\n break;\n }\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "implementation", "number theory"], "code_uid": "f7f8e2958b2b7363cdb554f94c53864b", "src_uid": "4b51b99d1dea367bf37dc5ead08ca48f", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace Brauzer\n{\n class Program\n {\n private static int CalculateTime(int n,int pos,int l, int r)\n {\n if (l == 1 && r == n) return 0;\n int count = 0;\n if (l > 1 && r < n) count += r - l;\n if (pos >= l && pos <= r)\n {\n if (l == 1)\n count += r - pos+1;\n else\n if (r == n) count += pos - l+1; else count += Math.Min(r - pos, pos - l)+2;\n return count;\n }\n\n if (pos < l || (pos == l && l > 1)) \n {\n count += l - pos+1;\n if (r < n) count++;\n return count;\n }\n\n if (pos > r || (pos == r && r < n)) \n {\n count += pos - r+1;\n if (l > 1) count++;\n }\n\n return count;\n }\n\n static void Main(string[] args)\n {\n string[] s = Console.ReadLine().Split();\n\n int n = int.Parse(s[0]);\n int pos = int.Parse(s[1]);\n int l = int.Parse(s[2]);\n int r = int.Parse(s[3]);\n\n Console.Write(CalculateTime(n,pos,l,r));\n \n }\n }\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "eb272c595995447d8a2c713ad471e281", "src_uid": "5deaac7bd3afedee9b10e61997940f78", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.IO;\nusing System.Text;\n\nnamespace Browser\n{\n internal class Program\n {\n private static readonly StreamReader reader = new StreamReader(Console.OpenStandardInput(1024*10), Encoding.ASCII, false, 1024*10);\n private static readonly StreamWriter writer = new StreamWriter(Console.OpenStandardOutput(1024*10), Encoding.ASCII, 1024*10);\n\n private static void Main(string[] args)\n {\n writer.WriteLine(Solve(args));\n writer.Flush();\n }\n\n private static int Solve(string[] args)\n {\n int n = Next(), pos = Next(), l = Next(), r = Next();\n\n if (l == 1 && r == n)\n return 0;\n if (l == 1)\n {\n if (pos <= r)\n {\n return r - pos + 1;\n }\n return pos - r + 1;\n }\n if (r == n)\n {\n if (pos >= l)\n return pos - l + 1;\n return l - pos + 1;\n }\n if (pos <= l)\n {\n return r - pos + 2;\n }\n if (pos >= r)\n {\n return pos - l + 2;\n }\n return 2 + r - l + Math.Min(r - pos, pos - l);\n }\n\n private static int Next()\n {\n int c;\n int res = 0;\n do\n {\n c = reader.Read();\n if (c == -1)\n return res;\n } while (c < '0' || c > '9');\n res = c - '0';\n while (true)\n {\n c = reader.Read();\n if (c < '0' || c > '9')\n return res;\n res *= 10;\n res += c - '0';\n }\n }\n }\n}", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "b589397c336dc0eb155eb0651bb3619b", "src_uid": "5deaac7bd3afedee9b10e61997940f78", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Linq;\n\nnamespace _624B\n{\n class Program\n {\n static void Main()\n {\n var n = int.Parse(Console.ReadLine());\n var s = Console.ReadLine().Split().Select(long.Parse).OrderByDescending(x => x).ToArray();\n long ans = s[0], mark = s[0];\n for (int i = 1; i 1)\n {\n mark--; ans += mark;\n }\n else break;\n }\n Console.WriteLine(ans);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["sortings", "greedy"], "code_uid": "f2c46099f35b1eaa94dab0a29b328e9c", "src_uid": "3c4b2d1c9440515bc3002eddd2b89f6f", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.IO;\nusing System.Globalization;\n\nnamespace Beresta\n{\n\n\tclass ContestIO : StreamWriter\n\t{\n\t\tpublic ContestIO(Stream streamIn, Stream streamOut) : base(streamOut, Encoding.ASCII, 8192) { Reader = new StreamReader(streamIn, Encoding.ASCII, false, 8192); }\n\t\tpublic ContestIO(string inputFilePath, string outputFilePath) : this(File.OpenRead(inputFilePath), File.OpenWrite(outputFilePath)) { }\n\t\tpublic ContestIO() : this(Console.OpenStandardInput(8192), Console.OpenStandardOutput(8192)) { }\n\t\t//d.ToString(\"N12\", CultureInfo.InvariantCulture).Replace(\",\", \"\")\n\t\tpublic StreamReader Reader;\n\t\t\n\t\tbool IsDigit(int c) { return c >= '0' && c <= '9'; }\n\t\tpublic long Read()\n\t\t{\n\t\t\tint c1 = 0, c;\n\t\t\twhile (!IsDigit(c = Reader.Read())) { c1 = c; }\n\t\t\tlong r = c - '0';\n\t\t\twhile (IsDigit(c = Reader.Read()))\n\t\t\t\tr = r * 10 + c - '0';\n\t\t\treturn c1 == '-' ? -r : r;\n\t\t}\n\t\tpublic long[] ReadArray(int size) { return Enumerable.Range(0, size).Select(v => Read()).ToArray(); }\n\t}\n\n\tclass Program\n\t{\n\n\t\tstatic void Main(string[] args)\n\t\t{\n\t\t\tusing (var io = new ContestIO())\n\t\t\t{\n\t\t\t\tvar n = io.Read();\n\t\t\t\tvar arr = io.ReadArray((int)n);\n\n\t\t\t\tArray.Sort(arr);\n\t\t\t\tfor (var i = arr.Length - 1; i >= 0; i--)\n\t\t\t\t{\n\t\t\t\t\tif (arr[i] == 0)\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tfor (var j = i - 1; j >= 0; j--)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (arr[j] == arr[i])\n\t\t\t\t\t\t\tarr[j]--;\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tvar sum = arr.Sum();\n\t\t\t\tio.WriteLine(sum);\n\t\t\t}\n\n\t\t\tConsole.ReadLine();\n\t\t}\n\n\t}\n\n}\n", "lang_cluster": "C#", "tags": ["sortings", "greedy"], "code_uid": "658fbe9d8bd53b2136a642d26a16e62f", "src_uid": "3c4b2d1c9440515bc3002eddd2b89f6f", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace CF226\n{\n class Program\n {\n static void Main(string[] args)\n {\n byte n, c;\n int res, eq, qe;\n string[] num = Console.ReadLine().Split(' ');\n n = byte.Parse(num[0]);\n c = byte.Parse(num[1]);\n\n string[] arr = Console.ReadLine().Split(' ');\n\n qe = 0;\n for (byte i = 0; i < n; i++)\n {\n if (i < (n - 1))\n {\n if (int.Parse(arr[i]) > int.Parse(arr[i + 1]))\n {\n res = (int.Parse(arr[i]) - int.Parse(arr[i + 1]));\n eq = res - c;\n if (eq > 0 && eq>qe) qe = eq;\n }\n }\n }\n Console.Write(qe);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "greedy", "implementation"], "code_uid": "52e9f73d683b6feea8ad9d08d4686e2b", "src_uid": "411539a86f2e94eb6386bb65c9eb9557", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "#define Online\nusing System;\nusing System.Collections.Generic;\nusing System.Diagnostics;\nusing System.Text;\nusing System.IO;\n\ndelegate double F (double x);\n\ndelegate decimal Fdec (decimal x);\n\npartial class Program\n{\n\tpublic static StreamReader sr;\n\tpublic static StreamWriter sw;\n\n\tstatic void Main (string[] args)\n\t{\n\n#if FileIO\n\t\tsr = new StreamReader (\"input.txt\");\n\t\tsw = new StreamWriter (\"output.txt\");\n\t\tConsole.SetIn (sr);\n\t\tConsole.SetOut (sw);\n#endif\n\n\t\tA ();\n\n#if Online\n\t\tConsole.ReadLine ();\n#endif\n\n#if FileIO\n\t\tsr.Close ();\n\t\tsw.Close ();\n#endif\n\n\t}\n\n\tstatic void A ()\n\t{\n\t\tint n = NextInt ();\n\t\tint c = NextInt ();\n\t\tint[] x = new int[n];\n\t\tfor (int i =0; i0; x--) {\n\t\t\tsw.WriteLine (\"{0} {1}\", x, y);\n\t\t}\n\t\tfor (; y>0; y--) {\n\t\t\tsw.WriteLine (\"{0} {1}\", x, y);\n\t\t}\n\t\tsw.Close ();\n\t}\n\n}\n\npublic static class MyMath\n{\n\tpublic static long BinPow (long a, long n, long mod)\n\t{\n\t\tlong res = 1;\n\t\twhile (n > 0) {\n\t\t\tif ((n & 1) == 1) {\n\t\t\t\tres = (res * a) % mod;\n\t\t\t}\n\t\t\ta = (a * a) % mod;\n\t\t\tn >>= 1;\n\t\t}\n\t\treturn res;\n\t}\n\n\tpublic static long GCD (long a, long b)\n\t{\n\t\twhile (b != 0)\n\t\t\tb = a % (a = b);\n\t\treturn a;\n\t}\n\n\tpublic static int GCD (int a, int b)\n\t{\n\t\twhile (b != 0)\n\t\t\tb = a % (a = b);\n\t\treturn a;\n\t}\n\n\tpublic static long LCM (long a, long b)\n\t{\n\t\treturn (a * b) / GCD (a, b);\n\t}\n\n\tpublic static int LCM (int a, int b)\n\t{\n\t\treturn (a * b) / GCD (a, b);\n\t}\n}\n\nstatic class ArrayUtils\n{\n\tstatic void Swap (T[] a, int l, int r)\n\t{\n\t\tT t = a [l];\n\t\ta [l] = a [r];\n\t\ta [r] = t;\n\t}\n\n\tpublic static bool NextPermutation (int[] a)\n\t{\n\t\tbool isOkay = false;\n\t\tint n = a.Length;\n\t\tfor (int i=n-2; i>=0; i--) {\n\t\t\tif (a [i] < a [i + 1]) {\n\t\t\t\tisOkay = true;\n\t\t\t\tint j = i + 1;\n\t\t\t\twhile (j+1a[i]) {\n\t\t\t\t\tj++;\n\t\t\t\t}\n\t\t\t\tSwap (a, i, j);\n\t\t\t\tfor (j=1; i+j> 1);\n\t\t\tif (val <= a [mid]) {\n\t\t\t\tright = mid;\n\t\t\t} else {\n\t\t\t\tleft = mid + 1;\n\t\t\t}\n\t\t}\n\n\t\tif (a [left] == val)\n\t\t\treturn left;\n\t\telse\n\t\t\treturn -1;\n\t}\n\n\tpublic static double Bisection (F f, double left, double right, double eps)\n\t{\n\t\tdouble mid;\n\t\twhile (right - left > eps) {\n\t\t\tmid = left + ((right - left) / 2d);\n\t\t\tif (Math.Sign (f (mid)) != Math.Sign (f (left)))\n\t\t\t\tright = mid;\n\t\t\telse\n\t\t\t\tleft = mid;\n\t\t}\n\t\treturn (left + right) / 2d;\n\t}\n\n\tpublic static decimal TernarySearchDec (Fdec f, decimal eps, decimal l, decimal r, bool isMax)\n\t{\n\t\tdecimal m1, m2;\n\t\twhile (r - l > eps) {\n\t\t\tm1 = l + (r - l) / 3m;\n\t\t\tm2 = r - (r - l) / 3m;\n\t\t\tif (f (m1) < f (m2))\n\t\t\tif (isMax)\n\t\t\t\tl = m1;\n\t\t\telse\n\t\t\t\tr = m2;\n\t\t\telse\n if (isMax)\n\t\t\t\tr = m2;\n\t\t\telse\n\t\t\t\tl = m1;\n\t\t}\n\t\treturn r;\n\t}\n\n\tpublic static double TernarySearch (F f, double eps, double l, double r, bool isMax)\n\t{\n\t\tdouble m1, m2;\n\t\twhile (r - l > eps) {\n\t\t\tm1 = l + (r - l) / 3d;\n\t\t\tm2 = r - (r - l) / 3d;\n\t\t\tif (f (m1) < f (m2))\n\t\t\tif (isMax)\n\t\t\t\tl = m1;\n\t\t\telse\n\t\t\t\tr = m2;\n\t\t\telse\n if (isMax)\n\t\t\t\tr = m2;\n\t\t\telse\n\t\t\t\tl = m1;\n\t\t}\n\t\treturn r;\n\t}\n\n\tpublic static void Merge_Sort (T[]A, int p, int r, Comparison comp)\n\t{\n\t\tT[] L = new T[A.Length];\n\t\tT[] R = new T[A.Length];\n\t\tMerge_Sort (A, p, r, L, R, comp);\n\t}\n\n\tpublic static void Merge (T[] A, int p, int q, int r, T[] L, T[] R, Comparison comp)\n\t{\n\t\tfor (int i = p; i <= q; i++)\n\t\t\tL [i] = A [i];\n\t\tfor (int i = q + 1; i <= r; i++)\n\t\t\tR [i] = A [i];\n\n\t\tfor (int k = p, i = p, j = q + 1; k <= r; k++) {\n\t\t\tif (i > q) {\n\t\t\t\tfor (; k <= r; k++, j++)\n\t\t\t\t\tA [k] = R [j];\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (j > r) {\n\t\t\t\tfor (; k <= r; k++, i++)\n\t\t\t\t\tA [k] = L [i];\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (comp (L [i], R [j]) <= 0) {\n\t\t\t\tA [k] = L [i];\n\t\t\t\ti++;\n\t\t\t} else {\n\t\t\t\tA [k] = R [j];\n\t\t\t\tj++;\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate static void Merge_Sort (T[] A, int p, int r, T[] L, T[] R, Comparison comp)\n\t{\n\t\tif (p >= r)\n\t\t\treturn;\n\t\tint q = p + ((r - p) >> 1);\n\t\tMerge_Sort (A, p, q, L, R, comp);\n\t\tMerge_Sort (A, q + 1, r, L, R, comp);\n\t\tMerge (A, p, q, r, L, R, comp);\n\t}\n\n\tpublic static void Merge_Sort (T[]A, int p, int r)where T:IComparable\n\t{\n\t\tT[] L = new T[A.Length];\n\t\tT[] R = new T[A.Length];\n\t\tMerge_Sort (A, p, r, L, R);\n\t}\n\n\tpublic static void Merge (T[] A, int p, int q, int r, T[] L, T[] R) where T : IComparable\n\t{\n\t\tfor (int i = p; i <= q; i++)\n\t\t\tL [i] = A [i];\n\t\tfor (int i = q + 1; i <= r; i++)\n\t\t\tR [i] = A [i];\n\n\t\tfor (int k = p, i = p, j = q + 1; k <= r; k++) {\n\t\t\tif (i > q) {\n\t\t\t\tfor (; k <= r; k++, j++)\n\t\t\t\t\tA [k] = R [j];\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (j > r) {\n\t\t\t\tfor (; k <= r; k++, i++)\n\t\t\t\t\tA [k] = L [i];\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (L [i].CompareTo (R [j]) <= 0) {\n\t\t\t\tA [k] = L [i];\n\t\t\t\ti++;\n\t\t\t} else {\n\t\t\t\tA [k] = R [j];\n\t\t\t\tj++;\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate static void Merge_Sort (T[] A, int p, int r, T[] L, T[] R) where T : IComparable\n\t{\n\t\tif (p >= r)\n\t\t\treturn;\n\t\tint q = p + ((r - p) >> 1);\n\t\tMerge_Sort (A, p, q, L, R);\n\t\tMerge_Sort (A, q + 1, r, L, R);\n\t\tMerge (A, p, q, r, L, R);\n\t}\n\n\tpublic static void Merge_Sort_Non_Recursive (T[] A, int p, int r) where T : IComparable\n\t{\n\t\tT[] L = new T[A.Length];\n\t\tT[] R = new T[A.Length];\n\t\tint k = 1;\n\t\twhile (k < r - p + 1) {\n\t\t\tint i = 0;\n\t\t\twhile (i < r) {\n\t\t\t\tint _r = Math.Min (i + 2 * k - 1, r);\n\t\t\t\tint q = Math.Min (i + k - 1, r);\n\t\t\t\tMerge (A, i, q, _r, L, R);\n\t\t\t\ti += 2 * k;\n\t\t\t}\n\t\t\tk <<= 1;\n\t\t}\n\t}\n\n\tpublic static void Merge_Sort_Non_Recursive (T[] A, int p, int r, Comparison comp)\n\t{\n\t\tT[] L = new T[A.Length];\n\t\tT[] R = new T[A.Length];\n\t\tint k = 1;\n\t\twhile (k < r - p + 1) {\n\t\t\tint i = 0;\n\t\t\twhile (i < r) {\n\t\t\t\tint _r = Math.Min (i + 2 * k - 1, r);\n\t\t\t\tint q = Math.Min (i + k - 1, r);\n\t\t\t\tMerge (A, i, q, _r, L, R, comp);\n\t\t\t\ti += 2 * k;\n\t\t\t}\n\t\t\tk <<= 1;\n\t\t}\n\t}\n\n\tpublic static void Shake (T[] a)\n\t{\n\t\tRandom rnd = new Random (Environment.TickCount);\n\t\tint b;\n\t\tfor (int i = 0; i < a.Length; i++) {\n\t\t\tb = rnd.Next (i, a.Length);\n\t\t\tSwap (a, i, b);\n\t\t}\n\t}\n}\n\npartial class Program\n{\n\tstatic string[] tokens = new string[0];\n\tstatic int cur_token = 0;\n\n\tstatic void ReadArray (char sep)\n\t{\n\t\tcur_token = 0;\n\t\ttokens = Console.ReadLine ().Split (sep);\n\t}\n\n\tstatic int ReadInt ()\n\t{\n\t\treturn int.Parse (Console.ReadLine ());\n\t}\n\n\tstatic long ReadLong ()\n\t{\n\t\treturn long.Parse (Console.ReadLine ());\n\t}\n\n\tstatic int NextInt ()\n\t{\n\t\tif (cur_token == tokens.Length)\n\t\t\tReadArray (' ');\n\t\treturn int.Parse (tokens [cur_token++]);\n\t}\n\n\tstatic long NextLong ()\n\t{\n\t\tif (cur_token == tokens.Length)\n\t\t\tReadArray (' ');\n\t\treturn long.Parse (tokens [cur_token++]);\n\t}\n\n\tstatic double NextDouble ()\n\t{\n\t\tif (cur_token == tokens.Length)\n\t\t\tReadArray (' ');\n\t\treturn double.Parse (tokens [cur_token++]);\n\t}\n\n\tstatic decimal NextDecimal ()\n\t{\n\t\tif (cur_token == tokens.Length)\n\t\t\tReadArray (' ');\n\t\treturn decimal.Parse (tokens [cur_token++]);\n\t}\n\n\tstatic string NextToken ()\n\t{\n\t\tif (cur_token == tokens.Length)\n\t\t\tReadArray (' ');\n\t\treturn tokens [cur_token++];\n\t}\n\n\tstatic string ReadLine ()\n\t{\n\t\treturn Console.ReadLine ();\n\t}\n}", "lang_cluster": "C#", "tags": ["brute force", "greedy", "implementation"], "code_uid": "dd37a77d76d844d3dc3ed325812b1f34", "src_uid": "411539a86f2e94eb6386bb65c9eb9557", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nnamespace SolutionsForCodeforces\n{\n class RSP\n {\n static void Main(string[] args)\n {\n var F = Console.ReadLine();\n var M = Console.ReadLine();\n var S = Console.ReadLine();\n if ((F != M && F != S && M != S) || (F == M && F == S && M == S))\n {\n Console.WriteLine(\"?\");\n return;\n }\n if (F == M)\n {\n if (WhoIsBetter(F, S))\n {\n Console.WriteLine(\"?\");\n return;\n }\n else\n {\n Console.WriteLine(\"S\");\n return;\n }\n }\n if (M == S)\n {\n if (WhoIsBetter(M, F))\n {\n Console.WriteLine(\"?\");\n return;\n }\n else\n {\n Console.WriteLine(\"F\");\n return;\n }\n }\n if (F == S)\n {\n if (WhoIsBetter(F, M))\n {\n Console.WriteLine(\"?\");\n return;\n }\n else\n {\n Console.WriteLine(\"M\");\n return;\n }\n }\n }\n static bool WhoIsBetter(string First, string Second)\n {\n if (First == \"rock\" && Second == \"scissors\") return true;\n if (First == \"scissors\" && Second == \"paper\") return true;\n if (First == \"paper\" && Second == \"rock\") return true;\n return false;\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "e1423f9e207e83c26199ab4becb54919", "src_uid": "072c7d29a1b338609a72ab6b73988282", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\n\nnamespace ProgrammingContest.Codeforces.Round45\n{\n class A\n {\n public static void Main()\n {\n Dictionary map = new Dictionary();\n map[\"rock\"] = 0;\n map[\"scissors\"] = 1;\n map[\"paper\"] = 2;\n int[] xs =new int[]{map[Console.ReadLine()],\n map[Console.ReadLine()],\n map[Console.ReadLine()]};\n for(int i = 0; i < 3; i++)\n for (int j = 1; j < 3; j++)\n {\n int k = (i+j)%3;\n if ((xs[i] + 1) % 3 == xs[k] && (xs[i] + 1) % 3 == xs[(k + 1) % 3])\n {\n Console.Write(\"FMS\"[i]);\n return;\n }\n }\n Console.Write(\"?\");\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "3807d9359cc75c614d8bac1c1e01a1f1", "src_uid": "072c7d29a1b338609a72ab6b73988282", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Linq;\nusing System.Text;\nusing System.Collections.Generic;\n\nclass Program {\n\tstatic void Main() {\n\t\tstring[] name = new string[]{\"Washington\", \"Adams\", \"Jefferson\", \"Madison\", \"Monroe\", \"Adams\", \"Jackson\", \"Van Buren\", \"Harrison\", \"Tyler\", \"Polk\", \"Taylor\", \"Fillmore\", \"Pierce\", \"Buchanan\", \"Lincoln\", \"Johnson\", \"Grant\", \"Hayes\", \"Garfield\", \"Arthur\", \"Cleveland\", \"Harrison\", \"Cleveland\", \"McKinley\", \"Roosevelt\", \"Taft\", \"Wilson\", \"Harding\", \"Coolidge\", \"Hoover\", \"Roosevelt\", \"Truman\", \"Eisenhower\", \"Kennedy\", \"Johnson\", \"Nixon\", \"Ford\", \"Carter\", \"Reagan\"};\n\t\tint i = int.Parse(Console.ReadLine());\n\t\tConsole.WriteLine(name[i - 1]);\n\t}\n}", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "9e04798ce4962602ed0beb638f6b8821", "src_uid": "0b51a8318c9ec0c80c0f4dc04fe0bfb3", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\n\nnamespace AprilFools2013A\n{\n class Program\n {\n static void Main(string[] args)\n {\n Console.WriteLine(@\"Washington\nAdams\nJefferson\nMadison\nMonroe\nAdams\nJackson\nVan Buren\nHarrison\nTyler\nPolk\nTaylor\nFillmore\nPierce\nBuchanan\nLincoln\nJohnson\nGrant\nHayes\nGarfield\nArthur\nCleveland\nHarrison\nCleveland\nMcKinley\nRoosevelt\nTaft\nWilson\nHarding\nCoolidge\nHoover\nRoosevelt\nTruman\nEisenhower\nKennedy\nJohnson\nNixon\nFord\nCarter\nReagan\".Split('\\n')[int.Parse(Console.ReadLine()) - 1]);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "eab2fbc59c5cc877d8301c67b8e4f20f", "src_uid": "0b51a8318c9ec0c80c0f4dc04fe0bfb3", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System.Text;\nusing System.Threading.Tasks;\nusing System.Diagnostics;\nusing System.Numerics;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System;\n\nnamespace bla2\n{\n class Program\n {\n static void Main()\n {\n //Random rand = new Random();\n\n string[] s = Console.ReadLine().Split();\n l = long.Parse(s[0]);\n r = long.Parse(s[1]);\n x = long.Parse(s[2]);\n y = long.Parse(s[3]);\n //while (true)\n {\n Solve();\n //x = rand.Next(1, 1000000000);\n //y = x * rand.Next(1, 1000000000 / (int)x);\n //l = rand.Next(1, 1000000000);\n //r = rand.Next(1, 1000000000);\n }\n }\n\n static void Solve()\n {\n List yfactors = Factor(y);\n yf = new List();\n long x2 = x;\n long f = -1;\n for (int i = 0; i < yfactors.Count; i++)\n {\n if (x2 % yfactors[i] == 0)\n {\n x2 /= yfactors[i];\n }\n else if (yf.Count != 0 && yfactors[i] == f)\n {\n yf[yf.Count - 1] *= yfactors[i];\n }\n else\n {\n yf.Add(yfactors[i]);\n f = yfactors[i];\n }\n }\n if (x2 != 1)\n {\n Console.WriteLine(\"0\");\n }\n else\n {\n Console.WriteLine(Count(new bool[yf.Count], 0));\n }\n }\n\n static long x, y, r, l;\n static List yf;\n\n public static long Count(bool[] b, long at)\n {\n if(at == b.Length)\n {\n //Console.WriteLine(string.Join(\", \", b));\n long n = x, m = x;\n for (int i = 0; i < b.Length; i++)\n {\n if (b[i])\n n *= yf[i];\n else\n m *= yf[i];\n }\n if (n <= r && n >= l && m <= r && m >= l)\n {\n //Console.WriteLine(n + \", \" + m);\n return 1;\n }\n else\n return 0;\n }\n long e = 0;\n bool[] nb = new bool[b.Length];\n Array.Copy(b, nb, b.Length);\n nb[at] = false;\n e += Count(nb, at + 1);\n nb[at] = true;\n e += Count(nb, at + 1);\n return e;\n }\n\n public static List Factor(long n)\n {\n List r = new List();\n\n while (n % 2 == 0)\n {\n n /= 2;\n r.Add(2);\n }\n while (n % 3 == 0)\n {\n n /= 3;\n r.Add(3);\n }\n\n long sqrtn = (long)(Math.Sqrt(n)) + 1;\n long i = 6;\n while (n > 1 && i <= sqrtn)\n {\n bool nc = false;\n long a;\n while ((a = n % (i - 1)) == 0)\n {\n r.Add(i - 1);\n n /= i - 1;\n nc = true;\n }\n while ((a = n % (i + 1)) == 0)\n {\n r.Add(i + 1);\n n /= i + 1;\n nc = true;\n }\n i += 6;\n if (nc)\n sqrtn = (long)(Math.Sqrt(n)) + 1;\n }\n if (n != 1) r.Add(n);\n return r;\n }\n } \n}", "lang_cluster": "C#", "tags": ["math", "number theory"], "code_uid": "17dc028e4dd8cd7f9dace669da842184", "src_uid": "d37dde5841116352c9b37538631d0b15", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.IO;\nusing System.Runtime.CompilerServices;\nusing System.Text;\nusing static Template;\nusing static System.Console;\nusing static System.Convert;\nusing static System.Math;\nusing Pi = Pair;\n\nclass Solver\n{\n Scanner sc = new Scanner();\n //\n public void Solve()\n {\n int l, r, x, y;\n sc.Make(out l, out r, out x, out y);\n var fx = Factorize(x);\n var fy = Factorize(y);\n foreach (var p in fx)\n {\n if (!fy.ContainsKey(p.Key)||fy[p.Key]();\n foreach (var p in fy)\n {\n if (!fx.ContainsKey(p.Key)) fx[p.Key] = 0;\n n.Add(new P(p.Key, p.Value, fx[p.Key]));\n }\n var res = 0;\n var ok = new Dictionary>();\n for(var i = 0; i < (1 << n.Count); i++)\n {\n long u = 1, v = 1;\n for(var j=0;j> j) == 1)\n {\n for (var k = 0; k < n[j].x; k++)\n u *= n[j].v;\n for (var k = 0; k < n[j].y; k++)\n v *= n[j].v;\n }\n else\n {\n for (var k = 0; k < n[j].x; k++)\n v *= n[j].v;\n for (var k = 0; k < n[j].y; k++)\n u *= n[j].v;\n }\n if (r < u || u < l || r < v || v < l) continue;\n if (!ok.ContainsKey(u))\n ok[u] = new Dictionary();\n if (!ok[u].ContainsKey(v))\n {\n res++;\n ok[u][v] = true;\n }\n }\n WriteLine(res);\n }\n struct P\n {\n public long v, x, y;\n public P(long V,int X,int Y)\n {\n v = V;x = X;y = Y;\n }\n }\n\n public static Dictionary Factorize(long num)\n {\n var dic = new Dictionary();\n for (var i = 2L; i * i <= num; i++)\n {\n var ct = 0;\n while (num % i == 0)\n {\n ct++;\n num /= i;\n }\n if (ct != 0) dic[i] = ct;\n }\n if (num != 1) dic[num] = 1;\n return dic;\n }\n}\n\n#region Template\npublic class Template\n{\n static void Main(string[] args)\n {\n Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });\n new Solver().Solve();\n Console.Out.Flush();\n }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static bool chmin(ref T a, T b) where T : IComparable\n { if (a.CompareTo(b) == 1) { a = b; return true; } return false; }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static bool chmax(ref T a, T b) where T : IComparable\n { if (a.CompareTo(b) == -1) { a = b; return true; } return false; }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static void swap(ref T a, ref T b)\n { var t = b; b = a; a = t; }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static T[] Create(int n, Func f)\n {\n var rt = new T[n];\n for (var i = 0; i < rt.Length; ++i)\n rt[i] = f();\n return rt;\n }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static T[] Create(int n, Func f)\n {\n var rt = new T[n];\n for (var i = 0; i < rt.Length; ++i)\n rt[i] = f(i);\n return rt;\n }\n public static void Fail(T s) { Console.WriteLine(s); Console.Out.Close(); Environment.Exit(0); }\n}\n\npublic class Scanner\n{\n public string Str => ReadLine().Trim();\n public int Int => int.Parse(Str);\n public long Long => long.Parse(Str);\n public double Double => double.Parse(Str);\n public int[] ArrInt => Str.Split(' ').Select(int.Parse).ToArray();\n public long[] ArrLong => Str.Split(' ').Select(long.Parse).ToArray();\n public char[][] Grid(int n) => Create(n, () => Str.ToCharArray());\n public int[] ArrInt1D(int n) => Create(n, () => Int);\n public long[] ArrLong1D(int n) => Create(n, () => Long);\n public int[][] ArrInt2D(int n) => Create(n, () => ArrInt);\n public long[][] ArrLong2D(int n) => Create(n, () => ArrLong);\n public Pair PairMake() => new Pair(Next(), Next());\n public Pair PairMake() => new Pair(Next(), Next(), Next());\n private Queue q = new Queue();\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public T Next() { if (q.Count == 0) foreach (var item in Str.Split(' ')) q.Enqueue(item); return (T)Convert.ChangeType(q.Dequeue(), typeof(T)); }\n public void Make(out T1 v1) => v1 = Next();\n public void Make(out T1 v1, out T2 v2) { v1 = Next(); v2 = Next(); }\n public void Make(out T1 v1, out T2 v2, out T3 v3) { Make(out v1, out v2); v3 = Next(); }\n public void Make(out T1 v1, out T2 v2, out T3 v3, out T4 v4) { Make(out v1, out v2, out v3); v4 = Next(); }\n public void Make(out T1 v1, out T2 v2, out T3 v3, out T4 v4, out T5 v5) { Make(out v1, out v2, out v3, out v4); v5 = Next(); }\n public void Make(out T1 v1, out T2 v2, out T3 v3, out T4 v4, out T5 v5, out T6 v6) { Make(out v1, out v2, out v3, out v4, out v5); v6 = Next(); }\n}\n\npublic class Pair : IComparable>\n{\n public T1 v1;\n public T2 v2;\n public Pair() { }\n public Pair(T1 v1, T2 v2)\n { this.v1 = v1; this.v2 = v2; }\n\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public int CompareTo(Pair p)\n {\n var c = Comparer.Default.Compare(v1, p.v1);\n if (c == 0)\n c = Comparer.Default.Compare(v2, p.v2);\n return c;\n }\n public override string ToString() => $\"{v1.ToString()} {v2.ToString()}\";\n public void Tie(out T1 a, out T2 b) { a = v1; b = v2; }\n}\n\npublic class Pair : Pair, IComparable>\n{\n public T3 v3;\n public Pair() : base() { }\n public Pair(T1 v1, T2 v2, T3 v3) : base(v1, v2)\n { this.v3 = v3; }\n\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public int CompareTo(Pair p)\n {\n var c = base.CompareTo(p);\n if (c == 0)\n c = Comparer.Default.Compare(v3, p.v3);\n return c;\n }\n public override string ToString() => $\"{base.ToString()} {v3.ToString()}\";\n public void Tie(out T1 a, out T2 b, out T3 c) { Tie(out a, out b); c = v3; }\n}\n#endregion\n", "lang_cluster": "C#", "tags": ["math", "number theory"], "code_uid": "c9d52a61ae62e0da7e2428eb37e07a5a", "src_uid": "d37dde5841116352c9b37538631d0b15", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Linq;\nusing System.Collections.Generic;\nusing System.Diagnostics;\nusing Debug = System.Diagnostics.Trace;\nusing SB = System.Text.StringBuilder;\nusing System.Numerics;\nusing static System.Math;\nusing Number = System.Int64;\nusing N = System.Int64;\nusing C = System.Int32;\nnamespace Program {\n\tpublic class Solver {\n\t\tRandom rnd = new Random();\n\t\tpublic void Solve() {\n\t\t\tvar n = ri;\n\t\t\tvar k = ri;\n\t\t\t// TGLTGLTGL...RRRRRRRRTTGRTGTGT....TG\n\t\t\t// throw:n n+1\n\t\t\t// G: n\n\t\t\t// move: L or R + n-1\n\t\t\tvar ans = 3 * n;\n\t\t\tans += Min(k - 1, n - k);\n\t\t\tConsole.WriteLine(ans);\n\n\t\t}\n\t\tconst long INF = 1L << 60;\n\t\tstatic int[] dx = { -1, 0, 1, 0 };\n\t\tstatic int[] dy = { 0, 1, 0, -1 };\n\t\tint ri { get { return sc.Integer(); } }\n\t\tlong rl { get { return sc.Long(); } }\n\t\tdouble rd { get { return sc.Double(); } }\n\t\tstring rs { get { return sc.Scan(); } }\n\t\tpublic IO.StreamScanner sc = new IO.StreamScanner(Console.OpenStandardInput());\n\n\t\tstatic T[] Enumerate(int n, Func f) {\n\t\t\tvar a = new T[n];\n\t\t\tfor (int i = 0; i < a.Length; ++i) a[i] = f(i);\n\t\t\treturn a;\n\t\t}\n\t\tstatic public void Swap(ref T a, ref T b) { var tmp = a; a = b; b = tmp; }\n\t}\n}\n\n#region main\nstatic class Ex {\n\tstatic public string AsString(this IEnumerable ie) { return new string(ie.ToArray()); }\n\tstatic public string AsJoinedString(this IEnumerable ie, string st = \" \") {\n\t\treturn string.Join(st, ie);\n\t}\n\tstatic public void Main() {\n\t\t//Console.SetOut(new Program.IO.Printer(Console.OpenStandardOutput()) { AutoFlush = false });\n\t\tvar solver = new Program.Solver();\n\t\tsolver.Solve();\n\t\tConsole.Out.Flush();\n\t}\n}\n#endregion\n#region Ex\nnamespace Program.IO {\n\tusing System.IO;\n\tusing System.Text;\n\tusing System.Globalization;\n\n\tpublic class Printer : StreamWriter {\n\t\tpublic override IFormatProvider FormatProvider { get { return CultureInfo.InvariantCulture; } }\n\t\tpublic Printer(Stream stream) : base(stream, new UTF8Encoding(false, true)) { }\n\t}\n\n\tpublic class StreamScanner {\n\t\tpublic StreamScanner(Stream stream) { str = stream; }\n\n\t\tpublic readonly Stream str;\n\t\tprivate readonly byte[] buf = new byte[1024];\n\t\tprivate int len, ptr;\n\t\tpublic bool isEof = false;\n\t\tpublic bool IsEndOfStream { get { return isEof; } }\n\n\t\tprivate byte read() {\n\t\t\tif (isEof) return 0;\n\t\t\tif (ptr >= len) {\n\t\t\t\tptr = 0;\n\t\t\t\tif ((len = str.Read(buf, 0, 1024)) <= 0) {\n\t\t\t\t\tisEof = true;\n\t\t\t\t\treturn 0;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn buf[ptr++];\n\t\t}\n\n\t\tpublic char Char() {\n\t\t\tbyte b = 0;\n\t\t\tdo b = read(); while ((b < 33 || 126 < b) && !isEof);\n\t\t\treturn (char)b;\n\t\t}\n\t\tpublic string Scan() {\n\t\t\tvar sb = new StringBuilder();\n\t\t\tfor (var b = Char(); b >= 33 && b <= 126; b = (char)read()) sb.Append(b);\n\t\t\treturn sb.ToString();\n\t\t}\n\t\tpublic string ScanLine() {\n\t\t\tvar sb = new StringBuilder();\n\t\t\tfor (var b = Char(); b != '\\n' && b != 0; b = (char)read()) if (b != '\\r') sb.Append(b);\n\t\t\treturn sb.ToString();\n\t\t}\n\t\tpublic long Long() { return isEof ? long.MinValue : long.Parse(Scan()); }\n\t\tpublic int Integer() { return isEof ? int.MinValue : int.Parse(Scan()); }\n\t\tpublic double Double() { return isEof ? double.NaN : double.Parse(Scan(), CultureInfo.InvariantCulture); }\n\t}\n}\n\n#endregion\n", "lang_cluster": "C#", "tags": ["math", "constructive algorithms"], "code_uid": "f4daf666abc4df8ebe669894018ee5eb", "src_uid": "24b02afe8d86314ec5f75a00c72af514", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nnamespace BasicProgramming\n{\n class Program\n {\n static void Main(string[] args)\n {\n var nk = Console.ReadLine().Split(' ');\n int n = Convert.ToInt32(nk[0]);\n int k = Convert.ToInt32(nk[1]);\n Console.WriteLine(3 * n + Math.Min(k - 1, n - k));\n\n }\n }\n}", "lang_cluster": "C#", "tags": ["math", "constructive algorithms"], "code_uid": "af7ea0e3482cdb3f14b2aaf3e89672e6", "src_uid": "24b02afe8d86314ec5f75a00c72af514", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\n\nnamespace CrokContest\n{\n class Program\n {\n static void Main(string[] args)\n {\n var arr = Console.ReadLine().Split();\n int a = int.Parse(arr[0]);\n int n = int.Parse(arr[1]);\n\n int end = a + n -1;\n\n int sqrLen = 1;\n int[] table = new int[3163]; \n table[0] = 1;\n for (int i = 1; table[i-1] < end; ++i, ++sqrLen)\n table[i] = 1 + i*2 + table[i -1]; \n\n int max = end+1;\n int[] sqrs = new int[max];\n for (int i = 0; i < sqrLen; ++i)\n {\n for (int j = table[i]; j < max; j += table[i])\n {\n sqrs[j] = table[i];\n }\n }\n\n decimal sum = 0;\n for (int i = a; i <= end; ++i)\n {\n sum += i / sqrs[i];\n }\n Console.Write(sum);\n }\n }\n}\n\n", "lang_cluster": "C#", "tags": ["number theory"], "code_uid": "74e60b179c5c9703c01439db4f487b54", "src_uid": "915081861e391958dce6ee2a117abd4e", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Text.RegularExpressions;\n\nnamespace _114a\n{\n class Program\n {\n class Scanner\n {\n string[] s;\n int i;\n\n char[] cs = new char[] { ' ' };\n\n public Scanner()\n {\n //s = @\"50 5\".Split(cs, StringSplitOptions.RemoveEmptyEntries);\n s = new string[0];\n i = 0;\n }\n\n public string next()\n {\n if (i < s.Length) return s[i++];\n s = Console.ReadLine().Split(cs, StringSplitOptions.RemoveEmptyEntries);\n i = 0;\n return s[i++];\n }\n\n public int nextInt()\n {\n return int.Parse(next());\n }\n\n public long nextLong()\n {\n return long.Parse(next());\n }\n }\n\n static void Main(string[] args)\n {\n Hren h = new Hren();\n h.Go();\n }\n\n class Hren\n {\n public void Go()\n {\n Scanner sc = new Scanner();\n int a = sc.nextInt();\n int n = sc.nextInt();\n\n int[] lst = new int[a + n];\n\n for (int i = 0; i < a + n; i++)\n {\n lst[i] = 0;\n }\n\n\n for (int i = 2; i <= 3162; i++) \n {\n int res = 0;\n int lim = (a + n) / (i * i);\n for(int j = 1; j< lim + 2; j++)\n {\n res = j * i * i;\n if (res < a + n && res > 0)\n {\n lst[res] = j;\n }\n else\n {\n break;\n }\n }\n }\n long result = 0;\n for (int i = a; i < a + n; i++ )\n {\n if (lst[i] != 0)\n {\n result += lst[i];\n }\n else\n {\n result += i;\n }\n }\n\n Console.WriteLine(result);\n }\n }\n }\n\n}\n", "lang_cluster": "C#", "tags": ["number theory"], "code_uid": "828795d0a6b0d69bc4ecddf4c4ed5f99", "src_uid": "915081861e391958dce6ee2a117abd4e", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\n\nnamespace prog\n{\n class Program\n {\n static void Main()\n {\n string s;\n int i;\n char c;\n\n s = Console.ReadLine();\n s = s.ToUpper();\n for(i = s.Length - 1; s[i] == ' ' || s[i] == '?'; i--);\n c = s[i];\n if (c == 'A' || c == 'E' || c == 'I' || c == 'O' || c == 'U' || c == 'Y')\n Console.WriteLine(\"YES\");\n else\n Console.WriteLine(\"NO\");\n Console.ReadLine();\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "2f32b34df46d9bf597a3b38a545af609", "src_uid": "dea7eb04e086a4c1b3924eff255b9648", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\n\nnamespace A49\n{\n class Program\n {\n static void Main(string[] args)\n {\n String s = Console.ReadLine();\n s = s.Remove(s.Length-1,1).Trim().ToUpper();\n switch (s[s.Length-1])\n {\n case 'A':\n Console.Write(\"YES\");\n break;\n case 'E':\n Console.Write(\"YES\");\n break;\n case 'I':\n Console.Write(\"YES\");\n break;\n case 'O':\n Console.Write(\"YES\");\n break;\n case 'U':\n Console.Write(\"YES\");\n break;\n case 'Y':\n Console.Write(\"YES\");\n break;\n\n default:\n Console.Write(\"NO\");\n \n break;\n }\n \n \n }\n }\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "7ffa2be2def4e6f34b14fc2eb49af3b3", "src_uid": "dea7eb04e086a4c1b3924eff255b9648", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading;\n\nnamespace Codeforces\n{\n class Program\n { \n static int ReadInt()\n {\n return Int32.Parse(Console.ReadLine());\n }\n static long ReadLong()\n {\n return long.Parse(Console.ReadLine());\n }\n static void ReadIntArray(out int[] array, char separator = ' ')\n {\n var input = Console.ReadLine().Split(separator);\n array = new int[input.Length];\n for (int i = 0; i < input.Length; i++)\n {\n array[i] = Int32.Parse(input[i]);\n }\n\n }\n\n static int ReadNextInt(string[] input, int index)\n {\n return Int32.Parse(input[index]);\n }\n\n\n static void Main()\n {\n var n = ReadLong();\n var k = ReadLong();\n int res = 0;\n while (k != 1 && k % n == 0)\n {\n k /= n;\n res++;\n }\n if (k != 1)\n Console.WriteLine(\"NO\");\n else\n {\n Console.WriteLine(\"YES\");\n Console.WriteLine(res - 1);\n }\n }\n }\n}", "lang_cluster": "C#", "tags": ["math"], "code_uid": "3b8f9d18d9fa74933771a52a763ac75f", "src_uid": "8ce89b754aa4080e7c3b2c3b10f4be46", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\n\nnamespace Achill\n{\n class Program\n {\n static void Main(string[] args)\n {\n int k = int.Parse(Console.ReadLine());\n int l = int.Parse(Console.ReadLine()), res = 0;\n bool flag = k == l;\n double tmp = 1.0 * l / k;\n while(tmp > 1 && tmp == (int)tmp)\n {\n tmp /= k;\n ++res;\n }\n if(tmp == 1)\n {\n Console.WriteLine(\"YES\");\n Console.WriteLine(res);\n }\n else\n {\n Console.WriteLine(\"NO\");\n }\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math"], "code_uid": "36f2d1022123fbe49717f49ac5a0a86a", "src_uid": "8ce89b754aa4080e7c3b2c3b10f4be46", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\n\nnamespace Number266A {\n class Program {\n static void Main(string[] args) {\n Int32 count = Int32.Parse(Console.ReadLine());\n Int32 counter = 0;\n Char previousCymbol = (Char)Console.Read();\n for(Int32 i = 1; i < count; i++) {\n Char symbol = (Char)Console.Read();\n if(symbol == previousCymbol)\n counter++;\n previousCymbol = symbol;\n }\n Console.WriteLine(counter);\n }\n }\n}", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "a1379507cd1505648ce73bd727c83e9b", "src_uid": "d561436e2ddc9074b98ebbe49b9e27b8", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\n\nnamespace temp\n{\n\n class Program\n {\n private static void Main()\n {\n int n = Convert.ToInt32(Console.ReadLine());\n string input = Console.ReadLine();\n int c = 0;\n for (int i = 0; i < n; i++)\n {\n if (i+1 < n && input[i] == input[i + 1])\n {\n c++;\n }\n }\n Console.WriteLine(c);\n }\n }\n\n}", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "11b28e126eef3725994263d05caf32d8", "src_uid": "d561436e2ddc9074b98ebbe49b9e27b8", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "// Straight \u00abA\u00bb - CodeForces\n// Status: Unsolved\n\nusing System;\n\nnamespace ConsoleApp {\n class Program {\n\n static Func invr =\n () => Array.ConvertAll(Console.ReadLine().Split(' '),\n int.Parse);\n\n static bool val(int a, int k, int n1, int n2) {\n return ((a + (k * n2)) / ((n1 + n2) * (k - 0.5f))) < 1;\n }\n\n static int Main(string[] args) {\n int[] input = invr();\n int n = input[0], k = input[1];\n int[] a = invr();\n int aa = 0;\n\n foreach (int nn in a) {\n aa += nn;\n }\n\n float x = ((k - aa) / 0.5f) - n;\n int i = 0;\n while (val(aa, k, n, i))i++;\n Console.WriteLine(i);\n return 0;\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "implementation"], "code_uid": "7a3e2eafcc14af2589e774e55eaf0c78", "src_uid": "f22267bf3fad0bf342ecf4c27ad3a900", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Diagnostics;\nusing System.Numerics;\nusing System.Runtime.InteropServices;\nusing System.Runtime.Remoting.Messaging;\nusing System.Security.Principal;\nusing System.Text;\nusing System.Linq;\nusing System.IO;\nusing System.Globalization;\nusing System.Collections;\nusing System.Text.RegularExpressions;\n\nnamespace Task\n{\n\n #region MyIo\n\n internal class MyIo : IDisposable\n {\n#if LOCAL_TEST\n private readonly TextReader inputStream = new StreamReader(\"input.txt\");\n#else\n private readonly TextReader inputStream = Console.In;\n#endif\n#if FBHC_TEST\n private readonly TextWriter outputStream = new StreamWriter(\"output.txt\");\n#else\n private readonly TextWriter outputStream = Console.Out;\n#endif\n\n private string[] tokens;\n private int pointer;\n\n public char NextChar()\n {\n try\n {\n var c = inputStream.Read();\n\n if (c < 0)\n c = 0;\n\n return (char)c;\n }\n catch (IOException)\n {\n return '\\0';\n }\n }\n\n public string NextLine()\n {\n try\n {\n return inputStream.ReadLine();\n }\n catch (IOException)\n {\n return null;\n }\n }\n\n public string NextString()\n {\n try\n {\n while (tokens == null || pointer >= tokens.Length)\n {\n tokens = (NextLine() + string.Empty).Split(new[] { ' ', '\\t' }, StringSplitOptions.RemoveEmptyEntries);\n pointer = 0;\n }\n return tokens[pointer++];\n }\n catch (IOException)\n {\n return null;\n }\n }\n\n public int NextInt()\n {\n return Next();\n }\n\n public long NextLong()\n {\n return Next();\n }\n\n public T Next()\n {\n var t = typeof(T);\n\n if (t == typeof(char))\n return (T)(object)NextChar();\n\n object s = NextString();\n\n if (t == typeof(string))\n return (T)s;\n\n return (T)Convert.ChangeType(s, typeof(T));\n }\n\n\n public IEnumerable NextWhile(Predicate pred)\n {\n if (pred == null)\n yield break;\n\n var res = Next();\n\n while (pred(res))\n {\n yield return res;\n\n res = Next();\n }\n }\n\n public IEnumerable NextSeq(long n)\n {\n for (var i = 0; i < n; i++)\n yield return Next();\n }\n\n public void Print(string format, params object[] args)\n {\n outputStream.Write(string.Format(CultureInfo.InvariantCulture, format, args));\n }\n\n public void PrintLine(string format, params object[] args)\n {\n Print(format, args);\n\n outputStream.WriteLine();\n }\n\n public void Print(bool o)\n {\n Print(o ? \"YES\" : \"NO\");\n }\n\n public void PrintLine(bool o)\n {\n Print(o);\n\n outputStream.WriteLine();\n }\n\n public void Print(T o)\n {\n var ienum = o as IEnumerable;\n\n if (ienum != null && typeof(T) != typeof(string))\n {\n var first = true;\n\n foreach (var iev in ienum)\n {\n if (!first && iev != null)\n Print(\" \");\n\n Print(iev);\n\n first = false;\n }\n\n }\n else\n {\n outputStream.Write(Convert.ToString(o, CultureInfo.InvariantCulture));\n }\n\n }\n\n\n public void PrintLine(T o)\n {\n Print(o);\n\n outputStream.WriteLine();\n }\n\n public void Close()\n {\n inputStream.Close();\n outputStream.Close();\n }\n\n void IDisposable.Dispose()\n {\n Close();\n\n#if LOCAL_TEST\n Console.ReadLine();\n#endif\n }\n }\n\n\n public static class ListExtensions\n {\n public static void Each(this IEnumerable self, Action action)\n {\n foreach (var v in self)\n action(v);\n }\n\n public static string Reverse(this string s)\n {\n var charArray = s.ToCharArray();\n Array.Reverse(charArray);\n return new string(charArray);\n }\n\n public static IEnumerable ToCycleEnumerable(this IEnumerable self)\n {\n if (self != null)\n {\n for (; ; )\n {\n foreach (var x in self)\n yield return x;\n }\n }\n }\n\n public static T CycleGet(this IList self, int index)\n {\n var c = self.Count;\n return self[(index % c + c) % c];\n }\n\n\n public static long MODPower(this int x, long y, long mod)\n {\n long answ = 1;\n\n if (y == 0)\n return answ;\n if (y % 2 == 1)\n answ *= x;\n\n answ *= MODPower(x, y / 2, mod) * MODPower(x, y / 2, mod);\n\n answ %= mod;\n\n return answ;\n }\n\n public static IList Shuffle(this IList self)\n {\n var rnd = new Random(DateTime.Now.Millisecond);\n\n var n = self.Count;\n\n while (n > 1)\n {\n n--;\n var k = rnd.Next(n + 1);\n var value = self[k];\n self[k] = self[n];\n self[n] = value;\n }\n\n return self;\n }\n\n public static IList> UseForNew2D(this T def, int fd, int sd)\n {\n var fdim = new T[fd][];\n\n for (int i = 0; i < fd; i++)\n {\n fdim[i] = new T[sd];\n Fill(fdim[i], def);\n }\n\n return fdim;\n }\n\n public static IList Fill(this IList self, Func, T> fval)\n {\n for (var i = 0; i < self.Count; i++)\n self[i] = fval(i, self);\n\n\n return self;\n }\n\n public static IList Fill(this IList self, Func fval)\n {\n return self.Fill((x, slf) => fval(x));\n }\n\n public static IList Fill(this IList self, Func fval)\n {\n return self.Fill(x => fval());\n }\n\n\n public static IList Fill(this IList self, T val)\n {\n return self.Fill(() => val);\n }\n\n public static long Hash(this IList self, Func val = null)\n {\n return val != null ? self.Hash((t, current) => unchecked(current * 19L + val(t))) : self.Hash(HashOne);\n }\n\n public static long Hash(this IList self, Func val)\n {\n return self.Aggregate(0L, (current, t) => unchecked(val(t, current)));\n }\n\n\n public static long HashOne(this T self, long current)\n {\n return unchecked(current * 19L + (Equals(self, default(T)) ? 0 : self.GetHashCode()));\n }\n\n\n public static IList BuildSegTree(this IList a, Func combine, Func convert)\n {\n var t = new T1[a.Count << 2];\n\n a.BuildSegTree(t, 1, 0, a.Count - 1, combine, convert);\n\n return t;\n }\n\n private static void BuildSegTree(this IList a, IList t, int v, int tl, int tr, Func combine, Func convert)\n {\n if (tl == tr)\n {\n t[v] = convert(a[tl]);\n }\n else\n {\n int tm = (tl + tr) >> 1;\n\n BuildSegTree(a, t, v << 1, tl, tm, combine, convert);\n BuildSegTree(a, t, (v << 1) + 1, tm + 1, tr, combine, convert);\n\n t[v] = combine(t[v << 1], t[(v << 1) + 1]);\n }\n }\n\n public static int Xor1n(this int n)\n {\n return (n >> 1) & 1 ^ ((n & 1) > 0 ? 1 : n);\n }\n }\n\n public static class P\n {\n public static P Create(T1 key, T2 val)\n {\n return new P(key, val);\n }\n }\n\n public class P\n {\n private class PComparer : IComparer>\n {\n private readonly bool? byKey;\n\n public PComparer(bool? byKey)\n {\n this.byKey = byKey;\n }\n\n\n public int Compare(P x, P y)\n {\n x = x ?? new P();\n y = y ?? new P();\n\n\n if (byKey == true)\n return Comparer.Default.Compare(x.Key, y.Key);\n else if (byKey == false)\n return Comparer.Default.Compare(x.Value, y.Value);\n else\n {\n var tr = Comparer.Default.Compare(x.Key, y.Key);\n\n if (tr != 0)\n tr = Comparer.Default.Compare(x.Value, y.Value);\n\n return tr;\n }\n }\n }\n\n\n public P()\n {\n }\n\n public P(T1 key, T2 val)\n {\n this.Key = key;\n this.Value = val;\n }\n\n\n public T1 Key\n {\n get;\n set;\n }\n\n public T2 Value\n {\n get;\n set;\n }\n\n public P Clone()\n {\n return new P(Key, Value);\n }\n\n public static IComparer> KeyComparer\n {\n get { return new PComparer(true); }\n }\n\n public static IComparer> ValueComparer\n {\n get { return new PComparer(false); }\n }\n\n public static implicit operator T1(P obj)\n {\n return obj.Key;\n }\n\n public static implicit operator T2(P obj)\n {\n return obj.Value;\n }\n\n public P SetKey(T1 key)\n {\n Key = key;\n return this;\n }\n\n public P SetValue(T2 value)\n {\n Value = value;\n return this;\n }\n\n public override string ToString()\n {\n return string.Format(\"Key: {0}, Value: {1}\", Key, Value);\n }\n\n public override bool Equals(object obj)\n {\n var co = obj as P;\n\n return co != null && co.GetHashCode() == GetHashCode();\n }\n\n public override int GetHashCode()\n {\n int hash = 17;\n hash = unchecked(hash * 31 + ((Equals(Key, default(T1))) ? 0 : Key.GetHashCode()));\n hash = unchecked(hash * 31 + ((Equals(Value, default(T1))) ? 0 : Value.GetHashCode()));\n return hash;\n\n }\n }\n\n #endregion\n\n\n\n\n internal class Program\n {\n #region Program\n\n private readonly MyIo io;\n\n public Program(MyIo io)\n {\n this.io = io;\n }\n\n public static void Main(string[] args)\n {\n using (var io = new MyIo())\n {\n try\n {\n new Program(io)\n .Solve();\n }\n catch (Exception e)\n {\n io.PrintLine(e.Message + \"\\r\\n\" + e.StackTrace);\n\n throw;\n }\n }\n }\n\n\n\n #endregion\n\n public const long MOD = 1000000007;\n public const double EPS = 1e-14;\n\n private void Solve()\n {\n var n = io.NextInt();\n var k = io.NextInt();\n\n\n var a = io.NextSeq(n).ToList();\n var sm = (double)a.Sum();\n var cnt = 0;\n double x;\n\n do\n {\n x = sm / (n + cnt);\n sm += k;\n cnt++;\n } while (x < k - 0.5);\n\n io.PrintLine(cnt - 1);\n }\n\n }\n\n}\n\n", "lang_cluster": "C#", "tags": ["math", "implementation"], "code_uid": "8502d4b1acb1980487edaddbd7cab697", "src_uid": "f22267bf3fad0bf342ecf4c27ad3a900", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System; using System.Linq;\n\nclass P {\n static void Main () { \n var s = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();\n var a = s[0]; var b = s[1]; var c = s[2];\n var res = Enumerable.Range(0,1000000).First(x => a*c <= b*(c+x));\n Console.Write(res);\n }\n}", "lang_cluster": "C#", "tags": ["brute force", "math", "binary search"], "code_uid": "47bf8a71b1240688b738f682c746f355", "src_uid": "7dd098ec3ad5b29ad681787173eba341", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Linq;\n\nnamespace LetsWatchFootball\n{\n class Program\n {\n static void Main(string[] args)\n {\n int[] input = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();\n int temp = (input[0] * input[2]) - (input[1] * input[2]);\n int seconds = 0;\n while (seconds * input[1] < temp)\n seconds++;\n Console.WriteLine(seconds);\n Console.ReadLine();\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "math", "binary search"], "code_uid": "867a615639a952c5fcc1b2ce1eb91d5f", "src_uid": "7dd098ec3ad5b29ad681787173eba341", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace ConsoleApp4\n{\n class Program\n {\n static void Main(string[] args)\n {\n long ty = 0, tb = 0, y = 0, g = 0, b = 0, t = 0;\n string tmp1=Console.ReadLine();\n //cin >> ty >> tb;\n string[] t1 = tmp1.Split(' ');\n ty = long.Parse(t1[0]);\n tb = long.Parse(t1[1]);\n string tmp2 = Console.ReadLine();\n t1 = tmp2.Split(' ');\n y = long.Parse(t1[0]);\n g = long.Parse(t1[1]);\n b = long.Parse(t1[2]);\n //cin >> y >> g >> b;\n ty = ty - g; tb = tb - g;\n if (ty - y * 2 < 0)\n {\n t = t + (y * 2 - ty);\n ty = 0;\n }\n else\n {\n ty = ty - y * 2;\n }\n\n if (tb - b * 3 < 0)\n {\n t = t + (b * 3 - tb); tb = 0;\n }\n else\n {\n tb = tb - b * 3;\n }\n // if (t < 0)\n // t = -1 * t;\n Console.Write(t);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "4f35bdf790b606beb06315bd2063a0a5", "src_uid": "35202a4601a03d25e18dda1539c5beba", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\n\nnamespace CSharp\n{\n public class _912A\n {\n public static void Main()\n {\n string[] tokens = Console.ReadLine().Split();\n\n long a = long.Parse(tokens[0]);\n long b = long.Parse(tokens[1]);\n\n tokens = Console.ReadLine().Split();\n\n long x = long.Parse(tokens[0]);\n long y = long.Parse(tokens[1]);\n long z = long.Parse(tokens[2]);\n\n Console.WriteLine(Math.Max(0, 2 * x + y - a) + Math.Max(0, y + 3 * z - b));\n }\n }\n}", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "95b2c2505ffe96764448ef80a67f82a6", "src_uid": "35202a4601a03d25e18dda1539c5beba", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.IO;\nusing System.Linq;\nusing System.Text;\nusing System.Globalization;\n\n#if DEBUG\nusing System.Diagnostics;\n#endif\n\nnamespace CompetitiveProgramming\n{\n class Program\n {\n static bool s_IsMultipleTestCases = false;\n static void Main(string[] args)\n {\n#if DEBUG\n var streamReader = new StreamReader(\"../../input.txt\", Encoding.ASCII, false, 32768);\n var streamWriter = new StreamWriter(\"../../output.txt\", false, Encoding.ASCII, 32768);\n var timer = new Stopwatch();\n timer.Start();\n#else\n var streamReader = new StreamReader(Console.OpenStandardInput(32768), Encoding.ASCII, false, 32768);\n var streamWriter = new StreamWriter(Console.OpenStandardOutput(32768), Encoding.ASCII, 32768);\n#endif\n var reader = new InputReader(streamReader);\n\n var numberOfTest = 1;\n if (s_IsMultipleTestCases)\n {\n numberOfTest = reader.NextInt();\n }\n for (var testNumber = 1; testNumber <= numberOfTest; ++testNumber)\n {\n Task solver = new Task();\n solver.Solve(testNumber, reader, streamWriter);\n }\n#if DEBUG\n streamWriter.WriteLine(\"\\nEslapsed Time: \" + timer.ElapsedMilliseconds + \" ms\");\n#endif\n streamReader.Close();\n streamWriter.Close();\n }\n }\n\n class Task\n {\n public void Solve(int testNumber, InputReader reader, StreamWriter writer)\n {\n var s = reader.Next().Split(':');\n var min = reader.NextInt();\n var timeSpan = new TimeSpan(int.Parse(s[0]), int.Parse(s[1]), 0);\n var ans = timeSpan.Add(new TimeSpan(0, min, 0));\n writer.WriteLine(ans.ToString(@\"hh\\:mm\"));\n }\n }\n\n class InputReader\n {\n private char[] _inbuf;\n private int _lenbuf = 0, _ptrbuf = 0;\n private StreamReader _reader;\n\n public InputReader(StreamReader reader)\n {\n _reader = reader;\n _inbuf = new char[1024];\n _lenbuf = 0;\n _ptrbuf = 0;\n }\n\n private int ReadByte()\n {\n if (_lenbuf == -1)\n throw new Exception();\n if (_ptrbuf >= _lenbuf)\n {\n _ptrbuf = 0;\n try\n {\n _lenbuf = _reader.Read(_inbuf, 0, 1024);\n }\n catch (IOException e)\n {\n throw e;\n }\n if (_lenbuf <= 0)\n return -1;\n }\n return _inbuf[_ptrbuf++];\n }\n\n private bool IsSpaceChar(int c)\n {\n return !(c >= 33 && c <= 126);\n }\n\n private int Skip()\n {\n int b;\n while ((b = ReadByte()) != -1 && IsSpaceChar(b)) ;\n return b;\n }\n\n public int NextInt()\n {\n int num = 0, b;\n var minus = false;\n while ((b = ReadByte()) != -1 && !((b >= '0' && b <= '9') || b == '-')) ;\n if (b == '-')\n {\n minus = true;\n b = ReadByte();\n }\n\n while (true)\n {\n if (b >= '0' && b <= '9')\n {\n num = num * 10 + (b - '0');\n }\n else\n {\n return minus ? -num : num;\n }\n b = ReadByte();\n }\n }\n\n public long NextLong()\n {\n long num = 0, b;\n var minus = false;\n while ((b = ReadByte()) != -1 && !((b >= '0' && b <= '9') || b == '-')) ;\n if (b == '-')\n {\n minus = true;\n b = ReadByte();\n }\n\n while (true)\n {\n if (b >= '0' && b <= '9')\n {\n num = num * 10 + (b - '0');\n }\n else\n {\n return minus ? -num : num;\n }\n b = ReadByte();\n }\n }\n\n public string Next()\n {\n var b = Skip();\n var sb = new StringBuilder();\n while (!(IsSpaceChar(b)))\n {\n sb.Append((char)b);\n b = ReadByte();\n }\n return sb.ToString();\n }\n\n public double NextDouble()\n {\n return double.Parse(Next(), CultureInfo.InvariantCulture);\n }\n }\n\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "52822d127f0763f7dfae740f9301d21f", "src_uid": "20c2d9da12d6b88f300977d74287a15d", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.IO;\nusing System.Linq;\nusing System.Text;\nusing System.Collections.Generic;\nusing System.Diagnostics;\nusing System.Numerics;\nusing Enu = System.Linq.Enumerable;\n\nclass Program\n{\n public void Solve()\n {\n var S = Reader.String();\n int h = int.Parse(S.Substring(0, 2));\n int m = int.Parse(S.Substring(3));\n m += Reader.Int();\n h += m / 60;\n m %= 60;\n h %= 24;\n Console.WriteLine(h.ToString(\"d2\") + \":\" + m.ToString(\"d2\"));\n Console.ReadLine();\n }\n}\n\n\nclass Entry { static void Main() { new Program().Solve(); } }\nclass Reader\n{\n private static TextReader reader = Console.In;\n private static readonly char[] separator = { ' ' };\n private static readonly StringSplitOptions op = StringSplitOptions.RemoveEmptyEntries;\n private static string[] A = new string[0];\n private static int i;\n private static void Init() { A = new string[0]; }\n public static void Set(TextReader r) { reader = r; Init(); }\n public static void Set(string file) { reader = new StreamReader(file); Init(); }\n public static bool HasNext() { return CheckNext(); }\n public static string String() { return Next(); }\n public static int Int() { return int.Parse(Next()); }\n public static long Long() { return long.Parse(Next()); }\n public static double Double() { return double.Parse(Next()); }\n public static int[] IntLine() { return Array.ConvertAll(Split(Line()), int.Parse); }\n public static int[] IntArray(int N) { return Enu.Range(0, N).Select(i => Int()).ToArray(); }\n public static int[][] IntTable(int H) { return Enu.Range(0, H).Select(i => IntLine()).ToArray(); }\n public static string[] StringArray(int N) { return Enu.Range(0, N).Select(i => Next()).ToArray(); }\n public static string Line() { return reader.ReadLine().Trim(); }\n private static string[] Split(string s) { return s.Split(separator, op); }\n private static string Next() { CheckNext(); return A[i++]; }\n private static bool CheckNext()\n {\n if (i < A.Length) return true;\n string line = reader.ReadLine();\n if (line == null) return false;\n if (line == \"\") return CheckNext();\n A = Split(line);\n i = 0;\n return true;\n }\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "17e59fac176e9ab2c00d62732fd1752b", "src_uid": "20c2d9da12d6b88f300977d74287a15d", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace Code\n{\n class Program\n {\n public static int[] a;\n static void Main(string[] args)\n {\n string s = Console.ReadLine();\n int n = int.Parse(s.Split(' ')[0]), x = int.Parse(s.Split(' ')[1]);\n s = Console.ReadLine();\n bool[] b = new bool[x+1];\n for (int i = 0; i < x; i++)\n b[i] = false;\n foreach (string s1 in s.Split(' '))\n {\n if (int.Parse(s1)<= x)\n b[int.Parse(s1)] = true;\n }\n int c = 0; \n for (int i=0; i 11)\n {\n Console.WriteLine(0);\n }\n else\n {\n Console.WriteLine(4);\n }\n }\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "b56fe6d1ed1b2c5c0790a518e17b2776", "src_uid": "5802f52caff6015f21b80872274ab16c", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nusing System.IO;\n\nclass PairVariable : IComparable\n{\n public int a, b;\n public int c;\n public PairVariable()\n {\n a = b = 0;\n c = 0;\n }\n public PairVariable(string s)\n {\n string[] q = s.Split();\n a = int.Parse(q[0]);\n b = int.Parse(q[1]);\n c = 0;\n\n }\n\n public PairVariable(int a, int b, int c)\n {\n this.a = a;\n this.b = b;\n this.c = c;\n\n }\n public PairVariable(int a, int b)\n {\n this.a = a;\n this.b = b;\n }\n\n\n\n\n public int CompareTo(PairVariable other)\n {\n return this.a.CompareTo(other.a);\n }\n}\nnamespace ConsoleApplication1\n{\n class Program\n {\n\n static char[,] s = new char[10, 10];\n\n static List position = new List();\n\n\n\n\n\n static void Main(string[] args)\n {\n \n for (int i = 1; i <= 8; i++)\n {\n string q = Console.ReadLine();\n \n for (int e = 1; e <= 8; e++)\n {\n s[i, e] = q[e - 1];\n }\n }\n \n for (int i = 1; i <= 8; i++)\n {\n for (int e = 1; e <= 8; e++)\n {\n if (s[i, e] == 'S')\n {\n s[i, e] = '.';\n position.Add(new PairVariable(i, e));\n }\n }\n }\n int x = 8;\n int y = 1;\n List d = new List();\n d.Add(new PairVariable(x, y));\n for (int i = 0; i < 8; i++)\n {\n if (d.Count == 0)\n {\n Console.WriteLine(\"LOSE\");\n return;\n }\n int kk = d.Count;\n for (int e = 0; e < kk; e++)\n {\n int xx = d[e].a;\n int yy = d[e].b;\n int x1 = xx - 1;\n int y1 = yy;\n bool q = true;\n for (int j = 0; j < position.Count; j++)\n {\n if (position[j].a == x1 && position[j].b == y1)\n {\n q = false;\n\t\t\t\t\t\t\t\tbreak;\n }\n }\n\t\t\t\t\t\tfor (int j = 0; j < d.Count; j++)\n {\n if (d[j].a == x1 && d[j].b == y1)\n {\n q = false;\n\t\t\t\t\t\t\t\tbreak;\n }\n }\n if (s[x1, y1] != '.')\n {\n q = false;\n }\n if (q)\n {\n d.Add(new PairVariable(x1, y1));\n }\n x1 = xx - 1;\n y1 = yy - 1;\n q = true;\n for (int j = 0; j < position.Count; j++)\n {\n if (position[j].a == x1 && position[j].b == y1)\n {\n q = false;\n\t\t\t\t\t\t\t\tbreak;\n }\n }\n\t\t\t\t\t\tfor (int j = 0; j < d.Count; j++)\n {\n if (d[j].a == x1 && d[j].b == y1)\n {\n q = false;\n\t\t\t\t\t\t\t\tbreak;\n }\n }\n if (s[x1, y1] != '.')\n {\n q = false;\n }\n if (q)\n {\n d.Add(new PairVariable(x1, y1));\n }\n x1 = xx - 1;\n y1 = yy + 1;\n\n q = true;\n for (int j = 0; j < position.Count; j++)\n {\n if (position[j].a == x1 && position[j].b == y1)\n {\n q = false;\n\t\t\t\t\t\t\t\tbreak;\n }\n }\n\n\t\t\t\t\t\tfor (int j = 0; j < d.Count; j++)\n {\n if (d[j].a == x1 && d[j].b == y1)\n {\n q = false;\n\t\t\t\t\t\t\t\tbreak;\n }\n }\n if (s[x1, y1] != '.')\n {\n q = false;\n }\n\n if (q)\n {\n d.Add(new PairVariable(x1, y1));\n }\n x1 = xx;\n y1 = yy + 1;\n q = true;\n for (int j = 0; j < position.Count; j++)\n {\n if (position[j].a == x1 && position[j].b == y1)\n {\n q = false;\n\t\t\t\t\t\t\t\tbreak;\n }\n }\n\t\t\t\t\t\tfor (int j = 0; j < d.Count; j++)\n {\n if (d[j].a == x1 && d[j].b == y1)\n {\n q = false;\n\t\t\t\t\t\t\t\tbreak;\n }\n }\n if (s[x1, y1] != '.')\n {\n q = false;\n }\n if (q)\n {\n d.Add(new PairVariable(x1, y1));\n }\n x1 = xx;\n y1 = yy - 1;\n q = true;\n for (int j = 0; j < position.Count; j++)\n {\n if (position[j].a == x1 && position[j].b == y1)\n {\n q = false;\n\t\t\t\t\t\t\t\tbreak;\n }\n }\n\t\t\t\t\t\tfor (int j = 0; j < d.Count; j++)\n {\n if (d[j].a == x1 && d[j].b == y1)\n {\n q = false;\n\t\t\t\t\t\t\t\tbreak;\n }\n }\n if (s[x1, y1] != '.')\n {\n q = false;\n }\n if (q)\n {\n d.Add(new PairVariable(x1, y1));\n }\n x1 = xx+1;\n y1 = yy - 1;\n q = true;\n for (int j = 0; j < position.Count; j++)\n {\n if (position[j].a == x1 && position[j].b == y1)\n {\n q = false;\n\t\t\t\t\t\t\t\tbreak;\n }\n }\n\t\t\t\t\t\tfor (int j = 0; j < d.Count; j++)\n {\n if (d[j].a == x1 && d[j].b == y1)\n {\n q = false;\n\t\t\t\t\t\t\t\tbreak;\n }\n }\n if (s[x1, y1] != '.')\n {\n q = false;\n }\n if (q)\n {\n d.Add(new PairVariable(x1, y1));\n }\n x1 = xx+1;\n y1 = yy + 1;\n q = true;\n for (int j = 0; j < position.Count; j++)\n {\n if (position[j].a == x1 && position[j].b == y1)\n {\n q = false;\n\t\t\t\t\t\t\t\tbreak;\n }\n }\n\t\t\t\t\t\tfor (int j = 0; j < d.Count; j++)\n {\n if (d[j].a == x1 && d[j].b == y1)\n {\n q = false;\n\t\t\t\t\t\t\t\tbreak;\n }\n }\n if (s[x1, y1] != '.')\n {\n q = false;\n }\n if (q)\n {\n d.Add(new PairVariable(x1, y1));\n }\n x1 = xx+1;\n y1 = yy;\n q = true;\n for (int j = 0; j < position.Count; j++)\n {\n if (position[j].a == x1 && position[j].b == y1)\n {\n q = false;\n\t\t\t\t\t\t\t\tbreak;\n }\n }\n\t\t\t\t\t\tfor (int j = 0; j < d.Count; j++)\n {\n if (d[j].a == x1 && d[j].b == y1)\n {\n q = false;\n\t\t\t\t\t\t\t\tbreak;\n }\n }\n if (s[x1, y1] != '.')\n {\n q = false;\n }\n if (q)\n {\n d.Add(new PairVariable(x1, y1));\n }\n }\n for (int e = 0; e < position.Count; e++)\n {\n position[e].a++;\n }\n \n for (int e = 0; e < position.Count; e++)\n {\n for (int j = 0; j < d.Count; j++)\n {\n if (position[e].a == d[j].a && position[e].b == d[j].b)\n {\n d.RemoveAt(j);\n }\n\n }\n }\n \n \n\n\n }\n Console.WriteLine(\"WIN\");\n\n \n\n }\n }\n}", "lang_cluster": "C#", "tags": ["dfs and similar"], "code_uid": "2d324f1f76a137a363d06707d60d71cf", "src_uid": "f47e4ab041288ba9567c19930eb9a090", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Text;\nusing System.IO;\nusing System.Globalization;\nusing System.Collections.Generic;\nusing System.Linq;\n\nclass App {\n\tstatic void Main() {\n\t\tvar field = new List {\n\t\t\t\"........\".ToCharArray(),\n\t\t\t\"........\".ToCharArray(),\n\t\t};\n\t\t\n\t\tfor (int i = 0 ; i < 8 ; i++) field.Add(Console.ReadLine().Replace('A', '.').ToCharArray());\n\t\t\n\t\tvar queue = new List> {\n\t\t\tTuple.Create(9, 0),\n\t\t};\n\t\t\n\t\tAction tryMove = (y, x) => {\n\t\t\tif (x < 0 || x > 7 || y > 9) return;\n\t\t\tif (field[y][x] == 'S' || field[y-1][x] == 'S') return;\n\t\t\tif (field[y-1][x] == 'M') return;\n\t\t\tfield[y-1][x] = 'M';\n\t\t\tqueue.Add(Tuple.Create(y - 1, x));\n\t\t};\n\t\t\n\t\tfor (int i = 0 ; i < queue.Count ; i++) {\n\t\t\tvar move = queue[i];\n\t\t\tvar y = move.Item1;\n\t\t\tvar x = move.Item2;\n\t\t\tif (y < 2) {\n\t\t\t\tConsole.WriteLine(\"WIN\");\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tfor (int ny = y - 1 ; ny <= y + 1 ; ny++)\n\t\t\tfor (int nx = x - 1 ; nx <= x + 1 ; nx++)\n\t\t\t\ttryMove(ny, nx);\n\t\t}\n\t\tConsole.Write(\"LOSE\");\n\t}\n}", "lang_cluster": "C#", "tags": ["dfs and similar", "implementation", "graphs"], "code_uid": "0bc04decb926e12a884084ee16ec6937", "src_uid": "f47e4ab041288ba9567c19930eb9a090", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.IO;\nusing System.Collections;\n\nnamespace ConsoleApplication1\n{\n class cf384_2\n {\n static void Main(string[] args)\n {\n //Console.SetIn(new StreamReader(@\"D:\\Sergey\\Code\\1.txt\"));\n\n string[] strParams = Console.ReadLine().Split(new char[] { ' ' });\n int n = int.Parse(strParams[0]);\n ulong k = ulong.Parse(strParams[1]);\n\n\n Console.WriteLine(GetNum(k, n));\n } // Main\n\n\n\n static int GetNum(ulong k, int n)\n {\n if (n == 1)\n return 1;\n\n ulong len = (ulong)Math.Pow(2, n) - 1;\n if ((len / 2 + 1) == k)\n return n;\n\n\n if (k > (len / 2 + 1))\n k -= (len / 2 + 1);\n\n return GetNum(k, n -1);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["constructive algorithms", "binary search", "implementation", "bitmasks"], "code_uid": "49f6fdbd1a1d4814766c8c407e80a5ff", "src_uid": "0af400ea8e25b1a36adec4cc08912b71", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Collections;\nusing System.Globalization;\nusing System.IO;\nusing System.Linq;\n//\u0413\u0430\u0432\u043d\u043e \u043a\u043e\u0434 \u043d\u0435\u0434\u043e\u0440\u0435\u0448\u0435\u043d\u043d\u044b\u0439\npublic class Source\n{\n public void Program()\n {\n }\n void Read()\n {\n long n = ReadLong(), a = ReadLong();\n long size = 0;\n for (int i = 0; i < n; i++)\n {\n size += 1 + size;\n }\n long maxnum = n;\n while(true)\n {\n if (a != size / 2 + 1)\n {\n if (a > size / 2 + 1)\n a -= size / 2 + 1;\n size /= 2;\n n--;\n }\n else\n { writeLine(n); return; }\n }\n // writeLine(l[a]);\n }\n\n #region hide it\n #region Main\n\n protected static TextReader reader;\n protected static TextWriter writer;\n static void Main()\n {\n#if DEBUG\n reader = new StreamReader(\"..\\\\..\\\\input.txt\");\n //reader = new StreamReader(Console.OpenStandardInput());\n writer = Console.Out;\n //writer = new StreamWriter(\"..\\\\..\\\\output.txt\");\n#else\n reader = new StreamReader(Console.OpenStandardInput());\n writer = new StreamWriter(Console.OpenStandardOutput());\n //reader = new StreamReader(\"input.txt\");\n //writer = new StreamWriter(\"output.txt\");\n#endif\n var source = new Source();\n source.Read();\n source.Program();\n\n /* try\n {\n new Source().Program();\n }\n catch (Exception ex)\n {\n #if DEBUG\n Console.WriteLine(ex);\n #else\n throw;\n #endif\n }*/\n reader.Close();\n writer.Close();\n }\n\n\n #endregion\n\n #region Read / Write\n private static Queue currentLineTokens = new Queue();\n private static string[] ReadAndSplitLine() { return reader.ReadLine().Split(new[] { ' ', '\\t', }, StringSplitOptions.RemoveEmptyEntries); }\n public static string ReadToken()\n {\n while (currentLineTokens.Count == 0)\n currentLineTokens = new Queue(ReadAndSplitLine());\n return currentLineTokens.Dequeue();\n }\n public static int ri() { return int.Parse(ReadToken()); }\n public static char ReadChar() { return char.Parse(ReadToken()); }\n public static long ReadLong() { return long.Parse(ReadToken()); }\n public static ulong ReaduLong() { return ulong.Parse(ReadToken()); }\n public static double ReadDouble() { return double.Parse(ReadToken(), CultureInfo.InvariantCulture); }\n public static int[] ReadIntArray() { return ReadAndSplitLine().Select(i => int.Parse(i)).ToArray(); }\n public static char[] ReadCharArray() { return ReadAndSplitLine().Select(i => char.Parse(i)).ToArray(); }\n public static long[] ReadLongArray() { return ReadAndSplitLine().Select(i => long.Parse(i)).ToArray(); }\n public static double[] ReadDoubleArray() { return ReadAndSplitLine().Select(s => double.Parse(s, CultureInfo.InvariantCulture)).ToArray(); }\n public static int[][] ReadIntMatrix(int numberOfRows) { int[][] matrix = new int[numberOfRows][]; for (int i = 0; i < numberOfRows; i++) matrix[i] = ReadIntArray(); return matrix; }\n public static char[][] ReadCharMatrix(int numberOfRows) { char[][] matrix = new char[numberOfRows][]; for (int i = 0; i < numberOfRows; i++) matrix[i] = ReadCharArray(); return matrix; }\n public static int[][] ReadAndTransposeIntMatrix(int numberOfRows)\n {\n int[][] matrix = ReadIntMatrix(numberOfRows); int[][] ret = new int[matrix[0].Length][];\n for (int i = 0; i < ret.Length; i++) { ret[i] = new int[numberOfRows]; for (int j = 0; j < numberOfRows; j++) ret[i][j] = matrix[j][i]; }\n return ret;\n }\n public static string[] ReadLines(int quantity) { string[] lines = new string[quantity]; for (int i = 0; i < quantity; i++) lines[i] = reader.ReadLine().Trim(); return lines; }\n public static void write(T value) { writer.Write(value); }\n public static void writeLine(T value) { writer.WriteLine(value); }\n public static void writeArray(T[] array, string split) { for (int i = 0; i < array.Length; i++) { write(array[i] + split); } }\n public static void writeMatrix(T[][] matrix, string split) { for (int i = 0; i < matrix.Length; i++) { writeArray(matrix[i], split); writer.Write(\"\\n\"); } }\n private class SDictionary : Dictionary\n {\n public new TValue this[TKey key]\n {\n get { return ContainsKey(key) ? base[key] : default(TValue); }\n set { base[key] = value; }\n }\n }\n private static T[] Init(int size) where T : new() { var ret = new T[size]; for (int i = 0; i < size; i++) ret[i] = new T(); return ret; }\n #endregion\n\n #region Methods\n #region DSU\n public void MakeSet(int[] poi)\n {\n for (int i = 0; i < poi.Length; i++)\n {\n poi[i] = i;\n }\n }\n public int Find(int x, int[] poi)\n {\n if (poi[x] == x) return x;\n return poi[x] = Find(poi[x], poi);\n }\n Random rand = new Random();\n public void Unite(int x, int y, int[] poi)\n {\n y = Find(y, poi);\n x = Find(x, poi);\n if (rand.Next() % 2 == 0)\n Swap(ref x, ref y);\n poi[x] = y;\n }\n #endregion\n\n class Deque\n {\n T[] array;\n int start, length;\n public Deque()\n {\n start = 0; length = 0; array = new T[1];\n }\n public T this[int index] { get { return array[(start + index) % array.Length]; } set { array[(start + index) % array.Length] = value; } }\n int last { get { return (start + length) % array.Length; } }\n /// \n /// \u00c3\u0083\u00c6\u0092\u00c3\u00a2\u00e2\u0082\u00ac\u00cb\u009c\u00c3\u0083\u00e2\u0080\u009a\u00c3\u0082\u00c2\u0081\u00c3\u0083\u00c6\u0092\u00c3\u00a2\u00e2\u0082\u00ac\u00cb\u009c\u00c3\u0083\u00c2\u00a2\u00c3\u00a2\u00e2\u0080\u009a\u00c2\u00ac\u00c3\n /// \n public T PeekFirst()\n {\n return array[start];\n }\n public int Count { get { return length; } }\n /// \n /// \u00c3\u0083\u00c6\u0092\u00c3\u0082\u00c2\u0090\u00c3\u0083\u00e2\u0080\u009a\u00c3\u0082\u00c2\u00ba\u00c3\u0083\u00c6\u0092\u00c3\u0082\u00c2\u0090\u00c3\u0083\u00e2\u0080\u009a\u00c3\u0082\u00c2\u00be\u00c3\u0083\u00c6\u0092\u00c3\u0082\u00c2\u0090\u00c3\u0083\u00e2\u0080\u009a\u00c3\u0082\u00c2\u00bd\u00c3\u0083\u00c6\u0092\u00c3\u0082\u00c2\u0090\u00c3\u0083\u00e2\u0080\u009a\u00c3\u0082\u00c2\u00b5\u00c3\u0083\u00c6\u0092\u00c3\u00a2\u00e2\u0082\u00ac\u00cb\u009c\u00c3\u0083\u00c2\u00a2\u00c3\u00a2\u00e2\u0080\u009a\u00c2\u00ac \u00c3\u0083\u00c6\u0092\u00c3\u0082\u00c2\u0090\u00c3\u0083\u00e2\u0080\u009a\u00c3\u0082\u00c2\u00b1\u00c3\u0083\u00c6\u0092\u00c3\u0082\u00c2\u0090\u00c3\u0083\u00e2\u0080\u009a\u00c3\u0082\u00c2\u00b5\u00c3\u0083\u00c6\u0092\u00c3\u0082\u00c2\u0090\u00c3\u0083\u00e2\u0080\u009a\u00c3\u0082\u00c2\u00b7 \u00c3\u0083\u00c6\u0092\u00c3\u00a2\u00e2\u0082\u00ac\u00cb\u009c\u00c3\u0083\u00e2\u0080 \u00c3\u00a2\u00e2\u0082\u00ac\u00e2\u0084\u00a2\u00c3\u0083\u00c6\u0092\u00c3\u0082\u00c2\u0090\u00c3\u0083\u00e2\u0080\u009a\u00c3\u0082\u00c2\u00b4\u00c3\u0083\u00c6\u0092\u00c3\u0082\u00c2\u0090\u00c3\u0083\u00e2\u0080\u009a\u00c3\u0082\u00c2\u00b0\u00c3\u0083\u00c6\u0092\u00c3\u0082\u00c2\u0090\u00c3\u0083\u00e2\u0080\u009a\u00c3\u0082\u00c2\u00bb\u00c3\u0083\u00c6\u0092\u00c3\u0082\u00c2\u0090\u00c3\u0083\u00e2\u0080\u009a\u00c3\u0082\u00c2\u00b5\u00c3\u0083\u00c6\u0092\u00c3\u0082\u00c2\u0090\u00c3\u0083\u00e2\u0080\u009a\u00c3\u0082\u00c2\u00bd\u00c3\u0083\u00c6\u0092\u00c3\u0082\u00c2\u0090\u00c3\u0083\u00e2\u0080\u009a\u00c3\u0082\u00c2\u00b8\u00c3\u0083\u00c6\u0092\u00c3\u00a2\u00e2\u0082\u00ac\u00cb\u009c\u00c3\u0083\u00e2\u0080\u009a\u00c3\u0082\u00c2\u008f\n /// \n public T PeekLsat()\n {\n return array[last];\n }\n public T PopLast()\n {\n if (length == 0)\n throw new IndexOutOfRangeException(\"OutOfRange\");\n length--;\n return array[last];\n }\n public T PopFirst()\n {\n if (length == 0)\n throw new IndexOutOfRangeException(\"OutOfRange\");\n length--;\n if (start >= array.Length - 1) start = 0; else start++;\n return array[start - 1 < 0 ? array.Length - 1 : start - 1];\n }\n public void AddFirst(T value)\n {\n IncreaseAndInspection();\n if (start <= 0) start = array.Length - 1; else start--;\n array[start] = value;\n length++;\n }\n public void AddLast(T value)\n {\n IncreaseAndInspection();\n array[last] = value;\n length++;\n }\n bool overflow { get { return length == array.Length; } }\n void IncreaseAndInspection()\n {\n if (overflow)\n increase();\n\n }\n void increase()\n {\n T[] array2 = new T[array.Length * 2];\n for (int i = 0; i < array.Length; i++)\n {\n int pos = (start + i) % array.Length;\n array2[i] = array[pos];\n }\n array = array2;\n start = 0;\n array2 = null;\n }\n public void Clear()\n {\n start = 0; length = 0; array = new T[1];\n }\n }\n class Heap\n {\n Comparison ic;\n List storage = new List();\n public Heap(Comparison ic)\n {\n this.ic = ic;\n }\n public void Add(T element)\n {\n storage.Add(element);\n int pos = storage.Count - 1;\n while (pos != 0 && ic(storage[((int)(pos - 1) >> 1)], element) > 0)\n {\n Swap(storage, pos, ((int)(pos - 1) / 2));\n pos = ((int)(pos - 1) / 2);\n }\n }\n public T Pop()\n {\n T t = storage[0];\n Swap(storage, 0, storage.Count - 1);\n int pos = 0;\n storage.RemoveAt(storage.Count - 1);\n if (Count > 0)\n while (true)\n {\n T my = storage[pos];\n if (pos * 2 + 1 >= Count)\n break;\n T left = storage[pos * 2 + 1];\n if (pos * 2 + 2 >= Count)\n {\n if (ic(left, my) < 0)\n {\n Swap(storage, pos, pos * 2 + 1);\n pos = pos * 2 + 1;\n }\n break;\n }\n T right = storage[pos * 2 + 2];\n if (ic(left, my) < 0 || ic(right, my) < 0)\n {\n if (ic(left, right) < 0)\n {\n Swap(storage, pos, pos * 2 + 1);\n pos = pos * 2 + 1;\n }\n else\n {\n\n Swap(storage, pos, pos * 2 + 2);\n pos = pos * 2 + 2;\n }\n }\n else break;\n }\n return t;\n }\n\n public void Clear()\n {\n storage.Clear();\n }\n /// \n /// \u00c3\u0083\u00c6\u0092\u00c3\u0082\u00c2\u0090\u00c3\u0083\u00e2\u0080\u009a\u00c3\u0082\u00c2\u00b1\u00c3\u0083\u00c6\u0092\u00c3\u0082\u00c2\u0090\u00c3\u0083\u00e2\u0080\u009a\u00c3\u0082\u00c2\u00b5\u00c3\u0083\u00c6\u0092\u00c3\u0082\u00c2\u0090\u00c3\u0083\u00e2\u0080\u009a\u00c3\u0082\u00c2\u00b7 \u00c3\u0083\u00c6\u0092\u00c3\u00a2\u00e2\u0082\u00ac\u00cb\u009c\u00c3\u0083\u00e2\u0080 \u00c3\u00a2\u00e2\u0082\u00ac\u00e2\u0084\u00a2\u00c3\u0083\u00c6\u0092\u00c3\u0082\u00c2\u0090\u00c3\u0083\u00e2\u0080\u009a\u00c3\u0082\u00c2\u00b4\u00c3\u0083\u00c6\u0092\u00c3\u0082\u00c2\u0090\u00c3\u0083\u00e2\u0080\u009a\u00c3\u0082\u00c2\u00b0\u00c3\u0083\u00c6\u0092\u00c3\u0082\u00c2\u0090\u00c3\u0083\u00e2\u0080\u009a\u00c3\u0082\u00c2\u00bb\u00c3\u0083\u00c6\u0092\u00c3\u0082\u00c2\u0090\u00c3\u0083\u00e2\u0080\u009a\u00c3\u0082\u00c2\u00b5\u00c3\u0083\u00c6\u0092\u00c3\u0082\u00c2\u0090\u00c3\u0083\u00e2\u0080\u009a\u00c3\u0082\u00c2\u00bd\u00c3\u0083\u00c6\u0092\u00c3\u0082\u00c2\u0090\u00c3\u0083\u00e2\u0080\u009a\u00c3\u0082\u00c2\u00b8\u00c3\u0083\u00c6\u0092\u00c3\u00a2\u00e2\u0082\u00ac\u00cb\u009c\u00c3\u0083\u00e2\u0080\u009a\u00c3\u0082\u00c2\u008f\n /// \n /// \n public T Peek()\n {\n return storage[0];\n }\n public int Count\n {\n get { return storage.Count; }\n }\n //void RemoveLast, Size, peeklast, add\n }\n static void Swap(ref T lhs, ref T rhs)\n {\n T temp;\n temp = lhs;\n lhs = rhs;\n rhs = temp;\n }\n static void Swap(T[] a, int l, int r)\n {\n T temp;\n temp = a[l];\n a[l] = a[r];\n a[r] = temp;\n }\n static void Swap(List a, int l, int r)\n {\n T temp;\n temp = a[l];\n a[l] = a[r];\n a[r] = temp;\n }\n\n bool outregion(long y, long x, long n, long m)\n {\n if (x < 0 || x >= m || y < 0 || y >= n)\n return true;\n return false;\n }\n static void initlist(ref List[] list, int n)\n {\n list = new List[n];\n for (int i = 0; i < n; i++)\n list[i] = new List();\n }\n static void newarray(ref T[][] array, int n, int m)\n {\n array = new T[n][];\n for (int i = 0; i < n; i++)\n array[i] = new T[m];\n }\n static void newarray(ref T[] array, int n)\n {\n array = new T[n];\n }\n static void fill(T[] array, T value)\n {\n for (int i = 0; i < array.Length; i++)\n array[i] = value;\n }\n static void fill(T[][] array, T value)\n {\n for (int i = 0; i < array.Length; i++)\n for (int j = 0; j < array[i].Length; j++)\n array[i][j] = value;\n }\n public bool NextPermutation(T[] b, Comparison ic)\n {\n for (int j = b.Length - 2; j >= 0; j--)\n {\n if (ic(b[j], b[j + 1]) < 0)\n {\n for (int l = b.Length - 1; l >= 0; l--)\n {\n if (ic(b[l], b[j]) > 0)\n {\n Swap(b, j, l);\n Array.Reverse(b, j + 1, b.Length - (j + 1));\n return true;\n }\n }\n }\n }\n return false;\n }\n int[,] step8 = new int[,]\n {\n {-1,0 },\n {1,0 },\n {0,-1 },\n {0,1 },\n {1,1 },\n {-1,1 },\n {-1,-1 },\n {1,-1 },\n };\n int[,] step4 = new int[,]\n {\n {-1,0 },\n {1,0 },\n {0,-1 },\n {0,1 },\n };\n struct Vector2\n {\n public double x;\n public double y;\n public Vector2(double x, double y)\n {\n this.x = x;\n this.y = y;\n }\n public double Dist(Vector2 to)\n {\n return Math.Sqrt(Math.Abs(Math.Pow(to.x - x, 2)) + Math.Abs(Math.Pow(to.y - y, 2)));\n }\n public static bool operator ==(Vector2 left, Vector2 right) { return left.x == right.x && left.y == right.y; }\n public static bool operator !=(Vector2 left, Vector2 right) { return left.x != right.x || left.y != right.y; }\n }\n #endregion\n #endregion\n\n}", "lang_cluster": "C#", "tags": ["constructive algorithms", "binary search", "implementation", "bitmasks"], "code_uid": "0ed38ba704728a912f11916f3ae8b48d", "src_uid": "0af400ea8e25b1a36adec4cc08912b71", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": ".NET Core C#", "source_code": "using System;\nusing System.Linq;\t\t\t\t\t\npublic class Program\n{\n\tpublic static void Main()\n\t{\n\t\tstring word = Console.ReadLine();\n\t\tint lengthOfWord = word.Count();\n\t\tint upperCount = 0;\n\t\tforeach(char c in word){\n\t\t\tif(Char.IsUpper(c)){\n\t\t\t\tupperCount+=1;\n\t\t\t}\n\t\t}\n\t\tif((upperCount > lengthOfWord-upperCount)){\n\t\t\tConsole.WriteLine(word.ToUpper());\n\t\t}else{\n\t\t\tConsole.WriteLine(word.ToLower());\n\t\t}\n\t\t\n\t}\n}", "lang_cluster": "C#", "tags": ["strings", "implementation"], "code_uid": "c8ce81bc29bbec6aeb3c39b76da75d57", "src_uid": "b432dfa66bae2b542342f0b42c0a2598", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections;\nusing System.Collections.Generic;\nusing System.Dynamic;\nusing System.Linq;\n\nnamespace URI_practice\n{\n public class Program\n {\n static void Main(string[] args)\n {\n String str = Console.ReadLine();\n int upper = 0, lower = 0;\n \n\n for (int i = 0; i < str.Length; i++)\n {\n char ch = str[i];\n if (ch >= 'A' && ch <= 'Z')\n upper++;\n else if (ch >= 'a' && ch <= 'z')\n lower++;\n \n }\n if (lower >= upper)\n {\n Console.WriteLine(str.ToLower());\n }\n else\n {\n Console.WriteLine(str.ToUpper());\n }\n }\n\n \n }\n \n}\n", "lang_cluster": "C#", "tags": ["strings", "implementation"], "code_uid": "bb06267d85b4607d1974705accb2bec8", "src_uid": "b432dfa66bae2b542342f0b42c0a2598", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Linq;\n\nnamespace Minimum_Binary_Number\n{\n class Program\n {\n static void Main(string[] args)\n {\n int n = int.Parse(Console.ReadLine());\n string characters = Console.ReadLine();\n int zeroCount = characters.Count(x => x == '0');\n if (!characters.Contains('1')) Console.WriteLine(characters);\n else\n {\n Console.Write(\"1\");\n for (int i = 0; i < zeroCount; i++) Console.Write(\"0\");\n }\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "71bd0295cdf0fe631d356ac76176fb39", "src_uid": "ac244791f8b648d672ed3de32ce0074d", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.IO;\nusing System.Threading;\nusing System.Runtime.CompilerServices;\nusing System.Text;\nusing System.Diagnostics;\nusing System.Numerics;\nusing static System.Console;\nusing static System.Convert;\nusing static System.Math;\nusing static Template;\nusing Pi = Pair;\n\nclass Solver\n{\n public Scanner sc;\n public void Solve()\n {\n var N = sc.Int;\n var S = sc.Str.ToCharArray();\n if (N == 1) Fail(new string(S));\n var ct = 0;\n var res = new List() { 1 };\n for (int i = 1; i < N; i++)\n {\n if (S[i] == '1') ct++;\n }\n for (int k = 0; k < N - 1 - ct; k++) res.Add(0);\n Console.WriteLine(string.Join(\"\", res));\n }\n}\n\n#region Template\npublic static class Template\n{\n static void Main(string[] args)\n {\n Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });\n var sol = new Solver() { sc = new Scanner() };\n //var th = new Thread(sol.Solve, 1 << 26);th.Start();th.Join();\n sol.Solve();\n Console.Out.Flush();\n }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static bool chmin(ref T a, T b) where T : IComparable { if (a.CompareTo(b) > 0) { a = b; return true; } return false; }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static bool chmax(ref T a, T b) where T : IComparable { if (a.CompareTo(b) < 0) { a = b; return true; } return false; }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static void swap(ref T a, ref T b) { var t = b; b = a; a = t; }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static void swap(this IList A, int i, int j) { var t = A[i]; A[i] = A[j]; A[j] = t; }\n public static T[] Create(int n, Func f) { var rt = new T[n]; for (var i = 0; i < rt.Length; ++i) rt[i] = f(); return rt; }\n public static T[] Create(int n, Func f) { var rt = new T[n]; for (var i = 0; i < rt.Length; ++i) rt[i] = f(i); return rt; }\n public static IEnumerable Shuffle(this IEnumerable A) => A.OrderBy(v => Guid.NewGuid());\n public static int CompareTo(this T[] A, T[] B, Comparison cmp = null) { cmp = cmp ?? Comparer.Default.Compare; for (var i = 0; i < Min(A.Length, B.Length); i++) { int c = cmp(A[i], B[i]); if (c > 0) return 1; else if (c < 0) return -1; } if (A.Length == B.Length) return 0; if (A.Length > B.Length) return 1; else return -1; }\n public static int MaxElement(this IList A, Comparison cmp = null) { cmp = cmp ?? Comparer.Default.Compare; T max = A[0]; int rt = 0; for (int i = 1; i < A.Count; i++) if (cmp(max, A[i]) < 0) { max = A[i]; rt = i; } return rt; }\n public static T PopBack(this List A) { var v = A[A.Count - 1]; A.RemoveAt(A.Count - 1); return v; }\n public static void Fail(T s) { Console.WriteLine(s); Console.Out.Close(); Environment.Exit(0); }\n}\npublic class Scanner\n{\n public string Str => Console.ReadLine().Trim();\n public int Int => int.Parse(Str);\n public long Long => long.Parse(Str);\n public double Double => double.Parse(Str);\n public int[] ArrInt => Str.Split(' ').Select(int.Parse).ToArray();\n public long[] ArrLong => Str.Split(' ').Select(long.Parse).ToArray();\n public char[][] Grid(int n) => Create(n, () => Str.ToCharArray());\n public int[] ArrInt1D(int n) => Create(n, () => Int);\n public long[] ArrLong1D(int n) => Create(n, () => Long);\n public int[][] ArrInt2D(int n) => Create(n, () => ArrInt);\n public long[][] ArrLong2D(int n) => Create(n, () => ArrLong);\n private Queue q = new Queue();\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public T Next() { if (q.Count == 0) foreach (var item in Str.Split(' ')) q.Enqueue(item); return (T)Convert.ChangeType(q.Dequeue(), typeof(T)); }\n public void Make(out T1 v1) => v1 = Next();\n public void Make(out T1 v1, out T2 v2) { v1 = Next(); v2 = Next(); }\n public void Make(out T1 v1, out T2 v2, out T3 v3) { Make(out v1, out v2); v3 = Next(); }\n public void Make(out T1 v1, out T2 v2, out T3 v3, out T4 v4) { Make(out v1, out v2, out v3); v4 = Next(); }\n public void Make(out T1 v1, out T2 v2, out T3 v3, out T4 v4, out T5 v5) { Make(out v1, out v2, out v3, out v4); v5 = Next(); }\n public void Make(out T1 v1, out T2 v2, out T3 v3, out T4 v4, out T5 v5, out T6 v6) { Make(out v1, out v2, out v3, out v4, out v5); v6 = Next(); }\n public void Make(out T1 v1, out T2 v2, out T3 v3, out T4 v4, out T5 v5, out T6 v6, out T7 v7) { Make(out v1, out v2, out v3, out v4, out v5, out v6); v7 = Next(); }\n //public (T1, T2) Make() { Make(out T1 v1, out T2 v2); return (v1, v2); }\n //public (T1, T2, T3) Make() { Make(out T1 v1, out T2 v2, out T3 v3); return (v1, v2, v3); }\n //public (T1, T2, T3, T4) Make() { Make(out T1 v1, out T2 v2, out T3 v3, out T4 v4); return (v1, v2, v3, v4); }\n}\npublic class Pair : IComparable>\n{\n public T1 v1;\n public T2 v2;\n public Pair() { }\n public Pair(T1 v1, T2 v2)\n { this.v1 = v1; this.v2 = v2; }\n\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public int CompareTo(Pair p)\n {\n var c = Comparer.Default.Compare(v1, p.v1);\n if (c == 0)\n c = Comparer.Default.Compare(v2, p.v2);\n return c;\n }\n public override string ToString() => $\"{v1.ToString()} {v2.ToString()}\";\n public void Deconstruct(out T1 a, out T2 b) { a = v1; b = v2; }\n}\n\npublic class Pair : Pair, IComparable>\n{\n public T3 v3;\n public Pair() : base() { }\n public Pair(T1 v1, T2 v2, T3 v3) : base(v1, v2)\n { this.v3 = v3; }\n\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public int CompareTo(Pair p)\n {\n var c = base.CompareTo(p);\n if (c == 0)\n c = Comparer.Default.Compare(v3, p.v3);\n return c;\n }\n public override string ToString() => $\"{base.ToString()} {v3.ToString()}\";\n public void Deconstruct(out T1 a, out T2 b, out T3 c) { Deconstruct(out a, out b); c = v3; }\n}\n#endregion", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "53b9153d477b30ee4e608c6b9537a76f", "src_uid": "ac244791f8b648d672ed3de32ce0074d", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace Problem\n{\n class Program\n {\n static void Main(string[] args)\n {\n Console.ReadLine();\n List nums = Console.ReadLine().Split(' ').Select(long.Parse).Distinct().ToList();\n int result = 0;\n while (nums.Count > 0)\n {\n long min = nums.Min();\n nums = nums.Where(n => n % min != 0).ToList();\n result++;\n }\n\n Console.WriteLine(result);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "greedy", "implementation"], "code_uid": "397158fb56c8ec7132eea98832998b64", "src_uid": "63d9b7416aa96129c57d20ec6145e0cd", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "/*\ncsc -debug A.cs && mono --debug A.exe <<< \"6\n10 2 3 5 4 2\"\n*/\n\nusing System;\nusing System.Collections;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading;\nusing System.Reflection;\n\npublic class HelloWorld {\n public static void SolveCodeForces() {\n var n = cin.NI();\n var A = cin.NIA();\n\n var ans = 0;\n\n while (A.Length > 0) {\n ans++;\n var min = A.Min();\n A = A.Where(a => a % min != 0).ToArray();\n }\n\n System.Console.WriteLine(ans);\n }\n\n static Scanner cin = new Scanner();\n static StringBuilder cout = new StringBuilder();\n\n static public void Main () {\n SolveCodeForces();\n // IncreaseStack(SolveCodeForces);\n // System.Console.Write(cout.ToString());\n }\n\n public static void IncreaseStack(ThreadStart action, int stackSize = 128000000)\n {\n var thread = new Thread(action, stackSize);\n thread.Start();\n thread.Join();\n }\n}\n\npublic static class Helpers {\n public static string Join(this IEnumerable arr, string sep = \" \") {\n return string.Join(sep, arr);\n }\n\n public static void Swap(ref T a, ref T b) {\n var tmp = a;\n a = b;\n b = tmp;\n }\n\n public static T[] CreateArray(int length, Func itemCreate) {\n var result = new T[length];\n for (var i = 0; i < result.Length; i++)\n result[i] = itemCreate(i);\n return result;\n }\n}\n\npublic class Scanner\n{\n private string[] line = new string[0];\n private int index = 0;\n\n public string Next() {\n if (line.Length <= index) {\n line = Console.ReadLine().Split(' ');\n index = 0;\n }\n var res = line[index];\n index++;\n return res;\n }\n\n public int NI() {\n return int.Parse(Next());\n }\n\n public long NL() {\n return long.Parse(Next());\n }\n\n public ulong NUL() {\n return ulong.Parse(Next());\n }\n\n public string[] Array() {\n line = Console.ReadLine().Split(' ');\n index = line.Length;\n return line;\n }\n\n public int[] NIA(int emptyPrefixLen = 0) {\n var array = Array();\n var result = new int[emptyPrefixLen + array.Length];\n for (int i = 0; i < array.Length; i++)\n result[emptyPrefixLen + i] = int.Parse(array[i]);\n return result;\n }\n\n public long[] NLA() {\n var array = Array();\n var result = new long[array.Length];\n for (int i = 0; i < array.Length; i++)\n result[i] = long.Parse(array[i]);\n return result;\n }\n\n public ulong[] NULA() {\n var array = Array();\n var result = new ulong[array.Length];\n for (int i = 0; i < array.Length; i++)\n result[i] = ulong.Parse(array[i]);\n return result;\n }\n}", "lang_cluster": "C#", "tags": ["math", "greedy", "implementation"], "code_uid": "9eb38db38598f3f017c7b57b938b44fc", "src_uid": "63d9b7416aa96129c57d20ec6145e0cd", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeff\ufeffusing System;\nusing System.Collections.Generic;\nusing System.IO;\nusing System.Text;\nusing System.Linq;\n\nclass Program\n{\n private static long[] pow2 = new long[64];\n private static int Iterate(long a, long b, int size)\n {\n long mask = pow2[size] - 1;\n\n int ans = 0;\n for(int i=0;i[] ReadGraph(int n, int m)\n {\n List[] g = new List[n + 1];\n for (int i = 0; i <= n; i++) g[i] = new List();\n for (int i = 0; i < m; i++)\n {\n int a = ReadInt();\n int b = ReadInt();\n g[a].Add(b);\n g[b].Add(a);\n }\n\n return g;\n }\n\n private static int[,] ReadGraphAsMatrix(int n, int m)\n {\n int[,] matrix = new int[n + 1, n + 1];\n for (int i = 0; i < m; i++)\n {\n int a = ReadInt();\n int b = ReadInt();\n matrix[a, b] = matrix[b, a] = 1;\n }\n\n return matrix;\n }\n\n private static void Sort(ref int a, ref int b)\n {\n if (a > b) Swap(ref a, ref b);\n }\n\n private static void Swap(ref int a, ref int b)\n {\n int tmp = a;\n a = b;\n b = tmp;\n }\n\n private const int BufferSize = 1 << 16;\n private static readonly StreamReader consoleReader = new StreamReader(Console.OpenStandardInput(BufferSize), Encoding.ASCII, false, BufferSize);\n\n private static int ReadInt()\n {\n int ans = 0;\n int mul = 1;\n do\n {\n ans = consoleReader.Read();\n if (ans == -1)\n return 0;\n if (ans == '-') mul = -1;\n } while (ans < '0' || ans > '9');\n\n ans -= '0';\n while (true)\n {\n int chr = consoleReader.Read();\n if (chr < '0' || chr > '9')\n return ans * mul;\n ans = ans * 10 + chr - '0';\n }\n }\n\n private static ulong ReadULong()\n {\n ulong ans = 0;\n int chr;\n do\n {\n chr = consoleReader.Read();\n if (chr == -1)\n return 0;\n } while (chr < '0' || chr > '9');\n\n ans = (uint)(chr - '0');\n while (true)\n {\n chr = consoleReader.Read();\n if (chr < '0' || chr > '9')\n return ans;\n ans = ans * 10 + (uint)(chr - '0');\n }\n }\n\n private static long ReadLong()\n {\n long ans = 0;\n int mul = 1;\n do\n {\n ans = consoleReader.Read();\n if (ans == -1)\n return 0;\n if (ans == '-') mul = -1;\n } while (ans < '0' || ans > '9');\n\n ans -= '0';\n while (true)\n {\n int chr = consoleReader.Read();\n if (chr < '0' || chr > '9')\n return ans * mul;\n ans = ans * 10 + chr - '0';\n }\n }\n\n private static int[] ReadIntArray(int n)\n {\n int[] ans = new int[n];\n for (int i = 0; i < n; i++)\n ans[i] = ReadInt();\n return ans;\n }\n\n private static long[] ReadLongArray(int n)\n {\n long[] ans = new long[n];\n for (int i = 0; i < n; i++)\n ans[i] = ReadLong();\n return ans;\n }\n\n private static char[] ReadString()\n {\n int ans;\n\n do\n {\n ans = consoleReader.Read();\n } while (ans < 'a' || ans > 'z');\n\n List s = new List();\n do\n {\n s.Add((char)ans);\n ans = consoleReader.Read();\n } while (ans >= 'a' && ans <= 'z');\n\n return s.ToArray();\n }\n\n private static char[] ReadString(int n)\n {\n int ans;\n\n do\n {\n ans = consoleReader.Read();\n } while (ans < 'a' || ans > 'z');\n\n char[] s = new char[n];\n int pos = 0;\n do\n {\n s[pos++] = (char)ans;\n ans = consoleReader.Read();\n } while (ans >= 'a' && ans <= 'z');\n\n return s;\n }\n\n private static char ReadLetter()\n {\n while (true)\n {\n int ans = consoleReader.Read();\n if ((ans >= 'a' && ans <= 'z') || (ans >= 'A' && ans <= 'Z'))\n return (char)ans;\n }\n }\n\n private static char ReadDigit()\n {\n while (true)\n {\n int ans = consoleReader.Read();\n if (ans >= '0' && ans <= '9')\n return (char)ans;\n }\n }\n\n private static int ReadDigitInt()\n {\n while (true)\n {\n int ans = consoleReader.Read();\n if (ans >= '0' && ans <= '9')\n return (char)ans - (int)'0';\n }\n }\n\n private static char ReadAnyChar()\n {\n return (char)consoleReader.Read();\n }\n}", "lang_cluster": "C#", "tags": ["brute force", "implementation", "bitmasks"], "code_uid": "67fbee22359651370cdc6a6c1d9cb92e", "src_uid": "581f61b1f50313bf4c75833cefd4d022", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Linq;\n\nnamespace CSharp\n{\n public class _611B\n {\n public static void Main()\n {\n string[] tokens = Console.ReadLine().Split();\n\n long a = long.Parse(tokens[0]);\n long b = long.Parse(tokens[1]);\n\n int count = 0;\n\n for (int length = 1; length < 64; length++)\n {\n for (int i = length == 1 ? 0 : 1; i < length; i++)\n {\n char[] chars = Enumerable.Repeat('1', length).ToArray();\n chars[i] = '0';\n\n long n = Convert.ToInt64(new string(chars), 2);\n if (a <= n && n <= b)\n {\n count++;\n }\n }\n }\n\n Console.WriteLine(count);\n }\n }\n}", "lang_cluster": "C#", "tags": ["brute force", "implementation", "bitmasks"], "code_uid": "7e64edc9652e57e78cdcf85f0d0792da", "src_uid": "581f61b1f50313bf4c75833cefd4d022", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "#define Online\nusing System;\nusing System.Collections.Generic;\nusing System.Diagnostics;\nusing System.Text;\nusing System.IO;\n\nnamespace CF\n{\n\tdelegate double F (double x);\n\n\tdelegate decimal Fdec (decimal x);\n\n\tpartial class Program\n\t{\n\n\t\tstatic void Main (string[] args)\n\t\t{\n\n#if FileIO\n\t\t\tStreamReader sr = new StreamReader (\"mountains.in\");\n\t\t\tStreamWriter sw = new StreamWriter (\"mountains.out\");\n\t\t\tConsole.SetIn (sr);\n\t\t\tConsole.SetOut (sw);\n#endif\n\n\n\t\t\tA ();\n\n#if Online\n\t\t\tConsole.ReadLine ();\n#endif\n\n#if FileIO\n\t\t\tsr.Close ();\n\t\t\tsw.Close ();\n#endif\n\t\t}\n\n\t\tstatic void A ()\n\t\t{\n\t\t\tint n = ReadInt ();\n\t\t\tdo {\n\t\t\t\tint c = n % 10;\n\t\t\t\tif (c >= 5) {\n\t\t\t\t\tConsole.Write (\"-O|\");\n\t\t\t\t\tc -= 5;\n\t\t\t\t} else {\n\t\t\t\t\tConsole.Write (\"O-|\");\n\t\t\t\t}\n\t\t\t\tfor (int j=0; j<5; j++,c--) {\n\t\t\t\t\tif (c > 0)\n\t\t\t\t\t\tConsole.Write (\"O\");\n\t\t\t\t\telse {\n\t\t\t\t\t\tif (c == 0)\n\t\t\t\t\t\t\tConsole.Write (\"-\");\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\tConsole.Write (\"O\");\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tn /= 10;\n\t\t\t\tConsole.WriteLine ();\n\t\t\t} while(n!=0);\n\t\t}\n\n\t\tstatic void B ()\n\t\t{\n\n\t\t}\n\n\t\tstatic void C ()\n\t\t{\n\n\t\t}\n\n\t\tstatic void D ()\n\t\t{\n\n\t\t}\n\n\t\tstatic void E ()\n\t\t{\n\n\t\t}\n\n\t\tstatic void TestGen ()\n\t\t{\n\n\t\t}\n\n\t}\n\n\tpublic static class MyMath\n\t{\n\t\tpublic static long BinPow (long a, long n, long mod)\n\t\t{\n\t\t\tlong res = 1;\n\t\t\twhile (n > 0) {\n\t\t\t\tif ((n & 1) == 1) {\n\t\t\t\t\tres = (res * a) % mod;\n\t\t\t\t}\n\t\t\t\ta = (a * a) % mod;\n\t\t\t\tn >>= 1;\n\t\t\t}\n\t\t\treturn res;\n\t\t}\n\n\t\tpublic static long GCD (long a, long b)\n\t\t{\n\t\t\twhile (b != 0)\n\t\t\t\tb = a % (a = b);\n\t\t\treturn a;\n\t\t}\n\n\t\tpublic static int GCD (int a, int b)\n\t\t{\n\t\t\twhile (b != 0)\n\t\t\t\tb = a % (a = b);\n\t\t\treturn a;\n\t\t}\n\n\t\tpublic static long LCM (long a, long b)\n\t\t{\n\t\t\treturn (a * b) / GCD (a, b);\n\t\t}\n\n\t\tpublic static int LCM (int a, int b)\n\t\t{\n\t\t\treturn (a * b) / GCD (a, b);\n\t\t}\n\t}\n\n\tstatic class ArrayUtils\n\t{\n\t\tpublic static int BinarySearch (int[] a, int val)\n\t\t{\n\t\t\tint left = 0;\n\t\t\tint right = a.Length - 1;\n\t\t\tint mid;\n\n\t\t\twhile (left < right) {\n\t\t\t\tmid = left + ((right - left) >> 1);\n\t\t\t\tif (val <= a [mid]) {\n\t\t\t\t\tright = mid;\n\t\t\t\t} else {\n\t\t\t\t\tleft = mid + 1;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (a [left] == val)\n\t\t\t\treturn left;\n\t\t\telse\n\t\t\t\treturn -1;\n\t\t}\n\n\t\tpublic static double Bisection (F f, double left, double right, double eps)\n\t\t{\n\t\t\tdouble mid;\n\t\t\twhile (right - left > eps) {\n\t\t\t\tmid = left + ((right - left) / 2d);\n\t\t\t\tif (Math.Sign (f (mid)) != Math.Sign (f (left)))\n\t\t\t\t\tright = mid;\n\t\t\t\telse\n\t\t\t\t\tleft = mid;\n\t\t\t}\n\t\t\treturn (left + right) / 2d;\n\t\t}\n\n\t\tpublic static decimal TernarySearchDec (Fdec f, decimal eps, decimal l, decimal r, bool isMax)\n\t\t{\n\t\t\tdecimal m1, m2;\n\t\t\twhile (r - l > eps) {\n\t\t\t\tm1 = l + (r - l) / 3m;\n\t\t\t\tm2 = r - (r - l) / 3m;\n\t\t\t\tif (f (m1) < f (m2))\n\t\t\t\tif (isMax)\n\t\t\t\t\tl = m1;\n\t\t\t\telse\n\t\t\t\t\tr = m2;\n\t\t\t\telse\n if (isMax)\n\t\t\t\t\tr = m2;\n\t\t\t\telse\n\t\t\t\t\tl = m1;\n\t\t\t}\n\t\t\treturn r;\n\t\t}\n\n\t\tpublic static double TernarySearch (F f, double eps, double l, double r, bool isMax)\n\t\t{\n\t\t\tdouble m1, m2;\n\t\t\twhile (r - l > eps) {\n\t\t\t\tm1 = l + (r - l) / 3d;\n\t\t\t\tm2 = r - (r - l) / 3d;\n\t\t\t\tif (f (m1) < f (m2))\n\t\t\t\tif (isMax)\n\t\t\t\t\tl = m1;\n\t\t\t\telse\n\t\t\t\t\tr = m2;\n\t\t\t\telse\n if (isMax)\n\t\t\t\t\tr = m2;\n\t\t\t\telse\n\t\t\t\t\tl = m1;\n\t\t\t}\n\t\t\treturn r;\n\t\t}\n\n\t\tpublic static void Merge (T[] A, int p, int q, int r, T[] L, T[] R, Comparison comp)\n\t\t{\n\t\t\tfor (int i = p; i <= q; i++)\n\t\t\t\tL [i] = A [i];\n\t\t\tfor (int i = q + 1; i <= r; i++)\n\t\t\t\tR [i] = A [i];\n\n\t\t\tfor (int k = p, i = p, j = q + 1; k <= r; k++) {\n\t\t\t\tif (i > q) {\n\t\t\t\t\tfor (; k <= r; k++, j++)\n\t\t\t\t\t\tA [k] = R [j];\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif (j > r) {\n\t\t\t\t\tfor (; k <= r; k++, i++)\n\t\t\t\t\t\tA [k] = L [i];\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif (comp (L [i], R [j]) <= 0) {\n\t\t\t\t\tA [k] = L [i];\n\t\t\t\t\ti++;\n\t\t\t\t} else {\n\t\t\t\t\tA [k] = R [j];\n\t\t\t\t\tj++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tpublic static void Merge_Sort (T[] A, int p, int r, T[] L, T[] R, Comparison comp)\n\t\t{\n\t\t\tif (p >= r)\n\t\t\t\treturn;\n\t\t\tint q = p + ((r - p) >> 1);\n\t\t\tMerge_Sort (A, p, q, L, R, comp);\n\t\t\tMerge_Sort (A, q + 1, r, L, R, comp);\n\t\t\tMerge (A, p, q, r, L, R, comp);\n\t\t}\n\n\t\tpublic static void Merge (T[] A, int p, int q, int r, T[] L, T[] R) where T : IComparable\n\t\t{\n\t\t\tfor (int i = p; i <= q; i++)\n\t\t\t\tL [i] = A [i];\n\t\t\tfor (int i = q + 1; i <= r; i++)\n\t\t\t\tR [i] = A [i];\n\n\t\t\tfor (int k = p, i = p, j = q + 1; k <= r; k++) {\n\t\t\t\tif (i > q) {\n\t\t\t\t\tfor (; k <= r; k++, j++)\n\t\t\t\t\t\tA [k] = R [j];\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif (j > r) {\n\t\t\t\t\tfor (; k <= r; k++, i++)\n\t\t\t\t\t\tA [k] = L [i];\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif (L [i].CompareTo (R [j]) <= 0) {\n\t\t\t\t\tA [k] = L [i];\n\t\t\t\t\ti++;\n\t\t\t\t} else {\n\t\t\t\t\tA [k] = R [j];\n\t\t\t\t\tj++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tpublic static void Merge_Sort (T[] A, int p, int r, T[] L, T[] R) where T : IComparable\n\t\t{\n\t\t\tif (p >= r)\n\t\t\t\treturn;\n\t\t\tint q = p + ((r - p) >> 1);\n\t\t\tMerge_Sort (A, p, q, L, R);\n\t\t\tMerge_Sort (A, q + 1, r, L, R);\n\t\t\tMerge (A, p, q, r, L, R);\n\t\t}\n\n\t\tpublic static void Merge_Sort1 (T[] A, int p, int r, T[] L, T[] R) where T : IComparable\n\t\t{\n\t\t\tint k = 1;\n\t\t\twhile (k < r - p + 1) {\n\t\t\t\tint i = 0;\n\t\t\t\twhile (i < r) {\n\t\t\t\t\tint _r = Math.Min (i + 2 * k - 1, r);\n\t\t\t\t\tint q = Math.Min (i + k - 1, r);\n\t\t\t\t\tMerge (A, i, q, _r, L, R);\n\t\t\t\t\ti += 2 * k;\n\t\t\t\t}\n\t\t\t\tk <<= 1;\n\t\t\t}\n\t\t}\n\n\t\tpublic static void Merge_Sort1 (T[] A, int p, int r, T[] L, T[] R, Comparison comp)\n\t\t{\n\t\t\tint k = 1;\n\t\t\twhile (k < r - p + 1) {\n\t\t\t\tint i = 0;\n\t\t\t\twhile (i < r) {\n\t\t\t\t\tint _r = Math.Min (i + 2 * k - 1, r);\n\t\t\t\t\tint q = Math.Min (i + k - 1, r);\n\t\t\t\t\tMerge (A, i, q, _r, L, R, comp);\n\t\t\t\t\ti += 2 * k;\n\t\t\t\t}\n\t\t\t\tk <<= 1;\n\t\t\t}\n\t\t}\n\n\t\tstatic void Shake (T[] a)\n\t\t{\n\t\t\tRandom rnd = new Random (Environment.TickCount);\n\t\t\tT temp;\n\t\t\tint b;\n\t\t\tfor (int i = 0; i < a.Length; i++) {\n\t\t\t\tb = rnd.Next (i, a.Length);\n\t\t\t\ttemp = a [b];\n\t\t\t\ta [b] = a [i];\n\t\t\t\ta [i] = temp;\n\t\t\t}\n\t\t}\n\n\t\tstatic void Swap (T[] a, int l, int r)\n\t\t{\n\t\t\tT t = a [l];\n\t\t\ta [l] = a [r];\n\t\t\ta [r] = t;\n\t\t}\n\n\t\tstatic bool NextPermutation (int[] a)\n\t\t{\n\t\t\tbool isOkay = false;\n\t\t\tint n = a.Length;\n\t\t\tfor (int i=n-2; i>=0; i--) {\n\t\t\t\tif (a [i] < a [i + 1]) {\n\t\t\t\t\tisOkay = true;\n\t\t\t\t\tint j = i + 1;\n\t\t\t\t\twhile (j+1a[i]) {\n\t\t\t\t\t\tj++;\n\t\t\t\t\t}\n\t\t\t\t\tSwap (a, i, j);\n\t\t\t\t\tfor (j=1; i+j int.Parse(x)).ToArray();\n }\n\n static void PrintLn(object obj)\n {\n Console.WriteLine(obj.ToString());\n }\n\n public static string Reverse(string s)\n {\n char[] charArray = s.ToCharArray();\n Array.Reverse(charArray);\n return new string(charArray);\n }\n\n\n public static void PrintLnCollection(IEnumerable col)\n {\n PrintLn(string.Join(\" \",col));\n }\n\n public static string ReadLine()\n {\n return Console.ReadLine();\n }\n\n\n public static string MySubstring(this string str, int start, int finish)\n {\n return str.Substring(start, finish - start + 1);\n }\n\n\n public static bool IsInRange(this int a, int lb, int ub)\n {\n return (a>=lb) && (a<=ub);\n }\n\n//----------------------------------------------------------------------------\n\n\n static string getDigit(int n)\n {\n if (n == 0)\n return \"O-|-OOOO\";\n if (n == 1)\n return \"O-|O-OOO\";\n if (n == 2)\n return \"O-|OO-OO\";\n if (n == 3)\n return \"O-|OOO-O\";\n if (n == 4)\n return \"O-|OOOO-\";\n if (n == 5)\n return \"-O|-OOOO\";\n if (n == 6)\n return \"-O|O-OOO\";\n if (n == 7)\n return \"-O|OO-OO\";\n if (n == 8)\n return \"-O|OOO-O\";\n if (n == 9)\n return \"-O|OOOO-\";\n return \"\";\n\n\n }\n\n\n static void Main(string[] args)\n {\n int n = ReadIntLine();\n\n do\n {\n PrintLn(getDigit(n % 10));\n n = n / 10;\n } while (n > 0);\n\n\n }\n \n\n }\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "451f16671b1116dcea8017fa7b91c3c2", "src_uid": "c2e3aced0bc76b6484360563355d23a7", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\n\nnamespace Lift_Ladder\n{\n class Program\n {\n static void Main(string[] args)\n {\n string input = Console.ReadLine();\n string[] splitted = input.Split(' ');\n\n int x = Convert.ToInt32(splitted[0]); //\u043d\u043e\u043c\u0435\u0440 \u044d\u0442\u0430\u0436\u0430, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u041c\u0430\u0448\u0430\n int y = Convert.ToInt32(splitted[1]); //\u043d\u043e\u043c\u0435\u0440 \u044d\u0442\u0430\u0436\u0430, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0445\u043e\u0447\u0435\u0442 \u043f\u043e\u043f\u0430\u0441\u0442\u044c \u041c\u0430\u0448\u0430\n int z = Convert.ToInt32(splitted[2]); //\u043d\u043e\u043c\u0435\u0440 \u044d\u0442\u0430\u0436\u0430, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u043b\u0438\u0444\u0442\n int t1 = Convert.ToInt32(splitted[3]); //\u0432\u0440\u0435\u043c\u044f, \u0437\u0430 \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u041c\u0430\u0448\u0430 \u043f\u0440\u043e\u0445\u043e\u0434\u0438\u0442 \u043c\u0435\u0436\u0434\u0443 \u0441\u043e\u0441\u0435\u0434\u043d\u0438\u043c\u0438 \u044d\u0442\u0430\u0436\u0430\u043c\u0438 \u043f\u043e \u043b\u0435\u0441\u0442\u043d\u0438\u0446\u0435\n int t2 = Convert.ToInt32(splitted[4]); //\u0432\u0440\u0435\u043c\u044f, \u0437\u0430 \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043b\u0438\u0444\u0442 \u043f\u0440\u043e\u0435\u0437\u0436\u0430\u0435\u0442 \u043c\u0435\u0436\u0434\u0443 \u044d\u0442\u0430\u0436\u0430\u043c\u0438\n int t3 = Convert.ToInt32(splitted[5]); //\u0432\u0440\u0435\u043c\u044f, \u0437\u0430 \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043e\u0442\u043a\u0440\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u0438 \u0437\u0430\u043a\u0440\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u0434\u0432\u0435\u0440\u0438 \u0443 \u043b\u0438\u0444\u0442\u0430\n\n int LiftUsingTime = (Math.Abs(x - z) + Math.Abs(x - y)) * t2 + (t3 * 3);\n int LadderUsingTime = Math.Abs(x - y) * t1;\n\n if (LiftUsingTime <= LadderUsingTime)\n {\n Console.WriteLine(\"YES\");\n } \n else\n {\n Console.WriteLine(\"NO\");\n }\n }\n }\n}", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "1fd50f4823cf09f6da065e6c96e38293", "src_uid": "05cffd59b28b9e026ca3203718b2e6ca", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Text.RegularExpressions;\nusing System.Threading.Tasks;\n\nnamespace Ser\n{\n class Program\n {\n static void Main(string[] args)\n {\n int[] arr = Console.ReadLine().Split().Select(int.Parse).ToArray();\n int x = arr[0], y = arr[1], z = arr[2], t1 = arr[3], t2 = arr[4], t3 = arr[5];\n int pesh = Math.Abs(x - y) * t1;\n int lift = Math.Abs(x - z) * t2 + Math.Abs(x - y) * t2 + 3 * t3;\n Console.WriteLine((pesh < lift)?\"NO\":\"YES\");\n\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "a22ed12cfa38ca6ca75e08177ac20b33", "src_uid": "05cffd59b28b9e026ca3203718b2e6ca", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Globalization;\nusing System.IO;\nusing System.Linq;\nusing System.Numerics;\nusing System.Text;\n\n// (\u3065\u00b0\u03c9\u00b0)\u3065\uff90\u2605\u309c\u30fb\u3002\u3002\u30fb\u309c\u309c\u30fb\u3002\u3002\u30fb\u309c\u2606\u309c\u30fb\u3002\u3002\u30fb\u309c\u309c\u30fb\u3002\u3002\u30fb\u309c\npublic class Solver\n{\n public object Solve()\n {\n int c1 = ReadInt();\n int c2 = ReadInt();\n int x1 = ReadInt();\n int x2 = ReadInt();\n\n long l = 2, r = long.MaxValue;\n while (l < r)\n {\n long m = (l + r) / 2;\n long r0 = m / x1 / x2;\n long r1 = m / x1 - r0;\n long r2 = m / x2 - r0;\n if (m - r0 - r1 - r2 >= Math.Max(c1 - r2, 0) + Math.Max(c2 - r1, 0))\n r = m;\n else\n l = m + 1;\n }\n\n return l;\n\n return null;\n }\n \n #region Main\n\n protected static TextReader reader;\n protected static TextWriter writer;\n\n static void Main()\n {\n#if DEBUG\n reader = new StreamReader(\"..\\\\..\\\\input.txt\");\n writer = Console.Out;\n //writer = new StreamWriter(\"..\\\\..\\\\output.txt\");\n#else\n reader = new StreamReader(Console.OpenStandardInput());\n writer = new StreamWriter(Console.OpenStandardOutput());\n //reader = new StreamReader(\"exchange.in\");\n //writer = new StreamWriter(\"exchange.out\");\n#endif\n try\n {\n object result = new Solver().Solve();\n if (result != null)\n writer.WriteLine(result);\n }\n catch (Exception ex)\n {\n#if DEBUG\n Console.WriteLine(ex);\n#else\n Console.WriteLine(ex);\n throw;\n#endif\n }\n reader.Close();\n writer.Close();\n }\n\n #endregion\n\n #region Read / Write\n\n private static Queue currentLineTokens = new Queue();\n\n private static string[] ReadAndSplitLine()\n {\n return reader.ReadLine().Split(new[] { ' ', '\\t' }, StringSplitOptions.RemoveEmptyEntries);\n }\n\n public static string ReadToken()\n {\n while (currentLineTokens.Count == 0)\n currentLineTokens = new Queue(ReadAndSplitLine());\n return currentLineTokens.Dequeue();\n }\n\n public static int ReadInt()\n {\n return int.Parse(ReadToken());\n }\n\n public static long ReadLong()\n {\n return long.Parse(ReadToken());\n }\n\n public static double ReadDouble()\n {\n return double.Parse(ReadToken(), CultureInfo.InvariantCulture);\n }\n\n public static int[] ReadIntArray()\n {\n return ReadAndSplitLine().Select(int.Parse).ToArray();\n }\n\n public static long[] ReadLongArray()\n {\n return ReadAndSplitLine().Select(long.Parse).ToArray();\n }\n\n public static double[] ReadDoubleArray()\n {\n return ReadAndSplitLine().Select(s => double.Parse(s, CultureInfo.InvariantCulture)).ToArray();\n }\n\n public static int[][] ReadIntMatrix(int numberOfRows)\n {\n int[][] matrix = new int[numberOfRows][];\n for (int i = 0; i < numberOfRows; i++)\n matrix[i] = ReadIntArray();\n return matrix;\n }\n\n public static int[][] ReadAndTransposeIntMatrix(int numberOfRows)\n {\n int[][] matrix = ReadIntMatrix(numberOfRows);\n int[][] ret = new int[matrix[0].Length][];\n for (int i = 0; i < ret.Length; i++)\n {\n ret[i] = new int[numberOfRows];\n for (int j = 0; j < numberOfRows; j++)\n ret[i][j] = matrix[j][i];\n }\n return ret;\n }\n\n public static string[] ReadLines(int quantity)\n {\n string[] lines = new string[quantity];\n for (int i = 0; i < quantity; i++)\n lines[i] = reader.ReadLine().Trim();\n return lines;\n }\n\n public static void WriteArray(IEnumerable array)\n {\n writer.WriteLine(string.Join(\" \", array));\n }\n\n public static void Write(params T[] array)\n {\n WriteArray(array);\n }\n\n public static void WriteLines(IEnumerable array)\n {\n foreach (var a in array)\n writer.WriteLine(a);\n }\n\n #endregion\n}", "lang_cluster": "C#", "tags": ["math", "binary search"], "code_uid": "812a6452fbb88fb2b255593e2de7b6a7", "src_uid": "ff3c39b759a049580a6e96c66c904fdc", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\n\nnamespace Friends_and_Presents\n{\n\n class Program\n {\n static void Main(string[] args)\n {\n string str_Inputs = Console.ReadLine();\n string[] arr_Inputs = str_Inputs.Split(' ');\n long num_Cnt1 = Convert.ToInt32(arr_Inputs[0]);\n long num_Cnt2 = Convert.ToInt32(arr_Inputs[1]);\n long num_X = Convert.ToInt32(arr_Inputs[2]);\n long num_Y = Convert.ToInt32(arr_Inputs[3]);\n long num_Low = 1, num_High = long.MaxValue;\n while (num_Low < num_High)\n {\n long num_Mid = (num_High-num_Low)/2 +num_Low;\n if (num_Cnt1 <= AvailableArray(num_Mid, num_X) && num_Cnt2 <= AvailableArray(num_Mid, num_Y) && num_Cnt1 + num_Cnt2 <= AvailableArray(num_Mid, num_X * num_Y))\n {\n num_High = num_Mid;\n }\n else\n {\n num_Low = num_Mid + 1;\n }\n }\n Console.Write(num_High);\n Console.Read();\n }\n static long AvailableArray(long num_x,long num_y)\n {\n return num_x - num_x / num_y;\n }\n }\n}", "lang_cluster": "C#", "tags": ["math", "binary search"], "code_uid": "797115d706c51f8b4bac7e91660bbcba", "src_uid": "ff3c39b759a049580a6e96c66c904fdc", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Text;\nusing System.Linq;\nusing System.Collections.Generic;\n\nnamespace TmpSharpProj\n{\n class Program\n {\n static void Main()\n {\n Program app = new Program();\n app.Run();\n }\n\n public void Run()\n {\n int n = int.Parse(Console.ReadLine());\n StringBuilder ans = new StringBuilder(Console.ReadLine());\n int off = 0;\n bool b = false;\n do\n {\n b = false;\n for (int i = 0; i + 2 < ans.Length; i++)\n {\n if (ans[i] == 'o' && ans[i + 1] == 'g' && ans[i + 2] == 'o')\n {\n off = i;\n b = true;\n break;\n }\n }\n if (!b)\n break;\n ans[off] = '*';\n ans[off + 1] = '*';\n ans[off + 2] = '*';\n off += 3;\n while (off < ans.Length && off + 1 < ans.Length && ans[off] == 'g' && ans[off + 1] == 'o')\n {\n ans.Remove(off, 2);\n }\n } while (b);\n Console.WriteLine(ans.ToString());\n }\n }\n}", "lang_cluster": "C#", "tags": ["strings", "implementation"], "code_uid": "ecfd590d870aa0f026dca647f36a77f2", "src_uid": "619665bed79ecf77b083251fe6fe7eb3", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Globalization;\nusing System.IO;\nusing System.Linq;\nusing System.Text;\nusing System.Text.RegularExpressions;\n\nnamespace Olymp\n{\n public class ProblemSolver\n {\n public void Solve()\n {\n var n = int.Parse(Console.ReadLine());\n var s = Console.ReadLine();\n Console.WriteLine(Regex.Replace(s, \"ogo(go)*\", \"***\"));\n }\n }\n\n #region Service classes\n\n public class Tokenizer\n {\n private TextReader reader;\n\n public int NextInt()\n {\n return int.Parse(this.NextToken());\n }\n\n public long NextLong()\n {\n return long.Parse(this.NextToken());\n }\n\n public double NextDouble()\n {\n return double.Parse(this.NextToken(), CultureInfo.InvariantCulture);\n }\n\n public int[] ReadIntArray(int n)\n {\n int[] a = new int[n];\n for (int i = 0; i < n; i++)\n a[i] = NextInt();\n return a;\n }\n\n public long[] ReadLongArray(int n)\n {\n long[] a = new long[n];\n for (int i = 0; i < n; i++)\n a[i] = NextLong();\n return a;\n }\n\n public double[] ReadDoubleArray(int n)\n {\n double[] a = new double[n];\n for (int i = 0; i < n; i++)\n a[i] = NextDouble();\n return a;\n }\n\n public string NextToken()\n {\n int c = this.reader.Read();\n if (c == -1)\n return null;\n while (c > 0 && char.IsWhiteSpace((char)c))\n c = this.reader.Read();\n if (c == -1)\n return null;\n var sb = new StringBuilder();\n while (c > 0 && !char.IsWhiteSpace((char)c))\n {\n sb.Append((char)c);\n c = this.reader.Read();\n }\n return sb.ToString();\n }\n\n public Tokenizer()\n : this(Console.In)\n {\n }\n\n public Tokenizer(TextReader reader)\n {\n this.reader = reader;\n }\n }\n\n class Program\n {\n public static void Main(string[] args)\n {\n var solver = new ProblemSolver();\n solver.Solve();\n }\n }\n\n #endregion\n}", "lang_cluster": "C#", "tags": ["strings", "implementation"], "code_uid": "8859e3bc6e2e850a93f3c4651607928b", "src_uid": "619665bed79ecf77b083251fe6fe7eb3", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": ".NET Core C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.IO;\nusing System.Linq;\nusing System.Runtime.CompilerServices;\n\npublic static class Ex\n{\n public static bool IsNullOrEmpty(this string s) { return string.IsNullOrEmpty(s); }\n public static void yesno(this bool b) => Console.WriteLine(b ? \"yes\" : \"no\");\n public static void YesNo(this bool b) => Console.WriteLine(b ? \"Yes\" : \"No\");\n public static void YESNO(this bool b) => Console.WriteLine(b ? \"YES\" : \"NO\");\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n //public static bool Chmax(ref this T a, T b) where T : struct, IComparable\n //{\n // if (b.CompareTo(a) > 0) { a = b; return true; }\n // else return false;\n //}\n //[MethodImpl(MethodImplOptions.AggressiveInlining)]\n //public static bool Chmin(ref this T a, T b) where T : struct, IComparable\n //{\n // if (b.CompareTo(a) < 0) { a = b; return true; }\n // else return false;\n //}\n\n public static List FastSort(this List s) { s.Sort(StringComparer.OrdinalIgnoreCase); return s.ToList(); }\n\n public static int PopCount(this uint bits)\n {\n bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);\n bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);\n bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);\n bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);\n return (int)((bits & 0x0000ffff) + (bits >> 16 & 0x0000ffff));\n }\n}\n\n\n\npartial class Program\n{\n string GetStr() { return Console.ReadLine().Trim(); }\n char GetChar() { return Console.ReadLine().Trim()[0]; }\n int GetInt() { return int.Parse(Console.ReadLine().Trim()); }\n long GetLong() { return long.Parse(Console.ReadLine().Trim()); }\n double GetDouble() { return double.Parse(Console.ReadLine().Trim()); }\n string[] GetStrArray() { return Console.ReadLine().Trim().Split(' '); }\n string[][] GetStrArray(int N)\n {\n var res = new string[N][];\n for (int i = 0; i < N; i++) res[i] = Console.ReadLine().Trim().Split(' ');\n return res;\n }\n int[] GetIntArray() { return Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray(); }\n int[][] GetIntArray(int N)\n {\n var res = new int[N][];\n for (int i = 0; i < N; i++) res[i] = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();\n return res;\n }\n public long[] GetLongArray() { return Console.ReadLine().Trim().Split(' ').Select(long.Parse).ToArray(); }\n long[][] GetLongArray(int N)\n {\n var res = new long[N][];\n for (int i = 0; i < N; i++) res[i] = Console.ReadLine().Trim().Split(' ').Select(long.Parse).ToArray();\n return res;\n }\n char[] GetCharArray() { return Console.ReadLine().Trim().Split(' ').Select(char.Parse).ToArray(); }\n double[] GetDoubleArray() { return Console.ReadLine().Trim().Split(' ').Select(double.Parse).ToArray(); }\n double[][] GetDoubleArray(int N)\n {\n var res = new double[N][];\n for (int i = 0; i < N; i++) res[i] = Console.ReadLine().Trim().Split(' ').Select(double.Parse).ToArray();\n return res;\n }\n char[][] GetGrid(int H)\n {\n var res = new char[H][];\n for (int i = 0; i < H; i++) res[i] = Console.ReadLine().Trim().ToCharArray();\n return res;\n }\n T[] CreateArray(int N, T value)\n {\n var res = new T[N];\n for (int i = 0; i < N; i++) res[i] = value;\n return res;\n }\n T[][] CreateArray(int H, int W, T value)\n {\n var res = new T[H][];\n for (int i = 0; i < H; i++)\n {\n res[i] = new T[W];\n for (int j = 0; j < W; j++) res[i][j] = value;\n }\n return res;\n }\n T[][][] CreateArray(int H, int W, int R, T value)\n {\n var res = new T[H][][];\n for (int i = 0; i < H; i++)\n {\n res[i] = new T[W][];\n for (int j = 0; j < W; j++)\n {\n res[i][j] = new T[R];\n for (int k = 0; k < R; k++) res[i][j][k] = value;\n }\n }\n return res;\n }\n\n Dictionary> GetUnweightedAdjacencyList(int N, int M, bool isDirected, bool isNode_0indexed)\n {\n var dic = new Dictionary>();\n foreach (var e in Enumerable.Range(0, N)) { dic.Add(e, new List()); }\n for (int i = 0; i < M; i++)\n {\n var input = GetIntArray();\n var a = isNode_0indexed ? input[0] : input[0] - 1;\n var b = isNode_0indexed ? input[1] : input[1] - 1;\n dic[a].Add(b);\n if (isDirected == false) dic[b].Add(a);\n }\n return dic;\n }\n //Dictionary> GetWeightedAdjacencyList(int N, int M, bool isDirected, bool isNode_0indexed)\n //{\n // var dic = new Dictionary>();\n // foreach (var e in Enumerable.Range(0, N)) { dic.Add(e, new List<(int, long)>()); }\n // for (int i = 0; i < M; i++)\n // {\n // var input = GetIntArray();\n // var a = isNode_0indexed ? input[0] : input[0] - 1;\n // var b = isNode_0indexed ? input[1] : input[1] - 1;\n // var c = input[2];\n // dic[a].Add((b, c));\n // if (isDirected == false) dic[b].Add((a, c));\n // }\n // return dic;\n //}\n\n bool eq() => typeof(T).Equals(typeof(U));\n T ct(U a) => (T)Convert.ChangeType(a, typeof(T));\n T cv(string s) => eq() ? ct(int.Parse(s))\n : eq() ? ct(long.Parse(s))\n : eq() ? ct(double.Parse(s))\n : eq() ? ct(s[0])\n : ct(s);\n void Multi(out T a) => a = cv(GetStr());\n void Multi(out T a, out U b)\n {\n var ar = GetStrArray(); a = cv(ar[0]); b = cv(ar[1]);\n }\n void Multi(out T a, out U b, out V c)\n {\n var ar = GetStrArray(); a = cv(ar[0]); b = cv(ar[1]); c = cv(ar[2]);\n }\n void Multi(out T a, out U b, out V c, out W d)\n {\n var ar = GetStrArray(); a = cv(ar[0]); b = cv(ar[1]); c = cv(ar[2]); d = cv(ar[3]);\n }\n void Multi(out T a, out U b, out V c, out W d, out X e)\n {\n var ar = GetStrArray(); a = cv(ar[0]); b = cv(ar[1]); c = cv(ar[2]); d = cv(ar[3]); e = cv(ar[4]);\n }\n void Multi(out T a, out U b, out V c, out W d, out X e, out Y f)\n {\n var ar = GetStrArray(); a = cv(ar[0]); b = cv(ar[1]); c = cv(ar[2]); d = cv(ar[3]); e = cv(ar[4]); f = cv(ar[5]);\n }\n\n void Output(T t) => Console.WriteLine(t);\n void Output(IList ls) => Console.WriteLine(string.Join(\" \", ls));\n void Debug(IList> ls)\n {\n foreach (var l in ls)\n foreach (var s in l)\n Console.WriteLine(s);\n }\n\n\n void Swap(ref T a, ref T b) { T temp = a; a = b; b = temp; }\n\n int[] dx = new int[] { 1, 0, -1, 0, 1, -1, -1, 1 };\n int[] dy = new int[] { 0, 1, 0, -1, 1, 1, -1, -1 };\n long mod = 1000000007;\n}\n\n\n\n\n\n\npartial class Program\n{\n static void Main()\n {\n Console.SetIn(new StreamReader(Console.OpenStandardInput(8192)));\n Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });\n new Program().Solve();\n Console.Out.Flush();\n Console.Read();\n }\n\n public void Solve()\n {\n int T = GetInt();\n void so()\n {\n var S = GetStr();\n int cnt = 0;\n for (int j = 1; j <= 9; j++)\n {\n for (int k = 1; k < 5; k++)\n {\n cnt+=k;\n var t = new string(Enumerable.Repeat((char)('0' + j), k).ToArray());\n if (S == t)\n {\n Output(cnt);\n return;\n }\n }\n }\n }\n for(int i = 0; i < T; i++)\n {\n so();\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "implementation"], "code_uid": "9416c37228a401ac7c06841e47f6e90c", "src_uid": "289a55128be89bb86a002d218d31b57f", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\n\nclass Solution {\n\n public static int[] ReadLine()\n {\n return Console.ReadLine().Split(' ').Select(int.Parse).ToArray();\n }\n\n static void Main(string[] args)\n {\n var t = ReadLine()[0];\n\n for (int _ = 1; _ <= t; _++)\n {\n var n = ReadLine()[0];\n\n var total = 0;\n var digits = 1;\n var number = 1;\n var first = 1;\n\n while (number != n)\n {\n total += digits;\n\n digits++;\n if (digits == 5)\n {\n digits = 1;\n number = ++first;\n }\n else\n {\n number = 10 * number + first;\n }\n }\n\n total += digits;\n\n Console.WriteLine(total);\n }\n }\n}", "lang_cluster": "C#", "tags": ["math", "implementation"], "code_uid": "ec5a03ef5de581aab04cdde53084b26a", "src_uid": "289a55128be89bb86a002d218d31b57f", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace ConsoleApplication5\n{\n class Program\n {\n static void Main(string[] args)\n {\n int n_0s=0;\n int n_1s = 0;\n String number;\n number=Console.ReadLine();\n for (int i = 0; i < number.Length; i++)\n {\n if (number[i] == '1')\n {\n n_0s = 0;\n n_1s++;\n for (int j = i + 1; j < number.Length ; j++)\n {\n if (number[j] == '0')\n n_0s++;\n }\n }\n if (n_0s >= 6 && n_1s >= 1)\n {\n Console.WriteLine(\"yes\");\n return;\n }\n \n }\n //Console.WriteLine(\"0=\" + n_0s + \"-- 1=\" + n_1s);\n if (n_0s >= 6 && n_1s >= 1)\n {\n Console.WriteLine(\"yes\");\n }\n else\n {\n Console.WriteLine(\"no\");\n }\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "9234f47716011cd0d4443e5436de7452", "src_uid": "88364b8d71f2ce2b90bdfaa729eb92ca", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace ConsoleApp14\n{\n class Program\n {\n static void Main(string[] args)\n {\n string s = Console.ReadLine();\n int ndx = 0;\n int count = 0;\n for(int i = s.Length-1; i >= 0; i--)\n {\n if(s[i] == '0')\n {\n count++;\n }\n if(count == 6)\n {\n ndx = i;\n break;\n }\n }\n if(count < 6)\n {\n Console.WriteLine(\"no\");\n return;\n }\n for(int i = ndx; i >= 0; i--)\n {\n if(s[i] == '1')\n {\n Console.WriteLine(\"yes\");\n return;\n }\n }\n Console.WriteLine(\"no\");\n Console.ReadLine();\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "95d0d5022c4e2ccb98060a00749d330d", "src_uid": "88364b8d71f2ce2b90bdfaa729eb92ca", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace B.Queue_at_the_School\n{\n class Program\n {\n static void Main(string[] args)\n {\n string input = Console.ReadLine();\n int n = int.Parse(input.Split()[0]);\n int t = int.Parse(input.Split()[1]);\n string queue = Console.ReadLine();\n var que =queue.ToCharArray();\n while (t>0)\n {\n for (int i = 0; i < n-1; i++)\n {\n if (que[i]=='B'&& que[i+1]=='G')\n { que[i] = 'G'; que[i + 1] = 'B'; i++;}\n }\n t--;\n }\n Console.WriteLine(string.Join(\"\",que));\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["constructive algorithms", "implementation", "shortest paths", "graph matchings"], "code_uid": "a5fc57a6beb54908ebba968acff2c225", "src_uid": "964ed316c6e6715120039b0219cc653a", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\n\nnamespace sample\n{\n class Program\n {\n \n \n public static void Main()\n {\n int[] inputs = Array.ConvertAll(Console.ReadLine().Split(' '), num => Convert.ToInt32(num));\n char[] queue = Console.ReadLine().ToCharArray();\n int numbers = inputs[0];\n int times = inputs[1];\n for (int i = 0; i < times; i++)\n {\n for (int j = 0; j < numbers-1; j++)\n {\n if(queue[j]=='B' && queue[j+1]=='G')\n {\n queue[j]='G';\n queue[j+1]='B';\n j++;\n }\n }\n }\n System.Console.WriteLine(new string(queue));\n\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["constructive algorithms", "implementation", "shortest paths", "graph matchings"], "code_uid": "a940895caf074c0cd006076bb7c53901", "src_uid": "964ed316c6e6715120039b0219cc653a", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace ConsoleApp57\n{\n class Program\n {\n static void Main(string[] args)\n {\n int[] inp0 = Console.ReadLine().Split().Select(int.Parse).ToArray();\n int n = inp0[0];\n int t = inp0[1];\n char[] c = Console.ReadLine().ToCharArray();\n for (int i = 0; i < t; i++)\n {\n for (int j = 0; j < n-1; j++)\n {\n if (c[j]=='B'&&c[j+1]=='G')\n {\n c[j] = 'G';\n c[j + 1] = 'B';\n j++;\n }\n }\n }\n foreach (char item in c)\n {\n Console.Write(item);\n }\n\n }\n \n \n }\n}\n", "lang_cluster": "C#", "tags": ["constructive algorithms", "implementation", "shortest paths", "graph matchings"], "code_uid": "ae7487887c32b2a1f5e95e0d6778070c", "src_uid": "964ed316c6e6715120039b0219cc653a", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace ConsoleApp2\n{\n class Solution\n {\n private static IEnumerable ReadData()\n {\n string line;\n while ((line = Console.ReadLine()) != null)\n {\n if (line == \"\")\n break;\n\n yield return line\n .Split(new char[] { ' ', '\\t', }, StringSplitOptions.RemoveEmptyEntries)\n .Select(item => item)\n .ToArray();\n }\n }\n static void Main(string[] args)\n {\n List input = ReadData().ToList();\n int x = int.Parse(input[0][0]);\n int t = int.Parse(input[0][1]);\n\n string[] newArr = new string[input[1][0].Length];\n var newString = input[1][0];\n for (int i = 0; i < input[1][0].Length; i++)\n {\n var c = newString.First();\n newString = newString.Substring(1, newString.Length - 1);\n newArr[i] = c.ToString();\n\n }\n\n while (t != 0)\n {\n for (int i = 0; i < newArr.Length; i++)\n {\n var temp = \"\";\n\n if (!((i + 1) > newArr.Length - 1))\n {\n if (newArr[i] == \"B\" && newArr[i + 1] == \"G\")\n {\n temp = newArr[i];\n newArr[i] = newArr[i + 1];\n newArr[i + 1] = temp;\n i += 1;\n }\n }\n }\n t--;\n }\n \n \n var pom = \"\";\n for (int i = 0; i < newArr.Length; i++)\n pom += newArr[i];\n Console.WriteLine(pom);\n }\n }\n}\n\n", "lang_cluster": "C#", "tags": ["constructive algorithms", "implementation", "shortest paths", "graph matchings"], "code_uid": "6c4e2bf618df57d04c6132f1b546bd0d", "src_uid": "964ed316c6e6715120039b0219cc653a", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace Queue_at_the_School\n{\n class Program\n {\n static void Main(string[] args)\n {\n string[] tokens = Console.ReadLine().Split();\n int n = int.Parse(tokens[0]);\n int t = int.Parse(tokens[1]);\n string a = Console.ReadLine();\n char[] que = a.ToCharArray();\n\n for (int i = 0; i < t; i++)\n {\n for (int j = 1; j < n; j++)\n {\n if (que[j - 1] == 'B' && que[j] == 'G')\n {\n que[j - 1] = 'G';\n que[j] = 'B';\n j++;\n }\n }\n }\n for (int i = 0; i < n; i++)\n Console.Write(que[i]);\n Console.Read();\n\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["constructive algorithms", "implementation", "shortest paths", "graph matchings"], "code_uid": "8bd81cb3b21df8bcacb0054ce3a16336", "src_uid": "964ed316c6e6715120039b0219cc653a", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nnamespace _1A\n{\n class Program\n {\n static void Main(string[] args)\n {\n string[] w = Console.ReadLine().Split(' ');\n int n = int.Parse(w[0]);\n int t = int.Parse(w[1]);\n string s=Console.ReadLine();\n char [] c=s.ToCharArray(0,n);\n for (int i = 1; i <= t; i++)\n {\n for (int k = 0; k < n-1; k++)\n {\n if (c[k] == 'B' && c[k + 1] == 'G')\n {\n c[k] = 'G';\n c[k + 1] = 'B';\n k++;\n }\n }\n }\n string ans = new string(c);\n Console.WriteLine(ans);\n // Console.ReadKey();\n }\n\n } \n}\n", "lang_cluster": "C#", "tags": ["constructive algorithms", "implementation", "shortest paths", "graph matchings"], "code_uid": "9fc6df59ba335c03223d943cfb193698", "src_uid": "964ed316c6e6715120039b0219cc653a", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\n\nnamespace B266\n{\n class Program\n {\n static void Main(string[] args)\n {\n int[] input = Array.ConvertAll(Console.ReadLine().Split(new char[] { ' ' }), int.Parse);\n string queue = Console.ReadLine();\n \n for (int i = 0; i < input[1]; i++)\n {\n char[] output = queue.ToCharArray();\n for (int e = 0; e < input[0]; e++)\n {\n if (e < input[0] - 1)\n {\n if (queue[e] == 'B' && queue[e] != queue[e+1]) \n {\n output[e] = queue[e + 1];\n output[e + 1] = queue[e];\n e++;\n }\n }\n }\n queue = string.Join(\"\",output);\n }\n\n Console.WriteLine(queue);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["constructive algorithms", "implementation", "shortest paths", "graph matchings"], "code_uid": "f6f0d0acfd81112af6200b6619a97688", "src_uid": "964ed316c6e6715120039b0219cc653a", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\npublic class Program266B\n {\n public static string GetFinalPositions(int queuelength, int timeticks, string queue)\n {\n char[] students = queue.ToCharArray();\n\n for (int timetick = 0; timetick < timeticks; timetick++)\n {\n for (int s = 0; s < queuelength-1; s++)\n {\n if (students[s] == 'B' && students[s + 1] == 'G')\n {\n students[s] = 'G';\n students[s + 1] = 'B';\n s++;\n }\n }\n }\n\n return new String(students);\n }\n\n \n public static void Main()\n {\n try\n {\n string length_and_time = Console.ReadLine().Trim();\n int queuelength = int.Parse(length_and_time.Split(' ')[0]);\n int timeticks = int.Parse(length_and_time.Split(' ')[1]);\n\n string positions = Console.ReadLine().Trim();\n Console.WriteLine(GetFinalPositions(queuelength, timeticks, positions));\n }\n catch (Exception x)\n {\n Console.WriteLine(x);\n }\n }\n}", "lang_cluster": "C#", "tags": ["constructive algorithms", "implementation", "shortest paths", "graph matchings"], "code_uid": "4ef2d7b3326c89733c89d9ee0dc71e92", "src_uid": "964ed316c6e6715120039b0219cc653a", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nnamespace ConsoleApplication1\n{\n class Program\n {\n static void Main(string[] args)\n {\n string[] input = Console.ReadLine().Split();\n int n = Int32.Parse(input[0]);\n int t = Int32.Parse(input[1]);\n\n char[] str = Console.ReadLine().ToCharArray();\n for (int i = 0; i < t; i++)\n for (int j = n - 1; j > 0; j--)\n if (str[j] == 'G' && str[j - 1] == 'B')\n {\n str[j] = 'B';\n str[j - 1] = 'G';\n j -= 1;\n }\n Console.WriteLine(new string(str));\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["constructive algorithms", "implementation", "shortest paths", "graph matchings"], "code_uid": "5bd7d3e5c50b30fb0743a2a4f20ef440", "src_uid": "964ed316c6e6715120039b0219cc653a", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace Queue\n{\n class Program\n {\n static void Main(string[] args)\n {\n string[] input = Console.ReadLine().Split();\n int n = int.Parse(input[0]);\n int t = int.Parse(input[1]);\n string s = Console.ReadLine();\n char[] output = new char[n];\n int k = 0;\n foreach (char c in s)\n {\n output[k] = c;\n k++;\n }\n for (int i = 0, x = 0; i < t; i++)\n {\n for (int j = x + 1; j < output.Length; j = x + 1)\n {\n if (output[x] == 'B' && output[j] == 'G')\n {\n output[x] = 'G';\n output[j] = 'B';\n x = j + 1;\n }\n else\n {\n x = x + 1;\n }\n }\n x = 0;\n }\n foreach (char c in output)\n {\n Console.Write(c);\n }\n Console.WriteLine();\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["constructive algorithms", "implementation", "shortest paths", "graph matchings"], "code_uid": "ae760d56ad50b85f64366897229f43ab", "src_uid": "964ed316c6e6715120039b0219cc653a", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\n\nnamespace ConsoleApp1\n{\n class Program\n {\n static void Main(string[] args)\n {\n var input = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();\n\n var roundCnt = input[1];\n var que = Console.ReadLine();\n\n string swapped = string.Empty;\n int iNumber = -1;\n\n List newstring = new List();\n newstring.AddRange(que.ToList());\n\n for (var j = 0; j < roundCnt; j++)\n {\n for (var i = 0; i < newstring.Count; i++)\n {\n if (i != iNumber)// if not swapped \n {\n if ((i + 1 <= newstring.Count - 1) && (newstring[i].ToString() == \"B\") && (newstring[i + 1].ToString() == \"G\")) //if it's B and next one is G\n {\n var temp = newstring[i];\n newstring[i] = newstring[i + 1]; // do swapp\n newstring[i + 1] = temp;\n iNumber = i + 1;\n }\n }\n }\n iNumber = -1;\n }\n\n Console.WriteLine(string.Join(\"\", newstring.Select(x => x.ToString())));\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["constructive algorithms", "implementation", "shortest paths", "graph matchings"], "code_uid": "bfac7d893027bc99d2dcef83fa50b194", "src_uid": "964ed316c6e6715120039b0219cc653a", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": ".NET Core C#", "source_code": "using System;\nusing System.Collections.Generic;\n\nnamespace QueueAtSchool\n{\n class Program\n {\n static void Main(string[] args)\n {\n string variables = Console.ReadLine();\n string studentsString = Console.ReadLine();\n\n int n = 0;\n int s = 0;\n\n string txt = \"\";\n int c = 0;\n\n for(int i = 0; i < variables.Length; i++)\n {\n if(variables[i] != ' ')\n {\n txt += variables[i];\n }\n else\n {\n if(c == 0)\n {\n n = Convert.ToInt32(txt);\n c++;\n txt = \"\";\n }\n }\n }\n\n s = Convert.ToInt32(txt);\n\n List students = new List();\n\n for(int i = 0; i < studentsString.Length; i++)\n {\n students.Add(studentsString[i].ToString());\n }\n\n for(int i = 0; i < s; i++)\n {\n for(int j = 0; j < students.Count; j++)\n {\n if(j != students.Count - 1)\n {\n if(students[j] == \"B\" && students[j + 1] == \"G\")\n {\n students[j] = \"G\";\n students[j + 1] = \"B\";\n j++;\n }\n }\n }\n }\n\n\n for(int i = 0; i < students.Count; i++)\n {\n Console.Write(students[i]);\n }\n\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["constructive algorithms", "implementation", "shortest paths", "graph matchings"], "code_uid": "ed8afdaaedbd315422f1b4ecdb4f369e", "src_uid": "964ed316c6e6715120039b0219cc653a", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace ConsoleApplication14\n{\n\n class Program\n {\n\n static void Main(string[] args)\n {\n string nt = Convert.ToString(Console.ReadLine());\n char[] nt1 = nt.ToCharArray();\n int num = 0;\n\n for(int i = 0; i < nt.Length; i++)\n {\n if (nt1[i] == ' ')\n num = i;\n }\n\n int n = 0, t = 0;\n \n\n for (int i = 0; i < num; i++)\n {\n n = n + (int)nt1[i] - 48;\n\n //Console.WriteLine(n);\n\n if (i+ 1 < num)\n n = n * 10;\n }\n\n for (int i = num + 1; i < nt.Length; i++)\n {\n t = t + (int)nt1[i] - 48;\n\n \n\n if (i+1 < nt.Length)\n t = t * 10;\n }\n /*Console.WriteLine(n);\n Console.WriteLine(t);*/\n\n\n\n //int t = Convert.ToInt32(Console.ReadLine());\n string sq = Convert.ToString(Console.ReadLine());\n int ind = 0;\n char d;\n\n char[] sq1 = sq.ToCharArray();\n for (int i = 0; i < t; i++)\n {\n for (int j = 0; j < n - 1; j++)\n {\n\n if (sq1[j] == 'B' && sq1[j + 1] == 'G' && ind == 0)\n {\n d = sq1[j];\n sq1[j] = sq1[j + 1];\n sq1[j + 1] = d;\n ind = 1;\n }\n\n else ind = 0;\n }\n ind = 0;\n\n\n }\n for(int i = 0; i < n; i++)\n {\n Console.Write(sq1[i]);\n\n }\n\n //Console.ReadKey();\n\n\n\n\n }\n }\n\n}\n", "lang_cluster": "C#", "tags": ["constructive algorithms", "implementation", "shortest paths", "graph matchings"], "code_uid": "f89bf36ca4bb68ee122a6b05ccea8f95", "src_uid": "964ed316c6e6715120039b0219cc653a", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nclass HelloWorl\n{\n\n\n class Program\n {\n static void Main()\n {\n string[] w = Console.ReadLine().Split(' ');\n int n = int.Parse(w[0]);\n int t = int.Parse(w[1]);\n string s = Console.ReadLine();\n char[] z = s.ToCharArray();\n for (int j = 0; j vasya)\n {\n win = \"Misha\";\n }\n else if (misha < vasya)\n {\n win = \"Vasya\";\n }\n\n Console.WriteLine(win);\n }\n }\n}\n\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "59c14d5e5095b18777ea682372d7d9fa", "src_uid": "95b19d7569d6b70bd97d46a8541060d0", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Globalization;\nusing System.IO;\nusing System.Linq;\nusing System.Text;\nusing System.Threading;\n\n// (\u3065\u00b0\u03c9\u00b0)\u3065\uff90\u2605\u309c\u30fb\u3002\u3002\u30fb\u309c\u309c\u30fb\u3002\u3002\u30fb\u309c\u2606\u309c\u30fb\u3002\u3002\u30fb\u309c\u309c\u30fb\u3002\u3002\u30fb\u309c\npublic class Solver\n{\n public object Solve()\n {\n var a = ReadIntArray();\n int s1 = Math.Max(3 * a[0] / 10, a[0] - a[0] / 250 * a[2]);\n int s2 = Math.Max(3 * a[1] / 10, a[1] - a[1] / 250 * a[3]);\n\n if (s1 < s2)\n return \"Vasya\";\n if (s1 > s2)\n return \"Misha\";\n return \"Tie\";\n\n return null;\n }\n\n #region Main\n\n protected static TextReader reader;\n protected static TextWriter writer;\n\n static void Main()\n {\n#if DEBUG\n reader = new StreamReader(\"..\\\\..\\\\input.txt\");\n writer = Console.Out;\n //writer = new StreamWriter(\"..\\\\..\\\\output.txt\");\n#else\n reader = new StreamReader(Console.OpenStandardInput());\n writer = new StreamWriter(Console.OpenStandardOutput());\n //reader = new StreamReader(\"game.in\");\n //writer = new StreamWriter(\"game.out\");\n#endif\n try\n {\n// var thread = new Thread(new Solver().Solve, 1024 * 1024 * 128);\n// thread.Start();\n// thread.Join();\n object result = new Solver().Solve();\n if (result != null)\n writer.WriteLine(result);\n }\n catch (Exception ex)\n {\n#if DEBUG\n Console.WriteLine(ex);\n#else\n Console.WriteLine(ex);\n throw;\n#endif\n }\n reader.Close();\n writer.Close();\n }\n\n #endregion\n\n #region Read / Write\n\n private static Queue currentLineTokens = new Queue();\n\n private static string[] ReadAndSplitLine()\n {\n return reader.ReadLine().Split(new[] { ' ', '\\t' }, StringSplitOptions.RemoveEmptyEntries);\n }\n\n public static string ReadToken()\n {\n while (currentLineTokens.Count == 0)\n currentLineTokens = new Queue(ReadAndSplitLine());\n return currentLineTokens.Dequeue();\n }\n\n public static int ReadInt()\n {\n return int.Parse(ReadToken());\n }\n\n public static long ReadLong()\n {\n return long.Parse(ReadToken());\n }\n\n public static double ReadDouble()\n {\n return double.Parse(ReadToken(), CultureInfo.InvariantCulture);\n }\n\n public static int[] ReadIntArray()\n {\n return ReadAndSplitLine().Select(int.Parse).ToArray();\n }\n\n public static long[] ReadLongArray()\n {\n return ReadAndSplitLine().Select(long.Parse).ToArray();\n }\n\n public static double[] ReadDoubleArray()\n {\n return ReadAndSplitLine().Select(s => double.Parse(s, CultureInfo.InvariantCulture)).ToArray();\n }\n\n public static int[][] ReadIntMatrix(int numberOfRows)\n {\n int[][] matrix = new int[numberOfRows][];\n for (int i = 0; i < numberOfRows; i++)\n matrix[i] = ReadIntArray();\n return matrix;\n }\n\n public static int[][] ReadAndTransposeIntMatrix(int numberOfRows)\n {\n int[][] matrix = ReadIntMatrix(numberOfRows);\n int[][] ret = new int[matrix[0].Length][];\n for (int i = 0; i < ret.Length; i++)\n {\n ret[i] = new int[numberOfRows];\n for (int j = 0; j < numberOfRows; j++)\n ret[i][j] = matrix[j][i];\n }\n return ret;\n }\n\n public static string[] ReadLines(int quantity)\n {\n string[] lines = new string[quantity];\n for (int i = 0; i < quantity; i++)\n lines[i] = reader.ReadLine().Trim();\n return lines;\n }\n\n public static void WriteArray(IEnumerable array)\n {\n writer.WriteLine(string.Join(\" \", array));\n }\n\n public static void Write(params T[] array)\n {\n WriteArray(array);\n }\n\n public static void WriteLines(IEnumerable array)\n {\n foreach (var a in array)\n writer.WriteLine(a);\n }\n\n #endregion\n}", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "00fae78710f4a73f4a08fea1ccb40d71", "src_uid": "95b19d7569d6b70bd97d46a8541060d0", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\n\nnamespace ConsoleApplication15\n{\n class Program\n {\n static void Main(string[] args)\n {\n string[] stdin;\n stdin = Console.ReadLine().Split(' ');\n int n = Convert.ToInt32(stdin[0]);\n int d = Convert.ToInt32(stdin[1]);\n stdin=null;\n stdin = Console.ReadLine().Split(' ');\n int k=stdin.Length;\n int[] mas = new int[k];\n for(int i=0;i 0)\n {\n for (int i = 0; i < k; i++)\n {\n sum = sum + mas[i];\n }\n sum = sum - (m - n) * d;\n }\n else if (m - n < 0)\n {\n int buf = 0;\n for (int j = k - 1; j > 0; j--)\n {\n for (int i = 0; i < j; i++)\n {\n if (mas[i] > mas[i + 1])\n {\n buf = mas[i];\n mas[i] = mas[i + 1];\n mas[i + 1] = buf;\n }\n }\n }\n for (int i = 0; i < m; i++)\n {\n sum = sum + mas[i];\n }\n }\n Console.WriteLine(sum.ToString());\n Console.ReadLine();\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "b8e87200ca5b2c6c98cb1cad6a3d8cb8", "src_uid": "5c21e2dd658825580522af525142397d", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\n\nnamespace prob1\n{\n class Program\n {\n static void Main(string[] args)\n {\n int n, d;\n string[] str1 = Console.ReadLine().Split(' ');\n n = Convert.ToInt32(str1[0]);\n d = Convert.ToInt32(str1[1]);\n\n int[] a = new int[n];\n string[] str3=Console.ReadLine().Split(' ');\n for (int i = 0; i < n; i++)\n a[i] = Convert.ToInt32(str3[i]);\n int m = Convert.ToInt32(Console.ReadLine());\n int sum=0;\n int res = 0;\n Array.Sort(a);\n if (m <= n)\n {\n for (int i = 0; i < m; i++)\n sum += a[i];\n res = sum;\n }\n else\n {\n for (int i = 0; i < n; i++)\n sum += a[i];\n\n res = sum + ((n - m) * d);\n }\n Console.WriteLine(res);\n Console.ReadLine();\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "e411225dcb18a705303b45f2f8daf574", "src_uid": "5c21e2dd658825580522af525142397d", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace ConsoleApplication1\n{\n class Program\n {\n static void Main(string[] args)\n {\n string[] arr = Console.ReadLine().Split(' ');\n int[] A = new int[5];\n for (int i = 0; i < 5; i++)\n {\n A[i] = Convert.ToInt32(arr[i]);\n }\n int sum = 0;\n for (int i = 0; i < 5; i++)\n {\n sum += A[i];\n }\n if (sum < 5 ) Console.WriteLine(-1);\n else if (sum % 5 == 0) Console.WriteLine(sum/5);\n else Console.WriteLine(-1);\n Console.ReadLine();\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "5e70bc57a8faedaafd0b75711c17968b", "src_uid": "af1ec6a6fc1f2360506fc8a34e3dcd20", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Linq;\nclass Program{\n static void Main(){\n int s = Array.ConvertAll(Console.ReadLine().Split(), int.Parse).Sum();\n Console.WriteLine(s % 5 == 0 & s != 0 ? s / 5 : -1);\n }\n}", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "21f512add4918b1376649578ddb8ca3a", "src_uid": "af1ec6a6fc1f2360506fc8a34e3dcd20", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\n\nnamespace Cod\n{\n class Program\n {\n static void Main(string[] args)\n {\n var nB = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();\n var data = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();\n // \u041f\u0435\u0440\u0432\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u0434\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0433\u043e \u0440\u0430\u0437\u0434\u0435\u043b\u0438\u0442\u0435\u043b\u044f\n var currentOdd = 0;\n var currentEven = 0;\n var difs = new List();\n for (int i = 0; i < nB[0]-1; i++)\n {\n if (data[i] % 2 == 0)\n {\n currentEven++;\n }\n else\n {\n currentOdd++;\n }\n if (currentEven != currentOdd) continue;\n difs.Add(Math.Abs(data[i] - data[i+1]));\n currentOdd = 0;\n currentEven = 0;\n }\n var prices = difs.OrderBy(m => m).ToArray();\n var sum = 0;\n var number = 0;\n foreach (var price in prices)\n {\n if (sum + price <= nB[1])\n {\n sum += price;\n number++;\n }\n else\n {\n break;\n }\n }\n Console.WriteLine(number);\n //Console.ReadKey();\n }\n }\n}", "lang_cluster": "C#", "tags": ["sortings", "dp", "greedy"], "code_uid": "ff9705bac722d579a09c85863adc8e0e", "src_uid": "b3f8e769ee7719ea5c9f458428b16a4e", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections;\nusing System.Collections.Generic;\nusing System.Diagnostics;\nusing System.Globalization;\nusing System.IO;\nusing System.Linq;\nusing System.Text;\n\nnamespace Task\n{\n class Program\n {\n #region Read / Write\n protected static TextReader reader;\n protected static TextWriter writer;\n private static Queue currentLineTokens = new Queue();\n private static string[] ReadAndSplitLine() { return reader.ReadLine().Split(new[] { ' ', '\\t', }, StringSplitOptions.RemoveEmptyEntries); }\n public static string ReadToken() { while (currentLineTokens.Count == 0) currentLineTokens = new Queue(ReadAndSplitLine()); return currentLineTokens.Dequeue(); }\n public static int ReadInt() { return int.Parse(ReadToken()); }\n public static long ReadLong() { return long.Parse(ReadToken()); }\n public static double ReadDouble() { return double.Parse(ReadToken(), CultureInfo.InvariantCulture); }\n public static int[] ReadIntArray() { return ReadAndSplitLine().Select(int.Parse).ToArray(); }\n public static long[] ReadLongArray() { return ReadAndSplitLine().Select(long.Parse).ToArray(); }\n public static double[] ReadDoubleArray() { return ReadAndSplitLine().Select(s => double.Parse(s, CultureInfo.InvariantCulture)).ToArray(); }\n public static int[][] ReadIntMatrix(int numberOfRows) { int[][] matrix = new int[numberOfRows][]; for (int i = 0; i < numberOfRows; i++) matrix[i] = ReadIntArray(); return matrix; }\n public static int[][] ReadAndTransposeIntMatrix(int numberOfRows)\n {\n int[][] matrix = ReadIntMatrix(numberOfRows); int[][] ret = new int[matrix[0].Length][];\n for (int i = 0; i < ret.Length; i++) { ret[i] = new int[numberOfRows]; for (int j = 0; j < numberOfRows; j++) ret[i][j] = matrix[j][i]; }\n return ret;\n }\n public static string[] ReadLines(int quantity) { string[] lines = new string[quantity]; for (int i = 0; i < quantity; i++) lines[i] = reader.ReadLine().Trim(); return lines; }\n public static void WriteArray(IEnumerable array) { writer.WriteLine(string.Join(\" \", array)); }\n public static void Write(params object[] array) { WriteArray(array); }\n public static void WriteLines(IEnumerable array) { foreach (var a in array) writer.WriteLine(a); }\n private class SDictionary : Dictionary\n {\n public new TValue this[TKey key]\n {\n get { return ContainsKey(key) ? base[key] : default(TValue); }\n set { base[key] = value; }\n }\n }\n private static T[] Init(int size) where T : new() { var ret = new T[size]; for (int i = 0; i < size; i++) ret[i] = new T(); return ret; }\n #endregion=\n\n public static bool NextPermutation(List perm)\n {\n for (int i = perm.Count - 2; i >= 0; i--)\n {\n if (perm[i] < perm[i + 1])\n {\n int min = i + 1;\n for (int j = min; j < perm.Count; j++)\n if (perm[j] > perm[i] && perm[j] < perm[min])\n min = j;\n\n int tmp = perm[i];\n perm[i] = perm[min];\n perm[min] = tmp;\n perm.Reverse(i + 1, perm.Count - i - 1);\n return true;\n }\n }\n\n return false;\n }\n\n public static int[] Perm(int[] mas1, int[] mas2, int numb1 = 0)\n {\n if (mas1 == null)\n return mas2;\n if (mas2 == null)\n return mas1;\n\n var ans = new int[mas1.Length];\n for (int i = 0; i < mas1.Length; i++)\n {\n ans[i] = mas2[mas1[i] - 1];\n }\n\n return ans;\n }\n\n public static void Build(int[][] a, int v, int tl, int tr)\n {\n hash = new Dictionary();\n\n if (tl == tr)\n t[v] = a[tl];\n else\n {\n int tm = (tl + tr) / 2;\n Build(a, v * 2, tl, tm);\n Build(a, v * 2 + 1, tm + 1, tr);\n t[v] = Perm(t[v * 2], t[v * 2 + 1]);\n }\n }\n\n public static Dictionary hash;\n\n public static int[] Query(int v, int tl, int tr, int l, int r)\n {\n if (l > r)\n return null;\n if (l == tl && r == tr)\n return t[v];\n\n var key = ((long)l << 17) + r;\n if (hash.ContainsKey(key))\n return hash[key];\n\n int tm = (tl + tr) / 2;\n var res = Perm(Query(v * 2, tl, tm, l, Math.Min(r, tm)), Query(v * 2 + 1, tm + 1, tr, Math.Max(l, tm + 1), r));\n hash[key] = res;\n return res;\n }\n\n public static int[][] t;\n\n static void Main(string[] args)\n {\n //long i = 0;\n long ans = 0;\n reader = new StreamReader(Console.OpenStandardInput());\n writer = new StreamWriter(Console.OpenStandardOutput());\n\n var n = ReadInt();\n var B = ReadInt();\n var mas = ReadIntArray();\n //var mas = ReadIntArray().Select((item, index) => new Tuple(index, item)).ToArray();\n\n var lst = new List();\n int evenNumb = 0, oddNumb = 0;\n for (int i = 0; i < n - 1; i++)\n {\n if ((mas[i] & 1) == 0)\n {\n evenNumb++;\n }\n else\n {\n oddNumb++;\n }\n\n if (evenNumb == oddNumb)\n lst.Add(Math.Abs(mas[i] - mas[i + 1]));\n }\n\n lst.Sort();\n for (int i = 0; i < lst.Count; i++)\n {\n if (lst[i] <= B)\n {\n ans++;\n B -= lst[i];\n }\n else\n {\n break;\n }\n }\n\n Write(ans);\n\n reader.Close();\n writer.Close();\n }\n }\n}", "lang_cluster": "C#", "tags": ["sortings", "dp", "greedy"], "code_uid": "5bef24051436ac3d9dbf13639e3f434b", "src_uid": "b3f8e769ee7719ea5c9f458428b16a4e", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace ConsoleApp12\n{\n class Program\n {\n static void Main(string[] args)\n {\n int n=int.Parse(Console.ReadLine());\n int sumrobo = 0;\n int sumbio = 0;\n int[] robo = new int[n];\n int[] bio = new int[n];\n string robo1 = Console.ReadLine();\n\t\t\tstring bio1 = Console.ReadLine();\n\t\t\tfor(int i=0; i sumbio)\n\t\t\t{\n\t\t\t\tConsole.Write(1);\n\t\t\t\tConsole.Write(\"\\n\");\n\t\t\t}\n\t\t\telse if (sumrobo == 0)\n\t\t\t{\n\t\t\t\tConsole.Write(-1);\n\t\t\t\tConsole.Write(\"\\n\");\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tint answer = sumbio / sumrobo + 1;\n\t\t\t\tConsole.Write(answer);\n\t\t\t\tConsole.Write(\"\\n\");\n\n\t\t\t}\n\n\n\t\t}\n\t}\n}\n", "lang_cluster": "C#", "tags": ["greedy"], "code_uid": "cc8e6dd448390c1015aa4e02b226454e", "src_uid": "b62338bff0cbb4df4e5e27e1a3ffaa07", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "// Problem: 1321A - Contest for Robots\n// Author: Gusztav Szmolik\n\nusing System;\n\nclass ContestForRobots\n {\n static int Main ()\n {\n string line = Console.ReadLine ();\n if (line == null)\n return -1;\n char[] delims = {' ', '\\t'};\n string[] words = line.Split (delims,StringSplitOptions.RemoveEmptyEntries);\n if (words.Length != 1)\n return -1;\n byte n;\n if (!Byte.TryParse (words[0], out n))\n return -1;\n if (n < 1 || n > 100)\n return -1;\n line = Console.ReadLine ();\n if (line == null)\n return -1;\n words = line.Split (delims,StringSplitOptions.RemoveEmptyEntries);\n if (words.Length != n)\n return -1;\n byte[] r = new byte[n];\n byte countSolvedProblemR = 0;\n for (byte i = 0; i < n; i++)\n {\n byte ri;\n if (!Byte.TryParse (words[i], out ri))\n return -1;\n if (ri > 1)\n return -1;\n if (ri == 1)\n countSolvedProblemR++;\n r[i] = ri;\n }\n line = Console.ReadLine ();\n if (line == null)\n return -1;\n words = line.Split (delims,StringSplitOptions.RemoveEmptyEntries);\n if (words.Length != n)\n return -1;\n byte countSolvedProblemB = 0;\n byte countPointSource = 0;\n for (byte i = 0; i < n; i++)\n {\n byte bi;\n if (!Byte.TryParse (words[i], out bi))\n return -1;\n if (bi > 1)\n return -1;\n if (bi == 1)\n countSolvedProblemB++;\n else if (r[i] == 1)\n countPointSource++;\n }\n sbyte ans = 0;\n if (countSolvedProblemR > countSolvedProblemB)\n ans = 1;\n else if (countPointSource == 0)\n ans = -1;\n else\n {\n byte needPoints = Convert.ToByte (countSolvedProblemB-countSolvedProblemR+1);\n ans = Convert.ToSByte (needPoints/countPointSource);\n ans += Convert.ToSByte (needPoints%countPointSource > 0 ? 2 : 1);\n }\n Console.WriteLine (ans);\n return 0;\n }\n }\n", "lang_cluster": "C#", "tags": ["greedy"], "code_uid": "ecf66484e8a1f603c04bcc53348a1da6", "src_uid": "b62338bff0cbb4df4e5e27e1a3ffaa07", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace ConsoleApp10\n{\n class Program\n {\n static void Main(string[] args)\n {\n int n = int.Parse(Console.ReadLine());\n string[] s = Console.ReadLine().Split(' ');\n int[] a = new int[n];\n for (int i = 0; i < n; i++)\n a[i] = int.Parse(s[i]);\n int min = 1;\n int count = 0;\n for (int i = 0; i < n; i++)\n {\n for (int j = i; j < n; j++)\n if (a[j] == a[i])\n count++;\n if (min < count)\n min = count;\n count = 0;\n }\n Console.WriteLine(min);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "7abcffb2922fae8a8a9bd7276a48fecb", "src_uid": "f30329023e84b4c50b1b118dc98ae73c", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\n\nnamespace ConsoleApplication1\n{\n class Program\n {\n static void Main(string[] args)\n {\n int t = Convert.ToInt32(Console.ReadLine());\n string[] s = Console.ReadLine().Split(' ');\n if (t == 1)\n { Console.WriteLine(1);\n Environment.Exit(0);\n }\n \n int[] a = new int[t];\n int temp = 0;\n for (int i=0; i temp) temp = b[i];\n Console.WriteLine(temp);\n }\n }\n}", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "57a4c19570c3879c1dc05f7ce53d22ca", "src_uid": "f30329023e84b4c50b1b118dc98ae73c", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\n\nnamespace ConsoleApplication2\n{\n class Program\n {\n static void Main(string[] args)\n {\n int k = int.Parse(Console.ReadLine());\n int[] arr = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();\n Array.Sort(arr);\n int c = 0;\n if (k == 0)\n {\n Console.WriteLine(0);\n return;\n }\n for (int i = 11; i >= 0;i--)\n {\n c += arr[i];\n if (c >= k)\n {\n Console.WriteLine(12 - i);\n return;\n }\n }\n Console.WriteLine(\"-1\");\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["sortings", "implementation", "greedy"], "code_uid": "5aa622dad558784feed1b72d1337367b", "src_uid": "59dfa7a4988375febc5dccc27aca90a8", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Text;\n\nnamespace ProblemsFun\n{\n class Program\n {\n static void Main(string[] args)\n {\n int n = Convert.ToInt32( Console.ReadLine());\n string[] line = Console.ReadLine().Split(' ');\n List list = new List(); \n\n for (int i = 0; i < line.Length; i++)\n {\n \n list.Add(Convert.ToInt32(line[i]));\n }\n\n list = QuickSort(list, 0, list.Count - 1);\n\n if (n != 0)\n {\n int sum = 0;\n for (int i = list.Count-1; i > -1; i--)\n {\n sum += list[i];\n if (sum >= n)\n {\n Console.WriteLine(12 - i );\n break;\n }\n }\n\n if(sum < n)\n Console.WriteLine(\"-1\");\n }\n else\n {\n\n Console.WriteLine(\"0\");\n }\n }\n\n static List QuickSort(List list, int first, int last)\n {\n if (first < last)\n {\n int pivot = Devide(list, first, last);\n list = QuickSort(list, first, pivot);\n list = QuickSort(list, pivot + 1, last);\n }\n return list;\n }\n\n static int Devide(List list, int first, int last)\n {\n int pivotVal = list[first];\n int smallest = first - 1;\n int biggest = last + 1;\n\n while (true)\n {\n do\n {\n biggest--;\n }\n while (list[biggest] > pivotVal);\n\n do\n {\n smallest++;\n }\n while (list[smallest] < pivotVal);\n\n if (smallest < biggest)\n {\n int temp = list[smallest];\n list[smallest] = list[biggest];\n list[biggest] = temp;\n }\n else\n {\n return biggest;\n }\n }\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["sortings", "implementation", "greedy"], "code_uid": "d9fd97f254d9ea2bd1bffe244d6bc779", "src_uid": "59dfa7a4988375febc5dccc27aca90a8", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Globalization;\nusing System.Linq;\nusing System.Runtime.ExceptionServices;\nusing System.Text;\n\nnamespace CodeForces\n{\n class Program\n {\n \n public static void Main(string[] args) {\n long n, k;\n GetTwoInts(out n, out k);\n\n long d, g, o;\n d = n/2/(k + 1);\n g = d*k;\n o = n - d - g;\n\n Console.WriteLine(\"{0} {1} {2}\", d, g, o);\n }\n\n public static string Rw() { return Console.ReadLine(); }\n\n public static long GetInt() { return Int64.Parse(Rw()); }\n public static long[] GetIntArr() { return Array.ConvertAll(Rw().Split(' '), Int64.Parse); }\n\n public static double GetDouble() { return Double.Parse(Rw()); }\n public static double[] GetDoubleArr() { return Array.ConvertAll(Rw().Split(' '), DoubleParse); }\n public static double DoubleParse(string s) { return Double.Parse(s, NumberStyles.Any, System.Globalization.CultureInfo.GetCultureInfo(\"en-US\")); }\n\n public static void GetTwoInts(out long n, out long m)\n {\n long[] input = GetIntArr();\n n = input[0];\n m = input[1];\n }\n\n public const long Module = 1000000000 + 7;\n public const long Max = (long)1.0e18;\n\n }\n}\n\n", "lang_cluster": "C#", "tags": ["math", "implementation"], "code_uid": "b4acf286cbcc8806cee8c9a50cc88ca5", "src_uid": "405a70c3b3f1561a9546910ab3fb5c80", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\n\nnamespace CodefCS\n{\n class Program\n {\n static void Main(string[] args)\n {\n string[] tokens = Console.ReadLine().Split();\n\n long n = long.Parse(tokens[0]);\n long k= long.Parse(tokens[1]);\n\n Console.WriteLine($\"{n / 2 / (k + 1)} {n / 2 / (k + 1) * k} {n - n / 2 / (k + 1) - n / 2 / (k + 1) * k}\");\n }\n }\n}", "lang_cluster": "C#", "tags": ["math", "implementation"], "code_uid": "9c361210b29cc8a2308f983728d1790b", "src_uid": "405a70c3b3f1561a9546910ab3fb5c80", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Linq;\nusing System.Threading.Tasks;\nusing System.Text;\nusing System.Collections.Generic;\nusing System.Threading;\n\nnamespace HelloApp\n{\n class Program\n {\n static void Main(string[] args)\n {\n int[] arr = new int[3];\n int[] a = new int[3];\n string[] s = Console.ReadLine().Split();\n for (int i = 0; i < 3; i++)\n arr[i] = Convert.ToInt32(s[i]);\n int ans = 0, buffer = 0, max = 0;\n if (arr[0] >= 3 && arr[1] >= 2 && arr[2] >= 2)\n {\n int min = (arr[2] / 2 > arr[1] / 2) ? arr[1] / 2 : arr[2] / 2;\n min = (min > arr[0] / 3) ? (arr[0] / 3) : min;\n ans = min * 2 + min * 3 + min * 2;\n arr[0] = arr[0] - min * 3;\n arr[1] = arr[1] - min * 2;\n arr[2] = arr[2] - min * 2;\n }\n for (int i = 0; i < 7; i++)\n {\n a[0] = arr[0];\n a[1] = arr[1];\n a[2] = arr[2];\n for (int j = i; j 0) { a[0]--; buffer++; continue; }\n else if ((j % 7 == 0 || j % 7 == 3 || j % 7 == 6) && a[0] == 0) break;\n if ((j % 7 == 1 || j % 7 == 5) && a[1] > 0) { a[1]--; buffer++; continue; }\n else if ((j % 7 == 1 || j % 7 == 5) && a[1] == 0) break;\n if ((j % 7 == 2 || j % 7 == 4) && a[2] > 0) { a[2]--; buffer++; continue; }\n else if ((j % 7 == 2 || j % 7 == 4) && a[2] == 0) break;\n }\n max = (max > buffer) ? max : buffer;\n buffer = 0;\n }/*\n for (int j = 0; j < 7; j++)\n {\n a[0] = arr[0];\n a[1] = arr[1];\n a[2] = arr[2];\n Parallel.For(j, j+7,\n () => { return 0; },\n (i, loopState, taskValue) =>\n {\n if (a[0] == 0 || a[1] == 0 || a[2] == 0) loopState.Break();\n if (i % 7 == 0 || i % 7 == 3 || i % 7 == 6 && a[0]>0) { a[0]--; taskValue++; }\n if (i % 7 == 1 || i % 7 == 5 && a[1] > 0) { a[1]--; taskValue++; }\n if (i % 7 == 2 || i % 7 == 4 && a[2] > 0) { a[2]--; taskValue++; }\n return taskValue;\n },\n (taskValue) => { Interlocked.Add(ref buffer, taskValue); }\n );\n max = (max > buffer) ? max : buffer;\n buffer = 0;\n }*/\n Console.WriteLine(ans+max);\n //Parallel.For(0, 3, () => { return 0; }, (i, loopState, index) => { Console.WriteLine(index+i + \" \"); return index; }, index => { });\n //Parallel.ForEach(arr, () => { return 0; }, (i, loopState, index, taskLocal) => { Console.WriteLine(index); return Convert.ToInt32(index); }, index => { });\n }\n\n static int Sum(int k)\n {\n int sum = 0;\n for (; k > -1; k--)\n checked { sum += k; }\n return sum;\n }\n static void Foo()\n {\n Console.WriteLine(\"CallBack\");\n }\n }\n}", "lang_cluster": "C#", "tags": ["math", "implementation"], "code_uid": "4fd5f6f277bd7713a067681a7d878167", "src_uid": "e17df52cc0615585e4f8f2d31d2daafb", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace \u041a\u0430\u0441\u0441\u0438\u0440\n{\n\n class Program\n {\n\n static void Main(string[] args)\n {\n string[] str = Console.ReadLine().Split(' ');\n int[] eat = new int[3];\n for(int i =0; i<3; i++)\n {\n eat[i] = int.Parse(str[i]);\n }\n int n = eat[0] / 3;\n if (eat[1] / 2 < n)\n n = eat[1] / 2;\n if (eat[2] / 2 < n)\n n = eat[2] / 2;\n int[] week = new int[14] { 0, 1, 2, 0, 2, 1, 0, 0, 1, 2, 0, 2, 1, 0, };\n eat[0] -= n * 3;\n eat[1] -= n * 2;\n eat[2] -= n * 2;\n int max = 0;\n for (int i = 0; i<7; i++)\n {\n int[] eat1 = (int[])eat.Clone();\n int j;\n for(j = i; j max)\n max = j - i;\n }\n Console.WriteLine(n*7+max);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "implementation"], "code_uid": "e5fe566aafc7724db3eed1c7c9bea2b6", "src_uid": "e17df52cc0615585e4f8f2d31d2daafb", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace ConsoleApplication1\n{\n internal class Program\n {\n private static void Main(string[] args)\n {\n int n = Convert.ToInt32(Console.ReadLine());\n int answer = 0;\n\n int lastAdded = 0;\n int currSum = 0;\n\n while (true)\n {\n lastAdded++;\n currSum += lastAdded;\n\n if (n < currSum)\n {\n break;\n }\n n = n - currSum;\n answer++;\n }\n\n Console.WriteLine(answer);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "9e3f0f7831bb23caed058befb2658c45", "src_uid": "873a12edffc57a127fdfb1c65d43bdb0", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\nusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace ConsoleApplication1\n{\n class Program\n {\n static int[] ReadInt(int size)\n {\n string[] input = Console.ReadLine().Split(' ');\n int[] res = new int[size]; \n for (int i=0; i b ? a : b);\n }\n\n static void WL (T s)\n {\n Console.WriteLine(s);\n } \n \n static void swap(ref int a, ref int b)\n {\n int temp = a;\n a = b;\n b = temp;\n }\n\n static void Main(string[] args)\n {\n int n = ReadInt(); \n int i = Convert.ToInt32(Math.Ceiling(Math.Pow(6*n,1.0/3)));\n while (i * (i + 1) * (i + 2) / 6 > n) i--;\n WL(i); \n }\n }\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "38957c8166465cba6bde31b0cde2a50b", "src_uid": "873a12edffc57a127fdfb1c65d43bdb0", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.IO;\nusing System.Text;\n\nnamespace Petya_and_Origami\n{\n internal class Program\n {\n private static readonly StreamReader reader = new StreamReader(Console.OpenStandardInput(1024*10), Encoding.ASCII, false, 1024*10);\n private static readonly StreamWriter writer = new StreamWriter(Console.OpenStandardOutput(1024*10), Encoding.ASCII, 1024*10);\n\n private static void Main(string[] args)\n {\n writer.WriteLine(Solve(args));\n writer.Flush();\n }\n\n private static int Solve(string[] args)\n {\n int n = Next();\n int k = Next();\n\n return ((n*2) + k - 1)/k + ((n*5) + k - 1)/k + ((n*8) + k - 1)/k;\n }\n\n private static int Next()\n {\n int c;\n int res = 0;\n do\n {\n c = reader.Read();\n if (c == -1)\n return res;\n } while (c < '0' || c > '9');\n res = c - '0';\n while (true)\n {\n c = reader.Read();\n if (c < '0' || c > '9')\n return res;\n res *= 10;\n res += c - '0';\n }\n }\n }\n}", "lang_cluster": "C#", "tags": ["math"], "code_uid": "118b981da20ad7d895093894c485254b", "src_uid": "d259a3a5c38af34b2a15d61157cc0a39", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Linq;\nusing System.Collections.Generic;\nclass Program\n{\n public static void Main(string[] args)\n {\n string[] inp = Console.ReadLine().Split();\n int n = Convert.ToInt32(inp[0]);\n int k = Convert.ToInt32(inp[1]);\n Console.WriteLine(2*n/k + 5*n/k + 8*n/k + ((2*n)%k == 0 ? 0:1) + ((5*n)%k == 0 ? 0:1) + ((8*n)%k == 0 ? 0:1));\n //Console.WriteLine(15*n/k);\n //Console.WriteLine(Math.Floor((2.0*n)/k + 0.5) + Math.Floor((5.0*n)/k + 0.5) + Math.Floor((8.0*n)/k + 0.5));\n //Console.WriteLine(Math.Ceiling((decimal)((2*n)/k)) + Math.Ceiling((decimal)((5*n)/k)) + Math.Ceiling((decimal)((8*n)/k));\n }\n}", "lang_cluster": "C#", "tags": ["math"], "code_uid": "f46a800c787c0b707f0d4248551d4be4", "src_uid": "d259a3a5c38af34b2a15d61157cc0a39", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace ConsoleApplication1\n{\n class Program\n {\n static void Main(string[] args)\n {\n var data = Console.ReadLine().Split().Select(int.Parse).ToArray();\n var n = data[0];\n var m = data[1];\n var z = data[2];\n var g = Gcd(n, m);\n var mult = n*m/g;\n Console.WriteLine(z/mult);\n }\n\n static int Gcd(int a, int b)\n {\n if (b == 0)\n return a;\n return Gcd(b, a%b);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "math", "implementation"], "code_uid": "b04990f7e0b63165e6cde18492a2570d", "src_uid": "e7ad55ce26fc8610639323af1de36c2d", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace A.Taymyr_is_calling_you\n{\n class Program\n {\n static void Main(string[] args)\n {\n string[] s = Console.ReadLine().Split();\n int n = int.Parse(s[0]);\n int m = int.Parse(s[1]);\n int k = int.Parse(s[2]);\n List li1 = new List(); \n List li2 = new List(); \n for(int i=n;i<=k;i+=n)\n {\n li1.Add(i);\n } for (int i = m; i <= k; i += m)\n {\n li2.Add(i);\n }\n int sum = 0;\n for(int i=0;i biggestMBox)\n {\n biggestMBox = matches[i][1];\n biggestMBIndx = i;\n };\n }\n\n inputs[0] -= matches[biggestMBIndx][0];\n\n if (inputs [0] > 0)\n {\n\n result += (matches[biggestMBIndx][0]* matches[biggestMBIndx][1]);\n matches[biggestMBIndx][1] = 0;\n biggestMBox = int.MinValue;\n biggestMBIndx = 0;\n } else\n {\n inputs[0] += matches[biggestMBIndx][0];\n break;\n }\n }\n\n result += inputs[0] * matches[biggestMBIndx][1];\n\n return result;\n\n }\n\n static int[] GetInts()\n {\n string[] s = (Console.ReadLine()).Split(' ');\n int[] integers = new int[s.Length];\n for (int i = 0; i < s.Length; i++)\n {\n integers[i] = int.Parse(s[i]);\n }\n return integers;\n }\n\n\n }\n\n}\n", "lang_cluster": "C#", "tags": ["sortings", "implementation", "greedy"], "code_uid": "1d1290aa8abcb5cecec9af3b70ed3b37", "src_uid": "c052d85e402691b05e494b5283d62679", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Text;\n\nnamespace codeforces\n{\n class C\n {\n static CodeforcesUtils CF = new CodeforcesUtils(\n@\"\n3 3\n1 3\n2 2\n3 1\n\");\n\n static void Main(string[] args)\n {\n string[] ss = CF.ReadLine().Split(' ');\n int n = int.Parse(ss[0]);\n int m = int.Parse(ss[1]);\n\n List> list = new List>();\n for (int i = 0; i < m; i++)\n {\n ss = CF.ReadLine().Split(' ');\n int a = int.Parse(ss[0]);\n int b = int.Parse(ss[1]);\n list.Add(new KeyValuePair(a, b));\n }\n list.Sort(\n delegate(KeyValuePairkv1,KeyValuePairkv2)\n {\n return -(kv1.Value - kv2.Value);\n }\n );\n\n int sum = 0;\n int q = n;\n for (int i = 0; i < list.Count; i++)\n {\n int c = list[i].Key;\n c=Math.Min(c,q);\n if (c == 0)\n break;\n sum += (list[i].Value * c);\n q -= c;\n }\n CF.WriteLine(sum);\n }\n\n\n\n #region test\n\n class CodeforcesUtils\n {\n public string ReadLine()\n {\n#if DEBUG\n if (_lines == null)\n {\n _lines = new List();\n string[] ss = _test_input.Replace(\"\\n\", \"\").Split('\\r');\n for (int i = 0; i < ss.Length; i++)\n {\n if (\n (i == 0 || i == ss.Length - 1) &&\n ss[i].Length == 0\n )\n continue;\n\n _lines.Add(ss[i]);\n }\n }\n\n string s = null;\n if (_lines.Count > 0)\n {\n s = _lines[0];\n _lines.RemoveAt(0);\n }\n return s;\n#else\n return Console.In.ReadLine();\n#endif\n }\n\n public void WriteLine(object o)\n {\n#if DEBUG\n System.Diagnostics.Trace.WriteLine(o);\n#else\n Console.WriteLine(o);\n#endif\n }\n\n public void Write(object o)\n {\n#if DEBUG\n System.Diagnostics.Trace.Write(o);\n#else\n Console.Write(o);\n#endif\n }\n\n public CodeforcesUtils(string test_input)\n {\n _test_input = test_input;\n }\n\n string _test_input;\n\n List _lines;\n }\n\n #endregion\n }\n}\n", "lang_cluster": "C#", "tags": ["sortings", "implementation", "greedy"], "code_uid": "8ab5dd2c9190fab8ec6adf549e3d6f64", "src_uid": "c052d85e402691b05e494b5283d62679", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections;\nusing System.Collections.Generic;\nusing System.Collections.Specialized;\nusing System.Text;\nusing System.Linq;\n\nnamespace Codeforces\n{\n internal class Program\n {\n private static string Read()\n {\n return Console.ReadLine();\n }\n private static string[] ReadArray()\n {\n return Console.ReadLine().Split(' ');\n }\n private static int ReadInt()\n {\n return Int32.Parse(Console.ReadLine());\n }\n private static long ReadLong()\n {\n return long.Parse(Console.ReadLine());\n }\n private static int ReadNextInt(string[] input, int index)\n {\n return Int32.Parse(input[index]);\n }\n\n private static long min = long.MaxValue;\n private static long max = -1;\n private static int initN;\n private static void Main()\n {\n var n = ReadInt();\n initN = n;\n for (int i = 1; i * i * i <= n; i++)\n {\n if(n % i != 0)\n continue;\n\n var ni = (n / i);\n for (int j = i; j * j <= ni; j++)\n {\n if(ni % j != 0)\n continue;\n\n var k = ni/j;\n Check(i, j, k);\n }\n }\n Console.WriteLine(min + \" \" + max);\n }\n\n private static void Check(long i, long j, long k)\n {\n var count = (i + 1)*(j + 2)*(k + 2) - initN;\n max = Math.Max(max, count);\n min = Math.Min(min, count);\n count = (j + 1) * (i + 2) * (k + 2) - initN;\n max = Math.Max(max, count);\n min = Math.Min(min, count);\n count = (k + 1) * (j + 2) * (i + 2) - initN;\n max = Math.Max(max, count);\n min = Math.Min(min, count);\n }\n }\n}", "lang_cluster": "C#", "tags": ["math", "implementation"], "code_uid": "0fbdd7aae4398e45e851d22f2b1b8bb6", "src_uid": "2468eead8acc5b8f5ddc51bfa2bd4fb7", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Text.RegularExpressions;\n\nnamespace Codeforces\n{\n class C\n {\n public static void Main(string[] args)\n {\n C program = new C();\n string output = program.Go();\n if (output != null)\n Wl(output);\n }\n\n private IEnumerable> Decompose(long n)\n {\n if (n == 1) yield break;\n\n int p = 2;\n while (p * p <= n)\n {\n int r = 0;\n while (n % p == 0)\n {\n ++r;\n n /= p;\n }\n if (r > 0)\n yield return new Tuple(p, r);\n\n ++p;\n }\n\n if (n > 1)\n yield return new Tuple(n, 1);\n }\n\n private IEnumerable Divs(Tuple[] decomp, int start = 0)\n {\n if (decomp.Length == 0)\n {\n yield return 1;\n yield break;\n }\n\n if (decomp.Length - start == 1)\n {\n long ret = 1;\n yield return 1;\n for (int i = 0; i < decomp[start].Item2; ++i)\n {\n ret *= decomp[start].Item1;\n yield return (ret);\n }\n }\n else\n {\n long ret = 1;\n foreach(long d in Divs(decomp, start+1))\n {\n yield return d;\n }\n for (int i = 0; i < decomp[start].Item2; ++i)\n {\n ret *= decomp[start].Item1;\n foreach (long d in Divs(decomp, start + 1))\n yield return (ret * d);\n }\n }\n\n }\n\n private string Go()\n {\n long n = GetLong();\n Tuple[] decompN = Decompose(n).ToArray();\n Tuple[] decompNa;\n\n long m = long.MaxValue;\n long M = 0;\n\n foreach (long A1 in Divs(decompN))\n {\n decompNa = A1 == 1 ? decompN : Decompose(n / A1).ToArray();\n foreach (long B2 in Divs(decompNa))\n {\n long C2 = n / A1 / B2;\n\n long cand = (A1 + 1) * (B2 + 2) * (C2 + 2);\n m = cand < m ? cand : m;\n M = cand > M ? cand : M;\n }\n }\n\n Wl(new long[] { m - n, M - n });\n\n return null;\n }\n\n #region Template\n\n private IEnumerator ioEnum;\n private string GetString()\n {\n while (ioEnum == null || !ioEnum.MoveNext())\n {\n ioEnum = Console.ReadLine().Split().AsEnumerable().GetEnumerator();\n }\n\n return ioEnum.Current;\n }\n\n private int GetInt()\n {\n return int.Parse(GetString());\n }\n\n private long GetLong()\n {\n return long.Parse(GetString());\n }\n\n private double GetDouble()\n {\n return double.Parse(GetString());\n }\n\n private static void Wl(T o)\n {\n Console.WriteLine(o.ToString());\n }\n\n private static void Wl(IEnumerable enumerable)\n {\n Wl(string.Join(\" \", enumerable.Select(e => e.ToString()).ToArray()));\n }\n\n public struct Tuple\n {\n public T Item1;\n public K Item2;\n\n public Tuple(T t, K k)\n {\n Item1 = t;\n Item2 = k;\n }\n\n public override bool Equals(object obj)\n {\n var o = (Tuple)obj;\n return o.Item1.Equals(Item1) && o.Item2.Equals(Item2);\n }\n\n public override int GetHashCode()\n {\n return Item1.GetHashCode() ^ Item2.GetHashCode();\n }\n\n public override string ToString()\n {\n return \"(\" + Item1 + \" \" + Item2 + \")\";\n }\n }\n\n #endregion\n }\n}", "lang_cluster": "C#", "tags": ["math", "implementation"], "code_uid": "715dbd4a6b7fb649b1328275e0a64e69", "src_uid": "2468eead8acc5b8f5ddc51bfa2bd4fb7", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Globalization;\nusing System.IO;\n\nclass Program\n{\n public class ArrayEqualityComparer : IEqualityComparer\n {\n public bool Equals(int[] x, int[] y)\n {\n if (x.Length != y.Length)\n {\n return false;\n }\n for (int i = 0; i < x.Length; i++)\n {\n if (x[i] != y[i])\n {\n return false;\n }\n }\n return true;\n }\n\n public int GetHashCode(int[] obj)\n {\n int result = 17;\n for (int i = 0; i < obj.Length; i++)\n {\n unchecked\n {\n result = result * 23 + obj[i];\n }\n }\n return result;\n }\n }\n\n public static int[] Read(string str)\n {\n string[] tokens = str.Trim().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);\n int[] ret = new int[tokens.Length];\n for (int i = 0; i < ret.Length; i++)\n {\n ret[i] = int.Parse(tokens[i]);\n }\n\n return ret;\n }\n\n public class PriorityQueue where T : IComparable\n {\n private List data;\n\n public PriorityQueue()\n {\n this.data = new List();\n }\n\n public void Enqueue(T item)\n {\n data.Add(item);\n int ci = data.Count - 1; // child index; start at end\n while (ci > 0)\n {\n int pi = (ci - 1) / 2; // parent index\n if (data[ci].CompareTo(data[pi]) >= 0) break; // child item is larger than (or equal) parent so we're done\n T tmp = data[ci]; data[ci] = data[pi]; data[pi] = tmp;\n ci = pi;\n }\n }\n\n public T Dequeue()\n {\n // assumes pq is not empty; up to calling code\n int li = data.Count - 1; // last index (before removal)\n T frontItem = data[0]; // fetch the front\n data[0] = data[li];\n data.RemoveAt(li);\n\n --li; // last index (after removal)\n int pi = 0; // parent index. start at front of pq\n while (true)\n {\n int ci = pi * 2 + 1; // left child index of parent\n if (ci > li) break; // no children so done\n int rc = ci + 1; // right child\n if (rc <= li && data[rc].CompareTo(data[ci]) < 0) // if there is a rc (ci + 1), and it is smaller than left child, use the rc instead\n ci = rc;\n if (data[pi].CompareTo(data[ci]) <= 0) break; // parent is smaller than (or equal to) smallest child so done\n T tmp = data[pi]; data[pi] = data[ci]; data[ci] = tmp; // swap parent and child\n pi = ci;\n }\n return frontItem;\n }\n\n public T Peek()\n {\n T frontItem = data[0];\n return frontItem;\n }\n\n public int Count()\n {\n return data.Count;\n }\n\n public override string ToString()\n {\n string s = \"\";\n for (int i = 0; i < data.Count; ++i)\n s += data[i].ToString() + \" \";\n s += \"count = \" + data.Count;\n return s;\n }\n\n public bool IsConsistent()\n {\n // is the heap property true for all data?\n if (data.Count == 0) return true;\n int li = data.Count - 1; // last index\n for (int pi = 0; pi < data.Count; ++pi) // each parent index\n {\n int lci = 2 * pi + 1; // left child index\n int rci = 2 * pi + 2; // right child index\n\n if (lci <= li && data[pi].CompareTo(data[lci]) > 0) return false; // if lc exists and it's greater than parent then bad.\n if (rci <= li && data[pi].CompareTo(data[rci]) > 0) return false; // check the right child too.\n }\n return true; // passed all checks\n } // IsConsistent\n } // PriorityQueue\n\n\n class Pair : IComparable\n {\n public int Key;\n public int Value;\n public Pair(int a, int b)\n {\n Key = a; Value = b;\n }\n\n public int CompareTo(Pair other)\n {\n if (this.Key > other.Key) return -1;\n if (this.Key < other.Key) return 1;\n return 0;\n }\n }\n \n static void Main(string[] args)\n {\n int n = int.Parse(Console.ReadLine().Trim());\n int[] d = Read(Console.ReadLine().Trim());\n\n int[,,] S = new int[n + 1, 2, 2];\n\n for (int i = 1; i <= n; i++)\n {\n S[i, 0, 0] = Math.Max(Math.Max(S[i - 1, 0, 0], S[i - 1, 0, 1]), Math.Max(S[i - 1, 1, 0], S[i - 1, 1, 1]));\n if ((d[i - 1] & 1) != 0)\n {\n S[i, 0, 1] = Math.Max(S[i - 1, 1, 0], S[i - 1, 0, 0]) + 1;\n }\n else\n {\n S[i, 0, 1] = Math.Max(Math.Max(S[i - 1, 0, 0], S[i - 1, 0, 1]), Math.Max(S[i - 1, 1, 0], S[i - 1, 1, 1]));\n }\n if ((d[i - 1] & 2) != 0)\n {\n S[i, 1, 0] = Math.Max(S[i - 1, 0, 1], S[i - 1, 0, 0]) + 1;\n }\n else\n {\n S[i, 1, 0] = Math.Max(Math.Max(S[i - 1, 0, 0], S[i - 1, 0, 1]), Math.Max(S[i - 1, 1, 0], S[i - 1, 1, 1]));\n }\n S[i, 1, 1] = 0;\n }\n\n int max_d = Math.Max(Math.Max(S[n, 0, 0], S[n, 0, 1]), Math.Max(S[n, 1, 0], S[n, 1, 1]));\n\n Console.WriteLine(n - max_d);\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "dp"], "code_uid": "6ab716a929949d1db827cafb59113562", "src_uid": "08f1ba79ced688958695a7cfcfdda035", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.IO;\n\nclass Program\n{\n const int M = 1000000007;\n const double eps = 1e-9;\n static int[] dd = { 0, 1, 0, -1, 0 };\n static void Main()\n {\n var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };\n var sc = new Scan();\n int n = sc.Int;\n var a = sc.IntArr;\n var dp = new int[n + 1][];\n for (int i = 0; i <= n; i++)\n {\n dp[i] = new int[3];\n for (int j = 0; j < 3; j++)\n {\n dp[i][j] = 100000;\n }\n }\n dp[0][0] = 0;\n for (int i = 0; i < n; i++)\n {\n if ((a[i] & 1) > 0)\n {\n dp[i + 1][1] = Math.Min(dp[i][0], dp[i][2]);\n }\n if ((a[i] & 2) > 0)\n {\n dp[i + 1][2] = Math.Min(dp[i][0], dp[i][1]);\n }\n dp[i + 1][0] = Math.Min(dp[i][0], Math.Min(dp[i][1], dp[i][2])) + 1;\n }\n sw.WriteLine(Math.Min(dp[n][0], Math.Min(dp[n][1], dp[n][2])));\n sw.Flush();\n }\n static void swap(ref T a, ref T b) { var t = a; a = b; b = t; }\n\n static T[] copy(T[] a)\n {\n var ret = new T[a.Length];\n for (int i = 0; i < a.Length; i++) ret[i] = a[i];\n return ret;\n }\n static T[][] copy2(T[][] a)\n {\n var ret = new T[a.Length][];\n for (int i = 0; i < a.Length; i++)\n {\n ret[i] = new T[a[0].Length];\n for (int j = 0; j < a[0].Length; j++) ret[i][j] = a[i][j];\n }\n return ret;\n }\n}\nclass Scan\n{\n public int Int { get { return int.Parse(Str); } }\n public long Long { get { return long.Parse(Str); } }\n public double Double { get { return double.Parse(Str); } }\n public string Str { get { return Console.ReadLine().Trim(); } }\n public int[] IntArr { get { return StrArr.Select(int.Parse).ToArray(); } }\n public int[] IntArrWithSep(char sep) { return Str.Split(sep).Select(int.Parse).ToArray(); }\n public long[] LongArr { get { return StrArr.Select(long.Parse).ToArray(); } }\n public double[] DoubleArr { get { return StrArr.Select(double.Parse).ToArray(); } }\n public string[] StrArr { get { return Str.Split(); } }\n public void Multi(out int a, out int b) { var arr = IntArr; a = arr[0]; b = arr[1]; }\n public void Multi(out int a, out int b, out int c) { var arr = IntArr; a = arr[0]; b = arr[1]; c = arr[2]; }\n public void Multi(out int a, out string b) { var arr = StrArr; a = int.Parse(arr[0]); b = arr[1]; }\n public void Multi(out string a, out int b) { var arr = StrArr; a = arr[0]; b = int.Parse(arr[1]); }\n public void Multi(out int a, out char b) { var arr = StrArr; a = int.Parse(arr[0]); b = arr[1][0]; }\n public void Multi(out char a, out int b) { var arr = StrArr; a = arr[0][0]; b = int.Parse(arr[1]); }\n public void Multi(out long a, out long b) { var arr = LongArr; a = arr[0]; b = arr[1]; }\n public void Multi(out long a, out int b) { var arr = LongArr; a = arr[0]; b = (int)arr[1]; }\n public void Multi(out int a, out long b) { var arr = LongArr; a = (int)arr[0]; b = arr[1]; }\n public void Multi(out string a, out string b) { var arr = StrArr; a = arr[0]; b = arr[1]; }\n}\nclass mymath\n{\n public bool isprime(long a)\n {\n if (a < 2) return false;\n for (long i = 2; i * i <= a; i++) if (a % i == 0) return false;\n return true;\n }\n public long[][] powmat(long[][] A, long n, int M)\n {\n var E = new long[A.Length][];\n for (int i = 0; i < A.Length; i++)\n {\n E[i] = new long[A.Length];\n E[i][i] = 1;\n }\n if (n == 0) return E;\n var t = powmat(A, n / 2, M);\n if ((n & 1) == 0) return mulmat(t, t, M);\n return mulmat(mulmat(t, t, M), A, M);\n }\n public long[] mulmat(long[][] A, long[] x, int M)\n {\n var ans = new long[A.Length];\n for (int i = 0; i < A.Length; i++) for (int j = 0; j < x.Length; j++) ans[i] = (ans[i] + x[j] * A[i][j]) % M;\n return ans;\n }\n public long[][] mulmat(long[][] A, long[][] B, int M)\n {\n var ans = new long[A.Length][];\n for (int i = 0; i < A.Length; i++)\n {\n ans[i] = new long[B[0].Length];\n for (int j = 0; j < B[0].Length; j++) for (int k = 0; k < B.Length; k++) ans[i][j] = (ans[i][j] + A[i][k] * B[k][j]) % M;\n }\n return ans;\n }\n public long powmod(long a, long b, long M)\n {\n if (a == 0) return 0;\n if (b == 0) return 1;\n var t = powmod(a, b / 2, M);\n if ((b & 1) == 0) return t * t % M;\n return t * t % M * a % M;\n }\n public long gcd(long a, long b)\n {\n while (b > 0) { var t = a % b; a = b; b = t; }\n return a;\n }\n public long lcm(long a, long b) { return a * (b / gcd(a, b)); }\n public long Comb(int n, int r)\n {\n const int M = 1000000007;\n if (n < 0 || r < 0 || r > n) return 0;\n if (n - r < r) r = n - r;\n if (r == 0) return 1;\n if (r == 1) return n;\n var numerator = new int[r];\n var denominator = new int[r];\n for (int k = 0; k < r; k++)\n {\n numerator[k] = n - r + k + 1;\n denominator[k] = k + 1;\n }\n for (int p = 2; p <= r; p++)\n {\n int pivot = denominator[p - 1];\n if (pivot > 1)\n {\n int offset = (n - r) % p;\n for (int k = p - 1; k < r; k += p)\n {\n numerator[k - offset] /= pivot;\n denominator[k] /= pivot;\n }\n }\n }\n long result = 1;\n for (int k = 0; k < r; k++) if (numerator[k] > 1) result = result * numerator[k] % M;\n return result;\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "dp"], "code_uid": "49df7ee3b951ff3dc048fa4c7cc6c9d2", "src_uid": "08f1ba79ced688958695a7cfcfdda035", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\n\nclass Program\n {\n \n static void Main(string[] args)\n {\n string npt = Console.ReadLine();\n int fr = 0;\n int sv = 0;\n for (int i = 0; i < npt.Length; ++i)\n if (npt[i] == '4')\n fr++;\n else if (npt[i] == '7')\n sv++;\n if (sv == 0 && fr == 0)\n Console.WriteLine(\"-1\");\n else Console.WriteLine(sv > fr ? \"7\" : \"4\");\n }\n }", "lang_cluster": "C#", "tags": ["brute force", "implementation"], "code_uid": "946146eacbf70731c82c46dcc8b225c1", "src_uid": "639b8b8d0dc42df46b139f0aeb3a7a0a", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\n\n\nnamespace SportProg\n{\n class Program\n {\n static void Main(string[] args)\n {\n string a =System.Console.ReadLine();\n int b=0,c=0;\n for (int i = 0; i b) System.Console.WriteLine(\"7\"); \n else if ((b == c) && (c == 0)) System.Console.WriteLine(-1);\n else if (b >= c) System.Console.WriteLine(\"4\");\n System.Console.ReadLine();\n return;\n \n\n\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "implementation"], "code_uid": "15eaafa7456ed863d373e5b1c12e928a", "src_uid": "639b8b8d0dc42df46b139f0aeb3a7a0a", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections;\nusing System.Linq;\nusing System.Text.RegularExpressions;\n\nnamespace ConsoleApplication2\n{\n class Program\n {\n static void Main(string[] args)\n {\n /*******************************************/\n Hashtable hashtable = new Hashtable();\n hashtable.Add('6', 1);\n hashtable.Add('7', 2);\n hashtable.Add('8', 3);\n hashtable.Add('9', 4);\n hashtable.Add('T', 5);\n hashtable.Add('J', 6);\n hashtable.Add('Q', 7);\n hashtable.Add('K', 8);\n hashtable.Add('A', 9);\n /*******************************************/\n\n char trup = Convert.ToChar(Console.ReadLine());\n string[] Cards = Console.ReadLine().Split();\n\n string c1 = Cards[0];\n string c2 = Cards[1];\n\n\n if (c1[1] == c2[1])\n Console.WriteLine((int)hashtable[c1[0]] >= (int)hashtable[c2[0]] ? \"YES\" : \"NO\");\n else\n Console.WriteLine((c1[1] == trup) ? \"YES\" : \"NO\");\n //Console.Read();\n }\n }\n}", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "83fcc662526df7ac245165b93fd2f683", "src_uid": "da13bd5a335c7f81c5a963b030655c26", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\n\nnamespace _82_A\n{\n class Program\n {\n static void Main(string[] args)\n {\n char cosir = Console.ReadLine()[0];\n string[] cards = Console.ReadLine().Split(' ');\n if (cards[0][1] == cards[1][1])\n {\n if (price(cards[0][0]) > price(cards[1][0]))\n Console.WriteLine(\"YES\");\n else\n Console.WriteLine(\"NO\");\n }\n else if (cards[0][1] == cosir)\n Console.WriteLine(\"YES\");\n else\n Console.WriteLine(\"NO\");\n }\n static int price(char c)\n {\n return \"6789TJQKA\".IndexOf(c);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "7909015898004baf7023767fc10957e6", "src_uid": "da13bd5a335c7f81c5a963b030655c26", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace C.Tic_tac_toe\n{\n class Program\n {\n static void Main(string[] args)\n {\n string[] s1 = new string[3];\n int q = 0;\n int x = 0, o = 0, X = 0, O = 0;\n for (int i = 0; i < s1.Length; i++)\n {\n s1[i] = Console.ReadLine();\n for (int j = 0; j < s1[i].Length; j++)\n {\n if (s1[i][j] == 'X') x++;\n if (s1[i][j] == '0') o++;\n if (s1[i][j] == '.') q++;\n }\n if (s1[i] == \"XXX\") X = 1;\n if (s1[i] == \"000\") O = 1;\n }\n if (s1[0][0] == 'X' && s1[1][0] == 'X' && s1[2][0] == 'X') X = 1;\n else if (s1[0][1] == 'X' && s1[1][1] == 'X' && s1[2][1] == 'X') X = 1;\n else if (s1[0][2] == 'X' && s1[1][2] == 'X' && s1[2][2] == 'X') X = 1;\n else if (s1[0][0] == 'X' && s1[1][1] == 'X' && s1[2][2] == 'X') X = 1;\n else if (s1[0][2] == 'X' && s1[1][1] == 'X' && s1[2][0] == 'X') X = 1;\n\n else if (s1[0][0] == '0' && s1[1][0] == '0' && s1[2][0] == '0') O = 1;\n else if (s1[0][1] == '0' && s1[1][1] == '0' && s1[2][1] == '0') O = 1;\n else if (s1[0][2] == '0' && s1[1][2] == '0' && s1[2][2] == '0') O = 1;\n else if (s1[0][0] == '0' && s1[1][1] == '0' && s1[2][2] == '0') O = 1;\n else if (s1[0][2] == '0' && s1[1][1] == '0' && s1[2][0] == '0') O = 1;\n if (q != 0)\n {\n if (o > x || x - o > 1) Console.WriteLine(\"illegal\");\n else if (X == 1 && o == x) Console.WriteLine(\"illegal\");\n else if (O == 1 && x > o) Console.WriteLine(\"illegal\");\n else if (X == 1) Console.WriteLine(\"the first player won\");\n else if (O == 1) Console.WriteLine(\"the second player won\");\n else if (x == o) Console.WriteLine(\"first\");\n else if (x > o) Console.WriteLine(\"second\");\n }\n else\n {\n if (o > x || x - o > 1) Console.WriteLine(\"illegal\");\n else if (X == 1 && o == x) Console.WriteLine(\"illegal\");\n else if (O == 1 && x > o) Console.WriteLine(\"illegal\");\n else if (X == 1) Console.WriteLine(\"the first player won\");\n else if (O == 1) Console.WriteLine(\" the second player won\");\n else Console.WriteLine(\"draw\");\n }\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "implementation", "games"], "code_uid": "d51f7b3d131fccaa693f62d4c87ab743", "src_uid": "892680e26369325fb00d15543a96192c", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nclass CFBR3C\n{\n\tstatic void Main()\n\t{\n\t\tbyte xCount;\n\t\tbyte emptyCount;\n\t\tsbyte[,] gameState = GetGameState(out xCount, out emptyCount);\n\t\tConsole.WriteLine(GetVerdict(gameState, xCount, emptyCount));\n\t}\n\t\n\tstatic string GetVerdict(sbyte[,] gs, byte xCount, byte eCount)\n\t{\n\t\tbyte zCount = (byte)(9 - (xCount + eCount));\n\t\tbool firstPlayerWon = false;\n\t\tbool secondPlayerWon = false;\n\t\tif ((xCount == 0) && (zCount == 0)) return \"first\";\n\t\telse if (Math.Abs(xCount - zCount) > 1) return \"illegal\";\n\t\telse if (xCount < zCount) return \"illegal\";\n\t\telse if (((gs[0, 0] == 1) && (gs[1, 1] == 1) && (gs[2, 2] == 1)) || ((gs[0, 2] == 1) && (gs[1, 1] == 1) && (gs[2, 0] == 1))) firstPlayerWon = true;\n\t\telse if (((gs[0, 0] == 0) && (gs[1, 1] == 0) && (gs[2, 2] == 0)) || ((gs[0, 2] == 0) && (gs[1, 1] == 0) && (gs[2, 0] == 0))) secondPlayerWon = true;\n\t\tfor (byte i = 0; i < 3; i++)\n\t\t{\n\t\t\tif (((gs[i, 0] == 1) && (gs[i, 1] == 1) && (gs[i, 2] == 1)) || ((gs[0, i] == 1) && (gs[1, i] == 1) && (gs[2, i] == 1))) firstPlayerWon = true;\n\t\t\telse if (((gs[i, 0] == 0) && (gs[i, 1] == 0) && (gs[i, 2] == 0)) || ((gs[0, i] == 0) && (gs[1, i] == 0) && (gs[2, i] == 0))) secondPlayerWon = true;\n\t\t\tif (firstPlayerWon == true && secondPlayerWon == true) return \"illegal\";\n\t\t}\n\t\tif (firstPlayerWon == true)\n\t\t{\n\t\t\tif (xCount == zCount) return \"illegal\";\n\t\t\telse return \"the first player won\";\n\t\t}\n\t\telse if (secondPlayerWon == true)\n\t\t{\n\t\t\tif (zCount < xCount) return \"illegal\";\n\t\t\telse return \"the second player won\";\n\t\t}\n\t\t\n\t\tif (eCount > 0)\n\t\t{\n\t\t\tif (xCount > zCount) return \"second\";\n\t\t\telse return \"first\";\n\t\t}\n\t\treturn \"draw\";\n\t}\n\t\n\tstatic sbyte[,] GetGameState(out byte xCount, out byte emptyCount)\n\t{\n\t\txCount = 0;\n\t\temptyCount = 0;\n\t\tsbyte[,] gameState = new sbyte[3, 3];\n\t\tfor (byte i = 0; i < 3; i++)\n\t\t{\n\t\t\tstring line = Console.ReadLine();\n\t\t\tfor (byte j = 0; j < 3; j++)\n\t\t\t{\n\t\t\t\tswitch(line[j])\n\t\t\t\t{\n\t\t\t\t\tcase 'X':\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tgameState[i, j] = 1;\n\t\t\t\t\t\t\txCount++;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\tcase '0':\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tgameState[i, j] = 0;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\tcase '.':\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tgameState[i, j] = -1;\n\t\t\t\t\t\t\temptyCount++;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn gameState;\n\t}\n}", "lang_cluster": "C#", "tags": ["brute force", "implementation", "games"], "code_uid": "540e6a79393188df2f1da595991455ed", "src_uid": "892680e26369325fb00d15543a96192c", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace ConsoleApplication2\n{\n class Program\n {\n static void Main(string[] args)\n {\n string s1 = Console.ReadLine();\n string s2 = Console.ReadLine();\n bool f = false;\n bool b = false;\n for (int i = 0; i < s1.Length; i++)\n {\n if (s1.Length==s2.Length &&s1[i] == s2[(s2.Length - 1) - i]) f = true;\n else b = true;\n }\n if (f == true && b == false) Console.WriteLine(\"YES\");\n else Console.WriteLine(\"NO\");\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["strings", "implementation"], "code_uid": "c32f0ea6e521375e45747148682c5199", "src_uid": "35a4be326690b58bf9add547fb63a5a5", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\n\nclass A41 {\n public static void Main() {\n var s1 = Console.ReadLine().ToCharArray();\n Array.Reverse(s1);\n var s2 = Console.ReadLine();\n Console.WriteLine(new string(s1) == s2 ? \"YES\" : \"NO\");\n }\n}\n", "lang_cluster": "C#", "tags": ["strings", "implementation"], "code_uid": "7ea74d1a5beeb577a36a55b96dfdfcca", "src_uid": "35a4be326690b58bf9add547fb63a5a5", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace PashaMax\n{\n class Program\n {\n static void Main(string[] args)\n {\n\n #region \u0412\u0432\u043e\u0434\n//lol:\n string input = Console.ReadLine();\n\n var data = input.Split(' ');\n\n int[] numbers = new int[data[0].Length];\n\n for (int index = 0; index < data[0].Length; index++)\n {\n numbers[index] = (int) Char.GetNumericValue(data[0][index]);\n }\n \n int k = Convert.ToInt32(data[1]);\n\n #endregion\n\n Tuple pos;\n int m = 0;\n int m2 = 0;\n while (k > 0)\n {\n ////if (k+1-m2 <=0) break;\n\n //if (k >= numbers.Length)\n //{\n // m = numbers.ToList().IndexOf(numbers.Max());\n\n // if (m == 0)\n // {\n // if (fi)\n // m2++;\n // continue;\n // }\n\n // numbers = DvigLeft(numbers, m + m2, m2);\n\n // k -= m;\n //}\n //else\n //{\n pos = FindToChange(numbers, k);\n\n if (pos.Item2 - pos.Item1 == 0) break;\n\n numbers = DvigLeft(numbers, pos.Item2, pos.Item1);\n\n k -= pos.Item2 - pos.Item1;\n //m = numbers.ToList().GetRange(m2, k+1-m2).IndexOf(numbers.ToList().GetRange(m2, k+1-m2).Max());\n //}\n }\n\n #region \u0412\u044b\u0432\u043e\u0434\n\n string res = numbers.Aggregate(\"\", (current, number) => current + number);\n\n Console.WriteLine(res);\n //Console.ReadKey();\n //goto lol;\n\n #endregion\n\n }\n\n private static int FindToChange(int[] numbers)\n {\n for (int i = 1; i < numbers.Length; i++)\n {\n if (numbers[i - 1] < numbers[i]) return i;\n }\n return 0;\n }\n\n private static Tuple FindToChange(int[] numbers, int k)\n {\n int maxindex = 0;\n int minindex = 0;\n\n for (int i = 0; i < numbers.Length; i++)\n {\n int maxvalue = 0;\n\n int indx = k+1 + minindex;\n if (indx >= numbers.Length)\n indx = numbers.Length;\n \n for (int j = minindex; j < indx; j++)\n {\n if (maxvalue < numbers[j])\n {\n maxvalue = numbers[j];\n maxindex = j;\n }\n }\n\n if (maxindex != minindex && maxindex> minindex) \n return new Tuple(minindex, maxindex);\n\n minindex++;\n }\n \n return new Tuple(0,0);\n }\n\n static int[] DvigLeft(int[] old, int oldpos, int newpos)\n {\n int[] res = (int[]) old.Clone();\n\n res[newpos] = old[oldpos];\n\n for (int i = newpos; i < oldpos; i++)\n {\n res[i+1] = old[i];\n }\n\n return res;\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["greedy"], "code_uid": "3575e7c0b97ee7f88ca7eb8c0b88ce0e", "src_uid": "e56f6c343167745821f0b18dcf0d0cde", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace lab13\n{\n class Program\n {\n static string a = null;\n static long[] aa = new long[20];\n\n static void Main(string[] args)\n {\n int i;\n long k;\n \n FillChar(aa, 0);\n int f = 1;\n\n long[] input = Console.ReadLine().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(p => long.Parse(p)).ToArray();\n a = input[0].ToString();\n k = input[1];\n\n int len = a.Length;\n for (i = 1; i <= len; i++) aa[i] = a[i - 1] - '0';\n\n while(k > 0)\n {\n long max = -1;\n int flag = 0;\n for(i = f; i <= f + k && i <= len; i++)\n {\n if(max < aa[i]) \n { \n max = aa[i]; \n flag = i;\n }\n }\n for(i = flag; i > f; i--)\n {\n long c = aa[i];\n aa[i] = aa[i-1];\n aa[i-1] = c;\n }\n k = k - flag + f;\n f++;\n if(f > len) break;\n }\n for(i = 1; i <= len; i++) \n Console.Write(aa[i]);\n Console.WriteLine();\n }\n public static void FillChar(T[] array, T value)\n {\n for (int i = 0; i < array.Length; i++)\n array[i] = value;\n }\n }\n}", "lang_cluster": "C#", "tags": ["greedy"], "code_uid": "38be8fc6e450f2c62a368b75c6e1dd1b", "src_uid": "e56f6c343167745821f0b18dcf0d0cde", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace A.Carrot_Cakes\n{\n class Program\n {\n static void Main(string[] args)\n {\n int[] r = Console.ReadLine().Split().Select(int.Parse).ToArray();\n int x = 0;\n int y = 0;\n while(y r[3]+r[1])\n {\n Console.WriteLine(\"YES\");\n }\n else\n {\n Console.WriteLine(\"NO\");\n }\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "implementation"], "code_uid": "0f397a813c9ba1f455d5e8083f4ae5c4", "src_uid": "32c866d3d394e269724b4930df5e4407", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.IO;\nusing System.Text;\nusing System.Globalization;\nusing System.Diagnostics;\nusing System.Numerics;\n\n\n\nclass Myon\n{\n public Myon() { }\n public static int Main()\n {\n new Myon().calc();\n return 0;\n }\n\n Scanner cin;\n \n\n void calc()\n {\n cin = new Scanner();\n bool flag = false;\n\n int n, t, k, d;\n n = cin.nextInt();\n t = cin.nextInt();\n k = cin.nextInt();\n d = cin.nextInt();\n\n int needtime = (n + (k - 1)) / k * t;\n if (needtime - d > t) flag = true; \n\n if (flag) Console.WriteLine(\"YES\");\n else Console.WriteLine(\"NO\");\n }\n\n\n\n}\n\nclass Scanner\n{\n string[] s;\n int i;\n\n char[] cs = new char[] { ' ' };\n\n public Scanner()\n {\n s = new string[0];\n i = 0;\n }\n\n public string next()\n {\n if (i < s.Length) return s[i++];\n string st = Console.ReadLine();\n while (st == \"\") st = Console.ReadLine();\n s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);\n i = 0;\n return s[i++];\n }\n\n public int nextInt()\n {\n return int.Parse(next());\n }\n\n public long nextLong()\n {\n return long.Parse(next());\n }\n\n public double nextDouble()\n {\n return double.Parse(next());\n }\n\n}", "lang_cluster": "C#", "tags": ["brute force", "implementation"], "code_uid": "ee573a7b3d8c92044c13cc60763ac386", "src_uid": "32c866d3d394e269724b4930df5e4407", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\n\nnamespace CodeForce\n{\n class Program\n {\n static void Main(string[] args)\n {\n Console.ReadLine();\n string Data = Console.ReadLine().Replace(\"0\", \"\");\n if (Data.Length == 0) { Console.WriteLine(\"YES\"); return; };\n for (int i = 1; i < Data.Length; i++)\n {\n string measure = Data.Remove(i);\n int int_main = Func(measure);\n string pickup = Data.Remove(0,i);\n for (int j = 0; j < pickup.Length; j++)\n {\n string S = pickup.Substring(0, j+1);\n int Varable = Func(S);\n if (Varable > int_main) break;\n if (Varable == int_main)\n {\n pickup = pickup.Remove(0, j+1);\n j = -1;\n }\n if (pickup.Length == 0) { Console.WriteLine(\"YES\"); return; }\n }\n }\n Console.WriteLine(\"NO\");\n }\n static int Func(string num)\n {\n int A = 0;\n for (int i = 0; i < num.Length; i++)\n {\n string S = num[i].ToString();\n A += int.Parse(S);\n }\n return A;\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "61cb8dbe1ee844fe61d6e4b85962743e", "src_uid": "410296a01b97a0a39b6683569c84d56c", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\n\nclass Solution {\n\tstatic int Main () {\n\t\tstring s; \n\t\tint n;\n\t\tn = Convert.ToInt32(Console.ReadLine());\n\t\ts = Console.ReadLine();\n\n\t\tfor (int i = 0; i < n-1; i++) {\n\t\t\tint tmp = 0;\n\t\t\tfor (int j = 0; j <= i; j++) tmp += s[j]-'0';\n\t\t\tbool ans = false;\n\t\t\tint aux = 0;\n\t\t\tfor (int j = i+1; j < n; j++) {\n\t\t\t\taux += s[j]-'0';\n\t\t\t\tif (aux == tmp) {\n\t\t\t\t\tans = true;\n\t\t\t\t\tif (j < n-1) aux = 0;\n\t\t\t\t\telse break;\n\t\t\t\t} else if (aux > tmp) {\n\t\t\t\t\tans = false;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (aux != 0 && aux < tmp) ans = false;\n\t\t\tif (ans) {\n\t\t\t\tConsole.WriteLine(\"YES\");\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t}\n\n\t\tConsole.WriteLine(\"NO\");\t\n\t\treturn 0;\n\t}\n}", "lang_cluster": "C#", "tags": ["brute force", "implementation"], "code_uid": "06bd55c83c499eacca74240acc02857d", "src_uid": "410296a01b97a0a39b6683569c84d56c", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\n\nnamespace task160B\n{\n class Program\n {\n static void Main(string[] args)\n {\n Console.ReadLine();\n string input = Console.ReadLine();\n List f = new List();\n for (Int32 i = 0; i < input.Length >> 1; i++)\n {\n f.Add(input[i] - 48);\n }\n List s = new List();\n for (Int32 i = input.Length >> 1; i < input.Length; i++)\n {\n s.Add(input[i] - 48);\n }\n f.Sort();\n s.Sort();\n Int32 k = 0;\n Int32 l = 0;\n for (Int32 i = 0;i< f.Count; i++)\n {\n if (f[i] < s[i])\n {\n k++;\n }\n else\n if (f[i] > s[i])\n {\n l++;\n }\n }\n if (k == f.Count)\n {\n Console.WriteLine(\"YES\");\n return;\n }\n else\n if (l == f.Count)\n {\n Console.WriteLine(\"YES\");\n return;\n }\n else\n Console.WriteLine(\"NO\");\n //Console.ReadLine();\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["sortings", "greedy"], "code_uid": "dfa23217d98f4a25e89960a9411b00e7", "src_uid": "e4419bca9d605dbd63f7884377e28769", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\n\n\n public class unluckyTicket\n {\n public static void Main()\n {\n int n = Convert.ToInt32(Console.ReadLine());\n string input = Console.ReadLine();\n \n //int n = 2;\n //string input = \"2421\";\n char[] leftHalf = input.ToCharArray(0, n);\n char[] rightHalf = input.ToCharArray(n, n);\n\n Array.Sort(leftHalf);\n Array.Sort(rightHalf);\n\n string answer = \"YES\";\n if (leftHalf[0] > rightHalf[0])\n {\n for (int i = 1; i < leftHalf.Length; i++)\n {\n if (leftHalf[i] <= rightHalf[i])\n {\n answer = \"NO\";\n break;\n }\n }\n }\n else\n {\n if (leftHalf[0] < rightHalf[0])\n {\n for (int i = 1; i < leftHalf.Length; i++)\n {\n if (leftHalf[i] >= rightHalf[i])\n {\n answer = \"NO\";\n break;\n }\n }\n }\n else\n {\n answer = \"NO\";\n }\n }\n\n Console.WriteLine(answer);\n }\n }\n\n", "lang_cluster": "C#", "tags": ["sortings", "greedy"], "code_uid": "430f3db86d91ca7f7f7e6e9ac4d18db9", "src_uid": "e4419bca9d605dbd63f7884377e28769", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\n\nclass TEST{\n\tstatic void Main(){\n\t\tSol mySol =new Sol();\n\t\tmySol.Solve();\n\t}\n}\n\nclass Sol{\n\tpublic void Solve(){\n\t\t\n\t\tint tot = 0;\n\t\t\n\t\ttot += A;\n\t\tif(X > tot){\n\t\t\tConsole.WriteLine(\"NO\");\n\t\t\treturn;\n\t\t}\n\t\ttot -= X;\n\t\ttot += B;\n\t\tif(Y > tot){\n\t\t\tConsole.WriteLine(\"NO\");\n\t\t\treturn;\n\t\t}\n\t\t\n\t\ttot -= Y;\n\t\ttot += C;\n\t\tif(Z > tot){\n\t\t\tConsole.WriteLine(\"NO\");\n\t\t\treturn;\n\t\t}\n\t\t\n\t\tConsole.WriteLine(\"YES\");\n\t}\n\tint X,Y,Z;\n\tint A,B,C;\n\tpublic Sol(){\n\t\tvar d = ria();\n\t\tX = d[0]; Y = d[1]; Z = d[2];\n\t\td = ria();\n\t\tA = d[0]; B = d[1]; C = d[2];\n\t}\n\n\tstatic String rs(){return Console.ReadLine();}\n\tstatic int ri(){return int.Parse(Console.ReadLine());}\n\tstatic long rl(){return long.Parse(Console.ReadLine());}\n\tstatic double rd(){return double.Parse(Console.ReadLine());}\n\tstatic String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}\n\tstatic int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}\n\tstatic long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}\n\tstatic double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}\n}\n", "lang_cluster": "C#", "tags": ["brute force", "greedy", "implementation"], "code_uid": "f020b2613af2445a28d13c716dc44d12", "src_uid": "d54201591f7284da5e9ce18984439f4e", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.IO;\nusing System.Runtime.CompilerServices;\nusing System.Text;\nusing static Template;\nusing static System.Console;\nusing static System.Convert;\nusing static System.Math;\nusing Pi = Pair;\n\nclass Solver\n{\n Scanner sc = new Scanner();\n //\n\n public void Solve()\n {\n int x, y, z, a, b, c;\n sc.Make(out x, out y, out z, out a, out b, out c);\n if (x > a) Fail(\"NO\");\n a -= x;\n if (a + b < y) Fail(\"NO\");\n if (a + b + c - y < z) Fail(\"NO\");\n WriteLine(\"YES\");\n }\n}\n\n#region Template\npublic class Template\n{\n static void Main(string[] args)\n {\n Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });\n new Solver().Solve();\n Console.Out.Flush();\n }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static bool chmin(ref T a, T b) where T : IComparable\n { if (a.CompareTo(b) == 1) { a = b; return true; } return false; }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static bool chmax(ref T a, T b) where T : IComparable\n { if (a.CompareTo(b) == -1) { a = b; return true; } return false; }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static void swap(ref T a, ref T b)\n { var t = b; b = a; a = t; }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static T[] Create(int n, Func f)\n {\n var rt = new T[n];\n for (var i = 0; i < rt.Length; ++i)\n rt[i] = f();\n return rt;\n }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static T[] Create(int n, Func f)\n {\n var rt = new T[n];\n for (var i = 0; i < rt.Length; ++i)\n rt[i] = f(i);\n return rt;\n }\n public static void Fail(T s) { Console.WriteLine(s); Console.Out.Close(); Environment.Exit(0); }\n}\n\npublic class Scanner\n{\n public string Str => ReadLine().Trim();\n public int Int => int.Parse(Str);\n public long Long => long.Parse(Str);\n public double Double => double.Parse(Str);\n public int[] ArrInt => Str.Split(' ').Select(int.Parse).ToArray();\n public long[] ArrLong => Str.Split(' ').Select(long.Parse).ToArray();\n public char[][] Grid(int n) => Create(n, () => Str.ToCharArray());\n public int[] ArrInt1D(int n) => Create(n, () => Int);\n public long[] ArrLong1D(int n) => Create(n, () => Long);\n public int[][] ArrInt2D(int n) => Create(n, () => ArrInt);\n public long[][] ArrLong2D(int n) => Create(n, () => ArrLong);\n public Pair PairMake() => new Pair(Next(), Next());\n public Pair PairMake() => new Pair(Next(), Next(), Next());\n private Queue q = new Queue();\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public T Next() { if (q.Count == 0) foreach (var item in Str.Split(' ')) q.Enqueue(item); return (T)Convert.ChangeType(q.Dequeue(), typeof(T)); }\n public void Make(out T1 v1) => v1 = Next();\n public void Make(out T1 v1, out T2 v2) { v1 = Next(); v2 = Next(); }\n public void Make(out T1 v1, out T2 v2, out T3 v3) { Make(out v1, out v2); v3 = Next(); }\n public void Make(out T1 v1, out T2 v2, out T3 v3, out T4 v4) { Make(out v1, out v2, out v3); v4 = Next(); }\n public void Make(out T1 v1, out T2 v2, out T3 v3, out T4 v4, out T5 v5) { Make(out v1, out v2, out v3, out v4); v5 = Next(); }\n public void Make(out T1 v1, out T2 v2, out T3 v3, out T4 v4, out T5 v5, out T6 v6) { Make(out v1, out v2, out v3, out v4, out v5); v6 = Next(); }\n}\n\npublic class Pair : IComparable>\n{\n public T1 v1;\n public T2 v2;\n public Pair() { }\n public Pair(T1 v1, T2 v2)\n { this.v1 = v1; this.v2 = v2; }\n\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public int CompareTo(Pair p)\n {\n var c = Comparer.Default.Compare(v1, p.v1);\n if (c == 0)\n c = Comparer.Default.Compare(v2, p.v2);\n return c;\n }\n public override string ToString() => $\"{v1.ToString()} {v2.ToString()}\";\n public void Tie(out T1 a, out T2 b) { a = v1; b = v2; }\n}\n\npublic class Pair : Pair, IComparable>\n{\n public T3 v3;\n public Pair() : base() { }\n public Pair(T1 v1, T2 v2, T3 v3) : base(v1, v2)\n { this.v3 = v3; }\n\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public int CompareTo(Pair p)\n {\n var c = base.CompareTo(p);\n if (c == 0)\n c = Comparer.Default.Compare(v3, p.v3);\n return c;\n }\n public override string ToString() => $\"{base.ToString()} {v3.ToString()}\";\n public void Tie(out T1 a, out T2 b, out T3 c) { Tie(out a, out b); c = v3; }\n}\n#endregion\n", "lang_cluster": "C#", "tags": ["brute force", "greedy", "implementation"], "code_uid": "6a82f9a129c29f3719593df4a460df9e", "src_uid": "d54201591f7284da5e9ce18984439f4e", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.IO;\nusing SB = System.Text.StringBuilder;\n//using System.Threading.Tasks;\n//using System.Text.RegularExpressions;\n//using System.Globalization;\n//using System.Diagnostics;\nusing static System.Console;\nusing System.Numerics;\nusing static System.Math;\nusing pair = Pair;\n\nclass Program\n{\n static void Main()\n {\n //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });\n new Program().solve();\n Out.Flush();\n }\n readonly Scanner cin = new Scanner();\n readonly int[] dd = { 0, 1, 0, -1, 0 }; //\u2192\u2193\u2190\u2191\n readonly int mod = 1000000007;\n readonly int dom = 998244353;\n bool chmax(ref T a, T b) where T : IComparable { if (a.CompareTo(b) < 0) { a = b; return true; } return false; }\n bool chmin(ref T a, T b) where T : IComparable { if (b.CompareTo(a) < 0) { a = b; return true; } return false; }\n\n void solve()\n {\n int N = cin.nextint;\n var dp = new ModInt[2 * N + 1, N + 1];\n dp[0, 0] = 1;\n for (int i = 1; i <= 2 * N; i++)\n {\n for (int j = i % 2; j <= Min(N, 2 * N - i); j += 2)\n {\n if (j > 0) dp[i, j] = dp[i - 1, j - 1];\n if (j < N) dp[i, j] += dp[i - 1, j + 1];\n }\n }\n\n var S = new ModInt[2 * N + 1];\n for (int i = 0; i < S.Length; i++)\n {\n for (int j = 0; j <= N; j++)\n {\n S[i] += dp[i, j];\n }\n }\n S.Reverse();\n // S.join();\n \n\n ModInt ans = 0;\n for (int i = 1; i < S.Length; i += 2)\n {\n ans += S[i];\n }\n WriteLine(ans);\n\n //for (int i = 0; i < N; i++)\n //{\n // for (int j = 0; j < (i + 1) * 2; j++)\n // {\n // dp[j] += 1;\n // }\n // if (i > 0) dp[i * 2] += 1;\n //}\n //dp.join();\n //ModInt ans = 1;\n //foreach (var item in dp)\n //{\n // ans *= item;\n //}\n //WriteLine(ans);\n }\n\n}\n\n/// camypaper\nclass FenwickTree\n{\n readonly int n;\n readonly long[] bit;\n readonly int max = 1;\n public FenwickTree(int size)\n {\n n = size; bit = new long[n + 1];\n while ((max << 1) <= n) max <<= 1;\n }\n /// sum[a, b] 0-indexed\n public long this[int i, int j] { get { i++; j++; return i <= j ? this[j] - this[i - 1] : 0; } }\n /// sum[1, i] 1-indexed\n public long this[int i] { get { long s = 0; for (; i > 0; i -= i & -i) s += bit[i]; return s; } }\n public int LowerBound(long w)\n {\n if (w <= 0) return 0;\n int x = 0;\n for (int k = max; k > 0; k >>= 1)\n if (x + k <= n && bit[x + k] < w)\n {\n w -= bit[x + k];\n x += k;\n }\n return x + 1;\n }\n /// add v to bit[i] 0-indexed\n public void Add(int i, long v)\n {\n i++;\n //if (i == 0) System.Diagnostics.Debug.Fail(\"BIT is 1 indexed\");\n for (; i <= n; i += i & -i) bit[i] += v;\n }\n public long[] Items\n {\n get\n {\n var ret = new long[n + 1];\n for (int i = 0; i < ret.Length; i++)\n ret[i] = this[i, i];\n return ret;\n }\n }\n}\n\nclass RangeAddFenwickTree\n{\n readonly int n;\n FenwickTree a, b;\n public RangeAddFenwickTree(int n)\n {\n this.n = n;\n a = new FenwickTree(n);\n b = new FenwickTree(n);\n }\n /// Add V to[i, j] 0-indexed\n public void Add(int i, int j, long v)\n {\n //a.Add(i, -(i - 1) * v); a.Add(j + 1, j * v);\n //b.Add(i, v); b.Add(j + 1, -v);\n a.Add(i, -i * v); a.Add(j + 1, (j + 1) * v);\n b.Add(i, v); b.Add(j + 1, -v);\n }\n /// Sum [1, i] 1-indexed\n public long this[int i] => a[i] + b[i] * i;\n /// Sum [i, j] 0-indexed\n public long this[int i, int j] { get { i++; j++; return i <= j ? this[j] - this[i - 1] : 0; } }\n public long[] Items\n {\n get\n {\n var ret = new long[n + 1];\n for (int i = 0; i < ret.Length; i++)\n ret[i] = this[i, i];\n return ret;\n }\n }\n}\n\n/// \n/// [0,) \u307e\u3067\u306e\u5024\u3092\u53d6\u308b\u3088\u3046\u306a\u6570\n/// \n/// camypaper\nstruct ModInt\n{\n /// \n /// \u5270\u4f59\u3092\u53d6\u308b\u5024\uff0e\n /// \n public const long Mod = (int)1e9 + 7;\n\n /// \n /// \u5b9f\u969b\u306e\u6570\u5024\uff0e\n /// \n public long num;\n /// \n /// \u5024\u304c \u3067\u3042\u308b\u3088\u3046\u306a\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u3092\u69cb\u7bc9\u3057\u307e\u3059\uff0e\n /// \n /// \u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u304c\u6301\u3064\u5024\n /// \u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u306e\u554f\u984c\u4e0a\uff0c\u30b3\u30f3\u30b9\u30c8\u30e9\u30af\u30bf\u5185\u3067\u306f\u5270\u4f59\u3092\u53d6\u308a\u307e\u305b\u3093\uff0e\u305d\u306e\u305f\u3081\uff0c \u2208 [0,) \u3092\u6e80\u305f\u3059\u3088\u3046\u306a \u3092\u6e21\u3057\u3066\u304f\u3060\u3055\u3044\uff0e\u3053\u306e\u30b3\u30f3\u30b9\u30c8\u30e9\u30af\u30bf\u306f O(1) \u3067\u5b9f\u884c\u3055\u308c\u307e\u3059\uff0e\n public ModInt(long n) { num = n; }\n /// \n /// \u3053\u306e\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u306e\u6570\u5024\u3092\u6587\u5b57\u5217\u306b\u5909\u63db\u3057\u307e\u3059\uff0e\n /// \n /// [0,) \u306e\u7bc4\u56f2\u5185\u306e\u6574\u6570\u3092 10 \u9032\u8868\u8a18\u3057\u305f\u3082\u306e\uff0e\n public override string ToString() { return num.ToString(); }\n public static ModInt operator +(ModInt l, ModInt r) { l.num += r.num; if (l.num >= Mod) l.num -= Mod; return l; }\n public static ModInt operator -(ModInt l, ModInt r) { l.num -= r.num; if (l.num < 0) l.num += Mod; return l; }\n public static ModInt operator *(ModInt l, ModInt r) { return new ModInt(l.num * r.num % Mod); }\n public static implicit operator ModInt(long n) { n %= Mod; if (n < 0) n += Mod; return new ModInt(n); }\n\n /// \n /// \u4e0e\u3048\u3089\u308c\u305f 2 \u3064\u306e\u6570\u5024\u304b\u3089\u3079\u304d\u5270\u4f59\u3092\u8a08\u7b97\u3057\u307e\u3059\uff0e\n /// \n /// \u3079\u304d\u4e57\u306e\u5e95\n /// \u3079\u304d\u6307\u6570\n /// \u7e70\u308a\u8fd4\u3057\u4e8c\u4e57\u6cd5\u306b\u3088\u308a O(N log N) \u3067\u5b9f\u884c\u3055\u308c\u307e\u3059\uff0e\n public static ModInt Pow(ModInt v, long k) { return Pow(v.num, k); }\n\n /// \n /// \u4e0e\u3048\u3089\u308c\u305f 2 \u3064\u306e\u6570\u5024\u304b\u3089\u3079\u304d\u5270\u4f59\u3092\u8a08\u7b97\u3057\u307e\u3059\uff0e\n /// \n /// \u3079\u304d\u4e57\u306e\u5e95\n /// \u3079\u304d\u6307\u6570\n /// \u7e70\u308a\u8fd4\u3057\u4e8c\u4e57\u6cd5\u306b\u3088\u308a O(N log N) \u3067\u5b9f\u884c\u3055\u308c\u307e\u3059\uff0e\n public static ModInt Pow(long v, long k)\n {\n long ret = 1;\n for (k %= Mod - 1; k > 0; k >>= 1, v = v * v % Mod)\n if ((k & 1) == 1) ret = ret * v % Mod;\n return new ModInt(ret);\n }\n /// \n /// \u4e0e\u3048\u3089\u308c\u305f\u6570\u306e\u9006\u5143\u3092\u8a08\u7b97\u3057\u307e\u3059\uff0e\n /// \n /// \u9006\u5143\u3092\u53d6\u308b\u5bfe\u8c61\u3068\u306a\u308b\u6570\n /// \u9006\u5143\u3068\u306a\u308b\u3088\u3046\u306a\u5024\n /// \u6cd5\u304c\u7d20\u6570\u3067\u3042\u308b\u3053\u3068\u3092\u4eee\u5b9a\u3057\u3066\uff0c\u30d5\u30a7\u30eb\u30de\u30fc\u306e\u5c0f\u5b9a\u7406\u306b\u5f93\u3063\u3066\u9006\u5143\u3092 O(log N) \u3067\u8a08\u7b97\u3057\u307e\u3059\uff0e\n public static ModInt Inverse(ModInt v) { return Pow(v, Mod - 2); }\n}\n\nclass BinomialCoefficient\n{\n public ModInt[] fact, ifact;\n public BinomialCoefficient(int n)\n {\n fact = new ModInt[n + 1];\n ifact = new ModInt[n + 1];\n fact[0] = 1;\n for (int i = 1; i <= n; i++)\n fact[i] = fact[i - 1] * i;\n ifact[n] = ModInt.Inverse(fact[n]);\n for (int i = n - 1; i >= 0; i--)\n ifact[i] = ifact[i + 1] * (i + 1);\n ifact[0] = ifact[1];\n }\n public ModInt this[int n, int r]\n {\n get\n {\n if (n < 0 || n >= fact.Length || r < 0 || r > n) return 0;\n return fact[n] * ifact[n - r] * ifact[r];\n }\n }\n public ModInt RepeatedCombination(int n, int k)\n {\n if (k == 0) return 1;\n return this[n + k - 1, k];\n }\n}\n\nstatic class Ex\n{\n public static void join(this IEnumerable values, string sep = \" \") => WriteLine(string.Join(sep, values));\n public static string concat(this IEnumerable values) => string.Concat(values);\n public static string reverse(this string s) { var t = s.ToCharArray(); Array.Reverse(t); return t.concat(); }\n\n public static int lower_bound(this IList arr, T val) where T : IComparable\n {\n int low = 0, high = arr.Count;\n int mid;\n while (low < high)\n {\n mid = ((high - low) >> 1) + low;\n if (arr[mid].CompareTo(val) < 0) low = mid + 1;\n else high = mid;\n }\n return low;\n }\n public static int upper_bound(this IList arr, T val) where T : IComparable\n {\n int low = 0, high = arr.Count;\n int mid;\n while (low < high)\n {\n mid = ((high - low) >> 1) + low;\n if (arr[mid].CompareTo(val) <= 0) low = mid + 1;\n else high = mid;\n }\n return low;\n }\n}\n\nclass Pair : IComparable> where T : IComparable where U : IComparable\n{\n public T f; public U s;\n public Pair(T f, U s) { this.f = f; this.s = s; }\n public int CompareTo(Pair a) => f.CompareTo(a.f) != 0 ? f.CompareTo(a.f) : s.CompareTo(a.s);\n public override string ToString() => $\"{f} {s}\";\n}\n\nclass Scanner\n{\n string[] s; int i;\n readonly char[] cs = new char[] { ' ' };\n public Scanner() { s = new string[0]; i = 0; }\n public string[] scan => ReadLine().Split();\n public int[] scanint => Array.ConvertAll(scan, int.Parse);\n public long[] scanlong => Array.ConvertAll(scan, long.Parse);\n public double[] scandouble => Array.ConvertAll(scan, double.Parse);\n public string next\n {\n get\n {\n if (i < s.Length) return s[i++];\n string st = ReadLine();\n while (st == \"\") st = ReadLine();\n s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);\n i = 0;\n return next;\n }\n }\n public int nextint => int.Parse(next);\n public long nextlong => long.Parse(next);\n public double nextdouble => double.Parse(next);\n}\n", "lang_cluster": "C#", "tags": ["greedy", "dp", "trees"], "code_uid": "2fdac96091d8b79c391167de5c42ac46", "src_uid": "8218255989e5eab73ac7107072c3b2af", "difficulty": 2100.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Linq;\nusing CompLib.Util;\nusing System.Threading;\nusing CompLib.Mathematics;\n\npublic class Program\n{\n int N;\n public void Solve()\n {\n var sc = new Scanner();\n N = sc.NextInt();\n // \u9577\u30552N\u306e\u304b\u3063\u3053\u5217\u3059\u3079\u3066\n // Trie\u306e\u6700\u5927\u30de\u30c3\u30c1\u30f3\u30b0\n\n // \u6728\n // 2\u8272\u306b\u5857\u3063\u3066\u5c11\u306a\u3044\u65b9\n\n // \u9802\u70b9\u5897\u3048\u65b9\n // \u4ee5\u964d>\u3057\u304b\u7f6e\u3051\u306a\u3044\n\n // < >>>>>\n\n\n // 0 1 2 3\n // 0: 1 \n // 1: 1 1 ... 1\n // 2: 2 2 1 ... 3\n // 3: 5 5 3 1\n // 4: \n\n var dp = new ModInt[N + 1][];\n for (int i = 0; i <= N; i++)\n {\n dp[i] = new ModInt[i + 1];\n }\n\n dp[0][0] = 1;\n for (int i = 0; i < N; i++)\n {\n ModInt tmp = 0;\n for (int j = i; j >= 0; j--)\n {\n tmp += dp[i][j];\n dp[i + 1][j + 1] = tmp;\n }\n dp[i + 1][0] = tmp;\n }\n\n ModInt ans = 0;\n for (int i = 0; i < N; i++)\n {\n for (int j = 0; j <= i; j++)\n {\n ans += dp[i][j] * ((j + 2) / 2);\n }\n }\n\n Console.WriteLine(ans);\n }\n\n public static void Main(string[] args) => new Program().Solve();\n // public static void Main(string[] args) => new Thread(new Program().Solve, 1 << 27).Start();\n}\n\n// https://bitbucket.org/camypaper/complib\nnamespace CompLib.Mathematics\n{\n #region ModInt\n /// \n /// [0,) \u307e\u3067\u306e\u5024\u3092\u53d6\u308b\u3088\u3046\u306a\u6570\n /// \n public struct ModInt\n {\n /// \n /// \u5270\u4f59\u3092\u53d6\u308b\u5024\uff0e\n /// \n public const long Mod = (int)1e9 + 7;\n // public const long Mod = 998244353;\n\n /// \n /// \u5b9f\u969b\u306e\u6570\u5024\uff0e\n /// \n public long num;\n /// \n /// \u5024\u304c \u3067\u3042\u308b\u3088\u3046\u306a\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u3092\u69cb\u7bc9\u3057\u307e\u3059\uff0e\n /// \n /// \u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u304c\u6301\u3064\u5024\n /// \u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u306e\u554f\u984c\u4e0a\uff0c\u30b3\u30f3\u30b9\u30c8\u30e9\u30af\u30bf\u5185\u3067\u306f\u5270\u4f59\u3092\u53d6\u308a\u307e\u305b\u3093\uff0e\u305d\u306e\u305f\u3081\uff0c \u2208 [0,) \u3092\u6e80\u305f\u3059\u3088\u3046\u306a \u3092\u6e21\u3057\u3066\u304f\u3060\u3055\u3044\uff0e\u3053\u306e\u30b3\u30f3\u30b9\u30c8\u30e9\u30af\u30bf\u306f O(1) \u3067\u5b9f\u884c\u3055\u308c\u307e\u3059\uff0e\n public ModInt(long n) { num = n; }\n /// \n /// \u3053\u306e\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u306e\u6570\u5024\u3092\u6587\u5b57\u5217\u306b\u5909\u63db\u3057\u307e\u3059\uff0e\n /// \n /// [0,) \u306e\u7bc4\u56f2\u5185\u306e\u6574\u6570\u3092 10 \u9032\u8868\u8a18\u3057\u305f\u3082\u306e\uff0e\n public override string ToString() { return num.ToString(); }\n public static ModInt operator +(ModInt l, ModInt r) { l.num += r.num; if (l.num >= Mod) l.num -= Mod; return l; }\n public static ModInt operator -(ModInt l, ModInt r) { l.num -= r.num; if (l.num < 0) l.num += Mod; return l; }\n public static ModInt operator *(ModInt l, ModInt r) { return new ModInt(l.num * r.num % Mod); }\n public static implicit operator ModInt(long n) { n %= Mod; if (n < 0) n += Mod; return new ModInt(n); }\n\n /// \n /// \u4e0e\u3048\u3089\u308c\u305f 2 \u3064\u306e\u6570\u5024\u304b\u3089\u3079\u304d\u5270\u4f59\u3092\u8a08\u7b97\u3057\u307e\u3059\uff0e\n /// \n /// \u3079\u304d\u4e57\u306e\u5e95\n /// \u3079\u304d\u6307\u6570\n /// \u7e70\u308a\u8fd4\u3057\u4e8c\u4e57\u6cd5\u306b\u3088\u308a O(N log N) \u3067\u5b9f\u884c\u3055\u308c\u307e\u3059\uff0e\n public static ModInt Pow(ModInt v, long k) { return Pow(v.num, k); }\n\n /// \n /// \u4e0e\u3048\u3089\u308c\u305f 2 \u3064\u306e\u6570\u5024\u304b\u3089\u3079\u304d\u5270\u4f59\u3092\u8a08\u7b97\u3057\u307e\u3059\uff0e\n /// \n /// \u3079\u304d\u4e57\u306e\u5e95\n /// \u3079\u304d\u6307\u6570\n /// \u7e70\u308a\u8fd4\u3057\u4e8c\u4e57\u6cd5\u306b\u3088\u308a O(N log N) \u3067\u5b9f\u884c\u3055\u308c\u307e\u3059\uff0e\n public static ModInt Pow(long v, long k)\n {\n long ret = 1;\n for (k %= Mod - 1; k > 0; k >>= 1, v = v * v % Mod)\n if ((k & 1) == 1) ret = ret * v % Mod;\n return new ModInt(ret);\n }\n /// \n /// \u4e0e\u3048\u3089\u308c\u305f\u6570\u306e\u9006\u5143\u3092\u8a08\u7b97\u3057\u307e\u3059\uff0e\n /// \n /// \u9006\u5143\u3092\u53d6\u308b\u5bfe\u8c61\u3068\u306a\u308b\u6570\n /// \u9006\u5143\u3068\u306a\u308b\u3088\u3046\u306a\u5024\n /// \u6cd5\u304c\u7d20\u6570\u3067\u3042\u308b\u3053\u3068\u3092\u4eee\u5b9a\u3057\u3066\uff0c\u30d5\u30a7\u30eb\u30de\u30fc\u306e\u5c0f\u5b9a\u7406\u306b\u5f93\u3063\u3066\u9006\u5143\u3092 O(log N) \u3067\u8a08\u7b97\u3057\u307e\u3059\uff0e\n public static ModInt Inverse(ModInt v) { return Pow(v, Mod - 2); }\n }\n #endregion\n #region Binomial Coefficient\n public class BinomialCoefficient\n {\n public ModInt[] fact, ifact;\n public BinomialCoefficient(int n)\n {\n fact = new ModInt[n + 1];\n ifact = new ModInt[n + 1];\n fact[0] = 1;\n for (int i = 1; i <= n; i++)\n fact[i] = fact[i - 1] * i;\n ifact[n] = ModInt.Inverse(fact[n]);\n for (int i = n - 1; i >= 0; i--)\n ifact[i] = ifact[i + 1] * (i + 1);\n ifact[0] = ifact[1];\n }\n public ModInt this[int n, int r]\n {\n get\n {\n if (n < 0 || n >= fact.Length || r < 0 || r > n) return 0;\n return fact[n] * ifact[n - r] * ifact[r];\n }\n }\n public ModInt RepeatedCombination(int n, int k)\n {\n if (k == 0) return 1;\n return this[n + k - 1, k];\n }\n }\n #endregion\n}\n\n\nnamespace CompLib.Util\n{\n using System;\n using System.Linq;\n\n class Scanner\n {\n private string[] _line;\n private int _index;\n private const char Separator = ' ';\n\n public Scanner()\n {\n _line = new string[0];\n _index = 0;\n }\n\n public string Next()\n {\n if (_index >= _line.Length)\n {\n string s;\n do\n {\n s = Console.ReadLine();\n } while (s.Length == 0);\n\n _line = s.Split(Separator);\n _index = 0;\n }\n\n return _line[_index++];\n }\n\n public string ReadLine()\n {\n _index = _line.Length;\n return Console.ReadLine();\n }\n\n public int NextInt() => int.Parse(Next());\n public long NextLong() => long.Parse(Next());\n public double NextDouble() => double.Parse(Next());\n public decimal NextDecimal() => decimal.Parse(Next());\n public char NextChar() => Next()[0];\n public char[] NextCharArray() => Next().ToCharArray();\n\n public string[] Array()\n {\n string s = Console.ReadLine();\n _line = s.Length == 0 ? new string[0] : s.Split(Separator);\n _index = _line.Length;\n return _line;\n }\n\n public int[] IntArray() => Array().Select(int.Parse).ToArray();\n public long[] LongArray() => Array().Select(long.Parse).ToArray();\n public double[] DoubleArray() => Array().Select(double.Parse).ToArray();\n public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();\n }\n}\n", "lang_cluster": "C#", "tags": ["greedy", "dp", "trees"], "code_uid": "e6c57942a458f36c2c8f672988a29a2f", "src_uid": "8218255989e5eab73ac7107072c3b2af", "difficulty": 2100.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\n\nnamespace _596A\n{\n class Program\n {\n static void Main(string[] args)\n {\n int numberOfPoint = Convert.ToInt32(Console.ReadLine());\n int[,] coordinate = new int[numberOfPoint, 2];\n double area = 0;\n\n for (int i = 0; i < numberOfPoint; i++)\n {\n string str = Console.ReadLine();\n int index = str.IndexOf(' ');\n coordinate[i, 0] = Convert.ToInt32(str.Substring(0, index));\n coordinate[i, 1] = Convert.ToInt32(str.Substring(index));\n }\n\n if (numberOfPoint == 1) Console.WriteLine(-1);\n if (numberOfPoint == 2)\n {\n if (coordinate[0, 0] != coordinate[1, 0] && coordinate[0, 1] != coordinate[1, 1])\n {\n area = Math.Abs(coordinate[0, 0] - coordinate[1, 0]) * Math.Abs(coordinate[0, 1] - coordinate[1, 1]);\n }\n else area = -1;\n Console.WriteLine(area);\n }\n if (numberOfPoint == 3)\n {\n if (coordinate[0, 0] != coordinate[1, 0] && coordinate[0, 1] != coordinate[1, 1])\n {\n area = Math.Abs(coordinate[0, 0] - coordinate[1, 0]) * Math.Abs(coordinate[0, 1] - coordinate[1, 1]);\n }\n else if (coordinate[0, 0] != coordinate[2, 0] && coordinate[0, 1] != coordinate[2, 1])\n {\n area = Math.Abs(coordinate[0, 0] - coordinate[2, 0]) * Math.Abs(coordinate[0, 1] - coordinate[2, 1]);\n }\n else\n {\n if (coordinate[0, 0] == coordinate[1, 0])\n {\n area = Math.Abs(coordinate[0, 1] - coordinate[1, 1]) * Math.Abs(coordinate[0, 0] - coordinate[2, 0]);\n }\n else\n {\n area = Math.Abs(coordinate[0, 0] - coordinate[1, 0]) * Math.Abs(coordinate[0, 1] - coordinate[2, 1]);\n }\n }\n Console.WriteLine(area);\n }\n if (numberOfPoint == 4)\n {\n for(int i = 1; i < 4; i++)\n {\n if(coordinate[0, 0] != coordinate[i, 0] && coordinate[0, 1] != coordinate[i, 1])\n {\n area = Math.Abs(coordinate[0, 0] - coordinate[i, 0]) * Math.Abs(coordinate[0, 1] - coordinate[i, 1]);\n break;\n }\n }\n Console.WriteLine(area);\n }\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["geometry", "implementation"], "code_uid": "88c6c6a0977ad77c4d595a85249814d6", "src_uid": "ba49b6c001bb472635f14ec62233210e", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\n\nnamespace Olymp596A\n{\n class Program\n {\n static void Main(string[] args)\n {\n int n = int.Parse(Console.ReadLine());\n if (n == 1)\n {\n Console.WriteLine(-1);\n }\n else if (n == 2)\n {\n string input = Console.ReadLine();\n int x1 = int.Parse(input.Split()[0]), y1 = int.Parse(input.Split()[1]);\n input = Console.ReadLine();\n int x2 = int.Parse(input.Split()[0]), y2 = int.Parse(input.Split()[1]);\n\n if (x1 != x2 && y1 != y2)\n Console.WriteLine(Math.Abs(x2 - x1) * Math.Abs(y2 - y1));\n else Console.WriteLine(-1);\n }\n else if (n == 3)\n {\n string input = Console.ReadLine();\n int x1 = int.Parse(input.Split()[0]), y1 = int.Parse(input.Split()[1]);\n input = Console.ReadLine();\n int x2 = int.Parse(input.Split()[0]), y2 = int.Parse(input.Split()[1]);\n input = Console.ReadLine();\n int x3 = int.Parse(input.Split()[0]), y3 = int.Parse(input.Split()[1]);\n\n if (x1 != x2 && y1 != y2)\n Console.WriteLine(Math.Abs(x2 - x1) * Math.Abs(y2 - y1));\n else if (x1 != x3 && y1 != y3)\n Console.WriteLine(Math.Abs(x3 - x1) * Math.Abs(y3 - y1));\n else if (x2 != x3 && y2 != y3)\n Console.WriteLine(Math.Abs(x2 - x3) * Math.Abs(y2 - y3));\n }\n else if (n == 4)\n {\n string input = Console.ReadLine();\n int x1 = int.Parse(input.Split()[0]), y1 = int.Parse(input.Split()[1]);\n input = Console.ReadLine();\n int x2 = int.Parse(input.Split()[0]), y2 = int.Parse(input.Split()[1]);\n input = Console.ReadLine();\n int x3 = int.Parse(input.Split()[0]), y3 = int.Parse(input.Split()[1]);\n input = Console.ReadLine();\n int x4 = int.Parse(input.Split()[0]), y4 = int.Parse(input.Split()[1]);\n\n if (x1 != x2 && y1 != y2)\n Console.WriteLine(Math.Abs(x2 - x1) * Math.Abs(y2 - y1));\n else if (x1 != x3 && y1 != y3)\n Console.WriteLine(Math.Abs(x3 - x1) * Math.Abs(y3 - y1));\n else if (x2 != x3 && y2 != y3)\n Console.WriteLine(Math.Abs(x2 - x3) * Math.Abs(y2 - y3));\n }\n Console.ReadLine();\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["geometry", "implementation"], "code_uid": "1808838f906fced905dcd27f086accc4", "src_uid": "ba49b6c001bb472635f14ec62233210e", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Linq;\n\nnamespace codeforces\n{\n class Program\n {\n static void Main(string[] args)\n {\n double[] a = Console.ReadLine().Split().Select(double.Parse).ToArray();\n int forOne = (int)a[1] / (int)a[2] + ((a[1] / a[2]) % 1 != 0 ? 1 : 0);\n double rez = a[0] * forOne/ a[3];\n Console.WriteLine((int)rez + (rez % 1 != 0 ? 1 : 0));\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math"], "code_uid": "9579f1189deede3fbc7c5c446e0b73fe", "src_uid": "73f0c7cfc06a9b04e4766d6aa61fc780", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text.RegularExpressions;\n\nnamespace Rextester\n{\n public class Program\n {\n public static void Main(string[] args)\n {\n int ans=0;\n string[] tokens = Console.ReadLine().Split();\n int k = int.Parse(tokens[0]);\n int n = int.Parse(tokens[1]);\n int s = int.Parse(tokens[2]);\n int p = int.Parse(tokens[3]);\n /*ans=(k*(n+s-1)/s+p-1)/p;\n Console.WriteLine(ans);\n */ \n n=((n-1)/s+1)*k;\n /*ans=(n-1)/p+1;*/\n ans=(n+p-1)/p;\n \n Console.WriteLine(ans);\n }\n }\n}", "lang_cluster": "C#", "tags": ["math"], "code_uid": "365fc57f5b889eb074133fbeaf8a701b", "src_uid": "73f0c7cfc06a9b04e4766d6aa61fc780", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\n\nnamespace ZAD_1\n{\n class Program\n {\n const decimal byte_size = 127;\n const decimal short_size = 32767;\n const decimal int_size = 2147483647;\n const decimal long_size = 9223372036854775807;\n static void Main(string[] args)\n {\n string input = Console.ReadLine();\n decimal n;\n if (Decimal.TryParse(input, out n))\n {\n if (Decimal.Compare(n, Decimal.Zero) < 0)\n {\n n = Decimal.Negate(n);\n n = Decimal.Subtract(n, Decimal.One);\n }\n if (Decimal.Compare(n, byte_size) <= 0)\n {\n Console.WriteLine(\"byte\");\n }\n else if (Decimal.Compare(n, short_size) <= 0)\n {\n Console.WriteLine(\"short\");\n }\n else if (Decimal.Compare(n, int_size) <= 0)\n {\n Console.WriteLine(\"int\");\n }\n else if (Decimal.Compare(n, long_size) <= 0)\n {\n Console.WriteLine(\"long\");\n }\n else\n {\n Console.WriteLine(\"BigInteger\");\n }\n }\n else\n {\n Console.WriteLine(\"BigInteger\");\n }\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["strings", "implementation"], "code_uid": "ce08b258d158abd756015c6b8fbf2ecb", "src_uid": "33041f1832fa7f641e37c4c638ab08a1", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\n\nnamespace CF2\n{\n class Program\n {\n static void Main(string[] args)\n { long val=0;\n string s1 = Console.ReadLine();\n\n if (long.TryParse(s1, out val))\n {\n if (val >= -128 && val <= 127) Console.WriteLine(\"byte\");\n else if (val >= -32768 && val <= 32767) Console.WriteLine(\"short\");\n else if (val >= -2147483648 && val <= 2147483647) Console.WriteLine(\"int\");\n else Console.WriteLine(\"long\");\n }\n\n else Console.WriteLine(\"BigInteger\");\n }\n \n\n }\n}\n", "lang_cluster": "C#", "tags": ["strings", "implementation"], "code_uid": "ce8a01b5c1fd65dd779adb5a4ae1ec1b", "src_uid": "33041f1832fa7f641e37c4c638ab08a1", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Linq;\n\nnamespace FlippingGame\n{\n class FlippingGame\n {\n static void Main(string[] args)\n {\n int n = int.Parse(Console.ReadLine());\n int[] values = Console.ReadLine().Split().Select(int.Parse).ToArray();\n int[] partialOnesObtained = new int[n];\n\n int numOfOnes = values.Count(v => v == 1);\n\n if (numOfOnes == n)\n Console.WriteLine(n - 1);\n else\n {\n partialOnesObtained[0] = 1 - values[0];\n\n for (int i = 1; i < n; i++)\n {\n if (values[i] == 0)\n partialOnesObtained[i] = partialOnesObtained[i - 1] + 1;\n else\n partialOnesObtained[i] = partialOnesObtained[i - 1] - 1 < 0 ? 0 : partialOnesObtained[i - 1] - 1;\n }\n\n Console.WriteLine(numOfOnes + partialOnesObtained.Max());\n }\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "dp", "implementation"], "code_uid": "5a7a9b012ffe8a57eeef32c937944f4f", "src_uid": "9b543e07e805fe1dd8fa869d5d7c8b99", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "/*\nThere are n integers a1, a2, ..., an. Each of those integers can be either 0 or 1. We are allowed to do exactly one move: We must choose two indices i and j (1 <= i <= j <= n) and flip all values ak for which their positions are in range [i, j] (that is i <= k <= j). Flip the value of x means to apply operation x = 1 - x.\n\nThe goal is - After exactly one move to obtain the maximum number of ones. \n\nInput:-\n\nThe first line of the input contains an integer n (1 <= n <= 10^6). In the second line of the input there are n integers: a1, a2, ..., an. It is guaranteed that each of those n values is either 0 or 1\n\nOutput:-\nPrint an integer - the maximal number of 1s that can be obtained after exactly one move.\n\nSample test(s)\ninput\n5\n1 0 0 1 0\noutput\n4\n\ninput\n4\n1 0 0 1\noutput\n4\n\nNote:-\nIn the first case, flip the segment from 2 to 5 (i=2, j=5). That flip changes the sequence, it becomes: [1 1 1 0 1]. So, it contains four ones. There is no way to make the whole sequence equal to [1 1 1 1 1].\n\nIn the second case, flipping only the second and the third element (i=2, j=3) will turn all numbers into 1.\n\n\nSource: http://codeforces.ru/problemset/problem/327/A\n*/\n\nusing System;\n\nnamespace FlippingGame327A\n{\n class Program\n {\n static int kkMax(int a, int b)\n {\n return (a < b) ? b : a;\n }\n\n static void Main(string[] args)\n {\n string str = Console.ReadLine();\n int n = Convert.ToInt32(str);\n str = Console.ReadLine();\n string[] strArray = str.Split(' ');\n int[] input = new int[n + 3];\n int sum = 0;\n for (int i = 0; i < n; i++)\n {\n input[i] = Convert.ToInt32(strArray[i]);\n if (input[i] == 1)\n {\n sum++;\n }\n }\n\n // main logic\n // O(n^2) solution\n int[,] res = new int[n, n];\n int ans = Int32.MinValue;\n for (int i = 0; i < n; i++)\n {\n int zeros = 0;\n for (int j = i; j < n; j++)\n {\n if (input[j] == 0)\n {\n zeros++;\n res[i, j] = zeros;\n }\n int temp = sum - (j - i + 1 - res[i, j]) + res[i, j];\n ans = (temp > ans) ? temp : ans;\n }\n }\n Console.WriteLine(ans);\n }\n }\n}", "lang_cluster": "C#", "tags": ["brute force", "dp", "implementation"], "code_uid": "6b562f6ab961eeeb0aa133809b336eda", "src_uid": "9b543e07e805fe1dd8fa869d5d7c8b99", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Text;\n//using System.Linq;\n\n\nnamespace consoleTraining\n{\n class Program\n {\n static void Main(string[] args)\n {\n string path = Console.ReadLine();\n\n List coords = new List();\n coords.Add(\"0;0\");\n int lastX = 0, lastY = 0; char lastCh = path[0];\n foreach (char ch in path) \n {\n if (ch == 'L') { lastX--; }\n if (ch == 'R') { lastX++; }\n if (ch == 'U') { lastY++; }\n if (ch == 'D') { lastY--; }\n string[] checkStrs = strs(ch, lastX, lastY);\n foreach (string checkStr in checkStrs) if (coords.Contains(checkStr)) { Console.WriteLine(\"BUG\"); return; }\n if ((ch == 'L' && lastCh == 'R') || (ch == 'R' && lastCh == 'L') || (ch == 'U' && lastCh == 'D') || (ch == 'D' && lastCh == 'U')) { Console.WriteLine(\"BUG\"); return; }\n coords.Add(string.Format(\"{0};{1}\", lastX, lastY)); lastCh = ch;\n }\n Console.WriteLine(\"OK\");\n }\n\n static string[] strs(char ch, int x, int y)\n {\n List checkCoords = new List();\n string up = string.Format(\"{0};{1}\", x, y + 1);\n string down = string.Format(\"{0};{1}\", x, y - 1);\n string left = string.Format(\"{0};{1}\", x - 1, y);\n string right = string.Format(\"{0};{1}\", x + 1, y);\n if (ch == 'U') { checkCoords.Add(up); checkCoords.Add(right); checkCoords.Add(left); }\n if (ch == 'D') { checkCoords.Add(down); checkCoords.Add(right); checkCoords.Add(left); }\n if (ch == 'L') { checkCoords.Add(up); checkCoords.Add(down); checkCoords.Add(left); }\n if (ch == 'R') { checkCoords.Add(up); checkCoords.Add(right); checkCoords.Add(down); }\n return checkCoords.ToArray();\n }\n\n }\n}\n", "lang_cluster": "C#", "tags": ["constructive algorithms", "implementation", "graphs"], "code_uid": "5d6cdd02b9b8c2b2b480c5796ba4567e", "src_uid": "bb7805cc9d1cc907b64371b209c564b3", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "/*******************************************************************************\n* Author: Nirushuu\n*******************************************************************************/\n\nusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Windows;\nusing System.IO;\nusing System.Globalization;\nusing System.Numerics;\n\n/*******************************************************************************\n* IO from Kattio.cs from open.kattis.com/help/csharp */\npublic class NoMoreTokensException : Exception\n{\n}\n\npublic class Tokenizer\n{\n string[] tokens = new string[0];\n private int pos;\n StreamReader reader;\n\n public Tokenizer(Stream inStream)\n {\n var bs = new BufferedStream(inStream);\n reader = new StreamReader(bs);\n }\n\n public Tokenizer() : this(Console.OpenStandardInput())\n {\n // Nothing more to do\n }\n\n private string PeekNext()\n {\n if (pos < 0)\n // pos < 0 indicates that there are no more tokens\n return null;\n if (pos < tokens.Length)\n {\n if (tokens[pos].Length == 0)\n {\n ++pos;\n return PeekNext();\n }\n return tokens[pos];\n }\n string line = reader.ReadLine();\n if (line == null)\n {\n // There is no more data to read\n pos = -1;\n return null;\n }\n // Split the line that was read on white space characters\n tokens = line.Split(null);\n pos = 0;\n return PeekNext();\n }\n\n public bool HasNext()\n {\n return (PeekNext() != null);\n }\n\n public string Next()\n {\n string next = PeekNext();\n if (next == null)\n throw new NoMoreTokensException();\n ++pos;\n return next;\n }\n}\n\npublic class Scanner : Tokenizer\n{\n\n public int NextInt()\n {\n return int.Parse(Next());\n }\n\n public long NextLong()\n {\n return long.Parse(Next());\n }\n\n public float NextFloat()\n {\n return float.Parse(Next());\n }\n\n public double NextDouble()\n {\n return double.Parse(Next());\n }\n}\n\npublic class BufferedStdoutWriter : StreamWriter\n{\n public BufferedStdoutWriter() : base(new BufferedStream(Console.OpenStandardOutput()))\n {\n }\n}\n/******************************************************************************/\n\n/*******************************************************************************\n* DisjointSet datastructure */\npublic struct DisjointSet {\n public int[] parent;\n public int[] rank;\n public DisjointSet(int n) {\n parent = new int[n];\n for (int i = 0; i < n; ++i) {\n parent[i] = i;\n }\n rank = new int[n];\n }\n\n public int Find(int i) {\n int idx = i;\n var compress = new List();\n while (idx != parent[idx]) {\n compress.Add(idx);\n idx = parent[idx];\n }\n\n foreach (var e in compress) { // path compress \n parent[e] = idx;\n }\n return idx;\n }\n\n public void Union(int a, int b) {\n int aPar = this.Find(a);\n int bPar = this.Find(b);\n\n if (rank[aPar] > rank[bPar]) { // by rank\n parent[bPar] = aPar;\n } else {\n parent[aPar] = bPar;\n }\n if (rank[aPar] == rank[bPar]) {\n ++rank[bPar];\n }\n }\n}\n\nclass MaxHeap {\n List data;\n\n public MaxHeap() {\n data = new List();\n }\n\n public void Add(int a) {\n data.Add(a);\n int idx = data.Count - 1;\n int parent = (int) Math.Floor((double) (idx - 1) / 2);\n while (idx != 0 && (data[idx] > data[parent])) {\n int tmp = data[parent];\n data[parent] = data[idx];\n data[idx] = tmp;\n\n idx = parent;\n parent = (int) Math.Floor((double) (idx - 1) / 2);\n }\n }\n\n public int Pop() {\n int res = data[0];\n data[0] = data[data.Count - 1];\n data.RemoveAt(data.Count - 1);\n\n int idx = 0;\n while (true) {\n int child1 = (2 * idx) + 1;\n int child2 = (2 * idx) + 2;\n\n if (child1 >= data.Count) { // no children\n break;\n } else if (child2 >= data.Count) { // one child\n if (data[idx] < data[child1]) {\n int tmp = data[idx];\n data[idx] = data[child1];\n data[child1] = tmp;\n }\n break;\n } else { // two children\n int maxChild = data[child1] > data[child2] ? child1 : child2;\n if (data[idx] < data[maxChild]) {\n int tmp = data[idx];\n data[idx] = data[maxChild];\n data[maxChild] = tmp;\n idx = maxChild;\n continue;\n } else { // no swap\n break;\n }\n }\n } \n\n return res; \n }\n\n\n}\n\n\nclass Dequeue {\n public Dictionary data = new Dictionary();\n int firstIdx;\n public int Count;\n public Dequeue() {\n data = new Dictionary();\n firstIdx = 1;\n Count = 0;\n }\n\n public void PushFront(int a) {\n data[firstIdx - 1] = a;\n ++Count;\n --firstIdx;\n }\n\n public void PushBack(int a) {\n data[firstIdx + Count] = a;\n ++Count;\n }\n\n public int PopFront() {\n --Count;\n ++firstIdx;\n return data[firstIdx - 1];\n }\n\n public int PopBack() {\n --Count;\n return data[firstIdx + Count];\n }\n\n public int Get(int n) {\n return data[firstIdx + n];\n }\n}\n/******************************************************************************/\n\nclass MainClass {\n\n // Debug functions \n static void debug(IEnumerable a, string s = \"\") {\n Console.WriteLine($\"name: {s}\");\n int i = 0;\n foreach (var e in a) {\n Console.WriteLine($\"value {i}: {e}\");\n ++i;\n }\n }\n static void dbg(T a, string s = \"\") {\n Console.WriteLine($\"name: {s} value: {a}\");\n }\n ////////////////////\n \n static int gcd(int a, int b) {\n while (b != 0) {\n int t = b;\n b = a % b;\n a = t;\n }\n return a;\n }\n\n // class PairInt{\n // public int fst;\n // public int snd;\n\n // // void Add(Pair p) {\n // // fst += p.fst;\n // // snd += p.snd;\n // // }\n // }\n\n public static void Main() {\n \n var sc = new Scanner();\n var wr = new BufferedStdoutWriter();\n var dot = new NumberFormatInfo();\n dot.NumberDecimalSeparator = \".\";\n\n // int T = sc.NextInt();\n\n // for (int t = 0; t < T; ++t) {\n // }\n\n string s = sc.Next();\n\n var visited = new HashSet>();\n var dir = new Dictionary>{\n {'R', new Tuple(1, 0)},\n {'L', new Tuple(-1, 0)},\n {'U', new Tuple(0, 1)},\n {'D', new Tuple(0, -1)}\n };\n \n\n var pos = new Tuple(0, 0);\n visited.Add(pos);\n\n foreach (var e in s) {\n var prev = pos;\n pos = new Tuple(pos.Item1 + dir[e].Item1, pos.Item2 + dir[e].Item2);\n\n if (visited.Contains(pos)) {\n wr.Write(\"BUG\");\n wr.Flush();\n return;\n }\n\n visited.Add(pos);\n\n foreach (var d in dir.Values) {\n var nbr = new Tuple(pos.Item1 + d.Item1, pos.Item2 + d.Item2);\n if (visited.Contains(nbr) && !(nbr.Equals(prev))) {\n // wr.Write(e);\n // wr.Write(pos);\n // wr.Write(nbr);\n wr.Write(\"BUG\");\n wr.Flush();\n return;\n }\n }\n }\n\n // debug(pos);\n // foreach (var e in visited) {\n // debug(e);\n // }\n\n wr.Write(\"OK\");\n\n wr.Flush();\n\n \n }\n}", "lang_cluster": "C#", "tags": ["constructive algorithms", "implementation", "graphs"], "code_uid": "54d62c0431e16ddc0403ce0a2a620649", "src_uid": "bb7805cc9d1cc907b64371b209c564b3", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Linq;\n\nnamespace Task922Asecondtry\n{\n class Program\n {\n static void Main(string[] args)\n {\n var input = Console.ReadLine().Split().Select(int.Parse);\n int X = input.ElementAt(0), Y = input.ElementAt(1);\n\n if(\n Y == 1 && X!=0 ||\n Y == 0 ||\n Y % 2 == 0 && X % 2 == 0 ||\n Y % 2 != 0 && X % 2 != 0 ||\n X < Y - 1\n\n )\n \n Console.WriteLine(\"NO\");\n else Console.WriteLine(\"yes\");\n \n }\n }\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "58e0f51e78da5ff3fc9957ff93f58d65", "src_uid": "1527171297a0b9c5adf356a549f313b9", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace KlonirovanijeIgrushek\n{\n class Program\n {\n static void Main(string[] args)\n {\n string[] s = Console.ReadLine().Split();\n int x = int.Parse(s[0]);\n int y = int.Parse(s[1]);\n\n if (y == 1 && x > 0)\n Console.Write(\"no\");\n else if ((x - y + 1) % 2 == 0 && (y - 1 <= x) && y > 0)\n Console.Write(\"yes\");\n else\n Console.Write(\"no\");\n \n }\n }\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "259b9d900accc258aa2bd5070faa1814", "src_uid": "1527171297a0b9c5adf356a549f313b9", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Linq;\n\npublic class Program\n{\n public static void Main()\n {\n var input = Console.ReadLine().Split(' ');\n var n = int.Parse(input[0]);\n var a = int.Parse(input[1]);\n var b = int.Parse(input[2]);\n var c = int.Parse(input[3]);\n var d = int.Parse(input[4]);\n\n long totalCombinations = 0;\n for (var x1i = 1; x1i <= n; ++x1i)\n {\n var x2i = x1i + b - c;\n // x3i can be any number with [1, n] range.\n var x4i = x1i + a - d;\n var x5i = x1i + a + b - c - d;\n if (x2i >= 1 && x2i <= n && x4i >= 1 && x4i <= n && x5i >= 1 && x5i <= n)\n ++totalCombinations;\n }\n // Current total combinations is valid for any x3i.\n totalCombinations *= n;\n Console.WriteLine(totalCombinations);\n }\n}", "lang_cluster": "C#", "tags": ["brute force", "math", "constructive algorithms"], "code_uid": "3d03f2bccfa5bda28ca20b8aff3beb14", "src_uid": "b732869015baf3dee5094c51a309e32c", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections;\nusing System.Collections.Generic;\nusing System.Diagnostics;\nusing System.Globalization;\nusing System.IO;\nusing System.Linq;\nusing System.Text;\nusing System.Text.RegularExpressions;\nusing System.Threading.Tasks;\n\nnamespace ConsoleApplication5\n{\n class Program\n {\n static void Main(string[] args)\n {\n var input = Console.ReadLine()\n .Split()\n .Select(int.Parse)\n .ToList();\n int n = input[0], a = input[1], b = input[2], c = input[3], d = input[4];\n long count = 0;\n for (int x = 1; x <= n; x++)\n {\n int m = x + a - d, z = x + b - c, k = x + b - c + a - d;\n if (m >= 1 && z >= 1 && k >= 1 &&\n m <= n && z <= n && k <= n)\n {\n\n int f = x + a + b, s = b + m + d, t = d + c + k, fo = a + z + c;\n if (f == s && f == t && f == fo)\n count += n;\n }\n }\n Console.WriteLine(count);\n }\n }\n}", "lang_cluster": "C#", "tags": ["brute force", "math", "constructive algorithms"], "code_uid": "4d55d83b01a89d296587743298fbaa4d", "src_uid": "b732869015baf3dee5094c51a309e32c", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Linq;\n\nnamespace _985A\n{\n class Program\n {\n static void Main(string[] args)\n {\n int n = int.Parse(Console.ReadLine());\n int zoma = n / 2, oddCount=0,evenCount=0;\n int[] posArray = new int[zoma];\n var inputs = Console.ReadLine().Split().Select(int.Parse);\n posArray = inputs.ToArray();\n Array.Sort(posArray);\n for (int i=n, j = zoma-1; i > 0; i-=2,j--) \n if (posArray[j] != i) evenCount+= Math.Abs(i - posArray[j]);\n for (int i = n-1, j = zoma - 1; i > 0; i -= 2, j--)\n if (posArray[j] != i) oddCount+= Math.Abs(i - posArray[j]); \n Console.WriteLine(evenCount < oddCount ? evenCount : oddCount);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "5f85d7efcf762ef7cc1fd5f37ec9b54d", "src_uid": "0efe9afd8e6be9e00f7949be93f0ca1a", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\n\nusing System;\n\nnamespace Codeforces {\n\n class Chess {\n\n static int N;\n static int numCount;\n static int[] an = new int[2000];\n\n\n static void ReadData() {\n Int32.TryParse(Console.ReadLine(), out N);\n var line = Console.ReadLine().Split(new char[]{' '});\n numCount = line.Length;\n for (int i = 1; i <= numCount; ++i)\n {\n Int32.TryParse(line[i-1], out an[i]);\n }\n }\n\n static int TrySolve(int color) {\n var result = 0;\n for (int i = 1; i<=numCount; ++i) {\n var loc = (i*2) - color;\n result += Math.Abs(an[i]-loc); \n }\n return result;\n }\n \n static void Main(string[] args) {\n ReadData();\n Array.Sort(an,1,numCount);\n Console.WriteLine(Math.Min(TrySolve(0), TrySolve(1)));\n }\n\n }\n}\n\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "9adc7b592583cdf2de6d856ae2c54a68", "src_uid": "0efe9afd8e6be9e00f7949be93f0ca1a", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nclass A\n{\n\t\t\t\tstatic void Main()\n\t\t\t\t{\n\t\t\t\t\t\t\t\tstring input = Console.ReadLine();\n\t\t\t\t\t\t\t\tstring[] split = input.Split(' ');\n\t\t\t\t\t\t\t\tint n = int.Parse(split[0]);\n\t\t\t\t\t\t\t\tint m = int.Parse(split[1]);\n\t\t\t\t\t\t\t\tinput = Console.ReadLine();\n\t\t\t\t\t\t\t\tsplit = input.Split(' ');\n\t\t\t\t\t\t\t\tint[] button = new int [m];\n\t\t\t\t\t\t\t\tfor(int i = 0; i < m; i++)\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\tbutton[i] = int.Parse(split[i]);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tint[] light = new int [n];\n\t\t\t\t\t\t\t\tfor(int i = 0; i list = new List();\n for (int i = 0; i < splits.Length; i++)\n {\n list.Add(int.Parse(splits[i]));\n }\n \n string output = \"\"; \n for (int i = 1; i <= n; i++)\n {\n for (int j = 0; j < list.Count; j++)\n {\n if (i >= list[j])\n {\n output += list[j]+\" \";\n break;\n }\n }\n }\n \n Console.Write(output.Trim());\n }\n}", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "b9a7e8f65c91767e728b5b220d5f7792", "src_uid": "2e44c8aabab7ef7b06bbab8719a8d863", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace A\n{\n class Program\n {\n static void Main(string[] args)\n {\n string s = Console.ReadLine();\n var S = s.Split();\n int n = Convert.ToInt32(S[0]);\n int m = Convert.ToInt32(S[1]);\n s = Console.ReadLine();\n S = s.Split();\n List A = new List();\n foreach (var item in S) A.Add(Convert.ToInt32(item));\n s = Console.ReadLine();\n S = s.Split();\n List B = new List();\n foreach (var item in S) B.Add(Convert.ToInt32(item));\n for (int i = 0; i < A.Count; i++)\n {\n if (!B.Contains(A[i])) { A.RemoveAt(i); i--; }\n }\n foreach (var a in A)\n Console.Write(a +\" \");\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "1e3c166b83685cf69712ec3d2f37ac60", "src_uid": "f9044a4b4c3a0c2751217d9b31cd0c72", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.IO;\nusing System.Linq;\nclass Solution {\n static void Main(String[] args) {\n int[] nk = Console.ReadLine().Trim().Split(' ').Select(arTemp => Convert.ToInt32(arTemp)).ToArray(); \n int[] ar = Console.ReadLine().Trim().Split(' ').Select(arTemp => Convert.ToInt32(arTemp)).ToArray();\n int[] cnt=new int[10];\n int[] finger = Console.ReadLine().Trim().Split(' ').Select(arTemp => Convert.ToInt32(arTemp)).ToArray();\n for(int i=0;i0){\n Console.Write(ar[j]+\" \"); \n }\n }\n \n }\n}", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "3d44f3ee19f018ce0eb73baf153631ec", "src_uid": "f9044a4b4c3a0c2751217d9b31cd0c72", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\n\nnamespace A._Expression\n{\n class Program\n {\n static void Main(string[] args)\n {\n short a = Convert.ToInt16(Console.ReadLine());\n short b = Convert.ToInt16(Console.ReadLine());\n short c = Convert.ToInt16(Console.ReadLine());\n\n short max = 0;\n\n if ((a + b + c) > max) max = (short)(a + b + c);\n if (((a + b) + c) > max) max = (short)(a + b + c);\n if ((a + b * c) > max) max = (short)(a + b * c);\n if ((a * (b + c)) > max) max = (short)(a * (b + c));\n if ((a * b * c) > max) max = (short)(a * b * c);\n if (((a + b) * c) > max) max = (short)((a + b) * c);\n\n Console.WriteLine(max);\n\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "math"], "code_uid": "2cf44932370ba4f9c8ed7af15990c6e6", "src_uid": "1cad9e4797ca2d80a12276b5a790ef27", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.IO;\nusing System.Linq;\n\nclass Program\n{\n static char[] SPACE = new[] { ' ' };\n\n static void Main(string[] args)\n {\n#if DEBUG\n using (var input = new StreamReader(\"input.txt\"))\n using (var output = new StreamWriter(\"output.txt\"))\n {\n Console.SetIn(input);\n Console.SetOut(output);\n\n int n = 0;\n do\n {\n Console.WriteLine();\n Console.WriteLine(\"Sample {0}\", ++n);\n Prog();\n } while (Console.ReadLine() == string.Empty);\n }\n#else\n Prog();\n#endif\n }\n\n static int __ptr = 0;\n static string[] __input;\n static int NextInt()\n {\n return int.Parse(__input[__ptr++]);\n }\n static void ReadTokens(int n)\n {\n __ptr = 0;\n __input = Console.ReadLine().Split(SPACE, n);\n }\n\n //\n\n static void Prog()\n {\n ReadTokens(1);\n int a = NextInt();\n ReadTokens(1);\n int b = NextInt();\n ReadTokens(1);\n int c = NextInt();\n\n int r = 0;\n r = Math.Max(r, a + b + c);\n r = Math.Max(r, a * b + c);\n r = Math.Max(r, a + b * c);\n r = Math.Max(r, a * b * c);\n r = Math.Max(r, (a + b) * c);\n r = Math.Max(r, a * (b + c));\n \n Console.WriteLine(r);\n }\n}", "lang_cluster": "C#", "tags": ["brute force", "math"], "code_uid": "54c9227605fbb4477cd7a78c3a8f6eb7", "src_uid": "1cad9e4797ca2d80a12276b5a790ef27", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.IO;\nusing System.Collections;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\n\nnamespace A {\n\tclass Program {\n\t\tstatic void Main() {\n\t\t\tint[] arr = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);\n\t\t\tint a = arr[0];\n\t\t\tint b = arr[1];\n\t\t\tstring ret = \"NO\";\n \n\t\t\tif (-1 <= a-b && a-b <= 1 && a+b > 0) ret = \"YES\";\n\t\t\t\n\t\t\tConsole.WriteLine(ret);\n\t\t}\n\t}\n}", "lang_cluster": "C#", "tags": ["brute force", "math", "constructive algorithms", "implementation"], "code_uid": "a52f5dc402c9ab4a6149ec9fa74b440a", "src_uid": "ec5e3b3f5ee6a13eaf01b9a9a66ff037", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace A.Dasha_and_Stairs\n{\n class Program\n {\n static void Main(string[] args)\n {\n string[] s = Console.ReadLine().Split();\n here: int a =int.Parse(s[0]);\n int b = int.Parse(s[1]);\n if(a<0||b>100)\n {\n goto here;\n }\n if((a==b&&a!=0)||a==b+1||b==a+1)\n {\n Console.WriteLine(\"YES\");\n }\n else\n {\n Console.WriteLine(\"NO\");\n }\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "math", "constructive algorithms", "implementation"], "code_uid": "f8d52b5c254c92dcb019b479b614263d", "src_uid": "ec5e3b3f5ee6a13eaf01b9a9a66ff037", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\n\nnamespace ConsoleApplication2\n{\n class Program\n {\n static void Main(string[] args)\n {\n int k =int.Parse( Console.ReadLine());\n char []s=new char[35];\n for (int i = 0; i 4 ? (n + 1) / 3 : n > 0 ? 1 : 0;\n\t\t\tvar l2 = n > 4 ? n / 3 : n > 1 ? 1 : 0;\n\t\t\tvar l3 = n > 2 ? 1 : 0;\n\t\t\tvar l4 = n > 4 ? (n - 1) / 3 : n > 3 ? 1 : 0;\n\n\t\t\tFunc print = (k, m) => {\n\t\t\t\tvar sb = new StringBuilder();\n\t\t\t\tfor (var i = 1; i <= m; i++) {\n\t\t\t\t\tsb.AppendFormat(\"{0}.\", (i <= k) ? \"O\" : \"#\" );\n\t\t\t\t}\n\t\t\t\treturn sb.ToString();\n\t\t\t};\n\n\t\t\tConsole.WriteLine(\"+------------------------+\");\n\t\t\tConsole.WriteLine(\"|{0}|D|)\", print(l1, 11));\n\t\t\tConsole.WriteLine(\"|{0}|.|\", print(l2, 11));\n\t\t\tConsole.WriteLine(\"|{0}......................|\", print(l3, 1));\n\t\t\tConsole.WriteLine(\"|{0}|.|)\", print(l4, 11));\n\t\t\tConsole.WriteLine(\"+------------------------+\");\t\t\t\t\t\t \n\t\t}\n\t}\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "56d9f21f40172087dff5139366f242ee", "src_uid": "075f83248f6d4d012e0ca1547fc67993", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeff\ufeff\ufeff\ufeffusing System;\n\ufeff\ufeff\ufeffusing System.Collections.Generic;\n\ufeff\ufeff\ufeffusing System.Globalization;\n\ufeff\ufeff\ufeffusing System.IO;\n\ufeff\ufeff\ufeffusing System.Linq;\n\nnamespace CF317\n{\n internal class Program\n {\n private static void Main(string[] args)\n {\n var sr = new InputReader(Console.In);\n //var sr = new InputReader(new StreamReader(\"input.txt\"));\n var task = new Task();\n using (var sw = Console.Out)\n //using (var sw = new StreamWriter(\"output.txt\"))\n {\n task.Solve(sr, sw);\n //Console.ReadKey();\n }\n }\n }\n\n internal class Task\n {\n public void Solve(InputReader sr, TextWriter sw)\n {\n var matrix = new char[4, 4];\n for (var i = 0; i < 4; i++) {\n var next = sr.NextString();\n for (var j = 0; j < 4; j++) {\n matrix[i, j] = next[j];\n }\n }\n for (var i = 0; i < 4; i++) {\n for (var j = 0; j < 4; j++) {\n var old = matrix[i, j];\n if (matrix[i, j] == '.') {\n matrix[i, j] = 'x';\n if (Check(matrix)) {\n sw.WriteLine(\"YES\");\n return;\n }\n matrix[i, j] = old;\n }\n }\n }\n\n sw.WriteLine(\"NO\");\n }\n\n private bool Check(char[,] matrix)\n {\n for (var i = 0; i < 4; i++) {\n for (var j = 0; j < 4; j++) {\n if (i - 2 >= 0) {\n if (matrix[i, j] == 'x' && matrix[i - 1, j] == 'x' && matrix[i - 2, j] == 'x') {\n return true;\n }\n }\n if (i + 2 < 4) {\n if (matrix[i, j] == 'x' && matrix[i + 1, j] == 'x' && matrix[i + 2, j] == 'x') {\n return true;\n }\n }\n if (j - 2 >= 0)\n {\n if (matrix[i, j] == 'x' && matrix[i, j - 1] == 'x' && matrix[i, j - 2] == 'x')\n {\n return true;\n }\n }\n if (j + 2 < 4)\n {\n if (matrix[i, j] == 'x' && matrix[i, j + 1] == 'x' && matrix[i, j + 2] == 'x')\n {\n return true;\n }\n }\n if (i - 1 >= 0 && j - 1 >= 0 && i + 1 < 4 && j + 1 < 4) {\n if (matrix[i, j] == 'x' && matrix[i - 1, j - 1] == 'x' && matrix[i + 1, j + 1] == 'x') {\n return true;\n }\n }\n if (i - 1 >= 0 && j + 1 < 4 && j - 1 >= 0 && i + 1 < 4) {\n if (matrix[i, j] == 'x' && matrix[i - 1, j + 1] == 'x' && matrix[i + 1, j - 1] == 'x') {\n return true;\n }\n }\n }\n }\n\n return false;\n }\n }\n}\n\ninternal class InputReader : IDisposable\n{\n private bool isDispose;\n private readonly TextReader sr;\n\n public InputReader(TextReader stream)\n {\n sr = stream;\n }\n\n public void Dispose()\n {\n Dispose(true);\n GC.SuppressFinalize(this);\n }\n\n public string NextString()\n {\n var result = sr.ReadLine();\n return result;\n }\n\n public int NextInt32()\n {\n return Int32.Parse(NextString());\n }\n\n public long NextInt64()\n {\n return Int64.Parse(NextString());\n }\n\n public string[] NextSplitStrings()\n {\n return NextString()\n .Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);\n }\n\n public T[] ReadArray(Func func)\n {\n return NextSplitStrings()\n .Select(s => func(s, CultureInfo.InvariantCulture))\n .ToArray();\n }\n\n public T[] ReadArrayFromString(Func func, string str)\n {\n return\n str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)\n .Select(s => func(s, CultureInfo.InvariantCulture))\n .ToArray();\n }\n\n protected void Dispose(bool dispose)\n {\n if (!isDispose)\n {\n if (dispose)\n sr.Close();\n isDispose = true;\n }\n }\n\n ~InputReader()\n {\n Dispose(false);\n }\n}", "lang_cluster": "C#", "tags": ["brute force", "implementation"], "code_uid": "957677c4cf525f053a64224f34b0655d", "src_uid": "ca4a77fe9718b8bd0b3cc3d956e22917", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.IO;\nusing System.Text;\n\nnamespace Ilya_and_tic_tac_toe_game\n{\n internal class Program\n {\n private static readonly StreamReader reader = new StreamReader(Console.OpenStandardInput(1024*10), Encoding.ASCII, false, 1024*10);\n private static readonly StreamWriter writer = new StreamWriter(Console.OpenStandardOutput(1024*10), Encoding.ASCII, 1024*10);\n\n private static void Main(string[] args)\n {\n var nn = new int[10,10];\n for (int i = 0; i < 4; i++)\n {\n for (int j = 0; j < 4; j++)\n {\n nn[i + 3, j + 3] = Next();\n }\n }\n\n var dx = new[] {0, 1, 1, -1};\n var dy = new[] {1, 0, 1, 1};\n for (int i = 0; i < 4; i++)\n {\n for (int j = 0; j < 4; j++)\n {\n if (nn[i + 3, j + 3] == 0)\n {\n for (int k = 0; k < dx.Length; k++)\n {\n for (int l = -2; l <= 0; l++)\n {\n int c = 0;\n for (int m = 0; m < 3; m++)\n {\n c += nn[i + 3 + dx[k]*(l + m), j + 3 + dy[k]*(l + m)];\n }\n if (c == 2)\n {\n writer.WriteLine(\"YES\");\n writer.Flush();\n return;\n }\n }\n }\n }\n }\n }\n\n writer.WriteLine(\"NO\");\n writer.Flush();\n }\n\n private static int Next()\n {\n do\n {\n int c = reader.Read();\n if (c == 'x')\n return 1;\n if (c == '.')\n return 0;\n if (c == 'o')\n return -1;\n if (c == -1)\n return -2;\n } while (true);\n }\n }\n}", "lang_cluster": "C#", "tags": ["brute force", "implementation"], "code_uid": "c75cadb02055d201af40a51c90ba7f12", "src_uid": "ca4a77fe9718b8bd0b3cc3d956e22917", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace ConsoleApp1\n{\n class Program\n {\n static void Main(string[] args)\n {\n bool otv = true;\n string pass = Console.ReadLine();\n int n = int.Parse(Console.ReadLine());\n string[] a = new string[n];\n string s = null;\n for (int i = 0; i < n; i++) \n {\n a[i] = Console.ReadLine();\n }\n for(int k = 0; k < n; k++)\n {\n for (int i = 0; i < n; i++)\n {\n for (int j = 0; j < i; j++)\n {\n s += a[j];\n }\n s += a[k];\n for (int j = i; j < n; j++)\n {\n s += a[j];\n }\n if (s.Contains(pass))\n {\n otv = false;\n s = null;\n break;\n }\n else\n {\n s = null;\n }\n }\n }\n \n if (otv)\n Console.WriteLine(\"NO\");\n else\n Console.WriteLine(\"YES\");\n Console.Read();\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "strings", "implementation"], "code_uid": "b44ca370a8100e9de30342cb7bebc04c", "src_uid": "cad8283914da16bc41680857bd20fe9f", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Diagnostics;\nusing System.IO;\nusing System.Linq;\n\npublic static partial class MyExtension\n{\n public const int DEFAULT_BUFFER_SIZE = 4194304;\n public class Solution\n {\n /* Head ends here */\n \n public const int PAD_FACTOR = 7;\n\n bool solve()\n {\n var pass = ReadLine();\n var N = ReadInt32();\n var arr = new List(N);\n range(1, N).forEach(_ => arr.Add(ReadLine()));\n if (arr.Contains(pass)) return true;\n var first = arr.Any(s => s[0] == pass[1]);\n var second = arr.Any(s => s[1] == pass[0]);\n return first && second;\n }\n\n public void zStart()\n {\n Console.WriteLine(solve() ? \"YES\" : \"NO\");\n ///////////////////////////////////////\n\n //foreach (var @__ in Enumerable.Range(1, ReadInt32()))\n //{\n // start... - no CONSOLE\n\n // end...\n\n //var ansLines = new List(9999);\n //{\n // // ANS start...\n \n // //ansLines.AddRange(inp.Select(x => new string(x)));\n // //...\n\n // Console.Write(\"Case #{0}: \", @__);\n // Console.WriteLine(string.Join(\" \", __getFormattedString(ans)));\n // ansLines.ForEach(x => Console.WriteLine(x));\n //}\n //Trace.WriteLine(string.Format(\"DONE_{0}.\", @__));\n //}\n }\n\n T __getFormattedString(T val) { return val; }\n#if DEBUG\n string __getFormattedString(double d) { return d.ToString(\"0.000000\"); }\n#endif\n /* Tail starts here */\n }\n\n#if TORIQ\n static void Pretest()\n {\n Test(@\"ya\n4\nah\noy\nto\nha\", \"YES\");\n Test(@\"hp\n2\nht\ntp\", \"NO\");\n Test(@\"ah\n1\nha\", \"YES\");\n }\n static void MainTest()\n {\n Test(File.ReadAllText(\"input.txt\")\n , File.ReadAllText(\"output.txt\")\n );\n //\n }\n#endif\n\n // =============================================================================================\n\n #region faSTDIO\n [DebuggerNonUserCode]\n static void Main(String[] args)\n {\n#if TORIQ\n zTestSuite();\n //new Solution().zInternalTestSuite();\n return;\n#endif\n#if GOOGLE\n zGoogle();\n return;\n#endif\n new Solution().zStart();\n }\n\n static IEnumerable Read()\n {\n int cin;\n var empty = true;\n while ((cin = Console.Read()) > -1)\n {\n var c = (char)cin;\n if (c == ' ' || c == '\\n' || c == '\\r' || c == '\\t')\n {\n if (empty) continue;\n else break;\n }\n yield return c;\n empty = false;\n }\n }\n static T Read(Converter convert, int capacity = 20)\n { var temp = ReadString(capacity); return convert(temp); }\n static string ReadString(int capacity = 1000000)\n {\n capacity += Solution.PAD_FACTOR;\n var ans = new System.Text.StringBuilder(capacity);\n foreach (var c in Read()) ans.Append(c);\n return ans.ToString();\n }\n static string ReadLine(int capacity = DEFAULT_BUFFER_SIZE)\n {\n capacity += Solution.PAD_FACTOR;\n var ans = Console.ReadLine();\n if (string.IsNullOrWhiteSpace(ans.Trim()))\n ans = Console.ReadLine();\n return ans;\n }\n static int ReadInt32() { return Read(Convert.ToInt32); }\n static long ReadLong64() { return Read(Convert.ToInt64); }\n\n #endregion\n #region LIBS\n [DebuggerNonUserCode]\n public static void assert(bool mustBeTrue, string message = \"ASSERTION FAILED\", params object[] args)\n {\n if (mustBeTrue == false)\n throw new ApplicationException(string.Format(message, args));\n }\n\n [DebuggerNonUserCode]\n public static T assert(T actual, T expected)\n {\n if (object.Equals(actual, expected) == false)\n {\n Debug.WriteLine(expected, \"CORRECT\");\n Debug.WriteLine(actual, \"ACTUAL\");\n assert(false, \"[{0}] SHOULD BE [{1}]\", actual, expected);\n }\n return actual;\n }\n\n [Conditional(\"DEBUG\")]\n public static void EmptyConditionalDebugBreak() { }\n \n public static bool isLrLeftRight(T left, T right) where T : IComparable\n { return left.CompareTo(right) <= 0; }\n\n [DebuggerNonUserCode]\n public static void lrLeftRight_ASSERT(T left, T right) where T : IComparable\n { assert(isLrLeftRight(left, right), \"Expect left [{0}] <= [{1}] right\", left, right); }\n\n public static IEnumerable forEach(this IEnumerable range, Action action)\n { foreach (var elem in range) action(elem); return range; }\n\n [DebuggerNonUserCode]\n public static void __AssertIncrStep(double incrStep) { assert(incrStep > 0, \"Expect 'incrStep [{0}] > 0'\", incrStep); }\n\n public static IEnumerable range(int left, int right, int incrStep = 1)\n {\n lrLeftRight_ASSERT(left, right);\n __AssertIncrStep(incrStep);\n for (var i = left; i <= right; i += incrStep) yield return i;\n }\n public static IEnumerable rangeReverse(int left, int right, int decrStep = 1)\n {\n lrLeftRight_ASSERT(left, right);\n __AssertIncrStep(decrStep);\n for (var i = right; i >= left; i -= decrStep) yield return i;\n }\n\n #endregion\n\n // =============================================================================================\n\n\n}", "lang_cluster": "C#", "tags": ["brute force", "strings", "implementation"], "code_uid": "8ee89296e3fece5f67c9e27d8bf68448", "src_uid": "cad8283914da16bc41680857bd20fe9f", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace _513A\n{\n class Program\n {\n static void Main(string[] args)\n {\n string[] str = Console.ReadLine().Split(' ');\n int n1 = Convert.ToInt32(str[0]);\n int n2 = Convert.ToInt32(str[1]);\n\n if (n2 >= n1) { Console.WriteLine(\"Second\"); } else\n {\n Console.WriteLine(\"First\");\n }\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "constructive algorithms"], "code_uid": "cc8803c5d6c736ad7a1ca48b961f4e84", "src_uid": "aed24ebab3ed9fd1741eea8e4200f86b", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\n// Codeforces problem 513A \"\u0418\u0433\u0440\u0430\"\n// http://codeforces.com/problemset/problem/513/A\nnamespace _513_A\n{\n\tclass Program\n\t{\n\t\tstatic void Main(string[] args)\n\t\t{\n\t\t\t#region Read data\n\t\t\tstring[] tmp = Console.ReadLine().Split();\n\t\t\tint n1 = Convert.ToInt32(tmp[0]);\n\t\t\tint n2 = Convert.ToInt32(tmp[1]);\n\t\t\tint k1 = Convert.ToInt32(tmp[2]);\n\t\t\tint k2 = Convert.ToInt32(tmp[3]);\n\t\t\t#endregion\n\t\t\t#region Process data\n\n\t\t\t#endregion\n\t\t\t#region Write results\n\t\t\tif (n1 > n2)\n\t\t\t{\n\t\t\t\tConsole.WriteLine(\"First\");\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tConsole.WriteLine(\"Second\");\n\t\t\t}\n\t\t\tConsole.ReadLine();\n\t\t\t#endregion\n\t\t}\n\t}\n}\n", "lang_cluster": "C#", "tags": ["math", "constructive algorithms"], "code_uid": "12453b246076248367cf55097f15a5eb", "src_uid": "aed24ebab3ed9fd1741eea8e4200f86b", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Globalization;\nusing System.IO;\nusing System.Linq;\nusing System.Text;\nusing System.Threading;\n\n// (\u3065\u00b0\u03c9\u00b0)\u3065\uff90\u2605\u309c\u30fb\u3002\u3002\u30fb\u309c\u309c\u30fb\u3002\u3002\u30fb\u309c\u2606\u309c\u30fb\u3002\u3002\u30fb\u309c\u309c\u30fb\u3002\u3002\u30fb\u309c\npublic class Solver\n{\n int[][] divs = new []\n {\n null,\n null,\n new [] { 2 }, \n new [] { 3 }, \n new [] { 2, 2 }, \n new [] { 5 }, \n new [] { 2, 3 }, \n new [] { 7 }, \n new [] { 2, 2, 2 }, \n new [] { 3, 3 }\n };\n\n public void Solve()\n {\n ReadInt();\n var count = new int[8];\n foreach (char c in ReadToken())\n for (int i = 2; i <= c - '0'; i++)\n foreach (int x in divs[i])\n count[x]++;\n\n foreach (var x in new [] { 7, 5, 3, 2})\n while (count[x] > 0)\n {\n writer.Write(x);\n for (int i = 2; i <= x; i++)\n foreach (int y in divs[i])\n count[y]--;\n }\n Write();\n }\n \n #region Main\n\n protected static TextReader reader;\n protected static TextWriter writer;\n\n static void Main()\n {\n#if DEBUG\n reader = new StreamReader(\"..\\\\..\\\\input.txt\");\n writer = Console.Out;\n //writer = new StreamWriter(\"..\\\\..\\\\output.txt\");\n#else\n reader = new StreamReader(Console.OpenStandardInput());\n writer = new StreamWriter(Console.OpenStandardOutput());\n //reader = new StreamReader(\"game.in\");\n //writer = new StreamWriter(\"game.out\");\n#endif\n try\n {\n var thread = new Thread(new Solver().Solve, 1024 * 1024 * 256);\n thread.Start();\n thread.Join();\n //new Solver().Solve();\n }\n catch (Exception ex)\n {\n#if DEBUG\n Console.WriteLine(ex);\n#else\n Console.WriteLine(ex);\n throw;\n#endif\n }\n reader.Close();\n writer.Close();\n }\n\n #endregion\n\n #region Read / Write\n\n private static Queue currentLineTokens = new Queue();\n\n private static string[] ReadAndSplitLine()\n {\n return reader.ReadLine().Split(new[] { ' ', '\\t' }, StringSplitOptions.RemoveEmptyEntries);\n }\n\n public static string ReadToken()\n {\n while (currentLineTokens.Count == 0)\n currentLineTokens = new Queue(ReadAndSplitLine());\n return currentLineTokens.Dequeue();\n }\n\n public static int ReadInt()\n {\n return int.Parse(ReadToken());\n }\n\n public static long ReadLong()\n {\n return long.Parse(ReadToken());\n }\n\n public static double ReadDouble()\n {\n return double.Parse(ReadToken(), CultureInfo.InvariantCulture);\n }\n\n public static int[] ReadIntArray()\n {\n return ReadAndSplitLine().Select(int.Parse).ToArray();\n }\n\n public static long[] ReadLongArray()\n {\n return ReadAndSplitLine().Select(long.Parse).ToArray();\n }\n\n public static double[] ReadDoubleArray()\n {\n return ReadAndSplitLine().Select(s => double.Parse(s, CultureInfo.InvariantCulture)).ToArray();\n }\n\n public static int[][] ReadIntMatrix(int numberOfRows)\n {\n int[][] matrix = new int[numberOfRows][];\n for (int i = 0; i < numberOfRows; i++)\n matrix[i] = ReadIntArray();\n return matrix;\n }\n\n public static int[][] ReadAndTransposeIntMatrix(int numberOfRows)\n {\n int[][] matrix = ReadIntMatrix(numberOfRows);\n int[][] ret = new int[matrix[0].Length][];\n for (int i = 0; i < ret.Length; i++)\n {\n ret[i] = new int[numberOfRows];\n for (int j = 0; j < numberOfRows; j++)\n ret[i][j] = matrix[j][i];\n }\n return ret;\n }\n\n public static string[] ReadLines(int quantity)\n {\n string[] lines = new string[quantity];\n for (int i = 0; i < quantity; i++)\n lines[i] = reader.ReadLine().Trim();\n return lines;\n }\n\n public static void WriteArray(IEnumerable array)\n {\n writer.WriteLine(string.Join(\" \", array));\n }\n\n public static void Write(params object[] array)\n {\n WriteArray(array);\n }\n\n public static void WriteLines(IEnumerable array)\n {\n foreach (var a in array)\n writer.WriteLine(a);\n }\n\n #endregion\n}", "lang_cluster": "C#", "tags": ["math", "greedy", "dp", "implementation"], "code_uid": "f8a69ff3304efb11ecef3a1b2d94d42b", "src_uid": "60dbfc7a65702ae8bd4a587db1e06398", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections;\nusing System.Collections.Generic;\nusing System.Text;\n\n\n/// \npublic class Program\n{\n static int[] primes = new int[] { 2, 3, 5, 7 };\n static Tuple[] preCalc = new Tuple[10];\n static Tuple[] preCalcFact = new Tuple[10];\n private static void init()\n {\n for (int i = 0; i <= 9; i++)\n {\n int[] states = new int[4];\n\n int tmp = i;\n for (int j = 0; j < primes.Length && i >= 2; j++)\n {\n while (tmp % primes[j] == 0)\n {\n tmp /= primes[j];\n states[j]++;\n }\n }\n\n preCalc[i] = new Tuple(states[0], states[1], states[2], states[3]);\n }\n\n for (int i = 0; i <= 9; i++)\n {\n if (i - 1 >= 0)\n {\n preCalcFact[i] = new Tuple(\n preCalcFact[i - 1].Item1 + preCalc[i].Item1,\n preCalcFact[i - 1].Item2 + preCalc[i].Item2,\n preCalcFact[i - 1].Item3 + preCalc[i].Item3,\n preCalcFact[i - 1].Item4 + preCalc[i].Item4);\n }\n else\n {\n preCalcFact[i] = preCalc[i];\n }\n }\n }\n\n private static Dictionary, string> dp;\n\n private static void Main()\n {\n init();\n\n int n = Int32.Parse(Console.ReadLine());\n\n string input = Console.ReadLine();\n\n dp = new Dictionary, string>();\n\n Console.WriteLine(solve(Convert(input)));\n }\n\n\n private static string solve(Tuple state)\n {\n if (state.Item1 == 0 && state.Item2 == 0 && state.Item3 == 0 && state.Item4 == 0)\n {\n return \"\";\n }\n else if (dp.ContainsKey(state))\n {\n return dp[state];\n }\n else\n {\n string best = null;\n for (int i = 2; i <= 9; i++)\n {\n if (state.Item1 >= preCalcFact[i].Item1 && \n state.Item2 >= preCalcFact[i].Item2 &&\n state.Item3 >= preCalcFact[i].Item3 &&\n state.Item4 >= preCalcFact[i].Item4)\n {\n string subString = solve(new Tuple(state.Item1 - preCalcFact[i].Item1,\n state.Item2 - preCalcFact[i].Item2,\n state.Item3 - preCalcFact[i].Item3,\n state.Item4 - preCalcFact[i].Item4));\n\n if (subString != null)\n {\n string now = (char)('0' + i) + subString;\n\n if (best == null || now.Length > best.Length || (now.Length == best.Length && String.Compare(now, best) > 0))\n {\n best = now;\n }\n }\n }\n }\n\n dp[state] = best;\n\n return best;\n }\n }\n\n static Tuple Convert(string input)\n {\n int[] states = new int[4];\n for (int i = 0; i < input.Length; i++)\n {\n states[0] += preCalcFact[input[i] - '0'].Item1;\n states[1] += preCalcFact[input[i] - '0'].Item2;\n states[2] += preCalcFact[input[i] - '0'].Item3;\n states[3] += preCalcFact[input[i] - '0'].Item4;\n }\n\n return new Tuple(states[0], states[1], states[2], states[3]);\n }\n}\n\n", "lang_cluster": "C#", "tags": ["math", "greedy", "dp", "implementation"], "code_uid": "1157059b980d15a83b5a676b0960de20", "src_uid": "60dbfc7a65702ae8bd4a587db1e06398", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\n\nnamespace ConsoleApplication1\n{\n class Program\n {\n static int dp(string s,int c)\n {\n int res = -1;\n if ((c==0)&&(s.Length==0)) return 0;\n if ((c == 0) && (s.Length != 0)) return -1;\n if (s.Length >= c)\n {\n string num=\"\";\n int sum=-1;\n for (int i = 0; i < 7 && i < s.Length - c + 1; i++)\n {\n num += s[i];\n int tt =int.Parse(num);\n if (tt <= 1000000)\n {\n int t = dp(s.Substring(i + 1, s.Length - i - 1), c - 1);\n if ((t != -1) && ((num[0] != '0') || (num.Length == 1)))\n sum = Math.Max(sum, tt + t);\n }\n }\n return sum;\n }\n return res;\n\n }\n static void Main(string[] args)\n {\n string s = Console.ReadLine();\n Console.WriteLine(dp(s, 3));\n Console.ReadLine();\n\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "implementation"], "code_uid": "e4c972ea626b2d7c5753d6c238a8013f", "src_uid": "bf4e72636bd1998ad3d034ad72e63097", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Globalization;\nusing System.Linq;\nusing System.Text;\nusing System.Text.RegularExpressions;\nusing System.Threading;\n\nnamespace Codeforces\n{\n class A\n {\n private static ThreadStart s_threadStart = new A().Go;\n private static bool s_time = false;\n\n private void Go()\n {\n string s = GetString();\n int n = s.Length;\n int max = -1;\n for (int l1 = 1; l1 <= n-2; l1++)\n {\n for (int l2 = 1; l2 <= n - l1 - 1; l2++)\n {\n string s1 = s.Substring(0, l1);\n string s2 = s.Substring(l1, l2);\n string s3 = s.Substring(l1 + l2);\n\n if ((s1[0] == '0' && s1 != \"0\") || (s2[0] == '0' && s2 != \"0\") || (s3[0] == '0' && s3 != \"0\")) continue;\n if (s1.Length > 7 || s2.Length > 7 || s3.Length > 7) continue;\n int i1 = int.Parse(s1);\n int i2 = int.Parse(s2);\n int i3 = int.Parse(s3);\n if (i1 > 1000000 || i2 > 1000000 || i3 > 1000000) continue;\n\n if (max < i1 + i2 + i3)\n max = i1 + i2 + i3;\n }\n }\n\n Wl(max);\n }\n\n #region Template\n\n public static void Main(string[] args)\n {\n System.Diagnostics.Stopwatch timer = new System.Diagnostics.Stopwatch();\n Thread main = new Thread(new ThreadStart(s_threadStart), 512 * 1024 * 1024);\n timer.Start();\n main.Start();\n main.Join();\n timer.Stop();\n if (s_time)\n Wl(timer.ElapsedMilliseconds);\n }\n\n private static IEnumerator ioEnum;\n private static string GetString()\n {\n while (ioEnum == null || !ioEnum.MoveNext())\n {\n ioEnum = Console.ReadLine().Split().AsEnumerable().GetEnumerator();\n }\n\n return ioEnum.Current;\n }\n\n private static int GetInt()\n {\n return int.Parse(GetString());\n }\n\n private static long GetLong()\n {\n return long.Parse(GetString());\n }\n\n private static double GetDouble()\n {\n return double.Parse(GetString());\n }\n\n private static List GetIntArr(int n)\n {\n List ret = new List(n);\n for (int i = 0; i < n; i++)\n {\n ret.Add(GetInt());\n }\n return ret;\n }\n\n private static void Wl(T o)\n {\n if (o is double)\n {\n Wld((o as double?).Value, \"\");\n }\n else if (o is float)\n {\n Wld((o as float?).Value, \"\");\n }\n else\n Console.WriteLine(o.ToString());\n }\n\n private static void Wl(IEnumerable enumerable)\n {\n Wl(string.Join(\" \", enumerable.Select(e => e.ToString()).ToArray()));\n }\n\n private static void Wld(double d, string format)\n {\n Wl(d.ToString(format, CultureInfo.InvariantCulture));\n }\n\n public struct Tuple : IComparable>\n where T : IComparable\n where K : IComparable\n {\n public T Item1;\n public K Item2;\n\n public Tuple(T t, K k)\n {\n Item1 = t;\n Item2 = k;\n }\n\n public override bool Equals(object obj)\n {\n var o = (Tuple)obj;\n return o.Item1.Equals(Item1) && o.Item2.Equals(Item2);\n }\n\n public override int GetHashCode()\n {\n return Item1.GetHashCode() ^ Item2.GetHashCode();\n }\n\n public override string ToString()\n {\n return \"(\" + Item1 + \" \" + Item2 + \")\";\n }\n\n #region IComparable> Members\n\n public int CompareTo(Tuple other)\n {\n int ret = Item1.CompareTo(other.Item1);\n if (ret != 0) return ret;\n return Item2.CompareTo(other.Item2);\n }\n\n #endregion\n }\n\n #endregion\n }\n}", "lang_cluster": "C#", "tags": ["brute force", "implementation"], "code_uid": "77d04ad912a497cd0c5aa428da7042d9", "src_uid": "bf4e72636bd1998ad3d034ad72e63097", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace _476b\n{\n class Program\n {\n static void Main(string[] args)\n {\n int transmit=0;\n int reseive = 0;\n string s1 = Console.ReadLine();\n string s2 = Console.ReadLine();\n int count = 0;\n int count2 = 0;\n int i = 0;\n while (i < s1.Length)\n {\n transmit += s1[i] == '+' ? 1 : -1;\n if (s2[i] != '?')\n reseive += s2[i] == '+' ? 1 : -1;\n else\n count++;\n i++;\n }\n if(count == 0)\n {\n if (transmit == reseive)\n Console.WriteLine(1);\n else\n Console.Write(0);\n }\n else\n {\n if (Math.Abs((transmit - reseive)) % 2 == count % 2 && (transmit - reseive) <= count && (transmit - reseive) >= -count)\n {\n int k = (count - (transmit - reseive)) / 2;\n double result = 1;\n for (int z = 0; z < k; z++)\n {\n result *= (double)(count - z) / (z + 1);\n }\n Console.WriteLine((result / Math.Pow(2, count)).ToString(\"0.000000000000\").Replace(',', '.'));\n }\n else\n {\n Console.WriteLine(0);\n } \n \n }\n Console.ReadLine();\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "math", "dp", "combinatorics", "bitmasks", "probabilities"], "code_uid": "24ff7a3edf6940246c49450dfc3d5d5b", "src_uid": "f7f68a15cfd33f641132fac265bc5299", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace Dreamoon_and_WiFi\n{\n class Program\n {\n static void Main(string[] args)\n {\n //Teste x = new Teste();\n //x.calcula(Console.ReadLine(), Console.ReadLine());\n Codigo cod = new Codigo(Console.ReadLine(), Console.ReadLine()); //Chama a fun\u00e7\u00e3o com os dois valores digitados\n cod.exibe(); //Exibe o resultado em decimal\n }\n }\n\n class Codigo\n {\n //Iniciando um vetor que vai guardar os dois valores poss\u00edveis nas instru\u00e7\u00f5es\n private int[] contaDreamon = new int[2];\n private int[] contaDrazil = new int[2];\n\n //Quantidade de valores desconhecidos passados ao drazil\n private int quantInt;\n\n private int distancia;\n private int posDreamoon;\n private int posDrazil;\n\n public Codigo(string drazil, string dreamoon)\n {\n contaDreamon[0] = dreamoon.Split(new char[] { '-' }).Length - 1; //Vai contar quantos '-' possui e vai passar para a vari\u00e1vel, e assim respectivamente com as 3 pr\u00f3xima linhas\n contaDreamon[1] = dreamoon.Split(new char[] { '+' }).Length - 1;\n contaDrazil[0] = drazil.Split(new char[] { '-' }).Length - 1;\n contaDrazil[1] = drazil.Split(new char[] { '+' }).Length - 1;\n quantInt = dreamoon.Split(new char[] { '?' }).Length - 1; //Quantidade de c\u00f3digos desconhecidos\n posDrazil = contaDrazil[1] - contaDrazil[0]; //Determina a posi\u00e7\u00e3o do Drazil depois de enviar os comandos\n posDreamoon = contaDreamon[1] - contaDreamon[0]; //Determina a posi\u00e7\u00e3o do dreamoon depois de receber os comandos\n distancia = posDrazil - posDreamoon; //Define a dist\u00e2ncia restante para Dreamoon chegar na mesma posi\u00e7\u00e3o\n }\n\n private double compara()\n {\n if (contaDreamon[0] == contaDrazil[0] && contaDreamon[1] == contaDrazil[1]) //Se receberem a mesma quantidade de '+' e '-', a conta termina em 100%\n {\n return 1;\n }\n else if (quantInt < Math.Abs(distancia)) //Se a quantidade de caminhos duvidosos for maior que a dist\u00e2ncia restante, a chance \u00e9 zero\n return 0;\n else\n {\n int m = (quantInt + Math.Abs(distancia)) / 2; //Calcula a quantidade de passos v\u00e1lidos para chegar na posi\u00e7\u00e3o correta\n\n double combinacao = (fatorial(quantInt) / (fatorial(quantInt - m) * (fatorial(m)))); //Realiza o c\u00e1lculo da combina\u00e7\u00e3o\n\n return (double)combinacao / (1 << quantInt); //Retorna o restante da formula C(Quantidade de ?, m) / 2 ^ quantidade de ?\n }\n }\n\n public void exibe()\n {\n string result = compara().ToString();\n result = result.Replace(',', '.');\n Console.WriteLine(\"{0:F12}\", result); //Exibe o resultado com 12 algarismos\n }\n\n private double fatorial(int n)\n {\n if (n == 1 || n == 0)\n return 1;\n else\n return (n * fatorial(n - 1));\n }\n }\n\n\n}\n", "lang_cluster": "C#", "tags": ["brute force", "math", "dp", "combinatorics", "bitmasks", "probabilities"], "code_uid": "a7619e4ecf04c2389f0e24073f999772", "src_uid": "f7f68a15cfd33f641132fac265bc5299", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace test_codeforces\n{\n class Program\n {\n static void Main(string[] args)\n {\n int a, b, c, d, e, f;\n a = int.Parse( Console.ReadLine() );\n b = int.Parse(Console.ReadLine());\n c = int.Parse(Console.ReadLine());\n d = int.Parse(Console.ReadLine());\n e = int.Parse(Console.ReadLine());\n f = int.Parse(Console.ReadLine());\n\n if (e > f)\n {\n int delim = Math.Min(a, d);\n int ans = delim * e;\n if (delim != d) \n {\n d -= a;\n delim = Math.Min(b, Math.Min(c, d));\n ans += delim * f;\n }\n Console.WriteLine(ans);\n }else \n {\n int delim = Math.Min(b, Math.Min(c, d));\n int ans = delim * f;\n if (delim != d)\n {\n d -= delim;\n delim = Math.Min(a, d);\n ans += delim * e;\n }\n Console.WriteLine(ans);\n }\n //Console.ReadKey();\n\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "greedy", "brute force"], "code_uid": "8ed4f09224cb43d752c7d711c3b26a85", "src_uid": "84d9e7e9c9541d997e6573edb421ae0a", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace ConsoleApplication37\n{\n class Program\n {\n static void Main(string[] args)\n {\n int a = Convert.ToInt32(Console.ReadLine());\n int b = Convert.ToInt32(Console.ReadLine());\n int c = Convert.ToInt32(Console.ReadLine());\n int d = Convert.ToInt32(Console.ReadLine());\n int e = Convert.ToInt32(Console.ReadLine());\n int f = Convert.ToInt32(Console.ReadLine());\n\n if (f >= e)\n {\n int min = Math.Min(b, Math.Min(c, d));\n\n long ans = min * f;\n if (d > min)\n {\n d = d - min;\n\n int minn = Math.Min(a, d);\n ans = ans + minn * e;\n\n Console.WriteLine(ans);\n }\n else\n Console.WriteLine(ans);\n }\n else if (f < e)\n {\n int min = Math.Min(a, d);\n long ans = min * e;\n\n if (d == min)\n Console.WriteLine(ans);\n else\n {\n d = d - min;\n ans = ans + Math.Min(b, Math.Min(c, d)) * f;\n Console.WriteLine(ans);\n }\n }\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "greedy", "brute force"], "code_uid": "7f1c62d3d9abae5cbb520f8705e4036a", "src_uid": "84d9e7e9c9541d997e6573edb421ae0a", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\nusing System.IO;\n\nnamespace comp\n{\n class Program\n {\n\n static void Main(string[] args)\n {\n string a = \"\";\n a = Console.ReadLine();\n // string a = \"WUBWEWUBAREWUBWUBTHEWUBCHAMPIONSWUBMYWUBFRIENDWUB\";\n a = a.Replace(\"WUB\", \" \");\n Console.WriteLine(a) ;\n \n\n \n }\n }\n}\n", "lang_cluster": "C#", "tags": ["strings"], "code_uid": "20d3e7440b38d41700c8958236e42f53", "src_uid": "edede580da1395fe459a480f6a0a548d", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace Contesa\n{\n class Program\n {\n static void Main(string[] args)\n {\n string Song = Console.ReadLine();\n Song = Song.Replace(\"WUB\", \" \");\n Console.WriteLine(Song.TrimStart());\n \n }\n\n }\n}\n", "lang_cluster": "C#", "tags": ["strings"], "code_uid": "1a372de3af7f575753aaefb5fce4f5f4", "src_uid": "edede580da1395fe459a480f6a0a548d", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Linq;\nusing System.Collections.Generic;\nusing System.Text;\n\n\nnamespace MakeCalendar\n{\n public static class MainClass\n {\n\n static int ReadIntLine()\n {\n return int.Parse(Console.ReadLine());\n }\n\n static void ReadInt(ref int a)\n {\n a = ReadIntArrayLine()[0];\n }\n\n static void ReadInts(ref int a, ref int b)\n {\n var x = ReadIntArrayLine();\n a = x[0]; b = x[1];\n }\n\n\n\n static void ReadInts(ref int a, ref int b, ref int c)\n {\n var x = ReadIntArrayLine();\n a = x[0]; b = x[1]; c = x[2];\n }\n\n static void ReadInts(ref int a, ref int b, ref int c, ref int d)\n {\n var x = ReadIntArrayLine();\n a = x[0]; b = x[1]; c = x[2]; d = x[3];\n }\n\n\n static void ReadInts(ref int a, ref int b, ref int c, ref int d, ref int e)\n {\n var x = ReadIntArrayLine();\n a = x[0]; b = x[1]; c = x[2]; d = x[3]; e = x[4];\n }\n\n static void ReadInts(ref int a, ref int b, ref int c, ref int d, ref int e, ref int f)\n {\n var x = ReadIntArrayLine();\n a = x[0]; b = x[1]; c = x[2]; d = x[3]; e = x[4]; f = x[5];\n }\n\n static int[] ReadIntArrayLine()\n {\n char[] sep = { ' ' };\n return Console.ReadLine().Split(sep, StringSplitOptions.RemoveEmptyEntries).Select(x => int.Parse(x)).ToArray();\n }\n\n static void PrintLn(object obj)\n {\n Console.WriteLine(obj.ToString());\n }\n\n public static string Reverse(string s)\n {\n char[] charArray = s.ToCharArray();\n Array.Reverse(charArray);\n return new string(charArray);\n }\n\n\n public static void PrintLnCollection(IEnumerable col)\n {\n PrintLn(string.Join(\" \", col));\n }\n\n\n public static void PrintLn(params object[] v)\n {\n PrintLnCollection(v);\n }\n\n public static string ReadLine()\n {\n return Console.ReadLine();\n }\n\n\n public static string MySubstring(this string str, int start, int finish)\n {\n if (start > finish) return \"\";\n return str.Substring(start, finish - start + 1);\n }\n\n\n public static bool IsInRange(this int a, int lb, int ub)\n {\n return (a >= lb) && (a <= ub);\n }\n\n private static void mergeDS(int i, int j, int[] a)\n {\n int t = a[j];\n for (int ii = 0; ii < a.Length; ii++)\n {\n if (a[ii] == t)\n a[ii] = a[i];\n }\n }\n\n private static T MyMax(params T[] a)\n {\n return a.Max();\n }\n\n private static T MyMin(params T[] a)\n {\n return a.Min();\n }\n\n\n private static int[] GetPrimesLessThan(int x)\n {\n if (x < 2)\n return new int[0];\n\n int[] a = new int[x];\n\n a[0] = 1; a[1] = 1;\n\n for (int i = 0; i < a.Length; i++)\n {\n if (a[i] == 0)\n for (int j = 2 * i; j < a.Length; j += i)\n {\n a[j] = 1;\n }\n }\n\n var abc = new List(x);\n\n for (int i = 0; i < a.Length; i++)\n {\n if (a[i] == 0)\n abc.Add(i);\n }\n\n return abc.ToArray();\n }\n\n private static int FindNearestLEQElementInTheArray(int[] a, int startIndex, int endIndex, int target)\n {\n if (startIndex == endIndex)\n {\n if (a[startIndex] <= target)\n return startIndex;\n else\n return -1;\n }\n\n if (startIndex + 1 == endIndex)\n {\n if (a[endIndex] <= target)\n return endIndex;\n else if (a[startIndex] <= target)\n return startIndex;\n else\n return -1;\n }\n\n int mid = (startIndex + endIndex) / 2;\n if (target == a[mid])\n return mid;\n else if (target < a[mid])\n return FindNearestLEQElementInTheArray(a, startIndex, mid - 1, target);\n else\n return FindNearestLEQElementInTheArray(a, mid, endIndex, target);\n }\n\n private static int FindNearestLEQElementInTheArray(int[] a, int target)\n {\n return FindNearestLEQElementInTheArray(a, 0, a.Length - 1, target);\n }\n\n private static int gcd(int a, int b)\n {\n int r = a % b;\n while (r != 0)\n {\n a = b;\n b = r;\n r = a % b;\n }\n return b;\n }\n\n //----------------------------------------------------------------------------\n\n static void Main(string[] args)\n {\n\n int P = 1000000007 ;\n\n int n = ReadIntLine();\n\n long k = 1;\n long s_k = 0;\n long d_k = 1;\n\n\n\n while (k != n)\n {\n long s_k1 = (3 * d_k) % P;\n long d_k1 = (2 * d_k + s_k) % P;\n\n d_k = d_k1;\n s_k = s_k1;\n \n k++;\n }\n\n PrintLn(s_k);\n \n }\n\n \n\n }\n\n \n}", "lang_cluster": "C#", "tags": ["math", "matrices", "dp"], "code_uid": "5dd8650114f2e9f3a16ab667ba63b331", "src_uid": "77627cc366a22e38da412c3231ac91a8", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.IO;\n\nnamespace Codeforce158\n{\n class Program\n {\n static int[] parseInt(string s)\n {\n string[] temp = s.Split(' ');\n List res = new List();\n for (int i = 0; i < temp.Length; i++)\n {\n res.Add(Convert.ToInt32(temp[i]));\n }\n return res.ToArray();\n }\n\n const int Mod = 1000000007;\n static void Main(string[] args)\n {\n int n = Convert.ToInt32(Console.ReadLine());\n\n int[,] F = new int[n + 2, 4];\n\n F[1, 1] = 0;\n F[1, 2] = 0;\n F[1, 3] = 0;\n F[1, 0] = 1;\n\n for (int i = 2; i <= n + 1; i++)\n {\n F[i, 1] = ((F[i - 1, 2] + F[i - 1, 3]) % Mod + F[i - 1, 0])%Mod;\n F[i, 2] = ((F[i - 1, 1] + F[i - 1, 3]) % Mod + F[i - 1, 0])%Mod;\n F[i, 3] = ((F[i - 1, 1] + F[i - 1, 2]) % Mod + F[i - 1, 0])%Mod;\n F[i, 0] = ((F[i - 1, 1] + F[i - 1, 2]) % Mod + F[i - 1, 3])%Mod;\n }\n\n\n Console.WriteLine(F[n + 1, 0]);\n \n }\n }\n}", "lang_cluster": "C#", "tags": ["math", "matrices", "dp"], "code_uid": "54a631ccc6ab37315c2de420d2bf71c3", "src_uid": "77627cc366a22e38da412c3231ac91a8", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Numerics;\nusing System.Text;\nnamespace CP\n{\n class Program\n {\n static void Main(string [] main)\n {\n int [] nAndM = Array.ConvertAll(Console.ReadLine().Split(' ') , x => Convert.ToInt32(x));\n Console.WriteLine(nAndM.Max() - 1 + \" \" + nAndM.Min());\n }\n }\n}", "lang_cluster": "C#", "tags": ["greedy", "implementation", "games"], "code_uid": "645732d68d989ba9f29213034a2c66ed", "src_uid": "c8378e6fcaab30d15469a55419f38b39", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.IO;\n\nnamespace Timus\n{\n\n class Program\n {\n static int[] parseInt(string s)\n {\n string[] temp = s.Split(' ');\n List res = new List();\n for (int i = 0; i < temp.Length; i++)\n {\n res.Add(Convert.ToInt32(temp[i]));\n }\n return res.ToArray();\n }\n\n\n static void Main(string[] args)\n {\n int[] data = parseInt(Console.ReadLine());\n if (data[0] < data[1])\n {\n int temp = data[0];\n data[0] = data[1];\n data[1] = temp;\n }\n\n int a1 = data[1] + (data[0] - data[1] - 1);\n int a2 = data[1];\n Console.WriteLine(a1 + \" \" + a2);\n\n }\n\n\n }\n}", "lang_cluster": "C#", "tags": ["greedy", "implementation", "games"], "code_uid": "f9807e5a422568672e35cdbff9503d69", "src_uid": "c8378e6fcaab30d15469a55419f38b39", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Text;\n\n\nnamespace codeforces_round_157_1\n{\n class Program\n {\n static void Main(string[] args)\n {\n int[,] arr = new int[3,3];\n int sum = 0;\n int sum2 = 0;\n for (int i = 0; i < 3; i++)\n {\n string[] st = Console.ReadLine().Split(' ');\n for (int j = 0; j < 3; j++)\n {\n arr[i, j] = Int32.Parse(st[j]);\n sum += arr[i, j];\n }\n }\n sum /= 2;\n arr[0,0] = sum - (arr[0, 1] + arr[0, 2]);\n arr[2, 2] = sum - (arr[0, 2] + arr[1, 2]);\n arr[1, 1] = (arr[0, 0] + arr[2, 2])/2;\n int x = 0;\n foreach (int i in arr)\n {\n if (x++ < 2)\n Console.Write(i+\" \");\n else\n {\n Console.WriteLine(i);\n x = 0;\n }\n }\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "implementation"], "code_uid": "4e4f6b98394cc68338028ebf87eef2aa", "src_uid": "0c42eafb73d1e30f168958a06a0f9bca", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\n\nnamespace CDF157\n{\n class Program\n {\n static void Main(string[] args)\n {\n int[,] a = new int[3, 3];\n string[] input;\n for (int i = 0; i < 3; i++)\n {\n input = Console.ReadLine().Split(' ');\n for (int j = 0; j < 3; j++)\n a[i, j] = int.Parse(input[j]);\n }\n int e = (a[0, 1] + a[0, 2] + a[1, 0] + a[1, 2] + a[2, 0] + a[2, 1]) / 2;\n a[0,0] = e - a[0, 1] - a[0, 2];\n a[1,1]= e - a[1, 0] - a[1, 2];\n a[2,2] = e - a[2, 0] - a[2, 1];\n for (int i = 0; i < 3; i++)\n {\n for (int j = 0; j < 3; j++)\n Console.Write(a[i, j] + \" \");\n Console.WriteLine();\n }\n Console.ReadLine();\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "implementation"], "code_uid": "411f22bcbb18f0a2eb5195cb6a9f0369", "src_uid": "0c42eafb73d1e30f168958a06a0f9bca", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace Komanda\n{\n class Program\n {\n static void Main(string[] args)\n {\n string[] s = Console.ReadLine().Split();\n int l = int.Parse(s[0]);\n int r = int.Parse(s[1]);\n int a = int.Parse(s[2]);\n int min = Math.Min(l, r);\n int max = Math.Max(l, r);\n int diff = max - min;\n min += Math.Min(a, diff);\n a -= Math.Min(a, diff);\n min += a / 2;\n Console.Write(min * 2);\n \n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "implementation"], "code_uid": "d3dead92c588469b41753e198e2d426e", "src_uid": "e8148140e61baffd0878376ac5f3857c", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\n\nnamespace CodeForces\n{\n static class Program\n {\n static void Main()\n {\n const string filePath = @\"Data\\R469A.txt\";\n if (System.IO.File.Exists(filePath))\n {\n Console.SetIn(new System.IO.StreamReader(filePath));\n }\n\n IProblem counter = new R469A();\n\n foreach (var result in counter.GetResults())\n {\n Console.WriteLine(result);\n }\n }\n }\n\n internal class R469A : ProblemBase\n {\n public override IEnumerable GetResults()\n {\n var ints = this.ReadIntArray();\n var l = ints[0];\n var r = ints[1];\n var a = ints[2];\n\n var b = Math.Min(l, r);\n var over = Math.Max(l - b, r - b);\n if (a >= over)\n {\n b += over;\n a -= over;\n b += a / 2;\n }\n else\n {\n b += a;\n }\n\n yield return (b*2).ToString();\n }\n }\n\n internal class R469B : ProblemBase\n {\n public override IEnumerable GetResults()\n {\n yield return \"n/a\";\n }\n }\n internal class R469C : ProblemBase\n {\n public override IEnumerable GetResults()\n {\n yield return \"n/a\";\n }\n }\n internal class R469D : ProblemBase\n {\n public override IEnumerable GetResults()\n {\n yield return \"n/a\";\n }\n }\n\n abstract class MultipleTestsBase : ProblemBase\n {\n public sealed override IEnumerable GetResults()\n {\n var t = Convert.ToInt32(Console.ReadLine());\n for (int testCaseNumber = 0; testCaseNumber < t; testCaseNumber++)\n {\n foreach (var result in GetTestResult(testCaseNumber + 1))\n {\n yield return result;\n }\n\n }\n\n }\n\n protected abstract IEnumerable GetTestResult(int caseNumber);\n }\n\n public interface IProblem\n {\n IEnumerable GetResults();\n }\n\n public abstract class ProblemBase : IProblem\n {\n /// \n /// Pring array of T\n /// \n /// Generic paramter.\n /// The items.\n /// The message shown first.\n public void PrintArray(IEnumerable items, string prefixMessage)\n {\n Console.WriteLine(\"{0}: {1}\", prefixMessage, string.Join(\",\", items));\n }\n\n public void WriteDiagnostics(string message, params object[] objects)\n {\n Console.WriteLine(message, objects);\n }\n\n public virtual IEnumerable GetResults()\n {\n yield return \"No result\";\n }\n\n protected int[] ReadIntArray()\n {\n return Array.ConvertAll(ReadTokens(), Convert.ToInt32);\n }\n\n protected string[] ReadTokens()\n {\n var readLine = Console.ReadLine();\n if (readLine == null)\n {\n throw new Exception(\"Value read from Console is null\");\n }\n return readLine.Split(' ');\n }\n\n protected int ReadInt32()\n {\n return Convert.ToInt32(Console.ReadLine());\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "implementation"], "code_uid": "04a123e87b09e100349f08365fbb0915", "src_uid": "e8148140e61baffd0878376ac5f3857c", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\n\nnamespace a1\n{\n\tpublic class Program\n\t{\n\t\tpublic static int F(int x)\n\t\t{\n\t\t\tvar v = x + 1;\n\t\t\twhile (v % 10 == 0)\n\t\t\t{\n\t\t\t\tv /= 10;\n\t\t\t}\n\n\t\t\treturn v;\n\t\t}\n\n\t\tpublic static void Main(string[] args)\n\t\t{\n\t\t\tvar n = Int32.Parse(Console.ReadLine());\n\n\t\t\tvar d = new HashSet();\n\n\t\t\tfor (var i = 0; i < 10000; i++)\n\t\t\t{\n\t\t\t\td.Add(n);\n\t\t\t\tn = F(n);\n\t\t\t}\n\n\t\t\tConsole.WriteLine(d.Count);\n\t\t}\n\t}\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "66a75616251f1d34a170aaf1f840a07a", "src_uid": "055fbbde4b9ffd4473e6e716da6da899", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Text;\n\nnamespace UdsuTest\n{\n class Program\n {\n public static void Main(string[] args)\n {\n Int64 input = Int64.Parse(Console.ReadLine());\n\n Int64 answer = 1;\n if (input < 10)\n {\n answer = 0;\n }\n\n while (input >= 10L)\n {\n Int64 right = input % 10L;\n\n answer = 9L - right + answer;\n\n input /= 10;\n }\n\n answer += 9;\n\n Console.WriteLine(answer);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "013077298aac8fa125b99eb7ffa53016", "src_uid": "055fbbde4b9ffd4473e6e716da6da899", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Text;\nusing System.IO;\nusing System.Text.RegularExpressions;\nusing System.Globalization;\n\nnamespace CodeForcesApp\n{\n class B\n {\n #region Shortcuts\n static string RL() { return Console.ReadLine(); }\n static string[] RSA() { return RL().Split(' '); }\n static int[] RIA() { return Array.ConvertAll(RSA(), int.Parse); }\n static int RInt() { return int.Parse(RL()); }\n static long RLong() { return long.Parse(RL()); }\n static double RDouble() { return double.Parse(RL()); }\n static void RInts2(out int p1, out int p2) { int[] a = RIA(); p1 = a[0]; p2 = a[1]; }\n static void RInts3(out int p1, out int p2, out int p3) { int[] a = RIA(); p1 = a[0]; p2 = a[1]; p3 = a[2]; }\n\n static void Swap(ref T a, ref T b) { T tmp = a; a = b; b = tmp; }\n static void Fill(T[] d, T v) { for (int i = 0; i < d.Length; i++) d[i] = v; }\n static void Fill(T[,] d, T v) { for (int i = 0; i < d.GetLength(0); i++) { for (int j = 0; j < d.GetLength(1); j++) { d[i, j] = v; } } }\n #endregion\n\n static void Main(string[] args)\n {\n System.Threading.Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.InvariantCulture;\n\n //SolutionTester tester = new SolutionTester(CodeForcesTask.B);\n //tester.Test();\n\n Task task = new Task();\n task.Solve();\n }\n\n public class Task\n {\n public void Solve()\n {\n string cd = RL();\n string bd = RL();\n\n string[] cd_dd = cd.Split('.');\n\n string format = \"dd.MM.yyyy\";\n\n DateTime cd_date = DateTime.ParseExact(string.Format(\"{0}.{1}.{2}\", cd_dd[0], cd_dd[1], 2000 + int.Parse(cd_dd[2])), format, CultureInfo.InvariantCulture);\n\n int[] dd = Array.ConvertAll(bd.Split('.'), int.Parse);\n\n int[] p = { 0, 1, 2 };\n\n do\n {\n string nd = string.Format(\"{0}.{1}.{2}\", dd[p[0]].ToString().PadLeft(2, '0'), dd[p[1]].ToString().PadLeft(2, '0'), 2000 + dd[p[2]]);\n\n DateTime ddt;\n if (DateTime.TryParseExact(nd, format, CultureInfo.InvariantCulture, DateTimeStyles.AssumeUniversal, out ddt))\n {\n if (ddt.Year % 4 == 0 && ddt.Month == 2 && ddt.Day == 29)\n ddt = new DateTime(ddt.Year, 3, 1);\n\n if (ddt.AddYears(18) <= cd_date.AddMinutes(23 * 60 + 59))\n {\n Console.WriteLine(\"YES\");\n return;\n }\n }\n\n\n } while (GetNext(p));\n\n Console.WriteLine(\"NO\");\n }\n\n public bool GetNext(int[] p)\n {\n int n = p.Length;\n int i = n - 2;\n while (i >= 0 && p[i] >= p[i + 1])\n i--;\n if (i == -1)\n return false;\n\n int k = i + 1;\n for (int j = i + 1; j < n; j++)\n if (p[j] < p[k] && p[j] > p[i])\n k = j;\n\n int t = p[i];\n p[i] = p[k];\n p[k] = t;\n\n for (int j = 0; j < (n - i - 1) / 2; j++)\n {\n t = p[j + i + 1];\n p[j + i + 1] = p[n - j - 1];\n p[n - j - 1] = t;\n }\n\n return true;\n }\n }\n\n \n }\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "c60cfa1fb575bfc602af9d7fe4819cad", "src_uid": "5418c98fe362909f7b28f95225837d33", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Globalization;\nusing System.Text;\nusing System.IO;\n\n\n\n\nclass Program\n{\n void solve()\n {\n int[] a = get();\n int[] m = get();\n String res = \"NO\";\n for (int i = 0; i < 3; i++)\n for (int j = 0; j < 3; j++)\n {\n if (i == j)\n continue;\n int k = 3 - i - j;\n int[] cur = new int[3];\n cur[0] = m[i];\n cur[1] = m[j];\n cur[2] = m[k];\n if (ok(cur, a))\n res = \"YES\";\n }\n println(res);\n }\n\n private bool ok(int[] cur, int[] a)\n {\n int[]d=new int[]{31,28,31,30,31,30,31,31,30,31,30,31};\n cur[1]--;\n if(cur[1]>=12)\n return false;\n if (cur[2] % 4 == 0)\n {\n d[1]++;\n }\n if (d[cur[1]] < cur[0])\n return false;\n int y = cur[2]+18;\n int[] t = new int[3];\n t[2] =y;\n t[1] = cur[1];\n t[0] = cur[0];\n if (cur[0] == 29 && cur[1] == 1)\n {\n if (y % 4 == 0)\n t[0] = 29;\n else\n {\n t[0] = 1;\n t[1]++;\n }\n }\n t[1]++;\n for (int i = 2; i >= 0; i--)\n if (a[i] != t[i])\n return t[i] < a[i];\n return true;\n \n \n }\n\n private int[] get()\n {\n string[] t = nextString().Split('.');\n int[] r = new int[3];\n for (int i = 0; i < 3; i++)\n r[i] = int.Parse(t[i]);\n return r;\n }\n\n ////////////\n private void println(string Stringst)\n {\n Console.WriteLine(Stringst);\n }\n private void println(char charnum)\n {\n Console.WriteLine(charnum);\n }\n private void println(int Intnum)\n {\n Console.WriteLine(Intnum);\n }\n private void println(long Longnum)\n {\n Console.WriteLine(Longnum);\n }\n private void println(double Doublenum)\n {\n Console.WriteLine(Doublenum);\n }\n\n private void print(string Stringst)\n {\n Console.Write(Stringst);\n }\n private void print(int Intnum)\n {\n Console.Write(Intnum);\n }\n private void print(char charnum)\n {\n Console.Write(charnum);\n }\n private void print(long Longnum)\n {\n Console.Write(Longnum);\n }\n private void print(double Doublenum)\n {\n Console.Write(Doublenum);\n }\n\n\n string[] inputLine = new string[0];\n int inputInd = 0;\n string nextLine()\n {\n return Console.ReadLine();\n }\n void readInput()\n {\n if (inputInd != inputLine.Length)\n throw new Exception();\n inputInd = 0;\n inputLine = Console.ReadLine().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);\n if (inputLine.Length == 0)\n readInput();\n\n }\n int nextInt()\n {\n if (inputInd == inputLine.Length)\n readInput();\n return int.Parse(inputLine[inputInd++]);\n }\n long nextLong()\n {\n if (inputInd == inputLine.Length)\n readInput();\n return long.Parse(inputLine[inputInd++]);\n }\n double nextDouble()\n {\n if (inputInd == inputLine.Length)\n readInput();\n return double.Parse(inputLine[inputInd++]);\n }\n string nextString()\n {\n if (inputInd == inputLine.Length)\n readInput();\n return inputLine[inputInd++];\n }\n static void Main(string[] args)\n {\n new Program().solve();\n }\n}\n\n\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "59ec16af7a193f51ff6a6bb4d5d700ad", "src_uid": "5418c98fe362909f7b28f95225837d33", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Linq;\n\nnamespace KitaharaHarukisGift\n{\n class Program\n {\n static void Main(string[] args)\n {\n int apples = int.Parse(Console.ReadLine());\n int[] grams = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).OrderByDescending(x => x).ToArray();\n int friend1 = 0;\n int friend2 = 0;\n for (int i = 0; i < grams.Length; i++)\n {\n if (friend1 <= friend2)\n friend1 += grams[i];\n else\n friend2 += grams[i];\n }\n Console.WriteLine(friend1 == friend2 ? \"YES\" : \"NO\");\n Console.ReadLine();\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "implementation"], "code_uid": "7b9564252909ba02bf4864e70aca79b2", "src_uid": "9679acef82356004e47b1118f8fc836a", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Diagnostics;\nusing System.Globalization;\nusing System.IO;\nusing System.Linq;\nusing System.Text;\nusing System.Xml.Schema;\n\nnamespace Codeforces\n{\n internal static class Program\n {\n private const string Problem = \"a\";\n\n private static void Solve()\n {\n var n = ReadInt();\n var w = ReadIntArray();\n var sum = w.Sum();\n var a = sum/2;\n if(a % 200 == 0 || (a% 100 == 0 && w.Contains(100)))\n WriteLine(\"YES\");\n else\n WriteLine(\"NO\");\n }\n\n private static void Main()\n {\n var isDebbuger = Debugger.IsAttached;\n if (isDebbuger)\n {\n var projectPath = Directory.GetParent(Environment.CurrentDirectory).Parent;\n var testsPath = Path.Combine(projectPath != null? projectPath.FullName: \"\", \"tests\");\n var files = Directory.GetFiles(testsPath, string.Format(\"{0}*.in\", Problem));\n\n foreach (var file in files)\n {\n Console.SetIn(new StreamReader(file));\n Console.WriteLine(Path.GetFileNameWithoutExtension(file));\n Solve();\n\n Console.WriteLine();\n\n Console.In.Close();\n Console.SetIn(new StreamReader(Console.OpenStandardInput()));\n }\n\n Console.ReadLine();\n } \n else\n Solve();\n }\n\n private static int[] SortIndexs(this IEnumerable source) where T : IComparable\n {\n var array = source == null ? new List() : source.ToList();\n var n = array.Count;\n var res = Enumerable.Range(0, n).ToArray();\n Array.Sort(res, (a, b) =>\n {\n var compare = array[a].CompareTo(array[b]);\n return compare == 0 ? a.CompareTo(b) : compare;\n });\n return res;\n }\n\n #region Reader\n\n private static string Read()\n {\n return Console.ReadLine();\n }\n\n private static void Read(out T a1, out T a2)\n {\n var input = ReadArray();\n a1 = (T)Convert.ChangeType(input[0], typeof(T));\n a2 = (T)Convert.ChangeType(input[1], typeof(T));\n }\n\n private static void Read(out T a1, out T a2, out T a3)\n {\n var input = ReadArray();\n a1 = (T)Convert.ChangeType(input[0], typeof(T));\n a2 = (T)Convert.ChangeType(input[1], typeof(T));\n a3 = (T)Convert.ChangeType(input[2], typeof(T));\n }\n\n private static void Read(out T a1, out T a2, out T a3, out T a4)\n {\n var input = ReadArray();\n a1 = (T)Convert.ChangeType(input[0], typeof(T));\n a2 = (T)Convert.ChangeType(input[1], typeof(T));\n a3 = (T)Convert.ChangeType(input[2], typeof(T));\n a4 = (T)Convert.ChangeType(input[3], typeof(T));\n }\n\n private static void Read(out T a1, out T a2, out T a3, out T a4, out T a5)\n {\n var input = ReadArray();\n a1 = (T)Convert.ChangeType(input[0], typeof(T));\n a2 = (T)Convert.ChangeType(input[1], typeof(T));\n a3 = (T)Convert.ChangeType(input[2], typeof(T));\n a4 = (T)Convert.ChangeType(input[3], typeof(T));\n a5 = (T)Convert.ChangeType(input[4], typeof(T));\n }\n\n private static void Read(out T a1, out T a2, out T a3, out T a4, out T a5, out T a6)\n {\n var input = ReadArray();\n a1 = (T)Convert.ChangeType(input[0], typeof(T));\n a2 = (T)Convert.ChangeType(input[1], typeof(T));\n a3 = (T)Convert.ChangeType(input[2], typeof(T));\n a4 = (T)Convert.ChangeType(input[3], typeof(T));\n a5 = (T)Convert.ChangeType(input[4], typeof(T));\n a6 = (T)Convert.ChangeType(input[5], typeof(T));\n }\n\n private static int ReadInt()\n {\n return Int32.Parse(Read());\n }\n\n private static long ReadLong()\n {\n return long.Parse(Read());\n }\n\n private static double ReadDouble()\n {\n return double.Parse(Read(), CultureInfo.InvariantCulture);\n }\n\n private static T Read()\n {\n return (T)Convert.ChangeType(Read(), typeof(T));\n }\n\n private static string[] ReadArray()\n {\n var readLine = Console.ReadLine();\n if (readLine != null)\n return readLine.Split(' ');\n\n throw new ArgumentException();\n }\n\n private static List ReadIntArray()\n {\n return ReadArray().Select(Int32.Parse).ToList();\n }\n\n private static List ReadLongArray()\n {\n return ReadArray().Select(long.Parse).ToList();\n }\n\n private static List ReadDoubleArray()\n {\n return ReadArray().Select(d => double.Parse(d, CultureInfo.InvariantCulture)).ToList();\n }\n\n private static List ReadArray()\n {\n return ReadArray().Select(x => (T)Convert.ChangeType(x, typeof(T))).ToList();\n }\n\n private static void WriteLine(double value)\n {\n Console.WriteLine(value.ToString(CultureInfo.InvariantCulture));\n }\n\n private static void WriteLine(double value, string stringFormat)\n {\n Console.WriteLine(value.ToString(stringFormat, CultureInfo.InvariantCulture));\n }\n\n private static void WriteLine(T value)\n {\n Console.WriteLine(value);\n }\n\n private static void Write(double value)\n {\n Console.Write(value.ToString(CultureInfo.InvariantCulture));\n }\n\n private static void Write(double value, string stringFormat)\n {\n Console.Write(value.ToString(stringFormat, CultureInfo.InvariantCulture));\n }\n\n private static void Write(T value)\n {\n Console.Write(value);\n }\n\n #endregion\n }\n}", "lang_cluster": "C#", "tags": ["brute force", "implementation"], "code_uid": "95f1b9454e3f5358f751251c7c42e2b2", "src_uid": "9679acef82356004e47b1118f8fc836a", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\n\nnamespace \u0422\u0435\u043e\u0440\u0435\u043c\u0430_\u041f\u0438\u0444\u0430\u0433\u043e\u0440\u0430_II\n{\n class Program\n {\n static void Main(string[] args)\n {\n Int64 n;\n n = Convert.ToInt64(Console.ReadLine());\n Int64 sqn = n * n;\n Int64 a, b, c, ret = 0;\n double sqc;\n for (a = 1; a <= n; a++)\n for (b = a; b <= n; b++)\n {\n c = a * a + b * b;\n sqc = Math.Sqrt(c);\n if (c <= sqn)\n {\n if ((int)sqc == sqc) ret++;\n }\n else break;\n }\n Console.Write(ret);\n\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "math"], "code_uid": "9e5889d067bd8124f95956602beaae57", "src_uid": "36a211f7814e77339eb81dc132e115e1", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Linq;\nusing System.Collections.Generic;\nusing System.Text;\n\n\nnamespace MakeCalendar\n{\n public static class MainClass\n {\n\n static int ReadIntLine()\n {\n return int.Parse(Console.ReadLine());\n }\n\n static void ReadInt(ref int a)\n {\n a = ReadIntArrayLine()[0];\n }\n\n static void ReadInts(ref int a, ref int b)\n {\n var x = ReadIntArrayLine();\n a = x[0]; b = x[1];\n }\n\n\n\n static void ReadInts(ref int a, ref int b, ref int c)\n {\n var x = ReadIntArrayLine();\n a = x[0]; b = x[1]; c = x[2];\n }\n\n static void ReadInts(ref int a, ref int b, ref int c, ref int d)\n {\n var x = ReadIntArrayLine();\n a = x[0]; b = x[1]; c = x[2]; d = x[3];\n }\n\n\n static void ReadInts(ref int a, ref int b, ref int c, ref int d, ref int e)\n {\n var x = ReadIntArrayLine();\n a = x[0]; b = x[1]; c = x[2]; d = x[3]; e = x[4];\n }\n\n static void ReadInts(ref int a, ref int b, ref int c, ref int d, ref int e, ref int f)\n {\n var x = ReadIntArrayLine();\n a = x[0]; b = x[1]; c = x[2]; d = x[3]; e = x[4]; f = x[5];\n }\n\n static int[] ReadIntArrayLine()\n {\n char[] sep = { ' ' };\n return Console.ReadLine().Split(sep, StringSplitOptions.RemoveEmptyEntries).Select(x => int.Parse(x)).ToArray();\n }\n\n static void PrintLn(object obj)\n {\n Console.WriteLine(obj.ToString());\n }\n\n public static string Reverse(string s)\n {\n char[] charArray = s.ToCharArray();\n Array.Reverse(charArray);\n return new string(charArray);\n }\n\n\n public static void PrintLnCollection(IEnumerable col)\n {\n PrintLn(string.Join(\" \", col));\n }\n\n\n public static void PrintLn(params object[] v)\n {\n PrintLnCollection(v);\n }\n\n public static string ReadLine()\n {\n return Console.ReadLine();\n }\n\n\n public static string MySubstring(this string str, int start, int finish)\n {\n if (start > finish) return \"\";\n return str.Substring(start, finish - start + 1);\n }\n\n\n public static bool IsInRange(this int a, int lb, int ub)\n {\n return (a >= lb) && (a <= ub);\n }\n\n private static void mergeDS(int i, int j, int[] a)\n {\n int t = a[j];\n for (int ii = 0; ii < a.Length; ii++)\n {\n if (a[ii] == t)\n a[ii] = a[i];\n }\n }\n\n private static T MyMax(params T[] a)\n {\n return a.Max();\n }\n\n private static T MyMin(params T[] a)\n {\n return a.Min();\n }\n\n\n private static int[] GetPrimesLessThan(int x)\n {\n if (x < 2)\n return new int[0];\n\n int[] a = new int[x];\n\n a[0] = 1; a[1] = 1;\n\n for (int i = 0; i < a.Length; i++)\n {\n if (a[i] == 0)\n for (int j = 2 * i; j < a.Length; j += i)\n {\n a[j] = 1;\n }\n }\n\n var abc = new List(x);\n\n for (int i = 0; i < a.Length; i++)\n {\n if (a[i] == 0)\n abc.Add(i);\n }\n\n return abc.ToArray();\n }\n\n private static int FindNearestLEQElementInTheArray(int[] a, int startIndex, int endIndex, int target)\n {\n if (startIndex == endIndex)\n {\n if (a[startIndex] <= target)\n return startIndex;\n else\n return -1;\n }\n\n if (startIndex + 1 == endIndex)\n {\n if (a[endIndex] <= target)\n return endIndex;\n else if (a[startIndex] <= target)\n return startIndex;\n else\n return -1;\n }\n\n int mid = (startIndex + endIndex) / 2;\n if (target == a[mid])\n return mid;\n else if (target < a[mid])\n return FindNearestLEQElementInTheArray(a, startIndex, mid - 1, target);\n else\n return FindNearestLEQElementInTheArray(a, mid, endIndex, target);\n }\n\n private static int FindNearestLEQElementInTheArray(int[] a, int target)\n {\n return FindNearestLEQElementInTheArray(a, 0, a.Length - 1, target);\n }\n\n private static int gcd(int a, int b)\n {\n int r = a % b;\n while (r != 0)\n {\n a = b;\n b = r;\n r = a % b;\n }\n return b;\n }\n\n //----------------------------------------------------------------------------\n\n static void Main(string[] args)\n {\n int ub = ReadIntLine();\n int k = (int)Math.Ceiling(Math.Sqrt(ub));\n\n\n HashSet set = new HashSet();\n\n for (int m = 1; m < k; m++)\n {\n for (int n = 1; n < m; n++)\n {\n if (gcd(n, m) == 1)\n {\n int c = m * m + n * n;\n int b = Math.Max(m * m - n * n,2*m*n);\n int a = Math.Min(m * m - n * n, 2 * m * n);\n\n int cc = c, bb = b, aa = a;\n \n while (cc<=ub)\n {\n //PrintLn(aa,bb,cc);\n set.Add(aa + \",\" + bb);\n aa += a;\n bb += b;\n cc += c;\n }\n }\n }\n }\n\n\n PrintLn(set.Count);\n\n }\n\n\n }\n\n\n\n}", "lang_cluster": "C#", "tags": ["brute force", "math"], "code_uid": "5b2fdf0f54dabac1ec94a1fc51a93b16", "src_uid": "36a211f7814e77339eb81dc132e115e1", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Globalization;\nusing System.IO;\nusing System.Linq;\n\nnamespace CF\n{\n internal class Program\n {\n private static void Main(string[] args)\n {\n using (var sr = new InputReader(Console.In))\n//\t\t\tusing (var sr = new InputReader(new StreamReader(\"input.txt\")))\n using (var sw = Console.Out)\n //using (var sw = new StreamWriter(\"output.txt\"))\n using (var task = new Task(sr, sw)) {\n task.Solve();\n// Console.ReadKey();\n }\n }\n }\n\n internal class Task : IDisposable\n {\n private readonly InputReader sr;\n private readonly TextWriter sw;\n private bool isDispose;\n\n public Task(InputReader sr, TextWriter sw)\n {\n this.sr = sr;\n this.sw = sw;\n }\n \n public void Solve()\n {\n var a = sr.NextInt64();\n var b = sr.NextInt64();\n var f = sr.NextInt64();\n var k = sr.NextInt64();\n \n var currB = b;\n var count = 0L;\n for (var i = 0; i < k; i++) {\n var firstStation = i % 2 == 0 ? f : a - f;\n var secondStation = i % 2 == 0 ? 2*a - f : a + f;\n if (i + 1 == k) {\n if (currB - a >= 0) {\n break;\n }\n else {\n if (currB < firstStation) {\n sw.WriteLine(-1);\n return;\n }\n if (b < (a - firstStation)) {\n sw.WriteLine(-1);\n return;\n }\n count++;\n break;\n }\n }\n if (currB < firstStation) {\n sw.WriteLine(-1);\n return;\n }\n if (currB >= secondStation) {\n currB -= a;\n }\n else {\n currB = b - (a - firstStation);\n count++;\n }\n }\n\n sw.WriteLine(count);\n }\n\n ~Task()\n {\n Dispose(false);\n }\n\n public void Dispose()\n {\n Dispose(true);\n GC.SuppressFinalize(this);\n }\n\n private void Dispose(bool disposing)\n {\n if (!isDispose) {\n if (disposing) {\n if(sr != null)\n sr.Dispose();\n \n if(sw != null)\n sw.Dispose();\n }\n\n isDispose = true;\n } \n }\n }\n}\n\ninternal class InputReader : IDisposable\n{\n private bool isDispose;\n private readonly TextReader sr;\n private string[] buffer;\n private int seek;\n\n public InputReader(TextReader stream)\n {\n sr = stream;\n }\n\n public void Dispose()\n {\n Dispose(true);\n GC.SuppressFinalize(this);\n }\n\n public string NextString()\n {\n var result = sr.ReadLine();\n return result;\n }\n\n public int NextInt32()\n {\n return Int32.Parse(ReadNextToken());\n }\n\n private string ReadNextToken()\n {\n if (buffer == null || seek == buffer.Length) {\n seek = 0;\n buffer = NextSplitStrings();\n }\n\n return buffer[seek++];\n }\n\n public long NextInt64()\n {\n return Int64.Parse(ReadNextToken());\n }\n \n public int[] ReadArrayOfInt32()\n {\n return ReadArray(Int32.Parse);\n }\n\n public long[] ReadArrayOfInt64()\n {\n return ReadArray(Int64.Parse);\n }\n\n public string[] NextSplitStrings()\n {\n return NextString()\n .Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);\n }\n\n public T[] ReadArray(Func func)\n {\n return NextSplitStrings()\n .Select(s => func(s, CultureInfo.InvariantCulture))\n .ToArray();\n }\n\n public T[] ReadArrayFromString(Func func, string str)\n {\n return\n str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)\n .Select(s => func(s, CultureInfo.InvariantCulture))\n .ToArray();\n }\n\n protected void Dispose(bool dispose)\n {\n if (!isDispose)\n {\n if (dispose)\n sr.Close();\n \n isDispose = true;\n }\n }\n\n ~InputReader()\n {\n Dispose(false);\n }\n}", "lang_cluster": "C#", "tags": ["math", "greedy", "implementation"], "code_uid": "59f122bcb392cae097c4a6f5f38ee6c7", "src_uid": "283aff24320c6518e8518d4b045e1eca", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.CodeDom;\nusing System.Collections.Generic;\nusing System.ComponentModel.Design.Serialization;\nusing System.Globalization;\nusing System.IO;\nusing System.Linq;\nusing System.Numerics;\nusing System.Text;\nusing System.Threading;\n\nnamespace Codeforces\n{\n class Program : IDisposable\n {\n private static readonly TextReader textReader = new StreamReader(Console.OpenStandardInput());\n private static readonly TextWriter textWriter = new StreamWriter(Console.OpenStandardOutput());\n\n private void Solve()\n {\n var s = Console.ReadLine().Split(' ');\n var a = long.Parse(s[0]);\n var b = long.Parse(s[1]);\n var f = long.Parse(s[2]);\n var k = long.Parse(s[3]);\n\n long sum = f;\n long dist = k*a;\n var points = new List() {0,f};\n var forw = 2*(a-f);\n var back = 2*f;\n var sw = true;\n while (sum b)\n {\n Console.WriteLine(-1);\n return;\n }\n\n var cnt = 0;\n var r = b;\n for (int i = 1; i < points.Count; i++)\n {\n var d = points[i]-points[i-1];\n if (d > r)\n {\n cnt++;\n r = b;\n if (r < d)\n {\n Console.WriteLine(-1);\n return;\n }\n }\n r -= d;\n }\n Console.WriteLine(cnt);\n }\n\n\n int BinarySearch(int[] arr, int q)\n {\n var l = 0;\n var r = arr.Length - 1;\n //int med = -1;\n while (l <= r)\n {\n var med = l + (r - l) / 2;\n if (arr[med] == q)\n {\n return med;\n }\n if (q < arr[med])\n {\n r = med - 1;\n }\n else\n {\n l = med + 1;\n }\n }\n return -1;\n }\n\n\n static void Main(string[] args)\n {\n var p = new Program();\n p.Solve();\n //Console.ReadLine();\n //p.Dispose();\n //////////////////////////////\n }\n\n #region Helpers\n\n private static int ReadInt()\n {\n return int.Parse(textReader.ReadLine());\n }\n\n private static long ReadLong()\n {\n return long.Parse(textReader.ReadLine());\n }\n\n private static int[] ReadIntArray()\n {\n return textReader.ReadLine().Split(' ').Select(int.Parse).ToArray();\n }\n #endregion\n\n public void Dispose()\n {\n textReader.Close();\n textWriter.Close();\n }\n }\n\n //class Trie\n //{\n // public TrieNode root;\n\n // public Trie()\n // {\n // root = new TrieNode();\n // }\n\n // public void Insert(string s)\n // {\n // var current = root;\n // for (int i = 0; i < s.Length; i++)\n // {\n // var ch = s[i];\n // if (!current.Children.ContainsKey(ch))\n // current.Children.Add(ch, new TrieNode());\n // current = current.Children[ch];\n // }\n // current.IsEnd = true;\n // }\n\n // public bool Search(string word)\n // {\n // var current = root;\n // for (int i = 0; i < word.Length; i++)\n // {\n // var ch = word[i];\n // if (!current.Children.ContainsKey(ch))\n // return false;\n // current = current.Children[ch];\n // }\n // return current.IsEnd;\n // }\n //}\n\n //class TrieNode\n //{\n // public Dictionary Children { get; set; }\n // public bool IsEnd { get; set; }\n\n // public TrieNode()\n // {\n // Children = new Dictionary();\n // IsEnd = false;\n // }\n\n \n //}\n}\n\n\n", "lang_cluster": "C#", "tags": ["math", "greedy", "implementation"], "code_uid": "a0f6cc24166f39f675eead1780311328", "src_uid": "283aff24320c6518e8518d4b045e1eca", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Linq;\nusing System.Collections;\nusing System.Collections.Generic;\nclass solution\n{\n static void Main(string[] args)\n {\n string[] ab = Console.ReadLine().Split(' ');\n long n = Convert.ToInt64(ab[0]);\n long k = Convert.ToInt64(ab[1]);\n long div = n / k;\n long val = k*(div+1);\n Console.Write(val);\n }\n}", "lang_cluster": "C#", "tags": ["math", "implementation"], "code_uid": "87169d7bc14a16241a8f0b126fb446e4", "src_uid": "75f3835c969c871a609b978e04476542", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\n\nnamespace ConsoleApplication3\n{\n class Program\n {\n static void Main(string[] args)\n {\n string input = Console.ReadLine();\n string[] res = input.Split(new char[] {' '}, StringSplitOptions.RemoveEmptyEntries);\n int n = int.Parse(res[0]);\n int k = int.Parse(res[1]);\n Console.WriteLine(k*(n/k + 1));\n \n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "implementation"], "code_uid": "9fdd059af4be658711c374e8c0f9ef25", "src_uid": "75f3835c969c871a609b978e04476542", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\n\nnamespace CodeForcecTrain\n{\n class Program\n {\n static void Main(string[] args)\n {\n var kupuri = new int[] { 1, 5, 10, 20, 100 };\n var start = int.Parse(Console.ReadLine());\n int index = 0;\n int res = 0;\n while (start>0)\n {\n if (index < kupuri.Length)\n {\n while (start - kupuri[kupuri.Length - index - 1] >= 0)\n {\n start -= kupuri[kupuri.Length - index - 1];\n res++;\n }\n }\n index++;\n }\n Console.WriteLine(res);\n }\n }\n}", "lang_cluster": "C#", "tags": ["greedy", "dp"], "code_uid": "179c1019cc497b59996877625d47a540", "src_uid": "8e81ad7110552c20297f08ad3e5f8ddc", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace ConsoleApp3\n{\n class Program\n {\n static void Main(string[] args)\n {\n // input //\n int money = int.Parse(Console.ReadLine());\n\n // process //\n int counter = 0;\n while(money != 0)\n {\n if (money >= 100)\n {\n counter += money / 100;\n money %= 100;\n }\n else if (money >= 20)\n {\n counter += money / 20;\n money %= 20;\n }\n else if (money >= 10)\n {\n counter += money / 10;\n money %= 10;\n }\n else if (money >= 5)\n {\n counter += money / 5;\n money %= 5;\n }\n else\n {\n counter += money / 1;\n money = 0;\n }\n }\n\n // output //\n Console.Write(counter);\n Console.ReadLine(); \n\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["greedy", "dp"], "code_uid": "30e9b087d49b0ba862af18c4f5bae760", "src_uid": "8e81ad7110552c20297f08ad3e5f8ddc", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\n\nnamespace ConsoleApp5\n{\n\n\n class Program\n {\n\n static void Main(string[] args)\n {\n Int32 n = Int32.Parse(Console.ReadLine());\n\n \n Console.Write(n/2 +1);\n Console.ReadLine();\n \n \n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math"], "code_uid": "0f068060bbcd84b95c7b4fc344ca4755", "src_uid": "5551742f6ab39fdac3930d866f439e3e", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Linq;\nnamespace codeforces\n{\n class Program\n {\n static void Main(string[] args)\n {\n int n = int.Parse(Console.ReadLine());\n Console.WriteLine(n/2+1);\n }\n }\n}", "lang_cluster": "C#", "tags": ["math"], "code_uid": "80df3043d4dc94bb5c5f8ca4354e2ffd", "src_uid": "5551742f6ab39fdac3930d866f439e3e", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\npublic class Codeforces\n{\n static void Main()\n {\n var n = long.Parse(Console.ReadLine());\n var lim = (long)Math.Sqrt(n * 2) + 1;\n var i = 1L;\n var j = lim;\n while (i <= lim && j > 0)\n {\n if (i * i + i + j * j + j == 2 * n)\n {\n Console.WriteLine(\"YES\");\n return;\n }\n if (i * i + i + j * j + j > 2 * n)\n {\n j--;\n }\n else\n {\n i++;\n }\n }\n Console.WriteLine(\"NO\");\n }\n}", "lang_cluster": "C#", "tags": ["brute force", "implementation", "binary search"], "code_uid": "2f8dc8653bd0a1ec65216e7783bdded5", "src_uid": "245ec0831cd817714a4e5c531bffd099", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.IO;\nusing System.Linq;\nusing System.Text;\n\n#if DEBUG\nusing System.Reflection;\nusing System.Threading.Tasks;\n#endif\n\nnamespace _121b\n{\n class Program\n {\n static string _inputFilename = \"in.txt\";\n static string _outputFilename = \"out.txt\";\n static bool _useFileInput = false;\n\n static long n;\n //static int m;\n\n static int[] a;\n static int[] b;\n\n static void Main(string[] args)\n {\n StreamWriter file = null;\n if (_useFileInput)\n {\n Console.SetIn(File.OpenText(_inputFilename));\n file = new StreamWriter(_outputFilename);\n Console.SetOut(file);\n }\n\n#if DEBUG\n\t\t\tif (!_useFileInput)\n\t\t\t{\n\t\t\t\tConsole.SetIn(getInput());\n\t\t\t}\n#endif\n\n #region SOLUTION\n n = readLong();\n var can = false;\n for (int i = 1; i < n; i++)\n {\n var sum = i * (i + 1) / 2;\n if (sum >= n)\n {\n break;\n }\n\n\n var rem = n - sum;\n var l = 1L;\n var r = n;\n while (true)\n {\n if (l == r)\n {\n break;\n }\n\n var m = l + (r - l) / 2;\n var ns = m * (m + 1) / 2;\n if (ns < rem)\n {\n l = m + 1;\n }\n else\n {\n r = m;\n }\n }\n\n var ns1 = l * (l + 1) / 2;\n if (rem == ns1)\n {\n can = true;\n break;\n }\n }\n\n Console.WriteLine(can ? \"YES\" : \"NO\");\n //n = readInt();\n //m = readInt();\n\n //a = readIntArray();\n //b = readIntArray();\n #endregion\n\n if (_useFileInput)\n {\n file.Close();\n }\n }\n\n static int readInt()\n {\n return int.Parse(Console.ReadLine());\n }\n\n static long readLong()\n {\n return long.Parse(Console.ReadLine());\n }\n\n static int[] readIntArray()\n {\n return Console.ReadLine().Split(' ').Where(i => !string.IsNullOrEmpty(i)).Select(i => int.Parse(i)).ToArray();\n }\n\n static long[] readLongArray()\n {\n return Console.ReadLine().Split(' ').Where(i => !string.IsNullOrEmpty(i)).Select(i => long.Parse(i)).ToArray();\n }\n\n#if DEBUG\n\t\tstatic StreamReader getInput()\n\t\t{\n\t\t\tvar resName = Assembly.GetCallingAssembly().GetManifestResourceNames()[0];\n\t\t\tvar resource = Assembly.GetCallingAssembly().GetManifestResourceStream(resName);\n\n\t\t\treturn new StreamReader(resource);\n\t\t}\n#endif\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "implementation", "binary search"], "code_uid": "c35d00396bffc8d79e4ec61e58f0855c", "src_uid": "245ec0831cd817714a4e5c531bffd099", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\n class Program\n {\n static void Main(string[] args)\n {\n int n = int.Parse(Console.ReadLine());\n int a = n / 7 * 2;\n n%=7;\n Console.WriteLine(\"{0} {1}\", (a + (n == 6 ? 1 : 0)), (a+(n>1?2:n)));\n }\n }", "lang_cluster": "C#", "tags": ["math", "greedy", "constructive algorithms", "brute force"], "code_uid": "461e9a57eca8b56ff2fe54a41ed287b1", "src_uid": "8152daefb04dfa3e1a53f0a501544c35", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Globalization;\nusing System.IO;\nnamespace ConsoleApplication6\n{\n class Program\n {\n static void Main(string[] args)\n {\n int n = Convert.ToInt32(Console.ReadLine());\n int min=0;\n int max=0;\n \n min = (n / 7) * 2 + (n - (n / 7) * 7) / 6;\n if (n % 7 == 0) {\n max = min;\n }\n if (n % 7 > 1)\n {\n max = (n / 7 + 1) * 2;\n\n }\n if (n % 7 == 1)\n {\n max = (n / 7 * 2 + 1);\n }\n Console.WriteLine(min.ToString() + \" \" + max.ToString());\n Console.ReadLine();\n }\n }\n}", "lang_cluster": "C#", "tags": ["math", "greedy", "constructive algorithms", "brute force"], "code_uid": "8b0b5cb8e3aa82b4f913b065d49e4b70", "src_uid": "8152daefb04dfa3e1a53f0a501544c35", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.IO;\n\nnamespace Algorithm\n{\n class Solver\n {\n Player[] a = new Player[4];\n\n public void Run()\n {\n for (int i = 0; i < 4; i++)\n {\n string[] tokens = cin.ReadLine().Split();\n int x = int.Parse(tokens[0]);\n int y = int.Parse(tokens[1]);\n a[i] = new Player(x, y);\n }\n\n if (can_win(a[0].Defence, a[1].Attak, a[2].Defence, a[3].Attak) &&\n can_win(a[0].Defence, a[1].Attak, a[3].Defence, a[2].Attak))\n {\n cout.WriteLine(\"Team 1\");\n return;\n }\n if (can_win(a[1].Defence, a[0].Attak, a[2].Defence, a[3].Attak) &&\n can_win(a[1].Defence, a[0].Attak, a[3].Defence, a[2].Attak))\n {\n cout.WriteLine(\"Team 1\");\n return;\n }\n\n int cnt = 0;\n if (can_win(a[2].Defence, a[3].Attak, a[0].Defence, a[1].Attak) ||\n can_win(a[3].Defence, a[2].Attak, a[0].Defence, a[1].Attak)) cnt++;\n if (can_win(a[2].Defence, a[3].Attak, a[1].Defence, a[0].Attak) ||\n can_win(a[3].Defence, a[2].Attak, a[1].Defence, a[0].Attak)) cnt++;\n\n if (cnt == 2)\n cout.WriteLine(\"Team 2\");\n else\n cout.WriteLine(\"Draw\");\n }\n\n bool can_win(int a, int b, int c, int d)\n {\n if (a > d && b > c) return true;\n return false;\n }\n\n void Swap(ref int a, ref int b)\n {\n int tmp = a;\n a = b;\n b = tmp;\n }\n\n public StreamReader cin = null;\n public StreamWriter cout = null;\n }\n\n class Player\n {\n public Player() { }\n public Player(int _a, int _d)\n {\n this.Attak = _a;\n this.Defence = _d;\n }\n public int Attak;\n public int Defence;\n }\n\n class Program\n {\n public static void Main(string[] args)\n {\n Solver task = new Solver();\n#if DEBUG\n task.cin = new StreamReader(\"input.txt\");\n task.cout = new StreamWriter(\"output.txt\");\n#else\n task.cin = new StreamReader(Console.OpenStandardInput());\n task.cout = new StreamWriter(Console.OpenStandardOutput());\n#endif\n task.cout.AutoFlush = true;\n task.Run();\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "f0494bdbac49c0f8a6969dde9650b253", "src_uid": "1a70ed6f58028a7c7a86e73c28ff245f", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeff// Submitted by Silithus @ Macau\nusing System;\nusing System.IO;\nusing System.Collections.Generic;\nusing CCF_XOI;\n\nnamespace RCC2014\n{\n\tclass QR_C\n\t{\n\t\tprivate int beat(int a_atk, int a_def, int b_atk, int b_def)\n\t\t{\n\t\t\tif (a_atk > b_def && a_def > b_atk) return 1;\n\t\t\tif (b_atk > a_def && b_def > a_atk) return -1;\n\t\t\treturn 0;\n\t\t}\n\n\t\tpublic void Solve(XOI xoi)\n\t\t{\n\t\t\tint i, j, res, ans;\n\t\t\tint[,] team;\n\t\t\tstring[] ans_words = { \"Team 2\", \"Draw\", \"Team 1\" };\n\n\t\t\tteam = new int[4, 2];\n\t\t\tfor (i = 0; i < 4; i++)\n\t\t\t\tfor (j = 0; j < 2; j++)\n\t\t\t\t\tteam[i, j] = xoi.ReadInt();\n\n\t\t\tfor (i = 0, ans = -1999; i <= 1; i++)\n\t\t\t{\n\t\t\t\tfor (j = 2, res = 1999; j <= 3; j++)\n\t\t\t\t\tres = Math.Min(res, beat(team[i, 1], team[1 - i, 0], team[j, 1], team[5 - j, 0]));\n\t\t\t\tans = Math.Max(ans, res);\n\t\t\t}\n\n\t\t\txoi.o.WriteLine(ans_words[ans + 1]);\n\t\t}\n\t}\n\t\n\tclass RCC2014_QR\n\t{\n\t\tstatic void Main(string[] args)\n\t\t{\n\t\t\tXOI xoi = new XOI();\n\t\t\t(new QR_C()).Solve(xoi);\n\t\t}\n\t}\n}\n\nnamespace CCF_XOI\n{\n\tclass XOI\n\t{\n\t\tprotected StreamReader sr;\n\t\tpublic StreamWriter o;\n\t\tprotected Queue buf = new Queue();\n\t\tpublic bool EOF = false;\n\n\t\tpublic XOI()\n\t\t{\n\t\t\tthis.sr = new StreamReader(Console.OpenStandardInput());\n\t\t\tthis.o = new StreamWriter(Console.OpenStandardOutput());\n\t\t\tthis.o.AutoFlush = true;\n\t\t}\n\t\t\n\t\tpublic XOI(string in_path, string out_path)\n\t\t{\n\t\t\tthis.sr = new StreamReader(in_path);\n\t\t\tthis.o = new StreamWriter(out_path);\n\t\t\tthis.o.AutoFlush = true;\n\t\t}\n\n\t\tpublic int ReadInt()\n\t\t{\n\t\t\tstring s = this.GetNext();\n\t\t\tif (s == null) return -1;\n\t\t\telse return Int32.Parse(s);\n\t\t}\n\n\t\tpublic long ReadLong()\n\t\t{\n\t\t\tstring s = this.GetNext();\n\t\t\tif (s == null) return -1;\n\t\t\telse return Int64.Parse(s);\n\t\t}\n\n\t\tpublic double ReadDouble()\n\t\t{\n\t\t\tstring s = this.GetNext();\n\t\t\tif (s == null) return -1;\n\t\t\telse return Double.Parse(s);\n\t\t}\n\n\t\tpublic string ReadString()\n\t\t{\n\t\t\tstring s = this.GetNext();\n\t\t\treturn (s == null ? null : s);\n\t\t}\n\n\t\tpublic string ReadLine()\n\t\t{\t// I will ignore current buffer and read a new line\n\t\t\tstring s = \"\";\n\t\t\twhile (s == \"\" && !this.EOF)\n\t\t\t{\n\t\t\t\ts = sr.ReadLine();\n\t\t\t\tthis.EOF = (s == null);\n\t\t\t}\n\t\t\treturn (this.EOF ? null : s);\n\t\t}\n\n\t\tprotected string GetNext()\n\t\t{\n\t\t\tif (buf.Count == 0)\n\t\t\t{\n\t\t\t\twhile (buf.Count == 0 && !this.EOF)\n\t\t\t\t{\n\t\t\t\t\tstring s = sr.ReadLine();\n\t\t\t\t\tif (s == null)\n\t\t\t\t\t\tthis.EOF = true;\n\t\t\t\t\telse\n\t\t\t\t\t\tforeach (string ss in s.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries))\n\t\t\t\t\t\t\tbuf.Enqueue(ss);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn (this.EOF ? null : buf.Dequeue());\n\t\t}\n\t}\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "7925463fa6cac546d9a23038ac7d48f5", "src_uid": "1a70ed6f58028a7c7a86e73c28ff245f", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\n\nnamespace ConsoleApplication1\n{\n class Program\n {\n static void Main(string[] args)\n {\n var numbers = Console.ReadLine().Split(' ').Select(x => Convert.ToInt64(x)).ToArray();\n\n var criminals = Console.ReadLine().Split(' ').Select(x => Convert.ToInt64(x)).ToArray();\n\n long left = numbers[1] - 1;\n long right = numbers[1] - 1;\n\n long sum = 0;\n\n while (left >= 0 || right <= numbers[0] - 1)\n {\n if (left == right)\n {\n sum += criminals[left];\n }\n else if (left < 0)\n {\n sum += criminals[right];\n }\n else if (right > numbers[0] - 1)\n {\n sum += criminals[left];\n }\n else\n {\n if (criminals[right] == 1 && criminals[left] == 1)\n {\n sum += 2;\n }\n }\n left--;\n right++;\n }\n\n Console.WriteLine(sum);\n\n }\n\n }\n}\n", "lang_cluster": "C#", "tags": ["constructive algorithms", "implementation"], "code_uid": "7d8235a953dc1cf75ef55919ff9fbf59", "src_uid": "4840d571d4ce6e1096bb678b6c100ae5", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.IO;\nusing System.Linq;\nclass Solution{\n\t static void Main(string[] args) {\n var tmp = Console.ReadLine().Split(' ');\n int n = int.Parse(tmp[0]);\n int m = int.Parse(tmp[1]);\n\n m--;\n\n bool[] A = Array.ConvertAll(Console.ReadLine().Split(' '), x => x == \"1\");\n\n int ans = 0;\n if (A[m]) ans++;\n int i = m - 1, j = m + 1;\n while (i >= 0 && j < n) {\n if (A[i] && A[j]) ans += 2;\n i--; j++;\n }\n\n for (; i >= 0; i--) if (A[i]) ans++;\n for (; j < n; j++) if (A[j]) ans++;\n Console.WriteLine(ans);\n\t }\n}", "lang_cluster": "C#", "tags": ["constructive algorithms", "implementation"], "code_uid": "4ba6e0681b871bba5d6231c4e3fecb52", "src_uid": "4840d571d4ce6e1096bb678b6c100ae5", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\n\nnamespace ConsoleApplication3\n{\n class Program\n {\n static void Main(string[] args)\n {\n byte [] p = {0,0,0};\n\n int n = int.Parse(Console.ReadLine()) % 6;\n\n p[int.Parse(Console.ReadLine())] = 1;\n\n byte tmp;\n\n for(int i = n; i >= 1; i--)\n {\n tmp = p[0 + (1 - i % 2)];\n p[0 + (1 - i % 2)] = p[1 + (1 - i % 2)];\n p[1 + (1 - i % 2)] = tmp;\n }\n\n Console.WriteLine(p[0] == 1 ? 0 : (p[1] == 1 ? 1 : 2));\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "constructive algorithms", "implementation"], "code_uid": "b2578176e7ddd32c7499dd73de4580bb", "src_uid": "7853e03d520cd71571a6079cdfc4c4b0", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Linq;\nusing System.Collections.Generic;\n\nnamespace MyNewConsoleApp\n{\n class Program\n {\n static void Main()\n {\n int n = int.Parse(Console.ReadLine());\n byte x = byte.Parse(Console.ReadLine());\n\n for(int i = n % 6; i > 0; i--)\n {\n if(i % 2 == 0)\n {\n if (x == 1)\n x = 2;\n else if (x == 2)\n x = 1;\n }\n else\n {\n if (x == 0)\n x = 1;\n else if (x == 1)\n x = 0;\n }\n }\n Console.WriteLine(x);\n }\n }\n}", "lang_cluster": "C#", "tags": ["math", "constructive algorithms", "implementation"], "code_uid": "99e49f158545b2718fc756e7fd599276", "src_uid": "7853e03d520cd71571a6079cdfc4c4b0", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\n\nnamespace mod\n{\n class Program\n {\n static void Main(string[] args)\n {\n double n = Convert.ToInt32(Console.ReadLine());\n double m = Convert.ToInt32(Console.ReadLine());\n\n double res = m % Math.Pow(2, n);\n Console.WriteLine(res);\n }\n }\n}", "lang_cluster": "C#", "tags": ["math", "implementation"], "code_uid": "7cee52720c790bc30c7e2e3d923175af", "src_uid": "c649052b549126e600691931b512022f", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.IO;\nusing System.Text;\nusing System.Text.RegularExpressions;\nusing System.Linq;\nusing System.Collections.Generic;\nusing System.Numerics;\n\nnamespace Rextester {\n public class Program {\n private static readonly StreamReader reader = new StreamReader(Console.OpenStandardInput(1024*10), Encoding.ASCII, false, 1024*10);\n\n public static void Main(string[] args) {\n \n long n = Next();\n long m = Next();\n \n\n Console.WriteLine(m%Math.Pow(2,n));\n }\n\n private static long Next() {\n long c;\n long m = 1;\n do {\n c = reader.Read();\n if (c == '-')\n m = -1;\n } while (c < '0' || c > '9');\n long res = c - '0';\n while (true) {\n c = reader.Read();\n if (c < '0' || c > '9')\n return m*res;\n res *= 10;\n res += c - '0';\n }\n }\n }\n}", "lang_cluster": "C#", "tags": ["math", "implementation"], "code_uid": "2ee8fce829d444a9c69f7a7e952d4630", "src_uid": "c649052b549126e600691931b512022f", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Collections;\nusing System.Linq;\nusing System.Numerics;\n\n\n\n\nnamespace contest\n{\n\n class contest\n {\n\n\n static void Main(string[] args)\n {\n\n\n //int n = int.Parse(Console.ReadLine());\n //var input = Console.ReadLine().Split().Select(int.Parse).ToArray();\n\n //var num = Console.ReadLine().Split().Select(int.Parse).ToArray();\n\n\n\n int n = int.Parse(Console.ReadLine());\n string s = (Console.ReadLine());\n\n bool only = true;\n\n var memoA = new int[n];\n var memoB = new int[n];\n for(int i =0; i< n; i++)\n {\n \n int tmp = s[i]-'0';\n\n if (tmp == 0)\n {\n memoA[i] = 8;\n }\n else if (tmp == 3) memoA[i] = -1;\n else memoA[i] = tmp - 3;\n\n if(tmp ==0)\n {\n memoB[i] = 11;\n }\n else if(tmp ==8) memoB[i] = 0;\n else memoB[i] = tmp + 3;\n \n \n }\n\n if (!memoA.Any(c => c < 0 || c >= 10) || !memoB.Any(c => c < 0 || c >= 10)) only = false;\n\n memoA = new int[n];\n memoB = new int[n];\n for (int i = 0; i < n; i++)\n {\n\n int tmp = s[i] - '0';\n\n if (tmp == 1)\n {\n memoA[i] = -1;\n }\n else if (tmp == 4 || tmp ==7) memoA[i] = -1;\n else memoA[i] = tmp - 1;\n\n if (tmp == 0)\n {\n memoB[i] = 11;\n }\n else if (tmp == 3 || tmp==6) memoB[i] = 11;\n else memoB[i] = tmp + 1;\n\n\n }\n if (!memoA.Any(c => c < 0 || c >= 10) || !memoB.Any(c => c < 0 || c >= 10)) only = false;\n\n if (only) Console.WriteLine(\"YES\");\n else Console.WriteLine(\"NO\");\n\n\n\n\n \n\n\n }\n\n \n\n }\n\n\n}\n", "lang_cluster": "C#", "tags": ["brute force", "constructive algorithms", "implementation"], "code_uid": "6418daa8b7b3f09fbdcc5b702c6f567d", "src_uid": "d0f5174bb0bcca5a486db327b492bf33", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Globalization;\nusing System.IO;\nusing System.Linq;\nusing System.Text;\n\nnamespace TaskA\n{\n class Program\n {\n static void Main(string[] args)\n {\n new Solver().Solve().OutputResult();\n }\n\n private class ExtendedReader : StreamReader\n {\n private static readonly char Separator = ' ';\n\n public ExtendedReader(Stream stream) : base(stream) { }\n public ExtendedReader(Stream stream, bool detectEncodingFromByteOrderMarks) : base(stream, detectEncodingFromByteOrderMarks) { }\n public ExtendedReader(Stream stream, Encoding encoding) : base(stream, encoding) { }\n public ExtendedReader(Stream stream, Encoding encoding, bool detectEncodingFromByteOrderMarks) : base(stream, encoding, detectEncodingFromByteOrderMarks) { }\n public ExtendedReader(Stream stream, Encoding encoding, bool detectEncodingFromByteOrderMarks, int bufferSize) : base(stream, encoding, detectEncodingFromByteOrderMarks, bufferSize) { }\n public ExtendedReader(Stream stream, Encoding encoding, bool detectEncodingFromByteOrderMarks, int bufferSize, bool leaveOpen) : base(stream, encoding, detectEncodingFromByteOrderMarks, bufferSize, leaveOpen) { }\n public ExtendedReader(string path) : base(path) { }\n public ExtendedReader(string path, bool detectEncodingFromByteOrderMarks) : base(path, detectEncodingFromByteOrderMarks) { }\n public ExtendedReader(string path, Encoding encoding) : base(path, encoding) { }\n public ExtendedReader(string path, Encoding encoding, bool detectEncodingFromByteOrderMarks) : base(path, encoding, detectEncodingFromByteOrderMarks) { }\n public ExtendedReader(string path, Encoding encoding, bool detectEncodingFromByteOrderMarks, int bufferSize) : base(path, encoding, detectEncodingFromByteOrderMarks, bufferSize) { }\n\n public char ReadChar()\n {\n return (char)this.Read();\n }\n\n public double ReadDoubleFromArray()\n {\n StringBuilder sb = new StringBuilder();\n char ch = this.ReadChar();\n while (ch != Separator && ch != '\\n')\n {\n sb.Append(ch);\n ch = this.ReadChar();\n }\n return Convert.ToDouble(sb.ToString());\n }\n\n public int ReadInt()\n {\n return int.Parse(this.ReadLine());\n }\n\n public Int64 ReadInt64()\n {\n return Int64.Parse(this.ReadLine());\n }\n\n public int[] ReadIntArray()\n {\n return this.ReadLine().Split(' ').Select(int.Parse).ToArray();\n }\n\n public char[] ReadCharArray()\n {\n return this.ReadLine().ToCharArray();\n }\n\n public string ReadString()\n {\n return this.ReadLine();\n }\n\n public string[] ReadStringArray()\n {\n return this.ReadLine().Split(' ').ToArray();\n }\n\n public Int64[] ReadInt64Array()\n {\n return this.ReadLine().Split(Separator).Select(Int64.Parse).ToArray();\n }\n\n public Double[] ReadDoubleArray()\n {\n return this.ReadLine().Split(Separator).Select(Double.Parse).ToArray();\n }\n }\n\n private abstract class SolverBase\n {\n protected readonly ExtendedReader _reader;\n protected readonly TextWriter _writer;\n\n protected SolverBase()\n {\n#if DEBUG\n _reader = new ExtendedReader(\"input.txt\");\n //_writer = new StreamWriter(\"output.txt\");\n _writer = new StreamWriter(Console.OpenStandardOutput());\n#else\n _reader = new ExtendedReader(Console.OpenStandardInput());\n _writer = new StreamWriter(Console.OpenStandardOutput());\n#endif\n }\n\n public abstract Solver Solve();\n\n public abstract void OutputResult();\n }\n\n private class Solver : SolverBase\n {\n private bool result = false;\n\n public override Solver Solve()\n {\n // link to task: http://codeforces.com/problemset/problem/688/A\n\n var n = _reader.ReadInt();\n var s = _reader.ReadString();\n\n result = ShiftLeft(s) || ShiftRight(s) || ShiftUp(s) || ShiftDown(s);\n result = !result;\n\n return this;\n }\n\n private bool ShiftDown(string s)\n {\n return !s.Replace('0', '-').Replace('7', '-').Replace('9', '-').Contains(\"-\");\n }\n\n private bool ShiftUp(string s)\n {\n return !s.Replace('1', '-').Replace('2', '-').Replace('3', '-').Contains(\"-\");\n }\n\n private bool ShiftRight(string s)\n {\n return !s.Replace('0', '-').Replace('3', '-').Replace('6', '-').Replace('9', '-').Contains(\"-\");\n }\n\n private bool ShiftLeft(string s)\n {\n return !s.Replace('0', '-').Replace('1', '-').Replace('4', '-').Replace('7', '-').Contains(\"-\");\n }\n\n public override void OutputResult()\n {\n string answer = result ? \"YES\" : \"NO\";\n\n _writer.WriteLine(answer);\n _writer.Dispose();\n }\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "constructive algorithms", "implementation"], "code_uid": "e3152431743056846447eb479b50b5ea", "src_uid": "d0f5174bb0bcca5a486db327b492bf33", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\n\nnamespace Task2\n{\n class Program\n {\n static void Main(string[] args)\n {\n //\u0432\u0432\u043e\u0434\u0438\u043c n k \u0438 d\n int t = Convert.ToInt32(Console.ReadLine());\n for (int u = 0; u < t; u++)\n {\n string input = Console.ReadLine();\n string[] inputArr = input.Split();\n\n int n = Convert.ToInt32(inputArr[0]);\n int k = Convert.ToInt32(inputArr[1]);\n int d = Convert.ToInt32(inputArr[2]);\n\n\n int[] days = new int[n];\n\n //\u0437\u0430\u043f\u043e\u043b\u043d\u044f\u0435\u043c \u043c\u0430\u0441\u0441\u0438\u0432 \u0434\u043d\u0435\u0439 \u043f\u043e\u043a\u0430\u0437\u0430\n string inputDays = Console.ReadLine();\n string[] inputArrDays = inputDays.Split();\n for (int i = 0; i < days.Length; i++)\n {\n days[i] = Convert.ToInt32(inputArrDays[i]);\n }\n\n //\u043c\u0430\u0441\u0441\u0438\u0432 \"\u0440\u0430\u0437\u043d\u044b\u0445\" \u0441\u0435\u0440\u0438\u0430\u043b\u043e\u0432\n int[] differentSerials = new int[k];\n for (int i = 0; i < differentSerials.Length; i++)\n {\n differentSerials[i] = 0;\n }\n\n //\u043c\u0430\u0441\u0441\u0438\u0432 \u0434\u043b\u044f \"\u0431\u043b\u043e\u043a\u043e\u0432\" \u0434\u043d\u0435\u0439\n int[] arrForDaysBlock = new int[n - d + 1];\n for (int x = 0; x < arrForDaysBlock.Length; x++)\n {\n //\u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c, \u0447\u0442\u043e \u0432 i \u0434\u0435\u043d\u044c \u0438\u0434\u0435\u0442 j \u0441\u0435\u0440\u0438\u0430\u043b\n //\u0435\u0441\u043b\u0438 \u0434\u0430, \u0442\u043e \u0432 \u043c\u0430\u0441\u0441\u0438\u0432 \u0441\u0435\u0440\u0438\u0430\u043b\u043e\u0432 \u0441\u0443\u0435\u043c ++\n for (int i = x; i < x + d; i++)\n {\n for (int j = 1; j < differentSerials.Length + 1; j++)\n {\n if (days[i] == j)\n {\n differentSerials[j - 1]++;\n }\n }\n }\n //\u043f\u043e\u0434\u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u043c \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0420\u0410\u0417\u041b\u0418\u0427\u041d\u042b\u0425 \u0441\u0435\u0440\u0438\u0430\u043b\u043e\u0432 \u043f\u0440\u043e\u0448\u043b\u043e \u0432 d \u0434\u043d\u0435\u0439\n //\u0438 \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c \u044d\u0442\u043e \u0432 \u043c\u0430\u0441\u0441\u0438\u0432 \u0431\u043b\u043e\u043a\u043e\u0432 \u0434\u043d\u0435\u0439\n int summ = 0;\n for (int i = 0; i < differentSerials.Length; i++)\n {\n if (differentSerials[i] != 0)\n {\n summ++;\n }\n }\n arrForDaysBlock[x] = summ;\n for (int i = 0; i < differentSerials.Length; i++)\n {\n differentSerials[i] = 0;\n }\n }\n\n int min = arrForDaysBlock[0];\n for (int i = 0; i < arrForDaysBlock.Length; i++)\n {\n if (arrForDaysBlock[i] < min)\n {\n min = arrForDaysBlock[i];\n }\n }\n\n\n Console.WriteLine(min);\n }\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "e5cbeefcfa0d37d682e0d20bb08c4c8f", "src_uid": "56da4ec7cd849c4330d188d8c9bd6094", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections;\nusing System.Collections.Generic;\nusing System.Text;\nusing System.Linq;\nusing static MyIO;\n\n\npublic class B\n{\n\tpublic static void Main() => (new Solver()).Solve();\n}\n\n\npublic class Solver\n{\n\tpublic void Solve()\n\t{\n\t\tint T = GetInt();\n\t\t\n\t\tint[] ans = new int[T];\n\t\tfor(int i = 0; i < T; i++)\n\t\t\tans[i] = calc();\n\n\t\tConsole.WriteLine(string.Join(\"\\n\", ans.Select(x => x.ToString()).ToArray()));\n\t}\n\n\tprivate int calc()\n\t{\n\t\tint N = GetInt();\n\t\tint K = GetInt();\n\t\tint D = GetInt();\n\t\tint[] a = GetInts(N);\n\n\t\tint res = D;\n\t\tint[] cnt = new int[1000001];\n\t\tint sum = 0;\n\t\tfor(int i = 0; i < D; i++)\n\t\t{\n\t\t\tif(cnt[a[i]] == 0)\n\t\t\t\tsum++;\n\n\t\t\tcnt[a[i]]++;\n\t\t}\n\t\tchmin(ref res, sum);\n\n\t\tfor(int i = D; i < N; i++)\n\t\t{\n\t\t\tif(cnt[a[i]] == 0)\n\t\t\t\tsum++;\n\n\t\t\tcnt[a[i]]++;\n\n\t\t\tif(cnt[a[i - D]] == 1)\n\t\t\t\tsum--;\n\n\t\t\tcnt[a[i - D]]--;\n\n\t\t\tchmin(ref res, sum);\n\t\t}\n\n\t\treturn res;\n\t}\n\n\tprivate int chmin(ref int x, int y) => x = Math.Min(x, y);\n}\n\n\npublic static class MyIO\n{\n\tprivate static string[] args = null;\n\tprivate static int num = -1;\n\tprivate static int used = -1;\n\n\tprivate static string getArg()\n\t{\n\t\tif(used == num)\n\t\t{\n\t\t\targs = Console.ReadLine().Split(' ');\n\t\t\tnum = args.Length;\n\t\t\tused = 0;\n\t\t}\n\t\treturn args[used++];\n\t}\n\n\tpublic static int GetInt() => int.Parse(getArg());\n\tpublic static long GetLong() => long.Parse(getArg());\n\tpublic static double GetDouble() => double.Parse(getArg());\n\tpublic static string GetString() => getArg();\n\tpublic static char GetChar() => getArg()[0];\n\tpublic static int[] GetInts(int N) => Enumerable.Range(0, N).Select(_ => GetInt()).ToArray();\n\tpublic static long[] GetLongs(int N) => Enumerable.Range(0, N).Select(_ => GetLong()).ToArray();\n\tpublic static double[] GetDoubles(int N) => Enumerable.Range(0, N).Select(_ => GetDouble()).ToArray();\n\tpublic static string[] GetStrings(int N) => Enumerable.Range(0, N).Select(_ => GetString()).ToArray();\n}", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "5b73238758ad1199f11d17d74da26e77", "src_uid": "56da4ec7cd849c4330d188d8c9bd6094", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Linq;\nusing System.IO;\nusing System.Collections.Generic;\n// Powered by caide (code generator, tester, and library code inliner)\n\nclass Solution {\n\n int n, h;\n long[,] t;\n public void solve(TextReader input, TextWriter output) {\n var inp = input.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();\n n = inp[0];\n h = inp[1];\n\n t = new long[n+1, n+1];\n t[0, 0] = 1;\n\n for (int ni = 1; ni <= n; ni++)\n {\n for (int hi = 1; hi <= n; hi++)\n {\n long sum0 = 0;\n for (int m = 1; m <= ni; m++)\n {\n long sum1 = 0;\n for (int i = 0; i <= hi-1; i++)\n {\n sum1 += t[ni - m, i];\n }\n\n long sum2 = 0;\n for (int i = 0; i <= hi-2; i++)\n {\n sum2 += t[m - 1, i];\n }\n\n sum0 += t[m - 1, hi - 1] * sum1 + t[ni - m, hi - 1] * sum2;\n }\n\n t[ni, hi] = sum0;\n }\n }\n\n long ans = 0;\n for (int i = h; i <= n; i++)\n {\n ans += t[n, i];\n }\n\n output.WriteLine(ans);\n }\n}\n\nclass CaideConstants {\n public const string InputFile = null;\n public const string OutputFile = null;\n}\npublic class Program {\n public static void Main(string[] args) {\n Solution solution = new Solution();\n using (System.IO.TextReader input =\n CaideConstants.InputFile == null ? System.Console.In :\n new System.IO.StreamReader(CaideConstants.InputFile))\n using (System.IO.TextWriter output =\n CaideConstants.OutputFile == null ? System.Console.Out:\n new System.IO.StreamWriter(CaideConstants.OutputFile))\n\n solution.solve(input, output);\n }\n}\n\n", "lang_cluster": "C#", "tags": ["divide and conquer", "dp", "combinatorics"], "code_uid": "58863dd0fca330d306c2a7e38734c90b", "src_uid": "faf12a603d0c27f8be6bf6b02531a931", "difficulty": 1900.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\n\nnamespace CodeForces\n{\n static class Reader\n {\n public static int NextInt()\n {\n int ret = 0;\n char c;\n\n while (!char.IsDigit(c = (char)Console.Read()))\n {\n if (c == '-')\n return -NextInt();\n }\n do\n {\n ret = ret * 10 + c - '0';\n } while (char.IsDigit(c = (char)Console.Read()));\n\n return ret;\n }\n\n public static double NextDouble()\n {\n double ret = 0;\n char c;\n\n while (!char.IsDigit(c = (char)Console.Read())) \n {\n if (c == '-')\n return -NextDouble();\n }\n do\n {\n ret = ret * 10 + c - '0';\n } while (char.IsDigit(c = (char)Console.Read()));\n if (c != '.') return ret;\n\n double p10 = 0.1;\n while (char.IsDigit(c = (char)Console.Read()))\n {\n ret += p10 * (c - '0');\n }\n\n return ret;\n }\n }\n\n class Program\n {\n static long[,] memo;\n static bool[,] done;\n\n static long Rec(int n, int h)\n {\n if (n <= 1 && n == h)\n return 1;\n if (n < h)\n return 0;\n if (done[n, h])\n return memo[n, h];\n\n long ret = 0;\n for (int i = 1; i <= n; ++i)\n {\n int l = i - 1, r = n - i;\n for (int lh = 0; lh < h - 1; ++lh)\n ret += Rec(l, lh) * Rec(r, h - 1);\n for (int rh = 0; rh <= h - 1; ++rh)\n ret += Rec(l, h - 1) * Rec(r, rh);\n }\n done[n, h] = true;\n return memo[n, h] = ret;\n }\n\n static void Main(string[] args)\n {\n int n = Reader.NextInt(), h = Reader.NextInt();\n\n memo = new long[36, 36];\n done = new bool[36, 36];\n\n long sol = 0;\n for (int i = h; i <= n; ++i)\n sol += Rec(n, i);\n Console.WriteLine(sol);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["divide and conquer", "dp", "combinatorics"], "code_uid": "e2355e1f4193e5a333b3f599da04b093", "src_uid": "faf12a603d0c27f8be6bf6b02531a931", "difficulty": 1900.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\n\npublic class Demo {\n public static void Main() {\n // feel free to modify\n string[] tokens = Console.ReadLine().Split();\n int n = int.Parse(tokens[0]);\n int h = int.Parse(tokens[1]);\n // Console.WriteLine(NumTrees(n)-NumTreesUptoHeight(n, h));\n Console.WriteLine(NumTrees(n)-NumTreesUptoHeight(n, h-1));\n }\n \n private static long NumTrees(int n) {\n long[] numWays = new long[n+1];\n // initialization; note on 0 nodes: above\n numWays[0] = 1;\n \n for (int target=1; target<=n; target++)\n for (int i=1; i<=target; i++)\n numWays[target] += numWays[i-1] * numWays[target-i];\n return numWays[n];\n }\n\n // minHN is minimum height in number of nodes from root to leaf\n private static long NumTreesUptoHeight(int n, int minHN) {\n long[][] numWays = new long[minHN+1][];\n for (int i = 0; i <= minHN; i++)\n numWays[i] = new long[n+1]; // to make the indexing mapped exactly to height, 0 is unused\n numWays[0][0] = 1;\n for (int i = 1; i <= n; i++)\n numWays[0][i] = 0;\n\n //for (int h = 1; h <= minHN; h++)\n // numWays[h][0] = 1;\n for (int h = 1; h <= minHN; h++) {\n numWays[h][0] = 1;\n for (int target = 1; target <= n; target++)\n {\n for (int i = 1; i <= target; i++)\n numWays[h][target] += numWays[h - 1][i - 1] * numWays[h - 1][target - i];\n // Console.WriteLine(\"{0}, {1}: {2}\", h, target, numWays[h][target]);\n }\n\n }\n return numWays[minHN][n];\n }\n}\n", "lang_cluster": "C#", "tags": ["divide and conquer", "dp", "combinatorics"], "code_uid": "c2c65aef9e09643b3f4c976606ee8ce3", "src_uid": "faf12a603d0c27f8be6bf6b02531a931", "difficulty": 1900.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Globalization;\nusing System.IO;\nusing System.Linq;\nusing System.Text;\nusing System.Threading;\n\n// (\u3065\u00b0\u03c9\u00b0)\u3065\uff90e\u2605\u309c\u30fb\u3002\u3002\u30fb\u309c\u309c\u30fb\u3002\u3002\u30fb\u309c\u2606\u309c\u30fb\u3002\u3002\u30fb\u309c\u309c\u30fb\u3002\u3002\u30fb\u309c\npublic class Solver\n{\n long?[,] mem1 = new long?[36, 36];\n long Fun1(int n, int h)\n {\n if (mem1[n, h].HasValue)\n return mem1[n, h].Value;\n long ret = 0;\n if (h == 0)\n {\n if (n == 0)\n return 1;\n for (int i = 0; i < n; i++)\n ret += Fun1(i, 0) * Fun1(n - i - 1, 0);\n return (mem1[n, h] = ret).Value;\n }\n\n if (n < h)\n return 0;\n\n for (int i = 0; i < n; i++)\n ret += Fun1(i, h - 1) * Fun1(n - i - 1, h - 1) + Fun1(i, h - 1) * Fun2(n - i - 1, h - 1) + Fun2(i, h - 1) * Fun1(n - i - 1, h - 1);\n return (mem1[n, h] = ret).Value;\n }\n\n long?[,] mem2 = new long?[36, 36];\n long Fun2(int n, int h)\n {\n if (h < 0)\n return 0;\n if (h == 0)\n return 0;\n if (h == 1)\n return n > 0 ? 0 : 1;\n if (n == 0)\n return 1;\n if (mem2[n, h].HasValue)\n return mem2[n, h].Value;\n long ret = 0;\n for (int i = 0; i < n; i++)\n ret += Fun2(i, h - 1) * Fun2(n - i - 1, h - 1);\n return (mem2[n, h] = ret).Value;\n }\n\n public void Solve()\n {\n int n = ReadInt();\n int h = ReadInt();\n\n Write(Fun1(n, h));\n }\n\n #region Main\n\n protected static TextReader reader;\n protected static TextWriter writer;\n static void Main()\n {\n#if DEBUG\n reader = new StreamReader(\"..\\\\..\\\\input.txt\");\n //reader = new StreamReader(Console.OpenStandardInput());\n writer = Console.Out;\n //writer = new StreamWriter(\"..\\\\..\\\\output.txt\");\n#else\n reader = new StreamReader(Console.OpenStandardInput());\n writer = new StreamWriter(Console.OpenStandardOutput());\n //reader = new StreamReader(\"input.txt\");\n //writer = new StreamWriter(\"output.txt\");\n#endif\n try\n {\n //var thread = new Thread(new Solver().Solve, 1024 * 1024 * 128);\n //thread.Start();\n //thread.Join();\n new Solver().Solve();\n }\n catch (Exception ex)\n {\n Console.WriteLine(ex);\n#if DEBUG\n#else\n throw;\n#endif\n }\n reader.Close();\n writer.Close();\n }\n\n #endregion\n\n #region Read / Write\n private static Queue currentLineTokens = new Queue();\n private static string[] ReadAndSplitLine() { return reader.ReadLine().Split(new[] { ' ', '\\t', }, StringSplitOptions.RemoveEmptyEntries); }\n public static string ReadToken() { while (currentLineTokens.Count == 0)currentLineTokens = new Queue(ReadAndSplitLine()); return currentLineTokens.Dequeue(); }\n public static int ReadInt() { return int.Parse(ReadToken()); }\n public static long ReadLong() { return long.Parse(ReadToken()); }\n public static double ReadDouble() { return double.Parse(ReadToken(), CultureInfo.InvariantCulture); }\n public static int[] ReadIntArray() { return ReadAndSplitLine().Select(int.Parse).ToArray(); }\n public static long[] ReadLongArray() { return ReadAndSplitLine().Select(long.Parse).ToArray(); }\n public static double[] ReadDoubleArray() { return ReadAndSplitLine().Select(s => double.Parse(s, CultureInfo.InvariantCulture)).ToArray(); }\n public static int[][] ReadIntMatrix(int numberOfRows) { int[][] matrix = new int[numberOfRows][]; for (int i = 0; i < numberOfRows; i++)matrix[i] = ReadIntArray(); return matrix; }\n public static int[][] ReadAndTransposeIntMatrix(int numberOfRows)\n {\n int[][] matrix = ReadIntMatrix(numberOfRows); int[][] ret = new int[matrix[0].Length][];\n for (int i = 0; i < ret.Length; i++) { ret[i] = new int[numberOfRows]; for (int j = 0; j < numberOfRows; j++)ret[i][j] = matrix[j][i]; } return ret;\n }\n public static string[] ReadLines(int quantity) { string[] lines = new string[quantity]; for (int i = 0; i < quantity; i++)lines[i] = reader.ReadLine().Trim(); return lines; }\n public static void WriteArray(IEnumerable array) { writer.WriteLine(string.Join(\" \", array)); }\n public static void Write(params object[] array) { WriteArray(array); }\n public static void WriteLines(IEnumerable array) { foreach (var a in array)writer.WriteLine(a); }\n private class SDictionary : Dictionary\n {\n public new TValue this[TKey key]\n {\n get { return ContainsKey(key) ? base[key] : default(TValue); }\n set { base[key] = value; }\n }\n }\n private static T[] Init(int size) where T : new() { var ret = new T[size]; for (int i = 0; i < size; i++)ret[i] = new T(); return ret; }\n #endregion\n}", "lang_cluster": "C#", "tags": ["divide and conquer", "dp", "combinatorics"], "code_uid": "c0c0b8d79c08064284b2a50905c31eab", "src_uid": "faf12a603d0c27f8be6bf6b02531a931", "difficulty": 1900.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Text;\n\nnamespace A.Theatre_Square\n{\n class Program\n {\n static int sq2(int k)\n {\n return (1 << k) - 1;\n }\n\n static void Main(string[] args)\n {\n string[] data = Console.ReadLine().Trim().Split(' ');\n int n = Int32.Parse(data[0]);\n int h = Int32.Parse(data[1]);\n Int64[,] f=new Int64[36,36];\n f[0, 0] = 1;\n f[1, 1] = 1;\n for (int i = 2; i <= n; i++)\n {\n for (int j = i; j <= n; j++)\n {\n for (int k = 0; k <= j - 1; k++)\n {\n for (int l = (int)Math.Ceiling(Math.Log(k + 1, 2)); l <= k; l++)\n {\n for (int r = (int)Math.Ceiling(Math.Log(j - k, 2)); r <= j - k - 1; r++)\n {\n if((l==i-1 || r==i-1)&&(l= h)\n {\n ret += num;\n }\n }\n Console.WriteLine(ret);\n }\n\n private long go(int n, int h)\n {\n if (dp[n, h] != -1)\n return dp[n, h];\n if (n == 0)\n {\n if (h == 0)\n return dp[n, h] = 1;\n else\n return dp[n, h] = 0;\n }\n if(h==0)\n {\n return dp[n,h]=0;\n }\n long ret = 0;\n for (int i = 1; i <= n; i++)\n {\n int Left = i - 1;\n int right = n - i;\n for (int k = 0; k < h - 1; k++)\n {\n ret += go(Left, k) * go(right, h - 1);\n }\n for (int k = 0; k < h - 1; k++)\n {\n ret += go(right, k) * go(Left, h - 1);\n }\n ret += go(Left, h - 1) * go(right, h - 1);\n }\n return dp[n, h] = ret;\n }\n\n\n\n static void Main(string[] args)\n {\n new Program().solve();\n }\n}\n\n \n", "lang_cluster": "C#", "tags": ["divide and conquer", "dp", "combinatorics"], "code_uid": "3d26b61c608b26f74f1817dc778b6f71", "src_uid": "faf12a603d0c27f8be6bf6b02531a931", "difficulty": 1900.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace ConsoleApplication14\n{\n class Program\n {\n static void Main(string[] args)\n {\n int sum , i;\n string numbers = Console.ReadLine();\n string[] num = numbers.Split(' ');\n int a = int.Parse(num[0]);\n int b = int.Parse(num[1]);\n int s = int.Parse(num[2]);\n if (Math.Pow(-10, 9) <= a && a <= Math.Pow(10, 9) && Math.Pow(-10, 9) <= b && b <= Math.Pow(10, 9) && 1 <= s && s <= Math.Pow(2 * 10, 9))\n {\n sum = Math.Abs(a) + Math.Abs(b);\n i = (s - sum) % 2; \n if ( i == 0 && s >= sum )\n {\n Console.WriteLine(\"YES\");\n }\n else\n {\n Console.WriteLine(\"NO\");\n }\n\n }\n }\n }\n }\n\n", "lang_cluster": "C#", "tags": ["math"], "code_uid": "0ae9c18dd7b169fb47187a4fe832cf80", "src_uid": "9a955ce0775018ff4e5825700c13ed36", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace Pr1\n{\n class Program\n {\n static void Main()\n {\n var a= Array.ConvertAll(Console.ReadLine().Split(' '), Convert.ToInt32);\n a[0]=Math.Abs(a[0]);\n a[1]=Math.Abs(a[1]);\n if(a[2]%2==(a[0]+a[1])%2&&a[2]>=(a[0]+a[1]))\n Console.Write(\"Yes\");\n else\n Console.Write(\"No\");\n \n \n\n \n }\n }\n}", "lang_cluster": "C#", "tags": ["math"], "code_uid": "f403f24591d71f39ffeb0ba6b49ff85b", "src_uid": "9a955ce0775018ff4e5825700c13ed36", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace _841A\n{\n class Program\n {\n static void Main(string[] args)\n {\n var arr = Console.ReadLine().Split().Select(int.Parse).ToArray();\n int n = arr[0];\n int k = arr[1];\n string a = Console.ReadLine();\n int lenght = a.Length;\n int[] count = new int[n];\n for(int i=0; i int.Parse(s)).ToArray();\n string c = Console.ReadLine();\n Dictionary colors = new Dictionary();\n foreach(var ch in c)\n {\n if (!colors.ContainsKey(ch))\n colors.Add(ch, 1);\n else\n colors[ch]++;\n }\n\n bool yes = true;\n foreach(var d in colors)\n {\n if (d.Value > nk[1])\n yes = false;\n }\n\n Console.WriteLine(yes ? \"YES\" : \"NO\");\n }\n }\n}\n\n", "lang_cluster": "C#", "tags": ["brute force", "implementation"], "code_uid": "5ef3073188a55036dc27c4fd769324a7", "src_uid": "ceb3807aaffef60bcdbcc9a17a1391be", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Globalization;\nusing System.IO;\nusing System.Linq;\nusing System.Text;\n\n// (\u3065*\u03c9*)\u3065\uff90\u2605\u309c\u30fb\u3002\u3002\u30fb\u309c\u309c\u30fb\u3002\u3002\u30fb\u309c\u2606\u309c\u30fb\u3002\u3002\u30fb\u309c\u309c\u30fb\u3002\u3002\u30fb\u309c\npublic class Solver\n{\n public object Solve()\n {\n long n = ReadInt();\n long m = ReadInt();\n long k = ReadLong();\n\n long l = 1;\n long r = n * m;\n while (true)\n {\n long mid = (l + r) / 2;\n long gleft = 0;\n long gright = 0;\n long closestLeft = 0;\n long closestRight = long.MaxValue;\n for (long i = 1; i <= m; i++)\n {\n if (mid > i * n)\n {\n gleft += n;\n closestLeft = Math.Max(closestLeft, i * n);\n continue;\n }\n if (mid < i)\n {\n gright += n;\n closestRight = Math.Min(closestRight, i);\n continue;\n }\n if (mid % i == 0)\n {\n closestLeft = closestRight = mid;\n gleft += mid / i - 1;\n gright += n - mid / i;\n }\n else\n {\n closestLeft = Math.Max(closestLeft, mid / i * i);\n closestRight = Math.Min(closestRight, (mid / i + 1) * i);\n gleft += mid / i;\n gright += n - mid / i;\n }\n }\n if (gleft + gright == n * m)\n {\n if (gleft + 1 == k)\n return closestRight;\n if (gleft + 1 < k)\n l = closestRight;\n else\n r = closestLeft;\n }\n else\n {\n if (k > gleft && k + gright <= n * m)\n return closestLeft;\n if (k <= gleft)\n r = closestLeft - 1;\n else\n l = closestRight + 1;\n }\n }\n\n return null;\n }\n\n #region Main\n\n protected static TextReader reader;\n protected static TextWriter writer;\n\n static void Main()\n {\n#if DEBUG\n reader = new StreamReader(\"..\\\\..\\\\input.txt\");\n writer = Console.Out;\n //writer = new StreamWriter(\"..\\\\..\\\\output.txt\");\n#else\n reader = Console.In;\n writer = new StreamWriter(Console.OpenStandardOutput());\n#endif\n try\n {\n var ts = DateTime.Now;\n object result = new Solver().Solve();\n if (result != null)\n writer.WriteLine(result);\n }\n catch (Exception ex)\n {\n#if DEBUG\n Console.WriteLine(ex);\n#else\n throw;\n#endif\n }\n reader.Close();\n writer.Close();\n }\n\n #endregion\n\n #region Read/Write\n\n private static Queue currentLineTokens = new Queue();\n\n private static string[] ReadAndSplitLine()\n {\n return reader.ReadLine().Split(new[] { ' ', '\\t' }, StringSplitOptions.RemoveEmptyEntries);\n }\n\n public static string ReadToken()\n {\n while (currentLineTokens.Count == 0)\n currentLineTokens = new Queue(ReadAndSplitLine());\n return currentLineTokens.Dequeue();\n }\n\n public static int ReadInt()\n {\n return int.Parse(ReadToken());\n }\n\n public static long ReadLong()\n {\n return long.Parse(ReadToken());\n }\n\n public static double ReadDouble()\n {\n return double.Parse(ReadToken(), CultureInfo.InvariantCulture);\n }\n\n public static int[] ReadIntArray()\n {\n return ReadAndSplitLine().Select(int.Parse).ToArray();\n }\n\n public static long[] ReadLongArray()\n {\n return ReadAndSplitLine().Select(long.Parse).ToArray();\n }\n\n public static double[] ReadDoubleArray()\n {\n return ReadAndSplitLine().Select(s => double.Parse(s, CultureInfo.InvariantCulture)).ToArray();\n }\n\n public static int[][] ReadIntMatrix(int numberOfRows)\n {\n int[][] matrix = new int[numberOfRows][];\n for (int i = 0; i < numberOfRows; i++)\n matrix[i] = ReadIntArray();\n return matrix;\n }\n\n public static int[][] ReadAndTransposeIntMatrix(int numberOfRows)\n {\n int[][] matrix = ReadIntMatrix(numberOfRows);\n int[][] ret = new int[matrix[0].Length][];\n for (int i = 0; i < ret.Length; i++)\n {\n ret[i] = new int[numberOfRows];\n for (int j = 0; j < numberOfRows; j++)\n ret[i][j] = matrix[j][i];\n }\n return ret;\n }\n\n public static string[] ReadLines(int quantity)\n {\n string[] lines = new string[quantity];\n for (int i = 0; i < quantity; i++)\n lines[i] = reader.ReadLine().Trim();\n return lines;\n }\n\n public static void WriteArray(IEnumerable array)\n {\n writer.WriteLine(string.Join(\" \", array));\n }\n\n #endregion\n}", "lang_cluster": "C#", "tags": ["brute force", "binary search"], "code_uid": "4b79b2619124014a13112acefccdddfa", "src_uid": "13a918eca30799b240ceb9de47507a26", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\n\nnamespace Codeforces.R256\n{\n public class Task_D\n {\n static void Main(string[] args)\n {\n new Task_D().Solve();\n }\n\n private long n;\n private long m;\n private long k;\n\n private void Solve()\n {\n var parts = Console.ReadLine().Split();\n n = long.Parse(parts[0]);\n m = long.Parse(parts[1]);\n k = long.Parse(parts[2]);\n\n long left = 1;\n long right = n * m;\n while (left < right)\n {\n var x = (left + right + 1) / 2;\n var before = GetLessThenCount(x);\n if (before < k)\n {\n left = x;\n }\n else\n {\n right = x - 1;\n }\n }\n Console.WriteLine(left);\n }\n\n private long GetLessThenCount(long num)\n {\n long sum = 0;\n for (int i = 1; i <= n; i++)\n {\n long w = Math.Min(m, (num - 1) / i);\n sum += w;\n if (w == 0)\n break;\n }\n return sum;\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "binary search"], "code_uid": "e751bb6af658d40388e39fe4ec57a335", "src_uid": "13a918eca30799b240ceb9de47507a26", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace Main\n{\n class Program\n {\n static void Main(string[] args)\n {\n string keyboard = \"qwertyuiopasdfghjkl;zxcvbnm,./\";\n\n string[] str = Console.ReadLine().Split();\n char dir = Convert.ToChar(str[0].ToLower());\n string msg = Console.ReadLine();\n if (dir == 'r')\n {\n foreach (char ch in msg)\n {\n int index = keyboard.IndexOf(ch);\n if (index == 0 || index == 10 || index == 20)\n Console.Write(keyboard[index]);\n else\n Console.Write(keyboard[index - 1]);\n }\n }\n else\n {\n foreach (char ch in msg)\n {\n int index = keyboard.IndexOf(ch);\n if (index == 9 || index == 19 || index == 29)\n Console.Write(keyboard[index]);\n else\n Console.Write(keyboard[index + 1]);\n }\n }\n Console.Read();\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "eca511f50da2ef0d339d59f021cc0e0d", "src_uid": "df49c0c257903516767fdb8ac9c2bfd6", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.ComponentModel.Design;\nusing System.Linq;\nusing System.Text;\n\nnamespace Codeforces\n{\n\tclass Program\n\t{\n\t\tstatic void Main(string[] args) \n\t\t{\n\t\t\tstring input1 = Console.ReadLine();\n\t\t\tstring input2 = Console.ReadLine();\n\n\t\t\t//string input3 = Console.ReadLine();\n\t\t\t//string input4 = Console.ReadLine();\n\n\t\t\t//var inputs1 = input1.Split(new[] { ' ', '}', '{' , ',' }, StringSplitOptions.RemoveEmptyEntries).Select(int.Parse).ToArray();\n\t\t\t//var inputs2 = input2.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(long.Parse).ToArray();\n\n\t\t\tstring row1 = \"qwertyuiop\";\n\t\t\tstring row2 = \"asdfghjkl;\";\n\t\t\tstring row3 = \"zxcvbnm,./\";\n\n\t\t\tvar builder = new StringBuilder();\n\t\t\tfor (int i = 0; i < input2.Length; i++) \n\t\t\t{\n\t\t\t\tvar symbol = input2.Substring(i, 1);\n\n\t\t\t\tint index;\n\t\t\t\tif (row1.IndexOf(symbol) >= 0) \n\t\t\t\t{\n\t\t\t\t\tindex = row1.IndexOf(symbol);\n\t\t\t\t\tif (input1 == \"R\")\n\t\t\t\t\t{\n\t\t\t\t\t\tindex--;\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\tindex++;\n\t\t\t\t\t}\n\n\t\t\t\t\tbuilder.Append(row1.ElementAt(index));\n\t\t\t\t} \n\t\t\t\telse if (row2.IndexOf(symbol) >= 0) \n\t\t\t\t{\n\t\t\t\t\tindex = row2.IndexOf(symbol);\n\t\t\t\t\tif (input1 == \"R\")\n\t\t\t\t\t{\n\t\t\t\t\t\tindex--;\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\tindex++;\n\t\t\t\t\t}\n\n\t\t\t\t\tbuilder.Append(row2.ElementAt(index));\n\t\t\t\t} \n\t\t\t\telse \n\t\t\t\t{\n\t\t\t\t\tindex = row3.IndexOf(symbol);\n\t\t\t\t\tif (input1 == \"R\")\n\t\t\t\t\t{\n\t\t\t\t\t\tindex--;\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\tindex++;\n\t\t\t\t\t}\n\n\t\t\t\t\tbuilder.Append(row3.ElementAt(index));\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tConsole.WriteLine(builder.ToString());\n\t\t}\n\n\t\tstatic long Factorial(long a) \n\t\t{\n\t\t\treturn a > 1 ? a * Factorial(a - 1) : 1;\n\t\t}\n\t}\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "d588272fc78d8d84f7820333861a97fb", "src_uid": "df49c0c257903516767fdb8ac9c2bfd6", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "// Problem: 202A - LLPS\n// Author: Gusztav Szmolik\n\nusing System;\n\nclass LLPS\n\t{\n\tstatic int Main ()\n\t\t{\n\t\tstring line = Console.ReadLine ();\n\t\tif (line == null)\n\t\t\treturn -1;\n\t\tchar[] delims = {' ', '\\t'};\n\t\tstring[] words = line.Split (delims,StringSplitOptions.RemoveEmptyEntries);\n\t\tif (words.Length != 1)\n\t\t\treturn -1;\n\t\tstring s = words[0];\n\t\tbyte sLength = Convert.ToByte (s.Length);\n\t\tif (sLength > 10)\n\t\t\treturn -1;\n\t\tbyte[] countChars = new byte[26];\n\t\tArray.Clear (countChars,0,26);\n\t\tchar maxChar = 'a';\n\t\tfor (byte i = 0; i < sLength; i++)\n\t\t\t{\n\t\t\tchar c = s[i];\n\t\t\tif (!Char.IsLower (c))\n\t\t\t\treturn -1;\n\t\t\tcountChars[c-'a']++;\n\t\t\tif (c > maxChar)\n\t\t\t\tmaxChar = c;\n\t\t\t}\n\t\tstring ans = new String (maxChar,countChars[maxChar-'a']);\n\t\tConsole.WriteLine (ans);\n\t\treturn 0;\n\t\t}\n\t}\n", "lang_cluster": "C#", "tags": ["brute force", "binary search", "bitmasks", "greedy", "strings", "implementation"], "code_uid": "4d2e2074b706ec640370625c73819ed3", "src_uid": "9a40e9b122962a1f83b74ddee6246a40", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\n//using System.Threading.Tasks;\n\nnamespace Codeforces127\n{\n\tclass Program\n\t{\n\t\tstatic void A()\n\t\t{\n\t\t\tint[] chars = new int[255];\n\t\t\tstring s = Console.ReadLine();\n\t\t\tfor (int i = 0; i < s.Length; i++)\n\t\t\t{\n\t\t\t\tchars[(int)s[i]]++;\n\t\t\t}\n\n\t\t\tstring result = \"\";\n\t\t\tfor (int c = 254; c >= 0; c--)\n\t\t\t{\n\t\t\t\tbool found = false;\n\t\t\t\twhile (chars[c] > 1)\n\t\t\t\t{\n\t\t\t\t\tchars[c] -= 2;\n\t\t\t\t\tresult = result + (char)c + (char)c;\n\t\t\t\t\tfound = true;\n\t\t\t\t}\n\t\t\t\tif (chars[c] == 1)\n\t\t\t\t{\n\t\t\t\t\tfound = true;\n\t\t\t\t\tresult += (char)c;\n\t\t\t\t}\n\t\t\t\tif (found) \n\t\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\t//res\n\n\t\t\t\n\t\t\tConsole.WriteLine(result);\n\t\t}\n\t\tstatic void Main(string[] args)\n\t\t{\n\t\t\tA();\n\t\t}\n\t}\n}\n", "lang_cluster": "C#", "tags": ["brute force", "binary search", "bitmasks", "greedy", "strings", "implementation"], "code_uid": "0df57867db203ae52f848124528088b5", "src_uid": "9a40e9b122962a1f83b74ddee6246a40", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace TaskOne\n{\n class Program\n {\n static void Main(string[] args)\n {\n double n = Convert.ToDouble(Console.ReadLine());\n if (n > 5)\n {\n double s = n - 3;\n\n double nepol = n - 3;\n\n double count = (s - 1) * nepol;\n count = count + s * 2;\n count = count + s + 1;\n Console.Write(count);\n }\n else\n if (n == 3) Console.Write(\"1\");\n else\n if (n == 4) Console.Write(\"4\");\n else\n if (n == 5) Console.Write(\"9\");\n Console.ReadLine();\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math"], "code_uid": "22d4048813ddd9a2f4f7fd73239e6782", "src_uid": "efa8e7901a3084d34cfb1a6b18067f2b", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\nusing System.IO;\n\nnamespace _305\n{\n class Program\n {\n static void Main(string[] args)\n {\n \n //Console.BufferWidth = 1001;\n UInt64 x= Convert.ToUInt64(Console.ReadLine());\n \n Console.WriteLine((x-2)*(x-2));\n }\n }\n}", "lang_cluster": "C#", "tags": ["math"], "code_uid": "012abebc2f10ffcfb68801a9b9f07407", "src_uid": "efa8e7901a3084d34cfb1a6b18067f2b", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\n\nnamespace codeforces\n{\n\tclass Program\n\t{\n\t\tpublic class User\n\t\t{\n\t\t\tpublic int c;\n\n\t\t\tpublic int r;\n\t\t}\n\n\t\tpublic class Point\n\t\t{\n\t\t\tpublic int x;\n\n\t\t\tpublic double p;\n\t\t}\n\n\t\tpublic class Comparer : IComparer\n\t\t{\n\t\t\tpublic int Compare(User x, User y)\n\t\t\t{\n\t\t\t\tif (x.c < y.c || (x.c == y.c && x.r < y.r))\n\t\t\t\t\treturn -1;\n\t\t\t\treturn 1;\n\t\t\t}\n\t\t}\n\n\t\tpublic static long getGcd(long a, long b)\n\t\t{\n\t\t\tif (b == 0)\n\t\t\t\treturn a;\n\t\t\treturn getGcd(b, a % b);\n\t\t}\n\n\t\tpublic static void WriteYESNO(bool x, string yes = \"YES\", string no = \"NO\")\n\t\t{\n\t\t\tif (x)\n\t\t\t\tConsole.WriteLine(yes);\n\t\t\telse\n\t\t\t{\n\t\t\t\tConsole.WriteLine(no);\n\t\t\t}\n\t\t}\n\n\t\tpublic static string GetString()\n\t\t{\n\t\t\treturn Console.ReadLine();\n\t\t}\n\n\t\tpublic static List getList()\n\t\t{\n\t\t\tvar s = Console.ReadLine();\n\t\t\treturn s.Split(' ').Select(int.Parse).ToList();\n\t\t}\n\n\t\tpublic static int Min(int x, int y)\n\t\t{\n\t\t\treturn Math.Min(x, y);\n\t\t}\n\n\t\tpublic static int Max(int x, int y)\n\t\t{\n\t\t\treturn Math.Max(x, y);\n\t\t}\n\n\t\tpublic static int Abs(int x)\n\t\t{\n\t\t\treturn Math.Abs(x);\n\t\t}\n\n\t\tpublic static int getInt()\n\t\t{\n\t\t\tvar s = Console.ReadLine();\n\t\t\treturn int.Parse(s);\n\t\t}\n\n\t\tpublic static bool Equal(int x, int y, int x1, int y1)\n\t\t{\n\t\t\treturn x == x1 && y == y1;\n\t\t}\n\n\t\tpublic class Vertex\n\t\t{\n\t\t\tpublic List edges;\n\n\t\t\tpublic int ct;\n\n\t\t\tpublic Vertex()\n\t\t\t{\n\t\t\t\tct = 0;\n\t\t\t\tedges = new List();\n\t\t\t\tfor (var i = 0; i < 26; ++i)\n\t\t\t\t\tedges.Add(0);\n\t\t\t}\n\t\t}\n\n\n\t\tprivate static void Main(string[] args)\n\t\t{\n/*\t\t\tvar input = new StreamReader(\"input.txt\");\n\t\t\tvar output = new StreamWriter(\"output.txt\");*/\n\n\t\t\tvar n = getInt();\n\t\t\tvar a = n/10;\n\t\t\tvar b = n%10;\n\t\t\tvar ct1 = 0;\n\t\t\tvar ct2 = 0;\n\t\t\tif (a == 0)\n\t\t\t{\n\t\t\t\tct1 = 2;\n\t\t\t}\n\t\t\tif (a == 1)\n\t\t\t{\n\t\t\t\tct1 = 7;\n\t\t\t}\n\t\t\tif (a == 2)\n\t\t\t\tct1 = 2;\n\t\t\tif (a == 3)\n\t\t\t\tct1 = 3;\n\t\t\tif (a == 4)\n\t\t\t\tct1 = 3;\n\t\t\tif (a == 5)\n\t\t\t\tct1 = 4;\n\t\t\tif (a == 6)\n\t\t\t\tct1 = 2;\n\t\t\tif (a == 7)\n\t\t\t\tct1 = 5;\n\t\t\tif (a == 8)\n\t\t\t\tct1 = 1;\n\t\t\tif (a == 9)\n\t\t\t\tct1 = 2;\n\t\t\tif (b == 0)\n\t\t\t{\n\t\t\t\tct2 = 2;\n\t\t\t}\n\t\t\tif (b == 1)\n\t\t\t{\n\t\t\t\tct2 = 7;\n\t\t\t}\n\t\t\tif (b == 2)\n\t\t\t\tct2 = 2;\n\t\t\tif (b == 3)\n\t\t\t\tct2 = 3;\n\t\t\tif (b == 4)\n\t\t\t\tct2 = 3;\n\t\t\tif (b == 5)\n\t\t\t\tct2 = 4;\n\t\t\tif (b == 6)\n\t\t\t\tct2 = 2;\n\t\t\tif (b == 7)\n\t\t\t\tct2 = 5;\n\t\t\tif (b == 8)\n\t\t\t\tct2 = 1;\n\t\t\tif (b == 9)\n\t\t\t\tct2 = 2;\n\t\t\tConsole.WriteLine(ct1 * ct2);\n\t\t\t/*\t\t\tinput.Close();\n\t\t\toutput.Close();*/\n\t\t}\n\t}\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "c16d3216c7601d86438d887c8e188abe", "src_uid": "76c8bfa6789db8364a8ece0574cd31f5", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Text;\npublic class Test\n{\n public static void Main()\n {\n // your code goes here\n string str = Console.ReadLine().Trim();\n int[] arr = new int[]{2,7,2,3,3,4,2,5,1,2};\n if(str.Length > 1){\n int a1 = (int)str[0] - (int)'0';\n int b1 = (int)str[1] - (int)'0';\n Console.WriteLine(arr[a1] * arr[b1]);\n }else{\n int a1 = (int)str[0] - (int)'0';\n //int b1 = (int)str[1] - (int)'0';\n Console.WriteLine(arr[a1]);\n }\n }\n}", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "c8be3a671501001009ef8356c5332d4a", "src_uid": "76c8bfa6789db8364a8ece0574cd31f5", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace _724A {\n\tclass Program {\n\t\tstatic void Main(string[] args) {\n\t\t\tstring a = Console.ReadLine();\n\t\t\tstring b = Console.ReadLine();\n\t\t\tstring[] days = new string[] { \"monday\", \"tuesday\", \"wednesday\", \"thursday\", \"friday\", \"saturday\", \"sunday\" };\n\t\t\tint a1 = 0;\n\t\t\tint b1= 0;\n\t\t\tfor(int i=0; i b)\n {\n min = b;\n max = a;\n }\n else if (a < b)\n {\n min = a;\n max = b;\n }\n else\n {\n return a;\n }\n\n while (min != max)\n {\n max = max - min;\n if (max < min)\n {\n long t = max;\n max = min;\n min = t;\n }\n }\n\n return min;\n }\n static long DivNum(long b)\n {\n int count = 0;\n\n if (b == 1)\n return 1;\n\n for (int i = 1; i < Math.Sqrt(b); i++)\n {\n if ((b % i) == 0)\n count += 2;\n }\n if (b % Math.Sqrt(b) == 0)\n count++;\n\n return count;\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "number theory"], "code_uid": "dcc676700d1ac5f0175867691aa31045", "src_uid": "7fc9e7d7e25ab97d8ebc10ed8ae38fd1", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\n\nnamespace G6\n{\n class Program\n {\n static void Main(string[] args)\n {\n long b = long.Parse(Console.ReadLine().Trim(' '));\n\n int answer = 0;\n for (long s = 1; s <= (long)Math.Sqrt(b); s++)\n {\n if ((b % s == 0) && (s * s != b))\n answer += 2;\n else if (b % s == 0)\n answer++;\n }\n Console.Write(answer);\n\n //Console.ReadKey();\n }\n }\n}", "lang_cluster": "C#", "tags": ["math", "number theory"], "code_uid": "fcee7b7f344288b9831ae1c1bf5f08d6", "src_uid": "7fc9e7d7e25ab97d8ebc10ed8ae38fd1", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.IO;\nusing SB = System.Text.StringBuilder;\n//using System.Threading.Tasks;\n//using System.Text.RegularExpressions;\n//using System.Globalization;\n//using System.Diagnostics;\nusing static System.Console;\nusing System.Numerics;\nusing static System.Math;\nusing pair = Pair;\n\nclass Program\n{\n static void Main()\n {\n //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });\n new Program().solve();\n Out.Flush();\n }\n readonly Scanner cin = new Scanner();\n readonly int[] dd = { 0, 1, 0, -1, 0 }; //\u2192\u2193\u2190\u2191\n readonly int mod = 1000000007;\n readonly int dom = 998244353;\n bool chmax(ref T a, T b) where T : IComparable { if (a.CompareTo(b) < 0) { a = b; return true; } return false; }\n bool chmin(ref T a, T b) where T : IComparable { if (b.CompareTo(a) < 0) { a = b; return true; } return false; }\n\n int diff(char a, char b)\n {\n int p = Abs(a - b);\n int q = 26 - p;\n return Min(p, q);\n }\n void solve()\n {\n int N = cin.nextint;\n var S = cin.next;\n int ans = int.MaxValue;\n for (int i = 3; i < N; i++)\n {\n int sum = diff(S[i - 3], 'A') + diff(S[i - 2], 'C') + diff(S[i - 1], 'T') + diff(S[i], 'G');\n chmin(ref ans, sum);\n }\n WriteLine(ans);\n }\n\n}\n\n\nstatic class Ex\n{\n public static void join(this IEnumerable values, string sep = \" \") => WriteLine(string.Join(sep, values));\n public static string concat(this IEnumerable values) => string.Concat(values);\n public static string reverse(this string s) { var t = s.ToCharArray(); Array.Reverse(t); return t.concat(); }\n\n public static int lower_bound(this IList arr, T val) where T : IComparable\n {\n int low = 0, high = arr.Count;\n int mid;\n while (low < high)\n {\n mid = ((high - low) >> 1) + low;\n if (arr[mid].CompareTo(val) < 0) low = mid + 1;\n else high = mid;\n }\n return low;\n }\n public static int upper_bound(this IList arr, T val) where T : IComparable\n {\n int low = 0, high = arr.Count;\n int mid;\n while (low < high)\n {\n mid = ((high - low) >> 1) + low;\n if (arr[mid].CompareTo(val) <= 0) low = mid + 1;\n else high = mid;\n }\n return low;\n }\n}\n\nclass Pair : IComparable> where T : IComparable where U : IComparable\n{\n public T f; public U s;\n public Pair(T f, U s) { this.f = f; this.s = s; }\n public int CompareTo(Pair a) => f.CompareTo(a.f) != 0 ? f.CompareTo(a.f) : s.CompareTo(a.s);\n public override string ToString() => $\"{f} {s}\";\n}\n\nclass Scanner\n{\n string[] s; int i;\n readonly char[] cs = new char[] { ' ' };\n public Scanner() { s = new string[0]; i = 0; }\n public string[] scan => ReadLine().Split();\n public int[] scanint => Array.ConvertAll(scan, int.Parse);\n public long[] scanlong => Array.ConvertAll(scan, long.Parse);\n public double[] scandouble => Array.ConvertAll(scan, double.Parse);\n public string next\n {\n get\n {\n if (i < s.Length) return s[i++];\n string st = ReadLine();\n while (st == \"\") st = ReadLine();\n s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);\n i = 0;\n return next;\n }\n }\n public int nextint => int.Parse(next);\n public long nextlong => long.Parse(next);\n public double nextdouble => double.Parse(next);\n}\n", "lang_cluster": "C#", "tags": ["brute force", "strings"], "code_uid": "aebd827293173be38696b8b2067e593a", "src_uid": "ee4f88abe4c9fa776abd15c5f3a94543", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.IO;\n\nnamespace Contest\n{\n class Program\n {\n public void Solve()\n {\n var sc = new Scanner();\n int N = sc.NextInt();\n string S = sc.Next();\n int min = int.MaxValue;\n for (int i = 0; i <= N - 4; i++)\n {\n int dif = 0;\n dif += Diff('A', S[i]);\n dif += Diff('C', S[i + 1]);\n dif += Diff('T', S[i + 2]);\n dif += Diff('G', S[i + 3]);\n min = Math.Min(dif, min);\n }\n\n Console.WriteLine(min);\n }\n\n static void Main() => new Program().Solve();\n\n private int Diff(char a, char b)\n {\n int d = Math.Abs(a - b);\n return Math.Min(d, (26 - d));\n }\n }\n}\n\nclass Scanner\n{\n public Scanner()\n {\n _stream = new StreamReader(Console.OpenStandardInput());\n _pos = 0;\n _line = new string[0];\n _separator = ' ';\n }\n\n private char _separator;\n private StreamReader _stream;\n private int _pos;\n private string[] _line;\n\n #region get a element\n\n public string Next()\n {\n if (_pos >= _line.Length)\n {\n _line = _stream.ReadLine().Split(_separator);\n _pos = 0;\n }\n\n return _line[_pos++];\n }\n\n public int NextInt()\n {\n return int.Parse(Next());\n }\n\n public long NextLong()\n {\n return long.Parse(Next());\n }\n\n public double NextDouble()\n {\n return double.Parse(Next());\n }\n\n #endregion\n\n #region convert array\n\n private int[] ToIntArray(string[] array)\n {\n var result = new int[array.Length];\n for (int i = 0; i < array.Length; i++)\n {\n result[i] = int.Parse(array[i]);\n }\n\n return result;\n }\n\n private long[] ToLongArray(string[] array)\n {\n var result = new long[array.Length];\n for (int i = 0; i < array.Length; i++)\n {\n result[i] = long.Parse(array[i]);\n }\n\n return result;\n }\n\n private double[] ToDoubleArray(string[] array)\n {\n var result = new double[array.Length];\n for (int i = 0; i < array.Length; i++)\n {\n result[i] = double.Parse(array[i]);\n }\n\n return result;\n }\n\n #endregion\n\n #region get row elements\n\n #region get array\n\n public string[] Array()\n {\n if (_pos >= _line.Length)\n _line = _stream.ReadLine().Split(_separator);\n\n _pos = _line.Length;\n return _line;\n }\n\n public int[] IntArray()\n {\n return ToIntArray(Array());\n }\n\n public long[] LongArray()\n {\n return ToLongArray(Array());\n }\n\n public double[] DoubleArray()\n {\n return ToDoubleArray(Array());\n }\n\n #endregion\n\n #region get 2~4 elements\n\n public void GetRow(out string a, out string b)\n {\n a = Next();\n b = Next();\n }\n\n public void GetRow(out string a, out string b, out string c)\n {\n a = Next();\n b = Next();\n c = Next();\n }\n\n public void GetRow(out string a, out string b, out string c, out string d)\n {\n a = Next();\n b = Next();\n c = Next();\n d = Next();\n }\n\n public void GetIntRow(out int a, out int b)\n {\n a = NextInt();\n b = NextInt();\n }\n\n public void GetIntRow(out int a, out int b, out int c)\n {\n a = NextInt();\n b = NextInt();\n c = NextInt();\n }\n\n public void GetIntRow(out int a, out int b, out int c, out int d)\n {\n a = NextInt();\n b = NextInt();\n c = NextInt();\n d = NextInt();\n }\n\n public void GetLongRow(out long a, out long b)\n {\n a = NextLong();\n b = NextLong();\n }\n\n public void GetLongRow(out long a, out long b, out long c)\n {\n a = NextLong();\n b = NextLong();\n c = NextLong();\n }\n\n public void GetLongRow(out long a, out long b, out long c, out long d)\n {\n a = NextLong();\n b = NextLong();\n c = NextLong();\n d = NextLong();\n }\n\n public void GetDoubleRow(out double a, out double b)\n {\n a = NextDouble();\n b = NextDouble();\n }\n\n public void GetDoubleRow(out double a, out double b, out double c)\n {\n a = NextDouble();\n b = NextDouble();\n c = NextDouble();\n }\n\n public void GetDoubleRow(out double a, out double b, out double c, out double d)\n {\n a = NextDouble();\n b = NextDouble();\n c = NextDouble();\n d = NextDouble();\n }\n\n #endregion\n\n #endregion\n\n #region get 2~4 column elements\n\n public void GetColumn(int n, out string[] a)\n {\n a = new string[n];\n for (int i = 0; i < n; i++)\n {\n a[i] = Next();\n }\n }\n\n public void GetColumn(int n, out string[] a, out string[] b)\n {\n a = new string[n];\n b = new string[n];\n for (int i = 0; i < n; i++)\n {\n GetRow(out a[i], out b[i]);\n }\n }\n\n public void GetColumn(int n, out string[] a, out string[] b, out string[] c)\n {\n a = new string[n];\n b = new string[n];\n c = new string[n];\n for (int i = 0; i < n; i++)\n {\n GetRow(out a[i], out b[i], out c[i]);\n }\n }\n\n public void GetColumn(int n, out string[] a, out string[] b, out string[] c, out string[] d)\n {\n a = new string[n];\n b = new string[n];\n c = new string[n];\n d = new string[n];\n for (int i = 0; i < n; i++)\n {\n GetRow(out a[i], out b[i], out c[i], out d[i]);\n }\n }\n\n public void GetIntColumn(int n, out int[] a)\n {\n string[] sa;\n GetColumn(n, out sa);\n a = ToIntArray(sa);\n }\n\n public void GetIntColumn(int n, out int[] a, out int[] b)\n {\n string[] sa, sb;\n GetColumn(n, out sa, out sb);\n a = ToIntArray(sa);\n b = ToIntArray(sb);\n }\n\n public void GetIntColumn(int n, out int[] a, out int[] b, out int[] c)\n {\n string[] sa, sb, sc;\n GetColumn(n, out sa, out sb, out sc);\n a = ToIntArray(sa);\n b = ToIntArray(sb);\n c = ToIntArray(sc);\n }\n\n public void GetIntColumn(int n, out int[] a, out int[] b, out int[] c, out int[] d)\n {\n string[] sa, sb, sc, sd;\n GetColumn(n, out sa, out sb, out sc, out sd);\n a = ToIntArray(sa);\n b = ToIntArray(sb);\n c = ToIntArray(sc);\n d = ToIntArray(sd);\n }\n\n public void GetLongColumn(int n, out long[] a)\n {\n string[] sa;\n GetColumn(n, out sa);\n a = ToLongArray(sa);\n }\n\n public void GetLongColumn(int n, out long[] a, out long[] b)\n {\n string[] sa, sb;\n GetColumn(n, out sa, out sb);\n a = ToLongArray(sa);\n b = ToLongArray(sb);\n }\n\n public void GetLongColumn(int n, out long[] a, out long[] b, out long[] c)\n {\n string[] sa, sb, sc;\n GetColumn(n, out sa, out sb, out sc);\n a = ToLongArray(sa);\n b = ToLongArray(sb);\n c = ToLongArray(sc);\n }\n\n public void GetLongColumn(int n, out long[] a, out long[] b, out long[] c, out long[] d)\n {\n string[] sa, sb, sc, sd;\n GetColumn(n, out sa, out sb, out sc, out sd);\n a = ToLongArray(sa);\n b = ToLongArray(sb);\n c = ToLongArray(sc);\n d = ToLongArray(sd);\n }\n\n public void GetDoubleColumn(int n, out double[] a)\n {\n string[] sa;\n GetColumn(n, out sa);\n a = ToDoubleArray(sa);\n }\n\n public void GetDoubleColumn(int n, out double[] a, out double[] b)\n {\n string[] sa, sb;\n GetColumn(n, out sa, out sb);\n a = ToDoubleArray(sa);\n b = ToDoubleArray(sb);\n }\n\n public void GetDoubleColumn(int n, out double[] a, out double[] b, out double[] c)\n {\n string[] sa, sb, sc;\n GetColumn(n, out sa, out sb, out sc);\n a = ToDoubleArray(sa);\n b = ToDoubleArray(sb);\n c = ToDoubleArray(sc);\n }\n\n public void GetDoubleColumn(int n, out double[] a, out double[] b, out double[] c, out double[] d)\n {\n string[] sa, sb, sc, sd;\n GetColumn(n, out sa, out sb, out sc, out sd);\n a = ToDoubleArray(sa);\n b = ToDoubleArray(sb);\n c = ToDoubleArray(sc);\n d = ToDoubleArray(sd);\n }\n\n #endregion\n\n #region get matrix\n\n public string[][] GetMatrix(int h)\n {\n string[][] result = new string[h][];\n for (int i = 0; i < h; i++)\n {\n result[i] = Array();\n }\n\n return result;\n\n }\n\n public int[][] GetIntMatrix(int h)\n {\n int[][] result = new int[h][];\n for (int i = 0; i < h; i++)\n {\n result[i] = IntArray();\n }\n\n return result;\n }\n\n public long[][] GetLongMatrix(int h)\n {\n long[][] result = new long[h][];\n for (int i = 0; i < h; i++)\n {\n result[i] = LongArray();\n }\n\n return result;\n }\n\n public double[][] GetDoubleMatrix(int h)\n {\n double[][] result = new double[h][];\n for (int i = 0; i < h; i++)\n {\n result[i] = DoubleArray();\n }\n\n return result;\n }\n\n public char[][] GetCharMatrix(int h)\n {\n char[][] result = new char[h][];\n for (int i = 0; i < h; i++)\n {\n result[i] = Next().ToCharArray();\n }\n\n return result;\n }\n\n #endregion\n}", "lang_cluster": "C#", "tags": ["brute force", "strings"], "code_uid": "a88190d359a258a5f7c9ec2feec4f070", "src_uid": "ee4f88abe4c9fa776abd15c5f3a94543", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace _977B\n{\n class Program\n {\n static void Main(string[] args)\n {\n int n = Convert.ToInt32(Console.ReadLine());\n string[] dv = new string[n - 1];\n string str = Console.ReadLine();\n char[] ch = new char[n];\n for (int i = 0; i < n; i++)\n {\n ch[i] = str[i];\n }\n for (int i = 0; i < n-1; i++)\n {\n dv[i] = \"\"+ch[i] + ch[i + 1];\n }\n int max = 0;\n int mem = 0;\n for (int i = 0; i < n-1; i++)\n {\n int c = 0;\n for (int j = 0; j < n-1; j++)\n {\n if (dv[i] == dv[j]) { c++; }\n }\n if (c > max)\n {\n mem = i;\n max = c;\n }\n }\n Console.WriteLine(dv[mem]);\n\n\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["strings", "implementation"], "code_uid": "ceb0cde0d5d6a510fc808e84176ed96b", "src_uid": "e78005d4be93dbaa518f3b40cca84ab1", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Linq;\nclass Task {\n \n static void Main() {\n var n = Convert.ToInt32(Console.ReadLine());\n var original = Console.ReadLine();\n \n string[] str = new string[n - 1];\n for(int i = 0; i < n - 1; i++) {\n str[i] = Char.ToString(original[i]) + Char.ToString(original[i + 1]);\n }\n \n int[] nums = new int[n - 1];\n int count = 0;\n \n for(int i = 0; i < n - 1; i++) {\n count = str.Count(f => f == str[i]);\n nums[i] = count;\n }\n \n Console.WriteLine(str[nums.ToList().IndexOf(nums.Max())]);\n \n }\n}", "lang_cluster": "C#", "tags": ["strings", "implementation"], "code_uid": "7ea2f7970b25b238e3a41cb3ef5c09ba", "src_uid": "e78005d4be93dbaa518f3b40cca84ab1", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\n\nnamespace ko\n{\n class Program\n {\n static void Main()\n {\n int n, x, pr, nujno, res, i;\n int[] arr = new int[3];\n string[] tmp = Console.ReadLine().Split(' ');\n for (i = 0; i < 3; i++)\n arr[i] = Int32.Parse(tmp[i]);\n n = arr[0];\n x = arr[1];\n pr = arr[2];\n if (n * pr % 100 == 0)\n nujno = (n * pr / 100);\n else nujno = (n * pr / 100) + 1;\n if (nujno <= x) res = 0;\n else res = nujno - x;\n Console.WriteLine(res);\n }\n }\n }\n\n", "lang_cluster": "C#", "tags": ["math", "implementation"], "code_uid": "c95883b5c157b498a6454c88dddf5e10", "src_uid": "7038d7b31e1900588da8b61b325e4299", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Globalization;\nusing System.Threading;\nusing System.Collections;\nusing System.IO;\n\nnamespace AcmSolution\n{\n internal class Program\n {\n private static void Main(string[] args)\n {\n Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;\n //Console.SetIn(new StreamReader(\"gcd.in\"));\n // Console.SetOut(new StreamWriter(\"gcd.out\"));\n Do();\n //Console.Out.Close();\n Console.ReadLine();\n }\n\n private static void Do()\n {\n int n;\n int x;\n int y;\n double answer = 0;\n GetInts(out n, out x, out y);\n double person = n * y;\n person = person / 100;\n if (person > x)\n answer = person - x;\n if (answer != (int)(answer) && person > x)\n {\n answer = answer + 1;\n answer = (int)(answer);\n }\n Console.WriteLine(answer);\n } \n \n #region Utils\n private const double Epsilon = 0.00000001;\n\n private static string GetStr()\n {\n return Console.ReadLine();\n }\n\n private static string[] GetStrs()\n {\n return GetStr().Split(new[] { ' ', '\\t' }, StringSplitOptions.RemoveEmptyEntries);\n }\n\n private static string[] GetStrs(int cnt)\n {\n var s = new string[cnt];\n for (var i = 0; i < cnt; ++i)\n s[i] = GetStr();\n return s;\n }\n\n private static int GetInt()\n {\n return int.Parse(GetStr());\n }\n\n private static void GetInts(out int a, out int b)\n {\n var q = GetInts();\n a = q[0];\n b = q[1];\n }\n\n private static void GetInts(out int a, out int b, out int c)\n {\n var q = GetInts();\n a = q[0];\n b = q[1];\n c = q[2];\n }\n\n private static int[] GetInts()\n {\n var s = GetStrs();\n var a = new int[s.Length];\n for (var i = 0; i < s.Length; ++i)\n a[i] = int.Parse(s[i]);\n return a;\n }\n\n private static long GetLong()\n {\n return long.Parse(GetStr());\n }\n\n private static IEnumerable GetLongs()\n {\n return GetStrs().Select(long.Parse);\n }\n\n private static void WriteDouble(T d)\n {\n Console.WriteLine(string.Format(\"{0:0.000000000}\", d).Replace(',', '.'));\n }\n\n private static void WL(T s)\n {\n Console.WriteLine(s);\n }\n\n private static void W(T s)\n {\n Console.Write(s);\n }\n\n private static void Assert(bool b)\n {\n if (!b) throw new Exception();\n }\n\n private static void Swap(ref T a, ref T b)\n {\n var temp = a;\n a = b;\n b = temp;\n }\n\n #endregion\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "implementation"], "code_uid": "3b31b8efd6d6970c3a0c953458547233", "src_uid": "7038d7b31e1900588da8b61b325e4299", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\n\nnamespace _141B\n{\n class Program\n {\n static void Main(string[] args)\n {\n\n string s = Console.ReadLine();\n string[] mas = s.Split(' ');\n int a = int.Parse(mas[0]);\n int x = int.Parse(mas[1]);\n int y = int.Parse(mas[2]);\n\n bool check = true;\n\n int lines = y / a;\n\n if ((x >= a) || (x <= -a)) check = false;\n if (y % a == 0) check = false;\n if (((lines) % 2 == 1 || y/a<1) & (x >= a / 2.0 || x <= -a / 2.0)) check = false;\n if ((lines % 2 == 0 & y>a) & (x == 0)) check = false;\n if (check == false)\n {\n Console.WriteLine(\"-1\");\n }\n else\n {\n int nmin = 0;\n\n if (y < a) nmin = 1;\n else\n {\n\n if (y > a) nmin = ((y - a) / (a * 2)) * 3 + 1;\n if (lines % 2 == 0)\n {\n if (x < 0) nmin = nmin + 2;\n else nmin = nmin + 3;\n }\n else nmin++;\n }\n Console.WriteLine(nmin);\n Console.ReadLine();\n }\n\n\n\n\n\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "geometry"], "code_uid": "f84604c08f3eb2b6187fe0d6097cd247", "src_uid": "cf48ff6ba3e77ba5d4afccb8f775fb02", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\n\nnamespace _11111\n{\n class Program\n {\n static void Main(string[] args)\n {\n string[] iData = Console.ReadLine().Split(' ');\n int iA = Convert.ToInt32(iData[0]);\n int iX = Convert.ToInt32(iData[1]);\n int iY = Convert.ToInt32(iData[2]);\n\n int iLevel = iY / iA;\n int iNumberSquare = -1;\n if (iY % iA != 0)\n {\n iNumberSquare = 0;\n int iIndexLevel = 0;\n while (iIndexLevel != iLevel)\n {\n iIndexLevel++;\n iNumberSquare++;\n if (iIndexLevel != 1 && iIndexLevel % 2 != 0)\n iNumberSquare++;\n }\n\n if(iLevel+1 == 1 || (iLevel+1) % 2 == 0)\n {\n if (iX > -((double)iA) / 2 && iX < ((double)iA) / 2)\n iNumberSquare++;\n else\n iNumberSquare = -1;\n }\n else\n {\n if (iX > -((double)iA) && iX < 0)\n iNumberSquare++;\n else\n if (iX > 0 && iX < ((double)iA))\n iNumberSquare += 2;\n else\n iNumberSquare = -1;\n }\n\n }\n Console.WriteLine(iNumberSquare);\n }\n \n }\n}", "lang_cluster": "C#", "tags": ["math", "geometry"], "code_uid": "c3f8758869d3b7d6d7a2b3404fb0102f", "src_uid": "cf48ff6ba3e77ba5d4afccb8f775fb02", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace ConsoleApplication1\n{\n class Program\n {\n static void Main(string[] args)\n {\n int[] inputArray = Array.ConvertAll(Console.ReadLine().Split((char)32), int.Parse);\n\n Console.WriteLine(Math.Min(inputArray[0], Math.Min(inputArray[1], (inputArray[0] + inputArray[1]) / 3)));\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "greedy", "implementation", "number theory"], "code_uid": "38e5fe5864c1ae4a9281dfa7b5fdd0bf", "src_uid": "0718c6afe52cd232a5e942052527f31b", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Globalization;\nusing System.IO;\nusing System.Linq;\nusing static System.Math;\n\n// http://codeforces.com/problemset/problem/519/C\npublic class C___A_and_B_and_Team_Training\n{\n private static void Solve()\n {\n int a = ReadInt();\n int b = ReadInt();\n\n int teams = 0;\n while ((a > 0 && b > 1) || (a > 1 && b > 0))\n {\n if (a > b)\n {\n a -= 2;\n b -= 1;\n } else\n {\n a -= 1;\n b -= 2;\n }\n teams++;\n }\n\n Write(teams);\n }\n\n #region Main\n\n private static TextReader reader;\n private static TextWriter writer;\n\n public static void Main()\n {\n#if DEBUG\n\n //reader = new StreamReader(\"C:\\\\Users\\\\Axel\\\\Desktop\\\\input.txt\");\n reader = new StreamReader(Console.OpenStandardInput());\n writer = Console.Out;\n\n //writer = new StreamWriter(\"..\\\\..\\\\output.txt\");\n#else\n reader = new StreamReader(Console.OpenStandardInput());\n writer = new StreamWriter(Console.OpenStandardOutput());\n\n //reader = new StreamReader(\"input.txt\");\n //writer = new StreamWriter(\"output.txt\");\n#endif\n try\n {\n Solve();\n\n //var thread = new Thread(new String_Task().Solve, 1024 * 1024 * 128);\n //thread.Start();\n //thread.Join();\n }\n catch (Exception ex)\n {\n Console.WriteLine(ex);\n#if DEBUG\n#else\n throw;\n#endif\n }\n reader.Close();\n writer.Close();\n }\n\n #endregion Main\n\n #region Read / Write\n\n private static Queue currentLineTokens = new Queue();\n\n private static string[] ReadAndSplitLine()\n {\n return reader.ReadLine().Split(new[] { ' ', '\\t', }, StringSplitOptions.RemoveEmptyEntries);\n }\n\n public static string Read()\n {\n while (currentLineTokens.Count == 0) currentLineTokens = new Queue(ReadAndSplitLine()); return currentLineTokens.Dequeue();\n }\n\n public static int ReadInt()\n {\n return int.Parse(Read());\n }\n\n public static long ReadLong()\n {\n return long.Parse(Read());\n }\n\n public static double ReadDouble()\n {\n return double.Parse(Read(), CultureInfo.InvariantCulture);\n }\n\n public static int[] ReadIntArray()\n {\n return ReadAndSplitLine().Select(int.Parse).ToArray();\n }\n\n public static long[] ReadLongArray()\n {\n return ReadAndSplitLine().Select(long.Parse).ToArray();\n }\n\n public static double[] ReadDoubleArray()\n {\n return ReadAndSplitLine().Select(s => double.Parse(s, CultureInfo.InvariantCulture)).ToArray();\n }\n\n public static int[][] ReadIntMatrix(int numberOfRows)\n {\n int[][] matrix = new int[numberOfRows][]; for (int i = 0; i < numberOfRows; i++) matrix[i] = ReadIntArray(); return matrix;\n }\n\n public static int[][] ReadAndTransposeIntMatrix(int numberOfRows)\n {\n int[][] matrix = ReadIntMatrix(numberOfRows); int[][] ret = new int[matrix[0].Length][];\n for (int i = 0; i < ret.Length; i++) { ret[i] = new int[numberOfRows]; for (int j = 0; j < numberOfRows; j++) ret[i][j] = matrix[j][i]; }\n return ret;\n }\n\n public static string[] ReadLines(int quantity)\n {\n string[] lines = new string[quantity]; for (int i = 0; i < quantity; i++) lines[i] = reader.ReadLine().Trim(); return lines;\n }\n\n public static void WriteArray(IEnumerable array)\n {\n writer.WriteLine(string.Join(\" \", array));\n }\n\n public static void Write(params object[] array)\n {\n WriteArray(array);\n }\n\n public static void WriteLines(IEnumerable array)\n {\n foreach (var a in array) writer.WriteLine(a);\n }\n\n private class SDictionary : Dictionary\n {\n public new TValue this[TKey key]\n {\n get { return ContainsKey(key) ? base[key] : default(TValue); }\n set { base[key] = value; }\n }\n }\n\n private static T[] Init(int size) where T : new()\n {\n var ret = new T[size]; for (int i = 0; i < size; i++) ret[i] = new T(); return ret;\n }\n\n #endregion Read / Write\n}\n", "lang_cluster": "C#", "tags": ["math", "greedy", "implementation", "number theory"], "code_uid": "a3483db125abe2b622e6954a6930decf", "src_uid": "0718c6afe52cd232a5e942052527f31b", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\n\nnamespace test\n{\n class MainClass\n {\n public static void Main(string[] args)\n {\n Console.ReadLine();\n var x = Console.ReadLine().Split(' ');\n int ans = 0;\n foreach(var i in x){\n ans += Math.Abs(int.Parse(i));\n }\n Console.WriteLine(ans.ToString());\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["greedy"], "code_uid": "97cc0e98ce7f5af347c036d4c99928db", "src_uid": "4b5d14833f9b51bfd336cc0e661243a5", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Linq;\n\nnamespace codeforces\n{\n\n class Program\n {\n static void Main(string[] args)\n {\n int c1 = int.Parse(Console.ReadLine());\n int[] count = Console.ReadLine().Split().Select(int.Parse).ToArray();\n\n int a = count.Where(x => x <= 0).ToArray().Sum();\n int b = count.Where(x => x > 0).ToArray().Sum();\n Console.WriteLine(b-a);\n\n }\n }\n}", "lang_cluster": "C#", "tags": ["greedy"], "code_uid": "b0cb3e8e60e210245db53c809d0fa30b", "src_uid": "4b5d14833f9b51bfd336cc0e661243a5", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace CodeForces.C659\n{\n class Pa\n {\n static void Main(string[] args)\n {\n int[] data = Console.ReadLine().Split(' ').Select(t => int.Parse(t)).ToArray();\n Console.WriteLine((data[0]*100 + data[1] + data[2] - 1) % data[0] + 1);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "implementation"], "code_uid": "ad97065608fd3c44e4bd34512d4da4bd", "src_uid": "cd0e90042a6aca647465f1d51e6dffc4", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\n\nnamespace ConsoleApplication1\n{\n class Program\n {\n static void Main(string[] args)\n {\n string stroka = \"\"; ; string konec = \"\"; int a = 0; long itog = 0; long kol = 0; long nomer = 0;long y=1; long minut = 0; string konec2 = \"\"; long[] strochenka = { 0, 0 };\n stroka = Console.ReadLine();\n string[] split = stroka.Split(new Char[] { ' ' });\n foreach (string s in split)\n {\n if (s.Trim() != \"\")\n {\n if (a == 0)\n kol = Convert.ToInt64(s);\n if(a==1)\n nomer = Convert.ToInt64(s);\n if (a==2)\n minut = Convert.ToInt64(s);\n a++;\n }\n }\n itog = (nomer-1 + (minut%kol+kol)) % kol+1;\n Console.Write(Math.Abs(itog));\n }\n }\n}", "lang_cluster": "C#", "tags": ["math", "implementation"], "code_uid": "17aa99b573b3d9fb4dff504e7d526d86", "src_uid": "cd0e90042a6aca647465f1d51e6dffc4", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Globalization;\nusing System.IO;\nusing System.Linq;\nusing System.Text;\nusing static System.Console;\nusing static System.Math;\n\nnamespace Olymp\n{\n public class ProblemSolver\n {\n private readonly Tokenizer input;\n\n public void Solve()\n {\n var a = input.ReadIntArray(3);\n var d = input.ReadInt();\n Array.Sort(a);\n Write(Max(0, d - (a[1] - a[0]) + Max(0, d - (a[2] - a[1]))));\n }\n\n public ProblemSolver(TextReader input)\n {\n this.input = new Tokenizer(input);\n }\n }\n\n #region Service classes\n\n public class Tokenizer\n {\n private readonly TextReader reader;\n\n public string ReadToEnd()\n {\n return reader.ReadToEnd();\n }\n\n public int ReadInt()\n {\n var c = SkipWS();\n if (c == -1)\n throw new EndOfStreamException();\n var isNegative = false;\n if (c == '-' || c == '+')\n {\n isNegative = c == '-';\n c = reader.Read();\n if (c == -1)\n throw new EndOfStreamException(\"Digit expected, but end of stream occurs\");\n }\n\n if (!char.IsDigit((char)c))\n throw new InvalidOperationException($\"Digit expected, but was: '{(char)c}'\");\n var result = (char)c - '0';\n c = reader.Read();\n while (c > 0 && !char.IsWhiteSpace((char)c))\n {\n if (!char.IsDigit((char)c))\n throw new InvalidOperationException($\"Digit expected, but was: '{(char)c}'\");\n result = result * 10 + (char)c - '0';\n c = reader.Read();\n }\n\n if (isNegative)\n result = -result;\n return result;\n }\n\n public string ReadLine()\n {\n return reader.ReadLine();\n }\n\n public long ReadLong()\n {\n return long.Parse(ReadToken());\n }\n\n public double ReadDouble()\n {\n return double.Parse(ReadToken(), CultureInfo.InvariantCulture);\n }\n\n public int[] ReadIntArray(int n)\n {\n var a = new int[n];\n for (var i = 0; i < n; i++)\n a[i] = ReadInt();\n return a;\n }\n\n public (int, int) Read2Int() =>\n (ReadInt(), ReadInt());\n\n public (int, int, int) Read3Int() =>\n (ReadInt(), ReadInt(), ReadInt());\n\n public (int, int, int, int) Read4Int() =>\n (ReadInt(), ReadInt(), ReadInt(), ReadInt());\n\n public long[] ReadLongArray(int n)\n {\n var a = new long[n];\n for (var i = 0; i < n; i++)\n a[i] = ReadLong();\n return a;\n }\n\n public double[] ReadDoubleArray(int n)\n {\n var a = new double[n];\n for (var i = 0; i < n; i++)\n a[i] = ReadDouble();\n return a;\n }\n\n public string ReadToken()\n {\n var c = SkipWS();\n if (c == -1)\n return null;\n var sb = new StringBuilder();\n while (c > 0 && !char.IsWhiteSpace((char)c))\n {\n sb.Append((char)c);\n c = reader.Read();\n }\n\n return sb.ToString();\n }\n\n private int SkipWS()\n {\n var c = reader.Read();\n if (c == -1)\n return c;\n while (c > 0 && char.IsWhiteSpace((char)c))\n c = reader.Read();\n return c;\n }\n\n public Tokenizer(TextReader reader)\n {\n this.reader = reader;\n }\n }\n\n internal class Program\n {\n public static void Main()\n {\n var solver = new ProblemSolver(In);\n solver.Solve();\n }\n }\n\n #endregion\n}\n", "lang_cluster": "C#", "tags": ["math"], "code_uid": "914ea27e632fc21e6f4c2ac6f17b5982", "src_uid": "47c07e46517dbc937e2e779ec0d74eb3", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Linq;\n\nnamespace Codeforces\n{\n public class ProblemA568\n {\n static void Main(string[] args)\n {\n long[] abcd = Console.ReadLine().Split().Select(long.Parse).ToArray();\n long d = abcd[3];\n var l = abcd.Take(3).ToList();\n l.Sort();\n long target0 = l[1] - d;\n long target2 = l[1] + d;\n long duration = 0;\n duration += Math.Max(0, l[0] - target0);\n duration += Math.Max(0, target2 - l[2]);\n Console.WriteLine(duration);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math"], "code_uid": "f9653bf74bea7add22b3431a1c2c101e", "src_uid": "47c07e46517dbc937e2e779ec0d74eb3", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Globalization;\nusing System.Linq;\nusing System.Runtime.InteropServices;\nusing System.Security.Policy;\nusing System.Text;\n\nnamespace Console\n{\n class Program\n {\n static void Main(string[] args)\n {\n var arr = new List(System.Console.ReadLine().Split(' ').Select(long.Parse));\n var a = arr[0];\n var b = arr[1];\n var c = arr[2];\n var l = arr[3];\n\n long ans = (l + 1)*(l + 2)*(l + 3)/6;\n for (int i = 0; i <= l; ++i)\n {\n ans -= Fun(a + i, b, c, l - i);\n ans -= Fun(b + i, a, c, l - i);\n ans -= Fun(c + i, b, a, l - i);\n }\n System.Console.Write(ans);\n //System.Console.ReadLine();\n }\n\n static long Fun(long a, long b, long c, long x)\n {\n if (a < b + c)\n return 0;\n var min = Math.Min(a - b - c, x);\n return (min + 1)*(min + 2)/2;\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "implementation", "combinatorics"], "code_uid": "85ce1a8803769a9527e8e7bdbb0310ed", "src_uid": "185ff90a8b0ae0e2b75605f772589410", "difficulty": 2100.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Linq;\nusing System.Diagnostics;\nusing System.Collections.Generic;\nusing Debug = System.Diagnostics.Debug;\nusing StringBuilder = System.Text.StringBuilder;\nusing System.Numerics;\n\nnamespace Program\n{\n\n public class Solver\n {\n public void Solve()\n {\n var table = new CombinationTable(300050);\n var a = sc.Integer();\n var b = sc.Integer();\n var c = sc.Integer();\n var l = sc.Integer();\n long all = 0;\n for (int i = 0; i <= l; i++)\n {\n all += table[i + 2, 2];\n Debug.WriteLine(all);\n }\n var abc = new int[] { a, b, c };\n var sum = a + b + c;\n for (int i = 0; i < 3; i++)\n {\n for (int j = 0; j <= l; j++)\n {\n var max = abc[i] + j;\n var rem = Math.Min(l - j, max - sum + abc[i]);\n if (rem < 0) continue;\n all -= table[rem + 2, 2];\n }\n }\n IO.Printer.Out.WriteLine(all);\n }\n public IO.StreamScanner sc = new IO.StreamScanner(Console.OpenStandardInput());\n static T[] Enumerate(int n, Func f) { var a = new T[n]; for (int i = 0; i < n; ++i) a[i] = f(i); return a; }\n static public void Swap(ref T a, ref T b) { var tmp = a; a = b; b = tmp; }\n }\n}\n\n#region main\nstatic class Ex\n{\n static public string AsString(this IEnumerable ie) { return new string(System.Linq.Enumerable.ToArray(ie)); }\n static public string AsJoinedString(this IEnumerable ie, string st = \" \") { return string.Join(st, ie); }\n static public void Main()\n {\n var solver = new Program.Solver();\n solver.Solve();\n Program.IO.Printer.Out.Flush();\n }\n}\n#endregion\n#region Ex\nnamespace Program.IO\n{\n using System.IO;\n using System.Text;\n using System.Globalization;\n public class Printer : StreamWriter\n {\n static Printer() { Out = new Printer(Console.OpenStandardOutput()) { AutoFlush = false }; }\n public static Printer Out { get; set; }\n public override IFormatProvider FormatProvider { get { return CultureInfo.InvariantCulture; } }\n public Printer(System.IO.Stream stream) : base(stream, new UTF8Encoding(false, true)) { }\n public Printer(System.IO.Stream stream, Encoding encoding) : base(stream, encoding) { }\n public void Write(string format, T[] source) { base.Write(format, source.OfType().ToArray()); }\n public void WriteLine(string format, T[] source) { base.WriteLine(format, source.OfType().ToArray()); }\n }\n public class StreamScanner\n {\n public StreamScanner(Stream stream) { str = stream; }\n public readonly Stream str;\n private readonly byte[] buf = new byte[1024];\n private int len, ptr;\n public bool isEof = false;\n public bool IsEndOfStream { get { return isEof; } }\n private byte read()\n {\n if (isEof) return 0;\n if (ptr >= len) { ptr = 0; if ((len = str.Read(buf, 0, 1024)) <= 0) { isEof = true; return 0; } }\n return buf[ptr++];\n }\n public char Char() { byte b = 0; do b = read(); while ((b < 33 || 126 < b) && !isEof); return (char)b; }\n\n public string Scan()\n {\n var sb = new StringBuilder();\n for (var b = Char(); b >= 33 && b <= 126; b = (char)read())\n sb.Append(b);\n return sb.ToString();\n }\n public string ScanLine()\n {\n var sb = new StringBuilder();\n for (var b = Char(); b != '\\n'; b = (char)read())\n if (b == 0) break;\n else if (b != '\\r') sb.Append(b);\n return sb.ToString();\n }\n public long Long()\n {\n if (isEof) return long.MinValue;\n long ret = 0; byte b = 0; var ng = false;\n do b = read();\n while (b != '-' && (b < '0' || '9' < b));\n if (b == '-') { ng = true; b = read(); }\n for (; true; b = read())\n {\n if (b < '0' || '9' < b)\n return ng ? -ret : ret;\n else ret = ret * 10 + b - '0';\n }\n }\n public int Integer() { return (isEof) ? int.MinValue : (int)Long(); }\n public double Double() { return double.Parse(Scan(), CultureInfo.InvariantCulture); }\n private T[] enumerate(int n, Func f)\n {\n var a = new T[n];\n for (int i = 0; i < n; ++i) a[i] = f();\n return a;\n }\n\n public char[] Char(int n) { return enumerate(n, Char); }\n public string[] Scan(int n) { return enumerate(n, Scan); }\n public double[] Double(int n) { return enumerate(n, Double); }\n public int[] Integer(int n) { return enumerate(n, Integer); }\n public long[] Long(int n) { return enumerate(n, Long); }\n }\n}\n#endregion\n\n#region CombinationTable\npublic class CombinationTable\n{\n long[][] nCr;\n public CombinationTable(int n)\n {\n nCr = new long[n + 1][];\n for (int i = 0; i <= n; i++)\n nCr[i] = new long[4];\n nCr[0][0] = 1;\n for (int i = 0; i <= n; i++)\n {\n nCr[i][0] = 1;\n for (int j = 1; j < Math.Min(i + 1, 4); j++)\n nCr[i][j] = (nCr[i - 1][j - 1] + nCr[i - 1][j]);// % mod;\n }\n }\n public long this[int n, int r]\n {\n get\n {\n if (n < 0 || n > nCr.Length)\n return 0;\n if (r < 0 || r > n)\n return 0;\n return nCr[n][r];\n }\n }\n public long RepeatedCombination(int n, int k)\n {\n if (k == 0) return 1;\n return this[n + k - 1, k];\n }\n}\n#endregion\n", "lang_cluster": "C#", "tags": ["brute force", "math", "dp", "combinatorics"], "code_uid": "ba231792f1453b9ae94ff8ded546e944", "src_uid": "185ff90a8b0ae0e2b75605f772589410", "difficulty": 2100.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace Codeforces_Round_num426__Div._2_\n{\n class Program\n {\n static void Main(string[] args)\n {\n func1();\n }\n static void func1()\n {\n var instr = Console.ReadLine();\n int cols = Int32.Parse(Console.ReadLine());\n int s = 0;\n if (instr[0] == '^')\n s = 0;\n else if (instr[0] == '>')\n s = 90;\n else if (instr[0] == 'v')\n s = 180;\n else if (instr[0] == '<')\n s = 270;\n\n int e = 0;\n if (instr[2] == '^')\n e = 0;\n else if (instr[2] == '>')\n e = 90;\n else if (instr[2] == 'v')\n e = 180;\n else if (instr[2] == '<')\n e = 270;\n\n cols = cols % 4;\n\n var cwpath = e - s;\n if (cwpath < 0)\n cwpath += 360;\n var cwwpath = s - e;\n if (cwwpath < 0)\n cwwpath += 360;\n var cw = cwpath / 90 == cols;\n var cww = cwwpath / 90 == cols;\n if (cw == cww)\n Console.WriteLine(\"undefined\");\n else if (cw)\n Console.WriteLine(\"cw\");\n else if (cww)\n Console.WriteLine(\"ccw\");\n }\n\n static void func2()\n {\n \n }\n }\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "22ff82b9b5c916816680272bb7f467c0", "src_uid": "fb99ef80fd21f98674fe85d80a2e5298", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nnamespace CodeForces {\n class Solve834A {\n private static char[] chars = {'v', '<', '^', '>'};\n\n private static int GetIntRepresentation(char c) {\n for (int i = 0; i < chars.Length; i++) {\n if (chars[i] == c) {\n return i;\n }\n }\n\n throw new Exception(\"Invalid spin char\");\n }\n\n private static bool isClockwise(int start, int end, int seconds) {\n for (int i = 0; i < seconds; i++) {\n start = (start + 1) % 4;\n }\n\n return start == end;\n }\n\n private static bool isCounterClockwise(int start, int end, int seconds) {\n for (int i = 0; i < seconds; i++) {\n end = (end + 1) % 4;\n }\n\n return start == end;\n }\n\n public static void Main() {\n var input = Console.ReadLine();\n var parts = input.Split(' ');\n int start = GetIntRepresentation(parts[0][0]);\n int end = GetIntRepresentation(parts[1][0]);\n // Console.WriteLine(string.Format(\"start = {0}, end={1}\", start, end));\n\n input = Console.ReadLine();\n int seconds = int.Parse(input);\n seconds = seconds % 4;\n\n bool cw = isClockwise(start, end, seconds);\n bool ccw = isCounterClockwise(start, end, seconds);\n if (cw && ccw) {\n Console.WriteLine(\"undefined\");\n } else if (cw) {\n Console.WriteLine(\"cw\");\n } else {\n Console.WriteLine(\"ccw\");\n }\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "2d8fcc1a4d80a899e74b7eebdc4b2204", "src_uid": "fb99ef80fd21f98674fe85d80a2e5298", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Linq;\n\nnamespace LaraCroft\n{\n class Program\n {\n struct Vector2\n {\n public long X;\n public long Y;\n\n public Vector2(long x, long y)\n {\n this.X = x;\n this.Y = y;\n }\n\n public override string ToString()\n {\n return $\"{this.Y} {this.X}\";\n }\n }\n\n static void Main(string[] args)\n {\n var line = Console.ReadLine();\n var words = line.Split(' ');\n var values = words.Select(long.Parse).ToArray();\n\n var sizeY = values[0];\n var sizeX = values[1];\n var moves = values[2];\n\n Console.Write(SimulateMoves(sizeX, sizeY, moves));\n }\n\n static Vector2 SimulateMoves(long sizeX, long sizeY, long moves)\n {\n if (moves < sizeY)\n {\n return new Vector2(1, (long) moves + 1);\n }\n\n moves -= sizeY;\n var result = new Vector2(2, sizeY);\n var halfDividor = sizeX - 1;\n var dividor = halfDividor * 2;\n var yJumps = moves / dividor;\n moves -= yJumps * dividor;\n result.Y -= yJumps * 2;\n\n if (moves < halfDividor)\n {\n result.X += moves;\n return result;\n }\n else\n {\n moves -= halfDividor;\n result.X = sizeX;\n result.Y -= 1;\n result.X -= moves;\n return result;\n }\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "implementation"], "code_uid": "a0ce2e933d9156bbec435bd565909e9b", "src_uid": "e88bb7621c7124c54e75109a00f96301", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\n\nclass TEST{\n\tstatic void Main(){\n\t\tSol mySol =new Sol();\n\t\tmySol.Solve();\n\t}\n}\n\nclass Sol{\n\tpublic void Solve(){\n\t\t\n\t\tif(K <= N - 1){\n\t\t\tConsole.WriteLine(\"{0} {1}\",1 + K, 1);\n\t\t\treturn;\n\t\t}\n\t\t\n\t\tK -= N;\n\t\tlong rr = K / (2 * M - 2);\n\t\tlong cc = K % (2 * M - 2);\n\t\t\n\t\tlong r2 = cc / (M - 1);\n\t\t\n\t\tlong r = N - 2 * rr - r2;\n\t\tlong c = 2;\n\t\tif(cc < M - 1){\n\t\t\tc += cc;\n\t\t} else {\n\t\t\tc += M - 1 - (cc - (M - 1)) - 1;\n\t\t}\n\t\tConsole.WriteLine(\"{0} {1}\",r,c);\n\t\t\n\t}\n\t\n\tlong N,M,K;\n\tpublic Sol(){\n\t\tvar d = rla();\n\t\tN = d[0]; M = d[1]; K = d[2];\n\t}\n\n\tstatic String rs(){return Console.ReadLine();}\n\tstatic int ri(){return int.Parse(Console.ReadLine());}\n\tstatic long rl(){return long.Parse(Console.ReadLine());}\n\tstatic double rd(){return double.Parse(Console.ReadLine());}\n\tstatic String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}\n\tstatic int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}\n\tstatic long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}\n\tstatic double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}\n}\n", "lang_cluster": "C#", "tags": ["math", "implementation"], "code_uid": "947f12be81bcb2c3a95d1b937c593950", "src_uid": "e88bb7621c7124c54e75109a00f96301", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.IO;\n\nnamespace A\n{\n class Program\n {\n static char ConvertIndexToAnswer(int index)\n {\n switch (index)\n {\n case 0:\n return 'A';\n case 1:\n return 'B';\n case 2:\n return 'C';\n case 3:\n return 'D';\n default:\n throw new ArgumentException();\n }\n }\n\n static void Main(string[] args)\n {\n var answers = new List();\n var variants = new List();\n\n using(var input = Console.OpenStandardInput())\n using (var inputReader = new StreamReader(input))\n {\n answers.Add(inputReader.ReadLine().Substring(2));\n answers.Add(inputReader.ReadLine().Substring(2));\n answers.Add(inputReader.ReadLine().Substring(2));\n answers.Add(inputReader.ReadLine().Substring(2));\n }\n\n for (var i = 0; i < answers.Count; i++)\n {\n bool flag = true;\n for (var j = 0; j < answers.Count; j++)\n {\n if (i == j)\n continue;\n\n if (answers[j].Length/answers[i].Length < 2)\n flag = false;\n }\n\n if (flag)\n {\n variants.Add(i);\n }\n }\n\n for (var i = 0; i < answers.Count; i++)\n {\n bool flag = true;\n for (var j = 0; j < answers.Count; j++)\n {\n if (i == j)\n continue;\n\n if (answers[i].Length / answers[j].Length < 2)\n flag = false;\n }\n\n if (flag)\n {\n variants.Add(i);\n }\n }\n\n if (variants.Count == 1)\n {\n using (var output = Console.OpenStandardOutput())\n using (var outputWriter = new StreamWriter(output))\n {\n outputWriter.Write(ConvertIndexToAnswer(variants[0]));\n }\n }\n else\n {\n using (var output = Console.OpenStandardOutput())\n using (var outputWriter = new StreamWriter(output))\n {\n outputWriter.Write('C');\n }\n }\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "c695e0361311e7f9f1696715a38b1d6d", "src_uid": "30725e340dc07f552f0cce359af226a4", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace ConsoleApplication14\n{\n class Program\n {\n static void Main(string[] args)\n {\n string a1 = Console.ReadLine();\n string b1 = Console.ReadLine();\n string c1 = Console.ReadLine();\n string d1 = Console.ReadLine();\n int a = a1.Length - 2;\n int b = b1.Length - 2;\n int c = c1.Length - 2;\n int d = d1.Length - 2;\n int sum = 0;\n char otv='1';\n if (((a*2<=b) && (a*2<=c) && (a*2<=d)) || ((a>=b*2) && (a>=c*2) && (a>=d*2))) {sum++; otv='A';}\n if (((b*2 <= a) && (b*2 <= c) && (b*2 <= d)) || ((b >= a * 2) && (b >= c * 2) && (b >= d * 2))) { sum++; otv = 'B'; }\n if (((c*2 <= b) && (c*2 <= a) && (c*2 <= d)) || ((c >= b * 2) && (c >= a * 2) && (c >= d * 2))) { sum++; otv = 'C'; }\n if (((d*2 <= b) && (d*2 <= c) && (d*2 <= a)) || ((d >= b * 2) && (d >= c * 2) && (d >= a * 2))) { sum++; otv = 'D'; }\n if (sum == 1) { Console.WriteLine(otv); } else Console.WriteLine('C');\n } \n }\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "a1bb8861944059d4b86979ea492c0e87", "src_uid": "30725e340dc07f552f0cce359af226a4", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\n\nnamespace CodeForces\n{\n class R169_Div2_D \n {\n static void Main(string[] args)\n {\n string[] s = Console.ReadLine().Split();\n long l = long.Parse(s[0]);\n long r = long.Parse(s[1]);\n\n if (l == r)\n Console.WriteLine(0); // l ^ r\n else\n {\n long num = 0;\n for (int i = 62; i >= 0; i--)\n {\n long num1 = 1L << i;\n while (num + num1 > r) num1 /= 2;\n num += num1;\n if (num - 1 >= l) break;\n }\n\n // (num - 1 >= l)\n Console.WriteLine(num ^ (num - 1));\n }\n\n //Alternate way:\n //long num = 0;\n //for (int i = 62; i >= 0; i--)\n //{\n // long pow2 = 1L << i;\n // if ((l & pow2) == 0 && (r & pow2) == pow2)\n // {\n // num = pow2 * 2 - 1;\n // break;\n // }\n //}\n //Console.WriteLine(num);\n\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "dp", "bitmasks", "greedy", "implementation"], "code_uid": "5c413706b793131156a0e1cbd7b16edc", "src_uid": "d90e99d539b16590c17328d79a5921e0", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Linq;\n\nnamespace D {\n internal class Program {\n private static void Main() {\n var line = Console.ReadLine().Split(' ');\n ulong a = Convert.ToUInt64(line[0]);\n ulong b = Convert.ToUInt64(line[1]);\n\n\n var ab = new int[64];\n var bb = new int[64];\n\n for (int i = 0; i < 64; i++) {\n ulong ex = (ulong) 1 << i;\n if ((a & ex) == ex) {\n ab[i] = 1;\n }\n if ((b & ex) == ex) {\n bb[i] = 1;\n }\n }\n\n ab = ab.Reverse().ToArray();\n bb = bb.Reverse().ToArray();\n bool bot = false;\n\n for (int i = 0; i < 64; i++) {\n if (ab[i] == 0 && bb[i] == 1) {\n if (bot == false) {\n bot = true;\n continue;\n }\n }\n\n if (bot) {\n if (ab[i] == 0 && bb[i] == 0) {\n ab[i] = 1;\n continue;\n }\n if (ab[i] == 1 && bb[i] == 1) {\n bb[i] = 0;\n continue;\n }\n }\n }\n\n ulong ares = 0;\n ulong bres = 0;\n for (int i = 63; i >= 0; i--) {\n ulong ex = (ulong)1 << i;\n if (ab[63-i] == 1) {\n ares += ex;\n }\n if (bb[63-i] == 1) {\n bres += ex;\n }\n }\n\n Console.WriteLine(ares ^ bres);\n }\n }\n}", "lang_cluster": "C#", "tags": ["math", "dp", "bitmasks", "greedy", "implementation"], "code_uid": "b3f07d59545ed68246409855eb1de846", "src_uid": "d90e99d539b16590c17328d79a5921e0", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\n\nnamespace _678B\n{\n class Program\n {\n static void Main(string[] args)\n {\n int year = int.Parse(Console.ReadLine()), nextYear = year + 1;\n bool firstLeap = (year % 400 == 0) || (year % 4 == 0 && year % 100 != 0);\n int dayOfWeek = 0;\n for (;; nextYear++)\n {\n bool leap = (nextYear % 400 == 0) || (nextYear % 4 == 0 && nextYear % 100 != 0);\n dayOfWeek += leap ? 2 : 1;\n dayOfWeek %= 7;\n if (leap == firstLeap && dayOfWeek == 0)\n break;\n }\n Console.WriteLine(nextYear);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "99f2f87d7bfe7beef5869d1eb5fd8acb", "src_uid": "565bbd09f79eb7bfe2f2da46647af0f2", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Text.RegularExpressions;\n\nnamespace ConsoleApp2\n{\n class Program\n {\n public static bool L(int y)\n {\n if(y%400==0||(y%100!=0 && y%4==0))\n {\n return true;\n }\n return false;\n }\n static void Main(string[] args)\n {\n int y, day = 0,q=0;\n y=Int32.Parse(Console.ReadLine());\n q = y;\n while (q++>0)\n {\n if (L(q) == true)\n {\n day += 366;\n }\n else\n day +=+365;\n day %= 7;\n if(L(q)==L(y))\n {\n if(day==0)\n {\n Console.WriteLine(q);\n break;\n }\n }\n \n }\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "7b61dd8c0a0bf24b764750cfe0ad6051", "src_uid": "565bbd09f79eb7bfe2f2da46647af0f2", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": ".NET Core C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.IO;\nusing System.Linq;\nusing System.Runtime.CompilerServices;\nusing System.Numerics;\nusing System.Linq.Expressions;\nusing System.Threading;\nusing System.Security.Cryptography;\n\npublic static class Ex\n{\n public static bool IsNullOrEmpty(this string s) { return string.IsNullOrEmpty(s); }\n public static void yesno(this bool b) => Console.WriteLine(b ? \"yes\" : \"no\");\n public static void YesNo(this bool b) => Console.WriteLine(b ? \"Yes\" : \"No\");\n public static void YESNO(this bool b) => Console.WriteLine(b ? \"YES\" : \"NO\");\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static bool Chmax(ref this T a, T b) where T : struct, IComparable\n {\n if (b.CompareTo(a) > 0) { a = b; return true; }\n else return false;\n }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static bool Chmin(ref this T a, T b) where T : struct, IComparable\n {\n if (b.CompareTo(a) < 0) { a = b; return true; }\n else return false;\n }\n\n public static List FastSort(this List s) { s.Sort(StringComparer.OrdinalIgnoreCase); return s.ToList(); }\n\n public static int PopCount(this uint bits)\n {\n bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);\n bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);\n bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);\n bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);\n return (int)((bits & 0x0000ffff) + (bits >> 16 & 0x0000ffff));\n }\n}\n\n\n\npartial class Program\n{\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n string GetStr() { return Console.ReadLine().Trim(); }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n char GetChar() { return Console.ReadLine().Trim()[0]; }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n int GetInt() { return int.Parse(Console.ReadLine().Trim()); }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n long GetLong() { return long.Parse(Console.ReadLine().Trim()); }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n double GetDouble() { return double.Parse(Console.ReadLine().Trim()); }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n string[] GetStrArray() { return Console.ReadLine().Trim().Split(' '); }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n string[][] GetStrArray(int N)\n {\n var res = new string[N][];\n for (int i = 0; i < N; i++) res[i] = Console.ReadLine().Trim().Split(' ');\n return res;\n }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n int[] GetIntArray() { return Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray(); }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n int[][] GetIntArray(int N)\n {\n var res = new int[N][];\n for (int i = 0; i < N; i++) res[i] = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();\n return res;\n }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public long[] GetLongArray() { return Console.ReadLine().Trim().Split(' ').Select(long.Parse).ToArray(); }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n long[][] GetLongArray(int N)\n {\n var res = new long[N][];\n for (int i = 0; i < N; i++) res[i] = Console.ReadLine().Trim().Split(' ').Select(long.Parse).ToArray();\n return res;\n }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n char[] GetCharArray() { return Console.ReadLine().Trim().Split(' ').Select(char.Parse).ToArray(); }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n double[] GetDoubleArray() { return Console.ReadLine().Trim().Split(' ').Select(double.Parse).ToArray(); }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n double[][] GetDoubleArray(int N)\n {\n var res = new double[N][];\n for (int i = 0; i < N; i++) res[i] = Console.ReadLine().Trim().Split(' ').Select(double.Parse).ToArray();\n return res;\n }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n char[][] GetGrid(int H)\n {\n var res = new char[H][];\n for (int i = 0; i < H; i++) res[i] = Console.ReadLine().Trim().ToCharArray();\n return res;\n }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n T[] CreateArray(int N, T value)\n {\n var res = new T[N];\n for (int i = 0; i < N; i++) res[i] = value;\n return res;\n }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n T[][] CreateArray(int H, int W, T value)\n {\n var res = new T[H][];\n for (int i = 0; i < H; i++)\n {\n res[i] = new T[W];\n for (int j = 0; j < W; j++) res[i][j] = value;\n }\n return res;\n }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n T[][][] CreateArray(int H, int W, int R, T value)\n {\n var res = new T[H][][];\n for (int i = 0; i < H; i++)\n {\n res[i] = new T[W][];\n for (int j = 0; j < W; j++)\n {\n res[i][j] = new T[R];\n for (int k = 0; k < R; k++) res[i][j][k] = value;\n }\n }\n return res;\n }\n\n Dictionary> GetUnweightedAdjacencyList(int N, int M, bool isDirected, bool isNode_0indexed)\n {\n var dic = new Dictionary>();\n foreach (var e in Enumerable.Range(0, N)) { dic.Add(e, new List()); }\n for (int i = 0; i < M; i++)\n {\n var input = GetIntArray();\n var a = isNode_0indexed ? input[0] : input[0] - 1;\n var b = isNode_0indexed ? input[1] : input[1] - 1;\n dic[a].Add(b);\n if (isDirected == false) dic[b].Add(a);\n }\n return dic;\n }\n Dictionary> GetWeightedAdjacencyList(int N, int M, bool isDirected, bool isNode_0indexed)\n {\n var dic = new Dictionary>();\n foreach (var e in Enumerable.Range(0, N)) { dic.Add(e, new List<(int, long)>()); }\n for (int i = 0; i < M; i++)\n {\n var input = GetIntArray();\n var a = isNode_0indexed ? input[0] : input[0] - 1;\n var b = isNode_0indexed ? input[1] : input[1] - 1;\n var c = input[2];\n dic[a].Add((b, c));\n if (isDirected == false) dic[b].Add((a, c));\n }\n return dic;\n }\n\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n bool eq() => typeof(T).Equals(typeof(U));\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n T ct(U a) => (T)Convert.ChangeType(a, typeof(T));\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n T cv(string s) => eq() ? ct(int.Parse(s))\n : eq() ? ct(long.Parse(s))\n : eq() ? ct(double.Parse(s))\n : eq() ? ct(s[0])\n : ct(s);\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n void Multi(out T a) => a = cv(GetStr());\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n void Multi(out T a, out U b)\n {\n var ar = GetStrArray(); a = cv(ar[0]); b = cv(ar[1]);\n }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n void Multi(out T a, out U b, out V c)\n {\n var ar = GetStrArray(); a = cv(ar[0]); b = cv(ar[1]); c = cv(ar[2]);\n }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n void Multi(out T a, out U b, out V c, out W d)\n {\n var ar = GetStrArray(); a = cv(ar[0]); b = cv(ar[1]); c = cv(ar[2]); d = cv(ar[3]);\n }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n void Multi(out T a, out U b, out V c, out W d, out X e)\n {\n var ar = GetStrArray(); a = cv(ar[0]); b = cv(ar[1]); c = cv(ar[2]); d = cv(ar[3]); e = cv(ar[4]);\n }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n void Multi(out T a, out U b, out V c, out W d, out X e, out Y f)\n {\n var ar = GetStrArray(); a = cv(ar[0]); b = cv(ar[1]); c = cv(ar[2]); d = cv(ar[3]); e = cv(ar[4]); f = cv(ar[5]);\n }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n void Output(T t) => Console.WriteLine(t);\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n void Output(IList ls) => Console.WriteLine(string.Join(\" \", ls));\n void Debug(IList> ls)\n {\n foreach (var l in ls)\n foreach (var s in l)\n Console.WriteLine(s);\n }\n\n\n void Swap(ref T a, ref T b) { T temp = a; a = b; b = temp; }\n\n int[] dx = new int[] { 1, 0, -1, 0, 1, -1, -1, 1 };\n int[] dy = new int[] { 0, 1, 0, -1, 1, 1, -1, -1 };\n long mod = 1000000007;\n}\n\n\n\n\n\n\npartial class Program\n{\n static void Main()\n {\n Console.SetIn(new StreamReader(Console.OpenStandardInput(8192)));\n Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });\n new Program().Solve();\n Console.Out.Flush();\n Console.Read();\n }\n\n public void Solve()\n {\n int n, x, pos;\n Multi(out n, out x, out pos);\n var small = x - 1;\n var big = n - x;\n\n int a = 0, b = 0;\n int left = 0;\n int right = n;\n while (left < right)\n {\n int middle = (left + right) / 2;\n if (middle <= pos)\n {\n b++;\n left = middle + 1;\n }\n else\n {\n a++;\n right = middle;\n }\n }\n var mc = new ModCombination(mod);\n long sum = 1;\n sum = sum * mc.Combination(small, b-1) % mod * mc.Combination(big, a) % mod;\n for (int i = 1; i <= n-a-b; i++)\n {\n sum = sum * i % mod;\n }\n for(int i = 1; i <= a; i++)\n {\n sum = sum * i % mod;\n }\n for(int i = 1; i <= b - 1; i++)\n {\n sum = sum * i % mod;\n }\n Output(sum);\n }\n\n public void SubSolve()\n {\n }\n\n class ModCombination\n {\n long mod;\n static int max = 1000000;\n\n long[] fac = new long[max];\n long[] finv = new long[max];\n long[] inv = new long[max];\n\n /// \n /// fac,finv,inv\u306e\u4e8b\u524d\u8a08\u7b97\n /// n\n public ModCombination(long mod)\n {\n this.mod = mod;\n fac[0] = fac[1] = 1;\n finv[0] = finv[1] = 1;\n inv[1] = 1;\n for (int i = 2; i < max; i++)\n {\n fac[i] = fac[i - 1] * i % mod;\n inv[i] = mod - inv[mod % i] * (mod / i) % mod;\n finv[i] = finv[i - 1] * inv[i] % mod;\n }\n }\n\n /// \n /// O(1)\n /// \n public long Combination(int n, int m)\n {\n if (n < m) return 0;\n if (n < 0 || m < 0) return 0;\n return fac[n] * (finv[m] * finv[n - m] % mod) % mod;\n }\n }\n}", "lang_cluster": "C#", "tags": ["binary search", "combinatorics"], "code_uid": "5680a3416ba0eeaa400a41ab58cd39e2", "src_uid": "24e2f10463f440affccc2755f4462d8a", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing static System.Console;\nusing static System.Math;\n\nnamespace AtTest.CodeForces._1436\n{\n class C\n {\n static void Main(string[] args)\n {\n var sw = new System.IO.StreamWriter(OpenStandardOutput()) { AutoFlush = false };\n SetOut(sw);\n\n Method(args);\n\n Out.Flush();\n }\n\n static void Method(string[] args)\n {\n int[] nxp = ReadInts();\n int n = nxp[0];\n int x = nxp[1];\n int p = nxp[2];\n\n int bottom = 0;\n int top = n;\n int upperCnt = 0;\n int lowerCnt = 0;\n while (bottom < top)\n {\n int mid = (bottom + top) / 2;\n if (mid <= p)\n {\n bottom = mid + 1;\n if (mid < p)\n {\n lowerCnt++;\n }\n }\n else\n {\n top = mid;\n upperCnt++;\n }\n }\n\n \n long mask = 1000000000 + 7;\n var calculator = new CaseCalculator(mask, n);\n int lowers = x - 1;\n int uppers = n - x;\n long res = calculator.Permutation(lowers, lowerCnt);\n res *= calculator.Permutation(uppers, upperCnt);\n res %= mask;\n res *= calculator.Permutation(n -1- lowerCnt - upperCnt, n -1- lowerCnt - upperCnt);\n res %= mask;\n WriteLine(res);\n }\n\n class CaseCalculator\n {\n long mask;\n long[] allPermutations;\n long[] allInverses;\n\n public CaseCalculator(long mask, long permutationCnt)\n {\n this.mask = mask;\n allPermutations = AllPermutations(permutationCnt);\n allInverses = AllInverses(permutationCnt);\n }\n\n public long Combination(long n, long m)\n {\n if (n < m) return 0;\n\n if (n - m < m) m = n - m;\n\n return Multi(allPermutations[n], allInverses[n - m], allInverses[m]);\n }\n\n public long Permutation(long n, long m)\n {\n if (n < m) return 0;\n\n return Multi(allPermutations[n], allInverses[n - m]);\n }\n\n long[] AllPermutations(long n)\n {\n var perms = new long[n + 1];\n perms[0] = 1;\n for (int i = 1; i <= n; i++)\n {\n perms[i] = Multi(perms[i - 1], i);\n }\n return perms;\n }\n\n long[] AllInverses(long n)\n {\n var inverses = new long[n + 1];\n inverses[1] = 1;\n var permInverses = new long[n + 1];\n permInverses[0] = 1;\n permInverses[1] = 1;\n for (int i = 2; i <= n; i++)\n {\n inverses[i] = mask - inverses[mask % i] * (mask / i) % mask;\n permInverses[i] = Multi(permInverses[i - 1], inverses[i]);\n }\n return permInverses;\n }\n\n public long Multi(params long[] vals)\n {\n if (vals.Length == 0)\n {\n return 0;\n }\n\n long val = vals[0] % mask;\n for (int i = 1; i < vals.Length; i++)\n {\n val *= (vals[i] % mask);\n val %= mask;\n }\n return val;\n }\n\n public long Inverse(long val)\n {\n long a = mask;\n long b = val % mask;\n long x = 1;\n long x1 = 0;\n long y = 0;\n long y1 = 1;\n while (b > 0)\n {\n long q = a / b;\n long r = a % b;\n long x2 = (mask + x - (q * x1) % mask) % mask;\n long y2 = (mask + y - (q * y1) % mask) % mask;\n a = b;\n b = r;\n x = x1;\n x1 = x2;\n y = y1;\n y1 = y2;\n }\n return y;\n }\n\n long DeprecatedInverse(long val)\n {\n return Pow(val, mask - 2);\n }\n\n long Pow(long a, long exp)\n {\n if (exp == 0) return 1;\n else if (exp == 1) return a % mask;\n else\n {\n long halfMod = Pow(a, exp / 2);\n long nextMod = Multi(halfMod, halfMod);\n if (exp % 2 == 0)\n {\n return nextMod;\n }\n else\n {\n return Multi(nextMod, a);\n }\n }\n }\n }\n\n private static string Read() { return ReadLine(); }\n private static char[] ReadChars() { return Array.ConvertAll(Read().Split(), a => a[0]); }\n private static int ReadInt() { return int.Parse(Read()); }\n private static long ReadLong() { return long.Parse(Read()); }\n private static double ReadDouble() { return double.Parse(Read()); }\n private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }\n private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }\n private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }\n }\n}\n", "lang_cluster": "C#", "tags": ["binary search", "combinatorics"], "code_uid": "6331258ea29f94da7d481de34edbefc9", "src_uid": "24e2f10463f440affccc2755f4462d8a", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.IO;\nusing System.Linq;\nusing System.Text;\nusing System.Text.RegularExpressions;\nusing System.Threading.Tasks;\n\nnamespace TestProject\n{\n\tclass Program\n\t{\n\t\tstatic void Main(string[] args)\n\t\t{\n\t\t\tString input = null;\n\t\t\tString output = null;\n#if LOCALTEST\n\t\t\tinput = \"../../in.txt\";\n\t\t\toutput = \"../../out.txt\";\n#endif\n\t\t\tFastReader reader = new FastReader(input);\n\t\t\tFastWriter writer = new FastWriter(output);\n\n\t\t\tint n, m, current, previous, tu, tv;\n\t\t\tn = reader.nextInt();\n\t\t\tm = reader.nextInt();\n\t\t\tStringBuilder[] a = new StringBuilder[2];\n\t\t\ta[1] = new StringBuilder(new String('.', m));\n\n\t\t\tint[] di = { 0, 1, 0 };\n\t\t\tint[] dj = { 1, 0, -1 };\n\t\t\tint result = 0;\n\t\t\tfor (int i = 0; i < n; ++i)\n\t\t\t{\n\t\t\t\tcurrent = i % 2;\n\t\t\t\tprevious = (i + 1) % 2;\n\n\t\t\t\ta[current] = new StringBuilder(reader.next());\n\t\t\t\tfor (int u = 0; u < 2; ++u)\n\t\t\t\t{\n\t\t\t\t\tfor (int v = 0; v < m; ++v)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (a[u][v] == 'P')\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tfor (int k = 0; k < di.Length; ++k)\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\ttu = (u + di[k]) % 2;\n\t\t\t\t\t\t\t\ttv = (v + dj[k]);\n\t\t\t\t\t\t\t\tif (0 <= tv && tv < m && a[tu][tv] == 'W')\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t++result;\n\t\t\t\t\t\t\t\t\ta[u][v] = '.';\n\t\t\t\t\t\t\t\t\ta[tu][tv] = '.';\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\ta[previous] = a[current];\n\t\t\t}\n\t\t\twriter.Write(result);\n\t\t\t//flush \n\t\t\twriter.Close();\n\t\t}\n\t}\n\n\tclass FastReader\n\t{\n\t\tprivate TextReader reader = null;\n\t\tprivate Queue q = null;\n\n\t\tpublic FastReader(String fileName)\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (fileName != null)\n\t\t\t\t{\n\t\t\t\t\treader = new StreamReader(fileName);\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\treader = System.Console.In;\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (FileNotFoundException e)\n\t\t\t{\n\t\t\t\tthrow e;\n\t\t\t}\n\t\t}\n\n\t\tpublic FastReader()\n\t\t{\n\t\t\treader = System.Console.In;\n\t\t}\n\n\t\tpublic String next() {\n\t\t\twhile (q == null || q.Count == 0)\n\t\t\t{\t\n\t\t\t\tq = new Queue(reader.ReadLine().Split());\n\t\t\t}\n\t\t\treturn q.Dequeue();\n\t\t}\n\n\t\tpublic int nextInt()\n\t\t{\n\t\t\treturn Int32.Parse(next());\n\t\t}\n\n\t\tpublic long nextLong()\n\t\t{\n\t\t\treturn Int64.Parse(next());\n\t\t}\n\n\t\tpublic double nextDouble()\n\t\t{\n\t\t\treturn Double.Parse(next());\n\t\t}\n\t}\n\n\tclass FastWriter\n\t{\n\t\tprivate TextWriter writer = null;\n\n\t\tpublic FastWriter (String fileName ) \n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (fileName != null)\n\t\t\t\t{\n\t\t\t\t\twriter = new StreamWriter(fileName);\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\twriter = System.Console.Out;\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (FileNotFoundException e)\n\t\t\t{\n\t\t\t\tthrow e;\n\t\t\t}\n\t\t}\n\n\t\tpublic FastWriter()\n\t\t{\n\t\t\twriter = System.Console.Out;\n\t\t}\n\n\t\tpublic void Write(params object[] parameters)\n\t\t{\n\t\t\tforeach (object o in parameters)\n\t\t\t{\n\t\t\t\twriter.Write(o.ToString());\n\t\t\t}\n\t\t}\n\n\t\tpublic void WriteLine(params object[] parameters)\n\t\t{\n\t\t\tforeach (object o in parameters)\n\t\t\t{\n\t\t\t\twriter.Write(o.ToString());\n\t\t\t}\n\t\t\twriter.WriteLine();\n\t\t}\n\n\t\tpublic void Close()\n\t\t{\n\t\t\twriter.Close();\n\t\t}\n\t}\n\n}\n", "lang_cluster": "C#", "tags": ["greedy", "implementation"], "code_uid": "f7bdc9a0224e370b21b009f72962d7b8", "src_uid": "969b24ed98d916184821b2b2f8fd3aac", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading;\nusing System.Globalization;\n\nnamespace Codeforces\n{\n class Program\n { \n static int ReadInt()\n {\n return Int32.Parse(Console.ReadLine());\n }\n static long ReadLong()\n {\n return long.Parse(Console.ReadLine());\n }\n static void ReadIntArray(out int[] array, char separator = ' ')\n {\n var input = Console.ReadLine().Split(separator);\n array = new int[input.Length];\n for (int i = 0; i < input.Length; i++)\n {\n array[i] = Int32.Parse(input[i]);\n }\n\n }\n static int ReadNextInt(string input, int index)\n {\n var ints = input.Split(' ');\n return Int32.Parse(ints[index]);\n }\n\n static void Main()\n {\n int res = 0;\n var input = Console.ReadLine();\n var n = ReadNextInt(input, 0);\n var m = ReadNextInt(input, 1);\n string[] table = new string[n];\n for (int i = 0; i < n; i++)\n {\n table[i] = Console.ReadLine();\n }\n for (int i = 0; i < n; i++)\n {\n for (int j = 0; j < m; j++)\n {\n if(table[i][j] == 'W')\n {\n if ((i > 0 && table[i - 1][j] == 'P')\n || (i < n - 1 && table[i + 1][j] == 'P')\n || (j > 0 && table[i][j - 1] == 'P')\n || (j < m - 1 && table[i][j + 1] == 'P'))\n res++;\n }\n }\n }\n Console.WriteLine(res);\n }\n }\n}", "lang_cluster": "C#", "tags": ["greedy", "implementation"], "code_uid": "e80a7903eb6a4831e79d02d67ef487c4", "src_uid": "969b24ed98d916184821b2b2f8fd3aac", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\n\nclass TEST{\n\tstatic void Main(){\n\t\tSol mySol =new Sol();\n\t\tmySol.Solve();\n\t}\n}\n\nclass Sol{\n\tpublic void Solve(){\n\t\t\n\t\tbool chk = false;\n\t\tfor(int i=0;i<4;i++){\n\t\t\tif(A[i][3] == 0) continue;\n\t\t\tif(A[i][0] == 1 || A[i][1] == 1 || A[i][2] == 1) chk = true;\n\t\t\tif(A[(i+1)%4][0] == 1) chk = true;\n\t\t\tif(A[(i+2)%4][1] == 1) chk = true;\n\t\t\tif(A[(i+3)%4][2] == 1) chk = true;\n\t\t}\n\t\t\n\t\tConsole.WriteLine(chk ? \"YES\" : \"NO\");\n\t\t\n\t\t\n\t}\n\tint[][] A;\n\tpublic Sol(){\n\t\tA = new int[4][];\n\t\tfor(int i=0;i<4;i++) A[i] = ria();\n\t}\n\n\tstatic String rs(){return Console.ReadLine();}\n\tstatic int ri(){return int.Parse(Console.ReadLine());}\n\tstatic long rl(){return long.Parse(Console.ReadLine());}\n\tstatic double rd(){return double.Parse(Console.ReadLine());}\n\tstatic String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}\n\tstatic int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}\n\tstatic long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}\n\tstatic double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "63294d38740aaedf9c39cd67e055a8f5", "src_uid": "44fdf71d56bef949ec83f00d17c29127", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace Codeforces\n{\n class Program\n {\n public static void Main(string[] args)\n {\n var first = Console.ReadLine().Split(' ').Select(x => Convert.ToBoolean(Convert.ToInt16(x))).ToArray();\n var second = Console.ReadLine().Split(' ').Select(x => Convert.ToBoolean(Convert.ToInt16(x))).ToArray();\n var third = Console.ReadLine().Split(' ').Select(x => Convert.ToBoolean(Convert.ToInt16(x))).ToArray();\n var fourth = Console.ReadLine().Split(' ').Select(x => Convert.ToBoolean(Convert.ToInt16(x))).ToArray();\n if (first[3] && first.Take(3).Any(x => x))\n {\n Console.WriteLine(\"YES\");\n return;\n }\n if (second[3] && second.Take(3).Any(x => x))\n {\n Console.WriteLine(\"YES\");\n return;\n }\n if (third[3]&& third.Take(3).Any(x => x))\n {\n Console.WriteLine(\"YES\");\n return;\n }\n if (fourth[3] && fourth.Take(3).Any(x => x))\n {\n Console.WriteLine(\"YES\");\n return;\n }\n if (first[0] && fourth[3] || first[1] && third[3] || first[2] && second[3] || \n second[0] && first[3] || second[1] && fourth[3] || second[2] && third[3] ||\n third[0] && second[3] || third[1] && first[3] || third[2] && fourth[3] || \n fourth[0] && third[3] || fourth[1] && second[3] || fourth[2] && first[3])\n {\n Console.WriteLine(\"YES\");\n return;\n }\n Console.WriteLine(\"NO\");\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "0e5ae9bd112dc24d119919979481a199", "src_uid": "44fdf71d56bef949ec83f00d17c29127", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Globalization;\nusing System.IO;\nusing System.Linq;\nusing System.Text;\n\nclass Program\n{\n private static void Main(string[] args)\n {\n SolveA();\n }\n\n private static void SolveA()\n {\n long n = RL();\n var ans = (n - 1) / 2;\n Console.WriteLine(ans);\n\n }\n\n private const int Mod = 1000000000 + 7;\n\n #region Data Read\n\n private static long GCD(long a, long b)\n {\n if (a % b == 0) return b;\n return GCD(b, a % b);\n }\n\n private static List[] ReadGraph(int n, int m)\n {\n List[] g = new List[n];\n for (int i = 0; i < g.Length; i++) g[i] = new List();\n for (int i = 0; i < m; i++)\n {\n int a = RI() - 1;\n int b = RI() - 1;\n\n g[a].Add(b);\n g[b].Add(a);\n }\n\n return g;\n }\n\n private static int[,] ReadGraphAsMatrix(int n, int m)\n {\n int[,] matrix = new int[n + 1, n + 1];\n for (int i = 0; i < m; i++)\n {\n int a = RI();\n int b = RI();\n matrix[a, b] = matrix[b, a] = 1;\n }\n\n return matrix;\n }\n\n private static void Sort(ref int a, ref int b)\n {\n if (a > b) Swap(ref a, ref b);\n }\n\n private static void Swap(ref int a, ref int b)\n {\n int tmp = a;\n a = b;\n b = tmp;\n }\n\n private const int BufferSize = 1 << 16;\n private static StreamReader consoleReader;\n private static MemoryStream testData;\n\n private static int RI()\n {\n int ans = 0;\n int mul = 1;\n do\n {\n ans = consoleReader.Read();\n if (ans == -1)\n return 0;\n if (ans == '-') mul = -1;\n } while (ans < '0' || ans > '9');\n\n ans -= '0';\n while (true)\n {\n int chr = consoleReader.Read();\n if (chr < '0' || chr > '9')\n return ans * mul;\n ans = ans * 10 + chr - '0';\n }\n }\n\n private static ulong RUL()\n {\n ulong ans = 0;\n int chr;\n do\n {\n chr = consoleReader.Read();\n if (chr == -1)\n return 0;\n } while (chr < '0' || chr > '9');\n\n ans = (uint)(chr - '0');\n while (true)\n {\n chr = consoleReader.Read();\n if (chr < '0' || chr > '9')\n return ans;\n ans = ans * 10 + (uint)(chr - '0');\n }\n }\n\n private static long RL()\n {\n long ans = 0;\n int mul = 1;\n do\n {\n ans = consoleReader.Read();\n if (ans == -1)\n return 0;\n if (ans == '-') mul = -1;\n } while (ans < '0' || ans > '9');\n\n ans -= '0';\n while (true)\n {\n int chr = consoleReader.Read();\n if (chr < '0' || chr > '9')\n return ans * mul;\n ans = ans * 10 + chr - '0';\n }\n }\n\n private static int[] RIA(int n)\n {\n int[] ans = new int[n];\n for (int i = 0; i < n; i++)\n ans[i] = RI();\n return ans;\n }\n\n private static long[] RLA(int n)\n {\n long[] ans = new long[n];\n for (int i = 0; i < n; i++)\n ans[i] = RL();\n return ans;\n }\n\n private static char[] ReadWord()\n {\n int ans;\n\n do\n {\n ans = consoleReader.Read();\n } while (!((ans >= 'a' && ans <= 'z') || (ans >= 'A' && ans <= 'Z')));\n\n List s = new List();\n do\n {\n s.Add((char)ans);\n ans = consoleReader.Read();\n } while ((ans >= 'a' && ans <= 'z') || (ans >= 'A' && ans <= 'Z'));\n\n return s.ToArray();\n }\n\n private static char[] ReadString(int n)\n {\n int ans;\n\n do\n {\n ans = consoleReader.Read();\n } while (!((ans >= 'a' && ans <= 'z') || (ans >= 'A' && ans <= 'Z')));\n\n char[] s = new char[n];\n int pos = 0;\n do\n {\n s[pos++] = (char)ans;\n if (pos == n) break;\n ans = consoleReader.Read();\n } while ((ans >= 'a' && ans <= 'z') || (ans >= 'A' && ans <= 'Z'));\n\n return s;\n }\n\n private static char[] ReadStringLine()\n {\n int ans;\n\n do\n {\n ans = consoleReader.Read();\n } while (ans == 10 || ans == 13);\n\n List s = new List();\n\n do\n {\n s.Add((char)ans);\n ans = consoleReader.Read();\n } while (ans != 10 && ans != 13 && ans != -1);\n\n return s.ToArray();\n }\n\n private static char ReadLetter()\n {\n while (true)\n {\n int ans = consoleReader.Read();\n if ((ans >= 'a' && ans <= 'z') || (ans >= 'A' && ans <= 'Z'))\n return (char)ans;\n }\n }\n private static char ReadNonLetter()\n {\n while (true)\n {\n int ans = consoleReader.Read();\n if (!((ans >= 'a' && ans <= 'z') || (ans >= 'A' && ans <= 'Z')))\n return (char)ans;\n }\n }\n\n private static char ReadAnyOf(IEnumerable allowed)\n {\n while (true)\n {\n char ans = (char)consoleReader.Read();\n if (allowed.Contains(ans))\n return ans;\n }\n }\n\n private static char ReadDigit()\n {\n while (true)\n {\n int ans = consoleReader.Read();\n if (ans >= '0' && ans <= '9')\n return (char)ans;\n }\n }\n\n private static int ReadDigitInt()\n {\n return ReadDigit() - (int)'0';\n }\n\n private static char ReadAnyChar()\n {\n return (char)consoleReader.Read();\n }\n\n private static string DoubleToString(double x)\n {\n return x.ToString(CultureInfo.InvariantCulture);\n }\n\n private static double DoubleFromString(string x)\n {\n return double.Parse(x, CultureInfo.InvariantCulture);\n }\n\n static Program()\n {\n //Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;\n consoleReader = new StreamReader(Console.OpenStandardInput(BufferSize), Encoding.ASCII, false, BufferSize);\n }\n\n private static void PushTestData(StringBuilder sb)\n {\n PushTestData(sb.ToString());\n }\n private static void PushTestData(string data)\n {\n#if TOLYAN_TEST\n if (testData == null)\n {\n testData = new MemoryStream();\n consoleReader = new StreamReader(testData);\n }\n\n var pos = testData.Position;\n var bytes = Encoding.UTF8.GetBytes(data);\n testData.Write(bytes, 0, bytes.Length);\n testData.Flush();\n testData.Position = pos;\n#endif\n }\n #endregion\n}", "lang_cluster": "C#", "tags": ["math", "greedy", "constructive algorithms"], "code_uid": "2c74999638417ef7215d5db8f39d8984", "src_uid": "dfe9446431325c73e88b58ba204d0e47", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections;\nusing System.Collections.Generic;\nusing System.Diagnostics;\nusing System.IO;\nusing System.Linq;\nusing System.Numerics;\nusing System.Text;\nusing System.Text.RegularExpressions;\nusing System.Threading.Tasks;\nusing static System.Math;\n\npublic static class P\n{\n public static void Main()\n {\n int n = int.Parse(Console.ReadLine());\n Console.WriteLine(n / 2 - 1 + n % 2);\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "greedy", "constructive algorithms"], "code_uid": "7209704e935fdfaafa98875f74466cc8", "src_uid": "dfe9446431325c73e88b58ba204d0e47", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\n\nnamespace Text_Document_Analysis {\n class Program {\n static void Main(string[] args) {\n Console.ReadLine();\n int pCount = 0;\n int maxLen = 0;\n int len = 0;\n bool p = false;\n foreach (char c in Console.ReadLine()) {\n if (c != '_' && c != '(' && c != ')') {\n len++;\n } else if (len != 0) {\n if (p) { //in parentheses\n len = 0;\n pCount++;\n } else {\n maxLen = Math.Max(len, maxLen);\n len = 0;\n }\n }\n if (c == '(' || c == ')') {\n p = !p;\n }\n }\n if (len != 0) {\n if (p) { //in parentheses\n len = 0;\n pCount++;\n } else {\n maxLen = Math.Max(len, maxLen);\n len = 0;\n }\n }\n Console.Write(maxLen + \" \" + pCount);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["expression parsing", "strings", "implementation"], "code_uid": "6f2b208df5db6793659655f4c123f4ed", "src_uid": "fc86df4931e787fa3a1a40e2aecf0b92", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Globalization;\nusing System.IO;\nusing System.Linq;\nusing System.Text;\nusing System.Threading;\n\n// (\u3065\u00b0\u03c9\u00b0)\u3065\uff90e\u2605\u309c\u30fb\u3002\u3002\u30fb\u309c\u309c\u30fb\u3002\u3002\u30fb\u309c\u2606\u309c\u30fb\u3002\u3002\u30fb\u309c\u309c\u30fb\u3002\u3002\u30fb\u309c\npublic class Solver\n{\n public void Solve()\n {\n ReadInt();\n int ans1 = 0, ans2 = 0, len = 0;\n bool f = false;\n foreach (char c in ReadToken())\n {\n if (char.IsLetter(c))\n {\n len++;\n if (!f)\n ans1 = Math.Max(ans1, len);\n }\n else\n {\n if (len > 0 && f)\n ans2++;\n len = 0;\n if (c == '(' || c == ')')\n f = !f;\n }\n }\n\n Write(ans1, ans2);\n }\n\n #region Main\n\n protected static TextReader reader;\n protected static TextWriter writer;\n static void Main()\n {\n#if DEBUG\n reader = new StreamReader(\"..\\\\..\\\\input.txt\");\n //reader = new StreamReader(Console.OpenStandardInput());\n writer = Console.Out;\n //writer = new StreamWriter(\"..\\\\..\\\\output.txt\");\n#else\n reader = new StreamReader(Console.OpenStandardInput());\n writer = new StreamWriter(Console.OpenStandardOutput());\n //reader = new StreamReader(\"input.txt\");\n //writer = new StreamWriter(\"output.txt\");\n#endif\n try\n {\n new Solver().Solve();\n //var thread = new Thread(new Solver().Solve, 1024 * 1024 * 128);\n //thread.Start();\n //thread.Join();\n }\n catch (Exception ex)\n {\n#if DEBUG\n Console.WriteLine(ex);\n#else\n throw;\n#endif\n }\n reader.Close();\n writer.Close();\n }\n\n #endregion\n\n #region Read / Write\n private static Queue currentLineTokens = new Queue();\n private static string[] ReadAndSplitLine() { return reader.ReadLine().Split(new[] { ' ', '\\t', }, StringSplitOptions.RemoveEmptyEntries); }\n public static string ReadToken() { while (currentLineTokens.Count == 0)currentLineTokens = new Queue(ReadAndSplitLine()); return currentLineTokens.Dequeue(); }\n public static int ReadInt() { return int.Parse(ReadToken()); }\n public static long ReadLong() { return long.Parse(ReadToken()); }\n public static double ReadDouble() { return double.Parse(ReadToken(), CultureInfo.InvariantCulture); }\n public static int[] ReadIntArray() { return ReadAndSplitLine().Select(int.Parse).ToArray(); }\n public static long[] ReadLongArray() { return ReadAndSplitLine().Select(long.Parse).ToArray(); }\n public static double[] ReadDoubleArray() { return ReadAndSplitLine().Select(s => double.Parse(s, CultureInfo.InvariantCulture)).ToArray(); }\n public static int[][] ReadIntMatrix(int numberOfRows) { int[][] matrix = new int[numberOfRows][]; for (int i = 0; i < numberOfRows; i++)matrix[i] = ReadIntArray(); return matrix; }\n public static int[][] ReadAndTransposeIntMatrix(int numberOfRows)\n {\n int[][] matrix = ReadIntMatrix(numberOfRows); int[][] ret = new int[matrix[0].Length][];\n for (int i = 0; i < ret.Length; i++) { ret[i] = new int[numberOfRows]; for (int j = 0; j < numberOfRows; j++)ret[i][j] = matrix[j][i]; } return ret;\n }\n public static string[] ReadLines(int quantity) { string[] lines = new string[quantity]; for (int i = 0; i < quantity; i++)lines[i] = reader.ReadLine().Trim(); return lines; }\n public static void WriteArray(IEnumerable array) { writer.WriteLine(string.Join(\" \", array)); }\n public static void Write(params object[] array) { WriteArray(array); }\n public static void WriteLines(IEnumerable array) { foreach (var a in array)writer.WriteLine(a); }\n private class SDictionary : Dictionary\n {\n public new TValue this[TKey key]\n {\n get { return ContainsKey(key) ? base[key] : default(TValue); }\n set { base[key] = value; }\n }\n }\n private static T[] Init(int size) where T : new() { var ret = new T[size]; for (int i = 0; i < size; i++)ret[i] = new T(); return ret; }\n #endregion\n}", "lang_cluster": "C#", "tags": ["expression parsing", "strings", "implementation"], "code_uid": "dddea8cdee542c70f6d9a66707a92f17", "src_uid": "fc86df4931e787fa3a1a40e2aecf0b92", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace test2\n{\n class Program\n {\n static void Main(string[] args)\n {\n int num = Convert.ToInt32(Console.ReadLine());\n string valueStr = Console.ReadLine();\n Test(valueStr, num);\n }\n public static void Test(string valueStr, int num)\n {\n List num1 = new List();\n List num2 = new List();\n int indexOf = 0;\n string MidStr = \"\";\n do\n {\n int indexTwo = valueStr.IndexOf('(', indexOf);\n if (indexTwo == -1)\n {\n indexTwo = num;\n }\n MidStr = valueStr.Substring(indexOf, indexTwo - indexOf);\n int indexThree = MidStr.IndexOf(')', 0);\n\n if (indexThree != -1)\n {\n string MidStr2 = MidStr.Substring(0, indexThree);\n insertNum(num2, MidStr2);\n //indexOf = indexTwo + 1;\n MidStr = MidStr.Substring(indexThree + 1);\n }\n insertNum(num1, MidStr);\n indexOf = indexTwo + 1;\n if (indexOf >= num)\n {\n break;\n }\n } while (true);\n int[] nums = num1.ToArray();\n Array.Sort(nums);\n int num3 = 0;\n if (num1.Count != 0)\n {\n num3 = nums[num1.Count - 1];\n }\n Console.WriteLine(\"{0} {1}\", num3, num2.Count);\n }\n public static void insertNum(List num, string MidStr)\n {\n string[] value = MidStr.Split(new[] { '_' }, StringSplitOptions.RemoveEmptyEntries);\n foreach (var item in value)\n {\n num.Add(item.Length);\n }\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["expression parsing", "strings", "implementation"], "code_uid": "be88de970bf5263b0cf06f72c3114dad", "src_uid": "fc86df4931e787fa3a1a40e2aecf0b92", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace Task\n{\n class Program\n {\n static void Main(string[] args)\n {\n int n = int.Parse(Console.ReadLine());\n string input = Console.ReadLine();\n bool braces = false;\n int word = 0;\n int maxLength = 0;\n int count = 0;\n for (int i = 0; i < n; ++i)\n {\n if (input[i] == '_' && word != 0)\n {\n //Console.WriteLine($\"{i} {braces} {word} {maxLength} {count}\");\n if (braces)\n ++count;\n else if (maxLength < word)\n maxLength = word;\n word = 0;\n }\n else if (input[i] == '(')\n {\n //Console.WriteLine($\"{i} {braces} {word} {maxLength} {count}\");\n if (word != 0 && maxLength < word)\n maxLength = word;\n word = 0;\n braces = true;\n }\n else if (input[i] == ')')\n {\n //Console.WriteLine($\"{i} {braces} {word} {maxLength} {count}\");\n if (word != 0)\n ++count;\n word = 0;\n braces = false;\n }\n else if (input[i] != '_')\n {\n //Console.WriteLine($\"{i} {braces} {word} {maxLength} {count}\");\n ++word;\n if (i == n - 1 && word > maxLength)\n maxLength = word;\n } \n }\n Console.WriteLine($\"{maxLength} {count}\");\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["expression parsing", "strings", "implementation"], "code_uid": "07fdbe151b06d8120e861facfc7cfe28", "src_uid": "fc86df4931e787fa3a1a40e2aecf0b92", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Globalization;\nusing System.IO;\nusing System.Linq;\n\nnamespace CF317\n{\n\tinternal class Program\n\t{\n\t\tprivate static void Main(string[] args)\n\t\t{\n\t\t\tvar sr = new InputReader(Console.In);\n\t\t\t//var sr = new InputReader(new StreamReader(\"input.txt\"));\n\t\t\tvar task = new Task();\n\t\t\tusing (var sw = Console.Out)\n\t\t\t\t//using (var sw = new StreamWriter(\"output.txt\"))\n\t\t\t{\n\t\t\t\ttask.Solve(sr, sw);\n\t\t\t\t//Console.ReadKey();\n\t\t\t}\n\t\t}\n\t}\n\n\tinternal class Task\n\t{\n\t\tpublic void Solve(InputReader sr, TextWriter sw)\n\t\t{\n\t\t\tvar n = sr.NextInt32();\n\t\t\tvar str = sr.NextString();\n\t\t\tsw.Write(MaxWord(str) + \" \" + WordsCount(str));\n\t\t}\n\n\t\tprivate int MaxWord(string str)\n\t\t{\n\t\t\tvar maxLen = 0;\n\t\t\tfor (var i = 0; i < str.Length; i++) {\n\t\t\t\tif (str[i] == '(') {\n\t\t\t\t\twhile (str[i] != ')') {\n\t\t\t\t\t\ti++;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tif (str[i] != '_') {\n\t\t\t\t\t\tvar start = i;\n\t\t\t\t\t\twhile (i < str.Length && str[i] != '(' && str[i] != '_') {\n\t\t\t\t\t\t\ti++;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tmaxLen = Math.Max(maxLen, i - start);\n\t\t\t\t\t\ti--;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn maxLen;\n\t\t}\n\n\t\tprivate int WordsCount(string str)\n\t\t{\n\t\t\tvar count = 0;\n\t\t\tfor (var i = 0; i < str.Length; i++)\n\t\t\t{\n\t\t\t\tif (str[i] == '(')\n\t\t\t\t{\n\t\t\t\t\tvar j = i + 1;\n\t\t\t\t\tfor (; j < str.Length; j++)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str[j] != '_' && str[j] != ')') {\n\t\t\t\t\t\t\tcount++;\n\t\t\t\t\t\t\twhile (j < str.Length && str[j] != '_' && str[j] != ')') {\n\t\t\t\t\t\t\t\tj++;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (j == str.Length) {\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (str[j] == ')')\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn count;\n\t\t}\n\t}\n}\n\ninternal class InputReader : IDisposable\n{\n\tprivate bool isDispose;\n\tprivate readonly TextReader sr;\n\n\tpublic InputReader(TextReader stream)\n\t{\n\t\tsr = stream;\n\t}\n\n\tpublic void Dispose()\n\t{\n\t\tDispose(true);\n\t\tGC.SuppressFinalize(this);\n\t}\n\n\tpublic string NextString()\n\t{\n\t\tvar result = sr.ReadLine();\n\t\treturn result;\n\t}\n\n\tpublic int NextInt32()\n\t{\n\t\treturn Int32.Parse(NextString());\n\t}\n\n\tpublic long NextInt64()\n\t{\n\t\treturn Int64.Parse(NextString());\n\t}\n\n\tpublic string[] NextSplitStrings()\n\t{\n\t\treturn NextString()\n\t\t\t.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);\n\t}\n\n\tpublic T[] ReadArray(Func func)\n\t{\n\t\treturn NextSplitStrings()\n\t\t\t.Select(s => func(s, CultureInfo.InvariantCulture))\n\t\t\t.ToArray();\n\t}\n\n\tpublic T[] ReadArrayFromString(Func func, string str)\n\t{\n\t\treturn\n\t\t\tstr.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)\n\t\t\t\t.Select(s => func(s, CultureInfo.InvariantCulture))\n\t\t\t\t.ToArray();\n\t}\n\n\tprotected void Dispose(bool dispose)\n\t{\n\t\tif (!isDispose) {\n\t\t\tif (dispose)\n\t\t\t\tsr.Close();\n\t\t\tisDispose = true;\n\t\t}\n\t}\n\n\t~InputReader()\n\t{\n\t\tDispose(false);\n\t}\n}", "lang_cluster": "C#", "tags": ["expression parsing", "strings", "implementation"], "code_uid": "76a7cfd5b24a97f90dba3b496feb94af", "src_uid": "fc86df4931e787fa3a1a40e2aecf0b92", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace CodeforcesTasks\n{\n class Program_375B\n {\n public static void Main(string[] args)\n {\n int n = int.Parse(Console.ReadLine());\n string s = Console.ReadLine();\n\n int inBrackets = 0;\n bool inbr = false;\n int len = 0;\n int maxLen = 0;\n\n// char[] cha = s.ToCharArray();\n foreach (char ch in s)\n {\n if (ch == '(')\n {\n if (len > 0)\n {\n if (len > maxLen)\n {\n maxLen = len;\n }\n\n len = 0;\n }\n inbr = true;\n len = 0;\n }\n if (ch == ')')\n {\n if (len > 0)\n {\n inBrackets ++;\n }\n inbr = false;\n len = 0;\n }\n if (Char.IsLetter(ch))\n {\n len++;\n if ( (!inbr) && (len > maxLen) )\n {\n maxLen = len;\n }\n }\n if (ch == '_')\n {\n if ( len > 0 )\n {\n if (!inbr)\n {\n if (len > maxLen)\n {\n maxLen = len;\n }\n }\n else\n {\n inBrackets++;\n }\n len = 0;\n }\n }\n }\n\n\n Console.WriteLine(maxLen + \" \" + inBrackets);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["expression parsing", "strings", "implementation"], "code_uid": "1e88295741994c0c3db902037cdb34de", "src_uid": "fc86df4931e787fa3a1a40e2aecf0b92", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections;\nusing System.Collections.Generic;\nusing System.IO.Pipes;\nusing System.Linq;\nusing System.Runtime.InteropServices;\nusing System.Text;\n\nnamespace Codeforces\n{\n public class Program\n {\n private const int MAXN = 8000;\n\n public static void Main(string[] args)\n {\n int n = int.Parse(Console.ReadLine().Trim());\n string line = Console.ReadLine();\n\n int maxLen = 0;\n int count = 0;\n\n bool insidePar = false;\n\n int i = 0;\n while (i < line.Length)\n {\n if (line[i] == '_')\n {\n i++;\n }\n else if (line[i] == '(')\n {\n insidePar = true;\n i++;\n }\n else if (line[i] == ')')\n {\n insidePar = false;\n i++;\n }\n else\n {\n int len = 0;\n while (i < line.Length && char.IsLetter(line[i]))\n {\n i++;\n len++;\n }\n\n if (insidePar)\n {\n count++;\n }\n else\n {\n maxLen = Math.Max(maxLen, len);\n }\n \n }\n }\n\n Console.WriteLine(maxLen + \" \" + count);\n \n }\n }\n}", "lang_cluster": "C#", "tags": ["expression parsing", "strings", "implementation"], "code_uid": "a215d7ad986b476893deacc29a4201bf", "src_uid": "fc86df4931e787fa3a1a40e2aecf0b92", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace CFCSH\n{\n class Program\n {\n\n static void Main(string[] args)\n {\n int n = int.Parse(Console.ReadLine());\n string s;\n s = Console.ReadLine();\n bool f = false;\n int count = 0 , M = 0 , P = 0;\n s += '_';\n for (int i = 0; i < s.Length; ++i){\n if (s[i] == '(')\n {\n f = true;\n if (count > M)\n M = count;\n count = 0;\n\n }\n else if (s[i] == ')')\n {\n f = false;\n if (count > 0)\n ++P;\n count = 0;\n }\n else if (s[i] == '_')\n {\n if (count > 0)\n {\n if (f)\n ++P;\n else if (count > M)\n M = count;\n }\n count = 0;\n\n }\n else\n ++count;\n }\n Console.WriteLine(M + \" \" + P);\n \n }\n }\n}\n", "lang_cluster": "C#", "tags": ["expression parsing", "strings", "implementation"], "code_uid": "8fb9f9576a84792d41b3fb47d99f170d", "src_uid": "fc86df4931e787fa3a1a40e2aecf0b92", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\n class Program\n {\n public static void Main(string[] args)\n {\n int theLongestWord = 0;\n int countOfWords = 0;\n {\n bool outside = true;\n string input = Console.In.ReadToEnd().Split(new char[] { '\\n', '\\r'}, StringSplitOptions.RemoveEmptyEntries)[1];\n int wrdLngth = 0;\n for (int i = 0; i < input.Length; ++i)\n {\n if (Char.IsLetter(input[i]))\n wrdLngth++;\n else\n {\n if(wrdLngth>0)\n {\n if (outside)\n {\n if (wrdLngth > theLongestWord) theLongestWord = wrdLngth;\n }\n else countOfWords++;\n wrdLngth = 0;\n }\n if (input[i] != '_')\n outside = !outside;\n }\n }\n if (wrdLngth > theLongestWord) theLongestWord = wrdLngth;\n }\n Console.Write(\"{0} {1}\\n\", theLongestWord, countOfWords);\n }\n }", "lang_cluster": "C#", "tags": ["expression parsing", "strings", "implementation"], "code_uid": "880c072b6e34529299ed0dd071c5b0e3", "src_uid": "fc86df4931e787fa3a1a40e2aecf0b92", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.IO;\nusing System.Text;\n\nnamespace Text_Document_Analysis\n{\n internal class Program\n {\n private static readonly StreamReader reader = new StreamReader(Console.OpenStandardInput(1024*10), Encoding.ASCII, false, 1024*10);\n private static readonly StreamWriter writer = new StreamWriter(Console.OpenStandardOutput(1024*10), Encoding.ASCII, 1024*10);\n\n private static void Main(string[] args)\n {\n string s = reader.ReadLine();\n s = \"_\" + reader.ReadLine() + \"_\";\n\n int max = 0;\n int count = 0;\n\n int l = 0;\n bool inner = false;\n foreach (char c in s)\n {\n if (c == '_' || c == '(' || c == ')')\n {\n if (!inner)\n {\n max = Math.Max(l, max);\n }\n else\n {\n if (l > 0)\n {\n count++;\n }\n }\n if (c == '(')\n inner = true;\n if (c == ')')\n inner = false;\n\n l = 0;\n }\n else\n {\n l++;\n }\n }\n\n\n writer.Write(max);\n writer.Write(' ');\n writer.WriteLine(count);\n\n writer.Flush();\n }\n }\n}", "lang_cluster": "C#", "tags": ["expression parsing", "strings", "implementation"], "code_uid": "f717ae619b450819d68b2f1d51610f51", "src_uid": "fc86df4931e787fa3a1a40e2aecf0b92", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace Pipeline\n{\n class Program\n {\n static void Main(string[] args)\n {\n long[] input = Array.ConvertAll(Console.ReadLine().Split(), long.Parse);\n if (input[0] == 1)\n {\n Console.WriteLine(0);\n }\n else if (input[0] <= input[1])\n {\n Console.WriteLine(1);\n }\n else\n {\n --input[1];\n --input[0];\n if (sum(input[1]) < input[0])\n {\n Console.WriteLine(-1);\n }\n else\n {\n Console.WriteLine(minSplitters(input[1], input[0]));\n }\n\n\n }\n }\n\n public static long sum(long n)\n {\n return (n * (n + 1)) / 2;\n }\n\n public static long sum(long s, long e)\n {\n if (s <= 1)\n {\n return sum(e);\n }\n\n return sum(e) - sum(s - 1);\n }\n\n\n public static long minSplitters(long k, long n)\n {\n long st = 1,\n en = k;\n while (st < en)\n {\n long md = (st + en) / 2;\n long s = sum(md, k);\n\n if (s == n)\n return k - md + 1;\n if (s > n)\n st = md + 1;\n else\n en = md;\n }\n\n return k - st + 2;\n }\n }\n}", "lang_cluster": "C#", "tags": ["math", "binary search"], "code_uid": "635b8b207b2ffff0d88477e442667a7e", "src_uid": "83bcfe32db302fbae18e8a95d89cf411", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\n\nnamespace CodeForces\n{\n class R176_Div2_B\n {\n static void Main(string[] args)\n {\n string[] s = Console.ReadLine().Split();\n long n = long.Parse(s[0]);\n long k = long.Parse(s[1]);\n \n long l=0, r, mid;\n long maxsum = (k * (k + 1) / 2) - k + 1;\n if (maxsum < n)\n r = -1;\n else\n {\n r = k - 1;\n while (l < r)\n {\n mid = (l + r) / 2;\n if (k * (k - 1) / 2 - (k - mid) * (k - mid - 1) / 2 + 1 < n)\n l = mid + 1;\n else\n r = mid;\n }\n }\n Console.WriteLine(r); \n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "binary search"], "code_uid": "59649d62a7586970c60c916b40e91c4c", "src_uid": "83bcfe32db302fbae18e8a95d89cf411", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\n\nnamespace ProgrammingContest.Codeforces.Round78\n{\n class A\n {\n struct Dice\n {\n int[] val;\n\n public Dice(int[] ary) { val = (int[])ary.Clone(); }\n\n void Rotate1()\n {\n int v = val[3];\n for (int i = 2; i >= 0; i--)\n val[i + 1] = val[i];\n val[0] = v;\n }\n\n void Rotate2()\n {\n int v = val[0];\n val[0] = val[4];\n val[4] = val[2];\n val[2] = val[5];\n val[5] = v;\n }\n\n public int GetHash()\n {\n int bs = 1, res = 0;\n for (int i = 0; i < val.Length; i++, bs *= 8)\n res += val[i] * bs;\n return res;\n }\n\n public IEnumerable Rotations()\n {\n int u = GetHash();\n for (int i = 0; i < 4; i++)\n {\n Rotate1();\n Rotate2();\n int v = GetHash();\n for (int j = 0; j < 4; j++)\n {\n Rotate1();\n yield return GetHash();\n }\n if (v != GetHash())\n throw new Exception();\n for (int j = 0; j < 3; j++)\n Rotate2();\n }\n if (u != GetHash())\n throw new Exception();\n for (int j = 0; j < 2; j++)\n {\n for (int i = 0; i < 4; i++)\n {\n Rotate1();\n yield return GetHash();\n }\n for (int i = 0; i < 2; i++)\n Rotate2();\n }\n if (u != GetHash())\n throw new Exception();\n }\n }\n\n A()\n {\n var str = Console.ReadLine();\n int index = 0;\n HashSet memo = new HashSet();\n Dictionary dic1 = new Dictionary();\n for (int i = 0; i < str.Length; i++)\n if(!dic1.ContainsKey(str[i]))\n dic1[str[i]] = index++;\n\n int res = 0;\n foreach (var cs in Permutations(str.ToCharArray()))\n {\n var vv = cs.Select(c => dic1[c]).ToArray();\n bool ok = true;\n foreach (var d in new Dice(vv).Rotations())\n if (memo.Contains(d))\n {\n ok = false;\n break;\n }\n if (ok)\n {\n //Console.WriteLine(new string(cs));\n res++;\n memo.Add(new Dice(vv).GetHash());\n }\n }\n Console.WriteLine(res);\n }\n\n static void Main()\n {\n new A();\n }\n\n #region Permutations\n private static void Swap(T[] ts, int i, int j)\n {\n T tmp = ts[i];\n ts[i] = ts[j];\n ts[j] = tmp;\n }\n\n public static IEnumerable Permutations(T[] ts)\n {\n foreach (T[] p in Permutations(ts, 0, ts.Length))\n {\n yield return p;\n }\n }\n\n private static IEnumerable Permutations(T[] ts, int start, int end)\n {\n if (start == end) yield return ts;\n for (int i = start; i < end; i++)\n {\n for (int j = i - 1; j >= start; j--) Swap(ts, j, j + 1);\n foreach (T[] p in Permutations(ts, start + 1, end)) yield return p;\n for (int j = start; j < i; j++) Swap(ts, j, j + 1);\n }\n }\n #endregion\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "implementation"], "code_uid": "640b8f4bda2b7ce025b4caed021b55cf", "src_uid": "8176c709c774fa87ca0e45a5a502a409", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\n\nnamespace ProgrammingContest.Codeforces.Round78\n{\n class A\n {\n A()\n {\n var str = Console.ReadLine();\n int index = 0;\n HashSet memo = new HashSet();\n Dictionary dic1 = new Dictionary();\n for (int i = 0; i < str.Length; i++)\n if(!dic1.ContainsKey(str[i]))\n dic1[str[i]] = index++;\n\n int res = 0;\n foreach (var cs in Permutations(str.ToCharArray()))\n {\n var vv = cs.Select(c => dic1[c]).ToArray();\n bool ok = true;\n foreach (var d in new Dice(vv).Rotations())\n if (memo.Contains(d))\n {\n ok = false;\n break;\n }\n if (ok)\n {\n //Console.WriteLine(new string(cs));\n res++;\n memo.Add(new Dice(vv).GetHash());\n }\n }\n Console.WriteLine(res);\n }\n\n static void Main()\n {\n new A();\n }\n\n #region Dice\n struct Dice\n {\n /*\n * val[0]: \u5317\n * val[1]: \u897f\n * val[2]: \u5357\n * val[3]: \u6771\n * val[4]: \u4e0a\n * val[5]: \u4e0b\n */\n int[] val;\n\n // [0,8)\n public Dice(int[] ary) { val = (int[])ary.Clone(); }\n\n void Rotate(params int[] idx)\n {\n int n = idx.Length;\n int v = val[idx[0]];\n for (int i = 0; i < n - 1; i++)\n val[idx[i]] = val[idx[i + 1]];\n val[idx[n - 1]] = v;\n }\n\n // \u4e0a\u4e0b\u306f\u5909\u3048\u305a\u306b\u3001\u4e0a\u304b\u3089\u898b\u3066\u53cd\u6642\u8a08\u56de\u308a\u306b\u56de\u8ee2\n public void RotateZ() { Rotate(3, 2, 1, 0); }\n\n // \u5317\u65b9\u5411\u306b\u56de\u8ee2\u3001\u6771\u897f\u306f\u5909\u308f\u3089\u306a\u3044\n public void RotateX() { Rotate(0, 4, 2, 5); }\n\n // \u6771\u65b9\u5411\u306b\u56de\u8ee2\u3001\u5357\u5317\u306f\u5909\u308f\u3089\u306a\u3044\n public void RotateY() { Rotate(3, 4, 1, 5); }\n\n public int GetHash()\n {\n int bs = 1, res = 0;\n for (int i = 0; i < val.Length; i++, bs *= 8)\n res += val[i] * bs;\n return res;\n }\n\n // Dice\u306e\u56de\u8ee2\u540c\u578b\u3092\u5168\u3066\u5217\u6319\n public IEnumerable Rotations()\n {\n for (int i = 0; i < 4; i++)\n {\n RotateZ();\n RotateY();\n for (int j = 0; j < 4; j++)\n {\n RotateZ();\n yield return GetHash();\n }\n for (int j = 0; j < 3; j++)\n RotateY();\n }\n for (int j = 0; j < 2; j++)\n {\n for (int i = 0; i < 4; i++)\n {\n RotateZ();\n yield return GetHash();\n }\n for (int i = 0; i < 2; i++)\n RotateX();\n }\n }\n }\n #endregion\n #region Permutations\n private static void Swap(T[] ts, int i, int j)\n {\n T tmp = ts[i];\n ts[i] = ts[j];\n ts[j] = tmp;\n }\n\n public static IEnumerable Permutations(T[] ts)\n {\n foreach (T[] p in Permutations(ts, 0, ts.Length))\n {\n yield return p;\n }\n }\n\n private static IEnumerable Permutations(T[] ts, int start, int end)\n {\n if (start == end) yield return ts;\n for (int i = start; i < end; i++)\n {\n for (int j = i - 1; j >= start; j--) Swap(ts, j, j + 1);\n foreach (T[] p in Permutations(ts, start + 1, end)) yield return p;\n for (int j = start; j < i; j++) Swap(ts, j, j + 1);\n }\n }\n #endregion\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "implementation"], "code_uid": "5d9b89a29c7303cd2bfb96b23cf3965c", "src_uid": "8176c709c774fa87ca0e45a5a502a409", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Globalization;\nusing System.Threading;\nusing System.Collections;\nusing System.IO;\n\nnamespace AcmSolution\n{\n internal class Program\n {\n private static void Main(string[] args)\n {\n Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;\n //Console.SetIn(new StreamReader(\"gcd.in\"));\n // Console.SetOut(new StreamWriter(\"gcd.out\"));\n Do();\n //Console.Out.Close();\n Console.ReadLine();\n }\n\n private static void Do()\n {\n int n = GetInt();\n int[] pages = GetInts();\n int sum = pages.Sum();\n int index = 1;\n if (n > sum)\n {\n for (int i = 0; i < 1000000000; i++)\n {\n n = n - sum;\n if (n <= sum)\n break;\n }\n }\n for (int i = 0; i < pages.Length; i++)\n {\n n = n - pages[i];\n if (n <= 0)\n {\n index = index + i;\n break;\n }\n }\n Console.WriteLine(index);\n }\n\n\n #region Utils\n private const double Epsilon = 0.00000001;\n\n private static string GetStr()\n {\n return Console.ReadLine();\n }\n\n private static string[] GetStrs()\n {\n return GetStr().Split(new[] { ' ', '\\t' }, StringSplitOptions.RemoveEmptyEntries);\n }\n\n private static string[] GetStrs(int cnt)\n {\n var s = new string[cnt];\n for (var i = 0; i < cnt; ++i)\n s[i] = GetStr();\n return s;\n }\n\n private static int GetInt()\n {\n return int.Parse(GetStr());\n }\n\n private static void GetInts(out int a, out int b)\n {\n var q = GetInts();\n a = q[0];\n b = q[1];\n }\n\n private static void GetInts(out int a, out int b, out int c)\n {\n var q = GetInts();\n a = q[0];\n b = q[1];\n c = q[2];\n }\n\n private static int[] GetInts()\n {\n var s = GetStrs();\n var a = new int[s.Length];\n for (var i = 0; i < s.Length; ++i)\n a[i] = int.Parse(s[i]);\n return a;\n }\n\n private static long GetLong()\n {\n return long.Parse(GetStr());\n }\n\n private static IEnumerable GetLongs()\n {\n return GetStrs().Select(long.Parse);\n }\n\n private static void WriteDouble(T d)\n {\n Console.WriteLine(string.Format(\"{0:0.000000000}\", d).Replace(',', '.'));\n }\n\n private static void WL(T s)\n {\n Console.WriteLine(s);\n }\n\n private static void W(T s)\n {\n Console.Write(s);\n }\n\n private static void Assert(bool b)\n {\n if (!b) throw new Exception();\n }\n\n private static void Swap(ref T a, ref T b)\n {\n var temp = a;\n a = b;\n b = temp;\n }\n\n #endregion\n }\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "6478f49b3de8ccd522fb42c6c6c68204", "src_uid": "007a779d966e2e9219789d6d9da7002c", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Linq;\n\nnamespace codeforces\n{\n class Program\n {\n static void Main(string[] args)\n {\n int t = int.Parse(Console.ReadLine());\n var a = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();\n t %= a.Sum();\n if (t == 0)\n {\n Console.WriteLine(1 + Array.LastIndexOf(a, a.Last(x => x != 0)));\n return;\n }\n for (int i = 0; i < 7; i++)\n {\n t -= a[i];\n if (t <= 0)\n {\n Console.WriteLine(i + 1);\n return;\n }\n }\n }\n }\n}", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "26ea11a1d1aebe7a230f3bc6f37610e6", "src_uid": "007a779d966e2e9219789d6d9da7002c", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Linq;\n\nnamespace _171A\n{\n class Program\n {\n static void Main()\n {\n var s = Console.ReadLine().Split();\n var n1 = int.Parse(s[0]); \n var n2 = int.Parse(new string(s[1].Reverse().ToArray()));\n Console.WriteLine(n1+n2);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["constructive algorithms"], "code_uid": "6c568a9ffffd556afb4c61b49d15374e", "src_uid": "69b219054cad0844fc4f15df463e09c0", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections;\nusing System.Collections.Generic;\nusing System.Collections.Specialized;\nusing System.Diagnostics;\nusing System.Globalization;\nusing System.IO;\nusing System.Text;\nusing System.Linq;\n\nnamespace Codeforces\n{\n internal class Program\n {\n private const string Test = \"D1\";\n \n private static void Solve()\n {\n var input = ReadIntArray();\n var a = input[0];\n var b = input[1];\n var res = 0;\n while (b >= 1)\n {\n res = res*10 + (b%10);\n b/=10;\n }\n res += a;\n Console.WriteLine(res);\n }\n\n\n private static void Main()\n {\n if (Debugger.IsAttached)\n {\n Console.SetIn(new StreamReader(String.Format(@\"..\\..\\..\\..\\Tests\\{0}.in\", Test)));\n }\n\n Solve();\n\n if (Debugger.IsAttached)\n {\n Console.In.Close();\n Console.SetIn(new StreamReader(Console.OpenStandardInput()));\n Console.ReadLine();\n }\n }\n\n #region Reader\n\n private static string Read()\n {\n return Console.ReadLine();\n }\n\n private static string[] ReadArray()\n {\n return Console.ReadLine().Split(' ');\n }\n\n private static List ReadIntArray()\n {\n var input = Console.ReadLine().Split(' ').Select(Int32.Parse).ToList();\n return input;\n }\n\n private static int ReadInt()\n {\n return Int32.Parse(Console.ReadLine());\n }\n\n private static long ReadLong()\n {\n return long.Parse(Console.ReadLine());\n }\n\n private static int ReadNextInt(string[] input, int index)\n {\n return Int32.Parse(input[index]);\n }\n\n #endregion\n }\n}", "lang_cluster": "C#", "tags": ["constructive algorithms"], "code_uid": "1a6c5b7a6a2e014b0edb31cb88c0de6d", "src_uid": "69b219054cad0844fc4f15df463e09c0", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Globalization;\nusing System.IO;\nusing System.Linq;\nusing System.Text;\nusing System.Threading;\n\npublic class Solver\n{\n int Fun(ref int x, int p)\n {\n int ret = 0;\n while (x % p == 0)\n {\n x /= p;\n ret++;\n }\n return ret;\n }\n\n public void Solve()\n {\n int n = ReadInt();\n int m = ReadInt();\n\n int n2 = Fun(ref n, 2);\n int n3 = Fun(ref n, 3);\n int m2 = Fun(ref m, 2);\n int m3 = Fun(ref m, 3);\n\n if (n != m || n2 > m2 || n3 > m3)\n Write(-1);\n else\n Write(m2 - n2 + m3 - n3);\n }\n\n #region Main\n\n protected static TextReader reader;\n protected static TextWriter writer;\n static void Main()\n {\n#if DEBUG\n reader = new StreamReader(\"..\\\\..\\\\input.txt\");\n //reader = new StreamReader(Console.OpenStandardInput());\n writer = Console.Out;\n //writer = new StreamWriter(\"..\\\\..\\\\output.txt\");\n#else\n reader = new StreamReader(Console.OpenStandardInput());\n writer = new StreamWriter(Console.OpenStandardOutput());\n //reader = new StreamReader(\"input.txt\");\n //writer = new StreamWriter(\"output.txt\");\n#endif\n try\n {\n new Solver().Solve();\n //var thread = new Thread(new Solver().Solve, 1024 * 1024 * 128);\n //thread.Start();\n //thread.Join();\n }\n catch (Exception ex)\n {\n#if DEBUG\n Console.WriteLine(ex);\n#else\n throw;\n#endif\n }\n reader.Close();\n writer.Close();\n }\n\n #endregion\n\n #region Read / Write\n private static Queue currentLineTokens = new Queue();\n private static string[] ReadAndSplitLine() { return reader.ReadLine().Split(new[] { ' ', '\\t', }, StringSplitOptions.RemoveEmptyEntries); }\n public static string ReadToken() { while (currentLineTokens.Count == 0)currentLineTokens = new Queue(ReadAndSplitLine()); return currentLineTokens.Dequeue(); }\n public static int ReadInt() { return int.Parse(ReadToken()); }\n public static long ReadLong() { return long.Parse(ReadToken()); }\n public static double ReadDouble() { return double.Parse(ReadToken(), CultureInfo.InvariantCulture); }\n public static int[] ReadIntArray() { return ReadAndSplitLine().Select(int.Parse).ToArray(); }\n public static long[] ReadLongArray() { return ReadAndSplitLine().Select(long.Parse).ToArray(); }\n public static double[] ReadDoubleArray() { return ReadAndSplitLine().Select(s => double.Parse(s, CultureInfo.InvariantCulture)).ToArray(); }\n public static int[][] ReadIntMatrix(int numberOfRows) { int[][] matrix = new int[numberOfRows][]; for (int i = 0; i < numberOfRows; i++)matrix[i] = ReadIntArray(); return matrix; }\n public static int[][] ReadAndTransposeIntMatrix(int numberOfRows)\n {\n int[][] matrix = ReadIntMatrix(numberOfRows); int[][] ret = new int[matrix[0].Length][];\n for (int i = 0; i < ret.Length; i++) { ret[i] = new int[numberOfRows]; for (int j = 0; j < numberOfRows; j++)ret[i][j] = matrix[j][i]; } return ret;\n }\n public static string[] ReadLines(int quantity) { string[] lines = new string[quantity]; for (int i = 0; i < quantity; i++)lines[i] = reader.ReadLine().Trim(); return lines; }\n public static void WriteArray(IEnumerable array) { writer.WriteLine(string.Join(\" \", array)); }\n public static void Write(params object[] array) { WriteArray(array); }\n public static void WriteLines(IEnumerable array) { foreach (var a in array)writer.WriteLine(a); }\n private class SDictionary : Dictionary\n {\n public new TValue this[TKey key]\n {\n get { return ContainsKey(key) ? base[key] : default(TValue); }\n set { base[key] = value; }\n }\n }\n private static T[] Init(int size) where T : new() { var ret = new T[size]; for (int i = 0; i < size; i++)ret[i] = new T(); return ret; }\n #endregion\n}", "lang_cluster": "C#", "tags": ["math", "implementation"], "code_uid": "60ed8735692d213fa0c20dba2d5c3f08", "src_uid": "3f9980ad292185f63a80bce10705e806", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing static Input;\n\npublic class Prog\n{\n private const int INF = 1000000007;\n private const long INFINITY = 9223372036854775807;\n public static void Main()\n {\n long n = NextInt();\n long m = NextInt();\n if ((m / n) != ((m + .0) / (n + .0))) { Console.WriteLine(-1); return; }\n m /= n;\n long ans = 0;\n while (m != 1)\n {\n if (m % 3 == 0) m /= 3;\n else if (m % 2 == 0) m /= 2;\n else { Console.WriteLine(-1); return; }\n ans++;\n }\n Console.WriteLine(ans);\n }\n}\n\npublic class Input\n{\n private static Queue q = new Queue();\n private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); }\n public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); }\n public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); }\n public static string NextString() { Confirm(); return q.Dequeue(); }\n public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); }\n public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }\n public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }\n public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }\n public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }\n}", "lang_cluster": "C#", "tags": ["math", "implementation"], "code_uid": "d07f034c08c998deac7114cecb609ab9", "src_uid": "3f9980ad292185f63a80bce10705e806", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace Remove_The_Substring {\n class Program {\n static void Main( string[] args ) {\n var s = Console.ReadLine().ToArray();\n var t = Console.ReadLine().ToArray();\n\n var occ = new int[ t.Length ];\n\n var ind = Array.IndexOf( s, t[0] );\n occ[ 0 ] = ind;\n\n for ( var i = 1 ; i < t.Length; i++ ) {\n occ[ i ] = Array.IndexOf( s, t[ i ], occ[i-1] + 1 );\n }\n\n var occs = new List>();\n occs.Add( occ.ToList() );\n\n for( var j = t.Length - 1; j >= 0; j-- ) {\n var next = 0;\n\n if( j == t.Length - 1 ) {\n next = Array.LastIndexOf( s, t[ j ] );\n } else {\n next = Array.LastIndexOf( s, t[ j ], occ[ j + 1 ] - 1 );\n }\n if( next != -1 && next != occ[j] ) {\n occ[ j ] = next;\n occs.Add( occ.ToList() );\n }\n }\n\n var length = 0;\n var maxLength = Math.Max( s.Length - occs[0][t.Length - 1] - 1, occs.Last().First() );\n\n foreach( var o in occs ) {\n for( var j = 0; j < o.Count - 1; j++ ) {\n length = o[ j + 1 ] - o[ j ] - 1;\n if( length > maxLength ) { maxLength = length; }\n }\n }\n\n Console.WriteLine( maxLength );\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["greedy", "implementation"], "code_uid": "3cfc58ba8e076bf0aea7a7669d0118dc", "src_uid": "0fd33e1bdfd6c91feb3bf00a2461603f", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\n\nclass Program2\n {\n\n static bool validate(int k, int l, char[] a, char[] b) {\n int idB = 0;\n for (int i = 0; i < k && idB< b.Length; i++) {\n if (a[i] == b[idB])\n idB++;\n }\n for (int i = l+1; i < a.Length && idB < b.Length; i++) {\n if (a[i] == b[idB])\n idB++;\n }\n\n return idB == b.Length;\n }\n\n static void Main(string[] args)\n {\n char []a = Console.ReadLine().ToCharArray();\n char []b = Console.ReadLine().ToCharArray();\n int max = 0;\n\n for (int i = 0; i < a.Length; i++) {\n for (int j = i; j < a.Length; j++) {\n if (validate(i, j, a, b))\n max = Math.Max(max, j - i+1);\n }\n }\n\n //string[] array = aux.Split(new string[] { beta }, StringSplitOptions.None);\n //int max = 0;\n //if (array[0] != \"\")\n // max = array[0].Length;\n\n //for (int i = 1; i < array.Length; i++) { \n // if (array[i].Length > max) \n // max = array[i].Length;\n //}\n \n Console.WriteLine(max); \n\n }\n}\n", "lang_cluster": "C#", "tags": ["greedy", "implementation"], "code_uid": "f45a9fc999b0003658d0974252d00498", "src_uid": "0fd33e1bdfd6c91feb3bf00a2461603f", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nnamespace ConsoleApp3\n{\n class Program\n {\n static void Main(string[] args)\n {\n var input = Console.ReadLine().Split();\n long n = long.Parse(input[0]);\n long k = long.Parse(input[1]);\n bool success = true;\n for (long c = 2; c <= k; ++c) {\n if (n % c != c - 1) {\n success = false;\n break;\n }\n }\n if (success)\n Console.WriteLine(\"Yes\");\n else\n Console.WriteLine(\"No\");\n }\n }\n}", "lang_cluster": "C#", "tags": ["brute force", "number theory"], "code_uid": "15d05668e600cedfb39820bde2a9a65f", "src_uid": "5271c707c9c72ef021a0baf762bf3eb2", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace TestApp\n{\n class Program\n {\n static void Main(string[] args)\n {\n var input = Console.ReadLine().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);\n\n var n = long.Parse(input[0]);\n var k = long.Parse(input[1]);\n\n if(k >= 43)\n {\n Console.WriteLine(\"No\");\n return;\n }\n\n for (var i = 1; i <= k; i++)\n {\n if (n % i != i - 1)\n {\n Console.WriteLine(\"No\");\n return;\n }\n }\n\n Console.WriteLine(\"Yes\");\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "number theory"], "code_uid": "3e53ca01e39eca96ee6863a26bc173a8", "src_uid": "5271c707c9c72ef021a0baf762bf3eb2", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace Zadanie_3\n{\n class Program\n {\n public static int func(int n)\n {\n int i = 0;\n while (n > 0)\n {\n i++;\n n /= 10;\n }\n return i;\n }\n\n public static long mul(long n)\n {\n long res = 1;\n while(n > 0)\n {\n res *= n % 10;\n n /= 10;\n }\n return res;\n }\n\n static void Main(string[] args)\n {\n int n = int.Parse(Console.ReadLine());\n\n int s = n.ToString().Length;// func(n);\n long ans = mul(n);\n long res = n;\n \n string val = \"\";\n for(int i = 0; i <= s; i++)\n {\n val = \"0\";\n for (int j = 0; j < i; j++)\n {\n val += '9';\n }\n long pow_1 = (long)Math.Pow(10, i);\n long a = (n / pow_1 - 1) * pow_1 + long.Parse(val);\n long m = mul(a);\n if(m > ans)\n {\n ans = m;\n res = a;\n }\n }\n Console.WriteLine(ans);\n //Console.ReadKey();\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "math", "number theory"], "code_uid": "1474f39b9e282b8eb35152c1003302d9", "src_uid": "38690bd32e7d0b314f701f138ce19dfb", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace C\n{\n class Program\n {\n \n static void Main(string[] args)\n {\n StringBuilder n = new StringBuilder(Console.ReadLine());\n if(n.Length==1)\n Console.WriteLine(n);\n else\n {\n int max = 0;\n int res = 1;\n for(int i = 0; i=0; j--)\n {\n if(n[j]!='0'&&n[j]!='1')\n {\n n[j + 1] = '9';\n n[j] = (int.Parse(n[j].ToString()) - 1).ToString()[0];\n res = 1;\n for (int i = 0; i < n.Length; i++)\n {\n res *= int.Parse(n[i].ToString());\n }\n if (res > max)\n max = res;\n }\n else\n {\n n[j + 1] = '9';\n }\n }\n res = 1;\n if(n[0]=='1')\n for (int i = 1; i < n.Length; i++)\n {\n res *= int.Parse(n[i].ToString());\n }\n if (res > max)\n max = res;\n Console.WriteLine(max);\n }\n \n }\n }\n}\n\n", "lang_cluster": "C#", "tags": ["brute force", "math", "number theory"], "code_uid": "a5ae038d9b0c9a54983327a6b225e46a", "src_uid": "38690bd32e7d0b314f701f138ce19dfb", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Globalization;\nusing System.IO;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Diagnostics;\n\nnamespace Codeforces\n{\n class Program : ProgramBase\n {\n private const long commonMod = 1000000007;\n\n static void Main(string[] args)\n {\n var p = new Program();\n var x = p.Solve();\n p.Out(x);\n }\n object Solve()\n {\n var n = (int) ReadLong();\n for (int i = n / 2; i >= 1; i--)\n {\n var b = n - i;\n if (NOD(i, b) == 1)\n return i + \" \" + b; \n }\n throw new Exception();\n }\n\n long NOD (long a, long b)\n {\n if (b == 0)\n return a;\n return NOD(b, a % b);\n }\n\n long sum(long[] prefs, int i, int j)\n {\n if (i == j)\n return 0;\n var sub = i == 0 ? 0 : prefs[i - 1];\n return prefs[j - 1] - sub;\n }\n\n class Vac\n {\n public long Left { get; set; }\n public long Right { get; set; }\n public long Cost { get; set; }\n }\n\n class End\n {\n public long Val { get; set; }\n public bool Left { get; set; }\n }\n }\n\n abstract class ProgramBase\n {\n bool? prod = null;\n StreamReader f;\n Queue tokens;\n protected string FileName { private get; set; }\n\n protected string Read()\n {\n if (f == null)\n f = string.IsNullOrEmpty(FileName)\n ? new StreamReader(Console.OpenStandardInput(1024 * 10), Encoding.ASCII, false, 1024 * 10)\n : new StreamReader((GetProd() ? \"\" : \"c:\\\\dev\\\\\") + FileName);\n return f.ReadLine();\n }\n\n protected string ReadToken()\n {\n if (tokens == null || tokens.Count == 0)\n tokens = new Queue(Read().Split(' '));\n return tokens.Dequeue();\n }\n\n protected long ReadLong() { return long.Parse(ReadToken()); }\n\n protected long[] ReadLongs()\n {\n var s = Read();\n if (s == \"\")\n return new long[0];\n //var i = s.IndexOf(' ');\n //return new[] { long.Parse(s.Substring(0, i)), long.Parse(s.Substring(i + 1)) };\n var tokens = s.Split(' ');\n var result = new long[tokens.Length];\n for (int i = 0; i < tokens.Length; i++)\n result[i] = long.Parse(tokens[i]);\n return result;\n }\n\n public void Out(object r)\n {\n if (string.IsNullOrEmpty(FileName))\n Console.WriteLine(r);\n else if (GetProd())\n File.WriteAllText(FileName, r.ToString());\n else\n Console.WriteLine(r);\n }\n\n private bool GetProd()\n {\n\n if (!prod.HasValue)\n try\n {\n prod = Environment.MachineName != \"RENADEEN-W7\";\n }\n catch (Exception)\n {\n prod = true;\n }\n return prod.Value;\n }\n }\n\n public static class Huj\n {\n public static T MinBy(this IEnumerable source, Func func) where T : class\n {\n T result = null;\n var min = double.MaxValue;\n foreach (var item in source)\n {\n var current = func(item);\n if (min > current)\n {\n min = current;\n result = item;\n }\n }\n return result;\n }\n\n public static T MaxBy(this IEnumerable source, Func func, T defaultValue = default(T))\n {\n T result = defaultValue;\n var max = double.MinValue;\n foreach (var item in source)\n {\n var current = func(item);\n if (max < current)\n {\n max = current;\n result = item;\n }\n }\n return result;\n }\n\n public static string JoinStrings(this IEnumerable s, string d) { return string.Join(d, s.ToArray()); }\n\n public static string JoinStrings(this IEnumerable s, string d) { return s.Select(x => x.ToString()).JoinStrings(d); }\n public static string JoinStrings(this IEnumerable s, string d) { return s.Select(x => x.ToString()).JoinStrings(d); }\n }\n\n}", "lang_cluster": "C#", "tags": ["brute force", "math", "constructive algorithms"], "code_uid": "e0db205cba6f0a6fb31bf4d77d257999", "src_uid": "0af3515ed98d9d01ce00546333e98e77", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Text;\n\nnamespace Day_22\n{\n class Fraction\n {\n // Recursive function to \n // return gcd of a and b \n static int __gcd(int a, int b)\n {\n // Everything divides 0 \n if (a == 0 || b == 0)\n return 0;\n\n // base case \n if (a == b)\n return a;\n\n // a is greater \n if (a > b)\n return __gcd(a - b, b);\n\n return __gcd(a, b - a);\n }\n\n // function to check and print if \n // two numbers are co-prime or not \n static bool coprime(int a, int b)\n {\n\n if (__gcd(a, b) == 1)\n return true;\n return false;\n }\n\n static void Main(string[] args)\n {\n int n = Convert.ToInt32(Console.ReadLine());\n int i = n/2;\n while (i > 0)\n {\n if (coprime(i, n - i))\n {\n Console.WriteLine($\"{i} {n - i}\");\n break;\n }\n i--;\n }\n }\n\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "math", "constructive algorithms"], "code_uid": "ea9799aa30b4dfb096ac7741fef3f495", "src_uid": "0af3515ed98d9d01ce00546333e98e77", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\n\nnamespace Problem_5_579A___A._Raising_Bacteria\n{\n class Program\n {\n static void Main(string[] args)\n {\n int count = 0;\n string input = Convert.ToString(int.Parse(Console.ReadLine()), 2);\n for(int i = 0; i < input.Length; i++)\n {\n if (input[i] == '1')\n count++;\n }\n Console.WriteLine(count);\n }\n }\n}", "lang_cluster": "C#", "tags": ["bitmasks"], "code_uid": "e8947718e4520e47733b8737191f1408", "src_uid": "03e4482d53a059134676f431be4c16d2", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\n\npublic class Test\n{\n\tpublic static void Main()\n\t{\n\t\tint n = int.Parse(System.Console.ReadLine());\n int c = 0;\n\n if (n != 0)\n while (n != 0)\n { \n if ((n & 1) == 1)\n c++;\n n = n >> 1;\n }\n\n System.Console.WriteLine(c);\n\t}\n}\n\n\n", "lang_cluster": "C#", "tags": ["bitmasks"], "code_uid": "5b941ac1ea27f146f24bf7f37de56b00", "src_uid": "03e4482d53a059134676f431be4c16d2", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.IO;\nusing System.Text;\n\nnamespace Shower_Line\n{\n internal class Program\n {\n private static readonly StreamReader reader =\n new StreamReader(Console.OpenStandardInput(1024*10), Encoding.ASCII, false, 1024*10);\n\n private static readonly StreamWriter writer =\n new StreamWriter(Console.OpenStandardOutput(1024*10), Encoding.ASCII, 1024*10);\n\n private static void Main(string[] args)\n {\n var nn = new int[5,5];\n\n for (int i = 0; i < 5; i++)\n {\n string[] ss = reader.ReadLine().Split(' ');\n for (int j = 0; j < 5; j++)\n {\n nn[i, j] = int.Parse(ss[j]);\n }\n }\n\n\n int max = 0;\n\n for (int i1 = 0; i1 < 5; i1++)\n {\n for (int i2 = 0; i2 < 5; i2++)\n {\n if (i2 == i1)\n continue;\n for (int i3 = 0; i3 < 5; i3++)\n {\n if (i3 == i1 || i3 == i2)\n continue;\n for (int i4 = 0; i4 < 5; i4++)\n {\n if (i4 == i1 || i4 == i2 || i4 == i3)\n continue;\n for (int i5 = 0; i5 < 5; i5++)\n {\n if (i5 == i1 || i5 == i2 || i5 == i3 || i5 == i4)\n continue;\n //(g23\u2009+\u2009g32\u2009+\u2009g15\u2009+\u2009g51)\u2009+\u2009(g13\u2009+\u2009g31\u2009+\u2009g54\u2009+\u2009g45)\u2009+\u2009(g15\u2009+\u2009g51)\u2009+\u2009(g54\u2009+\u2009g45)\n int mm = (nn[i1, i2] + nn[i2, i1] + nn[i3, i4] + nn[i4, i3]) + (nn[i2, i3] + nn[i3, i2] + nn[i4, i5] + nn[i5, i4]) +\n (nn[i3, i4] + nn[i4, i3]) + (nn[i4, i5] + nn[i5, i4]);\n if (mm > max)\n max = mm;\n }\n }\n }\n }\n }\n\n writer.WriteLine(\"{0}\", max);\n writer.Flush();\n }\n }\n}", "lang_cluster": "C#", "tags": ["brute force", "implementation"], "code_uid": "d26bb9503e8f28ada1fdc3e7826da5d5", "src_uid": "be6d4df20e9a48d183dd8f34531df246", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections;\nusing System.Collections.Generic;\n \nclass TEST{\n\tstatic void Main(){\n\t\tSol mySol =new Sol();\n\t\tmySol.Solve();\n\t}\n}\n\nclass Sol{\n\tpublic void Solve(){\n\t\tint[] route=new int[5];\n\t\tfor(int i=0;i<5;i++)route[i]=0;\n\t\t\n\t\tMax=0;\n\t\tfor(int i=1;i<=5;i++){\n\t\t\troute[0]=i;\n\t\t\tdfs(route);\n\t\t\troute[0]=0;\n\t\t}\n\t\tConsole.WriteLine(\"{0}\",Max);\n\t}\n\t\n\tlong Max;\n\t\n\tvoid dfs(int[] route_){\n\t\tint[] route=new int[5];\n\t\tint[] visit=new int[6];\n\t\tfor(int i=0;i<=5;i++)visit[i]=0;\n\t\tint now=0;\n\t\t\n\t\tfor(int i=0;i<5;i++){\n\t\t\troute[i]=route_[i];\n\t\t\tif(route[i]!=0){\n\t\t\t\tnow=i;\n\t\t\t\tvisit[route[i]]=1;\n\t\t\t}\n\t\t}\n\t\t\n\t\tif(now==4){\n\t\t\tcal(route);\n\t\t\treturn;\n\t\t}\n\t\t\n\t\t\n\t\tfor(int i=1;i<=5;i++){\n\t\t\tif(visit[i]==0){\n\t\t\t\troute[now+1]=i;\n\t\t\t\tdfs(route);\n\t\t\t\troute[now+1]=0;\n\t\t\t}\n\t\t}\n\t\t\n\t\treturn;\n\t}\n\t\n\tvoid cal(int[] route){\n\t\tlong sum=0;\n\t\tsum+=G[route[0]-1][route[1]-1]+G[route[1]-1][route[0]-1];\n\t\tsum+=G[route[2]-1][route[3]-1]+G[route[3]-1][route[2]-1];\n\t\tsum+=G[route[1]-1][route[2]-1]+G[route[2]-1][route[1]-1];\n\t\tsum+=G[route[3]-1][route[4]-1]+G[route[4]-1][route[3]-1];\n\t\tsum+=G[route[2]-1][route[3]-1]+G[route[3]-1][route[2]-1];\n\t\tsum+=G[route[3]-1][route[4]-1]+G[route[4]-1][route[3]-1];\n\t\t\n\t\tMax=Math.Max(Max,sum);\n\t\treturn;\n\t}\n\t\t\n\t\n\t\n\t\n\t\n\t\n\t\n\tint[][] G;\n\tpublic Sol(){\n\t\tG=new int[5][];\n\t\tfor(int i=0;i<5;i++)G[i]=ria();\n\t}\n\n\n\n\n\tstatic String rs(){return Console.ReadLine();}\n\tstatic int ri(){return int.Parse(Console.ReadLine());}\n\tstatic long rl(){return long.Parse(Console.ReadLine());}\n\tstatic double rd(){return double.Parse(Console.ReadLine());}\n\tstatic String[] rsa(){return Console.ReadLine().Split(' ');}\n\tstatic int[] ria(){return Array.ConvertAll(Console.ReadLine().Split(' '),e=>int.Parse(e));}\n\tstatic long[] rla(){return Array.ConvertAll(Console.ReadLine().Split(' '),e=>long.Parse(e));}\n\tstatic double[] rda(){return Array.ConvertAll(Console.ReadLine().Split(' '),e=>double.Parse(e));}\n}\n", "lang_cluster": "C#", "tags": ["brute force", "implementation"], "code_uid": "a29b726ae8f727a5101f5b03221eef3a", "src_uid": "be6d4df20e9a48d183dd8f34531df246", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.IO.Pipes;\nusing System.Linq;\nusing System.Text;\n\nnamespace codeforces\n{\n\tclass Program\n\t{\n\t\tpublic class User\n\t\t{\n\t\t\tpublic int c;\n\n\t\t\tpublic int r;\n\t\t}\n\n\t\tpublic class Point\n\t\t{\n\t\t\tpublic int x;\n\n\t\t\tpublic double p;\n\t\t}\n\n\t\tpublic class Comparer : IComparer\n\t\t{\n\t\t\tpublic int Compare(User x, User y)\n\t\t\t{\n\t\t\t\tif (x.c < y.c || (x.c == y.c && x.r < y.r))\n\t\t\t\t\treturn -1;\n\t\t\t\treturn 1;\n\t\t\t}\n\t\t}\n\n\t\tpublic static long getGcd(long a, long b)\n\t\t{\n\t\t\tif (b == 0)\n\t\t\t\treturn a;\n\t\t\treturn getGcd(b, a % b);\n\t\t}\n\n\t\tpublic static void WriteYESNO(bool x, string yes = \"YES\", string no = \"NO\")\n\t\t{\n\t\t\tif (x)\n\t\t\t\tConsole.WriteLine(yes);\n\t\t\telse\n\t\t\t{\n\t\t\t\tConsole.WriteLine(no);\n\t\t\t}\n\t\t}\n\n\t\tpublic static string GetString()\n\t\t{\n\t\t\treturn Console.ReadLine();\n\t\t}\n\n\t\tpublic static List getList()\n\t\t{\n\t\t\tvar s = Console.ReadLine();\n\t\t\treturn s.Split(' ').Select(int.Parse).ToList();\n\t\t}\n\n\t\tpublic static int Min(int x, int y)\n\t\t{\n\t\t\treturn Math.Min(x, y);\n\t\t}\n\n\t\tpublic static int Max(int x, int y)\n\t\t{\n\t\t\treturn Math.Max(x, y);\n\t\t}\n\n\t\tpublic static int Abs(int x)\n\t\t{\n\t\t\treturn Math.Abs(x);\n\t\t}\n\n\t\tpublic static int getInt()\n\t\t{\n\t\t\tvar s = Console.ReadLine();\n\t\t\treturn int.Parse(s);\n\t\t}\n\n\t\tpublic static bool Equal(int x, int y, int x1, int y1)\n\t\t{\n\t\t\treturn x == x1 && y == y1;\n\t\t}\n\n\t\tpublic class Vertex\n\t\t{\n\t\t\tpublic List edges;\n\n\t\t\tpublic int ct;\n\n\t\t\tpublic Vertex()\n\t\t\t{\n\t\t\t\tct = 0;\n\t\t\t\tedges = new List();\n\t\t\t\tfor (var i = 0; i < 26; ++i)\n\t\t\t\t\tedges.Add(0);\n\t\t\t}\n\t\t}\n\n\n\t\tprivate static void Main(string[] args)\n\t\t{\n/*\t\t\tvar input = new StreamReader(\"input.txt\");\n\t\t\tvar output = new StreamWriter(\"output.txt\");*/\n\n\t\t\tvar n = long.Parse(GetString());\n\t\t\tlong ans = 1;\n\t\t\tfor (long i = 1; i*i <= n; ++i)\n\t\t\t{\n\t\t\t\tif (n%i == 0)\n\t\t\t\t{\n\t\t\t\t\tlong p = i;\n\t\t\t\t\tvar can = true;\n\t\t\t\t\tfor (long j = 2; j * j <= p; ++j)\n\t\t\t\t\t\tif (p%(j*j) == 0)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tcan = false;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\tif (can)\n\t\t\t\t\t\tans = Math.Max(ans, p);\n\t\t\t\t\tp = n / i;\n\t\t\t\t\tcan = true;\n\t\t\t\t\tfor (long j = 2; j * j <= p; ++j)\n\t\t\t\t\t\tif (p % (j * j) == 0)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tcan = false;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\tif (can)\n\t\t\t\t\t\tans = Math.Max(ans, p);\n\t\t\t\t}\n\t\t\t}\n\t\t\tConsole.WriteLine(ans);\n\t\t\t/*\t\t\tinput.Close();\n\t\t\toutput.Close();*/\n\t\t}\n\t}\n}\n", "lang_cluster": "C#", "tags": ["math"], "code_uid": "839bad9c790c97174250972808e98b86", "src_uid": "6d0da975fa0961acfdbe75f2f29aeb92", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace _326_2\n{\n class Program\n {\n static void Main(string[] args)\n {\n ulong n = Convert.ToUInt64(Console.ReadLine());\n ulong i = 2;ulong ans=1;\n bool f = false;\n ulong k= n;\n for ( i = 2; i*i <= k; i++)\n {\n if (n % i == 0)\n {\n ans *= i;\n while (n % i == 0) n /= i;\n }\n }\n if (n > 1) ans *= n;\n Console.WriteLine(ans);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math"], "code_uid": "c211212671e181dd8140a3bfed125bca", "src_uid": "6d0da975fa0961acfdbe75f2f29aeb92", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\n\nnamespace Test\n{\n static class Program\n {\n static void Main(string[] args)\n {\n string temp = Console.ReadLine();\n List temps = temp.Split(' ').Select(long.Parse).ToList();\n Console.WriteLine(Solve(temps[0], temps[1]));\n }\n\n static long Solve(long start, long end)\n {\n int[] segment = { 6, 2, 5, 5, 4, 5, 6, 3, 7, 6 };\n long total = 0;\n for (long i = start; i <= end; i++)\n {\n string s = i.ToString();\n total = s.Aggregate(total, (current, t) => current + segment[int.Parse(t.ToString())]);\n }\n return total;\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "ba5ebfa5c5585416378178ebff15eed0", "src_uid": "1193de6f80a9feee8522a404d16425b9", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nnamespace er\n{\n class Program\n {\n \n static void Main(string[] args)\n {\n\n int[] v = { 6, 2, 5, 5, 4, 5, 6, 3, 7, 6 };\n\n\n var s = Console.ReadLine().Split(' ');\n int sum = 0; \n int a = int.Parse(s[0]);\n int b = int.Parse(s[1]);\n\n for (int i = a; i <=b; i++)\n {\n string t = i.ToString();\n\n for (int j = 0; j < t.Length; j++)\n {\n sum += v[t[j] - 48];\n }\n }\n\n Console.WriteLine(sum);\n\n\n\n\n\n\n }\n\n\n\n\n\n }\n }\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "a827ef11502a12faa3b0492e48dca192", "src_uid": "1193de6f80a9feee8522a404d16425b9", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.ComponentModel.Design;\nusing System.Linq;\nusing System.Text;\n\nnamespace Codeforces\n{\n\tclass Program\n\t{\n\t\tstatic void Main(string[] args) \n\t\t{\n\t\t\tstring input1 = Console.ReadLine();\n\t\t\tstring input2 = Console.ReadLine();\n\t\t\tstring input3 = Console.ReadLine();\n\t\t\tstring input4 = Console.ReadLine();\n\n\t\t\t//var inputs1 = input1.Split(new[] { ' ', '}', '{' , ',' }, StringSplitOptions.RemoveEmptyEntries).Select(long.Parse).ToArray();\n\t\t\t//var inputs2 = input2.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(int.Parse).ToArray();\n\n\t\t\tlong n = long.Parse(input1);\n\n\t\t\tlong a = long.Parse(input2);\n\t\t\tlong b = long.Parse(input3);\n\t\t\tlong c = long.Parse(input4);\n\n\n\t\t\tif (n < a && n < b) \n\t\t\t{\n\t\t\t\tConsole.WriteLine(0);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (a < b - c) \n\t\t\t{\n\t\t\t\tConsole.WriteLine(n / a);\n\t\t\t} \n\t\t\telse \n\t\t\t{\n\t\t\t\tif (n >= b) \n\t\t\t\t{\n\t\t\t\t\tlong diff = b - c;\n\t\t\t\t\tlong glass = 1 + (n - b) / diff;\n\t\t\t\t\tlong plastic = (n - glass * diff) / a;\n\t\t\t\t\tConsole.WriteLine(glass + plastic);\n\t\t\t\t} \n\t\t\t\telse \n\t\t\t\t{\n\t\t\t\t\tConsole.WriteLine(n / a);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tstatic long Factorial(long a) \n\t\t{\n\t\t\treturn a > 1 ? a * Factorial(a - 1) : 1;\n\t\t}\n\t}\n}\n", "lang_cluster": "C#", "tags": ["math", "implementation"], "code_uid": "cdee6522dc7e6ac76a895fbd6854a2d9", "src_uid": "0ee9abec69230eab25de51aef0984f8f", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Runtime.CompilerServices;\nusing System.Runtime.InteropServices;\nusing System.Text;\n\nnamespace codeforces\n{\n\tclass Program\n\t{\n\t\tpublic const int Osn = 1000000007;\n\n\t\tpublic class Pair\n\t\t{\n\t\t\tpublic long First;\n\n\t\t\tpublic long Second;\n\t\t}\n\n\t\tpublic class PairComparer : IComparer\n\t\t{\n\t\t\tpublic int Compare(Pair x, Pair y)\n\t\t\t{\n\t\t\t\tif (x.First < y.First || (x.First == y.First && x.Second > y.Second))\n\t\t\t\t\treturn -1;\n\t\t\t\treturn 1;\n\t\t\t}\n\t\t}\n\n\t\tpublic static long GetGcd(long a, long b)\n\t\t{\n\t\t\twhile (true)\n\t\t\t{\n\t\t\t\tif (b == 0)\n\t\t\t\t\treturn a;\n\t\t\t\tvar a1 = a;\n\t\t\t\ta = b;\n\t\t\t\tb = a1 % b;\n\n\t\t\t}\n\t\t}\n\n\t\tpublic static void WriteYesNo(bool x, string yes = \"YES\", string no = \"NO\")\n\t\t{\n\t\t\tif (x)\n\t\t\t\tConsole.WriteLine(yes);\n\t\t\telse\n\t\t\t{\n\t\t\t\tConsole.WriteLine(no);\n\t\t\t}\n\t\t}\n\n\t\tpublic static string ReadString()\n\t\t{\n\t\t\treturn Console.ReadLine();\n\t\t}\n\n\t\tpublic static List ReadListOfInts()\n\t\t{\n\t\t\tvar s = Console.ReadLine();\n\t\t\treturn s.Split(' ').Select(int.Parse).ToList();\n\t\t}\n\n\t\tpublic static List ReadListOfLongs()\n\t\t{\n\t\t\tvar s = Console.ReadLine();\n\t\t\treturn s.Split(' ').Select(long.Parse).ToList();\n\t\t}\n\n\t\tpublic static int ReadInt()\n\t\t{\n\t\t\tvar s = Console.ReadLine();\n\t\t\treturn int.Parse(s);\n\t\t}\n\n\t\tpublic static long ReadLong()\n\t\t{\n\t\t\tvar s = Console.ReadLine();\n\t\t\treturn long.Parse(s);\n\t\t}\n\n\t\tpublic class Vertex\n\t\t{\n\t\t\tpublic int Was;\n\n\t\t\tpublic List Edges;\n\t\t}\n\n\t\tpublic static List Graph = new List();\n\n\n\t\tpublic static bool Dfs(int u)\n\t\t{\n\t\t\tif (Graph[u].Was == 1) return true;\n\t\t\tif (Graph[u].Was == 2) return false;\n\t\t\tGraph[u].Was = 1;\n\t\t\tforeach (var t in Graph[u].Edges)\n\t\t\t{\n\t\t\t\tif (Dfs(t)) return true;\n\t\t\t}\n\n\t\t\tGraph[u].Was = 2;\n\t\t\treturn false;\n\t\t}\n\n\t\tpublic static bool IsPrime(int x)\n\t\t{\n\t\t\tfor (var j = 2; j * j <= x; ++j)\n\t\t\t\tif (x % j == 0)\n\t\t\t\t\treturn false;\n\t\t\treturn true;\n\t\t}\n\n\t\tpublic class LinkedVertex\n\t\t{\n\t\t\tpublic int Next;\n\n\t\t\tpublic int Prev;\n\n\t\t\tpublic int Value;\n\t\t}\n\n\n\t\tpublic static int BinarySearch(List list, int value)\n\t\t{\n\t\t\tvar l = -1;\n\t\t\tvar r = list.Count;\n\t\t\twhile (r - l > 1)\n\t\t\t{\n\t\t\t\tvar m = (r + l) / 2;\n\t\t\t\tif (list[m] >= value)\n\t\t\t\t\tr = m;\n\t\t\t\telse\n\t\t\t\t\tl = m;\n\t\t\t}\n\n\t\t\treturn r;\n\t\t}\n\n\t\tpublic static Dictionary mp = new Dictionary(); \n\t\tpublic static long Go(long u, long v, long w)\n\t\t{\n\t\t\tlong ans = 0; \n\t\t\twhile (u != v)\n\t\t\t\tif (u > v)\n\t\t\t\t{\n\t\t\t\t\tif (!mp.ContainsKey(u))\n\t\t\t\t\t\tmp.Add(u, 0);\n\t\t\t\t\tans += mp[u];\n\t\t\t\t\tmp[u] += w;\n\t\t\t\t\tu /= 2;\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tif (!mp.ContainsKey(v))\n\t\t\t\t\t\tmp.Add(v, 0);\n\t\t\t\t\tans += mp[v];\n\t\t\t\t\tmp[v] += w;\n\t\t\t\t\tv /= 2;\n\t\t\t\t} \n\t\t\treturn ans;\n\t\t}\n\n\t\tprivate static void Main()\n\t\t{\n\t\t\tvar n = ReadLong();\n\t\t\tvar a = ReadLong();\n\t\t\tvar b = ReadLong();\n\t\t\tvar c = ReadLong();\n\t\t\tif (n < a && n < b)\n\t\t\t{\n\t\t\t\tConsole.WriteLine(0);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (a <= b - c)\n\t\t\t{\n\t\t\t\tConsole.WriteLine(n / a);\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tvar tt = (n - c) / (b - c);\n\t\t\t\ttt = Math.Max(tt, 0);\n\t\t\t\tvar ans = tt + (n - tt * b + tt * c) / a;\n\t\t\t\tConsole.WriteLine(ans);\n\t\t\t}\n\t\t\tConsole.ReadLine();\n\t\t}\n\t}\n}\n", "lang_cluster": "C#", "tags": ["math", "implementation"], "code_uid": "d3856299ccd944930a6015542f848469", "src_uid": "0ee9abec69230eab25de51aef0984f8f", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\n\nnamespace cAPS_lOCK\n{\n class Program\n {\n static void Main(string[] args)\n {\n string s2 = Console.ReadLine();\n char[] s = new char[s2.Length];\n int count = 0;\n for (int i = 0; i < s2.Length; i++)\n {\n s[i] = Convert.ToChar(s2[i]);\n }\n for (int i = 1; i < s.Length; i++)\n {\n if (s[i] >= 'a' && s[i] <= 'z')\n {\n Console.WriteLine(s2);\n return;\n } \n }\n string result = \"\";\n if (s[0] >= 'a' && s[0] <= 'z')\n {\n s[0] = Convert.ToChar(s[0] - 32);\n for (int i = 1; i < s.Length; i++)\n {\n result = result + Convert.ToChar(s[i] + 32);\n }\n Console.WriteLine(result = s[0] + result);\n }\n else\n {\n for (int i = 0; i < s.Length; i++)\n {\n result = result + Convert.ToChar(s[i] + 32);\n }\n Console.WriteLine(result);\n }\n \n }\n }\n}\n", "lang_cluster": "C#", "tags": ["strings", "implementation"], "code_uid": "1383fd14c6643c27c25dcac8ce1e300d", "src_uid": "db0eb44d8cd8f293da407ba3adee10cf", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace cAPSLOCK\n{\n class Program\n {\n static void Main(string[] args)\n {\n string str = Console.ReadLine();\n char a;\n bool perv = false;\n bool vtor = false;\n if (str[0]>=97 && str[0]<=122)\n {\n perv = true;\n }\n for (int i = 1; i < str.Length;i++ )\n {\n if (str[i] >= 97 && str[i] <= 122)\n vtor |= true;\n }\n if (!perv && !vtor)\n {\n str = str.ToLower();\n Console.Write(str);\n return;\n }\n if (perv && !vtor)\n {\n str = str.ToLower();\n a = (char)(str[0] - 32);\n Console.Write(a);\n for (int i=1;i 10 || myReg.IsMatch(Text))//\u0435\u0441\u043b\u0438 \u0447\u0438\u0441\u043b\u043e \u0434\u043b\u0438\u043d\u043d\u043e\u0435 \u0438 \u0435\u0441\u0442\u044c \u0441\u0438\u043c\u0432\u043e\u043b\u044b-\u043e\u0448\u0438\u0431\u043a\u0430 \u0432\u0432\u043e\u0434\u0430\n {\n Console.WriteLine(\"\u0421\u043b\u0438\u0448\u043a\u043e\u043c \u0434\u043b\u0438\u043d\u043d\u043e\u0435 \u0447\u0438\u0441\u043b\u043e \u0438\u043b\u0438 \u0432\u0432\u0435\u0434\u0435\u043d\u044b \u043d\u0435\u0434\u043e\u043f\u0443\u0441\u0442\u0438\u043c\u044b\u0435 \u0441\u0438\u043c\u0432\u043e\u043b\u044b\");\n Console.ReadLine();\n return true;\n }\n return false;\n }\n//=======================\u041a\u043e\u043d\u0435\u0446 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043f\u0440\u0432\u043e\u0435\u0440\u043a\u0438 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0432\u0432\u043e\u0434\u0430=======================\n\n\n//=======================\u0424\u0443\u043d\u043a\u0446\u0438\u044f \u041f\u0435\u0440\u0435\u0432\u043e\u0434 \u0432\u0432\u0435\u0434\u0435\u043d\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0438 \u0432 \u043c\u0430\u0441\u0438\u0432 \u0447\u0438\u0441\u0435\u043b==========================\n public static void StringInMass(ref uint[] Mass, string text)\n { //\u0434\u0430, \u0447\u0438\u0441\u043b\u0430 \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u0437\u0430\u0434\u043e\u043c \u043d\u0430\u043f\u0435\u0440\u0435\u0434. \u041d\u041e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044e \u0442\u043e \u0432\u0441\u0435\u0440\u0430\u0432\u043d\u043e \u0447\u0435 \u0432\u043d\u0443\u0442\u0440\u0438 =)\n int lenText = text.Length; //\u0437\u0430\u043f\u043e\u043c\u0438\u043d\u0430\u0435\u043c \u0434\u043b\u0438\u043d\u043d\u0443 \u0441\u0442\u0440\u043e\u043a\u0438\n for (int i = 0; i <= lenText - 1; i++) //\u0431\u0435\u0433\u0430\u0435\u043c \u043f\u043e\u043a\u0430 \u043d\u0435 \u043a\u043e\u043d\u0447\u0438\u0442\u0441\u044f \u0441\u0442\u0440\u043e\u043a\u0430\n {\n //\u041f\u0435\u0440\u0435\u0432\u043e\u0434\u0438\u043c \u0432\u0432\u0435\u0434\u0435\u043d\u0443\u044e \u0441\u0442\u0440\u043e\u043a\u0443 \u0432 \u0447\u0438\u0441\u043b\u043e \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u0438.\n //\u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c \u0432 \u044f\u0447\u0435\u0439\u043a\u0443 \u043c\u0430\u0441\u0441\u0438\u0432\u0430 \u043e\u0441\u0442\u0430\u0442\u043e\u043a \u043e\u0442 \u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043d\u0430 \u0434\u0435\u0441\u044f\u0442\u044c.\n Mass[i] = Convert.ToUInt32(text) % 10; \n text = text.Remove(text.Length - 1);//\u0443\u0431\u0438\u0440\u0430\u0435\u043c \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u0441\u0438\u043c\u0432\u043e\u043b \u0441\u0442\u0440\u043e\u043a\u0438 \u0447\u0442\u043e\u0431\u044b \u043e\u0431\u0440\u0435\u0437\u0430\u0442\u044c \u0447\u0438\u0441\u043b\u043e\n }\n }\n//=====================\u041a\u043e\u043d\u0435\u0446 \u0424\u0443\u043d\u043a\u0446\u0438\u0438 \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u0430 \u0441\u0442\u0440\u043e\u043a\u0438 \u0432 \u043c\u0430\u0441\u0441\u0438\u0432 \u0447\u0438\u0441\u0435\u043b============================\n\n\n//=====================\u0424\u0443\u043d\u043a\u0446\u0438\u044f \u0421\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0438 \u0438 \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f \u0447\u0438\u0441\u0435\u043b==================================================\n public static void MassObr(uint[] Mass1, uint[] Mass2)\n {\n\n for (int j = 0; j < Mass1.Length-1; j++)//\u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u0430\u044f \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0430 \u043f\u0443\u0437\u044b\u0440\u044c\u043a\u043e\u043c\n {\n for (int i = 0; i < Mass1.Length-j-1; i++)\n {\n if (Mass1[i] < Mass1[i + 1])\n {\n uint b = Mass1[i];\n Mass1[i] = Mass1[i + 1];\n Mass1[i + 1] = b;\n \n }\n\n }\n }\n\n if (Mass1[Mass1.Length - 1] == 0) //\u0435\u0441\u043b\u0438 \u0432 \u043d\u0430\u0447\u0430\u043b\u0435 \u0447\u0438\u0441\u043b\u0430 \u0432\u0435\u0434\u0443\u0449\u0438\u0439 0\n {\n \n\n for (int i = Mass1.Length-1; i > 0; i--) //\u0437\u0430\u043c\u0435\u043d\u0435\u044f\u0435\u043c \u043d\u043e\u043b\u044c \u043d\u0430 \u043f\u0435\u0440\u0432\u043e\u0435 \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u0447\u0438\u0441\u043b\u043e\n {\n if (Mass1[i - 1] != 0)\n {\n uint b = Mass1[i-1];\n Mass1[i-1] = Mass1[i];\n Mass1[Mass1.Length - 1] = b;\n break;\n }\n }\n\n }\n //\u0421\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u0435\u043c \u0434\u0432\u0430 \u043c\u0430\u0441\u0441\u0438\u0432\u0430 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u0438\n if (Mass1.SequenceEqual(Mass2)) Console.WriteLine(\"OK\"); else Console.WriteLine(\"WRONG_ANSWER\");\n Console.ReadLine();\n\n }\n //====================\u041a\u043e\u043d\u0435\u0446 \u0424\u0443\u043d\u043a\u0446\u0438\u0438 \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0438 \u0438 \u0441\u0440\u0430\u0432\u043d\u0438\u043d\u0438\u044f \u0447\u0438\u0441\u0435\u043b================================\n }\n }\n;\n", "lang_cluster": "C#", "tags": ["sortings", "implementation"], "code_uid": "6496a335c3da5d044121256cbc89038e", "src_uid": "d1e381b72a6c09a0723cfe72c0917372", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Linq;\n\nnamespace ConsoleApplication1\n{\n class Program\n {\n\n static void Main(string[] args)\n {\n string[] arg = Console.ReadLine().Split();\n Int64 requested = Convert.ToInt64(arg[0]);\n Int64 spd1 = Convert.ToInt64(arg[1]);\n Int64 spd2 = Convert.ToInt64(arg[2]);\n Int64[] minimize = new Int64[requested + 1];\n minimize[1] = spd1;\n decimal num = 0;\n long num2 = 0;\n int oddeven = 2;\n for (int i = 2; i <= requested; i++)\n {\n num = (decimal)i / 2;\n if (oddeven == 1)\n {\n num2 = spd2 + spd1;\n minimize[i] = new[] { minimize[i - 1] + spd1, minimize[Convert.ToInt32(Math.Ceiling(num))] + num2}.Min();\n }\n else\n {\n minimize[i] = new[] { minimize[i - 1] + spd1, minimize[Convert.ToInt32(num)] + spd2 }.Min();\n\n }\n if (oddeven == 2)\n oddeven = 1;\n else\n oddeven = 2;\n }\n Console.WriteLine(minimize[requested]);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["dfs and similar", "dp"], "code_uid": "c62b234643d20610d19bc9adec6cc6f8", "src_uid": "0f270af00be2a523515d5e7bd66800f6", "difficulty": 2000.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.IO;\nusing System.Text;\nusing System.Linq;\nusing System.Globalization;\n\nclass Program\n{\n static void Main(string[] args)\n {\n var tmp = Console.ReadLine().Split();\n int n = int.Parse(tmp[0]);\n long x = int.Parse(tmp[1]);\n long y = int.Parse(tmp[2]);\n\n int nn = n;\n n = (nn * 4 + 3) / 3;\n\n long[] dp = new long[n];\n for (int i = 1; i < n; i++) dp[i] = dp[i - 1] + x;\n for (int i = 1; i < n; i++)\n {\n if (i + i < n && dp[i + i] > dp[i] + y) dp[i + i] = dp[i] + y;\n if (i + 1 < n && dp[i + 1] > dp[i] + x) dp[i + 1] = dp[i] + x;\n\n while (dp[i - 1] > dp[i] + x)\n {\n dp[i - 1] = dp[i] + x;\n i -= 2;\n }\n }\n\n Console.Write(dp[nn]);\n }\n}", "lang_cluster": "C#", "tags": ["dfs and similar", "dp"], "code_uid": "81fe03bb07383d20cdf98bc9bccd4b62", "src_uid": "0f270af00be2a523515d5e7bd66800f6", "difficulty": 2000.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Text;\nusing System.IO;\nusing System.Linq;\nusing System.Collections;\n\nnamespace Task\n{\n class Program\n {\n int GetDiag(int s, int mlp)\n {\n return s > 0\n ? s / mlp + 1\n : s / mlp;\n }\n\n void Solve()\n {\n // Place your code here\n int a = io.NextInt();\n int b = io.NextInt();\n\n int x1 = io.NextInt();\n int y1 = io.NextInt();\n\n int x2 = io.NextInt();\n int y2 = io.NextInt();\n\n int diagA1 = GetDiag(x1 + y1, 2 * a);\n int diagB1 = GetDiag(x1 - y1, 2 * b);\n\n int diagA2 = GetDiag(x2 + y2, 2 * a);\n int diagB2 = GetDiag(x2 - y2, 2 * b);\n\n int d1 = Math.Abs(diagA1 - diagA2);\n int d2 = Math.Abs(diagB1 - diagB2);\n\n int ans = d1 + d2 - Math.Min(d1, d2);\n\n io.PrintLine(ans);\n }\n\n MyIo io = new MyIo();\n\n static void Main(string[] args)\n {\n var p = new Program();\n\n p.Solve();\n p.io.Close();\n }\n }\n\n class MyIo\n {\n char[] separators = new char[] { ' ', '\\t' };\n\n#if TEST\n TextReader inputStream = new StreamReader(\"..\\\\..\\\\input.txt\");\n#else\n TextReader inputStream = System.Console.In;\n#endif\n TextWriter outputStream = Console.Out;\n\n string[] tokens;\n int pointer;\n\n public string NextLine()\n {\n try\n {\n return inputStream.ReadLine();\n }\n catch (IOException)\n {\n return null;\n }\n }\n\n public string NextString()\n {\n try\n {\n while (tokens == null || pointer >= tokens.Length)\n {\n tokens = NextLine().Split(separators, StringSplitOptions.RemoveEmptyEntries);\n pointer = 0;\n }\n return tokens[pointer++];\n }\n catch (IOException)\n {\n return null;\n }\n }\n\n public int NextInt()\n {\n return int.Parse(NextString());\n }\n\n public long NextLong()\n {\n return long.Parse(NextString());\n }\n\n public void Print(string format, params object[] args)\n {\n outputStream.Write(format, args);\n }\n\n public void PrintLine(string format, params object[] args)\n {\n outputStream.WriteLine(format, args);\n }\n\n public void Print(T o)\n {\n outputStream.Write(o);\n }\n\n public void PrintLine(T o)\n {\n outputStream.WriteLine(o);\n }\n\n public void Close()\n {\n inputStream.Close();\n outputStream.Close();\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math"], "code_uid": "f09cd580bac0170373d88ca941924dea", "src_uid": "7219d1837c83b5920992aee5a60dc0d9", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\n\nnamespace Codeforces\n{\n class Program\n { \n static int ReadInt()\n {\n return Int32.Parse(Console.ReadLine());\n }\n static long ReadLong()\n {\n return long.Parse(Console.ReadLine());\n }\n static void ReadIntArray(out int[] array, char separator = ' ')\n {\n var input = Console.ReadLine().Split(separator);\n array = new int[input.Length];\n for (int i = 0; i < input.Length; i++)\n {\n array[i] = Int32.Parse(input[i]);\n }\n\n }\n static int ReadNextInt(string input, int index)\n {\n var ints = input.Split(' ');\n return Int32.Parse(ints[index]);\n }\n static void Main()\n {\n int res = 0;\n\n var input = Console.ReadLine();\n var a = ReadNextInt(input, 0);\n var b = ReadNextInt(input, 1);\n var x1 = ReadNextInt(input, 2);\n var y1 = ReadNextInt(input, 3);\n var x2 = ReadNextInt(input, 4);\n var y2 = ReadNextInt(input, 5);\n\n var k1 = Math.Min(x1 + y1, x2 + y2);\n var k2 = Math.Max(x1 + y1, x2 + y2);\n var m1 = Math.Min(x1 - y1, x2 - y2);\n var m2 = Math.Max(x1 - y1, x2 - y2);\n\n var n1 = k1/(2*a);\n var n2 = k2/(2*a);\n if (k1 < 0)\n n1--;\n if (k2 < 0)\n n2--;\n res = n2 - n1;\n n1 = m1/(2*b);\n n2 = m2/(2*b);\n if (m1 < 0)\n n1--;\n if (m2 < 0)\n n2--;\n \n res = Math.Max(res, n2-n1);\n \n Console.WriteLine(res);\n }\n }\n}", "lang_cluster": "C#", "tags": ["brute force", "constructive algorithms", "number theory"], "code_uid": "d519efdd553cd05d3bda7f249dbcaed0", "src_uid": "7219d1837c83b5920992aee5a60dc0d9", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text.RegularExpressions;\n\nnamespace Rextester\n{\n public class Program\n {\n public static void Main(string[] args)\n {\n string[] token = Console.ReadLine().Split();\n \n int w1 = int.Parse(token[0]);\n int h1 = int.Parse(token[1]);\n \n int w2 = int.Parse(token[2]);\n int h2 = int.Parse(token[3]);\n \n int HH = h1 + h2;\n \n int WW = Math.Max(w1,w2);\n \n int ans = 2 * (HH+WW) + 4;\n \n Console.WriteLine(ans);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math"], "code_uid": "7df9b207ef666f4b839f9fec66aac6b5", "src_uid": "b5d44e0041053c996938aadd1b3865f6", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.IO;\nusing System.Linq;\nusing System.Text;\nusing System.Threading;\n\nnamespace CodeForces\n{\n\tclass Program\n\t{\n\t\tstatic void Main(string[] args)\n\t\t{\n\t\t\tvar arr = Array.ConvertAll(Console.ReadLine().Split(), Int64.Parse);\n\t\t\tvar w1 = arr[0];\n\t\t\tvar h1 = arr[1];\n\t\t\tvar w2 = arr[2];\n\t\t\tvar h2 = arr[3];\n\t\t\tvar ans = (h1 + h2) * 2 + w1 * 2 + 4;\n\t\t\tConsole.WriteLine(ans);\n\t\t}\n\n\t\tstatic int Int()\n\t\t{\n\t\t\treturn Int32.Parse(Console.ReadLine());\n\t\t}\n\n\t\tstatic (int, int) Int2()\n\t\t{\n\t\t\tvar arr = Array.ConvertAll(Console.ReadLine().Split(), Int32.Parse);\n\t\t\treturn (arr[0], arr[1]);\n\t\t}\n\n\t\tstatic int[] Ints()\n\t\t{\n\t\t\treturn Array.ConvertAll(Console.ReadLine().Split(), Int32.Parse);\n\t\t}\n\n\t\tstatic long Long()\n\t\t{\n\t\t\treturn Int64.Parse(Console.ReadLine());\n\t\t}\n\n\t\tstatic (long, long) Long2()\n\t\t{\n\t\t\tvar arr = Array.ConvertAll(Console.ReadLine().Split(), Int64.Parse);\n\t\t\treturn (arr[0], arr[1]);\n\t\t}\n\n\t\tstatic long[] Longs()\n\t\t{\n\t\t\treturn Array.ConvertAll(Console.ReadLine().Split(), Int64.Parse);\n\t\t}\n\n\t\tstatic string Str()\n\t\t{\n\t\t\treturn Console.ReadLine();\n\t\t}\n\t}\n}", "lang_cluster": "C#", "tags": ["math"], "code_uid": "014c690a3dfa64f70156fd9fb45ad5b4", "src_uid": "b5d44e0041053c996938aadd1b3865f6", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nnamespace SortApp\n{\n class Program\n {\n static void Main(string[] args)\n {\n string str = Console.ReadLine();\n string [] s = str.Split(' ');\n int red = Convert.ToInt32(s[0]);\n int blue = Convert.ToInt32(s[1]);\n int yes = 0;\n int no = 0;\n if (red > blue)\n {\n yes = blue;\n no = (red - blue) / 2;\n\n }\n else\n {\n yes = red;\n no = (blue - red) / 2;\n }\n \n Console.WriteLine(yes+\" \"+no);\n //Console.WriteLine(1/2);\n \n Console.Read();\n\n }\n }\n}", "lang_cluster": "C#", "tags": ["math", "implementation"], "code_uid": "6398f504bdae6183e7bf7b2573b1116e", "src_uid": "775766790e91e539c1cfaa5030e5b955", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.IO;\n\nnamespace Issue_581A\n{\n class Program\n {\n public static void Main(string[] args) {\n var reds = IO.Read();\n var blues = IO.Read();\n\n if (reds < blues) {\n Swap(ref reds, ref blues);\n }\n\n var different = blues;\n var equal = (reds - blues) >> 1;\n\n Console.WriteLine(\"{0} {1}\", different, equal);\n }\n\n public static void Swap(ref int a, ref int b) {\n a = a ^ b;\n b = a ^ b;\n a = a ^ b;\n }\n }\n\n public static class IO {\n public static bool IsInputError = false;\n public static bool IsEndOfLine = false;\n\n static IO() {\n Reader = new StreamReader(\n Console.OpenStandardInput(sizeof(int)),\n System.Text.Encoding.ASCII,\n false, \n sizeof(int),\n false);\n }\n\n public static StreamReader Reader { get; set; }\n\n public static int Read() {\n const int zeroCode = (int) '0';\n\n int result = 0;\n int digit;\n int cache1;\n int cache2;\n\n var isNegative = false;\n var symbol = Reader.Read();\n IsInputError = false;\n IsEndOfLine = false;\n\n while (symbol == ' ') {\n symbol = Reader.Read();\n }\n\n if (symbol == '-') {\n isNegative = true;\n symbol = Reader.Read();\n }\n\n for ( ;\n (symbol != -1) && (symbol != ' ');\n symbol = Reader.Read()\n ) {\n digit = symbol - zeroCode;\n \n // if symbol == \\n\n if (symbol == 13) {\n // skip next \\r symbol\n Reader.Read();\n IsEndOfLine = true;\n break;\n }\n\n if (digit < 10 && digit >= 0) {\n cache1 = result << 1;\n cache2 = cache1 << 2;\n result = cache1 + cache2 + digit;\n } else {\n IsInputError = true;\n break;\n }\n }\n\n return isNegative ? ~result + 1 : result;\n }\n }\n}", "lang_cluster": "C#", "tags": ["math", "implementation"], "code_uid": "599065819ce66b98ae0fd5a53d27eccf", "src_uid": "775766790e91e539c1cfaa5030e5b955", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.IO;\nusing System.Linq;\nusing System.Text;\n\nnamespace Chores\n{\n internal class Program\n {\n private static readonly StreamReader reader = new StreamReader(Console.OpenStandardInput(1024*10), Encoding.ASCII, false, 1024*10);\n private static readonly StreamWriter writer = new StreamWriter(Console.OpenStandardOutput(1024*10), Encoding.ASCII, 1024*10);\n\n private static void Main(string[] args)\n {\n writer.WriteLine(Solve(args));\n writer.Flush();\n }\n\n private static int Solve(string[] args)\n {\n int n = Next();\n int k = Next();\n int x = Next();\n\n var nn = new int[n];\n for (int i = 0; i < n; i++)\n {\n nn[i] = Next();\n }\n\n for (int i = 0; i < k; i++)\n {\n nn[n - 1 - i] = x;\n }\n\n return nn.Sum();\n }\n\n private static int Next()\n {\n int c;\n int res = 0;\n do\n {\n c = reader.Read();\n if (c == -1)\n return res;\n } while (c < '0' || c > '9');\n res = c - '0';\n while (true)\n {\n c = reader.Read();\n if (c < '0' || c > '9')\n return res;\n res *= 10;\n res += c - '0';\n }\n }\n }\n}", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "0fac9a55bcaf622e7061e76eef9f431c", "src_uid": "92a233f8d9c73d9f33e4e6116b7d0a96", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\n\nclass test\n{\n static void Main()\n {\n string[] s = Console.ReadLine().Split();\n int n = int.Parse(s[0]),k = int.Parse(s[1]),x = int.Parse(s[2]),r=0;\n s = Console.ReadLine().Split();\n for (int i = 0; i < n - k; i++)\n r += int.Parse(s[i]);\n r += x * k;\n Console.WriteLine(r);\n }\n}", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "1db9e1f7aff945df786a0f9d3b98cc1d", "src_uid": "92a233f8d9c73d9f33e4e6116b7d0a96", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace A1\n{\n class Program\n {\n static void Main(string[] args)\n {\n int res = 1;\n String s = Console.ReadLine();\n Dictionary d=new Dictionary();\n int mul;\n for (int i = 0; i < s.Length;i++ )\n {\n if (i == 0) mul = 9;\n else mul = 10;\n if (s[i] == '?')\n res *= mul;\n if (s[i] >= 'A' && s[i] <= 'J')\n {\n if(i!=0)mul = 10-d.Count;\n try\n {\n d.Add(s[i], s[i]);\n res *= mul;\n }\n catch\n {\n \n }\n }\n }\n Console.WriteLine(res);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["greedy"], "code_uid": "153a4ac16b8a10712721d0cbe912dcdb", "src_uid": "d3c10d1b1a17ad018359e2dab80d2b82", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "#define Online\n\nusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.IO;\n\nnamespace CF\n{\n delegate double F(double x);\n delegate decimal Fdec(decimal x);\n\n class Program\n {\n\n static void Main(string[] args)\n {\n\n#if FileIO\n StreamReader sr = new StreamReader(\"input.txt\");\n StreamWriter sw = new StreamWriter(\"output.txt\");\n Console.SetIn(sr);\n Console.SetOut(sw);\n#endif\n\n A();\n\n#if Online\n Console.ReadLine();\n#endif\n\n#if FileIO\n sr.Close();\n sw.Close();\n#endif\n }\n\n static void A()\n {\n string input = ReadLine();\n int tens = 0;\n bool[] letters = new bool[10];\n int cnt = 10;\n int other = 1;\n bool isPrevNull = false;\n for (int i = 0; i < input.Length; i++)\n {\n if (input[i].Equals('?'))\n {\n if (i == 0)\n {\n other *= 9;\n continue;\n }\n tens++;\n }\n else\n {\n if (!char.IsDigit(input[i]))\n {\n if (!letters[input[i] - 'A'])\n {\n if (i == 0) other *= --cnt;\n else other *= cnt--;\n letters[input[i] - 'A'] = true;\n }\n }\n }\n }\n StringBuilder ans = new StringBuilder();\n ans.Append(other.ToString());\n for (int i = 0; i < tens; i++)\n ans.Append(\"0\");\n Console.WriteLine(ans);\n }\n\n static void B()\n {\n\n }\n\n static void C()\n {\n\n }\n\n static void D()\n {\n\n }\n\n static void E()\n {\n\n }\n\n static void TestGen()\n {\n\n }\n\n static string[] ReadArray(char sep)\n {\n return Console.ReadLine().Split(sep);\n }\n\n static int ReadInt()\n {\n return int.Parse(Console.ReadLine());\n }\n\n static string ReadLine()\n {\n return Console.ReadLine();\n }\n }\n\n public static class MyMath\n {\n public static long BinPow(long a, long n, long mod)\n {\n long res = 1;\n while (n > 0)\n {\n if ((n & 1) == 1)\n {\n res = (res * a) % mod;\n }\n a = (a * a) % mod;\n n >>= 1;\n }\n return res;\n }\n\n public static long GCD(long a, long b)\n {\n while (b != 0) b = a % (a = b);\n return a;\n }\n\n public static int GCD(int a, int b)\n {\n while (b != 0) b = a % (a = b);\n return a;\n }\n\n public static long LCM(long a, long b)\n {\n return (a * b) / GCD(a, b);\n }\n\n public static int LCM(int a, int b)\n {\n return (a * b) / GCD(a, b);\n }\n }\n\n class Edge\n {\n public int a;\n public int b;\n public int w;\n\n public Edge(int a, int b, int w)\n {\n this.a = a;\n this.b = b;\n this.w = w;\n }\n }\n\n class Graph\n {\n public List[] g;\n public int[] color; //0-white, 1-gray, 2-black\n public int[] o; //open\n public int[] c; //close\n public int[] p;\n public int[] d;\n public List e;\n public Stack ans = new Stack();\n public Graph(int n)\n {\n g = new List[n + 1];\n for (int i = 0; i <= n; i++)\n g[i] = new List();\n color = new int[n + 1];\n o = new int[n + 1];\n c = new int[n + 1];\n p = new int[n + 1];\n d = new int[n + 1];\n }\n\n const int white = 0;\n const int gray = 1;\n const int black = 2;\n\n public bool DFS(int u, ref int time)\n {\n color[u] = gray;\n time++;\n o[u] = time;\n for (int i = 0; i < g[u].Count; i++)\n {\n int v = g[u][i];\n if (color[v] == gray)\n {\n return true;\n }\n if (color[v] == white)\n {\n p[v] = u;\n if (DFS(v, ref time)) return true;\n }\n }\n color[u] = black;\n ans.Push(u);\n c[u] = time;\n time++;\n return false;\n }\n }\n\n static class GraphUtils\n {\n const int white = 0;\n const int gray = 1;\n const int black = 2;\n\n public static void BFS(int s, Graph g)\n {\n Queue q = new Queue();\n q.Enqueue(s);\n while (q.Count != 0)\n {\n int u = q.Dequeue();\n for (int i = 0; i < g.g[u].Count; i++)\n {\n int v = g.g[u][i];\n if (g.color[v] == white)\n {\n g.color[v] = gray;\n g.d[v] = g.d[u] + 1;\n g.p[v] = u;\n q.Enqueue(v);\n }\n }\n g.color[u] = black;\n }\n }\n\n public static bool DFS(int u, ref int time, Graph g, Stack st)\n {\n g.color[u] = gray;\n time++;\n g.o[u] = time;\n for (int i = 0; i < g.g[u].Count; i++)\n {\n int v = g.g[u][i];\n if (g.color[v] == gray)\n {\n return true;\n }\n if (g.color[v] == white)\n {\n g.p[v] = u;\n if (DFS(v, ref time, g, st)) return true;\n }\n }\n g.color[u] = black;\n st.Push(u);\n g.c[u] = time;\n time++;\n return false;\n }\n\n public static void FordBellman(int u, Graph g)\n {\n int n = g.g.Length;\n for (int i = 0; i <= n; i++)\n {\n g.d[i] = int.MaxValue;\n g.p[i] = 0;\n }\n\n g.d[u] = 0;\n\n for (int i = 0; i < n - 1; i++)\n {\n for (int j = 0; j < g.e.Count; j++)\n {\n if (g.d[g.e[j].a] != int.MaxValue)\n {\n if (g.d[g.e[j].a] + g.e[j].w < g.d[g.e[j].b])\n {\n g.d[g.e[j].b] = g.d[g.e[j].a] + g.e[j].w;\n g.p[g.e[j].b] = g.e[j].a;\n }\n }\n }\n }\n }\n }\n\n static class ArrayUtils\n {\n public static int BinarySearch(int[] a, int val)\n {\n int left = 0;\n int right = a.Length - 1;\n int mid;\n\n while (left < right)\n {\n mid = left + ((right - left) >> 1);\n if (val <= a[mid])\n {\n right = mid;\n }\n else\n {\n left = mid + 1;\n }\n }\n\n if (a[left] == val)\n return left;\n else\n return -1;\n }\n\n public static double Bisection(F f, double left, double right, double eps)\n {\n double mid;\n while (right - left > eps)\n {\n mid = left + ((right - left) / 2d);\n if (Math.Sign(f(mid)) != Math.Sign(f(left)))\n right = mid;\n else\n left = mid;\n }\n return (left + right) / 2d;\n }\n\n\n public static decimal TernarySearchDec(Fdec f, decimal eps, decimal l, decimal r, bool isMax)\n {\n decimal m1, m2;\n while (r - l > eps)\n {\n m1 = l + (r - l) / 3m;\n m2 = r - (r - l) / 3m;\n if (f(m1) < f(m2))\n if (isMax)\n l = m1;\n else\n r = m2;\n else\n if (isMax)\n r = m2;\n else\n l = m1;\n }\n return r;\n }\n\n public static double TernarySearch(F f, double eps, double l, double r, bool isMax)\n {\n double m1, m2;\n while (r - l > eps)\n {\n m1 = l + (r - l) / 3d;\n m2 = r - (r - l) / 3d;\n if (f(m1) < f(m2))\n if (isMax)\n l = m1;\n else\n r = m2;\n else\n if (isMax)\n r = m2;\n else\n l = m1;\n }\n return r;\n }\n\n public static void Merge(T[] A, int p, int q, int r, T[] L, T[] R, Comparison comp)\n {\n for (int i = p; i <= q; i++)\n L[i] = A[i];\n for (int i = q + 1; i <= r; i++)\n R[i] = A[i];\n\n for (int k = p, i = p, j = q + 1; k <= r; k++)\n {\n if (i > q)\n {\n for (; k <= r; k++, j++)\n A[k] = R[j];\n return;\n }\n if (j > r)\n {\n for (; k <= r; k++, i++)\n A[k] = L[i];\n return;\n }\n if (comp(L[i], R[j]) <= 0)\n {\n A[k] = L[i];\n i++;\n }\n else\n {\n A[k] = R[j];\n j++;\n }\n }\n }\n\n public static void Merge_Sort(T[] A, int p, int r, T[] L, T[] R, Comparison comp)\n {\n if (p >= r) return;\n int q = p + ((r - p) >> 1);\n Merge_Sort(A, p, q, L, R, comp);\n Merge_Sort(A, q + 1, r, L, R, comp);\n Merge(A, p, q, r, L, R, comp);\n }\n\n public static void Merge(T[] A, int p, int q, int r, T[] L, T[] R) where T : IComparable\n {\n for (int i = p; i <= q; i++)\n L[i] = A[i];\n for (int i = q + 1; i <= r; i++)\n R[i] = A[i];\n\n for (int k = p, i = p, j = q + 1; k <= r; k++)\n {\n if (i > q)\n {\n for (; k <= r; k++, j++)\n A[k] = R[j];\n return;\n }\n if (j > r)\n {\n for (; k <= r; k++, i++)\n A[k] = L[i];\n return;\n }\n if (L[i].CompareTo(R[j]) <= 0)\n {\n A[k] = L[i];\n i++;\n }\n else\n {\n A[k] = R[j];\n j++;\n }\n }\n }\n\n public static void Merge_Sort(T[] A, int p, int r, T[] L, T[] R) where T : IComparable\n {\n if (p >= r) return;\n int q = p + ((r - p) >> 1);\n Merge_Sort(A, p, q, L, R);\n Merge_Sort(A, q + 1, r, L, R);\n Merge(A, p, q, r, L, R);\n }\n\n static void Shake(T[] a)\n {\n Random rnd = new Random(Environment.TickCount);\n T temp;\n int b, c;\n for (int i = 0; i < a.Length; i++)\n {\n b = rnd.Next(0, a.Length);\n c = rnd.Next(0, a.Length);\n temp = a[b];\n a[b] = a[c];\n a[c] = temp;\n }\n }\n }\n}", "lang_cluster": "C#", "tags": ["greedy"], "code_uid": "b08013569e9d76fff77af42cc77fc69e", "src_uid": "d3c10d1b1a17ad018359e2dab80d2b82", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\n\nnamespace tmpRound\n{\n class Program\n {\n static int Main(string[] args)\n {\n string[] strMas = Console.ReadLine().Split(' ');\n int n = int.Parse(strMas[0]), k = int.Parse(strMas[1]), numberG, numberT;\n string s = Console.ReadLine();\n numberG = s.IndexOf('G');\n numberT = s.IndexOf('T');\n if (Math.Abs(numberG - numberT) % k == 0)\n {\n int i = Math.Min(numberT, numberG) + k;\n while (s[i] != 'G' && s[i] != 'T')\n { \n if(s[i] == '#')\n {\n Console.WriteLine(\"NO\");\n return 0;\n }\n i += k;\n }\n Console.WriteLine(\"YES\");\n return 0;\n }\n Console.WriteLine(\"NO\");\n return 0;\n }\n }\n}", "lang_cluster": "C#", "tags": ["strings", "implementation"], "code_uid": "dfa747a908e3df1f9ff3a80c806c0e62", "src_uid": "189a9b5ce669bdb04b9d371d74a5dd41", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.ComponentModel;\nusing System.Linq;\n\nnamespace ConsoleApplication17\n{\n internal class Program\n {\n private static void Main(string[] args)\n {\n string str = Console.ReadLine();\n\n int n = Int32.Parse(str.Split(' ')[0]);\n int k = Int32.Parse(str.Split(' ')[1]);\n\n string str1 = Console.ReadLine();\n\n List TG = new List();\n\n int nomerT = str1.ToCharArray().ToList().IndexOf('T');\n int nomerG = str1.ToCharArray().ToList().IndexOf('G');\n\n TG.Add(nomerG);\n TG.Add(nomerT);\n\n int raznTG = Math.Abs(nomerG - nomerT);\n int indicator = 0;\n\n if (raznTG < k)\n {\n Console.WriteLine(\"NO\");\n }\n else if (raznTG == k)\n {\n Console.WriteLine(\"YES\");\n }\n else if (raznTG%k != 0)\n {\n Console.WriteLine(\"NO\");\n }\n else\n {\n for (int i = TG.Min(); i < TG.Max(); i = i + k)\n {\n if (str1.ToCharArray()[i] == '#')\n {\n indicator++;\n break;\n }\n }\n\n if (indicator == 0)\n {\n Console.WriteLine(\"YES\");\n }\n else\n {\n Console.WriteLine(\"NO\");\n }\n\n }\n \n \n \n }\n }\n}\n", "lang_cluster": "C#", "tags": ["strings", "implementation"], "code_uid": "bff2efaa81ddba8925b1ff784085518f", "src_uid": "189a9b5ce669bdb04b9d371d74a5dd41", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace Z1294\n{\n class Program\n {\n static void Main(string[] args)\n {\n string[] req = Console.ReadLine().Split(' ');\n\n int len1 = int.Parse(req[0]);\n int len2 = int.Parse(req[1]);\n\n int[] nums1 = new int[len1];\n int[] nums2 = new int[len2];\n\n req = Console.ReadLine().Split(' ');\n\n for (int i = 0; i < len1; i++)\n {\n nums1[i] = int.Parse(req[i]);\n }\n\n req = Console.ReadLine().Split(' ');\n\n for (int i = 0; i < len2; i++)\n {\n nums2[i] = int.Parse(req[i]);\n }\n\n int minNum = 99;\n\n for (int i = 0; i < len1; i++)\n {\n for (int j = 0; j < len2; j++)\n {\n if (nums1[i] == nums2[j])\n {\n minNum = Math.Min(minNum, nums2[j]);\n }\n else\n {\n minNum = Math.Min(minNum, nums1[i] * 10 + nums2[j]);\n minNum = Math.Min(minNum, nums2[j] * 10 + nums1[i]);\n }\n }\n }\n\n Console.WriteLine(minNum);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "implementation"], "code_uid": "48fe0fec7f4be8bcc7a081852355fa4b", "src_uid": "3a0c1b6d710fd8f0b6daf420255d76ee", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace ConsoleApp4\n{\n class Program\n {\n static void Main(string[] args)\n {\n\n Console.ReadLine();\n string[] firstValues = Console.ReadLine().Split(' ');\n string[] secondValues = Console.ReadLine().Split(' ');\n SortedSet firstSet=new SortedSet();\n SortedSet secondSet = new SortedSet();\n for (int i = 0; i < firstValues.Length; i++)\n firstSet.Add(Convert.ToInt16(firstValues[i]));\n for (int i = 0; i < secondValues.Length; i++)\n secondSet.Add(Convert.ToInt16(secondValues[i]));\n if (!firstSet.Intersect(secondSet).Any())\n if(firstSet.First()< secondSet.First())\n Console.WriteLine(firstSet.First().ToString() + secondSet.First().ToString());\n else\n Console.WriteLine(secondSet.First().ToString() + firstSet.First().ToString());\n else\n {\n firstSet.IntersectWith(secondSet);\n Console.WriteLine(firstSet.First());\n } \n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "implementation"], "code_uid": "671d456c917380af88aa765cc1d9929d", "src_uid": "3a0c1b6d710fd8f0b6daf420255d76ee", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffnamespace Csharp_Contest\n{\n using System;\n using System.Collections.Generic;\n using System.Globalization;\n using System.IO;\n using System.Linq;\n using System.Text;\n using System.Threading;\n using System.Diagnostics;\n\n static class Program\n {\n private const long Mod = (long) (1e9 + 7);\n static void Solve()\n {\n long n = NextLong();\n long factorial = n;\n long power = 1;\n for (long i = 1; i < n; i++)\n {\n factorial = (factorial * i) % Mod;\n power = (power * 2) % Mod;\n }\n\n long ans = factorial - power;\n while (ans < 0)\n {\n ans += Mod;\n }\n\n ans %= Mod;\n\n Console.WriteLine(ans);\n }\n\n public static void Main(string[] args)\n {\n#if CLown1331\n for (int testCase = 0; testCase < 3; testCase++)\n {\n Solve();\n }\n#else\n if (args.Length == 0)\n {\n Console.SetOut(new Printer(Console.OpenStandardOutput()));\n }\n\n Thread t = new Thread(Solve, 134217728);\n t.Start();\n t.Join();\n Console.Out.Flush();\n#endif\n#if CLown1331\n if (Debugger.IsAttached) Thread.Sleep(Timeout.Infinite);\n#endif\n }\n\n static int NextInt() => int.Parse(Console_.NextString());\n static long NextLong() => long.Parse(Console_.NextString());\n static double NextDouble() => double.Parse(Console_.NextString());\n static string NextString() => Console_.NextString();\n static string NextLine() => Console.ReadLine();\n static IEnumerable OrderByRand(this IEnumerable x) => x.OrderBy(_ => xorshift);\n static long Count(this IEnumerable x, Func pred) => Enumerable.Count(x, pred);\n static IEnumerable Repeat(T v, long n) => Enumerable.Repeat(v, (int)n);\n static IEnumerable Range(long s, long c) => Enumerable.Range((int)s, (int)c);\n static uint xorshift { get { _xsi.MoveNext(); return _xsi.Current; } }\n static IEnumerator _xsi = _xsc();\n static IEnumerator _xsc() { uint x = 123456789, y = 362436069, z = 521288629, w = (uint)(DateTime.Now.Ticks & 0xffffffff); while (true) { var t = x ^ (x << 11); x = y; y = z; z = w; w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)); yield return w; } }\n\n static class Console_\n {\n static Queue param = new Queue();\n public static string NextString()\n {\n if (param.Count == 0)\n {\n foreach (string item in NextLine().Split(' '))\n {\n param.Enqueue(item);\n }\n }\n return param.Dequeue();\n }\n }\n class Printer : StreamWriter\n {\n public override IFormatProvider FormatProvider => CultureInfo.InvariantCulture;\n public Printer(Stream stream) : base(stream, new UTF8Encoding(false, true)) { base.AutoFlush = false; }\n public Printer(Stream stream, Encoding encoding) : base(stream, encoding) { base.AutoFlush = false; }\n }\n }\n}", "lang_cluster": "C#", "tags": ["math", "dp", "combinatorics", "graphs"], "code_uid": "ecb11fc0deb1857666f4964b1183104a", "src_uid": "3dc1ee09016a25421ae371fa8005fce1", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\n\nnamespace ContestTemplateStartUp\n{\n class ProgramA_\n {\n public class Heap where TK : IComparable\n {\n public bool Any()\n {\n return _list.Any();\n }\n\n public int Count\n {\n get { return _list.Count; }\n }\n\n private readonly List> _list = new List>();\n private int GetParentIndex(int index)\n {\n return ((index + 1) / 2) - 1;\n }\n\n private int? GetLeftChildIndex(int index)\n {\n int result = 2 * (index + 1) - 1;\n return result < _list.Count ? result : (int?)null;\n }\n\n private int? GetRightChildIndex(int index)\n {\n int result = 2 * (index + 1);\n return result < _list.Count ? result : (int?)null; ;\n }\n\n public void Insert(TK newValue, TV value)\n {\n _list.Add(new KeyValuePair(newValue, value));\n SiftUp(_list.Count - 1);\n }\n private void SiftDown(int index)\n {\n var leftChildIndex = GetLeftChildIndex(index);\n var rightChildIndex = GetRightChildIndex(index);\n\n var leftChild = leftChildIndex.HasValue ? (KeyValuePair?)_list[leftChildIndex.Value] : null;\n\n var rightChild = rightChildIndex.HasValue ? (KeyValuePair?)_list[rightChildIndex.Value] : null;\n\n var curr = _list[index];\n\n if (leftChild != null)\n {\n if (rightChild != null)\n {\n if (leftChild.Value.Key.CompareTo(curr.Key) > 0 && leftChild.Value.Key.CompareTo(rightChild.Value.Key) >= 0)\n {\n _list[index] = leftChild.Value;\n _list[leftChildIndex.Value] = curr;\n SiftDown(leftChildIndex.Value);\n }\n else if (rightChild.Value.Key.CompareTo(curr.Key) > 0 && rightChild.Value.Key.CompareTo(leftChild.Value.Key) >= 0)\n {\n _list[index] = rightChild.Value;\n _list[rightChildIndex.Value] = curr;\n SiftDown(rightChildIndex.Value);\n }\n }\n else\n {\n if (leftChild.Value.Key.CompareTo(curr.Key) > 0)\n {\n _list[index] = leftChild.Value;\n _list[leftChildIndex.Value] = curr;\n }\n }\n }\n\n }\n private void SiftUp(int index)\n {\n if (index == 0) return;\n var element = _list[index];\n var parentIndex = GetParentIndex(index);\n var parent = _list[parentIndex];\n if (parent.Key.CompareTo(element.Key) < 0)\n {\n _list[index] = parent;\n _list[parentIndex] = element;\n SiftUp(parentIndex);\n }\n }\n\n public KeyValuePair ExtractMax()\n {\n if (_list.Count <= 0) throw new InvalidOperationException();\n var last = GetLast();\n var max = _list[0];\n _list[0] = last;\n _list.RemoveAt(_list.Count - 1);\n if (_list.Any())\n {\n SiftDown(0);\n }\n return max;\n }\n\n private KeyValuePair GetLast()\n {\n return _list[_list.Count - 1];\n }\n\n public KeyValuePair GetMax()\n {\n if (_list.Count <= 0) throw new InvalidOperationException();\n var last = GetLast();\n var max = _list[0];\n return max;\n }\n }\n static void Main(string[] args)\n {\n //var results = new List();\n //foreach (var test in Enumerable.Range(0, GetIntFromReadLine()))\n {\n var n = GetInt();\n var nonCyclic = GetPower(2, n - 1);\n var factorial = GetFactorial(n);\n var diff = ((factorial - nonCyclic) + Modulo) % Modulo;\n\n Console.WriteLine(diff);\n // Console.WriteLine(result);\n //results.Add(count);\n }\n\n //foreach (var result in results)\n //{\n // Console.WriteLine(result);\n //}\n }\n\n static int dfs(int v, bool[] used, List[] graph, Dictionary, int> leavesCounts)\n {\n used[v] = true;\n var isLeave = true;\n var sum = 0;\n if (graph[v] != null)\n foreach (var u in graph[v])\n {\n if (!used[u])\n {\n var leavesCount = dfs(u, used, graph, leavesCounts);\n sum += leavesCount;\n leavesCounts[new KeyValuePair(v, u)] = leavesCount;\n isLeave = false;\n }\n }\n if (isLeave)\n {\n return 1;\n }\n else\n {\n return sum;\n }\n }\n\n private static int Exchange(int[] a, int count, HashSet newSet, HashSet oldSet, int index)\n {\n if (oldSet.Any())\n {\n var subSeqNum = oldSet.First();\n oldSet.Remove(subSeqNum);\n a[index + 1] = subSeqNum;\n newSet.Add(subSeqNum);\n }\n else\n {\n count++;\n var subSeqNum = count;\n a[index + 1] = subSeqNum;\n newSet.Add(subSeqNum);\n }\n return count;\n }\n\n static void Remove(Dictionary stat, int x)\n {\n if (stat[x] == 1)\n {\n stat.Remove(x);\n }\n else\n {\n stat[x] -= 1;\n }\n }\n\n //static void Main(string[] args)\n //{\n // var results = new List();\n // foreach (var test in Enumerable.Range(0, GetIntFromReadLine()))\n // {\n // var n = (long)GetInt();\n // var r = (long)GetInt(); \n // var min = (long)Math.Min(r, n - 1);\n // var sum = min * (min + 1) / 2L;\n // if (r >= n)\n // {\n // sum += +1;\n // } \n // results.Add(sum);\n // }\n\n // foreach (var result in results)\n // {\n // Console.WriteLine(result);\n // }\n //}\n\n //static void Main(string[] args)\n //{\n // var results = new List();\n // foreach (var test in Enumerable.Range(0, GetIntFromReadLine()))\n // { \n // var n = GetInt();\n // results.Add(n - (n/2));\n // }\n\n // foreach (var result in results)\n // {\n // Console.WriteLine(result);\n // }\n //}\n\n static long lower_bound(int h, int c, int t)\n {\n long l = 1;\n long r = int.MaxValue;\n while (l + 1 < r)\n {\n long mid = (r + l) / 2;\n if (mid * h + (mid - 1) * c >= t * (2 * mid - 1))\n {\n l = mid;\n }\n else\n {\n r = mid;\n }\n }\n return r;\n }\n\n private static int[] GetPrimes(int n)\n {\n var list = new List();\n while (true)\n {\n var del = GetMinDel(n);\n if (del == 1)\n {\n break;\n }\n list.Add(del);\n n = n / del;\n }\n return list.ToArray();\n }\n\n\n private static int GetMinDel(int n)\n {\n for (long index = 2; index * index <= n; ++index)\n {\n if (n % index == 0)\n {\n return (int)index;\n }\n }\n return n;\n }\n\n public static bool Success(int[] chet, int[] nechet)\n {\n foreach (var ch in chet)\n foreach (var nch in nechet)\n {\n if (Math.Abs(ch - nch) == 1)\n {\n return true;\n }\n }\n return false;\n }\n\n static int GetInt()\n {\n int integer = 0;\n int n = Console.Read();\n while (n == ' ' || n == '\\n' || n == '\\r' || n == '\\t' || n == -1)\n n = Console.Read();\n while (n >= '0' && n <= '9')\n {\n integer = integer * 10 + n - '0';\n n = Console.Read();\n }\n return integer;\n }\n static long GetLong()\n {\n long integer = 0;\n int n = Console.Read();\n while (n == ' ' || n == '\\n' || n == '\\r' || n == '\\t' || n == -1)\n n = Console.Read();\n while (n >= '0' && n <= '9')\n {\n integer = integer * 10 + n - '0';\n n = Console.Read();\n }\n return integer;\n }\n\n static int[] ReadArray(int count)\n {\n int[] arr = new int[count];\n for (var index = 0; index < count; ++index)\n {\n arr[index] = GetInt();\n }\n return arr;\n\n }\n\n static int[] ReadArrayFromReadLine()\n {\n return Console.ReadLine().Split().Select(int.Parse).ToArray();\n }\n\n static int GetIntFromReadLine()\n {\n return int.Parse(Console.ReadLine());\n }\n\n public static int GetPower_(int num, int power)\n {\n if (power == 0) return 1;\n if (power == 1) return num;\n var prev = GetPower_(num, power / 2);\n var prev2 = ((long)prev * prev);\n if (power % 2 != 0) return (int)((prev2 * num));\n return (int)prev2;\n }\n\n public static int Modulo = 1000000007;\n public static int GetPower(int num, int power)\n {\n if (power == 0) return 1;\n if (power == 1) return num % Modulo;\n var prev = GetPower(num, power / 2);\n var prev2 = ((long)prev * prev) % Modulo;\n if (power % 2 != 0) return (int)((prev2 * num) % Modulo);\n return (int)prev2;\n }\n public static long GetFactorial(int num)\n {\n if (num == 0) return 1;\n var res = 1L;\n for (var index = 1; index <= num; ++index)\n {\n res = (res * index) % Modulo;\n }\n\n return res;\n }\n\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "dp", "combinatorics", "graphs"], "code_uid": "946a66171550698ccea29f48b37f7378", "src_uid": "3dc1ee09016a25421ae371fa8005fce1", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\n\nnamespace ConsoleApp\n{\n class Program\n {\n static void Main(string[] args)\n {\n int[] input = Array.ConvertAll(Console.ReadLine().Split(), Int32.Parse);\n int minus = input[0] - input[1] - 1;\n if (minus <= 0)\n {\n Console.WriteLine(input[0] - 1);\n }\n else\n {\n Console.WriteLine(input[1] + (3 + minus) * minus / 2);\n }\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "greedy", "dp"], "code_uid": "9d3c393449c66dc0414f2f82922bb12b", "src_uid": "f8eb96deeb82d9f011f13d7dac1e1ab7", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Linq;\nusing System.Collections.Generic;\n\nstatic class UtilityMethods\n{\n\tpublic static void Swap(ref T a, ref T b)\n\t{\n\t\tT t = a;\n\t\ta = b;\n\t\tb = t;\n\t}\n\n\tpublic static int StrToInt(string s)\n\t{\n\t\tint number = 0;\n\t\tfor (int i = s[0] == '-' ? 1 : 0; i < s.Length; i++)\n\t\t\tnumber = number * 10 + (s[i] - '0');\n\t\treturn s[0] == '-' ? -number : number;\n\t}\n\tpublic static long StrToLong(string s)\n\t{\n\t\tlong number = 0;\n\t\tfor (int i = s[0] == '-' ? 1 : 0; i < s.Length; i++)\n\t\t\tnumber = number * 10 + (s[i] - '0');\n\t\treturn s[0] == '-' ? -number : number;\n\t}\n\n\tpublic static string ReadString() => Console.ReadLine();\n\tpublic static int ReadInt() => StrToInt(ReadString());\n\tpublic static long ReadLong() => StrToLong(ReadString());\n\tpublic static double ReadDouble() => double.Parse(ReadString());\n\n\tpublic static string[] ReadStringArray() => ReadString().Split();\n\tpublic static int[] ReadIntArray() => Array.ConvertAll(ReadStringArray(), StrToInt);\n\tpublic static long[] ReadLongArray() => Array.ConvertAll(ReadStringArray(), StrToLong);\n\tpublic static double[] ReadDoubleArray() => ReadStringArray().Select(double.Parse).ToArray();\n\n\tpublic static void WriteLine(object a) => Console.WriteLine(a);\n\tpublic static void WriteLineArray(string separator, T[] a, int startIndex, int count)\n\t{\n\t\tconst int MAXLEN = 1000000;\n\t\tint len = 0, j = startIndex, lastIndex = startIndex + count;\n\t\tSystem.Text.StringBuilder str;\n\t\tstring[] b = Array.ConvertAll(a, x => x.ToString());\n\t\tfor (int i = startIndex; i < lastIndex - 1; i++)\n\t\t{\n\t\t\tlen += b[i].Length + separator.Length;\n\t\t\tif (len >= MAXLEN)\n\t\t\t{\n\t\t\t\tstr = new System.Text.StringBuilder(len);\n\t\t\t\tfor (; j <= i; j++)\n\t\t\t\t{\n\t\t\t\t\tstr.Append(b[j]);\n\t\t\t\t\tstr.Append(separator);\n\t\t\t\t}\n\t\t\t\tConsole.Write(str);\n\t\t\t\tlen = 0;\n\t\t\t}\n\t\t}\n\t\tstr = new System.Text.StringBuilder(len);\n\t\tfor (; j < lastIndex - 1; j++)\n\t\t{\n\t\t\tstr.Append(b[j]);\n\t\t\tstr.Append(separator);\n\t\t}\n\t\tConsole.Write(str);\n\t\tConsole.WriteLine(b.Last());\n\t}\n}\n\nclass Program\n{\n\tstatic void Main()\n\t{\n\t\tint[] data = UtilityMethods.ReadIntArray();\n\t\tint n = data[0], v = data[1];\n\t\tint cost = 0, volume = 0;\n\t\tfor (int i = 1; i <= n; i++, volume--)\n\t\t\tif (volume + i < n)\n\t\t\t{\n\t\t\t\tcost += (v - volume) * i;\n\t\t\t\tvolume += v - volume;\n\t\t\t}\n\t\t\telse\n\t\t\t\tbreak;\n\t\tUtilityMethods.WriteLine(n - 1 <= v ? n - 1 : cost);\n\t\tConsole.ReadLine();\n\t}\n}", "lang_cluster": "C#", "tags": ["math", "greedy", "dp"], "code_uid": "9c87839b83847817caff2854dc186200", "src_uid": "f8eb96deeb82d9f011f13d7dac1e1ab7", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\n\nnamespace ReshetoEratosfena\n{\n public class DefaultClass\n {\n public static void ReshetoEratosfena(int n)\n {\n long ans = 0;\n long mn = 1;\n bool f = false;\n bool[] visited = new bool[n + 1];\n HashSet rq = new HashSet();\n for (int i = 2; i < n + 1; i++)\n {\n if (visited[i] == false)\n {\n int w = n;\n int k = 0;\n while (w % i == 0)\n {\n w /= i;\n k += 1;\n }\n if (k > 0)\n {\n mn *= i;\n }\n int actk = 1;\n int r = 0;\n while (actk < k)\n {\n actk *= 2;\n r += 1;\n }\n if (actk != k&&k>0)\n {\n f = true;\n }\n if (k > 0)\n {\n rq.Add(k);\n }\n ans =Math.Max( r,ans);\n for (int j = i; j < n + 1; j += i)\n {\n visited[j] = true;\n }\n }\n }\n if (f||rq.Count>1)\n {\n ans += 1;\n }\n Console.WriteLine(mn + \" \" + ans);\n // Console.ReadKey();\n \n }\n }\n class Program\n {\n static void Main(string[] args)\n {\n int n = int.Parse(Console.ReadLine());\n DefaultClass.ReshetoEratosfena(n);\n }\n }\n}", "lang_cluster": "C#", "tags": ["math", "greedy", "number theory"], "code_uid": "07cebd4b66760fd2d076d1054c79d1e2", "src_uid": "212cda3d9d611cd45332bb10b80f0b56", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing static System.Array;\nusing static System.Math;\n\nnamespace Codeforces\n{\n class Program\n {\n void Solve() {\n var n = int.Parse(ReadLine());\n var b = new List();\n var e = new List();\n for ( var p = 2; p*p <= n; ++p ) {\n if ( n%p != 0 ) continue;\n b.Add(p);\n e.Add(0);\n while ( n%p == 0 ) {\n n /= p;\n e[e.Count-1] += 1;\n }\n }\n\n if ( n > 1 ) { b.Add(n); e.Add(1); }\n\n var ans0 = 1;\n var ans1 = 0;\n var ans2 = 0;\n for ( var i = 0; i < b.Count; ++i ) {\n //Println(b[i] + \"^\" + e[i]);\n ans0 *= b[i];\n var p2 = 0;\n while ( (1<=b+c)\n t=a-(b+c)+1;\n else if (b>=a+c)\n t = b - (a + c)+1;\n else if (c>=a+b)\n t = c - (a + b)+1;\n Console.WriteLine(t);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "math", "geometry"], "code_uid": "d86cbece0da103c6ee63a016e66f72ac", "src_uid": "3dc56bc08606a39dd9ca40a43c452f09", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": ".NET Core C#", "source_code": "using System;\nusing System.Collections;\nusing System.Collections.Generic;\nusing System.Diagnostics;\nusing System.IO;\nusing System.Linq;\nusing System.Numerics;\nusing System.Text;\nusing System.Text.RegularExpressions;\nusing System.Threading.Tasks;\nusing static System.Math;\npublic static class P\n{\n public static void Main()\n {\n int t = int.Parse(Console.ReadLine());\n for (int i = 0; i < t; i++)\n {\n Solve();\n }\n }\n static void Solve()\n {\n var nkl = Console.ReadLine().Split().Select(long.Parse).ToArray();\n var n = nkl[0];\n var k = nkl[1]; //period\n var l = nkl[2]; //drawn limit\n var d = Console.ReadLine().Split().Select(long.Parse).ToArray();\n\n //0 1 k-1 k k+1\n //k, k-1, k-2, .. 1, 0, 1, ... k - 1\n long cur = 0;\n //\u30e4\u30d0\u3044\u6642\u306b\u3044\u3089\u308c\u308b\u5834\u6240\u307e\u3067\u99c6\u3051\u629c\u3051\u3089\u308c\u308b\u304b\n for (int i = 0; i < d.Length; i++)\n {\n if (d[i] + k <= l) cur = 0;\n else\n {\n cur++;\n var limit = l - d[i];\n if (limit + k < cur)\n {\n Console.WriteLine(\"No\");\n return;\n }\n //wait until\n var firstPossible = k - limit;\n cur = Max(firstPossible, cur);\n }\n }\n Console.WriteLine(\"Yes\");\n }\n}", "lang_cluster": "C#", "tags": ["brute force", "greedy", "dp"], "code_uid": "5fa4d15a432768f7a61dba46f53597d7", "src_uid": "4941b0a365f86b2e2cf686cdf5d532f8", "difficulty": 1900.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections;\nusing System.Collections.Generic;\nusing System.Diagnostics;\nusing System.Globalization;\nusing System.IO;\nusing System.Text;\nusing System.Linq;\n\nusing E = System.Linq.Enumerable;\n\ninternal partial class Solver {\n public void Run() {\n var t = ni();\n while (t-- > 0) {\n var n = ni();\n var k = ni();\n var l = ni();\n var d = ni(n);\n bool ans = true;\n bool increasing = false;\n int currentP = k + 1;\n foreach (var x in d) {\n // x + p <= l\n var maxP = l - x;\n if (maxP < 0) {\n ans = false;\n break;\n }\n if (maxP >= k) { // safe\n currentP = k + 1;\n increasing = false;\n } else {\n // maxP < k\n if (increasing) currentP++; else currentP--;\n if (increasing) {\n if (currentP > maxP) {\n ans = false;\n break;\n }\n } else {\n currentP = Math.Min(currentP, maxP);\n if (currentP == 0) increasing = true;\n }\n }\n }\n cout.WriteLine(ans ? \"Yes\" : \"No\");\n }\n }\n\n}\n\n\n\n// PREWRITEN CODE BEGINS FROM HERE\n\nstatic public class StringExtensions {\n static public string JoinToString(this IEnumerable source, string separator = \" \") {\n return string.Join(separator, source);\n }\n}\n\ninternal partial class Solver : Scanner {\n public static void Main() {\n#if LOCAL\n byte[] inputBuffer = new byte[1000000];\n var inputStream = Console.OpenStandardInput(inputBuffer.Length);\n using (var reader = new StreamReader(inputStream, Console.InputEncoding, false, inputBuffer.Length)) {\n Console.SetIn(reader);\n new Solver(Console.In, Console.Out).Run();\n }\n#else\n Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });\n new Solver(Console.In, Console.Out).Run();\n Console.Out.Flush();\n#endif\n }\n\n#pragma warning disable IDE0052\n private readonly TextReader cin;\n private readonly TextWriter cout;\n private readonly TextWriter cerr;\n#pragma warning restore IDE0052\n\n public Solver(TextReader reader, TextWriter writer)\n : base(reader) {\n cin = reader;\n cout = writer;\n cerr = Console.Error;\n }\n\n public Solver(string input, TextWriter writer)\n : this(new StringReader(input), writer) {\n }\n\n#pragma warning disable IDE1006\n#pragma warning disable IDE0051\n private int ni() { return NextInt(); }\n private int[] ni(int n) { return NextIntArray(n); }\n private long nl() { return NextLong(); }\n private long[] nl(int n) { return NextLongArray(n); }\n private double nd() { return NextDouble(); }\n private double[] nd(int n) { return NextDoubleArray(n); }\n private string ns() { return Next(); }\n private string[] ns(int n) { return NextArray(n); }\n#pragma warning restore IDE1006\n#pragma warning restore IDE0051\n}\n\n#if DEBUG\ninternal static class LinqPadExtension {\n public static string TextDump(this T obj) {\n if (obj is IEnumerable) return (obj as IEnumerable).Cast().JoinToString().Dump();\n else return obj.ToString().Dump();\n }\n public static T Dump(this T obj) {\n return LINQPad.Extensions.Dump(obj);\n }\n}\n#endif\n\npublic class Scanner {\n private readonly TextReader Reader;\n private readonly CultureInfo ci = CultureInfo.InvariantCulture;\n\n private readonly char[] buffer = new char[2 * 1024];\n private int cursor = 0, length = 0;\n private string Token;\n private readonly StringBuilder sb = new StringBuilder(1024);\n\n public Scanner()\n : this(Console.In) {\n }\n\n public Scanner(TextReader reader) {\n Reader = reader;\n }\n\n public int NextInt() { return checked((int)NextLong()); }\n public long NextLong() {\n var s = Next();\n long r = 0;\n int i = 0;\n bool negative = false;\n if (s[i] == '-') {\n negative = true;\n i++;\n }\n for (; i < s.Length; i++) {\n r = r * 10 + (s[i] - '0');\n#if DEBUG\n if (!char.IsDigit(s[i])) throw new FormatException();\n#endif\n }\n return negative ? -r : r;\n }\n public double NextDouble() { return double.Parse(Next(), ci); }\n public string[] NextArray(int size) {\n string[] array = new string[size];\n for (int i = 0; i < size; i++) {\n array[i] = Next();\n }\n\n return array;\n }\n public int[] NextIntArray(int size) {\n int[] array = new int[size];\n for (int i = 0; i < size; i++) {\n array[i] = NextInt();\n }\n\n return array;\n }\n\n public long[] NextLongArray(int size) {\n long[] array = new long[size];\n for (int i = 0; i < size; i++) {\n array[i] = NextLong();\n }\n\n return array;\n }\n\n public double[] NextDoubleArray(int size) {\n double[] array = new double[size];\n for (int i = 0; i < size; i++) {\n array[i] = NextDouble();\n }\n\n return array;\n }\n\n public string Next() {\n if (Token == null) {\n if (!StockToken()) {\n throw new Exception();\n }\n }\n var token = Token;\n Token = null;\n return token;\n }\n\n public bool HasNext() {\n if (Token != null) {\n return true;\n }\n\n return StockToken();\n }\n\n private bool StockToken() {\n while (true) {\n sb.Clear();\n while (true) {\n if (cursor >= length) {\n cursor = 0;\n if ((length = Reader.Read(buffer, 0, buffer.Length)) <= 0) {\n break;\n }\n }\n var c = buffer[cursor++];\n if (33 <= c && c <= 126) {\n sb.Append(c);\n } else {\n if (sb.Length > 0) break;\n }\n }\n\n if (sb.Length > 0) {\n Token = sb.ToString();\n return true;\n }\n\n return false;\n }\n }\n}", "lang_cluster": "C#", "tags": ["brute force", "greedy", "dp"], "code_uid": "967aebd235b0a29072dec652927a3f71", "src_uid": "4941b0a365f86b2e2cf686cdf5d532f8", "difficulty": 1900.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\n\nnamespace Play.Codeforces\n{\n class Program\n {\n static void Main(string[] args)\n {\n int[] xy = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);\n\n Console.WriteLine(StepsToConvertTriangleRev(xy[0], xy[1]));\n }\n\n static int StepsToConvertTriangleRev(int x, int y)\n {\n int a = y;\n int b = y;\n int c = y;\n int result = 0;\n\n while (a != x)\n {\n result++;\n\n if (c == x)\n {\n a = x;\n }\n else\n {\n a = Math.Min(b + c - 1, x);\n }\n\n if (a > b)\n {\n var t = a;\n a = b;\n b = t;\n }\n if (a > c)\n {\n var t = a;\n a = c;\n c = t;\n }\n if (b > c)\n {\n var t = b;\n b = c;\n c = t;\n }\n }\n\n return result;\n }\n\n }\n}", "lang_cluster": "C#", "tags": ["math", "greedy"], "code_uid": "bcab589b4b7d273e6d395066f69cf9ae", "src_uid": "8edf64f5838b19f9a8b19a14977f5615", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Linq;\n\nnamespace CSharp\n{\n class _712C\n {\n public static void Main()\n {\n var tokens = Console.ReadLine().Split();\n\n int x = int.Parse(tokens[0]);\n int y = int.Parse(tokens[1]);\n\n int min = Math.Min(x, y);\n int max = Math.Max(x, y);\n\n var sides = Enumerable.Repeat(min, 3).ToArray();\n int count;\n\n for (count = 0; sides[0] < max;)\n {\n sides[0] = Math.Min(max, sides[1] + sides[2] - 1);\n Array.Sort(sides);\n\n count++;\n }\n\n Console.WriteLine(count);\n }\n }\n}", "lang_cluster": "C#", "tags": ["math", "greedy"], "code_uid": "c04f41d9dc3a9cdf6dd69fcf2f0c7329", "src_uid": "8edf64f5838b19f9a8b19a14977f5615", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.IO;\nusing System.Linq;\n\nnamespace Codeforces\n{\n class Solver\n {\n static void Main()\n {\n var tokens = new List ();\n tokens.Add(Console.ReadLine());\n tokens.Add(Console.ReadLine());\n// var tokens = Console.ReadLine().Split();\n var num1 = int.Parse(tokens[0]);\n var num2 = int.Parse(tokens[1]);\n if ( (int.Parse(String.Concat(tokens[0].Split('0'))) +\n int.Parse(String.Concat(tokens[1].Split('0')))) == \n int.Parse(String.Concat( (num1+num2).ToString().Split('0'))) ) \n Console.WriteLine(\"YES\");\n else\n Console.WriteLine(\"NO\");\n }\n }\n} \n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "028bb2fd0b68b7bd20832f8a0b3119b0", "src_uid": "ac6971f4feea0662d82da8e0862031ad", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace Life_Without_Zeros\n{\n class Program\n {\n static void Main(string[] args)\n {\n string [] sum1=new string[1];\n string num1 = Console.ReadLine();\n\n string[] sum2 = new string[1];\n string num2 = Console.ReadLine();\n\n string[] num2withoutzero = num2.Split('0');\n\n int answer1 = Convert.ToInt32(num1) + Convert.ToInt32(num2);\n string answer1withoutzero = Convert.ToString(answer1);\n string[] sum3 = new string[1];\n string[] fanswerwithoutzero = answer1withoutzero.Split('0');\n for (int v = 0; v < fanswerwithoutzero.Length; v++)\n sum3[0] += fanswerwithoutzero[v];\n\n\n string[] num1withoutzero = num1.Split('0');\n for (int i = 0; i < num1withoutzero.Length; i++)\n sum1 [0]+= num1withoutzero[i];\n for (int j = 0; j < num2withoutzero.Length; j++)\n sum2[0] += num2withoutzero[j];\n\n int ans2 = Convert.ToInt32(sum1[0]) + Convert.ToInt32(sum2[0]);\n\n if (Convert.ToInt32(sum3[0]) == ans2)\n Console.WriteLine(\"YES\");\n else\n Console.WriteLine(\"NO\");\n \n\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "6cd6d34a5880708fdefbc0891c339d1d", "src_uid": "ac6971f4feea0662d82da8e0862031ad", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\n\n class Program\n {\n static void Main(string[] args)\n {\n\n string line = Console.ReadLine();\n var numbers = line.Split(' ');\n var x = int.Parse(numbers[0]);\n int y = int.Parse(numbers[1]);\n\n int intersections = x * y;\n int nTours = intersections / 2;\n if (x == 1 || y ==1)\n Console.WriteLine(\"Akshat\");\n else\n if (x == y || x < y)\n {\n if (x % 2 == 1)\n Console.WriteLine(\"Akshat\");\n else\n Console.WriteLine(\"Malvika\");\n }\n else\n if (y < x)\n {\n if (y % 2 == 1)\n Console.WriteLine(\"Akshat\");\n else\n Console.WriteLine(\"Malvika\");\n }\n }\n }", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "34a8e4fdf6dae16d36f7bcc54df0d315", "src_uid": "a4b9ce9c9f170a729a97af13e81b5fe4", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\n\nnamespace ConsoleApplication1\n{\n class Program\n {\n static void Main(string[] args)\n {\n string tmp = Console.ReadLine();\n var n = int.Parse(tmp.Split(' ')[0]);\n var m = int.Parse(tmp.Split(' ')[1]);\n n = n < m ? n : m;\n\n Console.WriteLine(n % 2 == 1 ? \"Akshat\" : \"Malvika\");\n //Console.ReadKey();\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "deee1db556c0324f9631c61428f36919", "src_uid": "a4b9ce9c9f170a729a97af13e81b5fe4", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\n\nnamespace ConsoleApplication1\n{\n class Program\n {\n public static long Rec(long ss, long i, long s, long l, long r, long x, long n, long[] mas, long k)\n {\n s += mas[i];\n if ((s <= r) && (s >= l) && ((mas[i] - mas[k]) >= x))\n {\n ss++;\n }\n if (s < r)\n {\n for (long j = i + 1; j < n; j++)\n {\n ss = Rec(ss, j, s, l, r, x, n, mas, k);\n }\n }\n return ss;\n }\n static void Main(string[] args)\n {\n long n, l, r, x;\n\n string[] lines = Console.ReadLine().Split(' ');\n n = long.Parse(lines[0]);\n l = long.Parse(lines[1]);\n r = long.Parse(lines[2]);\n x = long.Parse(lines[3]);\n long[] mas;\n mas = new long[n];\n string[] lines1 = Console.ReadLine().Split(' ');\n for (long i = 0; i < n; i++)\n mas[i] = long.Parse(lines1[i]);\n\n for (long i = 0; i < mas.Length; i++)\n {\n for (long j = 0; j < mas.Length - 1; j++)\n {\n if (mas[j] > mas[j + 1])\n {\n long z = mas[j];\n mas[j] = mas[j + 1];\n mas[j + 1] = z;\n }\n }\n }\n long s = 0, ss = 0, sl = 0;\n for (long jj = 0; jj < (n - 1); jj++)\n {\n sl = Rec(0, jj, s, l, r, x, n, mas, jj);\n ss += sl;\n }\n Console.WriteLine(ss);\n // Console.ReadLine();\n }\n\n\n }\n}", "lang_cluster": "C#", "tags": ["brute force", "bitmasks"], "code_uid": "2946a28b81b0c4aff50d7e0013fa66fa", "src_uid": "0d43104a0de924cdcf8e4aced5aa825d", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.IO;\nusing System.Linq;\nusing System.Security.Cryptography;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace Round306\n{\n class Program\n {\n #region Common Helper\n\n private static readonly StreamReader reader = new StreamReader(Console.OpenStandardInput(1024 * 10), Encoding.ASCII, false, 1024 * 10);\n private static readonly StreamWriter writer = new StreamWriter(Console.OpenStandardOutput(1024 * 10), Encoding.ASCII, 1024 * 10);\n\n private static int Next()\n {\n int c;\n int res = 0;\n do\n {\n c = reader.Read();\n if (c == -1)\n return res;\n } while (c < '0' || c > '9');\n res = c - '0';\n while (true)\n {\n c = reader.Read();\n if (c < '0' || c > '9')\n return res;\n res *= 10;\n res += c - '0';\n }\n }\n\n #endregion\n\n #region Problem A\n\n private static bool ProblemAHelper(string s, string input, string reverse)\n {\n var indexAB = s.IndexOf(input, StringComparison.InvariantCulture);\n if (indexAB == -1)\n return false;\n if (indexAB == 0)\n {\n if (s.Length < 4)\n {\n return false;\n }\n if (s.Substring(2, s.Length - 2).Contains(reverse))\n {\n return true;\n }\n }\n else if (s.Substring(0, indexAB - 1).Contains(reverse) || s.Substring(indexAB + 2, s.Length - indexAB - 2).Contains(reverse))\n {\n return true;\n }\n return false;\n }\n\n private static void ProblemA()\n {\n var s = Console.ReadLine();\n if (ProblemAHelper(s, \"AB\", \"BA\") || ProblemAHelper(s, \"BA\", \"AB\"))\n {\n Console.WriteLine(\"YES\");\n return;\n }\n \n Console.WriteLine(\"NO\");\n }\n\n private static void TwoSubstring()\n {\n var s = Console.ReadLine();\n var subA = \"AB\";\n\n var indexA = s.IndexOf(subA, StringComparison.InvariantCulture);\n if (indexA == -1)\n {\n Console.WriteLine(\"NO\");\n return;\n }\n\n var subB = \"BA\";\n var indexB = s.LastIndexOf(subB, StringComparison.InvariantCulture);\n if (indexB == -1)\n {\n Console.WriteLine(\"NO\");\n return;\n }\n if (indexA + 1 < indexB)\n {\n Console.WriteLine(\"YES\");\n return;\n }\n\n indexA = s.LastIndexOf(subA);\n indexB = s.IndexOf(subB);\n if (indexB + 1 < indexA)\n {\n Console.WriteLine(\"YES\");\n return;\n }\n\n\n Console.WriteLine(\"NO\");\n }\n\n private static void TwoSubstring2()\n {\n var s = Console.ReadLine();\n Console.WriteLine(s.Contains(\"AB\") && s.Contains(\"BA\") &&\n (s.LastIndexOf(\"BA\", StringComparison.OrdinalIgnoreCase) - 1 > s.IndexOf(\"AB\", StringComparison.OrdinalIgnoreCase) ||\n s.LastIndexOf(\"AB\", StringComparison.OrdinalIgnoreCase) - 1 > s.IndexOf(\"BA\", StringComparison.OrdinalIgnoreCase))\n ? \"YES\": \"NO\");\n }\n\n #endregion\n\n #region Problem B\n\n private static IEnumerable> powerSet(IList input, int n = 1)\n {\n var data = input.ToArray();\n for (var i = 0; i < ((n + 1) << data.Length); i++)\n {\n var tempList = new List(n + 1);\n tempList.AddRange(data.Where((t, j) => (i >> j)%2 == 1));\n yield return tempList;\n }\n\n }\n\n private static void ProblemB()\n {\n var n = Next();\n var l = Next();\n var r = Next();\n var x = Next();\n var c = new int[n];\n for (var i = 0; i < n; i++)\n c[i] = Next();\n\n reader.Close();\n var ans = 0;\n var total = 2 << (n - 1);\n for (var i = 0; i < total; i++)\n {\n var min = int.MaxValue;\n var max = 0;\n var sum = 0;\n var count = 0;\n //var tempList = c.Where((t, j) => (i1 >> j)%2 == 1).ToArray();\n for (var j = 0; j < n; j++)\n {\n if ((i >> j)%2 == 1)\n {\n sum += c[j];\n max = Math.Max(max, c[j]);\n min = Math.Min(min, c[j]);\n count++;\n }\n }\n //if (tempList.Length > 1 && tempList.Sum() >= l && tempList.Sum() <= r && tempList.Max() - tempList.Min() >= x)\n if (count > 1 && sum <= r && sum >= l && max - min >= x) \n ans++;\n }\n\n\n Console.WriteLine(ans);\n }\n\n #endregion\n static void Main(string[] args)\n {\n //ProblemA();\n //TwoSubstring();\n //TwoSubstring2();\n\n ProblemB();\n //Console.ReadKey();\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "bitmasks"], "code_uid": "c259bdfbffda367e0f220aa6c3c12d8e", "src_uid": "0d43104a0de924cdcf8e4aced5aa825d", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace _1426E\n{\n class Program\n {\n static void Main(string[] args)\n {\n Console.ReadLine();\n int[] alice = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();\n int[] Bob = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();\n\n //most wins\n int mostWins = 0;\n mostWins += Math.Min(alice[0], Bob[1]);\n mostWins += Math.Min(alice[1], Bob[2]);\n mostWins += Math.Min(alice[2], Bob[0]);\n\n //least wins\n List aliceDistribution = new List()\n { new int[3] { 0, 0, 0 }, new int[3] { 0, 0, 0 }, new int[3] { 0, 0, 0 } };\n\n for (int a = 0; a < alice.Length; a++)\n {\n for (int b = 0; b < Bob.Length; b++)\n {\n if ((a + b) % alice.Length == (a + 1) % alice.Length)\n continue;\n int c = Math.Min(Bob[(a + b) % alice.Length], alice[a]);\n alice[a] -= c;\n Bob[(a + b) % alice.Length] -= c;\n aliceDistribution[a][(a + b) % alice.Length] += c;\n }\n\n if (alice[a] > 0)\n {\n for (int a2 = 0; a2 < alice.Length; a2++)\n {\n if (a2 == a)\n continue;\n for (int ad = 0; ad < aliceDistribution.Count; ad++)\n {\n if (ad == (a + 1) % alice.Length)\n continue;\n\n int c = Math.Min(alice[a], aliceDistribution[a2][ad]);\n alice[a] -= c;\n aliceDistribution[a2][ad] -= c;\n aliceDistribution[a2][(a + 1) % alice.Length] += c;\n }\n }\n }\n }\n\n int leastWins = 0;\n foreach (var item in alice)\n leastWins += item;\n\n Console.WriteLine(leastWins + \" \" + mostWins);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "constructive algorithms", "flows", "math", "greedy"], "code_uid": "5699d624877ac15daa132a7c94070c8c", "src_uid": "e6dc3bc64fc66b6127e2b32cacc06402", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": ".NET Core C#", "source_code": "using System;\nusing System.Linq;\nusing CompLib.Util;\nusing System.Threading;\n\npublic class Program\n{\n public void Solve()\n {\n var sc = new Scanner();\n int n = sc.NextInt();\n int[] a = sc.IntArray();\n int[] b = sc.IntArray();\n\n // \u3058\u3083\u3093\u3051\u3093\n // alice \u30b0\u30fc a_1 \u30c1\u30e7\u30ad a_2 \u30d1\u30fc a_3\n // bob b\n\n // alice\u304c\u52dd\u3064\u6700\u5c0f\u3001\u6700\u5927\n\n\n // \u6700\u5927\n int max = Math.Min(a[0], b[1]) + Math.Min(a[1], b[2]) + Math.Min(a[2], b[0]);\n\n // min\n int min = int.MaxValue;\n {\n for (int j = 0; j < 3; j++)\n {\n int score = n;\n int[] ta = a.ToArray();\n int[] tb = b.ToArray();\n for (int i = 0; i < 3; i++)\n {\n int tmp = Math.Min(ta[(i + j) % 3], tb[(i + j + 2) % 3]);\n score -= tmp;\n ta[(i + j) % 3] -= tmp;\n tb[(i + j + 2) % 3] -= tmp;\n\n int tmp2 = Math.Min(ta[(i + j + 2) % 3], tb[(i + j + 2) % 3]);\n score -= tmp2;\n ta[(i + j + 2) % 3] -= tmp2;\n tb[(i + j + 2) % 3] -= tmp2;\n }\n\n min = Math.Min(min, score);\n // Console.WriteLine($\"{j} {score}\");\n }\n\n }\n Console.WriteLine($\"{min} {max}\");\n }\n\n public static void Main(string[] args) => new Program().Solve();\n // public static void Main(string[] args) => new Thread(new Program().Solve, 1 << 27).Start();\n}\n\nnamespace CompLib.Util\n{\n using System;\n using System.Linq;\n\n class Scanner\n {\n private string[] _line;\n private int _index;\n private const char Separator = ' ';\n\n public Scanner()\n {\n _line = new string[0];\n _index = 0;\n }\n\n public string Next()\n {\n if (_index >= _line.Length)\n {\n string s;\n do\n {\n s = Console.ReadLine();\n } while (s.Length == 0);\n\n _line = s.Split(Separator);\n _index = 0;\n }\n\n return _line[_index++];\n }\n\n public string ReadLine()\n {\n _index = _line.Length;\n return Console.ReadLine();\n }\n\n public int NextInt() => int.Parse(Next());\n public long NextLong() => long.Parse(Next());\n public double NextDouble() => double.Parse(Next());\n public decimal NextDecimal() => decimal.Parse(Next());\n public char NextChar() => Next()[0];\n public char[] NextCharArray() => Next().ToCharArray();\n\n public string[] Array()\n {\n string s = Console.ReadLine();\n _line = s.Length == 0 ? new string[0] : s.Split(Separator);\n _index = _line.Length;\n return _line;\n }\n\n public int[] IntArray() => Array().Select(int.Parse).ToArray();\n public long[] LongArray() => Array().Select(long.Parse).ToArray();\n public double[] DoubleArray() => Array().Select(double.Parse).ToArray();\n public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();\n }\n}", "lang_cluster": "C#", "tags": ["brute force", "constructive algorithms", "flows", "math", "greedy"], "code_uid": "873483e4b2a1412d930d16c3a4b61486", "src_uid": "e6dc3bc64fc66b6127e2b32cacc06402", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": ".NET Core C#", "source_code": "using Microsoft.Win32.SafeHandles;\nusing System;\nusing System.Collections.Generic;\nusing System.IO;\nusing System.Linq;\nusing System.Runtime.CompilerServices;\nusing System.Xml.Schema;\n\npublic static class Ex\n{\n public static bool IsNullOrEmpty(this string s) { return string.IsNullOrEmpty(s); }\n public static void yesno(this bool b) => Console.WriteLine(b ? \"yes\" : \"no\");\n public static void YesNo(this bool b) => Console.WriteLine(b ? \"Yes\" : \"No\");\n public static void YESNO(this bool b) => Console.WriteLine(b ? \"YES\" : \"NO\");\n //[MethodImpl(MethodImplOptions.AggressiveInlining)]\n //public static bool Chmax(ref this T a, T b) where T : struct, IComparable\n //{\n // if (b.CompareTo(a) > 0) { a = b; return true; }\n // else return false;\n //}\n //[MethodImpl(MethodImplOptions.AggressiveInlining)]\n //public static bool Chmin(ref this T a, T b) where T : struct, IComparable\n //{\n // if (b.CompareTo(a) < 0) { a = b; return true; }\n // else return false;\n //}\n\n public static List FastSort(this List s) { s.Sort(StringComparer.OrdinalIgnoreCase); return s.ToList(); }\n\n public static int PopCount(this uint bits)\n {\n bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);\n bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);\n bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);\n bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);\n return (int)((bits & 0x0000ffff) + (bits >> 16 & 0x0000ffff));\n }\n}\n\n\n\npartial class Program\n{\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n string GetStr() { return Console.ReadLine().Trim(); }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n char GetChar() { return Console.ReadLine().Trim()[0]; }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n int GetInt() { return int.Parse(Console.ReadLine().Trim()); }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n long GetLong() { return long.Parse(Console.ReadLine().Trim()); }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n double GetDouble() { return double.Parse(Console.ReadLine().Trim()); }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n string[] GetStrArray() { return Console.ReadLine().Trim().Split(' '); }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n string[][] GetStrArray(int N)\n {\n var res = new string[N][];\n for (int i = 0; i < N; i++) res[i] = Console.ReadLine().Trim().Split(' ');\n return res;\n }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n int[] GetIntArray() { return Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray(); }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n int[][] GetIntArray(int N)\n {\n var res = new int[N][];\n for (int i = 0; i < N; i++) res[i] = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();\n return res;\n }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public long[] GetLongArray() { return Console.ReadLine().Trim().Split(' ').Select(long.Parse).ToArray(); }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n long[][] GetLongArray(int N)\n {\n var res = new long[N][];\n for (int i = 0; i < N; i++) res[i] = Console.ReadLine().Trim().Split(' ').Select(long.Parse).ToArray();\n return res;\n }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n char[] GetCharArray() { return Console.ReadLine().Trim().Split(' ').Select(char.Parse).ToArray(); }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n double[] GetDoubleArray() { return Console.ReadLine().Trim().Split(' ').Select(double.Parse).ToArray(); }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n double[][] GetDoubleArray(int N)\n {\n var res = new double[N][];\n for (int i = 0; i < N; i++) res[i] = Console.ReadLine().Trim().Split(' ').Select(double.Parse).ToArray();\n return res;\n }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n char[][] GetGrid(int H)\n {\n var res = new char[H][];\n for (int i = 0; i < H; i++) res[i] = Console.ReadLine().Trim().ToCharArray();\n return res;\n }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n T[] CreateArray(int N, T value)\n {\n var res = new T[N];\n for (int i = 0; i < N; i++) res[i] = value;\n return res;\n }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n T[][] CreateArray(int H, int W, T value)\n {\n var res = new T[H][];\n for (int i = 0; i < H; i++)\n {\n res[i] = new T[W];\n for (int j = 0; j < W; j++) res[i][j] = value;\n }\n return res;\n }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n T[][][] CreateArray(int H, int W, int R, T value)\n {\n var res = new T[H][][];\n for (int i = 0; i < H; i++)\n {\n res[i] = new T[W][];\n for (int j = 0; j < W; j++)\n {\n res[i][j] = new T[R];\n for (int k = 0; k < R; k++) res[i][j][k] = value;\n }\n }\n return res;\n }\n\n Dictionary> GetUnweightedAdjacencyList(int N, int M, bool isDirected, bool isNode_0indexed)\n {\n var dic = new Dictionary>();\n foreach (var e in Enumerable.Range(0, N)) { dic.Add(e, new List()); }\n for (int i = 0; i < M; i++)\n {\n var input = GetIntArray();\n var a = isNode_0indexed ? input[0] : input[0] - 1;\n var b = isNode_0indexed ? input[1] : input[1] - 1;\n dic[a].Add(b);\n if (isDirected == false) dic[b].Add(a);\n }\n return dic;\n }\n //Dictionary> GetWeightedAdjacencyList(int N, int M, bool isDirected, bool isNode_0indexed)\n //{\n // var dic = new Dictionary>();\n // foreach (var e in Enumerable.Range(0, N)) { dic.Add(e, new List<(int, long)>()); }\n // for (int i = 0; i < M; i++)\n // {\n // var input = GetIntArray();\n // var a = isNode_0indexed ? input[0] : input[0] - 1;\n // var b = isNode_0indexed ? input[1] : input[1] - 1;\n // var c = input[2];\n // dic[a].Add((b, c));\n // if (isDirected == false) dic[b].Add((a, c));\n // }\n // return dic;\n //}\n\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n bool eq() => typeof(T).Equals(typeof(U));\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n T ct(U a) => (T)Convert.ChangeType(a, typeof(T));\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n T cv(string s) => eq() ? ct(int.Parse(s))\n : eq() ? ct(long.Parse(s))\n : eq() ? ct(double.Parse(s))\n : eq() ? ct(s[0])\n : ct(s);\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n void Multi(out T a) => a = cv(GetStr());\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n void Multi(out T a, out U b)\n {\n var ar = GetStrArray(); a = cv(ar[0]); b = cv(ar[1]);\n }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n void Multi(out T a, out U b, out V c)\n {\n var ar = GetStrArray(); a = cv(ar[0]); b = cv(ar[1]); c = cv(ar[2]);\n }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n void Multi(out T a, out U b, out V c, out W d)\n {\n var ar = GetStrArray(); a = cv(ar[0]); b = cv(ar[1]); c = cv(ar[2]); d = cv(ar[3]);\n }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n void Multi(out T a, out U b, out V c, out W d, out X e)\n {\n var ar = GetStrArray(); a = cv(ar[0]); b = cv(ar[1]); c = cv(ar[2]); d = cv(ar[3]); e = cv(ar[4]);\n }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n void Multi(out T a, out U b, out V c, out W d, out X e, out Y f)\n {\n var ar = GetStrArray(); a = cv(ar[0]); b = cv(ar[1]); c = cv(ar[2]); d = cv(ar[3]); e = cv(ar[4]); f = cv(ar[5]);\n }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n void Output(T t) => Console.WriteLine(t);\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n void Output(IList ls) => Console.WriteLine(string.Join(\" \", ls));\n void Debug(IList> ls)\n {\n foreach (var l in ls)\n foreach (var s in l)\n Console.WriteLine(s);\n }\n\n\n void Swap(ref T a, ref T b) { T temp = a; a = b; b = temp; }\n\n int[] dx = new int[] { 1, 0, -1, 0, 1, -1, -1, 1 };\n int[] dy = new int[] { 0, 1, 0, -1, 1, 1, -1, -1 };\n long mod = 1000000007;\n}\n\n\n\n\n\n\npartial class Program\n{\n static void Main()\n {\n Console.SetIn(new StreamReader(Console.OpenStandardInput(8192)));\n Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });\n new Program().Solve();\n Console.Out.Flush();\n Console.Read();\n }\n\n public void Solve()\n {\n int N = GetInt();\n var A = GetIntArray();\n var B = GetIntArray();\n var dinic = new Dinic(8);\n dinic.AddEdge(0, 1, A[0]);\n dinic.AddEdge(0, 2, A[1]);\n dinic.AddEdge(0, 3, A[2]);\n dinic.AddEdge(1, 4, int.MaxValue);\n dinic.AddEdge(1, 5, 0);\n dinic.AddEdge(1, 6, int.MaxValue);\n dinic.AddEdge(2, 4, int.MaxValue);\n dinic.AddEdge(2, 5, int.MaxValue);\n dinic.AddEdge(2, 6, 0);\n dinic.AddEdge(3, 4, 0);\n dinic.AddEdge(3, 5, int.MaxValue);\n dinic.AddEdge(3, 6, int.MaxValue);\n dinic.AddEdge(4, 7, B[0]);\n dinic.AddEdge(5, 7, B[1]);\n dinic.AddEdge(6, 7, B[2]);\n\n var min = N - dinic.MaxFlow(0, 7);\n\n int max = 0;\n for (int i = 0; i < 3; i++)\n {\n max += Math.Min(A[i], B[(i + 1) % 3]);\n }\n\n Output(min + \" \" + max);\n }\n\n class Dinic\n {\n public Dinic(int node_size)\n {\n V = node_size;\n G = Enumerable.Repeat(0, V).Select(_ => new List()).ToList();\n level = Enumerable.Repeat(0, V).ToList();\n iter = Enumerable.Repeat(0, V).ToList();\n }\n\n class Edge\n {\n public Edge(int to, int cap, int rev)\n {\n To = to; Cap = cap; Rev = rev;\n }\n public int To { get; set; }\n public int Cap { get; set; }\n public int Rev { get; set; }\n }\n\n List> G;\n int V;\n List level;\n List iter;\n\n public void AddEdge(int from, int to, int cap)\n {\n G[from].Add(new Edge(to, cap, G[to].Count));\n G[to].Add(new Edge(from, 0, G[from].Count - 1));\n }\n\n public int MaxFlow(int s, int t)\n {\n int flow = 0;\n while (true)\n {\n BFS(s);\n if (level[t] < 0) { return flow; }\n iter = Enumerable.Repeat(0, V).ToList();\n var f = DFS(s, t, int.MaxValue);\n while (f > 0)\n {\n flow += f;\n f = DFS(s, t, int.MaxValue);\n }\n }\n }\n\n void BFS(int s)\n {\n level = Enumerable.Repeat(-1, V).ToList();\n level[s] = 0;\n var que = new Queue();\n que.Enqueue(s);\n while (que.Count != 0)\n {\n var v = que.Dequeue();\n for (int i = 0; i < G[v].Count; i++)\n {\n var e = G[v][i];\n if (e.Cap > 0 && level[e.To] < 0)\n {\n level[e.To] = level[v] + 1;\n que.Enqueue(e.To);\n }\n }\n }\n }\n\n int DFS(int v, int t, int f)\n {\n if (v == t) return f;\n for (int i = iter[v]; i < G[v].Count; i++)\n {\n iter[v] = i;\n var e = G[v][i];\n if (e.Cap > 0 && level[v] < level[e.To])\n {\n var d = DFS(e.To, t, Math.Min(f, e.Cap));\n if (d > 0)\n {\n e.Cap -= d;\n G[e.To][e.Rev].Cap += d;\n return d;\n }\n }\n }\n return 0;\n }\n }\n}", "lang_cluster": "C#", "tags": ["brute force", "constructive algorithms", "flows", "math", "greedy"], "code_uid": "c1e4d5928444eacc9cd5abc031685293", "src_uid": "e6dc3bc64fc66b6127e2b32cacc06402", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing static System.Console;\nusing static System.Math;\n\nnamespace AtTest.Codeforces._1426\n{\n class E\n {\n static void Main(string[] args)\n {\n var sw = new System.IO.StreamWriter(OpenStandardOutput()) { AutoFlush = false };\n SetOut(sw);\n\n Method(args);\n\n Out.Flush();\n }\n\n static void Method(string[] args)\n {\n int n = ReadInt();\n int[] arrayA = ReadInts();\n int[] arrayB = ReadInts();\n\n int[][] pats = new int[6][];\n pats[0] = new int[3] { 0, 1, 2 };\n pats[1] = new int[3] { 0, 2, 1 };\n pats[2] = new int[3] { 1, 0, 2 };\n pats[3] = new int[3] { 1, 2, 0 };\n pats[4] = new int[3] { 2, 0, 1 };\n pats[5] = new int[3] { 2, 1, 0 };\n\n int min = int.MaxValue;\n int max = 0;\n for(int i = 0; i < 6; i++)\n {\n for(int j = 0; j < 6; j++)\n {\n int cnt = 0;\n int[] tmpA = new int[3] { arrayA[0], arrayA[1], arrayA[2] };\n int[] tmpB = new int[3] { arrayB[0], arrayB[1], arrayB[2] };\n for (int x = 0; x < 3; x++)\n {\n for(int y = 0; y < 3; y++)\n {\n int common = Min(tmpA[pats[i][x]], tmpB[pats[j][y]]);\n tmpA[pats[i][x]] -= common;\n tmpB[pats[j][y]] -= common;\n if ((pats[i][x] + 1) % 3 == pats[j][y])\n {\n cnt += common;\n }\n }\n }\n min = Min(min, cnt);\n max = Max(max, cnt);\n }\n }\n\n /*\n int min = 0;\n {\n int[] tmpA = new int[3] { arrayA[0], arrayA[1], arrayA[2] };\n int[] tmpB = new int[3] { arrayB[0], arrayB[1], arrayB[2] };\n for(int i = 0; i < 3; i++)\n {\n int common = Min(tmpA[i], tmpB[(i + 2) % 3]);\n tmpA[i] -= common;\n tmpB[(i + 2) % 3] -= common;\n }\n for(int i = 0; i < 3; i++)\n {\n int common = Min(tmpA[i], tmpB[i]);\n tmpA[i] -= common;\n tmpB[i] -= common;\n }\n for(int i = 0; i < 3; i++)\n {\n min += tmpA[i];\n }\n }\n\n int max = 0;\n {\n for (int i = 0; i < 3; i++)\n {\n max+= Min(arrayA[i], arrayB[(i +1) % 3]);\n }\n }\n */\n\n WriteLine(min + \" \" + max);\n }\n\n private static string Read() { return ReadLine(); }\n private static char[] ReadChars() { return Array.ConvertAll(Read().Split(), a => a[0]); }\n private static int ReadInt() { return int.Parse(Read()); }\n private static long ReadLong() { return long.Parse(Read()); }\n private static double ReadDouble() { return double.Parse(Read()); }\n private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }\n private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }\n private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "constructive algorithms", "flows", "math", "greedy"], "code_uid": "afa98315ac6d0b2da61fa5dcc7a6a2c8", "src_uid": "e6dc3bc64fc66b6127e2b32cacc06402", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": ".NET Core C#", "source_code": "\ufeffusing System;\nusing static System.Math;\n\nclass E2\n{\n\tstatic int[] Read() => Array.ConvertAll(Console.ReadLine().Split(), int.Parse);\n\tstatic void Main()\n\t{\n\t\tvar n = int.Parse(Console.ReadLine());\n\t\tvar a = Read();\n\t\tvar b = Read();\n\n\t\tvar max = Min(a[0], b[1]) + Min(a[1], b[2]) + Min(a[2], b[0]);\n\t\tvar min_ = 0;\n\n\t\tvar pairs = new[] { (0, 0), (1, 1), (2, 2), (0, 2), (1, 0), (2, 1) };\n\n\t\tPermutation(pairs, 6, ps =>\n\t\t{\n\t\t\tvar c = (int[])a.Clone();\n\t\t\tvar d = (int[])b.Clone();\n\n\t\t\tvar t = 0;\n\t\t\tforeach (var (i, j) in ps)\n\t\t\t{\n\t\t\t\tvar m = Min(c[i], d[j]);\n\t\t\t\tt += m;\n\t\t\t\tc[i] -= m;\n\t\t\t\td[j] -= m;\n\t\t\t}\n\t\t\tmin_ = Max(min_, t);\n\t\t});\n\n\t\tConsole.WriteLine($\"{n - min_} {max}\");\n\t}\n\n\tstatic void Permutation(T[] values, int r, Action action)\n\t{\n\t\tvar n = values.Length;\n\t\tvar p = new T[r];\n\t\tvar u = new bool[n];\n\n\t\tif (r > 0) Dfs(0);\n\t\telse action(p);\n\n\t\tvoid Dfs(int i)\n\t\t{\n\t\t\tvar i2 = i + 1;\n\t\t\tfor (int j = 0; j < n; ++j)\n\t\t\t{\n\t\t\t\tif (u[j]) continue;\n\t\t\t\tp[i] = values[j];\n\t\t\t\tu[j] = true;\n\n\t\t\t\tif (i2 < r) Dfs(i2);\n\t\t\t\telse action(p);\n\n\t\t\t\tu[j] = false;\n\t\t\t}\n\t\t}\n\t}\n}\n", "lang_cluster": "C#", "tags": ["brute force", "constructive algorithms", "flows", "math", "greedy"], "code_uid": "d290e552171784107b9cde200401bf28", "src_uid": "e6dc3bc64fc66b6127e2b32cacc06402", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Globalization;\nusing System.IO;\nusing System.Linq;\nusing System.Text;\nusing System.Threading;\n\n// (\u3065\u00b0\u03c9\u00b0)\u3065\uff90e\u2605\u309c\u30fb\u3002\u3002\u30fb\u309c\u309c\u30fb\u3002\u3002\u30fb\u309c\u2606\u309c\u30fb\u3002\u3002\u30fb\u309c\u309c\u30fb\u3002\u3002\u30fb\u309c\npublic class Solver\n{\n class Edge\n {\n public int To, Inv;\n public T Capacity;\n public Edge(int to, int inv, T capacity)\n {\n To = to;\n Inv = inv;\n Capacity = capacity;\n }\n }\n\n static void AddEdge(List>[] g, int from, int to, T capacity, bool directed = true)\n {\n g[from].Add(new Edge(to, g[to].Count, capacity));\n g[to].Add(new Edge(from, g[from].Count - 1, directed ? default(T) : capacity));\n }\n\n static class Flow\n {\n private static int[] level;\n private static int[] ptr;\n private static int n, source, sink;\n private static List>[] g;\n\n public static long Find(List>[] g, int source, int sink)\n {\n n = g.Length;\n level = new int[n];\n ptr = new int[n];\n Flow.g = g;\n Flow.source = source;\n Flow.sink = sink;\n\n long ret = 0;\n while (true)\n {\n Bfs();\n if (level[sink] < 0)\n return ret;\n Array.Clear(ptr, 0, n);\n long f;\n while ((f = Dfs(source, int.MaxValue / 2)) > 0)\n ret += f;\n }\n }\n\n static void Bfs()\n {\n for (int i = 0; i < n; i++)\n level[i] = -1;\n var q = new Queue();\n level[source] = 0;\n q.Enqueue(source);\n while (q.Count > 0)\n {\n var v = q.Dequeue();\n foreach (var e in g[v])\n if (e.Capacity > 0 && level[e.To] < 0)\n {\n level[e.To] = level[v] + 1;\n q.Enqueue(e.To);\n }\n }\n }\n\n static long Dfs(int v, long f)\n {\n if (v == sink)\n return f;\n for (; ptr[v] < g[v].Count; ptr[v]++)\n {\n var e = g[v][ptr[v]];\n if (e.Capacity <= 0 || level[v] >= level[e.To])\n continue;\n long d = Dfs(e.To, Math.Min(f, e.Capacity));\n if (d <= 0)\n continue;\n e.Capacity -= d;\n g[e.To][e.Inv].Capacity += d;\n return d;\n }\n return 0;\n }\n }\n\n public void Solve()\n {\n for (int tt = 1; tt > 0; tt--)\n {\n int n = ReadInt();\n var a = ReadIntArray();\n var b = ReadIntArray();\n\n long ans = 1L * Math.Min(a[0], b[1]) + Math.Min(a[1], b[2]) + Math.Min(a[2], b[0]);\n var g = Init>>(8);\n for (int i = 0; i < 3; i++)\n {\n AddEdge(g, 6, i, a[i]);\n AddEdge(g, i + 3, 7, b[i]);\n for (int j = 0; j < 2; j++)\n AddEdge(g, i, (i + 2 + j) % 3 + 3, long.MaxValue);\n }\n\n Write(a.Sum(aa => (long)aa) - Flow.Find(g, 6, 7), ans);\n }\n }\n\n #region Main\n\n protected static TextReader reader;\n protected static TextWriter writer;\n static void Main()\n {\n#if DEBUG\n reader = new StreamReader(\"..\\\\..\\\\input.txt\");\n //reader = new StreamReader(Console.OpenStandardInput());\n writer = Console.Out;\n //writer = new StreamWriter(\"..\\\\..\\\\output.txt\");\n#else\n reader = new StreamReader(Console.OpenStandardInput());\n writer = new StreamWriter(Console.OpenStandardOutput());\n //reader = new StreamReader(\"input.txt\");\n //writer = new StreamWriter(\"output.txt\");\n#endif\n try\n {\n new Solver().Solve();\n //var thread = new Thread(new Solver().Solve, 1024 * 1024 * 128);\n //thread.Start();\n //thread.Join();\n }\n catch (Exception ex)\n {\n#if DEBUG\n Console.WriteLine(ex);\n#else\n throw;\n#endif\n }\n reader.Close();\n writer.Close();\n }\n\n #endregion\n\n #region Read / Write\n private static Queue currentLineTokens = new Queue();\n private static string[] ReadAndSplitLine() { return reader.ReadLine().Split(new[] { ' ', '\\t', }, StringSplitOptions.RemoveEmptyEntries); }\n public static string ReadToken() { while (currentLineTokens.Count == 0) currentLineTokens = new Queue(ReadAndSplitLine()); return currentLineTokens.Dequeue(); }\n public static int ReadInt() { return int.Parse(ReadToken()); }\n public static long ReadLong() { return long.Parse(ReadToken()); }\n public static double ReadDouble() { return double.Parse(ReadToken(), CultureInfo.InvariantCulture); }\n public static int[] ReadIntArray() { return ReadAndSplitLine().Select(int.Parse).ToArray(); }\n public static long[] ReadLongArray() { return ReadAndSplitLine().Select(long.Parse).ToArray(); }\n public static double[] ReadDoubleArray() { return ReadAndSplitLine().Select(s => double.Parse(s, CultureInfo.InvariantCulture)).ToArray(); }\n public static int[][] ReadIntMatrix(int numberOfRows) { int[][] matrix = new int[numberOfRows][]; for (int i = 0; i < numberOfRows; i++) matrix[i] = ReadIntArray(); return matrix; }\n public static int[][] ReadAndTransposeIntMatrix(int numberOfRows)\n {\n int[][] matrix = ReadIntMatrix(numberOfRows); int[][] ret = new int[matrix[0].Length][];\n for (int i = 0; i < ret.Length; i++) { ret[i] = new int[numberOfRows]; for (int j = 0; j < numberOfRows; j++) ret[i][j] = matrix[j][i]; }\n return ret;\n }\n public static string[] ReadLines(int quantity) { string[] lines = new string[quantity]; for (int i = 0; i < quantity; i++) lines[i] = reader.ReadLine().Trim(); return lines; }\n public static void WriteArray(IEnumerable array) { writer.WriteLine(string.Join(\" \", array)); }\n public static void Write(params object[] array) { WriteArray(array); }\n public static void WriteLines(IEnumerable array) { foreach (var a in array) writer.WriteLine(a); }\n private class SDictionary : Dictionary\n {\n public new TValue this[TKey key]\n {\n get { return ContainsKey(key) ? base[key] : default(TValue); }\n set { base[key] = value; }\n }\n }\n private static T[] Init(int size) where T : new() { var ret = new T[size]; for (int i = 0; i < size; i++) ret[i] = new T(); return ret; }\n #endregion\n}", "lang_cluster": "C#", "tags": ["brute force", "constructive algorithms", "flows", "math", "greedy"], "code_uid": "9486eef764a98edaea3cbfda4eeda0d3", "src_uid": "e6dc3bc64fc66b6127e2b32cacc06402", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": ".NET Core C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing static System.Math;\n\nclass E\n{\n\tstatic int[] Read() => Console.ReadLine().Split().Select(int.Parse).ToArray();\n\tstatic void Main()\n\t{\n\t\tvar n = int.Parse(Console.ReadLine());\n\t\tvar a = Read();\n\t\tvar b = Read();\n\n\t\tvar max = Min(a[0], b[1]) + Min(a[1], b[2]) + Min(a[2], b[0]);\n\n\t\tvar dg = new List();\n\t\tvar sv = 6;\n\t\tvar ev = 7;\n\t\tfor (long i = 0; i < 3; i++)\n\t\t{\n\t\t\tdg.Add(new[] { sv, i, a[i] });\n\t\t\tdg.Add(new[] { 3 + i, ev, b[i] });\n\t\t}\n\t\tdg.Add(new[] { 0L, 3, Min(a[0], b[0]) });\n\t\tdg.Add(new[] { 1L, 4, Min(a[1], b[1]) });\n\t\tdg.Add(new[] { 2L, 5, Min(a[2], b[2]) });\n\t\tdg.Add(new[] { 0L, 5, Min(a[0], b[2]) });\n\t\tdg.Add(new[] { 1L, 3, Min(a[1], b[0]) });\n\t\tdg.Add(new[] { 2L, 4, Min(a[2], b[1]) });\n\n\t\tvar min = n - MaxFlow(ev, sv, ev, dg.ToArray());\n\t\tConsole.WriteLine($\"{min} {max}\");\n\t}\n\n\t// dg: { from, to, capacity }\n\tstatic long MaxFlow(int n, int sv, int ev, long[][] dg)\n\t{\n\t\tvar map = Array.ConvertAll(new int[n + 1], _ => new List());\n\t\tforeach (var e in dg)\n\t\t{\n\t\t\tmap[e[0]].Add(new[] { e[0], e[1], e[2], map[e[1]].Count });\n\t\t\tmap[e[1]].Add(new[] { e[1], e[0], 0, map[e[0]].Count - 1 });\n\t\t}\n\n\t\tlong Bfs()\n\t\t{\n\t\t\tvar from = new long[n + 1][];\n\t\t\tvar minFlow = new long[n + 1];\n\t\t\tArray.Fill(minFlow, long.MaxValue);\n\t\t\tvar q = new Queue();\n\t\t\tq.Enqueue(sv);\n\n\t\t\twhile (q.TryDequeue(out var v))\n\t\t\t{\n\t\t\t\tif (v == ev) break;\n\t\t\t\tforeach (var e in map[v])\n\t\t\t\t{\n\t\t\t\t\tif (from[e[1]] != null || e[2] == 0) continue;\n\t\t\t\t\tfrom[e[1]] = e;\n\t\t\t\t\tminFlow[e[1]] = Math.Min(minFlow[v], e[2]);\n\t\t\t\t\tq.Enqueue(e[1]);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (from[ev] == null) return 0;\n\t\t\tfor (long v = ev; v != sv; v = from[v][0])\n\t\t\t{\n\t\t\t\tvar e = from[v];\n\t\t\t\te[2] -= minFlow[ev];\n\t\t\t\tmap[e[1]][(int)e[3]][2] += minFlow[ev];\n\t\t\t}\n\t\t\treturn minFlow[ev];\n\t\t}\n\n\t\tlong M = 0, t;\n\t\twhile ((t = Bfs()) > 0) M += t;\n\t\treturn M;\n\t}\n}\n", "lang_cluster": "C#", "tags": ["brute force", "constructive algorithms", "flows", "math", "greedy"], "code_uid": "14ab4e353bbc6f4f1b1d2c8c01053ffa", "src_uid": "e6dc3bc64fc66b6127e2b32cacc06402", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Linq;\n\nnamespace CSharp\n{\n public class _908A\n {\n public static void Main(string[] args)\n {\n Console.WriteLine(Console.ReadLine().Count(c => c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u' || c == '1' || c == '3' || c == '5' || c == '7' || c == '9'));\n }\n }\n}", "lang_cluster": "C#", "tags": ["brute force", "implementation"], "code_uid": "e8d93999f05e416d8ef51f5d53fb0235", "src_uid": "b4af2b8a7e9844bf58ad3410c2cb5223", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections;\nusing System.Collections.Generic;\n\nnamespace dd\n{\n\tclass MainClass\n\t{\n\t\tpublic static void Main(string[] args)\n\t\t{\n\t\t\tstring str = Console.ReadLine();\n\t\t\tstring vowels = \"aouei\";\n\t\t\tint ans = 0;\n\t\t\tforeach (char x in str)\n\t\t\t{\n\t\t\t\tif (char.IsLetter(x))\n\t\t\t\t{\n\t\t\t\t\tBoolean ok = false;\n\t\t\t\t\tforeach (char j in vowels)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (x == j) ok = true;\n\t\t\t\t\t}\n\t\t\t\t\tif (ok) ans++;\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tint t = Convert.ToInt32(x);\n\t\t\t\t\tans += t % 2;\n\t\t\t\t}\n\n\t\t\t}\n\t\t\tConsole.WriteLine(ans);\n\t\t}\n\t}\n}", "lang_cluster": "C#", "tags": ["brute force", "implementation"], "code_uid": "fdcea2f13683fa9647282f6c95ec9ed5", "src_uid": "b4af2b8a7e9844bf58ad3410c2cb5223", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections;\nusing System.Linq;\nusing System.Numerics;\n\nclass Program3\n {\n public static void Main(string[] args)\n {\n char[] line = Console.ReadLine().ToCharArray();\n int fi = -1;\n bool si = false;\n for (int i = 0; i < line.Length; i++) {\n if (line[i] == '1' && fi == -1)\n fi = i;\n else\n if (line[i] == '1' && !si) {\n si = true;\n break;\n }\n }\n\n if (fi == -1)\n Console.WriteLine(0);\n else\n if (si)\n Console.WriteLine(Math.Ceiling((double)(line.Length - fi) / (double)2));\n else\n Console.WriteLine(Math.Floor((double)(line.Length - fi) / (double)2));\n\n }\n\n}\n", "lang_cluster": "C#", "tags": ["math"], "code_uid": "6b64ea31ab75b8885e441310740655ac", "src_uid": "d8ca1c83b431466eff6054d3b422ab47", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": ".NET Core C#", "source_code": "using System;\nusing System.Linq;\nusing System.Numerics;\nusing CompLib.Util;\nusing System.Threading;\n\npublic class Program\n{\n public void Solve()\n {\n var sc = new Scanner();\n string s = sc.Next();\n bool f = false;\n for (int i = 1; i < s.Length; i++) f |= s[i] == '1';\n\n int ans = (s.Length) / 2;\n if (s.Length % 2 == 1 && f) ans++;\n Console.WriteLine(ans);\n }\n\n public static void Main(string[] args) => new Program().Solve();\n // public static void Main(string[] args) => new Thread(new Program().Solve, 1 << 27).Start();\n}\n\nnamespace CompLib.Util\n{\n using System;\n using System.Linq;\n\n class Scanner\n {\n private string[] _line;\n private int _index;\n private const char Separator = ' ';\n\n public Scanner()\n {\n _line = new string[0];\n _index = 0;\n }\n\n public string Next()\n {\n if (_index >= _line.Length)\n {\n string s;\n do\n {\n s = Console.ReadLine();\n } while (s.Length == 0);\n\n _line = s.Split(Separator);\n _index = 0;\n }\n\n return _line[_index++];\n }\n\n public string ReadLine()\n {\n _index = _line.Length;\n return Console.ReadLine();\n }\n\n public int NextInt() => int.Parse(Next());\n public long NextLong() => long.Parse(Next());\n public double NextDouble() => double.Parse(Next());\n public decimal NextDecimal() => decimal.Parse(Next());\n public char NextChar() => Next()[0];\n public char[] NextCharArray() => Next().ToCharArray();\n\n public string[] Array()\n {\n string s = Console.ReadLine();\n _line = s.Length == 0 ? new string[0] : s.Split(Separator);\n _index = _line.Length;\n return _line;\n }\n\n public int[] IntArray() => Array().Select(int.Parse).ToArray();\n public long[] LongArray() => Array().Select(long.Parse).ToArray();\n public double[] DoubleArray() => Array().Select(double.Parse).ToArray();\n public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();\n }\n}", "lang_cluster": "C#", "tags": ["math"], "code_uid": "8b7395ae7239eb2bce91766ce2d73c74", "src_uid": "d8ca1c83b431466eff6054d3b422ab47", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing CompLib.Util;\n\npublic class Program\n{\n\n public void Solve()\n {\n var sc = new Scanner();\n int x1 = sc.NextInt();\n int y1 = sc.NextInt();\n int x2 = sc.NextInt();\n int y2 = sc.NextInt();\n\n int x3 = sc.NextInt();\n int y3 = sc.NextInt();\n int x4 = sc.NextInt();\n int y4 = sc.NextInt();\n\n int x5 = sc.NextInt();\n int y5 = sc.NextInt();\n int x6 = sc.NextInt();\n int y6 = sc.NextInt();\n\n S a = new S(x1, y1, x2, y2);\n S b = new S(x3, y3, x4, y4);\n S c = new S(x5, y5, x6, y6);\n\n if (!b.I(a.X1, a.Y1) && !c.I(a.X1, a.Y1))\n {\n Console.WriteLine(\"YES\");\n return;\n }\n if (!b.I(a.X1, a.Y2) && !c.I(a.X1, a.Y2))\n {\n Console.WriteLine(\"YES\");\n return;\n }\n if (!b.I(a.X2, a.Y1) && !c.I(a.X2, a.Y1))\n {\n Console.WriteLine(\"YES\");\n return;\n }\n if (!b.I(a.X2, a.Y2) && !c.I(a.X2, a.Y2))\n {\n Console.WriteLine(\"YES\");\n return;\n }\n\n if(b.I(a.X1,a.Y1) && b.I(a.X2, a.Y2))\n {\n Console.WriteLine(\"NO\");\n return;\n }\n\n if (c.I(a.X1, a.Y1) && c.I(a.X2, a.Y2))\n {\n Console.WriteLine(\"NO\");\n return;\n }\n\n if (b.I(c.X1, c.Y1) || b.I(c.X1, c.Y2) || b.I(c.X2, c.Y1) || b.I(c.X2, c.Y2))\n {\n Console.WriteLine(\"NO\");\n return;\n }\n if (c.I(b.X1, b.Y1) || c.I(b.X1, b.Y2) || c.I(b.X2, b.Y1) || c.I(b.X2, b.Y2))\n {\n Console.WriteLine(\"NO\");\n return;\n }\n\n Console.WriteLine(\"YES\");\n }\n\n public static void Main(string[] args) => new Program().Solve();\n}\n\nstruct S\n{\n public int X1, Y1, X2, Y2;\n public S(int x1, int y1, int x2, int y2)\n {\n X1 = x1;\n Y1 = y1;\n X2 = x2;\n Y2 = y2;\n }\n\n public bool I(int x, int y)\n {\n return X1 <= x && x <= X2 && Y1 <= y && y <= Y2;\n }\n}\n\nnamespace CompLib.Util\n{\n using System;\n using System.Linq;\n\n class Scanner\n {\n private string[] _line;\n private int _index;\n private const char Separator = ' ';\n\n public Scanner()\n {\n _line = new string[0];\n _index = 0;\n }\n\n public string Next()\n {\n while (_index >= _line.Length)\n {\n _line = Console.ReadLine().Split(Separator);\n _index = 0;\n }\n\n return _line[_index++];\n }\n\n public int NextInt() => int.Parse(Next());\n public long NextLong() => long.Parse(Next());\n public double NextDouble() => double.Parse(Next());\n public decimal NextDecimal() => decimal.Parse(Next());\n public char NextChar() => Next()[0];\n public char[] NextCharArray() => Next().ToCharArray();\n\n public string[] Array()\n {\n _line = Console.ReadLine().Split(Separator);\n _index = _line.Length;\n return _line;\n }\n\n public int[] IntArray() => Array().Select(int.Parse).ToArray();\n public long[] LongArray() => Array().Select(long.Parse).ToArray();\n public double[] DoubleArray() => Array().Select(double.Parse).ToArray();\n public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "geometry"], "code_uid": "8a6f9df7ff822ad60b5ff72a4305d335", "src_uid": "05c90c1d75d76a522241af6bb6af7781", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\n\nnamespace Problems\n{\n class Program\n {\n static void Main(string[] args)\n {\n int x1, y1, x2, y2;\n\n string[] input = Console.ReadLine().Split(' ');\n\n x1 = Convert.ToInt32(input[0]);\n y1 = Convert.ToInt32(input[1]);\n x2 = Convert.ToInt32(input[2]);\n y2 = Convert.ToInt32(input[3]);\n\n int x3, y3, x4, y4;\n\n input = Console.ReadLine().Split(' ');\n\n x3 = Convert.ToInt32(input[0]);\n y3 = Convert.ToInt32(input[1]);\n x4 = Convert.ToInt32(input[2]);\n y4 = Convert.ToInt32(input[3]);\n\n int x5, y5, x6, y6;\n\n input = Console.ReadLine().Split(' ');\n\n x5 = Convert.ToInt32(input[0]);\n y5 = Convert.ToInt32(input[1]);\n x6 = Convert.ToInt32(input[2]);\n y6 = Convert.ToInt32(input[3]);\n\n bool allCovered = false;\n\n if(x3 <= x1 && y3 <= y1 && x4 >= x2 && y4 >= y2)\n {\n //Console.WriteLine(\"In 1\");\n allCovered = true;\n }\n else if(x5 <= x1 && y5 <= y1 && x6 >= x2 && y6 >= y2)\n {\n //Console.WriteLine(\"In 2\");\n allCovered = true;\n }\n else if(x3 <= x1 && y3 <= y1 && x4 < x2 && y4 >= y2)\n {\n if(x5 <= x4 && y5 <= y1 && y6 >= y2 && x6 >= x2)\n {\n //Console.WriteLine(\"In 3\");\n allCovered = true;\n }\n }\n else if(x5 <= x1 && y5 <= y1 && x6 < x2 && y6 >= y2)\n {\n if(x3 <= x6 && y3 <= y1 && y4 >= y2 && x4 >= x2)\n {\n //Console.WriteLine(\"In 4\");\n allCovered = true;\n }\n }\n else if(x3 <= x1 && y3 <= y1 && x4 >= x2 && y4 < y2)\n {\n if(y5 <= y4 && x5 <= x1 && x6 >= x2 && y6 >= y2)\n {\n //Console.WriteLine(\"In 5\");\n allCovered = true;\n }\n }\n else if(x5 <= x1 && y5 <= y1 && x6 >= x2 && y6 < y2)\n {\n if(y3 <= y6 && x3 <= x1 && x4 >= x2 && y4 >= y2)\n {\n //Console.WriteLine(\"In 6\");\n allCovered = true;\n }\n }\n\n if(allCovered) Console.WriteLine(\"NO\");\n else Console.WriteLine(\"YES\");\n }\n }\n}", "lang_cluster": "C#", "tags": ["math", "geometry"], "code_uid": "8d9eb80605150f24948756f93f41a7e6", "src_uid": "05c90c1d75d76a522241af6bb6af7781", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\n\nnamespace test_project\n{\n class MainClass\n {\n public static void Main(string[] args)\n {\n int n = int.Parse(Console.ReadLine());\n int res = 1 + 2 * n * (n - 1);\n Console.WriteLine(res);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "dp", "implementation"], "code_uid": "e3dbecf6bb56d25ee31ff562f801a47e", "src_uid": "758d342c1badde6d0b4db81285be780c", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Globalization;\nusing System.IO;\nusing System.Linq;\nusing System.Text;\nusing System.Threading;\n\npublic class Solver\n{\n public void Solve()\n {\n\t\tint n = ReadInt();\n\t\tif (n == 1)\n\t\t\tWrite(1);\n\t\telse\n\t\t{\n\t\t\tint side = n - 1;\n\t\t\tint side_square = side*(side+1)/2;\n\t\t\tWrite(side_square*4+1);\n\t\t}\n }\n\n #region Main\n\n protected static TextReader reader;\n protected static TextWriter writer;\n static void Main()\n {\n#if DEBUG\n // reader = new StreamReader(\"..\\\\..\\\\input.txt\");\n reader = new StreamReader(Console.OpenStandardInput());\n writer = Console.Out;\n //writer = new StreamWriter(\"..\\\\..\\\\output.txt\");\n#else\n reader = new StreamReader(Console.OpenStandardInput());\n writer = new StreamWriter(Console.OpenStandardOutput());\n //reader = new StreamReader(\"input.txt\");\n //writer = new StreamWriter(\"output.txt\");\n#endif\n try\n {\n new Solver().Solve();\n //var thread = new Thread(new Solver().Solve, 1024 * 1024 * 128);\n //thread.Start();\n //thread.Join();\n }\n catch (Exception ex)\n {\n#if DEBUG\n Console.WriteLine(ex);\n#else\n throw;\n#endif\n }\n reader.Close();\n writer.Close();\n }\n\n #endregion\n\n #region Read / Write\n private static Queue currentLineTokens = new Queue();\n private static string[] ReadAndSplitLine() { return reader.ReadLine().Split(new[] { ' ', '\\t', }, StringSplitOptions.RemoveEmptyEntries); }\n public static string ReadToken() { while (currentLineTokens.Count == 0)currentLineTokens = new Queue(ReadAndSplitLine()); return currentLineTokens.Dequeue(); }\n public static int ReadInt() { return int.Parse(ReadToken()); }\n public static long ReadLong() { return long.Parse(ReadToken()); }\n public static double ReadDouble() { return double.Parse(ReadToken(), CultureInfo.InvariantCulture); }\n public static int[] ReadIntArray() { return ReadAndSplitLine().Select(int.Parse).ToArray(); }\n public static long[] ReadLongArray() { return ReadAndSplitLine().Select(long.Parse).ToArray(); }\n public static double[] ReadDoubleArray() { return ReadAndSplitLine().Select(s => double.Parse(s, CultureInfo.InvariantCulture)).ToArray(); }\n public static int[][] ReadIntMatrix(int numberOfRows) { int[][] matrix = new int[numberOfRows][]; for (int i = 0; i < numberOfRows; i++)matrix[i] = ReadIntArray(); return matrix; }\n public static int[][] ReadAndTransposeIntMatrix(int numberOfRows)\n {\n int[][] matrix = ReadIntMatrix(numberOfRows); int[][] ret = new int[matrix[0].Length][];\n for (int i = 0; i < ret.Length; i++) { ret[i] = new int[numberOfRows]; for (int j = 0; j < numberOfRows; j++)ret[i][j] = matrix[j][i]; } return ret;\n }\n public static string[] ReadLines(int quantity) { string[] lines = new string[quantity]; for (int i = 0; i < quantity; i++)lines[i] = reader.ReadLine().Trim(); return lines; }\n public static void WriteArray(IEnumerable array) { writer.WriteLine(string.Join(\" \", array)); }\n public static void Write(params object[] array) { WriteArray(array); }\n public static void WriteLines(IEnumerable array) { foreach (var a in array)writer.WriteLine(a); }\n private class SDictionary : Dictionary\n {\n public new TValue this[TKey key]\n {\n get { return ContainsKey(key) ? base[key] : default(TValue); }\n set { base[key] = value; }\n }\n }\n private static T[] Init(int size) where T : new() { var ret = new T[size]; for (int i = 0; i < size; i++)ret[i] = new T(); return ret; }\n #endregion\n}\n", "lang_cluster": "C#", "tags": ["math", "dp", "implementation"], "code_uid": "282081851261312128b016e38a313fb4", "src_uid": "758d342c1badde6d0b4db81285be780c", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\n\nnamespace codeforces\n{\n class Program\n {\n static void Main(string[] args)\n {\n string s = Console.ReadLine();\n if (s.Distinct().Count() > 2)\n Console.Write(\"NO\");\n else if (s.Distinct().Count() == 1 )\n {\n if (s.Contains('1'))\n Console.Write(\"YES\");\n else Console.Write(\"NO\");\n }\n else if (!(s.Contains('1') && s.Contains('4')))\n Console.Write(\"NO\");\n else\n {\n Console.Write(CheckSequence(s)?\"YES\":\"NO\");\n }\n //Console.ReadKey();\n }\n static bool CheckSequence(string s)\n {\n if (s[0] == '4')\n return false;\n for (int i = 2; i < s.Length; i++)\n {\n if (s[i] == '4' && s[i - 1] == '4' && s[i - 2] == '4')\n return false;\n }\n return true;\n }\n }\n}", "lang_cluster": "C#", "tags": ["brute force", "greedy"], "code_uid": "b7c66fc82d8198809f2be9fefafec377", "src_uid": "3153cfddae27fbd817caaf2cb7a6a4b5", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\n\nnamespace Magic_Numbers\n{\n class Program\n {\n static void Main(string[] args)\n {\n string numero = Console.ReadLine();\n bool ok = true;\n int n = numero.Length;\n int count = 0;\n if (numero[0]=='4')\n {\n ok=false;\n }\n else\n {\n for (int i = 0; i < n; i++)\n {\n if (numero[i] != '1' && numero[i] != '4')\n {\n ok = false;\n break;\n }\n else if (numero[i] == '4')\n {\n count++;\n if (count > 2)\n {\n ok = false;\n break;\n }\n }\n else if (numero[i] == '1')\n {\n count = 0;\n }\n } \n }\n \n Console.WriteLine(ok ? \"YES\" : \"NO\");\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "greedy"], "code_uid": "427545f88c7a2faa5707e28f63f21a33", "src_uid": "3153cfddae27fbd817caaf2cb7a6a4b5", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\n\nnamespace csharp\n{\n class Program\n {\n static void Main(string[] args)\n {\n int n = int.Parse(Console.ReadLine());\n String s = Console.ReadLine();\n String s2 = s;\n\n string d1 = \"RU\";\n string d2 = \"UR\";\n\n for(int i = 0; i< s.Length -1; i ++)\n {\n if((s[i] == d1[0] && s[i+1] == d1[1]) || (s[i] == d2[0] && s[i+1] == d2[1]))\n {\n n --;\n i++;\n }\n }\n\n Console.WriteLine(n);\n }\n }\n}", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "16bef651b980038ca54802bb31cf1a17", "src_uid": "986ae418ce82435badadb0bd5588f45b", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace Codeforces\n{ \n class A\n {\n static void Main(string[] args)\n {\n int n = int.Parse(Console.ReadLine());\n string s = Console.ReadLine();\n \n int ans = n;\n \n for(int i=0;i long.Parse(s)).ToArray();\n var beds = arg[0];\n var pillows = arg[1];\n var pos = arg[2];\n \n var low = (long)1;\n var high = pillows;\n while (low < high) {\n var mid = (low + high)/2 + (low+high)%2;\n if (AmountNeeded(beds,pos,mid) > pillows) {\n high = mid - 1;\n }\n else {\n low = mid;\n }\n }\n Console.WriteLine(high);\n }\n \n public static long AmountNeeded(long beds, long pos, long level) {\n var r = beds;\n level--;\n r += level;\n level--;\n r += 2 * AmountInSide(level);\n if (pos - level < 1) r -= AmountInSide(level - pos + 1);\n if (pos + level > beds) r -= AmountInSide(pos+level-beds);\n return r;\n }\n \n public static long AmountInSide(long length) {\n return length * (length + 1) / 2;\n }\n }\n}", "lang_cluster": "C#", "tags": ["greedy", "binary search"], "code_uid": "b70d4461711e8a95bd1d6670ee2b1c9e", "src_uid": "da9ddd00f46021e8ee9db4a8deed017c", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Globalization;\nusing System.Linq;\nusing System.Text;\nusing System.Text.RegularExpressions;\nusing System.Threading;\n\nnamespace Codeforces\n{\n class B\n {\n private static ThreadStart s_threadStart = new B().Go;\n\n private void Go()\n {\n long n = GetInt();\n long m = GetInt();\n long k = GetInt();\n\n long lo = (m + n - 1) / n;\n long hi = m + 1;\n long mi;\n\n long pillows;\n\n while (lo + 1 < hi)\n {\n mi = (lo + hi) / 2;\n pillows = Get(mi, k) + Get(mi, n - k + 1) - mi;\n if (pillows > m)\n hi = mi;\n else\n lo = mi;\n }\n\n pillows = Get(hi, k) + Get(hi, n - k + 1) - hi;\n if (pillows <= m)\n Wl(hi);\n else\n Wl(lo);\n }\n\n long Get(long value, long size)\n {\n if (value <= size)\n {\n return value * (value + 1) / 2 + size - value;\n }\n\n return value * (value + 1) / 2 - (value - size) * (value - size + 1) / 2;\n }\n\n public static IList Factors(long n)\n {\n List ret = new List();\n long[] factor = new long[] { 1L, 1L };\n for (long p = 2L; p * p <= n; ++p)\n {\n if (n % p == 0)\n {\n n /= p;\n factor = new long[] { p, 1L };\n ret.Add(factor);\n while (n % p == 0)\n {\n n /= p;\n factor[1]++;\n }\n }\n }\n if (n > 1)\n {\n if (n == factor[0]) factor[1]++;\n else ret.Add(new long[] { n, 1L });\n }\n return ret;\n }\n\n #region Template\n\n private static StringBuilder output = new StringBuilder();\n\n public static void Main(string[] args)\n {\n System.Diagnostics.Stopwatch timer = new System.Diagnostics.Stopwatch();\n output.Length = 0;\n Thread main = new Thread(new ThreadStart(s_threadStart), 512 * 1024 * 1024);\n timer.Start();\n main.Start();\n main.Join();\n Console.Write(output);\n timer.Stop();\n Console.Error.WriteLine(timer.ElapsedMilliseconds);\n }\n\n private static IEnumerator ioEnum;\n private static string GetString()\n {\n do\n {\n while (ioEnum == null || !ioEnum.MoveNext())\n {\n ioEnum = Console.ReadLine().Split().AsEnumerable().GetEnumerator();\n }\n } while (string.IsNullOrEmpty(ioEnum.Current));\n\n return ioEnum.Current;\n }\n\n\n private static int GetInt()\n {\n return int.Parse(GetString());\n }\n\n private static long GetLong()\n {\n return long.Parse(GetString());\n }\n\n private static double GetDouble()\n {\n return double.Parse(GetString());\n }\n\n private static List GetIntArr(int n)\n {\n List ret = new List(n);\n for (int i = 0; i < n; i++)\n {\n ret.Add(GetInt());\n }\n return ret;\n }\n\n private static void Wl(T o)\n {\n W(o);\n output.Append(Console.Out.NewLine);\n }\n\n private static void Wl(IEnumerable enumerable)\n {\n W(enumerable);\n output.Append(Console.Out.NewLine);\n }\n\n private static void W(T o)\n {\n if (o is double)\n {\n Wd((o as double?).Value, \"\");\n }\n else if (o is float)\n {\n Wd((o as float?).Value, \"\");\n }\n else\n output.Append(o.ToString());\n }\n\n private static void W(IEnumerable enumerable)\n {\n W(string.Join(\" \", enumerable.Select(e => e.ToString()).ToArray()));\n }\n\n private static void Wd(double d, string format)\n {\n W(d.ToString(format, CultureInfo.InvariantCulture));\n }\n\n #endregion\n }\n}", "lang_cluster": "C#", "tags": ["greedy", "binary search"], "code_uid": "c5c32ba4b8002123cf91efbe027360a4", "src_uid": "da9ddd00f46021e8ee9db4a8deed017c", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "/*\ncsc -debug A.cs && mono --debug A.exe <<< \"3 4 11\n4 2 5\n4 4 5 4\"\n*/\n\nusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\n\npublic class HelloWorld {\n public static void SolveCodeForces() {\n var n = cin.NextInt();\n var m = cin.NextInt();\n var r = cin.NextInt();\n var S = cin.IntArray().OrderBy(s => s).ToArray();\n var B = cin.IntArray();\n\n var sellPrice = B.Max();\n\n var cnt = 0;\n for (var i = 0; i < S.Length; i++) {\n if (r >= S[i] && S[i] < sellPrice) {\n var c = r / S[i];\n cnt += c;\n r -= S[i] * c;\n }\n }\n\n// System.Console.WriteLine(new {sellPrice, cnt, r});\n\n System.Console.WriteLine(r + cnt * sellPrice);\n }\n\n static Scanner cin = new Scanner();\n static StringBuilder cout = new StringBuilder();\n\n static public void Main () {\n SolveCodeForces();\n // System.Console.Write(cout.ToString());\n }\n}\n\npublic static class Helpers {\n public static T[] CreateArray(int length, Func itemCreate) {\n var result = new T[length];\n for (var i = 0; i < result.Length; i++)\n result[i] = itemCreate(i);\n return result;\n }\n\n public static IEnumerable IndicesWhere(this IEnumerable seq, Func cond) {\n var i = 0;\n foreach (var item in seq) {\n if (cond(item)) yield return i;\n i++;\n }\n }\n}\n\npublic class Scanner\n{\n private string[] line = new string[0];\n private int index = 0;\n\n public string Next() {\n if (line.Length <= index) {\n line = Console.ReadLine().Split(' ');\n index = 0;\n }\n var res = line[index];\n index++;\n return res;\n }\n\n public int NextInt() {\n return int.Parse(Next());\n }\n\n public long NextLong() {\n return long.Parse(Next());\n }\n\n public ulong NextUlong() {\n return ulong.Parse(Next());\n }\n\n public string[] Array() {\n line = Console.ReadLine().Split(' ');\n index = line.Length;\n return line;\n }\n\n public int[] IntArray(int emptyPrefixLen = 0) {\n var array = Array();\n var result = new int[emptyPrefixLen + array.Length];\n for (int i = 0; i < array.Length; i++)\n result[emptyPrefixLen + i] = int.Parse(array[i]);\n return result;\n }\n\n public long[] LongArray() {\n var array = Array();\n var result = new long[array.Length];\n for (int i = 0; i < array.Length; i++)\n result[i] = long.Parse(array[i]);\n return result;\n }\n\n public ulong[] UlongArray() {\n var array = Array();\n var result = new ulong[array.Length];\n for (int i = 0; i < array.Length; i++)\n result[i] = ulong.Parse(array[i]);\n return result;\n }\n}", "lang_cluster": "C#", "tags": ["greedy", "implementation"], "code_uid": "bf950e020611a95e498632526440b74b", "src_uid": "42f25d492bddc12d3d89d39315d63cb9", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace ConsoleApp27\n{\n class Program\n {\n static void Main(string[] args)\n {\n \n int[] N = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);\n int[] M = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);\n int[] E = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);\n Array.Sort(M);\n Array.Sort(E);\n int count = 0;\n if (M[0] < E[E.Length - 1])\n {\n count = N[2] / M[0];\n int add = N[2] % M[0];\n count = count * E[E.Length - 1] + add;\n\n }\n else {\n count = N[2];\n }\n Console.WriteLine(count);\n }\n }\n}", "lang_cluster": "C#", "tags": ["greedy", "implementation"], "code_uid": "4d3ef930f0c0cbe64dc0d2b96899605e", "src_uid": "42f25d492bddc12d3d89d39315d63cb9", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace ConsoleApplication3\n{\n class A839\n {\n static void Main(string[] args)\n {\n string[] arr = Console.ReadLine().Split();\n string[] arr1 = Console.ReadLine().Split();\n int n = int.Parse(arr[0]);\n int k = int.Parse(arr[1]);\n int[] a = new int[n];\n for (int i = 0; i < n; i++)\n {\n a[i] = int.Parse(arr1[i]);\n }\n int Bran = 0;\n int Aria = 0;\n int j = 0;\n\n while (n>0) {\n \n for (int i = 0; i < a.Length; i++)\n {\n if (a[i] <= 8)\n {\n Bran += a[i];\n if (8-a[i]>0)\n {\n if (Aria >= 8 - a[i])\n {\n Bran += 8 - a[i];\n Aria -= 8 - a[i];\n }\n else {\n Bran += Aria;\n Aria = 0;\n }\n }\n }\n else {\n Bran += 8;\n Aria += a[i] - 8;\n\n }\n j++;\n n--;\n \n if (Bran >= k) {\n Console.WriteLine(j);\n return;\n }\n\n }\n }\n Console.WriteLine(-1);\n \n \n\n\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "837dfd7cdaa094fcb64d44471701a382", "src_uid": "24695b6a2aa573e90f0fe661b0c0bd3a", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\n\nnamespace ConsoleApplication1\n{\n class Program\n {\n static void Main(string[] args)\n {\n string[]y=Console.ReadLine().Split(' ');\n \n int n=int.Parse(y[0]);\n int k=int.Parse(y[1]);\n string[]y1=Console.ReadLine().Split(' ');\n int[]a=new int[n];\n int ost=0;\n for(int i=0;i8)\n ost+=a[i]-8;\n k-=Math.Min(8,a[i]);\n \n \n f++;\n //Console.WriteLine(k);\n\n if(k<=0)\n break;\n }\n //Console.WriteLine(k);\n if(k>0)\n Console.WriteLine(-1);\n else\n Console.WriteLine(f);\n \n }\n }\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "a19a4605c51d36de619281c86591c1f1", "src_uid": "24695b6a2aa573e90f0fe661b0c0bd3a", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace CodeForcesHero\n{\n class Program\n {\n\n static void Main(string[] args)\n {\n\n // The code provided will print \u2018Hello World\u2019 to the console.\n // Press Ctrl+F5 (or go to Debug > Start Without Debugging) to run your app.\n\n string result = \"\";\n List damaged_bulbs_positions = new List();\n StringBuilder mapped_bulbs_sequence = new StringBuilder(\"0123\"); // mapping of rbyg \n Dictionary RealIndex_MappedIndex = new Dictionary(){\n {0,0},\n {1,0},\n {2,0},\n {3,0}\n };\n Dictionary MappedIndex_DamgedValue = new Dictionary(){\n {0,0},\n {1,0},\n {2,0},\n {3,0}\n };\n string string_input = Console.ReadLine();\n if (string_input.Contains('!') ==false)\n {\n Console.WriteLine(\"0 0 0 0\");\n }\n else\n {\n\n for (int i = 0; i < string_input.Length; i++)\n {\n\n\n switch (string_input[i])\n {\n case '!':\n damaged_bulbs_positions.Add(i%4);\n break;\n case 'R':\n \n RealIndex_MappedIndex[0]= i % 4;\n //mapped_bulbs_sequence[i % 4] = '0';\n break;\n case 'B':\n \n RealIndex_MappedIndex[1]=i % 4;\n break;\n case 'Y':\n RealIndex_MappedIndex[2] = i % 4;\n break;\n case 'G':\n RealIndex_MappedIndex[3] = i % 4;\n break;\n \n }\n }\n\n foreach (int position in damaged_bulbs_positions)\n {\n \n MappedIndex_DamgedValue[position] = MappedIndex_DamgedValue.ElementAt(position).Value + 1;\n\n }\n\n foreach (KeyValuePair map in RealIndex_MappedIndex)\n {\n result += MappedIndex_DamgedValue[map.Value].ToString() + \" \";\n }\n\n }\n Console.WriteLine(result);\n Console.ReadLine();\n\n // Go to http://aka.ms/dotnet-get-started-console to continue learning how to build a console app! \n }\n }\n}\n\n\n", "lang_cluster": "C#", "tags": ["brute force", "implementation", "number theory"], "code_uid": "65faf599d9a48e67cd4e3f05c4fd5e5d", "src_uid": "64fc6e9b458a9ece8ad70a8c72126b33", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Globalization;\nusing System.IO;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Diagnostics;\n\nnamespace Codeforces\n{\n class Program : ProgramBase\n {\n private const long commonMod = 1000000007;\n\n static void Main(string[] args)\n {\n var p = new Program();\n var x = p.Solve();\n p.Out(x);\n }\n\n object Solve()\n {\n checked\n {\n var s = Read();\n var r = 0;\n var b = 0;\n var y = 0;\n var g = 0;\n var counts = new int[4];\n for (int i = 0; i < s.Length; i++)\n {\n if (s[i] == '!')\n counts[i % 4]++;\n else if (s[i] == 'R')\n r = i % 4;\n else if (s[i] == 'B')\n b = i % 4;\n else if (s[i] == 'Y')\n y = i % 4;\n else if (s[i] == 'G')\n g = i % 4;\n }\n return counts[r] + \" \" + counts[b] + \" \" + counts[y] + \" \" + counts[g];\n }\n }\n\n bool IsPrime(int n)\n {\n for (int i = 2; i <= Math.Sqrt(n); i++)\n {\n if (n % i == 0)\n return false;\n }\n return true;\n }\n }\n\n class DSU\n {\n private int[] arr;\n private Random r = new Random();\n public DSU(int n)\n {\n arr = new int[n];\n for (int i = 0; i < n; i++)\n {\n arr[i] = i;\n }\n }\n\n public int Find(int x)\n {\n if (arr[arr[x]] == arr[x])\n return arr[x];\n var y = Find(arr[x]);\n arr[x] = y;\n return y;\n }\n\n public void Union(int x, int y)\n {\n var p1 = Find(x);\n var p2 = Find(y);\n if (p1 == p2)\n return;\n if (r.NextDouble() < 0.5)\n arr[p1] = p2;\n else\n arr[p2] = p1;\n }\n\n public int[][] Enumerate()\n {\n return arr.Select((x, i) => new { g = Find(x), i }).GroupBy(x => x.g, (k, e) => e.Select(y => y.i).ToArray()).ToArray();\n }\n }\n\n abstract class ProgramBase\n {\n bool? prod = null;\n StreamReader f;\n Queue tokens;\n protected string FileName { private get; set; }\n\n protected string Read()\n {\n if (f == null)\n f = string.IsNullOrEmpty(FileName)\n ? new StreamReader(Console.OpenStandardInput())\n : new StreamReader((GetProd() ? \"\" : \"c:\\\\dev\\\\\") + FileName);\n return f.ReadLine();\n }\n\n protected string ReadToken()\n {\n if (tokens == null || tokens.Count == 0)\n tokens = new Queue(Read().Split(' '));\n return tokens.Dequeue();\n }\n\n protected long ReadLong() { return long.Parse(ReadToken()); }\n\n protected long[] ReadLongs()\n {\n var s = Read();\n if (s == \"\")\n return new long[0];\n var tokens = s.Split(' ');\n var result = new long[tokens.Length];\n for (int i = 0; i < tokens.Length; i++)\n result[i] = long.Parse(tokens[i]);\n return result;\n }\n\n public void Out(object r)\n {\n if (string.IsNullOrEmpty(FileName))\n Console.WriteLine(r);\n else if (GetProd())\n File.WriteAllText(FileName, r.ToString());\n else\n Console.WriteLine(r);\n }\n\n private bool GetProd()\n {\n\n if (!prod.HasValue)\n try\n {\n prod = Environment.MachineName != \"RENADEEN-W7\";\n }\n catch (Exception)\n {\n prod = true;\n }\n return prod.Value;\n }\n }\n\n public static class Huj\n {\n public static T MinBy(this IEnumerable source, Func func) where T : class\n {\n T result = null;\n var min = double.MaxValue;\n foreach (var item in source)\n {\n var current = func(item);\n if (min > current)\n {\n min = current;\n result = item;\n }\n }\n return result;\n }\n\n public static T MaxBy(this IEnumerable source, Func func, T defaultValue = default(T))\n {\n T result = defaultValue;\n var max = double.MinValue;\n foreach (var item in source)\n {\n var current = func(item);\n if (max < current)\n {\n max = current;\n result = item;\n }\n }\n return result;\n }\n\n public static string JoinStrings(this IEnumerable s, string d) { return string.Join(d, s.ToArray()); }\n\n public static string JoinStrings(this IEnumerable s, string d) { return s.Select(x => x.ToString()).JoinStrings(d); }\n public static string JoinStrings(this IEnumerable s, string d) { return s.Select(x => x.ToString()).JoinStrings(d); }\n }\n}", "lang_cluster": "C#", "tags": ["brute force", "implementation", "number theory"], "code_uid": "dee9d3296aa9bedcf3d9c84c60b32016", "src_uid": "64fc6e9b458a9ece8ad70a8c72126b33", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace ConsoleApplication5\n{\n class Program\n {\n static void Main(string[] args)\n {\n string o = Console.ReadLine();\n int i = 0;\n int j = 0;\n foreach (char c in o)\n {\n if (c == '-')\n {\n ++i;\n }\n else\n {\n ++j;\n }\n }\n\n bool yes = j <= 1 || i % j == 0;\n Console.WriteLine(yes ? \"YES\" : \"NO\");\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "implementation"], "code_uid": "6ea9c6436145b968475ec9c51f1ed1e8", "src_uid": "6e006ae3df3bcd24755358a5f584ec03", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Linq;\n\nnamespace _980A_pearls_and_links\n{\n class Program\n {\n static void Main(string[] args)\n {\n string s = Console.ReadLine();\n int countLinks = s.Count(x => x == '-');\n int countPearls = s.Count(x => x == 'o');\n Console.WriteLine(countPearls != 0 && countLinks % countPearls != 0? \"NO\" : \"YES\");\n \n }\n \n }\n}\n", "lang_cluster": "C#", "tags": ["math", "implementation"], "code_uid": "959490b649cfe76a1726e404e708768e", "src_uid": "6e006ae3df3bcd24755358a5f584ec03", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace ConsoleApplication5\n{\n class Program\n {\n static void Main(string[] args)\n {\n string[] s1=Console.ReadLine().Split(':');\n DateTime d1=new DateTime(int.Parse(s1[0]),int.Parse(s1[1]),int.Parse(s1[2]));\n string[] s2 = Console.ReadLine().Split(':');\n DateTime d2 = new DateTime(int.Parse(s2[0]), int.Parse(s2[1]), int.Parse(s2[2]));\n Console.WriteLine(Math.Abs((d2 - d1).Days));\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "implementation"], "code_uid": "eab004ce93a44f57198b2c6a84d38369", "src_uid": "bdf99d78dc291758fa09ec133fff1e9c", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace codeforces____calendar\n{\n class Program\n {\n static void Main(string[] args)\n {\n string input;\n input = Console.ReadLine();\n String[] s = input.Split(':');\n int year = int.Parse(s[0]);\n int month = int.Parse(s[1]);\n int day = int.Parse(s[2]);\n DateTime start = new DateTime(year, month, day);\n input = Console.ReadLine();\n s = new String[3];\n s = input.Split(':');\n year = int.Parse(s[0]);\n month = int.Parse(s[1]);\n day = int.Parse(s[2]);\n DateTime enddate = new DateTime(year, month, day);\n TimeSpan result = enddate.Subtract(start);\n Console.WriteLine(Math.Abs(result.Days));\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "implementation"], "code_uid": "c41aa1bae91d263f60da9861ae9d28e4", "src_uid": "bdf99d78dc291758fa09ec133fff1e9c", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\nusing System.Text.RegularExpressions;\nusing System.IO;\nusing System.Numerics;\nusing System.Globalization;\nusing System.Threading;\n\n\nnamespace probleme {\n class Program {\n static void Main(string[] args) {\n //Console.SetIn(new StreamReader(\"file.txt\"));\n char[][]table = new char[8][];\n for (int i=0;i<8;i++){\n table[i] = Console.ReadLine().ToCharArray();\n }\n int minW = 9;\n for (int j = 0; j < 8; j++) {\n int minR = 9;\n bool free = true;\n for (int i = 7; i >= 0; i--) {\n if (table[i][j] == 'B') {\n free = false;\n }\n if (table[i][j] == 'W') {\n minR = i;\n free = true;\n }\n }\n if (free && minR < minW) {\n minW = minR;\n }\n }\n int minB = 9;\n for (int j = 0; j < 8; j++) {\n int minR = 9;\n bool free = true;\n for (int i = 0; i < 8; i++) {\n if (table[i][j] == 'W') {\n free = false;\n }\n if (table[i][j] == 'B') {\n minR = 7 - i;\n free = true;\n }\n }\n if (free && minR < minB) {\n minB = minR;\n }\n }\n // Console.Write(\"{0} {1}\\n\", minW, minB);\n if (minW <= minB) {\n Console.Write(\"A\");\n } else {\n Console.Write(\"B\");\n }\n //Console.ReadKey();\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "274f328e112e962a0039a6d5db195c34", "src_uid": "0ddc839e17dee20e1a954c1289de7fbd", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.IO;\nusing System.Collections;\nusing System.Collections.Generic;\nusing System.Text;\nusing System.Reflection;\nusing System.Threading;\nusing System.Diagnostics;\nusing System.Linq;\n\n#region testlib\npublic delegate bool ParserDelegate(string word, out T item);\n\npublic class Input : IDisposable\n{\nprivate static EventArgs DefaultEventArgs = new EventArgs();\n\npublic TextReader TextReader { get; private set; }\n\npublic event EventHandler OnEndOfStream;\npublic event EventHandler OnParseError;\npublic event EventHandler OnReadError;\n\npublic bool CanRead { get; private set; }\npublic bool ThrowExceptions { get; set; }\n\nstring line = string.Empty;\nint pos = 0;\n\nstatic EventHandler emptyHandler;\n\npublic Input(string path)\n: this(File.OpenRead(path))\n{\n}\npublic Input(Stream s)\n: this(new StreamReader(s))\n{\n\n}\npublic Input(TextReader tr)\n{\nTextReader = tr;\n\nif (emptyHandler == null)\nemptyHandler = (a, b) => { };\n\nOnEndOfStream = emptyHandler;\nOnParseError = emptyHandler;\nOnReadError = emptyHandler;\n\nCanRead = true;\n}\n\npublic static implicit operator Input(Stream s)\n{\nreturn new Input(s);\n}\npublic static implicit operator Input(TextReader tr)\n{\nreturn new Input(tr);\n}\n\nprivate bool ReadStream()\n{\nif (!CanRead) return false;\nif (pos < line.Length) return true;\n\nClear();\n\nstring s = TextReader.ReadLine();\nif (s == null)\n{\nCanRead = false;\nreturn false;\n}\n\nline = s;\nreturn true;\n}\n\npublic void SkipChar()\n{\nif (pos < line.Length) pos++;\nelse\n{\nReadStream();\n}\n}\npublic void SkipChars(int length)\n{\nwhile (length > 0)\n{\nint dt = line.Length - pos;\nif (dt <= 0)\n{\nlength--;\nif (!ReadStream()) return;\n}\ndt = Math.Min(length, dt);\npos += dt;\nlength -= dt;\n}\n}\n\npublic void SkipWhiteSpace()\n{\nwhile (true)\n{\nfor (; pos < line.Length; pos++)\n{\nif (!char.IsWhiteSpace(line[pos])) return;\n}\nif (!ReadStream())\n{\nOnEndOfStream(this, DefaultEventArgs);\nreturn;\n}\n}\n}\npublic bool CanReadData()\n{\nSkipWhiteSpace();\nreturn CanRead;\n}\n\npublic T[] ReadArray()\n{\nint length = ReadInt32();\nreturn ReadArray(length);\n}\npublic T[] ReadArray(int length)\n{\nParserDelegate parser = Parser.GetPrimitiveParser();\nreturn ReadArray(length, parser);\n}\npublic T[] ReadArray(ParserDelegate parser)\n{\nint length = ReadInt32();\nreturn ReadArray(length, parser);\n}\npublic T[] ReadArray(int length, ParserDelegate parser)\n{\nT[] res = new T[length];\nfor (int i = 0; i < length; i++)\n{\nres[i] = ReadData(parser);\n}\nreturn res;\n}\n\npublic Decimal ReadDecimal()\n{\nreturn ReadData(Parser.DecimalParser);\n}\npublic Double ReadDouble()\n{\nreturn ReadData(Parser.DoubleParser);\n}\npublic Single ReadSingle()\n{\nreturn ReadData(Parser.SingleParser);\n}\npublic UInt64 ReadUInt64()\n{\nreturn ReadData(UInt64.TryParse);\n}\npublic UInt32 ReadUInt32()\n{\nreturn ReadData(UInt32.TryParse);\n}\npublic UInt16 ReadUInt16()\n{\nreturn ReadData(UInt16.TryParse);\n}\npublic Int64 ReadInt64()\n{\nreturn ReadData(Int64.TryParse);\n}\npublic Int32 ReadInt32()\n{\nreturn ReadData(Int32.TryParse);\n}\npublic Int16 ReadInt16()\n{\nreturn ReadData(Int16.TryParse);\n}\npublic Boolean ReadYesNo()\n{\nreturn ReadData(Parser.YesNoParser);\n}\npublic Boolean ReadBoolean()\n{\nreturn ReadData(Boolean.TryParse);\n}\npublic Byte ReadByte()\n{\nreturn ReadData(Byte.TryParse);\n}\n\nprivate bool ReadCheck()\n{\nif (!CanRead)\n{\nOnReadError(this, DefaultEventArgs);\nif (ThrowExceptions)\n{\nthrow new Exception(\"!CanRead\");\n}\nreturn false;\n}\nreturn true;\n}\npublic T ReadData()\n{\nreturn ReadData(true);\n}\npublic T ReadData(bool skipWhiteSpace)\n{\nParserDelegate parser = Parser.GetPrimitiveParser();\nreturn ReadData(parser, skipWhiteSpace);\n}\npublic T ReadData(ParserDelegate parser)\n{\nreturn ReadData(parser, true);\n}\npublic T ReadData(ParserDelegate parser, bool skipWhiteSpace)\n{\nif (skipWhiteSpace)\nSkipWhiteSpace();\n\nif (!ReadCheck()) return default(T);\n\nstring s = ReadWord(false);\n\nT res;\nif (!parser.Invoke(s, out res))\n{\nOnParseError(this, DefaultEventArgs);\nif (ThrowExceptions)\n{\nthrow new Exception(\"!validate, word = \" + Output.ToString(s, 256));\n}\n}\nreturn res;\n}\n\npublic string ReadWord()\n{\nreturn ReadWord(true);\n}\npublic string ReadWord(bool skipWhiteSpace)\n{\nif (skipWhiteSpace)\nSkipWhiteSpace();\n\nif (!ReadCheck()) return string.Empty;\n\nint from = pos;\nint to = pos;\nfor (int i = pos; i < line.Length; i++)\n{\nif (char.IsWhiteSpace(line[i])) break;\nto = i + 1;\n}\npos = to;\n\nreturn line.Substring(from, to - from);\n}\n\npublic string ReadLine()\n{\nif (!ReadCheck()) return string.Empty;\n\nReadStream();\nstring res = line.Substring(pos);\npos = line.Length;\n\nreturn res;\n}\n\npublic void Close()\n{\nTextReader.Close();\n}\npublic void Clear()\n{\npos = 0;\nline = string.Empty;\n}\n\nprivate bool disposed = false;\npublic void Dispose()\n{\nDispose(true);\nGC.SuppressFinalize(this);\n}\n\nprotected virtual void Dispose(bool disposing)\n{\nif (!this.disposed)\n{\nif (disposing)\n{\nline = string.Empty;\nTextReader.Dispose();\n}\ndisposed = true;\n}\n}\n~Input()\n{\nDispose(false);\n}\n}\npublic class Output : IDisposable\n{\nstatic char[] space = new char[] { ' ' };\n\npublic TextWriter TextWriter { get; private set; }\npublic bool AutoFlush { get; set; }\n\n\npublic static string ToString(object obj, int maxLength)\n{\nreturn ToString(FormatReal(obj), maxLength);\n}\npublic static string ToString(string s, int maxLength)\n{\nif (s.Length <= maxLength) return s;\nelse return s.Substring(0, maxLength) + \"...\";\n}\npublic static object FormatReal(object v, string format)\n{\nif (v is decimal) return ((decimal)v).ToString(format).Replace(',', '.');\nif (v is double) return ((double)v).ToString(format).Replace(',', '.');\nif (v is float) return ((float)v).ToString(format).Replace(',', '.');\n\nreturn v;\n}\npublic static object FormatReal(object v)\n{\nif (v is decimal || v is double || v is float)\n{\nreturn v.ToString().Replace(',', '.');\n}\nreturn v;\n}\n\npublic Output()\n: this(new MemoryStream())\n{\n}\npublic Output(string path)\n: this(File.Create(path))\n{\n\n}\npublic Output(Stream s)\n: this(new StreamWriter(s))\n{\n}\npublic Output(TextWriter tw)\n{\nTextWriter = tw;\n}\n\npublic static implicit operator Output(Stream s)\n{\nreturn new Output(s);\n}\n\npublic static implicit operator Output(TextWriter tw)\n{\nreturn new Output(tw);\n}\n\npublic static Output operator +(Output output, object obj)\n{\noutput.Write(obj);\nreturn output;\n}\npublic Output WriteArray(params T[] array)\n{\nreturn WriteArray(array, false);\n}\npublic Output WriteArray(T[] array, bool appendLength)\n{\nreturn WriteArray(array, 0, array.Length, appendLength);\n}\npublic Output WriteArray(T[] array, int index, int count)\n{\nreturn WriteArray(array, index, count, false);\n}\npublic Output WriteArray(T[] array, int index, int count, bool appendLength)\n{\nif (index + count > array.Length)\n{\nstring message = string.Format(\n\"Index out of range: {0} + {1} >= {2}\",\nindex,\ncount,\narray.Length);\nthrow new Exception(message);\n}\nif (appendLength)\n{\nWriteLine(count);\n}\nfor (int i = 0; i < count; i++)\n{\nWrite(array[i]);\nWrite(space, 0, space.Length);\n}\nWriteLine();\n\nreturn this;\n}\npublic Output WriteLine(object obj)\n{\nobj = FormatReal(obj);\nreturn WriteLine(obj.ToString());\n}\npublic Output WriteLine(string format, params object[] args)\n{\nreturn WriteLine(string.Format(format, args));\n}\npublic Output WriteLine(string s)\n{\nreturn WriteLine(s.ToCharArray());\n}\npublic Output WriteLine(char[] buffer)\n{\nreturn WriteLine(buffer, 0, buffer.Length);\n}\npublic Output WriteLine(char[] buffer, int index, int count)\n{\nTextWriter.WriteLine(buffer, index, count);\nif (AutoFlush) TextWriter.Flush();\nreturn this;\n}\npublic Output WriteLine()\n{\nTextWriter.WriteLine();\nif (AutoFlush) TextWriter.Flush();\nreturn this;\n}\npublic Output Write(object obj)\n{\nobj = FormatReal(obj);\nreturn Write(obj.ToString());\n}\npublic Output Write(string format, params object[] args)\n{\nreturn Write(string.Format(format, args));\n}\npublic Output Write(string s)\n{\nreturn Write(s.ToCharArray());\n}\npublic Output Write(char[] buffer)\n{\nreturn Write(buffer, 0, buffer.Length);\n}\npublic Output Write(char[] buffer, int index, int count)\n{\nTextWriter.Write(buffer, index, count);\nif (AutoFlush) TextWriter.Flush();\nreturn this;\n}\n\npublic void Close()\n{\nTextWriter.Close();\n}\npublic void Flush()\n{\nTextWriter.Flush();\n}\n\n\nprivate bool disposed = false;\npublic void Dispose()\n{\nDispose(true);\nGC.SuppressFinalize(this);\n}\n\nprotected virtual void Dispose(bool disposing)\n{\nif (!this.disposed)\n{\nif (disposing)\n{\nTextWriter.Dispose();\n}\ndisposed = true;\n}\n}\n~Output()\n{\nDispose(false);\n}\n}\npublic static class Parser\n{\npublic static ParserDelegate GetPrimitiveParser()\n{\nif (!typeof(T).IsPrimitive) throw new Exception(\"Unknown type\");\nelse if (default(T) is Byte) return new ParserDelegate(Byte.TryParse) as ParserDelegate;\nelse if (default(T) is Boolean) return new ParserDelegate(Boolean.TryParse) as ParserDelegate;\nelse if (default(T) is Int16) return new ParserDelegate(Int16.TryParse) as ParserDelegate;\nelse if (default(T) is Int32) return new ParserDelegate(Int32.TryParse) as ParserDelegate;\nelse if (default(T) is Int64) return new ParserDelegate(Int64.TryParse) as ParserDelegate;\nelse if (default(T) is UInt16) return new ParserDelegate(UInt16.TryParse) as ParserDelegate;\nelse if (default(T) is UInt32) return new ParserDelegate(UInt32.TryParse) as ParserDelegate;\nelse if (default(T) is UInt64) return new ParserDelegate(UInt64.TryParse) as ParserDelegate;\nelse if (default(T) is Single) return new ParserDelegate(Parser.SingleParser) as ParserDelegate;\nelse if (default(T) is Double) return new ParserDelegate(Parser.DoubleParser) as ParserDelegate;\nelse if (default(T) is Decimal) return new ParserDelegate(Parser.DecimalParser) as ParserDelegate;\nelse if (default(T) is String) return new ParserDelegate(Parser.StringParser) as ParserDelegate;\nelse throw new Exception(\"Unknown type\");\n}\npublic static bool YesNoParser(string s, out Boolean result)\n{\ns = s.ToLower();\nif (s == \"yes\") result = true;\nelse if (s == \"no\") result = false;\nelse\n{\nresult = false;\nreturn false;\n}\nreturn true;\n}\npublic static bool StringParser(string s, out string result)\n{\nresult = s;\nreturn string.IsNullOrEmpty(s);\n}\npublic static bool DecimalParser(string s, out Decimal result)\n{\nreturn Decimal.TryParse(s.Replace('.', ','), out result);\n}\npublic static bool DoubleParser(string s, out Double result)\n{\nreturn Double.TryParse(s.Replace('.', ','), out result);\n}\npublic static bool SingleParser(string s, out Single result)\n{\nreturn Single.TryParse(s.Replace('.', ','), out result);\n}\n}\n#endregion\n\nclass V : IComparable\n{\n public int Index;\n public int StartT;\n public int EndT;\n public int Count;\n\n public int CompareTo(V a)\n {\n var r = EndT.CompareTo(a.EndT);\n if (r == 0) r = Count.CompareTo(a.Count);\n if (r == 0) r = Index.CompareTo(a.Index);\n return r;\n }\n}\nstatic class Program\n{\n #region Streams\n static string endl = Environment.NewLine;\n static Input cin = new Input(Console.In);\n static Output cout = new Output(Console.Out);\n static Output cerr = new Output(Console.Error);\n\n static void InitIO()\n {\n#if !DEBUG\n cin = new Input(\"input.txt\");\n cout = new Output(\"output.txt\");\n#endif\n }\n #endregion\n #region Time\n static Stopwatch sw = new Stopwatch();\n static void Start()\n {\n sw.Reset();\n sw.Start();\n }\n static void Restart(string text = \"\")\n {\n Stop(text);\n Start();\n }\n static void Time(string text = \"\")\n {\n if (string.IsNullOrEmpty(text))\n {\n cerr.WriteLine(sw.Elapsed);\n }\n else\n {\n cerr.WriteLine(text + \": \" + sw.Elapsed);\n }\n }\n static void Stop(string text = \"\")\n {\n sw.Stop();\n Time(text);\n }\n //*/\n #endregion\n #region Prewriten\n static void Swap(ref T a, ref T b)\n {\n T c = a;\n a = b;\n b = c;\n }\n static long Gcd(long a, long b)\n {\n while (a > 0)\n {\n b %= a;\n Swap(ref a, ref b);\n }\n return b;\n }\n static int[] ZFunction(string s)\n {\n var z = new int[s.Length];\n for (int i = 1, l = 0, r = 0; i < s.Length; ++i)\n {\n if (i <= r)\n {\n z[i] = Math.Min(r - i + 1, z[i - l]);\n }\n while (i + z[i] < s.Length && s[z[i]] == s[i + z[i]])\n {\n z[i]++;\n }\n if (i + z[i] - 1 > r)\n {\n l = i;\n r = i + z[i] - 1;\n }\n }\n return z;\n }\n static long Pow(long a, long p)\n {\n var b = 1L;\n while (p > 0)\n {\n if ((p & 1) == 0)\n {\n a *= a;\n p >>= 1;\n }\n else\n {\n b *= a;\n p--;\n }\n }\n return b;\n }\n #endregion\n const string nyan = \"^_^\";\n const string name = \"canalization\";\n const long mod = 1000000007;\n\n static int Find(string[] a, char x)\n {\n var blocked = new bool[8];\n for (var i = 0; i < 8; i++)\n {\n for (var j = 0; j < 8; j++)\n {\n if (a[i][j] == x && !blocked[j]) return i;\n if (a[i][j] != '.') blocked[j] = true;\n }\n }\n return -1;\n }\n static void Solve()\n {\n var a = new string[8];\n for (var i = 0; i < 8; i++) a[i] = cin.ReadWord().ToLower();\n\n var w = Find(a, 'w');\n var b = Find(a.Reverse().ToArray(), 'b');\n\n if (w <= b) cout.WriteLine(\"A\");\n else cout.WriteLine(\"B\");\n }\n\n static string[] Tests =\n {\n @\"........\n........\n.B....B.\n....W...\n........\n..W.....\n........\n........\",\n @\"..B.....\n..W.....\n......B.\n........\n.....W..\n......B.\n........\n........\"\n };\n\n static string Generate(int k, int n)\n {\n var sb = new StringWriter();\n var output = new Output(sb);\n\n output.WriteLine(\"{0} {1}\", k, n);\n\n return sb.ToString();\n }\n static void Main()\n {\n#if DEBUG\n if (Tests.Length == 0)\n {\n Solve();\n }\n else\n {\n foreach(var test in Tests)\n {\n cin = new Input(new StringReader(test));\n Start();\n Solve();\n Stop();\n }\n /*\n for (var i = 0; i <= 10; i++)\n {\n var test = Generate(1, i);\n Start();\n cin = new Input(new StringReader(test));\n Solve();\n Stop();\n }\n //*/\n }\n#else\n /*\n cin = new Input(name + \".in\");\n cout = new Output(name + \".out\");\n //*/\n //Solve();\n \n var th = new Thread(Solve, 1024 * 1024 * 64);\n th.Start();\n th.Join();\n cout.Flush();\n cout.Dispose();\n#endif\n }\n}", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "1cf0b76445870d1764b47469f9be9706", "src_uid": "0ddc839e17dee20e1a954c1289de7fbd", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace ConsoleApplication1\n{\n class Program\n {\n static void Main(string[] args)\n {\n int n = Convert.ToInt32(Console.ReadLine());\n int min, max;\n max = 0;\n min = 2200;\n int[] years = new int[n];\n int i = 0;\n foreach (string s in Console.ReadLine().Split())\n {\n years[i] = Convert.ToInt32(s);\n max = max <= years[i] ? years[i] : max;\n min = min >= years[i] ? years[i] : min;\n i++;\n }\n Console.WriteLine(\"{0}\", (max + min) / 2); \n }\n }\n}\n", "lang_cluster": "C#", "tags": ["sortings", "implementation"], "code_uid": "d2ec1a6538aa27eb9e4645df2dc968fa", "src_uid": "f03773118cca29ff8d5b4281d39e7c63", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\nusing System.IO;\n\nnamespace ConsoleApplication4\n{\n class Program\n {\n static int[] readArray()\n {\n string[] s = Console.ReadLine().Split(' ');\n int len = s.Length;\n int[] data = new int[len];\n for (int i = 0; i < len; i++)\n {\n data[i] = int.Parse(s[i]);\n }\n return data;\n }\n static int readInt()\n {\n string s = Console.ReadLine();\n return int.Parse(s);\n }\n static void Main(string[] args)\n {\n int n = readInt();\n int[] data = readArray();\n int min = data[0];\n int max = data[0];\n for(int i = 1; i < n; i++)\n {\n min = Math.Min(data[i], min);\n max = Math.Max(data[i], max);\n }\n\n Console.Write((min + max) / 2);\n } \n }\n}\n\n\n//int[] h = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);\n//Array.Sort(data, (int a,int b) => a>b?-1:a==b?0:1);\n", "lang_cluster": "C#", "tags": ["sortings", "implementation"], "code_uid": "4013b8d4a4fffb20b463bc997e040fc5", "src_uid": "f03773118cca29ff8d5b4281d39e7c63", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections;\nusing System.Collections.Generic;\nusing System.IO;\nusing System.Text;\n\nnamespace contest1\n{\n class Program\n {\n static void Main(string[] args)\n {\n //Console.SetIn(new StreamReader(\"input.txt\"));\n solve_482A();\n }\n\n public static void solve_482A()\n {\n long n = Convert.ToInt64(Console.ReadLine());\n \n long pieces = 0;\n if (n > 0)\n {\n long pizza = n + 1;\n if (pizza % 2 == 0)\n {\n pieces = pizza / 2;\n }\n else\n {\n pieces = pizza;\n }\n }\n Console.WriteLine(pieces);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math"], "code_uid": "59d07006f625bcc41ab84bcf00984dbe", "src_uid": "236177ff30dafe68295b5d33dc501828", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "// Problem: 979A - Pizza, Pizza, Pizza!!!\n// Author: Gusztav Szmolik\n\nusing System;\n\nclass PizzaPizzaPizza\n {\n static int Main ()\n {\n string[] words = ReadSplitLine (1);\n if (words == null)\n return -1;\n ulong n;\n if (!UInt64.TryParse (words[0], out n))\n return -1;\n if (n > 1000000000000000000)\n return -1;\n ulong ans = (n > 0 ? (n%2 == 0 ? n+1 : (n+1)/2) : 0);\n Console.WriteLine (ans);\n return 0;\n }\n\n static string[] ReadSplitLine (uint numWordNeed)\n {\n string line = Console.ReadLine ();\n if (line == null)\n return null;\n char[] delims = new char[2] {' ', '\\t'};\n string[] words = line.Split (delims,StringSplitOptions.RemoveEmptyEntries);\n return (words.Length == numWordNeed ? words : null);\n }\n }\n", "lang_cluster": "C#", "tags": ["math"], "code_uid": "523dc336aaad6056d80aecfb09275708", "src_uid": "236177ff30dafe68295b5d33dc501828", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\nusing System.Numerics;\n\nnamespace \u044f\u0440\u043c\u043e\u0440\u043a\u0430\n{\n class Program\n {\n static string Reverse(string s)\n {\n string res = \"\";\n for (int i = 0; i < s.Length; i++)\n {\n res = s[i] + res;\n }\n\n return res;\n }\n static void Main(string[] args)\n {\n\n string[] input = Console.ReadLine().Split();\n int k = Convert.ToInt32(input[0]);\n UInt64 p = Convert.ToUInt64(input[1]);\n\n UInt64 sum = 0;\n\n for (int i = k; i >= 1; i--)\n {\n string s = Convert.ToString(i) + Reverse(Convert.ToString(i));\n \n sum += Convert.ToUInt64(s);\n }\n\n Console.WriteLine(sum % p);\n\n\n\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force"], "code_uid": "63af7c84db246aec70e3dec9cc61030f", "src_uid": "00e90909a77ce9e22bb7cbf1285b0609", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.IO;\nusing System.Linq;\n\nnamespace Codeforces.NET\n{\n class Program\n {\n static void Main(string[] args)\n {\n string line = Console.ReadLine();\n string[] parts = line.Split(' ').ToArray();\n long k = int.Parse(parts[0]);\n long p = int.Parse(parts[1]);\n long nr = 1;\n long sol = 0;\n for (int i = 1; i<=k; i++)\n {\n long nrAux = nr;\n long aux = nr;\n while (aux != 0)\n {\n nrAux = nrAux * 10 + aux % 10;\n aux = aux / 10;\n }\n\n sol = (sol + nrAux) % p;\n nr++;\n }\n\n Console.WriteLine(sol);\n Console.ReadLine();\n }\n }\n}", "lang_cluster": "C#", "tags": ["brute force"], "code_uid": "aa452951ab098bc28083b7d2e72c206f", "src_uid": "00e90909a77ce9e22bb7cbf1285b0609", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Text.RegularExpressions;\n\nnamespace Codeforces\n{\n class A\n {\n public static void Main(string[] args)\n {\n A program = new A();\n string output = program.Go();\n if (output != null)\n Wl(output);\n }\n\n private string Go()\n {\n int r1 = GetInt();\n int r2 = GetInt();\n int c1 = GetInt();\n int c2 = GetInt();\n int d1 = GetInt();\n int d2 = GetInt();\n\n int x2 = r1 + c1 - d2;\n if (x2 % 2 != 0) return \"-1\";\n\n int x = x2 / 2;\n int y = r1 - x;\n int z = c1 - x;\n int t = d1 - x;\n\n HashSet s = new HashSet();\n s.Add(x); s.Add(y);\n s.Add(z); s.Add(t);\n\n if (x + y != r1 || z + t != r2 || x + z != c1 || y + t != c2 || x + t != d1 || y + z != d2\n || s.Count != 4 || x < 1 || x > 9 || y < 1 || y > 9 || z < 1 || z > 9 || t < 1 || t > 9) return \"-1\";\n\n Wl(new int[] { x, y });\n Wl(new int[] { z, t });\n\n return null;\n }\n\n #region Template\n\n private IEnumerator ioEnum;\n private string GetString()\n {\n while (ioEnum == null || !ioEnum.MoveNext())\n {\n ioEnum = Console.ReadLine().Split().AsEnumerable().GetEnumerator();\n }\n\n return ioEnum.Current;\n }\n\n private int GetInt()\n {\n return int.Parse(GetString());\n }\n\n private double GetDouble()\n {\n return double.Parse(GetString());\n }\n\n private static void Wl(T o)\n {\n Console.WriteLine(o.ToString());\n }\n\n private static void Wl(IEnumerable enumerable)\n {\n Wl(string.Join(\" \", enumerable.Select(e => e.ToString()).ToArray()));\n }\n\n public struct Tuple\n {\n public T Item1;\n public K Item2;\n\n public Tuple(T t, K k)\n {\n Item1 = t;\n Item2 = k;\n }\n\n public override bool Equals(object obj)\n {\n var o = (Tuple)obj;\n return o.Item1.Equals(Item1) && o.Item2.Equals(Item2);\n }\n\n public override int GetHashCode()\n {\n return Item1.GetHashCode() ^ Item2.GetHashCode();\n }\n }\n\n #endregion\n }\n}", "lang_cluster": "C#", "tags": ["brute force", "math"], "code_uid": "c3fabb608e1d69c7c27776a4394c19ab", "src_uid": "6821f502f5b6ec95c505e5dd8f3cd5d3", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Linq;\n\nclass Program\n{\n static void Main()\n {\n var r = Console.ReadLine().Split().Select(int.Parse).ToArray();\n var c = Console.ReadLine().Split().Select(int.Parse).ToArray();\n var d = Console.ReadLine().Split().Select(int.Parse).ToArray();\n for (int i = 1; i <= 9; i++)\n {\n for (int j = 1; j <= 9; j++)\n {\n if (j == i) continue;\n for (int k = 1; k <= 9; k++)\n {\n if (k == j || k == i) continue;\n for (int m = 1; m <= 9; m++)\n {\n if (m == k || m == j || m == i) continue;\n if (r[0] == i + j && r[1] == k + m && c[0] == i + k && c[1] == j + m\n && d[0] == i + m && d[1] == j + k)\n {\n Console.WriteLine(\"{0} {1}\", i, j);\n Console.WriteLine(\"{0} {1}\", k, m);\n return;\n }\n }\n }\n }\n }\n Console.WriteLine(-1);\n }\n}", "lang_cluster": "C#", "tags": ["brute force", "math"], "code_uid": "7e663f4907eda57dd82c8c3f5afec757", "src_uid": "6821f502f5b6ec95c505e5dd8f3cd5d3", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "/*\ncsc -debug D.cs && mono --debug D.exe <<< \"\n\n{ max = 100, ops1 = 382, ops2 = 2182 }\n{ max = 100 }\nTotal counts: 3913\nDifferent GCDs: 382\nMax number of divisors: 11 (60 72 84 90 96)\n\n{ max = 1000, ops1 = 6069, ops2 = 61945 }\n{ max = 1000 }\nTotal counts: 391617\nDifferent GCDs: 6069\nMax number of divisors: 31 (840)\n\n{ max = 10000, ops1 = 83668, ops2 = 1326800 }\n{ max = 10000 }\nTotal counts: 39205029\nDifferent GCDs: 83668\nMax number of divisors: 63 (7560 9240)\n\n{ max = 100000, ops1 = 1066750, ops2 = 24091272 }\n{ max = 100000 }\nTotal counts: 3920698493\nDifferent GCDs: 1066750\nMax number of divisors: 127 (83160 98280)\n*/\n\nusing System;\nusing System.Collections;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading;\nusing System.Reflection;\n\npublic class HelloWorld {\n const ulong MOD = 1000000007ul;\n\n public static void SolveCodeForces() {\n // ShowStats();\n Solve();\n }\n\n static void Solve() {\n var max = cin.NextInt();\n\n var Divs = Helpers.CreateArray(max + 1, _ => new List());\n for (var g = 2; g <= max; g++)\n for (var a = g; a <= max; a += g)\n Divs[a].Add(g);\n\n var Map = Helpers.CreateArray(max + 1, _ => new Dictionary());\n for (var g = 2; g <= max; g++) {\n var counter = Map[g];\n var divs = Divs[g];\n\n counter[g] = max / g;\n for (var i = divs.Count - 2; i >= 0; i--) {\n var sum = 0;\n for (var j = i + 1; j < divs.Count; j++)\n if (divs[j] % divs[i] == 0)\n sum += counter[divs[j]];\n counter[divs[i]] = max / divs[i] - sum;\n }\n }\n\n// for (var g = 2; g <= max; g++) {\n// System.Console.WriteLine(new {g});\n// foreach (var kvp in Map[g])\n// System.Console.WriteLine(\" \" + new { gcd=kvp.Key, cnt=kvp.Value });\n// }\n\n var maxU = (ulong)max;\n var anssum = 0ul;\n var F = new ulong[max + 1];\n for (var g = 2; g <= max; g++) {\n var ag = 0;\n var sum = 0ul;\n foreach (var kvp in Map[g]) {\n var gcd = kvp.Key;\n var count = kvp.Value;\n if (gcd == g)\n ag = count;\n else\n sum = (sum + F[gcd] * (ulong)count) % MOD;\n }\n F[g] = (maxU + sum) * ModInverse(maxU + MOD - (ulong)ag, MOD) % MOD;\n anssum = (anssum + F[g]) % MOD;\n\n// System.Console.WriteLine(new { g, fg=F[g] });\n }\n\n var ans = (1ul + anssum * ModInverse(maxU, MOD)) % MOD;\n System.Console.WriteLine(ans);\n }\n\n public static ulong ModInverse(ulong x, ulong mod) { return ModPow(x, mod - 2L, mod); }\n\n public static ulong ModPow(ulong x, ulong exp, ulong mod) {\n ulong ret = 1ul;\n while (exp > 0) {\n if (exp % 2 == 1) ret = ret * x % mod;\n x = x * x % mod;\n exp /= 2;\n }\n return ret;\n }\n\n static void ShowStats() {\n foreach (var max in new[] { 100, 1000, 10000, 100000 }) {\n // var MapBrute = GetGcdsCounter_Brute(max);\n var Map = GetGcdsCounter_InnerLoop(max);\n System.Console.WriteLine(new { max });\n // Compare(Map, MapBrute);\n System.Console.WriteLine(\"Total counts: \" + Map.Sum(c => (long)c.Dict.Values.Sum()));\n System.Console.WriteLine(\"Different GCDs: \" + Map.Sum(c => c.Dict.Count));\n var maxcnt = Map.Max(c => c.Dict.Count);\n System.Console.WriteLine(\"Max number of divisors: {0} ({1})\", maxcnt, Map.Select((c, i) => new { c, i }).Where(a => a.c.Dict.Count == maxcnt).Select(a => a.i).Join());\n System.Console.WriteLine();\n }\n }\n\n static Counter[] GetGcdsCounter_InnerLoop(int max) {\n var Map = Helpers.CreateArray(max + 1, _ => new Counter());\n\n var ops1 = 0;\n for (var g = 2; g <= max; g++) {\n for (var a = g; a <= max; a += g) {\n Map[a][g] = 0;\n ops1++;\n }\n }\n\n var ops2 = 0;\n for (var g = 2; g <= max; g++) {\n var counter = Map[g];\n counter[g] = max / g;\n\n var divs = counter.Dict.Keys.ToArray();\n Array.Sort(divs, 0, divs.Length);\n\n for (var i = divs.Length - 2; i >= 0; i--) {\n var cnt = max / divs[i];\n for (var j = i + 1; j < divs.Length; j++) {\n if (divs[j] % divs[i] == 0)\n cnt -= counter[divs[j]];\n }\n counter[divs[i]] = cnt;\n }\n\n ops2 += divs.Length * divs.Length;\n }\n\n if (max == 100) {\n for (var g = 1; g <= max; g++) {\n System.Console.WriteLine(new {g});\n foreach (var kvp in Map[g].Dict)\n System.Console.WriteLine(\" \" + new { gcd=kvp.Key, cnt=kvp.Value });\n }\n }\n\n System.Console.WriteLine(new {max, ops1, ops2});\n\n return Map;\n }\n\n static Counter[] GetGcdsCounter_Brute(int max) {\n var Map = Helpers.CreateArray(max + 1, _ => new Counter());\n for (var g = 1; g <= max; g++) {\n for (var x = 1; x <= max; x++) {\n var gcd = (int)GCD((ulong)g, (ulong)x);\n if (gcd > 1)\n Map[g][gcd]++;\n }\n if (max == 100) {\n System.Console.WriteLine(new {g});\n foreach (var kvp in Map[g].Dict)\n System.Console.WriteLine(\" \" + new { gcd=kvp.Key, cnt=kvp.Value });\n }\n }\n return Map;\n }\n\n private static ulong GCD(ulong a, ulong b) {\n while (a != 0 && b != 0) {\n if (a > b)\n a %= b;\n else\n b %= a;\n }\n return a == 0 ? b : a;\n }\n\n static void Compare(Counter[] A, Counter[] B) {\n for (var i = 0; i < A.Length; i++) {\n var C = A[i].Dict;\n var D = B[i].Dict;\n if (C.Count != D.Count) {\n System.Console.WriteLine(new { i, ccount = C.Count, dcount = D.Count });\n return;\n }\n if (!C.Keys.OrderBy(c => c).SequenceEqual(D.Keys.OrderBy(c => c))) {\n System.Console.WriteLine(new { i, ckeys=C.Keys.OrderBy(c => c).Join(), dkeys=D.Keys.OrderBy(c => c).Join() });\n return;\n }\n foreach (var key in C.Keys) {\n if (C[key] != D[key]) {\n System.Console.WriteLine(new { i, ckeys=C.Keys.OrderBy(c => c).Join(), dkeys=D.Keys.OrderBy(c => c).Join() });\n System.Console.WriteLine(new { key, cval=C[key], dval=D[key] });\n }\n }\n }\n System.Console.WriteLine(\"compare ok\");\n }\n\n static Scanner cin = new Scanner();\n static StringBuilder cout = new StringBuilder();\n\n static public void Main () {\n SolveCodeForces();\n // IncreaseStack(SolveCodeForces);\n // System.Console.Write(cout.ToString());\n }\n\n public static void IncreaseStack(ThreadStart action, int stackSize = 128000000)\n {\n var thread = new Thread(action, stackSize);\n thread.Start();\n thread.Join();\n }\n}\n\npublic class Counter {\n public Dictionary Dict;\n public Counter() { Dict = new Dictionary(); }\n public Counter(IEnumerable keys) { Dict = new Dictionary(); foreach (var k in keys) Add(k, 1); }\n public int this[T key] {\n get { int res; return Dict.TryGetValue(key, out res) ? res : 0; }\n set { Dict[key] = value; }\n }\n public void Add(T key, int add) { int res; if (Dict.TryGetValue(key, out res)) Dict[key] = res + add; else Dict[key] = add; }\n}\n\npublic static class Helpers {\n public static string Join(this IEnumerable arr, string sep = \" \") {\n return string.Join(sep, arr);\n }\n\n public static void Swap(ref T a, ref T b) {\n var tmp = a;\n a = b;\n b = tmp;\n }\n\n public static T[] CreateArray(int length, Func itemCreate) {\n var result = new T[length];\n for (var i = 0; i < result.Length; i++)\n result[i] = itemCreate(i);\n return result;\n }\n}\n\npublic class Scanner\n{\n private string[] line = new string[0];\n private int index = 0;\n\n public string Next() {\n if (line.Length <= index) {\n line = Console.ReadLine().Split(' ');\n index = 0;\n }\n var res = line[index];\n index++;\n return res;\n }\n\n public int NextInt() {\n return int.Parse(Next());\n }\n\n public long NextLong() {\n return long.Parse(Next());\n }\n\n public ulong NextUlong() {\n return ulong.Parse(Next());\n }\n\n public string[] Array() {\n line = Console.ReadLine().Split(' ');\n index = line.Length;\n return line;\n }\n\n public int[] IntArray(int emptyPrefixLen = 0) {\n var array = Array();\n var result = new int[emptyPrefixLen + array.Length];\n for (int i = 0; i < array.Length; i++)\n result[emptyPrefixLen + i] = int.Parse(array[i]);\n return result;\n }\n\n public long[] LongArray() {\n var array = Array();\n var result = new long[array.Length];\n for (int i = 0; i < array.Length; i++)\n result[i] = long.Parse(array[i]);\n return result;\n }\n\n public ulong[] UlongArray() {\n var array = Array();\n var result = new ulong[array.Length];\n for (int i = 0; i < array.Length; i++)\n result[i] = ulong.Parse(array[i]);\n return result;\n }\n}", "lang_cluster": "C#", "tags": ["math", "dp", "probabilities", "number theory"], "code_uid": "016a81151b290b249af1aa5919916f9e", "src_uid": "ff810b16b6f41d57c1c8241ad960cba0", "difficulty": 2300.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Diagnostics;\nusing System.Globalization;\nusing System.IO;\nusing System.Linq;\nusing System.Numerics;\nusing System.Text;\nusing System.Text.RegularExpressions;\nusing System.Threading;\n\nnamespace ReadWriteTemplate\n{\n public static class Solver\n {\n public const long MOD = 1000000000 + 7;\n\n private static List Primes;\n\n private static void SolveCase()\n {\n int m = ReadInt();\n\n Primes = GetPrimes(m);\n\n Frac[] f = new Frac[m + 1];\n f[1] = new Frac(0, 1);\n\n var p = new List[m + 1];\n for (int i = 2; i <= m; i++)\n {\n p[i] = new List();\n bool found = false;\n for (int j = 0; j < Primes.Count && Primes[j] * Primes[j] <= i; j++)\n {\n if (i % Primes[j] == 0)\n {\n bool inc = false;\n int d = i / Primes[j];\n for (int k = 0; k < p[d].Count; k++)\n {\n Pair pair = new Pair(p[d][k].A, p[d][k].B);\n if (p[d][k].A == Primes[j])\n {\n pair.B++;\n inc = true;\n }\n p[i].Add(pair);\n }\n if (!inc)\n {\n p[i].Add(new Pair(Primes[j], 1));\n }\n found = true;\n break;\n }\n }\n if (!found)\n {\n p[i].Add(new Pair(i, 1));\n }\n\n var pairs = new List();\n Build(m, p[i], 0, i, 0, new int[10], pairs);\n\n int eqk = 0;\n var pr = new Frac(m, 1);\n for (int j = 0; j < pairs.Count; j++)\n {\n var pair = pairs[j];\n if (pair.A != i)\n {\n var c = new Frac(f[pair.A].X * pair.B % MOD, f[pair.A].Y);\n pr = Sum(pr, c);\n }\n else\n {\n eqk += pair.B;\n }\n }\n\n pr.Y = pr.Y * (m - eqk) % MOD;\n\n f[i] = pr;\n }\n\n Frac sum = new Frac(m, 1);\n for (int i = 0; i < m; i++)\n {\n sum = Sum(sum, f[i + 1]);\n }\n\n long ans = sum.X * BinPower(sum.Y, MOD - 2, MOD) % MOD * BinPower(m, MOD - 2, MOD) % MOD;\n\n Writer.WriteLine(ans);\n }\n\n private static Frac Sum(Frac a, Frac b)\n {\n return new Frac((a.X * b.Y + a.Y * b.X) % MOD, (a.Y * b.Y) % MOD);\n }\n\n private static void Build(int m, List p, int t, int d, int q, int[] div, List pairs)\n {\n if (t >= p.Count)\n {\n int count = Calc(m / d, 0, q, div, 0);\n pairs.Add(new Pair(d, count));\n return;\n }\n\n Build(m, p, t + 1, d, q, div, pairs);\n div[q] = p[t].A;\n for (int i = 1; i <= p[t].B; i++)\n {\n d /= p[t].A;\n Build(m, p, t + 1, d, q + 1, div, pairs);\n }\n }\n\n private static int Calc(int x, int t, int q, int[] div, int c)\n {\n if (t >= q)\n {\n return (((div.Length + c) & 1) == 0 ? 1 : -1) * x;\n }\n\n return Calc(x, t + 1, q, div, c) +\n Calc(x / div[t], t + 1, q, div, c + 1);\n }\n\n public static long BinPower(long a, long n, long mod)\n {\n long result = 1;\n\n while (n > 0)\n {\n if ((n & 1) != 0)\n {\n result = (result * a) % mod;\n }\n\n a = (a * a) % mod;\n n >>= 1;\n }\n\n return result;\n }\n\n public class Pair\n {\n public Pair(int a, int b)\n {\n A = a;\n B = b;\n }\n\n public int A;\n\n public int B;\n\n public override string ToString()\n {\n return $\"({A}, {B})\";\n }\n }\n\n public class Frac\n {\n public Frac(long x, long y)\n {\n X = x;\n Y = y;\n }\n\n public long X;\n\n public long Y;\n\n public override string ToString()\n {\n return $\"{X} / {Y}\";\n }\n }\n\n public static List GetPrimes(long n)\n {\n var primes = new List();\n\n n = Math.Max(n, 2);\n bool[] isPrime = new bool[n + 1];\n for (int i = 2; i <= n; i++)\n {\n isPrime[i] = true;\n }\n\n for (int i = 2; i <= n; i++)\n {\n if (isPrime[i])\n {\n primes.Add(i);\n if ((long)i * i <= n)\n {\n for (int j = i * i; j <= n; j += i)\n {\n isPrime[j] = false;\n }\n }\n }\n }\n\n return primes;\n }\n\n public static void Solve()\n {\n#if DEBUG\n var sw = Stopwatch.StartNew();\n#endif\n\n SolveCase();\n\n /*int T = ReadInt();\n for (int i = 0; i < T; i++)\n {\n // Writer.WriteLine(\"Case {0}:\", i + 1);\n // Writer.Write(\"Case #{0}: \", i + 1);\n SolveCase();\n }*/\n\n#if DEBUG\n sw.Stop();\n Console.WriteLine($\"{sw.ElapsedMilliseconds} ms\");\n#endif\n }\n\n public static void Main()\n {\n Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;\n\n#if DEBUG\n // Reader = Console.In; Writer = Console.Out;\n Reader = File.OpenText(\"input.txt\"); Writer = File.CreateText(\"output.txt\");\n#else\n Reader = Console.In; Writer = Console.Out;\n#endif\n\n // Solve();\n Thread thread = new Thread(Solve, 64 * 1024 * 1024);\n thread.CurrentCulture = CultureInfo.InvariantCulture;\n thread.Start();\n thread.Join();\n\n Reader.Close();\n Writer.Close();\n }\n\n public static IOrderedEnumerable OrderByWithShuffle(this IEnumerable source, Func keySelector)\n {\n return source.Shuffle().OrderBy(keySelector);\n }\n\n public static T[] Shuffle(this IEnumerable source)\n {\n T[] result = source.ToArray();\n Random rnd = new Random();\n for (int i = result.Length - 1; i >= 1; i--)\n {\n int k = rnd.Next(i + 1);\n T tmp = result[k];\n result[k] = result[i];\n result[i] = tmp;\n }\n return result;\n }\n\n #region Read/Write\n\n private static TextReader Reader;\n\n private static TextWriter Writer;\n\n private static Queue CurrentLineTokens = new Queue();\n\n private static string[] ReadAndSplitLine()\n {\n return Reader.ReadLine().Split(new[] { ' ', '\\t' }, StringSplitOptions.RemoveEmptyEntries);\n }\n\n public static string ReadToken()\n {\n while (CurrentLineTokens.Count == 0)\n CurrentLineTokens = new Queue(ReadAndSplitLine());\n return CurrentLineTokens.Dequeue();\n }\n\n public static string ReadLine()\n {\n return Reader.ReadLine();\n }\n\n public static int ReadInt()\n {\n return int.Parse(ReadToken());\n }\n\n public static long ReadLong()\n {\n return long.Parse(ReadToken());\n }\n\n public static double ReadDouble()\n {\n return double.Parse(ReadToken(), CultureInfo.InvariantCulture);\n }\n\n public static int[] ReadIntArray()\n {\n return ReadAndSplitLine().Select(int.Parse).ToArray();\n }\n\n public static long[] ReadLongArray()\n {\n return ReadAndSplitLine().Select(long.Parse).ToArray();\n }\n\n public static double[] ReadDoubleArray()\n {\n return ReadAndSplitLine().Select(s => double.Parse(s, CultureInfo.InvariantCulture)).ToArray();\n }\n\n public static int[][] ReadIntMatrix(int numberOfRows)\n {\n int[][] matrix = new int[numberOfRows][];\n for (int i = 0; i < numberOfRows; i++)\n matrix[i] = ReadIntArray();\n return matrix;\n }\n\n public static string[] ReadLines(int quantity)\n {\n string[] lines = new string[quantity];\n for (int i = 0; i < quantity; i++)\n lines[i] = Reader.ReadLine().Trim();\n return lines;\n }\n\n public static void WriteArray(IEnumerable array)\n {\n Writer.WriteLine(string.Join(\" \", array));\n }\n\n #endregion\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "dp", "probabilities", "number theory"], "code_uid": "7ab6974760f93e7644e4b71f93760f3f", "src_uid": "ff810b16b6f41d57c1c8241ad960cba0", "difficulty": 2300.0, "exec_outcome": "PASSED"} {"lang": "C# 8", "source_code": "\ufeffusing System;\nusing System.Linq;\n\nnamespace CF1514B\n{\n class Program\n {\n static void Main(string[] args)\n {\n int T = int.Parse(Console.ReadLine());\n\n for (int t = 0; t < T; t++)\n {\n long[] nk = Console.ReadLine().Split(\" \").Select(long.Parse).ToArray();\n long ans = 1;\n for (int i = 0; i < nk[1]; i++)\n {\n ans = (ans * nk[0]) % 1000000007;\n }\n Console.WriteLine(ans);\n }\n }\n }\n}", "lang_cluster": "C#", "tags": ["math", "combinatorics", "bitmasks"], "code_uid": "b41b6f5b121aea5cf09890747a75d26b", "src_uid": "2e7a9f3a97938e4a7e036520d812b97a", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeff\ufeff\ufeff\ufeff\ufeff\ufeff\ufeff\ufeffusing System;\r\nusing System.Collections.Generic;\r\nusing System.Globalization;\r\nusing System.IO;\r\nusing System.Linq;\r\n using System.Net.Sockets;\r\n using System.Numerics;\r\n\r\nnamespace Task\r\n{\r\n static class Program\r\n {\r\n #region Read / Write\r\n static TextReader Reader;\r\n static TextWriter Writer;\r\n private static Queue _currentLineTokens = new Queue();\r\n private static string[] ReadAndSplitLine() { return Reader.ReadLine().Split(new[] { ' ', '\\t', }, StringSplitOptions.RemoveEmptyEntries); }\r\n public static string ReadToken() { while (_currentLineTokens.Count == 0) _currentLineTokens = new Queue(ReadAndSplitLine()); return _currentLineTokens.Dequeue(); }\r\n public static int ReadInt() { return int.Parse(ReadToken()); }\r\n public static long ReadLong() { return long.Parse(ReadToken()); }\r\n public static double ReadDouble() { return double.Parse(ReadToken(), CultureInfo.InvariantCulture); }\r\n public static int[] ReadIntArray() { return ReadAndSplitLine().Select(int.Parse).ToArray(); }\r\n public static long[] ReadLongArray() { return ReadAndSplitLine().Select(long.Parse).ToArray(); }\r\n public static double[] ReadDoubleArray() { return ReadAndSplitLine().Select(s => double.Parse(s, CultureInfo.InvariantCulture)).ToArray(); }\r\n public static int[][] ReadIntMatrix(int numberOfRows) { int[][] matrix = new int[numberOfRows][]; for (int i = 0; i < numberOfRows; i++) matrix[i] = ReadIntArray(); return matrix; }\r\n public static int[][] ReadAndTransposeIntMatrix(int numberOfRows)\r\n {\r\n int[][] matrix = ReadIntMatrix(numberOfRows); int[][] ret = new int[matrix[0].Length][];\r\n for (int i = 0; i < ret.Length; i++) { ret[i] = new int[numberOfRows]; for (int j = 0; j < numberOfRows; j++) ret[i][j] = matrix[j][i]; }\r\n return ret;\r\n }\r\n public static string[] ReadLines(int quantity) { string[] lines = new string[quantity]; for (int i = 0; i < quantity; i++) lines[i] = Reader.ReadLine().Trim(); return lines; }\r\n public static void WriteArray(IEnumerable array) { Writer.WriteLine(string.Join(\" \", array)); }\r\n public static void Write(params object[] array) { WriteArray(array); }\r\n public static void WriteLines(IEnumerable array) { foreach (var a in array) Writer.WriteLine(a); }\r\n private class SDictionary : Dictionary\r\n {\r\n public new TValue this[TKey key]\r\n {\r\n get { return ContainsKey(key) ? base[key] : default(TValue); }\r\n set { base[key] = value; }\r\n }\r\n }\r\n private static T[] Init(int size) where T : new() { var ret = new T[size]; for (int i = 0; i < size; i++) ret[i] = new T(); return ret; }\r\n #endregion=\r\n\r\n public static bool NextPermutation(List perm)\r\n {\r\n for (int i = perm.Count - 2; i >= 0; i--)\r\n {\r\n if (perm[i] < perm[i + 1])\r\n {\r\n int min = i + 1;\r\n for (int j = min; j < perm.Count; j++)\r\n if (perm[j] > perm[i] && perm[j] < perm[min])\r\n min = j;\r\n\r\n var tmp = perm[i];\r\n perm[i] = perm[min];\r\n perm[min] = tmp;\r\n perm.Reverse(i + 1, perm.Count - i - 1);\r\n return true;\r\n }\r\n }\r\n\r\n return false;\r\n }\r\n\r\n #region SegmentTree\r\n\r\n public static long SegmentTreeFunc(long a, long b)\r\n {\r\n return a + b;\r\n }\r\n\r\n public static void Build(long[] a, long v, long tl, long tr)\r\n {\r\n if (tl == tr)\r\n t[v] = a[tl];\r\n else\r\n {\r\n long tm = (tl + tr) / 2;\r\n Build(a, v * 2, tl, tm);\r\n Build(a, v * 2 + 1, tm + 1, tr);\r\n t[v] = SegmentTreeFunc(t[v * 2], t[v * 2 + 1]);\r\n }\r\n }\r\n\r\n public static long Query(long v, long tl, long tr, long l, long r)\r\n {\r\n if (l > r)\r\n return 0;\r\n if (l == tl && r == tr)\r\n return t[v];\r\n\r\n var tm = (tl + tr) / 2;\r\n var res = SegmentTreeFunc(Query(v * 2, tl, tm, l, Math.Min(r, tm)), Query(v * 2 + 1, tm + 1, tr, Math.Max(l, tm + 1), r));\r\n return res;\r\n }\r\n\r\n public static long[] t;\r\n\r\n #endregion\r\n\r\n private static readonly int modulus = 1000000007;\r\n // private static readonly int modulus1 = modulus - 1;\r\n\r\n public static long Pow(long a, long b)\r\n {\r\n long y = 1;\r\n\r\n while (true)\r\n {\r\n if ((b & 1) != 0)\r\n y = a * y % modulus;\r\n b = b >> 1;\r\n if (b == 0)\r\n return y;\r\n a = a * a % modulus;\r\n }\r\n }\r\n\r\n public static long ReversedNumbByPrimeModulo(long a)\r\n {\r\n return Pow(a, modulus - 2);\r\n }\r\n\r\n public static long FactByModulo(long a)\r\n {\r\n long ans = 1;\r\n\r\n while (a > 0)\r\n {\r\n ans = ans * a % modulus;\r\n a--;\r\n }\r\n\r\n return ans;\r\n }\r\n\r\n public static long nCkModulo(long n, long k)\r\n {\r\n if (k < n >> 1)\r\n k = n - k;\r\n\r\n long ans = 1;\r\n for (long i = n; i > k; i--)\r\n ans = ans * i % modulus;\r\n\r\n k = n - k;\r\n var fact = FactByModulo(k);\r\n var revFact = ReversedNumbByPrimeModulo(fact);\r\n\r\n ans = ans * revFact % modulus;\r\n\r\n return ans;\r\n }\r\n\r\n // public static int maxForPrimeCalc = 30000000;\r\n // public static List primes = new List(maxForPrimeCalc) {2};\r\n // public static int[] minPrimeDiv = new int[maxForPrimeCalc + 1];\r\n // public static bool[] isPrime = new bool[maxForPrimeCalc + 1];\r\n //\r\n // public static void CalcPrimes()\r\n // {\r\n // isPrime[2] = true;\r\n // for (var i = 2; i <= maxForPrimeCalc; i += 2)\r\n // {\r\n // isPrime[i] = false;\r\n // minPrimeDiv[i] = 2;\r\n // }\r\n // for (var i = 3; i <= maxForPrimeCalc; i += 2)\r\n // {\r\n // isPrime[i] = true;\r\n // }\r\n //\r\n // for (var i = 3; i * i <= maxForPrimeCalc; i += 2)\r\n // {\r\n // if (isPrime[i])\r\n // {\r\n // minPrimeDiv[i] = i;\r\n // primes.Add(i);\r\n // for (var j = i * i; j <= maxForPrimeCalc; j += i)\r\n // {\r\n // if (isPrime[j])\r\n // {\r\n // isPrime[j] = false;\r\n // minPrimeDiv[j] = i;\r\n // }\r\n // }\r\n // }\r\n // }\r\n // }\r\n //\r\n // public static int[] PrimeDifferentDividersCountHash = new int[maxForPrimeCalc + 1];\r\n //\r\n // private static int PrimeDifferentDividersCount(long numb)\r\n // {\r\n // if (numb == 1)\r\n // return 0;\r\n // if (isPrime[numb])\r\n // return 1;\r\n // \r\n // if (PrimeDifferentDividersCountHash[numb] > 0)\r\n // return PrimeDifferentDividersCountHash[numb];\r\n // \r\n // var divider = minPrimeDiv[numb];\r\n // var prevNumb = numb / divider;\r\n // var ans = PrimeDifferentDividersCount(prevNumb);\r\n //\r\n // if (divider != minPrimeDiv[prevNumb])\r\n // {\r\n // ans += 1;\r\n // }\r\n //\r\n // PrimeDifferentDividersCountHash[numb] = ans;\r\n //\r\n // return ans;\r\n // }\r\n\r\n #region Heap\r\n\r\n public static void InsertElementInHeap(int value, int[] arr, ref int sizeOfTree)\r\n { \r\n arr[sizeOfTree + 1] = value; \r\n sizeOfTree++; \r\n HeapifyBottomToTop(sizeOfTree, arr); \r\n }\r\n \r\n public static void HeapifyBottomToTop(int index, int[] arr)\r\n { \r\n int parent = index / 2; \r\n // We are at root of the tree. Hence no more Heapifying is required. \r\n if (index <= 1) { \r\n return; \r\n } \r\n // If Current value is smaller than its parent, then we need to swap \r\n if (arr[index] > arr[parent]) { \r\n int tmp = arr[index]; \r\n arr[index] = arr[parent]; \r\n arr[parent] = tmp; \r\n } \r\n HeapifyBottomToTop(parent, arr); \r\n }\r\n \r\n public static int ExtractHeadOfHeap(ref int sizeOfTree, int[] arr) { \r\n if(sizeOfTree == 0) { \r\n return -1; \r\n }else { \r\n int extractedValue = arr[1]; \r\n arr[1] = arr[sizeOfTree]; //Replacing with last element of the array \r\n sizeOfTree--; \r\n HeapifyTopToBottom(1, sizeOfTree, arr); \r\n return extractedValue; \r\n } \r\n }\r\n \r\n public static void HeapifyTopToBottom(int index, int sizeOfTree, int[] arr)\r\n { \r\n int left = index << 1; \r\n int right = left + 1; \r\n int smallestChild = 0; \r\n \r\n if (sizeOfTree < left) { //If there is no child of this node, then nothing to do. Just return. \r\n return; \r\n }else if (sizeOfTree == left) { //If there is only left child of this node, then do a comparison and return. \r\n if(arr[index] < arr[left]) { \r\n int tmp = arr[index]; \r\n arr[index] = arr[left]; \r\n arr[left] = tmp; \r\n } \r\n return; \r\n }else { //If both children are there \r\n if(arr[left] > arr[right]) { //Find out the smallest child \r\n smallestChild = left; \r\n }else { \r\n smallestChild = right; \r\n } \r\n if(arr[index] < arr[smallestChild]) { //If Parent is greater than smallest child, then swap \r\n int tmp = arr[index]; \r\n arr[index] = arr[smallestChild]; \r\n arr[smallestChild] = tmp; \r\n } \r\n } \r\n HeapifyTopToBottom(smallestChild, sizeOfTree, arr); \r\n }\r\n\r\n #endregion\r\n \r\n static long GCD(long a, long b)\r\n {\r\n while (b > 0) {\r\n a %= b;\r\n a ^= b;\r\n b ^= a;\r\n a ^= b;\r\n }\r\n return a;\r\n }\r\n \r\n private static int mod = 1000000007;\r\n\r\n static void Main(string[] args)\r\n {\r\n Reader = new StreamReader(Console.OpenStandardInput());\r\n Writer = new StreamWriter(Console.OpenStandardOutput());\r\n\r\n //CalcPrimes();\r\n \r\n var t = ReadInt();\r\n for (var tmp = 0; tmp < t; tmp++)\r\n {\r\n Solve();\r\n }\r\n \r\n Reader.Close();\r\n Writer.Close();\r\n }\r\n\r\n static void Solve()\r\n {\r\n var n = ReadInt();\r\n var k = ReadInt();\r\n\r\n var mod = 1000000007;\r\n if (n == 1)\r\n {\r\n Write(1);\r\n }\r\n else\r\n {\r\n var ans = Pow(n, k);\r\n Write(ans);\r\n }\r\n }\r\n\r\n private static void BFS(List[] g, int curV, int[] curColors, int[] c, HashSet visited, List ans)\r\n {\r\n if (curColors[c[curV - 1]] == 0)\r\n ans.Add(curV);\r\n \r\n visited.Add(curV);\r\n curColors[c[curV - 1]]++;\r\n foreach (var neigh in g[curV])\r\n {\r\n if (!visited.Contains(neigh))\r\n {\r\n BFS(g, neigh, curColors, c, visited, ans);\r\n }\r\n }\r\n curColors[c[curV - 1]]--;\r\n }\r\n\r\n private static long GetNumb(Dictionary letterDic, List permutation, string s)\r\n {\r\n long res = 0;\r\n long mult = 1;\r\n for (var i = s.Length - 1; i >= 0; i--)\r\n {\r\n res += permutation[letterDic[s[i]]] * mult;\r\n\r\n mult *= 10;\r\n }\r\n\r\n return res;\r\n }\r\n\r\n public class MyStruct\r\n {\r\n public int Index;\r\n public int Weight;\r\n public int Value;\r\n\r\n public MyStruct(int index, int weight, int value)\r\n {\r\n Index = index;\r\n Weight = weight;\r\n Value = value;\r\n }\r\n }\r\n\r\n static void Inc(this Dictionary dict, long key, long addedValue)\r\n {\r\n if (dict.ContainsKey(key))\r\n dict[key] += addedValue;\r\n else\r\n dict[key] = addedValue;\r\n }\r\n\r\n static void Inc(this Dictionary dict, int key, int addedValue)\r\n {\r\n if (dict.ContainsKey(key))\r\n dict[key] += addedValue;\r\n else\r\n dict[key] = addedValue;\r\n }\r\n }\r\n}", "lang_cluster": "C#", "tags": ["math", "combinatorics", "bitmasks"], "code_uid": "fc982710fc2b0f760ee44aea88db55dc", "src_uid": "2e7a9f3a97938e4a7e036520d812b97a", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\n\nnamespace CCS\n{\n class Program\n {\n static List s = new List();\n\n static bool Rec(int a, int b)\n {\n if (a == b)\n {\n s.Add(b);\n return true;\n }\n else if (b > a)\n {\n bool w = false;\n\n if (b % 2 == 0)\n {\n w = Rec(a, b / 2);\n if (w)\n s.Add(b);\n return w;\n }\n if ((b - 1) % 10 == 0)\n {\n w = Rec(a, (b - 1) / 10);\n if (w)\n s.Add(b);\n return w;\n }\n return false;\n }\n return false;\n }\n\n static void Main()\n {\n string[] input = Console.ReadLine().Split(' ');\n if (Rec(int.Parse(input[0]), int.Parse(input[1])))\n {\n Console.WriteLine(\"YES\");\n Console.WriteLine(s.Count.ToString());\n for (int i = 0; i < s.Count; i++)\n Console.Write(s[i] + \" \");\n return;\n }\n Console.Write(\"NO\");\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["dfs and similar", "math", "brute force"], "code_uid": "ce72328dd10fba8264c540f1a29ace52", "src_uid": "fc3adb1a9a7f1122b567b4d8afd7b3f3", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\n\nnamespace cf727A\n{\n class Program\n {\n static void Main(string[] args)\n {\n int[] ab = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();\n\n int a = ab[0]; int b = ab[1];\n\n List operations = new List();\n\n while(b > a)\n {\n operations.Add(b);\n if ((b % 2) == 0)\n b /= 2;\n else if (b.ToString().EndsWith(\"1\"))\n {\n b = (b - 1) / 10;\n }\n else\n {\n Console.WriteLine(\"NO\"); return;\n }\n }\n\n if (b == a)\n {\n Console.WriteLine(\"YES\");\n Console.WriteLine(operations.Count + 1);\n Console.Write(a); Console.Write(' ');\n for (int i = 1; i <= operations.Count; i++)\n {\n Console.Write(operations[operations.Count-i]); Console.Write(' ');\n }\n }\n else Console.WriteLine(\"NO\");\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["dfs and similar", "math", "brute force"], "code_uid": "9ceb8258ff9ef4902974c012856989f8", "src_uid": "fc3adb1a9a7f1122b567b4d8afd7b3f3", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\n\nclass Program\n{\n static void Main(string[] args)\n {\n var inp = Console.ReadLine().Split(' ');\n long t = long.Parse(inp[0]);\n long n = long.Parse(inp[1]);\n long r = 0;\n if (t >= 2 * n + 1)\n r = n * t + (t - 2 * n) * n - n;\n else\n r = t * (t - 1) / 2;\n Console.WriteLine(r);\n Console.ReadLine();\n }\n}", "lang_cluster": "C#", "tags": ["math", "greedy"], "code_uid": "e12a65338abcb60f568e01a94ddfd666", "src_uid": "ea36ca0a3c336424d5b7e1b4c56947b0", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeff#if DEBUG\nusing System.Reflection;\nusing System.Threading.Tasks;\n#endif\n\nusing System;\nusing System.Collections.Generic;\nusing System.IO;\nusing System.Linq;\nusing System.Text;\n\n\nnamespace KRO2\n{\n\tclass Program\n\t{\n\t\tstatic string _inputFilename = \"input.txt\";\n\t\tstatic string _outputFilename = \"output.txt\";\n#if DEBUG\n static bool _useFileInput = false;\n#else\n\t\tstatic bool _useFileInput = false;\n#endif\n\n\t\tstatic void Main(string[] args)\n\t\t{\n\t\t\tStreamWriter file = null;\n\t\t\tif (_useFileInput)\n\t\t\t{\n\t\t\t\tConsole.SetIn(File.OpenText(_inputFilename));\n\t\t\t\tfile = new StreamWriter(_outputFilename);\n\t\t\t\tConsole.SetOut(file);\n\t\t\t}\n\n#if DEBUG\n\t\t\tif (!_useFileInput)\n\t\t\t{\n\t\t\t\tConsole.SetIn(getInput());\n\t\t\t}\n#endif\n\n\t\t\ttry\n\t\t\t{\n\t\t\t\tsolution();\n\t\t\t}\n\t\t\tfinally\n\t\t\t{\n\t\t\t\tif (_useFileInput)\n\t\t\t\t{\n\t\t\t\t\tfile.Close();\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tstatic void solution()\n\t\t{\n\t\t\t#region SOLUTION\n\t\t\tvar d = readIntArray();\n\t\t\tvar n = d[0];\n\t\t\tvar k = d[1];\n\n\t\t\tif (n / 2 <= k)\n\t\t\t{\n\t\t\t\tvar val = 0L;\n\t\t\t\tfor (int i = 1; i <= n; i++)\n\t\t\t\t{\n\t\t\t\t\tval += n - (i);\n\t\t\t\t}\n\n\t\t\t\tConsole.WriteLine(val);\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tvar res = 0L;\n\t\t\t\tfor (int i = 1; i <= n; i++)\n\t\t\t\t{\n\t\t\t\t\tif (i <= k || i >= n - k + 1)\n\t\t\t\t\t{\n\t\t\t\t\t\tres += n - i;\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\tres += k;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tConsole.WriteLine(res);\n\t\t\t}\n\n\t\t\t//var n = readInt();\n\t\t\t//var m = readInt();\n\n\t\t\t//var a = readIntArray();\n\t\t\t//var b = readIntArray();\n\t\t\t#endregion\n\t\t}\n\n\t\tstatic int readInt()\n\t\t{\n\t\t\treturn int.Parse(Console.ReadLine());\n\t\t}\n\n\t\tstatic long readLong()\n\t\t{\n\t\t\treturn long.Parse(Console.ReadLine());\n\t\t}\n\n\t\tstatic int[] readIntArray()\n\t\t{\n\t\t\treturn Console.ReadLine().Split(' ').Where(i => !string.IsNullOrEmpty(i)).Select(i => int.Parse(i)).ToArray();\n\t\t}\n\n\t\tstatic long[] readLongArray()\n\t\t{\n\t\t\treturn Console.ReadLine().Split(' ').Where(i => !string.IsNullOrEmpty(i)).Select(i => long.Parse(i)).ToArray();\n\t\t}\n\n#if DEBUG\n\t\tstatic StreamReader getInput()\n\t\t{\n\t\t\tvar resName = Assembly.GetCallingAssembly().GetManifestResourceNames()[0];\n\t\t\tvar resource = Assembly.GetCallingAssembly().GetManifestResourceStream(resName);\n\n\t\t\treturn new StreamReader(resource);\n\t\t}\n#endif\n\t}\n}\n", "lang_cluster": "C#", "tags": ["math", "greedy"], "code_uid": "64e6cc5c438c885b849dc0b8e88866f2", "src_uid": "ea36ca0a3c336424d5b7e1b4c56947b0", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\n\npublic class Chocolate\n{\n public static void Main(string[] args)\n {\n int n = int.Parse(Console.ReadLine());\n string[] temp_nuts = Console.ReadLine().Split(' ');\n int[] nuts = Array.ConvertAll(temp_nuts, int.Parse);\n long answer = 1;\n int foundNut = -1;\n\n for (int x = 0; x < n; x++){\n if (nuts[x] == 1){\n if (foundNut != -1){\n answer *= (x - foundNut);\n }\n foundNut = x;\n }\n }\n if (foundNut == -1){\n Console.WriteLine(0);\n }\n else{\n Console.WriteLine(answer); \n }\n }\n}", "lang_cluster": "C#", "tags": ["combinatorics"], "code_uid": "f0975e32bc7663fb6bbb6ba35d344552", "src_uid": "58242665476f1c4fa723848ff0ecda98", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\nusing System;\nusing System.Collections.Generic;\nusing System.Linq;\npublic class GFG\n{\n public static void Main()\n {\n var n = int.Parse(Console.ReadLine());\n\n var arr = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();\n\n long result = 0;\n int prev = -1;\n\n for (int i = 0; i < n; i++)\n {\n if (arr[i] == 1)\n {\n if (prev == -1)\n {\n result = 1;\n }\n else\n {\n result *= i - prev;\n }\n prev = i;\n }\n\n }\n\n Console.Write(result);\n\n }\n\n\n}\n\n", "lang_cluster": "C#", "tags": ["combinatorics"], "code_uid": "975cf1f8453bcf858022aaa881c65291", "src_uid": "58242665476f1c4fa723848ff0ecda98", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.IO;\nusing System.Collections.Generic;\nusing System.Globalization;\nusing System.Linq;\n\n\nclass Program\n{\n\n\n\n //////////////////////////////////////////////////\n void Solution()\n {\n var l1 = rl;\n var r1 = rl;\n var l2 = rl;\n var r2 = rl;\n var k = rl;\n\n if (r2 < l1)\n {\n wln(0);\n return;\n }\n\n if (r1 < l2)\n {\n wln(0);\n return;\n }\n\n var ml = Math.Max(l1, l2);\n var mr = Math.Min(r1, r2);\n if (mr < ml)\n {\n wln(0);\n return;\n }\n var ans = mr - ml + 1;\n if (k >= ml && k <= mr)\n ans--;\n\n wln(ans);\n }\n //////////////////////////////////////////////////\n\n static void swap(ref T o1, ref T o2) { var o = o1; o1 = o2; o2 = o; }\n\n static void wln() { Console.WriteLine(); }\n static void wln(T o) { Console.WriteLine(o); }\n static void wsp(T o) { Console.Write(o + \" \"); }\n static void wrt(T o) { Console.Write(o); }\n\n static void wln(double o) { Console.WriteLine(string.Format(CultureInfo.InvariantCulture, \"{0:F12}\", o)); }\n static void wsp(double o) { Console.Write(string.Format(CultureInfo.InvariantCulture, \"{0:F12} \", o)); }\n static void wrt(double o) { Console.Write(string.Format(CultureInfo.InvariantCulture, \"{0:F12}\", o)); }\n\n static long gcd(long a, long b) { return (b != 0) ? gcd(b, a % b) : a; }\n static long lcm(long a, long b) { return a / gcd(a, b) * b; }\n\n int ri\n {\n get\n {\n _read(); while (_str[_ind] == ' ') ++_ind;\n int sign = 1; if (_str[_ind] == '-') { sign = -1; ++_ind; }\n int p = 0;\n while (_ind < _count && _str[_ind] != ' ') p = p * 10 + _str[_ind++] - '0';\n while (_ind < _count && _str[_ind] == ' ') ++_ind; return p * sign;\n }\n }\n long rl\n {\n get\n {\n _read(); while (_str[_ind] == ' ') ++_ind;\n int sign = 1; if (_str[_ind] == '-') { sign = -1; ++_ind; }\n long p = 0;\n while (_ind < _count && _str[_ind] != ' ') p = p * 10 + _str[_ind++] - '0';\n while (_ind < _count && _str[_ind] == ' ') ++_ind; return p * sign;\n }\n }\n double rd\n {\n get\n {\n _read(); while (_str[_ind] == ' ') ++_ind; int sign = 1; if (_str[_ind] == '-') { sign = -1; ++_ind; }\n long p = 0, q = 1; while (_ind < _count && _str[_ind] != ' ' && _str[_ind] != '.') p = p * 10 + _str[_ind++] - '0';\n if (_ind < _count && _str[_ind] == '.') { ++_ind; while (_ind < _count && _str[_ind] != ' ') { p = p * 10 + _str[_ind++] - '0'; q *= 10; } }\n while (_ind < _count && _str[_ind] == ' ') ++_ind; return (double)p / q * sign;\n }\n }\n string rs\n {\n get\n {\n _read(); while (_ind < _count && _str[_ind] == ' ') ++_ind;\n var tmp = _str.IndexOf(' ', _ind);\n if (tmp == -1) { _count = 0; _ind = 0; return _str.Substring(_ind); }\n var s = _str.Substring(_ind, tmp - _ind); _ind = tmp + 1;\n while (_ind < _count && _str[_ind] == ' ') ++_ind; return s;\n }\n }\n\n int[] ria(int n)\n {\n var res = new int[n];\n for (int k = 0; k < n;)\n {\n var s = Console.ReadLine(); var m = s.Length;\n for (int i = 0; i < m && k < n; ++i)\n {\n while (i < m && s[i] == ' ') ++i; if (i == m) break; int sign = 1; if (s[i] == '-') { sign = -1; ++i; }\n int p = 0; while (i < m && s[i] != ' ') p = p * 10 + s[i++] - '0'; res[k++] = p * sign;\n }\n }\n _count = 0; _ind = 0; return res;\n }\n long[] rla(int n)\n {\n var res = new long[n];\n for (int k = 0; k < n;)\n {\n var s = Console.ReadLine(); var m = s.Length;\n for (int i = 0; i < m && k < n; ++i)\n {\n while (i < m && s[i] == ' ') ++i; if (i == m) break; int sign = 1; if (s[i] == '-') { sign = -1; ++i; }\n long p = 0; while (i < m && s[i] != ' ') p = p * 10 + s[i++] - '0'; res[k++] = p * sign;\n }\n }\n _count = 0; _ind = 0; return res;\n }\n double[] rda(int n)\n {\n var res = new double[n];\n for (int k = 0; k < n;)\n {\n var s = Console.ReadLine(); var m = s.Length;\n for (int i = 0; i < m && k < n; ++i)\n {\n while (i < m && s[i] == ' ') ++i; if (i == m) break; int sign = 1; if (s[i] == '-') { sign = -1; ++i; }\n long p = 0, q = 1; while (i < m && s[i] != ' ' && s[i] != '.') p = p * 10 + s[i++] - '0';\n if (i < m && s[i] == '.') { ++i; while (i < m && s[i] != ' ') { p = p * 10 + s[i++] - '0'; q *= 10; } }\n res[k++] = (double)p / q * sign;\n }\n }\n _count = 0; _ind = 0; return res;\n }\n string[] rsa(int n) { var res = new string[n]; for (int k = 0; k < n; ++k) res[k] = Console.ReadLine(); _count = 0; _ind = 0; return res; }\n string _str = null; int _count = 0; int _ind = 0;\n void _read() { if (_ind == _count) { _str = Console.ReadLine(); _count = _str.Length; _ind = 0; } }\n static void Main() { new Program().Solution(); }\n}", "lang_cluster": "C#", "tags": ["math", "implementation"], "code_uid": "403e3c17295b18e7a3aa9aacf4af60a6", "src_uid": "9a74b3b0e9f3a351f2136842e9565a82", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace CodeforcesTasks\n{\n class Program_371A\n {\n static void Main()\n {\n string[] inStr = Console.ReadLine().Split(' ');\n long l1 = long.Parse(inStr[0]);\n long r1 = long.Parse(inStr[1]);\n long l2 = long.Parse(inStr[2]);\n long r2 = long.Parse(inStr[3]);\n long k = long.Parse(inStr[4]);\n long beg, end, dur;\n\n if (l1 >= l2)\n {\n beg = l1;\n }\n else\n {\n beg = l2;\n }\n if (r1 >= r2)\n {\n end = r2;\n }\n else\n {\n end = r1;\n }\n if (end < beg)\n {\n dur = 0;\n }\n else\n {\n dur = end - beg + 1;\n }\n if ( (dur > 0) && (k >= beg) && (k <= end) )\n {\n dur = dur - 1;\n }\n Console.WriteLine(dur);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "implementation"], "code_uid": "17ae5c66d38438ad4eb3354d41e1d694", "src_uid": "9a74b3b0e9f3a351f2136842e9565a82", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System; using System.Linq;\n\nclass P {\n static void Main() {\n var a = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();\n if (a[1] - a[0] == a[2] - a[1] && a[2]-a[1] == a[3] - a[2]){\n Console.Write(a[3] + a[2] - a[1]); return; \n }\n if (a[2]*a[0] == a[1]*a[1] && a[2]*a[2] == a[3]*a[1]) {\n var d = a[3]*a[3];\n if (d % a[2] == 0) {\n Console.Write(d/a[2]); return; }\n }\n Console.Write(42); \n }\n}", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "0ba72cabe8d8e3f8bc1ded53ffc36a2a", "src_uid": "68a9508d49fec672f9c61766d6051047", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\n\nnamespace CodeForces\n{\n class R191_Test8_A\n {\n static void Main(string[] args)\n {\n int n = 4;\n string[] s = Console.ReadLine().Split();\n int[] a = new int[n];\n for (int i = 0; i < n; i++)\n a[i] = int.Parse(s[i]);\n \n if (a[3] - a[2] == a[2] - a[1]\n && a[2] - a[1] == a[1] - a[0])\n {\n int d = a[1] - a[0];\n Console.WriteLine(a[3] + d);\n return;\n }\n\n if (a[3] * a[1] == a[2] * a[2]\n && a[2] * a[0] == a[1] * a[1])\n {\n double q = a[3] * a[3] / (double)a[2];\n if (Math.Abs(q - (int)q) < 0.0001)\n {\n Console.WriteLine(a[3] * a[3] / (double)a[2]);\n return;\n }\n }\n\n Console.WriteLine(42);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "f24d5ab1a90fd5cf23a69ff847c8493b", "src_uid": "68a9508d49fec672f9c61766d6051047", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace ConsoleApplication1\n{\n public class Program\n {\n public static void Main()\n {\n string[] lines = new string[8];\n string ans = \"YES\";\n\n for (int i = 0; i < 8; ++i)\n lines[i] = Console.ReadLine();\n\n for(int i = 0; i < 8; ++i)\n for (int j = 0; j < 7; ++j)\n {\n if (lines[i][j] == lines[i][j + 1])\n {\n ans = \"NO\";\n i = 8;\n break;\n }\n }\n\n Console.WriteLine(ans);\n }\n }\n}", "lang_cluster": "C#", "tags": ["brute force", "strings"], "code_uid": "fdc6571d4c0d4bd0ca2deeecd2e62480", "src_uid": "ca65e023be092b2ce25599f52acc1a67", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nnamespace codeforces\n{\n class Program\n {\n static void Main(string[] args)\n {\n for (int i = 0; i < 8; i++)\n {\n char prevChar = (char)Console.Read();\n for (int j = 1; j < 8; j++)\n {\n char ch = (char)Console.Read();\n if (ch == prevChar)\n {\n Console.WriteLine(\"NO\");\n return;\n }\n prevChar = ch;\n }\n Console.ReadLine();\n }\n Console.WriteLine(\"YES\");\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "strings"], "code_uid": "824503b8da9491bcb5594feeaadeabfd", "src_uid": "ca65e023be092b2ce25599f52acc1a67", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace ConsoleApplication34\n{\n class Program\n {\n static void Main(string[] args)\n {\n int n = Convert.ToInt32(Console.ReadLine());\n\n var nums = Console.ReadLine().Split().Select(e => Convert.ToInt32(e)).ToArray();\n \n for (int i = 0; i < 100; i++)\n {\n Array.Sort(nums);\n for (int j = nums.Length-1; j >0&& nums[j] > 1; j--)\n nums[j] = nums[j] > nums[j-1] ? nums[j] - nums[j-1] : nums[j];\n\n\n }\n\n Console.WriteLine(nums.Sum());\n Console.ReadLine();\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "greedy"], "code_uid": "cce8c1605f148f35bd7913d11ca7b677", "src_uid": "042cf938dc4a0f46ff33d47b97dc6ad4", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace Codeforces\n{\n class Program\n {\n public static int NOD(int a, int b)\n {\n int x;\n\n if (a > b)\n {\n x = a;\n a = b;\n b = x;\n }\n\n while (a > 0)\n {\n x = a;\n a = b % a;\n b = x;\n }\n\n return b;\n }\n\n static void Main(string[] args)\n {\n string s = Console.ReadLine();\n int n = int.Parse(s);\n\n string[] ss = Console.ReadLine().Split();\n int[] a = new int[n];\n\n int x = int.Parse(ss[0]);\n \n for (int i = 0; i < n; i++)\n a[i] = int.Parse(ss[i]);\n\n int k = a[0];\n\n for (int i = 0; i < n; i++)\n for (int j = i + 1; j < n; j++)\n {\n k = Math.Min(k, NOD(a[i], a[j]));\n if (k == 1)\n {\n Console.WriteLine(n);\n return;\n }\n }\n\n for (int i = 0; i < n; i++)\n k = Math.Min(k, NOD(a[i], k));\n \n Console.WriteLine(k * n);\n }\n }\n}", "lang_cluster": "C#", "tags": ["math", "greedy"], "code_uid": "6fc1ca646b5de8db9eec1194ecdfd0c9", "src_uid": "042cf938dc4a0f46ff33d47b97dc6ad4", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Globalization;\nusing System.IO;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace Codeforces\n{\n class Program\n {\n static StreamReader reader;\n static StreamWriter writer;\n static Random rand = new Random(0);\n\n static void Main(string[] args)\n {\n //#if DEBUG\n reader = new StreamReader(Console.OpenStandardInput(32768), Encoding.ASCII, false, 32768);\n writer = new StreamWriter(Console.OpenStandardOutput(32768), Encoding.ASCII, 32768);\n //#else\n // StreamReader streamReader = new StreamReader(Console.OpenStandardInput(32768), Encoding.ASCII, false, 32768);\n // StreamWriter writer = new StreamWriter(Console.OpenStandardOutput(32768), Encoding.ASCII, 32768);\n //#endif\n InputReader input = new InputReader(reader);\n\n long n = input.NextLong();\n bool ok = false;\n for (long a = 0; a < 820; a++)\n {\n for (long b = 0; b < 8200; b++)\n {\n long mul = a * 1234567L + b * 123456L;\n if (mul <= n)\n {\n ok |= ((n - mul) % 1234 == 0);\n }\n }\n }\n writer.WriteLine(ok ? \"YES\" : \"NO\");\n\n\n#if DEBUG\n Console.BackgroundColor = ConsoleColor.White;\n Console.ForegroundColor = ConsoleColor.Black;\n#endif\n writer.Flush();\n writer.Close();\n reader.Close();\n }\n }\n\n class MyInt\n {\n public int data;\n\n }\n\n class MyPair\n {\n public int x, y;\n\n public MyPair(int x, int y)\n {\n this.x = x;\n this.y = y;\n }\n }\n\n // this class is copy\n class InputReader\n {\n private char[] _inbuf;\n private int _lenbuf = 0, _ptrbuf = 0;\n private StreamReader _reader;\n\n public InputReader(StreamReader reader)\n {\n _reader = reader;\n _inbuf = new char[1024];\n _lenbuf = 0;\n _ptrbuf = 0;\n }\n\n private int ReadByte()\n {\n if (_lenbuf == -1)\n throw new Exception();\n if (_ptrbuf >= _lenbuf)\n {\n _ptrbuf = 0;\n try\n {\n _lenbuf = _reader.Read(_inbuf, 0, 1024);\n }\n catch (IOException e)\n {\n throw e;\n }\n if (_lenbuf <= 0)\n return -1;\n }\n return _inbuf[_ptrbuf++];\n }\n\n private bool IsSpaceChar(int c)\n {\n return !(c >= 33 && c <= 126);\n }\n\n private int Skip()\n {\n int b;\n while ((b = ReadByte()) != -1 && IsSpaceChar(b)) ;\n return b;\n }\n\n public int NextInt()\n {\n return int.Parse(this.Next());\n }\n\n public int[] NextIntArray(int n)\n {\n int[] a = new int[n];\n for (int i = 0; i < n; i++)\n {\n a[i] = NextInt();\n }\n return a;\n }\n\n public long NextLong()\n {\n return long.Parse(this.Next());\n }\n\n public string Next()\n {\n var b = Skip();\n var sb = new StringBuilder();\n while (!(IsSpaceChar(b)))\n {\n sb.Append((char)b);\n b = ReadByte();\n }\n return sb.ToString();\n }\n\n public double NextDouble()\n {\n return double.Parse(Next(), CultureInfo.InvariantCulture);\n }\n\n internal long[] NextLongArray(long n)\n {\n long[] a = new long[(int)n];\n for (int i = 0; i < a.Length; i++)\n {\n a[i] = NextLong();\n }\n return a;\n }\n\n internal double[] NextDoubleArray(int n)\n {\n double[] a = new double[n];\n for (int i = 0; i < a.Length; i++)\n {\n a[i] = NextDouble();\n }\n return a;\n }\n }\n}", "lang_cluster": "C#", "tags": ["brute force"], "code_uid": "58fc9cfebe230973e1bee073c2222964", "src_uid": "72d7e422a865cc1f85108500bdf2adf2", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace B.\u042d\u043a\u043e\u043d\u043e\u043c\u0438\u0447\u0435\u0441\u043a\u0430\u044f_\u0438\u0433\u0440\u0430\n{\n class Program\n {\n static void Main(string[] args)\n {\n int n = int.Parse(Console.ReadLine());\n bool pr = false;\n //int i, j, k = 0;\n\n //for (i = 0; i * 1234567 <= n; i++)\n //{\n // for (j = 0; j * 123456 <= n - i * 1234567; j++)\n // {\n // for (k = 0; k * 1234 <= n - i * 1234567 - j * 123456; k++)\n // {\n // if (n - i * 1234567 - j * 123456 - k * 1234 == 0)\n // {\n // pr = true;\n // break;\n // }\n // }\n // }\n\n //}\n\n\n for (int i = n / 1234567; i >= 0; i--)\n {\n for (int j = (n - 1234567 * i) / 123456; j >= 0; j--)\n {\n if ((n - i * 1234567 - j * 123456) % 1234 == 0)\n {\n pr = true;\n break;\n }\n }\n\n }\n\n if (pr) Console.WriteLine(\"YES\");\n else Console.WriteLine(\"NO\");\n\n Console.ReadLine();\n\n\n\n }\n }\n}", "lang_cluster": "C#", "tags": ["brute force"], "code_uid": "4bae4cdb86523e8c676d1a8e122c904f", "src_uid": "72d7e422a865cc1f85108500bdf2adf2", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.IO;\nusing System.Linq;\nusing System.Text;\n\n\nnamespace Compete.CFE38 {\n public class TaskA {\n public static void Main(string[] args) {\n new TaskA().Solve(Console.In, Console.Out);\n }\n\n public void Solve(TextReader input, TextWriter output) {\n // INPUT\n var n = int.Parse(input.ReadLine());\n var s = input.ReadLine();\n\n // SOLUTION\n var sb = new StringBuilder();\n bool prev = false;\n foreach (var c in s) {\n if (IsVowel(c)) {\n if (!prev) {\n prev = true;\n sb.Append(c);\n }\n }\n else {\n prev = false;\n sb.Append(c);\n }\n }\n\n // OUTPUT\n output.WriteLine(sb.ToString());\n }\n\n\n private static bool IsVowel(char c) { return \"aeiouy\".Contains(c); }\n }\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "a8c2c007d7a4a9a8352703351ee68406", "src_uid": "63a4a5795d94f698b0912bb8d4cdf690", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\n\nnamespace \u0411\u0443\u043a\u0432\u044b\n{\n class Program\n {\n static void Main(string[] args)\n {\n string G = \"aouiey\";\n\n bool Flag = false;\n int N = Convert.ToInt32(Console.ReadLine());\n for (int i = 0; i < N; i++)\n {\n char c = (char)Console.Read();\n if (G.Contains(c.ToString()) == false)\n {\n Flag = false;\n Console.Write(c);\n }\n else//(G.Contains(c) == true)\n {\n if (Flag==false)\n {\n Console.Write(c);\n \n }\n Flag = true;\n }\n \n }\n Console.WriteLine();\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "c6d7955c4e25146dcc22f3fe0e961499", "src_uid": "63a4a5795d94f698b0912bb8d4cdf690", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.IO;\nusing System.Text;\n\nnamespace Odds_and_Ends\n{\n internal class Program\n {\n private static readonly StreamReader reader = new StreamReader(Console.OpenStandardInput(1024*10), Encoding.ASCII, false, 1024*10);\n private static readonly StreamWriter writer = new StreamWriter(Console.OpenStandardOutput(1024*10), Encoding.ASCII, 1024*10);\n\n private static void Main(string[] args)\n {\n int n = Next();\n\n var nn = new int[n];\n for (int i = 0; i < n; i++)\n {\n nn[i] = Next()%2;\n }\n\n if (nn[0] == 0 || n%2 == 0)\n {\n writer.WriteLine(\"No\");\n writer.Flush();\n return;\n }\n\n if (!Solve(nn, n))\n {\n Array.Reverse(nn);\n if (nn[0] == 0)\n {\n writer.WriteLine(\"No\");\n writer.Flush();\n return;\n }\n\n writer.WriteLine(!Solve(nn, n) ? \"No\" : \"Yes\");\n }\n else writer.WriteLine(\"Yes\");\n\n writer.Flush();\n }\n\n private static bool Solve(int[] nn, int n)\n {\n int cross = 0;\n int g = 0;\n for (int i = 0; i < n; i++)\n {\n if (nn[i] == 0)\n {\n for (int j = i + 1; j < n; j++)\n {\n if (nn[j] == 1 && nn[j - 1] == 1 && (j - i)%2 == 0)\n {\n g++;\n cross += j - i + 1;\n i = j;\n break;\n }\n }\n if (nn[i] == 0)\n {\n if (nn[n - 1] == 1 && (n - i)%2 == 0)\n {\n g++;\n cross += n - i + 1;\n i = n;\n }\n else\n {\n return false;\n }\n }\n }\n }\n\n return (n - cross + g)%2 == 1;\n }\n\n private static int Next()\n {\n int c;\n int res = 0;\n do\n {\n c = reader.Read();\n if (c == -1)\n return res;\n } while (c < '0' || c > '9');\n res = c - '0';\n while (true)\n {\n c = reader.Read();\n if (c < '0' || c > '9')\n return res;\n res *= 10;\n res += c - '0';\n }\n }\n }\n}", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "589687c30c525dae39de194171d111a3", "src_uid": "2b8c2deb5d7e49e8e3ededabfd4427db", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\n\nclass TEST{\n\tstatic void Main(){\n\t\tSol mySol =new Sol();\n\t\tmySol.Solve();\n\t}\n}\n\nclass Sol{\n\tpublic void Solve(){\n\t\tif(N % 2 == 0){\n\t\t\tConsole.WriteLine(\"No\");\n\t\t\treturn;\n\t\t}\n\t\tif(A[0]%2 == 0 || A[N-1]%2 == 0){\n\t\t\tConsole.WriteLine(\"No\");\n\t\t\treturn;\n\t\t}\n\t\t\n\t\tConsole.WriteLine(\"Yes\");\n\t}\n\tint N;\n\tint[] A;\n\tpublic Sol(){\n\t\tN = ri();\n\t\tA = ria();\n\t}\n\n\tstatic String rs(){return Console.ReadLine();}\n\tstatic int ri(){return int.Parse(Console.ReadLine());}\n\tstatic long rl(){return long.Parse(Console.ReadLine());}\n\tstatic double rd(){return double.Parse(Console.ReadLine());}\n\tstatic String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}\n\tstatic int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}\n\tstatic long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}\n\tstatic double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "8bc1ae794bf5a4adee5e9e075269f517", "src_uid": "2b8c2deb5d7e49e8e3ededabfd4427db", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\n\nnamespace CSharp\n{\n public class _748A\n {\n public static void Main()\n {\n string[] tokens = Console.ReadLine().Split();\n\n int n = int.Parse(tokens[0]);\n int m = int.Parse(tokens[1]);\n int k = int.Parse(tokens[2]);\n\n int r = (k + 2 * m - 1) / (2 * m);\n int d = (k + 1) / 2 - (r - 1) * m;\n char s = k % 2 == 0 ? 'R' : 'L';\n\n Console.WriteLine($\"{r} {d} {s}\");\n }\n }\n}", "lang_cluster": "C#", "tags": ["math", "implementation"], "code_uid": "da8dac330d4371b1fd61fb87c1e89832", "src_uid": "d6929926b44c2d5b1a8e6b7f965ca1bb", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace mo\n{\n class Program\n {\n static void Main(string[] args)\n {\n var numbers = GetIntegerInputsFromLine();\n\n\n int i = 1;\n\n int lanes = numbers[1] * 2;\n\n while (lanes < numbers[2])\n {\n\n i++;\n\n lanes = numbers[1] * 2 * i;\n }\n\n var divider = ((i - 1) * numbers[1] * 2);\n\n var rows = numbers[2];\n\n if (divider != 0)\n {\n rows = rows % divider;\n }\n\n\n var f = 'R';\n\n if (rows == 0)\n {\n rows = numbers[1];\n }\n else if (rows % 2 == 1)\n {\n rows = rows / 2 + 1;\n\n f = 'L';\n }\n else\n {\n rows = rows / 2;\n }\n\n\n Console.WriteLine(i + \" \" + rows + ' ' + f);\n }\n\n static int GetIntegerInputFromLine()\n {\n var input = Convert.ToInt32(Console.ReadLine().Trim());\n return input;\n }\n\n static int[] GetIntegerInputsFromLine()\n {\n var inputs = Console.ReadLine().Split(' ').Select(x => Convert.ToInt32(x.Trim())).ToArray();\n return inputs;\n }\n\n static long GetLongInputFromLine()\n {\n var input = Convert.ToInt64(Console.ReadLine().Trim());\n return input;\n }\n\n static long[] GetLongInputsFromLine()\n {\n var inputs = Console.ReadLine().Split(' ').Select(x => Convert.ToInt64(x.Trim())).ToArray();\n return inputs;\n }\n\n static double GetDoubleInputFromLine()\n {\n var input = Convert.ToDouble(Console.ReadLine().Trim());\n return input;\n }\n\n static double[] GetDoubleInputsFromLine()\n {\n var inputs = Console.ReadLine().Split(' ').Select(x => Convert.ToDouble(x.Trim())).ToArray();\n return inputs;\n }\n\n static string GetStringInputFromLine()\n {\n var input = Console.ReadLine();\n return input;\n }\n\n static string[] GetStringInputsFromLine()\n {\n var inputs = Console.ReadLine().Split(' ');\n return inputs;\n }\n }\n}", "lang_cluster": "C#", "tags": ["math", "constructive algorithms"], "code_uid": "8599d6f6aa35389c512f648020d75f2a", "src_uid": "d6929926b44c2d5b1a8e6b7f965ca1bb", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing CompLib.Util;\n\npublic class Program\n{\n private int N, M;\n private int[] L;\n\n public void Solve()\n {\n var sc = new Scanner();\n N = sc.NextInt();\n M = sc.NextInt();\n L = sc.IntArray();\n\n // M\u30b9\u30c6\u30c3\u30d7\u3000\u30b2\u30fc\u30e0\n // \u30ea\u30fc\u30c0\u30fc i\n // A \u9806\u5217\n\n // \u6b21\u306eA_i\u756a\u76ee\u3092\u6307\u5b9a\u3057\u3066 \u30ea\u30fc\u30c0\u30fc\u306b\u3059\u308b\n // \u30ea\u30fc\u30c0\u30fc\u306b\u306a\u3063\u305f\u9806 L\u304c\u4e0e\u3048\u3089\u308c\u308b \n\n\n // A\u3092\u51fa\u529b or \u5b58\u5728\u3057\u306a\u3044 -1\n\n bool[] used = new bool[N + 1];\n int[] a = new int[N];\n for (int i = 0; i < M - 1; i++)\n {\n int d = (L[i + 1] - L[i] + N) % N;\n if (d == 0) d = N;\n if (a[L[i] - 1] == 0)\n {\n if (used[d])\n {\n Console.WriteLine(\"-1\");\n return;\n }\n\n used[d] = true;\n a[L[i] - 1] = d;\n }\n else\n {\n if (a[L[i] - 1] != d)\n {\n Console.WriteLine(\"-1\");\n return;\n }\n }\n }\n\n int index = 1;\n for (int i = 0; i < N; i++)\n {\n if (a[i] == 0)\n {\n while (used[index])\n {\n index++;\n }\n\n a[i] = index;\n used[index] = true;\n }\n }\n\n Console.WriteLine(string.Join(\" \", a));\n }\n\n public static void Main(string[] args) => new Program().Solve();\n}\n\nnamespace CompLib.Util\n{\n using System;\n using System.Linq;\n\n class Scanner\n {\n private string[] _line;\n private int _index;\n private const char Separator = ' ';\n\n public Scanner()\n {\n _line = new string[0];\n _index = 0;\n }\n\n public string Next()\n {\n if (_index >= _line.Length)\n {\n string s = Console.ReadLine();\n while (s.Length == 0)\n {\n s = Console.ReadLine();\n }\n\n _line = s.Split(Separator);\n _index = 0;\n }\n\n return _line[_index++];\n }\n\n public int NextInt() => int.Parse(Next());\n public long NextLong() => long.Parse(Next());\n public double NextDouble() => double.Parse(Next());\n public decimal NextDecimal() => decimal.Parse(Next());\n public char NextChar() => Next()[0];\n public char[] NextCharArray() => Next().ToCharArray();\n\n public string[] Array()\n {\n string s = Console.ReadLine();\n _line = s.Length == 0 ? new string[0] : s.Split(Separator);\n _index = _line.Length;\n return _line;\n }\n\n public int[] IntArray() => Array().Select(int.Parse).ToArray();\n public long[] LongArray() => Array().Select(long.Parse).ToArray();\n public double[] DoubleArray() => Array().Select(double.Parse).ToArray();\n public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();\n }\n}", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "c3422fd8f7d634b9f1f2e249883215cd", "src_uid": "4a7c959ca279d0a9bd9bbf0ce88cf72b", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Globalization;\nusing System.IO;\nusing System.Linq;\nusing System.Text;\n\nclass Program\n{\n private static void Main(string[] args)\n {\n var n = RI();\n var m = RI();\n var a = RIA(m);\n\n var ans = new int[n + 1];\n for (int i = 0; i < m - 1; i++)\n {\n var d = a[i + 1] - a[i];\n if (d <= 0) d += n;\n\n if (ans[a[i]] != 0 && ans[a[i]] != d)\n {\n Console.Write(-1);\n return;\n }\n\n ans[a[i]] = d;\n }\n\n for (int i = 1; i <= n; i++)\n if (ans[i] == 0)\n {\n for (int j = 1; j <= n; j++)\n if (!ans.Contains(j))\n {\n ans[i] = j;\n break;\n }\n }\n\n if (ans.Skip(1).Distinct().Count() != n)\n {\n Console.WriteLine(-1);\n return;\n }\n\n\n Console.WriteLine(string.Join(\" \", ans.Skip(1)));\n\n }\n \n\n private const int Mod = 1000000000 + 7;\n\n #region Data Read\n\n private static long GCD(long a, long b)\n {\n if (a % b == 0) return b;\n return GCD(b, a % b);\n }\n\n private static List[] ReadTree(int n)\n {\n return ReadGraph(n, n - 1);\n }\n\n private static List[] ReadGraph(int n, int m)\n {\n List[] g = new List[n];\n for (int i = 0; i < g.Length; i++) g[i] = new List();\n for (int i = 0; i < m; i++)\n {\n int a = RI() - 1;\n int b = RI() - 1;\n\n g[a].Add(b);\n g[b].Add(a);\n }\n\n return g;\n }\n\n private static int[,] ReadGraphAsMatrix(int n, int m)\n {\n int[,] matrix = new int[n + 1, n + 1];\n for (int i = 0; i < m; i++)\n {\n int a = RI();\n int b = RI();\n matrix[a, b] = matrix[b, a] = 1;\n }\n\n return matrix;\n }\n\n private static void Sort(ref int a, ref int b)\n {\n if (a > b) Swap(ref a, ref b);\n }\n\n private static void Swap(ref int a, ref int b)\n {\n int tmp = a;\n a = b;\n b = tmp;\n }\n\n private const int BufferSize = 1 << 16;\n private static StreamReader consoleReader;\n private static MemoryStream testData;\n\n private static int RI()\n {\n int ans = 0;\n int mul = 1;\n do\n {\n ans = consoleReader.Read();\n if (ans == -1)\n return 0;\n if (ans == '-') mul = -1;\n } while (ans < '0' || ans > '9');\n\n ans -= '0';\n while (true)\n {\n int chr = consoleReader.Read();\n if (chr < '0' || chr > '9')\n return ans * mul;\n ans = ans * 10 + chr - '0';\n }\n }\n\n private static ulong RUL()\n {\n ulong ans = 0;\n int chr;\n do\n {\n chr = consoleReader.Read();\n if (chr == -1)\n return 0;\n } while (chr < '0' || chr > '9');\n\n ans = (uint)(chr - '0');\n while (true)\n {\n chr = consoleReader.Read();\n if (chr < '0' || chr > '9')\n return ans;\n ans = ans * 10 + (uint)(chr - '0');\n }\n }\n\n private static long RL()\n {\n long ans = 0;\n int mul = 1;\n do\n {\n ans = consoleReader.Read();\n if (ans == -1)\n return 0;\n if (ans == '-') mul = -1;\n } while (ans < '0' || ans > '9');\n\n ans -= '0';\n while (true)\n {\n int chr = consoleReader.Read();\n if (chr < '0' || chr > '9')\n return ans * mul;\n ans = ans * 10 + chr - '0';\n }\n }\n\n private static int[] RIA(int n)\n {\n int[] ans = new int[n];\n for (int i = 0; i < n; i++)\n ans[i] = RI();\n return ans;\n }\n\n private static long[] RLA(int n)\n {\n long[] ans = new long[n];\n for (int i = 0; i < n; i++)\n ans[i] = RL();\n return ans;\n }\n\n private static char[] ReadWord()\n {\n int ans;\n\n do\n {\n ans = consoleReader.Read();\n } while (!((ans >= 'a' && ans <= 'z') || (ans >= 'A' && ans <= 'Z') || (ans == '*')));\n\n List s = new List();\n do\n {\n s.Add((char)ans);\n ans = consoleReader.Read();\n } while ((ans >= 'a' && ans <= 'z') || (ans >= 'A' && ans <= 'Z') || (ans == '*'));\n\n return s.ToArray();\n }\n\n private static char[] ReadString(int n)\n {\n int ans;\n\n do\n {\n ans = consoleReader.Read();\n } while (!((ans >= 'a' && ans <= 'z') || (ans >= 'A' && ans <= 'Z')));\n\n char[] s = new char[n];\n int pos = 0;\n do\n {\n s[pos++] = (char)ans;\n if (pos == n) break;\n ans = consoleReader.Read();\n } while ((ans >= 'a' && ans <= 'z') || (ans >= 'A' && ans <= 'Z'));\n\n return s;\n }\n\n private static char[] ReadStringLine()\n {\n int ans;\n\n do\n {\n ans = consoleReader.Read();\n } while (ans == 10 || ans == 13);\n\n List s = new List();\n\n do\n {\n s.Add((char)ans);\n ans = consoleReader.Read();\n } while (ans != 10 && ans != 13 && ans != -1);\n\n return s.ToArray();\n }\n\n private static char ReadLetter()\n {\n while (true)\n {\n int ans = consoleReader.Read();\n if ((ans >= 'a' && ans <= 'z') || (ans >= 'A' && ans <= 'Z'))\n return (char)ans;\n }\n }\n private static char ReadNonLetter()\n {\n while (true)\n {\n int ans = consoleReader.Read();\n if (!((ans >= 'a' && ans <= 'z') || (ans >= 'A' && ans <= 'Z')))\n return (char)ans;\n }\n }\n\n private static char ReadAnyOf(IEnumerable allowed)\n {\n while (true)\n {\n char ans = (char)consoleReader.Read();\n if (allowed.Contains(ans))\n return ans;\n }\n }\n\n private static char ReadDigit()\n {\n while (true)\n {\n int ans = consoleReader.Read();\n if (ans >= '0' && ans <= '9')\n return (char)ans;\n }\n }\n\n private static int ReadDigitInt()\n {\n return ReadDigit() - (int)'0';\n }\n\n private static char ReadAnyChar()\n {\n return (char)consoleReader.Read();\n }\n\n private static string DoubleToString(double x)\n {\n return x.ToString(CultureInfo.InvariantCulture);\n }\n\n private static double DoubleFromString(string x)\n {\n return double.Parse(x, CultureInfo.InvariantCulture);\n }\n\n static Program()\n {\n //Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;\n consoleReader = new StreamReader(Console.OpenStandardInput(BufferSize), Encoding.ASCII, false, BufferSize);\n }\n\n private static void PushTestData(StringBuilder sb)\n {\n PushTestData(sb.ToString());\n }\n private static void PushTestData(string data)\n {\n#if TOLYAN_TEST\n if (testData == null)\n {\n testData = new MemoryStream();\n consoleReader = new StreamReader(testData);\n }\n\n var pos = testData.Position;\n var bytes = Encoding.UTF8.GetBytes(data);\n testData.Write(bytes, 0, bytes.Length);\n testData.Flush();\n testData.Position = pos;\n#endif\n }\n #endregion\n}", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "f342c9a9d7c0947020234b70f82631ee", "src_uid": "4a7c959ca279d0a9bd9bbf0ce88cf72b", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Linq;\n\nnamespace CSharp\n{\n class _236B\n {\n public static void Main()\n {\n const int Mod = 1073741824;\n\n var tokens = Console.ReadLine().Split();\n\n int a = int.Parse(tokens[0]);\n int b = int.Parse(tokens[1]);\n int c = int.Parse(tokens[2]);\n\n int Max = a * b * c;\n\n var isPrime = new bool[Max + 1];\n for (int i = 2; i <= Max; i++)\n {\n isPrime[i] = true;\n }\n\n for (int i = 2; i <= Max; i++)\n {\n if (isPrime[i])\n {\n for (int j = 2 * i; j <= Max; j += i)\n {\n isPrime[j] = false;\n }\n }\n }\n\n var primes = Enumerable.Range(1, Max).Where(i => isPrime[i]).ToList();\n\n var d = new int[Max + 1];\n for (int i = 1; i <= Max; i++)\n {\n if (i == 1)\n {\n d[i] = 1;\n }\n else if (isPrime[i])\n {\n d[i] = 2;\n continue;\n }\n else\n {\n int prime = primes.First(p => i % p == 0);\n\n int x = i;\n int count = 0;\n\n while (x % prime == 0)\n {\n x /= prime;\n count++;\n }\n\n d[i] = d[x] * (count + 1);\n }\n }\n\n int sum = 0;\n\n for (int i = 1; i <= a; i++)\n {\n for (int j = 1; j <= b; j++)\n {\n for (int k = 1; k <= c; k++)\n {\n sum = (sum + d[i * j * k]) % Mod;\n }\n }\n }\n\n Console.WriteLine(sum);\n }\n }\n}", "lang_cluster": "C#", "tags": ["implementation", "number theory"], "code_uid": "c0148e2de6252fbb892385c721a43a2e", "src_uid": "4fdd4027dd9cd688fcc70e1076c9b401", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Text;\nusing System.IO;\n\npublic class taskB\n{\n public class MyReader\n {\n private TextReader instream;\n\n public int[] ReadIntArray()\n {\n string inp = instream.ReadLine().Trim();\n string[] spl = inp.Split(' ');\n\n int[] a = new int[spl.Length];\n for (int i = 0; i < a.Length; i++)\n a[i] = int.Parse(spl[i]);\n return a;\n }\n\n public double[] ReadDoubleArray()\n {\n string inp = instream.ReadLine().Trim();\n string[] spl = inp.Split(' ');\n\n double[] a = new double[spl.Length];\n\n System.Globalization.NumberFormatInfo nfi = new System.Globalization.NumberFormatInfo();\n nfi.NumberDecimalSeparator = \".\";\n for (int i = 0; i < a.Length; i++)\n a[i] = double.Parse(spl[i], nfi);\n return a;\n }\n\n public int ReadInt()\n {\n return int.Parse(instream.ReadLine());\n }\n\n public long ReadLong()\n {\n return long.Parse(instream.ReadLine());\n }\n\n public void SetInStream(TextReader textReader)\n {\n this.instream = textReader;\n }\n\n internal string ReadLine()\n {\n return instream.ReadLine();\n }\n }\n\n static void Main(string[] args)\n {\n MyReader instream = new MyReader();\n instream.SetInStream(Console.In);\n\n TextWriter outstream = Console.Out;\n\n solve(instream, outstream);\n\n }\n\n static long MODULO = 1073741824;\n\n static int[,] pows = new int[101, 101];\n static int[] dl;\n private static void solve(MyReader instream, TextWriter outstream)\n {\n int[] abc = instream.ReadIntArray();\n\n List primes = new List();\n primes.Add(2);\n for (int i = 3; i <= 100; i++)\n {\n bool ok = true;\n foreach (int p in primes)\n {\n if (i % p == 0) ok = false;\n }\n if (ok) primes.Add(i);\n }\n dl = primes.ToArray();\n\n for (int x = 2; x <= 100; x++)\n {\n int xx = x;\n\n for (int pi = 0; pi < dl.Length && dl[pi]<=x ; pi++)\n {\n int po = dl[pi];\n\n while (xx % po == 0)\n {\n pows[x, pi]++;\n xx /= po;\n }\n }\n }\n\n int[] total_pows = new int[100];\n long res = 0;\n\n for (int a = 1; a <= abc[0]; a++)\n for (int b = 1; b <= abc[1]; b++)\n for (int c = 1; c <= abc[2]; c++)\n {\n for (int i = 0; i < dl.Length; i++)\n total_pows[i] = 0;\n\n for (int i = 0, n = a; i < dl.Length; i++)\n total_pows[i] += pows[n, i];\n for (int i = 0, n = b; i < dl.Length; i++)\n total_pows[i] += pows[n, i];\n for (int i = 0, n = c; i < dl.Length; i++)\n total_pows[i] += pows[n, i];\n\n long subres = 1;\n for (int i = 0; i < dl.Length; i++)\n {\n subres = subres * (total_pows[i] + 1) % MODULO;\n }\n res = (res + subres) % MODULO;\n }\n\n outstream.WriteLine(res);\n }\n\n}\n", "lang_cluster": "C#", "tags": ["implementation", "number theory"], "code_uid": "975ada7e3bf39adb6c5cb62769adb488", "src_uid": "4fdd4027dd9cd688fcc70e1076c9b401", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Diagnostics;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace aDefintieGame\n{\n class Program\n {\n static void Main(string[] args)\n {\n int n = int.Parse(Console.ReadLine());\n bool done = true;\n while (done)\n {\n if (n - 1 != 0 && n % (n - 1) != 0)\n {\n n = n - (n - 1);\n }\n else if (n - 2 != 0 && n % (n - 2) != 0)\n {\n n = n - (n - 2);\n }\n else\n {\n done = false;\n }\n }\n Console.WriteLine(n);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "constructive algorithms"], "code_uid": "7072f2e01626d973e2707309cc235510", "src_uid": "c30b372a9cc0df4948dca48ef4c5d80d", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "/*\ncsc -debug A.cs && mono --debug A.exe <<< \"8\"\n*/\n\nusing System;\nusing System.Collections.Generic;\nusing System.Linq;\n\npublic class HelloWorld {\n static public void Main () {\n SolveCodeForces();\n }\n\n public static void SolveCodeForces() {\n var sc = new Scanner();\n var n = sc.NextLong();\n System.Console.WriteLine(n == 2 ? 2 : 1);\n }\n}\n\npublic static class Helpers {\n public static T[] CreateArray(int length, Func itemCreate) {\n var result = new T[length];\n for (var i = 0; i < result.Length; i++)\n result[i] = itemCreate(i);\n return result;\n }\n\n public static T ElementWithMax(this IEnumerable seq, Func func) {\n var bi = default(T);\n var bv = long.MinValue;\n foreach (var item in seq) {\n var v = func(item);\n if (v > bv) {\n bi = item;\n bv = v;\n }\n }\n return bi;\n }\n\n public static IEnumerable IndicesWhere(this IEnumerable seq, Func cond) {\n var i = 0;\n foreach (var item in seq) {\n if (cond(item)) yield return i;\n i++;\n }\n }\n}\n\npublic class Scanner\n{\n private string[] line = new string[0];\n private int index = 0;\n\n public string Next() {\n if (line.Length <= index) {\n line = Console.ReadLine().Split(' ');\n index = 0;\n }\n var res = line[index];\n index++;\n return res;\n }\n\n public int NextInt() {\n return int.Parse(Next());\n }\n\n public long NextLong() {\n return long.Parse(Next());\n }\n\n public ulong NextUlong() {\n return ulong.Parse(Next());\n }\n\n public string[] Array() {\n line = Console.ReadLine().Split(' ');\n index = line.Length;\n return line;\n }\n\n public int[] IntArray() {\n var array = Array();\n var result = new int[array.Length];\n for (int i = 0; i < array.Length; i++)\n result[i] = int.Parse(array[i]);\n return result;\n }\n\n public long[] LongArray() {\n var array = Array();\n var result = new long[array.Length];\n for (int i = 0; i < array.Length; i++)\n result[i] = long.Parse(array[i]);\n return result;\n }\n\n public ulong[] UlongArray() {\n var array = Array();\n var result = new ulong[array.Length];\n for (int i = 0; i < array.Length; i++)\n result[i] = ulong.Parse(array[i]);\n return result;\n }\n}", "lang_cluster": "C#", "tags": ["math", "constructive algorithms"], "code_uid": "aff7ed5bdf1a38d425d9af656f4aeac3", "src_uid": "c30b372a9cc0df4948dca48ef4c5d80d", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\n\t\t\t\t\t\npublic class Program\n{\n\tpublic static void Main()\n\t{\n\t\tint[] tmp = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);\n\t\tstring s = Console.ReadLine();\n\t\t\n\t\tint n = tmp[0];\n\t\tint d = tmp[1];\n\t\tstring str = \"\";\n\t\t\n\t\tfor(int j=0; j < d; j++)\n\t\t{\n\t\t \tstr += \"0\";\n\t\t}\n\t\t\n\t\tif(s.IndexOf(str) > -1)\n\t\t{\n\t\t\tConsole.WriteLine(-1);\n\t\t\treturn;\n\t\t}\n\t\t\n\t\tint i = 0;\n\t\tint count = 0;\n\t\twhile(i < n-1)\n\t\t{\n\t\t\tif(s[i] == '1')\n\t\t\t{\n\t\t\t i += d;\n\t\t\t\tcount++;\n\t\t\t}\n\t\t\telse\n\t\t\t i--;\n\t\t}\n\t\tConsole.WriteLine(count);\n\t\t\n\t}\n}", "lang_cluster": "C#", "tags": ["dfs and similar", "greedy", "dp", "implementation"], "code_uid": "a63a899282d5f7062a40463a90b0e849", "src_uid": "c08d2ecdfc66cd07fbbd461b1f069c9e", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\nusing System.Numerics;\n\nnamespace CodeForces\n{\n class Program\n {\n \n static void Main(string[] args)\n {\n string firstLine = Console.ReadLine();\n string[] numbers = firstLine.Split(' ');\n\n int wordLength =int.Parse(numbers[0]);\n int MaxJump = int.Parse(numbers[1]);\n int next = 0;\n string way = Console.ReadLine();\n int steps=0;\n bool outofrange=false;\n\n for (int pointer = 0; pointer < wordLength-1; )\n {\n //Bring Maximum 1 after My Jump\n next = pointer + MaxJump;\n\n if (next < wordLength && way[next] == '1')\n {\n steps++;\n pointer = next;\n }\n else\n {\n int j;\n if (next > wordLength)\n {\n steps++;\n break;\n }\n for ( j = next-1; j > pointer; j--)\n {\n if (j\n {\n public int Compare(int x, int y)\n {\n int v = d[x].CompareTo(d[y]);\n return v != 0 ? v : x.CompareTo(y);\n }\n }\n\n const int N = 80;\n\n static int[] di = new int[4] { 0, 0, -1, 1 };\n static int[] dj = new int[4] { -1, 1, 0, 0 };\n\n static int n, m;\n static int[,] a = new int[N, N];\n\n static int[] d = new int[N * N + 2];\n static int[] phi = new int[N * N + 2];\n static int[] parent = new int[N * N + 2];\n static int[] numEdge = new int[N * N + 2];\n static List[] G = new List[N * N + 2];\n static SortedSet sVertex = new SortedSet(new CompareVertex());\n static int minCost = 0;\n\n static void AddEdge(int from, int to, int cap, int cost)\n {\n G[from].Add(new Flow(to, cap, 0, cost, G[to].Count));\n G[to].Add(new Flow(from, 0, 0, -cost, G[from].Count - 1));\n }\n\n static bool FindPath(int from, int to)\n {\n for (int i = 0; i <= to; ++i)\n {\n d[i] = int.MaxValue;\n }\n int v;\n sVertex.Clear();\n d[from] = 0;\n sVertex.Add(from);\n while (sVertex.Count > 0)\n {\n v = sVertex.Min;\n sVertex.Remove(v);\n\n for (int i = 0; i < G[v].Count; ++i)\n {\n var f = G[v][i];\n if (f.flow < f.capacity && d[f.to] > d[v] + f.cost - phi[v] + phi[f.to])\n {\n if (sVertex.Contains(f.to))\n {\n sVertex.Remove(f.to);\n }\n d[f.to] = d[v] + f.cost - phi[v] + phi[f.to];\n sVertex.Add(f.to);\n parent[f.to] = v;\n numEdge[f.to] = i;\n }\n }\n }\n\n if (d[to] == int.MaxValue)\n {\n return false;\n }\n for (int i = 0; i <= to; ++i)\n {\n if (d[i] != int.MaxValue)\n {\n phi[i] += d[i]; \n }\n }\n v = to;\n int flow = int.MaxValue;\n while (v != from)\n {\n int u = parent[v];\n flow = Math.Min(flow, G[u][numEdge[v]].capacity - G[u][numEdge[v]].flow);\n v = u;\n }\n\n v = to;\n while(v != from)\n {\n int u = parent[v];\n G[u][numEdge[v]].flow += flow;\n G[v][G[u][numEdge[v]].iRevEdge].flow -= flow;\n minCost += flow * G[u][numEdge[v]].cost;\n v = u;\n }\n return true;\n\n }\n \n\n static void Main(string[] args)\n {\n var t = Console.ReadLine().Split(' ');\n n = int.Parse(t[0]);\n m = int.Parse(t[1]);\n for (int i = 0; i < n; ++i)\n {\n t = Console.ReadLine().Split(' ');\n for (int j = 0; j < m; ++j)\n {\n a[i, j] = int.Parse(t[j]);\n }\n }\n int from = n * m;\n int to = n * m + 1;\n for (int i = 0; i <= to; ++i)\n {\n phi[i] = 0;\n G[i] = new List();\n }\n\n for (int i = 0; i < n; ++i)\n {\n for (int j = 0; j < m; ++j)\n {\n if ((i + j) % 2 == 0)\n {\n AddEdge(from, i * m + j, 1, 0);\n for (int k = 0; k < 4; ++k)\n {\n int ei = i + di[k];\n int ej = j + dj[k];\n if (ei >= 0 && ei < n && ej >= 0 && ej < m)\n {\n AddEdge(i * m + j, ei * m + ej, 1, a[i, j] == a[ei, ej] ? 0 : 1);\n }\n }\n }\n else\n {\n AddEdge(i * m + j, to, 1, 0);\n }\n\n }\n }\n\n while (FindPath(from, to)) { }\n\n Console.WriteLine(minCost);\n\n Console.Read();\n }\n\n }\n}", "lang_cluster": "C#", "tags": ["flows"], "code_uid": "522700af98cc0f18f4b1614814c97471", "src_uid": "1f0e8bbd5bf4fcdea927fbb505a8949b", "difficulty": 2200.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Globalization;\nusing System.IO;\nusing System.Linq;\nusing System.Text;\nusing System.Threading;\n\n// (\u3065\u00b0\u03c9\u00b0)\u3065\uff90\u2605\u309c\u30fb\u3002\u3002\u30fb\u309c\u309c\u30fb\u3002\u3002\u30fb\u309c\u2606\u309c\u30fb\u3002\u3002\u30fb\u309c\u309c\u30fb\u3002\u3002\u30fb\u309c\npublic class Solver\n{\n class Edge\n {\n public int To, Inv;\n public T Capacity, Cost, Flow;\n public Edge(int to, int inv, T capacity, T cost, T flow)\n {\n To = to;\n Inv = inv;\n Capacity = capacity;\n Cost = cost;\n Flow = flow;\n }\n }\n\n static void AddEdge(List>[] g, int from, int to, int capacity, int cost)\n {\n g[from].Add(new Edge(to, g[to].Count, capacity, cost, 0));\n g[to].Add(new Edge(from, g[from].Count - 1, 0, -cost, 0));\n }\n\n int MinCost(List>[] g, int source, int sink, int limit)\n {\n const int INF = int.MaxValue / 2;\n\n int n = g.Length;\n int flow = 0, cost = 0;\n while (flow < limit)\n {\n var id = new int[n];\n var dist = Enumerable.Repeat(INF, n).ToArray();\n var q = new int[n];\n var path = new int[n];\n var epath = new int[n];\n int qh = 0, qt = 0;\n q[qt++] = source;\n dist[source] = 0;\n while (qh != qt)\n {\n int v = q[qh++];\n if (qh == n)\n qh = 0;\n id[v] = 2;\n for (int i = 0; i < g[v].Count; i++)\n {\n var r = g[v][i];\n if (r.Flow < r.Capacity && dist[v] + r.Cost < dist[r.To])\n {\n dist[r.To] = dist[v] + r.Cost;\n if (id[r.To] == 0)\n {\n q[qt++] = r.To;\n if (qt == n)\n qt = 0;\n }\n else if (id[r.To] == 2)\n {\n if (--qh == -1)\n qh = n - 1;\n q[qh] = r.To;\n }\n id[r.To] = 1;\n path[r.To] = v;\n epath[r.To] = i;\n }\n }\n }\n if (dist[sink] == INF)\n break;\n int addflow = limit - flow;\n for (int v = sink; v != source; v = path[v])\n {\n int pv = path[v];\n int pr = epath[v];\n addflow = Math.Min(addflow, g[pv][pr].Capacity - g[pv][pr].Flow);\n }\n for (int v = sink; v != source; v = path[v])\n {\n int pv = path[v];\n int pr = epath[v], r = g[pv][pr].Inv;\n g[pv][pr].Flow += addflow;\n g[v][r].Flow -= addflow;\n cost += g[pv][pr].Cost * addflow;\n }\n flow += addflow;\n }\n return cost;\n }\n\n private int[] dr = {1, 0, -1, 0};\n private int[] dc = {0, 1, 0, -1};\n\n public void Solve()\n {\n int n = ReadInt();\n int m = ReadInt();\n var a = ReadIntMatrix(n);\n\n var g = Enumerable.Repeat(0, n * m + 2).Select(x => new List>()).ToArray();\n for (int i = 0; i < n; i++)\n for (int j = 0; j < m; j++)\n {\n int x = i * m + j;\n if ((i + j) % 2 == 0)\n {\n AddEdge(g, n * m, x, 1, 0);\n for (int k = 0; k < 4; k++)\n {\n int ii = i + dr[k];\n int jj = j + dc[k];\n if (ii < 0 || ii == n || jj < 0 || jj == m)\n continue;\n AddEdge(g, x, ii * m + jj, 1, a[i][j] == a[ii][jj] ? 0 : 1);\n }\n }\n else\n {\n AddEdge(g, x, n * m + 1, 1, 0);\n }\n }\n\n Write(MinCost(g, n * m, n * m + 1, n * m / 2));\n }\n \n #region Main\n\n protected static TextReader reader;\n protected static TextWriter writer;\n\n static void Main()\n {\n#if DEBUG\n reader = new StreamReader(\"..\\\\..\\\\input.txt\");\n writer = Console.Out;\n //writer = new StreamWriter(\"..\\\\..\\\\output.txt\");\n#else\n reader = new StreamReader(Console.OpenStandardInput());\n writer = new StreamWriter(Console.OpenStandardOutput());\n //reader = new StreamReader(\"game.in\");\n //writer = new StreamWriter(\"game.out\");\n#endif\n try\n {\n var thread = new Thread(new Solver().Solve, 1024 * 1024 * 256);\n thread.Start();\n thread.Join();\n //new Solver().Solve();\n }\n catch (Exception ex)\n {\n#if DEBUG\n Console.WriteLine(ex);\n#else\n Console.WriteLine(ex);\n throw;\n#endif\n }\n reader.Close();\n writer.Close();\n }\n\n #endregion\n\n #region Read / Write\n\n private static Queue currentLineTokens = new Queue();\n\n private static string[] ReadAndSplitLine()\n {\n return reader.ReadLine().Split(new[] { ' ', '\\t' }, StringSplitOptions.RemoveEmptyEntries);\n }\n\n public static string ReadToken()\n {\n while (currentLineTokens.Count == 0)\n currentLineTokens = new Queue(ReadAndSplitLine());\n return currentLineTokens.Dequeue();\n }\n\n public static int ReadInt()\n {\n return int.Parse(ReadToken());\n }\n\n public static long ReadLong()\n {\n return long.Parse(ReadToken());\n }\n\n public static double ReadDouble()\n {\n return double.Parse(ReadToken(), CultureInfo.InvariantCulture);\n }\n\n public static int[] ReadIntArray()\n {\n return ReadAndSplitLine().Select(int.Parse).ToArray();\n }\n\n public static long[] ReadLongArray()\n {\n return ReadAndSplitLine().Select(long.Parse).ToArray();\n }\n\n public static double[] ReadDoubleArray()\n {\n return ReadAndSplitLine().Select(s => double.Parse(s, CultureInfo.InvariantCulture)).ToArray();\n }\n\n public static int[][] ReadIntMatrix(int numberOfRows)\n {\n int[][] matrix = new int[numberOfRows][];\n for (int i = 0; i < numberOfRows; i++)\n matrix[i] = ReadIntArray();\n return matrix;\n }\n\n public static int[][] ReadAndTransposeIntMatrix(int numberOfRows)\n {\n int[][] matrix = ReadIntMatrix(numberOfRows);\n int[][] ret = new int[matrix[0].Length][];\n for (int i = 0; i < ret.Length; i++)\n {\n ret[i] = new int[numberOfRows];\n for (int j = 0; j < numberOfRows; j++)\n ret[i][j] = matrix[j][i];\n }\n return ret;\n }\n\n public static string[] ReadLines(int quantity)\n {\n string[] lines = new string[quantity];\n for (int i = 0; i < quantity; i++)\n lines[i] = reader.ReadLine().Trim();\n return lines;\n }\n\n public static void WriteArray(IEnumerable array)\n {\n writer.WriteLine(string.Join(\" \", array));\n }\n\n public static void Write(params object[] array)\n {\n WriteArray(array);\n }\n\n public static void WriteLines(IEnumerable array)\n {\n foreach (var a in array)\n writer.WriteLine(a);\n }\n\n #endregion\n}", "lang_cluster": "C#", "tags": ["flows"], "code_uid": "f2284ae1e2b5d708e55737461ec88032", "src_uid": "1f0e8bbd5bf4fcdea927fbb505a8949b", "difficulty": 2200.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Text;\nusing System.Collections.Generic;\nusing System.Linq;\nclass Solve{\n public Solve(){}\n StringBuilder sb;\n public static int Main(){\n new Solve().Run();\n return 0;\n }\n void Run(){\n sb = new StringBuilder();\n Calc();\n Console.Write(sb.ToString());\n }\n void Calc(){\n string[] str = Console.ReadLine().Split(' ');\n int H = int.Parse(str[0]);\n int W = int.Parse(str[1]);\n int[,] D = new int[H,W];\n for(int i=0;i F = new List();\n List T = new List();\n List capacity = new List();\n List cost = new List();\n for(int i=0;i edges;\n public void AddEdge(Edge e){\n edges.Add(e);\n }\n public Vertex(){\n edges = new List();\n finished = false;\n cost = -1;\n }\n}\nstruct Data{\n public Vertex v;\n public long cost;\n public Data(Vertex v0,long c){\n v = v0;\n cost = c;\n }\n}\nclass MinCostFlow{\n Vertex[] point;\n Vertex S;\n Vertex G;\n public long res;\n int E;\n const long INF = 1000000000000000;\n public MinCostFlow(int[] f,int[] t,long[] capacity,long[] cost,int n,int s,int g,long flow){\n point = new Vertex[n];\n for(int i=0;i V.cost + V.edges[i].cost + V.h - T.h){\n T.cost = V.cost + V.edges[i].cost + V.h - T.h;\n T.fromv = V;\n T.frome = V.edges[i];\n H.push(new Data(T,T.cost));\n }\n }\n }\n if(G.cost == -1){\n res = -1;\n break;\n }\n for(int i=0;i 0){\n int p = (i - 1)/2;\n if(obj[p].cost <= a.cost){\n obj[i] = a;\n break;\n }\n obj[i] = obj[p];\n i = p;\n }\n if(i == 0){\n obj[0] = a;\n }\n }\n public bool Empty(){\n return size == 0;\n }\n public Data pop(){\n Data t = obj[0];\n int i = 0;\n size--;\n while(2*i+1 < size){\n int p = 2*i+1;\n if(p+1 < size && obj[p+1].cost < obj[p].cost){\n p++;\n }\n if(obj[p].cost < obj[size].cost){\n obj[i] = obj[p];\n i = p;\n }\n else{\n obj[i] = obj[size];\n break;\n }\n }\n if(2*i+1 >= size){\n obj[i] = obj[size];\n }\n return t;\n }\n}", "lang_cluster": "C#", "tags": ["flows"], "code_uid": "54512255d3f5db8151ece94b177d0b03", "src_uid": "1f0e8bbd5bf4fcdea927fbb505a8949b", "difficulty": 2200.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections;\nusing System.Collections.Generic;\n\nclass Myon\n{\n public Myon() { }\n public static int Main()\n {\n new Myon().solve();\n return 0;\n }\n\n void solve()\n {\n Scanner cin = new Scanner();\n\n int h = cin.nextInt();\n int w = cin.nextInt();\n int[,] board = new int[h, w];\n for (int i = 0; i < h; i++)\n {\n for (int j = 0; j < w; j++)\n {\n board[i, j] = cin.nextInt();\n }\n }\n\n int MAX = 1 << w;\n int[] dp = new int[MAX];\n for (int i = 0; i < MAX; i++)\n {\n dp[i] = 1 << 16;\n }\n dp[0] = 0;\n\n for (int i = 0; i < h; i++)\n {\n for (int j = 0; j < w; j++)\n {\n int[] nextdp = new int[MAX];\n for (int k = 0; k < MAX; k++)\n {\n nextdp[k] = 1 << 16;\n }\n\n for (int k = 0; k < MAX; k++)\n {\n if (k % 2 == 0)\n {\n if (j != w - 1)\n {\n int add = 0;\n if (board[i, j] != board[i, j + 1]) add = 1;\n int next = k / 2 + 1;\n nextdp[next] = Math.Min(nextdp[next], dp[k] + add);\n }\n if (i != h - 1)\n {\n int add = 0;\n if (board[i, j] != board[i + 1, j]) add = 1;\n int next = k / 2 + (1 << (w - 1));\n nextdp[next] = Math.Min(nextdp[next], dp[k] + add);\n }\n }\n else\n {\n nextdp[k / 2] = Math.Min(nextdp[k / 2], dp[k]);\n }\n }\n dp = nextdp;\n }\n }\n Console.WriteLine(dp[0]);\n\n }\n\n \n}\n\n\n\nclass Scanner\n{\n string[] s;\n int i;\n\n char[] cs = new char[] { ' ' };\n\n public Scanner()\n {\n s = new string[0];\n i = 0;\n }\n\n public string next()\n {\n if (i < s.Length) return s[i++];\n s = Console.ReadLine().Split(cs, StringSplitOptions.RemoveEmptyEntries);\n i = 0;\n return s[i++];\n }\n\n public int nextInt()\n {\n return int.Parse(next());\n }\n\n public long nextLong()\n {\n return long.Parse(next());\n }\n}\n", "lang_cluster": "C#", "tags": ["flows"], "code_uid": "d8b367e5970a96bd5d772728bd6311cf", "src_uid": "1f0e8bbd5bf4fcdea927fbb505a8949b", "difficulty": 2200.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeff\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nclass Solver\n{\n void Solve()\n {\n var n = sc.Integer();\n var m = sc.Integer();\n var hori = sc.ScanLine().Select(x => x == '>' ? 1 : -1).ToArray();\n var ver = sc.ScanLine().Select(x => x == 'v' ? 1 : -1).ToArray();\n for (int r = 0; r < n; r++)\n {\n for (int c = 0; c < m; c++)\n {\n var used = new bool[n, m];\n var qr = new Queue();\n var qc = new Queue();\n qr.Enqueue(r);\n qc.Enqueue(c);\n while (qr.Any())\n {\n var pr = qr.Dequeue();\n var pc = qc.Dequeue();\n if (used[pr, pc]) continue;\n used[pr, pc] = true;\n //horizon\n {\n var nc = pc + hori[pr];\n if (nc < 0 || nc >= m || used[pr, nc]) { }\n else\n {\n qr.Enqueue(pr);\n qc.Enqueue(nc);\n }\n\n }\n //vertical\n {\n var nr = pr + ver[pc];\n if (nr < 0 || nr >= n || used[nr, pc]) { }\n else\n {\n qr.Enqueue(nr);\n qc.Enqueue(pc);\n }\n }\n }\n for (int i = 0; i < n; i++)\n for (int j = 0; j < m; j++)\n if (!used[i, j])\n {\n Printer.PrintLine(\"NO\");\n return;\n }\n }\n }\n Printer.PrintLine(\"YES\");\n }\n\n static void Main()\n {\n#if DEBUG\n var ostream = new System.IO.FileStream(\"debug.txt\", System.IO.FileMode.Create, System.IO.FileAccess.Write);\n var iStream = new System.IO.FileStream(\"input.txt\", System.IO.FileMode.Open, System.IO.FileAccess.Read, System.IO.FileShare.ReadWrite);\n Console.SetIn(new System.IO.StreamReader(iStream));\n System.Diagnostics.Debug.AutoFlush = true;\n System.Diagnostics.Debug.Listeners.Add(new System.Diagnostics.TextWriterTraceListener(new System.IO.StreamWriter(ostream, System.Text.Encoding.UTF8)));\n try\n {\n#endif\n var solver = new Solver();\n solver.Solve();\n#if DEBUG\n }\n catch (Exception ex)\n {\n Console.WriteLine(ex.Message);\n Console.WriteLine(ex.StackTrace);\n }\n Console.ReadKey(true);\n#endif\n }\n _Scanner sc = new _Scanner();\n\n}\n\nstatic public class Printer\n{\n static readonly private System.IO.TextWriter writer;\n static readonly private System.Globalization.CultureInfo info;\n static string Separator { get; set; }\n static Printer()\n {\n writer = Console.Out;\n info = System.Globalization.CultureInfo.InvariantCulture;\n Separator = \" \";\n }\n\n static public void Print(int num) { writer.Write(num.ToString(info)); }\n static public void Print(int num, string format) { writer.Write(num.ToString(format, info)); }\n static public void Print(long num) { writer.Write(num.ToString(info)); }\n static public void Print(long num, string format) { writer.Write(num.ToString(format, info)); }\n static public void Print(double num) { writer.Write(num.ToString(info)); }\n static public void Print(double num, string format) { writer.Write(num.ToString(format, info)); }\n static public void Print(string str) { writer.Write(str); }\n static public void Print(string format, params object[] arg) { writer.Write(format, arg); }\n static public void Print(IEnumerable sources) { writer.Write(sources.AsString()); }\n static public void Print(params object[] arg)\n {\n var res = new System.Text.StringBuilder();\n foreach (var x in arg)\n {\n res.AppendFormat(info, \"{0}\", x);\n if (!string.IsNullOrEmpty(Separator))\n res.Append(Separator);\n }\n writer.Write(res.ToString(0, res.Length - Separator.Length));\n }\n static public void Print(IEnumerable sources)\n {\n var res = new System.Text.StringBuilder();\n foreach (var x in sources)\n {\n res.AppendFormat(info, \"{0}\", x);\n if (string.IsNullOrEmpty(Separator))\n res.Append(Separator);\n }\n writer.Write(res.ToString(0, res.Length - Separator.Length));\n }\n static public void PrintLine(int num) { writer.WriteLine(num.ToString(info)); }\n static public void PrintLine(int num, string format) { writer.WriteLine(num.ToString(format, info)); }\n static public void PrintLine(long num) { writer.WriteLine(num.ToString(info)); }\n static public void PrintLine(long num, string format) { writer.WriteLine(num.ToString(format, info)); }\n static public void PrintLine(double num) { writer.WriteLine(num.ToString(info)); }\n static public void PrintLine(double num, string format) { writer.WriteLine(num.ToString(format, info)); }\n static public void PrintLine(string str) { writer.WriteLine(str); }\n static public void PrintLine(string format, params object[] arg) { writer.WriteLine(format, arg); }\n static public void PrintLine(IEnumerable sources) { writer.WriteLine(sources.AsString()); }\n static public void PrintLine(params object[] arg)\n {\n var res = new System.Text.StringBuilder();\n foreach (var x in arg)\n {\n res.AppendFormat(info, \"{0}\", x);\n if (!string.IsNullOrEmpty(Separator))\n res.Append(Separator);\n }\n writer.WriteLine(res.ToString(0, res.Length - Separator.Length));\n }\n static public void PrintLine(IEnumerable sources)\n {\n var res = new System.Text.StringBuilder();\n foreach (var x in sources)\n {\n res.AppendFormat(info, \"{0}\", x);\n if (!string.IsNullOrEmpty(Separator))\n res.Append(Separator);\n }\n writer.WriteLine(res.ToString(0, res.Length - Separator.Length));\n }\n static public void PrintLine(System.Linq.Expressions.Expression> ex)\n {\n var res = ex.Parameters[0];\n writer.WriteLine(res.Name);\n }\n}\npublic class _Scanner\n{\n readonly private System.Globalization.CultureInfo info;\n readonly System.IO.TextReader reader;\n string[] buffer = new string[0];\n int position;\n\n public char[] Separator { get; set; }\n public _Scanner(System.IO.TextReader reader = null, string separator = null, System.Globalization.CultureInfo info = null)\n {\n\n this.reader = reader ?? Console.In;\n if (string.IsNullOrEmpty(separator))\n separator = \" \";\n this.Separator = separator.ToCharArray();\n this.info = info ?? System.Globalization.CultureInfo.InvariantCulture;\n }\n public string Scan()\n {\n if (this.position < this.buffer.Length)\n return this.buffer[this.position++];\n this.buffer = this.reader.ReadLine().Split(this.Separator, StringSplitOptions.RemoveEmptyEntries);\n this.position = 0;\n return this.buffer[this.position++];\n }\n\n public string[] ScanToEndLine()\n {\n if (this.position >= this.buffer.Length)\n return this.reader.ReadLine().Split(this.Separator, StringSplitOptions.RemoveEmptyEntries);\n var size = this.buffer.Length - this.position;\n var ar = new string[size];\n Array.Copy(this.buffer, position, ar, 0, size);\n return ar;\n\n }\n\n public string ScanLine()\n {\n if (this.position >= this.buffer.Length)\n return this.reader.ReadLine();\n else\n {\n var sb = new System.Text.StringBuilder();\n for (; this.position < buffer.Length; this.position++)\n {\n sb.Append(this.buffer[this.position]);\n sb.Append(' ');\n }\n return sb.ToString();\n }\n }\n public string[] ScanArray(int length)\n {\n var ar = new string[length];\n for (int i = 0; i < length; i++)\n {\n ar[i] = this.Scan();\n }\n return ar;\n }\n\n public int Integer()\n {\n return int.Parse(this.Scan(), info);\n }\n public long Long()\n {\n return long.Parse(this.Scan(), info);\n }\n public double Double()\n {\n return double.Parse(this.Scan(), info);\n }\n public double Double(string str)\n {\n return double.Parse(str, info);\n }\n\n public int[] IntArray(int length)\n {\n var a = new int[length];\n for (int i = 0; i < length; i++)\n a[i] = this.Integer();\n return a;\n }\n public long[] LongArray(int length)\n {\n var a = new long[length];\n for (int i = 0; i < length; i++)\n a[i] = this.Long();\n return a;\n }\n public double[] DoubleArray(int length)\n {\n var a = new double[length];\n for (int i = 0; i < length; i++)\n a[i] = this.Double();\n return a;\n }\n\n}\nstatic public partial class EnumerableEx\n{\n static public string AsString(this IEnumerable source)\n {\n return new string(source.ToArray());\n }\n static public IEnumerable Enumerate(this int count, Func selector)\n {\n return Enumerable.Range(0, count).Select(x => selector(x));\n }\n}\n", "lang_cluster": "C#", "tags": ["dfs and similar", "implementation", "graphs", "brute force"], "code_uid": "7034804bf93e0b17efffeeb3575ec946", "src_uid": "eab5c84c9658eb32f5614cd2497541cf", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\n\nnamespace _475B\n{\n class Program\n {\n static void Main(string[] args)\n {\n string[] str = Console.ReadLine().Split(' ');\n int n = int.Parse(str[0]);\n int m = int.Parse(str[1]);\n str[0] = Console.ReadLine();\n str[1] = Console.ReadLine();\n string result = String.Join(null, str[0][0], str[0][n - 1], str[1][0], str[1][m - 1]);\n if (result.Equals(\"<>v^\") || result.Equals(\"><^v\"))\n {\n Console.WriteLine(\"YES\");\n }\n else\n {\n Console.WriteLine(\"NO\");\n }\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["dfs and similar", "implementation", "graphs", "brute force"], "code_uid": "1c16eba5e4f68d4cb2b544c9b4bae666", "src_uid": "eab5c84c9658eb32f5614cd2497541cf", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\n// you can also use other imports, for example:\nusing System.Collections.Generic;\nusing System.Linq;\n\n// you can write to stdout for debugging purposes, e.g.\n// Console.WriteLine(\"this is a debug message\");\n\n//mcs HelloWorld.cs\n//mono HelloWorld.exe\npublic class HelloWorld {\n\t\n\tpublic static void Main(string[] args)\n\t{\n\t\tvar arr = Array.ConvertAll(Console.ReadLine().Split(' '), t=> Convert.ToInt32(t));\n\t\tsolve(arr);\n\t\t//tests();\n\t}\n\n\n\tpublic static void solve(int[] ar)\n\t{ \t\n\t\tvar n = ar.Length;\n\t\t\n\t\tlong max= 0;\n\t\tfor (var ind = 0; ind < n; ind++)\n\t\t{\n\t\t\tif (ar[ind] == 0)\n\t\t\t\tcontinue;\n\n\t\t\tvar arr = new int[n];\n\t\t\tArray.Copy(ar,arr,n);\n\t\t\tvar p = arr[ind] / 14;\n\t\t\tvar k = arr[ind] % 14;\n\t\t\tarr[ind] = 0;\n\t\t\tif (p > 0)\n\t\t\t{\n\t\t\t\tfor (var i = 0; i < n; i++)\n\t\t\t\t{\n\t\t\t\t\tarr[i] = arr[i] + p;\n\t\t\t\t}\n\t\t\t}\n\t\t\t//Console.WriteLine( p + \" \" + k);\n\t\t\tif (k > 0)\n\t\t\t{\n\t\t\t\tfor (var i = ind + 1; i < Math.Min(n, ind + k + 1); i++)\n\t\t\t\t{\n\t\t\t\t\tarr[i] += 1;\n\t\t\t\t}\n\t\t\t\tif (ind + k + 1 > n)\n\t\t\t\t{\n\t\t\t\t\tfor (var i = 0; i <= ind + k - n; i++)\n\t\t\t\t\t{\n\t\t\t\t\t\tarr[i] += 1;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tlong sum = 0;\n\t\t\tfor (var i = 0; i < n; i++)\n\t\t\t{\n\t\t\t\t//Console.Write(arr[i] + \" \");\n\t\t\t\tif (arr[i] % 2 == 0)\n\t\t\t\t{\n\t\t\t\t\tsum+= arr[i];\n\t\t\t\t}\n\t\t\t}\n\t\t\tmax = Math.Max(sum, max);\n\t\t}\n\t\tConsole.WriteLine(max);\n\n\n\t}\n \t\n}", "lang_cluster": "C#", "tags": ["brute force", "implementation"], "code_uid": "7e79c2fc5a23341e9c08588686baf3a1", "src_uid": "1ac11153e35509e755ea15f1d57d156b", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\n\nnamespace _a\n{\n class MainClass\n {\n public static void Main(string[] args)\n {\n long[] Arr = new long[14];\n string[] Input = Console.ReadLine().Split();\n for (int i = 0; i < 14; i++) Arr[i] = Convert.ToInt64(Input[i]);\n\n long Max = 0;\n for (int i = 0; i < 14; i++)\n {\n if (Arr[i] != 0)\n {\n long[] ArrW = new long[14]; \n Array.Copy(Arr, ArrW, 14);\n long K = ArrW[i % 14] % 14;\n long T = ArrW[i % 14];\n ArrW[i % 14] = 0;\n for (int j = 0; j < 14; j++)\n {\n ArrW[(i + j + 1) % 14] += T / 14 ;\n }\n\n for (int j = 1; j <= K; j++)\n {\n ArrW[(i + j) % 14]++;\n }\n\n\n long Res = 0;\n for (int j = 0; j < 14; j++)\n {\n if (ArrW[j] % 2 == 0)\n {\n Res += ArrW[j];\n }\n }\n\n if (Res > Max) Max = Res;\n }\n }\n\n Console.WriteLine(Max);\n }\n }\n}", "lang_cluster": "C#", "tags": ["brute force", "implementation"], "code_uid": "c3335f09b6d1359cf2520adbee1f2fb2", "src_uid": "1ac11153e35509e755ea15f1d57d156b", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeff\ufeff\ufeff\ufeff\ufeff\ufeff\ufeff\ufeff\ufeff\ufeff#define EXTENDSTACKSIZE\n\n\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Globalization;\nusing System.IO;\nusing System.Linq;\nusing System.Text;\nusing System.Threading;\n\nnamespace CF\n{\n internal class Program\n {\n private const int stackSize = 64 * 1024 * 1024;\n \n private static void Run()\n {\n using (var sr = new InputReader(Console.In))\n// using (var sr = new InputReader(new StreamReader(\"input.txt\")))\n using (var sw = Console.Out)\n// using (var sw = new StreamWriter(\"output.txt\"))\n using (var task = new Task(sr, sw)) {\n task.Solve();\n// Console.ReadKey();\n }\n }\n \n private static void Main(string[] args)\n {\n#if EXTENDSTACKSIZE\n var threadStart = new ThreadStart(Run);\n var thread = new Thread(threadStart, stackSize);\n thread.Start();\n thread.Join();\n#else\n Run();\n#endif\n }\n }\n\n internal class Task : IDisposable\n {\n private readonly InputReader sr;\n private readonly TextWriter sw;\n private bool isDispose;\n \n public Task(InputReader sr, TextWriter sw)\n {\n this.sr = sr;\n this.sw = sw;\n }\n \n public void Solve()\n {\n Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;\n Thread.CurrentThread.CurrentUICulture = CultureInfo.InvariantCulture;\n var s1 = sr.NextString().Split(new[] {':'});\n var h1 = int.Parse(s1[0]);\n var m1 = int.Parse(s1[1]);\n var s2 = sr.NextString().Split(new[] {':'});\n var h2 = int.Parse(s2[0]);\n var m2 = int.Parse(s2[1]);\n var d1 = new DateTime(1, 1, 1, h1, m1, 0);\n var d2 = new DateTime(1, 1, 1, h2, m2, 0);\n var d = (d2 - d1).Ticks / 2;\n var d3 = d1.AddTicks(d);\n var h = d3.Hour.ToString();\n var m = d3.Minute.ToString();\n if (h.Length == 1)\n {\n h = \"0\" + h;\n }\n\n if (m.Length == 1)\n {\n m = \"0\" + m;\n }\n sw.WriteLine(h + \":\" + m);\n }\n \n public void Dispose()\n {\n Dispose(true);\n GC.SuppressFinalize(this);\n }\n \n private void Dispose(bool disposing)\n {\n if (!isDispose) {\n if (disposing) {\n if(sr != null)\n sr.Dispose();\n \n if(sw != null)\n sw.Dispose();\n }\n\n isDispose = true;\n }\n }\n }\n}\n \ninternal class InputReader : IDisposable\n{\n private bool isDispose;\n private readonly TextReader sr;\n private string[] buffer;\n private int seek;\n\n public InputReader(TextReader stream)\n {\n sr = stream;\n }\n\n public void Dispose()\n {\n Dispose(true);\n GC.SuppressFinalize(this);\n }\n\n public string NextString()\n {\n var result = sr.ReadLine();\n return result;\n }\n\n public int NextInt32()\n {\n return Int32.Parse(ReadNextToken());\n }\n\n private string ReadNextToken()\n {\n if (buffer == null || seek == buffer.Length) {\n seek = 0;\n buffer = NextSplitStrings();\n }\n\n return buffer[seek++];\n }\n\n public long NextInt64()\n {\n return Int64.Parse(ReadNextToken());\n }\n \n public int[] ReadArrayOfInt32()\n {\n return ReadArray(Int32.Parse);\n }\n\n public long[] ReadArrayOfInt64()\n {\n return ReadArray(Int64.Parse);\n }\n\n public string[] NextSplitStrings()\n {\n return NextString()\n .Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);\n }\n\n public T[] ReadArray(Func func)\n {\n return NextSplitStrings()\n .Select(s => func(s, CultureInfo.InvariantCulture))\n .ToArray();\n }\n\n public T[] ReadArrayFromString(Func func, string str)\n {\n return\n str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)\n .Select(s => func(s, CultureInfo.InvariantCulture))\n .ToArray();\n }\n\n protected void Dispose(bool dispose)\n {\n if (!isDispose)\n {\n if (dispose)\n sr.Close();\n \n isDispose = true;\n }\n }\n\n ~InputReader()\n {\n Dispose(false);\n }\n}", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "4e0907bc4db096bbe1b3286d93f58800", "src_uid": "f7a32a8325ce97c4c50ce3a5c282ec50", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\n\nnamespace Task1\n{\n class Program\n {\n static void Main(string[] args)\n {\n List time0 = Console.ReadLine().Split(':').ToList().ConvertAll(int.Parse);\n int minutsBegin = 60 * time0[0] + time0[1];\n List timeK = Console.ReadLine().Split(':').ToList().ConvertAll(int.Parse);\n int minutsEnd = 60 * timeK[0] + timeK[1];\n int minuteAverage = (minutsBegin + minutsEnd) / 2;\n int hourEnd = minuteAverage / 60;\n int minuteEnd = minuteAverage % 60;\n Console.WriteLine(String.Format(\"{0:00}\", hourEnd)+\":\"+ String.Format(\"{0:00}\", minuteEnd));\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "c5e3d4b3f31abef86325175ba62a2c79", "src_uid": "f7a32a8325ce97c4c50ce3a5c282ec50", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace ConsoleApplication15\n{\n class Program\n {\n static int Main(string[] args)\n {\n string[] inArr = Console.ReadLine().Split(' ');\n int n = int.Parse(inArr[0]),\n m = int.Parse(inArr[1]);\n int[] originalArr = new int[n];\n for (int i = 0; i < n; i++)\n originalArr[i] = i + 1;\n string[] allArrays= new string[factorial(n)];\n for (int i=0; i maxFp) maxFp = fP;\n }\n int curM = 1;\n for (int i = 0; i < allArrays.Length; i++)\n {\n if (allFp[i] == maxFp)\n {\n\n if (curM == m)\n {\n Console.Write(allArrays[i]);\n break;\n }\n curM++;\n }\n }\n return 0;\n }\n static string getNumbers(int[] nums, long cur)\n {\n\n int size = nums.Length;\n if (size == 1) return Convert.ToString(nums[0]);\n long amount = factorial(size);\n long ind = (long)(cur / (amount / size));\n int[] newNums = new int[size - 1];\n int Tx = 0;\n for (int x = 0; x < size; x++)\n {\n if (x == ind)\n continue;\n newNums[Tx] = nums[x];\n Tx++;\n }\n return nums[ind] + \" \" + getNumbers(newNums, (cur - (amount / size) * ind));\n\n }\n static long factorial(int n)\n {\n return n <= 1 ? 1 : n * factorial(n - 1);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force"], "code_uid": "aebb5a1682b27e7846145ab7c947d0bc", "src_uid": "a8da7cbd9ddaec8e0468c6cce884e7a2", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace RocketB\n{\n class Program\n {\n \n\n static void Main(string[] args)\n {\n string str = Console.ReadLine();\n var strs = str.Split(' ');\n int n = 0;\n long m = 0;\n int.TryParse(strs[0], out n);\n long.TryParse(strs[1], out m);\n --m;\n \n\n int[] array = new int[n];\n\n var tempm = m;\n for (int i = 0; i < n; i++)\n {\n array[i] = (int)(tempm % 2);\n tempm /= 2;\n }\n\n \n for (int i = 0; i < n - 1; i ++)\n {\n if (array[n - 1 - i - 1] == 0)\n {\n Console.Write(i + 1);\n Console.Write(\" \");\n }\n else\n {\n //Console.Write(i + 1 );\n //Console.Write(\" \");\n }\n \n }\n\n // if (p2 > 0)\n {\n Console.Write(n - 1 + 1 );\n Console.Write(\" \");\n }\n\n for (int i = n - 2; i >= 0; i--)\n {\n if (array[n - 1 - i -1] == 0)\n {\n //Console.Write(i + 1);\n //Console.Write(\" \");\n }\n else\n {\n Console.Write(i + 1);\n Console.Write(\" \");\n }\n \n }\n Console.WriteLine(\"\");\n\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "divide and conquer", "bitmasks"], "code_uid": "07050257a0de727eb03efa433e18ed39", "src_uid": "a8da7cbd9ddaec8e0468c6cce884e7a2", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Net;\nnamespace olimp\n{\n\n class Node\n {\n public List Roads;\n public List ClosedRoads; \n public int Id,Mark;\n }\n\n\n static class Program\n {\n private static void Main()\n {\n string[] s = Console.ReadLine().Split(' ');\n int[] a = new[]{ int.Parse(s[0]), int.Parse(s[1]), int.Parse(s[2]) };\n Array.Sort(a);\n int r, g, b;\n r = a[0];\n g = a[1];\n b = a[2];\n int ans = r + (g-r)/3 + (b-r)/3;\n int ans2 = b / 3 + g / 3 + Math.Min(r, Math.Min(b % 3, g % 3)) + (r - Math.Min(r, Math.Min(b % 3, g % 3)))/3;\n ans = Math.Max(ans, ans2);\n Console.WriteLine(ans);\n Console.ReadLine();\n }\n\n \n static void ReadIntPair(out int a1, out int a2)\n {\n string[] s = Console.ReadLine().Split(' ');\n a1 = int.Parse(s[0]);\n a2 = int.Parse(s[1]);\n }\n\n static long ReadNextInt()\n {\n char c;\n StringBuilder builder = new StringBuilder(4);\n while (char.IsDigit(c = (char) Console.Read()) || c == '-'||c == '\\r' || c == '\\n')\n {\n if (c == '\\r' || c == '\\n')\n continue;\n builder.Append(c);\n }\n return long.Parse(builder.ToString());\n }\n\n static int Sum1(int n)\n {\n int sum = 0;\n for (int i = 0; i < n; i++)\n {\n sum += (int)(Math.Pow(-1, i)*Math.Pow(n - i, 2));\n }\n return sum;\n }\n\n static int Sum2(int n)\n {\n return (n*(n+1))/2;\n }\n\n static double Log10(double x)\n {\n int n = CalnN((int) x);\n double val = n;\n double last = x;\n for (int i = 1; i <= sizeof(double) * 8; i++)\n {\n last = last*last;\n if (last >= 10)\n {\n val += 1/Math.Pow(2, i);\n last /= 10;\n }\n }\n return val;\n }\n\n static int CalnN(int x)\n {\n int i = 0;\n for (; Math.Pow(x, i + 1) < x; i++)\n {\n }\n return i;\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "combinatorics"], "code_uid": "6763643071937a4f2f724d78a3b2be7a", "src_uid": "acddc9b0db312b363910a84bd4f14d8e", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\n\nnamespace Flowers\n{\n class Flowers\n {\n static void Main(string[] args)\n {\n string[] rgb = Console.ReadLine().Split(' ');\n long r = long.Parse(rgb[0]);\n long g = long.Parse(rgb[1]);\n long b = long.Parse(rgb[2]);\n\n long rm = r % 3;\n long gm = g % 3;\n long bm = b % 3;\n if (rm == 0 && r > 0) rm = 3;\n if (gm == 0 && g > 0) gm = 3;\n if (bm == 0 && b > 0) bm = 3;\n\n long f = (r - rm) / 3 + (g - gm) / 3 + (b - bm) / 3;\n\n long min = Math.Min(rm, Math.Min(bm, gm));\n long thr = (rm == 3 ? 1 : 0) + (gm == 3 ? 1 : 0) + (bm == 3 ? 1 : 0);\n f += Math.Max(min, thr);\n\n Console.WriteLine(f);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "combinatorics"], "code_uid": "8b2695365b4d3426781b0814492467ca", "src_uid": "acddc9b0db312b363910a84bd4f14d8e", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Diagnostics;\nusing System.IO;\nusing System.Linq;\nusing System.Numerics;\nusing System.Text;\n\nnamespace CodeforcesTemplate\n{\n public static class Permutation\n {\n private static bool Next(ref int[] arr)\n {\n int k, j, l;\n for (j = arr.Length - 2; (j >= 0) && (arr[j] >= arr[j + 1]); j--) { }\n if (j == -1)\n {\n arr = arr.OrderBy(c => c).ToArray();\n return false;\n }\n for (l = arr.Length - 1; (arr[j] >= arr[l]) && (l >= 0); l--) { }\n var tmp = arr[j];\n arr[j] = arr[l];\n arr[l] = tmp;\n for (k = j + 1, l = arr.Length - 1; k < l; k++, l--)\n {\n tmp = arr[k];\n arr[k] = arr[l];\n arr[l] = tmp;\n }\n return true;\n }\n public static IEnumerable AllPermutations(int[] arr)\n {\n do yield return arr;\n while (Next(ref arr));\n }\n }\n\n class Program\n {\n private const string FILENAME = \"distance4\";\n\n private const string INPUT = FILENAME + \".in\";\n\n private const string OUTPUT = FILENAME + \".out\";\n\n private static Stopwatch _stopwatch = new Stopwatch();\n\n private static StreamReader _reader = null;\n private static StreamWriter _writer = null;\n\n private static string[] _curLine;\n private static int _curTokenIdx;\n\n private static char[] _whiteSpaces = new char[] { ' ', '\\t', '\\r', '\\n' };\n\n public static string Check(string s)\n {\n string letters = \"aeiouy\";\n\n while (true)\n {\n bool used = false;\n\n for (int i = 0; i < s.Length - 1; i++)\n {\n if (letters.Contains(s[i].ToString()) && letters.Contains(s[i + 1].ToString()))\n {\n s = s.Remove(i + 1, 1);\n\n used = true;\n }\n }\n\n if (!used)\n {\n return s;\n }\n }\n }\n\n private static string ReadNextToken()\n {\n if (_curTokenIdx >= _curLine.Length)\n {\n //Read next line\n string line = _reader.ReadLine();\n if (line != null)\n _curLine = line.Split(_whiteSpaces, StringSplitOptions.RemoveEmptyEntries);\n else\n _curLine = new string[] { };\n _curTokenIdx = 0;\n }\n\n if (_curTokenIdx >= _curLine.Length)\n return null;\n\n return _curLine[_curTokenIdx++];\n }\n\n private static int ReadNextInt()\n {\n return int.Parse(ReadNextToken());\n }\n\n private static void RunTimer()\n {\n#if (DEBUG)\n\n _stopwatch.Start();\n\n#endif\n }\n\n private static void Main(string[] args)\n {\n\n#if (DEBUG)\n double before = GC.GetTotalMemory(false);\n#endif\n\n\n int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();\n\n int p = a[0];\n int y = a[1];\n\n for (int i = y; i > p; i--)\n {\n bool ok = true;\n\n for (int j = 2; j <= p && j * j <= i; j++)\n {\n if (i % j == 0)\n {\n ok = false;\n break;\n }\n }\n if (ok)\n {\n Console.WriteLine(i);\n return;\n }\n }\n Console.WriteLine(-1);\n\n\n\n\n\n\n\n\n\n#if (DEBUG)\n _stopwatch.Stop();\n\n double after = GC.GetTotalMemory(false);\n\n double consumedInMegabytes = (after - before) / (1024 * 1024);\n\n Console.WriteLine($\"Time elapsed: {_stopwatch.Elapsed}\");\n\n Console.WriteLine($\"Consumed memory (MB): {consumedInMegabytes}\");\n\n Console.ReadKey();\n#endif\n\n\n }\n\n private static int CountLeadZeros(string source)\n {\n int countZero = 0;\n\n for (int i = source.Length - 1; i >= 0; i--)\n {\n if (source[i] == '0')\n {\n countZero++;\n }\n\n else\n {\n break;\n }\n\n }\n\n return countZero;\n }\n\n private static string ReverseString(string source)\n {\n char[] reverseArray = source.ToCharArray();\n\n Array.Reverse(reverseArray);\n\n string reversedString = new string(reverseArray);\n\n return reversedString;\n }\n\n\n private static int[] CopyOfRange(int[] src, int start, int end)\n {\n int len = end - start;\n int[] dest = new int[len];\n Array.Copy(src, start, dest, 0, len);\n return dest;\n }\n\n private static string StreamReader()\n {\n\n if (_reader == null)\n _reader = new StreamReader(INPUT);\n string response = _reader.ReadLine();\n if (_reader.EndOfStream)\n _reader.Close();\n return response;\n\n\n }\n\n private static void StreamWriter(string text)\n {\n\n if (_writer == null)\n _writer = new StreamWriter(OUTPUT);\n _writer.WriteLine(text);\n\n\n }\n\n\n\n\n\n private static int BFS(int start, int end, int[,] arr)\n {\n Queue> queue = new Queue>();\n List visited = new List();\n for (int i = 0; i < arr.GetLength(0); i++)\n {\n visited.Add(false);\n }\n\n queue.Enqueue(new KeyValuePair(start, 0));\n KeyValuePair node;\n int level = 0;\n bool flag = false;\n\n while (queue.Count != 0)\n {\n node = queue.Dequeue();\n if (node.Key == end)\n {\n return node.Value;\n }\n flag = false;\n for (int i = 0; i < arr.GetLength(0); i++)\n {\n\n if (arr[node.Key, i] == 1)\n {\n if (visited[i] == false)\n {\n if (!flag)\n {\n level = node.Value + 1;\n flag = true;\n }\n queue.Enqueue(new KeyValuePair(i, level));\n visited[i] = true;\n }\n }\n }\n\n }\n return 0;\n\n }\n\n\n\n private static void Write(string source)\n {\n File.WriteAllText(OUTPUT, source);\n }\n\n private static string ReadString()\n {\n return File.ReadAllText(INPUT);\n }\n\n private static void WriteStringArray(string[] source)\n {\n File.WriteAllLines(OUTPUT, source);\n }\n\n private static string[] ReadStringArray()\n {\n return File.ReadAllLines(INPUT);\n }\n\n private static int[] GetIntArray()\n {\n return ReadString().Split(' ').Select(int.Parse).ToArray();\n }\n\n private static double[] GetDoubleArray()\n {\n return ReadString().Split(' ').Select(double.Parse).ToArray();\n }\n\n private static int[,] ReadINT2XArray(List lines)\n {\n int[,] arr = new int[lines.Count, lines.Count];\n\n for (int i = 0; i < lines.Count; i++)\n {\n int[] row = lines[i].Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(int.Parse).ToArray();\n\n for (int j = 0; j < lines.Count; j++)\n {\n arr[i, j] = row[j];\n }\n }\n\n return arr;\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "math", "number theory"], "code_uid": "0f75ce92dbd8b80c0a7232bc73c646fc", "src_uid": "b533203f488fa4caf105f3f46dd5844d", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\n\nnamespace CSharp\n{\n class _937B\n {\n public static void Main()\n {\n var tokens = Console.ReadLine().Split();\n\n int p = int.Parse(tokens[0]);\n int y = int.Parse(tokens[1]);\n\n for (; y > p; y--)\n {\n bool suitable = true;\n\n for (int i = 2; i <= p && i <= y / i; i++)\n {\n if (y % i == 0)\n {\n suitable = false;\n break;\n }\n }\n\n if (suitable)\n {\n Console.WriteLine(y);\n return;\n }\n }\n\n Console.WriteLine(-1);\n }\n }\n}", "lang_cluster": "C#", "tags": ["brute force", "math", "number theory"], "code_uid": "bfde47ee3986f73e59d17adc3506e7eb", "src_uid": "b533203f488fa4caf105f3f46dd5844d", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "/*\ncsc -debug B.cs && mono --debug B.exe <<< \"6\n5 10 2 3 14 5\"\n*/\n\nusing System;\nusing System.Collections.Generic;\nusing System.Linq;\n\npublic class HelloWorld {\n static public void Main () {\n SolveCodeForces();\n }\n\n public static void SolveCodeForces() {\n var sc = new Scanner();\n\n var n = sc.NextInt();\n var A = sc.UlongArray().OrderBy(a => a).ToArray();\n\n var cnt = 0ul;\n for (var i = 0; i < n/2; i++) {\n cnt += A[2*i+1] - A[2*i];\n }\n\n System.Console.WriteLine(cnt);\n }\n}\n\npublic static class Helpers {\n public static T[] CreateArray(int length, Func itemCreate) {\n var result = new T[length];\n for (var i = 0; i < result.Length; i++)\n result[i] = itemCreate(i);\n return result;\n }\n\n public static T ElementWithMax(this IEnumerable seq, Func func) {\n var bi = default(T);\n var bv = long.MinValue;\n foreach (var item in seq) {\n var v = func(item);\n if (v > bv) {\n bi = item;\n bv = v;\n }\n }\n return bi;\n }\n\n public static IEnumerable IndicesWhere(this IEnumerable seq, Func cond) {\n var i = 0;\n foreach (var item in seq) {\n if (cond(item)) yield return i;\n i++;\n }\n }\n}\n\npublic class Scanner\n{\n private string[] line = new string[0];\n private int index = 0;\n\n public string Next() {\n if (line.Length <= index) {\n line = Console.ReadLine().Split(' ');\n index = 0;\n }\n var res = line[index];\n index++;\n return res;\n }\n\n public int NextInt() {\n return int.Parse(Next());\n }\n\n public long NextLong() {\n return long.Parse(Next());\n }\n\n public ulong NextUlong() {\n return ulong.Parse(Next());\n }\n\n public string[] Array() {\n line = Console.ReadLine().Split(' ');\n index = line.Length;\n return line;\n }\n\n public int[] IntArray() {\n var array = Array();\n var result = new int[array.Length];\n for (int i = 0; i < array.Length; i++)\n result[i] = int.Parse(array[i]);\n return result;\n }\n\n public long[] LongArray() {\n var array = Array();\n var result = new long[array.Length];\n for (int i = 0; i < array.Length; i++)\n result[i] = long.Parse(array[i]);\n return result;\n }\n\n public ulong[] UlongArray() {\n var array = Array();\n var result = new ulong[array.Length];\n for (int i = 0; i < array.Length; i++)\n result[i] = ulong.Parse(array[i]);\n return result;\n }\n}", "lang_cluster": "C#", "tags": ["sortings"], "code_uid": "62966233216c41b85b8a2843ef307d26", "src_uid": "55485fe203a114374f0aae93006278d3", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.IO;\nusing System.Linq;\nusing System.Text;\n\nnamespace Graph\n{\n public class Program\n {\n static void Main(string[] args)\n {\n#if DEBUG\n Console.SetIn(new StreamReader(\"in.txt\"));\n Console.SetOut(new StreamWriter(\"out.txt\") { AutoFlush = true });\n#endif\n var n = int.Parse(Console.ReadLine());\n var array = Console.ReadLine().Split().Select(int.Parse).ToList();\n\n array.Sort();\n\n int result = 0;\n for (int i = 0; i < n; i+=2)\n {\n result += array[i + 1] - array[i];\n }\n Console.WriteLine(result);\n }\n }\n}", "lang_cluster": "C#", "tags": ["sortings"], "code_uid": "d85704c0e8051018f575f705e374f37b", "src_uid": "55485fe203a114374f0aae93006278d3", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\n\nclass Program\n{\n\tstatic void Main()\n\t{\n\t\tint n = int.Parse(Console.ReadLine());\n\t\tDictionary a = new Dictionary();\n\t\tfor (int i = 1; i <= 5; i++)\n\t\t{\n\t\t\ta[i] = 0;\n\t\t}\n\t\tstring s = Console.ReadLine();\n\t\tfor (int i = 0; i < s.Length; i += 2)\n\t\t{\n\t\t\ta[int.Parse(s[i].ToString())]++;\n\t\t}\n\t\tDictionary b = new Dictionary();\n\t\tfor (int i = 1; i <= 5; i++)\n\t\t{\n\t\t\tb[i] = 0;\n\t\t}\n\t\ts = Console.ReadLine();\n\t\tfor (int i = 0; i < s.Length; i += 2)\n\t\t{\n\t\t\tb[int.Parse(s[i].ToString())]++;\n\t\t}\n\t\tint counter = 0;\n\t\tfor (int i = 1; i <= 5; i++)\n\t\t{\n\t\t\tif ((a[i] + b[i]) % 2 == 0)\n\t\t\t{\n\t\t\t\tif (a[i] > b[i])\n\t\t\t\t{\n\t\t\t\t\tcounter += (a[i] - b[i]) / 2;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tConsole.WriteLine(\"-1\");\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t\tConsole.WriteLine(counter);\n\t}\n}\n", "lang_cluster": "C#", "tags": ["math", "constructive algorithms"], "code_uid": "06b8c81d20eed4a15a0717324a6da0f7", "src_uid": "47da1dd95cd015acb8c7fd6ae5ec22a3", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Linq;\n\nstatic class P {\n static int[] ToIntArray(this string s) { return s.Split().Select(int.Parse).ToArray(); }\n static void Main() {\n int n = int.Parse(Console.ReadLine()), r = 0;\n int[] A = Console.ReadLine().ToIntArray(),\n B = Console.ReadLine().ToIntArray();\n\n var all = A.Concat(B).GroupBy(x => x)\n .Select(x => new { Key = x.Key, Count = x.Count() });\n\n foreach (var info in all) {\n if (info.Count % 2 != 0) {\n Console.WriteLine(-1);\n return;\n }\n }\n\n var grA = A.GroupBy(x => x)\n .Select(x => new { Key = x.Key, Count = x.Count() });\n\n foreach (var info in all) {\n var val = info.Count / 2;\n var found = grA.FirstOrDefault(x => x.Key == info.Key);\n\n if (found != null) {\n if (found.Count > val) {\n r += found.Count - val;\n }\n } \n }\n\n Console.WriteLine(r);\n }\n}", "lang_cluster": "C#", "tags": ["math", "constructive algorithms"], "code_uid": "5c89ea16bdccaf4c0612d2ddb8678a85", "src_uid": "47da1dd95cd015acb8c7fd6ae5ec22a3", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\n\nnamespace ConsoleApplication2\n{\n internal class Program\n {\n public static void Main(string[] args)\n {\n int n = Convert.ToInt32(Console.ReadLine());\n string a = Console.ReadLine();\n int end = 0;;\n for (int i = 0; i < n; i++)\n {\n if (a[i] == '+')\n {\n end++;\n }\n else\n {\n end--;\n }\n\n if (end < 0)\n {\n end++;\n }\n }\n \n int s = end;\n Console.WriteLine(s);\n Console.ReadLine();\n }\n }\n}", "lang_cluster": "C#", "tags": ["math", "implementation"], "code_uid": "cc89d30f77c82b1c219955462acdea01", "src_uid": "a593016e4992f695be7c7cd3c920d1ed", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "// Problem: 1159A - A pile of stones\n// Author: Gusztav Szmolik\n\nusing System;\n\nclass APileOfStones\n {\n public static int Main ()\n {\n string line = Console.ReadLine ();\n if (line == null)\n return -1;\n string[] words = line.Split ();\n if (words.Length != 1)\n return -1;\n byte n;\n if (!Byte.TryParse (words[0], out n))\n return -1;\n if (n < 1 || n > 100)\n return -1;\n line = Console.ReadLine ();\n if (line == null)\n return -1;\n words = line.Split ();\n if (words.Length != 1)\n return -1;\n string s = words[0];\n if (s.Length != n)\n return -1;\n byte ans = 0;\n char c;\n for (byte i = 0; i < n; i++)\n {\n c = s[i];\n if (c != '-' && c != '+')\n return -1;\n if (c == '-' && ans > 0)\n ans--;\n else if (c == '+')\n ans++;\n }\n Console.WriteLine (ans);\n return 0;\n }\n }\n", "lang_cluster": "C#", "tags": ["math", "implementation"], "code_uid": "57acfc302ed4c2153aed286ddd252785", "src_uid": "a593016e4992f695be7c7cd3c920d1ed", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace TaskB\n{\n class Program\n {\n static void Main(string[] args)\n {\n\n var input = Console.ReadLine().Split('e');\n string a = input[0];\n string exp = input[1];\n int b = int.Parse(exp);\n\n if (a == \"0.0\")\n {\n Console.WriteLine(0);\n return;\n }\n\n if (a.First() == '0')\n {\n Console.WriteLine(a);\n return;\n }\n\n int pointIndex = a.IndexOf('.');\n\n if (b == 0)\n {\n if (a.Length - (pointIndex + 1) == 1 && a.Last() == '0')\n {\n Console.WriteLine(a.Substring(0, pointIndex));\n return;\n }\n }\n\n\n if (pointIndex != -1)\n {\n\n a = a.Remove(pointIndex, 1);\n if (pointIndex + b < a.Length)\n {\n pointIndex += b;\n a = a.Insert(pointIndex, \".\");\n }\n else\n {\n int extend = pointIndex + b - a.Length;\n if ( extend > 0)\n {\n char[] zero = new char[extend];\n for (int i = 0; i < extend; i++)\n\t\t\t {\n\t\t\t zero[i] = '0';\n\t\t\t }\n\n a += new string(zero);\n }\n }\n \n Console.WriteLine(a);\n Console.ReadLine();\n }\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "math", "strings", "implementation"], "code_uid": "93127bed8efd1ab77b49797414d0e5ed", "src_uid": "a79358099f08f3ec50c013d47d910eef", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\n\nclass Round362P2{\n\tstatic string StripFrontZero(string str){\n\t\tstring ret = \"\";\n\t\tbool fl = true;\n\t\tfor(int i=0;i isPrime[i]).ToArray();\n Console.WriteLine(Enumerable.Range(1, primes.Length - 1).Select(i => primes[i - 1] + primes[i] + 1).Count(p => p <= n && isPrime[p]) >= k ? \"YES\" : \"NO\");\n }\n }\n}", "lang_cluster": "C#", "tags": ["brute force", "math", "number theory"], "code_uid": "a1a1802bad069d4febef02a8f4a4dbe1", "src_uid": "afd2b818ed3e2a931da9d682f6ad660d", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\n\nnamespace _17A\n{\n class Program\n {\n public static void Main(string[] args)\n {\n\n List primes = new List();\n int[] temp = Console.ReadLine().Split().Select(int.Parse).ToArray();\n int n = temp[0], k = temp[1];\n for(int i = 2; i <= n; i++)\n {\n if (IsPrime(i))\n primes.Add(i);\n }\n int counter = 0;\n for(int i = 0; i < primes.Count - 1; i++)\n {\n int t = primes[i] + primes[i + 1] + 1;\n if (IsPrime(t) && t <= n)\n counter++;\n if (t > n || counter >= k) break;\n }\n Console.WriteLine((counter >= k) ? \"YES\" : \"NO\");\n\n }\n\n static bool IsPrime(int num)\n {\n if(num==2)return true;\n if (num < 2 || num % 2 == 0) return false;\n int limit = Convert.ToInt32( Math.Sqrt(num));\n for(int i = 3; i <= limit; i += 2)\n {\n if (num % i == 0) return false;\n }\n return true;\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "math", "number theory"], "code_uid": "dbe0883aad9f5f8b33bf63fff6363232", "src_uid": "afd2b818ed3e2a931da9d682f6ad660d", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\n\nnamespace codeforces\n{\n\tclass Program\n\t{\n\t\tpublic const int Osn = 1000000007;\n\n\t\tpublic class Pair\n\t\t{\n\t\t\tpublic long First;\n\n\t\t\tpublic int Second;\n\n\t\t\tpublic int Third;\n\t\t}\n\n\t\tpublic class PairComparer : IComparer\n\t\t{\n\t\t\tpublic int Compare(Pair x, Pair y)\n\t\t\t{\n\t\t\t\tif (x.First > y.First || (x.First == y.First && x.Second < y.Second))\n\t\t\t\t\treturn -1;\n\t\t\t\treturn 1;\n\t\t\t}\n\t\t}\n\n\t\tpublic static long GetGcd(long a, long b)\n\t\t{\n\t\t\twhile (true)\n\t\t\t{\n\t\t\t\tif (b == 0)\n\t\t\t\t\treturn a;\n\t\t\t\tvar a1 = a;\n\t\t\t\ta = b;\n\t\t\t\tb = a1 % b;\n\t\t\t}\n\t\t}\n\n\t\tpublic static void WriteYesNo(bool x, string yes = \"YES\", string no = \"NO\")\n\t\t{\n\t\t\tif (x)\n\t\t\t\tConsole.WriteLine(yes);\n\t\t\telse\n\t\t\t{\n\t\t\t\tConsole.WriteLine(no);\n\t\t\t}\n\t\t}\n\n\t\tpublic static string ReadString()\n\t\t{\n\t\t\treturn Console.ReadLine();\n\t\t}\n\n\t\tpublic static List ReadListOfInts()\n\t\t{\n\t\t\tvar s = Console.ReadLine();\n\t\t\treturn s.Split(' ').Select(int.Parse).ToList();\n\t\t}\n\n\t\tpublic static List ReadListOfLongs()\n\t\t{\n\t\t\tvar s = Console.ReadLine();\n\t\t\treturn s.Split(' ').Select(long.Parse).ToList();\n\t\t}\n\n\t\tpublic static int ReadInt()\n\t\t{\n\t\t\tvar s = Console.ReadLine();\n\t\t\treturn int.Parse(s);\n\t\t}\n\n\t\tpublic static long ReadLong()\n\t\t{\n\t\t\tvar s = Console.ReadLine();\n\t\t\treturn long.Parse(s);\n\t\t}\n\n\t\tpublic class Vertex\n\t\t{\n\t\t\tpublic int Was;\n\n\t\t\tpublic List Edges;\n\t\t}\n\n\t\tpublic static List> Graph = new List>();\n\n/*\t\tpublic static bool Dfs(int x, int y, int prevx, int prevy)\n\t\t{\n\t\t\tGraph[x][y].Was = 1;\n\t\t\tvar result = false;\n\t\t\tforeach (var t in Graph[x][y].Edges)\n\t\t\t{\n\t\t\t\tif (Graph[t.First][t.Second].Was == 0)\n\t\t\t\t\tresult |= Dfs(t.First, t.Second, x, y);\n\t\t\t\telse if (t.First != prevx || t.Second != prevy)\n\t\t\t\t\treturn true;\n\t\t\t}\n\n\t\t\treturn result;\n\t\t}*/\n\n\t\tpublic static bool IsPrime(int x)\n\t\t{\n\t\t\tfor (var j = 2; j * j <= x; ++j)\n\t\t\t\tif (x % j == 0)\n\t\t\t\t\treturn false;\n\t\t\treturn true;\n\t\t}\n\n\t\tpublic class LinkedVertex\n\t\t{\n\t\t\tpublic int Next;\n\n\t\t\tpublic int Prev;\n\n\t\t\tpublic int Value;\n\t\t}\n\n\n\t\tprivate static void Main()\n\t\t{\n\t\t\tvar s = ReadString();\n\t\t\tvar ans = 0;\n\t\t\tvar curO = s[0];\n\t\t\tvar curCt = 1;\n\t\t\tvar i = 1;\n\t\t\twhile (i < s.Length)\n\t\t\t{\n\t\t\t\tif (s[i] != curO)\n\t\t\t\t{\n\t\t\t\t\tans++;\n\t\t\t\t\tcurO = s[i];\n\t\t\t\t\tcurCt = 1;\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tif (curCt == 5)\n\t\t\t\t\t{\n\t\t\t\t\t\tans++;\n\t\t\t\t\t\tcurCt = 1;\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\tcurCt++;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\ti++;\n\t\t\t}\n\t\t\tans++;\n\t\t\tConsole.WriteLine(ans);\n\t\t\tConsole.ReadLine();\n\t\t}\n\t}\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "94bdc9c8a4f01c507f8da56e38ae38c3", "src_uid": "5257f6b50f5a610a17c35a47b3a0da11", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Globalization;\nusing System.IO;\nusing System.Linq;\nusing System.Text;\npublic class Codeforces\n{\n protected static TextReader reader;\n protected static TextWriter writer;\n static void Main()\n {\n reader = new StreamReader(Console.OpenStandardInput(1024 * 10), System.Text.Encoding.ASCII, false, 1024 * 10);\n writer = new StreamWriter(Console.OpenStandardOutput(1024 * 10), System.Text.Encoding.ASCII, 1024 * 10);\n var cp = ReadToken();\n var n = 1;\n var c = 0;\n for (int i = 0; i < cp.Length - 1; i++)\n {\n if (cp[i] == cp[i + 1])\n {\n c++;\n if (c == 5)\n {\n n++;\n c = 0;\n }\n }\n else\n {\n n++;\n c = 0;\n }\n }\n Write(n);\n reader.Close();\n writer.Close();\n }\n #region Read / Write\n\n private static Queue currentLineTokens = new Queue();\n\n private static string[] ReadAndSplitLine()\n {\n return reader.ReadLine().Split(new[] { ' ', '\\t' }, StringSplitOptions.RemoveEmptyEntries);\n }\n\n public static string ReadToken()\n {\n while (currentLineTokens.Count == 0)\n currentLineTokens = new Queue(ReadAndSplitLine());\n return currentLineTokens.Dequeue();\n }\n\n public static int ReadInt()\n {\n return int.Parse(ReadToken());\n }\n\n public static long ReadLong()\n {\n return long.Parse(ReadToken());\n }\n\n public static double ReadDouble()\n {\n return double.Parse(ReadToken(), CultureInfo.InvariantCulture);\n }\n\n public static int[] ReadIntArray()\n {\n return ReadAndSplitLine().Select(int.Parse).ToArray();\n }\n\n public static long[] ReadLongArray()\n {\n return ReadAndSplitLine().Select(long.Parse).ToArray();\n }\n\n public static double[] ReadDoubleArray()\n {\n return ReadAndSplitLine().Select(s => double.Parse(s, CultureInfo.InvariantCulture)).ToArray();\n }\n public static int[][] ReadIntMatrix(int numberOfRows)\n {\n int[][] matrix = new int[numberOfRows][];\n for (int i = 0; i < numberOfRows; i++)\n matrix[i] = ReadIntArray();\n return matrix;\n }\n public static int[][] ReadAndTransposeIntMatrix(int numberOfRows)\n {\n int[][] matrix = ReadIntMatrix(numberOfRows);\n int[][] ret = new int[matrix[0].Length][];\n for (int i = 0; i < ret.Length; i++)\n {\n ret[i] = new int[numberOfRows];\n for (int j = 0; j < numberOfRows; j++)\n ret[i][j] = matrix[j][i];\n }\n return ret;\n }\n\n public static string[] ReadLines(int quantity)\n {\n string[] lines = new string[quantity];\n for (int i = 0; i < quantity; i++)\n lines[i] = reader.ReadLine().Trim();\n return lines;\n }\n public static void WriteArray(IEnumerable array)\n {\n writer.WriteLine(string.Join(\" \", array));\n }\n\n public static void Write(params T[] array)\n {\n WriteArray(array);\n }\n\n public static void WriteLines(IEnumerable array)\n {\n foreach (var a in array)\n writer.WriteLine(a);\n }\n private static int Next()\n {\n int c;\n int res = 0;\n do\n {\n c = reader.Read();\n if (c == -1)\n return res;\n } while (c != '-' && (c < '0' || c > '9'));\n int sign = 1;\n if (c == '-')\n {\n sign = -1;\n c = reader.Read();\n }\n res = c - '0';\n while (true)\n {\n c = reader.Read();\n if (c < '0' || c > '9')\n return res * sign;\n res *= 10;\n res += c - '0';\n }\n }\n #endregion\n}", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "b6940287e338cfdb2b4486a82e9c625a", "src_uid": "5257f6b50f5a610a17c35a47b3a0da11", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Dynamic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace ConsoleApplication1\n{\n class Program\n {\n static void Main(string[] args)\n {\n var n = int.Parse(Console.ReadLine());\n Console.WriteLine(GetMax(n, n));\n }\n\n private static long GetMax(int i, int j)\n {\n if (i == 1 || j == 1)\n return 1;\n return GetMax(i - 1, j) + GetMax(i, j - 1);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "implementation"], "code_uid": "a3012895fe95e63de9f9f382faba6950", "src_uid": "2f650aae9dfeb02533149ced402b60dc", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Text;\nusing System.Collections.Generic;\nusing System.Collections;\nclass Problem\n{\n static void Main()\n {\n int n = Convert.ToInt32( Console.ReadLine() );\n Console.WriteLine( kq( n - 1) );\n }\n\n private static string kq(int p)\n {\n long str = 1;\n for(int i = p + 1 ; i <= 2 * p ; i++)\n str*= i;\n for(int i = 1 ; i <= p ; i++)\n str /= i;\n return str.ToString();\n }\n}", "lang_cluster": "C#", "tags": ["brute force", "implementation"], "code_uid": "4cd91b415c9a9f4532ede7125abbb164", "src_uid": "2f650aae9dfeb02533149ced402b60dc", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading;\n\nnamespace Codeforces\n{\n\tclass Program\n\t{\n\t\tstatic void Main(string[] args) \n\t\t{\n\t\t\tstring input1 = Console.ReadLine();\n\t\t\t//string input2 = Console.ReadLine();\n\n\t\t\t//string input3 = Console.ReadLine();\n\t\t\t//string input4 = Console.ReadLine();\n\n\t\t\tvar inputs1 = input1.Split(new[] {' ', '}', '{', ','}, StringSplitOptions.RemoveEmptyEntries).Select(long.Parse).ToArray();\n\t\t\t//var inputs2 = input2.Split(new[] { ' ', '}', '{', ',' }, StringSplitOptions.RemoveEmptyEntries).Select(long.Parse).ToArray();\n\t\t\t//var inputs3 = input3.Split(new[] { ' ', '}', '{', ',' }, StringSplitOptions.RemoveEmptyEntries).Select(long.Parse).ToArray();\n\t\t\t//var inputs4 = input4.Split(new[] { ' ', '}', '{', ',' }, StringSplitOptions.RemoveEmptyEntries).Select(long.Parse).ToArray();\n\n\t\t\tlong a1 = inputs1[0];\n\t\t\tlong a2 = inputs1[1];\n\n\t\t\tvar min = Math.Min(a1, a2);\n\t\t\tvar max = a1 + a2 - min;\n\n\t\t\tif (max == 1) \n\t\t\t{\n\t\t\t\tConsole.WriteLine(0);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tlong count = 0;\n\t\t\twhile (min > 0 && max > 0) \n\t\t\t{\n\t\t\t\twhile (max > 2)\n\t\t\t\t{\n\t\t\t\t\tmin++;\n\t\t\t\t\tmax -= 2;\n\t\t\t\t\tcount++;\n\t\t\t\t}\n\n\t\t\t\tvar temp = Math.Min(min, max);\n\t\t\t\tmax = min + max - temp;\n\t\t\t\tmin = temp;\n\n\t\t\t\tif (max == 1 || max == 2) \n\t\t\t\t{\n\t\t\t\t\tcount++;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tConsole.WriteLine(count);\n\t\t}\n\n\t\tpublic class Team\n\t\t{\n\t\t\tpublic string Name { get; set; }\n\n\t\t\tpublic int Points { get; set; }\n\n\t\t\tpublic int GoalsFor { get; set; }\n\n\t\t\tpublic int GoalsAgainst { get; set; }\n\t\t}\n\n\t\tstatic long Factorial(long a) \n\t\t{\n\t\t\treturn a > 1 ? a * Factorial(a - 1) : 1;\n\t\t}\n\t}\n}\n", "lang_cluster": "C#", "tags": ["math", "greedy", "dp", "implementation"], "code_uid": "76988cea471930a49f793101c253865c", "src_uid": "ba0f9f5f0ad4786b9274c829be587961", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nclass Program\n {\n static void Main(string[] args)\n {\n string [] input = Console.In.ReadLine().Split(new char[] { ' ', '\\n', '\\r', '\\t' }, StringSplitOptions.RemoveEmptyEntries);\n int a = int.Parse(input[0]);\n int b = int.Parse(input[1]);\n input = null;\n int ans = (a + b - (Math.Abs(a - b) % 3 == 0 ? 3 : 2));\n Console.WriteLine(ans>0?ans:0);\n }\n }", "lang_cluster": "C#", "tags": ["math", "greedy", "dp", "implementation"], "code_uid": "4df93dc7b52d3705bf791cc79bc2b334", "src_uid": "ba0f9f5f0ad4786b9274c829be587961", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Text;\nusing System.IO;\nusing System.Globalization;\nusing System.Collections;\n\nnamespace Task\n{\n #region MyIo\n\n class MyIo : IDisposable\n {\n private readonly TextReader inputStream;\n private readonly TextWriter outputStream = Console.Out;\n\n string[] tokens;\n int pointer;\n\n public MyIo()\n#if LOCAL_TEST\n : this(new StreamReader(\"input.txt\"))\n#else\n : this(System.Console.In)\n#endif\n {\n \n }\n\n public MyIo(TextReader inputStream)\n {\n this.inputStream = inputStream;\n }\n\n public string NextLine()\n {\n try\n {\n return inputStream.ReadLine();\n }\n catch (IOException)\n {\n return null;\n }\n }\n\n public string NextString()\n {\n try\n {\n while (tokens == null || pointer >= tokens.Length)\n {\n tokens = NextLine().Split(new char[] { ' ', '\\t' }, StringSplitOptions.RemoveEmptyEntries);\n pointer = 0;\n }\n return tokens[pointer++];\n }\n catch (IOException)\n {\n return null;\n }\n }\n\n public int NextInt()\n {\n return int.Parse(NextString());\n }\n\n public long NextLong()\n {\n return long.Parse(NextString());\n }\n\n public void Print(string format, params object[] args)\n {\n outputStream.Write(string.Format(CultureInfo.InvariantCulture, format, args));\n }\n\n public void PrintLine(string format, params object[] args)\n {\n Print(format, args);\n\n outputStream.WriteLine();\n }\n\n public void Print(T o)\n {\n outputStream.Write(o);\n }\n\n\n public void PrintLine(T o)\n {\n outputStream.WriteLine(o);\n }\n\n public void Close()\n {\n inputStream.Close();\n outputStream.Close();\n }\n\n void IDisposable.Dispose()\n {\n Close();\n\n#if LOCAL_TEST\n Console.ReadLine();\n#endif\n }\n }\n #endregion\n\n class Program\n {\n #region Program\n\n readonly MyIo io;\n\n public Program(MyIo io)\n {\n this.io = io;\n }\n\n static void Main(string[] args)\n {\n using (MyIo io = new MyIo())\n {\n new Program(io)\n .Solve();\n }\n }\n\n\n\n #endregion\n\n \n\n void Solve()\n {\n var a = io.NextInt();\n var b = io.NextInt();\n\n for (int i = a + 1; i <= 200000 + b; i++)\n {\n if (CalcGood(i) == b)\n {\n io.Print(i);\n break;\n }\n }\n }\n\n private int CalcGood(int i)\n {\n int res = 0;\n int step = 1;\n\n while (i != 0)\n {\n int ost = i % 10;\n i /= 10;\n\n if (ost == 4 || ost == 7)\n {\n res += ost * step;\n step *= 10;\n }\n }\n\n return res;\n }\n\n\n }\n}", "lang_cluster": "C#", "tags": ["brute force", "implementation"], "code_uid": "e282311132963e262a4f31ef215393a7", "src_uid": "e5e4ea7a5bf785e059e10407b25d73fb", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\n\nnamespace CodeForceContest\n{\n class Program\n {\n static void Main(string[] args)\n {\n var s = Console.ReadLine().Split(' ').Select(ss => int.Parse(ss)).ToArray();\n //var s = \"401 4\".Split(' ').Select(ss => int.Parse(ss)).ToArray();\n var a = s[0];\n var b = s[1];\n var res = a + 1;\n for (; ; )\n {\n if(TakeMask(res)==b)\n {\n break;\n }\n res++;\n }\n Console.WriteLine(res);\n }\n static int TakeMask(int a)\n {\n var e = a.ToString();\n var list = new List();\n foreach (var i in e)\n {\n if(i=='4' ||i=='7')list.Add(i);\n }\n if (list.Count > 0)\n return int.Parse(String.Join(\"\", list.Select(s => s.ToString()).ToArray()));\n else return 0;\n }\n }\n\n}\n", "lang_cluster": "C#", "tags": ["brute force", "implementation"], "code_uid": "57ceb15908bc6043c181f6fd07a56684", "src_uid": "e5e4ea7a5bf785e059e10407b25d73fb", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text.RegularExpressions;\n\nclass Program\n{\n static void Main(string[] args)\n {\n string [] Input = Console.ReadLine().Split();\n int Parent = Int32.Parse(Input[0]);\n int Childs = Int32.Parse(Input[1]);\n int max, min;\n \n if (Childs == 0)\n max = Parent;\n else\n max = Parent + Childs - 1;\n if (Childs >= Parent) min = Parent + (Childs - Parent);\n else\n min = Parent;\n \n if (Parent == 0 && Childs != 0)\n Console.Write(\"Impossible\");\n else\n Console.Write(\"{0} {1}\", min, max);\n }\n}", "lang_cluster": "C#", "tags": ["math", "greedy"], "code_uid": "8b26524e4781c64658f4c79313c24680", "src_uid": "1e865eda33afe09302bda9077d613763", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\n\nnamespace Vasia\n{\n class Program\n {\n static void Main(string[] args)\n {\n long n, m;\n \n string s;\n string[] ss;\n\n s = Console.ReadLine();\n ss = s.Split();\n n = Convert.ToInt32(ss[0]);\n m = Convert.ToInt32(ss[1]);\n\n if (n == 0 & m == 0) \n {\n Console.WriteLine(\"{0} {1}\", 0, 0);\n return;\n }\n\n if (n == 0)\n {\n Console.WriteLine(\"Impossible\");\n return;\n }\n\n if(m == 0)\n {\n Console.WriteLine(\"{0} {1}\", n, n);\n return;\n }\n\n if (n > m)\n {\n Console.WriteLine(\"{0} {1}\", n, (n + m) - 1);\n }\n else\n {\n Console.WriteLine(\"{0} {1}\", m, (n + m) - 1);\n }\n \n \n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "greedy"], "code_uid": "a8fada503b33056cfc21cb03e9ecb511", "src_uid": "1e865eda33afe09302bda9077d613763", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Diagnostics;\nusing System.Globalization;\nusing System.IO;\nusing System.Linq;\nusing System.Text;\n\nnamespace CF317\n{\n internal class Program\n {\n private static void Main(string[] args)\n {\n using (var sr = new InputReader(Console.In))\n //using (var sr = new InputReader(new StreamReader(\"input.txt\")))\n {\n var task = new Task();\n using (var sw = Console.Out)\n {\n //using (var sw = new StreamWriter(\"output.txt\")) {\n task.Solve(sr, sw);\n //Console.ReadKey();\n }\n }\n }\n }\n\n internal class Task\n {\n public void Solve(InputReader sr, TextWriter sw)\n {\n var n = sr.NextInt32();\n var array = sr.ReadArrayOfInt32();\n if (n == 1) {\n sw.WriteLine(\"YES\");\n return;\n }\n for (var i = 0; i < array.Length; i++) {\n for (var j = i; j < array.Length; j++) {\n var can = true;\n for (var k = 1; k <= i; k++) {\n if (array[k] <= array[k - 1]) {\n can = false;\n break;\n }\n }\n for (var k = i; k <= j; k++) {\n if (array[k] != array[i]) {\n can = false;\n break;\n }\n }\n for (var k = j + 1; k < array.Length; k++) {\n if (array[k] >= array[k - 1]) {\n can = false;\n break;\n }\n }\n if (can) {\n sw.WriteLine(\"YES\");\n return;\n }\n }\n }\n\n sw.WriteLine(\"NO\");\n }\n }\n}\n\ninternal class InputReader : IDisposable\n{\n private bool isDispose;\n private readonly TextReader sr;\n\n public InputReader(TextReader stream)\n {\n sr = stream;\n }\n\n public void Dispose()\n {\n Dispose(true);\n GC.SuppressFinalize(this);\n }\n\n public string NextString()\n {\n var result = sr.ReadLine();\n return result;\n }\n\n public int NextInt32()\n {\n return Int32.Parse(NextString());\n }\n\n public long NextInt64()\n {\n return Int64.Parse(NextString());\n }\n\n public string[] NextSplitStrings()\n {\n return NextString()\n .Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);\n }\n\n public T[] ReadArray(Func func)\n {\n return NextSplitStrings()\n .Select(s => func(s, CultureInfo.InvariantCulture))\n .ToArray();\n }\n\n public int[] ReadArrayOfInt32()\n {\n return ReadArray(Int32.Parse);\n }\n\n public long[] ReadArrayOfInt64()\n {\n return ReadArray(Int64.Parse);\n }\n\n public T[] ReadArrayFromString(Func func, string str)\n {\n return\n str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)\n .Select(s => func(s, CultureInfo.InvariantCulture))\n .ToArray();\n }\n\n protected void Dispose(bool dispose)\n {\n if (!isDispose)\n {\n if (dispose)\n sr.Close();\n isDispose = true;\n }\n }\n\n ~InputReader()\n {\n Dispose(false);\n }\n}", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "b929283a526481bd99a3800d8e91bcc0", "src_uid": "5482ed8ad02ac32d28c3888299bf3658", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Linq;\n\nnamespace Problem831A\n{\n class Program\n {\n static void Main(string[] args)\n {\n Console.ReadLine();\n var a = Console.ReadLine().Split(' ').Select(_ => int.Parse(_)).ToArray();\n\n Console.WriteLine(Check(a) ? \"YES\" : \"NO\");\n }\n\n static bool Check(int[] a)\n {\n int le = -1;\n int l = a.Length;\n int i = 0;\n if (l == 1)\n return true;\n\n while (i < l && a[i] > le)\n {\n le = a[i];\n i++;\n }\n if (i == l && a[l - 1] > a[l - 2])\n return true;\n\n if (a[i] == le)\n {\n while (i < l && a[i] == le)\n {\n le = a[i];\n i++;\n }\n\n if (i == l && a[l - 1] == a[l - 2])\n return true;\n }\n le = a[i - 1];\n while (i < l && a[i] < le)\n {\n le = a[i];\n i++;\n }\n\n if (i != l)\n return false;\n\n return true;\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "f48f25cd1f5737078e5edd66b18ca620", "src_uid": "5482ed8ad02ac32d28c3888299bf3658", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "C# 8", "source_code": "using System;\r\nusing System.Collections.Generic;\r\nusing System.Linq;\r\nusing System.IO;\r\nusing System.Threading;\r\nusing System.Text;\r\nusing System.Text.RegularExpressions;\r\nusing System.Diagnostics;\r\nusing static util;\r\nusing P = pair;\r\n\r\nclass Program {\r\n static void Main(string[] args) {\r\n var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };\r\n var solver = new Solver(sw);\r\n // var t = new Thread(solver.solve, 1 << 28); // 256 MB\r\n // t.Start();\r\n // t.Join();\r\n solver.solve();\r\n sw.Flush();\r\n }\r\n}\r\n\r\nclass Solver {\r\n StreamWriter sw;\r\n Scan sc;\r\n void Prt(string a) => sw.WriteLine(a);\r\n void Prt(IEnumerable a) => Prt(string.Join(\" \", a));\r\n void Prt(params object[] a) => Prt(string.Join(\" \", a));\r\n public Solver(StreamWriter sw) {\r\n this.sw = sw;\r\n this.sc = new Scan();\r\n }\r\n\r\n public void solve() {\r\n var s = sc.Str;\r\n var a = s.Select(x => x - 'A').ToArray();\r\n for (int i = 0; i + 2 < a.Length; i++)\r\n {\r\n if (a[i + 2] != (a[i] + a[i + 1]) % 26) {\r\n Prt(\"NO\");\r\n return;\r\n }\r\n }\r\n Prt(\"YES\");\r\n\r\n }\r\n}\r\n\r\nclass pair : IComparable> {\r\n public T v1;\r\n public U v2;\r\n public pair() : this(default(T), default(U)) {}\r\n public pair(T v1, U v2) { this.v1 = v1; this.v2 = v2; }\r\n public int CompareTo(pair a) {\r\n int c = Comparer.Default.Compare(v1, a.v1);\r\n return c != 0 ? c : Comparer.Default.Compare(v2, a.v2);\r\n }\r\n public override string ToString() => $\"{v1} {v2}\";\r\n public void Deconstruct(out T a, out U b) { a = v1; b = v2; }\r\n}\r\nstatic class util {\r\n public static readonly int M = 1000000007;\r\n // public static readonly int M = 998244353;\r\n public static readonly long LM = 1L << 60;\r\n public static readonly double eps = 1e-11;\r\n public static void DBG(string a) => Console.Error.WriteLine(a);\r\n public static void DBG(IEnumerable a) => DBG(string.Join(\" \", a));\r\n public static void DBG(params object[] a) => DBG(string.Join(\" \", a));\r\n public static void Assert(params bool[] conds) {\r\n if (conds.Any(x => !x)) throw new Exception();\r\n }\r\n public static pair make_pair(T v1, U v2) => new pair(v1, v2);\r\n public static int CompareList(IList a, IList b) where T : IComparable {\r\n for (int i = 0; i < a.Count && i < b.Count; i++)\r\n if (a[i].CompareTo(b[i]) != 0) return a[i].CompareTo(b[i]);\r\n return a.Count.CompareTo(b.Count);\r\n }\r\n public static bool inside(int i, int j, int h, int w) => i >= 0 && i < h && j >= 0 && j < w;\r\n public static readonly int[] dd = { 0, 1, 0, -1 };\r\n // static readonly string dstring = \"RDLU\";\r\n public static IEnumerable

adjacents(int i, int j) {\r\n for (int k = 0; k < 4; k++) yield return new P(i + dd[k], j + dd[k ^ 1]);\r\n }\r\n public static IEnumerable

adjacents(int i, int j, int h, int w) {\r\n for (int k = 0; k < 4; k++) if (inside(i + dd[k], j + dd[k ^ 1], h, w))\r\n yield return new P(i + dd[k], j + dd[k ^ 1]);\r\n }\r\n public static IEnumerable

adjacents(this P p) => adjacents(p.v1, p.v2);\r\n public static IEnumerable

adjacents(this P p, int h, int w) => adjacents(p.v1, p.v2, h, w);\r\n public static IEnumerable all_subset(this int p) {\r\n for (int i = 0; ; i = i - p & p) {\r\n yield return i;\r\n if (i == p) break;\r\n }\r\n }\r\n public static Dictionary compress(this IEnumerable a)\r\n => a.Distinct().OrderBy(v => v).Select((v, i) => new { v, i }).ToDictionary(p => p.v, p => p.i);\r\n public static Dictionary compress(params IEnumerable[] a)\r\n => compress(a.SelectMany(x => x));\r\n public static T[] inv(this Dictionary dic) {\r\n var res = new T[dic.Count];\r\n foreach (var item in dic) res[item.Value] = item.Key;\r\n return res;\r\n }\r\n public static void swap(ref T a, ref T b) where T : struct { var t = a; a = b; b = t; }\r\n public static void swap(this IList a, int i, int j) where T : struct {\r\n var t = a[i]; a[i] = a[j]; a[j] = t;\r\n }\r\n public static T[] copy(this IList a) {\r\n var ret = new T[a.Count];\r\n for (int i = 0; i < a.Count; i++) ret[i] = a[i];\r\n return ret;\r\n }\r\n}\r\n\r\nclass Scan {\r\n StreamReader sr;\r\n public Scan() { sr = new StreamReader(Console.OpenStandardInput()); }\r\n public Scan(string path) { sr = new StreamReader(path); }\r\n public int Int => int.Parse(Str);\r\n public long Long => long.Parse(Str);\r\n public double Double => double.Parse(Str);\r\n public string Str => ReadLine.Trim();\r\n public string ReadLine => sr.ReadLine();\r\n public pair Pair() {\r\n T a; U b;\r\n Multi(out a, out b);\r\n return new pair(a, b);\r\n }\r\n public P P => Pair();\r\n public int[] IntArr => StrArr.Select(int.Parse).ToArray();\r\n public long[] LongArr => StrArr.Select(long.Parse).ToArray();\r\n public double[] DoubleArr => StrArr.Select(double.Parse).ToArray();\r\n public string[] StrArr => Str.Split(new[]{' '}, StringSplitOptions.RemoveEmptyEntries);\r\n bool eq() => typeof(T).Equals(typeof(U));\r\n T ct(U a) => (T)Convert.ChangeType(a, typeof(T));\r\n T cv(string s) => eq() ? ct(int.Parse(s))\r\n : eq() ? ct(long.Parse(s))\r\n : eq() ? ct(double.Parse(s))\r\n : eq() ? ct(s[0])\r\n : ct(s);\r\n public void Multi(out T a) => a = cv(Str);\r\n public void Multi(out T a, out U b) {\r\n var ar = StrArr; a = cv(ar[0]); b = cv(ar[1]);\r\n }\r\n public void Multi(out T a, out U b, out V c) {\r\n var ar = StrArr; a = cv(ar[0]); b = cv(ar[1]); c = cv(ar[2]);\r\n }\r\n public void Multi(out T a, out U b, out V c, out W d) {\r\n var ar = StrArr; a = cv(ar[0]); b = cv(ar[1]); c = cv(ar[2]); d = cv(ar[3]);\r\n }\r\n public void Multi(out T a, out U b, out V c, out W d, out X e) {\r\n var ar = StrArr;\r\n a = cv(ar[0]); b = cv(ar[1]); c = cv(ar[2]); d = cv(ar[3]); e = cv(ar[4]);\r\n }\r\n public void Multi(out T a, out U b, out V c, out W d, out X e, out Y f) {\r\n var ar = StrArr;\r\n a = cv(ar[0]); b = cv(ar[1]); c = cv(ar[2]);\r\n d = cv(ar[3]); e = cv(ar[4]); f = cv(ar[5]);\r\n }\r\n}\r\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "f281c062266d68a315f97f36fab99083", "src_uid": "27e977b41f5b6970a032d13e53db2a6a", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "C# 8", "source_code": "using System;\r\nusing System.Text;\r\nusing System.Collections.Generic;\r\nusing System.Linq;\r\nusing static System.Console;\r\nusing System.IO;\r\n\r\nnamespace TestCodes\r\n{\r\n class Problem\r\n {\r\n static void Main()\r\n {\r\n var w = ReadLine();\r\n\r\n if (string.IsNullOrEmpty(w))\r\n WriteLine(\"YES\");\r\n else if (w.Length <= 2)\r\n\t\t\t\tWriteLine(\"YES\");\r\n else if (((w[0] - 'A' + w[1] - 'A') % 26) == (w[2] - 'A'))\r\n WriteLine(\"YES\");\r\n else\r\n WriteLine(\"NO\");\r\n }\r\n }\r\n}\r\n\r\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "3563452dfd65cf80c7ce6c123e5e7013", "src_uid": "27e977b41f5b6970a032d13e53db2a6a", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\n\nnamespace Skyscraper\n{\n class Program\n {\n static void Main()\n {\n int t1 = Convert.ToInt32(Console.ReadLine());\n int t2 = Convert.ToInt32(Console.ReadLine());\n int t3 = Convert.ToInt32(Console.ReadLine());\n int t4 = Convert.ToInt32(Console.ReadLine());\n if (t3 > 0)\n if (t1 == 0)\n {\n Console.WriteLine(\"0\");\n return;\n }\n if (t1 != t4)\n {\n Console.WriteLine(\"0\");\n return;\n }\n Console.WriteLine(\"1\");\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["greedy", "implementation"], "code_uid": "973b067af6c4c19284c8263a5040bd20", "src_uid": "b99578086043537297d374dc01eeb6f8", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "/*\ncsc -debug A.cs && mono --debug A.exe <<< \"3\n1\n4\n3\"\n*/\n\nusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\n\npublic class HelloWorld {\n public static void SolveCodeForces() {\n var A = cin.NextInt();\n var B = cin.NextInt();\n var C = cin.NextInt();\n var D = cin.NextInt();\n\n if (A + C + D == 0) {\n System.Console.WriteLine(1);\n return;\n }\n\n if (A == 0) {\n System.Console.WriteLine(0);\n return;\n }\n\n if (D != A) {\n System.Console.WriteLine(0);\n return;\n }\n\n System.Console.WriteLine(1);\n }\n\n static Scanner cin = new Scanner();\n static StringBuilder cout = new StringBuilder();\n\n static public void Main () {\n SolveCodeForces();\n // System.Console.Write(cout.ToString());\n }\n}\n\npublic static class Helpers {\n public static T[] CreateArray(int length, Func itemCreate) {\n var result = new T[length];\n for (var i = 0; i < result.Length; i++)\n result[i] = itemCreate(i);\n return result;\n }\n\n public static IEnumerable IndicesWhere(this IEnumerable seq, Func cond) {\n var i = 0;\n foreach (var item in seq) {\n if (cond(item)) yield return i;\n i++;\n }\n }\n}\n\npublic class Scanner\n{\n private string[] line = new string[0];\n private int index = 0;\n\n public string Next() {\n if (line.Length <= index) {\n line = Console.ReadLine().Split(' ');\n index = 0;\n }\n var res = line[index];\n index++;\n return res;\n }\n\n public int NextInt() {\n return int.Parse(Next());\n }\n\n public long NextLong() {\n return long.Parse(Next());\n }\n\n public ulong NextUlong() {\n return ulong.Parse(Next());\n }\n\n public string[] Array() {\n line = Console.ReadLine().Split(' ');\n index = line.Length;\n return line;\n }\n\n public int[] IntArray(int emptyPrefixLen = 0) {\n var array = Array();\n var result = new int[emptyPrefixLen + array.Length];\n for (int i = 0; i < array.Length; i++)\n result[emptyPrefixLen + i] = int.Parse(array[i]);\n return result;\n }\n\n public long[] LongArray() {\n var array = Array();\n var result = new long[array.Length];\n for (int i = 0; i < array.Length; i++)\n result[i] = long.Parse(array[i]);\n return result;\n }\n\n public ulong[] UlongArray() {\n var array = Array();\n var result = new ulong[array.Length];\n for (int i = 0; i < array.Length; i++)\n result[i] = ulong.Parse(array[i]);\n return result;\n }\n}", "lang_cluster": "C#", "tags": ["greedy", "implementation"], "code_uid": "5a832bdb6552cfc714a859c5e8c8c67c", "src_uid": "b99578086043537297d374dc01eeb6f8", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": " using System;\n using System.Collections.Generic;\n using System.Linq;\n using System.Text;\n\n class Program\n {\n static void Main(string[] args)\n {\n var str = Console.ReadLine().Split(' ').ToList();\n long n = long.Parse(str[0]);\n long k = long.Parse(str[1]);\n int t = 0;\n int f = 0;\n\n long tmp = n;\n while(tmp % 2 == 0) \n {\n t++;\n tmp = tmp / 2;\n }\n tmp= n;\n while(tmp % 5 == 0) \n {\n f++;\n tmp /= 5;\n }\n\n\n\n if (k == 0) { Console.WriteLine(n); return; }\n\n long t1 = (k - t) > 0 ? k - t : 0;\n long f2 = (k - f) > 0 ? k - f : 0;\n\n long val = n * ((long) Math.Pow(2, t1)) * ((long) Math.Pow(5, f2));\n\n Console.WriteLine(val);\n\n }\n }", "lang_cluster": "C#", "tags": ["math", "number theory"], "code_uid": "f298a0cb6f40d42bc9d24174c80cb2d0", "src_uid": "73566d4d9f20f7bbf71bc06bc9a4e9f3", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\n\nnamespace CodeForces\n{\n\tclass A\n\t{\n\t\tstatic long gcd(long a, long b)\n\t\t{\n\t\t\twhile (b != 0)\n\t\t\t{\n\t\t\t\tlong temp = b;\n\t\t\t\tb = a % b;\n\t\t\t\ta = temp;\n\t\t\t}\n\t\t\treturn a;\n\t\t}\n\n\t\tstatic long lcm(long m, long n)\n\t\t{\n\t\t\treturn (m / gcd(m, n)) * n;\n\t\t}\n\n\t\tstatic void Main(string[] args)\n\t\t{\n\t\t\tstring s = Console.ReadLine();\n\t\t\tstring[] d = s.Split(' ');\n\t\t\tlong n = long.Parse(d[0]);\n\t\t\tint k = int.Parse(d[1]);\n\t\t\tint div = (int) Math.Pow(10, k);\n\n\t\t\tConsole.WriteLine(lcm(n, div));\n\t\t}\n\t}\n}\n", "lang_cluster": "C#", "tags": ["math", "number theory"], "code_uid": "b8d73a0802af16bb337f5ef4464705e2", "src_uid": "73566d4d9f20f7bbf71bc06bc9a4e9f3", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.IO;\nusing System.Collections.Generic;\nusing System.Globalization;\nusing System.Linq;\n\n\n\nclass Program\n{\n\n\n //////////////////////////////////////////////////\n void Solution()\n {\n var x = ri;\n var y = ri;\n long res = 0;\n if (y < x)\n {\n var buf = y;\n y = x;\n x = buf;\n }\n for (int i = 1; i <= x; i++)\n {\n res += (y + (i % 5)) / 5;\n }\n wln(res);\n }\n //////////////////////////////////////////////////\n\n static void swap(ref object o1, ref object o2) { var o = o1; o1 = o2; o2 = o; }\n static void wln(object o = null) { Console.WriteLine(o); }\n static void wsp(object o) { Console.Write(o + \" \"); }\n static void wrt(object o) { Console.Write(o); }\n //Console.Write(string.Format(CultureInfo.InvariantCulture, \"{0:F12}\", o));\n\n static long gcd(long a, long b) { return (b != 0) ? gcd(b, a % b) : a; }\n static long lcm(long a, long b) { return a / gcd(a, b) * b; }\n\n int ri\n {\n get\n {\n _read(); while (_str[_ind] == ' ') ++_ind;\n int sign = 1; if (_str[_ind] == '-') { sign = -1; ++_ind; }\n int p = 0;\n while (_ind < _count && _str[_ind] != ' ') p = p * 10 + _str[_ind++] - '0';\n while (_ind < _count && _str[_ind] == ' ') ++_ind; return p * sign;\n }\n }\n long rl\n {\n get\n {\n _read(); while (_str[_ind] == ' ') ++_ind;\n int sign = 1; if (_str[_ind] == '-') { sign = -1; ++_ind; }\n long p = 0;\n while (_ind < _count && _str[_ind] != ' ') p = p * 10 + _str[_ind++] - '0';\n while (_ind < _count && _str[_ind] == ' ') ++_ind; return p * sign;\n }\n }\n double rd\n {\n get\n {\n _read(); while (_str[_ind] == ' ') ++_ind; int sign = 1; if (_str[_ind] == '-') { sign = -1; ++_ind; }\n long p = 0, q = 1; while (_ind < _count && _str[_ind] != ' ' && _str[_ind] != '.') p = p * 10 + _str[_ind++] - '0';\n if (_ind < _count && _str[_ind] == '.') { ++_ind; while (_ind < _count && _str[_ind] != ' ') { p = p * 10 + _str[_ind++] - '0'; q *= 10; } }\n while (_ind < _count && _str[_ind] == ' ') ++_ind; return (double)p / q * sign;\n }\n }\n string rs\n {\n get\n {\n _read(); while (_ind < _count && _str[_ind] == ' ') ++_ind;\n var tmp = _str.IndexOf(' ', _ind);\n if (tmp == -1) { _count = 0; _ind = 0; return _str.Substring(_ind); }\n var s = _str.Substring(_ind, tmp - _ind); _ind = tmp + 1;\n while (_ind < _count && _str[_ind] == ' ') ++_ind; return s;\n }\n }\n\n int[] ria(int n)\n {\n var res = new int[n];\n for (int k = 0; k < n;)\n {\n var s = Console.ReadLine(); var m = s.Length;\n for (int i = 0; i < m && k < n; ++i)\n {\n while (i < m && s[i] == ' ') ++i; if (i == m) break; int sign = 1; if (s[i] == '-') { sign = -1; ++i; }\n int p = 0; while (i < m && s[i] != ' ') p = p * 10 + s[i++] - '0'; res[k++] = p * sign;\n }\n }\n _count = 0; _ind = 0; return res;\n }\n long[] rla(int n)\n {\n var res = new long[n];\n for (int k = 0; k < n;)\n {\n var s = Console.ReadLine(); var m = s.Length;\n for (int i = 0; i < m && k < n; ++i)\n {\n while (i < m && s[i] == ' ') ++i; if (i == m) break; int sign = 1; if (s[i] == '-') { sign = -1; ++i; }\n long p = 0; while (i < m && s[i] != ' ') p = p * 10 + s[i++] - '0'; res[k++] = p * sign;\n }\n }\n _count = 0; _ind = 0; return res;\n }\n double[] rda(int n)\n {\n var res = new double[n];\n for (int k = 0; k < n;)\n {\n var s = Console.ReadLine(); var m = s.Length;\n for (int i = 0; i < m && k < n; ++i)\n {\n while (i < m && s[i] == ' ') ++i; if (i == m) break; int sign = 1; if (s[i] == '-') { sign = -1; ++i; }\n long p = 0, q = 1; while (i < m && s[i] != ' ' && s[i] != '.') p = p * 10 + s[i++] - '0';\n if (i < m && s[i] == '.') { ++i; while (i < m && s[i] != ' ') { p = p * 10 + s[i++] - '0'; q *= 10; } }\n res[k++] = (double)p / q * sign;\n }\n }\n _count = 0; _ind = 0; return res;\n }\n string[] rsa(int n) { var res = new string[n]; for (int k = 0; k < n; ++k) res[k] = Console.ReadLine(); _count = 0; _ind = 0; return res; }\n string _str = null; int _count = 0; int _ind = 0;\n void _read() { if (_ind == _count) { _str = Console.ReadLine(); _count = _str.Length; _ind = 0; } }\n static void Main() { new Program().Solution(); }\n}", "lang_cluster": "C#", "tags": ["math", "constructive algorithms", "number theory"], "code_uid": "ca950c880f834d9135df306bef7abc22", "src_uid": "df0879635b59e141c839d9599abd77d2", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace CodeforcesRound358A\n{\n class Program\n {\n static void Main(string[] args)\n {\n string[] inp = Console.ReadLine().Split();\n\n int n = Convert.ToInt32(inp[0]);\n int m = Convert.ToInt32(inp[1]);\n int k = 0;\n\n long cnt = 0;\n\n for (int i = 1; i <= n; i++)\n {\n k = (i/5 + 1) * 5 - i;\n\n cnt += m / 5;\n if (m % 5 >= k)\n cnt++;\n }\n\n Console.WriteLine(cnt);\n //inp = Console.ReadLine().Split();\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "constructive algorithms", "number theory"], "code_uid": "3374b476c8d8125be1c862f0047526b9", "src_uid": "df0879635b59e141c839d9599abd77d2", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Globalization;\nusing System.IO;\nusing System.Linq;\nusing System.Text;\npublic class Codeforces\n{\n protected static TextReader reader;\n protected static TextWriter writer;\n static void Main()\n {\n reader = new StreamReader(Console.OpenStandardInput(1024 * 10), System.Text.Encoding.ASCII, false, 1024 * 10);\n writer = new StreamWriter(Console.OpenStandardOutput(1024 * 10), System.Text.Encoding.ASCII, 1024 * 10);\n var n = ReadInt();\n var b = ReadIntArray().OrderBy(d => d).ToArray();\n var c = 0;\n for (int i = 0; i < n; i++)\n {\n if (i + 1 > c * (b[i] + 1))\n {\n c++;\n }\n }\n writer.WriteLine(c);\n reader.Close();\n writer.Close();\n }\n #region Read / Write\n\n private static Queue currentLineTokens = new Queue();\n\n private static string[] ReadAndSplitLine()\n {\n return reader.ReadLine().Split(new[] { ' ', '\\t' }, StringSplitOptions.RemoveEmptyEntries);\n }\n\n public static string ReadToken()\n {\n while (currentLineTokens.Count == 0)\n currentLineTokens = new Queue(ReadAndSplitLine());\n return currentLineTokens.Dequeue();\n }\n\n public static int ReadInt()\n {\n return int.Parse(ReadToken());\n }\n\n public static long ReadLong()\n {\n return long.Parse(ReadToken());\n }\n\n public static double ReadDouble()\n {\n return double.Parse(ReadToken(), CultureInfo.InvariantCulture);\n }\n\n public static int[] ReadIntArray()\n {\n return ReadAndSplitLine().Select(int.Parse).ToArray();\n }\n\n public static long[] ReadLongArray()\n {\n return ReadAndSplitLine().Select(long.Parse).ToArray();\n }\n\n public static double[] ReadDoubleArray()\n {\n return ReadAndSplitLine().Select(s => double.Parse(s, CultureInfo.InvariantCulture)).ToArray();\n }\n public static int[][] ReadIntMatrix(int numberOfRows)\n {\n int[][] matrix = new int[numberOfRows][];\n for (int i = 0; i < numberOfRows; i++)\n matrix[i] = ReadIntArray();\n return matrix;\n }\n public static int[][] ReadAndTransposeIntMatrix(int numberOfRows)\n {\n int[][] matrix = ReadIntMatrix(numberOfRows);\n int[][] ret = new int[matrix[0].Length][];\n for (int i = 0; i < ret.Length; i++)\n {\n ret[i] = new int[numberOfRows];\n for (int j = 0; j < numberOfRows; j++)\n ret[i][j] = matrix[j][i];\n }\n return ret;\n }\n\n public static string[] ReadLines(int quantity)\n {\n string[] lines = new string[quantity];\n for (int i = 0; i < quantity; i++)\n lines[i] = reader.ReadLine().Trim();\n return lines;\n }\n public static void WriteArray(IEnumerable array)\n {\n writer.WriteLine(string.Join(\" \", array));\n }\n\n public static void Write(params T[] array)\n {\n WriteArray(array);\n }\n\n public static void WriteLines(IEnumerable array)\n {\n foreach (var a in array)\n writer.WriteLine(a);\n }\n private static int Next()\n {\n int c;\n int res = 0;\n do\n {\n c = reader.Read();\n if (c == -1)\n return res;\n } while (c != '-' && (c < '0' || c > '9'));\n int sign = 1;\n if (c == '-')\n {\n sign = -1;\n c = reader.Read();\n }\n res = c - '0';\n while (true)\n {\n c = reader.Read();\n if (c < '0' || c > '9')\n return res * sign;\n res *= 10;\n res += c - '0';\n }\n }\n #endregion\n}", "lang_cluster": "C#", "tags": ["sortings", "greedy"], "code_uid": "8179852be7c6fd3a00e49a331901c17e", "src_uid": "7c710ae68f27f140e7e03564492f7214", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Linq;\nusing System.Collections.Generic;\n\npublic class Program\n{\n public static void Main(string[] args)\n {\n var n = Int32.Parse(Console.ReadLine());\n var X = Array.ConvertAll(Console.ReadLine().Split(' '), Convert.ToInt32);\n Array.Sort(X);\n n++;\n var list = new int[n];\n foreach (var x in X)\n {\n var y = x;\n for (int i = 0; i < n; i++)\n {\n if (list[i] <= y)\n {\n list[i]++;\n break;\n }\n }\n }\n for (int i = 0; i < n; i++)\n if (list[i] == 0)\n {\n Console.WriteLine(i);\n return;\n }\n \n }\n}", "lang_cluster": "C#", "tags": ["sortings", "greedy"], "code_uid": "b162f4e56c5d2103ce7ec26f6f399e11", "src_uid": "7c710ae68f27f140e7e03564492f7214", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.IO;\nusing SB = System.Text.StringBuilder;\n//using System.Threading.Tasks;\n//using System.Text.RegularExpressions;\n//using System.Globalization;\n//using System.Diagnostics;\nusing static System.Console;\nusing System.Numerics;\nusing static System.Math;\nusing pair = Pair;\n\nclass Program\n{\n static void Main()\n {\n //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });\n new Program().solve();\n Out.Flush();\n }\n readonly Scanner cin = new Scanner();\n readonly int[] dd = { 0, 1, 0, -1, 0 }; //\u2192\u2193\u2190\u2191\n readonly int mod = 1000000007;\n readonly int dom = 998244353;\n bool chmax(ref T a, T b) where T : IComparable { if (a.CompareTo(b) < 0) { a = b; return true; } return false; }\n bool chmin(ref T a, T b) where T : IComparable { if (b.CompareTo(a) < 0) { a = b; return true; } return false; }\n\n void solve()\n {\n int N = cin.nextint;\n int M = cin.nextint;\n\n if (M == 0)\n {\n WriteLine(1);\n return;\n }\n\n if (N % 2 == 0)\n {\n if (M <= N / 2)\n {\n WriteLine(M);\n return;\n }\n else\n {\n WriteLine(N - M);\n }\n }\n else\n {\n int X = N / 2;\n if (true)\n {\n if (M <= X)\n {\n WriteLine(M);\n }\n else\n { \n WriteLine(N - M);\n }\n\n }\n }\n }\n\n}\n\n\nstatic class Ex\n{\n public static void join(this IEnumerable values, string sep = \" \") => WriteLine(string.Join(sep, values));\n public static string concat(this IEnumerable values) => string.Concat(values);\n public static string reverse(this string s) { var t = s.ToCharArray(); Array.Reverse(t); return t.concat(); }\n\n public static int lower_bound(this IList arr, T val) where T : IComparable\n {\n int low = 0, high = arr.Count;\n int mid;\n while (low < high)\n {\n mid = ((high - low) >> 1) + low;\n if (arr[mid].CompareTo(val) < 0) low = mid + 1;\n else high = mid;\n }\n return low;\n }\n public static int upper_bound(this IList arr, T val) where T : IComparable\n {\n int low = 0, high = arr.Count;\n int mid;\n while (low < high)\n {\n mid = ((high - low) >> 1) + low;\n if (arr[mid].CompareTo(val) <= 0) low = mid + 1;\n else high = mid;\n }\n return low;\n }\n}\n\nclass Pair : IComparable> where T : IComparable where U : IComparable\n{\n public T f; public U s;\n public Pair(T f, U s) { this.f = f; this.s = s; }\n public int CompareTo(Pair a) => f.CompareTo(a.f) != 0 ? f.CompareTo(a.f) : s.CompareTo(a.s);\n public override string ToString() => $\"{f} {s}\";\n}\n\nclass Scanner\n{\n string[] s; int i;\n readonly char[] cs = new char[] { ' ' };\n public Scanner() { s = new string[0]; i = 0; }\n public string[] scan => ReadLine().Split();\n public int[] scanint => Array.ConvertAll(scan, int.Parse);\n public long[] scanlong => Array.ConvertAll(scan, long.Parse);\n public double[] scandouble => Array.ConvertAll(scan, double.Parse);\n public string next\n {\n get\n {\n if (i < s.Length) return s[i++];\n string st = ReadLine();\n while (st == \"\") st = ReadLine();\n s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);\n i = 0;\n return next;\n }\n }\n public int nextint => int.Parse(next);\n public long nextlong => long.Parse(next);\n public double nextdouble => double.Parse(next);\n}\n", "lang_cluster": "C#", "tags": ["math", "greedy"], "code_uid": "3efe80cc18195c57899cafaead266007", "src_uid": "c05d0a9cabe04d8fb48c76d2ce033648", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Linq;\n\nnamespace ConsoleApp1\n{\n class Program\n {\n static void Main(string[] args)\n {\n int[] nm = Console.ReadLine().Split().Select(t => Convert.ToInt32(t)).ToArray();\n (int n, int m) = (nm[0], nm[1]);\n int res = 1;\n if (m > 0)\n res = n / m >= 2 ? m : n - m;\n Console.WriteLine(res);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "greedy"], "code_uid": "1abcd9fd76867d77200abaf3fe4db635", "src_uid": "c05d0a9cabe04d8fb48c76d2ce033648", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\n\nnamespace CrocCupB\n{\n class Program\n {\n static void Main(string[] args)\n {\n //\u043f\u043e\u043b\u0443\u0447\u0438\u043c \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435\n var nkList = Console.ReadLine().Split(' ').Select(int.Parse).ToList();\n var a = nkList[0];\n var b = nkList[1];\n var m = nkList[2];\n var r0 = nkList[3];\n\n var randGenerator = new RandGenerator(a, b, m, r0);\n var randList = new Dictionary();\n\n //\u043f\u043e\u0438\u0449\u0435\u043c \u0446\u0438\u043a\u043b...\n var curRandom = randGenerator.GetNext();\n var cycleIndex = -1;\n var n = 0;\n while (!randList.ContainsKey(curRandom))\n {\n randList.Add(curRandom, n);\n curRandom = randGenerator.GetNext();\n n++;\n }\n\n Console.WriteLine(randList.Count - randList[curRandom]);\n }\n }\n\n internal class RandGenerator\n {\n private readonly int _a;\n private readonly int _b;\n private readonly int _m;\n private int _ri;\n\n public RandGenerator(int a, int b, int m, int r0)\n {\n _a = a;\n _b = b;\n _m = m;\n _ri = r0;\n }\n\n public int GetNext()\n {\n return _ri = (((_a*_ri) + _b)%_m);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["implementation", "number theory"], "code_uid": "f551bd81dc2a4b086084a1dc8df39783", "src_uid": "9137197ee1b781cd5cc77c46f50b9012", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\n\nnamespace T2\n{\n class Program \n {\n static Int32 a;\n static Int32 b;\n static Int32 m;\n static Int32 r0;\n\n static Int32 gen(Int32 r)\n {\n return (a * r + b) % m;\n }\n\n static void Main(string[] args)\n {\n String[] input = Console.ReadLine().Split();\n a = Int32.Parse(input[0]);\n b = Int32.Parse(input[1]);\n m = Int32.Parse(input[2]);\n r0 = Int32.Parse(input[3]);\n Dictionary vals = new Dictionary();\n\n Int32 r = r0;\n\n Int32 klav = 0;\n while (true)\n {\n klav++;\n r = gen(r);\n if (vals.ContainsKey(r))\n {\n Console.Write(klav - vals[r]);\n break;\n }\n else\n {\n vals.Add(r, klav);\n } \n }\n }\n }\n}", "lang_cluster": "C#", "tags": ["implementation", "number theory"], "code_uid": "14ac1e49824be46be3a89baf985690e5", "src_uid": "9137197ee1b781cd5cc77c46f50b9012", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "// ReSharper disable All\n\nnamespace Codeforces\n{\n using System;\n using System.Collections;\n using System.Collections.Generic;\n using System.IO;\n using System.Linq;\n\n class Program\n {\n static void Main(string[] args)\n {\n List l = new List();\n var n = int.Parse(Console.ReadLine());\n for (int i = 0; i < n; i++)\n l.Add(int.Parse(Console.ReadLine()));\n\n Stack s = new Stack();\n s.Push(3);\n\n List lista = new List();\n lista.Add(1);\n lista.Add(2);\n var res = 0;\n for (int i = 0; i < n; i++)\n {\n\n if (l[i] == 1)\n {\n if (s.Contains(1))\n {\n res++;\n break;\n }\n\n var temp = (from a in lista where a != 1 select a).FirstOrDefault();\n lista.Remove(temp);\n var sta = s.Pop();\n lista.Add(sta);\n s.Push(temp);\n }\n else if (l[i] == 2)\n {\n if (s.Contains(2)) { res++;\n break;\n }\n\n var temp = (from a in lista where a != 2 select a).FirstOrDefault();\n lista.Remove(temp);\n var sta = s.Pop();\n lista.Add(sta);\n s.Push(temp);\n }\n else if (l[i] == 3)\n {\n\n if (s.Contains(3))\n {\n res++;\n break;\n }\n\n var temp = (from a in lista where a != 3 select a).FirstOrDefault();\n lista.Remove(temp);\n var sta = s.Pop();\n lista.Add(sta);\n s.Push(temp);\n }\n\n }\n \n\n if(res == 0)\n Console.WriteLine(\"YES\");\n else \n Console.WriteLine(\"NO\");\n }\n }\n\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "776f6c993d9cce32d8fc088720ad1ad3", "src_uid": "6c7ab07abdf157c24be92f49fd1d8d87", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\n\nclass Program\n{\n static void Swap(ref int Right, ref int Left)\n {\n int temp = Right;\n Right = Left;\n Left = temp;\n }\n\n static void Main()\n {\n int n = int.Parse(Console.ReadLine());\n int k1 = 1;\n int k2 = 2;\n int k3 = 3;\n for (int i = 0; i < n; i++)\n {\n int a = int.Parse(Console.ReadLine());\n if (k3 == a)\n {\n Console.WriteLine(\"NO\");\n return;\n }\n if (a == k1)\n Swap(ref k2, ref k3);\n if (a == k2)\n Swap(ref k1, ref k3);\n }\n Console.WriteLine(\"YES\");\n }\n}", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "3a258fb56daf3ad19c37882f21bc7f0b", "src_uid": "6c7ab07abdf157c24be92f49fd1d8d87", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\n\nnamespace _780B\n{\n class c\n {\n public ulong sumDigits(ulong n)\n {\n ulong sum = 0;\n while (n != 0)\n {\n sum = sum + n % 10;\n n = n / 10;\n }\n return sum;\n }\n }\n class Program\n {\n static void Main(string[] args)\n {\n c c = new c();\n int i,j;\n ulong max1 = 0, max2 = 0, sum=0,temp3;\n ulong[] a = new ulong[19];\n string x, temp;\n x = Console.ReadLine();\n temp = x;\n\n for (i = 0; i < x.Length; i++)\n {\n\n a[i] = Convert.ToUInt64(temp);\n temp3=c.sumDigits(a[i]);\n if (temp3 > max2)\n {\n max2 = temp3;\n max1 = a[i];\n }\n else if (temp3 == max2)\n {\n if (a[i] > max1)\n {\n max1 = a[i];\n }\n }\n\n temp = x;\n if (x[i] == '9')\n {\n temp=temp.Remove(i, 1).Insert(i, \"8\");\n for (j = i+1; j 9)\n {\n strM = x.ToString().Substring(1);\n for (int i = 0; i < strM.Length - 1; i++)\n {\n strH += \"9\";\n }\n if (sumNum(strM) < 9 * strM.Length - 1)\n {\n if (long.Parse(strM) < long.Parse(strH))\n {\n //Console.WriteLine(long.Parse((byte.Parse(x.ToString().Substring(0, 1)) - 1) + \"9\" + strH.Substring(1)));\n q = long.Parse((byte.Parse(x.ToString().Substring(0, 1)) - 1) + \"9\" + strH.Substring(1));\n }\n else\n {\n int strHLen = strH.Length, k = 2;\n strH = strH.Substring(1) + \"8\";\n while (long.Parse(strH) > long.Parse(strM))\n {\n strH = \"\";\n for (int i = 0; i < strHLen - k; i++)\n {\n strH += \"9\";\n }\n strH += \"8\";\n for (int i = strHLen - k + 1; i < strHLen; i++)\n {\n strH += \"9\";\n }\n k++;\n }\n //Console.WriteLine(x.ToString().Substring(0, 1) + strH);\n q = long.Parse(x.ToString().Substring(0, 1) + strH);\n }\n }\n else\n {\n //Console.WriteLine(x);\n q = x;\n }\n }\n else\n {\n //Console.WriteLine(x);\n q = x;\n }\n return q;\n }\n static void Main(string[] args)\n {\n long x = long.Parse(Console.ReadLine());\n Console.WriteLine(Tru(x));\n }\n }\n}", "lang_cluster": "C#", "tags": ["math", "implementation"], "code_uid": "d0642c2c9ca44b74b596fc2fa74ce394", "src_uid": "e55b0debbf33c266091e6634494356b8", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Diagnostics;\nusing System.Runtime.InteropServices;\nusing System.Runtime.Remoting.Messaging;\nusing System.Security.Principal;\nusing System.Text;\nusing System.Linq;\nusing System.IO;\nusing System.Globalization;\nusing System.Collections;\nusing System.Text.RegularExpressions;\n\nnamespace Task\n{\n\n #region MyIo\n\n internal class MyIo : IDisposable\n {\n#if LOCAL_TEST\n private readonly TextReader inputStream = new StreamReader(\"input.txt\");\n#else\n private readonly TextReader inputStream = Console.In;\n#endif\n#if FBHC_TEST\n private readonly TextWriter outputStream = new StreamWriter(\"output.txt\");\n#else\n private readonly TextWriter outputStream = Console.Out;\n#endif\n\n private string[] tokens;\n private int pointer;\n\n public char NextChar()\n {\n try\n {\n var c = inputStream.Read();\n\n if (c < 0)\n c = 0;\n\n return (char)c;\n }\n catch (IOException)\n {\n return '\\0';\n }\n }\n\n public string NextLine()\n {\n try\n {\n return inputStream.ReadLine();\n }\n catch (IOException)\n {\n return null;\n }\n }\n\n public string NextString()\n {\n try\n {\n while (tokens == null || pointer >= tokens.Length)\n {\n tokens = (NextLine() + string.Empty).Split(new[] { ' ', '\\t' }, StringSplitOptions.RemoveEmptyEntries);\n pointer = 0;\n }\n return tokens[pointer++];\n }\n catch (IOException)\n {\n return null;\n }\n }\n\n public int NextInt()\n {\n return Next();\n }\n\n public long NextLong()\n {\n return Next();\n }\n\n public T Next()\n {\n var t = typeof(T);\n\n if (t == typeof(char))\n return (T)(object)NextChar();\n\n object s = NextString();\n\n if (t == typeof(string))\n return (T)s;\n\n return (T)Convert.ChangeType(s, typeof(T));\n }\n\n\n public IEnumerable NextWhile(Predicate pred)\n {\n if (pred == null)\n yield break;\n\n var res = Next();\n\n while (pred(res))\n {\n yield return res;\n\n res = Next();\n }\n }\n\n public IEnumerable NextSeq(long n)\n {\n for (var i = 0; i < n; i++)\n yield return Next();\n }\n\n public void Print(string format, params object[] args)\n {\n outputStream.Write(string.Format(CultureInfo.InvariantCulture, format, args));\n }\n\n public void PrintLine(string format, params object[] args)\n {\n Print(format, args);\n\n outputStream.WriteLine();\n }\n\n public void Print(bool o)\n {\n Print(o ? \"YES\" : \"NO\");\n }\n\n public void PrintLine(bool o)\n {\n Print(o);\n\n outputStream.WriteLine();\n }\n\n public void Print(T o)\n {\n var ienum = o as IEnumerable;\n\n if (ienum != null && typeof(T) != typeof(string))\n {\n var first = true;\n\n foreach (var iev in ienum)\n {\n if (!first && iev != null)\n Print(\" \");\n\n Print(iev);\n\n first = false;\n }\n\n }\n else\n {\n outputStream.Write(Convert.ToString(o, CultureInfo.InvariantCulture));\n }\n\n }\n\n\n public void PrintLine(T o)\n {\n Print(o);\n\n outputStream.WriteLine();\n }\n\n public void Close()\n {\n inputStream.Close();\n outputStream.Close();\n }\n\n void IDisposable.Dispose()\n {\n Close();\n\n#if LOCAL_TEST\n Console.ReadLine();\n#endif\n }\n }\n\n\n public static class ListExtensions\n {\n public static void Each(this IEnumerable self, Action action)\n {\n foreach (var v in self)\n action(v);\n }\n\n public static string Reverse(this string s)\n {\n var charArray = s.ToCharArray();\n Array.Reverse(charArray);\n return new string(charArray);\n }\n\n public static IEnumerable ToCycleEnumerable(this IEnumerable self)\n {\n if (self != null)\n {\n for (; ; )\n {\n foreach (var x in self)\n yield return x;\n }\n }\n }\n\n public static T CycleGet(this IList self, int index)\n {\n var c = self.Count;\n return self[(index % c + c) % c];\n }\n\n\n public static IList Shuffle(this IList self)\n {\n var rnd = new Random(DateTime.Now.Millisecond);\n\n var n = self.Count;\n\n while (n > 1)\n {\n n--;\n var k = rnd.Next(n + 1);\n var value = self[k];\n self[k] = self[n];\n self[n] = value;\n }\n\n return self;\n }\n\n public static IList> UseForNew2D(this T def, int fd, int sd)\n {\n var fdim = new T[fd][];\n\n for (int i = 0; i < fd; i++)\n {\n fdim[i] = new T[sd];\n Fill(fdim[i], def);\n }\n\n return fdim;\n }\n\n public static IList Fill(this IList self, Func, T> fval)\n {\n for (var i = 0; i < self.Count; i++)\n self[i] = fval(i, self);\n\n\n return self;\n }\n\n public static IList Fill(this IList self, Func fval)\n {\n return self.Fill((x, slf) => fval(x));\n }\n\n public static IList Fill(this IList self, Func fval)\n {\n return self.Fill(x => fval());\n }\n\n\n public static IList Fill(this IList self, T val)\n {\n return self.Fill(() => val);\n }\n\n public static long Hash(this IList self, Func val = null)\n {\n return val != null ? self.Hash((t, current) => unchecked(current * 19L + val(t))) : self.Hash(HashOne);\n }\n\n public static long Hash(this IList self, Func val)\n {\n return self.Aggregate(0L, (current, t) => unchecked(val(t, current)));\n }\n\n\n public static long HashOne(this T self, long current)\n {\n return unchecked(current * 19L + (Equals(self, default(T)) ? 0 : self.GetHashCode()));\n }\n\n\n public static IList BuildSegTree(this IList a, Func combine, Func convert)\n {\n var t = new T1[a.Count << 2];\n\n a.BuildSegTree(t, 1, 0, a.Count - 1, combine, convert);\n\n return t;\n }\n\n private static void BuildSegTree(this IList a, IList t, int v, int tl, int tr, Func combine, Func convert)\n {\n if (tl == tr)\n {\n t[v] = convert(a[tl]);\n }\n else\n {\n int tm = (tl + tr) >> 1;\n\n BuildSegTree(a, t, v << 1, tl, tm, combine, convert);\n BuildSegTree(a, t, (v << 1) + 1, tm + 1, tr, combine, convert);\n\n t[v] = combine(t[v << 1], t[(v << 1) + 1]);\n }\n }\n\n public static int Xor1n(this int n)\n {\n return (n >> 1) & 1 ^ ((n & 1) > 0 ? 1 : n);\n }\n }\n\n public static class P\n {\n public static P Create(T1 key, T2 val)\n {\n return new P(key, val);\n }\n }\n\n public class P\n {\n private class PComparer : IComparer>\n {\n private readonly bool? byKey;\n\n public PComparer(bool? byKey)\n {\n this.byKey = byKey;\n }\n\n\n public int Compare(P x, P y)\n {\n x = x ?? new P();\n y = y ?? new P();\n\n\n if (byKey == true)\n return Comparer.Default.Compare(x.Key, y.Key);\n else if (byKey == false)\n return Comparer.Default.Compare(x.Value, y.Value);\n else\n {\n var tr = Comparer.Default.Compare(x.Key, y.Key);\n\n if (tr != 0)\n tr = Comparer.Default.Compare(x.Value, y.Value);\n\n return tr;\n }\n }\n }\n\n\n public P()\n {\n }\n\n public P(T1 key, T2 val)\n {\n this.Key = key;\n this.Value = val;\n }\n\n\n public T1 Key\n {\n get;\n set;\n }\n\n public T2 Value\n {\n get;\n set;\n }\n\n public P Clone()\n {\n return new P(Key, Value);\n }\n\n public static IComparer> KeyComparer\n {\n get { return new PComparer(true); }\n }\n\n public static IComparer> ValueComparer\n {\n get { return new PComparer(false); }\n }\n\n public static implicit operator T1(P obj)\n {\n return obj.Key;\n }\n\n public static implicit operator T2(P obj)\n {\n return obj.Value;\n }\n\n public P SetKey(T1 key)\n {\n Key = key;\n return this;\n }\n\n public P SetValue(T2 value)\n {\n Value = value;\n return this;\n }\n\n public override string ToString()\n {\n return string.Format(\"Key: {0}, Value: {1}\", Key, Value);\n }\n\n public override bool Equals(object obj)\n {\n var co = obj as P;\n\n return co != null && co.GetHashCode() == GetHashCode();\n }\n\n public override int GetHashCode()\n {\n int hash = 17;\n hash = unchecked(hash * 31 + ((Equals(Key, default(T1))) ? 0 : Key.GetHashCode()));\n hash = unchecked(hash * 31 + ((Equals(Value, default(T1))) ? 0 : Value.GetHashCode()));\n return hash;\n\n }\n }\n\n #endregion\n\n\n\n internal class Program\n {\n #region Program\n\n private readonly MyIo io;\n\n public Program(MyIo io)\n {\n this.io = io;\n }\n\n public static void Main(string[] args)\n {\n using (MyIo io = new MyIo())\n {\n new Program(io)\n .Solve();\n }\n }\n\n\n\n #endregion\n\n\n private void Solve()\n {\n var n = io.NextInt();\n var s = io.NextInt();\n\n var max = -1;\n var sum = 0;\n\n for (int i = 0; i < n; i++)\n {\n var ni = io.NextInt();\n\n sum += ni;\n\n if (ni > max)\n max = ni;\n }\n\n io.PrintLine((sum - max > s) ? \"NO\" : \"YES\");\n }\n\n\n }\n\n}\n\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "12f01ef2a48dd92320aef946bdcf1cd0", "src_uid": "496baae594b32c5ffda35b896ebde629", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\n\nnamespace ConsoleApplication1\n{\n class Program\n {\n static void Main(string[] args)\n {\n\n string[] ss = Console.ReadLine().Split(' ');\n int n = Convert.ToInt32(ss[0]);\n int m= Convert.ToInt32(ss[1]);\n string[] s = Console.ReadLine().Split(' ');\n int[] a = new int[n];\n\n for (int i = 0; i < n; i++)\n {\n a[i] = Convert.ToInt32(s[i]);\n }\n Array.Sort(a);\n\n int b = 0;\n for (int i = 0; i < n -1; i++)\n {\n b =b+ a[i];\n }\n\n if (b >m)\n Console.WriteLine(\"NO\");\n else\n Console.WriteLine(\"YES\");\n }\n \n \n }\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "d532626c7ec00fa84b5d444242ea6a71", "src_uid": "496baae594b32c5ffda35b896ebde629", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.IO;\nusing System.Globalization;\n\nnamespace Beresta\n{\n\n\tclass ContestIO : StreamWriter\n\t{\n\t\tpublic ContestIO(Stream streamIn, Stream streamOut) : base(streamOut, Encoding.ASCII, 8192) { Reader = new StreamReader(streamIn, Encoding.ASCII, false, 8192); }\n\t\tpublic ContestIO(string inputFilePath, string outputFilePath) : this(File.OpenRead(inputFilePath), File.OpenWrite(outputFilePath)) { }\n\t\tpublic ContestIO() : this(Console.OpenStandardInput(8192), Console.OpenStandardOutput(8192)) { }\n\t\t//d.ToString(\"N12\", CultureInfo.InvariantCulture).Replace(\",\", \"\")\n\t\tpublic StreamReader Reader;\n\t\t\n\t\tbool IsDigit(int c) { return c >= '0' && c <= '9'; }\n\t\tpublic long Read()\n\t\t{\n\t\t\tint c1 = 0, c;\n\t\t\twhile (!IsDigit(c = Reader.Read())) { c1 = c; }\n\t\t\tlong r = c - '0';\n\t\t\twhile (IsDigit(c = Reader.Read()))\n\t\t\t\tr = r * 10 + c - '0';\n\t\t\treturn c1 == '-' ? -r : r;\n\t\t}\n\t\tpublic long[] ReadArray(int size) { return Enumerable.Range(0, size).Select(v => Read()).ToArray(); }\n\t}\n\n\tclass Program\n\t{\n\n\t\tstatic void Main(string[] args)\n\t\t{\n\t\t\tusing (var io = new ContestIO())\n\t\t\t{\n\t\t\t\tvar x1 = io.Read();\n\t\t\t\tvar y1 = io.Read();\n\t\t\t\tvar x2 = io.Read();\n\t\t\t\tvar y2 = io.Read();\n\n\t\t\t\tvar d = Math.Max(Math.Abs(x2 - x1), Math.Abs(y2 - y1));\n\t\t\t\tio.WriteLine(d);\n\t\t\t}\n\n#if DEBUG\n\t\t\tConsole.ReadLine();\n#endif\n\t\t}\n\n\t}\n\n}\n", "lang_cluster": "C#", "tags": ["math", "implementation"], "code_uid": "c1089ff49782a84da5553d65136f31d4", "src_uid": "a6e9405bc3d4847fe962446bc1c457b4", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Linq;\n\nnamespace codeforces\n{\n class Program\n {\n static void Main(string[] args)\n {\n int[] first= Console.ReadLine().Split().Select(z => int.Parse(z)).ToArray();\n int[] second = Console.ReadLine().Split().Select(z => int.Parse(z)).ToArray();\n int x = Math.Abs(first[0] - second[0]);\n int y = Math.Abs(first[1] - second[1]);\n int max = Math.Max(x, y);\n int min = Math.Min(x, y);\n int rez = min+(max-min);\n Console.WriteLine(rez);\n }\n }\n}\n\n", "lang_cluster": "C#", "tags": ["math", "implementation"], "code_uid": "782f4d7002043ee64c104e41045615f4", "src_uid": "a6e9405bc3d4847fe962446bc1c457b4", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\n\nnamespace GeorgeTime\n{\n class Program\n {\n static void Main(string[] args)\n {\n string[] time1 = Console.ReadLine().Split(':');\n int h1 = Convert.ToInt32(time1[0]);\n int m1 = Convert.ToInt32(time1[1]);\n string[] time2 = Console.ReadLine().Split(':');\n int h2 = Convert.ToInt32(time2[0]);\n int m2 = Convert.ToInt32(time2[1]);\n int h = h1 - h2;\n int m = m1 - m2;\n //if (h1 <= h2)\n //{\n // if (h1 < h2)\n // h = 24;\n // if ((h1 == h2) && (m1 < m2))\n // h = 24;\n //}\n\n \n if (h < 0)\n {\n h = 24 + h;\n }\n if (m < 0)\n {\n m = 60 + m;\n h--;\n }\n string hour = Convert.ToString(h);\n\n string minute = Convert.ToString(m);\n if (h < 10)\n hour = 0 + hour;\n if (m < 10)\n minute = 0 + minute;\n if (h < 0)\n hour = \"23\";\n Console.WriteLine(hour + \":\" + minute);\n //Console.ReadKey();\n\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "53d60806e9ca419c0d7eef95ebeac4ba", "src_uid": "595c4a628c261104c8eedad767e85775", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\npublic struct Time\n{\n public int hours;\n public int minutes;\n}\n\nnamespace ConsoleApplication1\n{\n public class Program\n {\n public static void Main()\n {\n Time Current_time, Time_slept, ans;\n string input, hours, minutes;\n\n input = Console.ReadLine();\n Current_time.hours = int.Parse(input.Substring(0, 2));\n Current_time.minutes = int.Parse(input.Substring(3));\n\n input = Console.ReadLine();\n Time_slept.hours = int.Parse(input.Substring(0, 2));\n Time_slept.minutes = int.Parse(input.Substring(3));\n\n ans.minutes = Current_time.minutes - Time_slept.minutes;\n if (ans.minutes < 0)\n {\n ans.minutes = 60 + ans.minutes;\n --Current_time.hours;\n }\n\n ans.hours = Current_time.hours - Time_slept.hours;\n if (ans.hours < 0)\n ans.hours = 24 + ans.hours;\n\n hours = ans.hours.ToString(\"00\");\n minutes = ans.minutes.ToString(\"00\");\n Console.WriteLine(\"{0}:{1}\", hours, minutes);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "010458db65c40d56fe5c1bd57bb7c698", "src_uid": "595c4a628c261104c8eedad767e85775", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\n \nnamespace codeforces1061A\n{\n class Program\n {\n static void Main(string[] args)\n {\n int[] nm=Array.ConvertAll(Console.ReadLine().Split(' '),e=>int.Parse(e));\n int n = nm[0];\n int m = nm[1];\n Console.WriteLine((int)Math.Ceiling((double)m/n));\n }\n }\n}", "lang_cluster": "C#", "tags": ["math", "greedy", "implementation"], "code_uid": "2c62a47484646a117e4b3d6ba4f10416", "src_uid": "04c067326ec897091c3dbcf4d134df96", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections;\nusing System.Collections.Generic;\n\nclass Solution\n{\n static void Main(string[] args)\n {\n long[] ns = Array.ConvertAll(Console.ReadLine().Split(' '), item => Convert.ToInt64(item));\n long n = ns[0], s = ns[1], count = 0;\n for(long i=n;i>0;i--)\n {\n if (s == 0) break;\n if(s>=i)\n {\n count += s / i;\n s %= i;\n }\n }\n Console.Write(count);\n }\n}", "lang_cluster": "C#", "tags": ["math", "greedy", "implementation"], "code_uid": "163ebbd0f5f7fac85d11824c1204ef46", "src_uid": "04c067326ec897091c3dbcf4d134df96", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Text;\n\n\nclass Program\n{\n static void Main(string[] args)\n {\n string line1 = Console.ReadLine();\n string line2 = Console.ReadLine();\n string[] data1 = line1.Split(new char[] { ' ' });\n string[] data2 = line2.Split(new char[] { ' ' });\n\n Console.WriteLine(new Solver().Solve(int.Parse(data1[0]), int.Parse(data1[1]), int.Parse(data1[2]),\n int.Parse(data2[0]), int.Parse(data2[1]), int.Parse(data2[2])));\n }\n}\n\nclass Solver\n{\n public int Solve(int a1, int b1, int c1, int a2, int b2, int c2)\n {\n if (a1 == 0 && b1 == 0 && c1 != 0) return 0;\n if (a2 == 0 && b2 == 0 && c2 != 0) return 0;\n if ((a1 == 0 && b1 == 0) || (a2 == 0 && b2 == 0)) return -1;\n\n if ((a1 == 0 && b2 == 0) || (a2 == 0 && b1 == 0)) return 1;\n if (a1 == 0 && a2 == 0)\n {\n if (b1 * c2 == b2 * c1) return -1;\n return 0;\n }\n if (b1 == 0 && b2 == 0)\n {\n if (a1 * c2 == a2 * c1) return -1;\n return 0;\n }\n\n bool a_same = (a1 * b2 == a2 * b1);\n bool b_same = (c1 * b2 == b1 * c2);\n return (a_same && b_same) ? -1 : (a_same ? 0 : 1);\n\n }\n}\n\n", "lang_cluster": "C#", "tags": ["math", "implementation"], "code_uid": "17b586dd7400b452413c5b6c7e39d94a", "src_uid": "c8e869cb17550e888733551c749f2e1a", "difficulty": 2000.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\n\t\t\t\t\t\npublic class Program\n{\n\tpublic static void Main()\n\t{\n\t\tstring[] input = Console.ReadLine().Split(' ');\n\t\tdouble a1 = double.Parse(input[0]);\n\t\tdouble b1 = double.Parse(input[1]);\n\t\tdouble c1 = double.Parse(input[2]);\n\t\t\n\t\tinput = Console.ReadLine().Split(' ');\n\t\tdouble a2 = double.Parse(input[0]);\n\t\tdouble b2 = double.Parse(input[1]);\n\t\tdouble c2 = double.Parse(input[2]);\n\t\t\n\t\t//if at least one is empty set\n\t\tif((a1 == 0 && b1 == 0 && c1 != 0) || (a2 == 0 && b2 == 0 && c2 != 0))\n\t\t{\n\t\t\tConsole.WriteLine(0);\n\t\t}\n\t\t//else if at least one is infinite\n\t\telse if((a1 == 0 && b1 == 0 && c1 == 0) || (a2 == 0 && b2 == 0 && c2 == 0))\n\t\t{\n\t\t\tConsole.WriteLine(-1);\n\t\t}\n\t\t//else\n\t\telse if(a1 == 0 && a2 == 0 && c1 / b1 == c2 / b2)\n\t\t{\n\t\t\tConsole.WriteLine(-1);\n\t\t}\n\t\telse if(a1 == 0 && a2 == 0 && c1 / b1 != c2 / b2)\n\t\t{\n\t\t\tConsole.WriteLine(0);\n\t\t}\n\t\telse if(b1 == 0 && b2 == 0 && c1 / a1 == c2 / a2)\n\t\t{\n\t\t\tConsole.WriteLine(-1);\n\t\t}\n\t\telse if(b1 == 0 && b2 == 0 && c1 / a1 != c2 / a2)\n\t\t{\n\t\t\tConsole.WriteLine(0);\n\t\t}\n\t\telse if(a1 / b1 == a2 / b2 && c1 / b1 == c2 / b2)\n\t\t{\n\t\t\tConsole.WriteLine(-1);\n\t\t}\n\t\telse if(a1 / b1 == a2 / b2 && c1 / b1 != c2 / b2)\n\t\t{\n\t\t\tConsole.WriteLine(0);\n\t\t}\n\t\telse\n\t\t{\n\t\t\tConsole.WriteLine(1);\n\t\t}\n\t}\n}", "lang_cluster": "C#", "tags": ["math", "implementation"], "code_uid": "9438f02a7bfdedc7a8161d69cdfedb2f", "src_uid": "c8e869cb17550e888733551c749f2e1a", "difficulty": 2000.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\n\nusing System.Text;\n\nnamespace ConsoleApplication1\n{\n class Program\n {\n \n static void Main(string[] args)\n {\n string s = Console.ReadLine();\n int max = 0;\n int d = 1; //\u043a\u0430\u043a \u0431\u044d \u0441\u0434\u0432\u0438\u0433\n bool b = false;\n for (; d < s.Length; d++)\n {\n int cnt = 0;\n int cnt2 = 0;\n for (int i = d; i < s.Length; i++)\n {\n if (s[i - d] == s[i])\n {\n if (b == false)\n {\n b = true;\n cnt2 = Math.Max(cnt, cnt2);\n cnt = 0;\n }\n cnt++;\n }\n else\n {\n b = false;\n }\n }\n max = Math.Max(Math.Max(cnt, cnt2), max);\n }\n Console.WriteLine(max);\n Console.ReadLine();\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "greedy"], "code_uid": "803ee6127f26ef1497e24030fc0c7c34", "src_uid": "13b5cf94f2fabd053375a5ccf3fd44c7", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\n\nnamespace code_23_a\n{\n class Program\n {\n static void Main(string[] args)\n {\n string s = Console.ReadLine();\n string sub;\n string comp_str;\n int leng = 1;\n int max = 0;\n\n for (int i = 0; i < s.Length; i++)\n {\n leng = 1;\n List lst = new List();\n for (int j = i+1; j < s.Length; j++)\n lst.Add(j);\n while (true)\n {\n List lst2 = new List();\n sub = s.Substring(i, leng);\n foreach (var k in lst)\n {\n if (k + leng > s.Length) break;\n comp_str = s.Substring(k, leng);\n if (comp_str == sub)\n lst2.Add(k);\n\n }\n if (lst2.Count == 0) break;\n lst = lst2;\n if (leng > max) max = leng;\n leng++;\n }\n\n if (s.Length - i < max) break;\n }\n Console.WriteLine(max);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "greedy"], "code_uid": "f77a9b1cc15bc149b70c19321b8cf3d5", "src_uid": "13b5cf94f2fabd053375a5ccf3fd44c7", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\n\n\nclass Program\n{\n static void Main(string[] args)\n {\n string[] abc = Console.ReadLine().Split(' ');\n\n long a, b, c;\n a = long.Parse(abc[0]);\n b = long.Parse(abc[1]);\n c = long.Parse(abc[2]);\n\n long s = b * c + a * c + b * a - a - b - c + 1;\n\n Console.WriteLine(s);\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "implementation"], "code_uid": "534d607eb11d0e8d74f56d6040469263", "src_uid": "8ab25ed4955d978fe20f6872cb94b0da", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\n\nnamespace _216A\n{\n class Program\n {\n static void Main()\n {\n String[] k = Console.ReadLine().Split(' ');\n int a = Convert.ToInt32(k[0]);\n int b = Convert.ToInt32(k[1]);\n int c = Convert.ToInt32(k[2]);\n int d = 0;\n if (a > b && a>c)\n {\n d = c;\n c = a;\n a = d;\n if (a > b)\n {\n d = b;\n b = a;\n a = d;\n }\n }\n else if (a > b && a <= c)\n {\n d = b;\n b = a;\n a = d;\n }\n else if (a < b && a < c)\n {\n if (b > c)\n {\n d = b;\n b = c;\n c = d;\n }\n }\n Console.Write(calculate(a, b, c));\n }\n static int calculate(int a, int b, int c)\n {\n int output = b * (2 * a + (b - 1)) + (c - b - 1) * (a + b - 1);\n\n return output;\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "implementation"], "code_uid": "0c62ddd5bfda7ed3824051408ab33e9f", "src_uid": "8ab25ed4955d978fe20f6872cb94b0da", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Linq;\nusing System.Collections.Generic;\n\nnamespace CodeForces\n{\n\tclass Program\n\t{\n\n\t\tstatic void Solve()\n\t\t{\n\t\t\tint idx = read();\n\t\t\tList dig = new List();\n\t\t\tint n = 0;\n\t\t\twhile (dig.Count <= idx)\n\t\t\t{\n\t\t\t\tn++;\n\t\t\t\tforeach (char i in n.ToString())\n\t\t\t\t{\n\t\t\t\t\tdig.Add(i);\n\t\t\t\t}\n\t\t\t}\n\t\t\tConsole.WriteLine(dig[idx - 1]);\n\t\t}\n\n\t\tstatic void Main(string[] args)\n\t\t{\n\t\t\tSolve();\n#if !ONLINE_JUDGE\n\t\t\tConsole.ReadKey();\n#endif\n\t\t}\n\n\t\tprivate static T read()\n\t\t{\n\t\t\treturn (T)Convert.ChangeType(Console.ReadLine(), typeof(T));\n\t\t}\n\n\t\tprivate static string read()\n\t\t{\n\t\t\treturn Console.ReadLine();\n\t\t}\n\n\t\tprivate static T[] readMany()\n\t\t{\n\t\t\treturn readMany(' ');\n\t\t}\n\n\t\tprivate static _[] readMany<_>(params char[] ___)\n\t\t{\n\t\t\treturn read().Split(___).Select(__ => (_)Convert.ChangeType(__, typeof(_))).ToArray();\n\t\t}\n\n\t\tprivate static string[] readMany()\n\t\t{\n\t\t\treturn readMany();\n\t\t}\n\n\t\tprivate static T[][] readField(int height, Func map)\n\t\t{\n\t\t\tT[][] res = new T[height][];\n\t\t\tfor (int _ = 0; _ < height; _++)\n\t\t\t{\n\t\t\t\tres[_] = read().Select(c => map(c)).ToArray();\n\t\t\t}\n\t\t\treturn res;\n\t\t}\n\n\t\tprivate static char[][] readField(int height)\n\t\t{\n\t\t\treturn readField(height, c => c);\n\t\t}\n\n\t\tprivate static T[][] readField(int height, Dictionary dic)\n\t\t{\n\t\t\treturn readField(height, c => dic[c]);\n\t\t}\n\n\t\tstatic Func DP(Func f)\n\t\t{\n\t\t\tvar cache = new Dictionary, TResult>();\n\t\t\treturn (t1) =>\n\t\t\t{\n\t\t\t\tvar key = Tuple.Create(t1);\n\t\t\t\tif (!cache.ContainsKey(key))\n\t\t\t\t\tcache.Add(key, f(t1));\n\t\t\t\treturn cache[key];\n\t\t\t};\n\t\t}\n\n\t\tstatic Func DP(Func f)\n\t\t{\n\t\t\tvar cache = new Dictionary, TResult>();\n\t\t\treturn (t1, t2) =>\n\t\t\t{\n\t\t\t\tvar key = Tuple.Create(t1, t2);\n\t\t\t\tif (!cache.ContainsKey(key))\n\t\t\t\t\tcache.Add(key, f(t1, t2));\n\t\t\t\treturn cache[key];\n\t\t\t};\n\t\t}\n\n\t\tstatic Func DP(Func f)\n\t\t{\n\t\t\tvar cache = new Dictionary, TResult>();\n\t\t\treturn (t1, t2, t3) =>\n\t\t\t{\n\t\t\t\tvar key = Tuple.Create(t1, t2, t3);\n\t\t\t\tif (!cache.ContainsKey(key))\n\t\t\t\t\tcache.Add(key, f(t1, t2, t3));\n\t\t\t\treturn cache[key];\n\t\t\t};\n\t\t}\n\n\t\tstatic Func DP(Func f)\n\t\t{\n\t\t\tvar cache = new Dictionary, TResult>();\n\t\t\treturn (t1, t2, t3, t4) =>\n\t\t\t{\n\t\t\t\tvar key = Tuple.Create(t1, t2, t3, t4);\n\t\t\t\tif (!cache.ContainsKey(key))\n\t\t\t\t\tcache.Add(key, f(t1, t2, t3, t4));\n\t\t\t\treturn cache[key];\n\t\t\t};\n\t\t}\n\n\t\tstatic IEnumerable range(long first, long last, long step = 1)\n\t\t{\n\t\t\tfor (long i = first; i <= last; i += step)\n\t\t\t{\n\t\t\t\tyield return i;\n\t\t\t}\n\t\t}\n\n\t\tstatic IEnumerable range(int first, int last, int step = 1)\n\t\t{\n\t\t\tfor (int i = first; i <= last; i += step)\n\t\t\t{\n\t\t\t\tyield return i;\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic static class ExtensionMethods\n\t{\n\t\tpublic static IEnumerable Cartesian(this IEnumerable first, IEnumerable second, Func collector)\n\t\t{\n\t\t\treturn first.SelectMany(f => second.Select(s => collector(f, s)));\n\t\t}\n\n\t\tpublic static IEnumerable> Cartesian(this IEnumerable first, IEnumerable second)\n\t\t{\n\t\t\treturn first.Cartesian(second, Tuple.Create);\n\t\t}\n\n\t\tpublic static IEnumerable> Cartesian(this IEnumerable> first, IEnumerable second)\n\t\t{\n\t\t\treturn first.Cartesian(second, (x, y) => Tuple.Create(x.Item1, x.Item2, y));\n\t\t}\n\n\t\tpublic static IEnumerable> Cartesian(this IEnumerable> first, IEnumerable second)\n\t\t{\n\t\t\treturn first.Cartesian(second, (x, y) => Tuple.Create(x.Item1, x.Item2, x.Item3, y));\n\t\t}\n\n\t\tpublic static IEnumerable> Cartesian(this IEnumerable> first, IEnumerable second)\n\t\t{\n\t\t\treturn first.Cartesian(second, (x, y) => Tuple.Create(x.Item1, x.Item2, x.Item3, x.Item4, y));\n\t\t}\n\n\t\tpublic static IEnumerable> Pow(this IEnumerable it, int num)\n\t\t{\n\t\t\tIEnumerable> res = it.Select(x => new[] { x });\n\t\t\tfor (int i = 0; i < num - 1; i++)\n\t\t\t{\n\t\t\t\tres = res.Cartesian(it, (sofar, n) => sofar.Concat(new[] { n }));\n\t\t\t}\n\t\t\treturn res;\n\t\t}\n\n\t\tpublic static IEnumerable Demask(this IEnumerable> inp)\n\t\t{\n\t\t\tforeach (var pair in inp)\n\t\t\t{\n\t\t\t\tif (pair.Item2)\n\t\t\t\t{\n\t\t\t\t\tyield return pair.Item1;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tpublic static IEnumerable> Combinations(this IEnumerable it)\n\t\t{\n\t\t\tforeach (var conf in new[] { true, false }.Pow(it.Count()))\n\t\t\t{\n\t\t\t\tyield return it.Zip(conf, Tuple.Create).Demask();\n\t\t\t}\n\t\t}\n\n\t\tprivate static IEnumerable single(T it)\n\t\t{\n\t\t\tyield return it;\n\t\t}\n\n\t\tprivate static IEnumerable ExceptSingle(this IEnumerable first, T it, IEqualityComparer comp = null)\n\t\t{\n\t\t\tcomp = comp ?? EqualityComparer.Default;\n\t\t\tbool seen = false;\n\t\t\tforeach (T a in first)\n\t\t\t{\n\t\t\t\tif (seen)\n\t\t\t\t{\n\t\t\t\t\tyield return a;\n\t\t\t\t}\n\t\t\t\telse if (comp.Equals(a, it))\n\t\t\t\t{\n\t\t\t\t\tseen = true;\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tyield return a;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tpublic static IEnumerable> Permutations(this IEnumerable it)\n\t\t{\n\t\t\tif (it.Count() < 2)\n\t\t\t{\n\t\t\t\tyield return it;\n\t\t\t\tyield break;\n\t\t\t}\n\n\t\t\tforeach (T first in it)\n\t\t\t{\n\t\t\t\tforeach (IEnumerable part in Permutations(it.ExceptSingle(first)))\n\t\t\t\t{\n\t\t\t\t\tyield return single(first).Concat(part);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "67de48612569280d3d26b664dcac51ef", "src_uid": "2d46e34839261eda822f0c23c6e19121", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.IO;\nusing System.Text;\nusing System.Linq;\nusing System.Globalization;\n\nclass Program2\n{\n static void Main(string[] args)\n {\n int n = ReadInt();\n string s =\"\";\n int i = 1;\n while (s.Length < n)\n {\n s += i.ToString();\n i++;\n }\n Console.Write(s[n - 1]);\n }\n\n private static List[] ReadGraph(int n, int m)\n {\n List[] g = new List[n];\n for (int i = 0; i < n; i++) g[i] = new List();\n for (int i = 0; i < m; i++)\n {\n int a = ReadInt() - 1;\n int b = ReadInt() - 1;\n\n g[a].Add(b);\n }\n\n return g;\n }\n\n private static int[,] ReadGraphAsMatrix(int n, int m)\n {\n int[,] matrix = new int[n + 1, n + 1];\n for (int i = 0; i < m; i++)\n {\n int a = ReadInt();\n int b = ReadInt();\n matrix[a, b] = matrix[b, a] = 1;\n }\n\n return matrix;\n }\n\n private static void Sort(ref int a, ref int b)\n {\n if (a > b) Swap(ref a, ref b);\n }\n\n private static void Swap(ref int a, ref int b)\n {\n int tmp = a;\n a = b;\n b = tmp;\n }\n\n private const int BufferSize = 1 << 16;\n private static StreamReader consoleReader;\n private static MemoryStream testData;\n\n private static int ReadInt()\n {\n int ans = 0;\n int mul = 1;\n do\n {\n ans = consoleReader.Read();\n if (ans == -1)\n return 0;\n if (ans == '-') mul = -1;\n } while (ans < '0' || ans > '9');\n\n ans -= '0';\n while (true)\n {\n int chr = consoleReader.Read();\n if (chr < '0' || chr > '9')\n return ans * mul;\n ans = ans * 10 + chr - '0';\n }\n }\n\n private static ulong ReadULong()\n {\n ulong ans = 0;\n int chr;\n do\n {\n chr = consoleReader.Read();\n if (chr == -1)\n return 0;\n } while (chr < '0' || chr > '9');\n\n ans = (uint)(chr - '0');\n while (true)\n {\n chr = consoleReader.Read();\n if (chr < '0' || chr > '9')\n return ans;\n ans = ans * 10 + (uint)(chr - '0');\n }\n }\n\n private static long ReadLong()\n {\n long ans = 0;\n int mul = 1;\n do\n {\n ans = consoleReader.Read();\n if (ans == -1)\n return 0;\n if (ans == '-') mul = -1;\n } while (ans < '0' || ans > '9');\n\n ans -= '0';\n while (true)\n {\n int chr = consoleReader.Read();\n if (chr < '0' || chr > '9')\n return ans * mul;\n ans = ans * 10 + chr - '0';\n }\n }\n\n private static int[] ReadIntArray(int n)\n {\n int[] ans = new int[n];\n for (int i = 0; i < n; i++)\n ans[i] = ReadInt();\n return ans;\n }\n\n private static long[] ReadLongArray(int n)\n {\n long[] ans = new long[n];\n for (int i = 0; i < n; i++)\n ans[i] = ReadLong();\n return ans;\n }\n\n private static char[] ReadString()\n {\n int ans;\n\n do\n {\n ans = consoleReader.Read();\n } while (!((ans >= 'a' && ans <= 'z') || (ans >= 'A' && ans <= 'Z')));\n\n List s = new List();\n do\n {\n s.Add((char)ans);\n ans = consoleReader.Read();\n } while ((ans >= 'a' && ans <= 'z') || (ans >= 'A' && ans <= 'Z'));\n\n return s.ToArray();\n }\n\n private static char[] ReadString(int n)\n {\n int ans;\n\n do\n {\n ans = consoleReader.Read();\n } while (!((ans >= 'a' && ans <= 'z') || (ans >= 'A' && ans <= 'Z')));\n\n char[] s = new char[n];\n int pos = 0;\n do\n {\n s[pos++] = (char)ans;\n if (pos == n) break;\n ans = consoleReader.Read();\n } while ((ans >= 'a' && ans <= 'z') || (ans >= 'A' && ans <= 'Z'));\n\n return s;\n }\n\n private static char ReadLetter()\n {\n while (true)\n {\n int ans = consoleReader.Read();\n if ((ans >= 'a' && ans <= 'z') || (ans >= 'A' && ans <= 'Z'))\n return (char)ans;\n }\n }\n\n private static char ReadDigit()\n {\n while (true)\n {\n int ans = consoleReader.Read();\n if (ans >= '0' && ans <= '9')\n return (char)ans;\n }\n }\n\n private static int ReadDigitInt()\n {\n return ReadDigit() - (int)'0';\n }\n\n private static char ReadAnyChar()\n {\n return (char)consoleReader.Read();\n }\n\n private static string DoubleToString(double x)\n {\n return x.ToString(CultureInfo.InvariantCulture);\n }\n\n static Program2()\n {\n //System.Threading.Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;\n consoleReader = new StreamReader(Console.OpenStandardInput(BufferSize), Encoding.ASCII, false, BufferSize);\n }\n\n private static void PushTestData(string data)\n {\n#if !ONLINE_JUDGE\n if (testData == null)\n {\n testData = new MemoryStream();\n consoleReader = new StreamReader(testData);\n }\n\n var pos = testData.Position;\n var bytes = Encoding.UTF8.GetBytes(data);\n testData.Write(bytes, 0, bytes.Length);\n testData.Flush();\n testData.Position = pos;\n#endif\n }\n}", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "e5bf994ad7c154ae6318f57840d7aac1", "src_uid": "2d46e34839261eda822f0c23c6e19121", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace Kirill_And_The_Game\n{\n class Program\n {\n static void Main(string[] args)\n {\n double[] arr = Array.ConvertAll(Console.ReadLine().Split(' '), Double.Parse);\n Int64 l = Convert.ToInt64(arr[0]);\n Int64 r = Convert.ToInt64(arr[1]);\n Int64 x = Convert.ToInt64(arr[2]);\n Int64 y = Convert.ToInt64(arr[3]);\n double k = arr[4];\n bool cond = false;\n\n\n for(Int64 b = x; b= k)\n {\n cond = true;\n break;\n }\n \n }\n if (cond)\n Console.WriteLine(\"YES\");\n else\n Console.WriteLine(\"NO\");\n \n }\n }\n}\n", "lang_cluster": "C#", "tags": ["two pointers", "brute force"], "code_uid": "fb20ba4f8d5213a69c8cc1476632b819", "src_uid": "1110d3671e9f77fd8d66dca6e74d2048", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace Tier4\n{\n class Class2\n {\n static void Main(string[] args)\n {\n string[] nums_strings = Console.ReadLine().Split();\n ulong[] nums = new ulong[nums_strings.Length];\n for (int i = 0; i < nums_strings.Length; i++)\n nums[i] = Convert.ToUInt32(nums_strings[i]);\n ulong l = nums[0];\n ulong r = nums[1];\n ulong x = nums[2];\n ulong y = nums[3];\n ulong k = nums[4];\n for (ulong i = x; i <= y; i++)\n {\n if ((l <= i * k) && (i * k <= r))\n {\n Console.WriteLine(\"YES\");\n Environment.Exit(0);\n }\n }\n Console.WriteLine(\"NO\");\n \n }\n }\n}\n", "lang_cluster": "C#", "tags": ["two pointers", "brute force"], "code_uid": "85ef32f34092890abb7b98d2712304f8", "src_uid": "1110d3671e9f77fd8d66dca6e74d2048", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System; \nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace ConsoleApplication9\n{\n class Program\n {\n static string str ;\n static int[,,] dp; \n static int solve(int idx , int x , int y)\n {\n if (idx == str.Length)\n {\n if (x == 100 && y == 100) return 0;\n else return -1000000000;\n }\n int a=x;\n int b=y; \n if (dp[idx , x ,y]!=-1)\n {\n return dp[idx, x, y];\n }\n else if (str [idx]=='L')\n {\n a = x - 1;\n }\n else if (str[idx] == 'R')\n {\n a = x + 1;\n }\n else if (str[idx] == 'U')\n {\n b = y+1;\n }\n else\n {\n b = y-1;\n }\n int sol = Math.Max ( solve(idx + 1, x, y) , solve (idx+1,a,b)+1) ;\n dp[idx, x, y] = sol;\n return sol;\n }\n static void Main(string[] args)\n {\n int n= int.Parse ( Console.ReadLine());\n str = Console.ReadLine();\n dp = new int[205, 205, 205];\n for (int i=0;i<205; i++)\n {\n for (int j=0; j<205; j++)\n {\n for (int k=0; k<205; k++)\n {\n dp[i, j, k] = -1; \n }\n }\n }\n Console.WriteLine(solve(0, 100, 100)); \n }\n }\n}\n", "lang_cluster": "C#", "tags": ["greedy"], "code_uid": "7d9284e499d766171d13fa292a5a6eb5", "src_uid": "b9fa2bb8001bd064ede531a5281cfd8a", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Linq;\n\nnamespace b\n{\n class Program\n {\n static void Main(string[] args)\n {\n var n = Console.ReadLine();\n var comm = Console.ReadLine();\n System.Console.WriteLine(2* (Math.Min(comm.Count(i => i == 'U'), comm.Count(i => i == 'D')) + Math.Min(comm.Count(i => i == 'L'), comm.Count(i => i == 'R'))));\n }\n }\n}", "lang_cluster": "C#", "tags": ["greedy"], "code_uid": "726a06416e0819127faf87f36a476940", "src_uid": "b9fa2bb8001bd064ede531a5281cfd8a", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\n\nnamespace ConsoleApplication4\n{\n\tclass Program\n\t{\n\t\tstatic void Main(string[] args)\n\t\t{\n\t\t\tString line;\n\t\t\tInt32 n;\n\t\t\tline = Console.ReadLine();\n\t\t\tn = Convert.ToInt32(line);\n\t\t\tConsole.WriteLine(1.5*n);\n\t\t\t//Console.ReadKey();\n\t\t}\n\t}\n}\n", "lang_cluster": "C#", "tags": ["math", "number theory"], "code_uid": "72fa07ad025047fcb662ed2525846053", "src_uid": "031e53952e76cff8fdc0988bb0d3239c", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Text;\n\nnamespace A\n{\n class Program\n {\n static void Main(string[] args)\n {\n int n = int.Parse(Console.ReadLine());\n Console.WriteLine(3 * (n / 2));\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "number theory"], "code_uid": "25d9660e223e2a40a1c936ab0170ae12", "src_uid": "031e53952e76cff8fdc0988bb0d3239c", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\nusing System.Collections;\n\nnamespace ConsoleApplication6\n{\n class Program\n {\n \n static void Main(string[] args)\n {\n int[] mas = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();\n List val = Console.ReadLine().Split(' ').Select(int.Parse).ToList();\n val = val.Where(x => mas[1] % x == 0).ToList();\n Console.WriteLine(mas[1]/val.Max());\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "806f2300b6490e322938567939a8faa8", "src_uid": "80520be9916045aca3a7de7bc925af1f", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\n\nnamespace AlgoTasks\n{\n class Program\n {\n static void Main(string[] args)\n {\n int[] nk = Console.ReadLine().Split().Select(s => int.Parse(s)).ToArray();\n int[] a = Console.ReadLine().Split().Select(s => int.Parse(s)).ToArray();\n int min = int.MaxValue;\n for (int i = 0; i < nk[0]; i++)\n {\n if (nk[1] % a[i] == 0 && nk[1] / a[i] < min)\n min = nk[1] / a[i];\n }\n Console.WriteLine(min);\n }\n }\n} \n\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "886568859ba17b6de2eccd10869453e2", "src_uid": "80520be9916045aca3a7de7bc925af1f", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace Amr_and_Pins\n{\n class Program\n {\n static void Main(string[] args)\n {\n double[] x = Array.ConvertAll(Console.ReadLine().Split(' '), double.Parse);\n double distance = Math.Sqrt(Math.Pow((x[3] - x[1]), 2) + Math.Pow((x[4] - x[2]), 2)); \n Console.WriteLine(Math.Ceiling(distance / (2 * x[0])));\n Console.ReadLine();\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "geometry"], "code_uid": "0609a86ac3182008b3f60cbefa4d32c6", "src_uid": "698da80c7d24252b57cca4e4f0ca7031", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace Amr_and_Pins\n{\n class Program\n {\n static void Main(string[] args)\n {\n string[] t = Console.ReadLine().Split(' ');\n int r = int.Parse(t[0]);\n int x = int.Parse(t[1]);\n int y = int.Parse(t[2]);\n int x1 = int.Parse(t[3]);\n int y1 = int.Parse(t[4]);\n double d = Math.Sqrt((double)(x - x1) * (x - x1) + (double)(y - y1) * (y - y1));\n double br = Math.Ceiling(d / (2 * r));\n Console.WriteLine(br);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "geometry"], "code_uid": "9fc2684254f0de2aac29aa3611a5e38c", "src_uid": "698da80c7d24252b57cca4e4f0ca7031", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\n\n\nnamespace ConsoleApplication7\n{\n class Program\n {\n static void Main(string[] args)\n {\n string s = Console.ReadLine();\n string[] f = s.Split(' ');\n int k = int.Parse(f[0]);\n \n int a = int.Parse(f[1]);\n int b = int.Parse(f[2]);\n int v = int.Parse(f[3]);\n int y = 0;\n int m = b / (k - 1);\n if (m == 0)\n {\n m = b % (k - 1) + 1;\n a=a - m * v;\n y++; \n if ( a> 0)\n {\n \n y = y + a / v;\n \n }\n\n }\n else\n {\n int d = a / (k * v);\n if ( d>m)\n {\n y = m+1;\n a = a - (m *k* v);\n m = b % (k - 1) + 1;\n a = a - (m * v);\n\n y =y+ a / v; \n\n }\n else\n {\n if (d == 0) d++; \n y = d;\n \n a = a - d * v*k;\n if (a > 0) \n {\n d = b % (k - 1) + 1;\n y += 1;\n a = a - d * v; \n if(a>0)\n {\n y = y+ a / v; \n\n }\n }\n }\n \n }\n \n \n if (a>0 && a % v > 0) y++;\n\n Console.Write(y);\n\n }\n }\n }\n\n\n", "lang_cluster": "C#", "tags": ["math", "greedy"], "code_uid": "f362760566f00b528dc63aa9c5be060c", "src_uid": "7cff20b1c63a694baca69bdf4bdb2652", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace Codeforces_Div2\n{\n class Program\n {\n static void Main(string[] args)\n {\n string s = Console.ReadLine();\n int k = int.Parse(s.Split()[0]);\n int a = int.Parse(s.Split()[1]);\n int b = int.Parse(s.Split()[2]);\n int v = int.Parse(s.Split()[3]);\n int count = 0;\n\n while (a > 0)\n {\n count++;\n\n if (b == 0)\n {\n a -= v;\n\n count += a / v;\n if (a % v > 0)\n count++;\n\n break;\n }\n\n if (b >= k - 1)\n {\n b -= (k - 1);\n a -= k * v;\n }\n else\n {\n a -= (b + 1) * v;\n b = 0;\n }\n }\n\n Console.WriteLine(count);\n \n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "greedy"], "code_uid": "bf76059db4f9b1c357f07a66c03aeec9", "src_uid": "7cff20b1c63a694baca69bdf4bdb2652", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\n\nnamespace Task1\n{\n class Program\n {\n static void Main(string[] args)\n {\n string[] names = new string[]\n {\n \"Danil\",\n \"Olya\",\n \"Slava\",\n \"Ann\",\n \"Nikita\"\n };\n\n string read = Console.ReadLine();\n int count = 0;\n for (int i = 0; i < names.Length; i++)\n {\n int index = read.IndexOf(names[i]);\n if (index != -1)\n {\n read = read.Remove(index, names[i].Length);\n read = read.Insert(index, \"*\");\n count++;\n i--;\n if (count > 1)\n {\n Console.WriteLine(\"NO\");\n //Console.ReadLine();\n return;\n }\n }\n }\n if (count != 0)\n Console.WriteLine(\"YES\");\n else\n Console.WriteLine(\"NO\");\n //Console.ReadLine();\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["strings", "implementation"], "code_uid": "51124dbd5779fe557e4d0bc971bc7161", "src_uid": "db2dc7500ff4d84dcc1a37aebd2b3710", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.IO;\nusing System.Text;\n\nnamespace Alex_and_broken_contest\n{\n internal class Program\n {\n private static readonly StreamReader reader = new StreamReader(Console.OpenStandardInput(1024*10), Encoding.ASCII, false, 1024*10);\n private static readonly StreamWriter writer = new StreamWriter(Console.OpenStandardOutput(1024*10), Encoding.ASCII, 1024*10);\n\n private static void Main(string[] args)\n {\n writer.WriteLine(Solve(args) ? \"YES\" : \"NO\");\n writer.Flush();\n }\n\n private static bool Solve(string[] args)\n {\n string s = reader.ReadLine();\n var names = new[] {\"Danil\", \"Olya\", \"Slava\", \"Ann\", \"Nikita\"};\n\n int count = 0;\n\n foreach (string name in names)\n {\n while (true)\n {\n int index = s.IndexOf(name, StringComparison.Ordinal);\n if (index >= 0)\n {\n count++;\n s = s.Remove(index, name.Length);\n s = s.Insert(index, \"$\");\n }\n else break;\n }\n }\n\n return count == 1;\n }\n }\n}", "lang_cluster": "C#", "tags": ["strings", "implementation"], "code_uid": "87ffb0eaa33511a8189c77bc6daa5303", "src_uid": "db2dc7500ff4d84dcc1a37aebd2b3710", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Globalization;\nusing System.IO;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace Codeforces\n{\n class Program\n {\n static StreamReader reader;\n static StreamWriter writer;\n static int CAP = 1 << 12;\n\n static void Main(string[] args)\n {\n //#if DEBUG\n reader = new StreamReader(Console.OpenStandardInput(32768), Encoding.ASCII, false, 32768);\n writer = new StreamWriter(Console.OpenStandardOutput(32768), Encoding.ASCII, 32768);\n //#else\n // StreamReader streamReader = new StreamReader(Console.OpenStandardInput(32768), Encoding.ASCII, false, 32768);\n // StreamWriter writer = new StreamWriter(Console.OpenStandardOutput(32768), Encoding.ASCII, 32768);\n //#endif\n InputReader input = new InputReader(reader);\n\n int n = input.NextInt();\n int t = input.NextInt();\n int[,] a = new int[n, n];\n a[0, 0] = CAP * t;\n for (int i = 0; i < n; i++)\n {\n for (int j = 0; j <= i; j++)\n {\n Fill(i, j, n, a);\n }\n }\n int sum = 0;\n for (int i = 0; i < n; i++)\n {\n for (int j = 0; j < n; j++)\n {\n if (a[i, j] >= CAP)\n {\n sum++;\n }\n }\n }\n writer.WriteLine(sum);\n\n\n#if DEBUG\n Console.BackgroundColor = ConsoleColor.White;\n Console.ForegroundColor = ConsoleColor.Black;\n#endif\n writer.Close();\n reader.Close();\n }\n\n static void Fill(int x, int y, int n, int[,] a)\n {\n if (x + 1 >= n)\n {\n return;\n }\n if (a[x, y] > CAP)\n {\n int f = a[x, y] - CAP;\n a[x + 1, y] += f / 2;\n a[x + 1, y + 1] += f / 2;\n }\n }\n }\n\n class MyPair\n {\n public int x, y;\n\n public MyPair(int x, int y)\n {\n this.x = x;\n this.y = y;\n }\n\n public override string ToString()\n {\n return \"[\" + x + \", \" + y + \"]\";\n }\n }\n\n // this class is copy\n class InputReader\n {\n private char[] _inbuf;\n private int _lenbuf = 0, _ptrbuf = 0;\n private StreamReader _reader;\n\n public InputReader(StreamReader reader)\n {\n _reader = reader;\n _inbuf = new char[1024];\n _lenbuf = 0;\n _ptrbuf = 0;\n }\n\n private int ReadByte()\n {\n if (_lenbuf == -1)\n throw new Exception();\n if (_ptrbuf >= _lenbuf)\n {\n _ptrbuf = 0;\n try\n {\n _lenbuf = _reader.Read(_inbuf, 0, 1024);\n }\n catch (IOException e)\n {\n throw e;\n }\n if (_lenbuf <= 0)\n return -1;\n }\n return _inbuf[_ptrbuf++];\n }\n\n private bool IsSpaceChar(int c)\n {\n return !(c >= 33 && c <= 126);\n }\n\n private int Skip()\n {\n int b;\n while ((b = ReadByte()) != -1 && IsSpaceChar(b)) ;\n return b;\n }\n\n public int NextInt()\n {\n return int.Parse(this.Next());\n }\n\n public int[] NextIntArray(int n)\n {\n int[] a = new int[n];\n for (int i = 0; i < n; i++)\n {\n a[i] = NextInt();\n }\n return a;\n }\n\n public long NextLong()\n {\n return long.Parse(this.Next());\n }\n\n public string Next()\n {\n var b = Skip();\n var sb = new StringBuilder();\n while (!(IsSpaceChar(b)))\n {\n sb.Append((char)b);\n b = ReadByte();\n }\n return sb.ToString();\n }\n\n public double NextDouble()\n {\n return double.Parse(Next(), CultureInfo.InvariantCulture);\n }\n\n internal long[] NextLongArray(long n)\n {\n long[] a = new long[(int)n];\n for (int i = 0; i < a.Length; i++)\n {\n a[i] = NextLong();\n }\n return a;\n }\n\n internal double[] NextDoubleArray(int n)\n {\n double[] a = new double[n];\n for (int i = 0; i < a.Length; i++)\n {\n a[i] = NextDouble();\n }\n return a;\n }\n }\n}", "lang_cluster": "C#", "tags": ["math", "implementation"], "code_uid": "098796598502945c985abffdc1b49925", "src_uid": "b2b49b7f6e3279d435766085958fb69d", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Linq;\nusing System.Collections.Generic;\nusing System.Text;\nusing System.Globalization;\n\nnamespace CodeForces\n{\n\tclass MainClass\n\t{\n\t\tpublic static void Main (string[] args)\n\t\t{\n\t\t\tint[] nums = Console.ReadLine ().Split (' ').Select (int.Parse).ToArray ();\n\t\t\tint n = nums [0];\n\t\t\tint t = nums [1];\n\t\t\tdouble[,] triangle = new double[n, n];\n\t\t\tfor (int k = 0; k < t; k++) {\n\t\t\t\ttriangle [0, 0] += 1;\n\t\t\t\tfor (int col = 0; col < n - 1; col++) {\n\t\t\t\t\tfor (int row = 0; row <= col; row++) {\n\t\t\t\t\t\tif (triangle [col, row] > 1) {\n\t\t\t\t\t\t\tdouble diff = triangle [col, row] - 1;\n\t\t\t\t\t\t\ttriangle [col, row] = 1;\n\t\t\t\t\t\t\ttriangle [col + 1, row] += diff / 2;\n\t\t\t\t\t\t\ttriangle [col + 1, row + 1] += diff / 2;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tint count = 0;\n\t\t\tfor (int i = 0; i < n; i++) {\n\t\t\t\tfor (int j = 0; j < n; j++) {\n\t\t\t\t\tif (triangle [i, j] >= 1)\n\t\t\t\t\t\tcount++;\n\t\t\t\t}\n\t\t\t}\n\t\t\tConsole.WriteLine (count);\n\t\t}\n\t}\n}\n", "lang_cluster": "C#", "tags": ["math", "implementation"], "code_uid": "c7d49216e243e20390e66e5eb50d00e1", "src_uid": "b2b49b7f6e3279d435766085958fb69d", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\n\nnamespace ConsoleApplication16\n{\n internal class Program\n {\n private static void Main(string[] args)\n {\n string str = Console.ReadLine();\n\n int a = Int32.Parse(str.Split(' ')[0]);\n int b = Int32.Parse(str.Split(' ')[1]);\n\n int i = 1;\n while (a >= 0 || b >= 0)\n {\n a = a - i;\n if (a < 0)\n {\n Console.WriteLine(\"Vladik\");\n break;\n }\n\n i++;\n\n b = b - i;\n if (b < 0)\n {\n Console.WriteLine(\"Valera\");\n break;\n }\n i++;\n }\n \n \n }\n }\n}", "lang_cluster": "C#", "tags": ["brute force", "implementation"], "code_uid": "751209bfe1b72e46d7417ca9a69f53f9", "src_uid": "87e37a82be7e39e433060fd8cdb03270", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace A811\n{\n class Program\n {\n static void Main(string[] args)\n {\n string[] arr = Console.ReadLine().Split();\n int a = int.Parse(arr[0]);\n int b = int.Parse(arr[1]);\n int m = 1;\n while (true) {\n if (a < m) {\n Console.WriteLine(\"Vladik\");\n return;\n }\n a -= m;\n m++;\n if (b < m) {\n Console.WriteLine(\"Valera\");\n return;\n }\n b -= m;\n m++;\n }\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "implementation"], "code_uid": "cd95ce4687dc0a96b4dc2167bdfb53ce", "src_uid": "87e37a82be7e39e433060fd8cdb03270", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace codeforceCSharp\n{\n class Program\n {\n //static Stack dat = new Stack();\n \n\n static void Main(string[] args)\n {\n\n int n = int.Parse(Console.ReadLine());\n if(n%2!=0)\n {\n Console.WriteLine(0);\n }\n else\n {\n Console.WriteLine(Math.Pow(2,n/2));\n }\n\n Console.ReadLine();\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "dp"], "code_uid": "f7ab87669a7c3d022323d427f607b26b", "src_uid": "4b7ff467ed5907e32fd529fb39b708db", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\n\nnamespace Algorithms\n{\n class Program\n {\n \n static void Main(string[] args)\n {\n var n = int.Parse(Console.ReadLine());\n\n var result = FillingShapers(n);\n\n Console.WriteLine(result);\n }\n\n private static int FillingShapers(int n)\n {\n if (n < 2) return 0;\n\t\t\t\n if (n % 2 == 1) return 0;\n\n return (int)Math.Pow(2, n / 2);\n }\n\t\t\n }\n}", "lang_cluster": "C#", "tags": ["math", "dp"], "code_uid": "74aa779640d10973d8b99aa6f3666586", "src_uid": "4b7ff467ed5907e32fd529fb39b708db", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Globalization;\nusing System.Linq;\n\nnamespace Codeforces\n{\n internal static class Program\n {\n private static void Main()\n {\n var m = long.Parse(Console.ReadLine());\n var count = 0L;\n\n for (var i = 1; count <= m; i++)\n {\n count = GetCount(i);\n\n if (count == m)\n {\n Print(5);\n Print(string.Join(\" \", Enumerable.Range(i, 5)));\n return;\n }\n }\n\n Print(0);\n }\n\n private static long GetCount(long n)\n {\n var count = 0L;\n for (var t = 5L; t <= n; t *= 5) { count += n / t; }\n return count;\n }\n\n private static void Print(string s) { Console.WriteLine(s); }\n private static void Print(long x) { Console.WriteLine(x.ToString(CultureInfo.InvariantCulture)); }\n }\n}", "lang_cluster": "C#", "tags": ["brute force", "math", "constructive algorithms", "number theory"], "code_uid": "fb71e546aa1f234207fd75cbcbbc3ca2", "src_uid": "c27ecc6e4755b21f95a6b1b657ef0744", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\n\nnamespace CSharp\n{\n class _633B\n {\n public static void Main()\n {\n int m = int.Parse(Console.ReadLine());\n\n var result = new List();\n\n for (int n = 1, zeroes = 0; zeroes <= m; n++)\n {\n int x = n;\n\n while (x % 5 == 0)\n {\n x /= 5;\n zeroes++;\n\n if (zeroes > m)\n {\n break;\n }\n }\n\n if (zeroes == m)\n {\n result.Add(n);\n }\n }\n\n Console.WriteLine(result.Count);\n Console.WriteLine(string.Join(\" \", result));\n }\n }\n}", "lang_cluster": "C#", "tags": ["brute force", "math", "constructive algorithms", "number theory"], "code_uid": "fcd010d614f12baf18472ecb98b01a6b", "src_uid": "c27ecc6e4755b21f95a6b1b657ef0744", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": " using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Runtime.InteropServices;\nusing System.Text.RegularExpressions;\n\n\n class Program\n {\n static void Main(string[] args){\n \n string[] input = Console.ReadLine().Split(' ');\n \n int xCoordinate = Int32.Parse(input[0]);\n int yCoordinate = Int32.Parse(input[1]);\n //int turnsCOmpleted = 0;\n int turnsTaken = 0;\n if ((xCoordinate == 0 && yCoordinate == 0) || (xCoordinate == 1 && yCoordinate == 0)){\n\t\tturnsTaken =0;\n}\n \n else\n {\n int currentXCoor = 0;\n int currentYCoor = 0;\n int previousXCoor = 1;\n int previousYCoor = 0;\n int quadrant = 1;\n\n\n \n for (int i = 0; i < int.MaxValue; i++)\n {\n //int y = 0;\n //int x = 0;\n if (quadrant == 1)\n {\n currentXCoor = previousXCoor;\n currentYCoor = previousYCoor + 1 +(2*(-previousYCoor));\n turnsTaken += 1;\n if(xCoordinate == currentXCoor)\n {\n if (yCoordinate >= previousYCoor && yCoordinate <= currentYCoor)\n break;\n \n }\n \n\n }\n //continue;\n else if (quadrant == 2)\n {\n currentXCoor = -previousXCoor;\n currentYCoor = previousYCoor;\n turnsTaken += 1;\n if(yCoordinate == currentYCoor)\n {\n if (xCoordinate <= previousXCoor && xCoordinate >= currentXCoor)\n break;\n }\n\n //c//ontinue;\n }\n else if (quadrant == 3)\n {\n currentXCoor = previousXCoor;\n currentYCoor = -previousYCoor;\n turnsTaken += 1;\n if(xCoordinate == currentXCoor)\n {\n if (yCoordinate >= currentYCoor && yCoordinate <= previousYCoor)\n break;\n }\n\n }\n\n else if(quadrant == 4)\n {\n currentXCoor = -previousXCoor+1;\n currentYCoor = previousYCoor;\n turnsTaken += 1;\n if(yCoordinate == currentYCoor)\n {\n if (xCoordinate >= previousXCoor && xCoordinate <= currentXCoor)\n break;\n }\n\n }\n previousXCoor = currentXCoor;\n previousYCoor = currentYCoor;\n if (quadrant == 4)\n quadrant = 1;\n else\n quadrant += 1;\n\n\n\n }\n }\n Console.WriteLine(turnsTaken);\n }\n \n }", "lang_cluster": "C#", "tags": ["brute force", "geometry", "implementation"], "code_uid": "d138ed9fe4f5f6be4baf5c3f9dc6a06d", "src_uid": "2fb2a129e01efc03cfc3ad91dac88382", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\n\nnamespace ConsoleApplication136\n{\n class Program\n {\n static int Main(string[] args)\n {\n string[] s = Console.ReadLine().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);\n int x = int.Parse(s[0]);\n int y = int.Parse(s[1]);\n int answer = 0;\n int x1=0;\n int y1=0;\n int n = 1;\n int dir = 1;\n int count=0;\n while (x1 != x || y1 != y)\n {\n if (count == n)\n {\n dir = (dir % 4 + 1);\n answer++;\n count=0;\n if (dir % 2 == 1)\n n++;\n }\n if (dir == 1)\n x1 += 1;\n else\n if (dir == 2)\n y1 += 1;\n else\n if (dir == 3)\n x1 -= 1;\n else\n y1 -= 1;\n count++;\n }\n Console.WriteLine(answer);\n Console.ReadLine();\n return 0;\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "geometry", "implementation"], "code_uid": "17ff7d19114bc0b320650f9a4578334f", "src_uid": "2fb2a129e01efc03cfc3ad91dac88382", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\n\nnamespace b1cs\n{\n class Program\n {\n static void Main(string[] args)\n {\n bool[,] z = new bool[5, 5];\n int n = int.Parse(Console.ReadLine());\n for (int i = 0; i < n; i++)\n {\n string[] ss = Console.ReadLine().Split();\n int a = int.Parse(ss[0]);\n int b = int.Parse(ss[1]);\n a--;b--;\n z[a, b] = true;\n z[b, a] = true;\n }\n for (int a = 0; a < 3; a++)\n {\n for (int b = a + 1; b < 4; b++)\n {\n for (int c = b + 1; c < 5; c++)\n {\n if ((z[a, b] && z[a, c] && z[b, c]) || (!z[a, b] && !z[a, c] && !z[b, c]))\n {\n Console.WriteLine(\"WIN\");\n return;\n }\n }\n }\n }\n Console.WriteLine(\"FAIL\");\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "implementation", "graphs"], "code_uid": "db5db81e9e715af4b6c4f3dd180a812a", "src_uid": "2bc18799c85ecaba87564a86a94e0322", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.IO;\nusing System.Text;\n\nnamespace Friends\n{\n internal class Program\n {\n private static readonly StreamReader reader = new StreamReader(Console.OpenStandardInput(1024*10), Encoding.ASCII, false, 1024*10);\n private static readonly StreamWriter writer = new StreamWriter(Console.OpenStandardOutput(1024*10), Encoding.ASCII, 1024*10);\n\n private static void Main(string[] args)\n {\n writer.WriteLine(Solve() ? \"WIN\" : \"FAIL\");\n writer.Flush();\n }\n\n private static bool Solve()\n {\n var mm = new bool[6,6];\n int m = Next();\n for (int i = 0; i < m; i++)\n {\n int a = Next();\n int b = Next();\n mm[a, b] = true;\n mm[b, a] = true;\n }\n\n for (int i = 1; i < 6; i++)\n {\n for (int j = i + 1; j < 6; j++)\n {\n for (int k = j + 1; k < 6; k++)\n {\n if (mm[i, j] == mm[j, k] && mm[i, j] == mm[i, k])\n return true;\n }\n }\n }\n return false;\n }\n\n private static int Next()\n {\n int c;\n int res = 0;\n do\n {\n c = reader.Read();\n if (c == -1)\n return res;\n } while (c < '0' || c > '9');\n res = c - '0';\n while (true)\n {\n c = reader.Read();\n if (c < '0' || c > '9')\n return res;\n res *= 10;\n res += c - '0';\n }\n }\n }\n}", "lang_cluster": "C#", "tags": ["math", "implementation", "graphs"], "code_uid": "feacadf77f7f48f1fea7f909eb7f88b0", "src_uid": "2bc18799c85ecaba87564a86a94e0322", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\n\nnamespace CF_94A\n{\n class Program\n {\n static void Main(string[] args)\n {\n string ecrypted_code = Console.ReadLine();\n\n var code = new string[10];\n\n for(int i=0; i<10; i++)\n {\n code[i] = Console.ReadLine();\n }\n Console.WriteLine();\n\n string str = \"\";\n int count = 0;\n var list = new List();\n for(int i=0; i<=ecrypted_code.Length; i++)\n {\n if(count < 10)\n {\n str += ecrypted_code[i];\n count++;\n }\n else if(i < ecrypted_code.Length)\n {\n list.Add(str);\n str = \"\";\n count = 0;\n i--;\n }\n else\n {\n list.Add(str);\n str = \"\";\n }\n }\n\n foreach(var item in list)\n {\n for(int i=0; i nos = new Dictionary();\n for (int i = 0; i < 10; i++)\n {\n nos.Add(Console.ReadLine(), i);\n }\n\n Console.WriteLine(solve( encPassword, nos));\n Console.ReadLine();\n }\n static string solve(string str, Dictionary nos)\n {\n string result = \"\";\n for (int i = 0; i < 8; i++)\n {\n result += nos[str.Substring(10 * i, 10)].ToString();\n }\n\n\n return result;\n }\n\n\n }\n}", "lang_cluster": "C#", "tags": ["strings", "implementation"], "code_uid": "2ea856572668b64648aaba9203232e2a", "src_uid": "0f4f7ca388dd1b2192436c67f9ac74d9", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\n\n\nnamespace ConsoleApplication1\n{\n class Program\n {\n static void Main(string[] args)\n {\n String str;\n str= Console.ReadLine();\n int i;\n int sum = 0;\n \n int temp;\n \n for (i = 0; i < str.Length; i++)\n {\n if (i == 0)\n {\n sum += str[0] - 97;\n if (sum > 13) sum = 26 - sum;\n\n }\n else\n {\n temp = Math.Abs(str[i] - str[i - 1]);\n\n if (temp > 13) temp = 26 - temp;\n sum += temp;\n }\n }\n\n Console.WriteLine(sum);\n \n \n\n \n\n }\n }\n}\n\n\n\n\n", "lang_cluster": "C#", "tags": ["strings", "implementation"], "code_uid": "54430dc59ee999179141ee31c068bf64", "src_uid": "ecc890b3bdb9456441a2a265c60722dd", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.IO;\nusing System.Linq;\nusing System.Collections.Generic;\n\nnamespace CSharp_Shell\n{\n\n public static class Program \n {\n public static void Main() \n {\n char[] input = (\"a\"+Console.ReadLine()).ToCharArray();\n string aphal = \"abcdefghijklmnopqrstuvwxyz\";\n int s = 0;\n int c = 0;\n for(int i = 0; i< input.Length-1; i++){\n \tint c1 =0;\n \tint c2 =0;\n for(int k =0; k < aphal.Length; k++){\n \tif(aphal[k] == input[i]){\n \t\tc = k;\n \t\tbreak;\n \t}\n }\n c1 = c;\n int k1 = 0 , k2 =0;\n while(true){\n \tif(c1 == aphal.Length){\n \t\tc1 = 0;\n \t}\n \tif(aphal[c1] == input[i+1]){\n \t\tbreak;\n \t}\n \tk1++;\n //\tConsole.WriteLine(c1);\n \tc1++;\n }\n c2 = c;\n while(true){\n \tif(c2 < 0){\n \t\tc2 = aphal.Length -1;\n \t}\n \tif(aphal[c2] == input[i + 1]){\n \t\tbreak;\n \t}\n \tk2++;\n \t//Console.WriteLine(c2);\n \tc2--;\n }\n \n c = Math.Min(k2,k1);\n s+=c;\n // Console.WriteLine(c);\n }\n Console.WriteLine(s);\n }\n }\n}", "lang_cluster": "C#", "tags": ["strings", "implementation"], "code_uid": "9ca80bb54fc610945846c62501b0f200", "src_uid": "ecc890b3bdb9456441a2a265c60722dd", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.IO;\nusing System.Collections.Generic;\nusing System.Collections;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace csharp\n{\n class Program\n {\n private static TextReader cin = Console.In;\n private static TextWriter cout = Console.Out;\n private static long sqr(long x)\n {\n return x*x;\n }\n static void Main(string[] args)\n {\n string s = cin.ReadLine();\n long n = long.Parse(s.Split(' ')[0]);\n long m = long.Parse(s.Split(' ')[1]);\n \n string[] map = new string[n];\n for (int i = 0; i < n; i++) map[i] = cin.ReadLine();\n var r = new int[n,m];\n int ans = 0;\n for (int i = 0; i < n; i++)\n {\n if (map[i] == new string('.', (int)m))\n {\n for (int j= 0; j < m; j++) r[i,j]=1;\n }\n }\n for (int i = 0; i < m; i++)\n {\n int g = 1;\n for (int j = 0; j < n; j++)\n if (map[j][i] == 'S') { g = 0; break; }\n if (g == 1) for (int j = 0; j < n; j++) r[j, i] = 1;\n }\n for (int i = 0; i < n; i++)\n for (int j = 0; j < m; j++)\n if (r[i, j] == 1) ans++;\n cout.WriteLine(ans);\n \n //cin.ReadLine();\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "implementation"], "code_uid": "28b8cafde7a48e43f1cdc1e845dd544e", "src_uid": "ebaf7d89c623d006a6f1ffd025892102", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Linq;\nclass a\n{\n static void Main()\n {\n var a = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);\n \n string[] b = new string[a[0]];\n\n int r = 0;\n\n for (int i = 0; i < a[0]; i++)\n {\n b[i] = Console.ReadLine();\n if (!b[i].Contains('S'))\n {\n r += b[i].Length;\n b[i] = b[i].Replace('.', '0');\n }\n }\n\n for (int i = 0; i < a[1]; i++)\n {\n int tr = 0;\n for (int j = 0; j < a[0]; j++)\n {\n if (b[j][i] == 'S')\n {\n tr = 0;\n break;\n }\n else if (b[j][i] == '.') tr++; \n }\n r += tr;\n }\n Console.WriteLine(r);\n }\n}\n\n", "lang_cluster": "C#", "tags": ["brute force", "implementation"], "code_uid": "6a6d8d493a527ab3b1f865162340bfe0", "src_uid": "ebaf7d89c623d006a6f1ffd025892102", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Linq;\nusing System.Collections.Generic;\nusing System.Text;\n\nnamespace CodeForces.PRACTICE\n{\n // Jzzhu and Children (implementation)\n class _450A\n {\n static void Main(string[] args)\n {\n string[] ss = Console.ReadLine().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);\n int n = int.Parse(ss[0]);\n int m = int.Parse(ss[1]);\n ss = Console.ReadLine().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);\n int[] a = new int[n];\n for (int i = 0; i < n; i++)\n a[i] = int.Parse(ss[i]);\n int max = 0;\n int maxPos = -1;\n for (int i = n - 1; i >= 0; i--)\n {\n int db = a[i] / m + Math.Sign(a[i] % m);\n if (db > max) { max = db; maxPos = i; }\n }\n Console.WriteLine(maxPos + 1);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "7b71d621bab469bdd2562a5b5d2c4826", "src_uid": "c0ef1e4d7df360c5c1e52bc6f16ca87c", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Globalization;\nusing System.IO;\nusing System.Linq;\nusing System.Text;\npublic class Solver\n{\n #region Main\n protected static TextReader reader;\n protected static TextWriter writer;\n static void Main()\n {\n reader = new StreamReader(Console.OpenStandardInput(1024 * 10), System.Text.Encoding.ASCII, false, 1024 * 10);\n writer = new StreamWriter(Console.OpenStandardOutput(1024 * 10), System.Text.Encoding.ASCII, 1024 * 10);\n var n = ReadInt();\n var m = ReadInt();\n var a = ReadIntArray();\n int i = 0, h = -1;\n while (a.Any(z => z > 0))\n {\n if (a[i % n] - m > 0)\n {\n a[i % n] -= m;\n }\n else\n {\n a[i % n] = h--;\n }\n i++;\n }\n writer.WriteLine(Array.IndexOf(a, a.Min()) + 1);\n reader.Close();\n writer.Close();\n }\n #endregion\n #region Read / Write\n\n private static Queue currentLineTokens = new Queue();\n\n private static string[] ReadAndSplitLine()\n {\n return reader.ReadLine().Split(new[] { ' ', '\\t' }, StringSplitOptions.RemoveEmptyEntries);\n }\n\n public static string ReadToken()\n {\n while (currentLineTokens.Count == 0)\n currentLineTokens = new Queue(ReadAndSplitLine());\n return currentLineTokens.Dequeue();\n }\n\n public static int ReadInt()\n {\n return int.Parse(ReadToken());\n }\n\n public static long ReadLong()\n {\n return long.Parse(ReadToken());\n }\n\n public static double ReadDouble()\n {\n return double.Parse(ReadToken(), CultureInfo.InvariantCulture);\n }\n\n public static int[] ReadIntArray()\n {\n return ReadAndSplitLine().Select(int.Parse).ToArray();\n }\n\n public static long[] ReadLongArray()\n {\n return ReadAndSplitLine().Select(long.Parse).ToArray();\n }\n\n public static double[] ReadDoubleArray()\n {\n return ReadAndSplitLine().Select(s => double.Parse(s, CultureInfo.InvariantCulture)).ToArray();\n }\n\n public static int[][] ReadIntMatrix(int numberOfRows)\n {\n int[][] matrix = new int[numberOfRows][];\n for (int i = 0; i < numberOfRows; i++)\n matrix[i] = ReadIntArray();\n return matrix;\n }\n\n public static int[][] ReadAndTransposeIntMatrix(int numberOfRows)\n {\n int[][] matrix = ReadIntMatrix(numberOfRows);\n int[][] ret = new int[matrix[0].Length][];\n for (int i = 0; i < ret.Length; i++)\n {\n ret[i] = new int[numberOfRows];\n for (int j = 0; j < numberOfRows; j++)\n ret[i][j] = matrix[j][i];\n }\n return ret;\n }\n\n public static string[] ReadLines(int quantity)\n {\n string[] lines = new string[quantity];\n for (int i = 0; i < quantity; i++)\n lines[i] = reader.ReadLine().Trim();\n return lines;\n }\n\n public static void WriteArray(IEnumerable array)\n {\n writer.WriteLine(string.Join(\" \", array));\n }\n\n public static void Write(params T[] array)\n {\n WriteArray(array);\n }\n\n public static void WriteLines(IEnumerable array)\n {\n foreach (var a in array)\n writer.WriteLine(a);\n }\n\n #endregion\n}", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "423d9739e262c3bfd5b06bde63b1aa14", "src_uid": "c0ef1e4d7df360c5c1e52bc6f16ca87c", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\n\npublic class HelloWorld {\n static public void Main () {\n SolveCodeForces();\n }\n\n public static void SolveCodeForces() {\n var n = int.Parse(Console.ReadLine());\n var s = Console.ReadLine();\n\n var n8 = s.Count(c => c == '8');\n var m = s.Length - n8;\n\n var ans = 0;\n\n for (var i = 0; i <= n8; i++) {\n ans = Math.Max( ans, Math.Min(i, (s.Length - i) / 10) );\n }\n\n System.Console.WriteLine(ans);\n }\n}", "lang_cluster": "C#", "tags": ["brute force"], "code_uid": "f6737c8c2ba5447de8618e688a32466d", "src_uid": "259d01b81bef5536b969247ff2c2d776", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.IO;\nusing System.Linq;\nusing System.Text;\n\nnamespace Phone_Numbers\n{\n internal class Program\n {\n private static readonly StreamReader reader = new StreamReader(Console.OpenStandardInput(1024*10), Encoding.ASCII, false, 1024*10);\n private static readonly StreamWriter writer = new StreamWriter(Console.OpenStandardOutput(1024*10), Encoding.ASCII, 1024*10);\n\n private static void Main(string[] args)\n {\n writer.WriteLine(Solve(args));\n writer.Flush();\n }\n\n private static int Solve(string[] args)\n {\n string s = reader.ReadLine();\n s = reader.ReadLine();\n\n return Math.Min(s.Length/11, s.Count(c => c == '8'));\n }\n }\n}", "lang_cluster": "C#", "tags": ["brute force"], "code_uid": "fa229d0b5956a93748241eaedc83f199", "src_uid": "259d01b81bef5536b969247ff2c2d776", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing Solver.Ex;\nusing Debug = System.Diagnostics.Debug;\nusing Watch = System.Diagnostics.Stopwatch;\nusing StringBuilder = System.Text.StringBuilder;\nnamespace Solver\n{\n public class Solver\n {\n public void Solve()\n {\n var n = sc.Integer();\n var a = sc.Integer();\n var b = sc.Integer();\n var k = sc.Integer();\n const long mod = (long)1e9 + 7;\n var dp = new long[5050];\n dp[a]++;\n for (int _ = 0; _ < k; _++)\n {\n var ndp = new long[5050];\n for (int i = 1; i <= n; i++)\n {\n if (i == b) continue;\n var d = Math.Abs(b - i) - 1;\n var l = Math.Max(1, i - d);\n var r = Math.Min(n, i + d);\n ndp[l] += dp[i];\n ndp[i] -= dp[i];\n ndp[i + 1] += dp[i];\n ndp[r + 1] -= dp[i];\n }\n for (int i = 1; i <= n; i++)\n ndp[i] = (ndp[i] + ndp[i - 1]) % mod;\n dp = ndp;\n }\n long ret = 0;\n for (int i = 1; i <= n; i++)\n ret = (ret + dp[i]) % mod;\n IO.Printer.Out.WriteLine((ret + mod) % mod);\n }\n internal IO.StreamScanner sc;\n }\n\n #region Main and Settings\n static class Program\n {\n static void Main(string[] arg)\n {\n#if DEBUG\n var errStream = new System.IO.FileStream(@\"..\\..\\dbg.out\", System.IO.FileMode.Create, System.IO.FileAccess.Write, System.IO.FileShare.ReadWrite);\n Debug.Listeners.Add(new System.Diagnostics.TextWriterTraceListener(errStream, \"debugStream\"));\n Debug.AutoFlush = false;\n var sw = new Watch(); sw.Start();\n try\n {\n#endif\n var solver = new Solver();\n solver.sc = new IO.StreamScanner(Console.OpenStandardInput());\n solver.Solve();\n IO.Printer.Out.Flush();\n#if DEBUG\n }\n catch (Exception ex)\n {\n Console.Error.WriteLine(ex.Message);\n Console.Error.WriteLine(ex.StackTrace);\n }\n finally\n {\n sw.Stop();\n Console.ForegroundColor = ConsoleColor.Green;\n Console.Error.WriteLine(\"Time:{0}ms\", sw.ElapsedMilliseconds);\n Debug.Close();\n System.Threading.Thread.Sleep(System.Threading.Timeout.Infinite);\n }\n#endif\n }\n\n\n }\n #endregion\n}\n#region IO Helper\nnamespace Solver.IO\n{\n public class Printer : System.IO.StreamWriter\n {\n static Printer() { Out = new Printer(Console.OpenStandardOutput()) { AutoFlush = false }; }\n public static Printer Out { get; set; }\n public override IFormatProvider FormatProvider { get { return System.Globalization.CultureInfo.InvariantCulture; } }\n public Printer(System.IO.Stream stream) : base(stream, new System.Text.UTF8Encoding(false, true)) { }\n public Printer(System.IO.Stream stream, System.Text.Encoding encoding) : base(stream, encoding) { }\n public void Write(string format, IEnumerable source) { Write(format, source.OfType().ToArray()); }\n public void WriteLine(string format, IEnumerable source) { WriteLine(format, source.OfType().ToArray()); }\n }\n public class StreamScanner\n {\n public StreamScanner(System.IO.Stream stream) { iStream = stream; }\n private readonly System.IO.Stream iStream;\n private readonly byte[] buf = new byte[1024];\n private int len, ptr;\n private bool eof = false;\n public bool IsEndOfStream { get { return eof; } }\n const byte lb = 33, ub = 126, el = 10, cr = 13;\n public byte read()\n {\n if (eof) throw new System.IO.EndOfStreamException();\n if (ptr >= len) { ptr = 0; if ((len = iStream.Read(buf, 0, 1024)) <= 0) { eof = true; return 0; } }\n return buf[ptr++];\n }\n public char Char() { byte b = 0; do b = read(); while (b < lb || ub < b); return (char)b; }\n public char[] Char(int n) { var a = new char[n]; for (int i = 0; i < n; i++) a[i] = Char(); return a; }\n public char[][] Char(int n, int m) { var a = new char[n][]; for (int i = 0; i < n; i++) a[i] = Char(m); return a; }\n public string Scan()\n {\n if (eof) throw new System.IO.EndOfStreamException();\n StringBuilder sb = null;\n var enc = System.Text.UTF8Encoding.Default;\n do\n {\n for (; ptr < len && (buf[ptr] < lb || ub < buf[ptr]); ptr++) ;\n if (ptr < len) break;\n ptr = 0;\n if ((len = iStream.Read(buf, 0, 1024)) <= 0) { eof = true; return \"\"; }\n } while (true);\n do\n {\n var f = ptr;\n for (; ptr < len; ptr++)\n if (buf[ptr] < lb || ub < buf[ptr])\n //if(buf[i]==cr||buf[i]==el)\n {\n string s;\n if (sb == null) s = enc.GetString(buf, f, ptr - f);\n else { sb.Append(enc.GetChars(buf, f, ptr - f)); s = sb.ToString(); }\n ptr++; return s;\n }\n if (sb == null) sb = new StringBuilder(enc.GetString(buf, f, len - f));\n else sb.Append(enc.GetChars(buf, ptr, len - ptr));\n ptr = 0;\n\n }\n while (!eof && (len = iStream.Read(buf, 0, 1024)) > 0);\n eof = true; return (sb != null) ? sb.ToString() : \"\";\n }\n public long Long()\n {\n long ret = 0; byte b = 0; bool isMynus = false;\n const byte zr = 48, nn = 57, my = 45;\n do b = read();\n while (b != my && (b < zr || nn < b));\n if (b == my) { isMynus = true; b = read(); }\n for (; true; b = read())\n if (b < zr || nn < b)\n return isMynus ? -ret : ret;\n else ret = ret * 10 + b - zr;\n }\n public int Integer()\n {\n int ret = 0; byte b = 0; bool isMynus = false;\n const byte zr = 48, nn = 57, my = 45;\n do b = read();\n while (b != my && (b < zr || nn < b));\n if (b == my) { isMynus = true; b = read(); }\n for (; true; b = read())\n if (b < zr || nn < b)\n return isMynus ? -ret : ret;\n else ret = ret * 10 + b - zr;\n }\n public double Double() { return double.Parse(Scan(), System.Globalization.CultureInfo.InvariantCulture); }\n public string[] Scan(int n) { var a = new string[n]; for (int i = 0; i < n; i++) a[i] = Scan(); return a; }\n public double[] Double(int n) { var a = new double[n]; for (int i = 0; i < n; i++) a[i] = Double(); return a; }\n public int[] Integer(int n) { var a = new int[n]; for (int i = 0; i < n; i++) a[i] = Integer(); return a; }\n public long[] Long(int n) { var a = new long[n]; for (int i = 0; i < n; i++)a[i] = Long(); return a; }\n public void Flush() { iStream.Flush(); }\n }\n}\n#endregion\n#region Extension\nnamespace Solver.Ex\n{\n static public partial class EnumerableEx\n {\n static public string AsString(this IEnumerable ie) { return new string(ie.ToArray()); }\n static public string AsJoinedString(this IEnumerable ie, string st = \" \") { return string.Join(st, ie); }\n static public T[] Enumerate(this int n, Func f) { var a = new T[n]; for (int i = 0; i < n; i++) a[i] = f(i); return a; }\n }\n}\n#endregion", "lang_cluster": "C#", "tags": ["dp", "implementation", "combinatorics"], "code_uid": "883be4c69acf0b6a5d9c7dda96cb48f3", "src_uid": "142b06ed43b3473513995de995e19fc3", "difficulty": 1900.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Globalization;\nusing System.IO;\nusing System.Linq;\nusing System.Text;\n\n// (\u3065\u00b0\u03c9\u00b0)\u3065\uff90\u2605\u309c\u30fb\u3002\u3002\u30fb\u309c\u309c\u30fb\u3002\u3002\u30fb\u309c\u2606\u309c\u30fb\u3002\u3002\u30fb\u309c\u309c\u30fb\u3002\u3002\u30fb\u309c\npublic class Solver\n{\n private const int MOD = 1000000007;\n \n public object Solve()\n {\n int n = ReadInt();\n int a = ReadInt() - 1;\n int b = ReadInt() - 1;\n\n var dp = new long[n];\n dp[a] = 1;\n \n for (int k = ReadInt(); k > 0; k--)\n {\n var add = new long[n + 1];\n for (int i = 0; i < n; i++)\n {\n if (i < b)\n {\n int d = b - i - 1;\n if (d > 0)\n {\n add[Math.Max(0, i - d)] += dp[i];\n add[i] -= dp[i];\n add[i + 1] += dp[i];\n add[i + d + 1] -= dp[i];\n }\n }\n else\n {\n int d = i - b - 1;\n if (d > 0)\n {\n add[i - d] += dp[i];\n add[i] -= dp[i];\n add[i + 1] += dp[i];\n add[Math.Min(n, i + d + 1)] -= dp[i];\n }\n }\n }\n long c = 0;\n for (int i = 0; i < n; i++)\n {\n c = (c + add[i]) % MOD;\n dp[i] = c;\n }\n }\n\n long ans = 0;\n for (int i = 0; i < n; i++)\n ans = (ans + dp[i]) % MOD;\n if (ans < 0)\n ans += MOD;\n return ans;\n\n return null;\n }\n\n #region Main\n\n protected static TextReader reader;\n protected static TextWriter writer;\n\n static void Main()\n {\n#if DEBUG\n reader = new StreamReader(\"..\\\\..\\\\input.txt\");\n writer = Console.Out;\n //writer = new StreamWriter(\"..\\\\..\\\\output.txt\");\n#else\n reader = new StreamReader(Console.OpenStandardInput());\n writer = new StreamWriter(Console.OpenStandardOutput());\n// reader = new StreamReader(\"army.in\");\n// writer = new StreamWriter(\"army.out\");\n#endif\n try\n {\n object result = new Solver().Solve();\n if (result != null)\n writer.WriteLine(result);\n }\n catch (Exception ex)\n {\n#if DEBUG\n Console.WriteLine(ex);\n#else\n Console.WriteLine(ex);\n throw;\n#endif\n }\n reader.Close();\n writer.Close();\n }\n\n #endregion\n\n #region Read / Write\n\n private static Queue currentLineTokens = new Queue();\n\n private static string[] ReadAndSplitLine()\n {\n return reader.ReadLine().Split(new[] { ' ', '\\t' }, StringSplitOptions.RemoveEmptyEntries);\n }\n\n public static string ReadToken()\n {\n while (currentLineTokens.Count == 0)\n currentLineTokens = new Queue(ReadAndSplitLine());\n return currentLineTokens.Dequeue();\n }\n\n public static int ReadInt()\n {\n return int.Parse(ReadToken());\n }\n\n public static long ReadLong()\n {\n return long.Parse(ReadToken());\n }\n\n public static double ReadDouble()\n {\n return double.Parse(ReadToken(), CultureInfo.InvariantCulture);\n }\n\n public static int[] ReadIntArray()\n {\n return ReadAndSplitLine().Select(int.Parse).ToArray();\n }\n\n public static long[] ReadLongArray()\n {\n return ReadAndSplitLine().Select(long.Parse).ToArray();\n }\n\n public static double[] ReadDoubleArray()\n {\n return ReadAndSplitLine().Select(s => double.Parse(s, CultureInfo.InvariantCulture)).ToArray();\n }\n\n public static int[][] ReadIntMatrix(int numberOfRows)\n {\n int[][] matrix = new int[numberOfRows][];\n for (int i = 0; i < numberOfRows; i++)\n matrix[i] = ReadIntArray();\n return matrix;\n }\n\n public static int[][] ReadAndTransposeIntMatrix(int numberOfRows)\n {\n int[][] matrix = ReadIntMatrix(numberOfRows);\n int[][] ret = new int[matrix[0].Length][];\n for (int i = 0; i < ret.Length; i++)\n {\n ret[i] = new int[numberOfRows];\n for (int j = 0; j < numberOfRows; j++)\n ret[i][j] = matrix[j][i];\n }\n return ret;\n }\n\n public static string[] ReadLines(int quantity)\n {\n string[] lines = new string[quantity];\n for (int i = 0; i < quantity; i++)\n lines[i] = reader.ReadLine().Trim();\n return lines;\n }\n\n public static void WriteArray(IEnumerable array)\n {\n writer.WriteLine(string.Join(\" \", array));\n }\n\n public static void Write(params T[] array)\n {\n WriteArray(array);\n }\n\n public static void WriteLines(IEnumerable array)\n {\n foreach (var a in array)\n writer.WriteLine(a);\n }\n\n #endregion\n}", "lang_cluster": "C#", "tags": ["dp", "combinatorics"], "code_uid": "928a1fac144f8ba5553ee1cbc6084e7c", "src_uid": "142b06ed43b3473513995de995e19fc3", "difficulty": 1900.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace ConsoleApp12\n{\n class Program\n {\n static void Main(string[] args)\n {\n var inputs = (Console.ReadLine().Split().Select(x => int.Parse(x))).ToList();\n for (int i = Math.Min(inputs[1],inputs[2]); i > 0; --i)\n {\n if (inputs[1] / i + inputs[2] / i >= inputs[0])\n {\n Console.WriteLine(i);\n break;\n }\n }\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "implementation", "binary search"], "code_uid": "ddb02870a6ad87b2b67e472736e95ed3", "src_uid": "a254b1e3451c507cf7ce3e2496b3d69e", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace Codeforces\n{ \n class B\n {\n static void Main(string[] args)\n {\n string[] token = Console.ReadLine().Split();\n \n int n = int.Parse(token[0]);\n int a = int.Parse(token[1]);\n int b = int.Parse(token[2]);\n \n int min = Math.Min(a,b);\n int max = Math.Max(a,b);\n \n int ans = int.MinValue;\n \n\n for(int i=1;i 0)\n {\n s += ii%10;\n ii /= 10;\n }\n if (s == 10)\n {\n n--;\n if (n == 0)\n return i;\n }\n }\n }\n\n private static int Next()\n {\n int c;\n int res = 0;\n do\n {\n c = reader.Read();\n if (c == -1)\n return res;\n } while (c < '0' || c > '9');\n res = c - '0';\n while (true)\n {\n c = reader.Read();\n if (c < '0' || c > '9')\n return res;\n res *= 10;\n res += c - '0';\n }\n }\n }\n}", "lang_cluster": "C#", "tags": ["brute force", "dp", "binary search", "implementation", "number theory"], "code_uid": "6ce40dc1e85ee661cd940f5c2313569f", "src_uid": "0a98a6a15e553ce11cb468d3330fc86a", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Linq;\nusing System.Numerics;\n\nnamespace ProblemB\n{\n internal class Program\n {\n public static void Main(string[] args)\n {\n int k = int.Parse(Console.ReadLine());\n int i = 0;\n//\n long big = 0;\n// while (i < k)\n// {\n// big++;\n// if (big.ToString().ToCharArray().Select(c => c - '0').Sum() == 10)\n// {\n// Console.WriteLine(\"{0} {1}\", i + 1, big);\n// i++;\n// }\n// }\n\n i = 0;\n big = 10;\n while (i < k)\n {\n big += 9;\n if (big.ToString().ToCharArray().Select(c => c - '0').Sum() == 10)\n {\n i++;\n }\n }\n\n Console.WriteLine(big);\n \n }\n }\n}", "lang_cluster": "C#", "tags": ["brute force", "dp", "binary search", "implementation", "number theory"], "code_uid": "c0da4e4146c483dd1bfe022682c00a14", "src_uid": "0a98a6a15e553ce11cb468d3330fc86a", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nclass PairVariable : IComparable\n{\n public decimal a, b;\n public PairVariable()\n {\n a = b = 0;\n }\n public PairVariable(string s)\n {\n string[] q = s.Split();\n a = decimal.Parse(q[0]);\n b = decimal.Parse(q[1]);\n }\n public PairVariable(decimal a, decimal b)\n {\n this.a = a;\n this.b = b;\n }\n\n\n\n public int CompareTo(PairVariable other)\n {\n return this.a.CompareTo(other.a);\n }\n}\n\nnamespace ConsoleApplication254\n{\n\n class Program\n {\n\n\n static void Main(string[] args)\n {\n string[] ss = Console.ReadLine().Split();\n int n = int.Parse(ss[0]);\n string[] s = Console.ReadLine().Split();\n int[] m = new int[n - 1];\n for (int i = 1; i < n; i++)\n {\n m[i - 1] = int.Parse(s[i]);\n }\n int l = int.Parse((s[0]));\n if (l > m.Max())\n {\n Console.WriteLine(0);\n return;\n }\n while (true)\n {\n \n int max = m.Max();\n //Console.WriteLine(max);\n\n for (int i = 0; i < m.Length; i++)\n {\n if (m[i] == max)\n {\n m[i]--;\n l++;\n if (l > m.Max())\n {\n Console.WriteLine(l - int.Parse(s[0]));\n return;\n }\n }\n }\n\n }\n \n \n\n }\n }\n}", "lang_cluster": "C#", "tags": ["greedy", "implementation"], "code_uid": "703a0813d7d5ccfc51f8880b426bd929", "src_uid": "aa8fabf7c817dfd3d585b96a07bb7f58", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\nusing System;\nusing System.Linq;\nclass Program\n{\n static void Main()\n {\n Console.ReadLine();\n var p = Console.ReadLine().Split(' ').Select(x=>Convert.ToInt32(x)).ToArray();\n int l = p[0];\n p = p.Skip(1).ToArray();\n int k = 0;\n while (l <= p.Max())\n {\n p[Array.IndexOf(p, p.Max())]--;\n l++;\n k++;\n\n }\n Console.WriteLine(k);\n }\n}", "lang_cluster": "C#", "tags": ["greedy", "implementation"], "code_uid": "ca241ebba67a53cfd6620c2eac6b1c22", "src_uid": "aa8fabf7c817dfd3d585b96a07bb7f58", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.IO;\nusing System.Collections.Generic;\n\nnamespace _262\n{\n class Program\n {\n static void Main(string[] args)\n {\n //Console.SetIn(new StreamReader(\"input.txt\"));\n\n //solve_helvetic2019A1_improved();\n solve_573B();\n }\n\n\n public static void solve_573B()\n {\n string[] cards = Console.ReadLine().Split(' ');\n \n Array.Sort(cards);\n \n int answer = int.MaxValue;\n int diff = 0;\n int min = int.MaxValue;\n int card1 = Convert.ToInt32(cards[0][0].ToString());\n int card2 = Convert.ToInt32(cards[1][0].ToString());\n int card3 = Convert.ToInt32(cards[2][0].ToString());\n if (cards[0][1] == cards[1][1] && cards[1][1] == cards[2][1])\n {\n if ((Math.Abs(card1 - card2) == 1 && Math.Abs(card2 - card3) == 1) || (Math.Abs(card1 - card2) == 0 && Math.Abs(card2 - card3) == 0))\n {\n answer = 0;\n }\n else if (Math.Abs(card1 - card2) == 2 || Math.Abs(card2 - card3) == 2)\n {\n answer = 1;\n }\n else \n {\n answer = 2;\n }\n }\n \n min = Math.Min(min, answer);\n if (cards[0][1] == cards[1][1])\n {\n diff = Math.Abs(card1 - card2);\n \n if (diff <= 2)\n {\n answer = 1;\n }\n else\n {\n answer = 2; \n }\n min = Math.Min(min, answer);\n }\n \n if (cards[1][1] == cards[2][1])\n {\n diff = Math.Abs(card2 - card3);\n \n if (diff <= 2)\n {\n answer = 1;\n }\n else\n {\n answer = 2; \n }\n min = Math.Min(min, answer);\n }\n\n if (cards[0][1] == cards[2][1])\n {\n diff = Math.Abs(card1 - card3);\n \n if (diff <= 2)\n {\n answer = 1;\n }\n else\n {\n answer = 2; \n }\n min = Math.Min(min, answer);\n }\n\n min = Math.Min(min, 2);\n Console.WriteLine(min);\n }\n\n public static void solve_368B()\n {\n string[] nm = Console.ReadLine().Split(' ');\n int n = Convert.ToInt32(nm[0]);\n int m = Convert.ToInt32(nm[1]);\n string[] test = Console.ReadLine().Split(' ');\n int[] cnts = new int [1000001];\n\n for (int i = 0; i < test.Length; i++)\n {\n cnts[Convert.ToInt32(test[i])]++;\n }\n\n int uqCnt = 0;\n for (int i = 0; i < cnts.Length; i++)\n {\n if (cnts[i] > 0)\n {\n uqCnt++;\n }\n }\n\n List> prefs = new List>();\n for (int i = 0; i < test.Length; i++)\n {\n int idx = Convert.ToInt32(test[i]);\n if (cnts[idx] > 0)\n {\n --cnts[idx];\n\n prefs.Add(new KeyValuePair(i + 1, uqCnt));\n\n if (cnts[idx] == 0)\n {\n --uqCnt;\n }\n }\n }\n\n for (int i = 0; i < m; i++)\n {\n int idx = Convert.ToInt32(Console.ReadLine());\n Console.WriteLine(prefs[idx - 1].Value);\n }\n }\n /*\n In the tutorial it is mentioned that \n we are solving linear equation with one variable.\n\n Although it looks like a quadratic equation at first sight\n in reality it is a hidden linear equation. \n we just need to carefully analyse it and figure out\n that we don't always have equations in a clean canonical ways.\n like ax + b = 0. \n\n in the given equation:\n r = x^2 + 2xy + x + 1\n we could ajust it like that:\n r - x^2 - x - 1 = 2xy\n\n And this part brings confusion. Because the right part 2xy\n is not just y but also multiplied by 2x.\n TODO: Make description cleaner \n \n */\n public static void solve_helvetic2019A1_improved()\n {\n long r = Convert.ToInt64(Console.ReadLine());\n\n for (int x = 1; x < Math.Sqrt(r); x++)\n {\n long y = r - x * x - x - 1;\n\n if (y > 0 && y % 2 * x == 0)\n {\n Console.WriteLine(\"{0} {1}\", x, y / 2 * x);\n \n return;\n }\n }\n\n Console.WriteLine(\"NO\");\n }\n\n\n /*\n \u0412 \u043f\u0435\u0440\u0432\u043e\u043c \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0435, \u044f \u043f\u044b\u0442\u0430\u043b\u0441\u044f \u0442\u0443\u043f\u043e \u0434\u0432\u043e\u0439\u043d\u044b\u043c \u0446\u0438\u043a\u043b\u043e\u043c \u043d\u0430\u0439\u0442\u0438 \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e\n x \u0438 y. \u041d\u043e \u0434\u0430\u0436\u0435 \u0435\u0441\u043b\u0438 \u0443\u0447\u0435\u0441\u0442\u044c \u0447\u0442\u043e \u0432 \u043f\u0435\u0440\u0432\u043e\u043c \u0446\u0438\u043a\u043b\u0435 \u0443 \u043d\u0430\u0441 \u0431\u0443\u0434\u0435\u0442 sqrt(r) \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u0439\n \u0434\u043b\u044f \u043d\u0430\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u044f x, \u0442\u043e \u0432\u0442\u043e\u0440\u044b\u043c \u0446\u0438\u043a\u043b\u043e\u043c \u043c\u044b \u043d\u0435 \u0441\u043c\u043e\u0436\u0435\u043c \u0432 \u0440\u0430\u043c\u043a\u0430\u0445 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f \u043f\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0437\u0430\u0434\u0430\u0447\u0438\n \u043d\u0430\u0439\u0442\u0438 y.\n */\n public static void solve_helvetic2019A1()\n {\n long r = Convert.ToInt64(Console.ReadLine());\n\n bool found = false;\n long x = 0;\n long y = 0;\n long xLen = (int)Math.Sqrt(r);\n for (x = 1; x < xLen; x++)\n {\n long yLen = r <= 100000 ? r : r / (2 * xLen);\n for (y = 2 * x + 1; y < yLen; y++)\n {\n long h = x * x + 2 * x * y + x + 1;\n if (h > r)\n {\n break;\n }\n \n if (r == h)\n {\n found = true;\n break;\n }\n }\n\n if (found)\n {\n break;\n }\n }\n\n if (found)\n {\n Console.Write(\"{0} {1}\", x, y);\n }\n else\n {\n Console.Write(\"NO\");\n }\n }\n\n public static void solve_262A()\n {\n string[] nm = Console.ReadLine().Split(' ');\n\n int n = Convert.ToInt32(nm[0]);\n int m = Convert.ToInt32(nm[1]);\n\n int bought = n;\n int max = n;\n int start = max;\n while (bought > 0)\n {\n bought = start % m == 0 ? (bought + m - 1) / m : bought / m;\n \n max += bought;\n }\n Console.WriteLine(max);\n }\n\n /* \n1)4\n2)1 + (1 + 1) + (1 + 1)\n3)1 + (1 + 1 + 1)\n4)1\n\n1 1 \n\t \n2 3 \n \n3 7 \n \n4 14 \n\t\n5 25\n\n1)5\n2)1 + (1 + 1) + (1 + 1) + (1 + 1)\n3)1 + (1 + 1 + 1) + (1 + 1 + 1)\n4)1 + (1 + 1 + 1 + 1)\n5)1\n\n(0) + 1 => (1) + 2 => (1 + 3) + 3 => (3 + 7) + 4 => (7 + 14) + 5\n */\n public static void solve_164B()\n {\n int n = Convert.ToInt32(Console.ReadLine());\n\n int total = 0;\n int prev = 0;\n int prevPrev = 0;\n for (int i = 1; i <= n; i++)\n {\n total = prevPrev + prev + i;\n\n prevPrev = prev;\n prev = total;\n }\n\n Console.WriteLine(total);\n }\n\n\n /*\n \u0412\u043d\u0438\u043c\u0430\u043d\u0438\u0435: \u0432 \u0434\u0430\u043d\u043d\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0435 \u0435\u0441\u043b\u0438 \u043a\u0440\u043e\u0442 \u043d\u0430\u0436\u0430\u043b \u043d\u0430 \u043a\u043d\u043e\u043f\u043a\u0443 q \u0438 \u0431\u044b\u043b\u043e \u0441\u043c\u0435\u0449\u0435\u043d\u0438\u0435 \u0432\u043f\u0440\u0430\u0432\u043e.\n \u0422\u043e \u0435\u0441\u0442\u044c \u043d\u0430\u0434\u043e \u0432\u043e\u0441\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c, \u0441\u043c\u0435\u0441\u0442\u0438\u0432 \u0431\u0443\u043a\u0432\u0443 \u0432\u043b\u0435\u0432\u043e, \u0442\u043e \u0443 \u043d\u0430\u0441 \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435.\n \u041f\u043e\u0442\u043e\u043c\u0443\u0447\u0442\u043e \u0432 \u0441\u0442\u0440\u043e\u043a\u0435 keyboard q \u044d\u0442\u043e \u043f\u0435\u0440\u0432\u0430\u044f \u0431\u0443\u043a\u0432\u0430 \u0441\u0442\u0440\u043e\u043a\u0438. \u0418 \u043b\u0435\u0432\u0435\u0435 \u043d\u0435\u0435 \u0443 \u043d\u0430\u0441 \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435\u0442.\n \u041d\u041e! \u041f\u043e \u0443\u0441\u043b\u043e\u0432\u0438\u044e \u0443 \u043d\u0430\u0441 \u043d\u0438\u0433\u0434\u0435 \u043d\u0435 \u0441\u043a\u0430\u0437\u0430\u043d\u043e, \u0447\u0442\u043e \u0435\u0441\u043b\u0438 \u043a\u0440\u043e\u0442 \u043d\u0430\u0436\u0430\u043b \u043d\u0430 \u0441\u0430\u043c\u0443\u044e \u043b\u0435\u0432\u0443\u044e \u043a\u043b\u0430\u0432\u0438\u0448\u0443, \u0442\u043e\n \u043c\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0432\u043e\u0441\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u0432\u0437\u044f\u0432 \u0441\u0430\u043c\u0443\u044e \u043f\u0440\u0430\u0432\u0443\u044e \u0431\u0443\u043a\u0432\u0443. \u0426\u0438\u043a\u043b\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0441\u0434\u0432\u0438\u0433 \u0437\u0430\u043c\u043a\u043d\u0443\u0442\u043e\u0441\u0442\u044c.\n \u0422\u043e \u0435\u0441\u0442\u044c \u0442\u0430\u043a\u043e\u0439 \u043a\u0435\u0439\u0441 \u043d\u0435 \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0435\u0442\u0441\u044f.\n\n \u0414\u043b\u044f \u0443\u0441\u043a\u043e\u0440\u0435\u043d\u0438\u044f \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430, \u043c\u043e\u0436\u043d\u043e \u0438\u0437\u0431\u0430\u0432\u0438\u0442\u044c\u0441\u044f \u043e\u0442 \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u043e\u0439 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0441\u0438\u043c\u0432\u043e\u043b\u0430 IndexOf \u0438 \u0437\u0430\u043f\u0438\u0445\u0430\u0442\u044c\n \u0432\u0441\u0435 \u0431\u0443\u043a\u0432\u044b \u0432 \u0441\u043b\u043e\u0432\u0430\u0440\u044c. \u0413\u0434\u0435 \u0431\u0443\u043a\u0432\u044b \u0431\u0443\u0434\u0443\u0442 \u043a\u043b\u044e\u0447\u0430\u043c\u0438, \u0430 \u0438\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u043c \u0432 \u0441\u0442\u0440\u043e\u043a\u0435.\n */\n public static void solve_271A()\n {\n string direction = Console.ReadLine();\n string text = Console.ReadLine();\n\n string keyboard = \"qwertyuiopasdfghjkl;zxcvbnm,./\";\n\n string answer = String.Empty;\n if (direction == \"R\")\n {\n for (int i = 0; i < text.Length; i++)\n {\n answer += keyboard[keyboard.IndexOf(text[i]) - 1];\n }\n }\n else\n {\n for (int i = 0; i < text.Length; i++)\n {\n answer += keyboard[keyboard.IndexOf(text[i]) + 1];\n }\n }\n\n Console.WriteLine(answer);\n }\n\n /*\n \u0414\u0430\u043d\u043d\u044b\u0439 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u043c\u043e\u0436\u043d\u043e \u0435\u0449\u0435 \u0443\u043b\u0443\u0447\u0448\u0438\u0442\u044c, \u0435\u0441\u043b\u0438 \u0438\u0437\u0431\u0430\u0432\u0438\u0442\u044c\u0441\u044f \u043e\u0442 \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u043e\u0439 \u043f\u0440\u043e\u0432\u0435\u043a\u0440\u0438 \u043d\u0430 \u0441\u0438\u043c\u0432\u043e\u043b\n String.Contains.\n \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u0443\u044e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u0434\u0430\u043d\u043d\u044b\u0445 dictionary \u0441 \u043f\u0440\u043e\u0432\u0435\u0440\u043e\u043a\u043e\u0439 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0437\u0430 \u0445\u043e\u0442\u044f \u0431\u044b\n log(n)\n */\n public static void solve_368A()\n {\n string[] nm = Console.ReadLine().Split(' ');\n\n int n = Convert.ToInt32(nm[0]);\n int m = Convert.ToInt32(nm[1]);\n\n int count = 0;\n string noir = \"WBG\";\n for (int i = 0; i < n; i++)\n {\n string[] row = Console.ReadLine().Split(' ');\n\n for (int j = 0; j < m; j++)\n {\n if (noir.Contains(row[j]))\n {\n count++;\n }\n }\n }\n\n string answer = (count == n * m) ? \"#Black&White\" : \"#Color\";\n\n Console.WriteLine(answer); \n }\n\n public static void solve_90A()\n {\n string[] abn = Console.ReadLine().Split(' ');\n\n int a = Convert.ToInt32(abn[0]);\n int b = Convert.ToInt32(abn[1]);\n int n = Convert.ToInt32(abn[2]);\n \n int count = 1;\n while (n > 0)\n {\n if (count % 2 == 0)\n {\n n -= gcd(n, b);\n }\n else \n {\n n -= gcd(n, a);\n }\n \n count++;\n }\n\n int answer = (--count % 2 == 0) ? 1 : 0;\n\n Console.WriteLine(answer);\n }\n\n public static int gcd(int a, int b)\n {\n if (b == 0)\n {\n return a;\n }\n\n return gcd(b, a % b);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "implementation"], "code_uid": "adcbc091e3ebaba888cc8eb9647968d8", "src_uid": "7e42cebc670e76ace967e01021f752d3", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace ConsoleApplication1\n{\n class Program\n {\n static void Main(string[] args)\n {\n var tiles = Console.ReadLine().Split();\n var toGetJontsu = Kontsu(tiles);\n var toGetShuntsu = Shuntsu(tiles);\n Console.WriteLine(Math.Min(toGetJontsu, toGetShuntsu));\n }\n\n static int Shuntsu(string[] tiles)\n {\n var masts = new Dictionary>();\n foreach (var tile in tiles)\n {\n if(!masts.ContainsKey(tile[1]))\n masts.Add(tile[1], new List());\n masts[tile[1]].Add(tile);\n }\n\n var res = 2;\n foreach (var mast in masts)\n {\n if (mast.Value.Count == 2)\n {\n if (Math.Abs(mast.Value[0][0] - mast.Value[1][0]) == 1 ||\n Math.Abs(mast.Value[0][0] - mast.Value[1][0]) == 2)\n res = Math.Min(res, 1);\n }\n\n if (mast.Value.Count == 3)\n {\n var ordered = mast.Value.OrderBy(x => x[0] - '1').ToArray();\n if (ordered[1][0] - ordered[0][0] == 1 && ordered[2][0] - ordered[1][0] == 1)\n res = Math.Min(res, 0);\n for (int i = 0; i < 3; i++)\n {\n for (int j = 0; j < 3; j++)\n {\n if(Math.Abs(ordered[i][0] - ordered[j][0]) == 1 ||\n Math.Abs(ordered[i][0] - ordered[j][0]) == 2)\n res = Math.Min(res, 1); \n }\n }\n \n }\n }\n\n return res;\n }\n\n static int Kontsu(string[] tiles)\n {\n var d = new Dictionary();\n foreach (var tile in tiles)\n {\n if(!d.ContainsKey(tile))\n d.Add(tile, 0);\n d[tile]++;\n }\n\n return 3 - d.Values.Max();\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "implementation"], "code_uid": "58dedff5bdd713828a2ccbad255f8581", "src_uid": "7e42cebc670e76ace967e01021f752d3", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\n\nclass TEST{\n\tstatic void Main(){\n\t\tSol mySol =new Sol();\n\t\tmySol.Solve();\n\t}\n}\n\nclass Sol{\n\tpublic void Solve(){\n\t\t\n\t\tif(N == 1){\n\t\t\tConsole.WriteLine(0);\n\t\t\treturn;\n\t\t}\n\t\tint H = 2;\n\t\tint W = N;\n\t\t\n\t\t\n\t\tint M = 1<<4;\n\t\tint[] c = new int[]{\n\t\t\t0xF - 1,\n\t\t\t0xF - 2,\n\t\t\t0xF - 4,\n\t\t\t0xF - 8,\n\t\t\t0\n\t\t};\n\t\tint[] dp = new int[M];\n\t\tfor(int i=0;i> 2;\n\t\t\t\t\tfor(int j=0;j<2;j++){\n\t\t\t\t\t\tst |= ((t + 2 < N && S[j][t + 2] == 'X') ? 1 : 0) << (2 + j);\n\t\t\t\t\t}\n//Console.WriteLine(\"i:{0}, b:{1}, st:{2}\",i, b, st);\n\t\t\t\t\tndp[st] = Math.Max(ndp[st], dp[i] + (b == 0 ? 0 : 1));\n\t\t\t\t}\n\t\t\t}\n\t\t\tdp = ndp;\n//Console.WriteLine(\"ndp:{0}\",String.Join(\" \",dp));\n\t\t}\n\t\t\n\t\tConsole.WriteLine(dp.Max());\n\t\t\n\t\t\n\t}\n\tint N;\n\tString[] S;\n\tpublic Sol(){\n\t\tS = new String[2];\n\t\tfor(int i=0;i<2;i++) S[i] = rs();\n\t\tN = S[0].Length;\n\t}\n\n\tstatic String rs(){return Console.ReadLine();}\n\tstatic int ri(){return int.Parse(Console.ReadLine());}\n\tstatic long rl(){return long.Parse(Console.ReadLine());}\n\tstatic double rd(){return double.Parse(Console.ReadLine());}\n\tstatic String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}\n\tstatic int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}\n\tstatic long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}\n\tstatic double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}\n}\n", "lang_cluster": "C#", "tags": ["greedy", "dp"], "code_uid": "cdb13f4e0064a51e3d77a604aa9ebc44", "src_uid": "e6b3e787919e96fc893a034eae233fc6", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections;\nusing System.Collections.Generic;\nusing System.Diagnostics;\nusing System.Globalization;\nusing System.IO;\nusing System.Linq;\nusing System.Text;\n\nnamespace Task\n{\n class Program\n {\n #region Read / Write\n protected static TextReader reader;\n protected static TextWriter writer;\n private static Queue currentLineTokens = new Queue();\n private static string[] ReadAndSplitLine() { return reader.ReadLine().Split(new[] { ' ', '\\t', }, StringSplitOptions.RemoveEmptyEntries); }\n public static string ReadToken() { while (currentLineTokens.Count == 0) currentLineTokens = new Queue(ReadAndSplitLine()); return currentLineTokens.Dequeue(); }\n public static int ReadInt() { return int.Parse(ReadToken()); }\n public static long ReadLong() { return long.Parse(ReadToken()); }\n public static double ReadDouble() { return double.Parse(ReadToken(), CultureInfo.InvariantCulture); }\n public static int[] ReadIntArray() { return ReadAndSplitLine().Select(int.Parse).ToArray(); }\n public static long[] ReadLongArray() { return ReadAndSplitLine().Select(long.Parse).ToArray(); }\n public static double[] ReadDoubleArray() { return ReadAndSplitLine().Select(s => double.Parse(s, CultureInfo.InvariantCulture)).ToArray(); }\n public static int[][] ReadIntMatrix(int numberOfRows) { int[][] matrix = new int[numberOfRows][]; for (int i = 0; i < numberOfRows; i++) matrix[i] = ReadIntArray(); return matrix; }\n public static int[][] ReadAndTransposeIntMatrix(int numberOfRows)\n {\n int[][] matrix = ReadIntMatrix(numberOfRows); int[][] ret = new int[matrix[0].Length][];\n for (int i = 0; i < ret.Length; i++) { ret[i] = new int[numberOfRows]; for (int j = 0; j < numberOfRows; j++) ret[i][j] = matrix[j][i]; }\n return ret;\n }\n public static string[] ReadLines(int quantity) { string[] lines = new string[quantity]; for (int i = 0; i < quantity; i++) lines[i] = reader.ReadLine().Trim(); return lines; }\n public static void WriteArray(IEnumerable array) { writer.WriteLine(string.Join(\" \", array)); }\n public static void Write(params object[] array) { WriteArray(array); }\n public static void WriteLines(IEnumerable array) { foreach (var a in array) writer.WriteLine(a); }\n private class SDictionary : Dictionary\n {\n public new TValue this[TKey key]\n {\n get { return ContainsKey(key) ? base[key] : default(TValue); }\n set { base[key] = value; }\n }\n }\n private static T[] Init(int size) where T : new() { var ret = new T[size]; for (int i = 0; i < size; i++) ret[i] = new T(); return ret; }\n #endregion=\n\n public static bool NextPermutation(List perm)\n {\n for (int i = perm.Count - 2; i >= 0; i--)\n {\n if (perm[i] < perm[i + 1])\n {\n int min = i + 1;\n for (int j = min; j < perm.Count; j++)\n if (perm[j] > perm[i] && perm[j] < perm[min])\n min = j;\n\n int tmp = perm[i];\n perm[i] = perm[min];\n perm[min] = tmp;\n perm.Reverse(i + 1, perm.Count - i - 1);\n return true;\n }\n }\n\n return false;\n }\n\n static void Main(string[] args)\n {\n long i = 0;\n long ans = 0;\n reader = new StreamReader(Console.OpenStandardInput());\n writer = new StreamWriter(Console.OpenStandardOutput());\n\n var s = ReadLines(2);\n var mas = s.Select(it => it.Select(ch => ch == 'X' ? 1 : 0).ToArray()).ToArray();\n\n int n = mas[0].Length;\n if (n < 2)\n {\n Write(0);\n }\n else\n {\n for (i = 0; i < n - 1; i++)\n {\n int ones = mas[0][i] + mas[0][i + 1] + mas[1][i] + mas[1][i + 1];\n if (ones == 1)\n {\n ans++;\n mas[0][i] = mas[0][i + 1] = mas[1][i] = mas[1][i + 1] = 1;\n }\n else if (ones == 0)\n {\n ans++;\n mas[0][i] = mas[0][i + 1] = mas[1][i] = 1;\n }\n }\n Write(ans);\n }\n\n reader.Close();\n writer.Close();\n }\n }\n}", "lang_cluster": "C#", "tags": ["greedy", "dp"], "code_uid": "d8d96d0811263e44b0b98b28547a706e", "src_uid": "e6b3e787919e96fc893a034eae233fc6", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace Codeforces\n{\n class Program\n {\n static void Main(string[] args)\n {\n \n string[] numbers = Console.ReadLine().Split();\n double x = Convert.ToDouble(numbers[0]);\n double y = Convert.ToDouble(numbers[1]);\n double xpow = y * Math.Log(x);\n double ypow = x * Math.Log(y);\n\n if(xpow>ypow)\n {\n Console.WriteLine(\">\");\n }\n else if(xpow';\n\n if (Math.Min(x, y) == 2 && Math.Max(x, y) == 4)\n return '=';\n\n return x > y ? '<' : '>';\n }\n\n private static int Next()\n {\n int c;\n int res = 0;\n do\n {\n c = reader.Read();\n if (c == -1)\n return res;\n } while (c < '0' || c > '9');\n res = c - '0';\n while (true)\n {\n c = reader.Read();\n if (c < '0' || c > '9')\n return res;\n res *= 10;\n res += c - '0';\n }\n }\n }\n}", "lang_cluster": "C#", "tags": ["math"], "code_uid": "d3c2118b2d569ba6ed9d938f5e742e7c", "src_uid": "ec1e44ff41941f0e6436831b5ae543c6", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.IO;\nusing System.Text;\n\nnamespace Malek_Dance_Club\n{\n internal class Program\n {\n private static readonly StreamReader reader = new StreamReader(Console.OpenStandardInput(1024*10), Encoding.ASCII, false, 1024*10);\n private static readonly StreamWriter writer = new StreamWriter(Console.OpenStandardOutput(1024*10), Encoding.ASCII, 1024*10);\n\n private static void Main(string[] args)\n {\n string s = reader.ReadLine();\n\n long prev = 0;\n long count = 1;\n int mod = 1000000007;\n for (int i = s.Length - 1; i >= 0; i--)\n {\n long next;\n if (s[i] == '1')\n {\n next = (count*count)%mod;\n next += 2*prev;\n }\n else\n {\n next = 2*prev;\n }\n\n count = (count*2)%mod;\n prev = next%mod;\n }\n\n writer.WriteLine(prev);\n writer.Flush();\n }\n }\n}", "lang_cluster": "C#", "tags": ["math", "combinatorics"], "code_uid": "934b157f073c6a63371d4e83617fa076", "src_uid": "89b51a31e00424edd1385f2120028b9d", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\nusing System.IO;\n\nnamespace Project1\n{\n\n class Class1\n {\n static long MOD = 1000000007;\n static long power(long x, long n)\n {\n long r = 1;\n while (n > 0)\n {\n if ((n & 1) == 1)\n {\n r = (r * x) % MOD;\n }\n x = (x * x) % MOD;\n n >>= 1;\n }\n return r;\n }\n public static void Main()\n {\n string s = System.Console.ReadLine();\n int len = s.Length;\n // long iver_two = power(2,MOD-2);\n long cur = power(2, len-1);\n long cur2 = 1;\n long ans = 0;\n int index=0;\n while (index si) Console.WriteLine(\"YES\");\n else Console.WriteLine(\"NO\");\n\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "1e3b6b1f9ca99c7e7f693b53a06bbb44", "src_uid": "ab8a2070ea758d118b3c09ee165d9517", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Linq;\n\nnamespace CodeForcesTest\n{\n class Program\n {\n\n static void Main(string[] args)\n {\n int _ = Convert.ToInt32(Console.ReadLine());\n char[] d = Console.ReadLine().ToCharArray();\n\n int ttsf = 0;\n int tts = 0;\n\n for (int i = 0; i < d.Count() - 1; i++)\n {\n if (d[i] == d[i + 1])\n continue;\n\n if (d[i] == 'F')\n tts++;\n else\n ttsf++;\n }\n\n if (ttsf > tts)\n Console.WriteLine(\"YES\");\n else\n Console.WriteLine(\"NO\");\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "9b10e8e663575c0f96470cfceefac83c", "src_uid": "ab8a2070ea758d118b3c09ee165d9517", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.IO;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace Codeforces\n{\n public class PetrAndACombinationLock\n {\n public static void Main()\n {\n StreamWriter sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };\n new PetrAndACombinationLock().Solve(Console.In, sw);\n sw.Flush();\n }\n\n public void Solve(TextReader tr, TextWriter tw)\n {\n var n = int.Parse(tr.ReadLine());\n var a = new int[n];\n for (int i = 0; i < n; i++)\n {\n a[i] = int.Parse(tr.ReadLine());\n }\n\n tw.WriteLine(Solve(a));\n }\n\n\n public string Solve(int[] v)\n {\n int n = v.Length;\n int maxN = (1 << n);\n\n for (int i = 0; i < maxN; i++)\n {\n int res = 0;\n for (int x = 0; x < n; x++)\n {\n if ((i & (1 << x)) == 0)\n {\n res += v[x];\n }\n else\n {\n res -= v[x];\n }\n }\n if (res % 360 == 0)\n {\n return \"YES\";\n }\n }\n\n return \"NO\";\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "dp", "bitmasks"], "code_uid": "68afe3d45034cef31d222bfe7025a006", "src_uid": "01b50fcba4185ceb1eb8e4ba04a0cc10", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\n\nnamespace NetCore\n{\n class Program\n {\n static void Main(string[] args)\n {\n int n = int.Parse(Console.ReadLine());\n int[] arr = new int[n];\n for(int i = 0; i < n; i++)\n {\n arr[i] = int.Parse(Console.ReadLine());\n }\n bool valid = false;\n int mx = (1 << n);\n for(int i = 0; i < mx; i++)\n {\n int sum = 0;\n int j = 1;\n int counter = 0;\n while(counter < n)\n {\n if ((j & i) != 0) sum += arr[counter];\n else sum -= arr[counter];\n counter++;\n j <<= 1;\n sum %= 360;\n }\n if (sum == 0) valid = true;\n }\n Console.WriteLine(valid ? \"YES\" : \"NO\");\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "dp", "bitmasks"], "code_uid": "ff86733b1c51d0bd19be4267fd803294", "src_uid": "01b50fcba4185ceb1eb8e4ba04a0cc10", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\n\nnamespace Comp_CSHARP\n{\n class Program\n {\n static void Main(string[] args)\n {\n string[] input = Console.ReadLine().Split(new[] {' '}, StringSplitOptions.RemoveEmptyEntries);\n int N = int.Parse(input[0]);\n int M = int.Parse(input[1]);\n int Min = int.Parse(input[2]);\n int Max = int.Parse(input[3]);\n\n IEnumerable T =\n Console.ReadLine().Split(new[] {' '}, StringSplitOptions.RemoveEmptyEntries).Select(int.Parse);\n\n int rMin = T.Min();\n int rMax = T.Max();\n\n if (rMin < Min || rMax > Max)\n goto fail;\n\n int diff = 0;\n\n if (rMin > Min)\n diff++;\n if (rMax < Max)\n diff++;\n\n if (diff > N - M)\n goto fail;\n\n win:\n Console.WriteLine(\"Correct\");\n return;\n\n \n fail:\n Console.WriteLine(\"Incorrect\"); \n }\n }\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "545d01d7e0138026c80837da0bc45f02", "src_uid": "99f9cdc85010bd89434f39b78f15b65e", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.IO;\nusing System.Text;\n\nnamespace Data_Recovery\n{\n internal class Program\n {\n private static readonly StreamReader reader =\n new StreamReader(Console.OpenStandardInput(1024*10), Encoding.ASCII, false, 1024*10);\n\n private static readonly StreamWriter writer =\n new StreamWriter(Console.OpenStandardOutput(1024*10), Encoding.ASCII, 1024*10);\n\n private static void Main(string[] args)\n {\n string[] ss = reader.ReadLine().Split(' ');\n int n = int.Parse(ss[0]);\n int m = int.Parse(ss[1]);\n int min = int.Parse(ss[2]);\n int max = int.Parse(ss[3]);\n\n int m1 = int.MaxValue;\n int m2 = int.MinValue;\n\n ss = reader.ReadLine().Split(' ');\n for (int i = 0; i < m; i++)\n {\n int mm = int.Parse(ss[i]);\n if (m1 > mm)\n m1 = mm;\n if (m2 < mm)\n m2 = mm;\n }\n writer.WriteLine(\"{0}\", check(n, m, min, max, m1, m2) ? \"Correct\" : \"Incorrect\");\n writer.Flush();\n }\n\n private static bool check(int n, int m, int min, int max, int m1, int m2)\n {\n if (m1 < min)\n return false;\n if (m2 > max)\n return false;\n int toadd = (m1 == min ? 0 : 1) + (m2 == max ? 0 : 1);\n if (m + toadd > n)\n return false;\n\n return true;\n }\n }\n}", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "e9f054435b2281818b2f7b3d51eb9fb7", "src_uid": "99f9cdc85010bd89434f39b78f15b65e", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\n\nclass Program\n{\n static void Main(string[] args)\n {\n string[] l1 = Console.ReadLine().Split();\n int s = Int32.Parse(l1[0]);\n int x1 = Int32.Parse(l1[1]);\n int x2 = Int32.Parse(l1[2]);\n\n string[] l2 = Console.ReadLine().Split();\n int t1 = Int32.Parse(l2[0]);\n int t2 = Int32.Parse(l2[1]);\n\n string[] l3 = Console.ReadLine().Split();\n int p = Int32.Parse(l3[0]);\n int d = Int32.Parse(l3[1]);\n\n // First, trying by himself:\n int footTime = Math.Abs(x1 - x2) * t2;\n\n // For the train, he first needs to wait to get on.\n int trainTime = 0;\n if (d * (x1 - p) >= 0)\n {\n trainTime = Math.Abs(x1 - p) * t1;\n }\n else\n {\n int dist = (d > 0) ? 2 * s - x1 - p : x1 + p;\n trainTime = dist * t1;\n d = -d;\n }\n\n // Then wait to arrive at the destination\n if (d * (x2 - x1) >= 0)\n {\n trainTime += Math.Abs(x2 - x1) * t1;\n }\n else\n {\n int dist = (d > 0) ? 2 * s - x1 - x2 : x1 + x2;\n trainTime += dist * t1;\n }\n\n Console.WriteLine(Math.Min(trainTime, footTime));\n Console.ReadLine();\n\n }\n}", "lang_cluster": "C#", "tags": ["math", "constructive algorithms", "implementation"], "code_uid": "b194fe079554a2851ebddd0a754b49cb", "src_uid": "fb3aca6eba3a952e9d5736c5d8566821", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\n\nnamespace codeforcing\n{\n class Program\n {\n static void Main(string[] args)\n {\n //INPUT PHASE\n string[] tokens = Console.ReadLine().Split();\n int s = int.Parse(tokens[0]);\n int x1 = int.Parse(tokens[1]);\n int x2 = int.Parse(tokens[2]);\n\n tokens = Console.ReadLine().Split();\n\n int t1 = int.Parse(tokens[0]);\n int t2 = int.Parse(tokens[1]);\n\n tokens = Console.ReadLine().Split();\n\n int p = int.Parse(tokens[0]);\n int d = int.Parse(tokens[1]);\n\n int timeWithNoTram = Math.Abs(x1 - x2) * t2;\n if(t2 < t1)\n {\n Console.WriteLine(timeWithNoTram);\n return;\n }\n\n int distanceWithTram = 0;\n if(p < x2 && x2 < x1)\n {\n //Console.WriteLine(\"am here 1\");\n if (d == 1)\n {\n distanceWithTram += s - p;\n \n \n }\n else\n {\n distanceWithTram += p;\n distanceWithTram += s;\n \n }\n\n distanceWithTram += s - x2;\n }\n else if(x1 < x2 && x2 < p)\n {\n //Console.WriteLine(\"am here 2\");\n if (d == 1)\n {\n distanceWithTram += s - p;\n distanceWithTram += s;\n distanceWithTram += x2;\n\n }\n else\n {\n distanceWithTram += p;\n distanceWithTram += x2;\n\n }\n \n }\n else if(p <= x1 && x1 < x2)\n {\n //Console.WriteLine(\"am here 3\");\n if (d == 1)\n {\n distanceWithTram += x2 - p;\n }\n\n else\n {\n distanceWithTram += p;\n distanceWithTram += x2;\n }\n }\n else if (x2 < x1 && x1 <= p)\n {\n // Console.WriteLine(\"am here 4\");\n if (d == 1)\n {\n distanceWithTram += s - p;\n distanceWithTram += s - x2;\n }\n\n else\n {\n distanceWithTram += p - x2;\n }\n }\n else if(x1<= p && p< x2)\n {\n //Console.WriteLine(\"am here 5\");\n if (d == 1)\n {\n distanceWithTram += s - p;\n distanceWithTram += s;\n distanceWithTram += x2;\n }\n\n else\n {\n distanceWithTram += p;\n distanceWithTram += x2;\n\n }\n }\n else if (x2 < p && p <= x1)\n {\n // Console.WriteLine(\"am here 6\"); \n if (d == 1)\n {\n \n distanceWithTram += s - p;\n distanceWithTram += s;\n distanceWithTram += x2;\n }\n\n else\n {\n distanceWithTram += p;\n distanceWithTram += s;\n distanceWithTram += s - x2;\n\n }\n }\n\n \n \n int timeWithTram = distanceWithTram * t1;\n\n Console.WriteLine((timeWithNoTram < timeWithTram ? timeWithNoTram : timeWithTram));\n\n\n\n\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "constructive algorithms", "implementation"], "code_uid": "98d1728bffa887e00409427e6b39dcb4", "src_uid": "fb3aca6eba3a952e9d5736c5d8566821", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeff#if DEBUG\nusing System.Reflection;\nusing System.Threading.Tasks;\n#endif\n\nusing System;\nusing System.Collections.Generic;\nusing System.IO;\nusing System.Linq;\nusing System.Text;\nusing System.Numerics;\nusing System.Globalization;\n\n\nnamespace _308c\n{\n class Program\n {\n static string _inputFilename = \"input.txt\";\n static string _outputFilename = \"output.txt\";\n static bool _useFileInput = false;\n\n\n static void Main(string[] args)\n {\n StreamWriter file = null;\n#if DEBUG\n\t\t\tConsole.SetIn(getInput());\n#else\n if (_useFileInput)\n {\n Console.SetIn(File.OpenText(_inputFilename));\n file = new StreamWriter(_outputFilename);\n Console.SetOut(file);\n }\n#endif\n\n try\n {\n solution();\n }\n finally\n {\n if (_useFileInput)\n {\n file.Close();\n }\n }\n }\n\n static void solution()\n {\n #region SOLUTION\n var d = readIntArray();\n var w = d[0];\n var m = d[1];\n var val = new int[101];\n var i = 1;\n while (true)\n {\n if (m == 0)\n {\n break;\n }\n\n var rem = m % w;\n val[i] = rem;\n i++;\n m /= w;\n }\n\n var av = new bool[101];\n for (int j = 1; j < 101; j++)\n {\n av[j] = true;\n }\n\n for (int j = 1; j < 101; j++)\n {\n if (val[j] == 0 || val[j] == 1)\n {\n continue;\n }\n\n if (val[j] == w)\n {\n if (j == 100)\n {\n Console.WriteLine(\"NO\");\n return;\n }\n\n val[j + 1]++;\n }\n\n if (val[j] < w - 1)\n {\n Console.WriteLine(\"NO\");\n return;\n }\n\n //if (val[j] == w - 2)\n //{\n // if (j == 100)\n // {\n // Console.WriteLine(\"NO\");\n // return;\n // }\n\n // if (!av[j - 1])\n // {\n // Console.WriteLine(\"NO\");\n // return;\n // }\n\n // av[j - 1] = false;\n // av[j] = false;\n // val[j + 1]++;\n //}\n\n if (val[j] == w - 1)\n {\n if (j == 100)\n {\n Console.WriteLine(\"NO\");\n return;\n }\n\n av[j] = false;\n val[j + 1]++;\n }\n }\n\n Console.WriteLine(\"YES\");\n\n //for (int j = 1; j < 101; j++)\n //{\n\n //}\n\n //var n = readInt();\n //var m = readInt();\n\n //var a = readIntArray();\n //var b = readIntArray();\n #endregion\n }\n\n static int readInt()\n {\n return int.Parse(Console.ReadLine());\n }\n\n static long readLong()\n {\n return long.Parse(Console.ReadLine());\n }\n\n static int[] readIntArray()\n {\n return Console.ReadLine().Split(' ').Where(i => !string.IsNullOrEmpty(i)).Select(i => int.Parse(i)).ToArray();\n }\n\n static long[] readLongArray()\n {\n return Console.ReadLine().Split(' ').Where(i => !string.IsNullOrEmpty(i)).Select(i => long.Parse(i)).ToArray();\n }\n\n#if DEBUG\n\t\tstatic StreamReader getInput()\n\t\t{\n\t\t\tvar resName = Assembly.GetCallingAssembly().GetManifestResourceNames()[0];\n\t\t\tvar resource = Assembly.GetCallingAssembly().GetManifestResourceStream(resName);\n\n\t\t\treturn new StreamReader(resource);\n\t\t}\n#endif\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "math", "dp", "meet-in-the-middle", "greedy", "number theory"], "code_uid": "0012146f5dce53da004f338eeaf878e0", "src_uid": "a74adcf0314692f8ac95f54d165d9582", "difficulty": 1900.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\n\npublic class Class2\n{\n public static void Main()\n {\n string[] tokens = Console.ReadLine().Split();\n long w = long.Parse(tokens[0]);\n long m = long.Parse(tokens[1]);\n /*\n if (w == 2 || w == 3)\n {\n Console.Write(\"YES\");\n return;\n }\n */\n\n bool ans = solve(w,m);\n if (ans)\n {\n Console.Write(\"YES\");\n }\n else {\n Console.Write(\"NO\");\n }\n \n }\n\n private static bool solve(long w, long m)\n {\n if (m '9');\n res = c - '0';\n while (true)\n {\n c = reader.Read();\n if (c < '0' || c > '9')\n return res;\n res *= 10;\n res += c - '0';\n }\n }\n }\n}", "lang_cluster": "C#", "tags": ["brute force", "math", "dp", "meet-in-the-middle", "greedy", "number theory"], "code_uid": "15a432f958a0cf4a91072dcf5368a0d5", "src_uid": "a74adcf0314692f8ac95f54d165d9582", "difficulty": 1900.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace ConsoleApplication2\n{\n class Program\n {\n static int getNext(int power, int number)\n {\n int result = 1;\n while (result <= number / 2)\n {\n result *= power;\n }\n return result / power;\n }\n static void Main(string[] args)\n {\n string input;\n int w, m;\n input = Console.ReadLine();\n w = Int32.Parse(input.Split(' ')[0]);\n m = Int32.Parse(input.Split(' ')[1]);\n\n while (m > 0)\n {\n int temp = m % w;\n if (temp < 2)\n {\n m = m / w;\n }\n else if (temp == w - 1)\n {\n m = (m + 1) / w;\n }\n else\n {\n break;\n }\n }\n Console.WriteLine(m == 0 ? \"YES\" : \"NO\");\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "math", "dp", "meet-in-the-middle", "greedy", "number theory"], "code_uid": "d8e0f6855e01f3d74ffa14bf50e33c5d", "src_uid": "a74adcf0314692f8ac95f54d165d9582", "difficulty": 1900.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffnamespace topCoder\n{\n\tusing System;\n\tusing System.Collections.Generic;\n\n\tclass p3\n\t{\n\t\tstatic void Main(string[] args)\n\t\t{\n\t\t\t//p1 o = new p1();\n\t\t\t//o.foo();\n\n\t\t\t//p2 o = new p2();\n\t\t\t//o.foo();\n\n\t\t\tp3 o = new p3();\n\t\t\to.foo();\n\t\t}\n\t\tbool[] h = new bool[100];\n\t\tpublic void foo()\n\t\t{\n\t\t\tstring[] sp = Console.ReadLine().Split(' ');\n\t\t\tlong w = long.Parse(sp[0]);\n\t\t\tlong m = long.Parse(sp[1]);\n\n\t\t\tif (bar(m, w))\n\t\t\t\tConsole.WriteLine(\"YES\");\n\t\t\telse\n\t\t\t\tConsole.WriteLine(\"NO\");\n\t\t}\n\t\tprivate bool bar(long m, long w)\n\t\t{\n\t\t\tif (m == 0)\n\t\t\t\treturn true;\n\n\t\t\tlong r;\n\t\t\tlong x = high(m, w);\n\t\t\tif (!h[x])\n\t\t\t{\n\t\t\t\th[x] = true;\n\t\t\t\tr = m - (long)Math.Pow(w, x);\n\t\t\t\tif (r < m && bar(r, w))\n\t\t\t\t\treturn true;\n\t\t\t\th[x] = false; \n\t\t\t}\n\t\t\tif (!h[x+1])\n\t\t\t{\n\t\t\t\th[x+1]=true;\n\t\t\t\tr = (long)Math.Pow(w, x + 1) - m;\n\t\t\t\tif (r < m && bar(r, w))\n\t\t\t\t\treturn true;\n\t\t\t\th[x+1]=false;\n\t\t\t}\n\t\t\treturn false;\n\t\t}\n\t\tprivate long high(long m, long w)\n\t\t{\n\t\t\tint i = 0;\n\t\t\tfor (; i <= 100; i++)\n\t\t\t{\n\t\t\t\tif ((long)Math.Pow(w, i) > m)\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t\treturn i - 1;\n\t\t}\n\t}\n}\n\n", "lang_cluster": "C#", "tags": ["brute force", "math", "dp", "meet-in-the-middle", "greedy", "number theory"], "code_uid": "485fac577fe8c47a537a5548c8e2624b", "src_uid": "a74adcf0314692f8ac95f54d165d9582", "difficulty": 1900.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\n\nnamespace TaskC\n{\n class Program\n {\n static void Main(string[] args)\n {\n string[] s = Console.ReadLine().Split(' ', '\\t');\n int w = Convert.ToInt32(s[0]);\n int m = Convert.ToInt32(s[1]);\n\n Console.WriteLine(Check(w, m) ? \"YES\" : \"NO\");\n }\n\n private static bool Check(int w, int m, bool first = true)\n {\n if (m == 0)\n return true;\n if (m % w == 0)\n return Check(w, m / w);\n return first && (Check(w, m - 1, false) || Check(w, m + 1, false));\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "math", "dp", "meet-in-the-middle", "greedy", "number theory"], "code_uid": "7ca0c4d2772a6daad57437a09b8c5b34", "src_uid": "a74adcf0314692f8ac95f54d165d9582", "difficulty": 1900.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Globalization;\nusing System.IO;\nusing System.Linq;\nusing System.Text;\nusing System.Threading;\n\n// (\u3065\u00b0\u03c9\u00b0)\u3065\uff90\u2605\u309c\u30fb\u3002\u3002\u30fb\u309c\u309c\u30fb\u3002\u3002\u30fb\u309c\u2606\u309c\u30fb\u3002\u3002\u30fb\u309c\u309c\u30fb\u3002\u3002\u30fb\u309c\npublic class Solver\n{\n long lim;\n bool Fun(long d, int n, long s)\n {\n if (s == 0)\n return true;\n if (d <= lim)\n {\n long nd = d * n;\n if (nd < d)\n return false;\n if (Fun(nd, n, s) || Fun(nd, n, s + d) || Fun(nd, n, s - d))\n return true;\n }\n\n return false;\n }\n\n void Solve()\n {\n int n = ReadInt();\n int m = ReadInt();\n lim = 1000000000L * n;\n\n Write(n < 4 || Fun(1, n, m) ? \"YES\" : \"NO\");\n }\n\n #region Main\n\n protected static TextReader reader;\n protected static TextWriter writer;\n static void Main()\n {\n#if DEBUG\n reader = new StreamReader(\"..\\\\..\\\\input.txt\");\n //reader = new StreamReader(Console.OpenStandardInput());\n writer = Console.Out;\n //writer = new StreamWriter(\"..\\\\..\\\\output.txt\");\n#else\n reader = new StreamReader(Console.OpenStandardInput());\n writer = new StreamWriter(Console.OpenStandardOutput());\n //reader = new StreamReader(\"hull.in\");\n //writer = new StreamWriter(\"hull.out\");\n#endif\n try\n {\n // var thread = new Thread(new Solver().Solve, 1024 * 1024 * 128);\n // thread.Start();\n // thread.Join();\n new Solver().Solve();\n }\n catch (Exception ex)\n {\n Console.WriteLine(ex);\n#if DEBUG\n#else\n throw;\n#endif\n }\n reader.Close();\n writer.Close();\n }\n\n #endregion\n\n #region Read / Write\n private static Queue currentLineTokens = new Queue();\n private static string[] ReadAndSplitLine() { return reader.ReadLine().Split(new[] { ' ', '\\t', }, StringSplitOptions.RemoveEmptyEntries); }\n public static string ReadToken() { while (currentLineTokens.Count == 0)currentLineTokens = new Queue(ReadAndSplitLine()); return currentLineTokens.Dequeue(); }\n public static int ReadInt() { return int.Parse(ReadToken()); }\n public static long ReadLong() { return long.Parse(ReadToken()); }\n public static double ReadDouble() { return double.Parse(ReadToken(), CultureInfo.InvariantCulture); }\n public static int[] ReadIntArray() { return ReadAndSplitLine().Select(int.Parse).ToArray(); }\n public static long[] ReadLongArray() { return ReadAndSplitLine().Select(long.Parse).ToArray(); }\n public static double[] ReadDoubleArray() { return ReadAndSplitLine().Select(s => double.Parse(s, CultureInfo.InvariantCulture)).ToArray(); }\n public static int[][] ReadIntMatrix(int numberOfRows) { int[][] matrix = new int[numberOfRows][]; for (int i = 0; i < numberOfRows; i++)matrix[i] = ReadIntArray(); return matrix; }\n public static int[][] ReadAndTransposeIntMatrix(int numberOfRows)\n {\n int[][] matrix = ReadIntMatrix(numberOfRows); int[][] ret = new int[matrix[0].Length][];\n for (int i = 0; i < ret.Length; i++) { ret[i] = new int[numberOfRows]; for (int j = 0; j < numberOfRows; j++)ret[i][j] = matrix[j][i]; } return ret;\n }\n public static string[] ReadLines(int quantity) { string[] lines = new string[quantity]; for (int i = 0; i < quantity; i++)lines[i] = reader.ReadLine().Trim(); return lines; }\n public static void WriteArray(IEnumerable array) { writer.WriteLine(string.Join(\" \", array)); }\n public static void Write(params object[] array) { WriteArray(array); }\n public static void WriteLines(IEnumerable array) { foreach (var a in array)writer.WriteLine(a); }\n private class SDictionary : Dictionary\n {\n public new TValue this[TKey key]\n {\n get { return ContainsKey(key) ? base[key] : default(TValue); }\n set { base[key] = value; }\n }\n }\n private static T[] Init(int size) where T : new() { var ret = new T[size]; for (int i = 0; i < size; i++)ret[i] = new T(); return ret; }\n #endregion\n}", "lang_cluster": "C#", "tags": ["brute force", "math", "dp", "meet-in-the-middle", "greedy", "number theory"], "code_uid": "2223f9c801e49456316649a7dce56165", "src_uid": "a74adcf0314692f8ac95f54d165d9582", "difficulty": 1900.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.IO;\nclass _308_Div2_ProbD {\n\tstatic bool solve(int w, int m) {\n\t\treturn w <= 3 || m == 1 || trysolve(w, m - 1) || trysolve(w, m) || trysolve(w, m + 1);\n\t}\n\n\tstatic bool trysolve(int w, int m) {\n\t\treturn m % w == 0 && solve(w, m / w);\n\t}\n\tstatic void Main() {\n\t\t//Console.SetIn(new StreamReader(File.OpenRead(\"308_Div2_ProbC.txt\")));\n\t\tvar input = Console.ReadLine().Split(new char[] {' '});\n\t\tint w = int.Parse(input[0]);\n\t\tint m = int.Parse(input[1]);\n\n\t\tbool flag = solve(w, m);\n\t\tif (flag)\n\t\t\tConsole.WriteLine(\"YES\");\n\t\telse\n\t\t\tConsole.WriteLine(\"NO\");\n\n\n\t}\n}", "lang_cluster": "C#", "tags": ["brute force", "math", "dp", "meet-in-the-middle", "greedy", "number theory"], "code_uid": "839d7b1f0f1f9a289f4b05da2a2f6ccb", "src_uid": "a74adcf0314692f8ac95f54d165d9582", "difficulty": 1900.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\n\npublic class Class2\n{\n public static void Main()\n {\n string[] tokens = Console.ReadLine().Split();\n long w = long.Parse(tokens[0]);\n long m = long.Parse(tokens[1]);\n \n if (w == 2 || w == 3)\n {\n Console.Write(\"YES\");\n return;\n }\n \n\n bool ans = solve(w,m);\n if (ans)\n {\n Console.Write(\"YES\");\n }\n else {\n Console.Write(\"NO\");\n }\n \n }\n\n private static bool solve(long w, long m)\n {\n if (m result = new Deque();\n\t\t\twhile (a > 0)\n\t\t\t{\n\t\t\t\tresult.AddFirst(a % numberBase);\n\t\t\t\ta /= numberBase;\n\t\t\t}\n\t\t\treturn result.ToArray();\n\t\t}\n\t\tprivate static int solution()\n\t\t{\n\t\t\tint w = cin.ReadInt32();\n\t\t\tint m = cin.ReadInt32();\n\t\t\t\n\t\t\tint [] a = convertBase(m, w);\n\t\t\t\n\t\t\tfor (int i = a.Length - 1; i >= 0; --i)\n\t\t\t{\n\t\t\t\tif ((a[i] == 0) || (a[i] == 1)) continue;\n\t\t\t\ta[i] -= w;\n\t\t\t\tif (i > 0)\n\t\t\t\t\t++a[i - 1];\n\t\t\t\t//else ignore it as the higher digit is one LMAO.\n\t\t\t\tif ((a[i] != -1) && (a[i] != 0))\n\t\t\t\t{\n\t\t\t\t\tcout.Write(\"NO\");\n\t\t\t\t\treturn 0;\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\tcout.Write(\"YES\");\n\t\t\t\n\t\t\treturn 0;\n\t\t}\n\n//===============Prewritten code======================\n\t\tprivate static istream cin = new istream(Console.OpenStandardInput());\n\t\tprivate static ostream cout = new ostream(Console.OpenStandardOutput());\n\t\tprivate static ostream cerr = new ostream(Console.OpenStandardError());\n\t\tprivate static ostream clog = new ostream(Console.OpenStandardError(), true);\n\n\t\tpublic static int Main()\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tint returnValue = solution();\n\t\t\t\tcout.Flush();\n\t\t\t\tcerr.Flush();\n\t\t\t\treturn returnValue;\n\t\t\t}\n\t\t\tcatch (Exception e)\n\t\t\t{\n\t\t\t\tConsole.WriteLine(e.ToString());\n\t\t\t\treturn -1;\n\t\t\t}\n\t\t}\n\t}\n}\n\nnamespace Libraries.IO\n{\n\tpublic class istream : IDisposable\n\t{\n\t\tprivate BufferedStream buffer;\n\t\tprivate StreamReader reader;\n\t\tprivate Queue words = new Queue();\n\t\tprivate void getWords()\n\t\t{\n\t\t\twhile (words.Count == 0)\n\t\t\t{\n\t\t\t\tstring [] temp = reader.ReadLine().Split();\n\t\t\t\tforeach (var str in temp) \n\t\t\t\t{\n\t\t\t\t\tif (str.Length == 0) continue;\n\t\t\t\t\twords.Enqueue(str);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tpublic istream(Stream istr)\n\t\t{\n\t\t\tbuffer = new BufferedStream(istr);\n\t\t\treader = new StreamReader(buffer);\n\t\t}\n\t\tpublic int Peek()\n\t\t{\n\t\t\treturn reader.Peek();\n\t\t}\n\t\tpublic int Read()\n\t\t{\n\t\t\treturn reader.Read();\n\t\t}\n\t\tpublic string ReadLine()\n\t\t{\n\t\t\treturn reader.ReadLine();\n\t\t}\n\t\tpublic int [] ReadInt32Array()\n\t\t{\n\t\t\treturn reader.ReadLine().Split().Select(x => Convert.ToInt32(x)).ToArray();\n\t\t}\n\t\tpublic long [] ReadInt64Array()\n\t\t{\n\t\t\treturn reader.ReadLine().Split().Select(x => Convert.ToInt64(x)).ToArray();\n\t\t}\n\t\tpublic string [] ReadStringArray()\n\t\t{\n\t\t\treturn reader.ReadLine().Split();\n\t\t}\n\t\tpublic int ReadInt32()\n\t\t{\n\t\t\tgetWords();\n\t\t\treturn Convert.ToInt32(words.Dequeue());\n\t\t}\n\t\tpublic long ReadInt64()\n\t\t{\n\t\t\tgetWords();\n\t\t\treturn Convert.ToInt64(words.Dequeue());\n\t\t}\n\t\tpublic string ReadString()\n\t\t{\n\t\t\tgetWords();\n\t\t\treturn words.Dequeue();\n\t\t}\n\t\tpublic void Dispose()\n\t\t{\n\t\t\treader.Dispose();\n\t\t\tbuffer.Dispose();\n\t\t}\n\t}\n\tpublic class ostream : IDisposable\n\t{\n\t\tprivate BufferedStream buffer;\n\t\tprivate StreamWriter writer;\n\t\tpublic ostream(Stream ostr, bool autoflush = false)\n\t\t{\n\t\t\tbuffer = new BufferedStream(ostr);\n\t\t\twriter = new StreamWriter(buffer);\n\t\t\twriter.AutoFlush = autoflush;\n\t\t}\n\t\tpublic void Write(string format, params object[] args)\n\t\t{\n\t\t\twriter.Write(format, args);\n\t\t}\n\t\tpublic void Write(T value)\n\t\t{\n\t\t\twriter.Write(value);\n\t\t}\n\t\tpublic void Write(T [] arr, string sep)\n\t\t{\n\t\t\tstring fmt = \"{0}\" + sep;\n\t\t\tforeach (var x in arr) writer.Write(fmt, x);\n\t\t}\n\t\tpublic void WriteLine(string format, params object[] args)\n\t\t{\n\t\t\twriter.WriteLine(format, args);\n\t\t}\n\t\tpublic void WriteLine(T value)\n\t\t{\n\t\t\twriter.WriteLine(value);\n\t\t}\n\t\tpublic void WriteLine(IEnumerable arr, string sep)\n\t\t{\n\t\t\tstring fmt = \"{0}\" + sep;\n\t\t\tforeach (var x in arr) writer.Write(fmt, x);\n\t\t\twriter.WriteLine();\n\t\t}\n\t\tpublic void WriteLine(IEnumerable arr, string sep, Func funct)\n\t\t{\n\t\t\tstring fmt = \"{0}\" + sep;\n\t\t\tforeach (var x in arr) writer.Write(fmt, funct(x));\n\t\t\twriter.WriteLine();\n\t\t}\n\t\tpublic void WriteLine()\n\t\t{\n\t\t\twriter.WriteLine();\n\t\t}\n\t\tpublic void Flush()\n\t\t{\n\t\t\twriter.Flush();\n\t\t}\n\t\tpublic void Dispose()\n\t\t{\n\t\t\twriter.Dispose();\n\t\t\tbuffer.Dispose();\n\t\t}\n\t}\n}\nnamespace Libraries\n{\t\n\tpublic class Utilities\n\t{\n\t\tpublic static void Swap(ref T x, ref T y)\n\t\t{\n\t\t\tT temp = y;\n\t\t\ty = x;\n\t\t\tx = temp;\n\t\t}\n\t}\n\t\n\tpublic static class Arrays\n\t{\n\t\tprivate static T Inc(ref T value)\n\t\t{\n\t\t\tdynamic temp = value;\n\t\t\tdynamic temp2 = temp;\n\t\t\tvalue = ++temp2;\n\t\t\treturn temp++;\n\t\t}\n\t\tpublic static IEnumerable FillDefault(int size) where T : new()\n\t\t{\n\t\t\tfor (int i = 0; i < size; ++i) yield return new T();\n\t\t}\n\t\tpublic static IEnumerable Fill(int size, T value)\n\t\t{\n\t\t\tfor (int i = 0; i < size; ++i) yield return value;\n\t\t}\n\t\tpublic static IEnumerable Fill(int size, Func funct)\n\t\t{\n\t\t\tfor (int i = 0; i < size; ++i) yield return funct();\n\t\t}\n\t\tpublic static IEnumerable Iota(int size, T init) \n\t\t{\n\t\t\tfor (int i = 0; i < size; ++i) yield return Inc(ref init);\n\t\t}\n\t\tpublic static T First (this IList container)\n\t\t{\n\t\t\tif (container.Count == 0) throw new InvalidOperationException(\"The container is empty\");\n\t\t\treturn container[0];\n\t\t}\n\t\tpublic static T Last (this IList container)\n\t\t{\n\t\t\tif (container.Count == 0) throw new InvalidOperationException(\"The container is empty\");\n\t\t\treturn container[container.Count - 1];\n\t\t}\n\t\tpublic static void RemoveLast (this IList container)\n\t\t{\n\t\t\tif (container.Count == 0) throw new InvalidOperationException(\"The container is empty\");\n\t\t\tcontainer.RemoveAt(container.Count - 1);\n\t\t}\n\t}\n}\n\nnamespace Libraries.Collections\n{\n\tclass PriorityQueue where T : IComparable\n\t{\n\t private List list;\n\t public int Count { get { return list.Count; } }\n\t public readonly bool IsDescending;\n\t\n\t public PriorityQueue(bool isdesc = true)\n\t {\n\t list = new List();\n\t IsDescending = isdesc;\n\t }\n\t\n\t public PriorityQueue(int capacity, bool isdesc = true)\n\t {\n\t list = new List(capacity);\n\t IsDescending = isdesc;\n\t }\n\t\n\t public PriorityQueue(IEnumerable collection, bool isdesc = true)\n\t : this()\n\t {\n\t IsDescending = isdesc;\n\t foreach (var item in collection)\n\t Enqueue(item);\n\t }\n\t\n\t\n\t public void Enqueue(T x)\n\t {\n\t list.Add(x);\n\t int i = Count - 1;\n\t\n\t while (i > 0)\n\t {\n\t int p = (i - 1) / 2;\n\t if ((IsDescending ? -1 : 1) * list[p].CompareTo(x) <= 0) break;\n\t\n\t list[i] = list[p];\n\t i = p;\n\t }\n\t\n\t if (Count > 0) list[i] = x;\n\t }\n\t\n\t public T Dequeue()\n\t {\n\t T target = Peek();\n\t T root = list[Count - 1];\n\t list.RemoveAt(Count - 1);\n\t\n\t int i = 0;\n\t while (i * 2 + 1 < Count)\n\t {\n\t int a = i * 2 + 1;\n\t int b = i * 2 + 2;\n\t int c = b < Count && (IsDescending ? -1 : 1) * list[b].CompareTo(list[a]) < 0 ? b : a;\n\t\n\t if ((IsDescending ? -1 : 1) * list[c].CompareTo(root) >= 0) break;\n\t list[i] = list[c];\n\t i = c;\n\t }\n\t\n\t if (Count > 0) list[i] = root;\n\t return target;\n\t }\n\t\n\t public T Peek()\n\t {\n\t if (Count == 0) throw new InvalidOperationException(\"Queue is empty.\");\n\t return list[0];\n\t }\n\t\n\t public void Clear()\n\t {\n\t list.Clear();\n\t }\n\t}\n internal class DequeUtility\n {\n public static int ClosestPowerOfTwoGreaterThan(int x)\n {\n x--;\n x |= (x >> 1);\n x |= (x >> 2);\n x |= (x >> 4);\n x |= (x >> 8);\n x |= (x >> 16);\n return (x+1);\n }\n\n public static int Count(IEnumerable source)\n {\n if (source == null)\n {\n throw new ArgumentNullException(\"source\");\n }\n\n ICollection genericCollection = source as ICollection;\n if (genericCollection != null)\n {\n return genericCollection.Count;\n }\n\n ICollection nonGenericCollection = source as ICollection;\n if (nonGenericCollection != null)\n {\n return nonGenericCollection.Count;\n }\n\n checked\n {\n int count = 0;\n using (var iterator = source.GetEnumerator())\n {\n while (iterator.MoveNext())\n {\n count++;\n }\n }\n return count;\n }\n }\n }\n\n public class Deque : IList\n {\n private const int defaultCapacity = 16;\n\n private int startOffset;\n\n private T[] buffer;\n\n public Deque() : this(defaultCapacity) { }\n\n public Deque(int capacity)\n {\n if (capacity < 0)\n {\n throw new ArgumentOutOfRangeException(\n \"capacity\", \"capacity is less than 0.\");\n }\n\n this.Capacity = capacity;\n }\n\n public Deque(IEnumerable collection)\n : this(DequeUtility.Count(collection))\n {\n InsertRange(0, collection);\n }\n\n private int capacityClosestPowerOfTwoMinusOne;\n\n public int Capacity\n {\n get\n {\n return buffer.Length;\n }\n\n set\n {\n if (value < 0)\n {\n throw new ArgumentOutOfRangeException(\n \"value\",\n \"Capacity is less than 0.\");\n }\n else if (value < this.Count)\n {\n throw new InvalidOperationException(\n \"Capacity cannot be set to a value less than Count\");\n }\n else if (null != buffer && value == buffer.Length)\n {\n return;\n }\n\n int powOfTwo = DequeUtility.ClosestPowerOfTwoGreaterThan(value);\n\n value = powOfTwo;\n\n T[] newBuffer = new T[value];\n this.CopyTo(newBuffer, 0);\n\n buffer = newBuffer;\n startOffset = 0;\n this.capacityClosestPowerOfTwoMinusOne = powOfTwo - 1;\n }\n }\n\n public bool IsFull\n {\n get { return this.Count == this.Capacity; }\n }\n\n public bool IsEmpty\n {\n get { return 0 == this.Count; }\n }\n\n private void ensureCapacityFor(int numElements)\n {\n if (this.Count + numElements > this.Capacity)\n {\n this.Capacity = this.Count + numElements;\n }\n }\n\n private int toBufferIndex(int index)\n {\n int bufferIndex;\n\n bufferIndex = (index + this.startOffset)\n & this.capacityClosestPowerOfTwoMinusOne;\n\n return bufferIndex;\n }\n\n private void checkIndexOutOfRange(int index)\n {\n if (index >= this.Count)\n {\n throw new IndexOutOfRangeException(\n \"The supplied index is greater than the Count\");\n }\n }\n\n private static void checkArgumentsOutOfRange(\n int length,\n int offset,\n int count)\n {\n if (offset < 0)\n {\n throw new ArgumentOutOfRangeException(\n \"offset\", \"Invalid offset \" + offset);\n }\n\n if (count < 0)\n {\n throw new ArgumentOutOfRangeException(\n \"count\", \"Invalid count \" + count);\n }\n\n if (length - offset < count)\n {\n throw new ArgumentException(\n String.Format(\n \"Invalid offset ({0}) or count + ({1}) \"\n + \"for source length {2}\",\n offset, count, length));\n }\n }\n\n private int shiftStartOffset(int value)\n {\n this.startOffset = toBufferIndex(value);\n\n return this.startOffset;\n }\n\n private int preShiftStartOffset(int value)\n {\n int offset = this.startOffset;\n this.shiftStartOffset(value);\n return offset;\n }\n\n private int postShiftStartOffset(int value)\n {\n return shiftStartOffset(value);\n }\n\n #region IEnumerable\n\n public IEnumerator GetEnumerator()\n {\n if (this.startOffset + this.Count > this.Capacity)\n {\n for (int i = this.startOffset; i < this.Capacity; i++)\n {\n yield return buffer[i];\n }\n\n int endIndex = toBufferIndex(this.Count);\n for (int i = 0; i < endIndex; i++)\n {\n yield return buffer[i];\n }\n }\n else\n {\n int endIndex = this.startOffset + this.Count;\n for (int i = this.startOffset; i < endIndex; i++)\n {\n yield return buffer[i];\n }\n }\n }\n\n IEnumerator IEnumerable.GetEnumerator()\n {\n return this.GetEnumerator();\n }\n #endregion\n\n #region ICollection\n\n bool ICollection.IsReadOnly\n {\n get { return false; }\n }\n\n public int Count\n {\n get;\n private set;\n }\n\n private void incrementCount(int value)\n {\n this.Count = this.Count + value;\n }\n\n private void decrementCount(int value)\n {\n this.Count = Math.Max(this.Count - value, 0);\n }\n\n public void Add(T item)\n {\n AddLast(item);\n }\n\n private void ClearBuffer(int logicalIndex, int length)\n {\n int offset = toBufferIndex(logicalIndex);\n if (offset + length > this.Capacity)\n {\n int len = this.Capacity - offset;\n Array.Clear(this.buffer, offset, len);\n\n len = toBufferIndex(logicalIndex + length);\n Array.Clear(this.buffer, 0, len);\n }\n else\n {\n Array.Clear(this.buffer, offset, length);\n }\n }\n\n public void Clear()\n {\n if (this.Count > 0)\n {\n ClearBuffer(0, this.Count);\n }\n this.Count = 0;\n this.startOffset = 0;\n }\n\n public bool Contains(T item)\n {\n return this.IndexOf(item) != -1;\n }\n\n public void CopyTo(T[] array, int arrayIndex)\n {\n if (null == array)\n {\n throw new ArgumentNullException(\"array\", \"Array is null\");\n }\n\n if (null == this.buffer)\n {\n return;\n }\n\n checkArgumentsOutOfRange(array.Length, arrayIndex, this.Count);\n\n if (0 != this.startOffset\n && this.startOffset + this.Count >= this.Capacity)\n {\n int lengthFromStart = this.Capacity - this.startOffset;\n int lengthFromEnd = this.Count - lengthFromStart;\n\n Array.Copy(\n buffer, this.startOffset, array, 0, lengthFromStart);\n\n Array.Copy(\n buffer, 0, array, lengthFromStart, lengthFromEnd);\n }\n else\n {\n Array.Copy(\n buffer, this.startOffset, array, 0, Count);\n }\n }\n\n public bool Remove(T item)\n {\n bool result = true;\n int index = IndexOf(item);\n\n if (-1 == index)\n {\n result = false;\n }\n else\n {\n RemoveAt(index);\n }\n\n return result;\n }\n\n #endregion\n\n #region List\n\n public T this[int index]\n {\n get\n {\n return this.Get(index);\n }\n\n set\n {\n this.Set(index, value);\n }\n }\n\n public void Insert(int index, T item)\n {\n ensureCapacityFor(1);\n\n if (index == 0)\n {\n AddFirst(item);\n return;\n }\n else if (index == Count)\n {\n AddLast(item);\n return;\n }\n\n InsertRange(index, new[] { item });\n }\n\n public int IndexOf(T item)\n {\n int index = 0;\n foreach (var myItem in this)\n {\n if (myItem.Equals(item))\n {\n break;\n }\n ++index;\n }\n\n if (index == this.Count)\n {\n index = -1;\n }\n\n return index;\n }\n\n public void RemoveAt(int index)\n {\n if (index == 0)\n {\n RemoveFirst();\n return;\n }\n else if (index == Count - 1)\n {\n RemoveLast();\n return;\n }\n\n RemoveRange(index, 1);\n }\n #endregion\n\n public void AddFirst(T item)\n {\n ensureCapacityFor(1);\n buffer[postShiftStartOffset(-1)] = item;\n incrementCount(1);\n }\n\n public void AddLast(T item)\n {\n ensureCapacityFor(1);\n buffer[toBufferIndex(this.Count)] = item;\n incrementCount(1);\n }\n\n public T RemoveFirst()\n {\n if (this.IsEmpty)\n {\n throw new InvalidOperationException(\"The Deque is empty\");\n }\n\n T result = buffer[this.startOffset];\n buffer[preShiftStartOffset(1)] = default(T);\n decrementCount(1);\n return result;\n }\n\n public T RemoveLast()\n {\n if (this.IsEmpty)\n {\n throw new InvalidOperationException(\"The Deque is empty\");\n }\n\n decrementCount(1);\n int endIndex = toBufferIndex(this.Count);\n T result = buffer[endIndex];\n buffer[endIndex] = default(T);\n \n return result;\n }\n\n public void AddRange(IEnumerable collection)\n {\n AddLastRange(collection);\n }\n\n\n public void AddFirstRange(IEnumerable collection)\n {\n AddFirstRange(collection, 0, DequeUtility.Count(collection));\n }\n\n public void AddFirstRange(\n IEnumerable collection,\n int fromIndex,\n int count)\n {\n InsertRange(0, collection, fromIndex, count);\n }\n\n public void AddLastRange(IEnumerable collection)\n {\n AddLastRange(collection, 0, DequeUtility.Count(collection));\n }\n\n public void AddLastRange(\n IEnumerable collection,\n int fromIndex,\n int count)\n {\n InsertRange(this.Count, collection, fromIndex, count);\n }\n\n public void InsertRange(int index, IEnumerable collection)\n {\n int count = DequeUtility.Count(collection);\n this.InsertRange(index, collection, 0, count);\n }\n\n public void InsertRange(\n int index,\n IEnumerable collection,\n int fromIndex,\n int count)\n {\n checkIndexOutOfRange(index - 1);\n\n if (0 == count)\n {\n return;\n }\n\n ensureCapacityFor(count);\n\n if (index < this.Count / 2)\n {\n if (index > 0)\n {\n int copyCount = index;\n int shiftIndex = this.Capacity - count;\n for (int j = 0; j < copyCount; j++)\n {\n buffer[toBufferIndex(shiftIndex + j)] = \n buffer[toBufferIndex(j)];\n }\n }\n\n this.shiftStartOffset(-count);\n\n }\n else\n {\n if (index < this.Count)\n {\n int copyCount = this.Count - index;\n int shiftIndex = index + count;\n for (int j = 0; j < copyCount; j++)\n {\n buffer[toBufferIndex(shiftIndex + j)] = \n buffer[toBufferIndex(index + j)];\n }\n }\n }\n\n int i = index;\n foreach (T item in collection)\n {\n buffer[toBufferIndex(i)] = item;\n ++i;\n }\n\n incrementCount(count);\n }\n\n public void RemoveRange(int index, int count)\n {\n if (this.IsEmpty)\n {\n throw new InvalidOperationException(\"The Deque is empty\");\n }\n if (index > Count - count)\n {\n throw new IndexOutOfRangeException(\n \"The supplied index is greater than the Count\");\n }\n\n ClearBuffer(index, count);\n\n if (index == 0)\n {\n this.shiftStartOffset(count);\n this.Count -= count;\n return;\n }\n else if (index == Count - count)\n {\n this.Count -= count;\n return;\n }\n\n if ((index + (count / 2)) < Count / 2)\n {\n int copyCount = index;\n int writeIndex = count;\n for (int j = 0; j < copyCount; j++)\n {\n buffer[toBufferIndex(writeIndex + j)]\n = buffer[toBufferIndex(j)];\n }\n\n this.shiftStartOffset(count);\n }\n else\n {\n int copyCount = Count - count - index;\n int readIndex = index + count;\n for (int j = 0; j < copyCount; ++j)\n {\n buffer[toBufferIndex(index + j)] =\n buffer[toBufferIndex(readIndex + j)];\n }\n }\n\n decrementCount(count);\n }\n public T Get(int index)\n {\n checkIndexOutOfRange(index);\n return buffer[toBufferIndex(index)];\n }\n\n public void Set(int index, T item)\n {\n checkIndexOutOfRange(index);\n buffer[toBufferIndex(index)] = item;\n }\n\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "math", "dp", "meet-in-the-middle", "greedy", "number theory"], "code_uid": "0030002bac8eee2e603a6ea85c6999fd", "src_uid": "a74adcf0314692f8ac95f54d165d9582", "difficulty": 1900.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Linq;\nusing System.Globalization;\n\nnamespace _630\n{\n class Program\n {\n static void Main()\n {\n var n = long.Parse(Console.ReadLine());\n Console.WriteLine(n * n / 1 * (n-1) * (n-1) / 2 * (n-2) * (n-2) / 3 * (n-3)*(n-3) / 4 * (n-4)*(n-4) / 5);\n }\n }\n}", "lang_cluster": "C#", "tags": ["math", "combinatorics"], "code_uid": "bbd844ffaa64825d51ca8696bf38dcb7", "src_uid": "92db14325cd8aee06b502c12d2e3dd81", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\n\nnamespace ConsoleApplication1\n{\n class Program\n {\n static void Main(string[] args)\n {\n decimal n = Convert.ToUInt64(Console.ReadLine());\n decimal k = n * n * (n - 1) * (n - 1) * (n - 2) * (n - 2) * (n - 3) * (n - 3) * (n - 4) * (n - 4);\n Console.WriteLine(k/5/4/3/2);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "combinatorics"], "code_uid": "4626313084a7e98adf410d57fcef5ed7", "src_uid": "92db14325cd8aee06b502c12d2e3dd81", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\n// you can also use other imports, for example:\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.IO;\n\npublic class HelloWorld\n{\n\n public static void Main(string[] args)\n {\n var n = Convert.ToInt64(Console.ReadLine());\n Console.WriteLine(n / 2520);\n }\n\n}", "lang_cluster": "C#", "tags": ["math", "number theory"], "code_uid": "7ed33406dd316c98c976e281959bd8c3", "src_uid": "8551308e5ff435e0fc507b89a912408a", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace _630J_Divisibility\n{\n class Program\n {\n static void Main(string[] args)\n {\n ulong n = ulong.Parse(Console.ReadLine());\n\n Console.WriteLine(n / 2520);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "number theory"], "code_uid": "b9012819c61466563b10669084dfb901", "src_uid": "8551308e5ff435e0fc507b89a912408a", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace ConsoleApp5\n{\n class Program\n {\n static void Main(string[] args)\n {\n string s = Console.ReadLine();\n int n = int.Parse(s.Split(' ')[0]), m = int.Parse(s.Split(' ')[1]), k = int.Parse(s.Split(' ')[2]);\n if (m >= n && k >= n)\n Console.WriteLine(\"Yes\");\n else\n Console.WriteLine(\"No\");\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "13b0b0d2f7f30d26e0e942bd9dac2c72", "src_uid": "6cd07298b23cc6ce994bb1811b9629c4", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Linq;\n\nnamespace CodeForcesTest\n{\n class Program\n {\n\n static void Main(string[] args)\n {\n int[] n = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();\n\n Console.WriteLine(n[0] > n[1] || n[0] > n[2] ? \"No\" : \"Yes\");\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "344e442f0d4cc4a1df76bd1284c76b45", "src_uid": "6cd07298b23cc6ce994bb1811b9629c4", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text.RegularExpressions;\n\n\nnamespace Rextester\n{\n public class Program\n {\n public static void Main(string[] args)\n {\n string str = Console.ReadLine();\n int a = 0, q = 0, count = 0;\n for (int i = 0; i < str.Length; i++)\n {\n if (str[i] == 'Q')\n {\n for (int j = i + 1; j < str.Length; j++)\n {\n if (str[j] == 'A') a++;\n if (str[j] == 'Q') count += a;\n }\n a = 0;\n q = 0;\n }\n \n }\n Console.Write(count);\n //Console.ReadKey();\n \n \n }\n }\n}", "lang_cluster": "C#", "tags": ["brute force", "dp"], "code_uid": "fbe3388aac8955acfc884d769edeb212", "src_uid": "8aef4947322438664bd8610632fe0947", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\n\nnamespace Codeforces\n{\n\tstatic class Program\n\t{\n\n\t\tstatic void Main()\n\t\t{\n\t\t\tvar s = Console.ReadLine();\n\t\t\tvar pref = new int[s.Length];\n\t\t\tif (s[0] == 'Q') pref[0] = 1;\n\t\t\tfor (int i = 1; i < s.Length; i++)\n\t\t\t{\n\t\t\t\tif (s[i] == 'Q')\n\t\t\t\t\tpref[i] = pref[i - 1] + 1;\n\t\t\t\t\n\t\t\t\telse pref[i] = pref[i - 1];\n\t\t\t}\n\t\t\tint count = 0;\n\t\t\tfor (int i = 0; i < s.Length; i++)\n\t\t\t{\n\t\t\t\tif(s[i] == 'A')\n\t\t\t\t{\n\t\t\t\t\tif (pref[s.Length - 1] - pref[i] == 0) break;\n\t\t\t\t\tcount +=pref[i] * (pref[s.Length - 1] - pref[i]);\n\t\t\t\t}\n\t\t\t}\n\t\t\tConsole.WriteLine(count);\n\t\t\tConsole.ReadLine();\n\t\t}\n\n\t\tprivate static List ReadLongList() => Console.ReadLine().Split().Select(long.Parse).ToList();\n\t\tprivate static List ReadIntList() => Console.ReadLine().Split().Select(int.Parse).ToList();\n\t\tprivate static int[] ReadIntArray() => Console.ReadLine().Split().Select(int.Parse).ToArray();\n\t\tprivate static long[] ReadLongArray() => Console.ReadLine().Split().Select(long.Parse).ToArray();\n\t\tprivate static int ReadInt() => int.Parse(Console.ReadLine());\n\t\tprivate static long ReadLong() => long.Parse(Console.ReadLine());\n\t}\n}", "lang_cluster": "C#", "tags": ["brute force", "dp"], "code_uid": "ff1b48c2b30cf8e1d0a43aee2c580e05", "src_uid": "8aef4947322438664bd8610632fe0947", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.IO;\nusing System.Text;\nusing System.Windows.Forms;\nusing System.Linq;\n\nnamespace Contest {\n class Program {\n static void Main(string[] args) {\n var elem = Console.ReadLine().Split();\n int n = int.Parse(elem[0]), m = int.Parse(elem[1]);\n\n var nums = Console.ReadLine().Split().Select(str => int.Parse(str)).ToArray();\n\n int ans = 1, cur = 0;\n for (int i = 0; i < nums.Length; i++) {\n if (cur + nums[i] <= m) {\n cur += nums[i];\n } else {\n ans++;\n cur = nums[i];\n }\n }\n\n Console.WriteLine(ans);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "4c87ba0ecc046ea23dd9ba2e3c4095ba", "src_uid": "5c73d6e3770dff034d210cdd572ccf0f", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Globalization;\nusing System.IO;\nusing System.Linq;\nusing System.Text;\n\n// (\u3065*\u03c9*)\u3065\uff90\u2605\u309c\u30fb\u3002\u3002\u30fb\u309c\u309c\u30fb\u3002\u3002\u30fb\u309c\u2606\u309c\u30fb\u3002\u3002\u30fb\u309c\u309c\u30fb\u3002\u3002\u30fb\u309c\npublic class Solver\n{\n public object Solve()\n {\n int n = ReadInt();\n int m = ReadInt();\n var a = ReadIntArray();\n int c = 0;\n int ans = 0;\n while (c < n)\n {\n ans++;\n int x = m;\n while (c < n && a[c] <= x)\n {\n x -= a[c];\n c++;\n }\n }\n\n return ans;\n }\n\n #region Main\n\n protected static TextReader reader;\n protected static TextWriter writer;\n\n static void Main()\n {\n#if DEBUG\n reader = new StreamReader(\"..\\\\..\\\\input.txt\");\n writer = Console.Out;\n //writer = new StreamWriter(\"..\\\\..\\\\output.txt\");\n#else\n reader = Console.In;\n writer = new StreamWriter(Console.OpenStandardOutput());\n#endif\n try\n {\n object result = new Solver().Solve();\n if (result != null)\n writer.WriteLine(result);\n }\n catch (Exception ex)\n {\n#if DEBUG\n Console.WriteLine(ex);\n#else\n throw;\n#endif\n }\n reader.Close();\n writer.Close();\n }\n\n #endregion\n\n #region Read/Write\n\n private static Queue currentLineTokens = new Queue();\n\n private static string[] ReadAndSplitLine()\n {\n return reader.ReadLine().Split(new[] { ' ', '\\t' }, StringSplitOptions.RemoveEmptyEntries);\n }\n\n public static string ReadToken()\n {\n while (currentLineTokens.Count == 0)\n currentLineTokens = new Queue(ReadAndSplitLine());\n return currentLineTokens.Dequeue();\n }\n\n public static int ReadInt()\n {\n return int.Parse(ReadToken());\n }\n\n public static long ReadLong()\n {\n return long.Parse(ReadToken());\n }\n\n public static double ReadDouble()\n {\n return double.Parse(ReadToken(), CultureInfo.InvariantCulture);\n }\n\n public static int[] ReadIntArray()\n {\n return ReadAndSplitLine().Select(int.Parse).ToArray();\n }\n\n public static long[] ReadLongArray()\n {\n return ReadAndSplitLine().Select(long.Parse).ToArray();\n }\n\n public static double[] ReadDoubleArray()\n {\n return ReadAndSplitLine().Select(s => double.Parse(s, CultureInfo.InvariantCulture)).ToArray();\n }\n\n public static int[][] ReadIntMatrix(int numberOfRows)\n {\n int[][] matrix = new int[numberOfRows][];\n for (int i = 0; i < numberOfRows; i++)\n matrix[i] = ReadIntArray();\n return matrix;\n }\n\n public static int[][] ReadAndTransposeIntMatrix(int numberOfRows)\n {\n int[][] matrix = ReadIntMatrix(numberOfRows);\n int[][] ret = new int[matrix[0].Length][];\n for (int i = 0; i < ret.Length; i++)\n {\n ret[i] = new int[numberOfRows];\n for (int j = 0; j < numberOfRows; j++)\n ret[i][j] = matrix[j][i];\n }\n return ret;\n }\n\n public static string[] ReadLines(int quantity)\n {\n string[] lines = new string[quantity];\n for (int i = 0; i < quantity; i++)\n lines[i] = reader.ReadLine().Trim();\n return lines;\n }\n\n public static void WriteArray(IEnumerable array)\n {\n writer.WriteLine(string.Join(\" \", array));\n }\n\n #endregion\n}", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "a2ed864ca8b461b56ecac172b47a431b", "src_uid": "5c73d6e3770dff034d210cdd572ccf0f", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.IO;\nusing System.Collections.Generic;\nusing System.Numerics;\n\nnamespace cf495\n{\n class Program\n {\n static void Main(string[] args)\n {\n //Console.SetIn(new StreamReader(\"input.txt\"));\n \n Console.WriteLine(solve_cfindahacks2016A());\n }\n\n public static string solve_cfindahacks2016A()\n {\n int n = Convert.ToInt32(Console.ReadLine());\n int[] t = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);\n\n for (int i = 0; i < n; i++)\n {\n for (int j = i + 1; j < n; j++)\n {\n for (int k = j + 1; k < n; k++)\n {\n if ((t[i] != t[j] && t[j] != t[k] && t[i] != t[k]) && (Math.Abs(t[i] - t[j]) <= 2 && Math.Abs(t[j] - t[k]) <= 2 && Math.Abs(t[i] - t[k]) <= 2))\n {\n return \"YES\";\n }\n }\n }\n }\n\n return \"NO\";\n }\n public static void solve_cf495A()\n {\n int[] nd = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);\n int n = nd[0];\n int d = nd[1];\n int[] x = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);\n\n int cnt = 2;\n\n int prev = x[0];\n\n for (int i = 1; i < n; i++)\n {\n int diff = (prev < 0 && x[i] > 0 || prev > 0 && x[i] < 0) ? Math.Abs(prev) + Math.Abs(x[i]) : Math.Abs(Math.Abs(prev) - Math.Abs(x[i]));\n if (diff >= 2 * d && prev + d != x[i] - d)\n {\n cnt += 2;\n }\n else if (diff - d >= d)\n {\n cnt++;\n }\n prev = x[i];\n }\n\n Console.WriteLine(cnt);\n }\n }\n}\n\n", "lang_cluster": "C#", "tags": ["brute force", "sortings", "implementation"], "code_uid": "aa59f63ea198f5c2e98c3714927283f9", "src_uid": "d6c876a84c7b92141710be5d76536eab", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Diagnostics;\nusing System.IO;\nusing System.Linq;\n\nnamespace Codeforces\n{\n\tinternal class Template\n\t{\n\t\tprivate void Solve()\n\t\t{\n\t\t var n = cin.NextInt();\n\t\t var t = new int[n];\n\t\t for (var i = 0; i < t.Length; i++)\n\t\t {\n\t\t t[i] = cin.NextInt();\n\t\t }\n\t\t for (var i = 0; i < t.Length; i++)\n\t\t {\n\t\t for (var j = i + 1; j < t.Length; j++)\n\t\t {\n\t\t for (var k = j + 1; k < t.Length; k++)\n\t\t {\n\t\t if (t[i] != t[j] && t[i] != t[k] && t[j] != t[k])\n\t\t {\n\t\t if (Math.Abs(t[i] - t[j]) <= 2 && Math.Abs(t[i] - t[k]) <= 2 && Math.Abs(t[j] - t[k]) <= 2)\n\t\t {\n\t\t Console.WriteLine(\"YES\");\n\t\t return;\n\t\t }\n\t\t }\n\t\t }\n\t\t }\n\t\t }\n Console.WriteLine(\"NO\");\n\t\t}\n\n\t\tprivate static readonly Scanner cin = new Scanner();\n\n\t\tprivate static void Main()\n\t\t{\n#if DEBUG\n\t\t\tvar inputText = File.ReadAllText(@\"..\\..\\input.txt\");\n\t\t\tvar testCases = inputText.Split(new[] { \"input\" }, StringSplitOptions.RemoveEmptyEntries);\n\t\t\tvar consoleOut = Console.Out;\n\t\t\tfor (var i = 0; i < testCases.Length; i++)\n\t\t\t{\n\t\t\t\tvar parts = testCases[i].Split(new[] { \"output\" }, StringSplitOptions.RemoveEmptyEntries);\n\t\t\t\tConsole.SetIn(new StringReader(parts[0].Trim()));\n\t\t\t\tvar stringWriter = new StringWriter();\n\t\t\t\tConsole.SetOut(stringWriter);\n\t\t\t\tvar sw = Stopwatch.StartNew();\n\t\t\t\tnew Template().Solve();\n\t\t\t\tsw.Stop();\n\t\t\t\tvar output = stringWriter.ToString();\n\n\t\t\t\tConsole.SetOut(consoleOut);\n\t\t\t\tvar color = ConsoleColor.Green;\n\t\t\t\tvar status = \"Passed\";\n\t\t\t\tif (parts[1].Trim() != output.Trim())\n\t\t\t\t{\n\t\t\t\t\tcolor = ConsoleColor.Red;\n\t\t\t\t\tstatus = \"Failed\";\n\t\t\t\t}\n\t\t\t\tConsole.ForegroundColor = color;\n\t\t\t\tConsole.WriteLine(\"Test {0} {1} in {2}ms\", i + 1, status, sw.ElapsedMilliseconds);\n\t\t\t}\n\t\t\tConsole.ReadLine();\n\t\t\tConsole.ReadKey();\n#else\n\t\t\tnew Template().Solve();\n\t\t\tConsole.ReadLine();\n#endif\n\t\t}\n\t}\n\n\tinternal class Scanner\n\t{\n\t\tprivate string[] s = new string[0];\n\t\tprivate int i;\n\t\tprivate readonly char[] cs = { ' ' };\n\n\t\tpublic string NextString()\n\t\t{\n\t\t\tif (i < s.Length) return s[i++];\n\t\t\tvar line = Console.ReadLine() ?? string.Empty;\n\t\t\ts = line.Split(cs, StringSplitOptions.RemoveEmptyEntries);\n\t\t\ti = 1;\n\t\t\treturn s.First();\n\t\t}\n\n\t\tpublic double NextDouble()\n\t\t{\n\t\t\treturn double.Parse(NextString());\n\t\t}\n\n\t\tpublic int NextInt()\n\t\t{\n\t\t\treturn int.Parse(NextString());\n\t\t}\n\n\t\tpublic long NextLong()\n\t\t{\n\t\t\treturn long.Parse(NextString());\n\t\t}\n\t}\n}", "lang_cluster": "C#", "tags": ["brute force", "sortings", "implementation"], "code_uid": "5a78362a2fdca4543e8a5858bbf76f92", "src_uid": "d6c876a84c7b92141710be5d76536eab", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Globalization;\n\nnamespace CodeForces\n{\n class Program\n {\n static void Main(string[] args)\n {\n DateTime time = DateTime.ParseExact(Console.ReadLine(), \"HH:mm\", CultureInfo.InvariantCulture);\n Console.WriteLine(\"{0:0.#} {1:0.#}\", (time.Hour % 12) * 30d + 30d * (time.Minute / 60d), time.Minute * 6);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "geometry"], "code_uid": "351fbfdf90427a5b8a22eade0a6e52fe", "src_uid": "175dc0bdb5c9513feb49be6644d0d150", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\n\nnamespace CodeForces\n{\n class Depression\n {\n public static void Main(string[] args)\n {\n var line = Console.ReadLine().Split(':');\n double hours = double.Parse(line[0]);\n double mins = double.Parse(line[1]);\n\n while (hours >= 12) { \n hours -= 12; \n }\n\n Console.WriteLine(\"{0} {1}\", (hours + mins / 60) / 12 * 360, (mins / 60) * 360);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "geometry"], "code_uid": "ceb6df187be4d4474499f7e61652583e", "src_uid": "175dc0bdb5c9513feb49be6644d0d150", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\n\nclass Solution\n{\n\tpublic static void Main(String[] args)\n\t{\n\t\tInt32 length = Int32.Parse(Console.ReadLine());\n\t\tString line = Console.ReadLine();\n\n\t\tfor (int i = 1; i < length; i++)\n\t\t{\n\t\t\tif (line[i] != '?' && line[i] == line[i - 1])\n\t\t\t{\n\t\t\t\tConsole.WriteLine(\"No\");\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t\t\n\t\tif(line.Contains(\"?\") == false)\n\t\t{\n\t\t\tConsole.WriteLine(\"No\");\n\t\t\treturn;\n\t\t}\n\t\t\n\t\tif(line[0] == '?' || line[length - 1] == '?')\n\t\t{\n\t\t\tConsole.WriteLine(\"Yes\");\n\t\t\treturn;\n\t\t}\n\t\t\n\t\tfor(int i = 1; i < length - 1; i ++)\n\t\t{\n\t\t\tif(line[i] == '?' && (line[i - 1] == '?' || line[i + 1] == '?' || line[i - 1] == line[i + 1]))\n\t\t\t{\n\t\t\t\tConsole.WriteLine(\"Yes\");\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\n\t\tConsole.WriteLine(\"No\");\n\t\treturn;\n\t}\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "47718beb7862fea62745f6c825f4a476", "src_uid": "f8adfa0dde7ac1363f269dbdf00212c3", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeff\ufeffusing System;\nusing System.Collections;\nusing System.Collections.Generic;\nusing System.Globalization;\nusing System.IO;\nusing System.Linq;\nusing System.Text;\n\nnamespace CF\n{\n internal class Program\n {\n private static void Main(string[] args)\n {\n using (var sr = new InputReader(Console.In))\n//\t\t\tusing (var sr = new InputReader(new StreamReader(\"input.txt\")))\n using (var sw = Console.Out)\n //using (var sw = new StreamWriter(\"output.txt\"))\n using (var task = new Task(sr, sw)) {\n task.Solve();\n// Console.ReadKey();\n }\n }\n }\n\n internal class Task : IDisposable\n {\n private readonly InputReader sr;\n private readonly TextWriter sw;\n private bool isDispose;\n \n public Task(InputReader sr, TextWriter sw)\n {\n this.sr = sr;\n this.sw = sw;\n }\n \n public void Solve()\n {\n var n = sr.NextInt32();\n var str = sr.NextString().ToCharArray();\n for (var i = 1; i < str.Length; i++) {\n if (str[i] != '?' && str[i - 1] != '?') {\n if (str[i - 1] == str[i]) {\n sw.WriteLine(\"No\");\n return;\n }\n }\n }\n for (var i = 0; i < str.Length; i++) {\n if (str[i] == '?') {\n if (i + 1 < str.Length && str[i + 1] == '?') {\n sw.WriteLine(\"Yes\");\n return;\n }\n else {\n if (i + 1 < str.Length) {\n if (i == 0) {\n sw.WriteLine(\"Yes\");\n return;\n }\n\n if (str[i - 1] == str[i + 1]) {\n sw.WriteLine(\"Yes\");\n return;\n }\n }\n else {\n sw.WriteLine(\"Yes\");\n return;\n }\n }\n }\n }\n\n sw.WriteLine(\"No\");\n }\n \n ~Task()\n {\n Dispose(false);\n }\n \n public void Dispose()\n {\n Dispose(true);\n GC.SuppressFinalize(this);\n }\n \n private void Dispose(bool disposing)\n {\n if (!isDispose) {\n if (disposing) {\n if(sr != null)\n sr.Dispose();\n \n if(sw != null)\n sw.Dispose();\n }\n\n isDispose = true;\n }\n }\n }\n}\n\n\ninternal class InputReader : IDisposable\n{\n private bool isDispose;\n private readonly TextReader sr;\n private string[] buffer;\n private int seek;\n\n public InputReader(TextReader stream)\n {\n sr = stream;\n }\n\n public void Dispose()\n {\n Dispose(true);\n GC.SuppressFinalize(this);\n }\n\n public string NextString()\n {\n var result = sr.ReadLine();\n return result;\n }\n\n public int NextInt32()\n {\n return Int32.Parse(ReadNextToken());\n }\n\n private string ReadNextToken()\n {\n if (buffer == null || seek == buffer.Length) {\n seek = 0;\n buffer = NextSplitStrings();\n }\n\n return buffer[seek++];\n }\n\n public long NextInt64()\n {\n return Int64.Parse(ReadNextToken());\n }\n \n public int[] ReadArrayOfInt32()\n {\n return ReadArray(Int32.Parse);\n }\n\n public long[] ReadArrayOfInt64()\n {\n return ReadArray(Int64.Parse);\n }\n\n public string[] NextSplitStrings()\n {\n return NextString()\n .Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);\n }\n\n public T[] ReadArray(Func func)\n {\n return NextSplitStrings()\n .Select(s => func(s, CultureInfo.InvariantCulture))\n .ToArray();\n }\n\n public T[] ReadArrayFromString(Func func, string str)\n {\n return\n str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)\n .Select(s => func(s, CultureInfo.InvariantCulture))\n .ToArray();\n }\n\n protected void Dispose(bool dispose)\n {\n if (!isDispose)\n {\n if (dispose)\n sr.Close();\n \n isDispose = true;\n }\n }\n\n ~InputReader()\n {\n Dispose(false);\n }\n}", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "ae3bbe393baf57e96d891534e1ee8ac7", "src_uid": "f8adfa0dde7ac1363f269dbdf00212c3", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing Solver.Ex;\nusing Debug = System.Diagnostics.Debug;\nusing Watch = System.Diagnostics.Stopwatch;\nusing StringBuilder = System.Text.StringBuilder;\nusing System.Numerics;\nnamespace Solver\n{\n public class Solver\n {\n public void Solve()\n {\n var a = sc.Long();\n var b = sc.Long();\n if (a == b)\n IO.Printer.Out.WriteLine(\"infinity\");\n else if (a < b)\n IO.Printer.Out.WriteLine(0);\n else\n {\n var v = a - b;\n var set = new HashSet();\n for (long i = 1; i * i <= v; i++)\n {\n if (v % i == 0)\n {\n if (i > b) set.Add(i);\n if (v / i > b) set.Add(v / i);\n }\n }\n IO.Printer.Out.WriteLine(set.Count);\n\n }\n }\n\n\n internal IO.StreamScanner sc;\n static T[] Enumerate(int n, Func f) { var a = new T[n]; for (int i = 0; i < n; i++) a[i] = f(i); return a; }\n }\n\n #region Main and Settings\n static class Program\n {\n static void Main(string[] arg)\n {\n#if DEBUG\n var errStream = new System.IO.FileStream(@\"..\\..\\dbg.out\", System.IO.FileMode.Create, System.IO.FileAccess.Write, System.IO.FileShare.ReadWrite);\n Debug.Listeners.Add(new System.Diagnostics.TextWriterTraceListener(errStream, \"debugStream\"));\n Debug.AutoFlush = false;\n var sw = new Watch(); sw.Start();\n IO.Printer.Out.AutoFlush = true;\n try\n {\n#endif\n\n var solver = new Solver();\n solver.sc = new IO.StreamScanner(Console.OpenStandardInput());\n solver.Solve();\n IO.Printer.Out.Flush();\n#if DEBUG\n }\n catch (Exception ex)\n {\n Console.Error.WriteLine(ex.Message);\n Console.Error.WriteLine(ex.StackTrace);\n }\n finally\n {\n sw.Stop();\n Console.ForegroundColor = ConsoleColor.Green;\n Console.Error.WriteLine(\"Time:{0}ms\", sw.ElapsedMilliseconds);\n Debug.Close();\n System.Threading.Thread.Sleep(System.Threading.Timeout.Infinite);\n }\n#endif\n }\n\n\n }\n #endregion\n}\n\n#region IO Helper\nnamespace Solver.IO\n{\n public class Printer : System.IO.StreamWriter\n {\n static Printer()\n {\n Out = new Printer(Console.OpenStandardOutput()) { AutoFlush = false };\n#if DEBUG\n Error = new Printer(Console.OpenStandardError()) { AutoFlush = true };\n#else\n Error = new Printer(System.IO.Stream.Null) { AutoFlush = false };\n#endif\n }\n public static Printer Out { get; set; }\n public static Printer Error { get; set; }\n public override IFormatProvider FormatProvider { get { return System.Globalization.CultureInfo.InvariantCulture; } }\n public Printer(System.IO.Stream stream) : base(stream, new System.Text.UTF8Encoding(false, true)) { }\n public Printer(System.IO.Stream stream, System.Text.Encoding encoding) : base(stream, encoding) { }\n public void Write(string format, IEnumerable source) { base.Write(format, source.OfType().ToArray()); }\n public void WriteLine(string format, IEnumerable source) { base.WriteLine(format, source.OfType().ToArray()); }\n }\n public class StreamScanner\n {\n public StreamScanner(System.IO.Stream stream) { iStream = stream; }\n private readonly System.IO.Stream iStream;\n private readonly byte[] buf = new byte[1024];\n private int len, ptr;\n private bool eof = false;\n public bool IsEndOfStream { get { return eof; } }\n const byte lb = 33, ub = 126, el = 10, cr = 13;\n public byte read()\n {\n if (eof) throw new System.IO.EndOfStreamException();\n if (ptr >= len) { ptr = 0; if ((len = iStream.Read(buf, 0, 1024)) <= 0) { eof = true; return 0; } }\n return buf[ptr++];\n }\n public char Char() { byte b = 0; do b = read(); while (b < lb || ub < b); return (char)b; }\n public char[] Char(int n) { var a = new char[n]; for (int i = 0; i < n; i++) a[i] = Char(); return a; }\n public char[][] Char(int n, int m) { var a = new char[n][]; for (int i = 0; i < n; i++) a[i] = Char(m); return a; }\n public string Scan()\n {\n if (eof) throw new System.IO.EndOfStreamException();\n StringBuilder sb = null;\n var enc = System.Text.UTF8Encoding.Default;\n do\n {\n for (; ptr < len && (buf[ptr] < lb || ub < buf[ptr]); ptr++) ;\n if (ptr < len) break;\n ptr = 0;\n if ((len = iStream.Read(buf, 0, 1024)) <= 0) { eof = true; return \"\"; }\n } while (true);\n do\n {\n var f = ptr;\n for (; ptr < len; ptr++)\n if (buf[ptr] < lb || ub < buf[ptr])\n //if (buf[ptr] == cr || buf[ptr] == el)\n {\n string s;\n if (sb == null) s = enc.GetString(buf, f, ptr - f);\n else { sb.Append(enc.GetChars(buf, f, ptr - f)); s = sb.ToString(); }\n ptr++; return s;\n }\n if (sb == null) sb = new StringBuilder(enc.GetString(buf, f, len - f));\n else sb.Append(enc.GetChars(buf, f, len - f));\n ptr = 0;\n\n }\n while (!eof && (len = iStream.Read(buf, 0, 1024)) > 0);\n eof = true; return (sb != null) ? sb.ToString() : \"\";\n }\n public long Long()\n {\n long ret = 0; byte b = 0; bool isMynus = false;\n const byte zr = 48, nn = 57, my = 45;\n do b = read();\n while (b != my && (b < zr || nn < b));\n if (b == my) { isMynus = true; b = read(); }\n for (; true; b = read())\n if (b < zr || nn < b)\n return isMynus ? -ret : ret;\n else ret = ret * 10 + b - zr;\n }\n public int Integer()\n {\n int ret = 0; byte b = 0; bool isMynus = false;\n const byte zr = 48, nn = 57, my = 45;\n do b = read();\n while (b != my && (b < zr || nn < b));\n if (b == my) { isMynus = true; b = read(); }\n for (; true; b = read())\n if (b < zr || nn < b)\n return isMynus ? -ret : ret;\n else ret = ret * 10 + b - zr;\n }\n public double Double() { return double.Parse(Scan(), System.Globalization.CultureInfo.InvariantCulture); }\n public string[] Scan(int n) { var a = new string[n]; for (int i = 0; i < n; i++) a[i] = Scan(); return a; }\n public double[] Double(int n) { var a = new double[n]; for (int i = 0; i < n; i++) a[i] = Double(); return a; }\n public int[] Integer(int n) { var a = new int[n]; for (int i = 0; i < n; i++) a[i] = Integer(); return a; }\n public long[] Long(int n) { var a = new long[n]; for (int i = 0; i < n; i++)a[i] = Long(); return a; }\n public void Flush() { iStream.Flush(); }\n }\n}\n#endregion\n#region Extension\nnamespace Solver.Ex\n{\n static public partial class EnumerableEx\n {\n static public string AsString(this IEnumerable ie) { return new string(ie.ToArray()); }\n static public string AsJoinedString(this IEnumerable ie, string st = \" \") { return string.Join(st, ie); }\n\n }\n}\n#endregion\n", "lang_cluster": "C#", "tags": ["math", "number theory"], "code_uid": "eafcd2cbdfa50614b2dfe55e8811d974", "src_uid": "6e0715f9239787e085b294139abb2475", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.IO;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace B\n{\n class Program\n {\n static void Main(string[] args)\n {\n //Console.SetIn(File.OpenText(\"in.txt\"));\n var data = Console.ReadLine().Split().Select(d => int.Parse(d)).ToArray();\n var a = data[0];\n var b = data[1];\n r = a - b;\n\n if (a == b)\n {\n Console.WriteLine(\"infinity\");\n return;\n }\n else if (a < b)\n {\n Console.WriteLine(0);\n return;\n }\n else\n {\n var n = (int)Math.Floor(Math.Sqrt(r));\n var counter = 0;\n for (int i = 1; i <= n; i++)\n {\n var rem = r % i;\n if (rem == 0)\n {\n if (i > b)\n {\n counter++;\n }\n \n\n var d = r / i;\n if (d != i && d > b)\n {\n counter++;\n }\n }\n }\n\n Console.WriteLine(counter);\n return;\n }\n\n \n }\n\n static int r;\n static int getT(int del)\n {\n //var r = r1;\n if (r % del == 0)\n {\n int pos = 0;\n while (true)\n {\n var rem = r % del;\n \n if (rem == 0)\n {\n pos++;\n r = r / del;\n }\n else\n {\n break;\n }\n }\n\n return pos;\n }\n else\n {\n return 0;\n }\n }\n\n static int getT(int del, int r2)\n {\n //var r = r1;\n if (r2 % del == 0)\n {\n int pos = 0;\n while (true)\n {\n var rem = r2 % del;\n\n if (rem == 0)\n {\n pos++;\n r2 = r2 / del;\n }\n else\n {\n break;\n }\n }\n\n return pos;\n }\n else\n {\n return 0;\n }\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "number theory"], "code_uid": "e28a8904ed2fe4bda2267bbc3fb4e791", "src_uid": "6e0715f9239787e085b294139abb2475", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Text.RegularExpressions;\n\nnamespace Codeforces\n{\n class B\n {\n private static bool s_time = false;\n\n private static long mod = 1000000007;\n private static long pow(long a, long b)\n {\n long ret = 1;\n for (int i = 0; i < b; i++)\n {\n ret = (ret * a) % mod;\n }\n return ret;\n }\n\n private static object Go()\n {\n int ret = 1;\n\n int n = GetInt();\n int m = GetInt();\n int k = GetInt();\n\n if (n < k || k == 1)\n return pow(m, n);\n if (n == k)\n return pow(m, (n + 1) / 2);\n if (k % 2 == 0)\n return m;\n\n return (m + m * (m - 1)) % mod;\n }\n\n #region Template\n\n public static void Main(string[] args)\n {\n DateTime start = DateTime.Now;\n object output = Go();\n TimeSpan duration = DateTime.Now.Subtract(start);\n if (output != null)\n Wl(output.ToString());\n if (s_time)\n Wl(duration);\n }\n\n private static IEnumerator ioEnum;\n private static string GetString()\n {\n while (ioEnum == null || !ioEnum.MoveNext())\n {\n ioEnum = Console.ReadLine().Split().AsEnumerable().GetEnumerator();\n }\n\n return ioEnum.Current;\n }\n\n private static int GetInt()\n {\n return int.Parse(GetString());\n }\n\n private static long GetLong()\n {\n return long.Parse(GetString());\n }\n\n private static double GetDouble()\n {\n return double.Parse(GetString());\n }\n\n private static void Wl(T o)\n {\n Console.WriteLine(o.ToString());\n }\n\n private static void Wl(IEnumerable enumerable)\n {\n Wl(string.Join(\" \", enumerable.Select(e => e.ToString()).ToArray()));\n }\n\n public struct Tuple : IComparable>\n where T : IComparable\n where K : IComparable\n {\n public T Item1;\n public K Item2;\n\n public Tuple(T t, K k)\n {\n Item1 = t;\n Item2 = k;\n }\n\n public override bool Equals(object obj)\n {\n var o = (Tuple)obj;\n return o.Item1.Equals(Item1) && o.Item2.Equals(Item2);\n }\n\n public override int GetHashCode()\n {\n return Item1.GetHashCode() ^ Item2.GetHashCode();\n }\n\n public override string ToString()\n {\n return \"(\" + Item1 + \" \" + Item2 + \")\";\n }\n\n #region IComparable> Members\n\n public int CompareTo(Tuple other)\n {\n int ret = Item1.CompareTo(other.Item1);\n if (ret != 0) return ret;\n return Item2.CompareTo(other.Item2);\n }\n\n #endregion\n }\n\n #endregion\n }\n}", "lang_cluster": "C#", "tags": ["dfs and similar", "math", "combinatorics", "graphs"], "code_uid": "fe90ba19e0c87f26024f2072ba8b336e", "src_uid": "1f9107e8d1d8aebb1f4a1707a6cdeb6d", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace Codeforces\n{\n class Program\n {\n \n public static readonly int MOD = Convert.ToInt32(1e9 + 7);\n public static readonly int oo = Convert.ToInt32(1e9);\n public static readonly long OO = Convert.ToInt64(1e18);\n\n static void Main(string[] args)\n {\n String[] data = Console.ReadLine().Split(' ');\n int LengthOfWord = int.Parse(data[0]);\n int alphabetSize = int.Parse(data[1]);\n int requiredPalindromLength = int.Parse(data[2]);\n if (requiredPalindromLength > LengthOfWord)\n {\n Console.WriteLine(ModPow(alphabetSize, LengthOfWord));\n return;\n }\n\n Dsu dsu = new Dsu(LengthOfWord + 1);\n if (requiredPalindromLength % 2 == 0)\n {\n \n for (int center = 1; center <= LengthOfWord; center++)\n {\n if (Math.Min(center, LengthOfWord - center) >= requiredPalindromLength / 2)\n {\n for (int count = 0; count < requiredPalindromLength / 2; count++)\n {\n dsu.Unite(center - count, center + count + 1);\n }\n }\n }\n } else\n {\n for (int center = 1; center <= LengthOfWord; center++)\n {\n if (Math.Min(center - 1, LengthOfWord - center) >= requiredPalindromLength / 2)\n {\n dsu.Unite(center, center);\n for (int count = 1; count <= requiredPalindromLength / 2; count++)\n {\n dsu.Unite(center - count, center + count);\n }\n }\n }\n }\n\n long ans = 1;\n for (int vertex = 1; vertex <= LengthOfWord; vertex++)\n {\n if (dsu.Rank[vertex] > 0)\n {\n ans = (ans * alphabetSize) % MOD;\n }\n }\n Console.WriteLine(ans);\n }\n\n static long ModPow(long num, long exponent)\n {\n if (exponent == 0) return 1;\n long m = ModPow(num, exponent / 2);\n return exponent % 2 == 0 ? m * m % MOD : m * m % MOD * num % MOD;\n }\n\n class Dsu\n {\n private int vertices;\n private int connectedComponent;\n private int[] parentOf;\n private int[] rank;\n\n public int Vertices { get; set; }\n public int ConnectedComponent { get; set; }\n public int[] ParentOf { get; set; }\n public int[] Rank { get; set; }\n\n public Dsu(int vertices)\n {\n Vertices = vertices;\n ConnectedComponent = vertices;\n ParentOf = Enumerable.Range(0, vertices).ToArray();\n Rank = Enumerable.Range(0, vertices).Select(v => v = 1).ToArray();\n }\n\n public bool IsConnected(int from, int to)\n {\n return GetAncestor(from) == GetAncestor(to);\n }\n\n public int GetAncestor(int descended)\n {\n while (descended != ParentOf[descended]) descended = ParentOf[descended];\n return descended;\n }\n\n public void Unite(int from, int to)\n {\n int ancestorOfFrom = GetAncestor(from);\n int ancestorOfTo = GetAncestor(to);\n if (ancestorOfFrom == ancestorOfTo) return;\n connectedComponent--;\n if (Rank[ancestorOfFrom] > Rank[ancestorOfTo])\n {\n ParentOf[ancestorOfTo] = ParentOf[ancestorOfFrom];\n Rank[ancestorOfFrom] += Rank[ancestorOfTo];\n Rank[ancestorOfTo] = 0;\n } else\n {\n ParentOf[ancestorOfFrom] = ParentOf[ancestorOfTo];\n Rank[ancestorOfTo] += Rank[ancestorOfFrom];\n Rank[ancestorOfFrom] = 0;\n }\n }\n \n \n }\n\n }\n\n}", "lang_cluster": "C#", "tags": ["dfs and similar", "math", "combinatorics", "graphs"], "code_uid": "1acac7bff3f3e28baba4b0d7d1cca672", "src_uid": "1f9107e8d1d8aebb1f4a1707a6cdeb6d", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.IO;\nusing System.Collections.Generic;\nusing System.Numerics;\n\nnamespace tc2019r2\n{\n class Program\n {\n static void Main(string[] args)\n {\n // Console.SetIn(new StreamReader(\"input.txt\"));\n solve_tc2019r2A();\n }\n\n public static void solve_tc2019r2A()\n {\n int[] whk = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);\n\n int w = whk[0];\n int h = whk[1];\n int k = whk[2];\n\n int i = 0;\n\n int sum = 0;\n\n while (i < k)\n {\n sum += 2 * (w - i * 4 + h - i * 4) - 4;\n i++;\n }\n\n Console.WriteLine(sum);\n }\n }\n}\n\n\n", "lang_cluster": "C#", "tags": ["math", "implementation"], "code_uid": "ee6116b77e150a7815808e7267fc9bb7", "src_uid": "2c98d59917337cb321d76f72a1b3c057", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\n\nnamespace CSharp\n{\n public class _1031A\n {\n public static void Main()\n {\n string[] tokens = Console.ReadLine().Split();\n\n int w = int.Parse(tokens[0]);\n int h = int.Parse(tokens[1]);\n int k = int.Parse(tokens[2]);\n\n Console.WriteLine(2 * k * (h + w + 2 - 4 * k));\n }\n }\n}", "lang_cluster": "C#", "tags": ["math", "implementation"], "code_uid": "b60f45785e1bc30615be2967655d7e73", "src_uid": "2c98d59917337cb321d76f72a1b3c057", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\nusing System.Numerics;\n\n\nclass PairVariable : IComparable\n{\n public int a, b;\n public int c;\n public PairVariable()\n {\n a = b = 0;\n c = 0;\n }\n public PairVariable(string s)\n {\n string[] q = s.Split();\n a = int.Parse(q[0]);\n b = int.Parse(q[1]);\n c = 0;\n\n }\n\n public PairVariable(int a, int b, int c)\n {\n this.a = a;\n this.b = b;\n this.c = c;\n\n }\n\n\n\n public int CompareTo(PairVariable other)\n {\n return this.c.CompareTo(other.c);\n }\n}\n\nnamespace ConsoleApplication3\n{\n class Program\n {\n\n\n static bool isPrime(int n)\n {\n for (int i = 2; i <= Math.Sqrt(n); i++)\n {\n if (n % i == 0)\n {\n return false;\n }\n }\n return true;\n }\n static int gcd(int a, int b)\n {\n if (b == 0)\n {\n return a;\n }\n else\n {\n return gcd(b, a % b);\n }\n }\n \n static int[] mark;\n static Dictionary> d = new Dictionary>();\n static void dfs(int v)\n {\n mark[v] = 1;\n for (int i = 0; i < d[v].Count; i++)\n {\n if (mark[d[v][i]] == 0)\n {\n dfs(d[v][i]);\n }\n }\n }\n static void Main(string[] args)\n {\n long ans = 0;\n string[] ss = Console.ReadLine().Split();\n int m = int.Parse(ss[0]);\n int b = int.Parse(ss[1]);\n for (int y = 0; y <= b; y++)\n {\n int x = -((y - b) * m);\n if (x >= 0)\n {\n //cout< i) { razn2d[i, j] = razn1[j + 1]; }\n else if(i!=j) { razn2d[i, j] = razn1[j]; }\n\n \n }\n }\n for (int i = 0; i < n - 2; i++) { max[i] = 0; }\n for (int i = 0; i < n - 2; i++) {\n for (int j = 0; j < n - 2; j++) {\n if (razn2d[i, j] > max[i]) { max[i] = razn2d[i, j]; }\n \n }\n }\n min = max[0];\n for (int i = 0; i < n - 2; i++) {\n if (max[i] <= min) { min = max[i]; } \n \n }\n\n Console.WriteLine(min); \n \n \n\n \n Console.ReadLine();\n\n }\n }\n}", "lang_cluster": "C#", "tags": ["brute force", "math", "implementation"], "code_uid": "49fcd708fd659dccec865da7bbae9cf8", "src_uid": "8a8013f960814040ac4bf229a0bd5437", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Globalization;\n\nnamespace ConsoleApplication25\n{\n class Program\n {\n static void Main(string[] args)\n {\n var num = int.Parse(Console.ReadLine());\n var init = Console.ReadLine().Split(' ').Select(int.Parse).ToList();\n\n int max = int.MaxValue;\n for (int i = 1; i < init.Count - 1; i++)\n {\n var init1 = init.ToList();\n init1.RemoveAt(i);\n var localMax = 0;\n for (int j = 1 ; j < init1.Count; j++)\n {\n localMax = Math.Max(localMax, init1[j] - init1[j - 1]);\n }\n\n max = Math.Min(max, localMax);\n }\n \n\n Console.WriteLine(max);\n Console.ReadLine();\n }\n \n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "math", "implementation"], "code_uid": "b455f9ed8ae4032dc5ee50745b8f8bfc", "src_uid": "8a8013f960814040ac4bf229a0bd5437", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nnamespace test\n{\n internal class Program\n {\n public static void Main(string[] args)\n {\n int n = Int32.Parse(Console.ReadLine());\n\n int i = Console.ReadLine().IndexOf('0');\n Console.WriteLine(i == -1 ? n: i+1);\n }\n }\n}", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "22b24c39fa8a72dee67f32eb827c8ca1", "src_uid": "54cb2e987f2cc06c02c7638ea879a1ab", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Linq;\n\nclass Program\n{\n static void Main(string[] args)\n {\n Console.ReadLine();\n string s = Console.ReadLine();\n Console.WriteLine(\n s.All(c => c == '1') ? s.Length : s.TakeWhile(c => c == '1').Count() + 1\n );\n Console.ReadLine();\n }\n}", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "cc7f65ab50ad795342dce5747550b1bd", "src_uid": "54cb2e987f2cc06c02c7638ea879a1ab", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\nusing System.Text.RegularExpressions;\n\nnamespace ConsoleApp {\n\n class Program {\n\n static void Main(string[] args) {\n\n string number = Console.ReadLine().Trim();\n int step = -1;\n MinStep(0, 0, number, Fill(new int[number.Length], 1), ref step);\n\n Console.WriteLine(step);\n }\n\n public static bool IsSquare(string number) {\n\n return Math.Pow((int)Math.Sqrt(int.Parse(number)), 2) == int.Parse(number);\n }\n\n public static int[] Fill(int[] array, int value) {\n\n for(int i = 0; i < array.Length; i++) {\n\n array[i] = value;\n }\n\n return array;\n }\n\n public static string GetNumber(string number, int[] usage) {\n\n var result = new StringBuilder();\n\n for(int i = 0; i < usage.Length; i++) {\n\n if(usage[i] == 1) {\n\n result.Append(number[i]);\n }\n }\n\n return result.ToString();\n }\n\n public static void MinStep(int counter, int total, string number, int[] usage, ref int min) {\n\n string newNum = GetNumber(number, usage);\n\n if(newNum != string.Empty && newNum[0] != '0' && IsSquare(GetNumber(number, usage))) {\n\n min = min == -1 ? total : Math.Min(min, total);\n\n return;\n }\n\n if(counter == number.Length) {\n\n return;\n }\n\n int[] newUsage = usage.ToList().ToArray();\n newUsage[counter] = 0;\n MinStep(counter + 1, total + 1, number, newUsage, ref min);\n MinStep(counter + 1, total, number, usage, ref min);\n }\n }\n}", "lang_cluster": "C#", "tags": ["brute force", "math", "implementation"], "code_uid": "6e15119812aa102dc5ab4ddcea9fd557", "src_uid": "fa4b1de79708329bb85437e1413e13df", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.IO;\nusing System.Collections.Generic;\nusing System.Linq;\n\nnamespace CSharpParser\n{\n public class Solution : SolutionBase\n {\n protected override void Solve()\n {\n string s;\n Next(out s);\n var ans = s.Length;\n for (var i = 1; i < 1 << s.Length; i++)\n {\n var cur = \"\";\n for (var j = 0; j < s.Length; j++)\n if ((i >> j & 1) != 0)\n cur += s[j];\n if (cur[0] == '0')\n continue;\n var x = int.Parse(cur);\n var q = (int)Math.Sqrt(x);\n while (q * q < x) ++q;\n while (q * q > x) --q;\n if (q * q == x)\n ans = Math.Min(ans, s.Length - cur.Length);\n }\n PrintLine(ans == s.Length ? -1 : ans);\n }\n }\n\n\tpublic static class Algorithm\n\t{\n\t\tprivate static readonly Random Rnd = new Random();\n\n\t\tpublic static void Swap(ref T a, ref T b)\n\t\t{\n\t\t\tvar temp = a;\n\t\t\ta = b;\n\t\t\tb = temp;\n\t\t}\n\n\t\tpublic static T Max(params T[] a)\n\t\t{\n\t\t\tvar ans = a[0];\n\t\t\tvar comp = Comparer.Default;\n\t\t\tfor (var i = 1; i < a.Length; i++) ans = comp.Compare(ans, a[i]) >= 0 ? ans : a[i];\n\t\t\treturn ans;\n\t\t}\n\n\t\tpublic static T Min(params T[] a)\n\t\t{\n\t\t\tvar ans = a[0];\n\t\t\tvar comp = Comparer.Default;\n\t\t\tfor (var i = 1; i < a.Length; i++) ans = comp.Compare(ans, a[i]) <= 0 ? ans : a[i];\n\t\t\treturn ans;\n\t\t}\n\n\t\tpublic static void RandomShuffle(IList a, int index, int length)\n\t\t{\n\t\t\tif (index < 0 || length < 0) throw new ArgumentOutOfRangeException();\n\t\t\tvar last = index + length;\n\t\t\tif (last > a.Count) throw new ArgumentException();\n\t\t\tfor (var i = index + 1; i < last; i++)\n\t\t\t{\n\t\t\t\tvar j = Rnd.Next(index, i + 1);\n\t\t\t\tvar t = a[i];\n\t\t\t\ta[i] = a[j];\n\t\t\t\ta[j] = t;\n\t\t\t}\n\t\t}\n\n\t\tpublic static void RandomShuffle(IList a)\n\t\t{\n\t\t\tRandomShuffle(a, 0, a.Count);\n\t\t}\n\n\t\tpublic static bool NextPermutation(IList a, int index, int length, Comparison compare = null)\n\t\t{\n\t\t\tcompare = compare ?? Comparer.Default.Compare;\n\t\t\tif (index < 0 || length < 0) throw new ArgumentOutOfRangeException();\n\t\t\tvar last = index + length;\n\t\t\tif (last > a.Count) throw new ArgumentException();\n\t\t\tfor (var i = last - 1; i > index; i--)\n\t\t\t\tif (compare(a[i], a[i - 1]) > 0)\n\t\t\t\t{\n\t\t\t\t\tvar j = i + 1;\n\t\t\t\t\tfor (; j < last; j++) if (compare(a[j], a[i - 1]) <= 0) break;\n\t\t\t\t\tvar t = a[i - 1];\n\t\t\t\t\ta[i - 1] = a[j - 1];\n\t\t\t\t\ta[j - 1] = t;\n\t\t\t\t\tfor (; i < last - 1; i++, last--)\n\t\t\t\t\t{\n\t\t\t\t\t\tt = a[i];\n\t\t\t\t\t\ta[i] = a[last - 1];\n\t\t\t\t\t\ta[last - 1] = t;\n\t\t\t\t\t}\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\tfor (var i = index; i < last - 1; i++, last--)\n\t\t\t{\n\t\t\t\tvar t = a[i];\n\t\t\t\ta[i] = a[last - 1];\n\t\t\t\ta[last - 1] = t;\n\t\t\t}\n\t\t\treturn false;\n\t\t}\n\n\t\tpublic static bool NextPermutation(IList a, Comparison compare = null)\n\t\t{\n\t\t\treturn NextPermutation(a, 0, a.Count, compare);\n\t\t}\n\n\t\tpublic static bool PrevPermutation(IList a, int index, int length, Comparison compare = null)\n\t\t{\n\t\t\tcompare = compare ?? Comparer.Default.Compare;\n\t\t\tif (index < 0 || length < 0) throw new ArgumentOutOfRangeException();\n\t\t\tvar last = index + length;\n\t\t\tif (last > a.Count) throw new ArgumentException();\n\t\t\tfor (var i = last - 1; i > index; i--)\n\t\t\t\tif (compare(a[i], a[i - 1]) < 0)\n\t\t\t\t{\n\t\t\t\t\tvar j = i + 1;\n\t\t\t\t\tfor (; j < last; j++) if (compare(a[j], a[i - 1]) >= 0) break;\n\t\t\t\t\tvar t = a[i - 1];\n\t\t\t\t\ta[i - 1] = a[j - 1];\n\t\t\t\t\ta[j - 1] = t;\n\t\t\t\t\tfor (; i < last - 1; i++, last--)\n\t\t\t\t\t{\n\t\t\t\t\t\tt = a[i];\n\t\t\t\t\t\ta[i] = a[last - 1];\n\t\t\t\t\t\ta[last - 1] = t;\n\t\t\t\t\t}\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\tfor (var i = index; i < last - 1; i++, last--)\n\t\t\t{\n\t\t\t\tvar t = a[i];\n\t\t\t\ta[i] = a[last - 1];\n\t\t\t\ta[last - 1] = t;\n\t\t\t}\n\t\t\treturn false;\n\t\t}\n\n\t\tpublic static bool PrevPermutation(IList a, Comparison compare = null)\n\t\t{\n\t\t\treturn PrevPermutation(a, 0, a.Count, compare);\n\t\t}\n\n\t\tpublic static int LowerBound(IList a, int index, int length, T value, Comparison compare = null)\n\t\t{\n\t\t\tcompare = compare ?? Comparer.Default.Compare;\n\t\t\tif (index < 0 || length < 0) throw new ArgumentOutOfRangeException();\n\t\t\tif (index + length > a.Count) throw new ArgumentException();\n\t\t\tvar ans = index;\n\t\t\tvar last = index + length;\n\t\t\tvar p2 = 1;\n\t\t\twhile (p2 <= length) p2 *= 2;\n\t\t\tfor (p2 /= 2; p2 > 0; p2 /= 2) if (ans + p2 <= last && compare(a[ans + p2 - 1], value) < 0) ans += p2;\n\t\t\treturn ans;\n\t\t}\n\n\t\tpublic static int LowerBound(IList a, T value, Comparison compare = null)\n\t\t{\n\t\t\treturn LowerBound(a, 0, a.Count, value, compare);\n\t\t}\n\n\t\tpublic static int UpperBound(IList a, int index, int length, T value, Comparison compare = null)\n\t\t{\n\t\t\tcompare = compare ?? Comparer.Default.Compare;\n\t\t\tif (index < 0 || length < 0) throw new ArgumentOutOfRangeException();\n\t\t\tif (index + length > a.Count) throw new ArgumentException();\n\t\t\tvar ans = index;\n\t\t\tvar last = index + length;\n\t\t\tvar p2 = 1;\n\t\t\twhile (p2 <= length) p2 *= 2;\n\t\t\tfor (p2 /= 2; p2 > 0; p2 /= 2) if (ans + p2 <= last && compare(a[ans + p2 - 1], value) <= 0) ans += p2;\n\t\t\treturn ans;\n\t\t}\n\n\t\tpublic static int UpperBound(IList a, T value, Comparison compare = null)\n\t\t{\n\t\t\treturn UpperBound(a, 0, a.Count, value, compare);\n\t\t}\n\n\t\tpublic static void Fill(this IList array, T value) where T : struct\n\t\t{\n\t\t\tfor (var i = 0; i < array.Count; i++)\n\t\t\t\tarray[i] = value;\n\t\t}\n\n\t\tpublic static void Fill(this IList array, Func func)\n\t\t{\n\t\t\tfor (var i = 0; i < array.Count; i++)\n\t\t\t\tarray[i] = func(i);\n\t\t}\n\t}\n\n\tpublic class InStream : IDisposable\n\t{\n\t\tprotected readonly TextReader InputStream;\n\t\tprivate string[] _tokens;\n\t\tprivate int _pointer;\n\n\t\tprivate InStream(TextReader inputStream)\n\t\t{\n\t\t\tInputStream = inputStream;\n\t\t}\n\n\t\tpublic static InStream FromString(string str)\n\t\t{\n\t\t\treturn new InStream(new StringReader(str));\n\t\t}\n\n\t\tpublic static InStream FromFile(string str)\n\t\t{\n\t\t\treturn new InStream(new StreamReader(str));\n\t\t}\n\n\t\tpublic static InStream FromConsole()\n\t\t{\n\t\t\treturn new InStream(Console.In);\n\t\t}\n\n\t\tpublic string NextLine()\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\treturn InputStream.ReadLine();\n\t\t\t}\n\t\t\tcatch (Exception)\n\t\t\t{\n\t\t\t\treturn null;\n\t\t\t}\n\t\t}\n\n\t\tprivate string NextString()\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\twhile (_tokens == null || _pointer >= _tokens.Length)\n\t\t\t\t{\n\t\t\t\t\t_tokens = NextLine().Split(new[] { ' ', '\\t' }, StringSplitOptions.RemoveEmptyEntries);\n\t\t\t\t\t_pointer = 0;\n\t\t\t\t}\n\t\t\t\treturn _tokens[_pointer++];\n\t\t\t}\n\t\t\tcatch (Exception)\n\t\t\t{\n\t\t\t\treturn null;\n\t\t\t}\n\t\t}\n\n\t\tpublic bool Next(out T ans)\n\t\t{\n\t\t\tvar str = NextString();\n\t\t\tif (str == null)\n\t\t\t{\n\t\t\t\tans = default(T);\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tans = (T)Convert.ChangeType(str, typeof(T));\n\t\t\treturn true;\n\t\t}\n\n\t\tpublic T[] NextArray(int length)\n\t\t{\n\t\t\tvar array = new T[length];\n\t\t\tfor (var i = 0; i < length; i++)\n\t\t\t\tif (!Next(out array[i]))\n\t\t\t\t\treturn null;\n\t\t\treturn array;\n\t\t}\n\n\t\tpublic T[,] NextArray(int length, int width)\n\t\t{\n\t\t\tvar array = new T[length, width];\n\t\t\tfor (var i = 0; i < length; i++)\n\t\t\t\tfor (var j = 0; j < width; j++)\n\t\t\t\t\tif (!Next(out array[i, j]))\n\t\t\t\t\t\treturn null;\n\t\t\treturn array;\n\t\t}\n\n\t\tpublic void Dispose()\n\t\t{\n\t\t\tInputStream.Close();\n\t\t}\n\t}\n\n\tpublic class OutStream : IDisposable\n\t{\n\t\tprotected readonly TextWriter OutputStream;\n\n\t\tprivate OutStream(TextWriter outputStream)\n\t\t{\n\t\t\tOutputStream = outputStream;\n\t\t}\n\n\t\tpublic static OutStream FromString(System.Text.StringBuilder strB)\n\t\t{\n\t\t\treturn new OutStream(new StringWriter(strB));\n\t\t}\n\n\t\tpublic static OutStream FromFile(string str)\n\t\t{\n\t\t\treturn new OutStream(new StreamWriter(str));\n\t\t}\n\n\t\tpublic static OutStream FromConsole()\n\t\t{\n\t\t\treturn new OutStream(Console.Out);\n\t\t}\n\n\t\tpublic void Print(string format, params object[] args)\n\t\t{\n\t\t\tOutputStream.Write(format, args);\n\t\t}\n\n\t\tpublic void PrintLine(string format, params object[] args)\n\t\t{\n\t\t\tPrint(format, args);\n\t\t\tOutputStream.WriteLine();\n\t\t}\n\n\t\tpublic void PrintLine()\n\t\t{\n\t\t\tOutputStream.WriteLine();\n\t\t}\n\n\t\tpublic void Print(T o)\n\t\t{\n\t\t\tOutputStream.Write(o);\n\t\t}\n\n\t\tpublic void PrintLine(T o)\n\t\t{\n\t\t\tOutputStream.WriteLine(o);\n\t\t}\n\n\t\tpublic void PrintArray(IList a, string between = \" \", string after = \"\\n\", bool printCount = false)\n\t\t{\n\t\t\tif (printCount)\n\t\t\t\tPrintLine(a.Count);\n\t\t\tfor (var i = 0; i < a.Count; i++)\n\t\t\t\tPrint(\"{0}{1}\", a[i], i == a.Count - 1 ? after : between);\n\t\t}\n\n\t\tpublic void Dispose()\n\t\t{\n\t\t\tOutputStream.Close();\n\t\t}\n\t}\n\n\tpublic abstract class SolutionBase : IDisposable\n\t{\n\t\tprivate InStream _in;\n\t\tprivate OutStream _out;\n\n\t\tprotected SolutionBase()\n\t\t{\n\t\t\t//System.Threading.Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.InvariantCulture;\n\t\t\t_in = InStream.FromConsole();\n\t\t\t_out = OutStream.FromConsole();\n\t\t}\n\n\t\tprotected string NextLine()\n\t\t{\n\t\t\treturn _in.NextLine();\n\t\t}\n\n\t\tprotected bool Next(out T ans)\n\t\t{\n\t\t\treturn _in.Next(out ans);\n\t\t}\n\n\t\tprotected T[] NextArray(int length)\n\t\t{\n\t\t\treturn _in.NextArray(length);\n\t\t}\n\n\t\tprotected T[,] NextArray(int length, int width)\n\t\t{\n\t\t\treturn _in.NextArray(length, width);\n\t\t}\n\n\t\tprotected void PrintArray(IList a, string between = \" \", string after = \"\\n\", bool printCount = false)\n\t\t{\n\t\t\t_out.PrintArray(a, between, after, printCount);\n\t\t}\n\n\t\tpublic void Print(string format, params object[] args)\n\t\t{\n\t\t\t_out.Print(format, args);\n\t\t}\n\n\t\tpublic void PrintLine(string format, params object[] args)\n\t\t{\n\t\t\t_out.PrintLine(format, args);\n\t\t}\n\n\t\tpublic void PrintLine()\n\t\t{\n\t\t\t_out.PrintLine();\n\t\t}\n\n\t\tpublic void Print(T o)\n\t\t{\n\t\t\t_out.Print(o);\n\t\t}\n\n\t\tpublic void PrintLine(T o)\n\t\t{\n\t\t\t_out.PrintLine(o);\n\t\t}\n\n\t\tpublic void Dispose()\n\t\t{\n\t\t\t_in.Dispose();\n\t\t\t_out.Dispose();\n\t\t}\n\n\t\tpublic void Freopen(string path, FileAccess access)\n\t\t{\n\t\t\tswitch (access)\n\t\t\t{\n\t\t\t\tcase FileAccess.Read:\n\t\t\t\t\t_in.Dispose();\n\t\t\t\t\t_in = InStream.FromFile(path);\n\t\t\t\t\tbreak;\n\t\t\t\tcase FileAccess.Write:\n\t\t\t\t\t_out.Dispose();\n\t\t\t\t\t_out = OutStream.FromFile(path);\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\tprotected abstract void Solve();\n\n\t\tpublic static void Main()\n\t\t{\n\t\t\tusing (var p = new Solution()) p.Solve();\n\t\t}\n\t}\n}", "lang_cluster": "C#", "tags": ["brute force", "math", "implementation"], "code_uid": "1fc15bf66937731d8e85f331a94dff00", "src_uid": "fa4b1de79708329bb85437e1413e13df", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\n\nnamespace codeforces\n{\n class Program\n {\n static void Main(string[] args)\n {\n int[] input = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();\n int C = input[0];\n int D = input[1];\n int[] nm = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();\n int N = nm[0];\n int M = nm[1];\n int K = int.Parse(Console.ReadLine());\n int[] problems = new int[N * M + N + 1];\n for (int i = 0; i < problems.Length; i++)\n {\n problems[i] = int.MaxValue;\n }\n problems[1] = D;\n problems[N] = C;\n if (N == 1)\n problems[1] = Math.Min(D, C);\n problems[0] = 0;\n for (int i = 2; i < problems.Length; i++)\n {\n if (i - N >= 0)\n {\n problems[i] = Math.Min(problems[i - N] + C, (problems[i - 1] + D));\n }\n else\n {\n problems[i] = problems[i - 1] + D;\n }\n }\n int P = N * M - K;\n int min = int.MaxValue;\n if (P < 0)\n Console.Write(0);\n else\n {\n for (int i = P; i < problems.Length; i++)\n {\n min = Math.Min(min, problems[i]);\n }\n Console.Write(min);\n }\n // Console.ReadKey();\n }\n }\n}", "lang_cluster": "C#", "tags": ["math", "dp", "implementation"], "code_uid": "ab81c2aeaed72bb55d91f8c1711e0ad6", "src_uid": "c6ec932b852e0e8c30c822a226ef7bcb", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\n\nnamespace LongPath\n{\n public class Problem417A\n {\n public static void Main(string[] args)\n {\n var input = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();\n var c = input[0];\n var d = input[1];\n\n input = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();\n var n = input[0];\n var m = input[1];\n\n var k = int.Parse(Console.ReadLine());\n\n var mainpp = c / n;\n\n var count = 0;\n var candidates = n * m - k;\n\n while (candidates > 0)\n {\n if (d * Math.Min(candidates, n) > c)\n {\n count += c;\n candidates -= n;\n }\n else\n {\n count += d * candidates;\n candidates = 0;\n }\n }\n\n Console.WriteLine(count);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "dp", "implementation"], "code_uid": "a129dfb54e7a7eb29ed744b48850599a", "src_uid": "c6ec932b852e0e8c30c822a226ef7bcb", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\n\nnamespace Codeforces2\n{\n class Program\n {\n static void Main(string[] args)\n {\n string s = Console.ReadLine();\n string[] mas = s.Split(' ');\n int init = 2;\n double sum = 0;\n double minsum = 0;\n double maxsum = 0;\n for (int i = 0; i < int.Parse(mas[1]); i++)\n sum += Math.Pow(init, i);\n minsum = sum + int.Parse(mas[0]) - int.Parse(mas[1]);\n if (int.Parse(mas[1]) == int.Parse(mas[2]))\n maxsum = sum + (int.Parse(mas[0]) - int.Parse(mas[1])) * Math.Pow(init, int.Parse(mas[1])-1);\n else\n {\n for(int i=int.Parse(mas[1]);i= y)) ||\n (xy[0] == x2 && (xy[1] <= y2 && xy[1] >= y))||\n (xy[1] == y && (xy[0] <= x2 && xy[0] >= x)) ||\n (xy[1] == y2 && (xy[0] <= x2 && xy[0] >= x))))\n {\n xr = xy[0];\n yr = xy[1];\n if (found)\n {\n found = false;\n break;\n }\n\n found = true;\n }\n }\n\n if (found)\n {\n output.Write(xr + \" \" + yr);\n return;\n }\n }\n }\n }\n }\n }\n \n static void Main(string[] args)\n {\n //SolveC();\n SolveC();\n output.Flush();\n }\n }\n}", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "cad07c788590c64e6c166d5d32654362", "src_uid": "1f9153088dcba9383b1a2dbe592e4d06", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Linq.Expressions;\nusing System.IO;\nusing System.Text;\nusing System.Diagnostics;\n\nusing static util;\nusing P = pair;\n\nusing Binary = System.Func;\nusing Unary = System.Func;\n\nclass Program {\n static StreamWriter sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };\n static Scan sc = new Scan();\n const int M = 1000000007;\n const int M2 = 998244353;\n const long LM = 1L << 60;\n const double eps = 1e-11;\n static void Main(string[] args)\n {\n int n = sc.Int;\n var p = new P[n * 4 + 1];\n var xs = new HashSet();\n var ys = new HashSet();\n for (int i = 0; i < n * 4 + 1; i++)\n {\n p[i] = sc.P;\n xs.Add(p[i].v1);\n ys.Add(p[i].v2);\n }\n foreach (var x1 in xs)\n {\n foreach (var x2 in xs)\n {\n if (x1 >= x2) continue;\n foreach (var y1 in ys)\n {\n foreach (var y2 in ys)\n {\n if (y1 >= y2) continue;\n var lis = new List

();\n for (int i = 0; i < n * 4 + 1; i++)\n {\n if ((p[i].v1 == x1 || p[i].v1 == x2) && y1 <= p[i].v2 && p[i].v2 <= y2 ||\n (p[i].v2 == y1 || p[i].v2 == y2) && x1 <= p[i].v1 && p[i].v1 <= x2) {\n }\n else {\n lis.Add(p[i]);\n }\n }\n if (lis.Count == 1) {\n DBG(lis[0]);\n return;\n }\n }\n }\n }\n }\n\n sw.Flush();\n }\n\n static void DBG(string a) => Console.WriteLine(a);\n static void DBG(IEnumerable a) => DBG(string.Join(\" \", a));\n static void DBG(params object[] a) => DBG(string.Join(\" \", a));\n static void Prt(string a) => sw.WriteLine(a);\n static void Prt(IEnumerable a) => Prt(string.Join(\" \", a));\n static void Prt(params object[] a) => Prt(string.Join(\" \", a));\n}\nclass pair : IComparable> {\n public T v1;\n public U v2;\n public pair() : this(default(T), default(U)) {}\n public pair(T v1, U v2) { this.v1 = v1; this.v2 = v2; }\n public int CompareTo(pair a) {\n int c = Comparer.Default.Compare(v1, a.v1);\n return c != 0 ? c : Comparer.Default.Compare(v2, a.v2);\n }\n public override string ToString() => v1 + \" \" + v2;\n public void Deconstruct(out T a, out U b) { a = v1; b = v2; }\n public static bool operator>(pair a, pair b) => a.CompareTo(b) > 0;\n public static bool operator<(pair a, pair b) => a.CompareTo(b) < 0;\n public static bool operator>=(pair a, pair b) => a.CompareTo(b) >= 0;\n public static bool operator<=(pair a, pair b) => a.CompareTo(b) <= 0;\n}\nstatic class util {\n public static pair make_pair(T v1, U v2) => new pair(v1, v2);\n public static T sq(T a) => Operator.Multiply(a, a);\n public static T Max(params T[] a) => a.Max();\n public static T Min(params T[] a) => a.Min();\n public static bool inside(int i, int j, int h, int w) => i >= 0 && i < h && j >= 0 && j < w;\n static readonly int[] dd = { 0, 1, 0, -1 };\n static readonly string dstring = \"RDLU\";\n public static P[] adjacents(this P p) => adjacents(p.v1, p.v2);\n public static P[] adjacents(this P p, int h, int w) => adjacents(p.v1, p.v2, h, w);\n public static pair[] adjacents_with_str(int i, int j)\n => Enumerable.Range(0, dd.Length).Select(k => new pair(new P(i + dd[k], j + dd[k ^ 1]), dstring[k])).ToArray();\n public static pair[] adjacents_with_str(int i, int j, int h, int w)\n => Enumerable.Range(0, dd.Length).Select(k => new pair(new P(i + dd[k], j + dd[k ^ 1]), dstring[k])).Where(p => inside(p.v1.v1, p.v1.v2, h, w)).ToArray();\n public static P[] adjacents(int i, int j)\n => Enumerable.Range(0, dd.Length).Select(k => new P(i + dd[k], j + dd[k ^ 1])).ToArray();\n public static P[] adjacents(int i, int j, int h, int w)\n => Enumerable.Range(0, dd.Length).Select(k => new P(i + dd[k], j + dd[k ^ 1])).Where(p => inside(p.v1, p.v2, h, w)).ToArray();\n public static void Assert(bool cond) { if (!cond) throw new Exception(); }\n public static Dictionary compress(this IEnumerable a)\n => a.Distinct().OrderBy(v => v).Select((v, i) => new { v, i }).ToDictionary(p => p.v, p => p.i);\n public static Dictionary compress(params IEnumerable[] a) => compress(a.Aggregate(Enumerable.Union));\n public static void swap(ref T a, ref T b) where T : struct { var t = a; a = b; b = t; }\n public static void swap(this IList a, int i, int j) where T : struct { var t = a[i]; a[i] = a[j]; a[j] = t; }\n public static T[] copy(this IList a) {\n var ret = new T[a.Count];\n for (int i = 0; i < a.Count; i++) ret[i] = a[i];\n return ret;\n }\n}\nstatic class Operator {\n static readonly ParameterExpression x = Expression.Parameter(typeof(T), \"x\");\n static readonly ParameterExpression y = Expression.Parameter(typeof(T), \"y\");\n public static readonly Func Add = Lambda(Expression.Add);\n public static readonly Func Subtract = Lambda(Expression.Subtract);\n public static readonly Func Multiply = Lambda(Expression.Multiply);\n public static readonly Func Divide = Lambda(Expression.Divide);\n public static readonly Func Plus = Lambda(Expression.UnaryPlus);\n public static readonly Func Negate = Lambda(Expression.Negate);\n public static Func Lambda(Binary op) => Expression.Lambda>(op(x, y), x, y).Compile();\n public static Func Lambda(Unary op) => Expression.Lambda>(op(x), x).Compile();\n}\n\nclass Scan {\n StreamReader sr;\n public Scan() { sr = new StreamReader(Console.OpenStandardInput()); }\n public Scan(string path) { sr = new StreamReader(path); }\n public int Int => int.Parse(Str);\n public long Long => long.Parse(Str);\n public double Double => double.Parse(Str);\n public string Str => sr.ReadLine().Trim();\n public pair Pair() {\n T a; U b;\n Multi(out a, out b);\n return new pair(a, b);\n }\n public P P => Pair();\n public int[] IntArr => StrArr.Select(int.Parse).ToArray();\n public long[] LongArr => StrArr.Select(long.Parse).ToArray();\n public double[] DoubleArr => StrArr.Select(double.Parse).ToArray();\n public string[] StrArr => Str.Split(new[]{' '}, StringSplitOptions.RemoveEmptyEntries);\n bool eq() => typeof(T).Equals(typeof(U));\n T ct(U a) => (T)Convert.ChangeType(a, typeof(T));\n T cv(string s) => eq() ? ct(int.Parse(s))\n : eq() ? ct(long.Parse(s))\n : eq() ? ct(double.Parse(s))\n : eq() ? ct(s[0])\n : ct(s);\n public void Multi(out T a) => a = cv(Str);\n public void Multi(out T a, out U b)\n { var ar = StrArr; a = cv(ar[0]); b = cv(ar[1]); }\n public void Multi(out T a, out U b, out V c)\n { var ar = StrArr; a = cv(ar[0]); b = cv(ar[1]); c = cv(ar[2]); }\n public void Multi(out T a, out U b, out V c, out W d)\n { var ar = StrArr; a = cv(ar[0]); b = cv(ar[1]); c = cv(ar[2]); d = cv(ar[3]); }\n public void Multi(out T a, out U b, out V c, out W d, out X e)\n { var ar = StrArr; a = cv(ar[0]); b = cv(ar[1]); c = cv(ar[2]); d = cv(ar[3]); e = cv(ar[4]); }\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "565e5ed65d565bb66d4b8e09ee0daf9f", "src_uid": "1f9153088dcba9383b1a2dbe592e4d06", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\n\nnamespace Codeforces\n{\n\tclass Program\n\t{\n\t\tstatic void Main(string[] args)\n\t\t{\n\t\t\tstring input1 = Console.ReadLine();\n\t\t\t//string input2 = Console.ReadLine();\n\n\t\t\t//string input3 = Console.ReadLine();\n\t\t\t//string input4 = Console.ReadLine();\n\n\t\t\t//var inputs1 = input1.Split(new[] { ' ', '}', '{' , ',' }, StringSplitOptions.RemoveEmptyEntries).Select(long.Parse).ToArray();\n\t\t\t//var inputs2 = input2.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(long.Parse).ToList();\n\n\t\t\tlong n = long.Parse(input1);\n\t\t\tdouble temp = Math.Log(n, 2);\n\t\t\tint result = (int)temp + 1;\n\t\t\tConsole.WriteLine(result);\n\t\t}\n\t}\n}\n", "lang_cluster": "C#", "tags": ["math", "greedy", "constructive algorithms"], "code_uid": "2d307edd034d248aac14628d24a1e42a", "src_uid": "95cb79597443461085e62d974d67a9a0", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\n\nclass Program\n{\n \n #region Read Input\n static string[] lines;\n static int lineIndex = 0;\n\n static string ReadNextLine()\n {\n#if DEBUG\n if (lines == null)\n lines = System.IO.File.ReadAllLines(\"input.txt\");\n return lines[lineIndex++];\n#else\n return Console.ReadLine();\n#endif\n }\n #endregion\n\n static void Main(string[] args)\n {\n int n = int.Parse(ReadNextLine());\n\n int mul = 2;\n for(int i = 0; i < 33; i++)\n {\n if (n < mul)\n {\n Console.WriteLine(string.Format(\"{0:d}\", i + 1));\n break;\n }\n mul *= 2;\n }\n \n\n#if DEBUG\n Console.ReadKey();\n#endif\n }\n\n}", "lang_cluster": "C#", "tags": ["math", "greedy", "constructive algorithms"], "code_uid": "3fdaa3142a0d8b5af7f227fe87148386", "src_uid": "95cb79597443461085e62d974d67a9a0", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Globalization;\nusing System.Linq;\nusing System.Text;\nusing System.Text.RegularExpressions;\nusing System.Threading;\n\nnamespace Codeforces\n{\n class C\n {\n private static ThreadStart s_threadStart = new C().Go;\n\n private void Go()\n {\n int N = GetInt();\n List data = GetIntArr(N);\n\n int[,] dp = new int[N, 2];\n dp[N - 1, 0] = data[N - 1];\n dp[N - 1, 1] = 0;\n for (int i = N-2; i >= 0; i--)\n {\n if (dp[i + 1, 0] < data[i] + dp[i + 1, 1])\n {\n dp[i, 0] = data[i] + dp[i + 1, 1];\n dp[i, 1] = dp[i + 1, 0];\n }\n else\n {\n dp[i, 1] = data[i] + dp[i + 1, 1];\n dp[i, 0] = dp[i + 1, 0];\n }\n }\n\n Wl(dp[0, 1] + \" \" + dp[0, 0]);\n }\n\n #region Template\n\n private static StringBuilder output = new StringBuilder();\n\n public static void Main(string[] args)\n {\n System.Diagnostics.Stopwatch timer = new System.Diagnostics.Stopwatch();\n output.Length = 0;\n Thread main = new Thread(new ThreadStart(s_threadStart), 512 * 1024 * 1024);\n timer.Start();\n main.Start();\n main.Join();\n Console.Write(output);\n timer.Stop();\n Console.Error.WriteLine(timer.ElapsedMilliseconds);\n }\n\n private static IEnumerator ioEnum;\n private static string GetString()\n {\n do\n {\n while (ioEnum == null || !ioEnum.MoveNext())\n {\n ioEnum = Console.ReadLine().Split().AsEnumerable().GetEnumerator();\n }\n } while (string.IsNullOrEmpty(ioEnum.Current));\n\n return ioEnum.Current;\n }\n\n\n private static int GetInt()\n {\n return int.Parse(GetString());\n }\n\n private static long GetLong()\n {\n return long.Parse(GetString());\n }\n\n private static double GetDouble()\n {\n return double.Parse(GetString());\n }\n\n private static List GetIntArr(int n)\n {\n List ret = new List(n);\n for (int i = 0; i < n; i++)\n {\n ret.Add(GetInt());\n }\n return ret;\n }\n\n private static void Wl(T o)\n {\n W(o);\n output.Append(Console.Out.NewLine);\n }\n\n private static void Wl(IEnumerable enumerable)\n {\n W(enumerable);\n output.Append(Console.Out.NewLine);\n }\n\n private static void W(T o)\n {\n if (o is double)\n {\n Wd((o as double?).Value, \"\");\n }\n else if (o is float)\n {\n Wd((o as float?).Value, \"\");\n }\n else\n output.Append(o.ToString());\n }\n\n private static void W(IEnumerable enumerable)\n {\n W(string.Join(\" \", enumerable.Select(e => e.ToString()).ToArray()));\n }\n\n private static void Wd(double d, string format)\n {\n W(d.ToString(format, CultureInfo.InvariantCulture));\n }\n\n #endregion\n }\n}", "lang_cluster": "C#", "tags": ["dp", "games"], "code_uid": "77ffca0852b18c2cec1204c4a8a0857d", "src_uid": "414540223db9d4cfcec6a973179a0216", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.IO;\n\nclass Pie{\n DictionarywinSize;\n\n int getSum(int[]arr,int start){\n int sum = 0;\n int len = arr.Length;\n for(int i=start;i();\n int nSlices = slices.Length;\n int totalSz = getSum(slices,0);\n for(int i=nSlices-1;i>=0;i--){\n int sz = getWinSize(slices,i);\n\t winSize[i] = sz;\n }\n int bs = winSize[0];\n int az = totalSz-bs;\n int[]retArr = new int[]{az,bs};\n return retArr;\n }\n static int[]strToIntArr(String s){\n //s = s.Substring(1,s.Length-2);\n\t string[] strArr = s.Split(new char[]{' '});\n\t int len = strArr.Length;\n int[] retArr = new int[len]; \n\t for(int i=0;i\n {\n public int L;\n public int R;\n public int Index;\n public bool Inverted;\n public Pair Next;\n\n public void Invert(int h)\n {\n this.Inverted = !this.Inverted;\n int tmp = L;\n L = h - R;\n R = h - tmp;\n }\n public void Sort(int h)\n {\n if (L <= R && L > h - R)\n {\n this.Invert(h);\n }\n\n if (L > R && L < h - R)\n {\n this.Invert(h);\n }\n }\n\n public int CompareTo(Pair other)\n {\n return (this.R - this.L) * this.L.CompareTo(other.L);\n }\n\n public override string ToString()\n {\n return L + \" \" + R;\n }\n }\n\n static void Main(string[] args)\n {\n int n = ReadInt();\n int m = ReadInt();\n int x = 0;\n for (int i = 2; ; i++)\n {\n if (i % 2 == 0) n--;\n if (i % 3 == 0) m--;\n\n if (i % 6 == 0) x++;\n while (m < 0 && x > 0)\n {\n m++;\n x--;\n }\n while (n < 0 && x > 0)\n {\n n++;\n x--;\n }\n\n if (m <= 0 && n <= 0 && x<=0)\n {\n Console.WriteLine(i);\n return;\n }\n }\n /*\n int h = ReadInt();\n int n = ReadInt();\n\n Pair[] m = new Pair[n];\n Pair[] used = new Pair[h + 1];\n for (int i = 0; i < n; i++)\n {\n m[i] = new Pair()\n {\n L = ReadInt(),\n R = ReadInt(),\n Index = i + 1\n };\n m[i].Sort(h);\n\n if ((m[0].R - m[0].L != m[i].R - m[i].L) ||\n (m[0].R == m[0].L && m[i].L != m[0].L))\n {\n Console.WriteLine(0);\n return;\n }\n\n if (m[0].R != m[0].L)\n {\n if (used[m[i].L] == null)\n {\n used[m[i].L] = m[i];\n }\n else\n {\n m[i].Invert(h);\n if (used[m[i].L].Next != null)\n {\n Console.WriteLine(0);\n return;\n }\n\n used[m[i].L].Next = m[i];\n }\n }\n }\n\n int[] ans = new int[n];\n int start = m[0].L;\n if (m[0].L < m[0].R) start = m.Min(x => x.L);\n if (m[0].L > m[0].R) start = m.Max(x => x.L);\n\n int d = m[0].R - m[0].L;\n int xx = 0;\n while (true)\n {\n Pair c = null;\n if (used[start] != null)\n {\n c = used[start];\n used[start] = used[start].Next;\n }\n else\n {\n int pos = h - start;\n c = used[pos];\n if (c == null)\n {\n break;\n }\n used[pos] = used[pos].Next;\n c.Invert(h);\n }\n\n ans[xx++] = (c.Inverted ? -1 : 1) * c.Index;\n start = c.R;\n }\n\n if (xx != n)\n {\n Console.WriteLine(0);\n return;\n }\n\n Console.WriteLine(string.Join(\" \", ans));*/\n }\n\n\n private static List[] ReadGraph(int n, int m)\n {\n List[] g = new List[n + 1];\n for (int i = 0; i <= n; i++) g[i] = new List();\n for (int i = 0; i < m; i++)\n {\n int a = ReadInt();\n int b = ReadInt();\n g[a].Add(b);\n g[b].Add(a);\n }\n\n return g;\n }\n\n private static int[,] ReadGraphAsMatrix(int n, int m)\n {\n int[,] matrix = new int[n + 1, n + 1];\n for (int i = 0; i < m; i++)\n {\n int a = ReadInt();\n int b = ReadInt();\n matrix[a, b] = matrix[b, a] = 1;\n }\n\n return matrix;\n }\n\n private static void Sort(ref int a, ref int b)\n {\n if (a > b) Swap(ref a, ref b);\n }\n\n private static void Swap(ref int a, ref int b)\n {\n int tmp = a;\n a = b;\n b = tmp;\n }\n\n private const int BufferSize = 1 << 16;\n private static readonly StreamReader consoleReader = new StreamReader(Console.OpenStandardInput(BufferSize), Encoding.ASCII, false, BufferSize);\n\n private static int ReadInt()\n {\n int ans = 0;\n int mul = 1;\n do\n {\n ans = consoleReader.Read();\n if (ans == -1)\n return 0;\n if (ans == '-') mul = -1;\n } while (ans < '0' || ans > '9');\n\n ans -= '0';\n while (true)\n {\n int chr = consoleReader.Read();\n if (chr < '0' || chr > '9')\n return ans * mul;\n ans = ans * 10 + chr - '0';\n }\n }\n\n private static ulong ReadULong()\n {\n ulong ans = 0;\n int chr;\n do\n {\n chr = consoleReader.Read();\n if (chr == -1)\n return 0;\n } while (chr < '0' || chr > '9');\n\n ans = (uint)(chr - '0');\n while (true)\n {\n chr = consoleReader.Read();\n if (chr < '0' || chr > '9')\n return ans;\n ans = ans * 10 + (uint)(chr - '0');\n }\n }\n\n private static long ReadLong()\n {\n long ans = 0;\n int mul = 1;\n do\n {\n ans = consoleReader.Read();\n if (ans == -1)\n return 0;\n if (ans == '-') mul = -1;\n } while (ans < '0' || ans > '9');\n\n ans -= '0';\n while (true)\n {\n int chr = consoleReader.Read();\n if (chr < '0' || chr > '9')\n return ans * mul;\n ans = ans * 10 + chr - '0';\n }\n }\n\n private static int[] ReadIntArray(int n)\n {\n int[] ans = new int[n];\n for (int i = 0; i < n; i++)\n ans[i] = ReadInt();\n return ans;\n }\n\n private static long[] ReadLongArray(int n)\n {\n long[] ans = new long[n];\n for (int i = 0; i < n; i++)\n ans[i] = ReadLong();\n return ans;\n }\n\n private static char[] ReadString()\n {\n int ans;\n\n do\n {\n ans = consoleReader.Read();\n } while (ans < 'a' || ans > 'z');\n\n List s = new List();\n do\n {\n s.Add((char)ans);\n ans = consoleReader.Read();\n } while (ans >= 'a' && ans <= 'z');\n\n return s.ToArray();\n }\n\n private static char[] ReadString(int n)\n {\n int ans;\n\n do\n {\n ans = consoleReader.Read();\n } while (ans < 'a' || ans > 'z');\n\n char[] s = new char[n];\n int pos = 0;\n do\n {\n s[pos++] = (char)ans;\n ans = consoleReader.Read();\n } while (ans >= 'a' && ans <= 'z');\n\n return s;\n }\n\n private static char ReadLetter()\n {\n while (true)\n {\n int ans = consoleReader.Read();\n if ((ans >= 'a' && ans <= 'z') || (ans >= 'A' && ans <= 'Z'))\n return (char)ans;\n }\n }\n\n private static char ReadDigit()\n {\n while (true)\n {\n int ans = consoleReader.Read();\n if (ans >= '0' && ans <= '9')\n return (char)ans;\n }\n }\n\n private static int ReadDigitInt()\n {\n while (true)\n {\n return ReadDigit() - (int)'0';\n }\n }\n\n private static char ReadAnyChar()\n {\n return (char)consoleReader.Read();\n }\n}", "lang_cluster": "C#", "tags": ["math", "greedy", "number theory", "brute force"], "code_uid": "884278af74a0934643e5199e6ef5a8b6", "src_uid": "23f2c8cac07403899199abdcfd947a5a", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeff#if DEBUG\nusing System.Reflection;\nusing System.Threading.Tasks;\n#endif\n\nusing System;\nusing System.Collections.Generic;\nusing System.IO;\nusing System.Linq;\nusing System.Text;\n\n\nnamespace vce3\n{\n class Program\n {\n static string _inputFilename = \"input.txt\";\n static string _outputFilename = \"output.txt\";\n#if DEBUG\n static bool _useFileInput = false;\n#else\n static bool _useFileInput = false;\n#endif\n\n static void Main(string[] args)\n {\n StreamWriter file = null;\n if (_useFileInput)\n {\n Console.SetIn(File.OpenText(_inputFilename));\n file = new StreamWriter(_outputFilename);\n Console.SetOut(file);\n }\n\n#if DEBUG\n\t\t\tif (!_useFileInput)\n\t\t\t{\n\t\t\t\tConsole.SetIn(getInput());\n\t\t\t}\n#endif\n\n try\n {\n solution();\n }\n finally\n {\n if (_useFileInput)\n {\n file.Close();\n }\n }\n }\n\n static void solution()\n {\n #region SOLUTION\n var d = readIntArray();\n var n = d[0];\n var m = d[1];\n var max2 = n * 2;\n var max3 = m * 3;\n\n var need = Math.Min(max2, max3) / 6;\n for (int i = 0; i < need; i++)\n {\n if (max2 == max3)\n {\n max2 += 2;\n }\n else if (max2 > max3)\n {\n max3 += 3;\n //var n3 = max3 + 3;\n if (max3 % 6 == 0 && max2 >= max3)\n {\n need++;\n }\n }\n else\n {\n max2 += 2;\n if (max2 % 6 == 0 && max3 >= max2)\n {\n need++;\n }\n }\n }\n\n var res = Math.Max(max2, max3);\n Console.WriteLine(res);\n\n //var n = readInt();\n //var m = readInt();\n\n //var a = readIntArray();\n //var b = readIntArray();\n #endregion\n }\n\n static int readInt()\n {\n return int.Parse(Console.ReadLine());\n }\n\n static long readLong()\n {\n return long.Parse(Console.ReadLine());\n }\n\n static int[] readIntArray()\n {\n return Console.ReadLine().Split(' ').Where(i => !string.IsNullOrEmpty(i)).Select(i => int.Parse(i)).ToArray();\n }\n\n static long[] readLongArray()\n {\n return Console.ReadLine().Split(' ').Where(i => !string.IsNullOrEmpty(i)).Select(i => long.Parse(i)).ToArray();\n }\n\n#if DEBUG\n\t\tstatic StreamReader getInput()\n\t\t{\n\t\t\tvar resName = Assembly.GetCallingAssembly().GetManifestResourceNames()[0];\n\t\t\tvar resource = Assembly.GetCallingAssembly().GetManifestResourceStream(resName);\n\n\t\t\treturn new StreamReader(resource);\n\t\t}\n#endif\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "greedy", "number theory", "brute force"], "code_uid": "5ed5aa6b03e23ad55410ae52b76e91f3", "src_uid": "23f2c8cac07403899199abdcfd947a5a", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.IO;\n\nnamespace sdsdsdsdsdsConsoleApplication1\n{\n class Program\n {\n static void Main(string[] args)\n {\n long[] abc = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();\n long a = abc[0], b = abc[1], c = abc[2];\n List ans = new List();\n for (int i = 1; i <= 81; i++)\n {\n long e = b * Pow(i, a) + c;\n if (sum(Convert.ToString(e)) == i && e > 0 && e < 1000000000)\n ans.Add((int)e);\n }\n ans.Sort();\n Console.WriteLine(ans.Count);\n if (ans.Count > 0)\n foreach (var x in ans)\n {\n Console.Write(x + \" \");\n }\n }\n public static int sum(string x)\n {\n int s = 0;\n for (int i = 0; i < x.Length; i++)\n {\n s += Convert.ToInt32(x[i])-48;\n }\n return s;\n }\n public static long Pow(long x, long y)\n {\n long a = 1;\n for (int i = 0; i < y; i++)\n a = a*x;\n return a;\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "math", "implementation", "number theory"], "code_uid": "1ca633bfef57de7638b938afc8a1271d", "src_uid": "e477185b94f93006d7ae84c8f0817009", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace ConsoleApplication20\n{\n class Program\n {\n static int S(int x)\n {\n int res = x % 10; ;\n do\n {\n x = x / 10;\n res += x % 10;\n }\n while (x / 10 != 0);\n return res;\n }\n\n static void Main(string[] args)\n {\n int[] inp = Console.ReadLine().Split(new char[1] { ' ' }).Select(int.Parse).ToArray();\n int a = inp[0];\n int b = inp[1];\n int c = inp[2];\n\n int n = 0;\n StringBuilder s = new StringBuilder(1);\n for (int i = 1; i <= 81; i++)\n {\n double x = b * Math.Pow(i, a) + c;\n if (S((int)x) == i && x <= 999999999)\n {\n s.Append(x + \" \");\n n += 1;\n }\n }\n Console.WriteLine(n);\n Console.WriteLine(s);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "math", "implementation", "number theory"], "code_uid": "765e9830212669c0ed40bb4f315967a2", "src_uid": "e477185b94f93006d7ae84c8f0817009", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "/*\n * \u0421\u0434\u0435\u043b\u0430\u043d\u043e \u0432 SharpDevelop.\n * \u041f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c: alexey\n * \u0414\u0430\u0442\u0430: 16.11.2012\n * \u0412\u0440\u0435\u043c\u044f: 19:15\n * \n * \u0414\u043b\u044f \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u044d\u0442\u043e\u0433\u043e \u0448\u0430\u0431\u043b\u043e\u043d\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 \u0421\u0435\u0440\u0432\u0438\u0441 | \u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 | \u041a\u043e\u0434\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 | \u041f\u0440\u0430\u0432\u043a\u0430 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0445 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u043e\u0432.\n */\nusing System.Collections.Generic;\nusing System.Text;\nusing System.Linq;\nusing System.Threading;\nusing System.IO;\nusing System;\n\nnamespace round_159\n{\n\tclass Program\n\t{\n\t\tpublic static int ReadInt(){\n\t\t\t\n\t\t\t\treturn int.Parse(Console.ReadLine());\n\t\t\t\t\t\t\n\t\t\t}\t\t\t\t\t\n\t\t\t\t\n\t\tpublic static string[] ReadStrArr(){\n\t\t\t\n\t\t\t\treturn Console.ReadLine().Split(' ');\n\t\t\t\t\n\t\t\t}\n\t\t\n\t public static int ToInt(Object a){\n\t\t\t\t\n\t\t\treturn int.Parse(a.ToString());\n\t\t\t\t\n\t\t\t}\t\n\t\n\t\tpublic static void print(int[] mas){\n\t\n\t\tfor (int i =0;i 0)\n {\n for (int i = 1; i <= n; i++)\n {\n m -= i;\n\n if (m == 0)\n {\n break;\n }\n else if (m < 0)\n {\n result = m+i;\n break;\n }\n }\n }\n\n Console.WriteLine(result);\n }\n }\n}", "lang_cluster": "C#", "tags": ["math", "implementation"], "code_uid": "dec8951caedfe83f273cb89e301b494c", "src_uid": "5dd5ee90606d37cae5926eb8b8d250bb", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\n\nnamespace CodeForceContest\n{\n class Program\n {\n static void Main(string[] args)\n {\n var input = Console.ReadLine().Split(' ');\n var n = int.Parse(input[0]);\n var m = int.Parse(input[1]);\n var left = m%(n*(n + 1)/2);\n int count = 0;\n for (; ; )\n {\n if (count <= left) left -= count++;\n else break;\n }\n Console.WriteLine(left);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "implementation"], "code_uid": "90f3adf1a2e77b9c2559612b720a2a0a", "src_uid": "5dd5ee90606d37cae5926eb8b8d250bb", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Text;\n\nclass Prog \n{\n public static void Main(String[] args)\n {\n int m1 = 0, m2;\n string s1, s2 = \"\";\n s1 = Console.ReadLine();\n switch (s1)\n {\n case \"January\" : m1 = 1; break;\n case \"February\" : m1 = 2; break;\n case \"March\" : m1 = 3; break;\n case \"April\" : m1 = 4; break;\n case \"May\" : m1 = 5; break;\n case \"June\" : m1 = 6; break;\n case \"July\" : m1 = 7; break;\n case \"August\" : m1 = 8; break;\n case \"September\": m1 = 9; break;\n case \"October\" : m1 = 10; break;\n case \"November\" : m1 = 11; break;\n case \"December\" : m1 = 12; break;\n }\n int i = Convert.ToInt32(Console.ReadLine());\n m2 = m1 + i;\n while (m2 > 12) { m2 -= 12; }\n switch (m2)\n {\n case 1: s2 = \"January\"; break;\n case 2: s2 = \"February\"; break;\n case 3: s2 = \"March\"; break;\n case 4: s2 = \"April\"; break;\n case 5: s2 = \"May\"; break;\n case 6: s2 = \"June\"; break;\n case 7: s2 = \"July\"; break;\n case 8: s2 = \"August\"; break;\n case 9: s2 = \"September\"; break;\n case 10: s2 = \"October\"; break;\n case 11: s2 = \"November\"; break;\n case 12: s2 = \"December\"; break;\n }\n Console.WriteLine(s2);\n }\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "ad775ee7e7722fc3dda1915a3e72760e", "src_uid": "a307b402b20554ce177a73db07170691", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Text;\nusing System.Text.RegularExpressions;\n\nnamespace A.Codecraft_III\n{\n class Program\n {\n static void Main(string[] args)\n {\n string actualMonth = Console.ReadLine();\n int numberMonths = int.Parse(Console.ReadLine());\n List months = new List { \"January\", \"February\", \"March\", \"April\", \"May\", \"June\", \"July\", \"August\", \"September\", \"October\", \"November\", \"December\" };\n int actual = (months.IndexOf(actualMonth) + numberMonths) % 12;\n Console.WriteLine(months[actual]);\n Console.ReadLine();\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "3767fbf4942c3438ab70781c67d8fef5", "src_uid": "a307b402b20554ce177a73db07170691", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\n\nclass TEST{\n\tstatic void Main(){\n\t\tSol mySol =new Sol();\n\t\tmySol.Solve();\n\t}\n}\n\nclass Sol{\n\tpublic void Solve(){\n\t\t\n\t\tvar d = S.Split(':').Select(s => int.Parse(s)).ToArray();\n\t\tint H = d[0], M = d[1];\n\t\tfor(int i=0;i<720;i++){\n\t\t\tvar ss = String.Format(\"{0:D02}:{1:D02}\",H,M);\n\t\t\tif(isPari(ss)){\n\t\t\t\tConsole.WriteLine(i);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tM++;\n\t\t\tif(M == 60){\n\t\t\t\tM = 0;\n\t\t\t\tH++;\n\t\t\t\tif(H == 24) H = 0;\n\t\t\t}\n\t\t}\n\t}\n\t\n\tbool isPari(String s){\n\t\tint N = S.Length;\n\t\tint l = N / 2;\n\t\tint r = N / 2;\n\t\tif(N%2 == 0) l--;\n\t\tfor(;l>=0;l--){\n\t\t\tif(s[l] != s[r]) return false;\n\t\t\tr++;\n\t\t}\n\t\treturn true;\n\t}\t\n\t\n\tString S;\n\tpublic Sol(){\n\t\tS = rs();\n\t}\n\n\tstatic String rs(){return Console.ReadLine();}\n\tstatic int ri(){return int.Parse(Console.ReadLine());}\n\tstatic long rl(){return long.Parse(Console.ReadLine());}\n\tstatic double rd(){return double.Parse(Console.ReadLine());}\n\tstatic String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}\n\tstatic int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}\n\tstatic long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}\n\tstatic double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}\n}\n", "lang_cluster": "C#", "tags": ["brute force", "implementation"], "code_uid": "0189c99bdffa21d1ab233b023ad6fa21", "src_uid": "3ad3b8b700f6f34b3a53fdb63af351a5", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.IO;\nusing System.Linq;\nusing System.Text;\nusing System.Collections;\nusing System.Collections.Generic;\nusing System.Threading.Tasks;\n\nnamespace ConsoleApplication1.CodeForces\n{\n class _4032\n {\n private static int Next()\n {\n int c;\n int res = 0;\n do\n {\n c = reader.Read();\n if (c == -1)\n return res;\n } while (c < '0' || c > '9');\n res = c - '0';\n while (true)\n {\n c = reader.Read();\n if (c < '0' || c > '9')\n return res;\n res *= 10;\n res += c - '0';\n }\n }\n private static readonly StreamReader reader = new StreamReader(Console.OpenStandardInput(1024 * 10), Encoding.ASCII, false, 1024 * 10);\n private static readonly StreamWriter writer = new StreamWriter(Console.OpenStandardOutput(1024 * 10), Encoding.ASCII, 1024 * 10);\n\n class Node : IComparable\n {\n public long X { get; set; }\n public long Y { get; set; }\n public int CompareTo(object obj)\n {\n if (this.Y > ((Node)obj).Y)\n {\n return 1;\n }\n if (this.Y == ((Node)obj).Y)\n {\n return 0;\n }\n return -1;\n }\n }\n\n static bool isBig(long n, long s)\n {\n long sum = 0;\n var st = n.ToString();\n for (var i=0;i< st.Length; i++)\n {\n sum += long.Parse(st[i].ToString());\n }\n return n - sum >= s;\n }\n static void Main(String[] args)\n {\n var data = Console.ReadLine().Split(':').ToList();\n var first = data[0];\n var second = data[1];\n int i = 0;\n while(first[1] != second[0] || first[0] != second[1])\n {\n if(second == \"59\")\n {\n second = \"00\";\n var sb = new StringBuilder();\n var newFirst = int.Parse(first) + 1;\n if(newFirst == 24)\n {\n newFirst = 0;\n }\n if (newFirst < 10)\n {\n sb.Append(\"0\");\n }\n sb.Append(newFirst);\n first = sb.ToString();\n } else\n {\n var newSecond = int.Parse(second) + 1;\n var sb = new StringBuilder();\n if(newSecond < 10)\n {\n sb.Append(\"0\");\n }\n sb.Append(newSecond);\n second = sb.ToString();\n }\n i++;\n }\n\n Console.WriteLine(i);\n\n }\n\n }\n}", "lang_cluster": "C#", "tags": ["brute force", "implementation"], "code_uid": "83bea5d75dc8cea1761b5d8d7a83cddc", "src_uid": "3ad3b8b700f6f34b3a53fdb63af351a5", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.IO;\nusing SB = System.Text.StringBuilder;\n//using System.Threading.Tasks;\n//using System.Text.RegularExpressions;\n//using System.Globalization;\n//using System.Diagnostics;\nusing static System.Console;\nusing System.Numerics;\nusing static System.Math;\nusing pair = Pair;\n\nclass Program\n{\n static void Main()\n {\n //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });\n new Program().solve();\n Out.Flush();\n }\n readonly Scanner cin = new Scanner();\n readonly int[] dd = { 0, 1, 0, -1, 0 }; //\u2192\u2193\u2190\u2191\n readonly int mod = 1000000007;\n readonly int dom = 998244353;\n bool chmax(ref T a, T b) where T : IComparable { if (a.CompareTo(b) < 0) { a = b; return true; } return false; }\n bool chmin(ref T a, T b) where T : IComparable { if (b.CompareTo(a) < 0) { a = b; return true; } return false; }\n\n bool calc(int day, int[] K, List[] L, int Sum)\n {\n int used = 0;\n int money = day;\n for (int i = day - 1; i >= 0; i--)\n { \n if (i < L.Length)\n {\n foreach (var v in L[i])\n {\n int buy = Min(K[v], money);\n money -= buy;\n K[v] -= buy;\n used += buy;\n }\n }\n money = Min(i, money);\n }\n\n\n int remain = Sum - used;\n\n return remain * 2 <= (day - used);\n\n }\n void solve()\n {\n int N = cin.nextint;\n int M = cin.nextint;\n var K = cin.scanint;\n\n var L = new List[200000];\n for (int i = 0; i < L.Length; i++)\n {\n L[i] = new List();\n }\n for (int i = 0; i < M; i++)\n {\n L[cin.nextint - 1].Add(cin.nextint - 1);\n }\n int Sum = K.Sum();\n\n\n int ng = 0;\n int ok = Sum * 2;\n while (ok - ng > 1)\n {\n int mid = (ok + ng) / 2;\n\n var Z = new int[N];\n for (int i = 0; i < Z.Length; i++)\n {\n Z[i] = K[i];\n }\n\n if (calc(mid, Z, L, Sum))\n {\n ok = mid;\n }\n else\n {\n ng = mid;\n }\n }\n\n WriteLine(ok);\n\n }\n\n}\n\n\nstatic class Ex\n{\n public static void join(this IEnumerable values, string sep = \" \") => WriteLine(string.Join(sep, values));\n public static string concat(this IEnumerable values) => string.Concat(values);\n public static string reverse(this string s) { var t = s.ToCharArray(); Array.Reverse(t); return t.concat(); }\n\n public static int lower_bound(this IList arr, T val) where T : IComparable\n {\n int low = 0, high = arr.Count;\n int mid;\n while (low < high)\n {\n mid = ((high - low) >> 1) + low;\n if (arr[mid].CompareTo(val) < 0) low = mid + 1;\n else high = mid;\n }\n return low;\n }\n public static int upper_bound(this IList arr, T val) where T : IComparable\n {\n int low = 0, high = arr.Count;\n int mid;\n while (low < high)\n {\n mid = ((high - low) >> 1) + low;\n if (arr[mid].CompareTo(val) <= 0) low = mid + 1;\n else high = mid;\n }\n return low;\n }\n}\n\nclass Pair : IComparable> where T : IComparable where U : IComparable\n{\n public T f; public U s;\n public Pair(T f, U s) { this.f = f; this.s = s; }\n public int CompareTo(Pair a) => f.CompareTo(a.f) != 0 ? f.CompareTo(a.f) : s.CompareTo(a.s);\n public override string ToString() => $\"{f} {s}\";\n}\n\nclass Scanner\n{\n string[] s; int i;\n readonly char[] cs = new char[] { ' ' };\n public Scanner() { s = new string[0]; i = 0; }\n public string[] scan => ReadLine().Split();\n public int[] scanint => Array.ConvertAll(scan, int.Parse);\n public long[] scanlong => Array.ConvertAll(scan, long.Parse);\n public double[] scandouble => Array.ConvertAll(scan, double.Parse);\n public string next\n {\n get\n {\n if (i < s.Length) return s[i++];\n string st = ReadLine();\n while (st == \"\") st = ReadLine();\n s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);\n i = 0;\n return next;\n }\n }\n public int nextint => int.Parse(next);\n public long nextlong => long.Parse(next);\n public double nextdouble => double.Parse(next);\n}\n", "lang_cluster": "C#", "tags": ["greedy", "binary search"], "code_uid": "3103c355954d3192912c9bf42c121a29", "src_uid": "2eb101dcfcc487fe6e44c9b4c0e4024d", "difficulty": 2000.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Linq;\nusing CompLib.Util;\n\npublic class Program\n{\n int N, M;\n int[] K;\n int[] D, T;\n int[] index;\n public void Solve()\n {\n var sc = new Scanner();\n N = sc.NextInt();\n M = sc.NextInt();\n K = sc.IntArray();\n D = new int[M];\n T = new int[M];\n for (int i = 0; i < M; i++)\n {\n D[i] = sc.NextInt();\n T[i] = sc.NextInt() - 1;\n }\n index = new int[M];\n for (int i = 0; i < M; i++)\n {\n index[i] = i;\n }\n\n Array.Sort(index, (l, r) => D[l].CompareTo(D[r]));\n\n // n\u7a2e\u985e\u3042\u308b\n // \u6bce\u65e51\u7372\u5f97\n // \u901a\u5e382 \u30bb\u30fc\u30eb\u4e2d\u306f1\u652f\u6255\u3048\u3070\u8cb7\u3048\u308b\n // \u7a2e\u985ei\u3092\u4e01\u5ea6k[i]\u500b\u8cb7\u3046\n // \u6bce\u65e50\u500b\u4ee5\u4e0a\u6ce8\u6587\u3067\u304d\u308b\n // \u7a2e\u985et[j]\u306fd[j]\u65e5\u306b\u30bb\u30fc\u30eb\n\n // \n int ng = -1;\n int ok = 400000;\n while (ok - ng > 1)\n {\n int mid = (ok + ng) / 2;\n if (C(mid)) ok = mid;\n else ng = mid;\n }\n\n Console.WriteLine(ok);\n }\n\n // day\u65e5\u306b\u9054\u6210\u3067\u304d\u308b\u304b?\n bool C(int day)\n {\n // \u533a\u9593\u5185\u30bb\u30fc\u30eb\n // \u7a2e\u985e\u3054\u3068\u4e00\u756a\u6700\u5f8c\n // \u524d\u304b\u3089\n\n int[] s = new int[N];\n for (int i = 0; i < N; i++)\n {\n s[i] = int.MaxValue;\n }\n\n for (int i = 0; i < M; i++)\n {\n if (D[index[i]] <= day)\n {\n s[T[index[i]]] = D[index[i]];\n }\n }\n\n var tmp = new int[N];\n for (int i = 0; i < N; i++)\n {\n tmp[i] = i;\n }\n Array.Sort(tmp, (l, r) => s[l].CompareTo(s[r]));\n //if (day == 8)\n //{\n // Console.WriteLine(\"-----\");\n // Console.WriteLine(day);\n // Console.WriteLine(string.Join(\" \", s));\n // Console.WriteLine(string.Join(\" \", tmp));\n //}\n int nokori = 0;\n int m = 0;\n int p = 0;\n for (int i = 0; i < N; i++)\n {\n if (s[tmp[i]] == int.MaxValue)\n {\n nokori += K[tmp[i]];\n }\n else\n {\n // \u8cb7\u3048\u308b\u5206\n // s[i] - m \n \n int tt = Math.Min(K[tmp[i]], s[tmp[i]] - m);\n p += tt;\n m += tt;\n nokori += K[tmp[i]] - tt;\n //if (day == 8)\n //{\n // Console.WriteLine($\"{tmp[i]} {tt} {m}\");\n //}\n }\n }\n //if(day == 8)\n //{\n // Console.WriteLine(\"aaaa\" + m);\n //}\n return nokori * 2 <= day - m;\n }\n\n public static void Main(string[] args) => new Program().Solve();\n}\n\nnamespace CompLib.Util\n{\n using System;\n using System.Linq;\n\n class Scanner\n {\n private string[] _line;\n private int _index;\n private const char Separator = ' ';\n\n public Scanner()\n {\n _line = new string[0];\n _index = 0;\n }\n\n public string Next()\n {\n while (_index >= _line.Length)\n {\n _line = Console.ReadLine().Split(Separator);\n _index = 0;\n }\n\n return _line[_index++];\n }\n\n public int NextInt() => int.Parse(Next());\n public long NextLong() => long.Parse(Next());\n public double NextDouble() => double.Parse(Next());\n public decimal NextDecimal() => decimal.Parse(Next());\n public char NextChar() => Next()[0];\n public char[] NextCharArray() => Next().ToCharArray();\n\n public string[] Array()\n {\n _line = Console.ReadLine().Split(Separator);\n _index = _line.Length;\n return _line;\n }\n\n public int[] IntArray() => Array().Select(int.Parse).ToArray();\n public long[] LongArray() => Array().Select(long.Parse).ToArray();\n public double[] DoubleArray() => Array().Select(double.Parse).ToArray();\n public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();\n }\n}\n", "lang_cluster": "C#", "tags": ["greedy", "binary search"], "code_uid": "b883a132440e0417c0a5e83ff6d19a81", "src_uid": "2eb101dcfcc487fe6e44c9b4c0e4024d", "difficulty": 2000.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\n\nnamespace ConsoleApp1\n{\n class Program\n {\n static void Main(string[] args)\n {\n long n = Convert.ToInt64(Console.ReadLine());long k = n / 2;\n if (n % 2 == 0)\n {\n \n if (k % 2 == 0)\n {\n Console.WriteLine(\"0\");\n }\n else\n {\n Console.WriteLine(\"1\");\n }\n }\n else\n {\n if (k % 2 == 0)\n {\n Console.WriteLine(\"1\");\n }\n else\n {\n Console.WriteLine(\"0\");\n }\n }\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math"], "code_uid": "1d0a718d005ff2459c8515d058ccbe38", "src_uid": "fa163c5b619d3892e33e1fb9c22043a9", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\n\nnamespace CSharp\n{\n class _1102A\n {\n public static void Main()\n {\n long n = long.Parse(Console.ReadLine());\n Console.WriteLine(((n * (n + 1)) / 2) % 2);\n }\n }\n}", "lang_cluster": "C#", "tags": ["math"], "code_uid": "d1396c85cc214bbeddf12b2a651edb8c", "src_uid": "fa163c5b619d3892e33e1fb9c22043a9", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Text;\n\nclass Program\n{\n static void Main(string[] args)\n {\n int size = Convert.ToInt32(Console.ReadLine());\n if (size == 0){Console.WriteLine(1);return;}\n int modulo = 1;\n for (int index = 0; index < size - 1; index++)\n {\n modulo *= 3;\n if (modulo > 1000003)\n {\n modulo %= 1000003; \n }\n }\n Console.WriteLine(modulo);\n }\n\n}\n\n", "lang_cluster": "C#", "tags": ["math"], "code_uid": "ccf2ce38989591d029ee12059697b316", "src_uid": "1a335a9638523ca0315282a67e18eec7", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\n\nclass P { \n static void Main() {\n var n = int.Parse(Console.ReadLine()) - 1;\n var res = 1;\n while (n --> 0) res = (res * 3) % 1000003;\n Console.Write(res);\n }\n}", "lang_cluster": "C#", "tags": ["math"], "code_uid": "3a9d562a8289613f2bcd92a68f700c09", "src_uid": "1a335a9638523ca0315282a67e18eec7", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections;\nusing System.IO;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Numerics;\n\nnamespace Op\n{\n class Program\n { \n public static int Main(string[] args)\n { \n string[] line = Console.ReadLine().Split();\n long a,b,c,t;\n a=long.Parse(line[0]);\n b=long.Parse(line[1]);\n c=long.Parse(line[2]);\n for (long i=0;i<=Math.Min(a,b);i++)\n if (c==a-i+b-i) {Console.WriteLine(\"{0} {1} {2}\", i,b-i,a-i);return 0;} \n Console.WriteLine(\"Impossible\");\n //Console.ReadKey();\n return 0;\n }\n \n }\n }", "lang_cluster": "C#", "tags": ["brute force", "math", "graphs"], "code_uid": "f80d6d67accb14ecbc773cf19e35d1d4", "src_uid": "b3b986fddc3770fed64b878fa42ab1bc", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\n\nnamespace ConsoleApplication234\n{\n class Program\n {\n static void Main(string[] args)\n {\n string[] ok = new string[3]; int a, b, c;\n string read = Console.ReadLine();\n ok = read.Split(' ');\n a = int.Parse(ok[0]);\n b = int.Parse(ok[1]);\n c = int.Parse(ok[2]);\n\n int s = a + b + c;\n if (s%2==1)\n {\n Console.WriteLine(\"Impossible\");\n return;\n }\n s /= 2;\n a = s - a; b = s - b; c = s - c;\n if (a < 0 || b < 0 || c < 0) Console.WriteLine(\"Impossible\");\n else Console.WriteLine(c + \" \" + a + \" \" + b);\n //Console.ReadKey();\n }\n }\n}", "lang_cluster": "C#", "tags": ["brute force", "math", "graphs"], "code_uid": "507697536e31cb6f25b73aec3fb82fee", "src_uid": "b3b986fddc3770fed64b878fa42ab1bc", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Text;\nusing System.Linq;\nusing System.Collections.Generic;\n\nnamespace test\n{\n\tclass MainClass\n\t{\n\t\tpublic static void Main (string[] args)\n\t\t{\n\t\t\tvar n = Int32.Parse (Console.ReadLine ());\n\n\t\t\tvar tList = Console.ReadLine ().Split (' ').Select (x => Int32.Parse (x)).OrderBy(x => x).ToList();\n\n\t\t\tvar T = Int32.Parse (Console.ReadLine ());\n\n\t\t\tvar maxLen = 1;\n\t\t\tvar currentLen = 1;\n\n\t\t\tfor (var i = 0; i < n - 1; i++) {\n\t\t\t\tcurrentLen = 1;\n\n\t\t\t\tfor (var j = i + 1; j < n; j++) {\n\t\t\t\t\tif (tList [j] - tList [i] > T) {\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\n\t\t\t\t\tcurrentLen++;\n\t\t\t\t}\n\n\t\t\t\tif (currentLen > maxLen) {\n\t\t\t\t\tmaxLen = currentLen;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tConsole.WriteLine (maxLen);\n\n\t\t}\n\t}\n}\n", "lang_cluster": "C#", "tags": ["brute force", "implementation", "binary search"], "code_uid": "2ad38c10fef181080ee4a47684d7bd7c", "src_uid": "086d07bd6f9031df09bd6a6e8fe8f25c", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace codeforces386\n{\n class Program\n {\n static void Main(string[] args)\n {\n int n = Convert.ToInt32(Console.ReadLine());\n string[] inx = Console.ReadLine().Split(' ');\n int[] data = new int[n];\n for (int i = 0; i < n; i++)\n {\n data[i] = Convert.ToInt32(inx[i]);\n }\n int t = Convert.ToInt32(Console.ReadLine());\n if (n == 1)\n {\n Console.WriteLine(1);\n return;\n }\n Array.Sort(data);\n int a, b, max, curr;\n a = 0; b = 0;\n max = 0;\n curr = 0;\n while (b < n)\n {\n while (b < n && Math.Abs(data[a] - data[b]) <= t)\n {\n b++;\n curr++;\n if (curr > max) max = curr;\n }\n if (b == n) break;\n while (Math.Abs(data[a] - data[b]) > t)\n {\n a++;\n curr--;\n }\n }\n Console.WriteLine(max);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "implementation", "binary search"], "code_uid": "f124f019c734dbafa2b27d1f120a8525", "src_uid": "086d07bd6f9031df09bd6a6e8fe8f25c", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace ConsoleApp15\n{\n class Program\n {\n\n \n\n static bool ok(int k, int n, int[] a)\n {\n int cant = 0;\n int m = a.Length;\n for (int i = 0; i < m; i++)\n cant += a[i] / k;\n return cant >= n;\n }\n\n static void Main(string[] args)\n {\n string[] line = Console.ReadLine().Split(' ');\n int n = int.Parse(line[0]);\n int m = int.Parse(line[1]);\n line = Console.ReadLine().Split(' ');\n int[] a = new int[m];\n for (int i = 0; i < m; i++)\n a[i] = int.Parse(line[i]);\n int[] b = new int[105];\n for (int i = 0; i < m; i++)\n b[a[i]]++;\n\n int ans = 0;\n int lo = 1;\n int hi = m;\n while(lo <= hi)\n {\n int mid = (lo + hi) >> 1;\n if(ok(mid, n, b))\n {\n ans = mid;\n lo = mid + 1;\n }\n else\n {\n hi = mid - 1;\n }\n }\n\n Console.WriteLine(ans);\n \n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "implementation", "binary search"], "code_uid": "e65d5bd8ac5ae4f00a42643553fc74c8", "src_uid": "b7ef696a11ff96f2e9c31becc2ff50fe", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace ConsoleApp1\n{\n class Program\n {\n static void Main(string[] args)\n {\n string no1 = Console.ReadLine();\n List ar1 = no1.Split(' ').ToList();\n List ar = ar1.Select(s => int.Parse(s)).ToList();\n no1 = Console.ReadLine();\n List ar2 = no1.Split(' ').ToList();\n List ar3 = ar2.Select(s => int.Parse(s)).ToList();\n Console.WriteLine(PlainningTheExpedition(ar.ElementAt(0), ar.ElementAt(1), ar3));\n // Console.ReadKey();\n \n\n }\n public static int PlainningTheExpedition(int Participants, int typesOfFood, List foods)\n {\n if (Participants == 0)\n {\n return 0;\n }\n List distinctTypes = foods.Distinct().ToList();\n List noOfPackages = new List();\n distinctTypes.ForEach(x => noOfPackages.Add(foods.Count(y => y == x)));\n noOfPackages.Sort();\n int sum = noOfPackages.Sum();\n int maxdays = sum / Participants;\n if (maxdays == 0){\n return 0;\n }\n for (int i = maxdays; i > 0 ; i--)\n {\n int pos = 0;\n for (int j = 0; j < noOfPackages.Count; j++)\n {\n pos += noOfPackages[j] / i;\n }\n if (pos >= Participants) {\n return i;\n }\n }\n return 0;\n }\n\n\n }\n}\n//Planning The expedition\n//participants - n , type - h\n//list = arrType.distinct;\n//forech list (list1.push(arrType.Count(item)))\n//index = list1.length-n\n\n//7\n// 100 100 9 7 6", "lang_cluster": "C#", "tags": ["brute force", "implementation", "binary search"], "code_uid": "fd64056b8b864beeeae66269a26209c4", "src_uid": "b7ef696a11ff96f2e9c31becc2ff50fe", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Globalization;\nusing System.IO;\nusing System.Linq;\nusing System.Text;\nusing System.Threading;\n\n// (\u3065\u00b0\u03c9\u00b0)\u3065\uff90e\u2605\u309c\u30fb\u3002\u3002\u30fb\u309c\u309c\u30fb\u3002\u3002\u30fb\u309c\u2606\u309c\u30fb\u3002\u3002\u30fb\u309c\u309c\u30fb\u3002\u3002\u30fb\u309c\npublic class Solver\n{\n long Fun(int n, int m, int p, int[] a)\n {\n if (p == n)\n {\n var set = new HashSet();\n for (int mask = 0; mask < 1 << n; mask++)\n {\n int x = 0;\n for (int i = 0; i < n; i++)\n if ((mask >> i & 1) == 1)\n x = x * 10 + a[i];\n set.Add(x);\n }\n return set.Count;\n }\n\n long ret = 0;\n for (int i = 1; i <= m; i++)\n {\n a[p] = i;\n ret += Fun(n, m, p + 1, a);\n }\n return ret;\n }\n\n const int MOD = 1000000007;\n\n long Fun2(int n, int m)\n {\n int b = 2 * m - 1;\n long p = m;\n long ret = 2 * m;\n for (int i = 1; i < n; i++)\n {\n ret = (ret * b + p) % MOD;\n p = p * m % MOD;\n }\n return ret;\n }\n\n public void Solve()\n {\n int n = ReadInt();\n int m = ReadInt();\n Write(Fun2(n, m));\n }\n\n #region Main\n\n protected static TextReader reader;\n protected static TextWriter writer;\n static void Main()\n {\n#if DEBUG\n reader = new StreamReader(\"..\\\\..\\\\input.txt\");\n //reader = new StreamReader(Console.OpenStandardInput());\n writer = Console.Out;\n //writer = new StreamWriter(\"..\\\\..\\\\output.txt\");\n#else\n reader = new StreamReader(Console.OpenStandardInput());\n writer = new StreamWriter(Console.OpenStandardOutput());\n //reader = new StreamReader(\"input.txt\");\n //writer = new StreamWriter(\"output.txt\");\n#endif\n try\n {\n //var thread = new Thread(new Solver().Solve, 1024 * 1024 * 128);\n //thread.Start();\n //thread.Join();\n new Solver().Solve();\n }\n catch (Exception ex)\n {\n Console.WriteLine(ex);\n#if DEBUG\n#else\n throw;\n#endif\n }\n reader.Close();\n writer.Close();\n }\n\n #endregion\n\n #region Read / Write\n private static Queue currentLineTokens = new Queue();\n private static string[] ReadAndSplitLine() { return reader.ReadLine().Split(new[] { ' ', '\\t', }, StringSplitOptions.RemoveEmptyEntries); }\n public static string ReadToken() { while (currentLineTokens.Count == 0)currentLineTokens = new Queue(ReadAndSplitLine()); return currentLineTokens.Dequeue(); }\n public static int ReadInt() { return int.Parse(ReadToken()); }\n public static long ReadLong() { return long.Parse(ReadToken()); }\n public static double ReadDouble() { return double.Parse(ReadToken(), CultureInfo.InvariantCulture); }\n public static int[] ReadIntArray() { return ReadAndSplitLine().Select(int.Parse).ToArray(); }\n public static long[] ReadLongArray() { return ReadAndSplitLine().Select(long.Parse).ToArray(); }\n public static double[] ReadDoubleArray() { return ReadAndSplitLine().Select(s => double.Parse(s, CultureInfo.InvariantCulture)).ToArray(); }\n public static int[][] ReadIntMatrix(int numberOfRows) { int[][] matrix = new int[numberOfRows][]; for (int i = 0; i < numberOfRows; i++)matrix[i] = ReadIntArray(); return matrix; }\n public static int[][] ReadAndTransposeIntMatrix(int numberOfRows)\n {\n int[][] matrix = ReadIntMatrix(numberOfRows); int[][] ret = new int[matrix[0].Length][];\n for (int i = 0; i < ret.Length; i++) { ret[i] = new int[numberOfRows]; for (int j = 0; j < numberOfRows; j++)ret[i][j] = matrix[j][i]; } return ret;\n }\n public static string[] ReadLines(int quantity) { string[] lines = new string[quantity]; for (int i = 0; i < quantity; i++)lines[i] = reader.ReadLine().Trim(); return lines; }\n public static void WriteArray(IEnumerable array) { writer.WriteLine(string.Join(\" \", array)); }\n public static void Write(params object[] array) { WriteArray(array); }\n public static void WriteLines(IEnumerable array) { foreach (var a in array)writer.WriteLine(a); }\n private class SDictionary : Dictionary\n {\n public new TValue this[TKey key]\n {\n get { return ContainsKey(key) ? base[key] : default(TValue); }\n set { base[key] = value; }\n }\n }\n private static T[] Init(int size) where T : new() { var ret = new T[size]; for (int i = 0; i < size; i++)ret[i] = new T(); return ret; }\n #endregion\n}", "lang_cluster": "C#", "tags": ["combinatorics"], "code_uid": "87a30b5ae0f57b03bd0c726c3fb7bcf6", "src_uid": "5b775f17b188c1d8a4da212ebb3a525c", "difficulty": 2300.0, "exec_outcome": "PASSED"} {"lang": ".NET Core C#", "source_code": "using System;\nusing System.Collections;\nusing System.Collections.Generic;\nusing System.Diagnostics;\nusing System.IO;\nusing System.Linq;\nusing System.Numerics;\nusing System.Text;\nusing System.Text.RegularExpressions;\nusing System.Threading.Tasks;\nusing static System.Math;\n\npublic static class P\n{\n public static void Main()\n {\n var nm = Console.ReadLine().Split().Select(int.Parse).ToArray();\n var n = nm[0]; //num\n var m = nm[1]; //kind\n\n //Console.WriteLine(Stupid(1, 1));\n //Console.WriteLine(Stupid(2, 2));\n //Console.WriteLine(Stupid(3, 3));\n //Console.WriteLine(Stupid(4, 6));\n //Console.WriteLine(Stupid(5, 5));\n //Console.WriteLine(Stupid(6, 3));\n \n //1/m\u306e\u78ba\u7387\u3067\u6b21\u306e\u72b6\u614b\u306b\u9032\u3081\u308b\u30aa\u30fc\u30c8\u30de\u30c8\u30f3\u304c\u3001n\u30bf\u30fc\u30f3\u3067i\u56de\u4ee5\u4e0a\u5148\u306e\u72b6\u614b\u307e\u3067\u9032\u3080\u901a\u308a\u6570\n\n ModInt comb = Power(m, n);\n ModInt res = comb;\n for (int len = 1; len <= n; len++)\n {\n //len\u56de\u9032\u3081\u306a\u304b\u3063\u305f\u5834\u5408\n //\u3064\u307e\u308a\u3001len-1\u56de\u3042\u305f\u308a\u304c\u51fa\u3066\u3001n-len+1\u56de\u306f\u305a\u308c\n comb -= Power(m - 1, n - len + 1) * Factorial(n) / Factorial(len - 1) / Factorial(n - len + 1);\n res += comb * Power(m, len);\n }\n Console.WriteLine(res);\n }\n\n\n static List factorialMemo = new List() { 1 };\n static ModInt Factorial(int x)\n {\n for (int i = factorialMemo.Count; i <= x; i++) factorialMemo.Add(factorialMemo.Last() * i);\n return factorialMemo[x];\n }\n\n static ModInt Power(ModInt n, long m)\n {\n ModInt pow = n;\n ModInt res = 1;\n while (m > 0)\n {\n if ((m & 1) == 1) res *= pow;\n pow *= pow;\n m >>= 1;\n }\n return res;\n }\n\n static ModInt Stupid(int n, int m)\n {\n List seq = new List() { \"\" };\n for (int i = 0; i < n; i++)\n {\n var newseq = new List();\n foreach (var item in seq)\n {\n for (int j = 1; j <= m; j++)\n {\n newseq.Add(item + (char)('0' + j));\n }\n }\n seq = newseq;\n }\n int res = 0;\n Dictionary freqs = new Dictionary();\n foreach (var item in seq)\n {\n HashSet set = new HashSet() { \"\" };\n for (int i = 0; i < (1 << item.Length); i++)\n {\n string s = \"\";\n for (int j = 0; j < item.Length; j++)\n {\n if ((i >> j & 1) == 1) s += item[j];\n }\n set.Add(s);\n }\n //for (int i = 0; i < item.Length; i++)\n // for (int j = i + 1; j <= item.Length; j++)\n // set.Add(item[i..j]);\n foreach (var s in set)\n {\n if (!freqs.ContainsKey(s)) freqs[s] = 0;\n freqs[s]++;\n }\n res += set.Count;\n }\n foreach (var group in freqs.GroupBy(x => x.Value).OrderBy(x => x.Key))\n {\n Console.WriteLine($\"{group.Key} {group.Count()} {string.Join(\" \", group.Take(30).Select(x => x.Key))}\");\n }\n return res;\n }\n}\n\nstruct ModInt\n{\n public const int Mod = 1000000007;\n const long POSITIVIZER = ((long)Mod) << 31;\n long Data;\n public ModInt(long data) { if ((Data = data % Mod) < 0) Data += Mod; }\n public static implicit operator long(ModInt modInt) => modInt.Data;\n public static implicit operator ModInt(long val) => new ModInt(val);\n public static ModInt operator +(ModInt a, int b) => new ModInt() { Data = (a.Data + b + POSITIVIZER) % Mod };\n public static ModInt operator +(ModInt a, long b) => new ModInt(a.Data + b);\n public static ModInt operator +(ModInt a, ModInt b) { long res = a.Data + b.Data; return new ModInt() { Data = res >= Mod ? res - Mod : res }; }\n public static ModInt operator -(ModInt a, int b) => new ModInt() { Data = (a.Data - b + POSITIVIZER) % Mod };\n public static ModInt operator -(ModInt a, long b) => new ModInt(a.Data - b);\n public static ModInt operator -(ModInt a, ModInt b) { long res = a.Data - b.Data; return new ModInt() { Data = res < 0 ? res + Mod : res }; }\n public static ModInt operator *(ModInt a, int b) => new ModInt(a.Data * b);\n public static ModInt operator *(ModInt a, long b) => a * new ModInt(b);\n public static ModInt operator *(ModInt a, ModInt b) => new ModInt() { Data = a.Data * b.Data % Mod };\n public static ModInt operator /(ModInt a, ModInt b) => new ModInt() { Data = a.Data * GetInverse(b) % Mod };\n public static bool operator ==(ModInt a, ModInt b) => a.Data == b.Data;\n public static bool operator !=(ModInt a, ModInt b) => a.Data != b.Data;\n public override string ToString() => Data.ToString();\n public override bool Equals(object obj) => (ModInt)obj == this;\n public override int GetHashCode() => (int)Data;\n static long GetInverse(long a)\n {\n long div, p = Mod, x1 = 1, y1 = 0, x2 = 0, y2 = 1;\n while (true)\n {\n if (p == 1) return x2 + Mod; div = a / p; x1 -= x2 * div; y1 -= y2 * div; a %= p;\n if (a == 1) return x1 + Mod; div = p / a; x2 -= x1 * div; y2 -= y1 * div; p %= a;\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["combinatorics"], "code_uid": "d675482ce1658f1453036f330a8fff20", "src_uid": "5b775f17b188c1d8a4da212ebb3a525c", "difficulty": 2300.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\n\nnamespace equations\n{\n class MainClass\n {\n public static void Main (string[] args)\n {\n string[] tmp = new string[2];\n tmp = Console.ReadLine().Split(' ');\n int n = Convert.ToInt32(tmp[0]);\n int m = Convert.ToInt32(tmp[1]);\n \n int max = m;\n \n if( n >= m)\n max = n;\n \n \n int answer = 0; \n \n for (int a = 0; a <= max; a++)\n {\n for( int b = 0; b <= max; b++)\n {\n if( (a*a + b == n) && (a + b*b == m))\n answer ++; \n \n }\n \n \n }\n \n \n Console.WriteLine(Convert.ToString(answer));\n \n \n }\n }\n}", "lang_cluster": "C#", "tags": ["brute force"], "code_uid": "4721e27d5e1cf260b318b0ed742eaa9b", "src_uid": "03caf4ddf07c1783e42e9f9085cc6efd", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace ConsoleApplication1\n{\n class Program\n {\n static void Main(string[] args)\n {\n int count =0;\n \n String line = Console.ReadLine();\n String[] ps = line.Split(' ');\n int n = int.Parse(ps[0]);\n int m = int.Parse(ps[1]);\n for (int i = 0; i <= 1000; i++)\n {\n for (int j = 0; j <= 1000; j++)\n {\n if ((i * i) + j == n && i + (j * j) == m)\n count++;\n }\n \n }\n Console.WriteLine(count);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force"], "code_uid": "3ed6d298596bf521bf00db9ebe025378", "src_uid": "03caf4ddf07c1783e42e9f9085cc6efd", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.IO;\n\nnamespace CF\n{\n class Program\n {\n\n static long[] values;\n\n static void Main(string[] args)\n {\n\n#if DEBUG\n TextReader reader = new StreamReader(\"../../input.txt\");\n\n#else\n TextReader reader = Console.In;\n#endif\n\n\n //reader.ReadLine();\n\n values = reader.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();\n\n\n if (F()) Console.WriteLine(\"First\");\n else Console.WriteLine(\"Second\");\n\n\n#if DEBUG\n Console.ReadKey();\n#endif\n\n }\n\n static bool F()\n {\n if (values[2] * 2 > values[1] || values[2] * 2 > values[0]) return false;\n else return true;\n }\n }\n}", "lang_cluster": "C#", "tags": ["math", "constructive algorithms", "games"], "code_uid": "f0b6025308a4511b4e119845cb5c0777", "src_uid": "90b9ef939a13cf29715bc5bce26c9896", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeff\ufeffusing System;\nusing System.Collections;\nusing System.Collections.Generic;\nusing System.Collections.Specialized;\nusing System.Diagnostics;\nusing System.Globalization;\nusing System.IO;\nusing System.Text;\nusing System.Linq;\n\nnamespace Codeforces\n{\n internal static class Program\n {\n private const string TEST = \"C1\";\n\n private static void Solve()\n {\n var input = ReadIntArray();\n var a = input[0];\n var b = input[1];\n var r = input[2];\n if(a >=2*r && b >= 2*r)\n {\n WriteLine(\"First\");\n }\n else\n WriteLine(\"Second\");\n }\n\n private static int Gcd(int a, int b)\n {\n if (b==0)\n return a;\n\n return Gcd(b, a%b);\n }\n\n private static void Main()\n {\n if (Debugger.IsAttached)\n {\n Console.SetIn(new StreamReader(String.Format(@\"..\\..\\..\\..\\Tests\\{0}.in\", TEST)));\n }\n\n Solve();\n\n if (Debugger.IsAttached)\n {\n Console.In.Close();\n Console.SetIn(new StreamReader(Console.OpenStandardInput()));\n Console.ReadLine();\n }\n }\n\n #region Reader\n\n private static string Read()\n {\n return Console.ReadLine();\n }\n\n private static string[] ReadArray()\n {\n return Console.ReadLine().Split(' ');\n }\n\n private static List ReadIntArray()\n {\n var input = Console.ReadLine().Split(' ').Select(Int32.Parse).ToList();\n return input;\n }\n\n private static int ReadInt()\n {\n return Int32.Parse(Console.ReadLine());\n }\n\n private static long ReadLong()\n {\n return long.Parse(Console.ReadLine());\n }\n\n private static int ReadNextInt(string[] input, int index)\n {\n return Int32.Parse(input[index]);\n }\n\n private static double ReadDouble()\n {\n return double.Parse(Console.ReadLine(), CultureInfo.InvariantCulture);\n }\n\n private static List ReadDoubleArray()\n {\n return Console.ReadLine().Split(' ').Select(d => double.Parse(d, CultureInfo.InvariantCulture)).ToList();\n }\n\n private static void WriteLine(object value)\n {\n Console.WriteLine(value);\n }\n\n private static void WriteLine(string value)\n {\n Console.WriteLine(value);\n }\n\n private static void Write(object value)\n {\n Console.Write(value);\n }\n\n private static void Write(string value)\n {\n Console.Write(value);\n }\n\n #endregion\n }\n}", "lang_cluster": "C#", "tags": ["math", "constructive algorithms", "games"], "code_uid": "2ffd2db3cf0b24d8bd815ae1317db5ef", "src_uid": "90b9ef939a13cf29715bc5bce26c9896", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Diagnostics;\nusing System.IO;\nusing System.Linq;\nusing System.Numerics;\n\nnamespace CodeforcesTemplate\n{\n class Program\n {\n private const string FILENAME = \"distance4\";\n\n private const string INPUT = FILENAME + \".in\";\n\n private const string OUTPUT = FILENAME + \".out\";\n\n private static Stopwatch _stopwatch = new Stopwatch();\n\n static StreamReader _reader = null;\n static StreamWriter _writer = null;\n\n static string[] _curLine;\n static int _curTokenIdx;\n\n static char[] _whiteSpaces = new char[] { ' ', '\\t', '\\r', '\\n' };\n\n public static string ReadNextToken()\n {\n if (_curTokenIdx >= _curLine.Length)\n {\n //Read next line\n string line = _reader.ReadLine();\n if (line != null)\n _curLine = line.Split(_whiteSpaces, StringSplitOptions.RemoveEmptyEntries);\n else\n _curLine = new string[] { };\n _curTokenIdx = 0;\n }\n\n if (_curTokenIdx >= _curLine.Length)\n return null;\n\n return _curLine[_curTokenIdx++];\n }\n\n public static int ReadNextInt()\n {\n return int.Parse(ReadNextToken());\n }\n\n private static void RunTimer()\n {\n#if (DEBUG)\n\n _stopwatch.Start();\n\n#endif\n }\n\n private static void Main(string[] args)\n {\n#if (DEBUG)\n double before = GC.GetTotalMemory(false);\n#endif\n\n string s = Console.ReadLine();\n\n RunTimer();\n\n int countZero = 0;\n for (int i = s.Length - 1; i >= 0; i--)\n {\n if (s[i] == '0')\n {\n countZero++;\n }\n \n else\n {\n break;\n }\n \n }\n \n\n string ss = s.Substring(0, s.Length - countZero);\n\n char[] r = ss.ToCharArray();\n\n Array.Reverse(r);\n\n string reverse = new string(r);\n\n if(reverse == ss)\n {\n Console.WriteLine(\"YES\");\n }\n\n else\n {\n Console.WriteLine(\"NO\");\n }\n\n\n#if (DEBUG)\n _stopwatch.Stop();\n\n double after = GC.GetTotalMemory(false);\n\n double consumedInMegabytes = (after - before) / (1024 * 1024);\n\n Console.WriteLine($\"Time elapsed: {_stopwatch.Elapsed}\");\n\n Console.WriteLine($\"Consumed memory (MB): {consumedInMegabytes}\");\n\n Console.ReadKey();\n#endif\n\n\n }\n\n\n static int[] CopyOfRange(int[] src, int start, int end)\n {\n int len = end - start;\n int[] dest = new int[len];\n Array.Copy(src, start, dest, 0, len);\n return dest;\n }\n\n static string StreamReader()\n {\n\n if (_reader == null)\n _reader = new StreamReader(INPUT);\n string response = _reader.ReadLine();\n if (_reader.EndOfStream)\n _reader.Close();\n return response;\n\n\n }\n\n static void StreamWriter(string text)\n {\n\n if (_writer == null)\n _writer = new StreamWriter(OUTPUT);\n _writer.WriteLine(text);\n\n\n }\n\n\n\n\n\n public static int BFS(int start, int end, int[,] arr)\n {\n Queue> queue = new Queue>();\n List visited = new List();\n for (int i = 0; i < arr.GetLength(0); i++)\n {\n visited.Add(false);\n }\n\n queue.Enqueue(new KeyValuePair(start, 0));\n KeyValuePair node;\n int level = 0;\n bool flag = false;\n\n while (queue.Count != 0)\n {\n node = queue.Dequeue();\n if (node.Key == end)\n {\n return node.Value;\n }\n flag = false;\n for (int i = 0; i < arr.GetLength(0); i++)\n {\n\n if (arr[node.Key, i] == 1)\n {\n if (visited[i] == false)\n {\n if (!flag)\n {\n level = node.Value + 1;\n flag = true;\n }\n queue.Enqueue(new KeyValuePair(i, level));\n visited[i] = true;\n }\n }\n }\n\n }\n return 0;\n\n }\n\n\n\n private static void Write(string source)\n {\n File.WriteAllText(OUTPUT, source);\n }\n\n private static string ReadString()\n {\n return File.ReadAllText(INPUT);\n }\n\n private static void WriteStringArray(string[] source)\n {\n File.WriteAllLines(OUTPUT, source);\n }\n\n private static string[] ReadStringArray()\n {\n return File.ReadAllLines(INPUT);\n }\n\n private static int[] GetIntArray()\n {\n return ReadString().Split(' ').Select(int.Parse).ToArray();\n }\n\n private static double[] GetDoubleArray()\n {\n return ReadString().Split(' ').Select(double.Parse).ToArray();\n }\n\n private static int[,] ReadINT2XArray(List lines)\n {\n int[,] arr = new int[lines.Count, lines.Count];\n\n for (int i = 0; i < lines.Count; i++)\n {\n int[] row = lines[i].Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(int.Parse).ToArray();\n\n for (int j = 0; j < lines.Count; j++)\n {\n arr[i, j] = row[j];\n }\n }\n\n return arr;\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "implementation"], "code_uid": "7ffd56ad7063723c7892e458718ff6e1", "src_uid": "d82278932881e3aa997086c909f29051", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.IO;\nusing System.Runtime.CompilerServices;\nusing System.Text;\nusing System.Diagnostics;\nusing System.Numerics;\nusing static System.Console;\nusing static System.Convert;\nusing static System.Math;\nusing static Template;\nusing Pi = Pair;\n\nclass Solver\n{\n public void Solve(Scanner sc)\n {\n var X = sc.Str.ToCharArray();\n Array.Reverse(X);\n var T = X.SkipWhile(c => c == '0').ToArray();\n for (int i = 0; i < T.Length / 2; i++)\n if (T[i] != T[T.Length - 1 - i]) Fail(\"NO\");\n Console.WriteLine(\"YES\");\n }\n}\n\n#region Template\npublic static class Template\n{\n static void Main(string[] args)\n {\n Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });\n new Solver().Solve(new Scanner());\n Console.Out.Flush();\n }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static bool chmin(ref T a, T b) where T : IComparable { if (a.CompareTo(b) > 0) { a = b; return true; } return false; }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static bool chmax(ref T a, T b) where T : IComparable { if (a.CompareTo(b) < 0) { a = b; return true; } return false; }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static void swap(ref T a, ref T b) { var t = b; b = a; a = t; }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static void swap(this IList A, int i, int j) { var t = A[i]; A[i] = A[j]; A[j] = t; }\n public static T[] Create(int n, Func f) { var rt = new T[n]; for (var i = 0; i < rt.Length; ++i) rt[i] = f(); return rt; }\n public static T[] Create(int n, Func f) { var rt = new T[n]; for (var i = 0; i < rt.Length; ++i) rt[i] = f(i); return rt; }\n public static IEnumerable Shuffle(this IEnumerable A) => A.OrderBy(v => Guid.NewGuid());\n public static int CompareTo(this T[] A, T[] B, Comparison cmp = null) { cmp = cmp ?? Comparer.Default.Compare; for (var i = 0; i < Min(A.Length, B.Length); i++) { int c = cmp(A[i], B[i]); if (c > 0) return 1; else if (c < 0) return -1; } if (A.Length == B.Length) return 0; if (A.Length > B.Length) return 1; else return -1; }\n public static int MaxElement(this IList A, Comparison cmp = null) { cmp = cmp ?? Comparer.Default.Compare; T max = A[0]; int rt = 0; for (int i = 1; i < A.Count; i++) if (cmp(max, A[i]) < 0) { max = A[i]; rt = i; } return rt; }\n public static T PopBack(this List A) { var v = A[A.Count - 1]; A.RemoveAt(A.Count - 1); return v; }\n public static void Fail(T s) { Console.WriteLine(s); Console.Out.Close(); Environment.Exit(0); }\n}\npublic class Scanner\n{\n public string Str => Console.ReadLine().Trim();\n public int Int => int.Parse(Str);\n public long Long => long.Parse(Str);\n public double Double => double.Parse(Str);\n public int[] ArrInt => Str.Split(' ').Select(int.Parse).ToArray();\n public long[] ArrLong => Str.Split(' ').Select(long.Parse).ToArray();\n public char[][] Grid(int n) => Create(n, () => Str.ToCharArray());\n public int[] ArrInt1D(int n) => Create(n, () => Int);\n public long[] ArrLong1D(int n) => Create(n, () => Long);\n public int[][] ArrInt2D(int n) => Create(n, () => ArrInt);\n public long[][] ArrLong2D(int n) => Create(n, () => ArrLong);\n private Queue q = new Queue();\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public T Next() { if (q.Count == 0) foreach (var item in Str.Split(' ')) q.Enqueue(item); return (T)Convert.ChangeType(q.Dequeue(), typeof(T)); }\n public void Make(out T1 v1) => v1 = Next();\n public void Make(out T1 v1, out T2 v2) { v1 = Next(); v2 = Next(); }\n public void Make(out T1 v1, out T2 v2, out T3 v3) { Make(out v1, out v2); v3 = Next(); }\n public void Make(out T1 v1, out T2 v2, out T3 v3, out T4 v4) { Make(out v1, out v2, out v3); v4 = Next(); }\n public void Make(out T1 v1, out T2 v2, out T3 v3, out T4 v4, out T5 v5) { Make(out v1, out v2, out v3, out v4); v5 = Next(); }\n public void Make(out T1 v1, out T2 v2, out T3 v3, out T4 v4, out T5 v5, out T6 v6) { Make(out v1, out v2, out v3, out v4, out v5); v6 = Next(); }\n public void Make(out T1 v1, out T2 v2, out T3 v3, out T4 v4, out T5 v5, out T6 v6, out T7 v7) { Make(out v1, out v2, out v3, out v4, out v5, out v6); v7 = Next(); }\n //public (T1, T2) Make() { Make(out T1 v1, out T2 v2); return (v1, v2); }\n //public (T1, T2, T3) Make() { Make(out T1 v1, out T2 v2, out T3 v3); return (v1, v2, v3); }\n //public (T1, T2, T3, T4) Make() { Make(out T1 v1, out T2 v2, out T3 v3, out T4 v4); return (v1, v2, v3, v4); }\n}\npublic class Pair : IComparable>\n{\n public T1 v1;\n public T2 v2;\n public Pair() { }\n public Pair(T1 v1, T2 v2)\n { this.v1 = v1; this.v2 = v2; }\n\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public int CompareTo(Pair p)\n {\n var c = Comparer.Default.Compare(v1, p.v1);\n if (c == 0)\n c = Comparer.Default.Compare(v2, p.v2);\n return c;\n }\n public override string ToString() => $\"{v1.ToString()} {v2.ToString()}\";\n public void Deconstruct(out T1 a, out T2 b) { a = v1; b = v2; }\n}\n\npublic class Pair : Pair, IComparable>\n{\n public T3 v3;\n public Pair() : base() { }\n public Pair(T1 v1, T2 v2, T3 v3) : base(v1, v2)\n { this.v3 = v3; }\n\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public int CompareTo(Pair p)\n {\n var c = base.CompareTo(p);\n if (c == 0)\n c = Comparer.Default.Compare(v3, p.v3);\n return c;\n }\n public override string ToString() => $\"{base.ToString()} {v3.ToString()}\";\n public void Deconstruct(out T1 a, out T2 b, out T3 c) { Deconstruct(out a, out b); c = v3; }\n}\n#endregion\n", "lang_cluster": "C#", "tags": ["brute force", "implementation"], "code_uid": "6e59b09a87b5fc9669667c925ae94f6d", "src_uid": "d82278932881e3aa997086c909f29051", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections;\nusing System.Collections.Generic;\n \nclass TEST{\n\tstatic void Main(){\n\t\tSol mySol =new Sol();\n\t\tmySol.Solve();\n\t}\n}\n\nclass Sol{\n\tpublic void Solve(){\n\t\t\n\t\tif(M==1){\n\t\t\tConsole.WriteLine(\"{0} {0}\",(N*(N-1))/2);\n\t\t\treturn;\n\t\t}\n\t\t\n\t\tlong max=((N-(M-1))*(N-(M-1)-1))/2;\n\t\t\n\t\tlong s=N/M;\n\t\tlong t=N/M+1;\n\t\t\n\t\tlong min=(N%M)*((t*(t-1))/2)+(M-N%M)*((s*(s-1))/2);\n\t\tConsole.WriteLine(\"{0} {1}\",min,max);\n\t\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t}\n\tlong N;\n\tlong M;\n\tpublic Sol(){\n\t\tvar d=rla();\n\t\tN=d[0];M=d[1];\n\t}\n\n\n\n\n\tstatic String rs(){return Console.ReadLine();}\n\tstatic int ri(){return int.Parse(Console.ReadLine());}\n\tstatic long rl(){return long.Parse(Console.ReadLine());}\n\tstatic double rd(){return double.Parse(Console.ReadLine());}\n\tstatic String[] rsa(){return Console.ReadLine().Split(' ');}\n\tstatic int[] ria(){return Array.ConvertAll(Console.ReadLine().Split(' '),e=>int.Parse(e));}\n\tstatic long[] rla(){return Array.ConvertAll(Console.ReadLine().Split(' '),e=>long.Parse(e));}\n\tstatic double[] rda(){return Array.ConvertAll(Console.ReadLine().Split(' '),e=>double.Parse(e));}\n}\n", "lang_cluster": "C#", "tags": ["math", "greedy", "constructive algorithms", "combinatorics"], "code_uid": "1f30f1ed4880e1b69cc08e77c7cad861", "src_uid": "a081d400a5ce22899b91df38ba98eecc", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Linq;\n\nclass Program\n{\n #region utility\n static char ReadChar()\n {\n return (char)Console.Read();\n }\n static string ReadWord()\n {\n var str = string.Empty;\n while (true)\n {\n var chr = ReadChar();\n if (chr != ' ')\n {\n str += chr;\n break;\n }\n }//skip empty start\n while (true)\n {\n var chr = ReadChar();\n if (chr == ' ' || chr == '\\n') break;\n str += chr;\n }\n return str;\n }\n static int ReadInt()\n {\n return int.Parse(ReadWord());\n }\n static long ReadLong()\n {\n return long.Parse(ReadWord());\n }\n #endregion\n\n static void Main(string[] args)\n {\n var n = ReadLong(); var m = ReadLong();\n\n long maxCom = GetMaxComPosses(n, m);\n\n long minCom = GetMinComPosses(n, m);\n\n Console.WriteLine($\"{minCom} {maxCom}\");\n\n }\n\n static long GetMinComPosses(long n, long m)\n {\n var lessTeamSize = n / m;\n var bigTeamSize = lessTeamSize + 1;\n\n var lessTeamCount = m - (n % m);\n var bigTeamCount = m - lessTeamCount;\n\n var minCom = (lessTeamCount * SumUntil(lessTeamSize)) + (bigTeamCount * SumUntil(bigTeamSize));\n return minCom;\n }\n\n static long GetMaxComPosses(long n, long m)\n {\n var bigTeam = n - m + 1; //all of other team will have one player, but this wil have the rest\n var maxCom = SumUntil(bigTeam);\n return maxCom;\n }\n\n static long SumUntil(long n)\n {\n return (n * (n - 1)) / 2;\n }\n}\n\n", "lang_cluster": "C#", "tags": ["math", "greedy", "constructive algorithms", "combinatorics"], "code_uid": "ac158dc64632ea87fa470ae3e8f0f949", "src_uid": "a081d400a5ce22899b91df38ba98eecc", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\n\nnamespace CFB\n{\n class Program\n {\n static void Main(string[] args)\n {\n ulong a, b;\n string[] inp = Console.ReadLine().Split(' ');\n a = ulong.Parse(inp[0]);\n b = ulong.Parse(inp[1]);\n\n odin:\n if (a == 0 || b == 0)\n {\n Console.Write(a + \" \" + b);\n Environment.Exit(0);\n } else goto dva;\n\n dva:\n if (a >= 2 * b)\n {\n ulong c = a / (2 * b);\n a -= 2 * b * c;\n goto odin;\n }\n else goto tri;\n\n tri:\n if (b >= 2 * a)\n {\n ulong c = b / (2 * a);\n b -= 2 * a * c;\n goto odin;\n }\n else\n {\n Console.Write(a + \" \" + b);\n Environment.Exit(0);\n }\n\n }\n }\n}", "lang_cluster": "C#", "tags": ["math", "number theory"], "code_uid": "3737634d59a9a16cb0472cbaf9aff3e9", "src_uid": "1f505e430eb930ea2b495ab531274114", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace Problem946B\n{\n class Program\n {\n static void Main(string[] args)\n {\n var pars = Console.ReadLine().Split(' ').Select(_ => long.Parse(_)).ToArray();\n long a = pars[0], b = pars[1];\n while (a != 0 && b != 0)\n {\n if (a >= 2 * b)\n {\n a = a % (2 * b);\n }\n else if (b >= 2 * a)\n {\n b = b % (2 * a);\n }\n else\n break;\n }\n Console.WriteLine(\"{0} {1}\", a, b);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "number theory"], "code_uid": "06a2d59ddd0fb8818dfaa59dedc2c275", "src_uid": "1f505e430eb930ea2b495ab531274114", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\n\nnamespace CSharp\n{\n public class _820A\n {\n public static void Main()\n {\n string[] tokens = Console.ReadLine().Split();\n\n int c = int.Parse(tokens[0]);\n int v0 = int.Parse(tokens[1]);\n int v1 = int.Parse(tokens[2]);\n int a = int.Parse(tokens[3]);\n int l = int.Parse(tokens[4]);\n\n for (int day = 1, v = v0, read = v; ; day++, v = Math.Min(v + a, v1), read = Math.Max(0, read - l) + v)\n {\n if (read >= c)\n {\n Console.WriteLine(day);\n break;\n }\n }\n }\n }\n}", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "193c7634892dd0005dbb7e93dc4ce15c", "src_uid": "b743110117ce13e2090367fd038d3b50", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nnamespace CodeForces {\n class Solve820A {\n int c, v0, v1, a, l;\n int days;\n\n public void readInput() {\n var parts = Console.ReadLine().Split(' ');\n this.c = int.Parse(parts[0]);\n this.v0 = int.Parse(parts[1]);\n this.v1 = int.Parse(parts[2]);\n this.a = int.Parse(parts[3]);\n this.l = int.Parse(parts[4]);\n }\n\n public void printAnswer() {\n Console.WriteLine(this.days);\n }\n\n public void solve() {\n this.days = 1;\n int pagesRead = this.v0;\n while (pagesRead < this.c) {\n int theoreticalSpeed = this.v0 - this.l + this.days * this.a;\n pagesRead += Math.Min(theoreticalSpeed, this.v1 - l);\n this.days++;\n }\n }\n }\n\n class Runner {\n public static void Main() {\n Solve820A solver = new Solve820A();\n solver.readInput();\n solver.solve();\n solver.printAnswer();\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "a8436314456ab3e0cf80e23b3b6730d2", "src_uid": "b743110117ce13e2090367fd038d3b50", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\n\nnamespace ConsoleApplication1\n{\n class Program\n {\n static void Main(string[] args)\n {\n Console.ReadLine();\n string y = Console.ReadLine();\n string y1 = y; \n string y2 = y1;\n y2 = y2.ToLower();\n string[] s = y.Split(' ');\n string[] s1 = y2.Split(' ');\n int[] mass = new int[s.Length];\n for (int i = 0; i < s.Length; i++)\n {\n for (int j = 0; j < s[i].Length; j++)\n {\n if (s[i][j] != s1[i][j])\n {\n mass[i]++;\n }\n }\n }\n Array.Sort(mass);\n Console.WriteLine(mass[mass.Length - 1]);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "da75602acb7effbbbd72d0ccdbf2f08c", "src_uid": "d3929a9acf1633475ab16f5dfbead13c", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections;\nusing System.Collections.Generic;\nusing System.Collections.ObjectModel;\nusing System.Diagnostics;\nusing System.IO;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\npublic sealed partial class Program\n{\n public void EntryPoint()\n {\n var n = scanner.N();\n var v = scanner.Words(word => word.Count(char.IsUpper)).Max();\n WriteLine(v);\n }\n}\n\n#region Custom Library\npublic static class TemplateExtension\n{\n public static X[] MakeArray(this int count, Func func)\n {\n var xs = new X[count];\n for (var i = 0; i < count; i++)\n {\n xs[i] = func(i);\n }\n return xs;\n }\n\n public static int[] Range(this int count, int start = 0)\n {\n return count.MakeArray(i => i + start);\n }\n\n public static string Intercalate(this IEnumerable @this, string separator)\n {\n return string.Join(separator, @this);\n }\n\n public static void ForEach(this IEnumerable @this, Action action)\n {\n var list = @this as IReadOnlyList;\n if (list != null)\n {\n var count = list.Count;\n for (var i = 0; i < count; i++)\n {\n action(list[i], i);\n }\n }\n else\n {\n var i = 0;\n foreach (var x in @this)\n {\n action(x, i);\n i++;\n }\n }\n }\n}\n\npublic sealed class Scanner\n{\n readonly TextReader reader;\n\n ///

\n /// Reads next word separated by spaces.\n /// \n public string Word()\n {\n var sb = default(StringBuilder);\n var firstChar = default(char);\n var count = 0;\n\n while (true)\n {\n var r = reader.Read();\n\n if (r == '\\r')\n {\n if (reader.Peek() == '\\n') reader.Read();\n break;\n }\n else if (r == -1 || r == ' ' || r == '\\n')\n {\n break;\n }\n else\n {\n var c = (char)r;\n\n switch (count)\n {\n case 0:\n firstChar = c;\n count = 1;\n break;\n case 1:\n sb = new StringBuilder();\n sb.Append(firstChar).Append(c);\n count = 2;\n break;\n default:\n sb.Append(c);\n break;\n }\n }\n }\n\n switch (count)\n {\n case 0:\n return \"\";\n case 1:\n return firstChar.ToString();\n default:\n return sb.ToString();\n }\n }\n\n /// \n /// Reads next word as .\n /// \n public int N()\n {\n return int.Parse(Word());\n }\n\n /// \n /// Reads next word as .\n /// \n public long L()\n {\n return long.Parse(Word());\n }\n\n /// \n /// Reads next word as .\n /// \n public double F()\n {\n return double.Parse(Word());\n }\n\n public int[] Ns(int count)\n {\n return count.MakeArray(_ => N());\n }\n\n public long[] Ls(int count)\n {\n return count.MakeArray(_ => L());\n }\n\n public double[] Fs(int count)\n {\n return count.MakeArray(_ => F());\n }\n\n /// \n /// Reads next line and splits it by spaces.\n /// \n public X[] Words(Func func)\n {\n return reader.ReadLine().Split(' ').Select(func).ToArray();\n }\n\n public Scanner(TextReader reader)\n {\n this.reader = reader;\n }\n}\n\npublic partial class Program\n{\n readonly TextReader input;\n readonly TextWriter output;\n readonly Scanner scanner;\n\n void WriteLine(int value)\n {\n output.WriteLine(value);\n }\n\n void WriteLine(long value)\n {\n output.WriteLine(value);\n }\n\n void WriteLine(double value)\n {\n output.WriteLine(value);\n }\n\n void WriteLine(char value)\n {\n output.WriteLine(value);\n }\n\n void WriteLine(string value)\n {\n output.WriteLine(value);\n }\n\n public Program(TextReader input, TextWriter output)\n {\n this.input = input;\n this.output = output;\n scanner = new Scanner(input);\n }\n\n public static void Main(string[] args)\n {\n#if DEBUG\n using (var writer = new VainZero.IO.DebugTextWriter(Console.Out))\n#else\n var writer = Console.Out;\n#endif\n {\n new Program(Console.In, writer).EntryPoint();\n }\n }\n}\n#endregion\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "cae6fdc70f003cf1e54bf10982533b51", "src_uid": "d3929a9acf1633475ab16f5dfbead13c", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Text;\n\nnamespace B\n{\n class Program\n {\n static void Main(string[] args)\n {\n string[] line = Console.ReadLine().Split(' ');\n int n = int.Parse(line[0]);\n int m = int.Parse(line[1]) - 1; // rabbit\n int k = int.Parse(line[2]) - 1;\n int dir = Console.ReadLine() == \"to tail\" ? 1 : -1;\n string s = Console.ReadLine();\n\n if (k == 0)\n dir = 1;\n if (k == n - 1)\n dir = -1;\n\n bool rabbitbefore = m < k;\n bool caught = false;\n int time = 0;\n for (; time < s.Length; time++)\n {\n k += dir;\n\n if (s[time] == '1')\n {\n rabbitbefore = (dir == 1);\n }\n else\n {\n if (k == 0 && rabbitbefore || k == n - 1 && !rabbitbefore)\n {\n caught = true;\n break;\n }\n }\n\n if (k == 0 || k == n - 1)\n dir = -dir;\n }\n\n if(caught)\n Console.WriteLine(\"Controller {0}\", time + 1);\n else\n Console.WriteLine(\"Stowaway\");\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["greedy", "dp", "games"], "code_uid": "2dc1b97ea31533abc4fed6eec4d58131", "src_uid": "2222ce16926fdc697384add731819f75", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\n\nnamespace B\n{\n class Program\n {\n static void Main(string[] args)\n {\n var tmp = Console.ReadLine().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);\n int n = int.Parse(tmp[0]);\n int zayc = int.Parse(tmp[1]);\n int controller = int.Parse(tmp[2]);\n int minut = -5;\n string naprav = Console.ReadLine();\n int znak = 0;\n if (naprav == \"to head\") \n {\n znak = -1;\n }\n else\n {\n znak = 1;\n }\n\n string mask = Console.ReadLine();\n bool win = true;\n\n\n\n for (int i = 0; i < mask.Length; i++)\n {\n if ((controller == 1) && (znak == -1))\n {\n znak = -znak;\n }\n if ((controller == n) && (znak == 1))\n {\n znak = -znak;\n }\n if (mask[i] == '0')\n {\n if (zayc == 1 || zayc == n)\n {\n\n }\n else\n {\n if (zayc < controller)\n zayc--;\n else\n zayc++;\n }\n controller += znak;\n if (controller == zayc)\n {\n win = false;\n minut = i+1;\n break;\n }\n\n }\n else\n {\n controller += znak;\n if (znak == 1)\n {\n if (controller == 1)\n {\n zayc = n;\n }\n if (controller == n)\n {\n zayc = 1;\n }\n if(controller !=1)\n if(controller !=n)\n {\n zayc = 1;\n }\n }\n else\n {\n if (controller == n)\n {\n zayc = 1;\n }\n if (controller == 1)\n {\n zayc = n;\n }\n if (controller != 1)\n if (controller != n)\n {\n zayc = n;\n }\n }\n }\n\n }\n\n if (win)\n {\n Console.WriteLine(\"Stowaway\");\n }\n else\n {\n Console.WriteLine(\"Controller \" + minut);\n }\n Console.ReadLine();\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["greedy", "dp", "games"], "code_uid": "394aebf0081f72dc43e41c9b2642e15b", "src_uid": "2222ce16926fdc697384add731819f75", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.IO;\nusing System.Threading;\nusing System.Runtime.CompilerServices;\nusing System.Text;\nusing System.Diagnostics;\nusing System.Numerics;\nusing static System.Console;\nusing static System.Convert;\nusing static System.Math;\nusing static Template;\n\nclass Solver\n{\n public Scanner sc;\n public void Solve()\n {\n long N, M;\n sc.Make(out N, out M);\n var min = Max(0, N - 2 * M);\n int i;var now = 0L;\n if (M == 0) Fail($\"{min} {N}\");\n for (i = 0; i < N; i++)\n {\n now += i;\n if (now >= M) break;\n }\n Console.WriteLine($\"{min} {N-i-1}\");\n }\n}\n\n#region Template\npublic static class Template\n{\n static void Main(string[] args)\n {\n Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });\n var sol = new Solver() { sc = new Scanner() };\n //var th = new Thread(sol.Solve, 1 << 26);th.Start();th.Join();\n sol.Solve();\n Console.Out.Flush();\n }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static bool chmin(ref T a, T b) where T : IComparable { if (a.CompareTo(b) > 0) { a = b; return true; } return false; }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static bool chmax(ref T a, T b) where T : IComparable { if (a.CompareTo(b) < 0) { a = b; return true; } return false; }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static void swap(ref T a, ref T b) { var t = b; b = a; a = t; }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static void swap(this IList A, int i, int j) { var t = A[i]; A[i] = A[j]; A[j] = t; }\n public static T[] Create(int n, Func f) { var rt = new T[n]; for (var i = 0; i < rt.Length; ++i) rt[i] = f(); return rt; }\n public static T[] Create(int n, Func f) { var rt = new T[n]; for (var i = 0; i < rt.Length; ++i) rt[i] = f(i); return rt; }\n public static void Out(this IList A, out T a) => a = A[0];\n public static void Out(this IList A, out T a, out T b) { a = A[0]; b = A[1]; }\n public static void Out(this IList A, out T a, out T b, out T c) { A.Out(out a, out b); c = A[2]; }\n public static void Out(this IList A, out T a, out T b, out T c, out T d) { A.Out(out a, out b, out c); d = A[3]; }\n public static string Concat(this IEnumerable A, string sp) => string.Join(sp, A);\n public static char ToChar(this int s, char begin = '0') => (char)(s + begin);\n public static IEnumerable Shuffle(this IEnumerable A) => A.OrderBy(v => Guid.NewGuid());\n public static int CompareTo(this T[] A, T[] B, Comparison cmp = null) { cmp = cmp ?? Comparer.Default.Compare; for (var i = 0; i < Min(A.Length, B.Length); i++) { int c = cmp(A[i], B[i]); if (c > 0) return 1; else if (c < 0) return -1; } if (A.Length == B.Length) return 0; if (A.Length > B.Length) return 1; else return -1; }\n public static int ArgMax(this IList A, Comparison cmp = null) { cmp = cmp ?? Comparer.Default.Compare; T max = A[0]; int rt = 0; for (int i = 1; i < A.Count; i++) if (cmp(max, A[i]) < 0) { max = A[i]; rt = i; } return rt; }\n public static T PopBack(this List A) { var v = A[A.Count - 1]; A.RemoveAt(A.Count - 1); return v; }\n public static void Fail(T s) { Console.WriteLine(s); Console.Out.Close(); Environment.Exit(0); }\n}\npublic class Scanner\n{\n public string Str => Console.ReadLine().Trim();\n public int Int => int.Parse(Str);\n public long Long => long.Parse(Str);\n public double Double => double.Parse(Str);\n public int[] ArrInt => Str.Split(' ').Select(int.Parse).ToArray();\n public long[] ArrLong => Str.Split(' ').Select(long.Parse).ToArray();\n public char[][] Grid(int n) => Create(n, () => Str.ToCharArray());\n public int[] ArrInt1D(int n) => Create(n, () => Int);\n public long[] ArrLong1D(int n) => Create(n, () => Long);\n public int[][] ArrInt2D(int n) => Create(n, () => ArrInt);\n public long[][] ArrLong2D(int n) => Create(n, () => ArrLong);\n private Queue q = new Queue();\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public T Next() { if (q.Count == 0) foreach (var item in Str.Split(' ')) q.Enqueue(item); return (T)Convert.ChangeType(q.Dequeue(), typeof(T)); }\n public void Make(out T1 v1) => v1 = Next();\n public void Make(out T1 v1, out T2 v2) { v1 = Next(); v2 = Next(); }\n public void Make(out T1 v1, out T2 v2, out T3 v3) { Make(out v1, out v2); v3 = Next(); }\n public void Make(out T1 v1, out T2 v2, out T3 v3, out T4 v4) { Make(out v1, out v2, out v3); v4 = Next(); }\n public void Make(out T1 v1, out T2 v2, out T3 v3, out T4 v4, out T5 v5) { Make(out v1, out v2, out v3, out v4); v5 = Next(); }\n public void Make(out T1 v1, out T2 v2, out T3 v3, out T4 v4, out T5 v5, out T6 v6) { Make(out v1, out v2, out v3, out v4, out v5); v6 = Next(); }\n public void Make(out T1 v1, out T2 v2, out T3 v3, out T4 v4, out T5 v5, out T6 v6, out T7 v7) { Make(out v1, out v2, out v3, out v4, out v5, out v6); v7 = Next(); }\n public (T1, T2) Make() { Make(out T1 v1, out T2 v2); return (v1, v2); }\n public (T1, T2, T3) Make() { Make(out T1 v1, out T2 v2, out T3 v3); return (v1, v2, v3); }\n public (T1, T2, T3, T4) Make() { Make(out T1 v1, out T2 v2, out T3 v3, out T4 v4); return (v1, v2, v3, v4); }\n}\n\n#endregion", "lang_cluster": "C#", "tags": ["constructive algorithms", "graphs"], "code_uid": "c450a7988c1ea7eb6035e54e9ac3f4ff", "src_uid": "daf0dd781bf403f7c1bb668925caa64d", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\n\nnamespace G6\n{\n class Program\n {\n static void Main(string[] args)\n {\n long n, m;\n string[] sins = Console.ReadLine().Trim(' ').Split(' ');\n n = long.Parse(sins[0]);\n m = long.Parse(sins[1]);\n\n if (n != 1)\n {\n if (m != 0)\n {\n long summ = 1;\n long answerMax = n - 2;\n for (int i = 2; i <= n; i++)\n {\n if (summ < m)\n {\n answerMax--;\n }\n else\n {\n break;\n }\n summ += i;\n }\n\n long AnswerMin = 0;\n if (n % 2 == 0)\n {\n if (m < n / 2)\n AnswerMin = n - m * 2;\n }\n else\n {\n if (m < (n + 1) / 2)\n AnswerMin = n - m * 2;\n }\n Console.Write(AnswerMin + \" \" + answerMax);\n }\n else\n {\n Console.Write(n + \" \" + n);\n }\n }\n else\n {\n Console.Write(\"1 1\");\n }\n //Console.ReadKey();\n }\n }\n}", "lang_cluster": "C#", "tags": ["constructive algorithms", "graphs"], "code_uid": "071256cf2342ef2e957c4e7ad19ee4d7", "src_uid": "daf0dd781bf403f7c1bb668925caa64d", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\n\nnamespace ConsoleApp7\n{\n class Program\n {\n static void Main(string[] args)\n {\n var n = Console.ReadLine().Int();\n var a = Console.ReadLine().Int();\n var b = Console.ReadLine().Int();\n var c = Console.ReadLine().Int();\n int total = 0;\n int ate = 1;\n if (n == ate)\n {\n Console.WriteLine(0);\n return;\n }\n var l = new List\n {\n a,\n b,\n c\n };\n\n l = l.OrderBy(u => u).ToList();\n if (l[0] == a || l[0] == b)\n {\n n -= 1;\n Console.WriteLine(n * l[0]);\n }\n else\n {\n n -= 2;\n total += Math.Min(a, b);\n Console.WriteLine(total + n * l[0]);\n }\n }\n }\n static class H\n {\n public static int Int(this string str)\n {\n return int.Parse(str);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math"], "code_uid": "558b987d46dd73f108711d3ced3ce51b", "src_uid": "6058529f0144c853e9e17ed7c661fc50", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Diagnostics;\nusing System.IO;\nusing System.Linq;\nusing System.Numerics;\n\nnamespace CodeforcesTemplate\n{\n class Program\n {\n private const string FILENAME = \"distance4\";\n\n private const string INPUT = FILENAME + \".in\";\n\n private const string OUTPUT = FILENAME + \".out\";\n\n private static Stopwatch _stopwatch = new Stopwatch();\n\n private static StreamReader _reader = null;\n private static StreamWriter _writer = null;\n\n private static string[] _curLine;\n private static int _curTokenIdx;\n\n private static char[] _whiteSpaces = new char[] { ' ', '\\t', '\\r', '\\n' };\n\n private static string ReadNextToken()\n {\n if (_curTokenIdx >= _curLine.Length)\n {\n //Read next line\n string line = _reader.ReadLine();\n if (line != null)\n _curLine = line.Split(_whiteSpaces, StringSplitOptions.RemoveEmptyEntries);\n else\n _curLine = new string[] { };\n _curTokenIdx = 0;\n }\n\n if (_curTokenIdx >= _curLine.Length)\n return null;\n\n return _curLine[_curTokenIdx++];\n }\n\n private static int ReadNextInt()\n {\n return int.Parse(ReadNextToken());\n }\n\n private static void RunTimer()\n {\n#if (DEBUG)\n\n _stopwatch.Start();\n\n#endif\n }\n\n private static void Main(string[] args)\n {\n\n#if (DEBUG)\n double before = GC.GetTotalMemory(false);\n#endif\n int k, i = 0, s = 1, sum = 0, p = 1;\n\n int n = int.Parse(Console.ReadLine());\n\n int ks = int.Parse(Console.ReadLine());\n\n int ko = int.Parse(Console.ReadLine());\n\n int so = int.Parse(Console.ReadLine());\n\n while (s != n)\n {\n if (p == 1)\n {\n if (ks < ko)\n {\n sum = sum + ks;\n s++;\n p = 3;\n }\n else\n {\n sum = sum + ko;\n s++;\n p = 2;\n }\n }\n\n else if (p == 2)\n {\n if (ko < so)\n {\n sum = sum + ko;\n s++;\n p = 1;\n }\n\n else\n {\n sum = sum + so;\n s++;\n p = 3;\n }\n }\n\n else if (p == 3)\n {\n if (so < ks)\n {\n sum = sum + so;\n s++;\n p = 2;\n }\n else\n {\n sum = sum + ks;\n s++;\n p = 1;\n }\n }\n\n }\n\n Console.WriteLine(sum);\n\n\n\n\n#if (DEBUG)\n _stopwatch.Stop();\n\n double after = GC.GetTotalMemory(false);\n\n double consumedInMegabytes = (after - before) / (1024 * 1024);\n\n Console.WriteLine($\"Time elapsed: {_stopwatch.Elapsed}\");\n\n Console.WriteLine($\"Consumed memory (MB): {consumedInMegabytes}\");\n\n Console.ReadKey();\n#endif\n\n\n }\n\n private static int CountLeadZeros(string source)\n {\n int countZero = 0;\n\n for (int i = source.Length - 1; i >= 0; i--)\n {\n if (source[i] == '0')\n {\n countZero++;\n }\n\n else\n {\n break;\n }\n\n }\n\n return countZero;\n }\n\n private static string ReverseString(string source)\n {\n char[] reverseArray = source.ToCharArray();\n\n Array.Reverse(reverseArray);\n\n string reversedString = new string(reverseArray);\n\n return reversedString;\n }\n\n\n private static int[] CopyOfRange(int[] src, int start, int end)\n {\n int len = end - start;\n int[] dest = new int[len];\n Array.Copy(src, start, dest, 0, len);\n return dest;\n }\n\n private static string StreamReader()\n {\n\n if (_reader == null)\n _reader = new StreamReader(INPUT);\n string response = _reader.ReadLine();\n if (_reader.EndOfStream)\n _reader.Close();\n return response;\n\n\n }\n\n private static void StreamWriter(string text)\n {\n\n if (_writer == null)\n _writer = new StreamWriter(OUTPUT);\n _writer.WriteLine(text);\n\n\n }\n\n\n\n\n\n private static int BFS(int start, int end, int[,] arr)\n {\n Queue> queue = new Queue>();\n List visited = new List();\n for (int i = 0; i < arr.GetLength(0); i++)\n {\n visited.Add(false);\n }\n\n queue.Enqueue(new KeyValuePair(start, 0));\n KeyValuePair node;\n int level = 0;\n bool flag = false;\n\n while (queue.Count != 0)\n {\n node = queue.Dequeue();\n if (node.Key == end)\n {\n return node.Value;\n }\n flag = false;\n for (int i = 0; i < arr.GetLength(0); i++)\n {\n\n if (arr[node.Key, i] == 1)\n {\n if (visited[i] == false)\n {\n if (!flag)\n {\n level = node.Value + 1;\n flag = true;\n }\n queue.Enqueue(new KeyValuePair(i, level));\n visited[i] = true;\n }\n }\n }\n\n }\n return 0;\n\n }\n\n\n\n private static void Write(string source)\n {\n File.WriteAllText(OUTPUT, source);\n }\n\n private static string ReadString()\n {\n return File.ReadAllText(INPUT);\n }\n\n private static void WriteStringArray(string[] source)\n {\n File.WriteAllLines(OUTPUT, source);\n }\n\n private static string[] ReadStringArray()\n {\n return File.ReadAllLines(INPUT);\n }\n\n private static int[] GetIntArray()\n {\n return ReadString().Split(' ').Select(int.Parse).ToArray();\n }\n\n private static double[] GetDoubleArray()\n {\n return ReadString().Split(' ').Select(double.Parse).ToArray();\n }\n\n private static int[,] ReadINT2XArray(List lines)\n {\n int[,] arr = new int[lines.Count, lines.Count];\n\n for (int i = 0; i < lines.Count; i++)\n {\n int[] row = lines[i].Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(int.Parse).ToArray();\n\n for (int j = 0; j < lines.Count; j++)\n {\n arr[i, j] = row[j];\n }\n }\n\n return arr;\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math"], "code_uid": "c1cd0742ab9739bc710aa00bb0ca6470", "src_uid": "6058529f0144c853e9e17ed7c661fc50", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Text;\nusing System.Collections.Generic;\nusing System.Linq;\nclass Solve{\n public Solve(){}\n StringBuilder sb;\n ReadData re;\n public static int Main(){\n new Solve().Run();\n return 0;\n }\n void Run(){\n sb = new StringBuilder();\n re = new ReadData();\n Calc();\n Console.Write(sb.ToString());\n }\n void Calc(){\n int K = re.i();\n int A = 0;\n for(int i=0;i[] g(int N,int[] f,int[] t){\n List[] ans = new List[N];\n for(int j=0;j();\n }\n for(int j=0;j[] g(int N,int M){\n List[] ans = new List[N];\n for(int j=0;j();\n }\n for(int j=0;j[] g(){\n int N = i();\n int M = i();\n List[] ans = new List[N];\n for(int j=0;j();\n }\n for(int j=0;j int.Parse(s)).ToArray();\n int max = r.Max();\n if (max > 25)\n Console.WriteLine(max - 25);\n else\n Console.WriteLine(0);\n }\n }\n}", "lang_cluster": "C#", "tags": ["greedy", "implementation"], "code_uid": "4af21fc1e03e3fcc54bf5636d1b043d4", "src_uid": "ef657588b4f2fe8b2ff5f8edc0ab8afd", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.IO;\nusing System.Linq;\nusing System.Text;\nusing System.Globalization;\n\nnamespace CodeforcesSolution\n{\n class ProgramCF\n {\n static ConsoleInput inp;\n static void Main( string[] args )\n {\n try\n {\n if ( File.Exists( @\"d:\\zin.txt\" ) )\n Console.SetIn( new StreamReader( @\"d:\\zin.txt\" ) );\n }\n catch\n {\n }\n inp = new ConsoleInput();\n inp.ReadAll();\n\n int N = inp.NextInt();\n List f = new List();\n\n for ( int i = 0; i < N; i++ )\n {\n f.Add( 1 );\n while ( f.Count > 1 )\n {\n if ( f[f.Count - 1] == f[f.Count - 2] )\n {\n f.RemoveAt( f.Count - 1 );\n f[f.Count - 1] += 1;\n }\n else\n break;\n }\n }\n Console.WriteLine( string.Join( \" \", f.Select( n => n.ToString() ).ToArray() ) );\n\n // end here\n // ====\n //WriteLine ( \"\" );\n }\n\n private static bool IsPalindromic( long n )\n {\n string s = n.ToString();\n for ( int i = 0; i < s.Length; i++ )\n {\n int j = s.Length - i - 1;\n if ( s[i] != s[j] )\n return false;\n }\n return true;\n //string srev = new string ( s.ToCharArray ( ).Reverse ( ).ToArray ( ) );\n //return ( s.Equals ( srev ) );\n }\n\n //====================================================//\n private static void WriteLine( params object[] value )\n {\n Console.WriteLine( string.Format( CultureInfo.InvariantCulture, \"{0}\", value ) );\n }\n\n class ConsoleInput\n {\n List lines = new List();\n int idx = 0;\n\n public void ReadAll()\n {\n while ( true )\n {\n string line = Console.ReadLine();\n if ( line == null )\n break;\n lines.AddRange( line.Split( ' ' ) );\n }\n }\n\n public string NextString()\n {\n return lines[idx++];\n }\n\n public int NextInt()\n {\n return int.Parse( lines[idx++] );\n }\n\n public long NextLong()\n {\n return long.Parse( lines[idx++] );\n }\n\n public double NextDouble()\n {\n return double.Parse( lines[idx++] );\n }\n\n }\n\n }\n}", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "154ec9b38c6374c2f31f87e525697f5a", "src_uid": "757cd804aba01dc4bc108cb0722f68dc", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Linq;\nusing System.Collections.Generic;\n//using System.Numerics;\nusing Debug = System.Diagnostics.Debug;\nusing SB = System.Text.StringBuilder;\nusing Number = System.Int64;\nnamespace Program {\n public class Solver {\n public void Solve() {\n var n = ri;\n var a = new List();\n for (int i = 20; i >= 0; i--)\n if ((n >> i & 1) == 1) {\n a.Add(i + 1);\n }\n Console.WriteLine(a.AsJoinedString());\n\n }\n const long INF = 1L << 60;\n int[] dx = { -1, 0, 1, 0 };\n int[] dy = { 0, 1, 0, -1 };\n\n int ri { get { return sc.Integer(); } }\n long rl { get { return sc.Long(); } }\n double rd { get { return sc.Double(); } }\n string rs { get { return sc.Scan(); } }\n public IO.StreamScanner sc = new IO.StreamScanner(Console.OpenStandardInput());\n\n static T[] Enumerate(int n, Func f) {\n var a = new T[n];\n for (int i = 0; i < n; ++i) a[i] = f(i);\n return a;\n }\n\n static public void Swap(ref T a, ref T b) {\n var tmp = a;\n a = b;\n b = tmp;\n }\n }\n}\n\n#region main\n\nstatic class Ex {\n static public string AsString(this IEnumerable ie) {\n return new string(ie.ToArray());\n }\n\n static public string AsJoinedString(this IEnumerable ie, string st = \" \") {\n return string.Join(st, ie.Select(x => x.ToString()).ToArray());\n //return string.Join(st, ie);\n }\n\n static public void Main() {\n Console.SetOut(new Program.IO.Printer(Console.OpenStandardOutput()) { AutoFlush = false });\n var solver = new Program.Solver();\n solver.Solve();\n Console.Out.Flush();\n }\n}\n\n#endregion\n#region Ex\n\nnamespace Program.IO {\n using System.IO;\n using System.Text;\n using System.Globalization;\n\n public class Printer: StreamWriter {\n public override IFormatProvider FormatProvider {\n get { return CultureInfo.InvariantCulture; }\n }\n public Printer(Stream stream) : base(stream, new UTF8Encoding(false, true)) { }\n }\n\n public class StreamScanner {\n public StreamScanner(Stream stream) {\n str = stream;\n }\n\n public readonly Stream str;\n private readonly byte[] buf = new byte[1024];\n private int len, ptr;\n public bool isEof = false;\n public bool IsEndOfStream {\n get { return isEof; }\n }\n\n private byte read() {\n if (isEof) return 0;\n if (ptr >= len) {\n ptr = 0;\n if ((len = str.Read(buf, 0, 1024)) <= 0) {\n isEof = true;\n return 0;\n }\n }\n return buf[ptr++];\n }\n\n public char Char() {\n byte b = 0;\n do b = read(); while ((b < 33 || 126 < b) && !isEof);\n return (char)b;\n }\n\n public string Scan() {\n var sb = new StringBuilder();\n for (var b = Char(); b >= 33 && b <= 126; b = (char)read()) sb.Append(b);\n return sb.ToString();\n }\n\n public string ScanLine() {\n var sb = new StringBuilder();\n for (var b = Char(); b != '\\n' && b != 0; b = (char)read()) if (b != '\\r') sb.Append(b);\n return sb.ToString();\n }\n\n public long Long() {\n return isEof ? long.MinValue : long.Parse(Scan());\n }\n\n public int Integer() {\n return isEof ? int.MinValue : int.Parse(Scan());\n }\n\n public double Double() {\n return isEof ? double.NaN : double.Parse(Scan(), CultureInfo.InvariantCulture);\n }\n }\n}\n\n#endregion\n\n\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "7c5d43d145d857c6e38387e40ec7033c", "src_uid": "757cd804aba01dc4bc108cb0722f68dc", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": ".NET Core C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing CompLib.Util;\nusing System.Threading;\n\npublic class Program\n{\n public void Solve()\n {\n var sc = new Scanner();\n long n = sc.NextLong();\n int k = sc.NextInt();\n List div = new List();\n for (long i = 1; i * i <= n; i++)\n {\n if (n % i == 0)\n {\n div.Add(i);\n if (n / i != i) div.Add(n / i);\n }\n }\n\n if (div.Count < k)\n {\n Console.WriteLine(\"-1\");\n return;\n }\n\n div.Sort();\n\n Console.WriteLine(div[k - 1]);\n }\n\n public static void Main(string[] args) => new Program().Solve();\n // public static void Main(string[] args) => new Thread(new Program().Solve, 1 << 27).Start();\n}\n\nnamespace CompLib.Util\n{\n using System;\n using System.Linq;\n\n class Scanner\n {\n private string[] _line;\n private int _index;\n private const char Separator = ' ';\n\n public Scanner()\n {\n _line = new string[0];\n _index = 0;\n }\n\n public string Next()\n {\n if (_index >= _line.Length)\n {\n string s;\n do\n {\n s = Console.ReadLine();\n } while (s.Length == 0);\n\n _line = s.Split(Separator);\n _index = 0;\n }\n\n return _line[_index++];\n }\n\n public string ReadLine()\n {\n _index = _line.Length;\n return Console.ReadLine();\n }\n\n public int NextInt() => int.Parse(Next());\n public long NextLong() => long.Parse(Next());\n public double NextDouble() => double.Parse(Next());\n public decimal NextDecimal() => decimal.Parse(Next());\n public char NextChar() => Next()[0];\n public char[] NextCharArray() => Next().ToCharArray();\n\n public string[] Array()\n {\n string s = Console.ReadLine();\n _line = s.Length == 0 ? new string[0] : s.Split(Separator);\n _index = _line.Length;\n return _line;\n }\n\n public int[] IntArray() => Array().Select(int.Parse).ToArray();\n public long[] LongArray() => Array().Select(long.Parse).ToArray();\n public double[] DoubleArray() => Array().Select(double.Parse).ToArray();\n public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();\n }\n}", "lang_cluster": "C#", "tags": ["math", "number theory"], "code_uid": "5d36ec02b412cfadc7926d22161f37db", "src_uid": "6ba39b428a2d47b7d199879185797ffb", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\n\nnamespace \u0430\u0430\u0430\n{\n class Program\n {\n static void Main(string[] args)\n {\n string[] num = Console.ReadLine().Split(' ');\n Int64 n = Int64.Parse(num[0]);\n Int32 k = Int32.Parse(num[1]);\n Int64 End =Convert.ToInt64(Math.Sqrt(n));\n List spisok = new List();\n for (int i = 1; i <= End; i++)\n {\n if (n%i==0)\n {\n spisok.Add(i);\n if (i != (n / i))\n {\n spisok.Add(n / i);\n }\n } \n }\n if (spisok.Count < k)\n {\n Console.WriteLine(-1);\n }\n else\n {\n spisok.Sort();\n Console.WriteLine(spisok.ElementAt(k-1));\n }\n\n // Console.ReadKey();\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "number theory"], "code_uid": "776a4915abc35b1fd7053e88676c967e", "src_uid": "6ba39b428a2d47b7d199879185797ffb", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\n\nnamespace TaskD\n{\n class Program\n {\n static void Main(string[] args)\n {\n int n = int.Parse(Console.ReadLine());\n switch (n)\n {\n case 1: { Console.Write(\"2\"); break; }\n case 2: { Console.Write(\"3\"); break; }\n case 3: { Console.Write(\"1\"); break; }\n case 4: { Console.Write(\"2\"); break; }\n case 5: { Console.Write(\"1\"); break; }\n }\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force"], "code_uid": "52e8a65b5262383b835c555f4d5d6646", "src_uid": "c702e07fed684b7741d8337aafa005fb", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\n\nnamespace _171D\n{\n class Program\n {\n static void Main()\n {\n var n = int.Parse(Console.ReadLine());\n switch(n)\n {\n case 1:\n Console.WriteLine(2);\n break;\n case 2:\n Console.WriteLine(3);\n break;\n case 3:\n Console.WriteLine(1);\n break;\n case 4:\n Console.WriteLine(2);\n break;\n case 5:\n Console.WriteLine(1);\n break;\n }\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force"], "code_uid": "2ad2fbd364ce0c42f9a33fe4ec2e4473", "src_uid": "c702e07fed684b7741d8337aafa005fb", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace TaskA\n{\n class Program\n {\n static void Main(string[] args)\n {\n var input = Console.ReadLine().Split(' ');\n int t = int.Parse(input[0]);\n int s = int.Parse(input[1]);\n int x = int.Parse(input[2]);\n\n if (x < t)\n {\n Console.WriteLine(\"NO\");\n return;\n }\n\n if (t == x)\n {\n Console.WriteLine(\"YES\");\n return;\n }\n\n int dif = x - t;\n\n if (dif % s == 0 || ((dif - 1) > 0 && (dif - 1) % s == 0))\n {\n Console.WriteLine(\"YES\");\n return;\n }\n\n\n Console.WriteLine(\"NO\");\n Console.ReadLine();\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "implementation"], "code_uid": "7643a65df60cd30aa3dda5a253095d42", "src_uid": "3baf9d841ff7208c66f6de1b47b0f952", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace _697A\n{\n class Program\n {\n static void Main(string[] args)\n {\n string[] input = Console.ReadLine().Split(' ');\n decimal t = decimal.Parse(input[0]), s = decimal.Parse(input[1]), x = decimal.Parse(input[2]);\n decimal k1 = (x - t) / s;\n decimal k2 = (x - t - 1) / s;\n bool result = (k1 >= 0 && decimal.Compare(k1, Math.Truncate(k1)) == 0) ||\n (k2 >= 1 && decimal.Compare(k2, Math.Truncate(k2)) == 0);\n Console.WriteLine(result ? \"YES\" : \"NO\");\n //Console.ReadLine();\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "implementation"], "code_uid": "3bf7367158a0fe6177fdacdeeda9671a", "src_uid": "3baf9d841ff7208c66f6de1b47b0f952", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\n\n\nclass Scanner\n{\n string[] s;\n int i;\n\n char[] cs = new char[] { ' ' };\n\n public Scanner()\n {\n s = new string[0];\n i = 0;\n }\n\n public string next()\n {\n if (i < s.Length) return s[i++];\n s = Console.ReadLine().Split(cs, StringSplitOptions.RemoveEmptyEntries);\n i = 0;\n return s[i++];\n }\n\n public int nextInt()\n {\n return int.Parse(next());\n }\n\n public long nextLong()\n {\n return long.Parse(next());\n }\n\n}\n\nclass Myon\n{\n Scanner cin;\n Myon() { }\n\n public static void Main()\n {\n new Myon().calc();\n }\n\n int h, w;\n string[] s;\n int[,] num;\n int[,] usedcount;\n int count;\n int prenum = 0;\n\n void calc()\n {\n Scanner cin = new Scanner();\n int n, R, r;\n n = cin.nextInt();\n R = cin.nextInt();\n r = cin.nextInt();\n if (R < r)\n {\n Console.WriteLine(\"NO\");\n return;\n }\n else if (n == 1)\n {\n Console.WriteLine(\"YES\");\n return;\n }\n else if (R < 2 * r)\n {\n Console.WriteLine(\"NO\");\n return;\n }\n else if (R == 2 * r)\n {\n if (n <= 2) Console.WriteLine(\"YES\");\n else Console.WriteLine(\"NO\");\n return;\n }\n double length = r * (R / 2.0) / (R / 2.0 - r / 2.0);\n double len2 = Math.Sqrt(2 * (R / 2.0) * (R / 2.0) - 2 * (R / 2.0) * (R / 2.0) * Math.Cos(Math.PI * 2 / n));\n //Console.WriteLine(length + \" \" + len2);\n if (length <= len2) Console.WriteLine(\"YES\");\n else Console.WriteLine(\"NO\");\n }\n\n\n}\n", "lang_cluster": "C#", "tags": ["math", "geometry"], "code_uid": "896fc5bdcf0f57ea9880787a2b2f1288", "src_uid": "2fedbfccd893cde8f2fab2b5bf6fb6f6", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\n\nnamespace A\n{\n class Program\n {\n static void Main(string[] args)\n {\n string s = Console.ReadLine();\n int[] arr = s.Split(' ').Select(str => int.Parse(str)).ToArray();\n\n int n = arr[0];\n double R = arr[1];\n double r = arr[2];\n\n //double midle = 2.0 * Math.PI * (R - r);\n //int maxCount = (int)(midle / (2.0 * r));\n\n double alfa = Math.Asin(r / (R - r));\n int maxCount = int.MaxValue;\n\n if (Double.IsNaN(alfa))\n {\n maxCount = 0;\n }\n else if (alfa != 0)\n {\n //maxCount = (int)Math.Round((Math.PI / alfa), MidpointRounding.AwayFromZero);\n maxCount = (int)((Math.PI / alfa) + 1e-6);\n }\n\n bool onePlate = (n == 1 && r <= R);\n\n if (n <= maxCount || onePlate)\n {\n Console.WriteLine(\"YES\");\n }\n else\n {\n Console.WriteLine(\"NO\");\n }\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "geometry"], "code_uid": "86ec28c066ef558649010846fbfc1e0b", "src_uid": "2fedbfccd893cde8f2fab2b5bf6fb6f6", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\n\nnamespace ConsoleApplication1\n{\n class Program\n {\n static void Main(string[] args)\n {\n string[] s1 = Console.ReadLine().Split(' ');\n int t = Int32.Parse(s1[0]);\n int s = Int32.Parse(s1[1]);\n double q = Int32.Parse(s1[2]);\n\n int count = 1;\n double memory = s;\n double tmp = s;\n\n while (t > 0)\n {\n memory += tmp * (q - 1);\n if (memory >= t)\n break;\n else\n {\n count++;\n tmp = memory;\n }\n }\n Console.WriteLine(count);\n //Console.ReadKey();\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "implementation"], "code_uid": "f85059887070d30313dd6c5c3bd9587e", "src_uid": "0d01bf286fb2c7950ce5d5fa59a17dd9", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.IO;\nusing System.Text;\n\nnamespace ConsoleApplication1\n{\n public static class MainClass\n {\n const int BufferSize = (1 << 10) * 10;\n\n static readonly StreamReader Reader = new StreamReader(Console.OpenStandardInput(BufferSize), Encoding.ASCII, false, BufferSize);\n static readonly StreamWriter Writer = new StreamWriter(Console.OpenStandardOutput(BufferSize), Encoding.ASCII, BufferSize, false);\n\n static void Main(string[] args)\n {\n var array = ReadArray();\n var repeats = 0;\n\n while (array[1] < array[0])\n {\n array[1] *= array[2];\n repeats++;\n }\n\n Writer.WriteLine(repeats);\n Writer.Flush();\n }\n\n public static int ReadNumber()\n {\n return int.Parse(Reader.ReadLine());\n }\n\n public static long ReadLongNumber()\n {\n return long.Parse(Reader.ReadLine());\n }\n\n public static int[] ReadArray()\n {\n var inputLine = Reader.ReadLine().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);\n\n var resultArray = new int[inputLine.Length];\n for (var i = 0; i < inputLine.Length; i++)\n {\n resultArray[i] = int.Parse(inputLine[i]);\n }\n\n return resultArray;\n }\n }\n}", "lang_cluster": "C#", "tags": ["math", "implementation"], "code_uid": "248ee245669f8bcb3cb28b95a46a8ac3", "src_uid": "0d01bf286fb2c7950ce5d5fa59a17dd9", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\n\n\npublic class Song\n{\n public int Length { get; set; }\n public int Beauty { get; set; }\n\n public Song(int length, int beauty)\n {\n Length = length;\n Beauty = beauty;\n }\n}\n\npublic class Test\n{\n\n private static int ReadInt()\n {\n return Convert.ToInt32(Console.ReadLine());\n }\n\n private static long ReadLong()\n {\n return Convert.ToInt64(Console.ReadLine());\n }\n\n private static string ReadString()\n {\n return Console.ReadLine();\n }\n\n private static int[] ReadArray()\n {\n return Array.ConvertAll(Console.ReadLine().Split(' '), m => Convert.ToInt32(m));\n }\n public static void Main()\n {\n\n int N = ReadInt();\n\n int ans = 0;\n for(int i = 2; i < N; i++)\n {\n ans += i * (i + 1);\n }\n\n Console.WriteLine(ans);\n\n\n\n\n }\n\n}\n", "lang_cluster": "C#", "tags": ["math", "greedy", "dp"], "code_uid": "789e9b6d8df0a1c99afb7bc39388b646", "src_uid": "1bd29d7a8793c22e81a1f6fd3991307a", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\n\nclass _1140D\n{\n\tstatic void Main()\n\t{\n\t\tint n = int.Parse(Console.ReadLine());\n\n\t\tint ans = 0;\n\t\tfor (int i = 0; i < n - 2; ++i)\n\t\t{\n\t\t\tans += (i + 2) * (i + 3);\n\t\t}\n\t\tConsole.WriteLine(ans);\n\t}\n}", "lang_cluster": "C#", "tags": ["math", "greedy", "dp"], "code_uid": "6359cae271975739b277ec55426ef330", "src_uid": "1bd29d7a8793c22e81a1f6fd3991307a", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\n\nnamespace CodeF1\n{\n class Program\n {\n private static bool Need(String s1, String s2)\n {\n var b = new bool[s1.Length];\n for (int i = 0; i < s2.Length; i++)\n {\n bool cont = false;\n for (int j = 0; j < s1.Length; j++)\n {\n if (!b[j] && s1[j] == s2[i])\n {\n b[j] = true;\n\n cont = true;\n break;\n }\n }\n if (!cont) return false;\n }\n return true;\n }\n\n\n\n private static bool NeedB(String s1, String s2)\n {\n var b = new bool[s1.Length];\n var JJ = 0;\n for (int i = 0; i < s2.Length; i++)\n {\n bool cont = false;\n for (int j = JJ; j < s1.Length; j++)\n {\n JJ++;\n if (!b[j] && s1[j] == s2[i])\n {\n b[j] = true;\n\n cont = true;\n break;\n }\n }\n if (!cont) return false;\n }\n return true;\n }\n\n static void Main()\n {\n\n var str1 = Console.ReadLine();\n var str2 = Console.ReadLine();\n if (!Need(str1, str2))\n {\n Console.WriteLine(\"need tree\");\n return;\n }\n\n\n bool auto = false;\n bool array = false;\n if (str1.Length != str2.Length)\n {\n auto = true;\n }\n\n if (!NeedB(str1, str2))\n {\n array = true;\n }\n\n\n if (array && auto)\n {\n Console.WriteLine(\"both\");\n return;\n }\n\n if (auto)\n {\n Console.WriteLine(\"automaton\");\n return;\n }\n\n if (array)\n {\n Console.WriteLine(\"array\");\n }\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["strings", "implementation"], "code_uid": "ef45247b103b057ef757c11885ab0276", "src_uid": "edb9d51e009a59a340d7d589bb335c14", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace ConsoleApplication1\n{\n public class Program\n {\n public static void Main()\n {\n string startString, endString;\n int original_Length, StartStrLength, i = 0;\n bool possible = true, automaton = true;\n\n startString = Console.ReadLine();\n endString = Console.ReadLine();\n\n original_Length = endString.Length;\n StartStrLength = startString.Length;\n\n //loop checks to see if our letters are in order even if there are extra ones\n //used for cases like \"abacaba\" with \"aaaa\", so code says automaton and not \"both\"\n for (int j = 0; j < original_Length - 1; ++j)\n {\n if (i >= StartStrLength - 1)\n break;\n //search for letter, and make sure next letter is farther down from where we found previous one\n if (startString.IndexOf(endString[j], i) > startString.IndexOf(endString[j + 1], startString.IndexOf(endString[j],i) + 1))\n {\n automaton = false;\n break;\n }\n i = startString.IndexOf(endString[j], i) + 1;\n }\n\n if (original_Length > startString.Length)\n Console.WriteLine(\"need tree\");\n else\n {\n if (startString.IndexOf(endString) != -1)\n Console.WriteLine(\"automaton\");\n else\n {\n while (endString.Length != 0)\n {\n //makes sure our starting string has enough of specific characters for end string\n if (endString.Count(n => n == endString[0]) > startString.Count(n => n == endString[0]))\n {\n possible = false;\n break;\n }\n //gets rid of character just checked so we don't count the times a character appeared twice\n endString = endString.Replace(Convert.ToString(endString[0]), \"\");\n }\n\n if (possible && original_Length == startString.Length)\n Console.WriteLine(\"array\");\n else if (possible && automaton)\n Console.WriteLine(\"automaton\");\n else if (possible)\n Console.WriteLine(\"both\");\n else\n Console.WriteLine(\"need tree\");\n }\n }\n } \n }\n}\n", "lang_cluster": "C#", "tags": ["strings", "implementation"], "code_uid": "3eeb56e0e1bdf19e8580b82b74a459d8", "src_uid": "edb9d51e009a59a340d7d589bb335c14", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections;\nusing System.Collections.Generic;\nusing System.Collections.Specialized;\nusing System.Text;\nusing System.Text.RegularExpressions;\nusing System.Linq;\n\npublic class EllysCheckers\n{\n public static int [] time(string t)\n {\n int [] res = new int[t.Length];\n for (int i = 0; i < t.Length; i++) {\n \n if(t[t.Length - i - 1]>='A' && t[t.Length - i - 1] <= 'Z')\n {\n res[i] = (int)t[t.Length - i - 1] - 55; \n }\n else\n {\n res[i] = int.Parse(t[t.Length - i - 1].ToString());\n }\n }\n return res;\n \n }\n public static bool check(int[] t, int s, bool type )\n {\n int z = 1;\n int ans = 0;\n for (int i = 0; i < t.Length; i++) {\n if(t[i] >= s)\n return false;\n ans += t[i] * z;\n z *= s;\n }\n if(type)\n if(ans >= 24)\n return false;\n else \n return true;\n else\n if(ans >= 60)\n return false;\n else \n return true;\n }\n public static void Main(string[] args)\n {\n string []str = Console.ReadLine().Split(':').ToArray();\n string hour = str[0];\n string min = str[1];\n int [] h = time(hour);\n int [] m = time(min);\n if(check(h, 61, true) && check(m, 61, false))\n {\n Console.WriteLine (-1);\n return;\n }\n List ans = new List();\n for (int i = 2; i <=60; i++) {\n if(check(h, i, true) && check(m, i, false))\n ans.Add(i);\n }\n if(ans.Count == 0)\n Console.WriteLine (0);\n else\n {\n string pr = \"\";\n foreach (var item in ans) {\n Console.Write(pr + item);\n pr = \" \";\n }\n }\n \n \n }\n\n\n}", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "028e81775c60a2b486b91aa2b34f2289", "src_uid": "c02dfe5b8d9da2818a99c3afbe7a5293", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nnamespace ConsoleApp2\n{\n\tclass Program\n\t{\n\t\tstatic int dgt(char c)\n\t\t{\n\t\t\tif ('0' <= c && c <= '9')\n\t\t\t{\n\t\t\t\treturn c - '0';\n\t\t\t}\n\t\t\treturn 10 + c - 'A';\n\t\t}\n\n\n\t\tstatic int to_num(string s, int n)\n\t\t{\n\t\t\tint num = 0;\n\t\t\tint k = 1;\n\t\t\tfor (int i = 1; i <= s.Length; i++)\n\t\t\t{\n\t\t\t\tnum += dgt(s[s.Length - i]) * k;\n\t\t\t\tk *= n;\n\t\t\t}\n\t\t\treturn num;\n\t\t}\n\t\tstatic bool fit(string s1, string s2, int n)\n\t\t{\n\t\t\treturn to_num(s1, n) < 24 && to_num(s2, n) < 60;\n\t\t}\n\n\t\tstatic int get_min(string s)\n\t\t{\n\t\t\tint min = 0;\n\t\t\tfor (int i = 0; i < s.Length; i++)\n\t\t\t{\n\t\t\t\tif (dgt(s[i]) > min)\n\t\t\t\t{\n\t\t\t\t\tmin = dgt(s[i]);\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn min;\n\t\t}\n\n\t\tstatic void Main(string[] args)\n\t\t{\n\t\t\tstring input = Console.ReadLine();\n\t\t\tvar times = input.Split(':');\n\t\t\tint min = Math.Max(get_min(times[0]), get_min(times[1])) + 1;\n\n\t\t\tif (fit(times[0], times[1], 60))\n\t\t\t{\n\t\t\t\tConsole.WriteLine(-1);\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tint i;\n\t\t\t\tfor (i = min; i <= 59; i++)\n\t\t\t\t{\n\t\t\t\t\tif (!fit(times[0], times[1], i))\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tConsole.Write(\"{0} \", i);\n\t\t\t\t}\n\t\t\t\tif (i == min)\n\t\t\t\t\tConsole.WriteLine(0);\n\t\t\t}\n\t\t}\n\t}\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "4dc4857967d5b48cc75b9a1cbaa13e6e", "src_uid": "c02dfe5b8d9da2818a99c3afbe7a5293", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.IO;\nusing System.Text;\n\nnamespace Symmetric_and_Transitive\n{\n internal class Program\n {\n private const int mod = 1000000007;\n private static readonly StreamReader reader = new StreamReader(Console.OpenStandardInput(1024*10), Encoding.ASCII, false, 1024*10);\n private static readonly StreamWriter writer = new StreamWriter(Console.OpenStandardOutput(1024*10), Encoding.ASCII, 1024*10);\n\n private static readonly int[,] C = new int[4000,4000];\n private static readonly long[] a = new long[4001];\n\n private static long GetC(int n, int k)\n {\n if (n < k)\n {\n int c = k;\n k = n;\n n = c;\n }\n if (k == 0 || k == n)\n return 1;\n\n if (C[n, k] != 0)\n return C[n, k];\n\n return C[n, k] = (int)((GetC(n - 1, k - 1) + GetC(n - 1, k))%mod);\n }\n\n private static long A(int n)\n {\n if (n == 1)\n return 1;\n\n if (a[n] == 0)\n {\n //a(n+1) = 1 + sum { j=1, n, (1+binomial(n, j))*a(j)\n a[n] = 1;\n for (int j = 1; j < n; j++)\n {\n a[n] = (a[n] + (1 + GetC(n - 1, j))*A(j))%mod;\n }\n }\n\n return a[n];\n }\n\n private static void Main(string[] args)\n {\n int n = Next();\n writer.WriteLine(A(n)%mod);\n writer.Flush();\n }\n\n private static int Next()\n {\n int c;\n int res = 0;\n do\n {\n c = reader.Read();\n if (c == -1)\n return res;\n } while (c < '0' || c > '9');\n res = c - '0';\n while (true)\n {\n c = reader.Read();\n if (c < '0' || c > '9')\n return res;\n res *= 10;\n res += c - '0';\n }\n }\n }\n}", "lang_cluster": "C#", "tags": ["math", "dp", "combinatorics"], "code_uid": "9eb3a085803e88651b15d1fbb8913941", "src_uid": "aa2c3e94a44053a0d86f61da06681023", "difficulty": 1900.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Text;\n\nnamespace ConsoleApplication10\n{\n \n class Program\n {\n public const int MOD = 1000000007;\n\n static void Main(string[] args)\n {\n int n;\n string str = Console.ReadLine();\n int.TryParse(str, out n);\n int [][] C = new int[n + 1][];\n \n C[0] = new int[1];\n C[0][0] = 1;\n int[] prewrow = C[1] = new int[2];\n prewrow[0] = 1;\n prewrow[1] = 1;\n for (int i = 2; i <= n; i++)\n {\n int[] row = C[i] = new int[i+1];\n row[i] = 1;\n row[0] = 1;\n for(int j = 1; j = n && candidate.ToString().GroupBy(c => c).All(g => g.Count() == d / 2))\n {\n Console.WriteLine(candidate);\n return;\n }\n }\n }\n }\n }\n}", "lang_cluster": "C#", "tags": ["brute force", "binary search", "bitmasks"], "code_uid": "f5d6abc711f9981c27e0280ae8d8356d", "src_uid": "77b5f83cdadf4b0743618a46b646a849", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace Lucky_Numbers\n{\n class Program\n {\n public static UInt64 n = 0;\n static void Main(string[] args)\n {\n UInt64 x1 = UInt64.Parse(Console.ReadLine());\n n=x1;\n Console.WriteLine(recur(0, 0, 0));\n }\n static UInt64 recur( UInt64 x, UInt64 fours, UInt64 sevens)\n {\n if (fours == sevens && x > 0 && x >= n)\n {\n return x;\n }\n else if (x > (1000000000))\n return UInt64.MaxValue;\n {}\n UInt64 x1 = recur(x * 10 + 4, fours + 1, sevens);\n UInt64 x2 = recur(x * 10 + 7, fours , sevens+1);\n return Math.Min(x1, x2);\n\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "binary search", "bitmasks"], "code_uid": "e9a8bb537743f68e3091a1c8fc799359", "src_uid": "77b5f83cdadf4b0743618a46b646a849", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace Codeforces645A\n{\n class Program\n {\n static void Main(string[] args)\n {\n string inp1 = Console.ReadLine();\n string inp2 = Console.ReadLine();\n string inp3 = Console.ReadLine();\n string inp4 = Console.ReadLine();\n\n string exp1 = \"\", exp2 = \"\";\n\n exp1 = inp1.Substring(0, 1) + inp1.Substring(1, 1) + inp2.Substring(1, 1) + inp2.Substring(0, 1);\n exp1 = exp1.Remove(exp1.IndexOf('X'),1);\n int ind = exp1.IndexOf('A');\n if(ind !=0)\n exp1 = exp1.Substring(ind) + exp1.Remove(ind);\n\n exp2 = inp3.Substring(0, 1) + inp3.Substring(1, 1) + inp4.Substring(1, 1) + inp4.Substring(0, 1);\n exp2 = exp2.Remove(exp2.IndexOf('X'),1);\n ind = exp2.IndexOf('A');\n if (ind != 0)\n exp2 = exp2.Substring(ind) + exp2.Remove(ind);\n\n string outp = exp1 == exp2 ? \"YES\" : \"NO\";\n\n Console.WriteLine(outp);\n //inp1 = Console.ReadLine();\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "constructive algorithms", "implementation"], "code_uid": "9e5fe88ad8454608bf3c64876044f0c9", "src_uid": "46f051f58d626587a5ec449c27407771", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Text;\n\nnamespace Codeforces_645\n{\n class Program\n {\n static void Main(string[] args)\n {\n string B = Console.ReadLine(), B2 = Console.ReadLine();\n string E = Console.ReadLine(), E2 = Console.ReadLine();\n B += B2[1]; B += B2[0]; B = B.Replace(\"X\", \"\");\n E += E2[1]; E += E2[0]; E = E.Replace(\"X\", \"\");\n bool b = (B + B).IndexOf(\"AB\") < 0;\n bool e = (E + E).IndexOf(\"AB\") < 0;\n Console.WriteLine(b == e ? \"YES\" : \"NO\");\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "constructive algorithms", "implementation"], "code_uid": "70e6babdffe1bea8a76faa826c2ae98b", "src_uid": "46f051f58d626587a5ec449c27407771", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\n\nnamespace CodeForces\n{\n class R198_Div2_A\n {\n static int GCD(int a, int b)\n {\n if (b == 0) return a;\n return GCD(b, a % b);\n }\n static int LCM(int a, int b)\n {\n return a * b / GCD(a, b);\n }\n\n static void Main(string[] args)\n {\n string[] s = Console.ReadLine().Split();\n int x = int.Parse(s[0]);\n int y = int.Parse(s[1]);\n int a = int.Parse(s[2]);\n int b = int.Parse(s[3]);\n\n int lcm = LCM(x, y);\n int f = -1, l = -1;\n\n f = (a / lcm) * lcm;\n l = (b / lcm) * lcm;\n\n if (f < a) f += lcm;\n int cnt = 0;\n if (f <= l)\n cnt = (l - f) / lcm + 1;\n\n Console.WriteLine(cnt);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math"], "code_uid": "657ee095993fc394f01b20e668b61c9f", "src_uid": "c7aa8a95d5f8832015853cffa1374c48", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Linq;\nusing System.Numerics;\n\nnamespace Codeforces\n{\n\tclass Program\n\t{\n\t\tstatic void Main(string[] args)\n\t\t{\n\t\t\tstring input = Console.ReadLine();\n\t\t\tvar inputs = input.Split(new[] {' '}, StringSplitOptions.RemoveEmptyEntries);\n\n\t\t\tvar numbers = inputs.Select(long.Parse).ToArray();\n\t\t\tvar lcm = LCM(numbers[0], numbers[1]);\n\n\t\t\tConsole.WriteLine(numbers[3] / lcm - (numbers[2] - 1) / lcm);\n\t\t}\n\n\t\tprivate static long GCD(long a, long b)\n\t\t{\n\t\t\tlong max = Math.Max(a, b);\n\t\t\tlong min = Math.Min(a, b);\n\n\t\t\tif (min == 0)\n\t\t\t{\n\t\t\t\treturn max;\n\t\t\t}\n\n\t\t\ta = min;\n\t\t\tb = max % min;\n\t\t\treturn GCD(a, b);\n\t\t}\n\n\t\tprivate static long LCM(long a, long b)\n\t\t{\n\t\t\treturn Math.Abs(a * b) / GCD(a, b);\n\t\t}\n\n\t\t//private static int Length(short[] a)\n\t\t//{\n\t\t//\tint firstItemIndex = 0;\n\t\t//\tfor (int i = 0; i < a.Length; i++)\n\t\t//\t{\n\t\t//\t\tif (a[i] == 0)\n\t\t//\t\t{\n\t\t//\t\t\tcontinue;\n\t\t//\t\t}\n\n\t\t//\t\tfirstItemIndex = i;\n\t\t//\t\tbreak;\n\t\t//\t}\n\n\t\t//\treturn a.Length - firstItemIndex;\n\t\t//}\n\n\t\t//private static short[] Subtract(short[] a, short[] b)\n\t\t//{\n\t\t//\tif (a.Length != b.Length)\n\t\t//\t{\n\t\t//\t\tthrow new ArgumentException();\n\t\t//\t}\n\n\t\t//\tshort[] result = new short[a.Length];\n\t\t//\tArray.Copy(a, result, a.Length);\n\t\t//\tfor (int i = result.Length - 1; i >= 0; i--)\n\t\t//\t{\n\t\t//\t\tif (result[i] < b[i])\n\t\t//\t\t{\n\t\t//\t\t\tint j = i - 1;\n\t\t//\t\t\twhile (result[j] == 0)\n\t\t//\t\t\t{\n\t\t//\t\t\t\tresult[j--] = 9;\n\t\t//\t\t\t}\n\n\t\t//\t\t\tresult[j]--;\n\t\t//\t\t\tresult[i] += 10;\n\t\t//\t\t}\n\n\t\t//\t\tresult[i] -= b[i];\n\t\t//\t}\n\n\t\t//\treturn result;\n\t\t//}\n\n\t\t//private static short[] Multiply(short[] a, int b)\n\t\t//{\n\t\t//\tshort[] result = new short[a.Length];\n\t\t//\tfor (int i = a.Length - 1; i > 0; i--)\n\t\t//\t{\n\t\t//\t\tint temp = a[i] * b;\n\t\t//\t\tresult[i] = (short)(result[i] + temp % 10);\n\t\t//\t\tresult[i - 1] = (short)(result[i - 1] + temp / 10);\n\t\t//\t}\n\n\t\t//\treturn result;\n\t\t//}\n\n\t\t//private static int Mod(short[] a, int b)\n\t\t//{\n\t\t//\tint rest = 0, i = 0;\n\t\t//\twhile (i < a.Length)\n\t\t//\t{\n\t\t//\t\tint d = 10 * rest + a[i];\n\t\t//\t\twhile (d < b && i < a.Length - 1)\n\t\t//\t\t{\n\t\t//\t\t\td = 10 * d + a[++i];\n\t\t//\t\t}\n\n\t\t//\t\trest = d % b;\n\t\t//\t\ti++;\n\t\t//\t}\n\n\t\t//\treturn rest;\n\t\t//}\n\n\t\t//private static short[] Divide(short[] a, int b)\n\t\t//{\n\t\t//\tshort[] result = new short[a.Length];\n\t\t//\tint rest = 0, i = 0;\n\t\t//\twhile (i < a.Length)\n\t\t//\t{\n\t\t//\t\tint d = 10 * rest + a[i];\n\t\t//\t\twhile (d < b && i < a.Length - 1)\n\t\t//\t\t{\n\t\t//\t\t\td = 10 * d + a[++i];\n\t\t//\t\t}\n\n\t\t//\t\tresult[i] = (short)(d / b);\n\t\t//\t\trest = d % b;\n\t\t//\t\ti++;\n\t\t//\t}\n\n\t\t//\treturn result;\n\t\t//}\n\t}\n}\n", "lang_cluster": "C#", "tags": ["math"], "code_uid": "1a0d151a9aa0b5c40b95baeb593fd26d", "src_uid": "c7aa8a95d5f8832015853cffa1374c48", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\n\nclass Program\n{\n static void Main()\n {\n string input = Console.ReadLine();\n if (input.Length < 3 || !input.Contains('@')) { Console.WriteLine(\"NO\"); return; };\n\n string[] splited = input.Split('@','/');\n if (splited.Length < 2 || splited.Length > 3) { Console.WriteLine(\"NO\"); return; }\n string username = splited[0], hostname = splited[1];\n string resource = \"***\";\n if(splited.Length == 3)\n {\n resource = splited[2];\n }\n\n bool correct = CheckCorrectSymbols(username,hostname,resource);\n if (correct) Console.WriteLine(\"YES\");\n else Console.WriteLine(\"NO\");\n\n \n }\n static bool CheckCorrectSymbols(string username, string hostname, string resource)\n {\n string EngABC = \"_ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789\";\n\n if (username.Length < 1 || username.Length > 16) return false;\n for (int i = 0; i < username.Length; ++i)\n {\n if (!EngABC.Contains(username[i])) return false;\n }\n\n if (hostname.Length < 1 || hostname.Length > 32) return false;\n for (int i = 0; i < hostname.Length; ++i)\n {\n if (hostname[i] != '.' && !EngABC.Contains(hostname[i])) return false;\n }\n\n string[] words = hostname.Split('.');\n if (words.Length < 1) return false;\n for (int i = 0; i < words.Length; ++i)\n {\n if (words[i].Length < 1 || words[i].Length > 16) return false;\n }\n\n if (resource != \"***\")\n {\n if (resource.Length < 1 || resource.Length > 16) return false;\n for (int i = 0; i < resource.Length; ++i)\n {\n if (!EngABC.Contains(resource[i])) return false;\n }\n }\n\n return true;\n }\n\n}", "lang_cluster": "C#", "tags": ["strings", "implementation"], "code_uid": "7169380397e9ff57043bca6d2d7c4c77", "src_uid": "2a68157e327f92415067f127feb31e24", "difficulty": 1900.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nclass some\n{\n\tpublic static void Main()\n\t{\n\t\tstring []s=Console.ReadLine().Split(new char[]{'@'});\n\t\tbool y=find(s);\n\t\tif(y)Console.WriteLine(\"YES\");\n\t\telse\n\t\tConsole.WriteLine(\"NO\");\n\t}\n\tpublic static bool find(string[] s)\n\t{\n\t\t\n\t\tif(s.Length<2 || s.Length>2)return false;\n\t\tstring user=s[0];\n\t\tstring [] rest=s[1].Split('/');\n\t\tstring host=rest[0];\n\t\tif(!(host.Length>0 && host.Length<33))return false;\n\t\tif(!(user.Length>0 && user.Length<17))return false;\n\t\tforeach(char cc in user)\n\t\t{\n\t\t\tif(!(char.IsDigit(cc) || char.IsLetter(cc) || cc=='_'))return false;\n\t\t}\n\t\tforeach(char cc in host)\n\t\t{\n\t\t\tif(!(char.IsDigit(cc) || char.IsLetter(cc) || cc=='_' || cc=='.'))return false;\n\t\t}\n\t\tstring [] tt=host.Split(new char[]{'.'});\n\t\tforeach(string t in tt)\n\t\t{\n\t\t\tif(!(t.Length>0 && t.Length<17))return false;\n\t\t}\n\t\tList ll=new List();int le=0;\n\t\tif(rest.Length>1)\n\t\t{\n\t\t\tfor(int i=1;i0 && le<17))return false;\n\t\t\t\n\t\t\tforeach(string kk in ll)\n\t\t\t{\n\t\t\t\tforeach(char cc in kk)\n\t\t\t\t{\n\t\t\t\t\tif(!(char.IsDigit(cc) || char.IsLetter(cc) || cc=='_'))return false;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\treturn true;\n\t}\n}\n\n\t\t", "lang_cluster": "C#", "tags": ["strings", "implementation"], "code_uid": "d87955bb6a6b0fdc6207e60b4e3603e8", "src_uid": "2a68157e327f92415067f127feb31e24", "difficulty": 1900.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing CompLib.Util;\n\npublic class Program\n{\n public void Solve()\n {\n var sc = new Scanner();\n int a1 = sc.NextInt();\n int a2 = sc.NextInt();\n int k1 = sc.NextInt();\n int k2 = sc.NextInt();\n int n = sc.NextInt();\n\n // \u5168\u54e1\u9000\u5834\u3057\u306a\u3044\u30ae\u30ea\u30ae\u30ea\n int tmp = a1 * (k1 - 1) + a2 * (k2 - 1);\n int min = Math.Min(a1 + a2, Math.Max(0, n - tmp));\n\n int max = 0;\n\n if (k1 <= k2)\n {\n int d1 = Math.Min(a1, n / k1);\n max += d1;\n n -= d1 * k1;\n\n int d2 = Math.Min(a2, n / k2);\n max += d2;\n }\n else\n {\n int d1 = Math.Min(a2, n / k2);\n max += d1;\n n -= d1 * k2;\n\n int d2 = Math.Min(a1, n / k1);\n max += d2;\n }\n\n Console.WriteLine($\"{min} {max}\");\n }\n\n public static void Main(string[] args) => new Program().Solve();\n}\n\nnamespace CompLib.Util\n{\n using System;\n using System.Linq;\n\n class Scanner\n {\n private string[] _line;\n private int _index;\n private const char Separator = ' ';\n\n public Scanner()\n {\n _line = new string[0];\n _index = 0;\n }\n\n public string Next()\n {\n if (_index >= _line.Length)\n {\n string s;\n do\n {\n s = Console.ReadLine();\n } while (s.Length == 0);\n\n _line = s.Split(Separator);\n _index = 0;\n }\n\n return _line[_index++];\n }\n\n public int NextInt() => int.Parse(Next());\n public long NextLong() => long.Parse(Next());\n public double NextDouble() => double.Parse(Next());\n public decimal NextDecimal() => decimal.Parse(Next());\n public char NextChar() => Next()[0];\n public char[] NextCharArray() => Next().ToCharArray();\n\n public string[] Array()\n {\n string s = Console.ReadLine();\n _line = s.Length == 0 ? new string[0] : s.Split(Separator);\n _index = _line.Length;\n return _line;\n }\n\n public int[] IntArray() => Array().Select(int.Parse).ToArray();\n public long[] LongArray() => Array().Select(long.Parse).ToArray();\n public double[] DoubleArray() => Array().Select(double.Parse).ToArray();\n public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();\n }\n}", "lang_cluster": "C#", "tags": ["math", "greedy", "implementation"], "code_uid": "e05ff6fa22a51c943f1b6925b262857c", "src_uid": "2be8e0b8ad4d3de2930576c0209e8b91", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\n\nnamespace ConsoleApplication1\n{\n class Program\n {\n static void Main(string[] args)\n {\n int a1=int.Parse(Console.ReadLine());\n int a2=int.Parse(Console.ReadLine());\n int k1=int.Parse(Console.ReadLine());\n int k2=int.Parse(Console.ReadLine());\n int n=int.Parse(Console.ReadLine());\n int e1=(k1-1)*a1;\n int e2=(k2-1)*a2+e1;\n int min=n-e2;\n if(min<0)\n min=0;\n int max=0;\n int o=0;\n int u=0;\n if(k10&&a1>0)\n {\n o++;\n n--;\n if(o>=k1)\n {\n o=0;\n u++;\n a1--;\n }\n }\n o=0;\n while(n>0&&a2>0)\n {\n o++;\n n--;\n if(o>=k2)\n {\n o=0;\n u++;\n a2--;\n }\n }\n \n }\n else\n {\n while(n>0&&a2>0)\n {\n o++;\n n--;\n if(o>=k2)\n {\n o=0;\n u++;\n a2--;\n }\n }\n o=0;\n while(n>0&&a1>0)\n {\n o++;\n n--;\n if(o>=k1)\n {\n o=0;\n u++;\n a1--;\n }\n }\n }\n \n Console.Write(\"{0} {1}\",min,u);\n }\n\n }\n}\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n", "lang_cluster": "C#", "tags": ["math", "greedy", "implementation"], "code_uid": "6ac919a0e58d0d8cabc4317e27e1febd", "src_uid": "2be8e0b8ad4d3de2930576c0209e8b91", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\n\nnamespace CodeForces\n{\n class R195_Div2_A\n {\n static void Main(string[] args)\n {\n string[] s = Console.ReadLine().Split();\n int x = int.Parse(s[0]);\n int y = int.Parse(s[1]);\n\n if (x > 0 && y > 0)\n Console.WriteLine(\"0 \" + (x+y) + \" \" + (x+y) + \" 0\");\n else if (x < 0 && y > 0)\n Console.WriteLine((x-y) + \" 0 0 \" + (y - x));\n else if (x < 0 && y < 0)\n Console.WriteLine((x + y) + \" 0 0 \" + (x + y));\n else if (x > 0 && y < 0)\n Console.WriteLine(\" 0 \" + (y - x) + \" \" + (x-y) + \" 0\");\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "implementation"], "code_uid": "b7cf38ac7bb7d9a89d05ea2755aac4d5", "src_uid": "e2f15a9d9593eec2e19be3140a847712", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\n\nnamespace CodeForces\n{\n class Solution\n {\n static int Main(string[] args)\n {\n int[] xy = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();\n int x1 = Math.Abs(xy[0]) + Math.Abs(xy[1]);\n int y2 = x1;\n if (xy[0] < 0)\n {\n x1 *= -1;\n }\n if (xy[1] < 0)\n {\n y2 *= -1;\n }\n int y1 = 0;\n int x2 = 0;\n if (x1 < x2)\n {\n Console.WriteLine(\"{0} {1} {2} {3}\", x1, y1, x2, y2);\n }\n else\n {\n Console.WriteLine(\"{0} {1} {2} {3}\", x2, y2, x1, y1);\n }\n\n return 0;\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "implementation"], "code_uid": "f599ce533528a4b63d9b93e7bd7b87bc", "src_uid": "e2f15a9d9593eec2e19be3140a847712", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.IO;\nusing System.Text;\n\nnamespace If_at_first_you_dont_succeed\n{\n class Program\n {\n private static readonly StreamReader reader = new StreamReader(Console.OpenStandardInput(1024 * 10), Encoding.ASCII, false, 1024 * 10);\n private static readonly StreamWriter writer = new StreamWriter(Console.OpenStandardOutput(1024 * 10), Encoding.ASCII, 1024 * 10);\n\n private static void Main(string[] args)\n {\n writer.WriteLine(Solve(args));\n writer.Flush();\n }\n\n private static int Solve(string[] args)\n {\n int A = Next(), B = Next(), C = Next(), N = Next();\n\n if (A > N || B > N || C > A || C > B)\n return -1;\n\n int ans = N - A - B + C;\n if (ans > 0)\n return ans;\n return -1;\n }\n\n private static int Next()\n {\n int c;\n int res = 0;\n do\n {\n c = reader.Read();\n if (c == -1)\n return res;\n } while (c < '0' || c > '9');\n res = c - '0';\n while (true)\n {\n c = reader.Read();\n if (c < '0' || c > '9')\n return res;\n res *= 10;\n res += c - '0';\n }\n }\n }\n}", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "b0b515b9bc4b4026daa1b8ffbc673309", "src_uid": "959d56affbe2ff5dd999a7e8729f60ce", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\n\nnamespace CSharp\n{\n public class _991A\n {\n public static void Main()\n {\n string[] tokens = Console.ReadLine().Split();\n\n int a = int.Parse(tokens[0]);\n int b = int.Parse(tokens[1]);\n int c = int.Parse(tokens[2]);\n int n = int.Parse(tokens[3]);\n\n if (a + b - c > n | c > a || c > b)\n {\n Console.WriteLine(-1);\n }\n else\n {\n int failed = n - a - b + c;\n Console.WriteLine(failed <= 0 ? -1 : failed);\n }\n }\n }\n}", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "5fece981c87ded52c23aac631aa25473", "src_uid": "959d56affbe2ff5dd999a7e8729f60ce", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.IO;\nusing System.Text;\n\nnamespace Escape\n{\n internal class Program\n {\n private static readonly StreamReader reader = new StreamReader(Console.OpenStandardInput(1024*10), Encoding.ASCII, false, 1024*10);\n private static readonly StreamWriter writer = new StreamWriter(Console.OpenStandardOutput(1024*10), Encoding.ASCII, 1024*10);\n\n private static void Main(string[] args)\n {\n int vp = Next(), vd = Next(), t = Next(), f = Next(), c = Next();\n\n t *= vp*vd;\n f *= vp * vd;\n c *= vp * vd;\n\n int count = 0;\n int p = 0;\n int d = 0;\n int ds = 0;\n int towait = t;\n while (true)\n {\n p += vp;\n\n if (ds == 0)\n {\n towait--;\n if (towait < 0)\n {\n ds = 1;\n d += vd;\n }\n }\n else if (ds == 1)\n {\n d += vd;\n }\n else\n {\n d -= vd;\n }\n\n if (d >= p)\n {\n if (d==p &&p==c)\n break;\n count++;\n ds = 2;\n d = p - (d - p);\n }\n\n if (ds == 2 && d <= 0)\n {\n d = -d;\n ds = 0;\n towait = f;\n }\n\n if (p >= c)\n {\n break;\n }\n }\n\n writer.WriteLine(count);\n writer.Flush();\n }\n\n private static int Next()\n {\n int c;\n int res = 0;\n do\n {\n c = reader.Read();\n if (c == -1)\n return res;\n } while (c < '0' || c > '9');\n res = c - '0';\n while (true)\n {\n c = reader.Read();\n if (c < '0' || c > '9')\n return res;\n res *= 10;\n res += c - '0';\n }\n }\n }\n}", "lang_cluster": "C#", "tags": ["math", "implementation"], "code_uid": "f02980308a83effe3aa92635bd7a45cc", "src_uid": "c9c03666278acec35f0e273691fe0fff", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.IO;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\n\nnamespace CF105D2B\n{\n class CF105D2B\n {\n public static void Main(string[] args)\n {\n EasyScanner sc = new EasyScanner(Console.In);\n double vp = sc.NextInt();\n double vd = sc.NextInt();\n double t = sc.NextInt();\n double f = sc.NextInt();\n double c = sc.NextInt();\n\n if (vp >= vd)\n {\n Console.Out.WriteLine(0);\n return;\n }\n\n double x = vp * t;\n x += vp * (x / (vd - vp));\n\n int count = 0;\n while (x < c)\n {\n count++;\n x += vp * (x / vd);\n x += vp * f;\n x += vp * (x / (vd - vp));\n }\n Console.Out.WriteLine(count);\n }\n }\n\n class EasyScanner\n {\n private TextReader reader;\n private Queue tokens;\n\n public EasyScanner(TextReader reader)\n {\n this.reader = reader;\n this.tokens = new Queue();\n }\n\n private void MaybeReadLine()\n {\n if (tokens.Count > 0)\n {\n return;\n }\n string line = reader.ReadLine();\n foreach (string token in line.Split())\n {\n tokens.Enqueue(token);\n }\n }\n\n public int NextInt()\n {\n MaybeReadLine();\n string token = tokens.Dequeue();\n return int.Parse(token);\n }\n\n public long NextLong()\n {\n MaybeReadLine();\n string token = tokens.Dequeue();\n return long.Parse(token);\n }\n\n public double NextDouble()\n {\n MaybeReadLine();\n string token = tokens.Dequeue();\n return double.Parse(token);\n }\n\n public string NextString()\n {\n MaybeReadLine();\n string token = tokens.Dequeue();\n return token;\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "implementation"], "code_uid": "a7a521388e5218365d7f17fda40f0728", "src_uid": "c9c03666278acec35f0e273691fe0fff", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\n\t\t\t\t\t\npublic class Program\n{\n\tpublic static void Main()\n\t{\n\t\tstring input = Console.ReadLine();\n\t\tstring normalized = \"\";\n\t\tint count = 0;\n\t\tforeach(var item in input)\n\t\t{\n\t\t\tif(item != '/')\n\t\t\t{\n\t\t\t\tnormalized += item.ToString();\n\t\t\t\tcount = 0;\n\t\t\t}\n\t\t\telse if(count == 0)\n\t\t\t{\n\t\t\t\tnormalized += item.ToString();\n\t\t\t\tcount++;\n\t\t\t}\n\t\t}\n\t\t\n\t\tstring result = normalized;\n\t\tif(normalized.Length > 1 && normalized[normalized.Length - 1] == '/')\n\t\t{\n\t\t\tresult = normalized.Substring(0, normalized.Length - 1);\n\t\t}\n\t\t\n\t\tConsole.WriteLine(result);\n\t}\n}", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "c8cd3c1dff205c8a3981184c105036c5", "src_uid": "6c2e658ac3c3d6b0569dd373806fa031", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\n\nnamespace CodeForces\n{\n static class Reader\n {\n public static int NextInt()\n {\n int ret = 0;\n char c;\n\n while (!char.IsDigit(c = (char)Console.Read()))\n {\n if (c == '-')\n return -NextInt();\n }\n do\n {\n ret = ret * 10 + c - '0';\n } while (char.IsDigit(c = (char)Console.Read()));\n\n return ret;\n }\n\n public static double NextDouble()\n {\n double ret = 0;\n char c;\n\n while (!char.IsDigit(c = (char)Console.Read())) \n {\n if (c == '-')\n return -NextDouble();\n }\n do\n {\n ret = ret * 10 + c - '0';\n } while (char.IsDigit(c = (char)Console.Read()));\n if (c != '.') return ret;\n\n double p10 = 0.1;\n while (char.IsDigit(c = (char)Console.Read()))\n {\n ret += p10 * (c - '0');\n p10 *= 0.1;\n }\n\n return ret;\n }\n\n public static string NextToken()\n {\n StringBuilder ret = new StringBuilder();\n char c;\n\n while (char.IsWhiteSpace(c = (char)Console.Read())) ;\n do\n {\n ret.Append(c);\n } while (!char.IsWhiteSpace(c = (char)Console.Read()));\n\n return ret.ToString();\n }\n }\n\n class Program\n {\n static void Main(string[] args)\n {\n string s = Reader.NextToken();\n while (s != s.Replace(\"//\", \"/\"))\n s = s.Replace(\"//\", \"/\");\n if (s.Length > 1 && s.EndsWith(\"/\"))\n s = s.Substring(0, s.Length - 1);\n Console.WriteLine(s);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "4cae666547715d56fb36747ac37faadf", "src_uid": "6c2e658ac3c3d6b0569dd373806fa031", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Linq;\nusing System.Text;\nusing System.Collections.Generic;\nclass Program{\n\tstatic void Main() {\n\t\tint[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();\n\t\tint[] b = Console.ReadLine().Split().Select(int.Parse).ToArray();\n\t\tint[] c = Console.ReadLine().Split().Select(int.Parse).ToArray();\n\t\tlong[] v1 = new long[2]{b[0] - a[0], b[1] - a[1]};\n\t\tlong[] v2 = new long[2]{c[0] - b[0], c[1] - b[1]};\n\t\tlong product = (v1[0] * v2[1]) - (v1[1] * v2[0]);\n\t\t\n\t\tif(product == 0)\n\t\t\tConsole.WriteLine(\"TOWARDS\");\n\t\telse if(product > 0)\n\t\t\tConsole.WriteLine(\"LEFT\");\n\t\telse\n\t\t\tConsole.WriteLine(\"RIGHT\");\n\t}\n}", "lang_cluster": "C#", "tags": ["geometry"], "code_uid": "243494a3366ebdbe453888bbf09b8a48", "src_uid": "f6e132d1969863e9f28c87e5a44c2b69", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\n\nnamespace ConsoleApplication1\n{\n public class Program\n {\n static void Main()\n {\n string[] a = Console.ReadLine().Split(' '),\n b = Console.ReadLine().Split(' '),\n c = Console.ReadLine().Split(' ');\n string k = Solver(Int32.Parse(a[0]), Int32.Parse(a[1]), Int32.Parse(b[0]),\n Int32.Parse(b[1]), Int32.Parse(c[0]), Int32.Parse(c[1]));\n Console.WriteLine(k);\n }\n\n public static string Solver(int ax, int ay, int bx, int by, int cx, int cy)\n {\n \n\n Int64[,] mat = new Int64[3, 3] { { 1, 1, 1 }, { bx - ax, by - ay, 0 }, { cx - bx, cy - by, 0 } };\n Int64 k = mat[1, 0] * mat[2, 1] - mat[1, 1] * mat[2, 0];\n if (k > 0) return \"LEFT\";\n if (k < 0) return \"RIGHT\";\n return \"TOWARDS\";\n\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["geometry"], "code_uid": "e8dbdd8efb1cf25349c9536b793875a2", "src_uid": "f6e132d1969863e9f28c87e5a44c2b69", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\n\nnamespace _887B\n{\n class Program\n {\n static void Main(string[] args)\n {\n int n = 0;\n n = int.Parse(Console.ReadLine());\n int[,] array = new int[n, 6];\n for (int i = 0; i < n; i++)\n {\n //Console.Clear();\n string inputDice = Console.ReadLine();\n string[] splitInputDice = inputDice.Split(' ');\n \n for (int j = 0; j < 6; j++)\n {\n array[i, j] = int.Parse(splitInputDice[j]);\n }\n }\n\n int[] checker = new int[1000];\n Array.Clear(checker, 0, checker.Length);\n\n for (int i = 0; i < n; i++)\n {\n for(int j = 0; j < 6; j++)\n {\n checker[array[i, j]] = 1;\n\n for(int k = 0; k < n; k++ )\n {\n if (k == i) continue;\n for(int l = 0; l < 6; l++)\n {\n int index = array[i, j] * 10 + array[k, l];\n checker[index] = 1;\n for(int m = 0; m < n; m++)\n {\n if (m == i || m == k) continue;\n for(int o = 0; o < 6; o++)\n {\n int index2 = array[i, j] * 100 + array[k, l] * 10 + array[m, o];\n checker[index2] = 1;\n }\n }\n }\n }\n }\n }\n\n int res = 0;\n for(int i = 1; i < 1000; i++)\n {\n if(checker[i] == 0)\n {\n res = i - 1;\n break;\n }\n }\n\n Console.Write(res);\n\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "implementation"], "code_uid": "83a155dd8f12487fb24704ca68091da8", "src_uid": "20aa53bffdfd47b4e853091ee6b11a4b", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace ConsoleApp14\n{\n class Program\n {\n static void Main(string[] args)\n {\n int num2 = 0;\n int n = int.Parse(Console.ReadLine());\n int[][] toks = new int[3][];\n\n for(int i = 0; i < n; i++)\n {\n int[] temp = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);\n toks[i] = temp;\n }\n\n int number = 0;\n for(int x = 0; x <= 10000; x++)\n {\n number++;\n string tofind = number.ToString();\n int num1 = int.Parse(tofind[0].ToString());\n if (tofind.Length == 2)\n {\n num2 = int.Parse(tofind[1].ToString());\n }\n bool naid = false;\n for(int i = 0; i < n; i++)\n {\n if(toks[i].Contains(num1))\n {\n naid = true;\n if(tofind.Length == 1)\n {\n break;\n }\n else\n {\n naid = false;\n for(int j = 0; j < n; j++)\n {\n if (j == i)\n continue;\n if(toks[j].Contains(num2))\n {\n naid = true;\n i = n;\n break;\n }\n }\n }\n }\n }\n if (naid == false)\n break;\n\n }\n Console.WriteLine(--number);\n Console.ReadLine();\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "implementation"], "code_uid": "4a21394fef5ebddeef73c894e4d6113e", "src_uid": "20aa53bffdfd47b4e853091ee6b11a4b", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.IO;\nusing System.Text;\n\nnamespace Divisibility_by_25\n{\n internal class Program\n {\n private static readonly StreamReader reader = new StreamReader(Console.OpenStandardInput(1024*10), Encoding.ASCII, false, 1024*10);\n private static readonly StreamWriter writer = new StreamWriter(Console.OpenStandardOutput(1024*10), Encoding.ASCII, 1024*10);\n\n private static void Main(string[] args)\n {\n writer.WriteLine(Solve(args));\n writer.Flush();\n }\n\n private static int Solve(string[] args)\n {\n string s = reader.ReadLine();\n\n int min = Math.Min(Math.Min(Check(s, '0', '0'), Check(s, '2', '5')), Math.Min(Check(s, '5', '0'), Check(s, '7', '5')));\n if (min == int.MaxValue)\n return -1;\n\n return min;\n }\n\n private static int Check(string s, char c1, char c2)\n {\n int index = s.LastIndexOf(c2);\n if (index < 0)\n return int.MaxValue;\n int ans = s.Length - index - 1;\n int index2;\n if (c1 == c2)\n index2 = s.Substring(0, index).LastIndexOf(c1);\n else\n index2 = s.LastIndexOf(c1);\n\n if (index2 < 0)\n return int.MaxValue;\n\n if (index2 > index)\n ans += s.Length - index2 - 1;\n else\n ans += s.Length - index2 - 2;\n\n var b = new StringBuilder();\n for (int i = 0; i < s.Length; i++)\n {\n if (i == index || i == index2)\n continue;\n b.Append(s[i]);\n }\n\n bool f = b.Length == 0;\n for (int i = 0; i < b.Length; i++)\n {\n if (b[i] != '0')\n {\n f = true;\n break;\n }\n ans++;\n }\n\n if (f)\n return ans;\n\n return int.MaxValue;\n }\n }\n}", "lang_cluster": "C#", "tags": ["brute force", "greedy"], "code_uid": "e4ff13c63dd8e9b782e2a6b38eaecd63", "src_uid": "ea1c737956f88be94107f2565ca8bbfd", "difficulty": 2100.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Linq;\nusing CompLib.Collections;\nusing CompLib.Util;\n\npublic class Program\n{\n\n public void Solve()\n {\n var sc = new Scanner();\n var n = sc.Next().Reverse().ToArray();\n if (n.Length == 1)\n {\n Console.WriteLine(\"-1\");\n return;\n }\n\n // \u5148\u982d0\u4ee5\u5916\n // \u4e0b2\u6841 00 25 50 75\n\n int ans = int.MaxValue;\n\n // \u5148\u982d\n for (int i = 0; i < n.Length; i++)\n {\n if (n[i] == '0') continue;\n // 2\u6841\u76ee\n for (int j = 0; j < n.Length; j++)\n {\n if (n.Length > 2 && i == j) continue;\n for (int k = 0; k < n.Length; k++)\n {\n if (i == k || j == k) continue;\n\n bool zero = n[j] == '0' && n[k] == '0';\n bool twentyfive = n[j] == '2' && n[k] == '5';\n bool fifty = n[j] == '5' && n[k] == '0';\n bool seventyfive = n[j] == '7' && n[k] == '5';\n if (!zero && !twentyfive && !fifty && !seventyfive) continue;\n var array = new int[n.Length];\n for (int l = 0; l < n.Length; l++)\n {\n if (l == i) array[l] = 0;\n else if (l == j) array[l] = 2;\n else if (l == k) array[l] = 3;\n else array[l] = 1;\n }\n int tmp = 0;\n var bit = new FenwickTree(4);\n for (int l = 0; l < n.Length; l++)\n {\n tmp += bit.Sum(array[l]);\n bit.Add(array[l], 1);\n }\n ans = Math.Min(ans, tmp);\n }\n }\n }\n if (ans == int.MaxValue) Console.WriteLine(\"-1\");\n else Console.WriteLine(ans);\n }\n\n public static void Main(string[] args) => new Program().Solve();\n}\n\nnamespace CompLib.Collections\n{\n using Num = System.Int32;\n\n public class FenwickTree\n {\n private readonly Num[] _array;\n public readonly int Count;\n\n public FenwickTree(int size)\n {\n _array = new Num[size + 1];\n Count = size;\n }\n\n /// \n /// A[i]\u306bn\u3092\u52a0\u7b97\n /// \n /// \n /// \n public void Add(int i, Num n)\n {\n i++;\n for (; i <= Count; i += i & -i)\n {\n _array[i] += n;\n }\n }\n\n /// \n /// [0,r)\u306e\u548c\u3092\u6c42\u3081\u308b\n /// \n /// \n /// \n public Num Sum(int r)\n {\n Num result = 0;\n for (; r > 0; r -= r & -r)\n {\n result += _array[r];\n }\n\n return result;\n }\n\n // [l,r)\u306e\u548c\u3092\u6c42\u3081\u308b\n public Num Sum(int l, int r) => Sum(r) - Sum(l);\n }\n}\n\nnamespace CompLib.Util\n{\n using System;\n using System.Linq;\n\n class Scanner\n {\n private string[] _line;\n private int _index;\n private const char Separator = ' ';\n\n public Scanner()\n {\n _line = new string[0];\n _index = 0;\n }\n\n public string Next()\n {\n while (_index >= _line.Length)\n {\n _line = Console.ReadLine().Split(Separator);\n _index = 0;\n }\n\n return _line[_index++];\n }\n\n public int NextInt() => int.Parse(Next());\n public long NextLong() => long.Parse(Next());\n public double NextDouble() => double.Parse(Next());\n public decimal NextDecimal() => decimal.Parse(Next());\n public char NextChar() => Next()[0];\n public char[] NextCharArray() => Next().ToCharArray();\n\n public string[] Array()\n {\n _line = Console.ReadLine().Split(Separator);\n _index = _line.Length;\n return _line;\n }\n\n public int[] IntArray() => Array().Select(int.Parse).ToArray();\n public long[] LongArray() => Array().Select(long.Parse).ToArray();\n public double[] DoubleArray() => Array().Select(double.Parse).ToArray();\n public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "greedy"], "code_uid": "51ef7e5efb83b17a6449f880c59f9a4b", "src_uid": "ea1c737956f88be94107f2565ca8bbfd", "difficulty": 2100.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\n\n\nnamespace _535A\n{\n class Program\n {\n static void Main(string[] args)\n {\n var n = int.Parse(Console.ReadLine());\n string[] translate1 = { \"zero\", \"one\", \"two\", \"three\", \"four\", \"five\", \"six\", \"seven\", \"eight\", \"nine\",\n \"ten\", \"eleven\", \"twelve\", \"thirteen\", \"fourteen\", \"fifteen\", \"sixteen\", \"seventeen\",\n \"eighteen\", \"nineteen\"};\n string[] translate2 = { \"\", \"\", \"twenty\", \"thirty\", \"forty\", \"fifty\", \"sixty\", \"seventy\", \"eighty\", \"ninety\" };\n if (n <= 19) Console.WriteLine(translate1[n]);\n else if (n % 10 == 0) { Console.WriteLine(translate2[n/10]); }\n else { Console.WriteLine(translate2[n/10]+\"-\"+translate1[n%10]); }\n\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "implementation"], "code_uid": "3769b5df35cc4752362d4c0f0748bd3d", "src_uid": "a49ca177b2f1f9d5341462a38a25d8b7", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\n\nnamespace _535A\n{\n class Program\n {\n static string[] zeroToNine = new[] { \"zero\", \"one\", \"two\", \"three\", \"four\", \"five\", \"six\", \"seven\", \"eight\", \"nine\" };\n static string[] tenToNineteen = new[] { \"ten\", \"eleven\", \"twelve\", \"thirteen\", \"fourteen\", \"fifteen\", \"sixteen\", \"seventeen\", \"eighteen\", \"nineteen\" };\n static string[] decades = new[] { \"twenty\", \"thirty\", \"forty\", \"fifty\", \"sixty\", \"seventy\", \"eighty\", \"ninety\" };\n static void Main(string[] args)\n {\n int s = int.Parse(Console.ReadLine());\n string result;\n if (s < 10)\n result = zeroToNine[s];\n else if (s >= 10 && s < 20)\n result = tenToNineteen[s - 10];\n else\n {\n result = decades[s / 10 - 2];\n if (s % 10 > 0)\n result += '-' + zeroToNine[s % 10];\n }\n Console.WriteLine(result);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "implementation"], "code_uid": "07b9362df0c3b6ab46dc9585af56a07a", "src_uid": "a49ca177b2f1f9d5341462a38a25d8b7", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\n\nnamespace Codeforces\n{\n\tclass Program\n\t{\n\t\tstatic void Main(string[] args)\n\t\t{\n\t\t\tint x2 = int.Parse(Console.ReadLine());\n\t\t\tint px2 = maxPrimeDivs(x2);\n\t\t\tint min = x2;\n\t\t\tint start2 = ((x2 / px2) - 1) * px2 + 1;\n\n\t\t\tfor (int x1 = start2; x1 <= x2; x1++)\n\t\t\t{\n\t\t\t\tint px1 = maxPrimeDivs(x1);\n\t\t\t\tint start1 = ((x1 / px1) - 1) * px1 + 1;\n\t\t\t\tif (start1 > 2 && start1 < min)\n\t\t\t\t{\n\t\t\t\t\tmin = start1;\n\t\t\t\t}\n\t\t\t}\n\t\t\tConsole.WriteLine(min);\n\t\t\tConsole.ReadLine();\n\t\t}\n\n\t\tprivate static int maxPrimeDivs(int n)\n\t\t{\n\t\t\tint d = 2;\n\t\t\tint result = 0;\n\n\t\t\twhile (d * d <= n)\n\t\t\t{\n\t\t\t\tif (n % d == 0)\n\t\t\t\t{\n\t\t\t\t\tn /= d;\n\t\t\t\t\tif (result < d)\n\t\t\t\t\t\tresult = d;\n\t\t\t\t}\n\t\t\t\telse d++;\n\t\t\t}\n\t\t\treturn Math.Max(result, n);\n\t\t}\n\n\t}\n}\n", "lang_cluster": "C#", "tags": ["math", "number theory"], "code_uid": "87cad097dff6b2264bc6bfada0c1c05f", "src_uid": "43ff6a223c68551eff793ba170110438", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.IO;\nusing System.Text;\n\nnamespace Primal_Sport\n{\n internal class Program\n {\n private static readonly StreamReader reader = new StreamReader(Console.OpenStandardInput(1024*10), Encoding.ASCII, false, 1024*10);\n private static readonly StreamWriter writer = new StreamWriter(Console.OpenStandardOutput(1024*10), Encoding.ASCII, 1024*10);\n\n private static void Main(string[] args)\n {\n writer.WriteLine(Solve(args));\n writer.Flush();\n }\n\n private static int Solve(string[] args)\n {\n int n = Next();\n\n var nn = new int[n + 1];\n for (int i = 2; i < nn.Length; i++)\n {\n if (nn[i] == 0)\n {\n for (int j = i; j < nn.Length; j += i)\n {\n nn[j] = i;\n }\n }\n }\n\n int min = n;\n for (int j = n - nn[n] + 1; j <= n; j++)\n {\n if (nn[j] != j)\n {\n min = Math.Min(min, j - nn[j] + 1);\n }\n }\n\n return min;\n }\n\n private static int Next()\n {\n int c;\n int res = 0;\n do\n {\n c = reader.Read();\n if (c == -1)\n return res;\n } while (c < '0' || c > '9');\n res = c - '0';\n while (true)\n {\n c = reader.Read();\n if (c < '0' || c > '9')\n return res;\n res *= 10;\n res += c - '0';\n }\n }\n }\n}", "lang_cluster": "C#", "tags": ["brute force", "math", "number theory"], "code_uid": "8b6e5fe87dbc82146e15969088c94e7e", "src_uid": "43ff6a223c68551eff793ba170110438", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\n\nnamespace \u041a\u0440\u0430\u0442\u043d\u044b\u0435\n{\n class Program\n {\n static void Main(string[] args)\n {\n string[] str;\n str = Console.ReadLine().Split(' ');\n int y=Convert.ToInt32(str[0]), b=Convert.ToInt32(str[1]), r=Convert.ToInt32(str[2]), max=y;\n max = Math.Min(max, b - 1);\n max = Math.Min(max, r - 2);\n\n\n Console.WriteLine(3*max+3);\n \n\n\n\n // Console.ReadKey();\n\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "math", "implementation"], "code_uid": "8995d852b6645f68bfab86189af0d273", "src_uid": "03ac8efe10de17590e1ae151a7bae1a5", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\n\nnamespace ConsoleApplication1\n{\n class Program\n {\n static void Main(string[] args)\n {\n string[]y=Console.ReadLine().Split(' ');\n int[]a=new int[3];\n a[0]=1;\n a[1]=2;\n a[2]=3;\n int sum=0;\n while(true)\n {\n if((a[0]>=int.Parse(y[0]))||(a[1]>=int.Parse(y[1]))||(a[2]>=int.Parse(y[2])))\n {\n sum=a[0]+a[1]+a[2];\n break;\n }\n else\n {\n a[0]++;\n a[1]++;\n a[2]++;\n }\n }\n Console.WriteLine(sum);\n \n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "math", "implementation"], "code_uid": "efa637db087fa64d4ef442d2107a3244", "src_uid": "03ac8efe10de17590e1ae151a7bae1a5", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Linq;\n\nnamespace Task_C\n{\n class Program\n {\n private static int CardIndex(string card)\n {\n var num = card[1] - '1';\n int color = 0;\n if (card[0] == 'R')\n color = 0;\n if (card[0] == 'G')\n color = 1;\n if (card[0] == 'B')\n color = 2;\n if (card[0] == 'Y')\n color = 3;\n if (card[0] == 'W')\n color = 4;\n\n var index = (1 << num) | (1 << (color + 5));\n return index;\n }\n\n static void Main(string[] args)\n {\n int n = int.Parse(Console.ReadLine());\n var cards = Console.ReadLine().\n Split().\n Distinct().\n Select(x => CardIndex(x)).\n ToList();\n\n var minSuggest = int.MaxValue;\n\n var maxSuggest = 1 << 10;\n for (int suggest = 0; suggest < maxSuggest; suggest++)\n {\n var distinctCard = cards.Select(x => x & suggest).Distinct().Count();\n if (distinctCard == cards.Count)\n {\n var suggestSize = SparseBitcount(suggest);\n if (suggestSize < minSuggest)\n {\n minSuggest = suggestSize;\n }\n }\n }\n\n Console.WriteLine(minSuggest);\n }\n\n static int SparseBitcount(int n)\n {\n int count = 0;\n while (n != 0)\n {\n count++;\n n &= (n - 1);\n }\n return count;\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "constructive algorithms", "implementation", "bitmasks"], "code_uid": "2ea65af40df56314a2ec98891374f8fa", "src_uid": "3b12863997b377b47bae43566ec1a63b", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Linq;\nusing System.Collections.Generic;\n\npublic class Test\n{\n [Flags]\n enum Card\n {\n R = 1 << 0,\n G = 1 << 1,\n B = 1 << 2,\n Y = 1 << 3,\n W = 1 << 4,\n One = 1 << 5,\n Two = 1 << 6,\n Three = 1 << 7,\n Four = 1 << 8,\n Five = 1 << 9,\n }\n \n public static void Main()\n {\n int result = Solve();\n Console.WriteLine(result);\n }\n \n static int Solve()\n {\n \n // Don't care for n\n Console.ReadLine();\n \n var input = Console.ReadLine().Split(' ').Distinct().Select(x => ParseCard(x)).ToArray();\n if (input.Length == 1)\n {\n return 0;\n }\n List diffs = new List(input.Length * input.Length);\n for(int i = 0; i < input.Length - 1; i++)\n {\n for(int j = i + 1; j < input.Length; j++)\n {\n Card diff = Diff(input[i], input[j]);\n diffs.Add(diff);\n }\n }\n \n var subsets = Enumerable.Range(0, 1023).Select(x => (Card)x);\n int min = 11;\n foreach(var subset in subsets)\n {\n if(diffs.All(x => CanDistinguish(subset, x)))\n {\n // This is an answer\n min = Math.Min(min, CountBits((int)subset));\n }\n }\n \n return min;\n }\n \n static int CountBits(int num)\n {\n int res = 0;\n while(num > 0)\n {\n if ((num & 1) == 1) res++;\n num >>= 1;\n }\n return res;\n }\n \n static bool CanDistinguish(Card subset, Card diff)\n {\n return (subset & diff) != 0;\n }\n \n static Card Diff(Card f, Card s)\n {\n return f ^ s;\n }\n \n static Card ParseCard(string input)\n {\n Card colour = (Card)Enum.Parse(typeof(Card), input[0].ToString());\n Card num = Card.One;\n switch (input[1])\n {\n case '1': num = Card.One;break;\n case '2': num = Card.Two;break;\n case '3': num = Card.Three;break;\n case '4': num = Card.Four;break;\n case '5': num = Card.Five;break;\n }\n return colour | num;\n }\n}", "lang_cluster": "C#", "tags": ["brute force", "implementation", "bitmasks"], "code_uid": "1ecaac7622674e5d12720c7eb2bd8fa5", "src_uid": "3b12863997b377b47bae43566ec1a63b", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "C# 10", "source_code": "using System;\r\nusing System.Collections.Generic;\r\nusing System.Data.SqlTypes;\r\nusing System.Linq;\r\nusing System.Text;\r\nusing System.Threading.Tasks;\r\n\r\nnamespace CodeForces800\r\n{\r\n internal static class Program\r\n {\r\n public static long prime = 1000000007;\r\n public static long[] bprime = new long[2];\r\n public static Dictionary invar = new Dictionary();\r\n public static long[] fact = new long[1];\r\n public static void Main()\r\n {\r\n var cur = prime - 2;\r\n var list = new List();\r\n while (cur != 0)\r\n {\r\n list.Add(cur % 2);\r\n cur = cur / 2;\r\n }\r\n bprime = list.ToArray();\r\n var str = Console.ReadLine().Split(' ').Select(x => Int32.Parse(x)).ToList();\r\n var n = str[0];\r\n var k = str[1];\r\n long res = 0;\r\n fact = new long[n + 1];\r\n fact[0] = 1;\r\n for (var i = 1; i < n + 1; i++)\r\n {\r\n fact[i] = (long)((long)fact[i - 1] * i) % prime;\r\n }\r\n for (var i = 0; i <= Math.Min(n,k); i++)\r\n {\r\n res += C(n, i);\r\n res = res % prime;\r\n }\r\n Console.WriteLine(res);\r\n }\r\n private static long C(long n, long k)\r\n {\r\n if (n >= k)\r\n {\r\n long res = fact[n];\r\n res = res * calcInv(fact[n - k]);\r\n res = res % prime;\r\n res = res * calcInv(fact[k]);\r\n res = res % prime;\r\n return (long)res;\r\n }\r\n else return 0;\r\n }\r\n\r\n public static long calcInv(long n)\r\n {\r\n if (invar.TryGetValue(n, out var invn))\r\n return invn;\r\n else\r\n {\r\n var ost = new long[bprime.Length];\r\n ost[0] = n;\r\n for (var i = 1; i < bprime.Length; i++)\r\n {\r\n ost[i] = (ost[i - 1] * ost[i - 1]) % prime;\r\n }\r\n long inv = 1;\r\n for (var i = 0; i < bprime.Length; i++)\r\n {\r\n inv *= (bprime[i] == 1) ? ost[i] : 1;\r\n inv = inv % prime;\r\n }\r\n invar.Add(n, (long)inv);\r\n\r\n return (long)inv;\r\n }\r\n }\r\n }\r\n}", "lang_cluster": "C#", "tags": ["math", "greedy", "constructive algorithms", "combinatorics"], "code_uid": "c93ef434da4a2d03ce0fd4a8b7b28ab8", "src_uid": "dc7b887afcc2e95c4e90619ceda63071", "difficulty": 1900.0, "exec_outcome": "PASSED"} {"lang": "C# 8", "source_code": "using System;\r\nusing System.Linq;\r\nusing CompLib.Util;\r\nusing System.Threading;\r\nusing System.IO;\r\nusing System.Collections.Generic;\r\nusing System.Text;\r\nusing CompLib.Mathematics;\r\n\r\npublic class Program\r\n{\r\n int N, K;\r\n BinomialCoefficient Binom;\r\n public void Solve()\r\n {\r\n var sc = new Scanner();\r\n N = sc.NextInt();\r\n K = sc.NextInt();\r\n\r\n // 2^n\u4eba n\u56de\u6226\u30c8\u30fc\u30ca\u30e1\u30f3\u30c8\r\n\r\n // \u512a\u52dd\u304c\u5c0f\u3055\u3044\u65b9\u304c\u826f\u3044\r\n // \u30c8\u30fc\u30ca\u30e1\u30f3\u30c8\u306e\u69cb\u7bc9\u3001\u52dd\u3064\u4eba\u6c7a\u3081\u308b\r\n\r\n // K\u56de\u4ee5\u4e0b \u7d50\u679c\u5909\u3048\u3089\u308c\u308b\r\n\r\n // \u53ef\u80fd\u306a\u52dd\u3064\u4eba\u6700\u5c0f\r\n\r\n if (K >= N)\r\n {\r\n Console.WriteLine(ModInt.Pow(2, N));\r\n return;\r\n }\r\n\r\n Binom = new BinomialCoefficient(N);\r\n ModInt ans = 0;\r\n for (int i = 0; i <= K; i++)\r\n {\r\n ans += Binom[N, i];\r\n }\r\n\r\n Console.WriteLine(ans);\r\n\r\n // 1 1 + N\r\n // 2 1 + N + 1 + 2 + 3 + ... (N-1)\r\n\r\n // 1 + 3 + (1 + 2)\r\n }\r\n\r\n\r\n\r\n public static void Main(string[] args) => new Program().Solve();\r\n // public static void Main(string[] args) => new Thread(new Program().Solve, 1 << 27).Start();\r\n}\r\n\r\n// https://bitbucket.org/camypaper/complib\r\nnamespace CompLib.Mathematics\r\n{\r\n #region ModInt\r\n /// \r\n /// [0,) \u307e\u3067\u306e\u5024\u3092\u53d6\u308b\u3088\u3046\u306a\u6570\r\n /// \r\n public struct ModInt\r\n {\r\n /// \r\n /// \u5270\u4f59\u3092\u53d6\u308b\u5024\uff0e\r\n /// \r\n public const long Mod = (int)1e9 + 7;\r\n // public const long Mod = 998244353;\r\n\r\n /// \r\n /// \u5b9f\u969b\u306e\u6570\u5024\uff0e\r\n /// \r\n public long num;\r\n /// \r\n /// \u5024\u304c \u3067\u3042\u308b\u3088\u3046\u306a\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u3092\u69cb\u7bc9\u3057\u307e\u3059\uff0e\r\n /// \r\n /// \u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u304c\u6301\u3064\u5024\r\n /// \u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u306e\u554f\u984c\u4e0a\uff0c\u30b3\u30f3\u30b9\u30c8\u30e9\u30af\u30bf\u5185\u3067\u306f\u5270\u4f59\u3092\u53d6\u308a\u307e\u305b\u3093\uff0e\u305d\u306e\u305f\u3081\uff0c \u2208 [0,) \u3092\u6e80\u305f\u3059\u3088\u3046\u306a \u3092\u6e21\u3057\u3066\u304f\u3060\u3055\u3044\uff0e\u3053\u306e\u30b3\u30f3\u30b9\u30c8\u30e9\u30af\u30bf\u306f O(1) \u3067\u5b9f\u884c\u3055\u308c\u307e\u3059\uff0e\r\n public ModInt(long n) { num = n; }\r\n /// \r\n /// \u3053\u306e\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u306e\u6570\u5024\u3092\u6587\u5b57\u5217\u306b\u5909\u63db\u3057\u307e\u3059\uff0e\r\n /// \r\n /// [0,) \u306e\u7bc4\u56f2\u5185\u306e\u6574\u6570\u3092 10 \u9032\u8868\u8a18\u3057\u305f\u3082\u306e\uff0e\r\n public override string ToString() { return num.ToString(); }\r\n public static ModInt operator +(ModInt l, ModInt r) { l.num += r.num; if (l.num >= Mod) l.num -= Mod; return l; }\r\n public static ModInt operator -(ModInt l, ModInt r) { l.num -= r.num; if (l.num < 0) l.num += Mod; return l; }\r\n public static ModInt operator *(ModInt l, ModInt r) { return new ModInt(l.num * r.num % Mod); }\r\n public static implicit operator ModInt(long n) { n %= Mod; if (n < 0) n += Mod; return new ModInt(n); }\r\n\r\n /// \r\n /// \u4e0e\u3048\u3089\u308c\u305f 2 \u3064\u306e\u6570\u5024\u304b\u3089\u3079\u304d\u5270\u4f59\u3092\u8a08\u7b97\u3057\u307e\u3059\uff0e\r\n /// \r\n /// \u3079\u304d\u4e57\u306e\u5e95\r\n /// \u3079\u304d\u6307\u6570\r\n /// \u7e70\u308a\u8fd4\u3057\u4e8c\u4e57\u6cd5\u306b\u3088\u308a O(N log N) \u3067\u5b9f\u884c\u3055\u308c\u307e\u3059\uff0e\r\n public static ModInt Pow(ModInt v, long k) { return Pow(v.num, k); }\r\n\r\n /// \r\n /// \u4e0e\u3048\u3089\u308c\u305f 2 \u3064\u306e\u6570\u5024\u304b\u3089\u3079\u304d\u5270\u4f59\u3092\u8a08\u7b97\u3057\u307e\u3059\uff0e\r\n /// \r\n /// \u3079\u304d\u4e57\u306e\u5e95\r\n /// \u3079\u304d\u6307\u6570\r\n /// \u7e70\u308a\u8fd4\u3057\u4e8c\u4e57\u6cd5\u306b\u3088\u308a O(N log N) \u3067\u5b9f\u884c\u3055\u308c\u307e\u3059\uff0e\r\n public static ModInt Pow(long v, long k)\r\n {\r\n long ret = 1;\r\n for (k %= Mod - 1; k > 0; k >>= 1, v = v * v % Mod)\r\n if ((k & 1) == 1) ret = ret * v % Mod;\r\n return new ModInt(ret);\r\n }\r\n /// \r\n /// \u4e0e\u3048\u3089\u308c\u305f\u6570\u306e\u9006\u5143\u3092\u8a08\u7b97\u3057\u307e\u3059\uff0e\r\n /// \r\n /// \u9006\u5143\u3092\u53d6\u308b\u5bfe\u8c61\u3068\u306a\u308b\u6570\r\n /// \u9006\u5143\u3068\u306a\u308b\u3088\u3046\u306a\u5024\r\n /// \u6cd5\u304c\u7d20\u6570\u3067\u3042\u308b\u3053\u3068\u3092\u4eee\u5b9a\u3057\u3066\uff0c\u30d5\u30a7\u30eb\u30de\u30fc\u306e\u5c0f\u5b9a\u7406\u306b\u5f93\u3063\u3066\u9006\u5143\u3092 O(log N) \u3067\u8a08\u7b97\u3057\u307e\u3059\uff0e\r\n public static ModInt Inverse(ModInt v) { return Pow(v, Mod - 2); }\r\n }\r\n #endregion\r\n #region Binomial Coefficient\r\n public class BinomialCoefficient\r\n {\r\n public ModInt[] fact, ifact;\r\n public BinomialCoefficient(int n)\r\n {\r\n fact = new ModInt[n + 1];\r\n ifact = new ModInt[n + 1];\r\n fact[0] = 1;\r\n for (int i = 1; i <= n; i++)\r\n fact[i] = fact[i - 1] * i;\r\n ifact[n] = ModInt.Inverse(fact[n]);\r\n for (int i = n - 1; i >= 0; i--)\r\n ifact[i] = ifact[i + 1] * (i + 1);\r\n ifact[0] = ifact[1];\r\n }\r\n public ModInt this[int n, int r]\r\n {\r\n get\r\n {\r\n if (n < 0 || n >= fact.Length || r < 0 || r > n) return 0;\r\n return fact[n] * ifact[n - r] * ifact[r];\r\n }\r\n }\r\n public ModInt RepeatedCombination(int n, int k)\r\n {\r\n if (k == 0) return 1;\r\n return this[n + k - 1, k];\r\n }\r\n }\r\n #endregion\r\n}\r\n\r\n\r\nnamespace CompLib.Util\r\n{\r\n using System;\r\n using System.Linq;\r\n\r\n class Scanner\r\n {\r\n private string[] _line;\r\n private int _index;\r\n private const char Separator = ' ';\r\n\r\n public Scanner()\r\n {\r\n _line = new string[0];\r\n _index = 0;\r\n }\r\n\r\n public string Next()\r\n {\r\n if (_index >= _line.Length)\r\n {\r\n string s;\r\n do\r\n {\r\n s = Console.ReadLine();\r\n } while (s.Length == 0);\r\n\r\n _line = s.Split(Separator);\r\n _index = 0;\r\n }\r\n\r\n return _line[_index++];\r\n }\r\n\r\n public string ReadLine()\r\n {\r\n _index = _line.Length;\r\n return Console.ReadLine();\r\n }\r\n\r\n public int NextInt() => int.Parse(Next());\r\n public long NextLong() => long.Parse(Next());\r\n public double NextDouble() => double.Parse(Next());\r\n public decimal NextDecimal() => decimal.Parse(Next());\r\n public char NextChar() => Next()[0];\r\n public char[] NextCharArray() => Next().ToCharArray();\r\n\r\n public string[] Array()\r\n {\r\n string s = Console.ReadLine();\r\n _line = s.Length == 0 ? new string[0] : s.Split(Separator);\r\n _index = _line.Length;\r\n return _line;\r\n }\r\n\r\n public int[] IntArray() => Array().Select(int.Parse).ToArray();\r\n public long[] LongArray() => Array().Select(long.Parse).ToArray();\r\n public double[] DoubleArray() => Array().Select(double.Parse).ToArray();\r\n public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();\r\n }\r\n}\r\n", "lang_cluster": "C#", "tags": ["math", "greedy", "constructive algorithms", "combinatorics"], "code_uid": "21c74bf05eb15c223e3b43937ed9b163", "src_uid": "dc7b887afcc2e95c4e90619ceda63071", "difficulty": 1900.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Linq;\n\nnamespace CSharp\n{\n class _1060B\n {\n public static void Main()\n {\n long n = long.Parse(Console.ReadLine());\n long a = 0;\n\n while (a * 10 + 9 < n)\n {\n a = a * 10 + 9;\n }\n\n long b = n - a;\n Console.WriteLine(a.ToString().Sum(c => c - '0') + b.ToString().Sum(c => c - '0'));\n }\n }\n}", "lang_cluster": "C#", "tags": ["greedy"], "code_uid": "41a86c1a8f2b17059fad74799872452e", "src_uid": "5c61b4a4728070b9de49d72831cd2329", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\nusing System.IO;\nnamespace Codefoeces\n{\n class Program\n {\n static void Main(string[] args)\n {\n\n long n = long.Parse(Console.ReadLine());\n long max = -1;\n long a1 = n / 2;\n\n long a = 0 ;\n long b = 0; ;\n int i = 1;\n\n if (n == 1)\n {\n Console.WriteLine(1);\n return;\n }\n while (i < 10 && n-b >= 0)\n {\n b = long.Parse(i +\"\"+ new string('9', (int)Math.Log10(a1)) );\n a = n - b;\n if (a >= 0)\n {\n if (a.ToString().Sum(c => c - '0') + b.ToString().Sum(c => c - '0') > max)\n {\n max = a.ToString().Sum(c => c - '0') + b.ToString().Sum(c => c - '0');\n }\n }\n i++;\n }\n Console.WriteLine(max);\n\n \n\n }\n }\n}", "lang_cluster": "C#", "tags": ["greedy"], "code_uid": "6acbef7cfb8aa69ca32e11f3693236e1", "src_uid": "5c61b4a4728070b9de49d72831cd2329", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Text;\nusing System.Diagnostics;\n\nclass Solver\n{\n\tpublic void Solve()\n\t{\n\t\tvar s = CF.ReadLine();\n\t\tint res = 0;\n\t\tforeach (var c in s)\n\t\t{\n\t\t\tres *= 16;\n\t\t\tswitch (c)\n\t\t\t{\n\t\t\t\tcase '>': res += 8; break;\n\t\t\t\tcase '<': res += 9; break;\n\t\t\t\tcase '+': res += 10; break;\n\t\t\t\tcase '-': res += 11; break;\n\t\t\t\tcase '.': res += 12; break;\n\t\t\t\tcase ',': res += 13; break;\n\t\t\t\tcase '[': res += 14; break;\n\t\t\t\tcase ']': res += 15; break;\n\t\t\t}\n\t\t\tres %= 1000003;\n\t\t}\n\t\tCF.WriteLine(res);\n\t}\n\n\n\n\t// test\n\tstatic Utils CF = new Utils(new[]{\n@\"\n,.\n\"\n,\n@\"\n++++[>,.<-]\n\"\n \n });\n #region test\n\n static void Main(string[] args)\n {\n#if DEBUG\n for (int t=0;t();\n string[] ss = _test_input[t].Replace(\"\\n\", \"\").Split('\\r');\n for (int i = 0; i < ss.Length; i++)\n {\n if (\n (i == 0 || i == ss.Length - 1) &&\n ss[i].Length == 0\n )\n continue;\n\n _lines.Add(ss[i]);\n }\n }\n\n public int TestCount\n {\n get\n {\n return _test_input.Length;\n }\n }\n\n public string ReadLine()\n {\n#if DEBUG\n string s = null;\n if (_lines.Count > 0)\n {\n s = _lines[0];\n _lines.RemoveAt(0);\n }\n return s;\n\n#else\n //return _sr.ReadLine();\n return Console.In.ReadLine();\n#endif\n }\n\n public void WriteLine(object o)\n {\n#if DEBUG\n System.Diagnostics.Trace.WriteLine(o);\n#else\n //_sw.WriteLine(o);\n Console.WriteLine(o);\n#endif\n }\n\n public void Write(object o)\n {\n#if DEBUG\n System.Diagnostics.Trace.Write(o);\n#else\n //_sw.Write(o);\n Console.Write(o);\n#endif\n }\n\n string[] _test_input;\n\n List _lines;\n\n#if DEBUG\n public Utils(string[] test_input)\n {\n _test_input = test_input;\n }\n#else\n\n public Utils(string[] dummy)\n {\n //_sr = new System.IO.StreamReader(\"input.txt\");\n //_sw = new System.IO.StreamWriter(\"output.txt\");\n }\n#endif\n\n }\n\n #endregion\n}\n\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "048658414b5780b42d671b1679cf78be", "src_uid": "04fc8dfb856056f35d296402ad1b2da1", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Text.RegularExpressions;\n\nnamespace Codeforces\n{\n class A\n {\n private static bool s_time = false;\n\n static long mod = 1000003;\n\n private static object Go()\n {\n string s = GetString();\n\n Dictionary map = new Dictionary();\n map['>'] = 8;\n map['<'] = 9;\n map['+'] = 10;\n map['-'] = 11;\n map['.'] = 12;\n map[','] = 13;\n map['['] = 14;\n map[']'] = 15;\n\n long ret = 0;\n for (int i = 0; i < s.Length; i++)\n {\n ret = (ret * 16 + map[s[i]]) % mod;\n }\n\n return ret;\n }\n\n #region Template\n\n public static void Main(string[] args)\n {\n DateTime start = DateTime.Now;\n object output = Go();\n TimeSpan duration = DateTime.Now.Subtract(start);\n if (output != null)\n Wl(output.ToString());\n if (s_time)\n Wl(duration);\n }\n\n private static IEnumerator ioEnum;\n private static string GetString()\n {\n while (ioEnum == null || !ioEnum.MoveNext())\n {\n ioEnum = Console.ReadLine().Split().AsEnumerable().GetEnumerator();\n }\n\n return ioEnum.Current;\n }\n\n private static int GetInt()\n {\n return int.Parse(GetString());\n }\n\n private static long GetLong()\n {\n return long.Parse(GetString());\n }\n\n private static double GetDouble()\n {\n return double.Parse(GetString());\n }\n\n private static List GetIntArr(int n)\n {\n List ret = new List(n);\n for (int i = 0; i < n; i++)\n {\n ret.Add(GetInt());\n }\n return ret;\n }\n\n private static void Wl(T o)\n {\n Console.WriteLine(o.ToString());\n }\n\n private static void Wl(IEnumerable enumerable)\n {\n Wl(string.Join(\" \", enumerable.Select(e => e.ToString()).ToArray()));\n }\n\n public struct Tuple : IComparable>\n where T : IComparable\n where K : IComparable\n {\n public T Item1;\n public K Item2;\n\n public Tuple(T t, K k)\n {\n Item1 = t;\n Item2 = k;\n }\n\n public override bool Equals(object obj)\n {\n var o = (Tuple)obj;\n return o.Item1.Equals(Item1) && o.Item2.Equals(Item2);\n }\n\n public override int GetHashCode()\n {\n return Item1.GetHashCode() ^ Item2.GetHashCode();\n }\n\n public override string ToString()\n {\n return \"(\" + Item1 + \" \" + Item2 + \")\";\n }\n\n #region IComparable> Members\n\n public int CompareTo(Tuple other)\n {\n int ret = Item1.CompareTo(other.Item1);\n if (ret != 0) return ret;\n return Item2.CompareTo(other.Item2);\n }\n\n #endregion\n }\n\n #endregion\n }\n}", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "0a720c92b97986d0964eb3e3c31e31ff", "src_uid": "04fc8dfb856056f35d296402ad1b2da1", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections;\nusing System.Collections.Generic;\nusing System.Globalization;\nusing System.IO;\nusing System.Linq;\nusing System.Numerics;\nusing System.Text;\n\nclass Program\n{\n private static void Main(string[] args)\n {\n var tmp = Console.ReadLine().Split(' ');\n var s = tmp[0];\n var k = int.Parse(tmp[1]);\n\n if (s.Count(ss => ss == '0') < k)\n {\n Console.Write(s.Length - 1);\n return;\n }\n\n int cnt = 0;\n int zeros = 0;\n for (int i = s.Length - 1; i > 0; i--)\n {\n if (s[i] != '0')\n cnt++;\n else\n zeros++;\n\n if (zeros == k)\n {\n Console.WriteLine(cnt);\n return;\n }\n }\n\n Console.Write(0);\n }\n\n\n private const int Mod = 1000000000 + 7;\n\n #region Data Read\n private static char ReadSign()\n {\n while (true)\n {\n int ans = consoleReader.Read();\n if (ans == '+' || ans == '-' || ans == '?')\n return (char)ans;\n }\n }\n\n private static long GCD(long a, long b)\n {\n if (a % b == 0) return b;\n return GCD(b, a % b);\n }\n\n private static List[] ReadGraph(int n, int m)\n {\n List[] g = new List[n];\n for (int i = 0; i < g.Length; i++) g[i] = new List();\n for (int i = 0; i < m; i++)\n {\n int a = RI() - 1;\n int b = RI() - 1;\n\n g[a].Add(b);\n g[b].Add(a);\n }\n\n return g;\n }\n\n private static int[,] ReadGraphAsMatrix(int n, int m)\n {\n int[,] matrix = new int[n + 1, n + 1];\n for (int i = 0; i < m; i++)\n {\n int a = RI();\n int b = RI();\n matrix[a, b] = matrix[b, a] = 1;\n }\n\n return matrix;\n }\n\n private static void Sort(ref int a, ref int b)\n {\n if (a > b) Swap(ref a, ref b);\n }\n\n private static void Swap(ref int a, ref int b)\n {\n int tmp = a;\n a = b;\n b = tmp;\n }\n\n private const int BufferSize = 1 << 16;\n private static StreamReader consoleReader;\n private static MemoryStream testData;\n\n private static int RI()\n {\n int ans = 0;\n int mul = 1;\n do\n {\n ans = consoleReader.Read();\n if (ans == -1)\n return 0;\n if (ans == '-') mul = -1;\n } while (ans < '0' || ans > '9');\n\n ans -= '0';\n while (true)\n {\n int chr = consoleReader.Read();\n if (chr < '0' || chr > '9')\n return ans * mul;\n ans = ans * 10 + chr - '0';\n }\n }\n\n private static ulong RUL()\n {\n ulong ans = 0;\n int chr;\n do\n {\n chr = consoleReader.Read();\n if (chr == -1)\n return 0;\n } while (chr < '0' || chr > '9');\n\n ans = (uint)(chr - '0');\n while (true)\n {\n chr = consoleReader.Read();\n if (chr < '0' || chr > '9')\n return ans;\n ans = ans * 10 + (uint)(chr - '0');\n }\n }\n\n private static long RL()\n {\n long ans = 0;\n int mul = 1;\n do\n {\n ans = consoleReader.Read();\n if (ans == -1)\n return 0;\n if (ans == '-') mul = -1;\n } while (ans < '0' || ans > '9');\n\n ans -= '0';\n while (true)\n {\n int chr = consoleReader.Read();\n if (chr < '0' || chr > '9')\n return ans * mul;\n ans = ans * 10 + chr - '0';\n }\n }\n\n private static int[] RIA(int n)\n {\n int[] ans = new int[n];\n for (int i = 0; i < n; i++)\n ans[i] = RI();\n return ans;\n }\n\n private static long[] RLA(int n)\n {\n long[] ans = new long[n];\n for (int i = 0; i < n; i++)\n ans[i] = RL();\n return ans;\n }\n\n private static char[] ReadWord()\n {\n int ans;\n\n do\n {\n ans = consoleReader.Read();\n } while (!((ans >= 'a' && ans <= 'z') || (ans >= 'A' && ans <= 'Z')));\n\n List s = new List();\n do\n {\n s.Add((char)ans);\n ans = consoleReader.Read();\n } while ((ans >= 'a' && ans <= 'z') || (ans >= 'A' && ans <= 'Z'));\n\n return s.ToArray();\n }\n\n private static char[] ReadString(int n)\n {\n int ans;\n\n do\n {\n ans = consoleReader.Read();\n } while (!((ans >= 'a' && ans <= 'z') || (ans >= 'A' && ans <= 'Z')));\n\n char[] s = new char[n];\n int pos = 0;\n do\n {\n s[pos++] = (char)ans;\n if (pos == n) break;\n ans = consoleReader.Read();\n } while ((ans >= 'a' && ans <= 'z') || (ans >= 'A' && ans <= 'Z'));\n\n return s;\n }\n\n private static char[] ReadStringLine()\n {\n int ans;\n\n do\n {\n ans = consoleReader.Read();\n } while (ans == 10 || ans == 13);\n\n List s = new List();\n\n do\n {\n s.Add((char)ans);\n ans = consoleReader.Read();\n } while (ans != 10 && ans != 13 && ans != -1);\n\n return s.ToArray();\n }\n\n private static char ReadLetter()\n {\n while (true)\n {\n int ans = consoleReader.Read();\n if ((ans >= 'a' && ans <= 'z') || (ans >= 'A' && ans <= 'Z'))\n return (char)ans;\n }\n }\n private static char ReadNonLetter()\n {\n while (true)\n {\n int ans = consoleReader.Read();\n if (!((ans >= 'a' && ans <= 'z') || (ans >= 'A' && ans <= 'Z')))\n return (char)ans;\n }\n }\n\n private static char ReadAnyOf(IEnumerable allowed)\n {\n while (true)\n {\n char ans = (char)consoleReader.Read();\n if (allowed.Contains(ans))\n return ans;\n }\n }\n\n private static char ReadDigit()\n {\n while (true)\n {\n int ans = consoleReader.Read();\n if (ans >= '0' && ans <= '9')\n return (char)ans;\n }\n }\n\n private static int ReadDigitInt()\n {\n return ReadDigit() - (int)'0';\n }\n\n private static char ReadAnyChar()\n {\n return (char)consoleReader.Read();\n }\n\n private static string DoubleToString(double x)\n {\n return x.ToString(CultureInfo.InvariantCulture);\n }\n\n private static double DoubleFromString(string x)\n {\n return double.Parse(x, CultureInfo.InvariantCulture);\n }\n\n static Program()\n {\n //Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;\n consoleReader = new StreamReader(Console.OpenStandardInput(BufferSize), Encoding.ASCII, false, BufferSize);\n }\n\n private static void PushTestData(StringBuilder sb)\n {\n PushTestData(sb.ToString());\n }\n private static void PushTestData(string data)\n {\n#if TOLYAN_TEST\n if (testData == null)\n {\n testData = new MemoryStream();\n consoleReader = new StreamReader(testData);\n }\n\n var pos = testData.Position;\n var bytes = Encoding.UTF8.GetBytes(data);\n testData.Write(bytes, 0, bytes.Length);\n testData.Flush();\n testData.Position = pos;\n#endif\n }\n #endregion\n}", "lang_cluster": "C#", "tags": ["brute force", "greedy"], "code_uid": "c9b50894d006d99033bb5df2138ecc90", "src_uid": "7a8890417aa48c2b93b559ca118853f9", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nclass Program\n {\n public static void Main(string[] args)\n {\n string[] input = Console.In.ReadLine().Split(new char[] { ' ', '\\n', '\\r', '\\t' }, StringSplitOptions.RemoveEmptyEntries);\n int a = int.Parse(input[1]);\n int deleted = 0;\n for(int i = input[0].Length-1; i>0 && a>0; --i)\n {\n if (input[0][i] == '0') a--;\n else deleted++;\n }\n if (a > 0) deleted = input[0].Length - 1;\n Console.WriteLine(deleted);\n }\n }", "lang_cluster": "C#", "tags": ["brute force", "greedy"], "code_uid": "76fd02b8be0d6d9c1c7ccbff02ab6520", "src_uid": "7a8890417aa48c2b93b559ca118853f9", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Collections;\nusing System.Linq;\n\n\n\n\nnamespace contest\n{\n\n class contest\n {\n\n\n static void Main(string[] args)\n {\n\n\n //int n = int.Parse(Console.ReadLine());\n //var input = Console.ReadLine().Split().Select(int.Parse).ToArray();\n\n //var num = Console.ReadLine().Split().Select(int.Parse).ToArray();\n\n\n\n\n var num = Console.ReadLine().Split().Select(int.Parse).ToArray();\n int a = num[0];\n int target = num[1];\n int dif = num[2];\n\n if (a == target) Console.WriteLine(\"YES\");\n else if (dif == 0) Console.WriteLine(\"NO\");\n else if (target > a && dif < 0) Console.WriteLine(\"NO\");\n else if (target < a && dif > 0) Console.WriteLine(\"NO\");\n else if ((target - a) % dif == 0) Console.WriteLine(\"YES\");\n else Console.WriteLine(\"NO\");\n\n\n\n\n //Console.WriteLine();\n\n\n\n\n\n //Console.Read();\n\n\n }\n\n \n\n\n }\n\n\n}\n", "lang_cluster": "C#", "tags": ["math"], "code_uid": "83e950d27d76043614b1f631abd3a1f8", "src_uid": "9edf42c20ddf22a251b84553d7305a7d", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\n\n\nnamespace ConsoleApplication16\n{\n class Program\n {\n static void Main(string[] args)\n {\n string[] s = Console.ReadLine().Split(' ');\n int[] n = Array.ConvertAll(s, int.Parse);\n\n if (n[2] == 0)\n {\n if (n[1] == n[0])\n {\n Console.WriteLine(\"YES\");\n }\n else\n {\n Console.WriteLine(\"NO\");\n }\n }\n \n \n else if ((n[1] < n[0] && n[2] > 0) || (n[1] > n[0] && n[2] < 0))\n {\n Console.WriteLine(\"NO\");\n }\n else\n {\n if ((n[1] - n[0]) % n[2] == 0)\n {\n Console.WriteLine(\"YES\");\n }\n else\n {\n Console.WriteLine(\"NO\");\n }\n }\n }\n\n \n }\n \n}\n", "lang_cluster": "C#", "tags": ["math"], "code_uid": "cd232bfc52ef68543b24056e3745c71f", "src_uid": "9edf42c20ddf22a251b84553d7305a7d", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\nusing System;\nusing System.Collections.Generic;\nusing System.IO;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace AlgoTraining.Codeforces.D_s\n{\n public class FastScanner : StreamReader\n {\n private string[] _line;\n private int _iterator;\n\n public FastScanner(Stream stream) : base(stream)\n {\n _line = null;\n _iterator = 0;\n }\n public int NextInt()\n {\n if (_line == null || _iterator >= _line.Length)\n {\n _line = base.ReadLine().Split(' ');\n _iterator = 0;\n }\n if (_line.Count() == 0) throw new IndexOutOfRangeException(\"Input string is empty\");\n return Convert.ToInt32(_line[_iterator++]);\n }\n public long NextLong()\n {\n if (_line == null || _iterator >= _line.Length)\n {\n _line = base.ReadLine().Split(' ');\n _iterator = 0;\n }\n if (_line.Count() == 0) throw new IndexOutOfRangeException(\"Input string is empty\");\n return Convert.ToInt64(_line[_iterator++]);\n }\n }\n class IteratedLinearFunctionECR13\n {\n private static int _mod = (int)1e9 + 7;\n public static void Main(string[] args)\n {\n using (FastScanner fs = new FastScanner(new BufferedStream(Console.OpenStandardInput())))\n using (StreamWriter writer = new StreamWriter(new BufferedStream(Console.OpenStandardOutput())))\n {\n long A = fs.NextLong(), B = fs.NextLong(), n = fs.NextLong(), x = fs.NextLong();\n if (n == 0) writer.WriteLine(x);\n else if (n == 1) writer.WriteLine((A * x + B) % _mod);\n else\n {\n long[,] initial = new long[,] { { A * x + B, 1 } };\n long[,] factor = new long[,] { { A, 0 }, { B, 1 } };\n long[,] res = MultiplyMatricesMod(initial, BinPowMatrixMod(factor, n - 1, _mod), _mod);\n writer.WriteLine(res[0, 0]);\n }\n }\n }\n public static long BinPow(long a, long p)\n {\n if (p == 0) return 1;\n if ((p & 1) == 0)\n {\n long t = BinPow(a, p / 2);\n return t * t;\n }\n else\n {\n return a * BinPow(a, p - 1);\n }\n }\n public static long BinPowMod(long a, long p, long mod)\n {\n if (p == 0) return 1;\n if ((p & 1) == 0)\n {\n long t = BinPow(a, p / 2);\n return (t * t) % mod;\n }\n else\n {\n return (a % mod * BinPow(a, p - 1)) % mod;\n }\n }\n\n public static long[,] BinPowMatrix(long[,] a, long p) // p >= 1\n {\n if (a.GetLength(0) != a.GetLength(1))\n {\n throw new Exception(\"Not a square matrix\");\n }\n\n if (p == 1) return a;\n if ((p & 1) == 0)\n {\n long[,] t = BinPowMatrix(a, p / 2);\n return MultiplyMatrices(t, t);\n }\n else\n {\n return MultiplyMatrices(a, BinPowMatrix(a, p - 1));\n }\n }\n\n public static long[,] BinPowMatrixMod(long[,] a, long p, long mod) // p >= 1\n {\n if (a.GetLength(0) != a.GetLength(1))\n {\n throw new Exception(\"Not a square matrix\");\n }\n\n if (p == 1) return a;\n if ((p & 1) == 0)\n {\n long[,] t = BinPowMatrixMod(a, p / 2, mod);\n return MultiplyMatricesMod(t, t, mod);\n }\n else\n {\n return MultiplyMatricesMod(a, BinPowMatrixMod(a, p - 1, mod), mod);\n }\n }\n\n private static long[,] MultiplyMatrices(long[,] a, long[,] b)\n {\n if (a.GetLength(1) == b.GetLength(0))\n {\n long[,] c = new long[a.GetLength(0), b.GetLength(1)];\n for (int i = 0; i < c.GetLength(0); i++)\n {\n for (int j = 0; j < c.GetLength(1); j++)\n {\n c[i, j] = 0;\n for (int k = 0; k < a.GetLength(1); k++)\n c[i, j] = c[i, j] + a[i, k] * b[k, j];\n }\n }\n return c;\n }\n else\n {\n throw new Exception(\"Can't multiply because of incompatible sizes\");\n }\n }\n\n private static long[,] MultiplyMatricesMod(long[,] a, long[,] b, long mod)\n {\n if (a.GetLength(1) == b.GetLength(0))\n {\n long[,] c = new long[a.GetLength(0), b.GetLength(1)];\n for (int i = 0; i < c.GetLength(0); i++)\n {\n for (int j = 0; j < c.GetLength(1); j++)\n {\n c[i, j] = 0;\n for (int k = 0; k < a.GetLength(1); k++)\n {\n c[i, j] = c[i, j] + a[i, k] % mod * b[k, j] % mod;\n c[i, j] %= mod;\n }\n }\n }\n return c;\n }\n else\n {\n throw new Exception(\"Can't multiply because of incompatible sizes\");\n }\n }\n\n private static long[,] MatrixMod(long[,] a, long mod)\n {\n long[,] b = new long[a.GetLength(0), a.GetLength(1)];\n for (int i = 0; i < a.GetLength(0); i++)\n {\n for (int j = 0; j < a.GetLength(1); j++)\n {\n b[i, j] = a[i, j] % mod;\n }\n }\n return b;\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "number theory"], "code_uid": "64dab52391b88c0e106e369f7f6ef54a", "src_uid": "e22a1fc38c8b2a4cc30ce3b9f893028e", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.IO;\nusing System.Runtime.CompilerServices;\nusing System.Text;\nusing System.Diagnostics;\nusing System.Numerics;\nusing static System.Console;\nusing static System.Convert;\nusing static System.Math;\nusing static Template;\nusing Pi = Pair;\n\nclass Solver\n{\n public void Solve(Scanner sc)\n {\n long A, B, n, x;\n sc.Make(out A, out B, out n, out x);\n if (A == 1) Fail((x + (ModInt)B * n));\n ModInt res = ModInt.Pow(A, n)*x;\n res += B * (1 - ModInt.Pow(A, n)) / (1 - A);\n WriteLine(res);\n }\n}\n\npublic struct ModInt\n{\n public const long MOD = (int)1e9 + 7;\n //public const long MOD = 998244353;\n public long Value { get; set; }\n public ModInt(long n = 0) { Value = n; }\n private static ModInt[] fac;//i!\n private static ModInt[] inv;//1/i\n private static ModInt[] facinv;//1/(i!)\n public override string ToString() => Value.ToString();\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static ModInt operator +(ModInt l, ModInt r)\n {\n l.Value += r.Value;\n if (l.Value >= MOD) l.Value -= MOD;\n return l;\n }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static ModInt operator -(ModInt l, ModInt r)\n {\n l.Value -= r.Value;\n if (l.Value < 0) l.Value += MOD;\n return l;\n }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static ModInt operator *(ModInt l, ModInt r) => new ModInt(l.Value * r.Value % MOD);\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static ModInt operator /(ModInt l, ModInt r) => l * Pow(r, MOD - 2);\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static implicit operator long(ModInt l) => l.Value;\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static implicit operator ModInt(long n)\n {\n n %= MOD; if (n < 0) n += MOD;\n return new ModInt(n);\n }\n\n public static ModInt Pow(ModInt m, long n)\n {\n if (n == 0) return 1;\n if (n % 2 == 0) return Pow(m * m, n >> 1);\n else return Pow(m * m, n >> 1) * m;\n }\n\n public static void Build(int n)\n {\n fac = new ModInt[n + 1];\n facinv = new ModInt[n + 1];\n inv = new ModInt[n + 1];\n inv[1] = 1;\n fac[0] = fac[1] = 1;\n facinv[0] = facinv[1] = 1;\n for (var i = 2; i <= n; i++)\n {\n fac[i] = fac[i - 1] * i;\n inv[i] = MOD - inv[MOD % i] * (MOD / i);\n facinv[i] = facinv[i - 1] * inv[i];\n }\n }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static ModInt Fac(ModInt n) => fac[n];\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static ModInt Inv(ModInt n) => inv[n];\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static ModInt FacInv(ModInt n) => facinv[n];\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static ModInt Comb(ModInt n, ModInt r)\n {\n if (n < r) return 0;\n if (n == r) return 1;\n var calc = fac[n];\n calc = calc * facinv[r];\n calc = calc * facinv[n - r];\n return calc;\n }\n}\n#region Template\npublic static class Template\n{\n static void Main(string[] args)\n {\n Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });\n new Solver().Solve(new Scanner());\n Console.Out.Flush();\n }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static bool chmin(ref T a, T b) where T : IComparable { if (a.CompareTo(b) > 0) { a = b; return true; } return false; }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static bool chmax(ref T a, T b) where T : IComparable { if (a.CompareTo(b) < 0) { a = b; return true; } return false; }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static void swap(ref T a, ref T b) { var t = b; b = a; a = t; }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static void swap(this IList A, int i, int j) { var t = A[i]; A[i] = A[j]; A[j] = t; }\n public static T[] Create(int n, Func f) { var rt = new T[n]; for (var i = 0; i < rt.Length; ++i) rt[i] = f(); return rt; }\n public static T[] Create(int n, Func f) { var rt = new T[n]; for (var i = 0; i < rt.Length; ++i) rt[i] = f(i); return rt; }\n public static IEnumerable Shuffle(this IEnumerable A) => A.OrderBy(v => Guid.NewGuid());\n public static int CompareTo(this T[] A, T[] B, Comparison cmp = null) { cmp = cmp ?? Comparer.Default.Compare; for (var i = 0; i < Min(A.Length, B.Length); i++) { int c = cmp(A[i], B[i]); if (c > 0) return 1; else if (c < 0) return -1; } if (A.Length == B.Length) return 0; if (A.Length > B.Length) return 1; else return -1; }\n public static int MaxElement(this IList A, Comparison cmp = null) { cmp = cmp ?? Comparer.Default.Compare; T max = A[0]; int rt = 0; for (int i = 1; i < A.Count; i++) if (cmp(max, A[i]) < 0) { max = A[i]; rt = i; } return rt; }\n public static T PopBack(this List A) { var v = A[A.Count - 1]; A.RemoveAt(A.Count - 1); return v; }\n public static void Fail(T s) { Console.WriteLine(s); Console.Out.Close(); Environment.Exit(0); }\n}\npublic class Scanner\n{\n public string Str => Console.ReadLine().Trim();\n public int Int => int.Parse(Str);\n public long Long => long.Parse(Str);\n public double Double => double.Parse(Str);\n public int[] ArrInt => Str.Split(' ').Select(int.Parse).ToArray();\n public long[] ArrLong => Str.Split(' ').Select(long.Parse).ToArray();\n public char[][] Grid(int n) => Create(n, () => Str.ToCharArray());\n public int[] ArrInt1D(int n) => Create(n, () => Int);\n public long[] ArrLong1D(int n) => Create(n, () => Long);\n public int[][] ArrInt2D(int n) => Create(n, () => ArrInt);\n public long[][] ArrLong2D(int n) => Create(n, () => ArrLong);\n private Queue q = new Queue();\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public T Next() { if (q.Count == 0) foreach (var item in Str.Split(' ')) q.Enqueue(item); return (T)Convert.ChangeType(q.Dequeue(), typeof(T)); }\n public void Make(out T1 v1) => v1 = Next();\n public void Make(out T1 v1, out T2 v2) { v1 = Next(); v2 = Next(); }\n public void Make(out T1 v1, out T2 v2, out T3 v3) { Make(out v1, out v2); v3 = Next(); }\n public void Make(out T1 v1, out T2 v2, out T3 v3, out T4 v4) { Make(out v1, out v2, out v3); v4 = Next(); }\n public void Make(out T1 v1, out T2 v2, out T3 v3, out T4 v4, out T5 v5) { Make(out v1, out v2, out v3, out v4); v5 = Next(); }\n public void Make(out T1 v1, out T2 v2, out T3 v3, out T4 v4, out T5 v5, out T6 v6) { Make(out v1, out v2, out v3, out v4, out v5); v6 = Next(); }\n //public (T1, T2) Make() { Make(out T1 v1, out T2 v2); return (v1, v2); }\n //public (T1, T2, T3) Make() { Make(out T1 v1, out T2 v2, out T3 v3); return (v1, v2, v3); }\n //public (T1, T2, T3, T4) Make() { Make(out T1 v1, out T2 v2, out T3 v3, out T4 v4); return (v1, v2, v3, v4); }\n}\npublic class Pair : IComparable>\n{\n public T1 v1;\n public T2 v2;\n public Pair() { }\n public Pair(T1 v1, T2 v2)\n { this.v1 = v1; this.v2 = v2; }\n\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public int CompareTo(Pair p)\n {\n var c = Comparer.Default.Compare(v1, p.v1);\n if (c == 0)\n c = Comparer.Default.Compare(v2, p.v2);\n return c;\n }\n public override string ToString() => $\"{v1.ToString()} {v2.ToString()}\";\n public void Deconstruct(out T1 a, out T2 b) { a = v1; b = v2; }\n}\n\npublic class Pair : Pair, IComparable>\n{\n public T3 v3;\n public Pair() : base() { }\n public Pair(T1 v1, T2 v2, T3 v3) : base(v1, v2)\n { this.v3 = v3; }\n\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public int CompareTo(Pair p)\n {\n var c = base.CompareTo(p);\n if (c == 0)\n c = Comparer.Default.Compare(v3, p.v3);\n return c;\n }\n public override string ToString() => $\"{base.ToString()} {v3.ToString()}\";\n public void Deconstruct(out T1 a, out T2 b, out T3 c) { Deconstruct(out a, out b); c = v3; }\n}\n#endregion\n", "lang_cluster": "C#", "tags": ["math", "number theory"], "code_uid": "2958c00408bd0f8778e3cebcce6de643", "src_uid": "e22a1fc38c8b2a4cc30ce3b9f893028e", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\n\nclass Program\n{\n\n static void Main(string[] args)\n {\n int n, m;\n string[] input = Console.ReadLine().Split(' ');\n n = int.Parse(input[0]);\n m = int.Parse(input[1]);\n long res = 1;\n const long d = 1000000009;\n for (long t = 2; m > 0; m /= 2, t = (t * t) % d)\n {\n if (m % 2 == 1)\n res = (res * t) % d;\n }\n res--;\n long ans = 1;\n for (int i = 0; i < n; i++)\n {\n ans *= res;\n ans %= 1000000009;\n if (res > 0)\n res--;\n }\n Console.WriteLine(ans);\n Console.ReadLine();\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "constructive algorithms", "combinatorics"], "code_uid": "7e9df42e4ab287d98d20826c2ca439ec", "src_uid": "fef4d9c94a93fcf6d536f33503b1d4b8", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Globalization;\nusing System.Linq;\nusing System.Text;\nusing System.Text.RegularExpressions;\nusing System.Threading;\n\nnamespace Codeforces\n{\n class A\n {\n private static ThreadStart s_threadStart = new A().Go;\n private static bool s_time = false;\n\n long mod = 1000000009;\n\n private void Go()\n {\n int n = GetInt();\n int m = GetInt();\n\n long ans = 1;\n long k = 1;\n for (int i = 0; i < m; i++)\n {\n k = (k * 2) % mod;\n }\n k--;\n for (int i = 0; i < n; i++)\n {\n ans = (ans * k) % mod;\n k--;\n }\n\n Wl(ans);\n }\n\n #region Template\n\n public static void Main(string[] args)\n {\n System.Diagnostics.Stopwatch timer = new System.Diagnostics.Stopwatch();\n Thread main = new Thread(new ThreadStart(s_threadStart), 512 * 1024 * 1024);\n timer.Start();\n main.Start();\n main.Join();\n timer.Stop();\n if (s_time)\n Wl(timer.ElapsedMilliseconds);\n }\n\n private static IEnumerator ioEnum;\n private static string GetString()\n {\n while (ioEnum == null || !ioEnum.MoveNext())\n {\n ioEnum = Console.ReadLine().Split().AsEnumerable().GetEnumerator();\n }\n\n return ioEnum.Current;\n }\n\n private static int GetInt()\n {\n return int.Parse(GetString());\n }\n\n private static long GetLong()\n {\n return long.Parse(GetString());\n }\n\n private static double GetDouble()\n {\n return double.Parse(GetString());\n }\n\n private static List GetIntArr(int n)\n {\n List ret = new List(n);\n for (int i = 0; i < n; i++)\n {\n ret.Add(GetInt());\n }\n return ret;\n }\n\n private static void Wl(T o)\n {\n if (o is double)\n {\n Wld((o as double?).Value, \"\");\n }\n else if (o is float)\n {\n Wld((o as float?).Value, \"\");\n }\n else\n Console.WriteLine(o.ToString());\n }\n\n private static void Wl(IEnumerable enumerable)\n {\n Wl(string.Join(\" \", enumerable.Select(e => e.ToString()).ToArray()));\n }\n\n private static void Wld(double d, string format)\n {\n Wl(d.ToString(format, CultureInfo.InvariantCulture));\n }\n\n public struct Tuple : IComparable>\n where T : IComparable\n where K : IComparable\n {\n public T Item1;\n public K Item2;\n\n public Tuple(T t, K k)\n {\n Item1 = t;\n Item2 = k;\n }\n\n public override bool Equals(object obj)\n {\n var o = (Tuple)obj;\n return o.Item1.Equals(Item1) && o.Item2.Equals(Item2);\n }\n\n public override int GetHashCode()\n {\n return Item1.GetHashCode() ^ Item2.GetHashCode();\n }\n\n public override string ToString()\n {\n return \"(\" + Item1 + \" \" + Item2 + \")\";\n }\n\n #region IComparable> Members\n\n public int CompareTo(Tuple other)\n {\n int ret = Item1.CompareTo(other.Item1);\n if (ret != 0) return ret;\n return Item2.CompareTo(other.Item2);\n }\n\n #endregion\n }\n\n #endregion\n }\n}", "lang_cluster": "C#", "tags": ["math", "constructive algorithms"], "code_uid": "e8ef59a6cf41b97cd9c2b73750eec24a", "src_uid": "fef4d9c94a93fcf6d536f33503b1d4b8", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "// Problem: 859B - Lazy Security Guard\n// Author: Gusztav Szmolik\n\nusing System;\n\nclass LazySecurityGuard\n {\n static int Main ()\n {\n string[] words = ReadSplitLine (1);\n if (words == null)\n return -1;\n uint n;\n if (!UInt32.TryParse (words[0], out n))\n return -1;\n if (n < 1 || n > 1000000)\n return -1;\n ushort a = 1;\n ushort aNext = 2;\n while (aNext*aNext <= n)\n {\n a = aNext;\n aNext++;\n }\n ushort r = Convert.ToUInt16 (n-a*a);\n ushort ans = Convert.ToUInt16 (r == 0 ? 4*a : (r > a ? 4*a+4 : 4*a+2));\n Console.WriteLine (ans);\n return 0;\n }\n \n static string[] ReadSplitLine (uint numWordNeed)\n {\n string line = Console.ReadLine ();\n if (line == null)\n return null;\n char[] delims = new char[2] {' ', '\\t'};\n string[] words = line.Split (delims,StringSplitOptions.RemoveEmptyEntries);\n return (words.Length == numWordNeed ? words : null);\n } \n }\n", "lang_cluster": "C#", "tags": ["brute force", "math", "geometry"], "code_uid": "9683dc424f755d7a1f9dc0b3833a24f7", "src_uid": "414cc57550e31d98c1a6a56be6722a12", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\n\nnamespace ConsoleApplication3\n{\n class Program\n {\n static void Main(string[] args)\n {\n\n\n\n\n\n double n = double.Parse(Console.ReadLine());\n\n double k = Math.Ceiling(Math.Sqrt(n));\n\n double s = Math.Floor(n / k);\n\n double res = 0;\n\n \n \n\n if ( n-k*s!=0 )\n {\n res = (k * 2 + s * 2) + 2;\n }\n else\n {\n res = (k * 2 + s * 2);\n }\n \n \n\n Console.WriteLine(res);\n\n\n \n\n // while (Console.ReadKey().Key != ConsoleKey.Enter) ;\n\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "math", "geometry"], "code_uid": "0c59f2238c45a264f4dae07dcb9d6b95", "src_uid": "414cc57550e31d98c1a6a56be6722a12", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\n\nnamespace HeidiLearnsHashingEasy\n{\n class Program\n {\n static void Main(string[] args)\n {\n string input;\n long r;\n long x, y;\n\n while (true)\n {\n input = Console.ReadLine();\n\n if (string.IsNullOrEmpty(input)) break;\n\n r = long.Parse(input);\n\n if (r % 2 == 0)\n {\n Console.WriteLine(\"NO\");\n }\n else\n {\n x = 1;\n y = (r - 3) / 2;\n\n if (y <= 0)\n Console.WriteLine(\"NO\");\n else\n Console.WriteLine(\"{0} {1}\", x, y);\n }\n }\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "math", "number theory"], "code_uid": "c1bbfe229b1e0e34292dc5a45fa15ef5", "src_uid": "3ff1c25a1026c90aeb14d148d7fb96ba", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.IO;\nusing System.Collections.Generic;\n\nnamespace _262\n{\n class Program\n {\n static void Main(string[] args)\n {\n //Console.SetIn(new StreamReader(\"input.txt\"));\n\n solve_helvetic2019A1_improved();\n //solve_262A();\n }\n\n /*\n In the tutorial it is mentioned that \n we are solving linear equation with one variable.\n\n Although it looks like a quadratic equation at first sight\n in reality it is a hidden linear equation. \n we just need to carefully analyse it and figure out\n that we don't always have equations in a clean canonical ways.\n like ax + b = 0. \n\n in the given equation:\n r = x^2 + 2xy + x + 1\n we could ajust it like that:\n r - x^2 - x - 1 = 2xy\n\n And this part brings confusion. Because the right part 2xy\n is not just y but also multiplied by 2x.\n TODO: Make description cleaner \n \n */\n public static void solve_helvetic2019A1_improved()\n {\n long r = Convert.ToInt64(Console.ReadLine());\n\n for (int x = 1; x < Math.Sqrt(r); x++)\n {\n long y = r - x * x - x - 1;\n\n if (y > 0 && y % 2 * x == 0)\n {\n Console.WriteLine(\"{0} {1}\", x, y / 2 * x);\n \n return;\n }\n }\n\n Console.WriteLine(\"NO\");\n }\n\n\n /*\n \u0412 \u043f\u0435\u0440\u0432\u043e\u043c \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0435, \u044f \u043f\u044b\u0442\u0430\u043b\u0441\u044f \u0442\u0443\u043f\u043e \u0434\u0432\u043e\u0439\u043d\u044b\u043c \u0446\u0438\u043a\u043b\u043e\u043c \u043d\u0430\u0439\u0442\u0438 \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e\n x \u0438 y. \u041d\u043e \u0434\u0430\u0436\u0435 \u0435\u0441\u043b\u0438 \u0443\u0447\u0435\u0441\u0442\u044c \u0447\u0442\u043e \u0432 \u043f\u0435\u0440\u0432\u043e\u043c \u0446\u0438\u043a\u043b\u0435 \u0443 \u043d\u0430\u0441 \u0431\u0443\u0434\u0435\u0442 sqrt(r) \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u0439\n \u0434\u043b\u044f \u043d\u0430\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u044f x, \u0442\u043e \u0432\u0442\u043e\u0440\u044b\u043c \u0446\u0438\u043a\u043b\u043e\u043c \u043c\u044b \u043d\u0435 \u0441\u043c\u043e\u0436\u0435\u043c \u0432 \u0440\u0430\u043c\u043a\u0430\u0445 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f \u043f\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0437\u0430\u0434\u0430\u0447\u0438\n \u043d\u0430\u0439\u0442\u0438 y.\n */\n public static void solve_helvetic2019A1()\n {\n long r = Convert.ToInt64(Console.ReadLine());\n\n bool found = false;\n long x = 0;\n long y = 0;\n long xLen = (int)Math.Sqrt(r);\n for (x = 1; x < xLen; x++)\n {\n long yLen = r <= 100000 ? r : r / (2 * xLen);\n for (y = 2 * x + 1; y < yLen; y++)\n {\n long h = x * x + 2 * x * y + x + 1;\n if (h > r)\n {\n break;\n }\n \n if (r == h)\n {\n found = true;\n break;\n }\n }\n\n if (found)\n {\n break;\n }\n }\n\n if (found)\n {\n Console.Write(\"{0} {1}\", x, y);\n }\n else\n {\n Console.Write(\"NO\");\n }\n }\n\n public static void solve_262A()\n {\n string[] nm = Console.ReadLine().Split(' ');\n\n int n = Convert.ToInt32(nm[0]);\n int m = Convert.ToInt32(nm[1]);\n\n int bought = n;\n int max = n;\n while (bought > 0)\n {\n bought = max % m == 0 ? (bought + m - 1) / m : bought / m;\n max += bought;\n }\n Console.WriteLine(max);\n }\n\n /* \n1)4\n2)1 + (1 + 1) + (1 + 1)\n3)1 + (1 + 1 + 1)\n4)1\n\n1 1 \n\t \n2 3 \n \n3 7 \n \n4 14 \n\t\n5 25\n\n1)5\n2)1 + (1 + 1) + (1 + 1) + (1 + 1)\n3)1 + (1 + 1 + 1) + (1 + 1 + 1)\n4)1 + (1 + 1 + 1 + 1)\n5)1\n\n(0) + 1 => (1) + 2 => (1 + 3) + 3 => (3 + 7) + 4 => (7 + 14) + 5\n */\n public static void solve_164B()\n {\n int n = Convert.ToInt32(Console.ReadLine());\n\n int total = 0;\n int prev = 0;\n int prevPrev = 0;\n for (int i = 1; i <= n; i++)\n {\n total = prevPrev + prev + i;\n\n prevPrev = prev;\n prev = total;\n }\n\n Console.WriteLine(total);\n }\n\n\n /*\n \u0412\u043d\u0438\u043c\u0430\u043d\u0438\u0435: \u0432 \u0434\u0430\u043d\u043d\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0435 \u0435\u0441\u043b\u0438 \u043a\u0440\u043e\u0442 \u043d\u0430\u0436\u0430\u043b \u043d\u0430 \u043a\u043d\u043e\u043f\u043a\u0443 q \u0438 \u0431\u044b\u043b\u043e \u0441\u043c\u0435\u0449\u0435\u043d\u0438\u0435 \u0432\u043f\u0440\u0430\u0432\u043e.\n \u0422\u043e \u0435\u0441\u0442\u044c \u043d\u0430\u0434\u043e \u0432\u043e\u0441\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c, \u0441\u043c\u0435\u0441\u0442\u0438\u0432 \u0431\u0443\u043a\u0432\u0443 \u0432\u043b\u0435\u0432\u043e, \u0442\u043e \u0443 \u043d\u0430\u0441 \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435.\n \u041f\u043e\u0442\u043e\u043c\u0443\u0447\u0442\u043e \u0432 \u0441\u0442\u0440\u043e\u043a\u0435 keyboard q \u044d\u0442\u043e \u043f\u0435\u0440\u0432\u0430\u044f \u0431\u0443\u043a\u0432\u0430 \u0441\u0442\u0440\u043e\u043a\u0438. \u0418 \u043b\u0435\u0432\u0435\u0435 \u043d\u0435\u0435 \u0443 \u043d\u0430\u0441 \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435\u0442.\n \u041d\u041e! \u041f\u043e \u0443\u0441\u043b\u043e\u0432\u0438\u044e \u0443 \u043d\u0430\u0441 \u043d\u0438\u0433\u0434\u0435 \u043d\u0435 \u0441\u043a\u0430\u0437\u0430\u043d\u043e, \u0447\u0442\u043e \u0435\u0441\u043b\u0438 \u043a\u0440\u043e\u0442 \u043d\u0430\u0436\u0430\u043b \u043d\u0430 \u0441\u0430\u043c\u0443\u044e \u043b\u0435\u0432\u0443\u044e \u043a\u043b\u0430\u0432\u0438\u0448\u0443, \u0442\u043e\n \u043c\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0432\u043e\u0441\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u0432\u0437\u044f\u0432 \u0441\u0430\u043c\u0443\u044e \u043f\u0440\u0430\u0432\u0443\u044e \u0431\u0443\u043a\u0432\u0443. \u0426\u0438\u043a\u043b\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0441\u0434\u0432\u0438\u0433 \u0437\u0430\u043c\u043a\u043d\u0443\u0442\u043e\u0441\u0442\u044c.\n \u0422\u043e \u0435\u0441\u0442\u044c \u0442\u0430\u043a\u043e\u0439 \u043a\u0435\u0439\u0441 \u043d\u0435 \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0435\u0442\u0441\u044f.\n\n \u0414\u043b\u044f \u0443\u0441\u043a\u043e\u0440\u0435\u043d\u0438\u044f \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430, \u043c\u043e\u0436\u043d\u043e \u0438\u0437\u0431\u0430\u0432\u0438\u0442\u044c\u0441\u044f \u043e\u0442 \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u043e\u0439 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0441\u0438\u043c\u0432\u043e\u043b\u0430 IndexOf \u0438 \u0437\u0430\u043f\u0438\u0445\u0430\u0442\u044c\n \u0432\u0441\u0435 \u0431\u0443\u043a\u0432\u044b \u0432 \u0441\u043b\u043e\u0432\u0430\u0440\u044c. \u0413\u0434\u0435 \u0431\u0443\u043a\u0432\u044b \u0431\u0443\u0434\u0443\u0442 \u043a\u043b\u044e\u0447\u0430\u043c\u0438, \u0430 \u0438\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u043c \u0432 \u0441\u0442\u0440\u043e\u043a\u0435.\n */\n public static void solve_271A()\n {\n string direction = Console.ReadLine();\n string text = Console.ReadLine();\n\n string keyboard = \"qwertyuiopasdfghjkl;zxcvbnm,./\";\n\n string answer = String.Empty;\n if (direction == \"R\")\n {\n for (int i = 0; i < text.Length; i++)\n {\n answer += keyboard[keyboard.IndexOf(text[i]) - 1];\n }\n }\n else\n {\n for (int i = 0; i < text.Length; i++)\n {\n answer += keyboard[keyboard.IndexOf(text[i]) + 1];\n }\n }\n\n Console.WriteLine(answer);\n }\n\n /*\n \u0414\u0430\u043d\u043d\u044b\u0439 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u043c\u043e\u0436\u043d\u043e \u0435\u0449\u0435 \u0443\u043b\u0443\u0447\u0448\u0438\u0442\u044c, \u0435\u0441\u043b\u0438 \u0438\u0437\u0431\u0430\u0432\u0438\u0442\u044c\u0441\u044f \u043e\u0442 \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u043e\u0439 \u043f\u0440\u043e\u0432\u0435\u043a\u0440\u0438 \u043d\u0430 \u0441\u0438\u043c\u0432\u043e\u043b\n String.Contains.\n \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u0443\u044e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u0434\u0430\u043d\u043d\u044b\u0445 dictionary \u0441 \u043f\u0440\u043e\u0432\u0435\u0440\u043e\u043a\u043e\u0439 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0437\u0430 \u0445\u043e\u0442\u044f \u0431\u044b\n log(n)\n */\n public static void solve_368A()\n {\n string[] nm = Console.ReadLine().Split(' ');\n\n int n = Convert.ToInt32(nm[0]);\n int m = Convert.ToInt32(nm[1]);\n\n int count = 0;\n string noir = \"WBG\";\n for (int i = 0; i < n; i++)\n {\n string[] row = Console.ReadLine().Split(' ');\n\n for (int j = 0; j < m; j++)\n {\n if (noir.Contains(row[j]))\n {\n count++;\n }\n }\n }\n\n string answer = (count == n * m) ? \"#Black&White\" : \"#Color\";\n\n Console.WriteLine(answer); \n }\n\n public static void solve_90A()\n {\n string[] abn = Console.ReadLine().Split(' ');\n\n int a = Convert.ToInt32(abn[0]);\n int b = Convert.ToInt32(abn[1]);\n int n = Convert.ToInt32(abn[2]);\n \n int count = 1;\n while (n > 0)\n {\n if (count % 2 == 0)\n {\n n -= gcd(n, b);\n }\n else \n {\n n -= gcd(n, a);\n }\n \n count++;\n }\n\n int answer = (--count % 2 == 0) ? 1 : 0;\n\n Console.WriteLine(answer);\n }\n\n public static int gcd(int a, int b)\n {\n if (b == 0)\n {\n return a;\n }\n\n return gcd(b, a % b);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "math", "number theory"], "code_uid": "c576a036dc1171a82e850aaedc4fb8bb", "src_uid": "3ff1c25a1026c90aeb14d148d7fb96ba", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\n\nnamespace ConsoleApplication1\n{\n class Program\n {\n static void Main(string[] args)\n {\n char ch = 't';\n string str = \"\";\n while (ch != ' ')\n {\n ch = Convert.ToChar(Console.Read());\n str = str + ch;\n }\n long a = Int64.Parse(str);\n long m = Convert.ToInt64(Console.ReadLine());\n long z = 0;\n for (int i = 1; i < m; i++)\n {\n z = a % m;\n a = a + z;\n }\n if (z == 0) Console.WriteLine(\"Yes\");\n else Console.WriteLine(\"No\");\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "matrices", "implementation"], "code_uid": "b7613b6dcfff00ec08971beec44bb3e1", "src_uid": "f726133018e2149ec57e113860ec498a", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace Igranje.CF276\n{\n class ProblemA\n {\n public static void Main(string [] varg)\n {\n string[] tokens = Console.ReadLine().Split(new char[] {' '});\n int a = int.Parse(tokens[0]);\n int m = int.Parse(tokens[1]);\n\n int sum = a;\n for (int i = 0; i < m; i++)\n {\n int deltasum = sum%m;\n if ( deltasum == 0)\n {\n Console.WriteLine(\"Yes\");\n return;\n }\n sum = sum + deltasum;\n sum = sum%m;\n }\n Console.WriteLine(\"No\");\n\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "matrices", "implementation"], "code_uid": "ccdb1d4ac70377f9a1d26e1a2b8620e0", "src_uid": "f726133018e2149ec57e113860ec498a", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Text;\n\nnamespace ConsoleApp\n{\n public class Program\n {\n private static int[] dp;\n public static void Main()\n {\n int n = Convert.ToInt32(Console.ReadLine());\n if (n == 0)\n {\n Console.WriteLine(0);\n return;\n }\n if (n < 10)\n {\n Console.WriteLine(1);\n return;\n }\n dp = new int[n + 1];\n for (int i = 10; i <= n; i++)\n {\n int temp = i;\n int min = Int32.MaxValue;\n while (temp > 0)\n {\n int digit = temp % 10;\n if (digit != 0 && dp[i - digit] < min)\n {\n min = dp[i - digit];\n }\n temp /= 10;\n }\n dp[i] = min + 1;\n }\n Console.WriteLine(dp[n] + 1);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["dp"], "code_uid": "d3e7280acff101efbe42bf073c24c57c", "src_uid": "fc5765b9bd18dc7555fa76e91530c036", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.IO;\n\nnamespace C1\n{\n static class RW\n {\n public static ulong RIntStdin()\n {\n // Read ONE integer, infinite input\n ulong res = 0;\n int symb = Console.Read();\n while ((symb < '0') || (symb > '9'))\n {\n symb = Console.Read();\n }\n while ((symb >= '0') && (symb <= '9'))\n {\n res = 10 * res + (ulong)symb - '0';\n symb = Console.Read();\n }\n return res;\n }\n }\n class Solution\n {\n ulong n;\n uint s;\n Dictionary d;\n public Solution()\n {\n n = RW.RIntStdin();\n d = new Dictionary();\n }\n public void EvalN(ulong num, uint steps)\n {\n int[] digits = new int[10];\n ulong copy = num;\n ulong novy_key;\n uint prev_steps;\n while (copy > 0)\n {\n digits[copy % 10]++;\n copy /= 10;\n }\n for (int i = 0; i < digits.Length; i++)\n {\n if (digits[i] > 0)\n {\n novy_key = n - (ulong)i;\n if (!d.ContainsKey(novy_key))\n {\n d.Add(novy_key, steps + 1);\n }\n else\n {\n d.TryGetValue(novy_key, out prev_steps);\n if (prev_steps > steps + 1)\n {\n d[novy_key] = steps + 1;\n }\n }\n }\n }\n }\n public void Solve()\n {\n d.Add(n, 0);\n while (n > 0)\n {\n if (d.ContainsKey(n))\n {\n d.TryGetValue(n, out s);\n EvalN(n, s);\n d.Remove(n);\n }\n n--;\n }\n uint r; d.TryGetValue(0, out r); // result\n Console.WriteLine(r);\n }\n }\n class Program\n {\n static void Main(string[] args)\n {\n Solution s = new Solution();\n s.Solve();\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["dp"], "code_uid": "41681a6c0671b3828f6dc179f0101456", "src_uid": "fc5765b9bd18dc7555fa76e91530c036", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Text;\nusing System.Linq;\nusing System.IO;\nusing System.Globalization;\nusing System.Collections;\n\nnamespace Task\n{\n\n #region MyIo\n\n internal class MyIo : IDisposable\n {\n private readonly TextReader inputStream;\n private readonly TextWriter outputStream = Console.Out;\n\n private string[] tokens;\n private int pointer;\n\n public MyIo()\n#if LOCAL_TEST\n : this(new StreamReader(\"input.txt\"))\n#else\n : this(System.Console.In)\n#endif\n {\n\n }\n\n public MyIo(TextReader inputStream)\n {\n this.inputStream = inputStream;\n }\n\n public string NextLine()\n {\n try\n {\n return inputStream.ReadLine();\n }\n catch (IOException)\n {\n return null;\n }\n }\n\n public string NextString()\n {\n try\n {\n while (tokens == null || pointer >= tokens.Length)\n {\n tokens = NextLine().Split(new[] { ' ', '\\t' }, StringSplitOptions.RemoveEmptyEntries);\n pointer = 0;\n }\n return tokens[pointer++];\n }\n catch (IOException)\n {\n return null;\n }\n }\n\n public int NextInt()\n {\n return Next();\n }\n\n public long NextLong()\n {\n return Next();\n }\n\n public T Next()\n {\n return (T)Convert.ChangeType(NextString(), typeof(T));\n }\n\n\n public IEnumerable NextSeq(int n)\n {\n for (int i = 0; i < n; i++)\n yield return Next();\n }\n\n public void Print(string format, params object[] args)\n {\n outputStream.Write(string.Format(CultureInfo.InvariantCulture, format, args));\n }\n\n public void PrintLine(string format, params object[] args)\n {\n Print(format, args);\n\n outputStream.WriteLine();\n }\n\n public void Print(bool o)\n {\n Print(o ? \"YES\" : \"NO\");\n }\n\n public void PrintLine(bool o)\n {\n PrintLine(o ? \"YES\" : \"NO\");\n }\n\n public void Print(T o)\n {\n outputStream.Write(o);\n }\n\n\n public void PrintLine(T o)\n {\n outputStream.WriteLine(o);\n }\n\n public void Close()\n {\n inputStream.Close();\n outputStream.Close();\n }\n\n void IDisposable.Dispose()\n {\n Close();\n\n#if LOCAL_TEST\n Console.ReadLine();\n#endif\n }\n }\n\n #endregion\n\n\n internal class Program\n {\n #region Program\n\n private readonly MyIo io;\n\n public Program(MyIo io)\n {\n this.io = io;\n }\n\n public static void Main(string[] args)\n {\n using (MyIo io = new MyIo())\n {\n new Program(io)\n .Solve();\n }\n }\n\n\n public static class P\n {\n public static P Create(T1 key, T2 val)\n {\n return new P(key, val);\n }\n }\n\n public class P\n {\n private class PComparer : IComparer>\n {\n private readonly bool? byKey;\n\n public PComparer(bool? byKey)\n {\n this.byKey = byKey;\n }\n\n\n public int Compare(P x, P y)\n {\n x = x ?? new P();\n y = y ?? new P();\n\n\n if (byKey == true)\n return Comparer.Default.Compare(x.Key, y.Key);\n else if (byKey == false)\n return Comparer.Default.Compare(x.Value, y.Value);\n else\n {\n var tr = Comparer.Default.Compare(x.Key, y.Key);\n\n if (tr != 0)\n tr = Comparer.Default.Compare(x.Value, y.Value);\n\n return tr;\n }\n }\n }\n\n\n public P()\n {\n }\n\n public P(T1 key, T2 val)\n {\n this.Key = key;\n this.Value = val;\n }\n\n\n public T1 Key\n {\n get;\n set;\n }\n\n public T2 Value\n {\n get;\n set;\n }\n\n public P Clone()\n {\n return new P(Key, Value);\n }\n\n public static IComparer> KeyComparer\n {\n get { return new PComparer(true); }\n }\n\n public static IComparer> ValueComparer\n {\n get { return new PComparer(false); }\n }\n\n public static implicit operator T1(P obj)\n {\n return obj.Key;\n }\n\n public static implicit operator T2(P obj)\n {\n return obj.Value;\n }\n\n public P SetKey(T1 key)\n {\n Key = key;\n return this;\n }\n\n public P SetValue(T2 value)\n {\n Value = value;\n return this;\n }\n\n public override string ToString()\n {\n return string.Format(\"Key: {0}, Value: {1}\", Key, Value);\n }\n\n public override int GetHashCode()\n {\n int hash = 17;\n hash = hash * 31 + ((Equals(Key, default(T1))) ? 0 : Key.GetHashCode());\n hash = hash * 31 + ((Equals(Value, default(T1))) ? 0 : Key.GetHashCode());\n return hash;\n\n }\n }\n\n\n #endregion\n public const long MOD = 1000000007;\n public const double EPS = 1e-14;\n\n private void Solve()\n {\n var n = io.NextInt();\n var m = io.NextInt();\n\n var fi = io.NextSeq(n).ToArray();\n\n var g = new P[m];\n var g1 = new P[m];\n\n var sk = Enumerable.Range(0, m).ToArray();\n var sk1 = Enumerable.Range(0, m).ToArray();\n var c = new int[n + 1];\n var c1 = new int[n + 1];\n\n for (int i = 0; i < m; i++)\n {\n var from = io.NextInt() - 1;\n var to = io.NextInt() - 1;\n\n g[i] = P.Create(from , to);\n c[from + 1]++;\n g1[i] = P.Create(to, from);\n c1[to + 1]++;\n }\n\n for (int i = 1; i <= n; i++)\n {\n c[i] += c[i - 1];\n c1[i] += c1[i - 1];\n }\n\n Array.Sort(sk, (i, i1) => P.KeyComparer.Compare(g[i], g[i1]));\n\n Array.Sort(sk1, (i, i1) => P.KeyComparer.Compare(g1[i], g1[i1]));\n \n\n\n var used = new bool[n];\n var used1 = new bool[n];\n\n \n \n for (int i = 0; i < n; i++)\n {\n if (fi[i] == 1)\n BFS(g, sk, c, used, null, 0 , i);\n }\n \n for (int i = 0; i < n; i++)\n {\n if (fi[i] == 2)\n BFS(g1, sk1, c1, used1, fi, 1, i);\n }\n\n\n for (int i = 0; i < n; i++)\n {\n io.PrintLine((used[i] && used1[i]) ? \"1\":\"0\");\n }\n }\n\n public void BFS(P[] g, int[] sk, int[] c, bool[] used, int[] fi, int ifi, int s)\n {\n \n var n = c.Length;\n\n used = used ?? new bool[n];\n\n if (used[s])\n return;\n\n Queue q = new Queue();\n q.Enqueue(s);\n\n used[s] = true;\n\n while (q.Count > 0)\n {\n int v = q.Dequeue();\n for (var i = c[v]; i < c[v + 1]; i++)\n {\n var to = g[sk[i]].Value;\n\n if (used[to])\n continue;\n\n used[to] = true;\n\n if (fi != null && fi[to] == ifi)\n continue;\n\n q.Enqueue(to);\n }\n }\n }\n \n public static void Shuffle(IList list)\n {\n var rnd = new Random(DateTime.Now.Millisecond);\n\n var n = list.Count;\n\n while (n > 1)\n {\n n--;\n var k = rnd.Next(n + 1);\n var value = list[k];\n list[k] = list[n];\n list[n] = value;\n }\n }\n\n }\n\n}\n\n", "lang_cluster": "C#", "tags": ["graphs"], "code_uid": "1077d68750e980382a4563a37e8756a1", "src_uid": "87d869a0fd4a510c5e7e310886b86a57", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.IO;\nusing System.Diagnostics;\n\nnamespace ConsoleApplication1 {\n struct Pair {\n public int X, Y;\n public Pair(int x, int y) {\n X = x;\n Y = y;\n }\n public override string ToString() {\n return string.Format(\"{0} {1}\", X, Y);\n }\n }\n\n class Graph : List> {\n public Graph(int num) : base(num) {\n for (int i = 0; i < num; i++) {\n this.Add(new List());\n }\n }\n }\n\n class Program {\n static int n, m, k, t, ans;\n static TextReader input;\n static int[] f;\n static bool[] u1, u2;\n static Graph g, rg;\n static void Main(string[] args) {\n#if TESTS \n Stopwatch sw = new Stopwatch();\n sw.Start();\n input = new StreamReader(\"input.txt\"); \n#else\n input = Console.In;\n#endif \n Solve(); \n#if TESTS\n Console.WriteLine();\n Console.WriteLine(\"Milliseconds: {0}\", sw.ElapsedMilliseconds);\n Console.ReadLine();\n#endif\n }\n\n #region read helpers\n public static int[] ReadIntArray() {\n return input.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();\n }\n\n public static List ReadIntList() {\n return input.ReadLine().Split(' ').Select(x => int.Parse(x)).ToList();\n }\n\n public static int ReadInt() {\n return int.Parse(input.ReadLine());\n }\n \n #endregion\n\n static void Solve() {\n int[] a = ReadIntArray();\n n = a[0];\n m = a[1];\n g = new Graph(n);\n rg = new Graph(n);\n u1 = new bool[n];\n u2 = new bool[n];\n f = ReadIntArray();\n for (int i = 0; i < m; i++) {\n int[] b = ReadIntArray();\n g[--b[0]].Add(--b[1]);\n rg[b[1]].Add(b[0]);\n }\n for (int i = 0; i < n; i++) {\n if (f[i] == 1 && !u1[i]) {\n Bfs1(i);\n }\n }\n for (int i = 0; i < n; i++) {\n if (f[i] == 2 && !u2[i]) {\n Bfs2(i);\n }\n }\n for (int i = 0; i < n; i++) {\n if (u1[i] && u2[i])\n Console.WriteLine(1);\n else\n Console.WriteLine(0);\n }\n }\n\n static void Bfs1(int v) {\n u1[v] = true;\n Queue q = new Queue();\n q.Enqueue(v);\n while (q.Count > 0) {\n int u = q.Dequeue();\n foreach (int i in g[u]) {\n if (!u1[i]) {\n u1[i] = true;\n q.Enqueue(i);\n }\n }\n }\n }\n\n static void Bfs2(int v) {\n u2[v] = true;\n Queue q = new Queue();\n q.Enqueue(v);\n while (q.Count > 0) {\n int u = q.Dequeue();\n foreach (int i in rg[u]) {\n if (!u2[i]) {\n u2[i] = true;\n if (f[i] != 1)\n q.Enqueue(i);\n }\n }\n }\n }\n\n static void Dfs1(int v) {\n u1[v] = true;\n foreach (int i in g[v]) {\n if (!u1[i]) Dfs1(i);\n }\n }\n\n static void Dfs2(int v) {\n u2[v] = true;\n if (f[v] == 1) return;\n foreach (int i in rg[v]) {\n if (!u2[i]) Dfs2(i);\n }\n }\n\n static int[] Count_Sort(int[] a, int k) {\n int n = a.Length;\n int[] b = new int[n];\n int[] c = new int[k];\n for (int i = 0; i < n; ++i)\n ++c[a[i]];\n for (int i = 1; i < k; ++i)\n c[i] += c[i - 1];\n for (int i = n - 1; i >= 0; --i) {\n b[c[a[i]] - 1] = a[i];\n --c[a[i]];\n }\n return b;\n }\n\n static void Radix_Sort(int[] a, int k) {\n int n = a.Length;\n int repeats = 32 / k;\n int size = 1 << k;\n int mask = size - 1;\n for (int i = 0; i < repeats; ++i) {\n int[] c = new int[size];\n int[] b = new int[n];\n for (int j = 0; j < n; ++j) {\n int r = (a[j] & (mask << (i * k))) >> (i * k);\n ++c[r];\n }\n for (int j = 1; j < size; ++j)\n c[j] += c[j - 1];\n for (int j = n - 1; j >= 0; --j) {\n int r = (a[j] & (mask << (i * k))) >> (i * k);\n b[c[r] - 1] = a[j];\n --c[r];\n }\n Array.Copy(b, a, n);\n }\n }\n }\n\n public static class Extensions {\n public static void Print(this IEnumerable e) {\n foreach (T item in e) {\n Console.Write(\"{0} \", item);\n }\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["graphs"], "code_uid": "78e4db847191b58325c0b12429d151ec", "src_uid": "87d869a0fd4a510c5e7e310886b86a57", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Text;\nusing System.IO;\n\nnamespace mono\n{\n public class Program\n {\n public static char res(int a, int b)\n {\n return a > b ? '+' : (a < b ? '-' : '0');\n }\n \n public static void Main(string[] args)\n {\n string s = Console.ReadLine();\n string[] arr = s.Split(new char[]{ ' ' });\n char c;\n Console.WriteLine((c = res(int.Parse(arr[0]) + int.Parse(arr[2]), int.Parse(arr[1]))) == res(int.Parse(arr[0]), int.Parse(arr[1]) + int.Parse(arr[2])) ? c : '?');\n }\n }\n}", "lang_cluster": "C#", "tags": ["greedy"], "code_uid": "804122d8abad780ef5a7d43c9415d165", "src_uid": "66398694a4a142b4a4e709d059aca0fa", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nnamespace ConsoleApp1\n{\n class Program\n {\n static void Main(string[] args)\n {\n string[] s = Console.ReadLine().Split(' ');\n int x=Convert.ToInt32(s[0]), y=Convert.ToInt32(s[1]), z=Convert.ToInt32(s[2]);\n if (x-y+z<0 && x-y-z<0) Console.WriteLine(\"-\");\n if (x-y+z>0 && x-y-z>0) Console.WriteLine(\"+\");\n if (x-y+z==0 && x-y-z==0) Console.WriteLine(\"0\");\n if ((x-y+z>0 && x-y-z<0) || (x-y+z<0 && x-y-z>0) ||(x-y+z<0 && x-y-z==0) || (x-y+z>0 && x-y-z==0) || (x-y+z==0 && x-y-z>0) || (x-y+z==0 && x-y-z<0)) Console.WriteLine(\"?\");\n \n \n }\n }\n}", "lang_cluster": "C#", "tags": ["greedy"], "code_uid": "a4354a4f32ee9eb6ef2d3e4965a6b4b4", "src_uid": "66398694a4a142b4a4e709d059aca0fa", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Globalization;\nusing System.IO;\nusing System.Linq;\nusing System.Text;\n\n\npublic static class Intparser\n{\n public static int ToInt32(this string text)\n {\n return Convert.ToInt32(text);\n }\n public static long ToInt64(this string text)\n {\n return Convert.ToInt64(text);\n }\n}\n\nclass Program\n{\n private static void Main(string[] args)\n {\n var ins = Console.ReadLine().Split(' ').Select(x => x.ToInt64()).ToArray();\n\n if (ins[0] >= ins[1])\n {\n\n var max = ins[1] / 2;\n\n if (ins[1] % 2 == 0)\n max--;\n\n Console.WriteLine(max);\n\n }\n else\n {\n var sub = ins[1] - ins[0];\n\n if (sub > ins[0])\n {\n Console.WriteLine(0);\n }\n else\n {\n sub = ins[0] - sub;\n sub = (sub / 2) + sub % 2;\n\n Console.WriteLine(sub);\n }\n }\n }\n}", "lang_cluster": "C#", "tags": ["math"], "code_uid": "051393babe3e5abc53de58e0932fa803", "src_uid": "98624ab2fcd2a50a75788a29e04999ad", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\n\nnamespace Code_Force\n{\n class Program\n {\n static void Main(string[] args)\n {\n string S = Console.ReadLine();\n long k = Int64.Parse(S.Remove(0, S.IndexOf(' ')));\n long n = Int64.Parse(S.Remove(S.IndexOf(' ')));\n if (n == .5 * (k + 1)&k!=1) Console.WriteLine(1);\n else if (n < .5 * (k + 1)) Console.WriteLine(0);\n else if (n >= k) Console.WriteLine((k - 1) / 2);\n else\n {\n long dif = k - n-1;\n Console.WriteLine(((k - 1) / 2)-dif);\n }\n }\n \n }\n}", "lang_cluster": "C#", "tags": ["math"], "code_uid": "4423a5d297ad3808b19bf86720983b09", "src_uid": "98624ab2fcd2a50a75788a29e04999ad", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.IO;\nusing System.Linq;\nusing System.Text;\n\nnamespace TaskC\n{\n class Program\n {\n static void Main(string[] args)\n {\n new Solver().Solve().OutputResult();\n }\n\n private class ExtendedReader : StreamReader\n {\n private static readonly char Separator = ' ';\n\n public ExtendedReader(Stream stream) : base(stream) { }\n public ExtendedReader(Stream stream, bool detectEncodingFromByteOrderMarks) : base(stream, detectEncodingFromByteOrderMarks) { }\n public ExtendedReader(Stream stream, Encoding encoding) : base(stream, encoding) { }\n public ExtendedReader(Stream stream, Encoding encoding, bool detectEncodingFromByteOrderMarks) : base(stream, encoding, detectEncodingFromByteOrderMarks) { }\n public ExtendedReader(Stream stream, Encoding encoding, bool detectEncodingFromByteOrderMarks, int bufferSize) : base(stream, encoding, detectEncodingFromByteOrderMarks, bufferSize) { }\n public ExtendedReader(Stream stream, Encoding encoding, bool detectEncodingFromByteOrderMarks, int bufferSize, bool leaveOpen) : base(stream, encoding, detectEncodingFromByteOrderMarks, bufferSize, leaveOpen) { }\n public ExtendedReader(string path) : base(path) { }\n public ExtendedReader(string path, bool detectEncodingFromByteOrderMarks) : base(path, detectEncodingFromByteOrderMarks) { }\n public ExtendedReader(string path, Encoding encoding) : base(path, encoding) { }\n public ExtendedReader(string path, Encoding encoding, bool detectEncodingFromByteOrderMarks) : base(path, encoding, detectEncodingFromByteOrderMarks) { }\n public ExtendedReader(string path, Encoding encoding, bool detectEncodingFromByteOrderMarks, int bufferSize) : base(path, encoding, detectEncodingFromByteOrderMarks, bufferSize) { }\n\n public char ReadChar()\n {\n return (char)this.Read();\n }\n\n public double ReadDoubleFromArray()\n {\n StringBuilder sb = new StringBuilder();\n char ch = this.ReadChar();\n while (ch != Separator && ch != '\\n')\n {\n sb.Append(ch);\n ch = this.ReadChar();\n }\n return Convert.ToDouble(sb.ToString());\n }\n\n public int ReadInt()\n {\n return int.Parse(this.ReadLine());\n }\n\n public Int64 ReadInt64()\n {\n return Int64.Parse(this.ReadLine());\n }\n\n public int[] ReadIntArray()\n {\n return this.ReadLine().Split(' ').Select(int.Parse).ToArray();\n }\n\n public char[] ReadCharArray()\n {\n return this.ReadLine().ToCharArray();\n }\n\n public string ReadString()\n {\n return this.ReadLine();\n }\n\n public Int64[] ReadInt64Array()\n {\n return this.ReadLine().Split(Separator).Select(Int64.Parse).ToArray();\n }\n\n public Double[] ReadDoubleArray()\n {\n return this.ReadLine().Split(Separator).Select(Double.Parse).ToArray();\n }\n }\n\n private abstract class SolverBase\n {\n protected readonly ExtendedReader _reader;\n protected readonly TextWriter _writer;\n\n protected SolverBase()\n {\n#if DEBUG\n _reader = new ExtendedReader(@\"input.txt\");\n //_writer = new StreamWriter(@\"output.txt\");\n _writer = new StreamWriter(Console.OpenStandardOutput());\n#else\n _reader = new ExtendedReader(Console.OpenStandardInput());\n _writer = new StreamWriter(Console.OpenStandardOutput());\n#endif\n }\n\n public abstract Solver Solve();\n\n public abstract void OutputResult();\n }\n\n private class Solver : SolverBase\n {\n private long result = -1L;\n\n public override Solver Solve()\n {\n // link to task: http://codeforces.com/contest/689/problem/C\n\n var m = _reader.ReadInt64();\n long lower = 1;\n long upper = (long)1e16;\n while (upper - lower > 1)\n {\n long middle = (lower + upper) / 2;\n\n var M = CalcM(middle);\n if (M >= m)\n upper = middle;\n else\n lower = middle;\n }\n\n if (CalcM(upper) == m)\n result = upper;\n\n return this;\n }\n\n static long CalcM(long n)\n {\n long M = 0;\n for (long k = 2; k * k * k <= n; k++)\n {\n M += n / (k * k * k);\n }\n return M;\n }\n\n public override void OutputResult()\n {\n string answer = result.ToString();\n\n _writer.WriteLine(answer);\n _writer.Dispose();\n }\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "binary search", "combinatorics"], "code_uid": "7687b217710f20ce0c24b24c2ed1a8de", "src_uid": "602deaad5c66e264997249457d555129", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Globalization;\nusing System.IO;\nusing System.Linq;\nusing System.Text;\nusing System.Threading;\nusing System.Threading.Tasks;\n\nclass Program\n{\n static long calc(long med)\n {\n var calc = 0L;\n var st = 2;\n while (med / st / st / st > 0)\n {\n calc += med / st / st / st;\n st++;\n }\n return calc;\n }\n\n static void solve(StreamReader reader, StreamWriter writer)\n {\n long m = reader.ReadLong();\n var min = 1L;\n var max = (long)1e18;\n while (max - min > 1)\n {\n var med = (min + max)/2;\n var cl = calc(med);\n if (cl >= m)\n max = med;\n else\n min = med;\n }\n if (calc(min) == m)\n writer.WriteLine(min);\n else if (calc(max) == m)\n writer.WriteLine(max);\n else\n writer.WriteLine(-1);\n\n //int n = reader.ReadInt();\n //var a = new int[n+1];\n //var r = new int[n+1];\n //for (int i = 1; i <= n; ++i)\n //{\n // a[i] = reader.ReadInt();\n // r[i] = i-1;\n //}\n\n //for (int j = 1; j <= n; ++j)\n //{\n // if (j < n)\n // r[j+1] = Math.Min(r[j+1], r[j] + 1);\n // r[a[j]] = Math.Min(r[a[j]], r[j] + 1);\n //}\n //for (int j = 1; j <= n; ++j)\n //{\n // writer.Write(r[j] + \" \");\n //}\n }\n\n #region launch\n static void Main(string[] args)\n {\n using (var writer = new FormattedStreamWriter(Console.OpenStandardOutput()))\n {\n using (var reader = new StreamReader(\n#if CODECHIEF_LOCAL\n \"input.txt\"\n#else\nConsole.OpenStandardInput()\n#endif\n))\n {\n solve(reader, writer);\n }\n }\n }\n #endregion\n}\n\n#region helpers\nclass FormattedStreamWriter : StreamWriter\n{\n public FormattedStreamWriter(Stream stream)\n : base(stream)\n {\n }\n\n public override IFormatProvider FormatProvider\n {\n get\n {\n return CultureInfo.InvariantCulture;\n }\n }\n}\n\nstatic class IOExtensions\n{\n public static string ReadString(this StreamReader reader)\n {\n return reader.ReadToken();\n }\n\n public static int ReadInt(this StreamReader reader)\n {\n return int.Parse(reader.ReadToken(), CultureInfo.InvariantCulture);\n }\n\n public static long ReadLong(this StreamReader reader)\n {\n return long.Parse(reader.ReadToken(), CultureInfo.InvariantCulture);\n }\n\n public static double ReadDouble(this StreamReader reader)\n {\n return double.Parse(reader.ReadToken(), CultureInfo.InvariantCulture);\n }\n\n static Queue buffer = new Queue(100);\n\n static string ReadToken(this StreamReader reader)\n {\n while (buffer.Count == 0)\n {\n reader.ReadLine().Split(new[] { ' ', '\\t' }, StringSplitOptions.RemoveEmptyEntries).ToList().ForEach((t) =>\n {\n buffer.Enqueue(t);\n });\n }\n return buffer.Dequeue();\n }\n}\n#endregion", "lang_cluster": "C#", "tags": ["math", "binary search", "combinatorics"], "code_uid": "cbd5198c28e08cfd23bdf99fe5003947", "src_uid": "602deaad5c66e264997249457d555129", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeff// done\n/***************************************************************************\n* Title : Almost Prime\n* URL : http://codeforces.com/problemset/problem/26/A\n* Contst: Offline\n* Date : 2018-04-27\n* Author: Atiq Rahman\n* Comp : O(N)\n* Status: Accepted\n* Notes : This is not really a good problem for practicing implementation of\n* doubly linked list. Building LinkedList is not trivial since nodes are out\n* of order.. we can say this place for practicing alternative doubly linked\n* list representation.\n* \n* Applications of this problem:\n* Test Prime Number Generatation algorithm up to a small range (<=3000)\n* \n* With this problem following Prime Generation Algos tested,\n* - Dynamic Programming Approach for generating primes\n* - Sieve of Eratosthenes\n* \n* related: 'uva-online-judge/old/10699_Count the factors.cpp'\n* meta : tag-linked-list, tag-easy\n***************************************************************************/\nusing System;\nusing System.Collections.Generic;\n\npublic class PrimeUtil {\n // The access level for class members and struct members, including nested\n // classes and structs, is private by default.\n // ref: https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/\n // classes-and-structs/access-modifiers\n List primes;\n System.Collections.BitArray isPrime;\n int n;\n\n // Divide each candidate number (starting from 6) by prime numbers to find\n // divisors. Keep dividing the number with the divisor/factor. Do it twice\n // and if the number comes down to one after those divisions we got an\n // almost prime\n public int FindAlmostPrimes()\n {\n int count = 0;\n\n for (int num = 6; num <= n; num++) {\n int firstPrimeDivisorIndex = GetPrimeFactor(num);\n if (firstPrimeDivisorIndex == -1)\n continue;\n // divide the number as long as it is divisible by factor\n int dNum = DivideDown(num, primes[firstPrimeDivisorIndex]);\n int secondPrimeDivisorIndex = GetPrimeFactor(dNum, firstPrimeDivisorIndex\n + 1);\n if (secondPrimeDivisorIndex == -1)\n continue;\n if (DivideDown(dNum, primes[secondPrimeDivisorIndex]) == 1)\n count++;\n }\n return count;\n }\n\n // start from the index after the previous prime factor's index\n private int GetPrimeFactor(int num, int startIndex=0) {\n if (num == 1)\n return -1;\n // find prime divisor/factor\n for (int i= startIndex; primes[i] <= num && i(new int[] { 2 });\n for (int j = 3; j <= n; j += 2) {\n int pi = 1; // index inside the prime number collection\n for (; pi < primes.Count; pi++)\n if (j % primes[pi] == 0)\n break;\n if (pi == primes.Count)\n primes.Add(j);\n }\n }*/\n\n\n /*\n consider example,\n 2, 3, 4,\n */\n // Sieve\n public void GeneratePrimes()\n {\n isPrime = new System.Collections.BitArray(n + 1, true);\n for (int i = 3; i * i <= n; i+=2)\n if (isPrime.Get(i))\n for (int j = i * i; j <= n; j += i)\n isPrime.Set(j, false);\n\n primes = new List(new int[] { 2 });\n for (int i = 3; i <= n; i+=2)\n if (isPrime.Get(i))\n primes.Add(i);\n }\n\n public void Input()\n {\n n = int.Parse(Console.ReadLine());\n }\n}\n\npublic class CF_Solution {\n public static void Main() {\n PrimeUtil primeDemo = new PrimeUtil();\n primeDemo.Input();\n primeDemo.GeneratePrimes();\n Console.WriteLine(primeDemo.FindAlmostPrimes());\n }\n}\n", "lang_cluster": "C#", "tags": ["number theory"], "code_uid": "e55415df5c10badb8aedb1944ca18a78", "src_uid": "356666366625bc5358bc8b97c8d67bd5", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeff// done\n/***************************************************************************\n* Title : Almost Prime\n* URL : http://codeforces.com/problemset/problem/26/A\n* Contst: Offline\n* Date : 2018-04-27\n* Author: Atiq Rahman\n* Comp : O(N)\n* Status: Accepted\n* Notes : This is not really a good problem for practicing implementation of\n* doubly linked list. Building LinkedList is not trivial since nodes are out\n* of order.. we can say this place for practicing alternative doubly linked\n* list representation.\n* \n* Applications of this problem:\n* Test Prime Number Generatation algorithms\n* meta : tag-linked-list, tag-easy\n***************************************************************************/\nusing System;\nusing System.Collections.Generic;\n\npublic class PrimeUtil {\n // The access level for class members and struct members, including nested\n // classes and structs, is private by default.\n // ref: https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/\n // classes-and-structs/access-modifiers\n List primes;\n int n;\n\n // Divide each candidate number (starting from 6) by prime numbers to find\n // divisors. Keep dividing the number with the divisor/factor. Do it twice\n // and if the number comes down to one after those divisions we got an\n // almost prime\n public int FindAlmostPrimes()\n {\n int count = 0;\n\n for (int num = 6; num <= n; num++) {\n int firstPrimeDivisorIndex = GetPrimeFactor(num);\n if (firstPrimeDivisorIndex == -1)\n continue;\n // divide the number as long as it is divisible by factor\n int dNum = DivideDown(num, primes[firstPrimeDivisorIndex]);\n int secondPrimeDivisorIndex = GetPrimeFactor(dNum, firstPrimeDivisorIndex\n + 1);\n if (secondPrimeDivisorIndex == -1)\n continue;\n if (DivideDown(dNum, primes[secondPrimeDivisorIndex]) == 1)\n count++;\n }\n return count;\n }\n\n // start from the index after the previous prime factor's index\n private int GetPrimeFactor(int num, int startIndex=0) {\n if (num == 1)\n return -1;\n // find prime divisotr/factor\n for (int i= startIndex; primes[i] <= num && i(new int[] { 2 });\n for (int j = 3; j <= n; j += 2) {\n int pi = 1; // index inside the prime number collection\n for (; pi < primes.Count; pi++)\n if (j % primes[pi] == 0)\n break;\n if (pi == primes.Count)\n primes.Add(j);\n }\n }\n\n public void Input()\n {\n n = int.Parse(Console.ReadLine());\n }\n}\n\npublic class CF_Solution {\n public static void Main() {\n PrimeUtil primeDemo = new PrimeUtil();\n primeDemo.Input();\n primeDemo.GeneratePrimes();\n Console.WriteLine(primeDemo.FindAlmostPrimes());\n }\n}\n", "lang_cluster": "C#", "tags": ["number theory"], "code_uid": "fada3b88255fad287c5e2d753d0e85c6", "src_uid": "356666366625bc5358bc8b97c8d67bd5", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.IO;\nusing System.Runtime.CompilerServices;\nusing System.Text;\nusing static Template;\nusing static System.Console;\nusing static System.Convert;\nusing static System.Math;\nusing Pi = Pair;\n\nclass Solver\n{\n public void Solve(Scanner sc)\n {\n int N, M;\n sc.Make(out N, out M);\n int[] res = new int[N],ex=new int[N];\n int[] ct = new int[M],ts=new int[M];\n \n var pq = new PriorityQueue((a,b)=>a.v1-b.v1);\n for(var i = 0; i < M; i++)\n {\n int s, t, c;\n sc.Make(out s, out t, out c);\n s--;t--;\n res[t] = M+1;\n ts[i] = t;\n ex[t] = i;\n pq.Push(new Pi(s,i));\n ct[i] = c;\n }\n var f = new PriorityQueue>((a, b) => a.v1 - b.v1);\n var use = new bool[M];\n for(var i = 0; i < N; i++)\n {\n while (pq.Any() && pq.Top.v1 == i)\n f.Push(new Pair(ts[pq.Top.v2], ct[pq.Top.v2],pq.Pop().v2));\n if (res[i] == M+1)\n {\n if (!use[ex[i]]) Fail(-1);\n continue;\n }\n if (!f.Any()) continue;\n var p = f.Pop();\n res[i] = p.v3+1;\n p.v2--;\n if (p.v2 != 0) f.Push(p);\n else use[p.v3] = true;\n }\n\n Console.WriteLine(string.Join(\" \", res));\n\n }\n}\n\npublic class PriorityQueue\n{\n private List data = new List();\n private Comparison cmp;\n public int Count { get { return data.Count; } }\n public T Top { get { return data[0]; } }\n public PriorityQueue() { cmp = cmp ?? Comparer.Default.Compare; }\n\n public PriorityQueue(Comparison comparison) { cmp = comparison; }\n\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n private int Parent(int i)\n => (i - 1) >> 1;\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n private int Left(int i)\n => (i << 1) + 1;\n public T Push(T val)\n {\n int i = data.Count;\n data.Add(val);\n while (i > 0)\n {\n int p = Parent(i);\n if (cmp(data[p], val) <= 0)\n break;\n data[i] = data[p];\n i = p;\n }\n data[i] = val;\n return val;\n }\n public T Pop()\n {\n var ret = data[0];\n var p = 0;\n var x = data[data.Count - 1];\n while (Left(p) < data.Count - 1)\n {\n var l = Left(p);\n if (l < data.Count - 2 && cmp(data[l + 1], data[l]) < 0) l++;\n if (cmp(data[l], x) >= 0)\n break;\n data[p] = data[l];\n p = l;\n }\n data[p] = x;\n data.RemoveAt(data.Count - 1);\n return ret;\n }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public bool Any() => data.Count > 0;\n}\n#region Template\npublic static class Template\n{\n static void Main(string[] args)\n {\n Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });\n new Solver().Solve(new Scanner());\n Console.Out.Flush();\n }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static bool chmin(ref T a, T b) where T : IComparable\n { if (a.CompareTo(b) == 1) { a = b; return true; } return false; }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static bool chmax(ref T a, T b) where T : IComparable\n { if (a.CompareTo(b) == -1) { a = b; return true; } return false; }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static void swap(ref T a, ref T b)\n { var t = b; b = a; a = t; }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static T[] Create(int n, Func f)\n {\n var rt = new T[n];\n for (var i = 0; i < rt.Length; ++i)\n rt[i] = f();\n return rt;\n }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static T[] Create(int n, Func f)\n {\n var rt = new T[n];\n for (var i = 0; i < rt.Length; ++i)\n rt[i] = f(i);\n return rt;\n }\n public static T[] Copy(this T[] A)\n => Create(A.Length, i => A[i]);\n public static void Fail(T s) { Console.WriteLine(s); Console.Out.Close(); Environment.Exit(0); }\n}\n\npublic class Scanner\n{\n public string Str => Console.ReadLine().Trim();\n public int Int => int.Parse(Str);\n public long Long => long.Parse(Str);\n public double Double => double.Parse(Str);\n public int[] ArrInt => Str.Split(' ').Select(int.Parse).ToArray();\n public long[] ArrLong => Str.Split(' ').Select(long.Parse).ToArray();\n public char[][] Grid(int n) => Create(n, () => Str.ToCharArray());\n public int[] ArrInt1D(int n) => Create(n, () => Int);\n public long[] ArrLong1D(int n) => Create(n, () => Long);\n public int[][] ArrInt2D(int n) => Create(n, () => ArrInt);\n public long[][] ArrLong2D(int n) => Create(n, () => ArrLong);\n public Pair PairMake() => new Pair(Next(), Next());\n public Pair PairMake() => new Pair(Next(), Next(), Next());\n private Queue q = new Queue();\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public T Next() { if (q.Count == 0) foreach (var item in Str.Split(' ')) q.Enqueue(item); return (T)Convert.ChangeType(q.Dequeue(), typeof(T)); }\n public void Make(out T1 v1) => v1 = Next();\n public void Make(out T1 v1, out T2 v2) { v1 = Next(); v2 = Next(); }\n public void Make(out T1 v1, out T2 v2, out T3 v3) { Make(out v1, out v2); v3 = Next(); }\n public void Make(out T1 v1, out T2 v2, out T3 v3, out T4 v4) { Make(out v1, out v2, out v3); v4 = Next(); }\n public void Make(out T1 v1, out T2 v2, out T3 v3, out T4 v4, out T5 v5) { Make(out v1, out v2, out v3, out v4); v5 = Next(); }\n public void Make(out T1 v1, out T2 v2, out T3 v3, out T4 v4, out T5 v5, out T6 v6) { Make(out v1, out v2, out v3, out v4, out v5); v6 = Next(); }\n}\n\npublic class Pair : IComparable>\n{\n public T1 v1;\n public T2 v2;\n public Pair() { }\n public Pair(T1 v1, T2 v2)\n { this.v1 = v1; this.v2 = v2; }\n\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public int CompareTo(Pair p)\n {\n var c = Comparer.Default.Compare(v1, p.v1);\n if (c == 0)\n c = Comparer.Default.Compare(v2, p.v2);\n return c;\n }\n public override string ToString() => $\"{v1.ToString()} {v2.ToString()}\";\n public void Tie(out T1 a, out T2 b) { a = v1; b = v2; }\n}\n\npublic class Pair : Pair, IComparable>\n{\n public T3 v3;\n public Pair() : base() { }\n public Pair(T1 v1, T2 v2, T3 v3) : base(v1, v2)\n { this.v3 = v3; }\n\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public int CompareTo(Pair p)\n {\n var c = base.CompareTo(p);\n if (c == 0)\n c = Comparer.Default.Compare(v3, p.v3);\n return c;\n }\n public override string ToString() => $\"{base.ToString()} {v3.ToString()}\";\n public void Tie(out T1 a, out T2 b, out T3 c) { Tie(out a, out b); c = v3; }\n}\n#endregion\n", "lang_cluster": "C#", "tags": ["sortings", "implementation", "greedy"], "code_uid": "3f6aa142df8d4c9f1de035c71cb140fa", "src_uid": "02d8d403eb60ae77756ff96f71b662d3", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.IO;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace Petya_Exam\n{\n class Program\n {\n struct Exam\n {\n public int ExamIndex;\n public int Publish;\n public int ExamDay;\n public int PrepDays;\n } \n \n static void Main(string[] args)\n {\n List list2 = new List();\n int N_Days;\n int Total_exams;\n \n string[] s = (Console.ReadLine()).Split(' ');\n N_Days = int.Parse(s[0]);\n Total_exams = int.Parse(s[1]);\n \n for (int i = 0; i < Total_exams; ++i)\n {\n Exam exm;\n s = (Console.ReadLine()).Split(' ');\n exm.ExamIndex = i + 1;\n exm.Publish = int.Parse(s[0]);\n exm.ExamDay = int.Parse(s[1]);\n exm.PrepDays = int.Parse(s[2]);\n list2.Add(exm);\n }\n\n \n list2.Sort((x, y) => x.ExamDay.CompareTo(y.ExamDay));\n List seq = new List();\n for (int i = 0; i <= N_Days; ++i)\n {\n seq.Add(0);\n }\n int print = 0;\n foreach (Exam l in list2)\n {\n if (l.Publish - 1 + l.PrepDays < l.ExamDay)\n {\n if (Ispossible(l.ExamIndex, l, seq))\n {\n seq[l.ExamDay] = Total_exams + 1;\n \n continue;\n }\n else\n {\n print = -1;\n break;\n }\n }\n else\n {\n print = -1;\n break;\n }\n }\n if (print == 0)\n {\n if (seq.Sum() != 0)\n {\n for (int j = 1; j < seq.Count; ++j)\n {\n if (j + 1 == seq.Count)\n {\n Console.Write(seq[j]);\n continue;\n }\n Console.Write(seq[j] + \" \");\n }\n }\n else\n {\n Console.WriteLine(\"-1\");\n }\n }\n else\n {\n Console.WriteLine(\"-1\");\n }\n \n //Console.ReadKey();\n }\n\n private static bool Ispossible(int exam_number, Exam l, List seq)\n {\n int days = l.PrepDays;\n\n int i = l.Publish;\n while (i < l.ExamDay && days > 0)\n {\n if (seq[i] == 0)\n {\n seq[i] = exam_number;\n days--;\n }\n i++;\n }\n return days == 0 ? true : false;\n }\n\n }\n}\n", "lang_cluster": "C#", "tags": ["sortings", "implementation", "greedy"], "code_uid": "a8798c4e3c080e080c30ec5bc059ebc8", "src_uid": "02d8d403eb60ae77756ff96f71b662d3", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Linq;\nusing System.Collections.Generic;\nusing System.Text;\n\nnamespace CodeForces.PRACTICE\n{\n // Kyoya and Photobooks (brute force, math)\n class _554A\n {\n static void Main(string[] args)\n {\n string s = Console.ReadLine();\n\n // egyik megoldas:\n //Console.WriteLine((s.Length + 1) * 25 + 1);\n\n HashSet set = new HashSet();\n\n int n = s.Length;\n for (int i = 0; i <= n; i++)\n for (char j = 'a'; j <= 'z'; j++)\n {\n string t = s.Substring(0, i) + j + s.Substring(i);\n set.Add(t);\n }\n Console.WriteLine(set.Count);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "math", "strings"], "code_uid": "2279fad45a7c6d0ea6f3c42e765214c0", "src_uid": "556684d96d78264ad07c0cdd3b784bc9", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nclass PairVariable : IComparable\n{\n public int a, b;\n public PairVariable()\n {\n a = b = 0;\n }\n public PairVariable(string s)\n {\n string[] q = s.Split();\n a = int.Parse(q[0]);\n b = int.Parse(q[1]);\n }\n public PairVariable(int a, int b)\n {\n this.a = a;\n this.b = b;\n }\n public int CompareTo(PairVariable pv)\n {\n if (this.a > pv.a)\n {\n return 1;\n }\n else if (this.a < pv.a)\n {\n return -1;\n }\n else\n {\n if (this.b >= pv.b)\n {\n return 1;\n }\n else\n {\n return -1;\n }\n }\n }\n\n}\nnamespace ConsoleApplication2\n{\n\n class Program\n {\n\n static int[,] matrix;\n static int[] mark;\n\n static void DFS(int v)\n {\n\n mark[v] = 1;\n for (int i = 0; i < matrix.GetLength(0); i++)\n {\n\n if (matrix[v, i] == 1)\n {\n\n if (mark[v] == 0)\n {\n DFS(i);\n }\n }\n }\n\n }\n static bool IsPrime(int n)\n {\n for (int i = 2; i <= Math.Sqrt(n); i++)\n {\n if (n % i == 0)\n {\n return false;\n }\n }\n return true;\n }\n static void IsYesNo(bool b)\n {\n if (b)\n {\n Console.WriteLine(\"YES\");\n }\n else\n {\n Console.WriteLine(\"NO\");\n }\n }\n static void Main(string[] args)\n {\n //string[] ss = Console.ReadLine().Split();\n string s = Console.ReadLine();\n Console.WriteLine(1+((s.Length+1)*25));\n \n }\n }\n}", "lang_cluster": "C#", "tags": ["brute force", "math", "strings"], "code_uid": "4df538af928c2d6a273dc9454012f2c3", "src_uid": "556684d96d78264ad07c0cdd3b784bc9", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\nusing System.Collections;\n\nnamespace Practice\n{\n class Program\n {\n static void Main(string[] args)\n {\n string[] s = new string[3];\n for (int i = 0; i < 3;i++)\n {\n s[i] = Console.ReadLine();\n }\n SolveProblem(s);\n Console.ReadLine();\n\n }\n\n static void SolveProblem(string [] s)\n {\n Dictionary coins = new Dictionary();\n coins.Add('A',0);\n coins.Add('B', 0);\n coins.Add('C', 0);\n\n for (int i = 0; i < s.Length;i++)\n {\n switch (s [i] [1])\n {\n case '>':\n coins[s[i][0]] += 1;\n break;\n case '<':\n coins[s[i][2]] += 1;\n break;\n \n }\n }\n \n if (coins ['A'] == coins ['B'] && coins['B'] == coins['C'])\n {\n Console.WriteLine(\"Impossible\");\n\n } else\n {\n var items = from pair in coins\n orderby pair.Value ascending\n select pair;\n foreach (KeyValuePair pair in items)\n {\n Console.Write(pair.Key);\n }\n }\n }\n\n }\n\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "5d060b23c326fff808ccdf2c8f8d3f2d", "src_uid": "97fd9123d0fb511da165b900afbde5dc", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Globalization;\nusing System.Text;\nusing System.IO;\nusing System.Linq;\nusing System.Threading;\n\n\n\n\nclass Program\n{\n\n void solve()\n {\n\n string[] s = new string[3];\n for (int i = 0; i < 3; i++)\n s[i] = nextString();\n string all = \"ABC\";\n foreach (char c1 in all)\n foreach (char c2 in all)\n if (c1 != c2)\n foreach (char c3 in all)\n if (c3 != c1 && c3 != c2)\n {\n bool ok = true;\n string cur = \"\" + c1 + c2 + c3;\n for (int i = 0; i < 3; i++)\n {\n int i1 = cur.IndexOf(s[i][0]);\n int i2 = cur.IndexOf(s[i][2]);\n if (s[i][1] == '<')\n {\n if (i1 > i2)\n ok = false;\n }\n if (s[i][1] == '>')\n {\n if (i1 < i2)\n ok = false;\n }\n }\n if (ok)\n {\n println(cur);\n return;\n }\n\n }\n println(\"Impossible\");\n }\n\n ////////////\n private void println(int[] ar)\n {\n for (int i = 0; i < ar.Length; i++)\n {\n if (i == ar.Length - 1)\n println(ar[i]);\n else\n print(ar[i] + \" \");\n }\n }\n private void println(int[] ar, bool add)\n {\n int A = 0;\n if (add)\n A++;\n for (int i = 0; i < ar.Length; i++)\n {\n if (i == ar.Length - 1)\n println(ar[i] + A);\n else\n print((ar[i] + A) + \" \");\n }\n }\n\n private void println(string Stringst)\n {\n Console.WriteLine(Stringst);\n }\n private void println(char charnum)\n {\n Console.WriteLine(charnum);\n }\n private void println(int Intnum)\n {\n Console.WriteLine(Intnum);\n }\n private void println(long Longnum)\n {\n Console.WriteLine(Longnum);\n }\n private void println(double Doublenum)\n {\n string s = Doublenum.ToString(CultureInfo.InvariantCulture);\n Console.WriteLine(s);\n }\n\n private void print(string Stringst)\n {\n Console.Write(Stringst);\n }\n private void print(int Intnum)\n {\n Console.Write(Intnum);\n }\n private void print(char charnum)\n {\n Console.Write(charnum);\n }\n private void print(long Longnum)\n {\n Console.Write(Longnum);\n }\n private void print(double Doublenum)\n {\n Console.Write(Doublenum);\n }\n\n\n string[] inputLine = new string[0];\n int inputInd = 0;\n string nextLine()\n {\n return Console.ReadLine();\n }\n void readInput()\n {\n if (inputInd != inputLine.Length)\n throw new Exception();\n inputInd = 0;\n inputLine = Console.ReadLine().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);\n if (inputLine.Length == 0)\n readInput();\n\n }\n int nextInt()\n {\n if (inputInd == inputLine.Length)\n readInput();\n return int.Parse(inputLine[inputInd++]);\n }\n long nextLong()\n {\n if (inputInd == inputLine.Length)\n readInput();\n return long.Parse(inputLine[inputInd++]);\n }\n double nextDouble()\n {\n if (inputInd == inputLine.Length)\n readInput();\n return double.Parse(inputLine[inputInd++]);\n }\n string nextString()\n {\n if (inputInd == inputLine.Length)\n readInput();\n return inputLine[inputInd++];\n }\n static void Main(string[] args)\n {\n Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;\n new Program().solve();\n }\n}\n\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "dd9be1ea3fd7661e8e6a346ff98c5293", "src_uid": "97fd9123d0fb511da165b900afbde5dc", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\n\nnamespace CodeForces\n{\n static class Program\n {\n static void Main()\n {\n const string filePath = @\"Data\\R468A.txt\";\n if (System.IO.File.Exists(filePath))\n {\n Console.SetIn(new System.IO.StreamReader(filePath));\n }\n\n IProblem counter = new R468A();\n\n foreach (var result in counter.GetResults())\n {\n Console.WriteLine(result);\n }\n }\n }\n\n internal class R468A : ProblemBase\n {\n public override IEnumerable GetResults()\n {\n var a = this.ReadInt32();\n var b = this.ReadInt32();\n var delta = Math.Abs(b - a);\n var s1 = delta / 2;\n var s2 = delta / 2;\n if (delta % 2 == 1)\n {\n s2++;\n }\n \n\n yield return ((s1+1)*s1/2+ (s2 + 1) * s2 / 2).ToString();\n }\n }\n\n internal class R468B : ProblemBase\n {\n public override IEnumerable GetResults()\n {\n yield return \"n/a\";\n }\n }\n\n internal class R468C : ProblemBase\n {\n public override IEnumerable GetResults()\n {\n yield return \"n/a\";\n }\n }\n\n internal class R468D : ProblemBase\n {\n public override IEnumerable GetResults()\n {\n yield return \"n/a\";\n }\n }\n\n abstract class MultipleTestsBase : ProblemBase\n {\n public sealed override IEnumerable GetResults()\n {\n var t = Convert.ToInt32(Console.ReadLine());\n for (int testCaseNumber = 0; testCaseNumber < t; testCaseNumber++)\n {\n foreach (var result in GetTestResult(testCaseNumber + 1))\n {\n yield return result;\n }\n\n }\n\n }\n\n protected abstract IEnumerable GetTestResult(int caseNumber);\n }\n\n public interface IProblem\n {\n IEnumerable GetResults();\n }\n\n public abstract class ProblemBase : IProblem\n {\n /// \n /// Pring array of T\n /// \n /// Generic paramter.\n /// The items.\n /// The message shown first.\n public void PrintArray(IEnumerable items, string prefixMessage)\n {\n Console.WriteLine(\"{0}: {1}\", prefixMessage, string.Join(\",\", items));\n }\n\n public void WriteDiagnostics(string message, params object[] objects)\n {\n Console.WriteLine(message, objects);\n }\n\n public virtual IEnumerable GetResults()\n {\n yield return \"No result\";\n }\n\n protected int[] ReadIntArray()\n {\n return Array.ConvertAll(ReadTokens(), Convert.ToInt32);\n }\n\n protected string[] ReadTokens()\n {\n var readLine = Console.ReadLine();\n if (readLine == null)\n {\n throw new Exception(\"Value read from Console is null\");\n }\n return readLine.Split(' ');\n }\n\n protected int ReadInt32()\n {\n return Convert.ToInt32(Console.ReadLine());\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "greedy", "implementation", "brute force"], "code_uid": "1ba4b8efd0edea5374d29d480930b4ba", "src_uid": "d3f2c6886ed104d7baba8dd7b70058da", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace ConsoleApplication1\n{\n class Program\n {\n static void Main(string[] args)\n {\n int a = int.Parse(Console.ReadLine());\n int b = int.Parse(Console.ReadLine());\n int c = Math.Abs(a - b);\n int d = c / 2;\n int e = c - d;\n int f = (1 + d) * d / 2;\n int g = (1 + e) * e / 2;\n int h = f + g;\n Console.WriteLine(h);\n //Console.ReadKey();\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "greedy", "implementation", "brute force"], "code_uid": "fadf4cefcb8204ea90f60f0152fb2346", "src_uid": "d3f2c6886ed104d7baba8dd7b70058da", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\n\nnamespace SecTry_1040AF\n{\n class Program\n {\n static void Main(string[] args)\n {\n IEnumerable container = Console.ReadLine().Split().Select(int.Parse);\n int n = container.ElementAt(0), whiteCost = container.ElementAt(1), blackCost = container.ElementAt(2), ans = 0;\n List line = Console.ReadLine().Split().Select(int.Parse).ToList();\n\n\n\n for (int i = 0, j = line.Count - 1; i <= j; i++, j--)\n {\n if (i == j && line[i] == 2) ans += Math.Min(whiteCost, blackCost);\n else if (line[i] != 2 && line[j] == 2) ans += line[i] == 0 ? whiteCost : blackCost;\n else if (line[i] == 2 && line[j] != 2) ans += line[j] == 0 ? whiteCost : blackCost;\n else if (line[i] == 2 && line[j] == 2) ans += Math.Min(blackCost, whiteCost)*2;\n else if (line[i] != line[j])\n {\n ans = -1;\n break;\n }\n\n\n }\n\n\n Console.WriteLine(ans);\n \n\n\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["greedy"], "code_uid": "e11ec3b74c5fdd8ee9766ea05e27abc3", "src_uid": "af07223819aeb5bd6ded4340c472b2b6", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Linq;\n\nnamespace codeforces\n{\n class Program\n {\n static void Main(string[] args)\n {\n int[] nm = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();\n int[] a = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();\n int sum = 0;\n for (int i = 0; i < nm[0] / 2; i++)\n {\n if (a[i] != 2 && a[nm[0] - 1 - i] != 2 && a[i] != a[nm[0] - 1 - i])\n {\n Console.WriteLine(-1);\n return;\n }\n if (a[i] == a[nm[0] - 1 - i] && a[i] != 2)\n continue;\n if (a[i] == a[nm[0] - 1 - i] && a[i] == 2)\n sum += Math.Min(nm[1], nm[2]) * 2;\n else if (a[i] == 2 && a[nm[0] - 1 - i] == 0 || a[i] == 0 && a[nm[0] - 1 - i] == 2)\n sum += nm[1];\n else sum += nm[2];\n }\n if (nm[0] % 2!=0)\n sum += a[nm[0]/2] == 2 ? Math.Min(nm[1], nm[2]) : 0;\n Console.WriteLine(sum);\n }\n }\n}", "lang_cluster": "C#", "tags": ["greedy"], "code_uid": "b57713ff83543f19af8b2a9ba77b909b", "src_uid": "af07223819aeb5bd6ded4340c472b2b6", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": ".NET Core C#", "source_code": "using System;\nusing System.Linq;\nusing CompLib.Util;\nusing System.Threading;\nusing CompLib.Mathematics;\n\npublic class Program\n{\n private int N;\n\n public void Solve()\n {\n var sc = new Scanner();\n N = sc.NextInt();\n\n /*\n * \u88570 ~ n+1\n *\n * 1/2\u306e\u78ba\u7387\u3067 1~n\u306b\u5efa\u3066\u308b\n *\n * i\u306b\u30d1\u30ef\u30fcp\u306e\u5efa\u3066\u308b\n * \u8ddd\u96e2p\u672a\u6e80\u306e\u8857\u306b\u5c4a\u304f\n *\n * 0\u3068n+1\u306b\u5c4a\u304b\u306a\u3044\n * 1~n\u306b\u306f1\u3064\u304b\u3089\u5c4a\u304f\n *\n * \n */\n\n // i\u672a\u6e80\u306e\u8857\u306b\u5c4a\u304f\n // i\u306b\u306f\u5c4a\u3044\u3066\u306a\u3044\n // \u78ba\u7387\n ModInt[] dp = new ModInt[N + 2];\n dp[1] = 1;\n\n ModInt odd = 1;\n ModInt even = 0;\n\n ModInt h = ModInt.Inverse(2);\n\n for (int i = 2; i <= N + 1; i++)\n {\n odd *= h;\n even *= h;\n if (i % 2 == 0)\n {\n dp[i] = odd;\n even += odd;\n }\n else\n {\n dp[i] = even;\n odd += even;\n }\n }\n\n Console.WriteLine(dp[N + 1]);\n }\n\n public static void Main(string[] args) => new Program().Solve();\n // public static void Main(string[] args) => new Thread(new Program().Solve, 1 << 27).Start();\n}\n\n// https://bitbucket.org/camypaper/complib\nnamespace CompLib.Mathematics\n{\n #region ModInt\n\n /// \n /// [0,) \u307e\u3067\u306e\u5024\u3092\u53d6\u308b\u3088\u3046\u306a\u6570\n /// \n public struct ModInt\n {\n /// \n /// \u5270\u4f59\u3092\u53d6\u308b\u5024\uff0e\n /// \n // public const long Mod = (int) 1e9 + 7;\n public const long Mod = 998244353;\n\n /// \n /// \u5b9f\u969b\u306e\u6570\u5024\uff0e\n /// \n public long num;\n\n /// \n /// \u5024\u304c \u3067\u3042\u308b\u3088\u3046\u306a\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u3092\u69cb\u7bc9\u3057\u307e\u3059\uff0e\n /// \n /// \u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u304c\u6301\u3064\u5024\n /// \u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u306e\u554f\u984c\u4e0a\uff0c\u30b3\u30f3\u30b9\u30c8\u30e9\u30af\u30bf\u5185\u3067\u306f\u5270\u4f59\u3092\u53d6\u308a\u307e\u305b\u3093\uff0e\u305d\u306e\u305f\u3081\uff0c \u2208 [0,) \u3092\u6e80\u305f\u3059\u3088\u3046\u306a \u3092\u6e21\u3057\u3066\u304f\u3060\u3055\u3044\uff0e\u3053\u306e\u30b3\u30f3\u30b9\u30c8\u30e9\u30af\u30bf\u306f O(1) \u3067\u5b9f\u884c\u3055\u308c\u307e\u3059\uff0e\n public ModInt(long n)\n {\n num = n;\n }\n\n /// \n /// \u3053\u306e\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u306e\u6570\u5024\u3092\u6587\u5b57\u5217\u306b\u5909\u63db\u3057\u307e\u3059\uff0e\n /// \n /// [0,) \u306e\u7bc4\u56f2\u5185\u306e\u6574\u6570\u3092 10 \u9032\u8868\u8a18\u3057\u305f\u3082\u306e\uff0e\n public override string ToString()\n {\n return num.ToString();\n }\n\n public static ModInt operator +(ModInt l, ModInt r)\n {\n l.num += r.num;\n if (l.num >= Mod) l.num -= Mod;\n return l;\n }\n\n public static ModInt operator -(ModInt l, ModInt r)\n {\n l.num -= r.num;\n if (l.num < 0) l.num += Mod;\n return l;\n }\n\n public static ModInt operator *(ModInt l, ModInt r)\n {\n return new ModInt(l.num * r.num % Mod);\n }\n\n public static implicit operator ModInt(long n)\n {\n n %= Mod;\n if (n < 0) n += Mod;\n return new ModInt(n);\n }\n\n /// \n /// \u4e0e\u3048\u3089\u308c\u305f 2 \u3064\u306e\u6570\u5024\u304b\u3089\u3079\u304d\u5270\u4f59\u3092\u8a08\u7b97\u3057\u307e\u3059\uff0e\n /// \n /// \u3079\u304d\u4e57\u306e\u5e95\n /// \u3079\u304d\u6307\u6570\n /// \u7e70\u308a\u8fd4\u3057\u4e8c\u4e57\u6cd5\u306b\u3088\u308a O(N log N) \u3067\u5b9f\u884c\u3055\u308c\u307e\u3059\uff0e\n public static ModInt Pow(ModInt v, long k)\n {\n return Pow(v.num, k);\n }\n\n /// \n /// \u4e0e\u3048\u3089\u308c\u305f 2 \u3064\u306e\u6570\u5024\u304b\u3089\u3079\u304d\u5270\u4f59\u3092\u8a08\u7b97\u3057\u307e\u3059\uff0e\n /// \n /// \u3079\u304d\u4e57\u306e\u5e95\n /// \u3079\u304d\u6307\u6570\n /// \u7e70\u308a\u8fd4\u3057\u4e8c\u4e57\u6cd5\u306b\u3088\u308a O(N log N) \u3067\u5b9f\u884c\u3055\u308c\u307e\u3059\uff0e\n public static ModInt Pow(long v, long k)\n {\n long ret = 1;\n for (k %= Mod - 1; k > 0; k >>= 1, v = v * v % Mod)\n if ((k & 1) == 1)\n ret = ret * v % Mod;\n return new ModInt(ret);\n }\n\n /// \n /// \u4e0e\u3048\u3089\u308c\u305f\u6570\u306e\u9006\u5143\u3092\u8a08\u7b97\u3057\u307e\u3059\uff0e\n /// \n /// \u9006\u5143\u3092\u53d6\u308b\u5bfe\u8c61\u3068\u306a\u308b\u6570\n /// \u9006\u5143\u3068\u306a\u308b\u3088\u3046\u306a\u5024\n /// \u6cd5\u304c\u7d20\u6570\u3067\u3042\u308b\u3053\u3068\u3092\u4eee\u5b9a\u3057\u3066\uff0c\u30d5\u30a7\u30eb\u30de\u30fc\u306e\u5c0f\u5b9a\u7406\u306b\u5f93\u3063\u3066\u9006\u5143\u3092 O(log N) \u3067\u8a08\u7b97\u3057\u307e\u3059\uff0e\n public static ModInt Inverse(ModInt v)\n {\n return Pow(v, Mod - 2);\n }\n }\n\n #endregion\n\n #region Binomial Coefficient\n\n public class BinomialCoefficient\n {\n public ModInt[] fact, ifact;\n\n public BinomialCoefficient(int n)\n {\n fact = new ModInt[n + 1];\n ifact = new ModInt[n + 1];\n fact[0] = 1;\n for (int i = 1; i <= n; i++)\n fact[i] = fact[i - 1] * i;\n ifact[n] = ModInt.Inverse(fact[n]);\n for (int i = n - 1; i >= 0; i--)\n ifact[i] = ifact[i + 1] * (i + 1);\n ifact[0] = ifact[1];\n }\n\n public ModInt this[int n, int r]\n {\n get\n {\n if (n < 0 || n >= fact.Length || r < 0 || r > n) return 0;\n return fact[n] * ifact[n - r] * ifact[r];\n }\n }\n\n public ModInt RepeatedCombination(int n, int k)\n {\n if (k == 0) return 1;\n return this[n + k - 1, k];\n }\n }\n\n #endregion\n}\n\n\nnamespace CompLib.Util\n{\n using System;\n using System.Linq;\n\n class Scanner\n {\n private string[] _line;\n private int _index;\n private const char Separator = ' ';\n\n public Scanner()\n {\n _line = new string[0];\n _index = 0;\n }\n\n public string Next()\n {\n if (_index >= _line.Length)\n {\n string s;\n do\n {\n s = Console.ReadLine();\n } while (s.Length == 0);\n\n _line = s.Split(Separator);\n _index = 0;\n }\n\n return _line[_index++];\n }\n\n public string ReadLine()\n {\n _index = _line.Length;\n return Console.ReadLine();\n }\n\n public int NextInt() => int.Parse(Next());\n public long NextLong() => long.Parse(Next());\n public double NextDouble() => double.Parse(Next());\n public decimal NextDecimal() => decimal.Parse(Next());\n public char NextChar() => Next()[0];\n public char[] NextCharArray() => Next().ToCharArray();\n\n public string[] Array()\n {\n string s = Console.ReadLine();\n _line = s.Length == 0 ? new string[0] : s.Split(Separator);\n _index = _line.Length;\n return _line;\n }\n\n public int[] IntArray() => Array().Select(int.Parse).ToArray();\n public long[] LongArray() => Array().Select(long.Parse).ToArray();\n public double[] DoubleArray() => Array().Select(double.Parse).ToArray();\n public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();\n }\n}", "lang_cluster": "C#", "tags": ["math", "dp", "combinatorics"], "code_uid": "3694599ea6e0d6dde5947897ddb8ef37", "src_uid": "cec37432956bb0a1ce62a0188fe2d805", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing static System.Console;\nusing static System.Math;\n\nnamespace AtTest.CodeForces._1452\n{\n class D\n {\n static void Main(string[] args)\n {\n var sw = new System.IO.StreamWriter(OpenStandardOutput()) { AutoFlush = false };\n SetOut(sw);\n\n Method(args);\n\n Out.Flush();\n }\n\n static void Method(string[] args)\n {\n int n = ReadInt();\n long mask = 998244353;\n\n long[] dp = new long[n+1];\n dp[0] = 1;\n dp[1] = 1;\n long[] oddSums = new long[n + 1];\n oddSums[1] = 1;\n long[] evenSums = new long[n + 1];\n evenSums[0] = 1;\n\n for(int i = 2; i <= n; i++)\n {\n if (i % 2 == 1)\n {\n dp[i] = evenSums[i - 1];\n dp[i] %= mask;\n oddSums[i] = oddSums[i - 2] + dp[i];\n oddSums[i] %= mask;\n }\n else\n {\n dp[i] = oddSums[i - 1];\n dp[i] %= mask;\n evenSums[i] = evenSums[i - 2] + dp[i];\n evenSums[i] %= mask;\n }\n }\n\n long div = 1;\n for(int i = 0; i < n; i++)\n {\n div *= 2;\n div %= mask;\n }\n\n long res = dp[n];\n res *= Inverse(div, mask);\n res %= mask;\n WriteLine(res);\n }\n\n\n static long Inverse(long val,long mask)\n {\n long a = mask;\n long b = val % mask;\n long x = 1;\n long x1 = 0;\n long y = 0;\n long y1 = 1;\n while (b > 0)\n {\n long q = a / b;\n long r = a % b;\n long x2 = (mask + x - (q * x1) % mask) % mask;\n long y2 = (mask + y - (q * y1) % mask) % mask;\n a = b;\n b = r;\n x = x1;\n x1 = x2;\n y = y1;\n y1 = y2;\n }\n return y;\n }\n\n private static string Read() { return ReadLine(); }\n private static char[] ReadChars() { return Array.ConvertAll(Read().Split(), a => a[0]); }\n private static int ReadInt() { return int.Parse(Read()); }\n private static long ReadLong() { return long.Parse(Read()); }\n private static double ReadDouble() { return double.Parse(Read()); }\n private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }\n private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }\n private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "dp", "combinatorics"], "code_uid": "fe5dd34285663c219a27687b1ef0d552", "src_uid": "cec37432956bb0a1ce62a0188fe2d805", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Text;\n\nnamespace ConsoleApplication1\n{\n class Program\n {\n static void Main(string[] args)\n {\n int n, m;\n double q;\n\n n = int.Parse(Console.ReadLine());\n m = 8 * n + 1;\n q = Math.Sqrt(m);\n if (Math.Truncate(q) == q) Console.WriteLine(\"YES\");\n else Console.WriteLine(\"NO\");\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "math"], "code_uid": "ea29c3c35b77c5a59ca272e385f0c45d", "src_uid": "587d4775dbd6a41fc9e4b81f71da7301", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nnamespace ConsoleApplication1\n{\n class Program\n {\n static void Main()\n {\n var s = 2*Convert.ToInt16(Console.ReadLine());\n var a = (byte) Math.Sqrt(s);\n Console.WriteLine(a*(a+1)==s?\"YES\":\"NO\");\n }\n }\n}", "lang_cluster": "C#", "tags": ["brute force", "math"], "code_uid": "e5287b4c5cbb7484056ce1b26c601d2e", "src_uid": "587d4775dbd6a41fc9e4b81f71da7301", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.IO;\nusing System.Text;\n\nnamespace MUH_and_House_of_Cards\n{\n internal class Program\n {\n private static readonly StreamReader reader = new StreamReader(Console.OpenStandardInput(1024*10), Encoding.ASCII, false, 1024*10);\n private static readonly StreamWriter writer = new StreamWriter(Console.OpenStandardOutput(1024*10), Encoding.ASCII, 1024*10);\n\n private static void Main(string[] args)\n {\n long n = long.Parse(reader.ReadLine());\n\n if (n < 2)\n {\n writer.WriteLine(\"0\");\n }\n else\n {\n long count = 2;\n long delta = 2;\n int flour = 0;\n while (count <= n)\n {\n flour++;\n delta += 3;\n count += delta;\n }\n\n if (flour%3 == 2)\n {\n if (n%3 == 0)\n flour -= 2;\n else\n {\n flour++;\n }\n }\n else if (flour%3 == 1)\n {\n if (n%3 == 2)\n flour += 2;\n else\n {\n flour--;\n }\n }\n\n writer.WriteLine(flour/3);\n }\n\n\n writer.Flush();\n }\n }\n}", "lang_cluster": "C#", "tags": ["math", "greedy", "binary search", "brute force"], "code_uid": "a131eac99055bc43d9c554403d1c1a76", "src_uid": "ab4f9cb3bb0df6389a4128e9ff1207de", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing Solver.Ex;\nusing Enum = System.Linq.Enumerable;\nusing Watch = System.Diagnostics.Stopwatch;\nusing StringBuilder = System.Text.StringBuilder;\nusing BitVector = System.Collections.Specialized.BitVector32;\nnamespace Solver\n{\n\n public class Solver\n {\n public void Solve()\n {\n var n = sc.Long();\n var count = 0;\n for (long i = 1; i < n; i++)\n {\n var t = 3 * i * (i + 1) / 2;\n var num = n + i;\n if (t > num)\n break;\n if (num % 3 != 0)\n continue;\n count++;\n }\n IO.Printer.Out.PrintLine(count);\n }\n internal IO.StreamScanner sc;\n }\n\n #region Main and Settings\n static class Program\n {\n static void Main(string[] arg)\n {\n#if DEBUG\n var errStream = new System.IO.FileStream(@\"..\\..\\dbg.out\", System.IO.FileMode.Create, System.IO.FileAccess.Write, System.IO.FileShare.ReadWrite);\n System.Diagnostics.Debug.Listeners.Add(new System.Diagnostics.TextWriterTraceListener(errStream, \"debugStream\"));\n System.Diagnostics.Debug.AutoFlush = false;\n var sw = new Watch();\n sw.Start();\n try\n {\n#endif\n var solver = new Solver();\n solver.sc = new IO.StreamScanner(Console.OpenStandardInput());\n IO.Printer.Out = new IO.Printer(new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });\n solver.Solve();\n IO.Printer.Out.Flush();\n#if DEBUG\n }\n catch (Exception ex)\n {\n Console.Error.WriteLine(ex.Message);\n Console.Error.WriteLine(ex.StackTrace);\n }\n finally\n {\n sw.Stop();\n Console.ForegroundColor = ConsoleColor.Green;\n Console.Error.WriteLine(\"Time:{0}ms\", sw.ElapsedMilliseconds);\n System.Diagnostics.Debug.Close();\n System.Threading.Thread.Sleep(System.Threading.Timeout.Infinite);\n }\n#endif\n }\n\n\n }\n #endregion\n}\n#region IO Helper\nnamespace Solver.IO\n{\n public class Printer\n {\n static Printer()\n {\n Out = new Printer(Console.Out);\n }\n public static Printer Out { get; set; }\n private readonly System.IO.TextWriter writer;\n private readonly System.Globalization.CultureInfo info;\n public string Separator { get; set; }\n public string NewLine { get { return writer.NewLine; } set { writer.NewLine = value ?? \"\\n\"; } }\n public Printer(System.IO.TextWriter tw = null, System.Globalization.CultureInfo ci = null, string separator = null, string newLine = null)\n {\n writer = tw ?? System.IO.TextWriter.Null;\n info = ci ?? System.Globalization.CultureInfo.InvariantCulture;\n NewLine = newLine;\n Separator = separator ?? \" \";\n }\n public void Print(int num) { writer.Write(num.ToString(info)); }\n public void Print(int num, string format) { writer.Write(num.ToString(format, info)); }\n public void Print(long num) { writer.Write(num.ToString(info)); }\n public void Print(long num, string format) { writer.Write(num.ToString(format, info)); }\n public void Print(double num) { writer.Write(num.ToString(\"F12\", info)); }\n public void Print(double num, string format) { writer.Write(num.ToString(format, info)); }\n public void Print(string str) { writer.Write(str); }\n public void Print(string format, params object[] arg) { writer.Write(string.Format(info, format, arg)); }\n public void Print(string format, IEnumerable sources) { writer.Write(format, sources.OfType().ToArray()); }\n public void Print(IEnumerable sources) { writer.Write(sources.AsString()); }\n public void Print(IEnumerable sources)\n {\n var res = new System.Text.StringBuilder();\n foreach (var x in sources)\n {\n res.AppendFormat(info, \"{0}\", x);\n if (string.IsNullOrEmpty(Separator))\n res.Append(Separator);\n }\n writer.Write(res.ToString(0, res.Length - Separator.Length));\n }\n public void PrintLine() { writer.WriteLine(); }\n public void PrintLine(int num) { writer.WriteLine(num.ToString(info)); }\n public void PrintLine(int num, string format) { writer.WriteLine(num.ToString(format, info)); }\n public void PrintLine(long num) { writer.WriteLine(num.ToString(info)); }\n public void PrintLine(long num, string format) { writer.WriteLine(num.ToString(format, info)); }\n public void PrintLine(double num) { writer.WriteLine(num.ToString(\"F12\", info)); }\n public void PrintLine(double num, string format) { writer.WriteLine(num.ToString(format, info)); }\n public void PrintLine(string str) { writer.WriteLine(str); }\n public void PrintLine(string format, params object[] arg) { writer.WriteLine(string.Format(info, format, arg)); }\n public void PrintLine(string format, IEnumerable sources) { writer.WriteLine(format, sources.OfType().ToArray()); }\n public void PrintLine(IEnumerable sources)\n {\n var res = new StringBuilder();\n foreach (var x in sources)\n {\n res.AppendFormat(info, \"{0}\", x);\n if (!string.IsNullOrEmpty(Separator))\n res.Append(Separator);\n }\n writer.WriteLine(res.ToString(0, res.Length - Separator.Length));\n }\n public void Flush() { writer.Flush(); }\n }\n public class StreamScanner\n {\n public StreamScanner(System.IO.Stream stream)\n {\n iStream = stream;\n }\n private readonly System.IO.Stream iStream;\n private readonly byte[] buf = new byte[1024];\n private int len, ptr;\n private bool eof = false;\n public bool EndOfStream { get { return eof; } }\n private byte readByte()\n {\n if (eof) throw new System.IO.EndOfStreamException();\n if (ptr >= len)\n {\n ptr = 0;\n len = iStream.Read(buf, 0, 1024);\n if (len <= 0)\n {\n eof = true;\n return 0;\n }\n }\n return buf[ptr++];\n }\n private bool inSpan(byte c)\n {\n const byte lb = 33, ub = 126;\n return !(c >= lb && c <= ub);\n }\n private byte skip()\n {\n byte b = 0;\n do b = readByte();\n while (!eof && inSpan(b));\n return b;\n }\n public char Char()\n {\n return (char)skip();\n }\n public char[] Char(int n)\n {\n var a = new char[n];\n for (int i = 0; i < n; i++)\n a[i] = (char)skip();\n return a;\n }\n public char[][] Char(int n, int m)\n {\n var a = new char[n][];\n for (int i = 0; i < n; i++)\n a[i] = Char(m);\n return a;\n }\n public string Scan()\n {\n\n const byte lb = 33, ub = 126;\n if (eof) throw new System.IO.EndOfStreamException();\n\n do\n {\n while (ptr < len && (buf[ptr] < lb || ub < buf[ptr]))\n {\n ptr++;\n }\n if (ptr < len)\n break;\n ptr = 0;\n len = iStream.Read(buf, 0, 1024);\n if (len <= 0)\n {\n eof = true;\n return null;\n }\n continue;\n } while (true);\n\n StringBuilder sb = null;\n do\n {\n var i = ptr;\n while (i < len)\n {\n if (buf[i] < lb || ub < buf[i])\n {\n string s;\n if (sb != null)\n {\n sb.Append(System.Text.UTF8Encoding.Default.GetChars(buf, ptr, i - ptr));\n s = sb.ToString();\n }\n else s = new string(System.Text.UTF8Encoding.Default.GetChars(buf, ptr, i - ptr));\n ptr = i + 1;\n return s;\n }\n i++;\n }\n i = len - ptr;\n if (sb == null) sb = new StringBuilder(i + 32);\n sb.Append(System.Text.UTF8Encoding.Default.GetChars(buf, ptr, i));\n ptr = 0;\n } while ((len = iStream.Read(buf, 0, 1024)) > 0);\n eof = true;\n return sb.ToString();\n }\n public string[] Scan(int n)\n {\n var a = new string[n];\n for (int i = 0; i < n; i++)\n a[i] = Scan();\n return a;\n }\n public string ScanLine()\n {\n const byte el = 10, cr = 13;\n if (eof) throw new System.IO.EndOfStreamException();\n StringBuilder sb = null;\n do\n {\n var i = ptr;\n while (i < len)\n {\n if (buf[i] == cr || buf[i] == el)\n {\n string s;\n if (sb != null)\n {\n sb.Append(System.Text.UTF8Encoding.Default.GetChars(buf, ptr, i - ptr));\n s = sb.ToString();\n }\n else s = new string(System.Text.UTF8Encoding.Default.GetChars(buf, ptr, i - ptr));\n if (buf[i] == cr) i++;\n if (buf[i] == el) i++;\n ptr = i;\n return s;\n }\n i++;\n }\n i = len - ptr;\n if (sb == null) sb = new StringBuilder(i + 32);\n sb.Append(System.Text.UTF8Encoding.Default.GetChars(buf, ptr, i));\n ptr = 0;\n } while ((len = iStream.Read(buf, 0, 1024)) > 0);\n eof = true;\n return sb.ToString();\n }\n public double Double()\n {\n return double.Parse(Scan(), System.Globalization.CultureInfo.InvariantCulture);\n }\n public double[] Double(int n)\n {\n var a = new double[n];\n for (int i = 0; i < n; i++)\n a[i] = Double();\n return a;\n }\n public int Integer()\n {\n var ret = 0;\n byte b = 0;\n bool isMynus = false;\n const byte zero = 48, nine = 57, mynus = 45;\n do b = readByte();\n while (!eof && !((b >= zero && b <= nine) || b == mynus));\n\n if (b == mynus)\n {\n isMynus = true;\n b = readByte();\n }\n while (true)\n {\n if (b >= zero && b <= nine)\n {\n ret = ret * 10 + b - zero;\n }\n else return isMynus ? -ret : ret;\n b = readByte();\n }\n\n }\n public int[] Integer(int n)\n {\n var a = new int[n];\n for (int i = 0; i < n; i++)\n a[i] = Integer();\n return a;\n }\n public long Long()\n {\n long ret = 0;\n byte b = 0;\n bool isMynus = false;\n const byte zero = 48, nine = 57, mynus = 45;\n do b = readByte();\n while (!eof && !((b >= zero && b <= nine) || b == mynus));\n if (b == '-')\n {\n isMynus = true;\n b = readByte();\n }\n while (true)\n {\n if (b >= zero && b <= nine)\n ret = ret * 10 + (b - zero);\n else return isMynus ? -ret : ret;\n b = readByte();\n }\n\n }\n public long[] Long(int n)\n {\n var a = new long[n];\n for (int i = 0; i < n; i++)\n a[i] = Long();\n return a;\n }\n public void Flush()\n {\n iStream.Flush();\n }\n\n }\n\n}\n#endregion\n#region Extension\nnamespace Solver.Ex\n{\n static public partial class EnumerableEx\n {\n static public string AsString(this IEnumerable source)\n {\n return new string(source.ToArray());\n }\n static public string AsJoinedString(this IEnumerable source, string separator = \" \")\n {\n return string.Join(separator, source);\n }\n static public T[] Enumerate(this int n, Func selector)\n {\n var res = new T[n];\n for (int i = 0; i < n; i++)\n res[i] = selector(i);\n return res;\n }\n }\n}\n#endregion\n", "lang_cluster": "C#", "tags": ["math", "greedy", "binary search", "brute force"], "code_uid": "d0885bd4efa23a142191a144fbe6089a", "src_uid": "ab4f9cb3bb0df6389a4128e9ff1207de", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\nusing System.IO;\n\nnamespace razmer_monitora\n{\n class Program\n {\n static void Main(string[] args)\n {\n int n = Int32.Parse(Console.ReadLine());\n int a = (int)Math.Sqrt(n);\n int b = n/a;\n while (a*b!=n)\n {\n a--;\n b = n / a;\n }\n Console.WriteLine(a+\" \"+b);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "math"], "code_uid": "dbc724dc416aab8b77773010d5342d4f", "src_uid": "f52af273954798a4ae38a1378bfbf77a", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\n\npublic class Program\n{\n\tpublic static void Main()\n\t{\n\t\tint n = int.Parse(Console.ReadLine());\n\t\tfor (int i = (int)Math.Sqrt(n); i > 0; i--)\n\t\t{\n\t\t\tif (n % i == 0)\n\t\t\t{\n\t\t\t\tConsole.WriteLine($\"{i} {n / i}\");\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t}\n}", "lang_cluster": "C#", "tags": ["brute force", "math"], "code_uid": "69662d118c3bd43e0361d2076d642675", "src_uid": "f52af273954798a4ae38a1378bfbf77a", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\n\nclass Program\n{\n\tstatic void Main()\n\t{\n\t\tint n = Convert.ToInt32(Console.ReadLine());\n\t\tstring inp = Console.ReadLine();\n\t\tstring[] par = inp.Split(' ');\n\t\tint i, d, prognoz;\n\n\t\tint[] a = new int[n];\n\n\t\tfor (i = 0; i < n; i++)\n\t\t\ta[i] = Convert.ToInt32(par[i]);\n\n\t\td = (a[n - 1] - a[0]) / (n - 1);\n\n\t\tfor (i = 1; i < n; i++)\n\t\t{\n\t\t\tif (a[i] - a[i - 1] != d)\n\t\t\t{\n\t\t\t\td = 0;\n\t\t\t}\n\t\t}\n\n\t\t/*if (d == a[1] - a[0])\n\t\t\tprognoz = a[n - 1] + d;\n\t\telse\n\t\t\tprognoz = a[n - 1];*/\n\n\t\tprognoz = a[n - 1] + d;\n\n\t\tConsole.WriteLine(\"{0}\", prognoz);\n\t}\n}\n", "lang_cluster": "C#", "tags": ["math", "implementation"], "code_uid": "05e09893f51f357a3c982f179811416c", "src_uid": "d04fa4322a1b300bdf4a56f09681b17f", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": ".NET Core C#", "source_code": "\ufeffusing System;\n\nnamespace E\n{\n class Program\n {\n static void Main(string[] args)\n {\n int days = int.Parse(Console.ReadLine());\n var _temp = Console.ReadLine().Split(' ');\n\n bool _flag = true;\n int zeroDay, secondDay, progress, expectedTemp, currTemp = 0;\n\n\n\n zeroDay = int.Parse(_temp[0]);\n secondDay = int.Parse(_temp[1]);\n\n progress = secondDay - zeroDay;\n if (days >= 3)\n {\n for (int i = 1; i < days; i++)\n {\n currTemp = int.Parse(_temp[i]);\n expectedTemp = int.Parse(_temp[i - 1]) + progress;\n if(currTemp != expectedTemp)\n {\n _flag = false;\n break;\n }\n }\n if(_flag)\n {\n Console.WriteLine(currTemp + progress);\n \n }\n else\n {\n Console.WriteLine(_temp[days - 1]);\n }\n\n }\n else\n {\n expectedTemp = zeroDay + progress * (days - 1);\n\n if (int.Parse(_temp[days - 1]) == expectedTemp)\n {\n Console.WriteLine(expectedTemp + progress);\n\n }\n else\n Console.WriteLine(_temp[days - 1]);\n }\n\n\n\n\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "implementation"], "code_uid": "df88ea4157a4dd1711b9cfe6a0dc3ea6", "src_uid": "d04fa4322a1b300bdf4a56f09681b17f", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.IO;\nusing System.Text;\n\nnamespace Lucky_Year\n{\n internal class Program\n {\n private static readonly StreamReader reader = new StreamReader(Console.OpenStandardInput(1024*10), Encoding.ASCII, false, 1024*10);\n private static readonly StreamWriter writer = new StreamWriter(Console.OpenStandardOutput(1024*10), Encoding.ASCII, 1024*10);\n\n private static void Main(string[] args)\n {\n string s = reader.ReadLine();\n int n = int.Parse(s);\n\n char[] next = s.ToCharArray();\n string ss;\n for (int i = 1; i < next.Length; i++)\n {\n next[i] = '0';\n }\n if (next[0] < '9')\n {\n next[0]++;\n ss = new string(next);\n }\n else\n {\n next[0] = '0';\n ss = \"1\" + new string(next);\n }\n\n writer.WriteLine(long.Parse(ss) - n);\n writer.Flush();\n }\n }\n}", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "922a27aba11e561271f8f6630e1bccdb", "src_uid": "a3e15c0632e240a0ef6fe43a5ab3cc3e", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace A808\n{\n class Program\n {\n static void Main(string[] args)\n {\n int a = int.Parse(Console.ReadLine());\n string a1 = a + \"\";\n int l = a1.Length;\n if (l == 1)\n {\n Console.WriteLine(1);\n }\n else {\n\n int m =int.Parse(a1[0]+\"\");\n int k = (int)Math.Pow(10, l - 1);\n Console.WriteLine((m+1)* k-a);\n }\n \n }\n }\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "7b0b7ae3275fd269657b221d8d67ad5c", "src_uid": "a3e15c0632e240a0ef6fe43a5ab3cc3e", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Diagnostics;\nusing System.Globalization;\nusing System.IO;\nusing System.Linq;\nusing System.Numerics;\nusing System.Text;\nusing System.Threading;\n\nnamespace ReadWriteTemplate\n{\n public static class Solver\n {\n private static void SolveCase()\n {\n long n = ReadLong();\n long m = ReadLong();\n long ans = 0;\n for (long i = 1; i <= m; i++)\n {\n for (long j = 1; j <= m; j++)\n {\n if ((i * i + j * j) % m == 0)\n {\n long ci = (n + m - i) / m;\n long cj = (n + m - j) / m;\n ans += ci * cj;\n }\n }\n }\n Writer.WriteLine(ans);\n }\n\n public static void Solve()\n {\n SolveCase();\n\n /*var sw = Stopwatch.StartNew();*/\n\n /*int T = ReadInt();\n for (int i = 0; i < T; i++)\n {\n // Writer.Write(\"Case #{0}: \", i + 1);\n Precalc();\n SolveCase();\n }*/\n\n /*sw.Stop();\n Console.WriteLine(sw.ElapsedMilliseconds);*/\n }\n\n public static void Main()\n {\n Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;\n\n#if DEBUG\n //Reader = Console.In; Writer = Console.Out;\n Reader = File.OpenText(\"input.txt\"); Writer = File.CreateText(\"output.txt\");\n#else\n Reader = Console.In; Writer = Console.Out;\n#endif\n\n // Solve();\n Thread thread = new Thread(Solve, 64 * 1024 * 1024);\n thread.CurrentCulture = CultureInfo.InvariantCulture;\n thread.Start();\n thread.Join();\n\n Reader.Close();\n Writer.Close();\n }\n\n public static IOrderedEnumerable OrderByWithShuffle(this IEnumerable source, Func keySelector)\n {\n return source.Shuffle().OrderBy(keySelector);\n }\n\n public static T[] Shuffle(this IEnumerable source)\n {\n T[] result = source.ToArray();\n Random rnd = new Random();\n for (int i = result.Length - 1; i >= 1; i--)\n {\n int k = rnd.Next(i + 1);\n T tmp = result[k];\n result[k] = result[i];\n result[i] = tmp;\n }\n return result;\n }\n\n #region Read/Write\n\n private static TextReader Reader;\n\n private static TextWriter Writer;\n\n private static Queue CurrentLineTokens = new Queue();\n\n private static string[] ReadAndSplitLine()\n {\n return Reader.ReadLine().Split(new[] { ' ', '\\t' }, StringSplitOptions.RemoveEmptyEntries);\n }\n\n public static string ReadToken()\n {\n while (CurrentLineTokens.Count == 0)\n CurrentLineTokens = new Queue(ReadAndSplitLine());\n return CurrentLineTokens.Dequeue();\n }\n\n public static string ReadLine()\n {\n return Reader.ReadLine();\n }\n\n public static int ReadInt()\n {\n return int.Parse(ReadToken());\n }\n\n public static long ReadLong()\n {\n return long.Parse(ReadToken());\n }\n\n public static double ReadDouble()\n {\n return double.Parse(ReadToken(), CultureInfo.InvariantCulture);\n }\n\n public static int[] ReadIntArray()\n {\n return ReadAndSplitLine().Select(int.Parse).ToArray();\n }\n\n public static long[] ReadLongArray()\n {\n return ReadAndSplitLine().Select(long.Parse).ToArray();\n }\n\n public static double[] ReadDoubleArray()\n {\n return ReadAndSplitLine().Select(s => double.Parse(s, CultureInfo.InvariantCulture)).ToArray();\n }\n\n public static int[][] ReadIntMatrix(int numberOfRows)\n {\n int[][] matrix = new int[numberOfRows][];\n for (int i = 0; i < numberOfRows; i++)\n matrix[i] = ReadIntArray();\n return matrix;\n }\n\n public static string[] ReadLines(int quantity)\n {\n string[] lines = new string[quantity];\n for (int i = 0; i < quantity; i++)\n lines[i] = Reader.ReadLine().Trim();\n return lines;\n }\n\n public static void WriteArray(IEnumerable array)\n {\n Writer.WriteLine(string.Join(\" \", array));\n }\n\n #endregion\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "number theory"], "code_uid": "8cdd1b66995aedd0adf4e3f4c9d00fa7", "src_uid": "2ec9e7cddc634d7830575e14363a4657", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.IO;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace Lib\n{\n public class DivideCandies\n {\n public static void Main()\n {\n Solve(Console.In, Console.Out);\n }\n\n public static void Solve(TextReader tr, TextWriter tw)\n {\n var tokens = tr.ReadLine().Split();\n var n = long.Parse(tokens[0]);\n var m = long.Parse(tokens[1]);\n\n var t = new long[m, m];\n\n var res = 0L;\n for (long i = 0; i < m; i++)\n {\n for (long j = 0; j < m; j++)\n {\n t[i, j] = ((i+1) * (i+1) + (j+1) * (j+1)) % m;\n if (t[i, j] == 0)\n res++;\n }\n }\n\n var p = n / m;\n res *= p * p;\n\n var r = n % m;\n\n var res2 = 0L;\n for (long i = 0; i < r; i++)\n {\n for (long j = 0; j < m; j++)\n {\n if (t[i, j] == 0)\n res2++;\n }\n }\n res += res2 * p * 2;\n\n for (long i = 0; i < r; i++)\n {\n for (long j = 0; j < r; j++)\n {\n if (t[i, j] == 0)\n res++;\n }\n }\n\n tw.WriteLine(res);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "number theory"], "code_uid": "d45538f9c8a62439abcd8d561e940b91", "src_uid": "2ec9e7cddc634d7830575e14363a4657", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Diagnostics;\nusing System.IO;\nusing System.Linq;\nusing System.Text;\n\nclass Solution\n{\n\n static void Main(String[] args)\n {\n Dictionary r = new Dictionary();\n r[3] ='3';\n r[7] ='7';\n r[4] ='6';\n r[6] ='4';\n r[5] ='9';\n r[9] ='5';\n r[8] ='0';\n r[0] = '8';\n string s = Console.ReadLine();\n string rs = string.Concat(s.Reverse());\n for (int i = 0; i < s.Length ; i++)\n {\n int q = int.Parse(s[i].ToString());\n if(!r.ContainsKey(q))\n {\n Console.WriteLine(\"NO\");\n Console.Read();\n return;\n }\n if(r[q] != rs[i])\n {\n Console.WriteLine(\"NO\");\n Console.Read();\n return;\n }\n }\n Console.WriteLine(\"YES\");\n Console.Read();\n }\n}", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "10f1690df3a990f57f13301baff273dd", "src_uid": "0f11f41cefd7cf43f498e511405426c3", "difficulty": 1900.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.IO;\nusing System.Text;\n\nnamespace Touchy_Feely_Palindromes\n{\n internal class Program\n {\n private static readonly StreamReader reader = new StreamReader(Console.OpenStandardInput(1024*10), Encoding.ASCII, false, 1024*10);\n private static readonly StreamWriter writer = new StreamWriter(Console.OpenStandardOutput(1024*10), Encoding.ASCII, 1024*10);\n\n private static void Main(string[] args)\n {\n string s = reader.ReadLine();\n\n for (int i = 0; i < s.Length - i; i++)\n {\n switch (s[s.Length - i - 1])\n {\n case '1':\n case '2':\n writer.WriteLine(\"No\");\n writer.Flush();\n return;\n case '3':\n if (s[i] != '3')\n {\n writer.WriteLine(\"No\");\n writer.Flush();\n return;\n }\n break;\n case '4':\n if (s[i] != '6')\n {\n writer.WriteLine(\"No\");\n writer.Flush();\n return;\n }\n break;\n case '5':\n if (s[i] != '9')\n {\n writer.WriteLine(\"No\");\n writer.Flush();\n return;\n }\n break;\n case '6':\n if (s[i] != '4')\n {\n writer.WriteLine(\"No\");\n writer.Flush();\n return;\n }\n break;\n case '7':\n if (s[i] != '7')\n {\n writer.WriteLine(\"No\");\n writer.Flush();\n return;\n }\n break;\n case '8':\n if (s[i] != '0')\n {\n writer.WriteLine(\"No\");\n writer.Flush();\n return;\n }\n break;\n case '9':\n if (s[i] != '5')\n {\n writer.WriteLine(\"No\");\n writer.Flush();\n return;\n }\n break;\n case '0':\n if (s[i] != '8')\n {\n writer.WriteLine(\"No\");\n writer.Flush();\n return;\n }\n break;\n }\n }\n\n writer.WriteLine(\"Yes\");\n writer.Flush();\n }\n }\n}", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "e510772b61cf63a8036ca822681da947", "src_uid": "0f11f41cefd7cf43f498e511405426c3", "difficulty": 1900.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\n\nclass Program {\n static void Main() {\n int n = int.Parse(Console.ReadLine());\n \n int b = n%3 == 2? n/3 + 1 : n/3;\n int a = b/12;\n b %= 12;\n \n Console.WriteLine(a + \" \" + b);\n }\n}", "lang_cluster": "C#", "tags": ["math"], "code_uid": "1a5205b949dbdefe1ec7292fa97d92f5", "src_uid": "5d4f38ffd1849862623325fdbe06cd00", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace ConsoleApplication254\n{\n class Program\n {\n\n\n static void Main(string[] args)\n {\n int n = Convert.ToInt32(Console.ReadLine());\n int a = n/36;\n int b = (n-a*36)/3;\n if ((n - a * 36) % 3 == 2) b++;\n if (b == 12) { a++; b = 0; }\n Console.WriteLine(a+\" \"+b);\n\n\n }\n }\n}/*\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Text;\n\nnamespace chislo\n{\n class Program\n {\n static void Main(string[] args)\n {int sch = 0;\n string[] s = Console.ReadLine().Split(' ');\n long n = Convert.ToInt64(s[0]);\n long l1 = Convert.ToInt64(s[1]);\n long r1 = Convert.ToInt64(s[2]);\n List l = new List(); if (n == 0) Console.WriteLine(0);\n else\n if (n == 1)\n {\n if (l1 <= 2 && r1 >= 2) Console.WriteLine(1);\n else\n Console.WriteLine(0);\n }\n else\n {\n for (int i = 0; n > 1; i++)\n {\n l.Add(n); n /= 2;\n }\n string c = Convert.ToString(l[l.Count - 1] / 2);\n string c1 = Convert.ToString(l[l.Count - 1] % 2);\n string str = (c + c1 + c);\n for (int i = l.Count - 2; i >= 0; i--)\n {\n c1 = Convert.ToString(l[i] % 2);\n str += c1 + str;\n }\n Console.WriteLine(str);\n \n /*for (long i = l1 - 1; i < r1; i++)\n {\n if (str[i] == '1') sch++;\n }\n Console.WriteLine(str);\n Console.WriteLine(sch);\n\n }\n \n }\n }\n}*/\n\n \n \n\n\n", "lang_cluster": "C#", "tags": ["math"], "code_uid": "5940dce269f07d3c5df989f6a27253ee", "src_uid": "5d4f38ffd1849862623325fdbe06cd00", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.IO;\nusing System.Text;\n\nnamespace Alice__Bob__Oranges_and_Apples\n{\n internal class Program\n {\n private static readonly StreamReader reader = new StreamReader(Console.OpenStandardInput(1024*10), Encoding.ASCII, false, 1024*10);\n private static readonly StreamWriter writer = new StreamWriter(Console.OpenStandardOutput(1024*10), Encoding.ASCII, 1024*10);\n\n private static void Main(string[] args)\n {\n long a = Next();\n long b = Next();\n\n var r = new StringBuilder();\n\n while (true)\n {\n if (a > b)\n {\n if (b != 1)\n r.Append(a/b);\n else\n {\n r.Append(a/b - 1);\n }\n r.Append('A');\n a %= b;\n }\n else\n {\n if (a != 1)\n r.Append(b/a);\n else\n {\n r.Append(b/a - 1);\n }\n r.Append('B');\n b %= a;\n }\n\n if ((a == 0 || b == 0))\n {\n if ((a + b) != 1)\n {\n writer.WriteLine(\"Impossible\");\n writer.Flush();\n return;\n }\n break;\n }\n }\n\n writer.WriteLine(r.ToString());\n writer.Flush();\n }\n\n private static long Next()\n {\n int c;\n long res = 0;\n do\n {\n c = reader.Read();\n if (c == -1)\n return res;\n } while (c < '0' || c > '9');\n res = c - '0';\n while (true)\n {\n c = reader.Read();\n if (c < '0' || c > '9')\n return res;\n res *= 10;\n res += c - '0';\n }\n }\n }\n}", "lang_cluster": "C#", "tags": ["number theory"], "code_uid": "5147c43b016d55c08850b0da08a014b2", "src_uid": "6a9ec3b23bd462353d985e0c0f2f7671", "difficulty": 2400.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.IO;\nusing System.Text;\n\nnamespace Lucky_Sum\n{\n internal class Program\n {\n private static readonly StreamReader reader = new StreamReader(Console.OpenStandardInput(1024*10), Encoding.ASCII, false, 1024*10);\n private static readonly StreamWriter writer = new StreamWriter(Console.OpenStandardOutput(1024*10), Encoding.ASCII, 1024*10);\n\n private static void Main(string[] args)\n {\n var lucky = new List {4, 7};\n\n int l = Next();\n int r = Next();\n\n\n int first = 0;\n int last = 1;\n long d = 10;\n do\n {\n for (int i = first; i <= last; i++)\n {\n lucky.Add(d*4 + lucky[i]);\n lucky.Add(d*7 + lucky[i]);\n }\n d *= 10;\n first = last + 1;\n last = lucky.Count - 1;\n } while (lucky[last] < r);\n\n long sum = 0;\n\n lucky.Sort();\n\n int il = lucky.BinarySearch(l);\n if (il < 0)\n il = ~il;\n\n int ir = lucky.BinarySearch(r);\n if (ir < 0)\n ir = ~ir;\n\n if (il == ir)\n {\n sum = lucky[ir]*(r - l + 1);\n }\n else\n {\n sum = lucky[il]*(lucky[il] - l + 1);\n sum += lucky[ir]*(r - lucky[ir - 1]);\n\n for (int i = il + 1; i < ir; i++)\n {\n sum += lucky[i]*(lucky[i] - lucky[i - 1]);\n }\n }\n\n writer.WriteLine(sum);\n writer.Flush();\n }\n\n private static int Next()\n {\n int c;\n int res = 0;\n do\n {\n c = reader.Read();\n if (c == -1)\n return res;\n } while (c < '0' || c > '9');\n res = c - '0';\n while (true)\n {\n c = reader.Read();\n if (c < '0' || c > '9')\n return res;\n res *= 10;\n res += c - '0';\n }\n }\n }\n}", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "e29b2333fcb9c7e13916ff84a3d29012", "src_uid": "8a45fe8956d3ac9d501f4a13b55638dd", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\n\nnamespace ProgrammingContest.Codeforces.Round91 {\n class A {\n static List num = new List();\n static void gen(long x) {\n if (x <= 10000000000L) {\n num.Add(x);\n gen(x * 10 + 4);\n gen(x * 10 + 7);\n }\n }\n\n // \n static void Main() {\n var xs = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);\n int a = xs[0],\n b = xs[1];\n gen(0);\n num.Sort();\n long res = 0;\n for (int i = 0; ; i++) {\n if (num[i+1] < a) {\n continue;\n }\n if (num[i+1] > b) {\n res += (b - Math.Max(num[i], a-1)) * num[i + 1];\n break;\n }\n res += (num[i + 1] - Math.Max(num[i], a-1)) * num[i + 1];\n }\n Console.WriteLine(res);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "3b2aa40bf1d4f90afb4cfd20428072a4", "src_uid": "8a45fe8956d3ac9d501f4a13b55638dd", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Threading;\nusing System.Linq;\nusing System.IO;\nusing System.Collections.Generic;\nusing System.Text;\nnamespace Codeforces\n{\n public class Program\n {\n public static void Main(string[] args)\n {\n string s = Console.ReadLine();\n if (Petals(s))\n Console.WriteLine(\"Yes\");\n else\n Console.WriteLine(\"No\");\n }\n\n static bool Petals(string landscape)\n {\n string substring = string.Empty;\n var values = new [] {\"ABC\", \"ACB\", \"BCA\", \"BAC\", \"CAB\", \"CBA\"};\n bool result = false;\n for (int i = 0; i < landscape.Length - 2; i++)\n {\n if (landscape.Substring(i, 3).Contains(\"ABC\") || landscape.Substring(i, 3).Contains(\"ACB\") || landscape.Substring(i, 3).Contains(\"BCA\") || landscape.Substring(i, 3).Contains(\"BAC\") || landscape.Substring(i, 3).Contains(\"CAB\") || landscape.Substring(i, 3).Contains(\"CBA\"))\n {\n result = true;\n break;\n }\n else\n result = false;\n }\n return result;\n }\n }\n}", "lang_cluster": "C#", "tags": ["strings", "implementation"], "code_uid": "d6ed119ec0082cc2c6debe14d02c5a32", "src_uid": "ba6ff507384570152118e2ab322dd11f", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.IO;\nusing System.Linq;\nusing System.Threading;\nusing static CF.ReadNext;\n\nnamespace CF\n{\n public static class Program\n {\n private static void Main()\n {\n var s = Console.ReadLine();\n for (int i = 0; i <= s.Length - 3; i++)\n {\n var substring = string.Concat(s.Substring(i, 3).OrderBy(c=>c));\n if (substring == \"ABC\")\n {\n Console.WriteLine(\"YES\");\n return;\n }\n }\n Console.WriteLine(\"NO\");\n }\n }\n\n public static class ReadNext\n {\n public static int NextInt()\n {\n var next = ReadUntilSpace();\n return int.Parse(next);\n }\n\n public static double NextDouble()\n {\n var next = ReadUntilSpace();\n return double.Parse(next);\n }\n\n public static string NextWord()\n {\n return ReadUntilSpace();\n }\n\n private static bool IsWhiteSpace(int n)\n {\n return n == ' ' || n == '\\n' || n == '\\r' || n == '\\t' || n == -1;\n }\n\n private static string ReadUntilSpace()\n {\n var result = \"\";\n\n var n = Console.Read();\n // read whitespace \n while (IsWhiteSpace(n))\n {\n n = Console.Read();\n }\n\n // read characters\n while (!IsWhiteSpace(n))\n {\n result += (char)n;\n n = Console.Read();\n }\n\n return result;\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["strings", "implementation"], "code_uid": "6467d8f487967ef754aed696888ca52b", "src_uid": "ba6ff507384570152118e2ab322dd11f", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace Task13A\n{\n class Program\n {\n static void Main(string[] args)\n {\n int A = int.Parse(Console.ReadLine());\n\n int counter = 0;\n for (int i = 2; i < A; i++)\n counter += sumOfBase(A, i);\n\n \n Console.WriteLine(\"{0}/{1}\", counter / gcd(counter, A-2), (A-2) / gcd(counter, A-2));\n }\n private static int gcd(int a, int b)\n {\n return b == 0 ? a : gcd(b, a % b);\n }\n private static int sumOfBase(int A, int Base)\n {\n int ans = 0;\n while (A > 0)\n { \n ans += A % Base;\n A /= Base;\n }\n return ans;\n }\n\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "implementation"], "code_uid": "88486436aa31c1b26d822f86dab32e3b", "src_uid": "1366732dddecba26db232d6ca8f35fdc", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\n\nnamespace CodeForce\n{\n class _13a\n {\n public static void Main()\n {\n var line = Console.ReadLine();\n var n = int.Parse(line);\n var sum = 0;\n for (var i = 2; i < n; i++)\n {\n var num = n;\n while (num != 0)\n {\n sum += num % i;\n num /= i;\n }\n }\n var low = n - 2;\n for (var i = 2; i < 1010; i++)\n {\n while (low % i == 0 && sum % i == 0)\n {\n low /= i;\n sum /= i;\n }\n }\n Console.WriteLine(\"{0}/{1}\", sum, low);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "implementation"], "code_uid": "13a3b62fbcdde4ba4e993e7d1effdfd3", "src_uid": "1366732dddecba26db232d6ca8f35fdc", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\n\nnamespace Codeforces\n{\n\tclass MainClass\n\t{\n\t\tpublic static void Main (string[] args)\n\t\t{\n\t\t\tnew Solution();\n\t\t}\n\t}\n\tclass Solution\n\t{\n\t\tpublic Solution(){\n int x = int.Parse(Console.ReadLine());\n if (x == 1)\n {\n Console.WriteLine(\"1\");\n return;\n }\n String sx = x.ToString();\n int count = 1;\n for (int i = 1; i <= Math.Sqrt(x); i++)\n {\n char[] si = i.ToString().ToCharArray();\n if (x % i == 0 && sx.IndexOfAny(si) >= 0)\n {\n count++;\n }\n if (i > 1 && i != x / i && x % (x / i) == 0)\n {\n char[] ssi = (x / i).ToString().ToCharArray();\n if(sx.IndexOfAny(ssi)>=0)\n count++;\n }\n }\n Console.Write(count);\n //Console.ReadKey(true);\n \n\t\t}\n\t}\n}\n/*A\nint n=int.Parse(Console.ReadLine());\nConsole.Write(n+\" \");\nfor (int i = 1; i < n; i++)\n{\n Console.Write(i + \" \");\n}\n*/\n\n/* B\n int x = int.Parse(Console.ReadLine());\n if (x == 1)\n {\n Console.WriteLine(\"1\");\n return;\n }\n String sx=x.ToString();\n int count=1;\n for (int i = 1; i <= Math.Sqrt(x); i++)\n {\n char[] si=i.ToString().ToCharArray();\n if (x%i==0 && sx.IndexOfAny(si)>=0)\n {\n count++;\n } \n }\n Console.Write(count);\n */\n/*C\n int n = int.Parse(Console.ReadLine());\n String s=Console.ReadLine();\n String[] z=s.Split(' ');\n int[] c = new int[n];\n for (int i = 0; i < n; i++)\n {\n c[i] = int.Parse(z[i]);\n }\n int count = 0;\n for (int i = 1; i < n; i++)\n {\n if (c[i - 1] > c[i]) count++;\n if (count > 2)\n {\n Console.WriteLine(\"NO\");\n return;\n }\n }\n if (count == 2 || count ==0)\n {\n Console.WriteLine(\"YES\");\n return;\n }\n if (count == 1)\n {\n int i=0;\n while (c[i] <= c[i + 1]) i++;\n int p=c[i];\n int t=c[i+1];i++;\n while (i\n{\n public int a, b;\n public PairVariable()\n {\n a = b = 0;\n }\n public PairVariable(string s)\n {\n string[] q = s.Split();\n a = int.Parse(q[0]);\n b = int.Parse(q[1]);\n }\n public PairVariable(int a, int b)\n {\n this.a = a;\n this.b = b;\n }\n\n\n\n public int CompareTo(PairVariable other)\n {\n return other.a.CompareTo(this.a);\n }\n}\n\nnamespace ConsoleApplication254\n{\n\n class Program\n {\n\n static bool foo(string s1, string s2)\n {\n for (int i = 0; i < s1.Length; i++)\n {\n for (int e = 0; e < s2.Length; e++)\n {\n if (s1[i] == s2[e])\n {\n return true;\n }\n }\n }\n return false;\n }\n static void Main(string[] args)\n {\n string[] ss = Console.ReadLine().Split();\n int n = int.Parse(ss[0]);\n List d = new List();\n int ans = 0;\n for (int i = 1; i <= Math.Sqrt(n); i++)\n {\n if (n % i == 0)\n {\n d.Add(i);\n }\n }\n \n int x = d.Count;\n for (int i = 0; i < x; i++)\n {\n if (n / d[i] != d[i])\n {\n d.Add(n / d[i]);\n }\n }\n \n string z = n.ToString();\n for (int i = 0; i < d.Count; i++)\n {\n string s = d[i].ToString();\n \n if (foo(s, z))\n {\n ans++;\n }\n }\n Console.WriteLine(ans);\n }\n }\n}", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "35e05a58e9337d2fa8ee456d3857a572", "src_uid": "ada94770281765f54ab264b4a1ef766e", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Linq;\n\nclass Program\n{\n static void Main()\n {\n string str = Console.ReadLine();\n int n = int.Parse(str);\n\n var squares = new int[n, 4];\n\n int minX = -1, maxX = -1, minY = -1, maxY = -1;\n\n for (int i = 0; i < n; i++)\n {\n str = Console.ReadLine();\n var q = str.Split(new char[] {' '});\n\n squares[i, 0] = int.Parse(q[0]);\n squares[i, 1] = int.Parse(q[1]);\n squares[i, 2] = int.Parse(q[2]);\n squares[i, 3] = int.Parse(q[3]);\n\n if (i == 0)\n {\n minX = squares[i, 0];\n minY = squares[i, 1];\n maxX = squares[i, 2];\n maxY = squares[i, 3];\n }\n\n\n if (minX > squares[i, 0]) minX = squares[i, 0];\n if (minY > squares[i, 1]) minY = squares[i, 1];\n if (maxX < squares[i, 2]) maxX = squares[i, 2];\n if (maxY < squares[i, 3]) maxY = squares[i, 3];\n // Console.WriteLine(str);\n }\n\n if (maxX - minX != maxY - minY)\n {\n Console.WriteLine(\"NO\");\n return;\n }\n\n int square1 = (maxX - minX) * (maxY - minY);\n int square2 = 0;\n\n for (int i = 0; i < n; i++)\n {\n square2 += (squares[i, 2] - squares[i, 0]) * (squares[i, 3] - squares[i, 1]);\n }\n\n if (square1 != square2)\n {\n // Console.WriteLine(\"NO 2 1: {0} 2: {1}\", square1, square2);\n Console.WriteLine(\"NO\");\n return;\n }\n\n Console.WriteLine(\"YES\");\n }\n}", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "2130c7967e148c63b156939e6afbf282", "src_uid": "f63fc2d97fd88273241fce206cc217f2", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Linq;\nclass Demo\n{\n static void Main()\n {\n int n = int.Parse(Console.ReadLine());\n int S = 0;\n int minx = 31401, miny = 31401, maxx = 0, maxy = 0;\n while (n-- > 0)\n {\n int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();\n S += (a[2] - a[0]) * (a[3] - a[1]);\n if (a[0] < minx) minx = a[0];\n if (a[1] < miny) miny = a[1];\n if (a[2] > maxx) maxx = a[2]; \n if (a[3] > maxy) maxy = a[3]; \n }\n string ans = maxx - minx == maxy - miny && Math.Pow(maxx - minx, 2) == S ? \"YES\" : \"NO\";\n Console.WriteLine(ans);\n }\n}", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "6c81bd056946e24efbe0fb67a60d8451", "src_uid": "f63fc2d97fd88273241fce206cc217f2", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Text;\n\nnamespace A\n{\n class Program\n {\n static int Dist(int x1, int y1, int x2, int y2)\n {\n return ((x1 - x2) * (x1 - x2) + (y2 - y1) * (y2 - y1));\n }\n static bool F(int x1, int y1, int x2, int y2, int x3, int y3)\n {\n if (x1 == x2 && y1 == y2) return false;\n if (x1 == x3 && y1 == y3) return false;\n if (x3 == x2 && y3 == y2) return false;\n int a = Dist(x1, y1, x2, y2);\n int b = Dist(x1, y1, x3, y3);\n int c = Dist(x3, y3, x2, y2);\n\n if (a + b == c)\n return true;\n if (a == b + c)\n return true;\n if (b == a + c)\n return true;\n return false;\n }\n\n static bool Ans(int x1, int y1, int x2, int y2, int x3, int y3)\n {\n if (F(x1 + 1, y1, x2, y2, x3, y3)) return true;\n if (F(x1 - 1, y1, x2, y2, x3, y3)) return true;\n if (F(x1, y1 + 1, x2, y2, x3, y3)) return true;\n if (F(x1, y1 - 1, x2, y2, x3, y3)) return true;\n return false;\n }\n static void Main(string[] args)\n {\n string[] s = Console.ReadLine().Split();\n int x1 = int.Parse(s[0]);\n int y1 = int.Parse(s[1]);\n int x2 = int.Parse(s[2]);\n int y2 = int.Parse(s[3]);\n int x3 = int.Parse(s[4]);\n int y3 = int.Parse(s[5]);\n if (F(x1, y1, x2, y2, x3, y3))\n {\n Console.WriteLine(\"RIGHT\");\n }\n else\n {\n if (Ans(x1, y1, x2, y2, x3, y3))\n {\n Console.WriteLine(\"ALMOST\");\n return;\n }\n if (Ans(x2, y2, x1, y1, x3, y3))\n {\n Console.WriteLine(\"ALMOST\");\n return;\n }\n if (Ans(x3, y3, x1, y1, x2, y2))\n {\n Console.WriteLine(\"ALMOST\");\n return;\n }\n Console.WriteLine(\"NEITHER\");\n }\n }\n }\n}", "lang_cluster": "C#", "tags": ["brute force", "geometry"], "code_uid": "3017f7b69313de923482021a45191205", "src_uid": "8324fa542297c21bda1a4aed0bd45a2d", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Linq;\n\nnamespace _18A\n{\n class Program\n {\n static int[] dx = new[] { -1, 1, 0, 0 };\n static int[] dy = new[] { 0, 0, -1, 1 };\n\n static void Main(string[] args)\n {\n string[] input = Console.ReadLine().Split(' ');\n int[] x = new int[3], y = new int[3];\n for (int i = 0; i < 6; i++)\n {\n if (i % 2 == 0)\n x[i / 2] = int.Parse(input[i]);\n else\n y[i / 2] = int.Parse(input[i]);\n }\n\n bool right = Check(x, y), almost = false;\n if (!right)\n {\n for (int i = 0; i < 4 && !almost; i++) // direction\n {\n for (int j = 0; j < 3 && !almost; j++) // point\n {\n x[j] += dx[i]; y[j] += dy[i];\n almost = Check(x, y);\n x[j] -= dx[i]; y[j] -= dy[i];\n }\n }\n }\n\n if (right) Console.WriteLine(\"RIGHT\");\n else if (almost) Console.WriteLine(\"ALMOST\");\n else Console.WriteLine(\"NEITHER\");\n }\n\n static bool Check(int[] x, int[] y)\n {\n if (x.All(a => a == x[0]) || y.All(a => a == y[0]))\n return false;\n\n for (int i = 0; i < 3; i++)\n for (int j = i + 1; j < 3; j++)\n if (x[i] == x[j] && y[i] == y[j])\n return false;\n\n double[] dist = new[]\n {\n Distance(x[0], y[0], x[1], y[1]),\n Distance(x[1], y[1], x[2], y[2]),\n Distance(x[2], y[2], x[0], y[0])\n };\n int maxIndex = -1; double max = 0;\n for (int i = 0; i < 3; i++)\n if (dist[i] > max)\n {\n max = dist[i];\n maxIndex = i;\n }\n\n double sum = 0;\n for (int i = 0; i < 3; i++)\n if (i != maxIndex)\n sum += dist[i];\n\n return sum == max;\n }\n\n static double Distance(double x1, double y1, double x2, double y2)\n {\n return (x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "geometry"], "code_uid": "38d7399ee4711ed4cb1ac841b62d3ba3", "src_uid": "8324fa542297c21bda1a4aed0bd45a2d", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace ConsoleApp2\n{\n class Program\n {\n const long MOD = 1000000007;\n static int before(int x, int ost)\n {\n if (x < ost)\n return 0;\n return (x - ost) / 3 + 1;\n }\n static void Main(string[] args)\n {\n int n, l, r;\n string[] input = Console.ReadLine().Split();\n n = int.Parse(input[0]);\n l = int.Parse(input[1]);\n r = int.Parse(input[2]);\n long[,] dp = new long[n, 3];\n dp[0, 0] = before(r, 0) - before(l - 1, 0);\n dp[0, 1] = before(r, 1) - before(l - 1, 1);\n dp[0, 2] = before(r, 2) - before(l - 1, 2);\n for (int i = 1; i < n; i++)\n {\n for (int j = 0; j < 3; j++)\n {\n int pred0 = j;\n int pred1 = j - 1;\n int pred2 = j - 2;\n if (pred1 < 0)\n pred1 += 3;\n if (pred2 < 0)\n pred2 += 3;\n dp[i, j] += dp[i - 1, pred0] * dp[0, 0];\n dp[i, j] %= MOD;\n dp[i, j] += dp[i - 1, pred1] * dp[0, 1];\n dp[i, j] %= MOD;\n dp[i, j] += dp[i - 1, pred2] * dp[0, 2];\n dp[i, j] %= MOD;\n }\n }\n /*for (int i = 0; i < n; i++)\n {\n for (int j = 0; j < 3; j++)\n Console.Write($\"{dp[i, j]} \");\n Console.WriteLine();\n }*/\n Console.WriteLine((dp[n - 1, 0])%MOD);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "dp", "combinatorics"], "code_uid": "08ce04b89522a61875a4eddaa25d207a", "src_uid": "4c4852df62fccb0a19ad8bc41145de61", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections;\nusing System.Collections.Generic;\nusing System.IO;\nusing System.Linq;\nusing System.Numerics;\nusing System.Text;\nusing System.Threading.Tasks;\nusing static System.Console;\nusing static System.Math;\nclass Z { static void Main() => new K(); }\nclass K\n{\n\tint F => int.Parse(Str);\n\tlong FL => long.Parse(Str);\n\tint[] G => Strs.Select(int.Parse).ToArray();\n\tlong[] GL => Strs.Select(long.Parse).ToArray();\n\tstring Str => ReadLine();\n\tstring[] Strs => Str.Split(new char[] { ' ', '\\t' }, StringSplitOptions.RemoveEmptyEntries);\n\tconst int MOD = 1000000007;\n\tpublic K()\n\t{\n\t\tSetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });\n\t\tSolve();\n\t\tOut.Flush();\n\t}\n\tvoid Solve()\n\t{\n\t\tvar I = G;\n\t\tint N = I[0], l = I[1], r = I[2];\n\t\tvar mx = new int[3];\n\t\tmx[0] = (r + 3) / 3 - (l + 2) / 3;\n\t\tmx[1] = (r + 2) / 3 - (l + 1) / 3;\n\t\tmx[2] = (r + 1) / 3 - l / 3;\n\t\tvar dp = new long[N + 1, 3];\n\t\tdp[0, 0] = 1;\n\t\tfor (var n = 1; n <= N; n++)\n\t\t\tfor (var m = 0; m < 3; m++)\n\t\t\t\tfor (var x = 0; x < 3; x++)\n\t\t\t\t\tdp[n, m] = (dp[n, m] + mx[x] * dp[n - 1, (m - x + 3) % 3] % MOD) % MOD;\n\t\tWriteLine(dp[N, 0]);\n\t}\n}\n", "lang_cluster": "C#", "tags": ["math", "dp", "combinatorics"], "code_uid": "b6bcbb694436effa2614bedf122778f5", "src_uid": "4c4852df62fccb0a19ad8bc41145de61", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\n\nclass Program\n{\n \n\n static void Main(string[] args)\n {\n int n = int.Parse(Console.ReadLine());\n string str = Console.ReadLine();\n int[] arr = new int[n];\n\n HashSet set = new HashSet();\n for (int i = 0; i < n; i++)\n {\n if (char.IsUpper(str[i]))\n {\n arr[i] = 0;\n set = new HashSet();\n }\n\n else\n {\n set.Add(str[i]);\n arr[i] = set.Count();\n }\n }\n\n\n Console.WriteLine(arr.Max());\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "strings", "implementation"], "code_uid": "95cc520d63e07e4fa3b4a7d6661d3a4e", "src_uid": "567ce65f87d2fb922b0f7e0957fbada3", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace ConsoleApplication6\n{\n class Program\n {\n static void Main(string[] args)\n {\n int n = Int32.Parse(Console.ReadLine());\n string str = Console.ReadLine();\n int currentMax = 0;\n for (int i = 0; i < n; ++i)\n {\n if(char.IsLower(str, i))\n {\n int max = 1;\n for(int j = i+1; j currentMax)\n currentMax = max;\n }\n }\n Console.WriteLine(currentMax);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "strings", "implementation"], "code_uid": "7b12d10ce62446892a957a26cd844380", "src_uid": "567ce65f87d2fb922b0f7e0957fbada3", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\n\nnamespace ConsoleApplication1\n{\n class Program\n {\n static void Main(string[] args)\n {\n int n = int.Parse(Console.ReadLine());\n int[] a = new int[n+4];\n string[] s = Console.ReadLine().Split(' ');\n int ans = 0;\n for (int i = 0; i < n; i++)\n {\n a[i] = int.Parse(s[i]);\n if (a[i] == 1)\n ans++;\n }\n for (int i = 0; i < n; i++)\n if (a[i] == 1 && a[i + 1] == 0 && a[i + 2] == 1)\n ans++;\n \n Console.WriteLine(ans);\n // Console.ReadLine();\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "faaa61451ba838c0510bd1592a7693be", "src_uid": "2896aadda9e7a317d33315f91d1ca64d", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\n\nclass Program\n{\n\n\n static void Main()\n {\n string[] t = new string[1];\n t[0] = Console.ReadLine();\n\n int n = int.Parse(t[0]);\n int[] arr = new int[n];\n t[0] = Console.ReadLine();\n\n t = t[0].Split();\n\n for (int j = 0; j < n; ++j)\n {\n arr[j] = int.Parse(t[j]);\n }\n\n int i = 0, ans = 0;\n\n while (i < n && arr[i] == 0)\n ++i;\n\n for (; i < n;)\n {\n int q = 0;\n\n if (arr[i] != 0)\n {\n ++ans;\n ++i;\n continue;\n }\n\n while (i < n && arr[i] == 0)\n {\n ++i; ++q;\n if (i == n) q = 0;\n }\n\n if (q == 1)\n ++ans;\n\n }\n\n Console.WriteLine(ans);\n }\n}", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "f8a1c3dc8a9302597c2807779fe4d543", "src_uid": "2896aadda9e7a317d33315f91d1ca64d", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nclass Program\n{\n static void Main()\n {\n int ans = 0;\n string[] tokens = Console.ReadLine().Split();\n long l = long.Parse(tokens[0]);\n long r = long.Parse(tokens[1]);\n for (int i = 0; i <= 32; ++i) {\n for (int j = 0; j <= 20; ++j)\n {\n long x = (long)Math.Pow(2, i) * (long)Math.Pow(3, j);\n if (x >= l && x <=r)\n ans++;\n }\n }\n Console.WriteLine(ans);\n\n }\n\n}", "lang_cluster": "C#", "tags": ["math", "implementation"], "code_uid": "00be810819c230cc83376cc557c212fc", "src_uid": "05fac54ed2064b46338bb18f897a4411", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\n\nnamespace Codeforces\n{\n\tclass Program\n\t{\n\t\tstatic void Main(string[] args) \n\t\t{\n\t\t\tstring input1 = Console.ReadLine();\n\t\t\t//string input2 = Console.ReadLine();\n\n\t\t\t//string input3 = Console.ReadLine();\n\t\t\t//string input4 = Console.ReadLine();\n\n\t\t\tvar inputs1 = input1.Split(new[] {' ', '}', '{', ','}, StringSplitOptions.RemoveEmptyEntries).Select(long.Parse).ToArray();\n\t\t\t//var inputs2 = input2.Split(new[] { ' ', '}', '{', ',' }, StringSplitOptions.RemoveEmptyEntries).Select(long.Parse).ToList();\n\t\t\t//var inputs3 = input3.Split(new[] { ' ', '}', '{', ',' }, StringSplitOptions.RemoveEmptyEntries).Select(long.Parse).ToArray();\n\t\t\t//var inputs4 = input4.Split(new[] { ' ', '}', '{', ',' }, StringSplitOptions.RemoveEmptyEntries).Select(long.Parse).ToArray();\n\n\t\t\tlong l = inputs1[0];\n\t\t\tlong r = inputs1[1];\n\n\t\t\tlong end2 = (long)Math.Log(r, 2) + 1;\n\n\t\t\tvar set = new HashSet();\n\t\t\tfor (long i = 0; i < end2 + 1; i++) \n\t\t\t{\n\t\t\t\tlong start3 = (long)Math.Log(l / Math.Pow(2, i), 3);\n\t\t\t\tif (start3 < 0) \n\t\t\t\t{\n\t\t\t\t\tstart3 = 0;\n\t\t\t\t}\n\n\t\t\t\tlong end3 = (long)Math.Log(r / Math.Pow(2, i), 3) + 1;\n\t\t\t\tif (end3 < 0)\n\t\t\t\t{\n\t\t\t\t\tend3 = 0;\n\t\t\t\t}\n\n\t\t\t\tfor (long j = start3; j < end3 + 1; j++) \n\t\t\t\t{\n\t\t\t\t\tlong current = (long)(Math.Pow(2, i) * Math.Pow(3, j));\n\t\t\t\t\tif (current < l || current > r) \n\t\t\t\t\t{\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\n\t\t\t\t\tset.Add(current);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tConsole.WriteLine(set.Count);\n\t\t}\n\n\t\tpublic class Team\n\t\t{\n\t\t\tpublic string Name { get; set; }\n\n\t\t\tpublic int Points { get; set; }\n\n\t\t\tpublic int GoalsFor { get; set; }\n\n\t\t\tpublic int GoalsAgainst { get; set; }\n\t\t}\n\n\t\tstatic long Factorial(long a) \n\t\t{\n\t\t\treturn a > 1 ? a * Factorial(a - 1) : 1;\n\t\t}\n\t}\n}\n", "lang_cluster": "C#", "tags": ["math", "implementation"], "code_uid": "a4a742c2d6b2238e4152b74e97036da4", "src_uid": "05fac54ed2064b46338bb18f897a4411", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Linq;\n\nnamespace CSharp\n{\n public class _822A\n {\n public static void Main(string[] args)\n {\n Console.WriteLine(Enumerable.Range(1, Console.ReadLine().Split().Select(token => int.Parse(token)).Min()).Aggregate((a, b) => a * b));\n }\n }\n}", "lang_cluster": "C#", "tags": ["math", "implementation", "number theory"], "code_uid": "3a28b7812edf4b36aa608b9e98260e72", "src_uid": "7bf30ceb24b66d91382e97767f9feeb6", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeff\ufeffusing System;\nusing System.Text;\nusing System.Collections.Generic;\nusing System.Collections;\nusing System.Linq;\nclass Problem\n{\n static void Main()\n {\n //--------------------------------input--------------------------------//\n\n var s = Array.ConvertAll( Console.ReadLine().Split(), Convert.ToInt32 );\n int a = s[0], b = s[1];\n\n //--------------------------------solve--------------------------------/\n\n Console.WriteLine( kq( Math.Min( a, b ) ) );\n\n }\n\n private static long kq(int p)\n {\n if(p == 1)\n return 1;\n else\n return p * kq( p - 1 );\n }\n}", "lang_cluster": "C#", "tags": ["math", "implementation", "number theory"], "code_uid": "f9c5f98acf27850af80c4064013d3564", "src_uid": "7bf30ceb24b66d91382e97767f9feeb6", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\n\nnamespace ConsoleApplication6\n{\n\n class Program\n {\n static void Main(string[] args)\n {\n int[,] tabl = new int[3, 3];\n int[,] tablrezult = new int[3, 3];\n string[] str1 = new string[3];\n for (int i = 0; i < 3; i++)\n {\n str1[i] = Console.ReadLine();\n }\n string[] strin1 = str1[0].Split(' ');\n string[] strin2 = str1[1].Split(' ');\n string[] strin3 = str1[2].Split(' ');\n for (int i = 0; i < 3; i++)\n {\n tabl[0, i] = int.Parse(strin1[i]);\n tabl[1, i] = int.Parse(strin2[i]);\n tabl[2, i] = int.Parse(strin3[i]);\n }\n\n tablrezult[2, 1] = tabl[2, 0] + tabl[2, 2] + tabl[1, 1] + tabl[2, 1];\n\n tablrezult[0, 1] = tabl[1, 1] + tabl[0, 0] + tabl[0, 2] + tabl[0, 1];\n tablrezult[1, 0] = tabl[0, 0] + tabl[2, 0] + tabl[1, 1] + tabl[1, 0];\n tablrezult[1, 2] = tabl[2, 2] + tabl[1, 1] + tabl[0, 2] + tabl[1, 2];\n\n tablrezult[0, 0] = tabl[1, 0] + tabl[0, 1] + tabl[0, 0];\n\n\n tablrezult[2, 2] = tabl[1, 2] + tabl[2, 1] + tabl[2, 2];\n\n tablrezult[0, 2] = tabl[1, 2] + tabl[0, 1] + tabl[0, 2];\n\n tablrezult[2, 0] = tabl[1, 0] + tabl[2, 1] + tabl[2, 0];\n\n tablrezult[1, 1] = tabl[2, 1] + tabl[1, 2] + tabl[0, 1] + tabl[1, 0] + tabl[1, 1];\n\n for (int i = 0; i < 3; i++)\n {\n for (int j = 0; j < 3; j++)\n {\n if ((tablrezult[i, j] % 2) == 0)\n {\n tablrezult[i, j] = 1;\n }\n else { tablrezult[i, j] = 0; }\n\n }\n }\n\n Console.WriteLine(tablrezult[0, 0].ToString() + tablrezult[0, 1].ToString() + tablrezult[0, 2].ToString());\n Console.WriteLine(tablrezult[1, 0].ToString() + tablrezult[1, 1].ToString() + tablrezult[1, 2].ToString());\n Console.WriteLine(tablrezult[2, 0].ToString() + tablrezult[2, 1].ToString() + tablrezult[2, 2].ToString());\n \n\n Console.ReadLine();\n }\n\n }\n}", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "2c00a49f4cb4592f1ec02b92f5922e8b", "src_uid": "b045abf40c75bb66a80fd6148ecc5bd6", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\n\n\nnamespace ConvexShape\n{\n class Program\n {\n public static void Main(string[] args)\n {\n int[,] lights = new int[3,3];\n int[,] lightsCumulative = new int[3, 3];\n for (int i = 0; i < 3; ++i)\n {\n string s = Console.ReadLine();\n string[] nums = s.Split(new[]{' '}, StringSplitOptions.RemoveEmptyEntries);\n for (int j = 0; j < 3; ++j )\n {\n lights[i, j] = int.Parse(nums[j]);\n }\n }\n\n for (int i = 0; i < 3; ++i)\n {\n for (int j = 0; j < 3; ++j)\n {\n int l=0, r=0, t=0, b=0;\n l = (i - 1) >= 0 && (i - 1) < 3 ? lights[i - 1,j] : 0;\n r = (i + 1) >= 0 && (i + 1) < 3 ? lights[i + 1,j] : 0;\n b = (j + 1) >= 0 && (j + 1) < 3 ? lights[i ,j+1] : 0;\n t = (j - 1) >= 0 && (j - 1) < 3 ? lights[i ,j-1] : 0;\n lightsCumulative[i, j] = lights[i, j] + l + r + t + b;\n\n Console.Write((lightsCumulative[i, j] + 1) % 2);\n }\n Console.WriteLine();\n }\n\n\n\n\n }\n\n\n\n }\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "500e456798ec1793e4ac6687a19bf668", "src_uid": "b045abf40c75bb66a80fd6148ecc5bd6", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\n\n\nclass Scanner\n{\n string[] s;\n int i;\n\n char[] cs = new char[] { ' ' };\n\n public Scanner()\n {\n s = new string[0];\n i = 0;\n }\n\n public string next()\n {\n if (i < s.Length) return s[i++];\n s = Console.ReadLine().Split(cs, StringSplitOptions.RemoveEmptyEntries);\n i = 0;\n return s[i++];\n }\n\n public int nextInt()\n {\n return int.Parse(next());\n }\n\n public long nextLong()\n {\n return long.Parse(next());\n }\n\n public double nextDouble()\n {\n return Double.Parse(next());\n }\n}\n\n\nclass Myon\n{\n Scanner cin;\n Myon() { }\n\n public static void Main()\n {\n new Myon().calc();\n }\n\n void calc()\n {\n cin = new Scanner();\n long ret = 0;\n int n, m, t;\n n = cin.nextInt();\n m = cin.nextInt();\n t = cin.nextInt();\n int i, j;\n const int MAX = 100;\n long[] choosen = new long[MAX];\n long[] choosem = new long[MAX];\n choosen[0] = choosem[0] = 1;\n for (i = 0; i < n; i++)\n {\n for (j = MAX - 1; j > 0; j--)\n {\n choosen[j] += choosen[j - 1];\n }\n }\n for (i = 0; i < m; i++)\n {\n for (j = MAX - 1; j > 0; j--)\n {\n choosem[j] += choosem[j - 1];\n }\n }\n for (i = 4; i < t; i++)\n {\n ret += choosen[i] * choosem[t - i];\n }\n Console.WriteLine(ret);\n\n }\n}", "lang_cluster": "C#", "tags": ["math", "combinatorics"], "code_uid": "8b11786ddc692132aaa4793919a8f991", "src_uid": "489e69c7a2fba5fac34e89d7388ed4b8", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\n\nnamespace CSharp\n{\n class _131C\n {\n public static void Main()\n {\n var tokens = Console.ReadLine().Split();\n\n int n = int.Parse(tokens[0]);\n int m = int.Parse(tokens[1]);\n int t = int.Parse(tokens[2]);\n\n long ways = 0;\n\n for (int b = 4; b <= n; b++)\n {\n int g = t - b;\n\n if (g >= 1 && g <= m)\n {\n ways += Choose(n, b) * Choose(m, g);\n }\n }\n\n Console.WriteLine(ways);\n }\n\n private static long Choose(int n, int k)\n {\n long result = 1;\n\n for (int i = 0; i < k; i++)\n {\n result *= n - i;\n result /= i + 1;\n }\n\n return result;\n }\n }\n}", "lang_cluster": "C#", "tags": ["math", "combinatorics"], "code_uid": "8c47859e777c645229b69e762cc5359c", "src_uid": "489e69c7a2fba5fac34e89d7388ed4b8", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\n\nnamespace codeforces\n{\n\n class Program\n {\n public static int ReadInt() => Int32.Parse(Console.ReadLine());\n\n public static int[] ReadInts() =>\n Console.ReadLine().Split(new[]{' '}, StringSplitOptions.RemoveEmptyEntries)\n .Select(Int32.Parse).ToArray();\n\n static void Main(string[] args)\n {\n int n = ReadInt();\n var grades = ReadInts();\n Array.Sort(grades);\n var todo = n*9 - grades.Sum() * 2;\n\n int i;\n for (i = 0; i < grades.Length && todo > 0; i++)\n {\n var grade = grades[i];\n var plus = (5 - grade)*2;\n todo -= plus;\n }\n Console.WriteLine(i);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["sortings", "greedy"], "code_uid": "4ad363b7f7555caa66f8b641511061d1", "src_uid": "715608282b27a0a25b66f08574a6d5bd", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\n\nnamespace cs\n{\n class Program\n {\n static void Main(string[] args)\n {\n int n = int.Parse(Console.ReadLine());\n int twos = 0, threes = 0, fours = 0;\n int[] scores = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();\n for (int i = 0; i < scores.Length; i++)\n {\n if (scores[i] == 2)\n twos++;\n else if (scores[i] == 3)\n threes++;\n else if (scores[i] == 4)\n fours++;\n }\n double EPSILON = 0E-12;\n int count = 0;\n int sum = scores.Sum();\n while ((double)sum / n - 4.5 < EPSILON && twos + threes + fours > 0)\n {\n if (twos > 0)\n {\n twos--;\n sum += 3;\n count++;\n }\n else if (threes > 0)\n {\n threes--;\n sum += 2;\n count++;\n }\n else if (fours > 0)\n {\n fours--;\n sum += 1;\n count++;\n }\n }\n\n Console.WriteLine(count);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["sortings", "greedy"], "code_uid": "6b29a0b1ca14c491f3cdd6c87938c410", "src_uid": "715608282b27a0a25b66f08574a6d5bd", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.IO;\nusing System.Text;\n\nnamespace Table_Tennis_Game_2\n{\n internal class Program\n {\n private static readonly StreamReader reader = new StreamReader(Console.OpenStandardInput(1024*10), Encoding.ASCII, false, 1024*10);\n private static readonly StreamWriter writer = new StreamWriter(Console.OpenStandardOutput(1024*10), Encoding.ASCII, 1024*10);\n\n private static void Main(string[] args)\n {\n int k = Next();\n int a = Next();\n int b = Next();\n\n\n if (k > a && k > b)\n writer.WriteLine(\"-1\");\n else\n {\n int ma = a%k;\n int mb = b%k;\n\n if (ma > 0 && b/k == 0 || mb > 0 && a/k == 0)\n writer.WriteLine(\"-1\");\n else\n writer.WriteLine(a/k + b/k);\n }\n\n\n writer.Flush();\n }\n\n private static int Next()\n {\n int c;\n int res = 0;\n do\n {\n c = reader.Read();\n if (c == -1)\n return res;\n } while (c < '0' || c > '9');\n res = c - '0';\n while (true)\n {\n c = reader.Read();\n if (c < '0' || c > '9')\n return res;\n res *= 10;\n res += c - '0';\n }\n }\n }\n}", "lang_cluster": "C#", "tags": ["math"], "code_uid": "b498a3948d01c07b315645b5d54bf635", "src_uid": "6e3b8193d1ca1a1d449dc7a4ad45b8f2", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Diagnostics;\nusing System.IO;\nusing System.Linq;\n\nnamespace Codeforces\n{\n\tinternal class Template\n\t{\n\t\tprivate void Solve()\n\t\t{\n\t\t\tvar k = cin.NextInt();\n\t\t\tvar a = cin.NextInt();\n\t\t\tvar b = cin.NextInt();\n\n\t\t\tif (k > a && (b%k != 0 || b == 0))\n\t\t\t{\n\t\t\t\tConsole.WriteLine(-1);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (k > b && (a % k != 0 || a == 0))\n\t\t\t{\n\t\t\t\tConsole.WriteLine(-1);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (k > a && k > b)\n\t\t\t{\n\t\t\t\tConsole.WriteLine(-1);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tvar count = a / k + b / k;\n\t\t\tConsole.WriteLine(count);\n\t\t}\n\n\t\tprivate static readonly Scanner cin = new Scanner();\n\n\t\tprivate static void Main()\n\t\t{\n#if DEBUG\n\t\t\tvar inputText = File.ReadAllText(@\"..\\..\\input.txt\");\n\t\t\tvar testCases = inputText.Split(new[] { \"input\" }, StringSplitOptions.RemoveEmptyEntries);\n\t\t\tvar consoleOut = Console.Out;\n\t\t\tfor (var i = 0; i < testCases.Length; i++)\n\t\t\t{\n\t\t\t\tvar parts = testCases[i].Split(new[] { \"output\" }, StringSplitOptions.RemoveEmptyEntries);\n\t\t\t\tConsole.SetIn(new StringReader(parts[0].Trim()));\n\t\t\t\tvar stringWriter = new StringWriter();\n\t\t\t\tConsole.SetOut(stringWriter);\n\t\t\t\tvar sw = Stopwatch.StartNew();\n\t\t\t\tnew Template().Solve();\n\t\t\t\tsw.Stop();\n\t\t\t\tvar output = stringWriter.ToString();\n\n\t\t\t\tConsole.SetOut(consoleOut);\n\t\t\t\tvar color = ConsoleColor.Green;\n\t\t\t\tvar status = \"Passed\";\n\t\t\t\tif (parts[1].Trim() != output.Trim())\n\t\t\t\t{\n\t\t\t\t\tcolor = ConsoleColor.Red;\n\t\t\t\t\tstatus = \"Failed\";\n\t\t\t\t}\n\t\t\t\tConsole.ForegroundColor = color;\n\t\t\t\tConsole.WriteLine(\"Test {0} {1} in {2}ms\", i + 1, status, sw.ElapsedMilliseconds);\n\t\t\t}\n\t\t\tConsole.ReadLine();\n\t\t\tConsole.ReadKey();\n#else\n\t\t\tnew Template().Solve();\n\t\t\tConsole.ReadLine();\n#endif\n\t\t}\n\t}\n\n\tinternal class Scanner\n\t{\n\t\tprivate string[] s = new string[0];\n\t\tprivate int i;\n\t\tprivate readonly char[] cs = { ' ' };\n\n\t\tpublic string NextString()\n\t\t{\n\t\t\tif (i < s.Length) return s[i++];\n\t\t\tvar line = Console.ReadLine() ?? string.Empty;\n\t\t\ts = line.Split(cs, StringSplitOptions.RemoveEmptyEntries);\n\t\t\ti = 1;\n\t\t\treturn s.First();\n\t\t}\n\n\t\tpublic double NextDouble()\n\t\t{\n\t\t\treturn double.Parse(NextString());\n\t\t}\n\n\t\tpublic int NextInt()\n\t\t{\n\t\t\treturn int.Parse(NextString());\n\t\t}\n\n\t\tpublic long NextLong()\n\t\t{\n\t\t\treturn long.Parse(NextString());\n\t\t}\n\t}\n}", "lang_cluster": "C#", "tags": ["math"], "code_uid": "cce0114a4d8bca6bed41eaaa6a1f019e", "src_uid": "6e3b8193d1ca1a1d449dc7a4ad45b8f2", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\n\nnamespace CodeForces\n{\n static class Program\n {\n static void Main()\n {\n const string filePath = @\"Data/MR18R2C.txt\";\n if (System.IO.File.Exists(filePath))\n {\n Console.SetIn(new System.IO.StreamReader(filePath));\n }\n\n IProblem counter = new MR18R2C();\n\n foreach (var result in counter.GetResults())\n {\n Console.WriteLine(result);\n }\n }\n }\n\n internal class MR18R2C : ProblemBase\n {\n public override IEnumerable GetResults()\n {\n var ints = this.ReadLongArray();\n var la = ints[0];\n var ra = ints[1];\n var ta = ints[2];\n\n ints = this.ReadLongArray();\n var lb = ints[0];\n var rb = ints[1];\n var tb = ints[2];\n\n var l = Math.Min(la, lb);\n\n la -= l;\n ra -= l;\n lb -= l;\n rb -= l;\n\n long result = 0;\n\n if (ta == tb)\n {\n result = GetLength(la, ra, lb, rb);\n }\n else\n {\n var t = Math.Max(ta, tb);\n var delta = t - Math.Min(ta, tb);\n\n var d = (int)this.Gcd(delta, t);\n if (d == 1)\n {\n result = Math.Min(ra - la + 1, rb - lb + 1);\n }\n else // cycles\n {\n var aDiff = (la / d) * d;\n la -= aDiff;\n ra -= aDiff;\n \n var bDiff = (lb / d) * d;\n lb -= bDiff;\n rb -= bDiff;\n\n var deltas = new[] {-2, -1, 0, 1, 2};\n \n for (int i = 0; i < deltas.Length; i++)\n {\n long current = GetLength(la, ra, lb + deltas[i] * d, rb + deltas[i] * d);\n if (current >= result)\n {\n result = current;\n }\n\n }\n }\n }\n\n yield return result.ToString();\n }\n\n private static long GetLength(long la, long ra, long lb, long rb)\n {\n var left = Math.Max(la, lb);\n var right = Math.Min(ra, rb);\n if (right >= left)\n {\n return right - left + 1;\n }\n\n return 0;\n }\n \n private long Gcd(long a, long b)\n {\n var first = a;\n var second = b;\n\n while (second != 0)\n {\n var temp = first % second;\n first = second;\n second = temp;\n }\n return first;\n }\n \n }\n \n internal class MR18R2D : ProblemBase\n {\n public override IEnumerable GetResults()\n {\n yield return \"n/a\";\n }\n }\n \n \n \n abstract class MultipleTestsBase : ProblemBase\n {\n public sealed override IEnumerable GetResults()\n {\n var t = Convert.ToInt32(Console.ReadLine());\n for (int testCaseNumber = 0; testCaseNumber < t; testCaseNumber++)\n {\n foreach (var result in GetTestResult(testCaseNumber + 1))\n {\n yield return result;\n }\n\n }\n\n }\n\n protected abstract IEnumerable GetTestResult(int caseNumber);\n }\n\n public interface IProblem\n {\n IEnumerable GetResults();\n }\n\n public abstract class ProblemBase : IProblem\n {\n public void PrintArray(IEnumerable items, string prefixMessage)\n {\n Console.WriteLine(\"{0}: {1}\", prefixMessage, string.Join(\",\", items));\n }\n\n public void WriteDiagnostics(string message, params object[] objects)\n {\n Console.WriteLine(message, objects);\n }\n\n public virtual IEnumerable GetResults()\n {\n yield return \"No result\";\n }\n\n protected int[] ReadIntArray()\n {\n return Array.ConvertAll(ReadTokens(), Convert.ToInt32);\n }\n\n protected long[] ReadLongArray()\n {\n return Array.ConvertAll(ReadTokens(), Convert.ToInt64);\n }\n\n protected string[] ReadTokens()\n {\n var readLine = Console.ReadLine();\n if (readLine == null)\n {\n throw new Exception(\"Value read from Console is null\");\n }\n return readLine.Split(' ');\n }\n\n protected int ReadInt32()\n {\n return Convert.ToInt32(Console.ReadLine());\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "number theory"], "code_uid": "ab12a727eaa4cba7fde1a16f9bc5f7ff", "src_uid": "faa75751c05c3ff919ddd148c6784910", "difficulty": 1900.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.IO;\nusing System.Collections.Generic;\nusing System.Globalization;\nusing System.Linq;\nusing System.Text;\n\nclass Program\n{\n class T\n {\n public int X;\n public int Y;\n\n public T(int x, int y)\n {\n X = x;\n Y = y;\n }\n }\n //////////////////////////////////////////////////\n\n long gcda(long a, long b,out long x,out long y)\n {\n if (a == 0)\n {\n x = 0; y = 1;\n return b;\n }\n long x1, y1;\n long d = gcda(b % a, a,out x1,out y1);\n x = y1 - (b / a) * x1;\n y = x1;\n return d;\n }\n\n bool find_any_solution(long a, long b, long c, out long x0, out long y0, out long g)\n {\n g = gcda(Math.Abs(a), Math.Abs(b), out x0, out y0);\n if (c % g != 0)\n return false;\n change(a,b, c, g, ref x0, ref y0);\n return true;\n }\n\n void change(long a, long b, long c, long g, ref long x0, ref long y0)\n {\n x0 *= c / g;\n y0 *= c / g;\n if (a < 0) x0 *= -1;\n if (b < 0) y0 *= -1;\n }\n\n //////////////////////////////////////////////////\n void Solution()\n {\n var la = rl;\n var ra = rl;\n var ta = rl;\n var lb = rl;\n var rb = rl;\n var tb = rl;\n\n //kb*tb=ka*ta+la-lb\n //tb*kb-ta*ka=la-lb\n var c = la - lb;\n //long x = 0;// kb;\n var a = -ta;\n //long y = 0;// ka;\n var b = tb;\n\n if (c < 0)\n {\n c *= -1;\n a *= -1;\n b *= -1;\n }\n\n if (c == 0)\n {\n wln(Math.Min(rb, ra) - la + 1);\n return;\n }\n\n var flag = find_any_solution(a, b, c, out long x, out long y, out long g);\n if (flag)\n {\n wln(Math.Min(rb + y * tb - x * ta, ra) - la + 1);\n }\n else\n {\n\n var c1 = (c / g) * g;\n var c2 = c1 + g;\n var c0 = c1 - g;\n find_any_solution(a, b, c1, out long x1, out long y1, out long g1);\n find_any_solution(a, b, c2, out long x2, out long y2, out long g2);\n if (c0 < 0)\n {\n c0 *= -1;\n a *= -1;\n b *= -1;\n }\n find_any_solution(a, b, c0, out long x0, out long y0, out long g0);\n\n\n var res1 = Math.Min((rb + y1 * tb - x1 * ta), ra) - Math.Max(la, (lb + y1 * tb - x1 * ta)) + 1;\n var res2 = Math.Min((rb + y2 * tb - x2 * ta), ra) - Math.Max(la, (lb + y2 * tb - x2 * ta)) + 1;\n var res0 = Math.Min((rb + y0 * tb - x0 * ta), ra) - Math.Max(la, (lb + y0 * tb - x0 * ta)) + 1;\n wln(Math.Max(0, Math.Max(res0, Math.Max(res1, res2))));\n }\n }\n\n //////////////////////////////////////////////////\n\n struct P : IComparable

\n {\n public long X;\n public long Y;\n\n public P(long x, long y)\n {\n X = x;\n Y = y;\n }\n\n public int CompareTo(P other) => X != other.X ? X.CompareTo(other.X) : Y.CompareTo(other.Y);\n public static int Comparison(P p1, P p2) => p1.CompareTo(p2);\n\n public static bool operator ==(P p1, P p2) => (p1.X == p2.X) && (p1.Y == p2.Y);\n public static bool operator !=(P p1, P p2) => (p1.X != p2.X) || (p1.Y != p2.Y);\n\n public static P operator +(P p1, P p2) => new P(p1.X + p2.X, p1.Y + p2.Y);\n public static P operator -(P p1, P p2) => new P(p1.X - p2.X, p1.Y - p2.Y);\n }\n\n void swap(ref T o1, ref T o2) { var o = o1; o1 = o2; o2 = o; }\n long gcd(long a, long b) => (b != 0) ? gcd(b, a % b) : a;\n long lcm(long a, long b) => a / gcd(a, b) * b;\n\n long rast2(long x1, long y1, long x2, long y2) => (x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2);\n long rast2(P p1, P p2) => (p1.X - p2.X) * (p1.X - p2.X) + (p1.Y - p2.Y) * (p1.Y - p2.Y);\n long ccw(P p1, P p2, P p3) => p1.X * p2.Y + p1.Y * p3.X + p2.X * p3.Y - p2.Y * p3.X - p3.Y * p1.X - p1.Y * p2.X;\n\n StringBuilder _sb = new StringBuilder();\n void wln() { _sb.AppendLine(); }\n void wln(T o) { _sb.AppendLine(o.ToString()); }\n void wsp(T o) { _sb.Append(o).Append(\" \"); }\n void wrt(T o) { _sb.Append(o); }\n void wln(double o) { _sb.AppendLine(string.Format(CultureInfo.InvariantCulture, \"{0:F12}\", o)); }\n void wsp(double o) { _sb.Append(string.Format(CultureInfo.InvariantCulture, \"{0:F12} \", o)); }\n void wrt(double o) { _sb.Append(string.Format(CultureInfo.InvariantCulture, \"{0:F12}\", o)); }\n\n List

rpa(int n)\n {\n var res = new List

(n);\n for (int i = 0; i < n; i++)\n res.Add(new P(rl, rl));\n return res;\n }\n\n int ri\n {\n get\n {\n _read(); while (_str[_ind] == ' ') ++_ind;\n int sign = 1; if (_str[_ind] == '-') { sign = -1; ++_ind; }\n int p = 0;\n while (_ind < _count && _str[_ind] != ' ') p = p * 10 + _str[_ind++] - '0';\n while (_ind < _count && _str[_ind] == ' ') ++_ind; return p * sign;\n }\n }\n long rl\n {\n get\n {\n _read(); while (_str[_ind] == ' ') ++_ind;\n int sign = 1; if (_str[_ind] == '-') { sign = -1; ++_ind; }\n long p = 0;\n while (_ind < _count && _str[_ind] != ' ') p = p * 10 + _str[_ind++] - '0';\n while (_ind < _count && _str[_ind] == ' ') ++_ind; return p * sign;\n }\n }\n double rd\n {\n get\n {\n _read(); while (_str[_ind] == ' ') ++_ind; int sign = 1; if (_str[_ind] == '-') { sign = -1; ++_ind; }\n long p = 0, q = 1; while (_ind < _count && _str[_ind] != ' ' && _str[_ind] != '.') p = p * 10 + _str[_ind++] - '0';\n if (_ind < _count && _str[_ind] == '.') { ++_ind; while (_ind < _count && _str[_ind] != ' ') { p = p * 10 + _str[_ind++] - '0'; q *= 10; } }\n while (_ind < _count && _str[_ind] == ' ') ++_ind; return (double)p / q * sign;\n }\n }\n string rs\n {\n get\n {\n _read(); while (_ind < _count && _str[_ind] == ' ') ++_ind;\n var tmp = _str.IndexOf(' ', _ind);\n if (tmp == -1) { var res = _str.Substring(_ind); _count = 0; _ind = 0; return res; }\n var s = _str.Substring(_ind, tmp - _ind); _ind = tmp + 1;\n while (_ind < _count && _str[_ind] == ' ') ++_ind; return s;\n }\n }\n\n List ria(int n)\n {\n var res = new int[n];\n for (int k = 0; k < n;)\n {\n var s = Console.ReadLine(); var m = s.Length;\n for (int i = 0; i < m && k < n; ++i)\n {\n while (i < m && s[i] == ' ') ++i; if (i == m) break; int sign = 1; if (s[i] == '-') { sign = -1; ++i; }\n int p = 0; while (i < m && s[i] != ' ') p = p * 10 + s[i++] - '0'; res[k++] = p * sign;\n }\n }\n _count = 0; _ind = 0; return res.ToList();\n }\n List rla(int n)\n {\n var res = new long[n];\n for (int k = 0; k < n;)\n {\n var s = Console.ReadLine(); var m = s.Length;\n for (int i = 0; i < m && k < n; ++i)\n {\n while (i < m && s[i] == ' ') ++i; if (i == m) break; int sign = 1; if (s[i] == '-') { sign = -1; ++i; }\n long p = 0; while (i < m && s[i] != ' ') p = p * 10 + s[i++] - '0'; res[k++] = p * sign;\n }\n }\n _count = 0; _ind = 0; return res.ToList();\n }\n List rda(int n)\n {\n var res = new double[n];\n for (int k = 0; k < n;)\n {\n var s = Console.ReadLine(); var m = s.Length;\n for (int i = 0; i < m && k < n; ++i)\n {\n while (i < m && s[i] == ' ') ++i; if (i == m) break; int sign = 1; if (s[i] == '-') { sign = -1; ++i; }\n long p = 0, q = 1; while (i < m && s[i] != ' ' && s[i] != '.') p = p * 10 + s[i++] - '0';\n if (i < m && s[i] == '.') { ++i; while (i < m && s[i] != ' ') { p = p * 10 + s[i++] - '0'; q *= 10; } }\n res[k++] = (double)p / q * sign;\n }\n }\n _count = 0; _ind = 0; return res.ToList();\n }\n List rsa(int n) { var res = new string[n]; for (int k = 0; k < n; ++k) res[k] = Console.ReadLine(); _count = 0; _ind = 0; return res.ToList(); }\n string _str = null; int _count = 0; int _ind = 0;\n void _read() { if (_ind == _count) { _str = Console.ReadLine(); _count = _str.Length; _ind = 0; } }\n static void Main(string[] args) { new Program().Main(); }\n void Main()\n {\n //Console.SetIn(new StreamReader(\"input.txt\")); Console.SetOut(new StreamWriter(\"output.txt\"));\n Solution();\n Console.Write(_sb);\n //Console.In.Close(); Console.Out.Close();\n }\n}", "lang_cluster": "C#", "tags": ["math", "number theory"], "code_uid": "e8faa56edc624414858222603a5c12e9", "src_uid": "faa75751c05c3ff919ddd148c6784910", "difficulty": 1900.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections;\nusing System.Collections.Generic;\n \nclass TEST{\n\tstatic void Main(){\n\t\tSol mySol =new Sol();\n\t\tmySol.Solve();\n\t}\n}\n\nclass Sol{\n\tpublic void Solve(){\n\t\t\n\t\tint mod=(int)(1e9+7);\n\t\tint N=200001;\n\t\t\n\t\tint[][] dp=new int[2][];\n\t\t\n\t\tdp[0]=new int[N];\n\t\tdp[1]=new int[N];\n\t\tdp[0][0]=1;\n\t\t\n\t\tint[] d=new int[1010];\n\t\td[0]=1;\n\t\t\n\t\tint h=0;\n\t\tint rmax=0;\n\t\tint next;\n\t\tint now;\n\t\tint rr;\n\t\tint gg;\n\t\tfor(int i=1;i<894;i++){\n\t\t\tnext=i%2;\n\t\t\tnow=1-next;\n\t\t\tfor(int j=0;j<=Math.Min(rmax+i,N-1);j++)dp[next][j]=0;\n\t\t\tfor(int j=0;j<=rmax;j++){\n\t\t\t\tif(dp[now][j]==0)continue;\n\t\t\t\trr=j;\n\t\t\t\tgg=((i-1+1)*(i-1))/2-rr;\n\t\t\t\t\n\t\t\t\tif(r-rr>=i){\n\t\t\t\t\tdp[next][rr+i]+=dp[now][j];\n\t\t\t\t\tdp[next][rr+i]%=mod;\n\t\t\t\t\tif(rmax=i){\n\t\t\t\t\tdp[next][rr]+=dp[now][j];\n\t\t\t\t\tdp[next][rr]%=mod;\n\t\t\t\t\td[i]+=dp[now][j];\n\t\t\t\t\td[i]%=mod;\n\t\t\t\t\th=i;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t//Console.WriteLine(h);\n\t\tConsole.WriteLine(d[h]);\n\t\t\n\t\t\n\t}\n\t\n\t\n\tint r;\n\tint g;\n\tpublic Sol(){\n\t\tvar d=ria();\n\t\tr=d[0];\n\t\tg=d[1];\n\t}\n\n\n\n\n\tstatic String rs(){return Console.ReadLine();}\n\tstatic int ri(){return int.Parse(Console.ReadLine());}\n\tstatic long rl(){return long.Parse(Console.ReadLine());}\n\tstatic double rd(){return double.Parse(Console.ReadLine());}\n\tstatic String[] rsa(){return Console.ReadLine().Split(' ');}\n\tstatic int[] ria(){return Array.ConvertAll(Console.ReadLine().Split(' '),e=>int.Parse(e));}\n\tstatic long[] rla(){return Array.ConvertAll(Console.ReadLine().Split(' '),e=>long.Parse(e));}\n\tstatic double[] rda(){return Array.ConvertAll(Console.ReadLine().Split(' '),e=>double.Parse(e));}\n}\n", "lang_cluster": "C#", "tags": ["dp"], "code_uid": "f857074db2f52761b3eb6a6b90c2407b", "src_uid": "34b6286350e3531c1fbda6b0c184addc", "difficulty": 2000.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections;\nusing System.Collections.Generic;\n \nclass TEST{\n\tstatic void Main(){\n\t\tSol mySol =new Sol();\n\t\tmySol.Solve();\n\t}\n}\n\nclass Sol{\n\tpublic void Solve(){\n\t\t\n\t\tint mod=(int)(1e9+7);\n\t\tint N=200001;\n\t\t\n\t\tint[][] dp=new int[2][];\n\t\t\n\t\tdp[0]=new int[N];\n\t\tdp[1]=new int[N];\n\t\tdp[0][0]=1;\n\t\t\n\t\tint[] d=new int[1010];\n\t\td[0]=1;\n\t\t\n\t\tint h=0;\n\t\tint rmax=0;\n\t\tint next;\n\t\tint now;\n\t\tint rr;\n\t\tint gg;\n\t\tfor(int i=1;i<894;i++){\n\t\t\tnext=i%2;\n\t\t\tnow=1-next;\n\t\t\tfor(int j=0;j<=Math.Min(rmax+i,N-1);j++)dp[next][j]=0;\n\t\t\tfor(int j=0;j<=rmax;j++){\n\t\t\t\tif(dp[now][j]==0)continue;\n\t\t\t\trr=j;\n\t\t\t\tgg=((i-1+1)*(i-1))/2-rr;\n\t\t\t\t\n\t\t\t\tif(r-rr>=i){\n\t\t\t\t\tdp[next][rr+i]+=dp[now][j];\n\t\t\t\t\tif(dp[next][rr+i]>mod)dp[next][rr+i]-=mod;\n\t\t\t\t\tif(rmaxmod)d[i]-=mod;\n\t\t\t\t\th=i;\n\t\t\t\t}\n\t\t\t\tif(g-gg>=i){\n\t\t\t\t\tdp[next][rr]+=dp[now][j];\n\t\t\t\t\tif(dp[next][rr]>mod)dp[next][rr]-=mod;\n\t\t\t\t\td[i]+=dp[now][j];\n\t\t\t\t\tif(d[i]>mod)d[i]-=mod;\n\t\t\t\t\th=i;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t//Console.WriteLine(h);\n\t\tConsole.WriteLine(d[h]%mod);\n\t\t\n\t\t\n\t}\n\t\n\t\n\tint r;\n\tint g;\n\tpublic Sol(){\n\t\tvar d=ria();\n\t\tr=d[0];\n\t\tg=d[1];\n\t}\n\n\n\n\n\tstatic String rs(){return Console.ReadLine();}\n\tstatic int ri(){return int.Parse(Console.ReadLine());}\n\tstatic long rl(){return long.Parse(Console.ReadLine());}\n\tstatic double rd(){return double.Parse(Console.ReadLine());}\n\tstatic String[] rsa(){return Console.ReadLine().Split(' ');}\n\tstatic int[] ria(){return Array.ConvertAll(Console.ReadLine().Split(' '),e=>int.Parse(e));}\n\tstatic long[] rla(){return Array.ConvertAll(Console.ReadLine().Split(' '),e=>long.Parse(e));}\n\tstatic double[] rda(){return Array.ConvertAll(Console.ReadLine().Split(' '),e=>double.Parse(e));}\n}\n", "lang_cluster": "C#", "tags": ["dp"], "code_uid": "1125d15da9fb40f3bcb18d8a8eb74b11", "src_uid": "34b6286350e3531c1fbda6b0c184addc", "difficulty": 2000.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Globalization;\nusing System.IO;\nusing System.Linq;\nusing System.Text;\npublic class Codeforces\n{\n protected static TextReader reader;\n protected static TextWriter writer;\n static void Main()\n {\n reader = new StreamReader(Console.OpenStandardInput(1024 * 10), System.Text.Encoding.ASCII, false, 1024 * 10);\n writer = new StreamWriter(Console.OpenStandardOutput(1024 * 10), System.Text.Encoding.ASCII, 1024 * 10);\n var v1 = ReadInt();\n var v2 = ReadInt();\n var t = ReadInt();\n var d = ReadInt();\n var a = 0;\n for (int i = 0; i < t; i++)\n {\n a += Math.Min(v1 + i * d, v2 + (t - i - 1) * d);\n }\n Write(a);\n reader.Close();\n writer.Close();\n }\n #region Read / Write\n\n private static Queue currentLineTokens = new Queue();\n\n private static string[] ReadAndSplitLine()\n {\n return reader.ReadLine().Split(new[] { ' ', '\\t' }, StringSplitOptions.RemoveEmptyEntries);\n }\n\n public static string ReadToken()\n {\n while (currentLineTokens.Count == 0)\n currentLineTokens = new Queue(ReadAndSplitLine());\n return currentLineTokens.Dequeue();\n }\n\n public static int ReadInt()\n {\n return int.Parse(ReadToken());\n }\n\n public static long ReadLong()\n {\n return long.Parse(ReadToken());\n }\n\n public static double ReadDouble()\n {\n return double.Parse(ReadToken(), CultureInfo.InvariantCulture);\n }\n\n public static int[] ReadIntArray()\n {\n return ReadAndSplitLine().Select(int.Parse).ToArray();\n }\n\n public static long[] ReadLongArray()\n {\n return ReadAndSplitLine().Select(long.Parse).ToArray();\n }\n\n public static double[] ReadDoubleArray()\n {\n return ReadAndSplitLine().Select(s => double.Parse(s, CultureInfo.InvariantCulture)).ToArray();\n }\n public static int[][] ReadIntMatrix(int numberOfRows)\n {\n int[][] matrix = new int[numberOfRows][];\n for (int i = 0; i < numberOfRows; i++)\n matrix[i] = ReadIntArray();\n return matrix;\n }\n public static int[][] ReadAndTransposeIntMatrix(int numberOfRows)\n {\n int[][] matrix = ReadIntMatrix(numberOfRows);\n int[][] ret = new int[matrix[0].Length][];\n for (int i = 0; i < ret.Length; i++)\n {\n ret[i] = new int[numberOfRows];\n for (int j = 0; j < numberOfRows; j++)\n ret[i][j] = matrix[j][i];\n }\n return ret;\n }\n\n public static string[] ReadLines(int quantity)\n {\n string[] lines = new string[quantity];\n for (int i = 0; i < quantity; i++)\n lines[i] = reader.ReadLine().Trim();\n return lines;\n }\n public static void WriteArray(IEnumerable array)\n {\n writer.WriteLine(string.Join(\" \", array));\n }\n\n public static void Write(params T[] array)\n {\n WriteArray(array);\n }\n\n public static void WriteLines(IEnumerable array)\n {\n foreach (var a in array)\n writer.WriteLine(a);\n }\n #endregion\n}", "lang_cluster": "C#", "tags": ["math", "greedy", "dp"], "code_uid": "e64bc1abd5498894d89ec7a78333578c", "src_uid": "9246aa2f506fcbcb47ad24793d09f2cf", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace Takmicenja.CodeForces.CF298\n{\n class B\n {\n public static void Main(string[] varg)\n {\n string[] tok = Console.ReadLine().Split(new char[] { ' ' });\n int v1 = int.Parse(tok[0]);\n int v2 = int.Parse(tok[1]);\n\n tok = Console.ReadLine().Split(new char[] { ' ' });\n int t = int.Parse(tok[0]);\n int d = int.Parse(tok[1]);\n\n int[] vleft = new int[t];\n vleft[0] = v1;\n for (int i = 1; i < t; i++)\n vleft[i] = vleft[i - 1] + d;\n\n int[] vright = new int[t];\n vright[0] = v2;\n for (int i = 1; i < t; i++)\n vright[i] = vright[i - 1] + d;\n\n int maxSpeed = v1>v2?v1:v2;\n int[] vUpper = new int[t];\n for (int i=0;i vright[t - i - 1])\n vUpper[i] = vright[t - i - 1];\n }\n\n long s = 0;\n for (int i = 0; i < t; i++)\n s += vUpper[i];\n\n Console.WriteLine(s);\n\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "greedy", "dp"], "code_uid": "e6fe73512cd99a85feb1675c76928f1c", "src_uid": "9246aa2f506fcbcb47ad24793d09f2cf", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\npublic class Codeforces\n{\n static void Main()\n {\n var _ = Console.ReadLine().Split().Select(int.Parse).ToArray();\n var a = _[0];\n var c = _[1];\n var a3 = new Stack();\n var a3ctr = 0;\n var b3 = new Stack();\n var c3 = new Stack();\n var c3ctr = 0;\n while (a > 0)\n {\n var rem = a % 3;\n a /= 3;\n a3.Push(rem);\n a3ctr++;\n }\n while (c > 0)\n {\n var rem = c % 3;\n c /= 3;\n c3.Push(rem);\n c3ctr++;\n }\n if (a3ctr > c3ctr)\n {\n for (int i = 0; i < a3ctr - c3ctr; i++)\n {\n c3.Push(0);\n }\n c3ctr = a3ctr;\n }\n else if (c3ctr > a3ctr)\n {\n for (int i = 0; i < c3ctr - a3ctr; i++)\n {\n a3.Push(0);\n }\n a3ctr = c3ctr;\n }\n long res = 0L;\n for (int i = 0; i < a3ctr; i++)\n {\n var ter = new[] { 0, 1, 2 };\n var m = c3.Pop();\n var n = a3.Pop();\n while (n-- != 0)\n {\n m--;\n if (m < 0) m = 2;\n }\n b3.Push(m);\n res += m * (long)Math.Pow(3, (a3ctr - 1 - i));\n }\n Console.WriteLine(res);\n }\n}", "lang_cluster": "C#", "tags": ["math", "implementation"], "code_uid": "fdb24e9c09978300922e5ca82034ab0a", "src_uid": "5fb635d52ddccf6a4d5103805da02a88", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\nusing System.Numerics;\n\nnamespace ConsoleApplication2\n{\n\n \n\n class Program\n {\n\n static void Main(string[] args)\n {\n \n\n\n string[] str = Console.ReadLine().Split(' ');\n long a = long.Parse(str[0]);\n long c = long.Parse(str[1]);\n\n if(a == 0 && c ==0)\n {\n Console.WriteLine(0);\n return;\n }\n\n int length = (int)Math.Max(Math.Ceiling(Math.Log(a, 3)), Math.Ceiling(Math.Log(c, 3)))+1;\n\n //Console.WriteLine(length);\n\n int[] astr = new int[length];\n for (int i = 0; i < length; i++ )\n {\n astr[i] = (int)((a / (int)Math.Pow(3, i)) % 3);\n }\n\n\n int[] cstr = new int[length];\n for (int i = 0; i < length; i++)\n {\n cstr[i] = (int)((c / (int)Math.Pow(3, i)) % 3);\n }\n\n\n\n int[] bstr = new int[length];\n for (int i = 0; i < length; i++)\n {\n if (astr[i] <= cstr[i])\n {\n bstr[i] = cstr[i] - astr[i];\n }\n else \n {\n bstr[i] = cstr[i] - astr[i] + 3;\n }\n }\n\n\n\n /*\n for (int i = 0; i < length; i++ )\n {\n Console.Write(astr[i]);\n }\n Console.WriteLine();\n\n for (int i = 0; i < length; i++)\n {\n Console.Write(bstr[i]);\n }\n Console.WriteLine();\n\n for (int i = 0; i < length; i++)\n {\n Console.Write(cstr[i]);\n }\n Console.WriteLine();\n */\n\n long res = 0;\n for (int i = 0; i < length; i++)\n {\n //Console.WriteLine(bstr[i] + \" \" + (int)Math.Pow(3, i));\n res += bstr[i] * (long)Math.Pow(3, i);\n }\n Console.WriteLine(res);\n }\n\n\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "implementation"], "code_uid": "4378c3b2ac185b303d1ed2d735f8d441", "src_uid": "5fb635d52ddccf6a4d5103805da02a88", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "C# 8", "source_code": "\ufeff// CodeForces Basic Question For Recursions\r\n//https://codeforces.com/group/MWSDmqGsZm/contest/223339\r\n\r\nusing System;\r\nusing System.Collections;\r\nusing System.Diagnostics;\r\n\r\npublic static class Program\r\n{\r\n public static void Main()\r\n {\r\n int n = int.Parse(Console.ReadLine());\r\n for (int i = 0; i < n; i++)\r\n {\r\n int[] x = Array.ConvertAll(Console.ReadLine().Split(' '), (item) => Convert.ToInt32(item));\r\n int[] y = Array.ConvertAll(Console.ReadLine().Split(' '), (item2) => Convert.ToInt32(item2));\r\n Console.WriteLine(Solve(x, y));\r\n }\r\n }\r\n public static int Solve(int[] x, int[] y)\r\n {\r\n int count = 0;\r\n for (int i = 0; i < 2; i++)\r\n {\r\n if (x[i] == 1) count++;\r\n if (y[i] == 1) count++;\r\n }\r\n if(count == 0) return 0;\r\n if (count == 4) return 2;\r\n else return 1;\r\n }\r\n}", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "77e4597c6170f49343384659953e1956", "src_uid": "7336b8becd2438f0439240ee8f9610ec", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "C# 10", "source_code": "// See https://aka.ms/new-console-template for more informatio\r\n//int t, n, m;\r\n//t = Convert.ToInt32(Console.ReadLine());\r\n//for (int t1 = 0; t1 < t; t1++)\r\n//{\r\n// var s = Console.ReadLine();\r\n// var endId = 0;\r\n// for(int i = 0; i < s.Length; i++)\r\n// {\r\n// if(s[i] == ' ')\r\n// {\r\n// endId = i;\r\n// break;\r\n// }\r\n// }\r\n// n = Convert.ToInt32(s.Substring(0, endId));\r\n// m = Convert.ToInt32(s.Substring(endId + 1, s.Length - endId - 1));\r\n// long res = 0;\r\n// for (int i = 1; i <= m; i++)\r\n// {\r\n// res += i;\r\n// }\r\n// for (int i = 1; i < n; i++)\r\n// {\r\n// res += i * m + m;\r\n// }\r\n// Console.WriteLine(res);\r\n//}\r\nusing System;\r\n\r\npublic class HelloWorld\r\n{\r\n public static void Main(string[] args)\r\n {\r\n int testCase;\r\n testCase = Convert.ToInt32(Console.ReadLine());\r\n for (int x = 0; x < testCase; x++)\r\n {\r\n var s = Console.ReadLine();\r\n int sum = 0;\r\n var endId = 0;\r\n for (int i = 0; i < s.Length; i++)\r\n {\r\n if (s[i] == ' ')\r\n {\r\n endId = i;\r\n break;\r\n }\r\n }\r\n sum += Convert.ToInt32(s.Substring(0, endId));\r\n sum += Convert.ToInt32(s.Substring(endId + 1, s.Length - endId - 1));\r\n s = Console.ReadLine();\r\n endId = 0;\r\n for (int i = 0; i < s.Length; i++)\r\n {\r\n if (s[i] == ' ')\r\n {\r\n endId = i;\r\n break;\r\n }\r\n }\r\n sum += Convert.ToInt32(s.Substring(0, endId));\r\n sum += Convert.ToInt32(s.Substring(endId + 1, s.Length - endId - 1));\r\n int res = 0;\r\n if (sum == 4)\r\n {\r\n res = 2;\r\n }\r\n else if (sum > 0)\r\n {\r\n res = 1;\r\n }\r\n Console.WriteLine(res);\r\n }\r\n }\r\n}", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "d268bb8ffb151ceaed2f5bc242e2485d", "src_uid": "7336b8becd2438f0439240ee8f9610ec", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Collections;\nusing System.Linq;\n\n\n\nnamespace tes\n{\n\tclass contest\n\t{\n\t\t\t\t\n\t\t\n\t\tstatic void Main(string[] args)\n\t\t{\n\n\t\t \n \n string s = Console.ReadLine();\n string r = \"\";\n string c = \"\";\n int len = s.Length;\n for(int i=0; i< len; i++)\n {\n if (i < len - 1) r += s[i];\n else c += s[i];\n }\n\n var col = new string[]{\"f\",\"e\",\"d\",\"a\",\"b\",\"c\" };\n long row = long.Parse(r);\n\n long time = (Array.IndexOf(col,c))+1;\n \n long a = row/3;\n long b = row % 3;\n\n long turn = row / 4;\n if (row % 4 > 0) turn++;\n\n time += (turn+turn-2) * 7;\n time += (turn -1) * 2;\n\n if (row % 2 == 0)\n {\n time += 7;\n }\n\n\n \n\n\n\n\n Console.WriteLine(time);\n\n\n\n\n\t\n\n\n\t\t\n }\n\t\t\n\t\t\n\t\t\t\n\t}\n}", "lang_cluster": "C#", "tags": ["math", "implementation"], "code_uid": "6d747ebfabd54cf65ea6cfad3a8b810f", "src_uid": "069d0cb9b7c798a81007fb5b63fa0f45", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace _725B\n{\n class Program\n {\n static void Main(string[] args)\n {\n string S = Console.ReadLine();\n int L = S.Length; sbyte A2 = 0;\n char C = char.Parse(S.Substring(L-1));\n string SN = (S.Substring(0, L - 1));\n long N = long.Parse(SN);\n\n switch (C)\n {\n case 'f':\n A2 = 1;\n break;\n case 'e':\n A2 = 2;\n break;\n case 'd':\n A2 = 3;\n break;\n case 'a':\n A2 = 4;\n break;\n case 'b':\n A2 = 5;\n break;\n case 'c':\n A2 = 6;\n break;\n\n }\n\n long A1 = 16 * ((N - 1) / 4);\n sbyte A3 = 0;\n if ((N % 2) == 0) A3 = 7;\n long T = A1 + A2 + A3;\n\n Console.WriteLine(T);\n\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "implementation"], "code_uid": "d069ea6a80ad571449f8768a07e456ce", "src_uid": "069d0cb9b7c798a81007fb5b63fa0f45", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Diagnostics;\n\nnamespace CF\n{\n public static class FromConsole\n {\n public static T To(this string input) where T : IConvertible\n {\n return (T)Convert.ChangeType(input, typeof(T));\n }\n\n public static T[] ToArrayOf(this string input, char? delimiter = null) where T : IConvertible\n {\n IEnumerable sequence = delimiter == null ? input.Select(x => x.ToString()) : input.Split(delimiter.Value);\n\n return sequence.Select(x => x.ToString().To()).ToArray();\n }\n\n public static T[] ToArrayOf(int count) where T : IConvertible\n {\n T[] output = new T[count];\n\n for (int i = 0; i < count; i++)\n {\n output[i] = Console.ReadLine().To();\n }\n\n return output;\n }\n\n public static T[] ToArrayOf(T value, int count)\n {\n return Enumerable.Repeat(value, count).ToArray();\n }\n\n public static T[][] ToMatrixOf(int n, char? delimiter = null) where T : IConvertible\n {\n T[][] output = new T[n][];\n\n for (int i = 0; i < n; i++)\n {\n output[i] = Console.ReadLine().ToArrayOf(delimiter);\n }\n\n return output;\n }\n\n public static T[][] ToMatrixOf(T value, int n, int m)\n {\n T[][] output = new T[n][];\n\n for (int i = 0; i < n; i++)\n {\n output[i] = ToArrayOf(value, m);\n }\n\n return output;\n }\n\n public static Tuple IndexOf(this T[][] input, params T[] targets)\n {\n for (int i = 0; i < input.Length; i++)\n {\n for (int j = 0; j < input[0].Length; j++)\n {\n if (targets.Any(x => x.Equals(input[i][j])))\n {\n return new Tuple(i, j);\n }\n }\n }\n\n return new Tuple(-1, -1);\n }\n\n public static void AddToList(this Dictionary> input, T k, U v)\n {\n if (input.ContainsKey(k))\n {\n input[k].Add(v);\n }\n else\n {\n input.Add(k, new List() { v });\n }\n }\n\n public static void AddAndIncrement(this Dictionary input, T k)\n {\n if (input.ContainsKey(k))\n {\n input[k]++;\n }\n else\n {\n input.Add(k, 1);\n }\n }\n\n public static string ToBinary(this long input)\n {\n return Convert.ToString(input, 2);\n }\n\n public static long ToDecimal(this string input)\n {\n return Convert.ToInt32(input, 2);\n }\n\n public static long Binomial(long n, long k)\n {\n long r = 1;\n long d;\n if (k > n) return 0;\n for (d = 1; d <= k; d++)\n {\n r *= n--;\n r /= d;\n }\n return r;\n }\n }\n\n class Program\n {\n static void Main(string[] args)\n {\n int[] bounds = Console.ReadLine().ToArrayOf(' ');\n int n = bounds[0];\n int x = Math.Min(bounds[1], bounds[2]);\n int y = Math.Max(bounds[1], bounds[2]);\n\n Node head = new Node(1);\n Node current = head;\n for (int i = 2; i <= n; i++)\n {\n Node next = new Node(i);\n next.Previous = current;\n current.Next = next;\n current = next;\n }\n\n int round = 1;\n bool stillPossible = true;\n int finalRound = (int)Math.Log(n, 2);\n while (round <= finalRound)\n {\n Node one = head;\n Node two = head.Next;\n while (one != null)\n {\n int i = one.Value;\n int j = two.Value;\n\n if (i == x && j == y)\n {\n stillPossible = false;\n break;\n }\n else\n {\n if (i == x || i == y)\n {\n one.Next = two.Next;\n\n if (two.Next == null)\n {\n break;\n }\n\n two.Next.Previous = one;\n two = one.Next;\n\n one = one.Next;\n two = two.Next;\n }\n else\n {\n if (one.Previous == null)\n {\n head = two;\n two.Previous = null;\n one = head;\n two = one.Next;\n\n one = one.Next;\n two = two.Next;\n }\n else\n {\n one.Previous.Next = two;\n two.Previous = one.Previous;\n one = two;\n two = one.Next;\n\n if (two == null)\n {\n break;\n }\n\n one = one.Next;\n two = two.Next;\n }\n }\n }\n }\n\n if (!stillPossible)\n {\n break;\n }\n\n round++;\n }\n \n Console.WriteLine(round == finalRound ? \"Final!\" : round.ToString());\n //Console.ReadKey();\n } \n }\n\n class Node\n {\n public int Value { get; set; }\n public Node Previous { get; set; }\n public Node Next { get; set; }\n\n public Node(int value)\n {\n Value = value;\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["constructive algorithms", "implementation"], "code_uid": "f33adec2a81dc5420818c70d7006545d", "src_uid": "a753bfa7bde157e108f34a28240f441f", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\n\nnamespace Codeforces\n{\n class Program\n {\n static void Main(string[] args)\n {\n string[] s = Console.ReadLine().Split(' ');\n int n = int.Parse(s[0]);\n int a = int.Parse(s[1]);\n int b = int.Parse(s[2]);\n \n if (a > b)\n {\n int x = a;\n a = b;\n b = x;\n }\n \n if (a <= n / 2 && b > n / 2)\n Console.WriteLine(\"Final!\");\n else\n {\n a--; \n b--;\n int res;\n for (res = 0; a != b; res++)\n {\n a /= 2;\n b /= 2;\n }\n Console.WriteLine(res);\n }\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["constructive algorithms", "implementation"], "code_uid": "fac4118ffb829bd53a7c937021647963", "src_uid": "a753bfa7bde157e108f34a28240f441f", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "C# 8", "source_code": "using System;\r\n\r\nnamespace CodeForces\r\n{\r\n internal class ThreeDoors\r\n {\r\n public static void Main(string[] args)\r\n {\r\n int testcases = int.Parse(Console.ReadLine());\r\n\r\n for (int i = 0; i < testcases; i++)\r\n {\r\n int key = int.Parse(Console.ReadLine());\r\n\r\n int[] doors = new int[3];\r\n string[] split = Console.ReadLine().Split();\r\n\r\n for (int j = 0; j < 3; j++)\r\n {\r\n doors[j] = int.Parse(split[j]);\r\n }\r\n\r\n TestPossible(key, doors);\r\n }\r\n }\r\n\r\n static void TestPossible(int key, int[] doors)\r\n {\r\n for (int i = 0; i < 2; i++)\r\n {\r\n key = doors[key - 1];\r\n if (key == 0)\r\n {\r\n Console.WriteLine(\"no\");\r\n return;\r\n }\r\n }\r\n Console.WriteLine(\"yes\");\r\n }\r\n }\r\n}\r\n", "lang_cluster": "C#", "tags": ["brute force", "greedy", "implementation", "math"], "code_uid": "837f9cd4a1627d8c1d4c20f644aa5168", "src_uid": "5cd113a30bbbb93d8620a483d4da0349", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "C# 8", "source_code": "using System;\r\nusing System.Linq;\r\nusing System.Text;\r\nusing System.Numerics;\r\nusing static System.Console;\r\nusing System.Collections.Generic;\r\n\r\nusing static CompLib.Algorithm;\r\nusing static CompLib.EMath;\r\n\r\nnamespace ProblemSolving.cs\r\n{\r\n class MainClass\r\n {\r\n const int Mod = (int) (1e9 + 7);\r\n const int Def = (int) 1e9;\r\n\r\n static long[] OneLongLine => ReadLine().Trim().Split(' ').Select(long.Parse).ToArray();\r\n static int[] OneIntLine => ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();\r\n static int[] OneCharLine => ReadLine().Trim().ToCharArray().Select(v => v - '0').ToArray();\r\n static long OneLong => long.Parse(ReadLine().Trim());\r\n static int OneInt => int.Parse(ReadLine().Trim());\r\n static string OneString => ReadLine().Trim();\r\n\r\n\r\n static void Solve()\r\n {\r\n int key = OneInt;\r\n var list = OneIntLine.ToList();\r\n int idx = list.IndexOf(0) + 1;\r\n\r\n if (list[key - 1] == 0 || list[list[key - 1] - 1] == 0)\r\n {\r\n WriteLine(\"NO\");\r\n }\r\n else WriteLine(\"YES\");\r\n \r\n \r\n\r\n\r\n\r\n\r\n }\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n static bool Check(int[] arr)\r\n {\r\n return true;\r\n }\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n static void Main()\r\n {\r\n int cases = OneInt;\r\n while (--cases >= 0)\r\n {\r\n Solve();\r\n }\r\n\r\n // Solve();\r\n }\r\n }\r\n}\r\n\r\nnamespace CompLib\r\n{\r\n public static class Algorithm\r\n {\r\n public static long LowerBound(long[] arr, long low, long high, long val)\r\n {\r\n if (low > high)\r\n {\r\n return low;\r\n }\r\n\r\n long mid = low + (high - low) / 2;\r\n\r\n if (val <= arr[mid])\r\n {\r\n return LowerBound(arr, low, mid - 1, val);\r\n }\r\n\r\n return LowerBound(arr, mid + 1, high, val);\r\n }\r\n\r\n public static long UpperBound(long[] arr, long low, long high, long val)\r\n {\r\n if (low > high || low == arr.Length)\r\n {\r\n return low;\r\n }\r\n\r\n long mid = low + (high - low) / 2;\r\n\r\n if (val >= arr[mid])\r\n {\r\n return UpperBound(arr, mid + 1, high, val);\r\n }\r\n\r\n return UpperBound(arr, low, mid - 1, val);\r\n }\r\n }\r\n\r\n\r\n\r\n\r\n\r\n\r\n public static class EMath\r\n {\r\n public static int Mod(int a, int m)\r\n {\r\n return (a % m + m) % m;\r\n }\r\n\r\n public static long Gcd(long a, long b)\r\n {\r\n long r;\r\n while (b != 0)\r\n {\r\n r = a % b;\r\n a = b;\r\n b = r;\r\n }\r\n\r\n return a;\r\n }\r\n\r\n public static long Lcm(long a, long b)\r\n {\r\n if (a > b)\r\n {\r\n return (a / Gcd(a, b)) * b;\r\n }\r\n\r\n return (b / Gcd(a, b)) * a;\r\n }\r\n }\r\n}", "lang_cluster": "C#", "tags": ["brute force", "greedy", "implementation", "math"], "code_uid": "9554b22a5466bed520a95ddc60c693e1", "src_uid": "5cd113a30bbbb93d8620a483d4da0349", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": " using System;\n using System.Linq;\n using System.Collections.Generic;\n\n namespace Codeforces\n {\n class TaskA\n {\n static void Main()\n {\n var input = Console.ReadLine().Trim().Split(' ');\n var a = Int32.Parse(input[0]);\n var b = Int32.Parse(input[1]);\n\n var max = Math.Max(a, b);\n var min = Math.Min(a, b);\n\n long lenMax = 0;\n long nok = (long)a*b;\n for (long i = 1; i <= min; i++)\n {\n var q = (max * i) % min;\n if (q == 0)\n {\n lenMax += min;\n nok = i * max;\n }\n else\n lenMax += q;\n }\n if(lenMax*2 == nok)\n Console.WriteLine(\"Equal\");\n else if (lenMax * 2 < nok)\n {\n if (max == b)\n Console.WriteLine(\"Dasha\");\n else\n Console.WriteLine(\"Masha\");\n }\n else\n {\n if (max == a)\n Console.WriteLine(\"Dasha\"); \n else\n Console.WriteLine(\"Masha\");\n }\n\n }\n }\n }", "lang_cluster": "C#", "tags": ["math", "implementation"], "code_uid": "3a1176f07bc66aa010ef4605da0c8f49", "src_uid": "06eb66df61ff5d61d678bbb3bb6553cc", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeff\ufeffusing System;\n\ufeffusing System.Collections.Generic;\n\ufeffusing System.Globalization;\n\ufeffusing System.IO;\n\ufeffusing System.Linq;\n\ufeffusing System.Text;\n\nnamespace CF\n{\n\tinternal class Program\n\t{\n\t\tprivate static void Main(string[] args)\n\t\t{\n\t\t\tvar sr = new InputReader(Console.In);\n\t\t\t//var sr = new InputReader(new StreamReader(\"input.txt\"));\n\t\t\tvar task = new Task();\n\t\t\tusing (var sw = Console.Out)\n\t\t\t{\n\t\t\t\t//using (var sw = new StreamWriter(\"output.txt\")) {\n\t\t\t\ttask.Solve(sr, sw);\n\t\t\t\t//Console.ReadKey();\n\t\t\t}\n\t\t}\n\t}\n\n\tinternal class Task\n\t{\n\t\tpublic void Solve(InputReader sr, TextWriter sw)\n\t\t{\n\t\t\tvar input = sr.ReadArrayOfInt64();\n\t\t\tvar a = input[0];\n\t\t\tvar b = input[1];\n\t\t\tvar gcd = Gcd((int)a, (int)b);\n\t\t\tvar lcm = (a * b) / gcd;\n\t\t\tvar dCount = lcm / a;\n\t\t\tvar mCount = lcm / b;\n\t\t\tif (a > b)\n\t\t\t\tdCount++;\n\t\t\telse {\n\t\t\t\tmCount++;\n\t\t\t}\n\t\t\tif (dCount == mCount)\n\t\t\t{\n\t\t\t\tsw.WriteLine(\"Equal\");\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (dCount > mCount)\n\t\t\t{\n\t\t\t\tsw.WriteLine(\"Dasha\");\n\t\t\t}\n\t\t\telse {\n\t\t\t\tsw.WriteLine(\"Masha\");\n\t\t\t}\n\t\t}\n\n\t\tprivate int Gcd(int a, int b)\n\t\t{\n\t\t\tif (b == 0)\n\t\t\t\treturn a;\n\n\t\t\treturn Gcd(b, a % b);\n\t\t}\n\t}\n}\n\ninternal class InputReader : IDisposable\n{\n\tprivate bool isDispose;\n\tprivate readonly TextReader sr;\n\n\tpublic InputReader(TextReader stream)\n\t{\n\t\tsr = stream;\n\t}\n\n\tpublic void Dispose()\n\t{\n\t\tDispose(true);\n\t\tGC.SuppressFinalize(this);\n\t}\n\n\tpublic string NextString()\n\t{\n\t\tvar result = sr.ReadLine();\n\t\treturn result;\n\t}\n\n\tpublic int NextInt32()\n\t{\n\t\treturn Int32.Parse(NextString());\n\t}\n\n\tpublic long NextInt64()\n\t{\n\t\treturn Int64.Parse(NextString());\n\t}\n\n\tpublic string[] NextSplitStrings()\n\t{\n\t\treturn NextString()\n\t\t\t\t\t\t\t\t\t\t.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);\n\t}\n\n\tpublic T[] ReadArray(Func func)\n\t{\n\t\treturn NextSplitStrings()\n\t\t\t\t\t\t\t\t\t\t.Select(s => func(s, CultureInfo.InvariantCulture))\n\t\t\t\t\t\t\t\t\t\t.ToArray();\n\t}\n\n\tpublic int[] ReadArrayOfInt32()\n\t{\n\t\treturn ReadArray(Int32.Parse);\n\t}\n\n\tpublic long[] ReadArrayOfInt64()\n\t{\n\t\treturn ReadArray(Int64.Parse);\n\t}\n\n\tpublic T[] ReadArrayFromString(Func func, string str)\n\t{\n\t\treturn\n\t\t\t\t\t\t\t\t\t\tstr.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t.Select(s => func(s, CultureInfo.InvariantCulture))\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t.ToArray();\n\t}\n\n\tprotected void Dispose(bool dispose)\n\t{\n\t\tif (!isDispose)\n\t\t{\n\t\t\tif (dispose)\n\t\t\t\tsr.Close();\n\t\t\tisDispose = true;\n\t\t}\n\t}\n\n\t~InputReader()\n\t{\n\t\tDispose(false);\n\t}\n}", "lang_cluster": "C#", "tags": ["math", "implementation", "number theory"], "code_uid": "f47ea97c12f7dbd9ca137955c9941463", "src_uid": "06eb66df61ff5d61d678bbb3bb6553cc", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.IO;\nusing System.Text;\n\nnamespace Cows_and_Primitive_Roots\n{\n internal class Program\n {\n private static readonly StreamReader reader = new StreamReader(Console.OpenStandardInput(1024*10), Encoding.ASCII, false, 1024*10);\n private static readonly StreamWriter writer = new StreamWriter(Console.OpenStandardOutput(1024*10), Encoding.ASCII, 1024*10);\n\n private static void Main(string[] args)\n {\n int p = Next();\n\n int count = 0;\n\n for (int i = 1; i < p; i++)\n {\n int k = 1;\n for (int j = 1; j < p; j++)\n {\n k = (k*i)%p;\n if (k == 1)\n {\n if (j == p - 1)\n {\n count++;\n }\n break;\n }\n }\n }\n\n writer.WriteLine(count);\n writer.Flush();\n }\n\n private static int Next()\n {\n int c;\n int res = 0;\n do\n {\n c = reader.Read();\n if (c == -1)\n return res;\n } while (c < '0' || c > '9');\n res = c - '0';\n while (true)\n {\n c = reader.Read();\n if (c < '0' || c > '9')\n return res;\n res *= 10;\n res += c - '0';\n }\n }\n }\n}", "lang_cluster": "C#", "tags": ["math", "implementation", "number theory"], "code_uid": "0df2f2a7da4d832b288345ef0616d847", "src_uid": "3bed682b6813f1ddb54410218c233cff", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\n\nnamespace Codeforces174_A\n{\n internal class Program\n {\n private static void Main(string[] args)\n {\n int p = int.Parse(Console.ReadLine());\n Console.WriteLine(Eiler(Eiler(p)));\n }\n\n private static int Eiler(int n)\n {\n if (n == 1) return 1;\n int upperBound = (int) Math.Sqrt(n) + 1;\n Dictionary canonical_rep = new Dictionary();\n for (int i = 2; i <= n; i++)\n while (n%i == 0 && n != 1)\n {\n if (canonical_rep.ContainsKey(i)) canonical_rep[i]++;\n else\n canonical_rep.Add(i, 1);\n n /= i;\n }\n int result = 1;\n foreach (var divisor in canonical_rep)\n {\n result *= (int) Math.Pow(divisor.Key, divisor.Value) - (int) Math.Pow(divisor.Key, divisor.Value - 1);\n }\n return result;\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "implementation", "number theory"], "code_uid": "28f77af8e2ac1a1d73aee9a0498957f4", "src_uid": "3bed682b6813f1ddb54410218c233cff", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.IO;\nusing System.Linq;\nclass Solution{\n\t static void Main(string[] args) {\n var tmp = Console.ReadLine().Split(' ');\n long d = long.Parse(tmp[0]);\n long k = long.Parse(tmp[1]);\n long a = long.Parse(tmp[2]);\n long b = long.Parse(tmp[3]);\n long t = long.Parse(tmp[4]);\n\n if (d <= k) {\n Console.WriteLine(a * d);\n return;\n }\n\n long ans = k * a + (d - k) * b;\n long low = 0, high = 1000000000000;\n while (high - low > 1) {\n long mid = (high + low) / 2;\n\n long center = Calc(d, k, a, b, t, mid);\n long center1 = Calc(d, k, a, b, t, mid + 1);\n long center_1 = Calc(d, k, a, b, t, mid - 1);\n\n if (center != -1) ans = Math.Min(ans, center);\n if (center1 != -1) ans = Math.Min(ans, center1);\n if (center_1 != -1) ans = Math.Min(ans, center_1);\n\n if (center1 == -1) {\n high = mid;\n } else {\n if (center1 > center) high = mid; else low = mid;\n }\n }\n Console.WriteLine(ans);\n\t }\n private static long Calc(long d, long k, long a, long b, long t, long mid) {\n long withCar = k * mid;\n\n long remaining = d - withCar;\n if (remaining < 0) {\n return -1;\n }\n\n long time = k * mid * a + Math.Max(0, (mid - 1)) * t;\n if (remaining <= k) return Math.Min(t+time + remaining * a, time + remaining * b);\n return time + remaining * b;\n }\n}", "lang_cluster": "C#", "tags": ["math"], "code_uid": "201899051467caf4786814ae7250892a", "src_uid": "359ddf1f1aed9b3256836e5856fe3466", "difficulty": 1900.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.IO;\nusing System.Text;\n\nnamespace Road_to_Post_Office\n{\n internal class Program\n {\n private static readonly StreamReader reader = new StreamReader(Console.OpenStandardInput(1024*10), Encoding.ASCII, false, 1024*10);\n private static readonly StreamWriter writer = new StreamWriter(Console.OpenStandardOutput(1024*10), Encoding.ASCII, 1024*10);\n\n private static void Main(string[] args)\n {\n long d = Next(), k = Next(), a = Next(), b = Next(), t = Next();\n\n long cycle = t + a*k;\n\n long ans;\n\n if (d <= k)\n {\n ans = a*d;\n }\n else\n {\n d -= k;\n ans = k*a;\n if (cycle < b*k)\n {\n ans += cycle*(d/k);\n d %= k;\n\n ans += Math.Min(d*b, t + a*d);\n }\n else\n {\n ans += b*d;\n }\n }\n\n writer.WriteLine(ans);\n writer.Flush();\n }\n\n private static long Next()\n {\n int c;\n long res = 0;\n do\n {\n c = reader.Read();\n if (c == -1)\n return res;\n } while (c < '0' || c > '9');\n res = c - '0';\n while (true)\n {\n c = reader.Read();\n if (c < '0' || c > '9')\n return res;\n res *= 10;\n res += c - '0';\n }\n }\n }\n}", "lang_cluster": "C#", "tags": ["math"], "code_uid": "0269598f020ed459ca43e2a8db87a900", "src_uid": "359ddf1f1aed9b3256836e5856fe3466", "difficulty": 1900.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Linq;\nusing System.Security.Cryptography;\nusing CompLib.Util;\n\npublic class Program\n{\n int N, K;\n string S;\n string T;\n public void Solve()\n {\n var sc = new Scanner();\n N = sc.NextInt();\n K = sc.NextInt();\n S = sc.Next();\n T = sc.Next();\n\n /*\n * s\u30682\u6587\u5b57t\n * \n * s\u306e\u4efb\u610f\u306e\u6587\u5b57\u3092\u3048\u3089\u3093\u3067\u5225\u306e\u6587\u5b57\u306b\u7f6e\u304d\u63db\u3048\u308b\n * \n * k\u56de\u307e\u3067\u64cd\u4f5c\n * t\u306e\u51fa\u73fe\u56de\u6570\u6700\u5927\n */\n\n if (T[0] == T[1])\n {\n int cnt = 0;\n foreach (var c in S)\n {\n if (c == T[0]) cnt++;\n }\n\n int max = Math.Min(cnt + K, N);\n\n Console.WriteLine((long)max * (max - 1) / 2);\n }\n else\n {\n\n // i\u307e\u3067\u898b\u308b\n // T[0]\u306e\u500b\u6570\n // \u5909\u66f4\u56de\u6570\n int[,,] dp = new int[N + 1, N + 1, K + 1];\n for (int i = 0; i <= N; i++)\n {\n for (int j = 0; j <= N; j++)\n {\n for (int k = 0; k <= K; k++)\n {\n dp[i, j, k] = int.MinValue;\n }\n }\n }\n\n dp[0, 0, 0] = 0;\n for (int i = 0; i < N; i++)\n {\n for (int j = 0; j <= N; j++)\n {\n for (int k = 0; k <= K; k++)\n {\n if (dp[i, j, k] == int.MinValue) continue;\n if (S[i] == T[0])\n {\n dp[i + 1, j + 1, k] = Math.Max(dp[i + 1, j + 1, k], dp[i, j, k]);\n }\n else if (k + 1 <= K)\n {\n dp[i + 1, j + 1, k + 1] = Math.Max(dp[i + 1, j + 1, k + 1], dp[i, j, k]);\n }\n\n if (S[i] == T[1])\n {\n dp[i + 1, j, k] = Math.Max(dp[i + 1, j, k], dp[i, j, k] + j);\n }\n else if (k + 1 <= K)\n {\n dp[i + 1, j, k + 1] = Math.Max(dp[i + 1, j, k + 1], dp[i, j, k] + j);\n }\n\n dp[i + 1, j, k] = Math.Max(dp[i + 1, j, k], dp[i, j, k]);\n }\n }\n }\n\n int ans = int.MinValue;\n for (int j = 0; j <= N; j++)\n {\n for (int k = 0; k <= K; k++)\n {\n ans = Math.Max(ans, dp[N, j, k]);\n }\n }\n\n Console.WriteLine(ans);\n }\n }\n\n public static void Main(string[] args) => new Program().Solve();\n}\n\nnamespace CompLib.Util\n{\n using System;\n using System.Linq;\n\n class Scanner\n {\n private string[] _line;\n private int _index;\n private const char Separator = ' ';\n\n public Scanner()\n {\n _line = new string[0];\n _index = 0;\n }\n\n public string Next()\n {\n if (_index >= _line.Length)\n {\n string s;\n do\n {\n s = Console.ReadLine();\n } while (s.Length == 0);\n\n _line = s.Split(Separator);\n _index = 0;\n }\n\n return _line[_index++];\n }\n\n public string ReadLine()\n {\n _index = _line.Length;\n return Console.ReadLine();\n }\n\n public int NextInt() => int.Parse(Next());\n public long NextLong() => long.Parse(Next());\n public double NextDouble() => double.Parse(Next());\n public decimal NextDecimal() => decimal.Parse(Next());\n public char NextChar() => Next()[0];\n public char[] NextCharArray() => Next().ToCharArray();\n\n public string[] Array()\n {\n string s = Console.ReadLine();\n _line = s.Length == 0 ? new string[0] : s.Split(Separator);\n _index = _line.Length;\n return _line;\n }\n\n public int[] IntArray() => Array().Select(int.Parse).ToArray();\n public long[] LongArray() => Array().Select(long.Parse).ToArray();\n public double[] DoubleArray() => Array().Select(double.Parse).ToArray();\n public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();\n }\n}\n", "lang_cluster": "C#", "tags": ["strings", "dp"], "code_uid": "2a1b7072f80eb029c7b9e6a1535b20ef", "src_uid": "9c700390ac13942cbde7c3428965b18a", "difficulty": 2100.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.IO;\nusing System.Linq;\nusing static System.Math;\nusing System.Text;\nusing System.Threading;\nusing System.Globalization;\nusing System.Runtime.CompilerServices;\nusing Library;\n\nnamespace Program\n{\n public static class ProblemF\n {\n static bool SAIKI = false;\n static public int numberOfRandomCases = 0;\n static public void MakeTestCase(List _input, List _output, ref Func _outputChecker)\n {\n }\n static public void Solve()\n {\n var n = NN;\n var k = NN;\n var s = NS;\n var t = NS;\n var dp = new long[n + 1, n + 2, k + 2];\n for (var i = 0; i <= n; i++)\n {\n for (var j = 0; j <= n; j++)\n {\n for (var x = 0; x <= k; x++)\n {\n dp[i, j, x] = long.MinValue;\n }\n }\n }\n dp[0, 0, 0] = 0;\n var ans = 0L;\n for (var i = 0; i < n; i++)\n {\n for (var j = 0; j <= n; j++)\n {\n for (var x = 0; x <= k; x++)\n {\n if (s[i] == t[0])\n {\n dp[i + 1, j + 1, x] = Max(dp[i + 1, j + 1, x], dp[i, j, x]);\n }\n if (s[i] == t[1])\n {\n dp[i + 1, j, x] = Max(dp[i + 1, j, x], dp[i, j, x] + j);\n }\n if (s[i] == t[0] && s[i] == t[1])\n {\n dp[i + 1, j + 1, x] = Max(dp[i + 1, j + 1, x], dp[i, j, x] + j);\n }\n if (t[0] == t[1])\n {\n dp[i + 1, j + 1, x + 1] = Max(dp[i + 1, j + 1, x + 1], dp[i, j, x] + j);\n }\n dp[i + 1, j, x + 1] = Max(dp[i + 1, j, x + 1], dp[i, j, x] + j);\n dp[i + 1, j + 1, x + 1] = Max(dp[i + 1, j + 1, x + 1], dp[i, j, x]);\n dp[i + 1, j, x] = Max(dp[i + 1, j, x], dp[i, j, x]);\n }\n }\n }\n for (var j = 0; j <= n + 1; j++)\n {\n for (var x = 0; x <= k; x++)\n {\n ans = Max(ans, dp[n, j, x]);\n }\n }\n Console.WriteLine(ans);\n }\n class Printer : StreamWriter\n {\n public override IFormatProvider FormatProvider { get { return CultureInfo.InvariantCulture; } }\n public Printer(Stream stream) : base(stream, new UTF8Encoding(false, true)) { base.AutoFlush = false; }\n public Printer(Stream stream, Encoding encoding) : base(stream, encoding) { base.AutoFlush = false; }\n }\n static LIB_FastIO fastio = new LIB_FastIODebug();\n static public void Main(string[] args) { if (args.Length == 0) { fastio = new LIB_FastIO(); Console.SetOut(new Printer(Console.OpenStandardOutput())); } if (SAIKI) { var t = new Thread(Solve, 134217728); t.Start(); t.Join(); } else Solve(); Console.Out.Flush(); }\n static long NN => fastio.Long();\n static double ND => fastio.Double();\n static string NS => fastio.Scan();\n static long[] NNList(long N) => Repeat(0, N).Select(_ => NN).ToArray();\n static double[] NDList(long N) => Repeat(0, N).Select(_ => ND).ToArray();\n static string[] NSList(long N) => Repeat(0, N).Select(_ => NS).ToArray();\n static long Count(this IEnumerable x, Func pred) => Enumerable.Count(x, pred);\n static IEnumerable Repeat(T v, long n) => Enumerable.Repeat(v, (int)n);\n static IEnumerable Range(long s, long c) => Enumerable.Range((int)s, (int)c);\n static IOrderedEnumerable OrderByRand(this IEnumerable x) => Enumerable.OrderBy(x, _ => xorshift);\n static IOrderedEnumerable OrderBy(this IEnumerable x) => Enumerable.OrderBy(x.OrderByRand(), e => e);\n static IOrderedEnumerable OrderBy(this IEnumerable x, Func selector) => Enumerable.OrderBy(x.OrderByRand(), selector);\n static IOrderedEnumerable OrderByDescending(this IEnumerable x) => Enumerable.OrderByDescending(x.OrderByRand(), e => e);\n static IOrderedEnumerable OrderByDescending(this IEnumerable x, Func selector) => Enumerable.OrderByDescending(x.OrderByRand(), selector);\n static IOrderedEnumerable OrderBy(this IEnumerable x) => x.OrderByRand().OrderBy(e => e, StringComparer.OrdinalIgnoreCase);\n static IOrderedEnumerable OrderBy(this IEnumerable x, Func selector) => x.OrderByRand().OrderBy(selector, StringComparer.OrdinalIgnoreCase);\n static IOrderedEnumerable OrderByDescending(this IEnumerable x) => x.OrderByRand().OrderByDescending(e => e, StringComparer.OrdinalIgnoreCase);\n static IOrderedEnumerable OrderByDescending(this IEnumerable x, Func selector) => x.OrderByRand().OrderByDescending(selector, StringComparer.OrdinalIgnoreCase);\n static string Join(this IEnumerable x, string separator = \"\") => string.Join(separator, x);\n static uint xorshift { get { _xsi.MoveNext(); return _xsi.Current; } }\n static IEnumerator _xsi = _xsc();\n static IEnumerator _xsc() { uint x = 123456789, y = 362436069, z = 521288629, w = (uint)(DateTime.Now.Ticks & 0xffffffff); while (true) { var t = x ^ (x << 11); x = y; y = z; z = w; w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)); yield return w; } }\n }\n}\nnamespace Library {\n class LIB_FastIO\n {\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public LIB_FastIO() { str = Console.OpenStandardInput(); }\n readonly Stream str;\n readonly byte[] buf = new byte[1024];\n int len, ptr;\n public bool isEof = false;\n public bool IsEndOfStream\n {\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n get { return isEof; }\n }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n byte read()\n {\n if (isEof) throw new EndOfStreamException();\n if (ptr >= len)\n {\n ptr = 0;\n if ((len = str.Read(buf, 0, 1024)) <= 0)\n {\n isEof = true;\n return 0;\n }\n }\n return buf[ptr++];\n }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n char Char()\n {\n byte b = 0;\n do b = read();\n while (b < 33 || 126 < b);\n return (char)b;\n }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n virtual public string Scan()\n {\n var sb = new StringBuilder();\n for (var b = Char(); b >= 33 && b <= 126; b = (char)read())\n sb.Append(b);\n return sb.ToString();\n }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n virtual public long Long()\n {\n long ret = 0; byte b = 0; var ng = false;\n do b = read();\n while (b != '-' && (b < '0' || '9' < b));\n if (b == '-') { ng = true; b = read(); }\n for (; true; b = read())\n {\n if (b < '0' || '9' < b)\n return ng ? -ret : ret;\n else ret = ret * 10 + b - '0';\n }\n }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n virtual public double Double() { return double.Parse(Scan(), CultureInfo.InvariantCulture); }\n }\n class LIB_FastIODebug : LIB_FastIO\n {\n Queue param = new Queue();\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n string NextString() { if (param.Count == 0) foreach (var item in Console.ReadLine().Split(' ')) param.Enqueue(item); return param.Dequeue(); }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public LIB_FastIODebug() { }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public override string Scan() => NextString();\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public override long Long() => long.Parse(NextString());\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public override double Double() => double.Parse(NextString());\n }\n}\n", "lang_cluster": "C#", "tags": ["strings", "dp"], "code_uid": "414e24fe74400b1263786c1f155279fd", "src_uid": "9c700390ac13942cbde7c3428965b18a", "difficulty": 2100.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Diagnostics;\nusing System.Globalization;\nusing System.IO;\nusing System.Linq;\nusing System.Text;\nusing System.Xml.Schema;\n\nnamespace Codeforces\n{\n internal static class Program\n {\n private const string Problem = \"c\";\n\n private static void Solve()\n {\n int n, k, d;\n Read(out n, out k, out d);\n var mod = 1000000007;\n var dp = new int[n + 1, 2];\n dp[0, 0] = 1;\n\n for (int i = 1; i <= n; i++)\n {\n var maxJ = Math.Min(k, i);\n for (int j = 1; j <= maxJ; j++)\n {\n dp[i, 0] += dp[i - j, 0]%mod;\n dp[i, 0] %= mod;\n if (j >= d)\n {\n dp[i, 1] += dp[i - j, 0]%mod;\n dp[i, 1] %= mod;\n }\n else\n {\n dp[i, 1] += dp[i - j, 1] % mod;\n dp[i, 1] %= mod;\n }\n }\n }\n WriteLine(dp[n, 1]);\n }\n\n private static void Main()\n {\n var isDebbuger = Debugger.IsAttached;\n if (isDebbuger)\n {\n var projectPath = Directory.GetParent(Environment.CurrentDirectory).Parent;\n var testsPath = Path.Combine(projectPath != null? projectPath.FullName: \"\", \"tests\");\n var files = Directory.GetFiles(testsPath, string.Format(\"{0}*.in\", Problem));\n\n foreach (var file in files)\n {\n Console.SetIn(new StreamReader(file));\n Console.WriteLine(Path.GetFileNameWithoutExtension(file));\n Solve();\n\n Console.WriteLine();\n\n Console.In.Close();\n Console.SetIn(new StreamReader(Console.OpenStandardInput()));\n }\n\n Console.ReadLine();\n } \n else\n Solve();\n }\n\n private static int[] SortIndexs(this IEnumerable source) where T : IComparable\n {\n var array = source == null ? new List() : source.ToList();\n var n = array.Count;\n var res = Enumerable.Range(0, n).ToArray();\n Array.Sort(res, (a, b) =>\n {\n var compare = array[a].CompareTo(array[b]);\n return compare == 0 ? a.CompareTo(b) : compare;\n });\n return res;\n }\n\n #region Reader\n\n private static string Read()\n {\n return Console.ReadLine();\n }\n\n private static void Read(out T a1, out T a2)\n {\n var input = ReadArray();\n a1 = (T)Convert.ChangeType(input[0], typeof(T));\n a2 = (T)Convert.ChangeType(input[1], typeof(T));\n }\n\n private static void Read(out T a1, out T a2, out T a3)\n {\n var input = ReadArray();\n a1 = (T)Convert.ChangeType(input[0], typeof(T));\n a2 = (T)Convert.ChangeType(input[1], typeof(T));\n a3 = (T)Convert.ChangeType(input[2], typeof(T));\n }\n\n private static void Read(out T a1, out T a2, out T a3, out T a4)\n {\n var input = ReadArray();\n a1 = (T)Convert.ChangeType(input[0], typeof(T));\n a2 = (T)Convert.ChangeType(input[1], typeof(T));\n a3 = (T)Convert.ChangeType(input[2], typeof(T));\n a4 = (T)Convert.ChangeType(input[3], typeof(T));\n }\n\n private static void Read(out T a1, out T a2, out T a3, out T a4, out T a5)\n {\n var input = ReadArray();\n a1 = (T)Convert.ChangeType(input[0], typeof(T));\n a2 = (T)Convert.ChangeType(input[1], typeof(T));\n a3 = (T)Convert.ChangeType(input[2], typeof(T));\n a4 = (T)Convert.ChangeType(input[3], typeof(T));\n a5 = (T)Convert.ChangeType(input[4], typeof(T));\n }\n\n private static void Read(out T a1, out T a2, out T a3, out T a4, out T a5, out T a6)\n {\n var input = ReadArray();\n a1 = (T)Convert.ChangeType(input[0], typeof(T));\n a2 = (T)Convert.ChangeType(input[1], typeof(T));\n a3 = (T)Convert.ChangeType(input[2], typeof(T));\n a4 = (T)Convert.ChangeType(input[3], typeof(T));\n a5 = (T)Convert.ChangeType(input[4], typeof(T));\n a6 = (T)Convert.ChangeType(input[5], typeof(T));\n }\n\n private static int ReadInt()\n {\n return Int32.Parse(Read());\n }\n\n private static long ReadLong()\n {\n return long.Parse(Read());\n }\n\n private static double ReadDouble()\n {\n return double.Parse(Read(), CultureInfo.InvariantCulture);\n }\n\n private static T Read()\n {\n return (T)Convert.ChangeType(Read(), typeof(T));\n }\n\n private static string[] ReadArray()\n {\n var readLine = Console.ReadLine();\n if (readLine != null)\n return readLine.Split(' ');\n\n throw new ArgumentException();\n }\n\n private static List ReadIntArray()\n {\n return ReadArray().Select(Int32.Parse).ToList();\n }\n\n private static List ReadLongArray()\n {\n return ReadArray().Select(long.Parse).ToList();\n }\n\n private static List ReadDoubleArray()\n {\n return ReadArray().Select(d => double.Parse(d, CultureInfo.InvariantCulture)).ToList();\n }\n\n private static List ReadArray()\n {\n return ReadArray().Select(x => (T)Convert.ChangeType(x, typeof(T))).ToList();\n }\n\n private static void WriteLine(double value)\n {\n Console.WriteLine(value.ToString(CultureInfo.InvariantCulture));\n }\n\n private static void WriteLine(double value, string stringFormat)\n {\n Console.WriteLine(value.ToString(stringFormat, CultureInfo.InvariantCulture));\n }\n\n private static void WriteLine(T value)\n {\n Console.WriteLine(value);\n }\n\n private static void Write(double value)\n {\n Console.Write(value.ToString(CultureInfo.InvariantCulture));\n }\n\n private static void Write(double value, string stringFormat)\n {\n Console.Write(value.ToString(stringFormat, CultureInfo.InvariantCulture));\n }\n\n private static void Write(T value)\n {\n Console.Write(value);\n }\n\n #endregion\n }\n}", "lang_cluster": "C#", "tags": ["dp", "implementation", "trees"], "code_uid": "db47e6d1761870347b1e0502795e6325", "src_uid": "894a58c9bba5eba11b843c5c5ca0025d", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\n\nnamespace ConsoleApplication3\n{\n internal class Program\n {\n private static void Main()\n {\n var input = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();\n var n = input[0];\n var k = input[1];\n var d = input[2];\n\n Console.WriteLine(Solve(n, k, d, false, new Cache()));\n }\n\n private static int Solve(int n, int k, int d, bool hasD, Cache cache)\n {\n var key = new Tuple(n, hasD);\n if (cache.ContainsKey(key))\n return cache[key];\n if (n == 0)\n return hasD ? 1 : 0;\n\n var res = 0;\n for (var i = 1; i <= Math.Min(n, k); i++)\n res = (res + Solve(n - i, k, d, hasD | i >= d, cache))%1000000007;\n\n return cache[key] = res;\n }\n\n class Cache : Dictionary, int>\n {\n \n }\n }\n}\n", "lang_cluster": "C#", "tags": ["dp", "implementation", "trees"], "code_uid": "e5ff1571999ee32cd343166fcf3bfedd", "src_uid": "894a58c9bba5eba11b843c5c5ca0025d", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\n\nnamespace Codeforces_247_2\n{\n class Program\n {\n static long[,] cache;\n static long Count(int n, int k)\n {\n long ret = cache[n, k];\n if (ret < 0)\n {\n ret = 0;\n for (int i = 1; i <= k; ++i) {\n if (n > i) {\n ret = (ret + Count(n - i, k)) % 1000000007;\n }\n else if (n == i) {\n ret = ret + 1;\n }\n }\n cache[n, k] = ret;\n }\n return ret;\n }\n static void Main(string[] args)\n {\n string[] s = Console.ReadLine().Split(' ');\n int n = int.Parse(s[0]);\n int k = int.Parse(s[1]);\n int d = int.Parse(s[2]);\n cache = new long[n + 1, k + 1];\n for (int i = 0; i <= n; ++i) for (int j = 0; j <= k; ++j) cache[i, j] = -1;\n Console.WriteLine((1000000007 + Count(n, k) - Count(n, d - 1)) % 1000000007);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["dp", "implementation", "trees"], "code_uid": "7196bbea1f85552c9f45f36094997bf6", "src_uid": "894a58c9bba5eba11b843c5c5ca0025d", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.IO;\nusing System.Text;\n\nnamespace k_Tree\n{\n internal class Program\n {\n private const long TTT = 1000000007;\n\n private static readonly StreamReader reader =\n new StreamReader(Console.OpenStandardInput(1024*10), Encoding.ASCII, false, 1024*10);\n\n private static readonly StreamWriter writer =\n new StreamWriter(Console.OpenStandardOutput(1024*10), Encoding.ASCII, 1024*10);\n\n private static void Main(string[] args)\n {\n string[] ss = reader.ReadLine().Split(' ');\n int n = int.Parse(ss[0]);\n int k = int.Parse(ss[1]);\n int d = int.Parse(ss[2]);\n\n var kgood = new long[n + 1];\n var kbad = new long[n + 1];\n long sum = 0;\n for (int i = 1; i <= k && i <= n; i++)\n {\n if (i >= d)\n {\n kgood[i] = 1;\n }\n else\n kbad[i] = 1;\n }\n sum = (sum + kgood[n])%TTT;\n\n for (int j = 1; j <= n; j++)\n {\n var kgood1 = new long[n + 1];\n var kbad1 = new long[n + 1];\n\n for (int i = 1; i <= n; i++)\n {\n for (int l = 1; l <= k; l++)\n {\n if (i + l > n)\n break;\n\n kgood1[l + i] += kgood[i];\n if (l >= d)\n {\n kgood1[l + i] += kbad[i];\n }\n else\n {\n kbad1[l + i] += kbad[i];\n }\n }\n }\n sum = (sum + kgood1[n])%TTT;\n for (int i = 1; i <= n; i++)\n {\n kbad[i] = kbad1[i]%TTT;\n kgood[i] = kgood1[i]%TTT;\n }\n }\n\n writer.WriteLine(\"{0}\", sum);\n writer.Flush();\n }\n }\n}", "lang_cluster": "C#", "tags": ["dp", "implementation", "trees"], "code_uid": "3c53a89fc513d26a7a3ffef45dc0bb09", "src_uid": "894a58c9bba5eba11b843c5c5ca0025d", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\n\nclass C431 {\n const int M = 1000000007;\n\n public static void Main() {\n var line = Console.ReadLine().Split();\n var n = int.Parse(line[0]);\n var k = int.Parse(line[1]);\n var d = int.Parse(line[2]);\n var a = new long[n + 1];\n var b = new long[n + 1];\n a[0] = 1L;\n b[0] = 0L;\n for (int i = 1; i <= n; ++i) {\n var a1 = i - k >= 1 ? a[i - k - 1] : 0L;\n var a2 = i >= d ? a[i - d] : 0L;\n var b2 = i >= d ? b[i - d] : 0L;\n a[i] = (a[i - 1] + (a[i - 1] + M - a1)) % M;\n b[i] = (b[i - 1] + (b[i - 1] + M - b2) + (a2 + M - a1)) % M;\n }\n Console.WriteLine((b[n] + M - b[n - 1]) % M);\n }\n}\n", "lang_cluster": "C#", "tags": ["dp", "implementation", "trees"], "code_uid": "d4dc598cee5b252b0e0c1c1e353a394f", "src_uid": "894a58c9bba5eba11b843c5c5ca0025d", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace ConsoleApplication34\n{\n\n class Program\n {\n static void Main(string[] args)\n {\n int i = 1;\n string[] arr = Console.ReadLine().Split();\n int a = int.Parse(arr[0]);\n int b = int.Parse(arr[1]);\n a = a * 100;\n b = b * 10;\n while (true)\n {\n\n if (i % 2 != 0)\n {\n if (a >= 200)\n {\n if (b >= 20)\n {\n a -= 200;\n b -= 20;\n }\n else\n {\n Console.WriteLine(\"Hanako\");return;\n }\n }\n else if (a == 100)\n {\n\n if (b >= 120)\n {\n a -= 100;\n b -= 120;\n }\n else\n {\n Console.WriteLine(\"Hanako\"); return;\n }\n }\n else if (a < 100)\n {\n if (b >= 220)\n b -= 220;\n else\n {\n Console.WriteLine(\"Hanako\"); return;\n }\n }\n }\n\n if (i % 2 == 0)\n {\n if (b >= 220)\n {\n b -= 220;\n }\n else if (b < 220 && b >= 120)\n {\n if (a >= 100)\n {\n a -= 100;\n b -= 120;\n }\n else\n {\n Console.WriteLine(\"Ciel\"); return;\n }\n }\n else if (b >= 20)\n {\n if (a >= 200)\n {\n a -= 200;\n b -= 20;\n }\n else\n {\n Console.WriteLine(\"Ciel\"); return;\n }\n }\n else\n {\n Console.WriteLine(\"Ciel\"); return;\n }\n }\n i++;\n }\n \n }\n\n\n\n }\n }\n", "lang_cluster": "C#", "tags": ["greedy"], "code_uid": "a5d124d59d68fc553f0b9a6a0054ef53", "src_uid": "8ffee18bbc4bb281027f91193002b7f5", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Text;\n\nnamespace A.Theatre_Square\n{\n class Program\n {\n\n\n static void Main(string[] args)\n {\n int[,] step = { { 2, 2 }, { 1, 12 }, { 0, 22 } };\n string[] data = Console.ReadLine().Split(' ');\n int n = Int32.Parse(data[0]);\n int m = Int32.Parse(data[1]);\n bool isEnd = false;\n bool turn = false;\n while (!isEnd)\n {\n if (!turn)\n {\n for (int i = 0; i < 3; i++)\n {\n\n if (n >= step[i, 0] && m >= step[i, 1])\n {\n n -= step[i, 0];\n m -= step[i, 1];\n goto next;\n }\n \n }\n isEnd = true;\n }\n else\n {\n for (int i = 2; i >=0; i--)\n {\n\n if (n >= step[i, 0] && m >= step[i, 1])\n {\n n -= step[i, 0];\n m -= step[i, 1];\n goto next;\n }\n \n }\n isEnd = true;\n }\n next: turn = !turn;\n }\n\n if (turn)\n {\n Console.WriteLine(\"Hanako\");\n }\n else\n {\n Console.WriteLine(\"Ciel\");\n }\n Console.ReadKey();\n }\n\n }\n}\n", "lang_cluster": "C#", "tags": ["greedy"], "code_uid": "5762758441aecdeb793fb64fce853e02", "src_uid": "8ffee18bbc4bb281027f91193002b7f5", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Text;\nusing System.Collections.Generic;\nusing System.Linq;\nclass Solve{\n public Solve(){}\n StringBuilder sb;\n ReadData re;\n public static int Main(){\n new Solve().Run();\n return 0;\n }\n void Run(){\n sb = new StringBuilder();\n re = new ReadData();\n Calc();\n Console.Write(sb.ToString());\n }\n void Calc(){\n long H = re.l();\n long W = re.l(); \n if(H == 1 || W == 1){\n H = Math.Max(H,W);\n long count = H / 6 * 6;\n if(H % 6 == 4){\n count += 2;\n }\n if(H % 6 == 5){\n count += 4;\n }\n sb.Append(count + \"\\n\");\n return;\n }\n if(H >= 3 && W >= 3){\n sb.Append(H*W/2*2+\"\\n\");\n return;\n }\n if(H != 2){\n W = H;\n H = 2;\n }\n if(W == 2){\n sb.Append(\"0\\n\");\n return;\n }\n else if(W == 3){\n sb.Append(\"4\\n\");\n return;\n }\n else if(W == 7){\n sb.Append(\"12\\n\");\n return;\n }\n sb.Append((W*2)+\"\\n\");\n }\n}\nclass PrimeFactor{\n int[] LowestPrimeFactor;\n public int[] Prime;\n int N;\n public PrimeFactor(int N0){\n N = N0;\n N++;\n LowestPrimeFactor = new int[N];\n List prime = new List();\n for(int i=1;i ans = new List();\n while(X != 1){\n ans.Add(LowestPrimeFactor[X]);\n X /= LowestPrimeFactor[X];\n }\n return ans.ToArray();\n }\n public int[] PrimeDivide(long X0){\n List ans = new List();\n int X = (int)X0;\n int i=0;\n while(X >= N){\n if(X % Prime[i] == 0){\n ans.Add(Prime[i]);\n X /= Prime[i];\n }\n else{\n i++;\n if(i == Prime.Length){\n ans.Add(X);\n X = 1;\n }\n }\n }\n while(X != 1){\n ans.Add(LowestPrimeFactor[X]);\n X /= LowestPrimeFactor[X];\n }\n return ans.ToArray();\n }\n public int[] Divisor(int X){\n List ans = new List();\n ans.Add(1);\n while(X != 1){\n int p = LowestPrimeFactor[X];\n int c = 0;\n while(X % p == 0){\n X /= p;\n c++;\n }\n int l = ans.Count;\n int d = p;\n for(int i=1;i<=c;i++){\n for(int j=0;j ans = new List();\n int X = (int)X0;\n ans.Add(1);\n int i=0;\n while(X >= N){\n if(X % Prime[i] == 0){\n int p = Prime[i];\n int c = 0;\n while(X % p == 0){\n X /= p;\n c++;\n }\n int l = ans.Count;\n int d = p;\n for(int k=1;k<=c;k++){\n for(int j=0;j= N){\n if(X % Prime[i] == 0){\n int p = Prime[i];\n while(X % p == 0){\n X /= p;\n }\n ans /= p;\n ans *= p-1;\n }\n else{\n i++;\n if(i == Prime.Length){\n int p = X;\n ans /= p;\n ans *= p-1;\n X = 1;\n }\n }\n }\n while(X != 1){\n int p = LowestPrimeFactor[X];\n while(X % p == 0){\n X /= p;\n }\n ans /= p;\n ans *= p-1;\n }\n return ans;\n }\n}\nclass ReadData{\n string[] str;\n int counter;\n public ReadData(){\n counter = 0;\n }\n public string s(){\n if(counter == 0){\n str = Console.ReadLine().Split(' ');\n counter = str.Length;\n }\n counter--;\n return str[str.Length-counter-1];\n }\n public int i(){\n return int.Parse(s());\n }\n public long l(){\n return long.Parse(s());\n }\n public double d(){\n return double.Parse(s());\n }\n public int[] ia(int N){\n int[] ans = new int[N];\n for(int j=0;j[] g(int N,int[] f,int[] t){\n List[] ans = new List[N];\n for(int j=0;j();\n }\n for(int j=0;j[] g(int N,int M){\n List[] ans = new List[N];\n for(int j=0;j();\n }\n for(int j=0;j[] g(){\n int N = i();\n int M = i();\n List[] ans = new List[N];\n for(int j=0;j();\n }\n for(int j=0;j= len + 1)\n {\n res += go(rem - 1, nwho, nlen, nlen);\n }\n else\n {\n if (nlen + oks < len + 1)\n continue;\n res += go(rem - 1, nwho, nlen, oks - (len + 1 - nlen));\n }\n if (res >= mod)\n res -= mod;\n }\n return dp[rem, who, len, oks] = res;\n }\n\n ////////////\n private void println(int[] ar)\n {\n for (int i = 0; i < ar.Length; i++)\n {\n if (i == ar.Length - 1)\n println(ar[i]);\n else\n print(ar[i] + \" \");\n }\n }\n private void println(int[] ar, bool add)\n {\n int A = 0;\n if (add)\n A++;\n for (int i = 0; i < ar.Length; i++)\n {\n if (i == ar.Length - 1)\n println(ar[i] + A);\n else\n print((ar[i] + A) + \" \");\n }\n }\n\n private void println(string Stringst)\n {\n Console.WriteLine(Stringst);\n }\n private void println(char charnum)\n {\n Console.WriteLine(charnum);\n }\n private void println(int Intnum)\n {\n Console.WriteLine(Intnum);\n }\n private void println(long Longnum)\n {\n Console.WriteLine(Longnum);\n }\n private void println(double Doublenum)\n {\n string s = Doublenum.ToString(CultureInfo.InvariantCulture);\n Console.WriteLine(s);\n }\n\n private void print(string Stringst)\n {\n Console.Write(Stringst);\n }\n private void print(int Intnum)\n {\n Console.Write(Intnum);\n }\n private void print(char charnum)\n {\n Console.Write(charnum);\n }\n private void print(long Longnum)\n {\n Console.Write(Longnum);\n }\n private void print(double Doublenum)\n {\n Console.Write(Doublenum);\n }\n\n\n string[] inputLine = new string[0];\n int inputInd = 0;\n string nextLine()\n {\n return Console.ReadLine();\n }\n void readInput()\n {\n if (inputInd != inputLine.Length)\n throw new Exception();\n inputInd = 0;\n inputLine = Console.ReadLine().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);\n if (inputLine.Length == 0)\n readInput();\n\n }\n int nextInt()\n {\n if (inputInd == inputLine.Length)\n readInput();\n return int.Parse(inputLine[inputInd++]);\n }\n long nextLong()\n {\n if (inputInd == inputLine.Length)\n readInput();\n return long.Parse(inputLine[inputInd++]);\n }\n double nextDouble()\n {\n if (inputInd == inputLine.Length)\n readInput();\n return double.Parse(inputLine[inputInd++]);\n }\n string nextString()\n {\n if (inputInd == inputLine.Length)\n readInput();\n return inputLine[inputInd++];\n }\n static void Main(string[] args)\n {\n Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;\n new Program().solve();\n }\n}", "lang_cluster": "C#", "tags": ["strings", "dp", "trees"], "code_uid": "ad617ec5e4227bad3dc47f1e6837cf66", "src_uid": "3f053c07deaac55c2c51df6147080340", "difficulty": 2500.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text.RegularExpressions;\nusing System.Threading.Tasks;\n\nnamespace ConsoleApp12\n{\n class Program\n {\n static int[] SAI(string input, char sep = ' ')\n {\n return input.Split(sep).Select(x => int.Parse(x)).ToArray();\n }\n\n static int[] SAI(string input, string sep)\n {\n return new Regex(sep).Split(input).Select(x => int.Parse(x)).ToArray();\n }\n\n static long[] AI(char sep = ' ')\n {\n return Console.ReadLine().Split(sep).Select(x => long.Parse(x)).ToArray();\n }\n\n static uint[] AI(string sep)\n {\n return new Regex(sep).Split(Console.ReadLine()).Select(x => uint.Parse(x)).ToArray();\n }\n\n static List LI(char sep = ' ')\n {\n return Console.ReadLine().Split(sep).Select(x => int.Parse(x)).ToList();\n }\n\n static Int64[] AI64(char sep = ' ')\n {\n return Console.ReadLine().Split(sep).Select(x => Int64.Parse(x)).ToArray();\n }\n\n static List LI64(char sep = ' ')\n {\n return Console.ReadLine().Split(sep).Select(x => Int64.Parse(x)).ToList();\n }\n\n static void Main(string[] args)\n {\n var a = AI();\n if (a[1] == 1)\n {\n Console.Write(a[0]);\n return;\n }\n long result = 0;\n while (a[0] > 0)\n {\n result = result << 1;\n ++result;\n a[0] = a[0] >> 1;\n }\n Console.WriteLine(result);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["constructive algorithms", "number theory", "bitmasks"], "code_uid": "4e6e90e361e41f2ecdcb1627b05f36aa", "src_uid": "16bc089f5ef6b68bebe8eda6ead2eab9", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Diagnostics;\nusing System.IO;\nusing System.Linq;\nusing System.Numerics;\nusing System.Text;\n\nnamespace CodeforcesTemplate\n{\n public static class Permutation\n {\n private static bool Next(ref int[] arr)\n {\n int k, j, l;\n for (j = arr.Length - 2; (j >= 0) && (arr[j] >= arr[j + 1]); j--) { }\n if (j == -1)\n {\n arr = arr.OrderBy(c => c).ToArray();\n return false;\n }\n for (l = arr.Length - 1; (arr[j] >= arr[l]) && (l >= 0); l--) { }\n var tmp = arr[j];\n arr[j] = arr[l];\n arr[l] = tmp;\n for (k = j + 1, l = arr.Length - 1; k < l; k++, l--)\n {\n tmp = arr[k];\n arr[k] = arr[l];\n arr[l] = tmp;\n }\n return true;\n }\n public static IEnumerable AllPermutations(int[] arr)\n {\n do yield return arr;\n while (Next(ref arr));\n }\n }\n\n class Program\n {\n private const string FILENAME = \"distance4\";\n\n private const string INPUT = FILENAME + \".in\";\n\n private const string OUTPUT = FILENAME + \".out\";\n\n private static Stopwatch _stopwatch = new Stopwatch();\n\n private static StreamReader _reader = null;\n private static StreamWriter _writer = null;\n\n private static string[] _curLine;\n private static int _curTokenIdx;\n\n private static char[] _whiteSpaces = new char[] { ' ', '\\t', '\\r', '\\n' };\n\n private static string ReadNextToken()\n {\n if (_curTokenIdx >= _curLine.Length)\n {\n //Read next line\n string line = _reader.ReadLine();\n if (line != null)\n _curLine = line.Split(_whiteSpaces, StringSplitOptions.RemoveEmptyEntries);\n else\n _curLine = new string[] { };\n _curTokenIdx = 0;\n }\n\n if (_curTokenIdx >= _curLine.Length)\n return null;\n\n return _curLine[_curTokenIdx++];\n }\n\n private static int ReadNextInt()\n {\n return int.Parse(ReadNextToken());\n }\n\n private static void RunTimer()\n {\n#if (DEBUG)\n\n _stopwatch.Start();\n\n#endif\n }\n\n private static void Main(string[] args)\n {\n\n#if (DEBUG)\n double before = GC.GetTotalMemory(false);\n#endif\n\n long[] arr = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();\n\n long n = arr[0];\n\n long k = arr[1];\n\n if (k == 1)\n {\n Console.WriteLine(n);\n return;\n }\n long answer = 1;\n\n while (answer <= n)\n {\n answer <<= 1;\n }\n\n Console.WriteLine(answer - 1);\n\n\n\n#if (DEBUG)\n _stopwatch.Stop();\n\n double after = GC.GetTotalMemory(false);\n\n double consumedInMegabytes = (after - before) / (1024 * 1024);\n\n Console.WriteLine($\"Time elapsed: {_stopwatch.Elapsed}\");\n\n Console.WriteLine($\"Consumed memory (MB): {consumedInMegabytes}\");\n\n Console.ReadKey();\n#endif\n\n\n }\n\n private static int CountLeadZeros(string source)\n {\n int countZero = 0;\n\n for (int i = source.Length - 1; i >= 0; i--)\n {\n if (source[i] == '0')\n {\n countZero++;\n }\n\n else\n {\n break;\n }\n\n }\n\n return countZero;\n }\n\n private static string ReverseString(string source)\n {\n char[] reverseArray = source.ToCharArray();\n\n Array.Reverse(reverseArray);\n\n string reversedString = new string(reverseArray);\n\n return reversedString;\n }\n\n\n private static int[] CopyOfRange(int[] src, int start, int end)\n {\n int len = end - start;\n int[] dest = new int[len];\n Array.Copy(src, start, dest, 0, len);\n return dest;\n }\n\n private static string StreamReader()\n {\n\n if (_reader == null)\n _reader = new StreamReader(INPUT);\n string response = _reader.ReadLine();\n if (_reader.EndOfStream)\n _reader.Close();\n return response;\n\n\n }\n\n private static void StreamWriter(string text)\n {\n\n if (_writer == null)\n _writer = new StreamWriter(OUTPUT);\n _writer.WriteLine(text);\n\n\n }\n\n\n\n\n\n private static int BFS(int start, int end, int[,] arr)\n {\n Queue> queue = new Queue>();\n List visited = new List();\n for (int i = 0; i < arr.GetLength(0); i++)\n {\n visited.Add(false);\n }\n\n queue.Enqueue(new KeyValuePair(start, 0));\n KeyValuePair node;\n int level = 0;\n bool flag = false;\n\n while (queue.Count != 0)\n {\n node = queue.Dequeue();\n if (node.Key == end)\n {\n return node.Value;\n }\n flag = false;\n for (int i = 0; i < arr.GetLength(0); i++)\n {\n\n if (arr[node.Key, i] == 1)\n {\n if (visited[i] == false)\n {\n if (!flag)\n {\n level = node.Value + 1;\n flag = true;\n }\n queue.Enqueue(new KeyValuePair(i, level));\n visited[i] = true;\n }\n }\n }\n\n }\n return 0;\n\n }\n\n\n\n private static void Write(string source)\n {\n File.WriteAllText(OUTPUT, source);\n }\n\n private static string ReadString()\n {\n return File.ReadAllText(INPUT);\n }\n\n private static void WriteStringArray(string[] source)\n {\n File.WriteAllLines(OUTPUT, source);\n }\n\n private static string[] ReadStringArray()\n {\n return File.ReadAllLines(INPUT);\n }\n\n private static int[] GetIntArray()\n {\n return ReadString().Split(' ').Select(int.Parse).ToArray();\n }\n\n private static double[] GetDoubleArray()\n {\n return ReadString().Split(' ').Select(double.Parse).ToArray();\n }\n\n private static int[,] ReadINT2XArray(List lines)\n {\n int[,] arr = new int[lines.Count, lines.Count];\n\n for (int i = 0; i < lines.Count; i++)\n {\n int[] row = lines[i].Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(int.Parse).ToArray();\n\n for (int j = 0; j < lines.Count; j++)\n {\n arr[i, j] = row[j];\n }\n }\n\n return arr;\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["constructive algorithms", "number theory", "bitmasks"], "code_uid": "e7b9c5e405ac5fbec6772a9a89c836d1", "src_uid": "16bc089f5ef6b68bebe8eda6ead2eab9", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Text;\nusing System.Linq;\nusing System.IO;\nusing System.Globalization;\nusing System.Collections;\n\nusing Pair = System.Collections.Generic.KeyValuePair;\n\nnamespace Task\n{\n internal class Program\n {\n int cnt = 0;\n Dictionary data = new Dictionary();\n bool[,] was = new bool[100, 100];\n\n long xfx(int x, int y, long z)\n {\n if (x == -1)\n return 0;\n if (z == 0)\n return 0;\n if (y == 1)\n {\n if (x == 0)\n return 1;\n return 0;\n }\n\n var key = new Pair((x << 16) | y, z);\n\n if (data.ContainsKey(key))\n return data[key];\n\n long hsize = getSize(y - 1);\n\n long ans = 0;\n\n if (z >= hsize)\n {\n long temp1 = xfx(x, y - 1, hsize);\n long temp2 = xfx(x - 1, y - 1, z - hsize);\n ans += temp1 + temp2;\n }\n else\n {\n long temp = xfx(x, y - 1, z);\n ans += temp;\n }\n\n data[key] = ans;\n return ans;\n }\n\n\n\n long getSize(int y)\n {\n return 1L << (y - 1);\n }\n\n long get(int x, long z)\n {\n long ans = 0;\n\n int num = 1;\n while (z > 0)\n {\n long size = getSize(num);\n long temp = xfx(x, num, Math.Min(size, z));\n \n z -= size;\n ans += temp;\n\n num++;\n }\n\n return ans;\n\n }\n\n private void Solve()\n {\n long n = io.NextLong();\n long t = io.NextLong();\n\n long x = 1;\n int p = 0;\n\n while (x < t)\n {\n x <<= 1;\n p++;\n }\n\n if (x != t)\n {\n io.Print(0);\n return;\n }\n\n long ans = get(p, n + 1);\n if (t == 1)\n ans--;\n io.Print(ans);\n\n\n }\n\n #region Program\n\n private readonly MyIo io;\n\n public Program(MyIo io)\n {\n this.io = io;\n }\n\n public static void Main(string[] args)\n {\n using (MyIo io = new MyIo())\n {\n new Program(io).Solve();\n }\n }\n\n #endregion\n }\n\n #region MyIo\n\n internal class MyIo : IDisposable\n {\n private readonly TextReader inputStream;\n private readonly TextWriter outputStream = Console.Out;\n\n private string[] tokens;\n private int pointer;\n\n public MyIo()\n#if LOCAL_TEST\n : this(new StreamReader(\"..\\\\..\\\\input.txt\"))\n#else\n : this(System.Console.In)\n#endif\n {\n\n }\n\n public MyIo(TextReader inputStream)\n {\n this.inputStream = inputStream;\n }\n\n public string NextLine()\n {\n try\n {\n return inputStream.ReadLine();\n }\n catch (IOException)\n {\n return null;\n }\n }\n\n public string NextString()\n {\n try\n {\n while (tokens == null || pointer >= tokens.Length)\n {\n tokens = NextLine().Split(new char[] { ' ', '\\t' }, StringSplitOptions.RemoveEmptyEntries);\n pointer = 0;\n }\n return tokens[pointer++];\n }\n catch (IOException)\n {\n return null;\n }\n }\n\n public int NextInt()\n {\n return Next();\n }\n\n public long NextLong()\n {\n return Next();\n }\n\n public T Next()\n {\n return (T)Convert.ChangeType(NextString(), typeof(T));\n }\n\n\n public IEnumerable NextSeq(int n)\n {\n for (int i = 0; i < n; i++)\n yield return Next();\n }\n\n public void Print(string format, params object[] args)\n {\n outputStream.Write(string.Format(CultureInfo.InvariantCulture, format, args));\n }\n\n public void PrintLine(string format, params object[] args)\n {\n Print(format, args);\n\n outputStream.WriteLine();\n }\n\n public void Print(bool o)\n {\n Print(o ? \"YES\" : \"NO\");\n }\n\n public void PrintLine(bool o)\n {\n PrintLine(o ? \"YES\" : \"NO\");\n }\n\n public void Print(T o)\n {\n outputStream.Write(o);\n }\n\n\n public void PrintLine(T o)\n {\n outputStream.WriteLine(o);\n }\n\n public void Close()\n {\n inputStream.Close();\n outputStream.Close();\n }\n\n void IDisposable.Dispose()\n {\n Close();\n\n#if LOCAL_TEST\n Console.ReadLine();\n#endif\n }\n }\n\n #endregion\n}\n\n", "lang_cluster": "C#", "tags": ["math", "dp", "constructive algorithms"], "code_uid": "4046a4bc4a584c21ca429c665a9507fb", "src_uid": "727d5b601694e5e0f0cf3a9ca25323fc", "difficulty": 2000.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.IO;\nusing System.Linq;\nusing System.Numerics;\nusing System.Collections.Generic;\n\nclass Program\n{\n\tstatic void Main()\n\t{\n\t\tConsole.ReadLine();\n\t\tint[] a = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();\n\t\tint[] y = new int[] { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };\n\t\tbool ans = false;\n\t\tfor (int i = 0, j = 0; i < y.Length; i++)\n\t\t\tif (a[j] == y[i])\n\t\t\t{\n\t\t\t\tj++;\n\t\t\t\tif (j == a.Length)\n\t\t\t\t{\n\t\t\t\t\tans = true;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\ti -= j;\n\t\t\t\tj = 0;\n\t\t\t}\n\t\tConsole.WriteLine(ans ? \"YES\" : \"NO\");\n\t\tConsole.ReadLine();\n\t}\n}", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "3ea36db6a1add518b3f6a46495b9810f", "src_uid": "d60c8895cebcc5d0c6459238edbdb945", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Diagnostics;\nusing System.IO;\nusing System.Linq;\nusing System.Security.AccessControl;\nusing System.Threading;\n\nnamespace First\n{\n class Program\n {\n static void Main(string[] args)\n {\n\n int n = Convert.ToInt32(Console.ReadLine());\n string[] s = Console.ReadLine().Split(' ');\n int[] days = new int[n];\n\n for (int i = 0; i < n; i++)\n {\n days[i] = Convert.ToInt32(s[i]);\n }\n\n List normalYear = new List()\n {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};\n List leapYear = new List()\n {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};\n\n List template = new List();\n\n template.AddRange(normalYear);\n template.AddRange(normalYear);\n template.AddRange(leapYear);\n template.AddRange(normalYear);\n template.AddRange(normalYear);\n\n for (int i = 0; i < template.Count; i++)\n {\n if (template[i] == days[0])\n {\n bool ok = true;\n for (int j = 1; j < n; j++)\n {\n if ((i + j) >= template.Count || template[i + j] != days[j])\n {\n ok = false;\n break;\n }\n }\n\n if (ok)\n {\n Console.WriteLine(\"Yes\");\n return;\n }\n }\n }\n\n Console.WriteLine(\"No\");\n\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "070a40914b819d12b77cf06e1ca3d645", "src_uid": "d60c8895cebcc5d0c6459238edbdb945", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\n\n\nnamespace Olymp\n{\n class Program\n {\n\n static void Main(string[] args)\n {\n int n = Convert.ToInt32(Console.ReadLine());\n //int n = 763116;\n if (n == 1) Console.WriteLine(1);\n else if (n == 2) Console.WriteLine(2);\n else{\n \n Console.WriteLine(Numb(n));\n }\n }\n\n static public long Numb(int n)\n {\n long max = n * (n - 1) * (n - 2) / GCD(n, n - 2);\n for (int q = 10; q > 0; q--)\n {\n long t = n * (n - 1) * (n - 2) / GCD(n, n - 2);\n for (long i = n; i > n - 10 && i > 2; i--)\n {\n for (long j = i - 1; j > i - 11 && j > 1; j--)\n {\n for (long k = j - 1; k > i - 12 && k > 0; k--)\n {\n if ((i * j * k) / GCD(i, k) > t)\n t = i * j * k / GCD(i, k);\n }\n }\n }\n if (t > max) max = t;\n } \n return max;\n }\n public static long GCD(long a, long b)\n {\n if (b == 0) return a;\n else return GCD(b, a % b);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["number theory"], "code_uid": "c5c2982d08b3d7dae8e6328b8db8b28e", "src_uid": "25e5afcdf246ee35c9cef2fcbdd4566e", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\n\n\nnamespace Olymp\n{\n class Program\n {\n\n static void Main(string[] args)\n {\n int n = Convert.ToInt32(Console.ReadLine());\n if (n == 1) Console.WriteLine(1);\n else if (n == 2) Console.WriteLine(2);\n else\n Console.WriteLine(Numb(n));\n }\n\n static public long Numb(int n)\n {\n long max = n * (n - 1) * (n - 2) / GCD(n, n - 2);\n for (int q = 10; q > 0; q--)\n {\n long t = n * (n - 1) * (n - 2) / GCD(n, n - 2);\n for (long i = n; i > n - 10 && i > 2; i--)\n \n for (long j = i - 1; j > i - 10 && j > 1; j--)\n \n for (long k = j - 1; k > i - 11 && k > 0; k--)\n \n if ((i * j * k) / GCD(i, k) > t)\n t = i * j * k / GCD(i, k);\n \n \n \n if (t > max) max = t;\n } \n return max;\n }\n public static long GCD(long a, long b)\n {\n if (b == 0) return a;\n else return GCD(b, a % b);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["number theory"], "code_uid": "e8eacd90195960fcaacede9974f62817", "src_uid": "25e5afcdf246ee35c9cef2fcbdd4566e", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.IO;\nusing System.Linq;\nusing System.Text;\n\nnamespace Fox_Dividing_Cheese\n{\n internal class Program\n {\n private static readonly StreamReader reader = new StreamReader(Console.OpenStandardInput(1024*10), Encoding.ASCII, false, 1024*10);\n private static readonly StreamWriter writer = new StreamWriter(Console.OpenStandardOutput(1024*10), Encoding.ASCII, 1024*10);\n\n private static void Main(string[] args)\n {\n int a = Next();\n int b = Next();\n\n var divs = new[] {2, 3, 5};\n var na = new int[divs.Length];\n var nb = new int[divs.Length];\n for (int i = 0; i < divs.Length; i++)\n {\n while (a%divs[i] == 0)\n {\n a /= divs[i];\n na[i]++;\n }\n while (b%divs[i] == 0)\n {\n b /= divs[i];\n nb[i]++;\n }\n }\n if (a == b)\n {\n writer.WriteLine(na.Select((t, i) => Math.Abs(t - nb[i])).Sum());\n }\n else\n {\n writer.WriteLine(\"-1\");\n }\n\n writer.Flush();\n }\n\n private static int Next()\n {\n int c;\n int res = 0;\n do\n {\n c = reader.Read();\n if (c == -1)\n return res;\n } while (c < '0' || c > '9');\n res = c - '0';\n while (true)\n {\n c = reader.Read();\n if (c < '0' || c > '9')\n return res;\n res *= 10;\n res += c - '0';\n }\n }\n }\n}", "lang_cluster": "C#", "tags": ["math", "number theory"], "code_uid": "205a43a3f336c6cfb9d63844e506f874", "src_uid": "75a97f4d85d50ea0e1af0d46f7565b49", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\n\nnamespace CSharp\n{\n class _371B\n {\n public static void Main()\n {\n var tokens = Console.ReadLine().Split();\n\n var a = Operations(int.Parse(tokens[0]));\n var b = Operations(int.Parse(tokens[1]));\n\n Console.WriteLine(a.Keys.Intersect(b.Keys).Select(key => a[key] + b[key]).DefaultIfEmpty(-1).Min());\n }\n\n private static Dictionary Operations(int n)\n {\n var operations = new Dictionary { { n, 0 } };\n var queue = new Queue(new int[] { n });\n\n while (queue.Any())\n {\n int x = queue.Dequeue();\n\n if (x % 2 == 0 && !operations.ContainsKey(x / 2))\n {\n operations.Add(x / 2, operations[x] + 1);\n queue.Enqueue(x / 2);\n }\n\n if (x % 3 == 0 && !operations.ContainsKey(x / 3))\n {\n operations.Add(x / 3, operations[x] + 1);\n queue.Enqueue(x / 3);\n }\n\n if (x % 5 == 0 && !operations.ContainsKey(x / 5))\n {\n operations.Add(x / 5, operations[x] + 1);\n queue.Enqueue(x / 5);\n }\n }\n\n return operations;\n }\n }\n}", "lang_cluster": "C#", "tags": ["math", "number theory"], "code_uid": "f9caaf06f49cf44ec8b19a4062cc151e", "src_uid": "75a97f4d85d50ea0e1af0d46f7565b49", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Linq.Expressions;\nusing System.IO;\n\nusing static util;\nusing P = pair;\n\nusing Binary = System.Func;\nusing Unary = System.Func;\n\nclass Program\n{\n static StreamWriter sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };\n static Scan sc = new Scan();\n const int M = 1000000007;\n const int M2 = 998244353;\n const long LM = (long)1e18;\n const double eps = 1e-11;\n static readonly int[] dd = { 0, 1, 0, -1, 0 };\n const string dstring = \"RDLU\";\n static void Main()\n {\n long n;\n int k;\n sc.Multi(out n, out k);\n var lis = new List>();\n long m = n;\n for (long i = 2; i * i <= m; i++)\n {\n int c = 0;\n while (m % i == 0) {\n m /= i;\n ++c;\n }\n if (c > 0) {\n lis.Add(make_pair(i, c));\n }\n }\n if (m > 1) {\n lis.Add(make_pair(m, 1));\n }\n long ans = 1;\n var inv = new long[100];\n for (int i = 1; i < 100; i++)\n {\n inv[i] = MyMath.inv(i);\n }\n foreach (var item in lis)\n {\n int c = item.v2;\n var dp = new long[c + 1];\n dp[0] = 1;\n for (int i = 0; i < k; i++)\n {\n var nex = new long[c + 1];\n for (int j = 0; j <= c; j++)\n {\n for (int l = 0; l <= j; l++)\n {\n nex[j] = (nex[j] + dp[l] * inv[c - l + 1]) % M;\n }\n }\n dp = nex;\n }\n long a = 0;\n long b = 1;\n for (int i = c; i >= 0; i--)\n {\n a = (a + dp[i] * b) % M;\n b = b * (item.v1 % M) % M;\n }\n ans = ans * a % M;\n }\n Prt(ans);\n sw.Flush();\n }\n\n static void DBG(string a) => Console.WriteLine(a);\n static void DBG(IEnumerable a) => DBG(string.Join(\" \", a));\n static void DBG(params object[] a) => DBG(string.Join(\" \", a));\n static void Prt(string a) => sw.WriteLine(a);\n static void Prt(IEnumerable a) => Prt(string.Join(\" \", a));\n static void Prt(params object[] a) => Prt(string.Join(\" \", a));\n}\nclass pair : IComparable>\n{\n public T v1;\n public U v2;\n public pair(T v1, U v2) {\n this.v1 = v1;\n this.v2 = v2;\n }\n public int CompareTo(pair a) {\n int c = Comparer.Default.Compare(v1, a.v1);\n return c != 0 ? c : Comparer.Default.Compare(v2, a.v2);\n }\n public override string ToString() => v1 + \" \" + v2;\n public void Deconstruct(out T a, out U b) {\n a = v1; b = v2;\n }\n}\nstatic class util\n{\n public static pair make_pair(this IList l) => make_pair(l[0], l[1]);\n public static pair make_pair(T v1, U v2) => new pair(v1, v2);\n public static T sq(T a) => Operator.Multiply(a, a);\n public static T Max(params T[] a) => a.Max();\n public static T Min(params T[] a) => a.Min();\n public static bool inside(int i, int j, int h, int w) => i >= 0 && i < h && j >= 0 && j < w;\n public static void swap(ref T a, ref T b) where T : struct { var t = a; a = b; b = t; }\n public static void swap(this IList a, int i, int j) where T : struct { var t = a[i]; a[i] = a[j]; a[j] = t; }\n public static T[] copy(this IList a) {\n var ret = new T[a.Count];\n for (int i = 0; i < a.Count; i++) ret[i] = a[i];\n return ret;\n }\n}\nstatic class Operator\n{\n static readonly ParameterExpression x = Expression.Parameter(typeof(T), \"x\");\n static readonly ParameterExpression y = Expression.Parameter(typeof(T), \"y\");\n public static readonly Func Add = Lambda(Expression.Add);\n public static readonly Func Subtract = Lambda(Expression.Subtract);\n public static readonly Func Multiply = Lambda(Expression.Multiply);\n public static readonly Func Divide = Lambda(Expression.Divide);\n public static readonly Func Plus = Lambda(Expression.UnaryPlus);\n public static readonly Func Negate = Lambda(Expression.Negate);\n public static Func Lambda(Binary op) => Expression.Lambda>(op(x, y), x, y).Compile();\n public static Func Lambda(Unary op) => Expression.Lambda>(op(x), x).Compile();\n}\n\nclass Scan\n{\n public int Int => int.Parse(Str);\n public long Long => long.Parse(Str);\n public double Double => double.Parse(Str);\n public string Str => Console.ReadLine().Trim();\n public pair Pair() where T : IComparable where U : IComparable {\n T a; U b;\n Multi(out a, out b);\n return new pair(a, b);\n }\n public P P {\n get {\n int a, b;\n Multi(out a, out b);\n return new P(a, b);\n }\n }\n public int[] IntArr => StrArr.Select(int.Parse).ToArray();\n public long[] LongArr => StrArr.Select(long.Parse).ToArray();\n public double[] DoubleArr => StrArr.Select(double.Parse).ToArray();\n public string[] StrArr => Str.Split(new[]{' '}, StringSplitOptions.RemoveEmptyEntries);\n bool eq() => typeof(T).Equals(typeof(U));\n T ct(U a) => (T)Convert.ChangeType(a, typeof(T));\n T cv(string s) => eq() ? ct(int.Parse(s))\n : eq() ? ct(long.Parse(s))\n : eq() ? ct(double.Parse(s))\n : eq() ? ct(s[0])\n : ct(s);\n public void Multi(out T a) => a = cv(Str);\n public void Multi(out T a, out U b)\n { var ar = StrArr; a = cv(ar[0]); b = cv(ar[1]); }\n public void Multi(out T a, out U b, out V c)\n { var ar = StrArr; a = cv(ar[0]); b = cv(ar[1]); c = cv(ar[2]); }\n public void Multi(out T a, out U b, out V c, out W d)\n { var ar = StrArr; a = cv(ar[0]); b = cv(ar[1]); c = cv(ar[2]); d = cv(ar[3]); }\n public void Multi(out T a, out U b, out V c, out W d, out X e)\n { var ar = StrArr; a = cv(ar[0]); b = cv(ar[1]); c = cv(ar[2]); d = cv(ar[3]); e = cv(ar[4]); }\n public void Multi(out T a, out U b, out V c, out W d, out X e, out Y f)\n { var ar = StrArr; a = cv(ar[0]); b = cv(ar[1]); c = cv(ar[2]); d = cv(ar[3]); e = cv(ar[4]); f = cv(ar[5]); }\n}\n\nstatic class MyMath\n{\n public static long Mod = 1000000007;\n public static bool isprime(long a) {\n if (a < 2) return false;\n for (long i = 2; i * i <= a; i++) if (a % i == 0) return false;\n return true;\n }\n public static bool[] sieve(int n) {\n var p = new bool[n + 1];\n for (int i = 2; i <= n; i++) p[i] = true;\n for (int i = 2; i * i <= n; i++) if (p[i]) for (int j = i * i; j <= n; j += i) p[j] = false;\n return p;\n }\n public static List getprimes(int n) {\n var prs = new List();\n var p = sieve(n);\n for (int i = 2; i <= n; i++) if (p[i]) prs.Add(i);\n return prs;\n }\n public static long pow(long a, long b) {\n a %= Mod;\n if (a == 0) return 0;\n if (b == 0) return 1;\n var t = pow(a, b / 2);\n if ((b & 1) == 0) return t * t % Mod;\n return t * t % Mod * a % Mod;\n }\n public static long inv(long a) => pow(a, Mod - 2);\n public static long gcd(long a, long b) {\n while (b > 0) { var t = a % b; a = b; b = t; } return a;\n }\n // a x + b y = gcd(a, b)\n public static long extgcd(long a, long b, out long x, out long y) {\n long g = a; x = 1; y = 0;\n if (b > 0) { g = extgcd(b, a % b, out y, out x); y -= a / b * x; }\n return g;\n }\n public static long lcm(long a, long b) => a / gcd(a, b) * b;\n\n static long[] facts, invs;\n public static void setfacts(int n) {\n facts = new long[n + 1];\n facts[0] = 1;\n for (int i = 1; i <= n; i++) facts[i] = facts[i - 1] * i % Mod;\n invs = new long[n + 1];\n invs[n] = inv(facts[n]);\n for (int i = n; i > 0 ; i--) invs[i - 1] = invs[i] * i % Mod;\n }\n public static long comb(long n, long r) {\n if (n < 0 || r < 0 || r > n) return 0;\n if (facts != null && facts.Length > n) return facts[n] * invs[r] % Mod * invs[n - r] % Mod;\n if (n - r < r) r = n - r;\n long numer = 1, denom = 1;\n for (long i = 0; i < r; i++) {\n numer = numer * ((n - i) % Mod) % Mod;\n denom = denom * ((i + 1) % Mod) % Mod;\n }\n return numer * inv(denom) % Mod;\n }\n public static long[][] getcombs(int n) {\n var ret = new long[n + 1][];\n for (int i = 0; i <= n; i++) {\n ret[i] = new long[i + 1];\n ret[i][0] = ret[i][i] = 1;\n for (int j = 1; j < i; j++) ret[i][j] = (ret[i - 1][j - 1] + ret[i - 1][j]) % Mod;\n }\n return ret;\n }\n // nC0, nC2, ..., nCn\n public static long[] getcomb(int n) {\n var ret = new long[n + 1];\n ret[0] = 1;\n for (int i = 0; i < n; i++) ret[i + 1] = ret[i] * (n - i) % Mod * inv(i + 1) % Mod;\n return ret;\n }\n public static bool nextPermutation(IList p) where T : struct, IComparable {\n for (int i = p.Count - 2; i >= 0; --i) {\n if (p[i].CompareTo(p[i + 1]) < 0) {\n for (int j = p.Count - 1; ; --j) {\n if (p[j].CompareTo(p[i]) > 0) {\n p.swap(i, j);\n for(++i, j = p.Count - 1; i < j; ++i, --j)\n p.swap(i, j);\n\n return true;\n }\n }\n }\n }\n return false;\n }\n public static bool nextPermutation(IList p, Comparison compare) where T : struct {\n for (int i = p.Count - 2; i >= 0; --i) {\n if (compare(p[i], p[i + 1]) < 0) {\n for (int j = p.Count - 1; ; --j) {\n if (compare(p[j], p[i]) > 0) {\n p.swap(i, j);\n for (++i, j = p.Count - 1; i < j; ++i, --j)\n p.swap(i, j);\n\n return true;\n }\n }\n }\n }\n return false;\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "dp", "probabilities", "number theory"], "code_uid": "2e8a8e30828b9316dde0ebf454335b99", "src_uid": "dc466d9c24b7dcb37c0e99337b4124d2", "difficulty": 2200.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Linq;\nusing System.Collections.Generic;\nusing Debug = System.Diagnostics.Debug;\nusing SB = System.Text.StringBuilder;\nusing System.Numerics;\nusing static System.Math;\nnamespace Program {\n public class Solver {\n Random rnd = new Random(0);\n public void Solve() {\n var n = rl;\n var k = ri;\n solve(n, k);\n }\n void solve(long n, int k) {\n Debug.WriteLine($\"{n} {k}\");\n var rev = Enumerate(100, x => ModInt.Inverse(x));\n\n ModInt all = 1;\n for (long p = 2; n != 1; p++) {\n if (p * p > n) {\n p = n;\n }\n if (n % p != 0) continue;\n var cnt = 0;\n while (n % p == 0) {\n n /= p;\n cnt++;\n }\n var dp = new ModInt[cnt + 1];\n dp[cnt] = 1;\n for (int i = 0; i < k; i++) {\n var next = new ModInt[cnt + 1];\n for (int j = 0; j < dp.Length; j++)\n for (int jj = 0; jj <= j; jj++) {\n next[jj] += dp[j] * rev[j + 1];\n }\n dp = next;\n }\n ModInt ans = 0;\n for (long i = 0, v = 1; i < dp.Length; i++, v *= p)\n ans += v * dp[i];\n all *= ans;\n\n }\n Console.WriteLine(all);\n }\n const long INF = 1L << 60;\n int ri { get { return sc.Integer(); } }\n long rl { get { return sc.Long(); } }\n double rd { get { return sc.Double(); } }\n string rs { get { return sc.Scan(); } }\n public IO.StreamScanner sc = new IO.StreamScanner(Console.OpenStandardInput());\n\n static T[] Enumerate(int n, Func f) {\n var a = new T[n];\n for (int i = 0; i < n; ++i) a[i] = f(i);\n return a;\n }\n static public void Swap(ref T a, ref T b) { var tmp = a; a = b; b = tmp; }\n }\n}\n\n#region main\nstatic class Ex {\n static public string AsString(this IEnumerable ie) { return new string(ie.ToArray()); }\n static public string AsJoinedString(this IEnumerable ie, string st = \" \") {\n return string.Join(st, ie);\n }\n static public void Main() {\n Console.SetOut(new Program.IO.Printer(Console.OpenStandardOutput()) { AutoFlush = false });\n var solver = new Program.Solver();\n solver.Solve();\n Console.Out.Flush();\n }\n}\n#endregion\n#region Ex\nnamespace Program.IO {\n using System.IO;\n using System.Text;\n using System.Globalization;\n\n public class Printer: StreamWriter {\n public override IFormatProvider FormatProvider { get { return CultureInfo.InvariantCulture; } }\n public Printer(Stream stream) : base(stream, new UTF8Encoding(false, true)) { }\n }\n\n public class StreamScanner {\n public StreamScanner(Stream stream) { str = stream; }\n\n public readonly Stream str;\n private readonly byte[] buf = new byte[1024];\n private int len, ptr;\n public bool isEof = false;\n public bool IsEndOfStream { get { return isEof; } }\n\n private byte read() {\n if (isEof) return 0;\n if (ptr >= len) {\n ptr = 0;\n if ((len = str.Read(buf, 0, 1024)) <= 0) {\n isEof = true;\n return 0;\n }\n }\n return buf[ptr++];\n }\n\n public char Char() {\n byte b = 0;\n do b = read(); while ((b < 33 || 126 < b) && !isEof);\n return (char)b;\n }\n public string Scan() {\n var sb = new StringBuilder();\n for (var b = Char(); b >= 33 && b <= 126; b = (char)read()) sb.Append(b);\n return sb.ToString();\n }\n public string ScanLine() {\n var sb = new StringBuilder();\n for (var b = Char(); b != '\\n' && b != 0; b = (char)read()) if (b != '\\r') sb.Append(b);\n return sb.ToString();\n }\n public long Long() { return isEof ? long.MinValue : long.Parse(Scan()); }\n public int Integer() { return isEof ? int.MinValue : int.Parse(Scan()); }\n public double Double() { return isEof ? double.NaN : double.Parse(Scan(), CultureInfo.InvariantCulture); }\n }\n}\n\n#endregion\n\n\n#region sieve O(NloglogN)\nstatic public partial class MathEx {\n static public bool[] Sieve(int p, List primes = null) {\n var isPrime = new bool[p + 1];\n for (int i = 2; i < isPrime.Length; i++) isPrime[i] = true;\n for (int i = 2; i * i <= p; i++)\n if (!isPrime[i]) continue;\n else for (int j = i * i; j <= p; j += i) isPrime[j] = false;\n if (primes != null) for (int i = 0; i <= p; i++) if (isPrime[i]) primes.Add(i);\n\n return isPrime;\n }\n static public List SieveList(int p) { var ret = new List(); Sieve(p, ret); return ret; }\n}\n#endregion\n\n\n#region ModInt\n///

\n/// [0,) \u307e\u3067\u306e\u5024\u3092\u53d6\u308b\u3088\u3046\u306a\u6570\n/// \npublic struct ModInt {\n /// \n /// \u5270\u4f59\u3092\u53d6\u308b\u5024\uff0e\n /// \n public const long Mod = (int)1e9 + 7;\n\n /// \n /// \u5b9f\u969b\u306e\u6570\u5024\uff0e\n /// \n public long num;\n /// \n /// \u5024\u304c \u3067\u3042\u308b\u3088\u3046\u306a\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u3092\u69cb\u7bc9\u3057\u307e\u3059\uff0e\n /// \n /// \u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u304c\u6301\u3064\u5024\n /// \u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u306e\u554f\u984c\u4e0a\uff0c\u30b3\u30f3\u30b9\u30c8\u30e9\u30af\u30bf\u5185\u3067\u306f\u5270\u4f59\u3092\u53d6\u308a\u307e\u305b\u3093\uff0e\u305d\u306e\u305f\u3081\uff0c \u2208 [0,) \u3092\u6e80\u305f\u3059\u3088\u3046\u306a \u3092\u6e21\u3057\u3066\u304f\u3060\u3055\u3044\uff0e\u3053\u306e\u30b3\u30f3\u30b9\u30c8\u30e9\u30af\u30bf\u306f O(1) \u3067\u5b9f\u884c\u3055\u308c\u307e\u3059\uff0e\n public ModInt(long n) { num = n; }\n /// \n /// \u3053\u306e\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u306e\u6570\u5024\u3092\u6587\u5b57\u5217\u306b\u5909\u63db\u3057\u307e\u3059\uff0e\n /// \n /// [0,) \u306e\u7bc4\u56f2\u5185\u306e\u6574\u6570\u3092 10 \u9032\u8868\u8a18\u3057\u305f\u3082\u306e\uff0e\n public override string ToString() { return num.ToString(); }\n public static ModInt operator +(ModInt l, ModInt r) { l.num += r.num; if (l.num >= Mod) l.num -= Mod; return l; }\n public static ModInt operator -(ModInt l, ModInt r) { l.num -= r.num; if (l.num < 0) l.num += Mod; return l; }\n public static ModInt operator *(ModInt l, ModInt r) { return new ModInt(l.num * r.num % Mod); }\n public static implicit operator ModInt(long n) { n %= Mod; if (n < 0) n += Mod; return new ModInt(n); }\n\n /// \n /// \u4e0e\u3048\u3089\u308c\u305f 2 \u3064\u306e\u6570\u5024\u304b\u3089\u3079\u304d\u5270\u4f59\u3092\u8a08\u7b97\u3057\u307e\u3059\uff0e\n /// \n /// \u3079\u304d\u4e57\u306e\u5e95\n /// \u3079\u304d\u6307\u6570\n /// \u7e70\u308a\u8fd4\u3057\u4e8c\u4e57\u6cd5\u306b\u3088\u308a O(N log N) \u3067\u5b9f\u884c\u3055\u308c\u307e\u3059\uff0e\n public static ModInt Pow(ModInt v, long k) { return Pow(v.num, k); }\n\n /// \n /// \u4e0e\u3048\u3089\u308c\u305f 2 \u3064\u306e\u6570\u5024\u304b\u3089\u3079\u304d\u5270\u4f59\u3092\u8a08\u7b97\u3057\u307e\u3059\uff0e\n /// \n /// \u3079\u304d\u4e57\u306e\u5e95\n /// \u3079\u304d\u6307\u6570\n /// \u7e70\u308a\u8fd4\u3057\u4e8c\u4e57\u6cd5\u306b\u3088\u308a O(N log N) \u3067\u5b9f\u884c\u3055\u308c\u307e\u3059\uff0e\n public static ModInt Pow(long v, long k) {\n long ret = 1;\n for (k %= Mod - 1; k > 0; k >>= 1, v = v * v % Mod)\n if ((k & 1) == 1) ret = ret * v % Mod;\n return new ModInt(ret);\n }\n /// \n /// \u4e0e\u3048\u3089\u308c\u305f\u6570\u306e\u9006\u5143\u3092\u8a08\u7b97\u3057\u307e\u3059\uff0e\n /// \n /// \u9006\u5143\u3092\u53d6\u308b\u5bfe\u8c61\u3068\u306a\u308b\u6570\n /// \u9006\u5143\u3068\u306a\u308b\u3088\u3046\u306a\u5024\n /// \u6cd5\u304c\u7d20\u6570\u3067\u3042\u308b\u3053\u3068\u3092\u4eee\u5b9a\u3057\u3066\uff0c\u30d5\u30a7\u30eb\u30de\u30fc\u306e\u5c0f\u5b9a\u7406\u306b\u5f93\u3063\u3066\u9006\u5143\u3092 O(log N) \u3067\u8a08\u7b97\u3057\u307e\u3059\uff0e\n public static ModInt Inverse(ModInt v) { return Pow(v, Mod - 2); }\n}\n#endregion", "lang_cluster": "C#", "tags": ["math", "dp", "probabilities", "number theory"], "code_uid": "b14fe0eef9235d5461a510a6c5f24231", "src_uid": "dc466d9c24b7dcb37c0e99337b4124d2", "difficulty": 2200.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace codeforce\n{\n class Program\n {\n static void Main(string[] args)\n {\n string temp = Console.ReadLine();\n string[] splitted = temp.Split(' ');\n int N = Convert.ToInt32(splitted[0]);\n int K = Convert.ToInt32(splitted[1]);\n temp = Console.ReadLine();\n splitted = temp.Split(' ');\n int[] difficultyTask = new int[N];\n for (int i = 0; i < N; i++)\n {\n difficultyTask[i] = Convert.ToInt32(splitted[i]);\n }\n int TasksCanSolve = 0;\n bool[] solved = new bool[N];\n bool progress = true;\n for (int i = 0, j = N - 1; i < N && j >= 0 && !solved[i]\n && !solved[j] && progress;)\n {\n progress = false;\n if (difficultyTask[i] <= K && !solved[i])\n {\n TasksCanSolve++;\n solved[i] = true;\n i++;\n progress = true;\n }\n if (difficultyTask[j] <= K && !solved[j])\n {\n TasksCanSolve++;\n solved[j] = true;\n j--;\n progress = true;\n }\n }\n Console.WriteLine(TasksCanSolve);\n //Console.Read();\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "implementation"], "code_uid": "2f1aa8d9ae6dc477b2cba4e599993b98", "src_uid": "ecf0ead308d8a581dd233160a7e38173", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.IO;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace A\n{\n class Program\n {\n static void Main(string[] args)\n {\n TextReader sr = Console.In;\n string[] s = sr.ReadLine().Split();\n int n = Convert.ToInt32(s[0]);\n int k = Convert.ToInt32(s[1]);\n s = sr.ReadLine().Split();\n int z1 = -1;\n int z2 = -1;\n int c;\n int res;\n for (int i = 0; i < n; i++)\n {\n c = Convert.ToInt32(s[i]);\n if (c > k)\n {\n if (z1 == -1) z1 = i;\n else z2 = i;\n }\n }\n if (z1 == -1 && z2 == -1) res = n;\n else if (z2 == -1) res = n - 1;\n else res = n - (z2 - z1 + 1);\n Console.WriteLine(res.ToString());\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "implementation"], "code_uid": "41384080ea214fd9048a085bf7d40874", "src_uid": "ecf0ead308d8a581dd233160a7e38173", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nclass Program\n{\n\tstatic void Main(string[] args)\n\t{\n\t\tstring str = Console.ReadLine();\n\t\tint N = str.Length;\n\t\tstring ans = \"\";\n\t\tif(N%2==0){\n\t\t\tfor(var i=0;i(string s, char separator)\n {\n Type type = typeof(T);\n\n MethodInfo[] methods = type.GetMethods();\n\n MethodInfo parseMethod = methods.Where(m => m.Name == \"Parse\").FirstOrDefault();\n\n if (parseMethod == null)\n {\n throw new InvalidOperationException($\"The type {type} does not contain Parse method\");\n }\n\n T[] result = s.Split(separator).Select(e => parseMethod.Invoke(type, new object[] { e })).Cast().ToArray();\n\n return result;\n }\n\n public static void PrintAnArray(T[] array, string separator)\n {\n Console.WriteLine(string.Join(separator, array));\n }\n }\n\n class AlgorithmUtils\n {\n public static T[] PrefixSumOfArray(T[] array) where T : struct\n {\n T currentSum = default(T);\n\n T[] prefixSum = new T[array.Length];\n\n for (int i = 0; i < array.Length; i++)\n {\n currentSum = sumTwoElements(currentSum, array[i]);\n prefixSum[i] = currentSum;\n }\n\n return prefixSum;\n }\n\n public static T SumOfElementsInArray(T[] array, int leftIndex, int rightIndex)\n {\n dynamic right = array[rightIndex];\n dynamic left = array[leftIndex];\n\n return right - left;\n }\n\n private static T sumTwoElements(T a, T b) where T : struct\n {\n dynamic first = a;\n dynamic second = b;\n\n return first + second;\n }\n\n public static void Swap(ref T a, ref T b)\n {\n T temp = a;\n a = b;\n b = temp;\n }\n }\n\n class Program\n {\n private static List list = new List();\n\n static void Main(string[] args)\n {\n string s = Console.ReadLine();\n\n int l;\n\n if(s.Length % 2 == 0)\n {\n l = s.Length / 2 - 1;\n }\n else\n {\n l = s.Length / 2 ;\n }\n \n\n StringBuilder sb = new StringBuilder();\n\n int index = l;\n int step = 0;\n int k = 0;\n\n while(index>=0 && indexA[j])\n {\n i++;\n }\n else\n {\n max = Math.Max(max, j - i);\n break;\n }\n }\n\n while (i < j)\n {\n if (A[i] > A[j])\n {\n j--;\n }\n else\n {\n max = Math.Max(max, j - i);\n break;\n }\n }\n\n return max;\n }\n\n private static int summma(int [] a)\n {\n int sum = 0;\n\n foreach(int n in a)\n {\n sum += n;\n }\n\n return sum;\n }\n\n private static string createString(int n, int k)\n {\n StringBuilder sb = new StringBuilder();\n\n for (int i = 0; i < k; i++)\n {\n sb.Append(char.ConvertFromUtf32(i + 'a'));\n }\n\n int temp = n - k;\n int j = 0;\n\n for (int i = 0; i < temp; i++)\n {\n sb.Append(char.ConvertFromUtf32(j + 'a'));\n\n j++;\n\n if (j > k)\n {\n j = 0;\n }\n }\n\n return sb.ToString();\n }\n\n public int LargestRectangleArea(int[] heights)\n {\n int[] mins = min(heights);\n\n int left = 0;\n int right = heights.Length - 1;\n\n int max = int.MinValue;\n\n while (left < right)\n {\n int currentArea = Math.Min(heights[left], heights[right]) * (right - left);\n max = Math.Max(max, currentArea);\n Console.WriteLine(left + \" \" + right + \" \" + max);\n if (heights[left] < heights[right])\n {\n left++;\n }\n else\n {\n right--;\n }\n\n }\n return max;\n }\n\n private static int [] min (int [] a)\n {\n int min = a[0];\n\n int[] ans = new int[a.Length];\n ans[0] = min;\n\n for (int i = 1; i < a.Length; i++)\n {\n if(a[i] dict = new Dictionary();\n\n for(int i = 0; i < s.Length; i++)\n {\n dict[s[i]] = i;\n }\n\n char[] ans = t.ToCharArray();\n\n int index = 0;\n\n for (int i = 0; i < s.Length; i++)\n {\n for (int j = 0; j < t.Length; j++)\n {\n if(s[i] == t[j])\n {\n ans[index++] = t[j];\n }\n }\n }\n\n for (int i = 0; i < t.Length; i++)\n {\n if(!dict.ContainsKey(t[i]))\n {\n ans[index++] = t[i];\n }\n }\n\n return new string(ans);\n }\n\n private static void Swap(ref char a, ref char b)\n {\n char temp = a;\n a = b;\n b = temp;\n }\n\n private static int lowerBound(int[] a, int target)\n {\n int lo = 0;\n int hi = a.Length - 1;\n\n int ans = -1;\n\n while (lo <= hi)\n {\n int med = hi - (hi - lo) / 2;\n\n if (target == a[med])\n {\n ans = med;\n hi = med - 1;\n }\n else if (target > a[med])\n {\n lo = med + 1;\n }\n else\n {\n hi = med - 1;\n }\n }\n\n return ans;\n }\n\n private static int upperBound(int[] a, int target)\n {\n int lo = 0;\n int hi = a.Length - 1;\n\n int ans = -1;\n\n while (lo <= hi)\n {\n int med = hi - (hi - lo) / 2;\n\n if (target == a[med])\n {\n ans = med;\n lo = med + 1;\n }\n else if (target > a[med])\n {\n lo = med + 1;\n }\n else\n {\n hi = med - 1;\n }\n }\n\n return ans;\n }\n\n private static bool isPalindromePermutation(string s)\n {\n int count = 0;\n\n int[] frequency = characterFrequency(s);\n\n for (int i = 0; i < frequency.Length; i++)\n {\n if (frequency[i] % 2 != 0) count++;\n }\n\n return count <= 1;\n }\n\n private static bool isPermuatation(int[] fa, int[] fb)\n {\n for (int i = 0; i < fa.Length; i++)\n {\n if (fa[i] != fb[i]) return false;\n }\n\n return true;\n }\n\n private static bool isAllCharactersUnique(string s)\n {\n char[] c = s.ToCharArray();\n\n Array.Sort(c);\n\n for (int i = 0; i < c.Length - 1; i++)\n {\n if (c[i + 1] == c[i]) return false;\n }\n\n return true;\n }\n\n private static int[] characterFrequency(string s)\n {\n int[] a = new int[26];\n\n foreach (char c in s)\n {\n a[c - 'a']++;\n }\n\n return a;\n }\n\n\n private static void permutation(string str)\n {\n permutation(str, \"\");\n }\n\n private static void permutation(string str, string prefix)\n {\n if (str.Length == 0) list.Add(prefix);\n else\n {\n for (int i = 0; i < str.Length; i++)\n {\n string rem = str.Substring(0, i) + str.Substring(i + 1);\n permutation(rem, prefix + str[i]);\n }\n }\n }\n\n public static int[] prefixSum(int[] a)\n {\n int[] b = new int[a.Length];\n int sum = 0;\n for (int i = 0; i < a.Length; i++)\n {\n sum += a[i];\n b[i] = sum;\n }\n\n return b;\n }\n private static string shiftTheString(string s)\n {\n char[] c = s.ToCharArray();\n\n char first = c[0];\n\n for (int i = 0; i < c.Length - 1; i++)\n {\n c[i] = c[i + 1];\n }\n\n c[c.Length - 1] = first;\n\n return new string(c);\n }\n\n\n private static string reverseTheString(string s)\n {\n char[] c = s.ToCharArray();\n\n for (int i = 0; i < c.Length / 2; i++)\n {\n char temp = c[i];\n c[i] = c[c.Length - 1 - i];\n c[c.Length - 1 - i] = temp;\n }\n\n return new string(c);\n }\n\n private static int toDecimal(string s)\n {\n int result = 0;\n int j = 0;\n\n for (int i = s.Length - 1; i >= 0; i--)\n {\n result += Convert.ToInt32(s[i].ToString()) * (int)(Math.Pow(2, j));\n j++;\n }\n\n return result;\n }\n\n private static int gcd(int a, int b)\n {\n return b == 0 ? a : gcd(b, a % b);\n }\n\n private static bool isPrime(int n)\n {\n if (n < 2) return false;\n\n for (int i = 2; i * i <= n; i++)\n {\n if (n % i == 0) return false;\n }\n\n return true;\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["strings", "implementation"], "code_uid": "4ff82e9f32d702cea40ceb25f1f722ae", "src_uid": "992ae43e66f1808f19c86b1def1f6b41", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Globalization;\nusing System.IO;\nusing System.Linq;\n//using System.Numerics;\nusing System.Text;\nusing System.Threading;\n\n// (\u3065\u00b0\u03c9\u00b0)\u3065\uff90e\u2605\u309c\u30fb\u3002\u3002\u30fb\u309c\u309c\u30fb\u3002\u3002\u30fb\u309c\u2606\u309c\u30fb\u3002\u3002\u30fb\u309c\u309c\u30fb\u3002\u3002\u30fb\u309c\npublic class Solver\n{\n const int MOD = 1000000007;\n const int MAX = 2000000;\n\n long ModPow(long x, long p)\n {\n long ret = 1;\n while (p > 0)\n {\n if ((p & 1) == 1)\n ret = ret * x % MOD;\n x = x * x % MOD;\n p >>= 1;\n }\n return ret;\n }\n\n void Solve()\n {\n var fact = new long[MAX * 2];\n fact[0] = 1;\n for (int i = 1; i < 2 * MAX; i++)\n fact[i] = fact[i - 1] * i % MOD;\n\n int n = ReadInt() + 1;\n long ret = 2 * fact[2 * n - 1] * ModPow(fact[n], MOD - 2) % MOD * ModPow(fact[n - 1], MOD - 2) % MOD - 1;\n if (ret < 0)\n ret += MOD;\n Write(ret);\n }\n\n #region Main\n\n protected static TextReader reader;\n protected static TextWriter writer;\n static void Main()\n {\n#if DEBUG\n reader = new StreamReader(\"..\\\\..\\\\input.txt\");\n //reader = new StreamReader(Console.OpenStandardInput());\n writer = Console.Out;\n //writer = new StreamWriter(\"..\\\\..\\\\output.txt\");\n#else\n reader = new StreamReader(Console.OpenStandardInput());\n writer = new StreamWriter(Console.OpenStandardOutput());\n //reader = new StreamReader(\"transform.in\");\n //writer = new StreamWriter(\"transform.out\");\n#endif\n try\n {\n // var thread = new Thread(new Solver().Solve, 1024 * 1024 * 128);\n // thread.Start();\n // thread.Join();\n new Solver().Solve();\n }\n catch (Exception ex)\n {\n Console.WriteLine(ex);\n#if DEBUG\n#else\n throw;\n#endif\n }\n reader.Close();\n writer.Close();\n }\n\n #endregion\n\n #region Read / Write\n private static Queue currentLineTokens = new Queue();\n private static string[] ReadAndSplitLine() { return reader.ReadLine().Split(new[] { ' ', '\\t', }, StringSplitOptions.RemoveEmptyEntries); }\n public static string ReadToken() { while (currentLineTokens.Count == 0)currentLineTokens = new Queue(ReadAndSplitLine()); return currentLineTokens.Dequeue(); }\n public static int ReadInt() { return int.Parse(ReadToken()); }\n public static long ReadLong() { return long.Parse(ReadToken()); }\n public static double ReadDouble() { return double.Parse(ReadToken(), CultureInfo.InvariantCulture); }\n public static int[] ReadIntArray() { return ReadAndSplitLine().Select(int.Parse).ToArray(); }\n public static long[] ReadLongArray() { return ReadAndSplitLine().Select(long.Parse).ToArray(); }\n public static double[] ReadDoubleArray() { return ReadAndSplitLine().Select(s => double.Parse(s, CultureInfo.InvariantCulture)).ToArray(); }\n public static int[][] ReadIntMatrix(int numberOfRows) { int[][] matrix = new int[numberOfRows][]; for (int i = 0; i < numberOfRows; i++)matrix[i] = ReadIntArray(); return matrix; }\n public static int[][] ReadAndTransposeIntMatrix(int numberOfRows)\n {\n int[][] matrix = ReadIntMatrix(numberOfRows); int[][] ret = new int[matrix[0].Length][];\n for (int i = 0; i < ret.Length; i++) { ret[i] = new int[numberOfRows]; for (int j = 0; j < numberOfRows; j++)ret[i][j] = matrix[j][i]; } return ret;\n }\n public static string[] ReadLines(int quantity) { string[] lines = new string[quantity]; for (int i = 0; i < quantity; i++)lines[i] = reader.ReadLine().Trim(); return lines; }\n public static void WriteArray(IEnumerable array) { writer.WriteLine(string.Join(\" \", array)); }\n public static void Write(params object[] array) { WriteArray(array); }\n public static void WriteLines(IEnumerable array) { foreach (var a in array)writer.WriteLine(a); }\n private class SDictionary : Dictionary\n {\n public new TValue this[TKey key]\n {\n get { return ContainsKey(key) ? base[key] : default(TValue); }\n set { base[key] = value; }\n }\n }\n private static T[] Init(int size) where T : new() { var ret = new T[size]; for (int i = 0; i < size; i++)ret[i] = new T(); return ret; }\n #endregion\n}", "lang_cluster": "C#", "tags": ["combinatorics", "number theory"], "code_uid": "179515ef316090182ec42d22a659bf70", "src_uid": "a18833c987fd7743e8021196b5dcdd1b", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.IO;\nusing System.Text;\n\nnamespace Bots\n{\n internal class Program\n {\n private const int mod = 1000000007;\n private static readonly StreamReader reader = new StreamReader(Console.OpenStandardInput(1024*10), Encoding.ASCII, false, 1024*10);\n private static readonly StreamWriter writer = new StreamWriter(Console.OpenStandardOutput(1024*10), Encoding.ASCII, 1024*10);\n\n private static long Pow(long a, int k)\n {\n long r = 1;\n while (k > 0)\n {\n if ((k & 1) == 1)\n {\n r = (r*a)%mod;\n }\n a = (a*a)%mod;\n k >>= 1;\n }\n return r;\n }\n\n private static void Main(string[] args)\n {\n int n = Next()+1;\n\n long f = 1;\n for (int i = 2; i <= n; i++)\n {\n f = (f*i)%mod;\n }\n long f2 = f;\n for (int i = n + 1; i <= 2*n; i++)\n {\n f2 = (f2*i)%mod;\n }\n\n long f1 = Pow(f, mod - 2);\n\n long res = (((f2*f1)%mod)*f1)%mod;\n\n\n writer.WriteLine(res-1);\n writer.Flush();\n }\n\n private static int Next()\n {\n int c;\n int res = 0;\n do\n {\n c = reader.Read();\n if (c == -1)\n return res;\n } while (c < '0' || c > '9');\n res = c - '0';\n while (true)\n {\n c = reader.Read();\n if (c < '0' || c > '9')\n return res;\n res *= 10;\n res += c - '0';\n }\n }\n }\n}", "lang_cluster": "C#", "tags": ["combinatorics", "number theory"], "code_uid": "c39aa46010c1e6b0c6b478e7ed716c74", "src_uid": "a18833c987fd7743e8021196b5dcdd1b", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\n\nnamespace capp\n{\n class Program\n {\n static void Main(string[] args)\n {\n int[] data = Array.ConvertAll(Console.ReadLine().Split(' '), x => int.Parse(x));\n int a = (int)Math.Round(Math.Sqrt(data[0] * data[1] / data[2]));\n int b = (int)Math.Round(Math.Sqrt(data[1]*data[2]/data[0]));\n int c = (int)Math.Round(Math.Sqrt(data[2]*data[0]/data[1]));\n Console.WriteLine(4 * (a + b + c));\n }\n }\n\n\n}\n", "lang_cluster": "C#", "tags": ["brute force", "math", "geometry"], "code_uid": "9bda6b989f5d5fce42380fe81ad31a3e", "src_uid": "c0a3290be3b87f3a232ec19d4639fefc", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Runtime.InteropServices;\n\nnamespace codeforces\n{\n\tclass Program\n\t{\n\t\tpublic class User\n\t\t{\n\t\t\tpublic int c;\n\n\t\t\tpublic int r;\n\t\t}\n\n\t\tpublic class Point\n\t\t{\n\t\t\tpublic int x;\n\n\t\t\tpublic int y;\n\t\t}\n\n\t\tpublic class Comparer : IComparer\n\t\t{\n\t\t\tpublic int Compare(User x, User y)\n\t\t\t{\n\t\t\t\tif (x.c < y.c || (x.c == y.c && x.r < y.r))\n\t\t\t\t\treturn -1;\n\t\t\t\treturn 1;\n\t\t\t}\n\t\t}\n\n\t\tpublic static long getGcd(long a, long b)\n\t\t{\n\t\t\tif (b == 0)\n\t\t\t\treturn a;\n\t\t\treturn getGcd(b, a % b);\n\t\t}\n\n\t\tpublic static void WriteYESNO(bool x, string yes = \"YES\", string no = \"NO\")\n\t\t{\n\t\t\tif (x)\n\t\t\t\tConsole.WriteLine(yes);\n\t\t\telse\n\t\t\t{\n\t\t\t\tConsole.WriteLine(no);\n\t\t\t}\n\t\t}\n\n\t\tpublic static string getString()\n\t\t{\n\t\t\treturn Console.ReadLine();\n\t\t}\n\n\t\tpublic static List getList()\n\t\t{\n\t\t\tvar s = Console.ReadLine();\n\t\t\treturn s.Split(' ').Select(int.Parse).ToList();\n\t\t}\n\n\t\tpublic static List getLongList()\n\t\t{\n\t\t\tvar s = Console.ReadLine();\n\t\t\treturn s.Split(' ').Select(long.Parse).ToList();\n\t\t}\n\n\t\tpublic static int Min(int x, int y)\n\t\t{\n\t\t\treturn Math.Min(x, y);\n\t\t}\n\n\t\tpublic static int Max(int x, int y)\n\t\t{\n\t\t\treturn Math.Max(x, y);\n\t\t}\n\n\t\tpublic static int Abs(int x)\n\t\t{\n\t\t\treturn Math.Abs(x);\n\t\t}\n\n\t\tpublic static int getInt()\n\t\t{\n\t\t\tvar s = Console.ReadLine();\n\t\t\treturn int.Parse(s);\n\t\t}\n\n\t\tpublic static long getLong()\n\t\t{\n\t\t\tvar s = Console.ReadLine();\n\t\t\treturn long.Parse(s);\n\t\t}\n\n\t\tpublic static bool Equal(int x, int y, int x1, int y1)\n\t\t{\n\t\t\treturn x == x1 && y == y1;\n\t\t}\n\n\t\tpublic class Vertex\n\t\t{\n\t\t\tpublic List edges;\n\n\t\t\tpublic int ct;\n\n\t\t\tpublic bool was;\n\t\t}\n\n\t\tprivate static void Main(string[] args)\n\t\t{\n/*\t\t\tvar input = new StreamReader(\"input.txt\");\n\t\t\tvar output = new StreamWriter(\"output.txt\");*/\n\t\t\tvar l = getList();\n\t\t\tConsole.WriteLine(4* ((int)Math.Sqrt((l[0] * l[1]) / l[2]) + (int)Math.Sqrt((l[0] * l[2]) / l[1]) + (int)Math.Sqrt((l[2] * l[1]) / l[0])));\n\t\t\tConsole.ReadLine();\n\t\t}\n\t}\n}\n", "lang_cluster": "C#", "tags": ["brute force", "math", "geometry"], "code_uid": "686f36ca9ccc8d0dc3b13d5946d6281b", "src_uid": "c0a3290be3b87f3a232ec19d4639fefc", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Linq;\nusing System.IO;\n \nclass Program\n{\n private static void Main()\n {\n //InputFromFile();\n long[] nm = ConsoleReadLineAsArrayOfLongs();\n long n = nm[0];\n long m = nm[1];\n long modulo = 1000000000 + 7;\n\n long x = fastPow((fastPow(2, m, modulo) - 1), n, modulo);\n \n ConsoleWriteLine(\"\" + x);\n }\n\n //returns a^pw % mod\n private static long fastPow(long a, long pw, long mod) {\n long res = 1;\n a %= mod;\n while(pw > 0) {\n if((pw & 1) != 0) res = (res*a)%mod;\n a = (a*a)%mod;\n pw >>= 1;\n }\n return res;\n }\n\n private static long poww(long a, long b, long modulo)\n {\n long x = 1;\n for(int i = 0; i < b; ++i)\n {\n x *= a;\n x %= modulo;\n }\n return x;\n }\n\n private static void InputFromFile()\n {\n Console.SetIn(File.OpenText(\"input.txt\"));\n }\n \n private static long[] ConsoleReadLineAsArrayOfLongs()\n {\n return Console.ReadLine().Split(' ').Select(n => Convert.ToInt64(n)).ToArray();\n }\n \n private static int[] ConsoleReadLineAsArrayOfIntegers()\n {\n return Console.ReadLine().Split(' ').Select(n => Convert.ToInt32(n)).ToArray();\n }\n\n private static int[] ConsoleReadLineAsArrayOfIntegersReversed()\n {\n return Console.ReadLine().Split(' ').Select(n => Convert.ToInt32(n)).Reverse().ToArray();\n }\n\n private static long ConsoleReadLineAsLong()\n {\n return Convert.ToInt64(Console.ReadLine());\n }\n \n private static int ConsoleReadLineAsInteger()\n {\n return Convert.ToInt32(Console.ReadLine());\n }\n \n private static void ConsoleWriteLine(string line)\n {\n Console.WriteLine(line);\n }\n}", "lang_cluster": "C#", "tags": ["math", "combinatorics"], "code_uid": "6345339c86f6ffe5dd5551f308467927", "src_uid": "71029e5bf085b0f5f39d1835eb801891", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\n\nnamespace ConsoleApp1\n{\n class Program\n {\n static void Main(string[] args)\n {\n \n var nm = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();\n var n = nm[0];\n var m = nm[1];\n\n var result = PowerMod(PowerMod(2, m) - 1, n);\n Console.WriteLine(result);\n }\n\n static long PowerMod(long number, long power)\n {\n long res = 1;\n \n while(power > 0)\n {\n if((power&1) == 1)\n res = (res * number) % 1000000007;\n power = power >> 1;\n number = (number * number) % 1000000007;\n }\n return res;\n }\n }\n}", "lang_cluster": "C#", "tags": ["math", "combinatorics"], "code_uid": "b98b342ab4386f283af523e2fdfa05f0", "src_uid": "71029e5bf085b0f5f39d1835eb801891", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\n//using System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\n\nnamespace ConsoleApplication1\n{\n class Program\n {\n static void Sum854b() \n {\n/*\n \n\n\n\n\nB. \u041c\u0430\u043a\u0441\u0438\u043c \u043f\u043e\u043a\u0443\u043f\u0430\u0435\u0442 \u043a\u0432\u0430\u0440\u0442\u0438\u0440\u0443\n\n\u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435 \u043f\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u043d\u0430 \u0442\u0435\u0441\u0442:1 \u0441\u0435\u043a\u0443\u043d\u0434\u0430\n\n\u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435 \u043f\u043e \u043f\u0430\u043c\u044f\u0442\u0438 \u043d\u0430 \u0442\u0435\u0441\u0442:512 \u043c\u0435\u0433\u0430\u0431\u0430\u0439\u0442\n\n\u0432\u0432\u043e\u0434:\u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0439 \u0432\u0432\u043e\u0434\n\n\u0432\u044b\u0432\u043e\u0434:\u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0439 \u0432\u044b\u0432\u043e\u0434\n\n\n\u041c\u0430\u043a\u0441\u0438\u043c \u0445\u043e\u0447\u0435\u0442 \u043a\u0443\u043f\u0438\u0442\u044c \u043a\u0432\u0430\u0440\u0442\u0438\u0440\u0443 \u0432 \u043c\u043e\u0434\u043d\u043e\u043c \u043c\u043d\u043e\u0433\u043e\u043a\u0432\u0430\u0440\u0442\u0438\u0440\u043d\u043e\u043c \u0434\u043e\u043c\u0435 \u043d\u0430 \u041b\u0438\u043d\u0435\u0439\u043d\u043e\u043c \u043f\u0440\u043e\u0441\u043f\u0435\u043a\u0442\u0435 \u0433\u043e\u0440\u043e\u0434\u0430 \u041c\u0435\u0433\u0430\u043f\u043e\u043b\u0438\u0441\u0430. \u0412 \u044d\u0442\u043e\u043c \u0434\u043e\u043c\u0435 n \u043a\u0432\u0430\u0440\u0442\u0438\u0440, \u043f\u0440\u043e\u043d\u0443\u043c\u0435\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u043e\u0442 1 \u0434\u043e n \u0438 \u0440\u0430\u0441\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0445 \u0432 \u043e\u0434\u0438\u043d \u0440\u044f\u0434. \n * \u0414\u0432\u0435 \u043a\u0432\u0430\u0440\u0442\u0438\u0440\u044b \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0441\u043e\u0441\u0435\u0434\u043d\u0438\u043c\u0438, \u0435\u0441\u043b\u0438 \u0438\u0445 \u043d\u043e\u043c\u0435\u0440\u0430 \u0440\u0430\u0437\u043b\u0438\u0447\u0430\u044e\u0442\u0441\u044f \u0440\u043e\u0432\u043d\u043e \u043d\u0430 1. \u041d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043a\u0432\u0430\u0440\u0442\u0438\u0440\u044b \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u0443\u0436\u0435 \u0437\u0430\u0441\u0435\u043b\u0451\u043d\u043d\u044b\u043c\u0438, \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435 \u0441\u0432\u043e\u0431\u043e\u0434\u043d\u044b \u0438 \u0438\u0445 \u043c\u043e\u0436\u043d\u043e \u043a\u0443\u043f\u0438\u0442\u044c.\n\n\u041c\u0430\u043a\u0441\u0438\u043c \u0447\u0430\u0441\u0442\u043e \u0445\u043e\u0434\u0438\u0442 \u0432 \u0433\u043e\u0441\u0442\u0438 \u043a \u0441\u043e\u0441\u0435\u0434\u044f\u043c, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043a\u0432\u0430\u0440\u0442\u0438\u0440\u0430 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u043d\u0435\u0433\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u044f\u0449\u0435\u0439, \u0435\u0441\u043b\u0438 \u043e\u043d\u0430 \u0441\u0432\u043e\u0431\u043e\u0434\u043d\u0430 \u0438 \u0435\u0441\u0442\u044c \u0445\u043e\u0442\u044f \u0431\u044b \u043e\u0434\u043d\u0430 \u0437\u0430\u0441\u0435\u043b\u0451\u043d\u043d\u0430\u044f \u043a\u0432\u0430\u0440\u0442\u0438\u0440\u0430, \u0441\u043e\u0441\u0435\u0434\u043d\u044f\u044f \u0441 \u043d\u0435\u0439. \n * \u041c\u0430\u043a\u0441\u0438\u043c \u0437\u043d\u0430\u0435\u0442, \u0447\u0442\u043e \u0432 \u0434\u043e\u043c\u0435 \u0437\u0430\u0441\u0435\u043b\u0435\u043d\u043e k \u043a\u0432\u0430\u0440\u0442\u0438\u0440, \u043d\u043e \u043a\u0430\u043a\u0438\u0435 \u0438\u043c\u0435\u043d\u043d\u043e, \u043e\u043d \u043f\u043e\u043a\u0430 \u043d\u0435 \u0437\u043d\u0430\u0435\u0442. \n\n\u041e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u0435, \u043a\u0430\u043a\u0438\u043c \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u0438 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u0447\u0438\u0441\u043b\u043e \u043a\u0432\u0430\u0440\u0442\u0438\u0440, \u043f\u043e\u0434\u0445\u043e\u0434\u044f\u0449\u0438\u0445 \u0434\u043b\u044f \u041c\u0430\u043a\u0441\u0438\u043c\u0430.\n\n\n\u0412\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435\n\n\u0412 \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0435 \u0432\u0445\u043e\u0434\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u0441\u044f \u0434\u0432\u0430 \u0446\u0435\u043b\u044b\u0445 \u0447\u0438\u0441\u043b\u0430 n \u0438 k (1\u2009\u2264\u2009n\u2009\u2264\u2009109, 0\u2009\u2264\u2009k\u2009\u2264\u2009n).\n\n\n\u0412\u044b\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435\n\n\u0412\u044b\u0432\u0435\u0434\u0438\u0442\u0435 \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0435 \u0438 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u044f\u0449\u0438\u0445 \u0434\u043b\u044f \u041c\u0430\u043a\u0441\u0438\u043c\u0430 \u043a\u0432\u0430\u0440\u0442\u0438\u0440.\n\n\n\u041f\u0440\u0438\u043c\u0435\u0440\n\n\n\n\u0412\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435\n6 3\n\n\n\n\u0412\u044b\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435\n1 3\n\n\n\n\u041f\u0440\u0438\u043c\u0435\u0447\u0430\u043d\u0438\u0435\n\n\u0412 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0438\u0437 \u0443\u0441\u043b\u043e\u0432\u0438\u044f \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u044f\u0449\u0438\u0445 \u0434\u043b\u044f \u041c\u0430\u043a\u0441\u0438\u043c\u0430 \u043a\u0432\u0430\u0440\u0442\u0438\u0440 \u0434\u043e\u0441\u0442\u0438\u0433\u0430\u0435\u0442\u0441\u044f, \u0435\u0441\u043b\u0438, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0437\u0430\u0441\u0435\u043b\u0435\u043d\u044b \u043a\u0432\u0430\u0440\u0442\u0438\u0440\u044b \u0441 \u043d\u043e\u043c\u0435\u0440\u0430\u043c\u0438 1, 2 \u0438 3, \n * \u0442\u043e\u0433\u0434\u0430 \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u043a\u0432\u0430\u0440\u0442\u0438\u0440\u0430 \u043d\u043e\u043c\u0435\u0440 4. \u041c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u0436\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0434\u043e\u0441\u0442\u0438\u0433\u0430\u0435\u0442\u0441\u044f \u0435\u0441\u043b\u0438, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0437\u0430\u0441\u0435\u043b\u0435\u043d\u044b \u043a\u0432\u0430\u0440\u0442\u0438\u0440\u044b \u0441 \u043d\u043e\u043c\u0435\u0440\u0430\u043c\u0438 1, 3, 5, \u0442\u043e\u0433\u0434\u0430 \u043f\u043e\u0434\u0445\u043e\u0434\u044f\u0442 \u043a\u0432\u0430\u0440\u0442\u0438\u0440\u044b \u0441 \u043d\u043e\u043c\u0435\u0440\u0430\u043c\u0438 2, 4 \u0438 6.\n\n\n \n */\n string st = Console.ReadLine().Trim();\n Char[] ch = new Char[] { ' ' };\n int[] nk= st.Split(ch).Select(int.Parse).ToArray();\n int res0; // \u043c\u0438\u043d\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e\n int res1; // \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e\n int tmp;\n if ((nk[1]==nk[0]) || (nk[1]==0)) {\n res0 = 0; \n } else {\n res0 = 1; // 1 \u0432 \u043b\u044e\u0431\u043e\u043c \u0434\u0440\u0443\u0433\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0442\u043a \u043e\u043d\u0438 \u0438\u0434\u0443\u0442 \u043f\u043e\u0434\u0440\u044f\u0434 \n }\n res1 = nk[1] * 2 < nk[0] - nk[1] ? nk[1] * 2 : nk[0] - nk[1];\n Console.Write(\"{0} {1}\",res0,res1 );\n \n //\u0432\u0441\u0435 \u0437\u0430\u0441\u0435\u043b\u0435\u043d\u044b \u0438\u043b\u0438 \u043d\u0438 \u043e\u0434\u043d\u0430 \u043d\u0435 \u0437\u0430\u0441\u0435\u043b\u0435\u043d\u0430 - \u043d\u0435 \u043f\u043e\u0434\u0445\u043e\u0434\u044f\u0442\n }\n static void Main(string[] args)\n {\n// SumsCodeForces smc = new SumsCodeForces();\n// smc.Sum429b() ;\n Sum854b();\n Console.ReadLine();\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "constructive algorithms"], "code_uid": "618b7cf33e6921e2bd6c23a36aefd675", "src_uid": "bdccf34b5a5ae13238c89a60814b9f86", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.IO;\nusing System.Text;\n\nnamespace Maxim_Buys_an_Apartment\n{\n internal class Program\n {\n private static readonly StreamReader reader = new StreamReader(Console.OpenStandardInput(1024*10), Encoding.ASCII, false, 1024*10);\n private static readonly StreamWriter writer = new StreamWriter(Console.OpenStandardOutput(1024*10), Encoding.ASCII, 1024*10);\n\n private static void Main(string[] args)\n {\n int n = Next();\n int k = Next();\n\n writer.Write(k == 0 || k == n ? \"0 \" : \"1 \");\n\n writer.WriteLine(Math.Min(n - k, 2*k));\n writer.Flush();\n }\n\n private static int Next()\n {\n int c;\n int res = 0;\n do\n {\n c = reader.Read();\n if (c == -1)\n return res;\n } while (c < '0' || c > '9');\n res = c - '0';\n while (true)\n {\n c = reader.Read();\n if (c < '0' || c > '9')\n return res;\n res *= 10;\n res += c - '0';\n }\n }\n }\n}", "lang_cluster": "C#", "tags": ["math", "constructive algorithms"], "code_uid": "cad66a8d30dae4a1b67a4abfaad1d061", "src_uid": "bdccf34b5a5ae13238c89a60814b9f86", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections;\nusing System.Collections.Generic;\nusing System.Text;\nusing System.IO;\n\npublic class Program\n{\n string go(int k, char[] a)\n {\n bool[] used = new bool[k];\n for (int c = 0; c < k; ++c) used[c] = false;\n \n int n = a.Length;\n for (int c = 0; c < n; ++c)\n if (a[c] != '?') used[a[c] - 'a'] = true;\n\n int i = 0, j = n - 1;\n for (; i < j; ++i, --j)\n {\n if (a[i] != '?' && a[j] != '?' && a[i] != a[j]) return \"IMPOSSIBLE\";\n if (a[i] != '?')\n {\n a[j] = a[i];\n continue;\n }\n if (a[j] != '?')\n {\n a[i] = a[j];\n continue;\n }\n }\n\n for (; j >= 0 && i < n; ++i, --j)\n {\n if (a[i] != '?') continue;\n \n int c = k - 1;\n while (c >= 0 && used[c]) --c;\n\n if (c < 0) c = 0;\n a[i] = a[j] = (char)(c + 'a');\n used[c] = true;\n }\n\n for (int c = 0; c < k; ++c)\n if (!used[c]) return \"IMPOSSIBLE\";\n\n return new string(a);\n }\n\n void doit()\n {\n int k = int.Parse(Console.ReadLine());\n char[] a = Console.ReadLine().ToCharArray();\n Console.WriteLine(go(k, a));\n }\n\n public static void Main(string[] args)\n {\n (new Program()).doit();\n }\n}\n", "lang_cluster": "C#", "tags": ["expression parsing"], "code_uid": "bf36468d6d0cbb92ffd37767541aed5c", "src_uid": "9d1dd9d722e5fe46823224334b3b208a", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeff#if DEBUG\nusing System.Reflection;\nusing System.Threading.Tasks;\n#endif\n\nusing System;\nusing System.Collections.Generic;\nusing System.IO;\nusing System.Linq;\nusing System.Text;\nusing System.Numerics;\nusing System.Globalization;\n\n\nnamespace _55c_\n{\n class Program\n {\n static string _inputFilename = \"input.txt\";\n static string _outputFilename = \"output.txt\";\n static bool _useFileInput = false;\n\n\n static void Main(string[] args)\n {\n StreamWriter file = null;\n#if DEBUG\n\t\t\tConsole.SetIn(getInput());\n#else\n if (_useFileInput)\n {\n Console.SetIn(File.OpenText(_inputFilename));\n file = new StreamWriter(_outputFilename);\n Console.SetOut(file);\n }\n#endif\n\n try\n {\n solution();\n }\n finally\n {\n if (_useFileInput)\n {\n file.Close();\n }\n }\n }\n\n static void solution()\n {\n #region SOLUTION\n var k = readInt();\n var s = Console.ReadLine();\n var ex = new int[26];\n for (int i = 0; i < s.Length; i++)\n {\n if (s[i] == '?')\n {\n continue;\n }\n\n var next = s[i] - 97;\n if (next >= k)\n {\n Console.WriteLine(\"IMPOSSIBLE\");\n return;\n }\n\n ex[next]++;\n }\n\n var free = 0;\n for (int i = 0; i < s.Length / 2; i++)\n {\n var qr = s.Length - 1 - i;\n if (s[i] == '?' && s[qr] == '?')\n {\n free++;\n }\n }\n\n if (s.Length % 2 == 1 && s[s.Length / 2] == '?')\n {\n free++;\n }\n\n var needed = 0;\n for (int i = 0; i < k; i++)\n {\n if (ex[i] == 0)\n {\n needed++;\n }\n }\n\n\n var ans = new int[s.Length];\n for (int i = 0; i < s.Length; i++)\n {\n ans[i] = s[i] != '?' ? s[i] - 97 : -1;\n }\n\n for (int i = 0; i < s.Length / 2; i++)\n {\n var qr = s.Length - 1 - i;\n if (s[i] != '?' && s[qr] != '?' && s[i] != s[qr])\n {\n Console.WriteLine(\"IMPOSSIBLE\");\n return;\n }\n\n if (s[i] != '?' && s[qr] != '?')\n {\n //ans[i] = s[i];\n continue;\n }\n\n if (s[i] == '?' && s[qr] == '?')\n {\n var tos = getFirst(ex, k, i, needed, free);\n free--;\n if (ex[tos] == 0)\n {\n needed--;\n }\n\n ex[tos]++;\n ans[i] = tos;\n ans[qr] = tos;\n \n \n continue;\n }\n\n var need = -1;\n if (s[i] != '?')\n {\n need = s[i] - 97;\n }\n else if (s[qr] != '?')\n {\n need = s[qr] - 97;\n }\n\n ex[need]++;\n ans[i] = need;\n ans[qr] = need;\n }\n\n if (s.Length % 2 == 1)\n {\n var mid = s.Length / 2;\n if (s[mid] == '?')\n {\n var tos = getFirst(ex, k, mid, needed, free);\n\n ex[tos]++;\n ans[mid] = tos;\n }\n }\n\n for (int i = 0; i < k; i++)\n {\n if (ex[i] == 0)\n {\n Console.WriteLine(\"IMPOSSIBLE\");\n return;\n }\n }\n\n var sb = new StringBuilder();\n for (int i = 0; i < ans.Length; i++)\n {\n sb.Append((char)(ans[i] + 97));\n }\n\n Console.WriteLine(sb);\n //var n = readInt();\n //var m = readInt();\n\n //var a = readIntArray();\n //var b = readIntArray();\n #endregion\n }\n\n static int getFirst(int[] counts, int k, int i, int needed, int free)\n {\n if (free > needed)\n {\n return 0;\n }\n\n var found = -1;\n for (int j = 0; j < 26; j++)\n {\n if (j >= k)\n {\n break;\n }\n\n if (counts[j] == 0)\n {\n found = j;\n break;\n }\n }\n\n if (found != -1)\n {\n return found;\n }\n else\n {\n return 0;\n }\n }\n\n static int readInt()\n {\n return int.Parse(Console.ReadLine());\n }\n\n static long readLong()\n {\n return long.Parse(Console.ReadLine());\n }\n\n static int[] readIntArray()\n {\n return Console.ReadLine().Split(' ').Where(i => !string.IsNullOrEmpty(i)).Select(i => int.Parse(i)).ToArray();\n }\n\n static long[] readLongArray()\n {\n return Console.ReadLine().Split(' ').Where(i => !string.IsNullOrEmpty(i)).Select(i => long.Parse(i)).ToArray();\n }\n\n#if DEBUG\n\t\tstatic StreamReader getInput()\n\t\t{\n\t\t\tvar resName = Assembly.GetCallingAssembly().GetManifestResourceNames()[0];\n\t\t\tvar resource = Assembly.GetCallingAssembly().GetManifestResourceStream(resName);\n\n\t\t\treturn new StreamReader(resource);\n\t\t}\n#endif\n }\n}\n", "lang_cluster": "C#", "tags": ["expression parsing"], "code_uid": "c20e5fc6f51998b9651b9220f589f99e", "src_uid": "9d1dd9d722e5fe46823224334b3b208a", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\n\nnamespace ProgrammingContest.Codeforces.Round55\n{\n class C\n {\n public static void Main()\n {\n int k = int.Parse(Console.ReadLine());\n string s = Console.ReadLine();\n int n = s.Length;\n bool[] used = new bool[26];\n for (int i = 0; i < n; i++)\n if (s[i] != '?')\n used[s[i] - 'a'] = true;\n char[] res = s.ToCharArray();\n\n for (int i = 0; i < n; i++)\n if (res[i] != '?' && res[n - 1 - i] == '?')\n res[n - 1 - i] = res[i];\n\n for (int i = k - 1; i >= 0; i--)\n if (!used[i])\n for (int j = n / 2; j >= 0; j--)\n if (res[j] == '?' && res[n - j - 1] == '?')\n {\n res[j] = res[n - j - 1] = (char)(i + 'a');\n used[i] = true;\n break;\n }\n\n for (int i = 0; i < n; i++)\n if (res[i] == '?' && res[n - 1 - i] == '?')\n res[n - 1 - i] = res[i] = 'a';\n\n for(int i = 0; i < k; i++)\n if (!used[i])\n {\n Console.WriteLine(\"IMPOSSIBLE\");\n return;\n }\n\n for (int i = 0; i < n; i++)\n if (res[i] != res[n - 1 - i])\n {\n Console.WriteLine(\"IMPOSSIBLE\");\n return;\n }\n\n Console.WriteLine(new string(res));\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["expression parsing"], "code_uid": "34cc4d5eb6c13d77302229034ad85ec4", "src_uid": "9d1dd9d722e5fe46823224334b3b208a", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Text;\nusing System.IO;\nusing System.Globalization;\nusing System.Collections.Generic;\nusing System.Linq;\n\nstatic class Extensions {\n\tpublic static T MyLast(this IList list) { return list[list.Count - 1]; }\n}\n\nclass App {\n\tstatic string Solve() {\n\t\tvar k = int.Parse(Console.ReadLine());\n\t\tvar s = Console.ReadLine().ToArray();\n\t\tvar n = s.Length;\n\t\tfor (var i = 0 ; i < n / 2 ; i++) if (s[n - 1 - i] != '?') {\n\t\t\tif (s[n - 1 - i] == s[i]) continue;\n\t\t\tif (s[i] != '?') return null;\n\t\t\ts[i] = s[n - 1 - i];\n\t\t}\n\t\tvar requiredChars = Enumerable.Range(0, k).Select(i => (char) ('a' + i)).ToArray();\n\t\t\n\t\tvar firstHalf = Enumerable.Range(0, (n + 1) / 2);\n\t\tvar spots = firstHalf.Count(i => s[i] == '?');\n\t\tvar currentChars = requiredChars.Count(s.Contains);\n\t\tvar missingChars = requiredChars.Where(c => !s.Contains(c)).ToArray();\n\t\tif (missingChars.Count() > spots) return null;\n\t\tforeach (var q in Enumerable.Range(0, spots - missingChars.Count())) {\n\t\t\tvar i = firstHalf.First(ix => s[ix] == '?');\n\t\t\ts[i] = 'a';\n\t\t}\n\t\tforeach (var c in missingChars) {\n\t\t\tvar i = firstHalf.First(ix => s[ix] == '?');\n\t\t\ts[i] = c;\n\t\t}\n\t\t\n\t\tforeach (var i in firstHalf) s[n - 1 - i] = s[i];\n\t\treturn new string(s);\n\t}\n\n\tstatic void Main() {\n\t\tConsole.WriteLine(Solve() ?? \"IMPOSSIBLE\");\n\t}\n}", "lang_cluster": "C#", "tags": ["expression parsing"], "code_uid": "dcecabfdff98e09c73c282368450f47b", "src_uid": "9d1dd9d722e5fe46823224334b3b208a", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\n\nnamespace Contest_59\n{\n class Program\n {\n static void A()\n {\n var s = Console.ReadLine();\n var a = new string[] { s.ToUpper(), s.ToLower() };\n int[] k = new int[2];\n\n for (int j = 0; j < 2; j++)\n {\n for (int i = 0; i < s.Length; i++)\n {\n if (s[i] == a[j][i])\n k[j]++;\n }\n }\n if (k[0] > k[1])\n Console.WriteLine(a[0]);\n else Console.WriteLine(a[1]);\n }\n\n static void B()\n {\n int n = int.Parse(Console.ReadLine());\n var t = Console.ReadLine().Split(' ');\n\n List a = new List();\n List b = new List();\n\n foreach (var s in t)\n {\n int k = int.Parse(s);\n if (k % 2 == 0)\n b.Add(k);\n else a.Add(k);\n }\n int sum = 0;\n int min = 0;\n if (a.Count == 0)\n {\n Console.WriteLine(0);\n return;\n }\n if (a.Count % 2 == 0)\n {\n min = a.Min();\n }\n\n foreach (var s in a)\n sum += s;\n foreach (var s in b)\n sum += s;\n sum -= min;\n Console.WriteLine(sum);\n }\n\n static void C()\n {\n int n = int.Parse(Console.ReadLine());\n char[] s = Console.ReadLine().ToCharArray();\n Dictionary d = new Dictionary();\n for (int i = 0; i < n; i++)\n d.Add((char)('a' + i), 0);\n int l = s.Length;\n bool ok = true;\n int needChar = 0;\n for (int i = 0, j = l - 1; i < l / 2; i++, j--)\n {\n if ((s[i] == '?') && (s[j] != '?')) { s[i] = s[j]; d[s[i]]++; }\n else if ((s[i] != '?') && (s[j] == '?'))\n {\n s[j] =\n s[i]; d[s[i]]++;\n }\n else if (s[i] != s[j])\n {\n ok = false;\n break;\n }\n else if (s[i] == '?') needChar++;\n else d[s[i]]++;\n }\n if (l % 2 == 1)\n {\n if (s[l / 2] == '?')\n needChar++;\n else\n d[s[l / 2]]++;\n }\n int used = 0;\n List unused = new List();\n foreach (var e in d)\n {\n if ((e.Key < 'a' + n) && (e.Value > 0))\n used++;\n else unused.Add(e.Key);\n }\n\n if (n - used > needChar)\n ok = false;\n if (ok)\n {\n for (int i = 0, j = l - 1; i <= l / 2; i++, j--)\n {\n if (s[i] == '?')\n {\n if (needChar > unused.Count)\n {\n s[i] = 'a';\n s[j] = 'a';\n }\n else\n {\n s[i] = unused[0];\n s[j] = unused[0];\n if (unused.Count > 1)\n unused.RemoveAt(0);\n }\n needChar--;\n }\n }\n\n for (int i = 0; i < s.Length; i++)\n Console.Write(s[i]);\n }\n else\n {\n Console.Write(\"IMPOSSIBLE\");\n }\n Console.WriteLine();\n }\n\n static void Main(string[] args)\n {\n C();\n }\n }\n}", "lang_cluster": "C#", "tags": ["expression parsing"], "code_uid": "4b27f0bc6070972a0705ffd0596c2c33", "src_uid": "9d1dd9d722e5fe46823224334b3b208a", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.IO;\nusing System.Linq;\n\nnamespace CodeForces\n{\n\tinternal class Template\n\t{\n\t\tprivate static readonly Scanner cin = new Scanner();\n\n\t\tprivate static void Main()\n\t\t{\n\t\t\t//Console.SetIn(new StreamReader(@\"C:\\CodeForces\\input.txt\"));\n\t\t\tnew Template().Solve();\n\t\t\tConsole.ReadLine();\n\t\t}\n\n\t\tprivate void Solve()\n\t\t{\n\t\t\tvar n = cin.NextInt();\n\t\t\tvar m = cin.NextInt();\n\t\t\tvar k = cin.NextInt();\n\t\t\tvar a = new int[n];\n\t\t\tfor (var i = 0; i < a.Length; i++)\n\t\t\t{\n\t\t\t\ta[i] = cin.NextInt();\n\t\t\t}\n\t\t\tArray.Sort(a);\n\t\t\tArray.Reverse(a);\n\t\t\tfor (var i = 0; i <= n; i++)\n\t\t\t{\n\t\t\t\tif (k >= m)\n\t\t\t\t{\n\t\t\t\t\tConsole.WriteLine(i);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif (i == n)\n\t\t\t\t{\n\t\t\t\t\tConsole.WriteLine(-1);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tk += a[i] - 1;\n\t\t\t}\n\t\t}\n\t}\n\n\tinternal class Scanner\n\t{\n\t\tprivate string[] s = new string[0];\n\t\tprivate int i;\n\t\tprivate readonly char[] cs = new[] { ' ' };\n\n\t\tpublic string Next()\n\t\t{\n\t\t\tif (i < s.Length) return s[i++];\n\t\t\tvar line = Console.ReadLine() ?? string.Empty;\n\t\t\ts = line.Split(cs, StringSplitOptions.RemoveEmptyEntries);\n\t\t\ti = 1;\n\t\t\treturn s.First();\n\t\t}\n\n\t\tpublic double NextDouble()\n\t\t{\n\t\t\treturn double.Parse(Next());\n\t\t}\n\n\t\tpublic int NextInt()\n\t\t{\n\t\t\treturn int.Parse(Next());\n\t\t}\n\n\t\tpublic long NextLong()\n\t\t{\n\t\t\treturn long.Parse(Next());\n\t\t}\n\t}\n}", "lang_cluster": "C#", "tags": ["sortings", "implementation", "greedy"], "code_uid": "a8a270ea044a35f2fd2a81c1ad03d1dc", "src_uid": "b32ab27503ee3c4196d6f0d0f133d13c", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Text;\nusing System.Collections;\nusing System.Diagnostics;\nusing System.IO;\nusing System.Text.RegularExpressions;\n\n\nnamespace ProjectEuler\n{\n class timepass\n {\n\n \n static void Main(string[] args)\n {\n Stopwatch stopWatch = new Stopwatch();\n stopWatch.Start();\n String s = Console.ReadLine();\n string[] values = s.Split(' ');\n\n int n = int.Parse(values[0]);\n int m = int.Parse(values[1]);\n int k = int.Parse(values[2]);\n\n s = Console.ReadLine();\n values = s.Split(' ');\n int[] filter = new int[n];\n for (int i = 0; i < n; i++)\n {\n filter[i] = int.Parse(values[i]);\n\n }\n Array.Sort(filter);\n Array.Reverse(filter);\n int count=0;\n while ((m > k) &&(count>();\n q.Enqueue(Tuple.Create(sr, sc, 0));\n int ans = 0;\n int step = 0;\n int badSubMask = ((1 << nb) - 1) << nt;\n while (q.Count > 0)\n {\n var nq = new Queue>();\n while (q.Count > 0)\n {\n int r = q.Peek().Item1;\n int c = q.Peek().Item2;\n int mask = q.Dequeue().Item3;\n\n if (r == sr && c == sc && (mask & badSubMask) == 0)\n {\n int s = 0;\n for (int i = 0; i < nt; i++)\n if ((mask >> i & 1) == 1)\n s += price[i];\n ans = Math.Max(ans, s - step);\n }\n\n for (int i = 0; i < 4; i++)\n {\n int nr = r + dr[i];\n int nc = c + dc[i];\n if (nr < 0 || nr == n || nc < 0 || nc == m || a[nr][nc] != '.' && a[nr][nc] != 'S')\n continue;\n int nmask = mask;\n if (i == 0)\n {\n for (int j = 0; j < nt + nb; j++)\n if (nr == pos[j][0] && nc < pos[j][1])\n nmask ^= 1 << j;\n }\n else if (i == 2)\n {\n for (int j = 0; j < nt + nb; j++)\n if (nr == pos[j][0] - 1 && nc < pos[j][1])\n nmask ^= 1 << j;\n }\n if (!f[nr, nc, nmask])\n {\n f[nr, nc, nmask] = true;\n nq.Enqueue(Tuple.Create(nr, nc, nmask));\n }\n }\n }\n q = nq;\n step++;\n }\n\n Write(ans);\n }\n \n #region Main\n\n protected static TextReader reader;\n protected static TextWriter writer;\n static void Main()\n {\n#if DEBUG\n reader = new StreamReader(\"..\\\\..\\\\input.txt\");\n //reader = new StreamReader(Console.OpenStandardInput());\n writer = Console.Out;\n //writer = new StreamWriter(\"..\\\\..\\\\output.txt\");\n#else\n reader = new StreamReader(Console.OpenStandardInput());\n writer = new StreamWriter(Console.OpenStandardOutput());\n //reader = new StreamReader(\"hull.in\");\n //writer = new StreamWriter(\"hull.out\");\n#endif\n try\n {\n// var thread = new Thread(new Solver().Solve, 1024 * 1024 * 128);\n// thread.Start();\n// thread.Join();\n new Solver().Solve(); \n }\n catch (Exception ex)\n {\n Console.WriteLine(ex);\n#if DEBUG\n#else\n throw;\n#endif\n }\n reader.Close();\n writer.Close();\n }\n\n #endregion\n\n #region Read / Write\n private static Queue currentLineTokens = new Queue();\n private static string[] ReadAndSplitLine() {return reader.ReadLine().Split(new[] { ' ', '\\t' }, StringSplitOptions.RemoveEmptyEntries);}\n public static string ReadToken(){while (currentLineTokens.Count == 0)currentLineTokens = new Queue(ReadAndSplitLine());return currentLineTokens.Dequeue();}\n public static int ReadInt(){return int.Parse(ReadToken());}\n public static long ReadLong(){return long.Parse(ReadToken());}\n public static double ReadDouble(){return double.Parse(ReadToken(), CultureInfo.InvariantCulture);}\n public static int[] ReadIntArray(){return ReadAndSplitLine().Select(int.Parse).ToArray();}\n public static long[] ReadLongArray(){return ReadAndSplitLine().Select(long.Parse).ToArray();}\n public static double[] ReadDoubleArray(){return ReadAndSplitLine().Select(s => double.Parse(s, CultureInfo.InvariantCulture)).ToArray();}\n public static int[][] ReadIntMatrix(int numberOfRows){int[][] matrix = new int[numberOfRows][];for (int i = 0; i < numberOfRows; i++)matrix[i] = ReadIntArray();return matrix;}\n public static int[][] ReadAndTransposeIntMatrix(int numberOfRows){int[][] matrix = ReadIntMatrix(numberOfRows);int[][] ret = new int[matrix[0].Length][];\n for (int i = 0; i < ret.Length; i++){ret[i] = new int[numberOfRows];for (int j = 0; j < numberOfRows; j++)ret[i][j] = matrix[j][i];}return ret;}\n public static string[] ReadLines(int quantity){string[] lines = new string[quantity];for (int i = 0; i < quantity; i++)lines[i] = reader.ReadLine().Trim();return lines;}\n public static void WriteArray(IEnumerable array){writer.WriteLine(string.Join(\" \", array));}\n public static void Write(params object[] array){WriteArray(array);}\n public static void WriteLines(IEnumerable array){foreach (var a in array)writer.WriteLine(a);}\n private class SDictionary : Dictionary{public new TValue this[TKey key]{\n get { return ContainsKey(key) ? base[key] : default(TValue); }set { base[key] = value; }}}\n private static T[] Init(int size) where T : new(){var ret = new T[size];for (int i = 0; i < size; i++)ret[i] = new T();return ret;}\n #endregion\n}", "lang_cluster": "C#", "tags": ["shortest paths", "bitmasks"], "code_uid": "cbcb953c2e46c0bce996dcb5e8a885e3", "src_uid": "624a0d6cf305fcf67d3f1cdc1c5fef8d", "difficulty": 2600.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.IO;\nusing System.Text;\n\nnamespace Gabriel_and_Caterpillar\n{\n internal class Program\n {\n private static readonly StreamReader reader = new StreamReader(Console.OpenStandardInput(1024*10), Encoding.ASCII, false, 1024*10);\n private static readonly StreamWriter writer = new StreamWriter(Console.OpenStandardOutput(1024*10), Encoding.ASCII, 1024*10);\n\n private static void Main(string[] args)\n {\n int h1 = Next(), h2 = Next(), a = Next(), b = Next();\n\n int delta = h2 - 8*a - h1;\n if (delta <= 0)\n writer.WriteLine(\"0\");\n else\n {\n if (a <= b)\n writer.WriteLine(\"-1\");\n else\n {\n writer.WriteLine(1 + (delta-1)/(12*(a - b)));\n }\n }\n\n writer.Flush();\n }\n\n private static int Next()\n {\n int c;\n int res = 0;\n do\n {\n c = reader.Read();\n if (c == -1)\n return res;\n } while (c < '0' || c > '9');\n res = c - '0';\n while (true)\n {\n c = reader.Read();\n if (c < '0' || c > '9')\n return res;\n res *= 10;\n res += c - '0';\n }\n }\n }\n}", "lang_cluster": "C#", "tags": ["math", "implementation"], "code_uid": "b238f131027c407187af8b3a0e42f8a4", "src_uid": "2c39638f07c3d789ba4c323a205487d7", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": ".NET Core C#", "source_code": "using System;\nusing System.Collections;\nusing System.Collections.Generic;\nusing System.Diagnostics;\nusing System.IO;\nusing System.Linq;\nusing System.Numerics;\nusing System.Text;\nusing System.Text.RegularExpressions;\nusing System.Threading.Tasks;\nusing static System.Math;\n\npublic static class P\n{\n public static void Main()\n {\n var h = Console.ReadLine().Split().Select(long.Parse).ToArray();\n var h1 = h[0];\n var h2 = h[1];\n var ab = Console.ReadLine().Split().Select(long.Parse).ToArray();\n h1 += ab[0] * 8;\n if (h2 <= h1)\n {\n Console.WriteLine(0);\n return;\n }\n if (ab[0] <= ab[1])\n {\n Console.WriteLine(-1);\n return;\n }\n int day = 1;\n while (true)\n {\n h1 -= ab[1] * 12;\n h1 += ab[0] * 12;\n if (h2 <= h1)\n {\n Console.WriteLine(day);\n return;\n }\n day++;\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "implementation"], "code_uid": "a2f6d5a5eb86c7702966c8b50e9ffcc6", "src_uid": "2c39638f07c3d789ba4c323a205487d7", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeff#if DEBUG\nusing System.Reflection;\nusing System.Threading.Tasks;\n#endif\n\nusing System;\nusing System.Collections.Generic;\nusing System.IO;\nusing System.Linq;\nusing System.Text;\nusing System.Numerics;\nusing System.Globalization;\n\n\nnamespace ed32d\n{\n class Program\n {\n static string _inputFilename = \"input.txt\";\n static string _outputFilename = \"output.txt\";\n static bool _useFileInput = false;\n\n\n static void Main(string[] args)\n {\n StreamWriter file = null;\n#if DEBUG\n\t\t\tConsole.SetIn(getInput());\n#else\n if (_useFileInput)\n {\n Console.SetIn(File.OpenText(_inputFilename));\n file = new StreamWriter(_outputFilename);\n Console.SetOut(file);\n }\n#endif\n\n try\n {\n solution();\n }\n finally\n {\n if (_useFileInput)\n {\n file.Close();\n }\n }\n }\n\n static void solution()\n {\n //var d1 = new Dictionary();\n //for (int i = 0; i < 4; i++)\n //{\n // for (int j = 0; j < 4; j++)\n // {\n // for (int m = 0; m < 4; m++)\n // {\n // for (int h = 0; h < 4; h++)\n // {\n // var val = string.Format(\"{0}{1}{2}{3}\", i + 1, j + 1, m + 1, h + 1);\n // if (i != 0 && j != 1 && m != 2 && h != 3 && !d1.ContainsKey(val))\n // {\n // if (i != j && i != m && i != h && j != m && j != h && m != h)\n // {\n // d1[val] = 1;\n // }\n \n // }\n // }\n // }\n // }\n //}\n\n\n #region SOLUTION\n var d = readLongArray();\n var n = d[0];\n var k = d[1];\n\n var total = 1L;\n if (k == 1)\n {\n Console.WriteLine(total);\n return;\n }\n\n total += (n * (n - 1) / 2);\n if (k == 2)\n {\n Console.WriteLine(total);\n return;\n }\n\n var c = (n * (n - 1) * (n - 2) / (2L * 3));\n total += (c * 2);\n if (k == 3)\n {\n Console.WriteLine(total);\n return;\n }\n\n var c2 = (n * (n - 1) * (n - 2) * (n - 3) / (2L * 3 * 4));\n total += (c2 * 9);\n\n if (k == 4)\n {\n Console.WriteLine(total);\n return;\n }\n\n //var n = readInt();\n //var m = readInt();\n\n //var a = readIntArray();\n //var b = readIntArray();\n #endregion\n }\n\n static int readInt()\n {\n return int.Parse(Console.ReadLine());\n }\n\n static long readLong()\n {\n return long.Parse(Console.ReadLine());\n }\n\n static int[] readIntArray()\n {\n return Console.ReadLine().Split(' ').Where(i => !string.IsNullOrEmpty(i)).Select(i => int.Parse(i)).ToArray();\n }\n\n static long[] readLongArray()\n {\n return Console.ReadLine().Split(' ').Where(i => !string.IsNullOrEmpty(i)).Select(i => long.Parse(i)).ToArray();\n }\n\n#if DEBUG\n\t\tstatic StreamReader getInput()\n\t\t{\n\t\t\tvar resName = Assembly.GetCallingAssembly().GetManifestResourceNames()[0];\n\t\t\tvar resource = Assembly.GetCallingAssembly().GetManifestResourceStream(resName);\n\n\t\t\treturn new StreamReader(resource);\n\t\t}\n#endif\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "dp", "combinatorics"], "code_uid": "b4231e44c9e8d9c120c06e059dee230e", "src_uid": "96d839dc2d038f8ae95fc47c217b2e2f", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Linq;\nusing CompLib.Util;\n\npublic class Program\n{\n int N, K;\n public void Solve()\n {\n checked\n {\n var sc = new Scanner();\n N = sc.NextInt();\n K = sc.NextInt();\n\n /*\n * n\u9806\u5217p\n * \n * n-k\u500b\u4ee5\u4e0a p_i = i\n * \n * \n */\n\n\n long ans = 0;\n for (int i = 0; i <= K; i++)\n {\n // i\u500b\u9078\u3076\n // i\u500b\u4e26\u3079\u308b\n // !i\n\n ans += C(N, i) * A(i);\n }\n ans++;\n\n Console.WriteLine(ans);\n }\n }\n\n long C(int n, int m)\n {\n long r = 1;\n for (int i = 0; i < m; i++)\n {\n r *= n - i;\n }\n\n for (int i = 1; i <= m; i++)\n {\n r /= i;\n }\n return r;\n }\n\n long A(int n)\n {\n if (n <= 1) return 0;\n if (n == 2) return 1;\n else return (n - 1) * (A(n - 1) + A(n - 2));\n }\n\n public static void Main(string[] args) => new Program().Solve();\n}\n\nnamespace CompLib.Util\n{\n using System;\n using System.Linq;\n\n class Scanner\n {\n private string[] _line;\n private int _index;\n private const char Separator = ' ';\n\n public Scanner()\n {\n _line = new string[0];\n _index = 0;\n }\n\n public string Next()\n {\n if (_index >= _line.Length)\n {\n string s;\n do\n {\n s = Console.ReadLine();\n } while (s.Length == 0);\n\n _line = s.Split(Separator);\n _index = 0;\n }\n\n return _line[_index++];\n }\n\n public string ReadLine()\n {\n _index = _line.Length;\n return Console.ReadLine();\n }\n\n public int NextInt() => int.Parse(Next());\n public long NextLong() => long.Parse(Next());\n public double NextDouble() => double.Parse(Next());\n public decimal NextDecimal() => decimal.Parse(Next());\n public char NextChar() => Next()[0];\n public char[] NextCharArray() => Next().ToCharArray();\n\n public string[] Array()\n {\n string s = Console.ReadLine();\n _line = s.Length == 0 ? new string[0] : s.Split(Separator);\n _index = _line.Length;\n return _line;\n }\n\n public int[] IntArray() => Array().Select(int.Parse).ToArray();\n public long[] LongArray() => Array().Select(long.Parse).ToArray();\n public double[] DoubleArray() => Array().Select(double.Parse).ToArray();\n public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "dp", "combinatorics"], "code_uid": "4f129916b35fd2b3f9aa19da6cd1cc24", "src_uid": "96d839dc2d038f8ae95fc47c217b2e2f", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\n\nclass Program\n{\n const int nMax = 53; // NOTE: Levels greater that 53 will be definately greater that any k.\n static string f0 = \"What are you doing at the end of the world? Are you busy? Will you save us?\";\n static string pa1 = \"What are you doing while sending \\\"\";\n static string pa2 = \"\\\"? Are you busy? Will you send \\\"\";\n static string pa3 = \"\\\"?\";\n static long[] fnLen = new long[nMax + 1];\n\n static void Main(string[] args)\n {\n fnLen[0] = f0.Length;\n for (var i = 1; i <= nMax; ++i)\n {\n fnLen[i] = 2 * fnLen[i - 1] + pa1.Length + pa2.Length + pa3.Length;\n }\n\n var q = int.Parse(Console.ReadLine());\n var answer = new char[q];\n for (var i = 0; i < q; ++i)\n {\n string[] input = Console.ReadLine().Split(' ');\n int n = int.Parse(input[0]);\n long k = long.Parse(input[1]) - 1;\n\n answer[i] = Scan(n, k) ?? '.';\n\n }\n Console.WriteLine(string.Join(string.Empty, answer));\n }\n\n static char? Scan(int n, long k)\n {\n if (n == 0 && f0.Length <= k)\n return null;\n\n if (n > 0 && n < nMax && (pa1.Length + fnLen[n - 1] + pa2.Length + fnLen[n - 1] + pa3.Length) <= k)\n return null;\n\n for (var l = n; l > 0; --l)\n {\n if (pa1.Length > k)\n {\n return pa1[(int)k];\n }\n k -= pa1.Length;\n if (l - 1 > nMax || fnLen[l - 1] > k)\n {\n continue;\n }\n k -= fnLen[l - 1];\n if (pa2.Length > k)\n {\n return pa2[(int)k];\n }\n k -= pa2.Length;\n if (l - 1 > nMax || fnLen[l - 1] > k)\n {\n continue;\n }\n k -= fnLen[l - 1];\n if (pa3.Length > k)\n {\n return pa3[(int)k];\n }\n }\n\n return f0[(int)k];\n }\n}\n", "lang_cluster": "C#", "tags": ["dfs and similar", "binary search"], "code_uid": "cf49274e3b08925e2fe87468823db56f", "src_uid": "da09a893a33f2bf8fd00e321e16ab149", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\n\nclass TEST{\n\tstatic void Main(){\n\t\tSol mySol =new Sol();\n\t\tmySol.Solve();\n\t}\n}\n\nclass Sol{\n\tpublic void Solve(){\n\t\t\n\t\tlong Inf = (long) 2e18;\n\t\tlong[][] L = new long[100001][];\n\t\tfor(int i=0;i<=100000;i++){\n\t\t\tL[i] = new long[5];\n\t\t}\t\n\t\t\n\t\tlong f = F.Length;\n\t\tlong s = S.Length;\n\t\tlong t = T.Length;\n\t\tlong u = U.Length;\n\t\tfor(int i=1;i<5;i++)L[0][i] = f;\n\t\tfor(int i=1;i<=100000;i++){\n\t\t\tlong tot = 0;\n\t\t\tL[i][0] = s;\n\t\t\ttot += s;\n\t\t\tL[i][1] = Math.Min(Inf,L[i][0] + L[i-1][4]);\n\t\t\tL[i][2] = Math.Min(Inf,L[i][1] + t);\n\t\t\tL[i][3] = Math.Min(Inf,L[i][2] + L[i-1][4]);\n\t\t\tL[i][4] = Math.Min(Inf,L[i][3] + u);\n\t\t}\n\t\t\n\t\tfor(int q = 0;q=0; i--){\n//Console.WriteLine(String.Join(\" \",L[i]));\n\t\t\t\tif(0 <= k & k < L[i][0]){\n\t\t\t\t\tConsole.Write(S[(int)k]);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tif(L[i][0] <= k && k < L[i][1]){\n\t\t\t\t\tif(i == 0){\n\t\t\t\t\t\tConsole.Write(F[(int)k]);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tk -= L[i][0];\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tif(L[i][1] <= k && k < L[i][2]){\n\t\t\t\t\tConsole.Write(T[(int)(k - L[i][1])]);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tif(L[i][2] <= k && k < L[i][3]){\n\t\t\t\t\tk -= L[i][2];\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tif(L[i][3] <= k && k < L[i][4]){\n\t\t\t\t\tConsole.Write( U[(int)(k - L[i][3])]);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tConsole.Write('.');break;\n\t\t\t}\n\t\t}\n\t\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t}\n\tString F = \"What are you doing at the end of the world? Are you busy? Will you save us?\";\n\tString S = \"What are you doing while sending \\\"\";\n\tString T = \"\\\"? Are you busy? Will you send \\\"\";\n\tString U = \"\\\"?\";\n\t\n\t\n\tint Q;\n\tint[] N;\n\tlong[] K;\n\tpublic Sol(){\n\t\tQ = ri();\n\t\tN = new int[Q];\n\t\tK = new long[Q];\n\t\tfor(int i=0;iint.Parse(e));}\n\tstatic long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}\n\tstatic double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}\n}\n", "lang_cluster": "C#", "tags": ["dfs and similar", "binary search"], "code_uid": "e12e78b46ae930ed4af3be504e691e22", "src_uid": "da09a893a33f2bf8fd00e321e16ab149", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "/*\ncsc -debug C.cs && mono --debug C.exe <<< \"10 2\"\n*/\n\nusing System;\nusing System.Collections;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading;\nusing System.Reflection;\n// using System.Numerics;\n\npublic class HelloWorld {\n public static void SolveCodeForces() {\n var x = cin.NUL();\n var n = cin.NUL();\n\n// var sieve = GetPrimeSieve(13);\n// var primes = new List();\n// for (var p = 2; p < sieve.Length; p++) if (!sieve[p]) primes.Add(p);\n// System.Console.WriteLine(\"Sieve: \" + primes.Join());\n // var sieve = GetPrimeSieve(100);\n var sieve = GetPrimeSieve(100000);\n\n var primeDivs = new HashSet();\n for (var p = 1ul; p * p <= x; p++)\n if (x % p == 0) {\n if (p > 1 && !sieve[p]) primeDivs.Add(p);\n var q = x / p;\n if (q > 1 && q != p && (int)q < sieve.Length && !sieve[q]) primeDivs.Add(q);\n if (q > 1 && q != p && (int)q >= sieve.Length && IsPrime(q)) primeDivs.Add(q);\n }\n if (primeDivs.Count == 0)\n primeDivs.Add(x);\n\n// System.Console.WriteLine(primeDivs.Join());\n\n var ans = 1ul;\n\n // BigInteger nn = n;\n\n foreach (var p in primeDivs) {\n var pow = 0ul;\n\n // var ppow = p;\n // while (ppow <= n) {\n // pow += n / ppow;\n // ppow *= p;\n // }\n\n // BigInteger ppow = p;\n // while (ppow <= nn) {\n // pow += n / (ulong)ppow;\n // ppow *= p;\n // }\n\n var ppow = 1ul;\n while (ppow <= n / p) {\n ppow *= p;\n pow += n / ppow;\n }\n\n var curr = ModPow(p, pow, MOD);\n\n ans = ans * curr % MOD;\n }\n\n System.Console.WriteLine(ans);\n }\n\n const ulong MOD = 1000000007ul;\n\n public static ulong ModPow(ulong x, ulong exp, ulong mod) {\n ulong ret = 1ul;\n while (exp > 0) {\n if (exp % 2 == 1) ret = ret * x % mod;\n x = x * x % mod;\n exp /= 2;\n }\n return ret;\n }\n\n static bool[] GetPrimeSieve(int max) {\n var sieve = new bool[max + 1];\n for (var a = 2; 2 * a <= max; a++) {\n if (!sieve[a]) {\n for (var b = 2 * a; b <= max; b += a)\n sieve[b] = true;\n }\n }\n return sieve;\n }\n\n public static bool IsPrime(ulong n) {\n if (n == 2) return true;\n\n if (n < 2 || n % 2 == 0)\n return false;\n\n var d = n - 1;\n var s = 0ul;\n while (d % 2 == 0) {\n d /= 2;\n s += 1;\n }\n\n var arr =\n n < 4759123141ul ? new ulong[] {2, 7, 61}\n : n < 341550071728321ul ? new ulong[] {2, 3, 5, 7, 11, 13, 17}\n : new ulong[] {2, 3, 5, 7, 11, 13, 17, 19, 23};\n\n foreach (var a in arr)\n {\n if (a >= n) return true;\n\n var x = ModPow(a, d, n);\n\n if (x == 1) continue;\n if (x == n - 1) continue;\n\n for (var r = 1ul; r < s; r++) {\n x = ModPow(x, 2, n);\n if (x == 1) return false;\n if (x == n - 1) break;\n }\n\n if (x != n - 1) return false;\n }\n return true;\n }\n\n // static bool IsPrime(ulong n) {\n // if (n <= (1ul << 14)) {\n // int x = (int) n;\n // if (x <= 4 || x % 2 == 0 || x % 3 == 0)\n // return x == 2 || x == 3;\n // for (int i = 5; i * i <= x; i += 6)\n // if (x % i == 0 || x % (i + 2) == 0)\n // return false;\n // return true;\n // }\n\n // ulong s = n - 1;\n // int t = 0;\n // while (s % 2 == 0) { s /= 2; ++t; }\n\n // foreach (var aa in new[] {2ul, 325ul, 9375ul, 28178ul, 450775ul, 9780504ul, 1795265022ul}) {\n // var a = aa;\n // if (!(a %= n))\n // return true;\n // ulong f = ModPow(a, s, n);\n // if (f == 1 || f == n - 1) continue;\n // for (int i = 1; i < t; ++i)\n // if ((f = mulmod(f, f, n)) == n - 1)\n // goto nextp;\n // return false;\n // nextp: ;\n // }\n // return true;\n // }\n\n static Scanner cin = new Scanner();\n static StringBuilder cout = new StringBuilder();\n\n static public void Main () {\n SolveCodeForces();\n // IncreaseStack(SolveCodeForces);\n // System.Console.Write(cout.ToString());\n }\n\n public static void IncreaseStack(ThreadStart action, int stackSize = 128000000)\n {\n var thread = new Thread(action, stackSize);\n thread.Start();\n thread.Join();\n }\n}\n\npublic static class Helpers {\n public static string Join(this IEnumerable arr, string sep = \" \") {\n return string.Join(sep, arr);\n }\n\n public static void Swap(ref T a, ref T b) {\n var tmp = a;\n a = b;\n b = tmp;\n }\n\n public static T[] CreateArray(int length, Func itemCreate) {\n var result = new T[length];\n for (var i = 0; i < result.Length; i++)\n result[i] = itemCreate(i);\n return result;\n }\n}\n\npublic class Scanner\n{\n private string[] line = new string[0];\n private int index = 0;\n\n public string Next() {\n if (line.Length <= index) {\n line = Console.ReadLine().Split(' ');\n index = 0;\n }\n var res = line[index];\n index++;\n return res;\n }\n\n public int NI() {\n return int.Parse(Next());\n }\n\n public long NL() {\n return long.Parse(Next());\n }\n\n public ulong NUL() {\n return ulong.Parse(Next());\n }\n\n public string[] Array() {\n line = Console.ReadLine().Split(' ');\n index = line.Length;\n return line;\n }\n\n public int[] NIA(int emptyPrefixLen = 0) {\n var array = Array();\n var result = new int[emptyPrefixLen + array.Length];\n for (int i = 0; i < array.Length; i++)\n result[emptyPrefixLen + i] = int.Parse(array[i]);\n return result;\n }\n\n public long[] NLA() {\n var array = Array();\n var result = new long[array.Length];\n for (int i = 0; i < array.Length; i++)\n result[i] = long.Parse(array[i]);\n return result;\n }\n\n public ulong[] NULA() {\n var array = Array();\n var result = new ulong[array.Length];\n for (int i = 0; i < array.Length; i++)\n result[i] = ulong.Parse(array[i]);\n return result;\n }\n}", "lang_cluster": "C#", "tags": ["math", "number theory"], "code_uid": "18badc4f5cfc3c50da542611ab977715", "src_uid": "04610fbaa746c083dda30e21fa6e1a0c", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "/*\ncsc -debug C.cs && mono --debug C.exe <<< \"\n*/\n\nusing System;\nusing System.Collections;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading;\nusing System.Reflection;\n\npublic class HelloWorld {\n public static void SolveCodeForces() {\n var x = cin.NUL();\n var n = cin.NUL();\n\n var divs = new List();\n for (var p = 2ul; p * p <= x; p++) {\n if (x % p == 0) {\n divs.Add(p);\n while (x % p == 0) x /= p;\n }\n }\n if (x > 1)\n divs.Add(x);\n\n// System.Console.WriteLine(divs.Join());\n\n var ans = 1ul;\n\n foreach (var p in divs) {\n var pow = 0ul;\n\n var ppow = 1ul;\n while (ppow <= n / p) {\n ppow *= p;\n pow += n / ppow;\n }\n\n ans = ans * ModPow(p, pow, MOD) % MOD;\n }\n\n System.Console.WriteLine(ans);\n }\n\n const ulong MOD = 1000000007ul;\n\n public static ulong ModPow(ulong x, ulong exp, ulong mod) {\n ulong ret = 1ul;\n while (exp > 0) {\n if (exp % 2 == 1) ret = ret * x % mod;\n x = x * x % mod;\n exp /= 2;\n }\n return ret;\n }\n\n static Scanner cin = new Scanner();\n static StringBuilder cout = new StringBuilder();\n\n static public void Main () {\n SolveCodeForces();\n // IncreaseStack(SolveCodeForces);\n // System.Console.Write(cout.ToString());\n }\n\n public static void IncreaseStack(ThreadStart action, int stackSize = 128000000)\n {\n var thread = new Thread(action, stackSize);\n thread.Start();\n thread.Join();\n }\n}\n\npublic static class Helpers {\n public static string Join(this IEnumerable arr, string sep = \" \") {\n return string.Join(sep, arr);\n }\n\n public static void Swap(ref T a, ref T b) {\n var tmp = a;\n a = b;\n b = tmp;\n }\n\n public static T[] CreateArray(int length, Func itemCreate) {\n var result = new T[length];\n for (var i = 0; i < result.Length; i++)\n result[i] = itemCreate(i);\n return result;\n }\n}\n\npublic class Scanner\n{\n private string[] line = new string[0];\n private int index = 0;\n\n public string Next() {\n if (line.Length <= index) {\n line = Console.ReadLine().Split(' ');\n index = 0;\n }\n var res = line[index];\n index++;\n return res;\n }\n\n public int NI() {\n return int.Parse(Next());\n }\n\n public long NL() {\n return long.Parse(Next());\n }\n\n public ulong NUL() {\n return ulong.Parse(Next());\n }\n\n public string[] Array() {\n line = Console.ReadLine().Split(' ');\n index = line.Length;\n return line;\n }\n\n public int[] NIA(int emptyPrefixLen = 0) {\n var array = Array();\n var result = new int[emptyPrefixLen + array.Length];\n for (int i = 0; i < array.Length; i++)\n result[emptyPrefixLen + i] = int.Parse(array[i]);\n return result;\n }\n\n public long[] NLA() {\n var array = Array();\n var result = new long[array.Length];\n for (int i = 0; i < array.Length; i++)\n result[i] = long.Parse(array[i]);\n return result;\n }\n\n public ulong[] NULA() {\n var array = Array();\n var result = new ulong[array.Length];\n for (int i = 0; i < array.Length; i++)\n result[i] = ulong.Parse(array[i]);\n return result;\n }\n}", "lang_cluster": "C#", "tags": ["math", "number theory"], "code_uid": "d49774850b6649914dc37f3c5a811c61", "src_uid": "04610fbaa746c083dda30e21fa6e1a0c", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.IO;\nusing System.Text.RegularExpressions;\nusing System.Threading.Tasks;\nusing System.Xml;\n\nnamespace ConsoleApplication1\n{\n class Program\n {\n static void Main(string[] args)\n {\n int n = int.Parse(System.Console.ReadLine());\n int m = int.Parse(System.Console.ReadLine());\n int[] benches = new int[n];\n for(int i=0;imx)\n {\n mx = benches[j];\n }\n }\n benches[bn]++;\n }\n bn=-1;\n for(int j=0;j mn)\n {\n bn = j;\n mn = benches[j];\n }\n }\n System.Console.WriteLine(String.Format(\"{0} {1}\", mn, mx + m));\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["implementation", "binary search"], "code_uid": "ad1b1c562c45b33079fd7384054473f0", "src_uid": "78f696bd954c9f0f9bb502e515d85a8d", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\n\nnamespace ConsoleApp1\n{\n class Program\n {\n static void Main(string[] args)\n {\n int numBenches = Convert.ToInt32(Console.ReadLine());\n int numExtraPeople = Convert.ToInt32(Console.ReadLine());\n int modifiedNumExtraPeople = numExtraPeople;\n int[] benches = new int[numBenches];\n for (int i = 0; i < numBenches; i++) benches[i] = Convert.ToInt32(Console.ReadLine());\n int maxPeopleCount = FindMax(benches);\n foreach (var i in benches) modifiedNumExtraPeople -= maxPeopleCount - i;\n modifiedNumExtraPeople = Math.Max(0, modifiedNumExtraPeople);\n Console.WriteLine(\"{0} {1}\", maxPeopleCount + Math.Ceiling((double)modifiedNumExtraPeople / numBenches), numExtraPeople + maxPeopleCount);\n }\n\n static int FindMax(int[] array)\n {\n int max = Int32.MinValue;\n foreach(var i in array)\n {\n if (i > max) max = i;\n }\n return max;\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["implementation", "binary search"], "code_uid": "833b3c40232335055357c977dfa69d3f", "src_uid": "78f696bd954c9f0f9bb502e515d85a8d", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\n\nnamespace CodeForces\n{\n static class Reader\n {\n public static int NextInt()\n {\n int ret = 0;\n char c;\n\n while (!char.IsDigit(c = (char)Console.Read()))\n {\n if (c == '-')\n return -NextInt();\n }\n do\n {\n ret = ret * 10 + c - '0';\n } while (char.IsDigit(c = (char)Console.Read()));\n\n return ret;\n }\n\n public static double NextDouble()\n {\n double ret = 0;\n char c;\n\n while (!char.IsDigit(c = (char)Console.Read())) \n {\n if (c == '-')\n return -NextDouble();\n }\n do\n {\n ret = ret * 10 + c - '0';\n } while (char.IsDigit(c = (char)Console.Read()));\n if (c != '.') return ret;\n\n double p10 = 0.1;\n while (char.IsDigit(c = (char)Console.Read()))\n {\n ret += p10 * (c - '0');\n p10 *= 0.1;\n }\n\n return ret;\n }\n\n public static string NextToken()\n {\n StringBuilder ret = new StringBuilder();\n char c;\n\n while (char.IsWhiteSpace(c = (char)Console.Read())) ;\n do\n {\n ret.Append(c);\n } while (!char.IsWhiteSpace(c = (char)Console.Read()));\n\n return ret.ToString();\n }\n }\n\n class Program\n {\n static int GCD(int n, int m)\n {\n return m > 0 ? GCD(m, n % m) : n;\n }\n\n static void Main(string[] args)\n {\n int a, b, x, y;\n\n a = Reader.NextInt();\n b = Reader.NextInt();\n x = Reader.NextInt();\n y = Reader.NextInt();\n\n int g = GCD(x, y);\n int m = Math.Min(a / (x / g), b / (y / g));\n\n Console.WriteLine(\"{0} {1}\", x / g * m, y / g * m);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["binary search", "number theory"], "code_uid": "9b94249620c843529b099c5ccdf073cf", "src_uid": "97999cd7c6de79a4e39f56a41ff59e7a", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Globalization;\nusing System.IO;\nusing System.Linq;\nusing System.Text;\nusing System.Threading;\n\n// (\u3065\u00b0\u03c9\u00b0)\u3065\uff90e\u2605\u309c\u30fb\u3002\u3002\u30fb\u309c\u309c\u30fb\u3002\u3002\u30fb\u309c\u2606\u309c\u30fb\u3002\u3002\u30fb\u309c\u309c\u30fb\u3002\u3002\u30fb\u309c\npublic class Solver\n{\n int Gcd(int a, int b)\n {\n return b > 0 ? Gcd(b, a % b) : a;\n }\n\n public void Solve()\n {\n int a = ReadInt();\n int b = ReadInt();\n int x = ReadInt();\n int y = ReadInt();\n\n int g = Gcd(x, y);\n x /= g;\n y /= g;\n\n if (a < x || b < y)\n Write(0, 0);\n else\n {\n int v = Math.Min(a / x, b / y);\n Write(x * v, y * v);\n }\n }\n\n #region Main\n\n protected static TextReader reader;\n protected static TextWriter writer;\n static void Main()\n {\n#if DEBUG\n reader = new StreamReader(\"..\\\\..\\\\input.txt\");\n //reader = new StreamReader(Console.OpenStandardInput());\n writer = Console.Out;\n //writer = new StreamWriter(\"..\\\\..\\\\output.txt\");\n#else\n reader = new StreamReader(Console.OpenStandardInput());\n writer = new StreamWriter(Console.OpenStandardOutput());\n //reader = new StreamReader(\"input.txt\");\n //writer = new StreamWriter(\"output.txt\");\n#endif\n try\n {\n new Solver().Solve();\n //var thread = new Thread(new Solver().Solve, 1024 * 1024 * 128);\n //thread.Start();\n //thread.Join();\n }\n catch (Exception ex)\n {\n Console.WriteLine(ex);\n#if DEBUG\n#else\n throw;\n#endif\n }\n reader.Close();\n writer.Close();\n }\n\n #endregion\n\n #region Read / Write\n private static Queue currentLineTokens = new Queue();\n private static string[] ReadAndSplitLine() { return reader.ReadLine().Split(new[] { ' ', '\\t', }, StringSplitOptions.RemoveEmptyEntries); }\n public static string ReadToken() { while (currentLineTokens.Count == 0)currentLineTokens = new Queue(ReadAndSplitLine()); return currentLineTokens.Dequeue(); }\n public static int ReadInt() { return int.Parse(ReadToken()); }\n public static long ReadLong() { return long.Parse(ReadToken()); }\n public static double ReadDouble() { return double.Parse(ReadToken(), CultureInfo.InvariantCulture); }\n public static int[] ReadIntArray() { return ReadAndSplitLine().Select(int.Parse).ToArray(); }\n public static long[] ReadLongArray() { return ReadAndSplitLine().Select(long.Parse).ToArray(); }\n public static double[] ReadDoubleArray() { return ReadAndSplitLine().Select(s => double.Parse(s, CultureInfo.InvariantCulture)).ToArray(); }\n public static int[][] ReadIntMatrix(int numberOfRows) { int[][] matrix = new int[numberOfRows][]; for (int i = 0; i < numberOfRows; i++)matrix[i] = ReadIntArray(); return matrix; }\n public static int[][] ReadAndTransposeIntMatrix(int numberOfRows)\n {\n int[][] matrix = ReadIntMatrix(numberOfRows); int[][] ret = new int[matrix[0].Length][];\n for (int i = 0; i < ret.Length; i++) { ret[i] = new int[numberOfRows]; for (int j = 0; j < numberOfRows; j++)ret[i][j] = matrix[j][i]; } return ret;\n }\n public static string[] ReadLines(int quantity) { string[] lines = new string[quantity]; for (int i = 0; i < quantity; i++)lines[i] = reader.ReadLine().Trim(); return lines; }\n public static void WriteArray(IEnumerable array) { writer.WriteLine(string.Join(\" \", array)); }\n public static void Write(params object[] array) { WriteArray(array); }\n public static void WriteLines(IEnumerable array) { foreach (var a in array)writer.WriteLine(a); }\n private class SDictionary : Dictionary\n {\n public new TValue this[TKey key]\n {\n get { return ContainsKey(key) ? base[key] : default(TValue); }\n set { base[key] = value; }\n }\n }\n private static T[] Init(int size) where T : new() { var ret = new T[size]; for (int i = 0; i < size; i++)ret[i] = new T(); return ret; }\n #endregion\n}", "lang_cluster": "C#", "tags": ["binary search", "number theory"], "code_uid": "3f7370599f21442e8e251be2ce7bc6ed", "src_uid": "97999cd7c6de79a4e39f56a41ff59e7a", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\n\nnamespace Contest\n{\n class Program\n {\n static void Main(string[] args)\n {\n string[] nm = Console.ReadLine().Split();\n long n = int.Parse(nm[0]);\n long m = long.Parse(nm[1]);\n long[] fact = new long[250005];\n fact[0] = 1;\n for (int i = 1; i <= n; i++)\n fact[i] = fact[i - 1] * i % m;\n long ret = 0;\n for (int i = 1; i <= n; i++)\n {\n ret += (n - i + 1) * (fact[i] * fact[n - i + 1] % m);\n ret %= m;\n }\n Console.WriteLine(ret);\n }\n }\n}", "lang_cluster": "C#", "tags": ["math", "combinatorics"], "code_uid": "fe0d55efdddf376ba657da14816f82fe", "src_uid": "020d5dae7157d937c3f58554c9b155f9", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections;\nusing System.Collections.Generic;\nusing System.Diagnostics;\nusing System.IO;\nusing System.Linq;\nusing System.Numerics;\nusing System.Text;\nusing System.Text.RegularExpressions;\nusing System.Threading.Tasks;\nusing static System.Math;\nusing MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;\nusing MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;\n\npublic static class P\n{\n static int MOD;\n\n public static void Main()\n {\n var nm = Console.ReadLine().Split().Select(int.Parse).ToArray();\n var n = nm[0];\n MOD = nm[1];\n long res = 0;\n for (int frameSize = 1; frameSize <= n; frameSize++)\n {\n res += (n - frameSize + 1) * Factorial(frameSize) % MOD * Factorial(n - frameSize + 1) % MOD;\n res %= MOD;\n }\n Console.WriteLine(res);\n }\n\n static List factorialMemo = new List() { 1 };\n static long Factorial(int x)\n {\n for (int i = factorialMemo.Count; i <= x; i++) factorialMemo.Add(factorialMemo.Last() * i % MOD);\n return factorialMemo[x];\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "combinatorics"], "code_uid": "d6b3296e139effc756d41a714100e4e2", "src_uid": "020d5dae7157d937c3f58554c9b155f9", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\n\nclass Myon\n{\n public Myon() { }\n static void Main(string[] args)\n {\n new Myon().calc();\n }\n\n void calc()\n {\n string[] board = new string[3];\n for (int i = 0; i < 3; i++)\n {\n board[i] = Console.ReadLine();\n }\n if (calc2(board)) Console.WriteLine(\"YES\");\n else Console.WriteLine(\"NO\");\n }\n\n bool calc2(string[] board)\n {\n for (int i = 0; i < 3; i++)\n {\n for (int j = 0; j < 3; j++)\n {\n if (board[i][j] != board[2 - i][2 - j]) return false;\n }\n }\n return true;\n }\n}", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "d97fd41a0ceb58ea0602c5fc65e7c130", "src_uid": "6a5fe5fac8a4e3993dc3423180cdd6a9", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nstatic class P {\n static void Main() {\n string s = \"\", r = \"YES\"; int i = 0;\n for (; i < 3; ++i) { s += Console.ReadLine(); }\n i = 0; int j = s.Length - 1;\n while (i < j) { if (s[i++] != s[j--]) { r = \"NO\"; break; } }\n Console.WriteLine(r);\n }\n}", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "13f8382147aff88e09368e307664c8f3", "src_uid": "6a5fe5fac8a4e3993dc3423180cdd6a9", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Diagnostics;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Runtime.InteropServices;\nusing Enu = System.Linq.Enumerable;\n\nclass Solution {\n void calc() {\n long p, q;\n rlo(out p, out q);\n int n = 5000000;\n var primes = sieveOfEratosthenes(n);\n //Console.WriteLine(primes.Count);\n //Console.WriteLine(Enu.Range(1, n).Count(e => isPalindorome(e)));\n int idx = 0;\n long pi = 0, rub = 0;\n int ans = 0, last = primes.Last();\n for(int i = 1; i <= last; i++) {\n if(primes[idx] == i) {\n pi++;\n idx++;\n }\n if(isPalindorome(i)) rub++;\n if(q * pi <= p * rub) {\n ans = i;\n }\n }\n if(ans > 0) Console.WriteLine(ans);\n else Console.WriteLine(\"Palindromic tree is better than splay tree\");\n }\n bool isPalindorome(int n) {\n string s = n.ToString();\n for(int i = 0; i < s.Length; i++) {\n if(s[i] != s[s.Length - 1 - i]) return false;\n }\n return true;\n }\n public static List sieveOfEratosthenes(int n) {\n List primes = new List();\n bool[] isPrime = Enumerable.Repeat(true, n + 1).ToArray();\n isPrime[0] = isPrime[1] = false;\n for(int i = 2; i <= n; i++) {\n if(isPrime[i]) {\n primes.Add(i);\n for(int j = 2 * i; j <= n; j += i) isPrime[j] = false;\n }\n }\n return primes;\n }\n\n static void Main(string[] args) {\n new Solution().calc();\n }\n\n #region\n static int ri() { return int.Parse(Console.ReadLine()); }\n static int[] ria(int n) {\n if(n <= 0) { Console.ReadLine(); return new int[0]; }\n else return Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();\n }\n static void rio(out int p1) { p1 = ri(); }\n static void rio(out int p1, out int p2) { var r = ria(2); p1 = r[0]; p2 = r[1]; }\n static void rio(out int p1, out int p2, out int p3) { var r = ria(3); p1 = r[0]; p2 = r[1]; p3 = r[2]; }\n static void rio(out int p1, out int p2, out int p3, out int p4) { var r = ria(4); p1 = r[0]; p2 = r[1]; p3 = r[2]; p4 = r[3]; }\n static void rio(out int p1, out int p2, out int p3, out int p4, out int p5) { var r = ria(5); p1 = r[0]; p2 = r[1]; p3 = r[2]; p4 = r[3]; p5 = r[4]; }\n static long rl() { return long.Parse(Console.ReadLine()); }\n static long[] rla(int n) {\n if(n <= 0) { Console.ReadLine(); return new long[0]; }\n else return Console.ReadLine().Trim().Split(' ').Select(long.Parse).ToArray();\n }\n static void rlo(out long p1) { p1 = rl(); }\n static void rlo(out long p1, out long p2) { var r = rla(2); p1 = r[0]; p2 = r[1]; }\n static void rlo(out long p1, out long p2, out long p3) { var r = rla(3); p1 = r[0]; p2 = r[1]; p3 = r[2]; }\n static void rlo(out long p1, out long p2, out long p3, out long p4) { var r = rla(4); p1 = r[0]; p2 = r[1]; p3 = r[2]; p4 = r[3]; }\n static void rlo(out long p1, out long p2, out long p3, out long p4, out long p5) { var r = rla(5); p1 = r[0]; p2 = r[1]; p3 = r[2]; p4 = r[3]; p5 = r[4]; }\n static double rd() { return double.Parse(Console.ReadLine()); }\n static double[] rda(int n) {\n if(n <= 0) { Console.ReadLine(); return new double[0]; }\n else return Console.ReadLine().Trim().Split(' ').Select(double.Parse).ToArray();\n }\n static void rdo(out double p1) { p1 = rd(); }\n static void rdo(out double p1, out double p2) { var r = rda(2); p1 = r[0]; p2 = r[1]; }\n static void rdo(out double p1, out double p2, out double p3) { var r = rda(3); p1 = r[0]; p2 = r[1]; p3 = r[2]; }\n static void rdo(out double p1, out double p2, out double p3, out double p4) { var r = rda(4); p1 = r[0]; p2 = r[1]; p3 = r[2]; p4 = r[3]; }\n static void rdo(out double p1, out double p2, out double p3, out double p4, out double p5) { var r = rda(5); p1 = r[0]; p2 = r[1]; p3 = r[2]; p4 = r[3]; p5 = r[4]; }\n static void swap(ref T x, ref T y) { T temp = x; x = y; y = temp; }\n static void wa1(T[] a) { Debug.WriteLine(string.Join(\" \", a)); }\n static void wa2(T[][] a) {\n foreach(var row in a) {\n Debug.WriteLine(String.Join(\" \", row));\n }\n }\n [DebuggerDisplay(\"{x} , {y}\")]\n class point {\n public T x, y;\n public point(T x, T y) {\n this.x = x; this.y = y;\n }\n }\n #endregion\n}\n\nstatic class Extention {\n public static T[][] ToJagArray(this T[,] a) {\n int n = a.GetLength(0), m = a.GetLength(1);\n var ret = new T[n][];\n for(int i = 0; i < n; i++) {\n ret[i] = new T[m];\n for(int j = 0; j < m; j++) {\n ret[i][j] = a[i, j];\n }\n }\n return ret;\n }\n\n public static bool InRange(this T[,] a, int i, int j) {\n int n = a.GetLength(0), m = a.GetLength(1);\n return 0 <= i && i < n && 0 <= j && j < m;\n }\n}\n\n", "lang_cluster": "C#", "tags": ["brute force", "math", "binary search", "number theory"], "code_uid": "8d44dc0075abdc6ddf7351bec348d21d", "src_uid": "e6e760164882b9e194a17663625be27d", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\n\nnamespace ConsoleApplication1\n{\n internal class C\n {\n private static void Main(string[] args)\n {\n int n = 7000000;\n bool[] prime = new bool[n + 1];\n prime = Array.ConvertAll(prime, b => b = true);\n prime[0] = prime[1] = false;\n for (int i = 2; i * i <= n; ++i)\n {\n if (prime[i])\n for (int j = 2; j <= n / i; j++)\n if (prime[i * j])\n prime[i * j] = false;\n }\n\n bool[] palim = new bool[n + 1];\n for (int i = 0; i < n; i++)\n {\n if (Reverse(i.ToString()) == i.ToString())\n palim[i] = true;\n }\n\n string[] s = Console.ReadLine().Split(' ');\n\n float p = float.Parse(s[0]);\n float q = float.Parse(s[1]);\n float pq = p / q;\n int t = 1;\n int ppcnt = 0;\n int prcnt = 0;\n int ppi = 0;\n int res = 0;\n int ppimax = pp.Length;\n while (t < n)\n {\n if (palim[t])\n {\n ppcnt++;\n ppi++;\n }\n if (prime[t])\n prcnt++;\n if (prcnt <= pq * ppcnt)\n {\n res = t;\n }\n t++;\n }\n Console.WriteLine(\"{0}\", res);\n }\n\n public static string Reverse(string s)\n {\n char[] charArray = s.ToCharArray();\n Array.Reverse(charArray);\n return new string(charArray);\n }\n\n static int[] pp = {1,2,3,4,5,6,7,8,9,11,22,33,44,55,66,77,88,99,101,111,121,131,141,151,161,171,181,191,202,212,222,232,242,252,262,272,282,292,303,313,323,333,343,353,363,373,383,393,404,414,424,434,444,454,464,474,484,494,505,515,525,535,545,555,565,575,585,595,606,616,626,636,646,656,666,676,686,696,707,717,727,737,747,757,767,777,787,797,808,818,828,838,848,858,868,878,888,898,909,919,929,939,949,959,969,979,989,999,1001,1111,1221,1331,1441,1551,1661,1771,1881,1991,2002,2112,2222,2332,2442,2552,2662,2772,2882,2992,3003,3113,3223,3333,3443,3553,3663,3773,3883,3993,4004,4114,4224,4334,4444,4554,4664,4774,4884,4994,5005,5115,5225,5335,5445,5555,5665,5775,5885,5995,6006,6116,6226,6336,6446,6556,6666,6776,6886,6996,7007,7117,7227,7337,7447,7557,7667,7777,7887,7997,8008,8118,8228,8338,8448,8558,8668,8778,8888,8998,9009,9119,9229,9339,9449,9559,9669,9779,9889,9999,10001,10101,10201,10301,10401,10501,10601,10701,10801,10901,11011,11111,11211,11311,11411,11511,11611,11711,11811,11911,12021,12121,12221,12321,12421,12521,12621,12721,12821,12921,13031,13131,13231,13331,13431,13531,13631,13731,13831,13931,14041,14141,14241,14341,14441,14541,14641,14741,14841,14941,15051,15151,15251,15351,15451,15551,15651,15751,15851,15951,16061,16161,16261,16361,16461,16561,16661,16761,16861,16961,17071,17171,17271,17371,17471,17571,17671,17771,17871,17971,18081,18181,18281,18381,18481,18581,18681,18781,18881,18981,19091,19191,19291,19391,19491,19591,19691,19791,19891,19991,20002,20102,20202,20302,20402,20502,20602,20702,20802,20902,21012,21112,21212,21312,21412,21512,21612,21712,21812,21912,22022,22122,22222,22322,22422,22522,22622,22722,22822,22922,23032,23132,23232,23332,23432,23532,23632,23732,23832,23932,24042,24142,24242,24342,24442,24542,24642,24742,24842,24942,25052,25152,25252,25352,25452,25552,25652,25752,25852,25952,26062,26162,26262,26362,26462,26562,26662,26762,26862,26962,27072,27172,27272,27372,27472,27572,27672,27772,27872,27972,28082,28182,28282,28382,28482,28582,28682,28782,28882,28982,29092,29192,29292,29392,29492,29592,29692,29792,29892,29992,30003,30103,30203,30303,30403,30503,30603,30703,30803,30903,31013,31113,31213,31313,31413,31513,31613,31713,31813,31913,32023,32123,32223,32323,32423,32523,32623,32723,32823,32923,33033,33133,33233,33333,33433,33533,33633,33733,33833,33933,34043,34143,34243,34343,34443,34543,34643,34743,34843,34943,35053,35153,35253,35353,35453,35553,35653,35753,35853,35953,36063,36163,36263,36363,36463,36563,36663,36763,36863,36963,37073,37173,37273,37373,37473,37573,37673,37773,37873,37973,38083,38183,38283,38383,38483,38583,38683,38783,38883,38983,39093,39193,39293,39393,39493,39593,39693,39793,39893,39993,40004,40104,40204,40304,40404,40504,40604,40704,40804,40904,41014,41114,41214,41314,41414,41514,41614,41714,41814,41914,42024,42124,42224,42324,42424,42524,42624,42724,42824,42924,43034,43134,43234,43334,43434,43534,43634,43734,43834,43934,44044,44144,44244,44344,44444,44544,44644,44744,44844,44944,45054,45154,45254,45354,45454,45554,45654,45754,45854,45954,46064,46164,46264,46364,46464,46564,46664,46764,46864,46964,47074,47174,47274,47374,47474,47574,47674,47774,47874,47974,48084,48184,48284,48384,48484,48584,48684,48784,48884,48984,49094,49194,49294,49394,49494,49594,49694,49794,49894,49994,50005,50105,50205,50305,50405,50505,50605,50705,50805,50905,51015,51115,51215,51315,51415,51515,51615,51715,51815,51915,52025,52125,52225,52325,52425,52525,52625,52725,52825,52925,53035,53135,53235,53335,53435,53535,53635,53735,53835,53935,54045,54145,54245,54345,54445,54545,54645,54745,54845,54945,55055,55155,55255,55355,55455,55555,55655,55755,55855,55955,56065,56165,56265,56365,56465,56565,56665,56765,56865,56965,57075,57175,57275,57375,57475,57575,57675,57775,57875,57975,58085,58185,58285,58385,58485,58585,58685,58785,58885,58985,59095,59195,59295,59395,59495,59595,59695,59795,59895,59995,60006,60106,60206,60306,60406,60506,60606,60706,60806,60906,61016,61116,61216,61316,61416,61516,61616,61716,61816,61916,62026,62126,62226,62326,62426,62526,62626,62726,62826,62926,63036,63136,63236,63336,63436,63536,63636,63736,63836,63936,64046,64146,64246,64346,64446,64546,64646,64746,64846,64946,65056,65156,65256,65356,65456,65556,65656,65756,65856,65956,66066,66166,66266,66366,66466,66566,66666,66766,66866,66966,67076,67176,67276,67376,67476,67576,67676,67776,67876,67976,68086,68186,68286,68386,68486,68586,68686,68786,68886,68986,69096,69196,69296,69396,69496,69596,69696,69796,69896,69996,70007,70107,70207,70307,70407,70507,70607,70707,70807,70907,71017,71117,71217,71317,71417,71517,71617,71717,71817,71917,72027,72127,72227,72327,72427,72527,72627,72727,72827,72927,73037,73137,73237,73337,73437,73537,73637,73737,73837,73937,74047,74147,74247,74347,74447,74547,74647,74747,74847,74947,75057,75157,75257,75357,75457,75557,75657,75757,75857,75957,76067,76167,76267,76367,76467,76567,76667,76767,76867,76967,77077,77177,77277,77377,77477,77577,77677,77777,77877,77977,78087,78187,78287,78387,78487,78587,78687,78787,78887,78987,79097,79197,79297,79397,79497,79597,79697,79797,79897,79997,80008,80108,80208,80308,80408,80508,80608,80708,80808,80908,81018,81118,81218,81318,81418,81518,81618,81718,81818,81918,82028,82128,82228,82328,82428,82528,82628,82728,82828,82928,83038,83138,83238,83338,83438,83538,83638,83738,83838,83938,84048,84148,84248,84348,84448,84548,84648,84748,84848,84948,85058,85158,85258,85358,85458,85558,85658,85758,85858,85958,86068,86168,86268,86368,86468,86568,86668,86768,86868,86968,87078,87178,87278,87378,87478,87578,87678,87778,87878,87978,88088,88188,88288,88388,88488,88588,88688,88788,88888,88988,89098,89198,89298,89398,89498,89598,89698,89798,89898,89998,90009,90109,90209,90309,90409,90509,90609,90709,90809,90909,91019,91119,91219,91319,91419,91519,91619,91719,91819,91919,92029,92129,92229,92329,92429,92529,92629,92729,92829,92929,93039,93139,93239,93339,93439,93539,93639,93739,93839,93939,94049,94149,94249,94349,94449,94549,94649,94749,94849,94949,95059,95159,95259,95359,95459,95559,95659,95759,95859,95959,96069,96169,96269,96369,96469,96569,96669,96769,96869,96969,97079,97179,97279,97379,97479,97579,97679,97779,97879,97979,98089,98189,98289,98389,98489,98589,98689,98789,98889,98989,99099,99199,99299,99399,99499,99599,99699,99799,99899,99999,100001,101101,102201,103301,104401,105501,106601,107701,108801,109901,110011,111111,112211,113311,114411,115511,116611,117711,118811,119911,120021,121121,122221,123321,124421,125521,126621,127721,128821,129921,130031,131131,132231,133331,134431,135531,136631,137731,138831,139931,140041,141141,142241,143341,144441,145541,146641,147741,148841,149941,150051,151151,152251,153351,154451,155551,156651,157751,158851,159951,160061,161161,162261,163361,164461,165561,166661,167761,168861,169961,170071,171171,172271,173371,174471,175571,176671,177771,178871,179971,180081,181181,182281,183381,184481,185581,186681,187781,188881,189981,190091,191191,192291,193391,194491,195591,196691,197791,198891,199991,200002,201102,202202,203302,204402,205502,206602,207702,208802,209902,210012,211112,212212,213312,214412,215512,216612,217712,218812,219912,220022,221122,222222,223322,224422,225522,226622,227722,228822,229922,230032,231132,232232,233332,234432,235532,236632,237732,238832,239932,240042,241142,242242,243342,244442,245542,246642,247742,248842,249942,250052,251152,252252,253352,254452,255552,256652,257752,258852,259952,260062,261162,262262,263362,264462,265562,266662,267762,268862,269962,270072,271172,272272,273372,274472,275572,276672,277772,278872,279972,280082,281182,282282,283382,284482,285582,286682,287782,288882,289982,290092,291192,292292,293392,294492,295592,296692,297792,298892,299992,300003,301103,302203,303303,304403,305503,306603,307703,308803,309903,310013,311113,312213,313313,314413,315513,316613,317713,318813,319913,320023,321123,322223,323323,324423,325523,326623,327723,328823,329923,330033,331133,332233,333333,334433,335533,336633,337733,338833,339933,340043,341143,342243,343343,344443,345543,346643,347743,348843,349943,350053,351153,352253,353353,354453,355553,356653,357753,358853,359953,360063,361163,362263,363363,364463,365563,366663,367763,368863,369963,370073,371173,372273,373373,374473,375573,376673,377773,378873,379973,380083,381183,382283,383383,384483,385583,386683,387783,388883,389983,390093,391193,392293,393393,394493,395593,396693,397793,398893,399993,400004,401104,402204,403304,404404,405504,406604,407704,408804,409904,410014,411114,412214,413314,414414,415514,416614,417714,418814,419914,420024,421124,422224,423324,424424,425524,426624,427724,428824,429924,430034,431134,432234,433334,434434,435534,436634,437734,438834,439934,440044,441144,442244,443344,444444,445544,446644,447744,448844,449944,450054,451154,452254,453354,454454,455554,456654,457754,458854,459954,460064,461164,462264,463364,464464,465564,466664,467764,468864,469964,470074,471174,472274,473374,474474,475574,476674,477774,478874,479974,480084,481184,482284,483384,484484,485584,486684,487784,488884,489984,490094,491194,492294,493394,494494,495594,496694,497794,498894,499994,500005,501105,502205,503305,504405,505505,506605,507705,508805,509905,510015,511115,512215,513315,514415,515515,516615,517715,518815,519915,520025,521125,522225,523325,524425,525525,526625,527725,528825,529925,530035,531135,532235,533335,534435,535535,536635,537735,538835,539935,540045,541145,542245,543345,544445,545545,546645,547745,548845,549945,550055,551155,552255,553355,554455,555555,556655,557755,558855,559955,560065,561165,562265,563365,564465,565565,566665,567765,568865,569965,570075,571175,572275,573375,574475,575575,576675,577775,578875,579975,580085,581185,582285,583385,584485,585585,586685,587785,588885,589985,590095,591195,592295,593395,594495,595595,596695,597795,598895,599995,600006,601106,602206,603306,604406,605506,606606,607706,608806,609906,610016,611116,612216,613316,614416,615516,616616,617716,618816,619916,620026,621126,622226,623326,624426,625526,626626,627726,628826,629926,630036,631136,632236,633336,634436,635536,636636,637736,638836,639936,640046,641146,642246,643346,644446,645546,646646,647746,648846,649946,650056,651156,652256,653356,654456,655556,656656,657756,658856,659956,660066,661166,662266,663366,664466,665566,666666,667766,668866,669966,670076,671176,672276,673376,674476,675576,676676,677776,678876,679976,680086,681186,682286,683386,684486,685586,686686,687786,688886,689986,690096,691196,692296,693396,694496,695596,696696,697796,698896,699996,700007,701107,702207,703307,704407,705507,706607,707707,708807,709907,710017,711117,712217,713317,714417,715517,716617,717717,718817,719917,720027,721127,722227,723327,724427,725527,726627,727727,728827,729927,730037,731137,732237,733337,734437,735537,736637,737737,738837,739937,740047,741147,742247,743347,744447,745547,746647,747747,748847,749947,750057,751157,752257,753357,754457,755557,756657,757757,758857,759957,760067,761167,762267,763367,764467,765567,766667,767767,768867,769967,770077,771177,772277,773377,774477,775577,776677,777777,778877,779977,780087,781187,782287,783387,784487,785587,786687,787787,788887,789987,790097,791197,792297,793397,794497,795597,796697,797797,798897,799997,800008,801108,802208,803308,804408,805508,806608,807708,808808,809908,810018,811118,812218,813318,814418,815518,816618,817718,818818,819918,820028,821128,822228,823328,824428,825528,826628,827728,828828,829928,830038,831138,832238,833338,834438,835538,836638,837738,838838,839938,840048,841148,842248,843348,844448,845548,846648,847748,848848,849948,850058,851158,852258,853358,854458,855558,856658,857758,858858,859958,860068,861168,862268,863368,864468,865568,866668,867768,868868,869968,870078,871178,872278,873378,874478,875578,876678,877778,878878,879978,880088,881188,882288,883388,884488,885588,886688,887788,888888,889988,890098,891198,892298,893398,894498,895598,896698,897798,898898,899998,900009,901109,902209,903309,904409,905509,906609,907709,908809,909909,910019,911119,912219,913319,914419,915519,916619,917719,918819,919919,920029,921129,922229,923329,924429,925529,926629,927729,928829,929929,930039,931139,932239,933339,934439,935539,936639,937739,938839,939939,940049,941149,942249,943349,944449,945549,946649,947749,948849,949949,950059,951159,952259,953359,954459,955559,956659,957759,958859,959959,960069,961169,962269,963369,964469,965569,966669,967769,968869,969969,970079,971179,972279,973379,974479,975579,976679,977779,978879,979979,980089,981189,982289,983389,984489,985589,986689,987789,988889,989989,990099,991199,992299,993399,994499,995599,996699,997799,998899,999999,1000001,1001001,1002001,1003001,1004001,1005001,1006001,1007001,1008001,1009001,1010101,1011101,1012101,1013101,1014101,1015101,1016101,1017101,1018101,1019101,1020201,1021201,1022201,1023201,1024201,1025201,1026201,1027201,1028201,1029201,1030301,1031301,1032301,1033301,1034301,1035301,1036301,1037301,1038301,1039301,1040401,1041401,1042401,1043401,1044401,1045401,1046401,1047401,1048401,1049401,1050501,1051501,1052501,1053501,1054501,1055501,1056501,1057501,1058501,1059501,1060601,1061601,1062601,1063601,1064601,1065601,1066601,1067601,1068601,1069601,1070701,1071701,1072701,1073701,1074701,1075701,1076701,1077701,1078701,1079701,1080801,1081801,1082801,1083801,1084801,1085801,1086801,1087801,1088801,1089801,1090901,1091901,1092901,1093901,1094901,1095901,1096901,1097901,1098901,1099901,1100011,1101011,1102011,1103011,1104011,1105011,1106011,1107011,1108011,1109011,1110111,1111111,1112111,1113111,1114111,1115111,1116111,1117111,1118111,1119111,1120211,1121211,1122211,1123211,1124211,1125211,1126211,1127211,1128211,1129211,1130311,1131311,1132311,1133311,1134311,1135311,1136311,1137311,1138311,1139311,1140411,1141411,1142411,1143411,1144411,1145411,1146411,1147411,1148411,1149411,1150511,1151511,1152511,1153511,1154511,1155511,1156511,1157511,1158511,1159511,1160611,1161611,1162611,1163611,1164611,1165611,1166611,1167611,1168611,1169611,1170711,1171711,1172711,1173711,1174711,1175711,1176711,1177711,1178711,1179711,1180811,1181811,1182811,1183811,1184811,1185811,1186811,1187811,1188811,1189811,1190911,1191911,1192911,1193911,1194911,1195911,1196911,1197911,1198911,1199911,1200021,1201021,1202021,1203021,1204021,1205021,1206021,1207021,1208021,1209021,1210121,1211121,1212121,1213121,1214121,1215121,1216121,1217121,1218121,1219121,1220221,1221221,1222221,1223221,1224221,1225221,1226221,1227221,1228221,1229221,1230321,1231321,1232321,1233321,1234321,1235321,1236321,1237321,1238321,1239321,1240421,1241421,1242421,1243421,1244421,1245421,1246421,1247421,1248421,1249421,1250521,1251521,1252521,1253521,1254521,1255521,1256521,1257521,1258521,1259521,1260621,1261621,1262621,1263621,1264621,1265621,1266621,1267621,1268621,1269621,1270721,1271721,1272721,1273721,1274721,1275721,1276721,1277721,1278721,1279721,1280821,1281821,1282821,1283821,1284821,1285821,1286821,1287821,1288821,1289821,1290921,1291921,1292921,1293921,1294921,1295921,1296921,1297921,1298921,1299921,1300031,1301031,1302031,1303031,1304031,1305031,1306031,1307031,1308031,1309031,1310131,1311131,1312131,1313131,1314131,1315131,1316131,1317131,1318131,1319131,1320231,1321231,1322231,1323231,1324231,1325231,1326231,1327231,1328231,1329231,1330331,1331331,1332331,1333331,1334331,1335331,1336331,1337331,1338331,1339331,1340431,1341431,1342431,1343431,1344431,1345431,1346431,1347431,1348431,1349431,1350531,1351531,1352531,1353531,1354531,1355531,1356531,1357531,1358531,1359531,1360631,1361631,1362631,1363631,1364631,1365631,1366631,1367631,1368631,1369631,1370731,1371731,1372731,1373731,1374731,1375731,1376731,1377731,1378731,1379731,1380831,1381831,1382831,1383831,1384831,1385831,1386831,1387831,1388831,1389831,1390931,1391931,1392931,1393931,1394931,1395931,1396931,1397931,1398931,1399931,1400041,1401041,1402041,1403041,1404041,1405041,1406041,1407041,1408041,1409041,1410141,1411141,1412141,1413141,1414141,1415141,1416141,1417141,1418141,1419141,1420241,1421241,1422241,1423241,1424241,1425241,1426241,1427241,1428241,1429241,1430341,1431341,1432341,1433341,1434341,1435341,1436341,1437341,1438341,1439341,1440441,1441441,1442441,1443441,1444441,1445441,1446441,1447441,1448441,1449441,1450541,1451541,1452541,1453541,1454541,1455541,1456541,1457541,1458541,1459541,1460641,1461641,1462641,1463641,1464641,1465641,1466641,1467641,1468641,1469641,1470741,1471741,1472741,1473741,1474741,1475741,1476741,1477741,1478741,1479741,1480841,1481841,1482841,1483841,1484841,1485841,1486841,1487841,1488841,1489841,1490941,1491941,1492941,1493941,1494941,1495941,1496941,1497941,1498941,1499941,1500051,1501051,1502051,1503051,1504051,1505051,1506051,1507051,1508051,1509051,1510151,1511151,1512151,1513151,1514151,1515151,1516151,1517151,1518151,1519151,1520251,1521251,1522251,1523251,1524251,1525251,1526251,1527251,1528251,1529251,1530351,1531351,1532351,1533351,1534351,1535351,1536351,1537351,1538351,1539351,1540451,1541451,1542451,1543451,1544451,1545451,1546451,1547451,1548451,1549451,1550551,1551551,1552551,1553551,1554551,1555551,1556551,1557551,1558551,1559551,1560651,1561651,1562651,1563651,1564651,1565651,1566651,1567651,1568651,1569651,1570751,1571751,1572751,1573751,1574751,1575751,1576751,1577751,1578751,1579751,1580851,1581851,1582851,1583851,1584851,1585851,1586851,1587851,1588851,1589851,1590951,1591951,1592951,1593951,1594951,1595951,1596951,1597951,1598951,1599951,1600061,1601061,1602061,1603061,1604061,1605061,1606061,1607061,1608061,1609061,1610161,1611161,1612161,1613161,1614161,1615161,1616161,1617161,1618161,1619161,1620261,1621261,1622261,1623261,1624261,1625261,1626261,1627261,1628261,1629261,1630361,1631361,1632361,1633361,1634361,1635361,1636361,1637361,1638361,1639361,1640461,1641461,1642461,1643461,1644461,1645461,1646461,1647461,1648461,1649461,1650561,1651561,1652561,1653561,1654561,1655561,1656561,1657561,1658561,1659561,1660661,1661661,1662661,1663661,1664661,1665661,1666661,1667661,1668661,1669661,1670761,1671761,1672761,1673761,1674761,1675761,1676761,1677761,1678761,1679761,1680861,1681861,1682861,1683861,1684861,1685861,1686861,1687861,1688861,1689861,1690961,1691961,1692961,1693961,1694961,1695961,1696961,1697961,1698961,1699961,1700071,1701071,1702071,1703071,1704071,1705071,1706071,1707071,1708071,1709071,1710171,1711171,1712171,1713171,1714171,1715171,1716171,1717171,1718171,1719171,1720271,1721271,1722271,1723271,1724271,1725271,1726271,1727271,1728271,1729271,1730371,1731371,1732371,1733371,1734371,1735371,1736371,1737371,1738371,1739371,1740471,1741471,1742471,1743471,1744471,1745471,1746471,1747471,1748471,1749471,1750571,1751571,1752571,1753571,1754571,1755571,1756571,1757571,1758571,1759571,1760671,1761671,1762671,1763671,1764671,1765671,1766671,1767671,1768671,1769671,1770771,1771771,1772771,1773771,1774771,1775771,1776771,1777771,1778771,1779771,1780871,1781871,1782871,1783871,1784871,1785871,1786871,1787871,1788871,1789871,1790971,1791971,1792971,1793971,1794971,1795971,1796971,1797971,1798971,1799971,1800081,1801081,1802081,1803081,1804081,1805081,1806081,1807081,1808081,1809081,1810181,1811181,1812181,1813181,1814181,1815181,1816181,1817181,1818181,1819181,1820281,1821281,1822281,1823281,1824281,1825281,1826281,1827281,1828281,1829281,1830381,1831381,1832381,1833381,1834381,1835381,1836381,1837381,1838381,1839381,1840481,1841481,1842481,1843481,1844481,1845481,1846481,1847481,1848481,1849481,1850581,1851581,1852581,1853581,1854581,1855581,1856581,1857581,1858581,1859581,1860681,1861681,1862681,1863681,1864681,1865681,1866681,1867681,1868681,1869681,1870781,1871781,1872781,1873781,1874781,1875781,1876781,1877781,1878781,1879781,1880881,1881881,1882881,1883881,1884881,1885881,1886881,1887881,1888881,1889881,1890981,1891981,1892981,1893981,1894981,1895981,1896981,1897981,1898981,1899981,1900091,1901091,1902091,1903091,1904091,1905091,1906091,1907091,1908091,1909091,1910191,1911191,1912191,1913191,1914191,1915191,1916191,1917191,1918191,1919191,1920291,1921291,1922291,1923291,1924291,1925291,1926291,1927291,1928291,1929291,1930391,1931391,1932391,1933391,1934391,1935391,1936391,1937391,1938391,1939391,1940491,1941491,1942491,1943491,1944491,1945491,1946491,1947491,1948491,1949491,1950591,1951591,1952591,1953591,1954591,1955591,1956591,1957591,1958591,1959591,1960691,1961691,1962691,1963691,1964691,1965691,1966691,1967691,1968691,1969691,1970791,1971791,1972791,1973791,1974791,1975791,1976791,1977791,1978791,1979791,1980891,1981891,1982891,1983891,1984891,1985891,1986891,1987891,1988891,1989891,1990991,1991991,1992991,1993991,1994991,1995991,1996991,1997991,1998991,1999991,2000002,2001002,2002002,2003002,2004002,2005002,2006002,2007002,2008002,2009002,2010102,2011102,2012102,2013102,2014102,2015102,2016102,2017102,2018102,2019102,2020202,2021202,2022202,2023202,2024202,2025202,2026202,2027202,2028202,2029202,2030302,2031302,2032302,2033302,2034302,2035302,2036302,2037302,2038302,2039302,2040402,2041402,2042402,2043402,2044402,2045402,2046402,2047402,2048402,2049402,2050502,2051502,2052502,2053502,2054502,2055502,2056502,2057502,2058502,2059502,2060602,2061602,2062602,2063602,2064602,2065602,2066602,2067602,2068602,2069602,2070702,2071702,2072702,2073702,2074702,2075702,2076702,2077702,2078702,2079702,2080802,2081802,2082802,2083802,2084802,2085802,2086802,2087802,2088802,2089802,2090902,2091902,2092902,2093902,2094902,2095902,2096902,2097902,2098902,2099902,2100012,2101012,2102012,2103012,2104012,2105012,2106012,2107012,2108012,2109012,2110112,2111112,2112112,2113112,2114112,2115112,2116112,2117112,2118112,2119112,2120212,2121212,2122212,2123212,2124212,2125212,2126212,2127212,2128212,2129212,2130312,2131312,2132312,2133312,2134312,2135312,2136312,2137312,2138312,2139312,2140412,2141412,2142412,2143412,2144412,2145412,2146412,2147412,2148412,2149412,2150512,2151512,2152512,2153512,2154512,2155512,2156512,2157512,2158512,2159512,2160612,2161612,2162612,2163612,2164612,2165612,2166612,2167612,2168612,2169612,2170712,2171712,2172712,2173712,2174712,2175712,2176712,2177712,2178712,2179712,2180812,2181812,2182812,2183812,2184812,2185812,2186812,2187812,2188812,2189812,2190912,2191912,2192912,2193912,2194912,2195912,2196912,2197912,2198912,2199912,2200022,2201022,2202022,2203022,2204022,2205022,2206022,2207022,2208022,2209022,2210122,2211122,2212122,2213122,2214122,2215122,2216122,2217122,2218122,2219122,2220222,2221222,2222222,2223222,2224222,2225222,2226222,2227222,2228222,2229222,2230322,2231322,2232322,2233322,2234322,2235322,2236322,2237322,2238322,2239322,2240422,2241422,2242422,2243422,2244422,2245422,2246422,2247422,2248422,2249422,2250522,2251522,2252522,2253522,2254522,2255522,2256522,2257522,2258522,2259522,2260622,2261622,2262622,2263622,2264622,2265622,2266622,2267622,2268622,2269622,2270722,2271722,2272722,2273722,2274722,2275722,2276722,2277722,2278722,2279722,2280822,2281822,2282822,2283822,2284822,2285822,2286822,2287822,2288822,2289822,2290922,2291922,2292922,2293922,2294922,2295922,2296922,2297922,2298922,2299922,2300032,2301032,2302032,2303032,2304032,2305032,2306032,2307032,2308032,2309032,2310132,2311132,2312132,2313132,2314132,2315132,2316132,2317132,2318132,2319132,2320232,2321232,2322232,2323232,2324232,2325232,2326232,2327232,2328232,2329232,2330332,2331332,2332332,2333332,2334332,2335332,2336332,2337332,2338332,2339332,2340432,2341432,2342432,2343432,2344432,2345432,2346432,2347432,2348432,2349432,2350532,2351532,2352532,2353532,2354532,2355532,2356532,2357532,2358532,2359532,2360632,2361632,2362632,2363632,2364632,2365632,2366632,2367632,2368632,2369632,2370732,2371732,2372732,2373732,2374732,2375732,2376732,2377732,2378732,2379732,2380832,2381832,2382832,2383832,2384832,2385832,2386832,2387832,2388832,2389832,2390932,2391932,2392932,2393932,2394932,2395932,2396932,2397932,2398932,2399932,2400042,2401042,2402042,2403042,2404042,2405042,2406042,2407042,2408042,2409042,2410142,2411142,2412142,2413142,2414142,2415142,2416142,2417142,2418142,2419142,2420242,2421242,2422242,2423242,2424242,2425242,2426242,2427242,2428242,2429242,2430342,2431342,2432342,2433342,2434342,2435342,2436342,2437342,2438342,2439342,2440442,2441442,2442442,2443442,2444442,2445442,2446442,2447442,2448442,2449442,2450542,2451542,2452542,2453542,2454542,2455542,2456542,2457542,2458542,2459542,2460642,2461642,2462642,2463642,2464642,2465642,2466642,2467642,2468642,2469642,2470742,2471742,2472742,2473742,2474742,2475742,2476742,2477742,2478742,2479742,2480842,2481842,2482842,2483842,2484842,2485842,2486842,2487842,2488842,2489842,2490942,2491942,2492942,2493942,2494942,2495942,2496942,2497942,2498942,2499942,2500052,2501052,2502052,2503052,2504052,2505052,2506052,2507052,2508052,2509052,2510152,2511152,2512152,2513152,2514152,2515152,2516152,2517152,2518152,2519152,2520252,2521252,2522252,2523252,2524252,2525252,2526252,2527252,2528252,2529252,2530352,2531352,2532352,2533352,2534352,2535352,2536352,2537352,2538352,2539352,2540452,2541452,2542452,2543452,2544452,2545452,2546452,2547452,2548452,2549452,2550552,2551552,2552552,2553552,2554552,2555552,2556552,2557552,2558552,2559552,2560652,2561652,2562652,2563652,2564652,2565652,2566652,2567652,2568652,2569652,2570752,2571752,2572752,2573752,2574752,2575752,2576752,2577752,2578752,2579752,2580852,2581852,2582852,2583852,2584852,2585852,2586852,2587852,2588852,2589852,2590952,2591952,2592952,2593952,2594952,2595952,2596952,2597952,2598952,2599952,2600062,2601062,2602062,2603062,2604062,2605062,2606062,2607062,2608062,2609062,2610162,2611162,2612162,2613162,2614162,2615162,2616162,2617162,2618162,2619162,2620262,2621262,2622262,2623262,2624262,2625262,2626262,2627262,2628262,2629262,2630362,2631362,2632362,2633362,2634362,2635362,2636362,2637362,2638362,2639362,2640462,2641462,2642462,2643462,2644462,2645462,2646462,2647462,2648462,2649462,2650562,2651562,2652562,2653562,2654562,2655562,2656562,2657562,2658562,2659562,2660662,2661662,2662662,2663662,2664662,2665662,2666662,2667662,2668662,2669662,2670762,2671762,2672762,2673762,2674762,2675762,2676762,2677762,2678762,2679762,2680862,2681862,2682862,2683862,2684862,2685862,2686862,2687862,2688862,2689862,2690962,2691962,2692962,2693962,2694962,2695962,2696962,2697962,2698962,2699962,2700072,2701072,2702072,2703072,2704072,2705072,2706072,2707072,2708072,2709072,2710172,2711172,2712172,2713172,2714172,2715172,2716172,2717172,2718172,2719172,2720272,2721272,2722272,2723272,2724272,2725272,2726272,2727272,2728272,2729272,2730372,2731372,2732372,2733372,2734372,2735372,2736372,2737372,2738372,2739372,2740472,2741472,2742472,2743472,2744472,2745472,2746472,2747472,2748472,2749472,2750572,2751572,2752572,2753572,2754572,2755572,2756572,2757572,2758572,2759572,2760672,2761672,2762672,2763672,2764672,2765672,2766672,2767672,2768672,2769672,2770772,2771772,2772772,2773772,2774772,2775772,2776772,2777772,2778772,2779772,2780872,2781872,2782872,2783872,2784872,2785872,2786872,2787872,2788872,2789872,2790972,2791972,2792972,2793972,2794972,2795972,2796972,2797972,2798972,2799972,2800082,2801082,2802082,2803082,2804082,2805082,2806082,2807082,2808082,2809082,2810182,2811182,2812182,2813182,2814182,2815182,2816182,2817182,2818182,2819182,2820282,2821282,2822282,2823282,2824282,2825282,2826282,2827282,2828282,2829282,2830382,2831382,2832382,2833382,2834382,2835382,2836382,2837382,2838382,2839382,2840482,2841482,2842482,2843482,2844482,2845482,2846482,2847482,2848482,2849482,2850582,2851582,2852582,2853582,2854582,2855582,2856582,2857582,2858582,2859582,2860682,2861682,2862682,2863682,2864682,2865682,2866682,2867682,2868682,2869682,2870782,2871782,2872782,2873782,2874782,2875782,2876782,2877782,2878782,2879782,2880882,2881882,2882882,2883882,2884882,2885882,2886882,2887882,2888882,2889882,2890982,2891982,2892982,2893982,2894982,2895982,2896982,2897982,2898982,2899982,2900092,2901092,2902092,2903092,2904092,2905092,2906092,2907092,2908092,2909092,2910192,2911192,2912192,2913192,2914192,2915192,2916192,2917192,2918192,2919192,2920292,2921292,2922292,2923292,2924292,2925292,2926292,2927292,2928292,2929292,2930392,2931392,2932392,2933392,2934392,2935392,2936392,2937392,2938392,2939392,2940492,2941492,2942492,2943492,2944492,2945492,2946492,2947492,2948492,2949492,2950592,2951592,2952592,2953592,2954592,2955592,2956592,2957592,2958592,2959592,2960692,2961692,2962692,2963692,2964692,2965692,2966692,2967692,2968692,2969692,2970792,2971792,2972792,2973792,2974792,2975792,2976792,2977792,2978792,2979792,2980892,2981892,2982892,2983892,2984892,2985892,2986892,2987892,2988892,2989892,2990992,2991992,2992992,2993992,2994992,2995992,2996992,2997992,2998992,2999992,3000003,3001003,3002003,3003003,3004003,3005003,3006003,3007003,3008003,3009003,3010103,3011103,3012103,3013103,3014103,3015103,3016103,3017103,3018103,3019103,3020203,3021203,3022203,3023203,3024203,3025203,3026203,3027203,3028203,3029203,3030303,3031303,3032303,3033303,3034303,3035303,3036303,3037303,3038303,3039303,3040403,3041403,3042403,3043403,3044403,3045403,3046403,3047403,3048403,3049403,3050503,3051503,3052503,3053503,3054503,3055503,3056503,3057503,3058503,3059503,3060603,3061603,3062603,3063603,3064603,3065603,3066603,3067603,3068603,3069603,3070703,3071703,3072703,3073703,3074703,3075703,3076703,3077703,3078703,3079703,3080803,3081803,3082803,3083803,3084803,3085803,3086803,3087803,3088803,3089803,3090903,3091903,3092903,3093903,3094903,3095903,3096903,3097903,3098903,3099903,3100013,3101013,3102013,3103013,3104013,3105013,3106013,3107013,3108013,3109013,3110113,3111113,3112113,3113113,3114113,3115113,3116113,3117113,3118113,3119113,3120213,3121213,3122213,3123213,3124213,3125213,3126213,3127213,3128213,3129213,3130313,3131313,3132313,3133313,3134313,3135313,3136313,3137313,3138313,3139313,3140413,3141413,3142413,3143413,3144413,3145413,3146413,3147413,3148413,3149413,3150513,3151513,3152513,3153513,3154513,3155513,3156513,3157513,3158513,3159513,3160613,3161613,3162613,3163613,3164613,3165613,3166613,3167613,3168613,3169613,3170713,3171713,3172713,3173713,3174713,3175713,3176713,3177713,3178713,3179713,3180813,3181813,3182813,3183813,3184813,3185813,3186813,3187813,3188813,3189813,3190913,3191913,3192913,3193913,3194913,3195913,3196913,3197913,3198913,3199913,3200023,3201023,3202023,3203023,3204023,3205023,3206023,3207023,3208023,3209023,3210123,3211123,3212123,3213123,3214123,3215123,3216123,3217123,3218123,3219123,3220223,3221223,3222223,3223223,3224223,3225223,3226223,3227223,3228223,3229223,3230323,3231323,3232323,3233323,3234323,3235323,3236323,3237323,3238323,3239323,3240423,3241423,3242423,3243423,3244423,3245423,3246423,3247423,3248423,3249423,3250523,3251523,3252523,3253523,3254523,3255523,3256523,3257523,3258523,3259523,3260623,3261623,3262623,3263623,3264623,3265623,3266623,3267623,3268623,3269623,3270723,3271723,3272723,3273723,3274723,3275723,3276723,3277723,3278723,3279723,3280823,3281823,3282823,3283823,3284823,3285823,3286823,3287823,3288823,3289823,3290923,3291923,3292923,3293923,3294923,3295923,3296923,3297923,3298923,3299923,3300033,3301033,3302033,3303033,3304033,3305033,3306033,3307033,3308033,3309033,3310133,3311133,3312133,3313133,3314133,3315133,3316133,3317133,3318133,3319133,3320233,3321233,3322233,3323233,3324233,3325233,3326233,3327233,3328233,3329233,3330333,3331333,3332333,3333333,3334333,3335333,3336333,3337333,3338333,3339333,3340433,3341433,3342433,3343433,3344433,3345433,3346433,3347433,3348433,3349433,3350533,3351533,3352533,3353533,3354533,3355533,3356533,3357533,3358533,3359533,3360633,3361633,3362633,3363633,3364633,3365633,3366633,3367633,3368633,3369633,3370733,3371733,3372733,3373733,3374733,3375733,3376733,3377733,3378733,3379733,3380833,3381833,3382833,3383833,3384833,3385833,3386833,3387833,3388833,3389833,3390933,3391933,3392933,3393933,3394933,3395933,3396933,3397933,3398933,3399933,3400043,3401043,3402043,3403043,3404043,3405043,3406043,3407043,3408043,3409043,3410143,3411143,3412143,3413143,3414143,3415143,3416143,3417143,3418143,3419143,3420243,3421243,3422243,3423243,3424243,3425243,3426243,3427243,3428243,3429243,3430343,3431343,3432343,3433343,3434343,3435343,3436343,3437343,3438343,3439343,3440443,3441443,3442443,3443443,3444443,3445443,3446443,3447443,3448443,3449443,3450543,3451543,3452543,3453543,3454543,3455543,3456543,3457543,3458543,3459543,3460643,3461643,3462643,3463643,3464643,3465643,3466643,3467643,3468643,3469643,3470743,3471743,3472743,3473743,3474743,3475743,3476743,3477743,3478743,3479743,3480843,3481843,3482843,3483843,3484843,3485843,3486843,3487843,3488843,3489843,3490943,3491943,3492943,3493943,3494943,3495943,3496943,3497943,3498943,3499943,3500053,3501053,3502053,3503053,3504053,3505053,3506053,3507053,3508053,3509053,3510153,3511153,3512153,3513153,3514153,3515153,3516153,3517153,3518153,3519153,3520253,3521253,3522253,3523253,3524253,3525253,3526253,3527253,3528253,3529253,3530353,3531353,3532353,3533353,3534353,3535353,3536353,3537353,3538353,3539353,3540453,3541453,3542453,3543453,3544453,3545453,3546453,3547453,3548453,3549453,3550553,3551553,3552553,3553553,3554553,3555553,3556553,3557553,3558553,3559553,3560653,3561653,3562653,3563653,3564653,3565653,3566653,3567653,3568653,3569653,3570753,3571753,3572753,3573753,3574753,3575753,3576753,3577753,3578753,3579753,3580853,3581853,3582853,3583853,3584853,3585853,3586853,3587853,3588853,3589853,3590953,3591953,3592953,3593953,3594953,3595953,3596953,3597953,3598953,3599953,3600063,3601063,3602063,3603063,3604063,3605063,3606063,3607063,3608063,3609063,3610163,3611163,3612163,3613163,3614163,3615163,3616163,3617163,3618163,3619163,3620263,3621263,3622263,3623263,3624263,3625263,3626263,3627263,3628263,3629263,3630363,3631363,3632363,3633363,3634363,3635363,3636363,3637363,3638363,3639363,3640463,3641463,3642463,3643463,3644463,3645463,3646463,3647463,3648463,3649463,3650563,3651563,3652563,3653563,3654563,3655563,3656563,3657563,3658563,3659563,3660663,3661663,3662663,3663663,3664663,3665663,3666663,3667663,3668663,3669663,3670763,3671763,3672763,3673763,3674763,3675763,3676763,3677763,3678763,3679763,3680863,3681863,3682863,3683863,3684863,3685863,3686863,3687863,3688863,3689863,3690963,3691963,3692963,3693963,3694963,3695963,3696963,3697963,3698963,3699963,3700073,3701073,3702073,3703073,3704073,3705073,3706073,3707073,3708073,3709073,3710173,3711173,3712173,3713173,3714173,3715173,3716173,3717173,3718173,3719173,3720273,3721273,3722273,3723273,3724273,3725273,3726273,3727273,3728273,3729273,3730373,3731373,3732373,3733373,3734373,3735373,3736373,3737373,3738373,3739373,3740473,3741473,3742473,3743473,3744473,3745473,3746473,3747473,3748473,3749473,3750573,3751573,3752573,3753573,3754573,3755573,3756573,3757573,3758573,3759573,3760673,3761673,3762673,3763673,3764673,3765673,3766673,3767673,3768673,3769673,3770773,3771773,3772773,3773773,3774773,3775773,3776773,3777773,3778773,3779773,3780873,3781873,3782873,3783873,3784873,3785873,3786873,3787873,3788873,3789873,3790973,3791973,3792973,3793973,3794973,3795973,3796973,3797973,3798973,3799973,3800083,3801083,3802083,3803083,3804083,3805083,3806083,3807083,3808083,3809083,3810183,3811183,3812183,3813183,3814183,3815183,3816183,3817183,3818183,3819183,3820283,3821283,3822283,3823283,3824283,3825283,3826283,3827283,3828283,3829283,3830383,3831383,3832383,3833383,3834383,3835383,3836383,3837383,3838383,3839383,3840483,3841483,3842483,3843483,3844483,3845483,3846483,3847483,3848483,3849483,3850583,3851583,3852583,3853583,3854583,3855583,3856583,3857583,3858583,3859583,3860683,3861683,3862683,3863683,3864683,3865683,3866683,3867683,3868683,3869683,3870783,3871783,3872783,3873783,3874783,3875783,3876783,3877783,3878783,3879783,3880883,3881883,3882883,3883883,3884883,3885883,3886883,3887883,3888883,3889883,3890983,3891983,3892983,3893983,3894983,3895983,3896983,3897983,3898983,3899983,3900093,3901093,3902093,3903093,3904093,3905093,3906093,3907093,3908093,3909093,3910193,3911193,3912193,3913193,3914193,3915193,3916193,3917193,3918193,3919193,3920293,3921293,3922293,3923293,3924293,3925293,3926293,3927293,3928293,3929293,3930393,3931393,3932393,3933393,3934393,3935393,3936393,3937393,3938393,3939393,3940493,3941493,3942493,3943493,3944493,3945493,3946493,3947493,3948493,3949493,3950593,3951593,3952593,3953593,3954593,3955593,3956593,3957593,3958593,3959593,3960693,3961693,3962693,3963693,3964693,3965693,3966693,3967693,3968693,3969693,3970793,3971793,3972793,3973793,3974793,3975793,3976793,3977793,3978793,3979793,3980893,3981893,3982893,3983893,3984893,3985893,3986893,3987893,3988893,3989893,3990993,3991993,3992993,3993993,3994993,3995993,3996993,3997993,3998993,3999993,4000004,4001004,4002004,4003004,4004004,4005004,4006004,4007004,4008004,4009004,4010104,4011104,4012104,4013104,4014104,4015104,4016104,4017104,4018104,4019104,4020204,4021204,4022204,4023204,4024204,4025204,4026204,4027204,4028204,4029204,4030304,4031304,4032304,4033304,4034304,4035304,4036304,4037304,4038304,4039304,4040404,4041404,4042404,4043404,4044404,4045404,4046404,4047404,4048404,4049404,4050504,4051504,4052504,4053504,4054504,4055504,4056504,4057504,4058504,4059504,4060604,4061604,4062604,4063604,4064604,4065604,4066604,4067604,4068604,4069604,4070704,4071704,4072704,4073704,4074704,4075704,4076704,4077704,4078704,4079704,4080804,4081804,4082804,4083804,4084804,4085804,4086804,4087804,4088804,4089804,4090904,4091904,4092904,4093904,4094904,4095904,4096904,4097904,4098904,4099904,4100014,4101014,4102014,4103014,4104014,4105014,4106014,4107014,4108014,4109014,4110114,4111114,4112114,4113114,4114114,4115114,4116114,4117114,4118114,4119114,4120214,4121214,4122214,4123214,4124214,4125214,4126214,4127214,4128214,4129214,4130314,4131314,4132314,4133314,4134314,4135314,4136314,4137314,4138314,4139314,4140414,4141414,4142414,4143414,4144414,4145414,4146414,4147414,4148414,4149414,4150514,4151514,4152514,4153514,4154514,4155514,4156514,4157514,4158514,4159514,4160614,4161614,4162614,4163614,4164614,4165614,4166614,4167614,4168614,4169614,4170714,4171714,4172714,4173714,4174714,4175714,4176714,4177714,4178714,4179714,4180814,4181814,4182814,4183814,4184814,4185814,4186814,4187814,4188814,4189814,4190914,4191914,4192914,4193914,4194914,4195914,4196914,4197914,4198914,4199914,4200024,4201024,4202024,4203024,4204024,4205024,4206024,4207024,4208024,4209024,4210124,4211124,4212124,4213124,4214124,4215124,4216124,4217124,4218124,4219124,4220224,4221224,4222224,4223224,4224224,4225224,4226224,4227224,4228224,4229224,4230324,4231324,4232324,4233324,4234324,4235324,4236324,4237324,4238324,4239324,4240424,4241424,4242424,4243424,4244424,4245424,4246424,4247424,4248424,4249424,4250524,4251524,4252524,4253524,4254524,4255524,4256524,4257524,4258524,4259524,4260624,4261624,4262624,4263624,4264624,4265624,4266624,4267624,4268624,4269624,4270724,4271724,4272724,4273724,4274724,4275724,4276724,4277724,4278724,4279724,4280824,4281824,4282824,4283824,4284824,4285824,4286824,4287824,4288824,4289824,4290924,4291924,4292924,4293924,4294924,4295924,4296924,4297924,4298924,4299924,4300034,4301034,4302034,4303034,4304034,4305034,4306034,4307034,4308034,4309034,4310134,4311134,4312134,4313134,4314134,4315134,4316134,4317134,4318134,4319134,4320234,4321234,4322234,4323234,4324234,4325234,4326234,4327234,4328234,4329234,4330334,4331334,4332334,4333334,4334334,4335334,4336334,4337334,4338334,4339334,4340434,4341434,4342434,4343434,4344434,4345434,4346434,4347434,4348434,4349434,4350534,4351534,4352534,4353534,4354534,4355534,4356534,4357534,4358534,4359534,4360634,4361634,4362634,4363634,4364634,4365634,4366634,4367634,4368634,4369634,4370734,4371734,4372734,4373734,4374734,4375734,4376734,4377734,4378734,4379734,4380834,4381834,4382834,4383834,4384834,4385834,4386834,4387834,4388834,4389834,4390934,4391934,4392934,4393934,4394934,4395934,4396934,4397934,4398934,4399934,4400044,4401044,4402044,4403044,4404044,4405044,4406044,4407044,4408044,4409044,4410144,4411144,4412144,4413144,4414144,4415144,4416144,4417144,4418144,4419144,4420244,4421244,4422244,4423244,4424244,4425244,4426244,4427244,4428244,4429244,4430344,4431344,4432344,4433344,4434344,4435344,4436344,4437344,4438344,4439344,4440444,4441444,4442444,4443444,4444444,4445444,4446444,4447444,4448444,4449444,4450544,4451544,4452544,4453544,4454544,4455544,4456544,4457544,4458544,4459544,4460644,4461644,4462644,4463644,4464644,4465644,4466644,4467644,4468644,4469644,4470744,4471744,4472744,4473744,4474744,4475744,4476744,4477744,4478744,4479744,4480844,4481844,4482844,4483844,4484844,4485844,4486844,4487844,4488844,4489844,4490944,4491944,4492944,4493944,4494944,4495944,4496944,4497944,4498944,4499944,4500054,4501054,4502054,4503054,4504054,4505054,4506054,4507054,4508054,4509054,4510154,4511154,4512154,4513154,4514154,4515154,4516154,4517154,4518154,4519154,4520254,4521254,4522254,4523254,4524254,4525254,4526254,4527254,4528254,4529254,4530354,4531354,4532354,4533354,4534354,4535354,4536354,4537354,4538354,4539354,4540454,4541454,4542454,4543454,4544454,4545454,4546454,4547454,4548454,4549454,4550554,4551554,4552554,4553554,4554554,4555554,4556554,4557554,4558554,4559554,4560654,4561654,4562654,4563654,4564654,4565654,4566654,4567654,4568654,4569654,4570754,4571754,4572754,4573754,4574754,4575754,4576754,4577754,4578754,4579754,4580854,4581854,4582854,4583854,4584854,4585854,4586854,4587854,4588854,4589854,4590954,4591954,4592954,4593954,4594954,4595954,4596954,4597954,4598954,4599954,4600064,4601064,4602064,4603064,4604064,4605064,4606064,4607064,4608064,4609064,4610164,4611164,4612164,4613164,4614164,4615164,4616164,4617164,4618164,4619164,4620264,4621264,4622264,4623264,4624264,4625264,4626264,4627264,4628264,4629264,4630364,4631364,4632364,4633364,4634364,4635364,4636364,4637364,4638364,4639364,4640464,4641464,4642464,4643464,4644464,4645464,4646464,4647464,4648464,4649464,4650564,4651564,4652564,4653564,4654564,4655564,4656564,4657564,4658564,4659564,4660664,4661664,4662664,4663664,4664664,4665664,4666664,4667664,4668664,4669664,4670764,4671764,4672764,4673764,4674764,4675764,4676764,4677764,4678764,4679764,4680864,4681864,4682864,4683864,4684864,4685864,4686864,4687864,4688864,4689864,4690964,4691964,4692964,4693964,4694964,4695964,4696964,4697964,4698964,4699964,4700074,4701074,4702074,4703074,4704074,4705074,4706074,4707074,4708074,4709074,4710174,4711174,4712174,4713174,4714174,4715174,4716174,4717174,4718174,4719174,4720274,4721274,4722274,4723274,4724274,4725274,4726274,4727274,4728274,4729274,4730374,4731374,4732374,4733374,4734374,4735374,4736374,4737374,4738374,4739374,4740474,4741474,4742474,4743474,4744474,4745474,4746474,4747474,4748474,4749474,4750574,4751574,4752574,4753574,4754574,4755574,4756574,4757574,4758574,4759574,4760674,4761674,4762674,4763674,4764674,4765674,4766674,4767674,4768674,4769674,4770774,4771774,4772774,4773774,4774774,4775774,4776774,4777774,4778774,4779774,4780874,4781874,4782874,4783874,4784874,4785874,4786874,4787874,4788874,4789874,4790974,4791974,4792974,4793974,4794974,4795974,4796974,4797974,4798974,4799974,4800084,4801084,4802084,4803084,4804084,4805084,4806084,4807084,4808084,4809084,4810184,4811184,4812184,4813184,4814184,4815184,4816184,4817184,4818184,4819184,4820284,4821284,4822284,4823284,4824284,4825284,4826284,4827284,4828284,4829284,4830384,4831384,4832384,4833384,4834384,4835384,4836384,4837384,4838384,4839384,4840484,4841484,4842484,4843484,4844484,4845484,4846484,4847484,4848484,4849484,4850584,4851584,4852584,4853584,4854584,4855584,4856584,4857584,4858584,4859584,4860684,4861684,4862684,4863684,4864684,4865684,4866684,4867684,4868684,4869684,4870784,4871784,4872784,4873784,4874784,4875784,4876784,4877784,4878784,4879784,4880884,4881884,4882884,4883884,4884884,4885884,4886884,4887884,4888884,4889884,4890984,4891984,4892984,4893984,4894984,4895984,4896984,4897984,4898984,4899984,4900094,4901094,4902094,4903094,4904094,4905094,4906094,4907094,4908094,4909094,4910194,4911194,4912194,4913194,4914194,4915194,4916194,4917194,4918194,4919194,4920294,4921294,4922294,4923294,4924294,4925294,4926294,4927294,4928294,4929294,4930394,4931394,4932394,4933394,4934394,4935394,4936394,4937394,4938394,4939394,4940494,4941494,4942494,4943494,4944494,4945494,4946494,4947494,4948494,4949494,4950594,4951594,4952594,4953594,4954594,4955594,4956594,4957594,4958594,4959594,4960694,4961694,4962694,4963694,4964694,4965694,4966694,4967694,4968694,4969694,4970794,4971794,4972794,4973794,4974794,4975794,4976794,4977794,4978794,4979794,4980894,4981894,4982894,4983894,4984894,4985894,4986894,4987894,4988894,4989894,4990994,4991994,4992994,4993994,4994994,4995994,4996994,4997994,4998994,4999994,5000005,5001005,5002005,5003005,5004005,5005005,5006005,5007005,5008005,5009005,5010105,5011105,5012105,5013105,5014105,5015105,5016105,5017105,5018105,5019105,5020205,5021205,5022205,5023205,5024205,5025205,5026205,5027205,5028205,5029205,5030305,5031305,5032305,5033305,5034305,5035305,5036305,5037305,5038305,5039305,5040405,5041405,5042405,5043405,5044405,5045405,5046405,5047405,5048405,5049405,5050505,5051505,5052505,5053505,5054505,5055505,5056505,5057505,5058505,5059505,5060605,5061605,5062605,5063605,5064605,5065605,5066605,5067605,5068605,5069605,5070705,5071705,5072705,5073705,5074705,5075705,5076705,5077705,5078705,5079705,5080805,5081805,5082805,5083805,5084805,5085805,5086805,5087805,5088805,5089805,5090905,5091905,5092905,5093905,5094905,5095905,5096905,5097905,5098905,5099905,5100015,5101015,5102015,5103015,5104015,5105015,5106015,5107015,5108015,5109015,5110115,5111115,5112115,5113115,5114115,5115115,5116115,5117115,5118115,5119115,5120215,5121215,5122215,5123215,5124215,5125215,5126215,5127215,5128215,5129215,5130315,5131315,5132315,5133315,5134315,5135315,5136315,5137315,5138315,5139315,5140415,5141415,5142415,5143415,5144415,5145415,5146415,5147415,5148415,5149415,5150515,5151515,5152515,5153515,5154515,5155515,5156515,5157515,5158515,5159515,5160615,5161615,5162615,5163615,5164615,5165615,5166615,5167615,5168615,5169615,5170715,5171715,5172715,5173715,5174715,5175715,5176715,5177715,5178715,5179715,5180815,5181815,5182815,5183815,5184815,5185815,5186815,5187815,5188815,5189815,5190915,5191915,5192915,5193915,5194915,5195915,5196915,5197915,5198915,5199915,5200025,5201025,5202025,5203025,5204025,5205025,5206025,5207025,5208025,5209025,5210125,5211125,5212125,5213125,5214125,5215125,5216125,5217125,5218125,5219125,5220225,5221225,5222225,5223225,5224225,5225225,5226225,5227225,5228225,5229225,5230325,5231325,5232325,5233325,5234325,5235325,5236325,5237325,5238325,5239325,5240425,5241425,5242425,5243425,5244425,5245425,5246425,5247425,5248425,5249425,5250525,5251525,5252525,5253525,5254525,5255525,5256525,5257525,5258525,5259525,5260625,5261625,5262625,5263625,5264625,5265625,5266625,5267625,5268625,5269625,5270725,5271725,5272725,5273725,5274725,5275725,5276725,5277725,5278725,5279725,5280825,5281825,5282825,5283825,5284825,5285825,5286825,5287825,5288825,5289825,5290925,5291925,5292925,5293925,5294925,5295925,5296925,5297925,5298925,5299925,5300035,5301035,5302035,5303035,5304035,5305035,5306035,5307035,5308035,5309035,5310135,5311135,5312135,5313135,5314135,5315135,5316135,5317135,5318135,5319135,5320235,5321235,5322235,5323235,5324235,5325235,5326235,5327235,5328235,5329235,5330335,5331335,5332335,5333335,5334335,5335335,5336335,5337335,5338335,5339335,5340435,5341435,5342435,5343435,5344435,5345435,5346435,5347435,5348435,5349435,5350535,5351535,5352535,5353535,5354535,5355535,5356535,5357535,5358535,5359535,5360635,5361635,5362635,5363635,5364635,5365635,5366635,5367635,5368635,5369635,5370735,5371735,5372735,5373735,5374735,5375735,5376735,5377735,5378735,5379735,5380835,5381835,5382835,5383835,5384835,5385835,5386835,5387835,5388835,5389835,5390935,5391935,5392935,5393935,5394935,5395935,5396935,5397935,5398935,5399935,5400045,5401045,5402045,5403045,5404045,5405045,5406045,5407045,5408045,5409045,5410145,5411145,5412145,5413145,5414145,5415145,5416145,5417145,5418145,5419145,5420245,5421245,5422245,5423245,5424245,5425245,5426245,5427245,5428245,5429245,5430345,5431345,5432345,5433345,5434345,5435345,5436345,5437345,5438345,5439345,5440445,5441445,5442445,5443445,5444445,5445445,5446445,5447445,5448445,5449445,5450545,5451545,5452545,5453545,5454545,5455545,5456545,5457545,5458545,5459545,5460645,5461645,5462645,5463645,5464645,5465645,5466645,5467645,5468645,5469645,5470745,5471745,5472745,5473745,5474745,5475745,5476745,5477745,5478745,5479745,5480845,5481845,5482845,5483845,5484845,5485845,5486845,5487845,5488845,5489845,5490945,5491945,5492945,5493945,5494945,5495945,5496945,5497945,5498945,5499945,5500055,5501055,5502055,5503055,5504055,5505055,5506055,5507055,5508055,5509055,5510155,5511155,5512155,5513155,5514155,5515155,5516155,5517155,5518155,5519155,5520255,5521255,5522255,5523255,5524255,5525255,5526255,5527255,5528255,5529255,5530355,5531355,5532355,5533355,5534355,5535355,5536355,5537355,5538355,5539355,5540455,5541455,5542455,5543455,5544455,5545455,5546455,5547455,5548455,5549455,5550555,5551555,5552555,5553555,5554555,5555555,5556555,5557555,5558555,5559555,5560655,5561655,5562655,5563655,5564655,5565655,5566655,5567655,5568655,5569655,5570755,5571755,5572755,5573755,5574755,5575755,5576755,5577755,5578755,5579755,5580855,5581855,5582855,5583855,5584855,5585855,5586855,5587855,5588855,5589855,5590955,5591955,5592955,5593955,5594955,5595955,5596955,5597955,5598955,5599955,5600065,5601065,5602065,5603065,5604065,5605065,5606065,5607065,5608065,5609065,5610165,5611165,5612165,5613165,5614165,5615165,5616165,5617165,5618165,5619165,5620265,5621265,5622265,5623265,5624265,5625265,5626265,5627265,5628265,5629265,5630365,5631365,5632365,5633365,5634365,5635365,5636365,5637365,5638365,5639365,5640465,5641465,5642465,5643465,5644465,5645465,5646465,5647465,5648465,5649465,5650565,5651565,5652565,5653565,5654565,5655565,5656565,5657565,5658565,5659565,5660665,5661665,5662665,5663665,5664665,5665665,5666665,5667665,5668665,5669665,5670765,5671765,5672765,5673765,5674765,5675765,5676765,5677765,5678765,5679765,5680865,5681865,5682865,5683865,5684865,5685865,5686865,5687865,5688865,5689865,5690965,5691965,5692965,5693965,5694965,5695965,5696965,5697965,5698965,5699965,5700075,5701075,5702075,5703075,5704075,5705075,5706075,5707075,5708075,5709075,5710175,5711175,5712175,5713175,5714175,5715175,5716175,5717175,5718175,5719175,5720275,5721275,5722275,5723275,5724275,5725275,5726275,5727275,5728275,5729275,5730375,5731375,5732375,5733375,5734375,5735375,5736375,5737375,5738375,5739375,5740475,5741475,5742475,5743475,5744475,5745475,5746475,5747475,5748475,5749475,5750575,5751575,5752575,5753575,5754575,5755575,5756575,5757575,5758575,5759575,5760675,5761675,5762675,5763675,5764675,5765675,5766675,5767675,5768675,5769675,5770775,5771775,5772775,5773775,5774775,5775775,5776775,5777775,5778775,5779775,5780875,5781875,5782875,5783875,5784875,5785875,5786875,5787875,5788875,5789875,5790975,5791975,5792975,5793975,5794975,5795975,5796975,5797975,5798975,5799975,5800085,5801085,5802085,5803085,5804085,5805085,5806085,5807085,5808085,5809085,5810185,5811185,5812185,5813185,5814185,5815185,5816185,5817185,5818185,5819185,5820285,5821285,5822285,5823285,5824285,5825285,5826285,5827285,5828285,5829285,5830385,5831385,5832385,5833385,5834385,5835385,5836385,5837385,5838385,5839385,5840485,5841485,5842485,5843485,5844485,5845485,5846485,5847485,5848485,5849485,5850585,5851585,5852585,5853585,5854585,5855585,5856585,5857585,5858585,5859585,5860685,5861685,5862685,5863685,5864685,5865685,5866685,5867685,5868685,5869685,5870785,5871785,5872785,5873785,5874785,5875785,5876785,5877785,5878785,5879785,5880885,5881885,5882885,5883885,5884885,5885885,5886885,5887885,5888885,5889885,5890985,5891985,5892985,5893985,5894985,5895985,5896985,5897985,5898985,5899985,5900095,5901095,5902095,5903095,5904095,5905095,5906095,5907095,5908095,5909095,5910195,5911195,5912195,5913195,5914195,5915195,5916195,5917195,5918195,5919195,5920295,5921295,5922295,5923295,5924295,5925295,5926295,5927295,5928295,5929295,5930395,5931395,5932395,5933395,5934395,5935395,5936395,5937395,5938395,5939395,5940495,5941495,5942495,5943495,5944495,5945495,5946495,5947495,5948495,5949495,5950595,5951595,5952595,5953595,5954595,5955595,5956595,5957595,5958595,5959595,5960695,5961695,5962695,5963695,5964695,5965695,5966695,5967695,5968695,5969695,5970795,5971795,5972795,5973795,5974795,5975795,5976795,5977795,5978795,5979795,5980895,5981895,5982895,5983895,5984895,5985895,5986895,5987895,5988895,5989895,5990995,5991995,5992995,5993995,5994995,5995995,5996995,5997995,5998995,5999995,6000006,6001006,6002006,6003006,6004006,6005006,6006006,6007006,6008006,6009006,6010106,6011106,6012106,6013106,6014106,6015106,6016106,6017106,6018106,6019106,6020206,6021206,6022206,6023206,6024206,6025206,6026206,6027206,6028206,6029206,6030306,6031306,6032306,6033306,6034306,6035306,6036306,6037306,6038306,6039306,6040406,6041406,6042406,6043406,6044406,6045406,6046406,6047406,6048406,6049406,6050506,6051506,6052506,6053506,6054506,6055506,6056506,6057506,6058506,6059506,6060606,6061606,6062606,6063606,6064606,6065606,6066606,6067606,6068606,6069606,6070706,6071706,6072706,6073706,6074706,6075706,6076706,6077706,6078706,6079706,6080806,6081806,6082806,6083806,6084806,6085806,6086806,6087806,6088806,6089806,6090906,6091906,6092906,6093906,6094906,6095906,6096906,6097906,6098906,6099906,6100016,6101016,6102016,6103016,6104016,6105016,6106016,6107016,6108016,6109016,6110116,6111116,6112116,6113116,6114116,6115116,6116116,6117116,6118116,6119116,6120216,6121216,6122216,6123216,6124216,6125216,6126216,6127216,6128216,6129216,6130316,6131316,6132316,6133316,6134316,6135316,6136316,6137316,6138316,6139316,6140416,6141416,6142416,6143416,6144416,6145416,6146416,6147416,6148416,6149416,6150516,6151516,6152516,6153516,6154516,6155516,6156516,6157516,6158516,6159516,6160616,6161616,6162616,6163616,6164616,6165616,6166616,6167616,6168616,6169616,6170716,6171716,6172716,6173716,6174716,6175716,6176716,6177716,6178716,6179716,6180816,6181816,6182816,6183816,6184816,6185816,6186816,6187816,6188816,6189816,6190916,6191916,6192916,6193916,6194916,6195916,6196916,6197916,6198916,6199916,6200026,6201026,6202026,6203026,6204026,6205026,6206026,6207026,6208026,6209026,6210126,6211126,6212126,6213126,6214126,6215126,6216126,6217126,6218126,6219126,6220226,6221226,6222226,6223226,6224226,6225226,6226226,6227226,6228226,6229226,6230326,6231326,6232326,6233326,6234326,6235326,6236326,6237326,6238326,6239326,6240426,6241426,6242426,6243426,6244426,6245426,6246426,6247426,6248426,6249426,6250526,6251526,6252526,6253526,6254526,6255526,6256526,6257526,6258526,6259526,6260626,6261626,6262626,6263626,6264626,6265626,6266626,6267626,6268626,6269626,6270726,6271726,6272726,6273726,6274726,6275726,6276726,6277726,6278726,6279726,6280826,6281826,6282826,6283826,6284826,6285826,6286826,6287826,6288826,6289826,6290926,6291926,6292926,6293926,6294926,6295926,6296926,6297926,6298926,6299926,6300036,6301036,6302036,6303036,6304036,6305036,6306036,6307036,6308036,6309036,6310136,6311136,6312136,6313136,6314136,6315136,6316136,6317136,6318136,6319136,6320236,6321236,6322236,6323236,6324236,6325236,6326236,6327236,6328236,6329236,6330336,6331336,6332336,6333336,6334336,6335336,6336336,6337336,6338336,6339336,6340436,6341436,6342436,6343436,6344436,6345436,6346436,6347436,6348436,6349436,6350536,6351536,6352536,6353536,6354536,6355536,6356536,6357536,6358536,6359536,6360636,6361636,6362636,6363636,6364636,6365636,6366636,6367636,6368636,6369636,6370736,6371736,6372736,6373736,6374736,6375736,6376736,6377736,6378736,6379736,6380836,6381836,6382836,6383836,6384836,6385836,6386836,6387836,6388836,6389836,6390936,6391936,6392936,6393936,6394936,6395936,6396936,6397936,6398936,6399936,6400046,6401046,6402046,6403046,6404046,6405046,6406046,6407046,6408046,6409046,6410146,6411146,6412146,6413146,6414146,6415146,6416146,6417146,6418146,6419146,6420246,6421246,6422246,6423246,6424246,6425246,6426246,6427246,6428246,6429246,6430346,6431346,6432346,6433346,6434346,6435346,6436346,6437346,6438346,6439346,6440446,6441446,6442446,6443446,6444446,6445446,6446446,6447446,6448446,6449446,6450546,6451546,6452546,6453546,6454546,6455546,6456546,6457546,6458546,6459546,6460646,6461646,6462646,6463646,6464646,6465646,6466646,6467646,6468646,6469646,6470746,6471746,6472746,6473746,6474746,6475746,6476746,6477746,6478746,6479746,6480846,6481846,6482846,6483846,6484846,6485846,6486846,6487846,6488846,6489846,6490946,6491946,6492946,6493946,6494946,6495946,6496946,6497946,6498946,6499946,6500056,6501056,6502056,6503056,6504056,6505056,6506056,6507056,6508056,6509056,6510156,6511156,6512156,6513156,6514156,6515156,6516156,6517156,6518156,6519156,6520256,6521256,6522256,6523256,6524256,6525256,6526256,6527256,6528256,6529256,6530356,6531356,6532356,6533356,6534356,6535356,6536356,6537356,6538356,6539356,6540456,6541456,6542456,6543456,6544456,6545456,6546456,6547456,6548456,6549456,6550556,6551556,6552556,6553556,6554556,6555556,6556556,6557556,6558556,6559556,6560656,6561656,6562656,6563656,6564656,6565656,6566656,6567656,6568656,6569656,6570756,6571756,6572756,6573756,6574756,6575756,6576756,6577756,6578756,6579756,6580856,6581856,6582856,6583856,6584856,6585856,6586856,6587856,6588856,6589856,6590956,6591956,6592956,6593956,6594956,6595956,6596956,6597956,6598956,6599956,6600066,6601066,6602066,6603066,6604066,6605066,6606066,6607066,6608066,6609066,6610166,6611166,6612166,6613166,6614166,6615166,6616166,6617166,6618166,6619166,6620266,6621266,6622266,6623266,6624266,6625266,6626266,6627266,6628266,6629266,6630366,6631366,6632366,6633366,6634366,6635366,6636366,6637366,6638366,6639366,6640466,6641466,6642466,6643466,6644466,6645466,6646466,6647466,6648466,6649466,6650566,6651566,6652566,6653566,6654566,6655566,6656566,6657566,6658566,6659566,6660666,6661666,6662666,6663666,6664666,6665666,6666666,6667666,6668666,6669666,6670766,6671766,6672766,6673766,6674766,6675766,6676766,6677766,6678766,6679766,6680866,6681866,6682866,6683866,6684866,6685866,6686866,6687866,6688866,6689866,6690966,6691966,6692966,6693966,6694966,6695966,6696966,6697966,6698966,6699966,6700076,6701076,6702076,6703076,6704076,6705076,6706076,6707076,6708076,6709076,6710176,6711176,6712176,6713176,6714176,6715176,6716176,6717176,6718176,6719176,6720276,6721276,6722276,6723276,6724276,6725276,6726276,6727276,6728276,6729276,6730376,6731376,6732376,6733376,6734376,6735376,6736376,6737376,6738376,6739376,6740476,6741476,6742476,6743476,6744476,6745476,6746476,6747476,6748476,6749476,6750576,6751576,6752576,6753576,6754576,6755576,6756576,6757576,6758576,6759576,6760676,6761676,6762676,6763676,6764676,6765676,6766676,6767676,6768676,6769676,6770776,6771776,6772776,6773776,6774776,6775776,6776776,6777776,6778776,6779776,6780876,6781876,6782876,6783876,6784876,6785876,6786876,6787876,6788876,6789876,6790976,6791976,6792976,6793976,6794976,6795976,6796976,6797976,6798976,6799976,6800086,6801086,6802086,6803086,6804086,6805086,6806086,6807086,6808086,6809086,6810186,6811186,6812186,6813186,6814186,6815186,6816186,6817186,6818186,6819186,6820286,6821286,6822286,6823286,6824286,6825286,6826286,6827286,6828286,6829286,6830386,6831386,6832386,6833386,6834386,6835386,6836386,6837386,6838386,6839386,6840486,6841486,6842486,6843486,6844486,6845486,6846486,6847486,6848486,6849486,6850586,6851586,6852586,6853586,6854586,6855586,6856586,6857586,6858586,6859586,6860686,6861686,6862686,6863686,6864686,6865686,6866686,6867686,6868686,6869686,6870786,6871786,6872786,6873786,6874786,6875786,6876786,6877786,6878786,6879786,6880886,6881886,6882886,6883886,6884886,6885886,6886886,6887886,6888886,6889886,6890986,6891986,6892986,6893986,6894986,6895986,6896986,6897986,6898986,6899986,6900096,6901096,6902096,6903096,6904096,6905096,6906096,6907096,6908096,6909096,6910196,6911196,6912196,6913196,6914196,6915196,6916196,6917196,6918196,6919196,6920296,6921296,6922296,6923296,6924296,6925296,6926296,6927296,6928296,6929296,6930396,6931396,6932396,6933396,6934396,6935396,6936396,6937396,6938396,6939396,6940496,6941496,6942496,6943496,6944496,6945496,6946496,6947496,6948496,6949496,6950596,6951596,6952596,6953596,6954596,6955596,6956596,6957596,6958596,6959596,6960696,6961696,6962696,6963696,6964696,6965696,6966696,6967696,6968696,6969696,6970796,6971796,6972796,6973796,6974796,6975796,6976796,6977796,6978796,6979796,6980896,6981896,6982896,6983896,6984896,6985896,6986896,6987896,6988896,6989896,6990996,6991996,6992996,6993996,6994996,6995996,6996996,6997996,6998996,6999996};\n}\n}", "lang_cluster": "C#", "tags": ["brute force", "math", "binary search", "number theory"], "code_uid": "45055dd08ab01a679238de51bc0d4810", "src_uid": "e6e760164882b9e194a17663625be27d", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Collections;\nusing System.Linq;\nusing System.Text;\nusing System.IO;\n\n\nnamespace ConsoleApplication1\n{\n class Program\n {\n static int N,equal;\n static string board;\n static List position = new List();\n\n\n static void Main(string[] args)\n {\n N = Convert.ToInt32(Console.ReadLine());\n board = Console.ReadLine();\n\n\n for (int i = 0; i < board.Length; ++i)\n if (board[i] == '*')\n position.Add(i+1);\n\n\n for(int a=0; a;\n\nclass Solver\n{\n public void Solve(Scanner sc)\n {\n var s = ReadLine().ToCharArray();\n var l = new List { new string(s) };\n for(var i = 0; i < s.Length; i++)\n {\n for (var j = s.Length - 1; j > 0; j--)\n swap(ref s[j], ref s[j - 1]);\n if (!l.Contains(new string(s)))\n l.Add(new string(s));\n\n }\n WriteLine(l.Count);\n }\n}\n\n#region Template\npublic static class Template\n{\n static void Main(string[] args)\n {\n Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });\n new Solver().Solve(new Scanner());\n Console.Out.Flush();\n }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static bool chmin(ref T a, T b) where T : IComparable\n { if (a.CompareTo(b) == 1) { a = b; return true; } return false; }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static bool chmax(ref T a, T b) where T : IComparable\n { if (a.CompareTo(b) == -1) { a = b; return true; } return false; }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static void swap(ref T a, ref T b)\n { var t = b; b = a; a = t; }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static T[] Create(int n, Func f)\n {\n var rt = new T[n];\n for (var i = 0; i < rt.Length; ++i)\n rt[i] = f();\n return rt;\n }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static T[] Create(int n, Func f)\n {\n var rt = new T[n];\n for (var i = 0; i < rt.Length; ++i)\n rt[i] = f(i);\n return rt;\n }\n public static void Fail(T s) { Console.WriteLine(s); Console.Out.Close(); Environment.Exit(0); }\n}\n\npublic class Scanner\n{\n public string Str => Console.ReadLine().Trim();\n public int Int => int.Parse(Str);\n public long Long => long.Parse(Str);\n public double Double => double.Parse(Str);\n public int[] ArrInt => Str.Split(' ').Select(int.Parse).ToArray();\n public long[] ArrLong => Str.Split(' ').Select(long.Parse).ToArray();\n public char[][] Grid(int n) => Create(n, () => Str.ToCharArray());\n public int[] ArrInt1D(int n) => Create(n, () => Int);\n public long[] ArrLong1D(int n) => Create(n, () => Long);\n public int[][] ArrInt2D(int n) => Create(n, () => ArrInt);\n public long[][] ArrLong2D(int n) => Create(n, () => ArrLong);\n public Pair PairMake() => new Pair(Next(), Next());\n public Pair PairMake() => new Pair(Next(), Next(), Next());\n private Queue q = new Queue();\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public T Next() { if (q.Count == 0) foreach (var item in Str.Split(' ')) q.Enqueue(item); return (T)Convert.ChangeType(q.Dequeue(), typeof(T)); }\n public void Make(out T1 v1) => v1 = Next();\n public void Make(out T1 v1, out T2 v2) { v1 = Next(); v2 = Next(); }\n public void Make(out T1 v1, out T2 v2, out T3 v3) { Make(out v1, out v2); v3 = Next(); }\n public void Make(out T1 v1, out T2 v2, out T3 v3, out T4 v4) { Make(out v1, out v2, out v3); v4 = Next(); }\n public void Make(out T1 v1, out T2 v2, out T3 v3, out T4 v4, out T5 v5) { Make(out v1, out v2, out v3, out v4); v5 = Next(); }\n public void Make(out T1 v1, out T2 v2, out T3 v3, out T4 v4, out T5 v5, out T6 v6) { Make(out v1, out v2, out v3, out v4, out v5); v6 = Next(); }\n}\n\npublic class Pair : IComparable>\n{\n public T1 v1;\n public T2 v2;\n public Pair() { }\n public Pair(T1 v1, T2 v2)\n { this.v1 = v1; this.v2 = v2; }\n\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public int CompareTo(Pair p)\n {\n var c = Comparer.Default.Compare(v1, p.v1);\n if (c == 0)\n c = Comparer.Default.Compare(v2, p.v2);\n return c;\n }\n public override string ToString() => $\"{v1.ToString()} {v2.ToString()}\";\n public void Tie(out T1 a, out T2 b) { a = v1; b = v2; }\n}\n\npublic class Pair : Pair, IComparable>\n{\n public T3 v3;\n public Pair() : base() { }\n public Pair(T1 v1, T2 v2, T3 v3) : base(v1, v2)\n { this.v3 = v3; }\n\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public int CompareTo(Pair p)\n {\n var c = base.CompareTo(p);\n if (c == 0)\n c = Comparer.Default.Compare(v3, p.v3);\n return c;\n }\n public override string ToString() => $\"{base.ToString()} {v3.ToString()}\";\n public void Tie(out T1 a, out T2 b, out T3 c) { Tie(out a, out b); c = v3; }\n}\n#endregion\n", "lang_cluster": "C#", "tags": ["strings", "implementation"], "code_uid": "476e63cb120ff98f78485da52dd12513", "src_uid": "8909ac99ed4ab2ee4d681ec864c7831e", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace ConsoleApplication1\n{\n\n\n class Program\n {\n \n public void SelectionSort(int []arr, int startIndx, int lastIndx) \n {\n if (startIndx >= lastIndx) return;\n\n int minIndx; \n int temp;\n\n minIndx = MinIndx( arr, startIndx, lastIndx);\n \n temp = arr[startIndx];\n arr[startIndx] = arr[minIndx];\n arr[minIndx] = temp;\n\n SelectionSort( arr, startIndx+1, lastIndx);\n }\n\n public int MinIndx( int[] arr, int startIndx, int lastIndx) \n {\n int minVal = arr[startIndx];\n int minIndx = startIndx;\n for (int i = startIndx; i < arr.Length; ++i) \n {\n if (arr[i] < minVal) \n {\n minVal = arr[i];\n minIndx = i;\n }\n }\n return minIndx;\n }\n\n public void PrintArr(int []arr) \n {\n for (int i = 0; i < arr.Length; ++i)\n {\n Console.WriteLine(arr[i]);\n }\n }\n\n public void SelectionSortIt(int []arr)\n {\n for (int i = 0; i < arr.Length; ++i) \n {\n int minIndx = MinIndx(arr, i, arr.Length);\n int temp = arr[i];\n arr[i] = arr[minIndx];\n arr[minIndx] = temp;\n }\n }\n\n public void InsertionSort(int []arr)\n {\n //12, 11, 13, 5, 6\n int len = arr.Length;\n for (int i = 1; i < len; ++i ) \n {\n int j = i;\n while(j > 0 && arr[j] < arr[j-1])\n {\n int temp = arr[j];\n arr[j] = arr[j - 1];\n arr[j - 1] = temp;\n --j;\n }\n }\n }\n\n public void BubbleSort(int []arr)\n {\n int len = arr.Length;\n for (int i = 0; i < len; ++i )\n {\n for (int j = 0; j < len-1; ++j)\n {\n if (arr[j + 1] < arr[j]) \n {\n int temp = arr[j];\n arr[j] = arr[j + 1];\n arr[j + 1] = temp;\n }\n }\n }\n }\n\n public void Partion(int []arr, int low, int high) \n {\n \n }\n\n public int GetSpaces(string str, int i)\n {\n if(i>=str.Length) return 0;\n return (str[i] == ' ') ? 1 + GetSpaces(str, i + 1) : GetSpaces(str, i + 1);\n }\n\n\n public string WayTooLongWords(string word) \n {\n string abbr = \"\";\n if (word.Length <= 10)\n {\n abbr = word;\n }\n else \n {\n abbr += word[0];\n int count = 0, len = word.Length;\n for (int i = 1; i < len-1; ++i) \n {\n ++count;\n }\n abbr += count.ToString() + word[len-1];\n }\n return abbr;\n }\n\n public int HongcowLearnsTheCyclicShift(string word)\n {\n int count = 0;\n int len = word.Length;\n string temp1 = \"\", temp2 = word;\n do\n {\n temp1 += temp2[len - 1];\n for (int i = 0; i < len - 1; ++i)\n {\n temp1 += temp2[i];\n }\n temp2 = temp1;\n temp1 = \"\";\n count++;\n }\n while(temp2 != word);\n \n return count;\n }\n\n static void Main(string[] args)\n {\n Program p = new Program();\n Console.WriteLine(p.HongcowLearnsTheCyclicShift(Console.ReadLine()));\n /*int t = 0;\n t = int.Parse(Console.ReadLine());\n for (int i = 0; i < t; ++i) \n {\n string word = Console.ReadLine();\n Console.WriteLine(p.WayTooLongWords(word));\n }*/\n //Console.WriteLine(p.GetSpaces(\"am you mo el \",0));\n }\n\n }\n}\n", "lang_cluster": "C#", "tags": ["strings", "implementation"], "code_uid": "eee7278919f611000658f631d96818a0", "src_uid": "8909ac99ed4ab2ee4d681ec864c7831e", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing Solver.Ex;\nusing Watch = System.Diagnostics.Stopwatch;\nusing StringBuilder = System.Text.StringBuilder;\nusing BitVector = System.Collections.Specialized.BitVector32;\nnamespace Solver\n{\n public class Solver\n {\n public void Solve()\n {\n var a = sc.Long();\n var b = sc.Long();\n const long mod = (long)1e9 + 7;\n var ret = ((((a * (a + 1) / 2) % mod) * b + a) % mod) * ((b * (b - 1) / 2) % mod) % mod;\n IO.Printer.Out.PrintLine(ret);\n }\n internal IO.Scanner sc;\n\n }\n #region Main and Settings\n static class Program\n {\n static void Main(string[] arg)\n {\n#if DEBUG\n var errStream = new System.IO.FileStream(@\"..\\..\\dbg.out\", System.IO.FileMode.Create, System.IO.FileAccess.Write, System.IO.FileShare.ReadWrite);\n System.Diagnostics.Debug.Listeners.Add(new System.Diagnostics.TextWriterTraceListener(errStream, \"debugStream\"));\n System.Diagnostics.Debug.AutoFlush = false;\n var sw = new Watch();\n sw.Start();\n try\n {\n#endif\n var solver = new Solver();\n solver.sc = new IO.Scanner(Console.In);\n IO.Printer.Out = new IO.Printer(new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });\n solver.Solve();\n IO.Printer.Out.Flush();\n#if DEBUG\n }\n catch (Exception ex)\n {\n Console.Error.WriteLine(ex.Message);\n Console.Error.WriteLine(ex.StackTrace);\n }\n finally\n {\n sw.Stop();\n Console.ForegroundColor = ConsoleColor.Green;\n Console.Error.WriteLine(\"Time:{0}ms\", sw.ElapsedMilliseconds);\n System.Diagnostics.Debug.Close();\n System.Threading.Thread.Sleep(System.Threading.Timeout.Infinite);\n }\n#endif\n }\n\n\n }\n #endregion\n}\n#region IO Helper\nnamespace Solver.IO\n{\n public class Printer\n {\n static Printer()\n {\n Out = new Printer(Console.Out);\n }\n public static Printer Out { get; set; }\n private readonly System.IO.TextWriter writer;\n private readonly System.Globalization.CultureInfo info;\n public string Separator { get; set; }\n public string NewLine { get { return writer.NewLine; } set { writer.NewLine = value ?? \"\\n\"; } }\n public Printer(System.IO.TextWriter tw = null, System.Globalization.CultureInfo ci = null, string separator = null, string newLine = null)\n {\n writer = tw ?? System.IO.TextWriter.Null;\n info = ci ?? System.Globalization.CultureInfo.InvariantCulture;\n NewLine = newLine;\n Separator = separator ?? \" \";\n }\n public void Print(int num) { writer.Write(num.ToString(info)); }\n public void Print(int num, string format) { writer.Write(num.ToString(format, info)); }\n public void Print(long num) { writer.Write(num.ToString(info)); }\n public void Print(long num, string format) { writer.Write(num.ToString(format, info)); }\n public void Print(double num) { writer.Write(num.ToString(info)); }\n public void Print(double num, string format) { writer.Write(num.ToString(format, info)); }\n public void Print(string str) { writer.Write(str); }\n public void Print(string format, params object[] arg) { writer.Write(string.Format(info, format, arg)); }\n public void Print(string format, IEnumerable sources) { writer.Write(format, sources.OfType().ToArray()); }\n public void Print(IEnumerable sources) { writer.Write(sources.AsString()); }\n public void Print(IEnumerable sources)\n {\n var res = new System.Text.StringBuilder();\n foreach (var x in sources)\n {\n res.AppendFormat(info, \"{0}\", x);\n if (string.IsNullOrEmpty(Separator))\n res.Append(Separator);\n }\n writer.Write(res.ToString(0, res.Length - Separator.Length));\n }\n public void PrintLine() { writer.WriteLine(); }\n public void PrintLine(int num) { writer.WriteLine(num.ToString(info)); }\n public void PrintLine(int num, string format) { writer.WriteLine(num.ToString(format, info)); }\n public void PrintLine(long num) { writer.WriteLine(num.ToString(info)); }\n public void PrintLine(long num, string format) { writer.WriteLine(num.ToString(format, info)); }\n public void PrintLine(double num) { writer.WriteLine(num.ToString(info)); }\n public void PrintLine(double num, string format) { writer.WriteLine(num.ToString(format, info)); }\n public void PrintLine(string str) { writer.WriteLine(str); }\n public void PrintLine(string format, params object[] arg) { writer.WriteLine(string.Format(info, format, arg)); }\n public void PrintLine(string format, IEnumerable sources) { writer.WriteLine(format, sources.OfType().ToArray()); }\n public void PrintLine(IEnumerable sources)\n {\n var res = new StringBuilder();\n foreach (var x in sources)\n {\n res.AppendFormat(info, \"{0}\", x);\n if (!string.IsNullOrEmpty(Separator))\n res.Append(Separator);\n }\n writer.WriteLine(res.ToString(0, res.Length - Separator.Length));\n }\n public void Flush() { writer.Flush(); }\n }\n public class Scanner\n {\n readonly private System.Globalization.CultureInfo info;\n readonly System.IO.TextReader reader;\n string[] buffer = new string[0];\n int position;\n\n public char[] Separator { get; set; }\n public Scanner(System.IO.TextReader reader = null, string separator = null, System.Globalization.CultureInfo info = null)\n {\n\n this.reader = reader ?? Console.In;\n if (string.IsNullOrEmpty(separator))\n separator = \" \";\n this.Separator = separator.ToCharArray();\n this.info = info ?? System.Globalization.CultureInfo.InvariantCulture;\n }\n public string Scan()\n {\n if (this.position < this.buffer.Length)\n return this.buffer[this.position++];\n do this.buffer = this.reader.ReadLine().Split(this.Separator, StringSplitOptions.RemoveEmptyEntries);\n while (this.buffer.Length == 0);\n this.position = 0;\n return this.buffer[this.position++];\n }\n\n public string ScanLine()\n {\n if (this.position >= this.buffer.Length)\n return this.reader.ReadLine();\n else\n {\n var sb = new System.Text.StringBuilder();\n for (; this.position < buffer.Length; this.position++)\n {\n sb.Append(this.buffer[this.position]);\n sb.Append(' ');\n }\n return sb.ToString();\n }\n }\n public string[] ScanArray(int length)\n {\n var ar = new string[length];\n for (int i = 0; i < length; i++)\n ar[i] = this.Scan();\n return ar;\n }\n\n public int Integer()\n {\n return int.Parse(this.Scan(), info);\n }\n public long Long()\n {\n return long.Parse(this.Scan(), info);\n }\n public double Double()\n {\n return double.Parse(this.Scan(), info);\n }\n public double Double(string str)\n {\n return double.Parse(str, info);\n }\n\n public int[] IntArray(int length)\n {\n var a = new int[length];\n for (int i = 0; i < length; i++)\n a[i] = this.Integer();\n return a;\n }\n public long[] LongArray(int length)\n {\n var a = new long[length];\n for (int i = 0; i < length; i++)\n a[i] = this.Long();\n return a;\n }\n public double[] DoubleArray(int length)\n {\n var a = new double[length];\n for (int i = 0; i < length; i++)\n a[i] = this.Double();\n return a;\n }\n\n }\n\n}\n#endregion\n#region Extension\nnamespace Solver.Ex\n{\n static public partial class EnumerableEx\n {\n static public string AsString(this IEnumerable source)\n {\n return new string(source.ToArray());\n }\n static public string AsJoinedString(this IEnumerable source, string separator = \" \")\n {\n return string.Join(separator, source);\n }\n static public T[] Enumerate(this int n, Func selector)\n {\n var res = new T[n];\n for (int i = 0; i < n; i++)\n res[i] = selector(i);\n return res;\n }\n }\n}\n#endregion\n//*/", "lang_cluster": "C#", "tags": ["math"], "code_uid": "8923bc0a699aa815c3d8ee0cd3fdcec5", "src_uid": "cd351d1190a92d094b2d929bf1e5c44f", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Runtime.CompilerServices;\nusing System.Text;\n\nnamespace codeforces\n{\n\tclass Program\n\t{\n\t\tpublic const int Osn = 1000000007;\n\n\t\tpublic class Pair\n\t\t{\n\t\t\tpublic long First;\n\n\t\t\tpublic long Second;\n\t\t}\n\n\t\tpublic class PairComparer : IComparer\n\t\t{\n\t\t\tpublic int Compare(Pair x, Pair y)\n\t\t\t{\n\t\t\t\tif (x.First < y.First || (x.First == y.First && x.Second > y.Second))\n\t\t\t\t\treturn -1;\n\t\t\t\treturn 1;\n\t\t\t}\n\t\t}\n\n\t\tpublic static long GetGcd(long a, long b)\n\t\t{\n\t\t\twhile (true)\n\t\t\t{\n\t\t\t\tif (b == 0)\n\t\t\t\t\treturn a;\n\t\t\t\tvar a1 = a;\n\t\t\t\ta = b;\n\t\t\t\tb = a1 % b;\n\n\t\t\t}\n\t\t}\n\n\t\tpublic static void WriteYesNo(bool x, string yes = \"YES\", string no = \"NO\")\n\t\t{\n\t\t\tif (x)\n\t\t\t\tConsole.WriteLine(yes);\n\t\t\telse\n\t\t\t{\n\t\t\t\tConsole.WriteLine(no);\n\t\t\t}\n\t\t}\n\n\t\tpublic static string ReadString()\n\t\t{\n\t\t\treturn Console.ReadLine();\n\t\t}\n\n\t\tpublic static List ReadListOfInts()\n\t\t{\n\t\t\tvar s = Console.ReadLine();\n\t\t\treturn s.Split(' ').Select(int.Parse).ToList();\n\t\t}\n\n\t\tpublic static List ReadListOfLongs()\n\t\t{\n\t\t\tvar s = Console.ReadLine();\n\t\t\treturn s.Split(' ').Select(long.Parse).ToList();\n\t\t}\n\n\t\tpublic static int ReadInt()\n\t\t{\n\t\t\tvar s = Console.ReadLine();\n\t\t\treturn int.Parse(s);\n\t\t}\n\n\t\tpublic static long ReadLong()\n\t\t{\n\t\t\tvar s = Console.ReadLine();\n\t\t\treturn long.Parse(s);\n\t\t}\n\n\t\tpublic class Vertex\n\t\t{\n\t\t\tpublic int Was;\n\n\t\t\tpublic List Edges;\n\t\t}\n\n\t\tpublic static List Graph = new List();\n\n\n\t\tpublic static bool Dfs(int u)\n\t\t{\n\t\t\tif (Graph[u].Was == 1) return true;\n\t\t\tif (Graph[u].Was == 2) return false;\n\t\t\tGraph[u].Was = 1;\n\t\t\tforeach (var t in Graph[u].Edges)\n\t\t\t{\n\t\t\t\tif (Dfs(t)) return true;\n\t\t\t}\n\n\t\t\tGraph[u].Was = 2;\n\t\t\treturn false;\n\t\t}\n\n\t\tpublic static bool IsPrime(int x)\n\t\t{\n\t\t\tfor (var j = 2; j * j <= x; ++j)\n\t\t\t\tif (x % j == 0)\n\t\t\t\t\treturn false;\n\t\t\treturn true;\n\t\t}\n\n\t\tpublic class LinkedVertex\n\t\t{\n\t\t\tpublic int Next;\n\n\t\t\tpublic int Prev;\n\n\t\t\tpublic int Value;\n\t\t}\n\n\n\t\tpublic static int BinarySearch(List list, int value)\n\t\t{\n\t\t\tvar l = -1;\n\t\t\tvar r = list.Count;\n\t\t\twhile (r - l > 1)\n\t\t\t{\n\t\t\t\tvar m = (r + l) / 2;\n\t\t\t\tif (list[m] >= value)\n\t\t\t\t\tr = m;\n\t\t\t\telse\n\t\t\t\t\tl = m;\n\t\t\t}\n\n\t\t\treturn r;\n\t\t}\n\n\t\tprivate static void Main()\n\t\t{\n\t\t\tvar l = ReadListOfLongs();\n\t\t\tvar a = l[0];\n\t\t\tvar b = l[1];\n\t\t\tlong ans = (a * (a + 1) / 2) % Osn;\n\t\t\tans = (ans * b + a) % Osn;\n\t\t\tans = (((b * (b - 1) / 2) % Osn) * ans) % Osn;\n\t\t\tConsole.WriteLine(ans);\n\t\t\tConsole.ReadLine();\n\t\t}\n\t}\n}\n", "lang_cluster": "C#", "tags": ["math"], "code_uid": "8854861b2424744d5195d6ac60945181", "src_uid": "cd351d1190a92d094b2d929bf1e5c44f", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.IO;\nusing System.Runtime.CompilerServices;\nusing System.Text;\nusing System.Diagnostics;\nusing System.Numerics;\nusing static System.Console;\nusing static System.Convert;\nusing static System.Math;\nusing static Template;\nusing Pi = Pair;\n\nclass Solver\n{\n public void Solve(Scanner sc)\n {\n var G = sc.Grid(10);\n var gh = new[] { 0, 0, 1, 1, 1, -1, -1, -1 };\n var gw = new[] { 1, -1, 1, 0, -1, 1, 0, -1 };\n for (int i = 0; i < 10; i++)\n for (int j = 0; j < 10; j++)\n {\n for(int k = 0; k < 8; k++)\n {\n var t = 0;\n var c = 0;\n for(int l = 0; l < 5; l++)\n {\n int y = gh[k] * l + i, x = gw[k] * l + j;\n if (0 <= y && y < 10 && 0 <= x && x < 10)\n {\n t += ToInt32(G[y][x] == 'X');\n c += ToInt32(G[y][x] == '.');\n }\n else goto END;\n }\n if (t == 4 && c == 1) Fail(\"YES\");\n END:;\n }\n }\n Console.WriteLine(\"NO\");\n }\n}\n\n#region Template\npublic static class Template\n{\n static void Main(string[] args)\n {\n Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });\n new Solver().Solve(new Scanner());\n Console.Out.Flush();\n }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static bool chmin(ref T a, T b) where T : IComparable { if (a.CompareTo(b) > 0) { a = b; return true; } return false; }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static bool chmax(ref T a, T b) where T : IComparable { if (a.CompareTo(b) < 0) { a = b; return true; } return false; }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static void swap(ref T a, ref T b) { var t = b; b = a; a = t; }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static void swap(this IList A, int i, int j) { var t = A[i]; A[i] = A[j]; A[j] = t; }\n public static T[] Create(int n, Func f) { var rt = new T[n]; for (var i = 0; i < rt.Length; ++i) rt[i] = f(); return rt; }\n public static T[] Create(int n, Func f) { var rt = new T[n]; for (var i = 0; i < rt.Length; ++i) rt[i] = f(i); return rt; }\n public static IEnumerable Shuffle(this IEnumerable A) => A.OrderBy(v => Guid.NewGuid());\n public static int CompareTo(this T[] A, T[] B, Comparison cmp = null) { cmp = cmp ?? Comparer.Default.Compare; for (var i = 0; i < Min(A.Length, B.Length); i++) { int c = cmp(A[i], B[i]); if (c > 0) return 1; else if (c < 0) return -1; } if (A.Length == B.Length) return 0; if (A.Length > B.Length) return 1; else return -1; }\n public static int MaxElement(this IList A, Comparison cmp = null) { cmp = cmp ?? Comparer.Default.Compare; T max = A[0]; int rt = 0; for (int i = 1; i < A.Count; i++) if (cmp(max, A[i]) < 0) { max = A[i]; rt = i; } return rt; }\n public static T PopBack(this List A) { var v = A[A.Count - 1]; A.RemoveAt(A.Count - 1); return v; }\n public static void Fail(T s) { Console.WriteLine(s); Console.Out.Close(); Environment.Exit(0); }\n}\npublic class Scanner\n{\n public string Str => Console.ReadLine().Trim();\n public int Int => int.Parse(Str);\n public long Long => long.Parse(Str);\n public double Double => double.Parse(Str);\n public int[] ArrInt => Str.Split(' ').Select(int.Parse).ToArray();\n public long[] ArrLong => Str.Split(' ').Select(long.Parse).ToArray();\n public char[][] Grid(int n) => Create(n, () => Str.ToCharArray());\n public int[] ArrInt1D(int n) => Create(n, () => Int);\n public long[] ArrLong1D(int n) => Create(n, () => Long);\n public int[][] ArrInt2D(int n) => Create(n, () => ArrInt);\n public long[][] ArrLong2D(int n) => Create(n, () => ArrLong);\n private Queue q = new Queue();\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public T Next() { if (q.Count == 0) foreach (var item in Str.Split(' ')) q.Enqueue(item); return (T)Convert.ChangeType(q.Dequeue(), typeof(T)); }\n public void Make(out T1 v1) => v1 = Next();\n public void Make(out T1 v1, out T2 v2) { v1 = Next(); v2 = Next(); }\n public void Make(out T1 v1, out T2 v2, out T3 v3) { Make(out v1, out v2); v3 = Next(); }\n public void Make(out T1 v1, out T2 v2, out T3 v3, out T4 v4) { Make(out v1, out v2, out v3); v4 = Next(); }\n public void Make(out T1 v1, out T2 v2, out T3 v3, out T4 v4, out T5 v5) { Make(out v1, out v2, out v3, out v4); v5 = Next(); }\n public void Make(out T1 v1, out T2 v2, out T3 v3, out T4 v4, out T5 v5, out T6 v6) { Make(out v1, out v2, out v3, out v4, out v5); v6 = Next(); }\n public void Make(out T1 v1, out T2 v2, out T3 v3, out T4 v4, out T5 v5, out T6 v6, out T7 v7) { Make(out v1, out v2, out v3, out v4, out v5, out v6); v7 = Next(); }\n //public (T1, T2) Make() { Make(out T1 v1, out T2 v2); return (v1, v2); }\n //public (T1, T2, T3) Make() { Make(out T1 v1, out T2 v2, out T3 v3); return (v1, v2, v3); }\n //public (T1, T2, T3, T4) Make() { Make(out T1 v1, out T2 v2, out T3 v3, out T4 v4); return (v1, v2, v3, v4); }\n}\npublic class Pair : IComparable>\n{\n public T1 v1;\n public T2 v2;\n public Pair() { }\n public Pair(T1 v1, T2 v2)\n { this.v1 = v1; this.v2 = v2; }\n\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public int CompareTo(Pair p)\n {\n var c = Comparer.Default.Compare(v1, p.v1);\n if (c == 0)\n c = Comparer.Default.Compare(v2, p.v2);\n return c;\n }\n public override string ToString() => $\"{v1.ToString()} {v2.ToString()}\";\n public void Deconstruct(out T1 a, out T2 b) { a = v1; b = v2; }\n}\n\npublic class Pair : Pair, IComparable>\n{\n public T3 v3;\n public Pair() : base() { }\n public Pair(T1 v1, T2 v2, T3 v3) : base(v1, v2)\n { this.v3 = v3; }\n\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public int CompareTo(Pair p)\n {\n var c = base.CompareTo(p);\n if (c == 0)\n c = Comparer.Default.Compare(v3, p.v3);\n return c;\n }\n public override string ToString() => $\"{base.ToString()} {v3.ToString()}\";\n public void Deconstruct(out T1 a, out T2 b, out T3 c) { Deconstruct(out a, out b); c = v3; }\n}\n#endregion\n", "lang_cluster": "C#", "tags": ["brute force", "implementation"], "code_uid": "13b9e1e2a06fdfa6a37fc50907222baa", "src_uid": "d5541028a2753c758322c440bdbf9ec6", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Linq;\nusing System.Collections.Generic;\n\nnamespace cfr25\n{\n class MainClass\n {\n\t\tpublic static void Main(string[] args)\n\t\t{\n\t\t\tstring[] arr = new string[10];\n\t\t\tfor (int i = 0; i < 10; i++)\n\t\t\t\tarr[i] = Console.ReadLine();\n\t\t\tbool flag = false;\n\t\t\tfor (int i = 0; i < 10; i++)\n\t\t\t\tfor (int j = 0; j <= (10 - 5); j++)\n\t\t\t\t{\n\t\t\t\t\tint dot = 0;\n\t\t\t\t\tint xxx = 0;\n\t\t\t\t\tfor (int kl = j; kl < j + 5; kl++)\n\t\t\t\t\t{\n\t\t\t\t\t\tif ((arr[i])[kl] == 'X') xxx++;\n\t\t\t\t\t\tif ((arr[i])[kl] == '.') dot++;\n\t\t\t\t\t}\n\t\t\t\t\tif ((dot == 1) && (xxx == 4)) flag = true;\n\t\t\t\t}\n\t\t\tif (flag == false)\n\t\t\t\tfor (int i = 0; i < 10; i++)\n\t\t\t\t\tfor (int j = 0; j <= (10 - 5); j++)\n\t\t\t\t\t{\n\t\t\t\t\t\tint dot = 0;\n\t\t\t\t\t\tint xxx = 0;\n\t\t\t\t\t\tfor (int kl = j; kl < j + 5; kl++)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tif ((arr[kl])[i] == 'X') xxx++;\n\t\t\t\t\t\t\tif ((arr[kl])[i] == '.') dot++;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif ((dot == 1) && (xxx == 4)) flag = true;\n\t\t\t\t\t}\n\t\t\tif (flag == false)\n\t\t\t\tfor (int i = 0; i <= (10 - 5); i++)\n\t\t\t\t\tfor (int j = 0; j <= (10 - 5); j++)\n\t\t\t\t\t{\n\t\t\t\t\t\tint dot = 0;\n\t\t\t\t\t\tint xxx = 0;\n\t\t\t\t\t\tfor (int kl = j, kll = i; kl < j + 5; kl++, kll++)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tif ((arr[kll])[kl] == 'X') xxx++;\n\t\t\t\t\t\t\tif ((arr[kll])[kl] == '.') dot++;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif ((dot == 1) && (xxx == 4)) flag = true;\n\t\t\t\t\t}\n\t\t\tif (flag == false)\n\t\t\t\tfor (int i = 9; i >= 4; i--)\n\t\t\t\t\tfor (int j = 0; j <= (10 - 5); j++)\n\t\t\t\t\t{\n\t\t\t\t\t\tint dot = 0;\n\t\t\t\t\t\tint xxx = 0;\n\t\t\t\t\t\tfor (int kl = j, kll = i; kl < j + 5; kl++, kll--)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tif ((arr[kll])[kl] == 'X') xxx++;\n\t\t\t\t\t\t\tif ((arr[kll])[kl] == '.') dot++;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif ((dot == 1) && (xxx == 4)) flag = true;\n\t\t\t\t\t}\n\t\t\tif (!flag)\n\t\t\t\tConsole.WriteLine(\"NO\");\n\t\t\telse Console.WriteLine(\"YES\");\n\t\t}\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "implementation"], "code_uid": "c1d354935a3345a914fbfca9156220da", "src_uid": "d5541028a2753c758322c440bdbf9ec6", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Text;\nusing System.Diagnostics;\n\nclass Solver\n{\n // test\n static CodeforcesUtils CF = new CodeforcesUtils( new[]{\n\n@\"\n100 200 250 150 200 250\n\"\n,\n@\"\n100 50 50 200 200 100\n\"\n,\n@\"\n100 10 200 20 300 30\n\"\n ,\n@\"\n0 0 0 0 0 0\n\"\n\n,\n@\"\n1 1 0 1 1 1\n\"\n,\n@\"\n1 0 1 2 1 2\n\"\n,\n@\"\n100 1 100 1 0 1\n\" \n\n \n });\n\n\n public void Solve()\n {\n var ss = CF.ReadLine().Split(' ');\n List a = new List();\n foreach (var s in ss)\n a.Add(int.Parse(s));\n\n if (a[2] == 0 && a[3] > 0)\n CF.WriteLine(\"Ron\");\n else if (a[0]*a[2] == 0 && a[1]*a[3] > 0)\n CF.WriteLine(\"Ron\");\n else if (a[0]*a[2] * a[4] == 0 && a[1]*a[3] * a[5] > 0)\n CF.WriteLine(\"Ron\");\n \n else if (a[1] * a[3] * a[5] > a[0] * a[2] * a[4])\n CF.WriteLine(\"Ron\");\n else\n CF.WriteLine(\"Hermione\");\n\n }\n\n\n #region test\n\n static void Main(string[] args)\n {\n System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo(\"ru-RU\");\n\n#if DEBUG\n for (int t=0;t();\n string[] ss = _test_input[t].Replace(\"\\n\", \"\").Split('\\r');\n for (int i = 0; i < ss.Length; i++)\n {\n if (\n (i == 0 || i == ss.Length - 1) &&\n ss[i].Length == 0\n )\n continue;\n\n _lines.Add(ss[i]);\n }\n }\n\n public int TestCount\n {\n get\n {\n return _test_input.Length;\n }\n }\n\n public string ReadLine()\n {\n#if DEBUG\n string s = null;\n if (_lines.Count > 0)\n {\n s = _lines[0];\n _lines.RemoveAt(0);\n }\n return s;\n\n#else\n //return _sr.ReadLine();\n return Console.In.ReadLine();\n#endif\n }\n\n public void WriteLine(object o)\n {\n#if DEBUG\n System.Diagnostics.Trace.WriteLine(o);\n#else\n //_sw.WriteLine(o);\n Console.WriteLine(o);\n#endif\n }\n\n public void Write(object o)\n {\n#if DEBUG\n System.Diagnostics.Trace.Write(o);\n#else\n //_sw.Write(o);\n Console.Write(o);\n#endif\n }\n\n\n string[] _test_input;\n\n List _lines;\n\n#if DEBUG\n public CodeforcesUtils(string[] test_input)\n {\n _test_input = test_input;\n }\n#else\n\n public CodeforcesUtils(string[] dummy)\n {\n //_sr = new System.IO.StreamReader(\"input.txt\");\n //_sw = new System.IO.StreamWriter(\"output.txt\");\n }\n#endif\n\n public void Close()\n {\n if( _sr!= null)\n _sr.Close();\n if( _sw != null)\n _sw.Close();\n }\n\n System.IO.StreamReader _sr=null;\n System.IO.StreamWriter _sw=null;\n \n }\n\n #endregion\n}\n\n", "lang_cluster": "C#", "tags": ["math", "implementation"], "code_uid": "322869600b3dd8705356ba863d24d631", "src_uid": "44d608de3e1447f89070e707ba550150", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\n\n\n class Program\n {\n static void Main(string[] args)\n {\n string[] werte = Console.ReadLine().Split(' ');\n int a, b, c, d, e, f;\n\n a = Convert.ToInt32(werte[0]);\n b = Convert.ToInt32(werte[1]);\n c = Convert.ToInt32(werte[2]);\n d = Convert.ToInt32(werte[3]);\n e = Convert.ToInt32(werte[4]);\n f = Convert.ToInt32(werte[5]);\n\n if (istOk(a, b, c, d, e, f) == true)\n {\n Console.WriteLine(\"Ron\");\n }\n else\n {\n Console.WriteLine(\"Hermione\");\n }\n\n Console.ReadLine();\n }\n\n public static bool istOk(int a, int b, int c, int d, int e, int f)\n {\n bool ex_istOk = false;\n\n int a1, b1, c1, d1, e1, f1;\n a1 = 0;\n b1 = 0;\n c1 = 0;\n d1 = 0;\n e1 = 0;\n f1 = 0;\n\n \n\n if ( d != 0 )\n {\n if(c==0) ex_istOk = true;\n\n if (c != 0 && b != 0)\n {\n if (a == 0) ex_istOk = true;\n \n else if(a != 0 && f != 0)\n {\n if (e == 0) ex_istOk = true;\n else\n {\n e1 = Delimoe((Delimoe(b, c) / c * d), e);\n d1 = e1;\n f1 = e1 / e * f;\n c1 = d1 / d * c;\n b1 = c1;\n a1 = b1 / b * a;\n\n if (f1 > a1) ex_istOk = true;\n }\n }\n }\n\n }\n return ex_istOk;\n }\n\n public static int Delimoe (int a, int b)\n {\n int maxDel = Math.Max(a,b);\n\n while (maxDel % a != 0 || maxDel % b != 0)\n maxDel++;\n \n return maxDel;\n }\n\n }\n", "lang_cluster": "C#", "tags": ["math", "implementation"], "code_uid": "f30f978a0939bac6064c40c066e54dcb", "src_uid": "44d608de3e1447f89070e707ba550150", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing Solver.Ex;\nusing Watch = System.Diagnostics.Stopwatch;\nusing StringBuilder = System.Text.StringBuilder;\nnamespace Solver\n{\n\n public class Solver\n {\n public void Solve()\n {\n var n = sc.Integer();\n var k = sc.Integer();\n var t = sc.Integer();\n var l = new List>();\n for (int i = 0; i < n; i++)\n {\n var v = sc.Integer();\n if (l.Count == 0)\n l.Add(new Pair(v, 1));\n else\n {\n var end = l[l.Count - 1];\n if (end.L == v)\n l[l.Count - 1] = new Pair(v, end.R + 1);\n else l.Add(new Pair(v, 1));\n }\n }\n var ret = 1;\n for (int u = 0; u < l.Count; u++)\n {\n var st = new Stack>();\n var count = 0;\n for (int i = 0; i < u; i++)\n st.Push(l[i]);\n st.Push(new Pair(t, 1));\n for (int i = u; i < l.Count; i++)\n {\n if (!st.Any())\n break;\n var last = st.Peek();\n var next = l[i];\n if (last.L == next.L && last.R + next.R >= 3)\n {\n st.Pop();\n count += last.R + next.R;\n }\n else break;\n }\n ret = Math.Max(ret, count);\n\n }\n IO.Printer.Out.PrintLine(ret - 1);\n\n }\n internal IO.StreamScanner sc;\n }\n\n #region Main and Settings\n static class Program\n {\n static void Main(string[] arg)\n {\n#if DEBUG\n var errStream = new System.IO.FileStream(@\"..\\..\\dbg.out\", System.IO.FileMode.Create, System.IO.FileAccess.Write, System.IO.FileShare.ReadWrite);\n System.Diagnostics.Debug.Listeners.Add(new System.Diagnostics.TextWriterTraceListener(errStream, \"debugStream\"));\n System.Diagnostics.Debug.AutoFlush = false;\n var sw = new Watch();\n sw.Start();\n try\n {\n#endif\n var solver = new Solver();\n solver.sc = new IO.StreamScanner(Console.OpenStandardInput());\n IO.Printer.Out = new IO.Printer(new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });\n solver.Solve();\n IO.Printer.Out.Flush();\n#if DEBUG\n }\n catch (Exception ex)\n {\n Console.Error.WriteLine(ex.Message);\n Console.Error.WriteLine(ex.StackTrace);\n }\n finally\n {\n sw.Stop();\n Console.ForegroundColor = ConsoleColor.Green;\n Console.Error.WriteLine(\"Time:{0}ms\", sw.ElapsedMilliseconds);\n System.Diagnostics.Debug.Close();\n System.Threading.Thread.Sleep(System.Threading.Timeout.Infinite);\n }\n#endif\n }\n\n\n }\n #endregion\n}\n#region IO Helper\nnamespace Solver.IO\n{\n public class Printer\n {\n static Printer()\n {\n Out = new Printer(Console.Out);\n }\n public static Printer Out { get; set; }\n private readonly System.IO.TextWriter writer;\n private readonly System.Globalization.CultureInfo info;\n public string Separator { get; set; }\n public string NewLine { get { return writer.NewLine; } set { writer.NewLine = value ?? \"\\n\"; } }\n public Printer(System.IO.TextWriter tw = null, System.Globalization.CultureInfo ci = null, string separator = null, string newLine = null)\n {\n writer = tw ?? System.IO.TextWriter.Null;\n info = ci ?? System.Globalization.CultureInfo.InvariantCulture;\n NewLine = newLine;\n Separator = separator ?? \" \";\n }\n public void Print(int num) { writer.Write(num.ToString(info)); }\n public void Print(int num, string format) { writer.Write(num.ToString(format, info)); }\n public void Print(long num) { writer.Write(num.ToString(info)); }\n public void Print(long num, string format) { writer.Write(num.ToString(format, info)); }\n public void Print(double num) { writer.Write(num.ToString(\"F12\", info)); }\n public void Print(double num, string format) { writer.Write(num.ToString(format, info)); }\n public void Print(string str) { writer.Write(str); }\n public void Print(string format, params object[] arg) { writer.Write(string.Format(info, format, arg)); }\n public void Print(string format, IEnumerable sources) { writer.Write(format, sources.OfType().ToArray()); }\n public void Print(IEnumerable sources) { writer.Write(sources.AsString()); }\n public void Print(IEnumerable sources)\n {\n var res = new System.Text.StringBuilder();\n foreach (var x in sources)\n {\n res.AppendFormat(info, \"{0}\", x);\n if (string.IsNullOrEmpty(Separator))\n res.Append(Separator);\n }\n writer.Write(res.ToString(0, res.Length - Separator.Length));\n }\n public void PrintLine() { writer.WriteLine(); }\n public void PrintLine(int num) { writer.WriteLine(num.ToString(info)); }\n public void PrintLine(int num, string format) { writer.WriteLine(num.ToString(format, info)); }\n public void PrintLine(long num) { writer.WriteLine(num.ToString(info)); }\n public void PrintLine(long num, string format) { writer.WriteLine(num.ToString(format, info)); }\n public void PrintLine(double num) { writer.WriteLine(num.ToString(\"F12\", info)); }\n public void PrintLine(double num, string format) { writer.WriteLine(num.ToString(format, info)); }\n public void PrintLine(string str) { writer.WriteLine(str); }\n public void PrintLine(string format, params object[] arg) { writer.WriteLine(string.Format(info, format, arg)); }\n public void PrintLine(string format, IEnumerable sources) { writer.WriteLine(format, sources.OfType().ToArray()); }\n public void PrintLine(IEnumerable sources)\n {\n var res = new StringBuilder();\n foreach (var x in sources)\n {\n res.AppendFormat(info, \"{0}\", x);\n if (!string.IsNullOrEmpty(Separator))\n res.Append(Separator);\n }\n writer.WriteLine(res.ToString(0, res.Length - Separator.Length));\n }\n public void Flush() { writer.Flush(); }\n }\n public class StreamScanner\n {\n public StreamScanner(System.IO.Stream stream)\n {\n iStream = stream;\n }\n private readonly System.IO.Stream iStream;\n private readonly byte[] buf = new byte[1024];\n private int len, ptr;\n private bool eof = false;\n public bool EndOfStream { get { return eof; } }\n private byte readByte()\n {\n if (eof) throw new System.IO.EndOfStreamException();\n if (ptr >= len)\n {\n ptr = 0;\n len = iStream.Read(buf, 0, 1024);\n if (len <= 0)\n {\n eof = true;\n return 0;\n }\n }\n return buf[ptr++];\n }\n private bool inSpan(byte c)\n {\n const byte lb = 33, ub = 126;\n return !(c >= lb && c <= ub);\n }\n private byte skip()\n {\n byte b = 0;\n do b = readByte();\n while (!eof && inSpan(b));\n return b;\n }\n public char Char()\n {\n return (char)skip();\n }\n public char[] Char(int n)\n {\n var a = new char[n];\n for (int i = 0; i < n; i++)\n a[i] = (char)skip();\n return a;\n }\n public char[][] Char(int n, int m)\n {\n var a = new char[n][];\n for (int i = 0; i < n; i++)\n a[i] = Char(m);\n return a;\n }\n public string Scan()\n {\n\n const byte lb = 33, ub = 126;\n if (eof) throw new System.IO.EndOfStreamException();\n\n do\n {\n while (ptr < len && (buf[ptr] < lb || ub < buf[ptr]))\n {\n ptr++;\n }\n if (ptr < len)\n break;\n ptr = 0;\n len = iStream.Read(buf, 0, 1024);\n if (len <= 0)\n {\n eof = true;\n return null;\n }\n continue;\n } while (true);\n\n StringBuilder sb = null;\n do\n {\n var i = ptr;\n while (i < len)\n {\n if (buf[i] < lb || ub < buf[i])\n {\n string s;\n if (sb != null)\n {\n sb.Append(System.Text.UTF8Encoding.Default.GetChars(buf, ptr, i - ptr));\n s = sb.ToString();\n }\n else s = new string(System.Text.UTF8Encoding.Default.GetChars(buf, ptr, i - ptr));\n ptr = i + 1;\n return s;\n }\n i++;\n }\n i = len - ptr;\n if (sb == null) sb = new StringBuilder(i + 32);\n sb.Append(System.Text.UTF8Encoding.Default.GetChars(buf, ptr, i));\n ptr = 0;\n } while ((len = iStream.Read(buf, 0, 1024)) > 0);\n eof = true;\n return sb.ToString();\n }\n public string[] Scan(int n)\n {\n var a = new string[n];\n for (int i = 0; i < n; i++)\n a[i] = Scan();\n return a;\n }\n public string ScanLine()\n {\n const byte el = 10, cr = 13;\n if (eof) throw new System.IO.EndOfStreamException();\n StringBuilder sb = null;\n do\n {\n var i = ptr;\n while (i < len)\n {\n if (buf[i] == cr || buf[i] == el)\n {\n string s;\n if (sb != null)\n {\n sb.Append(System.Text.UTF8Encoding.Default.GetChars(buf, ptr, i - ptr));\n s = sb.ToString();\n }\n else s = new string(System.Text.UTF8Encoding.Default.GetChars(buf, ptr, i - ptr));\n if (buf[i] == cr) i++;\n if (buf[i] == el) i++;\n ptr = i;\n return s;\n }\n i++;\n }\n i = len - ptr;\n if (sb == null) sb = new StringBuilder(i + 32);\n sb.Append(System.Text.UTF8Encoding.Default.GetChars(buf, ptr, i));\n ptr = 0;\n } while ((len = iStream.Read(buf, 0, 1024)) > 0);\n eof = true;\n return sb.ToString();\n }\n public double Double()\n {\n return double.Parse(Scan(), System.Globalization.CultureInfo.InvariantCulture);\n }\n public double[] Double(int n)\n {\n var a = new double[n];\n for (int i = 0; i < n; i++)\n a[i] = Double();\n return a;\n }\n public int Integer()\n {\n var ret = 0;\n byte b = 0;\n bool isMynus = false;\n const byte zero = 48, nine = 57, mynus = 45;\n do b = readByte();\n while (!eof && !((b >= zero && b <= nine) || b == mynus));\n\n if (b == mynus)\n {\n isMynus = true;\n b = readByte();\n }\n while (true)\n {\n if (b >= zero && b <= nine)\n {\n ret = ret * 10 + b - zero;\n }\n else return isMynus ? -ret : ret;\n b = readByte();\n }\n\n }\n public int[] Integer(int n)\n {\n var a = new int[n];\n for (int i = 0; i < n; i++)\n a[i] = Integer();\n return a;\n }\n public long Long()\n {\n long ret = 0;\n byte b = 0;\n bool isMynus = false;\n const byte zero = 48, nine = 57, mynus = 45;\n do b = readByte();\n while (!eof && !((b >= zero && b <= nine) || b == mynus));\n if (b == '-')\n {\n isMynus = true;\n b = readByte();\n }\n while (true)\n {\n if (b >= zero && b <= nine)\n ret = ret * 10 + (b - zero);\n else return isMynus ? -ret : ret;\n b = readByte();\n }\n\n }\n public long[] Long(int n)\n {\n var a = new long[n];\n for (int i = 0; i < n; i++)\n a[i] = Long();\n return a;\n }\n public void Flush()\n {\n iStream.Flush();\n }\n\n }\n\n}\n#endregion\n#region Extension\nnamespace Solver.Ex\n{\n static public partial class EnumerableEx\n {\n static public string AsString(this IEnumerable source)\n {\n return new string(source.ToArray());\n }\n static public string AsJoinedString(this IEnumerable source, string separator = \" \")\n {\n return string.Join(separator, source);\n }\n static public T[] Enumerate(this int n, Func selector)\n {\n var res = new T[n];\n for (int i = 0; i < n; i++)\n res[i] = selector(i);\n return res;\n }\n }\n}\n#endregion\n#region Pair\n\npublic struct Pair\n{\n public T L;\n public T R;\n public Pair(T l, T r)\n : this()\n {\n L = l;\n R = r;\n }\n public Pair(params T[] arg)\n : this(arg[0], arg[1])\n {\n }\n public override string ToString()\n {\n return string.Format(\"{0} {1}\", L, R);\n }\n}\n#endregion", "lang_cluster": "C#", "tags": ["two pointers", "brute force"], "code_uid": "a32c22f1293926cbe22c57875caa7b16", "src_uid": "d73d9610e3800817a3109314b1e6f88c", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\n\nnamespace AllProblems\n{\n class Program\n {\n static void Main(string[] args)\n {\n _430B_BallsGame.Run();\n }\n }\n public class _430B_BallsGame\n {\n public static void Run()\n {\n var s1 = Console.ReadLine().Split(' ');\n var n = Int32.Parse(s1[0]);\n //var k = Int32.Parse(s1[1]);\n var x = Int32.Parse(s1[2]);\n\n var s2 = Console.ReadLine().Split(' ');\n var cols = new int[n];\n for (var i = 0; i < n; i++)\n {\n cols[i] = Int32.Parse(s2[i]);\n }\n\n var d = DoIt(cols, n, x);\n Console.WriteLine(d);\n }\n\n private static int DoIt(int[] cols, int n, int x)\n {\n var max = 0;\n for (var i = 1; i < n; i++)\n {\n var c = InsertItem(cols, i, x);\n while (c.Length > 0)\n {\n var old = c.Length;\n c = Delete3S(c);\n if (c.Length == old) break;\n }\n var len = n - c.Length;\n if (len > max) max = len;\n if (max == n) return max;\n }\n\n return max;\n }\n\n private static int[] InsertItem(int[] num, int index, int x)\n {\n var len = num.Length + 1;\n var arr = new int[len];\n\n for (var i = 0; i < index; i++)\n {\n arr[i] = num[i];\n }\n arr[index] = x;\n for (var i = index + 1; i < len; i++)\n {\n arr[i] = num[i - 1];\n }\n\n return arr;\n }\n\n private static int[] Delete3S(int[] num)\n {\n var len = num.Length;\n if (len == 0) return new int[0];\n var start = 0;\n var ctr = 1;\n var prev = num[0];\n for (var i = 1; i < len; i++)\n {\n var cur = num[i];\n if (cur == prev)\n {\n ++ctr;\n }else {\n if (ctr > 2)\n {\n break;\n }\n ctr = 1;\n start = i;\n }\n prev = cur;\n }\n\n var end = start + ctr;\n if (ctr > 2)\n {\n var arr = new int[len - ctr];\n for (var i = 0; i < start; i++)\n {\n arr[i] = num[i];\n }\n for (var i = end; i < len; i++)\n {\n arr[i - ctr] = num[i];\n }\n\n return arr;\n }\n return num;\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["two pointers", "brute force"], "code_uid": "b5be44269543e6de0e7b3b525b61feea", "src_uid": "d73d9610e3800817a3109314b1e6f88c", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace Nicholas_and_Permutation\n{\n class Program\n {\n static void Main(string[] args)\n {\n int n = int.Parse(Console.ReadLine());\n string[] r = Console.ReadLine().Split(' ');\n int ind1 = -1;\n int indN = -1;\n for (int i = 0; i < n; i++)\n {\n int a = int.Parse(r[i]);\n if (a == 1) ind1 = i + 1;\n else if (a == n) indN = i + 1;\n }\n int d = -1;\n if (ind1 == 1 && indN == n) d = n - 2;\n int d1 = Math.Abs(ind1 - 1);\n int d2 = Math.Abs(ind1 - n);\n int d3 = Math.Abs(indN - 1);\n int d4 = Math.Abs(indN - n);\n d = Math.Max(d, d1);\n d = Math.Max(d, d2);\n d = Math.Max(d, d3);\n d = Math.Max(d, d4);\n Console.WriteLine(d);\n Console.ReadLine();\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["constructive algorithms", "implementation"], "code_uid": "97ba67f67c57fabc2e266613c4b7dec6", "src_uid": "1d2b81ce842f8c97656d96bddff4e8b4", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Text;\n\nnamespace s1\n{\n class Program\n {\n static void Main(string[] args)\n {\n string s = Console.ReadLine();\n string[] ss = new string[1];\n ss = s.Split(' ');\n int t = Convert.ToInt32(ss[0]);\n string r = Console.ReadLine();\n string[] rr = new string[t];\n rr = r.Split(' ');\n int[] a = new int[t];\n for (int i = 0; i < t; i++)\n {\n a[i] = Convert.ToInt32(rr[i]);\n }\n int max = 0;\n int min = 0;\n int max1 = 0;\n int min1= 0;\n int max2=0;\n int max3 = 0;\n for (int i = 0; i < t; i++)\n {\n if (a[i] == 1 )\n {\n max = t - i-1;\n min = i;\n if (max > min)\n {\n max2 = max;\n }\n else\n {\n max2 = min;\n }\n }\n if (a[i] == t)\n {\n max1 = t - i-1;\n min1 = i;\n if (max1 > min1)\n {\n max3 = max1;\n }\n else\n {\n max3 = min1;\n }\n }\n }\n if (max3 > max2)\n {\n Console.WriteLine(max3);\n }\n else\n {\n Console.WriteLine(max2);\n }\n\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["constructive algorithms", "implementation"], "code_uid": "a6e95482af307c4714f8defbeafd7a03", "src_uid": "1d2b81ce842f8c97656d96bddff4e8b4", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nclass Demo\n{\n static void Main()\n {\n bool ans;\n var s = Console.ReadLine().Split();\n int x = int.Parse(s[0]);\n int y = int.Parse(s[1]);\n double a = Math.Sqrt(x * x + y * y) % 2;\n ans = a > 1;\n if (Math.Sign(x) * Math.Sign(y) < 0 && a != 0 && a != 1) ans = !ans;\n Console.WriteLine(ans ? \"white\" : \"black\");\n }\n}", "lang_cluster": "C#", "tags": ["math", "geometry", "constructive algorithms", "implementation"], "code_uid": "bdc3ced9007b7f4ddce99a5ca41a765e", "src_uid": "8c92aac1bef5822848a136a1328346c6", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\n\nnamespace qwetry {\n class Program {\n static void Main() {\n string[] s = Console.ReadLine().Split(' ');\n int x = int.Parse(s[0]);\n int y = int.Parse(s[1]);\n if (x == 0 || y == 0) {\n Console.Write(\"black\");\n return;\n }\n if (x * y > 0) {\n if (Math.Sqrt(x * x + y * y) % 2 >= 0 && Math.Sqrt(x * x + y * y) % 2 <= 1) {\n Console.Write(\"black\");\n } else {\n Console.Write(\"white\");\n }\n } else {\n if (Math.Sqrt(x * x + y * y) % 2 >= 1 || Math.Sqrt(x * x + y * y) % 2 == 0) {\n Console.Write(\"black\");\n } else {\n Console.Write(\"white\");\n }\n }\n }\n }\n}", "lang_cluster": "C#", "tags": ["math", "geometry", "constructive algorithms", "implementation"], "code_uid": "6c6b75d3202b8061f4e700313c01e39c", "src_uid": "8c92aac1bef5822848a136a1328346c6", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections;\nusing System.Collections.Generic;\nusing System.Collections.Specialized;\nusing System.Text;\nusing System.Text.RegularExpressions;\nusing System.IO;\n\npublic class SyllableSorting\n{\n\n\n public static long bigMod(long b, long p, long m)\n {\n long ans = 1;\n string str = Convert.ToString(p, 2);\n for (int i = 0; i < str.Length; i++)\n {\n ans = (ans * ans) % m;\n if (str[i] == '1')\n {\n ans = (ans * b) % m;\n }\n }\n return (ans-2)>=0? ans-2 : ans-2+m;\n }\n public static void Main()\n {\n //Console.SetIn(new StreamReader(\"C:\\\\Users\\\\saib\\\\Desktop\\\\abc.txt\"));\n string str = Console.ReadLine();\n string[] values = str.Split(' ');\n int n = int.Parse(values[0]);\n int m = int.Parse(values[1]);\n int k = int.Parse(values[2]);\n if (k > m)\n {\n Console.WriteLine(m);\n }\n else if (n - (n / k) >= m)\n {\n Console.WriteLine(m);\n }\n else\n {\n int ans = (n - m) * (k - 1);\n int rem = m - ans;\n int temp = 0;\n int pow = rem/k;\n temp = (int)(bigMod(2, pow + 1, 1000000009));\n temp = (int)(((long)temp * k) % (1000000009));\n temp += (rem % k);\n temp = temp % (1000000009);\n\n ans= ans%(1000000009);\n ans = ans + temp;\n ans = ans % (1000000009);\n Console.WriteLine(ans);\n } \n // Console.SetIn(new StreamReader(Console.OpenStandardInput()));\n Console.ReadLine();\n } \n}", "lang_cluster": "C#", "tags": ["math", "binary search", "number theory", "greedy", "matrices"], "code_uid": "59f940119e9bbd56406c2bba0a9c9550", "src_uid": "9cc1aecd70ed54400821c290e2c8018e", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.IO;\n\nnamespace Codeforces.R337.C\n{\n public static class Solver\n {\n public static void Main()\n {\n using (var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false })\n {\n Solve(Console.In, sw);\n }\n }\n\n public static void Solve(TextReader tr, TextWriter tw)\n {\n WriteAnswer(tw, Parse(tr));\n }\n\n private static void WriteAnswer(TextWriter tw, int answer)\n {\n tw.WriteLine(answer);\n }\n\n private static int Parse(TextReader tr)\n {\n var w = tr.ReadLine().Split();\n return Calc(int.Parse(w[0]), int.Parse(w[1]), int.Parse(w[2]));\n }\n\n public static int Calc(long n, int m, int k)\n {\n var modulo = new Modulo(1000000009);\n var y = n - m;\n var b = y * (k - 1);\n var r = m - b;\n if (r <= 0)\n return m;\n var x = r / k;\n var a = r % k;\n return (modulo.Pow(2, x + 1) - 2) * k + a + b;\n }\n }\n\n public class Modulo\n {\n readonly int mod;\n public Modulo(int mod)\n {\n this.mod = mod;\n }\n\n public ModuloInteger Create(long v)\n {\n return new ModuloInteger(v, mod);\n }\n\n public ModuloInteger Pow(int value, long exponent)\n {\n return ModuloInteger.Pow(Create(value), exponent);\n }\n\n public ModuloInteger Multiply(int left, int right)\n {\n return Create(left) * right;\n }\n }\n\n public struct ModuloInteger : IEquatable\n {\n readonly long value;\n readonly int mod;\n\n internal ModuloInteger(long value, int mod)\n {\n this.value = (value + mod) % mod;\n this.mod = mod;\n }\n\n public bool Equals(ModuloInteger other)\n {\n return mod == other.mod && value == other.value;\n }\n\n public static ModuloInteger Pow(ModuloInteger x, long n)\n {\n var res = new ModuloInteger(1, x.mod);\n\n for (; n > 0; n >>= 1, x *= x)\n if ((n & 1) == 1)\n res *= x;\n\n return res;\n }\n\n public override bool Equals(object obj)\n {\n return obj is ModuloInteger && Equals((ModuloInteger)obj);\n }\n\n public override int GetHashCode()\n {\n return value.GetHashCode() ^ mod.GetHashCode();\n }\n\n public static bool operator ==(ModuloInteger left, ModuloInteger right)\n {\n return left.Equals(right);\n }\n\n public static bool operator !=(ModuloInteger left, ModuloInteger right)\n {\n return !(left == right);\n }\n\n public static ModuloInteger LeftShift(ModuloInteger left, int right)\n {\n return left * Pow(new ModuloInteger(2, left.mod), right);\n }\n\n public static ModuloInteger operator <<(ModuloInteger left, int right)\n {\n return LeftShift(left, right);\n }\n\n public static ModuloInteger Add(ModuloInteger left, long right)\n {\n return new ModuloInteger(left.value + right, left.mod);\n }\n\n public static ModuloInteger operator +(ModuloInteger left, long right)\n {\n return Add(left, right);\n }\n\n public static ModuloInteger operator -(ModuloInteger left, ModuloInteger right)\n {\n return left - (long)right;\n }\n\n public static ModuloInteger operator -(ModuloInteger left, long right)\n {\n return new ModuloInteger(left.value - right, left.mod);\n }\n\n public static ModuloInteger operator -(long left, ModuloInteger right)\n {\n return new ModuloInteger(left - right.value, right.mod);\n }\n\n public static ModuloInteger operator ++(ModuloInteger m)\n {\n return Increment(m);\n }\n public static ModuloInteger Increment(ModuloInteger item)\n {\n return item + 1;\n }\n\n public static ModuloInteger Multiply(ModuloInteger left, long right)\n {\n return new ModuloInteger(left.value * right, left.mod);\n }\n\n public static ModuloInteger operator *(ModuloInteger left, long right)\n {\n return Multiply(left, right);\n }\n\n public static ModuloInteger operator /(ModuloInteger left, long right)\n {\n return Pow(new ModuloInteger(right, left.mod), left.mod - 2) * left;\n }\n\n public static implicit operator int(ModuloInteger value)\n {\n return ToInt32(value);\n }\n\n public static int ToInt32(ModuloInteger value)\n {\n return (int)value.value;\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "binary search", "number theory", "greedy", "matrices"], "code_uid": "cdfcc8451f082ff2226fd4b1fc452733", "src_uid": "9cc1aecd70ed54400821c290e2c8018e", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "C# 8", "source_code": "using System;\r\nusing System.Collections.Generic;\r\nusing System.Globalization;\r\nusing System.Linq;\r\nusing System.Security.Cryptography.X509Certificates;\r\nusing System.Text;\r\nusing System.Text.RegularExpressions;\r\nusing Microsoft.VisualBasic;\r\n\r\npublic static class Cin\r\n{\r\n public static string ReadString()\r\n {\r\n StringBuilder tokenChars = new StringBuilder();\r\n bool tokenFinished = false;\r\n bool skipWhiteSpaceMode = true;\r\n while (!tokenFinished)\r\n {\r\n int nextChar = Console.Read();\r\n if (nextChar == -1)\r\n {\r\n // End of stream reached\r\n tokenFinished = true;\r\n }\r\n else\r\n {\r\n char ch = (char) nextChar;\r\n if (char.IsWhiteSpace(ch))\r\n {\r\n if (!skipWhiteSpaceMode)\r\n {\r\n tokenFinished = true;\r\n if (ch == '\\r' && (Environment.NewLine == \"\\r\\n\"))\r\n {\r\n // Reached '\\r' in Windows --> skip the next '\\n'\r\n Console.Read();\r\n }\r\n }\r\n }\r\n else\r\n {\r\n // Character reached --> append it to the output\r\n skipWhiteSpaceMode = false;\r\n tokenChars.Append(ch);\r\n }\r\n }\r\n }\r\n\r\n string token = tokenChars.ToString();\r\n return token;\r\n }\r\n\r\n public static int ReadInt()\r\n {\r\n string token = ReadString();\r\n return int.Parse(token);\r\n }\r\n\r\n public static long ReadLong()\r\n {\r\n string token = ReadString();\r\n return long.Parse(token);\r\n }\r\n\r\n public static T[] ReadArrayFromLine(Func factory)\r\n {\r\n return Console.ReadLine()?.Split(' ').Select(factory).ToArray();\r\n }\r\n\r\n public static int[] ReadIntArrayFromLine()\r\n {\r\n return ReadArrayFromLine(int.Parse);\r\n }\r\n\r\n public static long[] ReadLongArrayFromLine()\r\n {\r\n return ReadArrayFromLine(long.Parse);\r\n }\r\n\r\n public static double ReadDouble(bool acceptAnyDecimalSeparator = true)\r\n {\r\n string token = ReadString();\r\n if (acceptAnyDecimalSeparator)\r\n {\r\n token = token.Replace(',', '.');\r\n double result = double.Parse(token, CultureInfo.InvariantCulture);\r\n return result;\r\n }\r\n else\r\n {\r\n double result = double.Parse(token);\r\n return result;\r\n }\r\n }\r\n}\r\n\r\nclass Program\r\n{\r\n static void Main()\r\n {\r\n int t = Cin.ReadInt();\r\n while (t-- > 0)\r\n {\r\n Console.WriteLine($\"{Test()}\");\r\n }\r\n }\r\n\r\n static long Test()\r\n {\r\n var n = Cin.ReadInt();\r\n var set = new HashSet();\r\n\r\n var result = 0;\r\n for (long i = 1; i * i <= n; ++i)\r\n {\r\n if (i * i <= n && !set.Contains(i * i))\r\n {\r\n ++result;\r\n set.Add(i * i);\r\n }\r\n \r\n if (i * i * i <= n && !set.Contains(i * i * i))\r\n {\r\n ++result;\r\n set.Add(i * i * i);\r\n }\r\n \r\n }\r\n\r\n return result;\r\n }\r\n}", "lang_cluster": "C#", "tags": ["math", "implementation"], "code_uid": "97dba145e3a48c6cf9c8be9486300e6e", "src_uid": "015afbefe1514a0e18fcb9286c7b6624", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "// Problem: 1619B - Squares and Cubes\r\n// Author: Gusztav Szmolik\r\n\r\nusing System;\r\nusing System.Collections.Generic;\r\nusing System.Text;\r\n\r\npublic class SquaresAndCubes {\r\n \r\n public static void Main () {\r\n StringBuilder ans = new StringBuilder ();\r\n byte t = byte.Parse (Console.ReadLine ());\r\n \r\n for (byte i = 0; i < t; i++) {\r\n int n = int.Parse (Console.ReadLine ());\r\n HashSet favNumbers = new HashSet ();\r\n int j = 1;\r\n int k = 1;\r\n \r\n while (k <= n) {\r\n favNumbers.Add (k);\r\n j++;\r\n k = j*j;\r\n }\r\n \r\n j = 1;\r\n k = 1;\r\n \r\n while (k <= n) {\r\n \r\n if (!favNumbers.Contains (k))\r\n favNumbers.Add (k);\r\n \r\n j++;\r\n k = j*j*j;\r\n }\r\n \r\n int ansi = favNumbers.Count;\r\n ans.Append (ansi);\r\n ans.AppendLine ();\r\n }\r\n \r\n Console.Write (ans);\r\n }\r\n}\r\n", "lang_cluster": "C#", "tags": ["math", "implementation"], "code_uid": "7dd1eb890dddea9b802bf7175116d28a", "src_uid": "015afbefe1514a0e18fcb9286c7b6624", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\n\nnamespace CD93D\n{\n class Program\n {\n static void Main(string[] args)\n {\n var temp = Console.ReadLine().Split(new char[]{' '},StringSplitOptions.RemoveEmptyEntries);\n\n long t1, t2, x1, x2, t0;\n t1 = long.Parse(temp[0]);\n t2 = long.Parse(temp[1]);\n x1 = long.Parse(temp[2]);\n x2 = long.Parse(temp[3]);\n t0 = long.Parse(temp[4]);\n long y1 = 0, y2 = 0;\n double e = 0.1;\n double emax = 10000000000000000000000000000000.0;\n long y1MAX = 1, y2MAX = 1;\n if (t1 == t2)\n {\n Console.WriteLine(x1 + \" \" + x2);\n }\n else if (t2 == t0)\n {\n Console.WriteLine(\"0 \" + x2);\n }\n else if (t1 == t0)\n {\n Console.WriteLine(x1 + \" 0\");\n }\n else\n {\n double y1DIVy2 = (t2 - t0) / ((double)t0 - t1);\n bool t = true;\n for (y2 = 0; t || ((y1 <= x1) && (y2 <= x2)); y2++)\n {\n\n y1 = (long)((y2 * y1DIVy2) + 0.0002);\n e = (t1 * y1 + t2 * y2) / ((double)(y1 + y2)) - t0;\n // if((y2 == 1341) || (y2 == 49998))\n // Console.WriteLine(y1 +\" \" + y2+ \" \"+ y1DIVy2 +\" \" + e);\n if (e >= 0 && (Math.Abs(e) -Math.Abs(emax) <= 0) )\n {\n if (t || ((y1 <= x1) && (y2 <= x2)))\n {\n t = false;\n emax = e;\n if (y1 > x1)\n y1 = x1;\n if (y2 > x2)\n y2 = x2;\n y1MAX = y1;\n y2MAX = y2;\n }\n }\n }\n\n Console.WriteLine(y1MAX + \" \" + y2MAX);\n\n }\n\n Console.ReadLine();\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "math", "binary search"], "code_uid": "441c1d3c915c61cd892dc5d74717078b", "src_uid": "87a500829c1935ded3ef6e4e47096b9f", "difficulty": 1900.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\n\nnamespace CF_93_A\n{\n class Program\n {\n public static double getTemp(Int64 t1, Int64 t2, Int64 y1, Int64 y2)\n {\n return ((double)((Int64)(t1 * y1) + (Int64)t2 * y2)) / (y1 + y2);\n }\n\n static void Main(string[] args)\n {\n int t1, t2, x1, x2, t0;\n\n string s = Console.ReadLine();\n //string s = \"1 100000 1000 1 2\";\n\n string[] ss = s.Split(' ');\n t1 = int.Parse(ss[0]);\n t2 = int.Parse(ss[1]);\n x1 = int.Parse(ss[2]);\n x2 = int.Parse(ss[3]);\n t0 = int.Parse(ss[4]);\n\n int y1 = 0, y2 = x2;\n double temp = getTemp(t1, y2, y1, y2);\n\n for (int i = 0; i <= x1; i++)\n {\n double t = getTemp(t1, t2, i, x2);\n if (t == temp && i + x2 > y1 + y2)\n {\n y1 = i;\n y2 = x2;\n }\n if (t >= t0 &&( Math.Abs(t0 - t) < Math.Abs(t0 - temp) || temp < t0))\n {\n y1 = i;\n y2 = x2;\n temp = t;\n }\n }\n\n for (int i = 0; i <= x2; i++)\n {\n double t = getTemp(t1, t2, x1, i);\n if (t == temp && i + x1 > y1 + y2)\n {\n y1 = x1;\n y2 = i;\n }\n if (t >= t0 && (Math.Abs(t0 - t) < Math.Abs(t0 - temp) || temp < t0))\n {\n y1 = x1;\n y2 = i;\n temp = t;\n }\n }\n\n if (y1 == x1 && y1 != 0)\n {\n double rat = ((double)y2)/y1;\n for (int i = x1 - 1; i >= 0; i--)\n {\n int ny2 = (int)(i * rat);\n for (int j = ny2 - 1; j <= ny2 + 1; j++)\n {\n if (j < 0 || j > x2)\n continue;\n\n double t = getTemp(t1, t2, i, j);\n if (t == temp && i + j > y1 + y2)\n {\n y1 = i;\n y2 = j;\n }\n if (t >= t0 && (Math.Abs(t0 - t) < Math.Abs(t0 - temp) || temp < t0))\n {\n y1 = i;\n y2 = j;\n temp = t;\n }\n }\n }\n }\n\n else if (y2 == x2 && y2 != 0)\n {\n double rat = ((double)y1) / y2;\n for (int i = x2 - 1; i >= 0; i--)\n {\n int ny1 = (int)(i * rat);\n for (int j = ny1 - 1; j <= ny1 + 1; j++)\n {\n if (j < 0 || j > x1)\n continue;\n\n double t = getTemp(t1, t2, j, i);\n if (t == temp && i + j > y1 + y2)\n {\n y1 = j;\n y2 = i;\n }\n if (t >= t0 && (Math.Abs(t0 - t) < Math.Abs(t0 - temp) || temp < t0))\n {\n y2 = i;\n y1 = j;\n temp = t;\n }\n }\n }\n }\n\n Console.Write(\"{0} {1}\", y1, y2);\n Console.ReadLine();\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "math", "binary search"], "code_uid": "36a554d7d8013038622b8cb2b2b52c0e", "src_uid": "87a500829c1935ded3ef6e4e47096b9f", "difficulty": 1900.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Linq;\n\nnamespace ConsoleApplication1\n{\n class Program\n {\n static void Main(string[] args)\n {\n string s;\n int number;\n s = Console.ReadLine();\n number = Int32.Parse(Console.ReadLine());\n if (s == \"\")\n {\n Console.WriteLine(number*2);\n return;\n }\n var strpl = new string('*', number);\n s += strpl;\n s = new string(s.ToArray().Reverse().ToArray());\n int a1 = 0;\n for (int i = 0; i < s.Length; i++)\n {\n if (Check(s, i) > a1)\n a1 = Check(s, i);\n }\n Console.WriteLine(a1);\n return;\n }\n\n public static int Check(string s, int start)\n {\n bool check = false;\n for (int i = s.Length/2; i >= 0; i--)\n {\n int j;\n for (j=start; j < i+start; j++)\n {\n if (j + i > s.Length-1)\n {\n check = false;\n break;\n }\n if ((s[j] == s[j + i]) || (s[j] == '*') || (s[j + i] == '*'))\n check = true;\n else\n {\n check = false;\n break;\n }\n }\n if (check)\n {\n return i*2;\n }\n }\n return 0;\n }\n \n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "strings", "implementation"], "code_uid": "d1ae13b04093578c1009c2bdb56fb53f", "src_uid": "bb65667b65ff069a9c0c9e8fe31da8ab", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections;\nusing System.Collections.Generic;\n \nclass TEST{\n\tstatic void Main(){\n\t\tSol mySol =new Sol();\n\t\tmySol.Solve();\n\t}\n}\n\nclass Sol{\n\tpublic void Solve(){\n\t\tchar[] CC=new char[K];\n\t\tfor(int i=0;iint.Parse(e));}\n\tstatic long[] rla(){return Array.ConvertAll(Console.ReadLine().Split(' '),e=>long.Parse(e));}\n\tstatic double[] rda(){return Array.ConvertAll(Console.ReadLine().Split(' '),e=>double.Parse(e));}\n}\n", "lang_cluster": "C#", "tags": ["brute force", "strings", "implementation"], "code_uid": "24bc57aa513986550558bd638d9017e9", "src_uid": "bb65667b65ff069a9c0c9e8fe31da8ab", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Text;\nusing System.Diagnostics;\n\nclass Solver\n{\n public void Solve()\n {\n var ss = CF.ReadLine().Split(' ');\n int[] ns = new int[3];\n int i = 0;\n foreach (var s in ss)\n {\n int n = 0;\n switch (s)\n {\n case \"C\": n = 0; break;\n case \"C#\": n = 1; break;\n case \"D\": n = 2; break;\n case \"D#\": n = 3; break;\n case \"E\": n = 4; break;\n case \"F\": n = 5; break;\n case \"F#\": n = 6; break;\n case \"G\": n = 7; break;\n case \"G#\": n = 8; break;\n case \"A\": n = 9; break;\n case \"B\": n = 10; break;\n case \"H\": n = 11; break;\n }\n ns[i++] = n;\n }\n\n int r1 = (12 + ns[1] - ns[0]) % 12;\n int r2 = (12 + ns[2] - ns[0]) % 12;\n\n if (\n (r1 == 4 && r2 == 7) || \n (r1 == 7 && r2 == 4) ||\n (r1 == 3 && r2 == 8) ||\n (r1 == 8 && r2 == 3) ||\n (r1 == 5 && r2 == 9) ||\n (r1 == 9 && r2 == 5)\n )\n CF.WriteLine(\"major\");\n else if (\n (r1 == 3 && r2 == 7) || \n (r1 == 7 && r2 == 3) ||\n (r1 == 5 && r2 == 8) ||\n (r1 == 8 && r2 == 5) ||\n (r1 == 4 && r2 == 9) ||\n (r1 == 9 && r2 == 4)\n )\n CF.WriteLine(\"minor\");\n else\n CF.WriteLine(\"strange\");\n }\n\n\n // test\n static Utils CF = new Utils(new[]{\n@\"\nC E G\n\",\n\n@\"\nC# B F\n\",\n@\"\nA B H\n\"\n\n\n });\n #region test\n\n static void Main(string[] args)\n {\n#if DEBUG\n for (int t=0;t();\n string[] ss = _test_input[t].Replace(\"\\n\", \"\").Split('\\r');\n for (int i = 0; i < ss.Length; i++)\n {\n if (\n (i == 0 || i == ss.Length - 1) &&\n ss[i].Length == 0\n )\n continue;\n\n _lines.Add(ss[i]);\n }\n }\n\n public int TestCount\n {\n get\n {\n return _test_input.Length;\n }\n }\n\n public string ReadLine()\n {\n#if DEBUG\n string s = null;\n if (_lines.Count > 0)\n {\n s = _lines[0];\n _lines.RemoveAt(0);\n }\n return s;\n\n#else\n //return _sr.ReadLine();\n return Console.In.ReadLine();\n#endif\n }\n\n public void WriteLine(object o)\n {\n#if DEBUG\n System.Diagnostics.Trace.WriteLine(o);\n#else\n //_sw.WriteLine(o);\n Console.WriteLine(o);\n#endif\n }\n\n public void Write(object o)\n {\n#if DEBUG\n System.Diagnostics.Trace.Write(o);\n#else\n //_sw.Write(o);\n Console.Write(o);\n#endif\n }\n\n string[] _test_input;\n\n List _lines;\n\n#if DEBUG\n public Utils(string[] test_input)\n {\n _test_input = test_input;\n }\n#else\n\n public Utils(string[] dummy)\n {\n //_sr = new System.IO.StreamReader(\"input.txt\");\n //_sw = new System.IO.StreamWriter(\"output.txt\");\n }\n#endif\n\n }\n\n #endregion\n}\n\n", "lang_cluster": "C#", "tags": ["brute force", "implementation"], "code_uid": "2b97e972ba9bfddd82f43d64e11e2a29", "src_uid": "6aa83c2f6e095848bc63aba7d013aa58", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Text;\n\nnamespace codeforces_cs\n{\n class Program\n {\n static string[] c = { \"C\", \"C#\", \"D\", \"D#\", \"E\", \"F\", \"F#\", \"G\", \"G#\", \"A\", \"B\", \"H\"};\n static Dictionary d = new Dictionary(); \n static int dist(int x, int y)\n {\n return (y - x + 12) % 12;\n }\n static void Main(string[] args)\n {\n for (int i = 0; i < c.Length; i++)\n {\n d[c[i]] = i;\n }\n\n string input = Console.ReadLine();\n string[] inputs = input.Split(' ');\n List sinputs = new List();\n for (int i = 0; i < 3; i++)\n {\n sinputs.Add(d[inputs[i]]);\n }\n for (int i = 0; i < 12; i++)\n {\n for(int j=0;j<3;j++)\n {\n sinputs[j] = (sinputs[j]+1)%12;\n }\n sinputs.Sort();\n int X = sinputs[0];\n int Y = sinputs[1];\n int Z = sinputs[2];\n if (dist(X, Y) == 4 && dist(Y, Z) == 3)\n {\n Console.WriteLine(\"major\");\n return;\n }\n else if (dist(X, Y) == 3 && dist(Y, Z) == 4)\n {\n Console.WriteLine(\"minor\");\n return;\n }\n }\n Console.WriteLine(\"strange\");\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "implementation"], "code_uid": "ada4148e04ea45903d02656e8943e501", "src_uid": "6aa83c2f6e095848bc63aba7d013aa58", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.IO;\nusing System.Text;\nusing System.Linq;\n\nclass Program\n{\n public static long ScalarProduct(long x1, long y1, long x2, long y2)\n {\n return x1 * y2 - x2 * y1;\n }\n\n private static int Log(int radix, long value)\n {\n int ans = 0;\n while (value > 1)\n {\n ans++;\n value /= radix;\n }\n\n return ans;\n }\n\n private static bool IsPowerOf2(long x)\n {\n return (x & (x - 1)) == 0;\n }\n\n private static long BinPower(long x, int power)\n {\n long ans = 1;\n while (power > 0)\n {\n if (power % 2 == 1)\n ans = (ans * x);\n\n x = x * x;\n }\n\n return ans;\n }\n\n private static long Fact(int x)\n {\n long ans = 1;\n for (int i = 2; i <= x; i++)\n ans *= i;\n return ans;\n }\n\n private static long Placing(int k, int n)\n {\n long ans = Fact(n) / (Fact(k) * Fact(n - k));\n\n return ans;\n }\n\n private const int Mod = 1000000007;\n static void Main(string[] args)\n {\n int n = ReadInt();\n int b = ReadInt();\n int p = ReadInt();\n\n //p *= n;\n /*int count = 0;\n while (n > 1)\n {\n int cnt = n / 2;\n count += cnt;\n n -= cnt;\n }*/\n\n Console.WriteLine((2 * b + 1) * (n - 1) + \" \" + p * n);\n\n }\n\n\n private static List[] ReadGraph(int n, int m)\n {\n List[] g = new List[n + 1];\n for (int i = 0; i <= n; i++) g[i] = new List();\n for (int i = 0; i < m; i++)\n {\n int a = ReadInt();\n int b = ReadInt();\n g[a].Add(b);\n g[b].Add(a);\n }\n\n return g;\n }\n\n private static int[,] ReadGraphAsMatrix(int n, int m)\n {\n int[,] matrix = new int[n + 1, n + 1];\n for (int i = 0; i < m; i++)\n {\n int a = ReadInt();\n int b = ReadInt();\n matrix[a, b] = matrix[b, a] = 1;\n }\n\n return matrix;\n }\n\n private static void Sort(ref int a, ref int b)\n {\n if (a > b) Swap(ref a, ref b);\n }\n\n private static void Swap(ref int a, ref int b)\n {\n int tmp = a;\n a = b;\n b = tmp;\n }\n\n private const int BufferSize = 1 << 16;\n private static readonly StreamReader consoleReader = new StreamReader(Console.OpenStandardInput(BufferSize), Encoding.ASCII, false, BufferSize);\n\n private static int ReadInt()\n {\n int ans = 0;\n int mul = 1;\n do\n {\n ans = consoleReader.Read();\n if (ans == -1)\n return 0;\n if (ans == '-') mul = -1;\n } while (ans < '0' || ans > '9');\n\n ans -= '0';\n while (true)\n {\n int chr = consoleReader.Read();\n if (chr < '0' || chr > '9')\n return ans * mul;\n ans = ans * 10 + chr - '0';\n }\n }\n\n private static ulong ReadULong()\n {\n ulong ans = 0;\n int chr;\n do\n {\n chr = consoleReader.Read();\n if (chr == -1)\n return 0;\n } while (chr < '0' || chr > '9');\n\n ans = (uint)(chr - '0');\n while (true)\n {\n chr = consoleReader.Read();\n if (chr < '0' || chr > '9')\n return ans;\n ans = ans * 10 + (uint)(chr - '0');\n }\n }\n\n private static long ReadLong()\n {\n long ans = 0;\n int mul = 1;\n do\n {\n ans = consoleReader.Read();\n if (ans == -1)\n return 0;\n if (ans == '-') mul = -1;\n } while (ans < '0' || ans > '9');\n\n ans -= '0';\n while (true)\n {\n int chr = consoleReader.Read();\n if (chr < '0' || chr > '9')\n return ans * mul;\n ans = ans * 10 + chr - '0';\n }\n }\n\n private static int[] ReadIntArray(int n)\n {\n int[] ans = new int[n];\n for (int i = 0; i < n; i++)\n ans[i] = ReadInt();\n return ans;\n }\n\n private static long[] ReadLongArray(int n)\n {\n long[] ans = new long[n];\n for (int i = 0; i < n; i++)\n ans[i] = ReadLong();\n return ans;\n }\n\n private static char[] ReadString()\n {\n int ans;\n\n do\n {\n ans = consoleReader.Read();\n } while (ans < 'a' || ans > 'z');\n\n List s = new List();\n do\n {\n s.Add((char)ans);\n ans = consoleReader.Read();\n } while (ans >= 'a' && ans <= 'z');\n\n return s.ToArray();\n }\n\n private static char[] ReadString(int n)\n {\n int ans;\n\n do\n {\n ans = consoleReader.Read();\n } while (ans < 'a' || ans > 'z');\n\n char[] s = new char[n];\n int pos = 0;\n do\n {\n s[pos++] = (char)ans;\n ans = consoleReader.Read();\n } while (ans >= 'a' && ans <= 'z');\n\n return s;\n }\n\n private static char ReadLetter()\n {\n while (true)\n {\n int ans = consoleReader.Read();\n if ((ans >= 'a' && ans <= 'z') || (ans >= 'A' && ans <= 'Z'))\n return (char)ans;\n }\n }\n\n private static char ReadDigit()\n {\n while (true)\n {\n int ans = consoleReader.Read();\n if (ans >= '0' && ans <= '9')\n return (char)ans;\n }\n }\n\n private static int ReadDigitInt()\n {\n while (true)\n {\n return ReadDigit() - (int)'0';\n }\n }\n\n private static char ReadAnyChar()\n {\n return (char)consoleReader.Read();\n }\n}", "lang_cluster": "C#", "tags": ["math", "implementation"], "code_uid": "3554d93160127e7395ab2be6306ce0a9", "src_uid": "eb815f35e9f29793a120d120968cfe34", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\n\nnamespace ConsoleApplication1\n{\n class Program\n {\n static void Main(string[] args)\n {\n var inp = Console.ReadLine().Split(' ');\n Int32 n = Convert.ToInt32(inp[0]);\n Int32 b = Convert.ToInt32(inp[1]);\n Int32 p = Convert.ToInt32(inp[2]);\n\n Int32 bottles = 0;\n Int32 papers = n * p;\n\n while(n > 1)\n {\n Int32 k = 1;\n while (k <= n)\n k *= 2;\n k /= 2;\n bottles += (2 * b + 1) * (k / 2);\n n -= k / 2;\n }\n\n Console.WriteLine(\"{0} {1}\", bottles, papers);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "implementation"], "code_uid": "74a4cd0f8ffa01f613799a6642e605b6", "src_uid": "eb815f35e9f29793a120d120968cfe34", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\n\npublic class Test\n{\n\n\tpublic static void Main()\n\t\n\t{\n\t\t\n int n=Convert.ToInt32(Console.ReadLine());\n \n string str=Console.ReadLine();\n \n int num=0;\n \n for (int i = 0; i < n; i++) {\n if (str[i] == '1') {\n num++;\n }\n else {\n Console.Write(num);\n num = 0;\n }\n }\n Console.WriteLine(num);\n\t\n\t}\n}", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "cf0891645f4feedd024999f3412230c1", "src_uid": "a4b3da4cb9b6a7ed0a33a862e940cafa", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.IO;\nusing System.Globalization;\nusing System.Diagnostics;\nusing static System.Console;\nusing Pair = System.Collections.Generic.KeyValuePair;\n//using System.Numerics;\n\nclass Program\n{\n static void Main()\n {\n //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });\n new Program().Solve();\n Out.Flush();\n }\n Scanner cin = new Scanner();\n Random rnd = new Random();\n Stopwatch sw = new Stopwatch();\n readonly int[] dd = { 0, 1, 0, -1, 0 };\n readonly int mod = 1000000007;\n readonly string alfa = \"abcdefghijklmnopqrstuvwxyz\";\n\n\n void Solve()\n {\n int N = cin.Nextint;\n var V = cin.Next;\n long ans = 0;\n int cnt = 0;\n for (int i = 0; i < N; i++)\n {\n if (V[i] == '1') cnt++;\n else\n {\n ans = ans * 10 + cnt;\n while (i + 1 < N && V[i + 1] == '0')\n {\n i++;\n ans *= 10;\n }\n cnt = 0;\n }\n }\n ans = ans * 10 + cnt;\n WriteLine(ans);\n }\n\n}\n\nclass Scanner\n{\n string[] s; int i;\n char[] cs = new char[] { ' ' };\n public Scanner() { s = new string[0]; i = 0; }\n public string[] Scan { get { return ReadLine().Split(); } }\n public int[] Scanint { get { return Array.ConvertAll(Scan, int.Parse); } }\n public long[] Scanlong { get { return Array.ConvertAll(Scan, long.Parse); } }\n public double[] Scandouble { get { return Array.ConvertAll(Scan, double.Parse); } }\n public string Next\n {\n get\n {\n if (i < s.Length) return s[i++];\n string st = ReadLine();\n while (st == \"\") st = ReadLine();\n s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);\n i = 0;\n return Next;\n }\n }\n public int Nextint { get { return int.Parse(Next); } }\n public long Nextlong { get { return long.Parse(Next); } }\n public double Nextdouble { get { return double.Parse(Next); } }\n}", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "0245b47ace52fa6011fcfc7cc7b82d96", "src_uid": "a4b3da4cb9b6a7ed0a33a862e940cafa", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\n\nnamespace olimpcsharp\n{\n class Program\n {\n static void Main(string[] args)\n {\n int[] arr = new int[101];\n foreach(var item in Console.ReadLine().Split(' ').Select(int.Parse))\n {\n arr[item]++;\n }\n int sum = 0;\n int maxDel = 0;\n for (int i = 0; i < arr.Length; i++)\n {\n sum += i * arr[i];\n if (arr[i] > 1)\n {\n int k = Math.Min(arr[i], 3) * i;\n maxDel = Math.Max(maxDel, k);\n }\n }\n Console.WriteLine(sum - maxDel);\n Console.ReadLine();\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["constructive algorithms", "implementation"], "code_uid": "7f67bb9113e01b2355acda17da8b074f", "src_uid": "a9c17ce5fd5f39ffd70917127ce3408a", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace hlpcodeforce0806\n{\nclass Program\n{\nstatic void Main(string[] args)\n{\nstring s;\ns = Console.ReadLine();\n\nint All_sum=0;\n\nstring[] split = s.Split(new char[] { ' ' });\nint[] mas = new int[split.Length];\nfor (int i = 0; i < split.Length; i++)\n{\nmas[i] = int.Parse(split[i]);\n\nAll_sum += mas[i];\n\n}\n\nbyte kolvo;\nint sum_help, sum_gl=0;\n\nfor(int i=0;i sum_gl) sum_gl = sum_help;\n\n\n}\n\n}\n\nConsole.WriteLine((All_sum - sum_gl).ToString());\n\n}\n}\n}", "lang_cluster": "C#", "tags": ["constructive algorithms", "implementation"], "code_uid": "1479e78076d599c6a6a66785e3d62d4a", "src_uid": "a9c17ce5fd5f39ffd70917127ce3408a", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Globalization;\nusing System.IO;\nusing System.Linq;\n\nnamespace Temp\n{ \n struct PointInt\n {\n public long X;\n\n public long Y;\n\n public PointInt(long x, long y)\n : this()\n {\n this.X = x;\n this.Y = y;\n }\n\n public static PointInt operator +(PointInt a, PointInt b)\n {\n return new PointInt(a.X + b.X, a.Y + b.Y);\n }\n\n public static PointInt operator -(PointInt a, PointInt b)\n {\n return new PointInt(a.X - b.X, a.Y - b.Y);\n }\n\n public static PointInt operator *(PointInt a, long k)\n {\n return new PointInt(k * a.X, k * a.Y);\n }\n\n public static PointInt operator *(long k, PointInt a)\n {\n return new PointInt(k * a.X, k * a.Y);\n }\n\n public bool IsInsideRectangle(long l, long b, long r, long t)\n {\n return (l <= X) && (X <= r) && (b <= Y) && (Y <= t);\n }\n }\n\n struct LineInt\n {\n public LineInt(PointInt a, PointInt b)\n : this()\n {\n A = a.Y - b.Y;\n B = b.X - a.X;\n C = a.X * b.Y - a.Y * b.X;\n }\n\n public long A, B, C;\n\n public bool ContainsPoint(PointInt p)\n {\n return A * p.X + B * p.Y + C == 0;\n }\n }\n\n class MatrixInt\n {\n private long[,] m_Matrix;\n\n public int Size\n {\n get\n {\n return m_Matrix.GetLength(0) - 1;\n }\n }\n\n public long Mod { get; private set; }\n\n public MatrixInt(int size, long mod = 0)\n {\n m_Matrix = new long[size + 1, size + 1];\n Mod = mod;\n }\n\n public MatrixInt(long[,] matrix, long mod = 0)\n {\n this.m_Matrix = matrix;\n Mod = mod;\n }\n\n public static MatrixInt GetIdentityMatrix(int size, long mod = 0)\n {\n long[,] matrix = new long[size + 1, size + 1];\n\n for (int i = 1; i <= size; i++)\n {\n matrix[i, i] = 1;\n }\n\n return new MatrixInt(matrix, mod);\n }\n\n public long this[int i, int j]\n {\n get\n {\n return m_Matrix[i, j];\n }\n\n set\n {\n m_Matrix[i, j] = value;\n }\n }\n\n public static MatrixInt operator +(MatrixInt a, MatrixInt b)\n {\n int n = a.Size;\n long mod = Math.Max(a.Mod, b.Mod);\n long[,] c = new long[n, n];\n for (int i = 1; i <= n; i++)\n {\n for (int j = 1; j <= n; j++)\n {\n c[i, j] = a[i, j] + b[i, j]; \n }\n }\n\n if (mod > 0)\n {\n for (int i = 1; i <= n; i++)\n {\n for (int j = 1; j <= n; j++)\n {\n c[i, j] %= mod;\n }\n }\n }\n\n return new MatrixInt(c, mod);\n }\n\n public static MatrixInt operator *(MatrixInt a, MatrixInt b)\n {\n int n = a.Size;\n long mod = Math.Max(a.Mod, b.Mod);\n\n long[,] c = new long[n, n];\n\n for (int i = 1; i <= n; i++)\n {\n for (int j = 1; j <= n; j++)\n {\n for (int k = 1; k <= n; k++)\n {\n c[i, j] += a[i, k] * b[k, j];\n if (mod > 0)\n {\n c[i, j] %= mod;\n }\n } \n }\n }\n\n return new MatrixInt(c, mod);\n }\n }\n\n static class Algebra\n {\n public static long Phi(long n)\n {\n long result = n;\n for (long i = 2; i * i <= n; i++)\n {\n if (n % i == 0)\n {\n while (n % i == 0)\n {\n n /= i;\n }\n\n result -= result / i;\n }\n }\n\n if (n > 1)\n {\n result -= result / n;\n }\n\n return result;\n }\n\n public static long BinPower(long a, long n, long mod)\n {\n long result = 1;\n\n while (n > 0)\n {\n if ((n & 1) != 0)\n {\n result = (result * a) % mod;\n }\n\n a = (a * a) % mod;\n n >>= 1;\n }\n\n return result;\n }\n\n public static class Permutations\n {\n public static int[] GetRandomPermutation(int n)\n {\n int[] p = new int[n];\n for (int i = 0; i < n; i++)\n {\n p[i] = i;\n }\n\n Random random = new Random();\n for (int i = n - 1; i > 0; i--)\n {\n int j = random.Next(i + 1);\n int tmp = p[i];\n p[i] = p[j];\n p[j] = tmp;\n }\n\n return p;\n }\n }\n\n public static T[] Shuffle(this T[] array)\n {\n int length = array.Length;\n int[] p = Permutations.GetRandomPermutation(length);\n T[] result = new T[length];\n for (int i = 0; i < length; i++)\n {\n result[i] = array[p[i]];\n }\n\n return result;\n }\n\n public static MatrixInt MatrixBinPower(MatrixInt a, long n)\n {\n MatrixInt result = new MatrixInt(a.Size);\n\n while (n > 0)\n {\n if ((n & 1) != 0)\n {\n result *= a;\n }\n\n a *= a;\n n >>= 1;\n }\n\n return result;\n }\n\n public static long Gcd(long a, long b)\n {\n return b == 0 ? a : Gcd(b, a % b);\n }\n\n public static long ExtendedGcd(long a, long b, out long x, out long y)\n {\n if (b == 0)\n {\n x = 1;\n y = 0;\n return a;\n }\n\n long x1;\n long y1;\n long d = ExtendedGcd(b, a % b, out x1, out y1);\n x = y1;\n y = x1 - (a / b) * y1;\n return d;\n }\n\n public static long Lcm(long a, long b)\n {\n return (a / Gcd(a, b)) * b;\n }\n\n public static bool[] GetPrimes(int n)\n {\n n = Math.Max(n, 2);\n bool[] prime = new bool[n + 1];\n for (int i = 2; i <= n; i++)\n {\n prime[i] = true;\n }\n\n for (int i = 2; i * i <= n; i++)\n {\n if (prime[i])\n {\n if ((long)i * i <= n)\n {\n for (int j = i * i; j <= n; j += i)\n {\n prime[j] = false;\n }\n }\n }\n }\n\n return prime;\n }\n\n public static long GetFibonacciNumber(long n, long mod = 0)\n {\n long[,] matrix = new long[,] { { 0, 0, 0 }, { 0, 0, 1 }, { 0, 1, 1 } };\n\n MatrixInt result = MatrixBinPower(new MatrixInt(matrix, mod), n);\n\n return result[2, 2];\n }\n\n public static long[] GetFibonacciSequence(int n)\n {\n long[] result = new long[n];\n result[0] = result[1] = 1;\n\n for (int i = 2; i < n; i++)\n {\n result[i] = result[i - 1] + result[i - 2];\n }\n\n return result;\n }\n\n public static long GetInverseElement(long a, long mod)\n {\n long x, y;\n long g = ExtendedGcd(a, mod, out x, out y);\n\n if (g != 1)\n {\n return -1;\n }\n\n return ((x % mod) + mod) % mod;\n }\n\n public static long[] GetAllInverseElements(long mod)\n {\n long[] result = new long[mod];\n result[1] = 1;\n for (int i = 2; i < mod; i++)\n {\n result[i] = (mod - (((mod / i) * result[mod % i]) % mod)) % mod;\n }\n\n return result;\n }\n }\n\n internal static class Reader\n {\n public static void ReadInt(out int a)\n {\n int[] number = new int[1];\n ReadInt(number);\n a = number[0];\n }\n\n public static void ReadInt(out int a, out int b)\n {\n int[] numbers = new int[2];\n ReadInt(numbers);\n a = numbers[0];\n b = numbers[1];\n }\n\n public static void ReadInt(out int int1, out int int2, out int int3)\n {\n int[] numbers = new int[3];\n ReadInt(numbers);\n int1 = numbers[0];\n int2 = numbers[1];\n int3 = numbers[2];\n }\n\n public static void ReadInt(out int int1, out int int2, out int int3, out int int4)\n {\n int[] numbers = new int[4];\n ReadInt(numbers);\n int1 = numbers[0];\n int2 = numbers[1];\n int3 = numbers[2];\n int4 = numbers[3];\n }\n\n public static void ReadLong(out long a)\n {\n long[] number = new long[1];\n ReadLong(number);\n a = number[0];\n }\n\n public static void ReadLong(out long a, out long b)\n {\n long[] numbers = new long[2];\n ReadLong(numbers);\n a = numbers[0];\n b = numbers[1];\n }\n\n public static void ReadLong(out long int1, out long int2, out long int3)\n {\n long[] numbers = new long[3];\n ReadLong(numbers);\n int1 = numbers[0];\n int2 = numbers[1];\n int3 = numbers[2];\n }\n\n public static void ReadLong(out long int1, out long int2, out long int3, out long int4)\n {\n long[] numbers = new long[4];\n ReadLong(numbers);\n int1 = numbers[0];\n int2 = numbers[1];\n int3 = numbers[2];\n int4 = numbers[3];\n }\n\n public static void ReadInt(int[] numbers)\n {\n // ReSharper disable PossibleNullReferenceException\n var list = Console.ReadLine().Split();\n // ReSharper restore PossibleNullReferenceException\n\n int count = Math.Min(numbers.Length, list.Length);\n\n for (int i = 0; i < count; i++)\n {\n numbers[i] = int.Parse(list[i]);\n }\n }\n\n public static int[] ReadDigits()\n {\n // ReSharper disable AssignNullToNotNullAttribute\n return Console.ReadLine().Select(x => int.Parse(x.ToString())).ToArray();\n // ReSharper restore AssignNullToNotNullAttribute\n }\n\n public static void ReadLong(long[] numbers)\n {\n // ReSharper disable PossibleNullReferenceException\n var list = Console.ReadLine().Split();\n // ReSharper restore PossibleNullReferenceException\n\n int count = Math.Min(numbers.Length, list.Length);\n\n for (int i = 0; i < count; i++)\n {\n numbers[i] = long.Parse(list[i]);\n }\n }\n\n public static void ReadDouble(double[] numbers)\n {\n // ReSharper disable PossibleNullReferenceException\n var list = Console.ReadLine().Split();\n // ReSharper restore PossibleNullReferenceException\n\n int count = Math.Min(numbers.Length, list.Length);\n\n for (int i = 0; i < count; i++)\n {\n numbers[i] = double.Parse(list[i]);\n }\n }\n\n public static void ReadDouble(out double a, out double b)\n {\n double[] numbers = new double[2];\n ReadDouble(numbers);\n a = numbers[0];\n b = numbers[1];\n }\n\n public static void ReadDouble(out double int1, out double int2, out double int3)\n {\n double[] numbers = new double[3];\n ReadDouble(numbers);\n int1 = numbers[0];\n int2 = numbers[1];\n int3 = numbers[2];\n }\n\n public static string ReadLine()\n {\n return Console.ReadLine();\n }\n }\n\n static class MyMath\n {\n public static int GetMinimalPrimeDivisor(int n)\n { \n for (int i = 2; i * i <= n; i++)\n {\n if (n % i == 0)\n {\n return i;\n }\n }\n\n return n;\n }\n\n public static long Sqr(long x)\n {\n return x * x;\n }\n }\n\n public interface IGraph\n {\n int Vertices { get; set; }\n\n IList this[int i] { get; }\n\n void AddEdge(int u, int v);\n\n void AddOrientedEdge(int u, int v); \n }\n\n public class Graph : IGraph\n {\n private List[] m_Edges;\n\n public int Vertices { get; set; }\n\n public IList this[int i]\n {\n get\n {\n return this.m_Edges[i];\n }\n }\n\n public Graph(int vertices)\n {\n this.Vertices = vertices;\n\n this.m_Edges = new List[vertices];\n\n for (int i = 0; i < vertices; i++)\n {\n this.m_Edges[i] = new List();\n }\n }\n\n public void AddEdge(int u, int v)\n {\n this.AddOrientedEdge(u, v);\n this.AddOrientedEdge(v, u);\n }\n\n public void AddOrientedEdge(int first, int second)\n {\n this.m_Edges[first].Add(second); \n }\n\n public int[] Bfs(int start)\n {\n int[] d = new int[Vertices];\n for (int i = 0; i < Vertices; i++)\n {\n d[i] = -1;\n }\n\n Queue queue = new Queue();\n queue.Enqueue(start);\n d[start] = 0;\n\n while (queue.Count > 0)\n {\n int v = queue.Dequeue();\n foreach (int t in this.m_Edges[v].Where(t => d[t] == -1))\n {\n queue.Enqueue(t);\n d[t] = d[v] + 1;\n }\n }\n\n return d;\n }\n } \n\n class SimpleSumTable\n {\n private readonly int[,] m_Sum;\n\n public SimpleSumTable(int n, int m, int[,] table)\n {\n m_Sum = new int[n + 1, m + 1];\n\n for (int i = 1; i < n + 1; i++)\n {\n for (int j = 1; j < m + 1; j++)\n {\n m_Sum[i, j] = m_Sum[i, j - 1] + m_Sum[i - 1, j] - m_Sum[i - 1, j - 1] + table[i, j];\n }\n }\n }\n\n public int GetSum(int l, int b, int r, int t)\n {\n return m_Sum[r, t] - m_Sum[r, b] - m_Sum[l, t] + m_Sum[l, b];\n }\n }\n\n class SegmentTreeSimpleInt\n {\n public int Size { get; private set; }\n\n private readonly T[] m_Tree;\n\n private Func m_Operation;\n\n private T m_Null;\n\n public SegmentTreeSimpleInt(int size, Func operation, T nullElement, IList array = null)\n {\n this.Size = size;\n this.m_Operation = operation;\n this.m_Null = nullElement;\n\n m_Tree = new T[4 * size];\n if (array != null)\n {\n this.Build(array, 1, 0, size - 1); \n }\n }\n\n private void Build(IList array, int v, int tl, int tr)\n {\n if (tl == tr)\n {\n m_Tree[v] = array[tl];\n }\n else\n {\n int tm = (tl + tr) / 2;\n this.Build(array, 2 * v, tl, tm);\n this.Build(array, 2 * v + 1, tm + 1, tr);\n this.CalculateNode(v);\n }\n }\n\n public T GetSum(int l, int r)\n {\n return GetSum(1, 0, Size - 1, l, r);\n }\n\n private T GetSum(int v, int tl, int tr, int l, int r)\n {\n if (l > r)\n {\n return m_Null;\n }\n\n if (l == tl && r == tr)\n {\n return m_Tree[v];\n }\n\n int tm = (tl + tr) / 2;\n\n return this.m_Operation(GetSum(2 * v, tl, tm, l, Math.Min(r, tm)),GetSum(2 * v + 1, tm + 1, tr, Math.Max(l, tm + 1), r));\n }\n\n public void Update(int pos, T newValue)\n {\n Update(1, 0, Size - 1, pos, newValue);\n }\n\n private void Update(int v, int tl, int tr, int pos, T newValue)\n {\n if (tl == tr)\n {\n m_Tree[v] = newValue;\n }\n else\n {\n int tm = (tl + tr) / 2;\n if (pos <= tm)\n {\n Update(2 * v, tl, tm, pos, newValue);\n }\n else\n {\n Update(2 * v + 1, tm + 1, tr, pos, newValue);\n }\n this.CalculateNode(v);\n }\n }\n\n private void CalculateNode(int v)\n {\n m_Tree[v] = this.m_Operation(m_Tree[2 * v], m_Tree[2 * v + 1]);\n }\n }\n\n struct Pair\n {\n public Pair(TFirst first, TSecond second)\n : this()\n {\n this.First = first;\n this.Second = second;\n }\n\n public TFirst First { set; get; }\n\n public TSecond Second { set; get; }\n }\n\n class Program\n { \n private static StreamReader m_InputStream;\n\n private static StreamWriter m_OutStream;\n\n private static void OpenFiles()\n {\n m_InputStream = File.OpenText(\"input.txt\");\n Console.SetIn(m_InputStream);\n\n m_OutStream = File.CreateText(\"output.txt\");\n Console.SetOut(m_OutStream);\n }\n\n private static void CloseFiles()\n {\n m_OutStream.Flush();\n\n m_InputStream.Dispose();\n m_OutStream.Dispose();\n }\n\n static void Main()\n {\n //OpenFiles();\n\n new Solution().Solve();\n\n //CloseFiles();\n }\n }\n\n internal class Solution\n {\n private int[,,,] pos;\n\n private Card[] cards;\n\n public void Solve()\n {\n int n;\n Reader.ReadInt(out n);\n\n cards = new Card[n];\n\n string s = Reader.ReadLine();\n var split = s.Split();\n for (int i = 0; i < n; i++)\n {\n cards[i] = new Card(split[i], i);\n }\n\n pos = new int[n + 1,n,n,n];\n\n Console.Write(this.IsPossible(n, n - 3, n - 2, n - 1) == 1 ? \"YES\" : \"NO\");\n }\n\n private int IsPossible(int n, int a, int b, int c)\n {\n if (n == 1)\n {\n return 1;\n }\n\n if (n == 2)\n {\n return this.Compatible(cards[b], cards[c]) ? 1 : 2;\n }\n\n if (pos[n, a, b, c] != 0)\n {\n return pos[n, a, b, c];\n }\n\n if (this.Compatible(cards[b], cards[c]) && this.IsPossible(n - 1, n - 4, a, c) == 1 ||\n n > 3 && this.Compatible(cards[n - 4], cards[c]) && this.IsPossible(n - 1, c, a, b) == 1)\n {\n pos[n, a, b, c] = 1;\n return 1;\n }\n else\n {\n pos[n, a, b, c] = 2;\n return 2;\n }\n }\n\n class Card\n {\n public Card(string card, int id)\n {\n Value = card[0];\n Suit = card[1];\n Id = id;\n }\n\n public char Value;\n\n public char Suit;\n\n public int Id;\n }\n\n private bool Compatible(Card a, Card b)\n {\n return a.Value == b.Value || a.Suit == b.Suit;\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["dfs and similar", "dp"], "code_uid": "a9cd174139e01b610374fa659b4149df", "src_uid": "1805771e194d323edacf2526a1eb6768", "difficulty": 1900.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace Task_2\n{\n class Program\n {\n static void Main(string[] args)\n {\n string s;\n int N;\n int k = -1 ;\n N = Console.Read();\n Console.ReadLine();\n s = Console.ReadLine();\n int j = 0;\n for(int i = 0 ;i1){\n ans -= dup;\n ans++;\n }\n \n Console.WriteLine(ans);\n \n \n }\n }\n}\n \n\n", "lang_cluster": "C#", "tags": ["strings", "implementation"], "code_uid": "da6b139e695ec0cf52cba28cedd35397", "src_uid": "ed8725e4717c82fa7cfa56178057bca3", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\n\nclass Program\n{\n static void Main(string[] args)\n {\n long[] nums = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();\n\n long k = nums[0];\n long n = nums[1];\n long r = k + n;\n Console.WriteLine(r);\n\n\n\n\n }\n}", "lang_cluster": "C#", "tags": ["dsu", "constructive algorithms", "implementation", "brute force"], "code_uid": "4c07f64356cf142fb249ed06add2a46e", "src_uid": "b6e3f9c9b124ec3ec20eb8fcea075add", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\n\nnamespace _409H_ABStrikeBack\n{\n class Program\n {\n static void Main(string[] args)\n {\n var temp = Array.ConvertAll(Console.ReadLine().Split(' '), x => Convert.ToInt32(x));\n int A = temp[0];\n int B = temp[1];\n int sum = A + B - 2 + 2;\n\n Console.WriteLine(sum);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["dsu", "constructive algorithms", "implementation", "brute force"], "code_uid": "d68487da8306305759631b9449a9c95e", "src_uid": "b6e3f9c9b124ec3ec20eb8fcea075add", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace ConsoleApplication1\n{\n class Program\n {\n static void Main()\n {\n string s =Console.ReadLine();\n string [] all=s.Split(' ');\n int a = Convert.ToInt32(all[0]);\n int b = Convert.ToInt32(all[1]);\n Console.Write(a + b);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["dsu", "constructive algorithms", "implementation", "brute force"], "code_uid": "ed4ee9147858efbfff20a172a8f0725d", "src_uid": "b6e3f9c9b124ec3ec20eb8fcea075add", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.IO;\nusing System.Collections;\nusing System.Collections.Generic;\nusing System.Text;\nusing System.Reflection;\nusing System.Threading;\nusing System.Diagnostics;\nusing System.Linq;\nusing System.Globalization;\n\npublic class Solution\n{\n public TextInput cin;\n public TextOutput cout;\n public TextOutput cerr;\n public virtual void Solve()\n {\n cout.WriteLine(cin.ReadArray(2).Sum());\n }\n}\n\n#region Core\nstatic class MainClass\n{\n public static readonly TextInput cin = new TextInput(Console.In);\n public static readonly TextOutput cout = new TextOutput(Console.Out);\n public static readonly TextOutput cerr = new TextOutput(Console.Error);\n#if !DEBUG\n static void Main()\n {\n new Solution\n {\n cin = cin,\n cout = cout,\n cerr = cerr\n }.Solve();\n }\n#endif\n}\npublic class SDictionary : Dictionary\n{\n public new TValue this[TKey key]\n {\n get\n {\n TValue res;\n base.TryGetValue(key, out res);\n return res;\n }\n set\n {\n base[key] = value;\n }\n }\n}\npublic static class Ext\n{\n\n #region Prewriten\n public static void Foreach(this IEnumerable elements, Action action)\n {\n foreach(var element in elements)\n {\n action(element);\n }\n }\n public static void Foreach(this IEnumerable elements, Action action)\n {\n var index = 0;\n foreach(var element in elements)\n {\n action(element, index++);\n }\n }\n public static void Do(int from, int n, Action action)\n {\n for (var i = from; i < n; i++) action(i);\n }\n public static IEnumerable Init(int n) where T : new()\n {\n for (var i = 0; i < n; i++)\n {\n yield return new T();\n }\n }\n public static IEnumerable Init(int n, T defaultValue = default(T))\n {\n for (var i = 0; i < n; i++)\n {\n yield return defaultValue;\n }\n }\n public static IEnumerable Init(int n, Func builder)\n {\n for (var i = 0; i < n; i++)\n {\n yield return builder(i);\n }\n }\n public static bool IsEmpty(this string s)\n {\n return string.IsNullOrEmpty(s);\n }\n public static string Safe(this string s)\n {\n return s.IsEmpty() ? string.Empty : s;\n }\n public static void Swap(ref T a, ref T b)\n {\n T c = a;\n a = b;\n b = c;\n }\n public static long Gcd(long a, long b)\n {\n while (a > 0)\n {\n b %= a;\n Swap(ref a, ref b);\n }\n return b;\n }\n public static int[] ZFunction(string s)\n {\n var z = new int[s.Length];\n for (int i = 1, l = 0, r = 0; i < s.Length; ++i)\n {\n if (i <= r)\n {\n z[i] = Math.Min(r - i + 1, z[i - l]);\n }\n while (i + z[i] < s.Length && s[z[i]] == s[i + z[i]])\n {\n z[i]++;\n }\n if (i + z[i] - 1 > r)\n {\n l = i;\n r = i + z[i] - 1;\n }\n }\n return z;\n }\n public static long Pow(long a, long p)\n {\n var b = 1L;\n while (p > 0)\n {\n if ((p & 1) == 0)\n {\n a *= a;\n p >>= 1;\n }\n else\n {\n b *= a;\n p--;\n }\n }\n return b;\n }\n #endregion\n}\n\npublic delegate bool TryParseDelegate(string s, NumberStyles style, IFormatProvider format, out T value);\npublic class TextInput\n{\n private static Dictionary primitiveParsers = new Dictionary\n {\n { typeof(sbyte), new TryParseDelegate(sbyte.TryParse) },\n { typeof(short), new TryParseDelegate(short.TryParse) },\n { typeof(int), new TryParseDelegate(int.TryParse) },\n { typeof(long), new TryParseDelegate(long.TryParse) },\n\n { typeof(byte), new TryParseDelegate(byte.TryParse) },\n { typeof(ushort), new TryParseDelegate(ushort.TryParse) },\n { typeof(uint), new TryParseDelegate(uint.TryParse) },\n { typeof(ulong), new TryParseDelegate(ulong.TryParse) },\n\n { typeof(float), new TryParseDelegate(float.TryParse) },\n { typeof(double), new TryParseDelegate(double.TryParse) },\n { typeof(decimal), new TryParseDelegate(decimal.TryParse) },\n\n { typeof(char), new TryParseDelegate(CharParser) },\n { typeof(string), new TryParseDelegate(StringParser) }\n };\n private static bool CharParser(string s, NumberStyles style, IFormatProvider format, out char res)\n {\n res = char.MinValue;\n if (string.IsNullOrEmpty(s))\n {\n return false;\n }\n else\n {\n res = s[0];\n return true;\n }\n }\n private static bool StringParser(string s, NumberStyles style, IFormatProvider format, out string res)\n {\n res = s == null ? string.Empty : s;\n return true;\n }\n\n\n private string line = null;\n private int pos = 0;\n\n public IFormatProvider FormatProvider { get; set; }\n public NumberStyles NumberStyle { get; set; }\n public TextReader TextReader { get; set; }\n\n public TextInput(string path) : this(path, NumberStyles.Any, CultureInfo.InvariantCulture)\n {\n }\n public TextInput(string path, NumberStyles numberStyle, IFormatProvider formatProvider) : this(new StreamReader(path), numberStyle, formatProvider)\n {\n\n }\n public TextInput(TextReader textReader) : this(textReader, NumberStyles.Any, CultureInfo.InvariantCulture)\n {\n\n }\n public TextInput(TextReader textReader, NumberStyles numberStyle, IFormatProvider formatProvider)\n {\n TextReader = textReader;\n NumberStyle = numberStyle;\n FormatProvider = formatProvider;\n }\n\n public bool IsEof\n {\n get\n {\n return (line == null || pos >= line.Length) && TextReader.Peek() == -1;\n }\n }\n public void SkipWhiteSpace()\n {\n while (!IsEof)\n {\n if (line != null && pos < line.Length && !char.IsWhiteSpace(line[pos]))\n {\n return;\n }\n if (line == null || pos >= line.Length)\n {\n Next();\n continue;\n }\n while (pos < line.Length && char.IsWhiteSpace(line[pos]))\n {\n pos++;\n }\n }\n }\n private void SkipWhiteSpace(bool force)\n {\n if (force)\n {\n SkipWhiteSpace();\n }\n else\n {\n SkipWhiteSpace();\n }\n }\n\n public T[] ReadArray()\n {\n var length = Read();\n return ReadArray(length);\n }\n public T[] ReadArray(int length)\n {\n var array = new T[length];\n\n var parser = GetParser();\n var style = NumberStyle;\n var format = FormatProvider;\n\n for (var i = 0; i < length; i++)\n {\n array[i] = Read(parser, style, format);\n }\n return array;\n }\n\n public bool TryReadArray(out T[] array)\n {\n return TryReadArray(GetParser(), NumberStyle, FormatProvider, out array);\n }\n public bool TryReadArray(out T[] array, int length)\n {\n return TryReadArray(GetParser(), NumberStyle, FormatProvider, out array, length);\n }\n public bool TryReadArray(T[] array, int offset, int length)\n {\n return TryReadArray(GetParser(), NumberStyle, FormatProvider, array, offset, length);\n }\n public bool TryReadArray(TryParseDelegate parser, NumberStyles style, IFormatProvider format, out T[] array)\n {\n var length = 0;\n if (!TryRead(out length))\n {\n array = null;\n return false;\n }\n array = new T[length];\n return TryReadArray(parser, style, format, array, 0, length);\n }\n public bool TryReadArray(TryParseDelegate parser, NumberStyles style, IFormatProvider format, out T[] array, int length)\n {\n array = new T[length];\n return TryReadArray(parser, style, format, array, 0, length);\n }\n public bool TryReadArray(TryParseDelegate parser, NumberStyles style, IFormatProvider format, T[] array, int offset, int length)\n {\n var result = true;\n for (var i = 0; i < length && result; i++)\n {\n result &= TryRead(parser, style, format, out array[offset + i]);\n }\n return result;\n }\n\n private TryParseDelegate GetParser()\n {\n var type = typeof(T);\n return (TryParseDelegate)primitiveParsers[type];\n }\n public T Read()\n {\n return Read(GetParser());\n }\n public T Read(NumberStyles style, IFormatProvider format)\n {\n return Read(GetParser(), style, format);\n }\n public T Read(TryParseDelegate parser)\n {\n return Read(parser, NumberStyle, FormatProvider);\n }\n public T Read(TryParseDelegate parser, NumberStyles style, IFormatProvider format)\n {\n T result;\n if (!TryRead(parser, style, format, out result))\n {\n throw new FormatException();\n }\n return result;\n }\n public bool TryRead(out T value)\n {\n return TryRead(GetParser(), out value);\n }\n public bool TryRead(NumberStyles style, IFormatProvider format, out T value)\n {\n return TryRead(GetParser(), style, format, out value);\n }\n public bool TryRead(TryParseDelegate parser, out T value)\n {\n return parser(ReadToken(), NumberStyle, FormatProvider, out value);\n }\n public bool TryRead(TryParseDelegate parser, NumberStyles style, IFormatProvider format, out T value)\n {\n return parser(ReadToken(), style, format, out value);\n }\n public string ReadToken()\n {\n SkipWhiteSpace(false);\n if (IsEof)\n {\n throw new EndOfStreamException();\n }\n\n if (pos >= line.Length || char.IsWhiteSpace(line[pos])) return string.Empty;\n\n var start = pos;\n while (pos < line.Length && !char.IsWhiteSpace(line[pos]))\n {\n pos++;\n }\n return line.Substring(start, pos - start);\n }\n public string ReadLine()\n {\n if (IsEof)\n {\n throw new EndOfStreamException();\n }\n if (line == null || pos >= line.Length)\n {\n Next();\n }\n\n var ans = line.Substring(pos);\n pos = line.Length;\n return ans;\n }\n\n private void Next()\n {\n line = TextReader.ReadLine();\n pos = 0;\n }\n}\n\npublic class TextOutput\n{\n public IFormatProvider FormatProvider { get; set; }\n public TextWriter TextWriter { get; set; }\n\n public TextOutput(string path) : this(path, CultureInfo.InvariantCulture)\n {\n }\n public TextOutput(string path, IFormatProvider formatProvider) : this(new StreamWriter(path), formatProvider)\n {\n\n }\n public TextOutput(TextWriter textWriter) : this(textWriter, CultureInfo.InvariantCulture)\n {\n\n }\n public TextOutput(TextWriter textWriter, IFormatProvider formatProvider)\n {\n TextWriter = textWriter;\n FormatProvider = formatProvider;\n }\n\n public TextOutput WriteArray(params T[] array)\n {\n return WriteArray(array, true);\n }\n public TextOutput WriteArray(T[] array, bool appendLine)\n {\n return WriteArray(array, 0, array.Length, appendLine);\n }\n public TextOutput WriteArray(T[] array, int offset, int length, bool appendLine = true)\n {\n var sb = new StringBuilder();\n for (var i = 0; i < length; i++)\n {\n sb.Append(Convert.ToString(array[offset + i], FormatProvider));\n if (i + 1 < length)\n {\n sb.Append(' ');\n }\n }\n return appendLine ? WriteLine(sb.ToString()) : Write(sb.ToString());\n }\n\n public TextOutput WriteLine(object obj)\n {\n return WriteLine(Convert.ToString(obj, FormatProvider));\n }\n public TextOutput WriteLine(string text, params object[] args)\n {\n return WriteLine(string.Format(FormatProvider, text, args));\n }\n public TextOutput WriteLine(string text)\n {\n TextWriter.WriteLine(text);\n return this;\n }\n public TextOutput WriteLine(char[] buffer)\n {\n TextWriter.WriteLine(buffer);\n return this;\n }\n public TextOutput WriteLine(char[] buffer, int offset, int length)\n {\n TextWriter.WriteLine(buffer, offset, length);\n return this;\n }\n public TextOutput WriteLine()\n {\n TextWriter.WriteLine();\n return this;\n }\n\n public TextOutput Write(object obj)\n {\n return Write(Convert.ToString(obj, FormatProvider));\n }\n public TextOutput Write(string text, params object[] args)\n {\n return Write(string.Format(FormatProvider, text, args));\n }\n public TextOutput Write(string text)\n {\n TextWriter.Write(text);\n return this;\n }\n public TextOutput Write(char[] buffer)\n {\n TextWriter.Write(buffer);\n return this;\n }\n public TextOutput Write(char[] buffer, int offset, int length)\n {\n TextWriter.Write(buffer, offset, length);\n return this;\n }\n}\n#endregion", "lang_cluster": "C#", "tags": ["dsu", "constructive algorithms", "implementation", "brute force"], "code_uid": "3d79c5d3d6e934b763b6da3e7f14b836", "src_uid": "b6e3f9c9b124ec3ec20eb8fcea075add", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\n\nclass Solution{\n static void Main(){\n string[] input = Console.ReadLine().Split();\n int ret=0;\n foreach(string s in input)\n ret+=int.Parse(s);\n Console.WriteLine(ret);\n }\n}", "lang_cluster": "C#", "tags": ["dsu", "constructive algorithms", "implementation", "brute force"], "code_uid": "3d66832215d71987c2bfc9dd0d89e8df", "src_uid": "b6e3f9c9b124ec3ec20eb8fcea075add", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Diagnostics;\nusing System.IO;\nusing System.Linq;\n\nnamespace codeforces\n{\n class Program\n {\n //16:23\n //reading\n static string ReadLine()\n {\n return Console.ReadLine();\n }\n static string[] ReadArray()\n {\n return ReadLine().Split(' ');\n }\n static List ReadList()\n {\n return ReadArray().ToList();\n }\n static List ReadIntList()\n {\n return ReadArray().Select(c => Convert.ToInt32(c)).ToList();\n }\n static List ReadLongList()\n {\n return ReadArray().Select(c => Convert.ToInt64(c)).ToList();\n }\n static List ReadULongList()\n {\n return ReadArray().Select(c => Convert.ToUInt64(c)).ToList();\n }\n static int ToInt(string str)\n {\n return Convert.ToInt32(str);\n }\n static long ToInt64(string str)\n {\n return Convert.ToInt64(str);\n }\n static ulong ToUInt64(string str)\n {\n return Convert.ToUInt64(str);\n }\n\n\n static void Main(string[] args)\n {\n string[] input = ReadArray();\n int a = ToInt(input[0]);\n int b = ToInt(input[1]);\n Console.WriteLine(b + a);\n\n /*\n watch.Stop();\n var elapsedMs = watch.ElapsedMilliseconds;\n Console.WriteLine(elapsedMs);*/\n }\n }\n}", "lang_cluster": "C#", "tags": ["dsu", "constructive algorithms", "implementation", "brute force"], "code_uid": "937d66da80404b87867fa8cab5e37a4b", "src_uid": "b6e3f9c9b124ec3ec20eb8fcea075add", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\n//idinahuyazzbe\nnamespace codeforces\n{\n class Program\n {\n static void Main(string[] args)\n {\n int[] n = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();\n Console.Write(n.Sum());\n }\n }\n}", "lang_cluster": "C#", "tags": ["dsu", "constructive algorithms", "implementation", "brute force"], "code_uid": "5660d15d69b931e8c12d85677c7de259", "src_uid": "b6e3f9c9b124ec3ec20eb8fcea075add", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\n using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace _1A\n{\n class Program\n {\n static void Main(string[] args)\n{\n var inpr = Console.ReadLine().Split().Select(int.Parse).ToArray();\n Console.WriteLine(inpr[1]+inpr[0]);\n}\n }\n \n \n}", "lang_cluster": "C#", "tags": ["dsu", "constructive algorithms", "implementation", "brute force"], "code_uid": "585d49a21a1e5674429f0238691b5a00", "src_uid": "b6e3f9c9b124ec3ec20eb8fcea075add", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.IO;\nusing System.Numerics;\n\nnamespace ZODACHA\n{\n class Program\n {\n class Sotr\n {\n public int number = 0;\n public int dolg = -1;\n }\n\n static void Main(string[] args)\n {\n string[] line = Console.ReadLine().Split(' ');\n\n int n = Convert.ToInt32(line[0]);\n int m = Convert.ToInt32(line[1]);\n\n \n \n \n \n Console.WriteLine(n + m); \n }\n }\n}\n", "lang_cluster": "C#", "tags": ["dsu", "constructive algorithms", "implementation", "brute force"], "code_uid": "64fd57f963933672d9bbef9d91308369", "src_uid": "b6e3f9c9b124ec3ec20eb8fcea075add", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Text.RegularExpressions;\n\nnamespace ConsoleApplication1\n{\n class Program\n {\n static void Main(string[] args)\n {\n int[] finals = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();\n Console.WriteLine(finals[0] + finals[1]);\n }\n }\n}", "lang_cluster": "C#", "tags": ["dsu", "constructive algorithms", "implementation", "brute force"], "code_uid": "2ce9c7095d0dbc6c67f347311dd51891", "src_uid": "b6e3f9c9b124ec3ec20eb8fcea075add", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace CF1011B\n{\n class Program\n {\n static void Main(string[] args)\n {\n int totNums, totNeed;\n string inp;string[] div;\n\n inp = Console.ReadLine();div = inp.Split(' ');\n totNums = Convert.ToInt32(div[0]);totNeed = Convert.ToInt32(div[1]);\n inp = Console.ReadLine();\n int[] num = new int[totNums];\n for (int i = 0; i < totNums; i++)\n num[i] = inp[i] - 'a' + 1;\n\n Array.Sort(num);\n int _count = num[0], lastChoose = num[0];totNeed--;\n for(int i = 1; i < totNums; i++) {\n if (totNeed <= 0) break;\n if (num[i] - lastChoose > 1) {\n _count += num[i];\n totNeed--;\n lastChoose = num[i];\n }\n }\n\n if (totNeed <= 0)\n Console.WriteLine(\"{0}\", _count);\n else Console.WriteLine(\"-1\");\n }\n }\n}", "lang_cluster": "C#", "tags": ["sortings", "implementation", "greedy"], "code_uid": "7841796044bfd12b34d027799d6ddf64", "src_uid": "56b13d313afef9dc6c6ba2758b5ea313", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace timus1100\n{\n class Program\n {\n\n static void Main(string[] args)\n { int n, k;\n string i=\"\";\n string[] numbers = Console.ReadLine().Split(' ');\n n= int.Parse(numbers[0]);\n k = int.Parse(numbers[1]);\n\n var source = new[] { Console.ReadLine() };\n\n var result = source.Select(s => new string(s.OrderBy(ch => ch).ToArray()));\n \n \n \n byte[] bytes = Encoding.ASCII.GetBytes(\"a\");\n foreach (string s in result) i = String.Concat(i, s);\n char last = Convert.ToChar(bytes[0]-2) ;\n int ans = 0;\n int len = 0;\n for (int ik = 0; ik < n; ik++)\n \n if (i[ik] >= last + 2)\n {\n last = i[ik];\n ans += i[ik] - 'a' + 1;\n len++;\n if (len == k)\n {\n Console.WriteLine(ans);\n //Console.ReadKey();\n Environment.Exit(0);\n \n}\n }\n Console.WriteLine(\"-1\");\n \n // Console.ReadKey();\n\n\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["sortings", "implementation", "greedy"], "code_uid": "d9cc7d983b1a786e84a208ab35b1b892", "src_uid": "56b13d313afef9dc6c6ba2758b5ea313", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Globalization;\nusing System.IO;\nusing System.Linq;\nusing System.Text;\n\nclass Program\n{\n static void Main(string[] args)\n {\n int n = RI();\n var next = RIA(n);\n if (next.Distinct().Count() != n)\n {\n Console.Write(-1);\n return;\n }\n\n bool[] visited = new bool[n];\n List size = new List();\n for (int i = 0; i < n; i++)\n if (!visited[i])\n {\n int cnt = 0;\n int t = i;\n while (!visited[t])\n {\n visited[t] = true;\n t = next[t] - 1;\n cnt++;\n }\n\n size.Add(cnt);\n }\n\n size.Sort();\n for (int i = 0; i < size.Count; i++)\n if (size[i] % 2 == 0)\n {\n size[i] /= 2;\n }\n\n long answer = 1;\n for (int i = 0; i < size.Count; i++)\n {\n var gcd = GCD(answer, size[i]);\n answer = (answer / gcd) * size[i];\n }\n\n Console.Write(answer);\n }\n\n private const int Mod = 1000000000 + 7;\n\n #region Data Read\n private static char ReadSign()\n {\n while (true)\n {\n int ans = consoleReader.Read();\n if (ans == '+' || ans == '-' || ans == '?')\n return (char)ans;\n }\n }\n\n private static long GCD(long a, long b)\n {\n if (a % b == 0) return b;\n return GCD(b, a % b);\n }\n\n private static List[] ReadGraph(int n, int m)\n {\n List[] g = new List[n];\n for (int i = 0; i < g.Length; i++) g[i] = new List();\n for (int i = 0; i < m; i++)\n {\n int a = RI() - 1;\n int b = RI() - 1;\n\n g[a].Add(b);\n g[b].Add(a);\n }\n\n return g;\n }\n\n private static int[,] ReadGraphAsMatrix(int n, int m)\n {\n int[,] matrix = new int[n + 1, n + 1];\n for (int i = 0; i < m; i++)\n {\n int a = RI();\n int b = RI();\n matrix[a, b] = matrix[b, a] = 1;\n }\n\n return matrix;\n }\n\n private static void Sort(ref int a, ref int b)\n {\n if (a > b) Swap(ref a, ref b);\n }\n\n private static void Swap(ref int a, ref int b)\n {\n int tmp = a;\n a = b;\n b = tmp;\n }\n\n private const int BufferSize = 1 << 16;\n private static StreamReader consoleReader;\n private static MemoryStream testData;\n\n private static int RI()\n {\n int ans = 0;\n int mul = 1;\n do\n {\n ans = consoleReader.Read();\n if (ans == -1)\n return 0;\n if (ans == '-') mul = -1;\n } while (ans < '0' || ans > '9');\n\n ans -= '0';\n while (true)\n {\n int chr = consoleReader.Read();\n if (chr < '0' || chr > '9')\n return ans * mul;\n ans = ans * 10 + chr - '0';\n }\n }\n\n private static ulong RUL()\n {\n ulong ans = 0;\n int chr;\n do\n {\n chr = consoleReader.Read();\n if (chr == -1)\n return 0;\n } while (chr < '0' || chr > '9');\n\n ans = (uint)(chr - '0');\n while (true)\n {\n chr = consoleReader.Read();\n if (chr < '0' || chr > '9')\n return ans;\n ans = ans * 10 + (uint)(chr - '0');\n }\n }\n\n private static long RL()\n {\n long ans = 0;\n int mul = 1;\n do\n {\n ans = consoleReader.Read();\n if (ans == -1)\n return 0;\n if (ans == '-') mul = -1;\n } while (ans < '0' || ans > '9');\n\n ans -= '0';\n while (true)\n {\n int chr = consoleReader.Read();\n if (chr < '0' || chr > '9')\n return ans * mul;\n ans = ans * 10 + chr - '0';\n }\n }\n\n private static int[] RIA(int n)\n {\n int[] ans = new int[n];\n for (int i = 0; i < n; i++)\n ans[i] = RI();\n return ans;\n }\n\n private static long[] RLA(int n)\n {\n long[] ans = new long[n];\n for (int i = 0; i < n; i++)\n ans[i] = RL();\n return ans;\n }\n\n private static char[] ReadWord()\n {\n int ans;\n\n do\n {\n ans = consoleReader.Read();\n } while (!((ans >= 'a' && ans <= 'z') || (ans >= 'A' && ans <= 'Z')));\n\n List s = new List();\n do\n {\n s.Add((char)ans);\n ans = consoleReader.Read();\n } while ((ans >= 'a' && ans <= 'z') || (ans >= 'A' && ans <= 'Z'));\n\n return s.ToArray();\n }\n\n private static char[] ReadString(int n)\n {\n int ans;\n\n do\n {\n ans = consoleReader.Read();\n } while (!((ans >= 'a' && ans <= 'z') || (ans >= 'A' && ans <= 'Z')));\n\n char[] s = new char[n];\n int pos = 0;\n do\n {\n s[pos++] = (char)ans;\n if (pos == n) break;\n ans = consoleReader.Read();\n } while ((ans >= 'a' && ans <= 'z') || (ans >= 'A' && ans <= 'Z'));\n\n return s;\n }\n\n private static char[] ReadStringLine()\n {\n int ans;\n\n do\n {\n ans = consoleReader.Read();\n } while (ans == 10 || ans == 13);\n\n List s = new List();\n\n do\n {\n s.Add((char)ans);\n ans = consoleReader.Read();\n } while (ans != 10 && ans != 13);\n\n return s.ToArray();\n }\n\n private static char ReadLetter()\n {\n while (true)\n {\n int ans = consoleReader.Read();\n if ((ans >= 'a' && ans <= 'z') || (ans >= 'A' && ans <= 'Z'))\n return (char)ans;\n }\n }\n private static char ReadNonLetter()\n {\n while (true)\n {\n int ans = consoleReader.Read();\n if (!((ans >= 'a' && ans <= 'z') || (ans >= 'A' && ans <= 'Z')))\n return (char)ans;\n }\n }\n\n private static char ReadAnyOf(IEnumerable allowed)\n {\n while (true)\n {\n char ans = (char)consoleReader.Read();\n if (allowed.Contains(ans))\n return ans;\n }\n }\n\n private static char ReadDigit()\n {\n while (true)\n {\n int ans = consoleReader.Read();\n if (ans >= '0' && ans <= '9')\n return (char)ans;\n }\n }\n\n private static int ReadDigitInt()\n {\n return ReadDigit() - (int)'0';\n }\n\n private static char ReadAnyChar()\n {\n return (char)consoleReader.Read();\n }\n\n private static string DoubleToString(double x)\n {\n return x.ToString(CultureInfo.InvariantCulture);\n }\n\n private static double DoubleFromString(string x)\n {\n return double.Parse(x, CultureInfo.InvariantCulture);\n }\n\n static Program()\n {\n //Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;\n consoleReader = new StreamReader(Console.OpenStandardInput(BufferSize), Encoding.ASCII, false, BufferSize);\n }\n\n private static void PushTestData(StringBuilder sb)\n {\n PushTestData(sb.ToString());\n }\n private static void PushTestData(string data)\n {\n#if TOLYAN_TEST\n if (testData == null)\n {\n testData = new MemoryStream();\n consoleReader = new StreamReader(testData);\n }\n\n var pos = testData.Position;\n var bytes = Encoding.UTF8.GetBytes(data);\n testData.Write(bytes, 0, bytes.Length);\n testData.Flush();\n testData.Position = pos;\n#endif\n }\n #endregion\n}", "lang_cluster": "C#", "tags": ["dfs and similar", "math"], "code_uid": "d8a99e66f8148f86afdf094d579b49c3", "src_uid": "149221131a978298ac56b58438df46c9", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Linq.Expressions;\nusing System.IO;\n//using System.Diagnostics;\n\nusing Binary = System.Func;\nusing Unary = System.Func;\n\nclass Program\n{\n static StreamWriter sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };\n// static Scan sc = new Scan();\n static Scan sc = new ScanCHK();\n const int M = 1000000007;\n const double eps = 1e-9;\n static readonly int[] dd = { 0, 1, 0, -1, 0 };\n static void Main()\n {\n int n = sc.Int;\n var c = sc.IntArr.Select(x => x - 1).ToArray();\n long lcm = 1;\n for (int i = 0; i < n; i++)\n {\n int now = i, cnt = -1;\n for (int j = 0; j < n; j++)\n {\n now = c[now];\n if (now == i)\n {\n cnt = j + 1;\n break;\n }\n }\n if (cnt < 0)\n {\n DBG(-1);\n return;\n }\n lcm = mymath.lcm(lcm, cnt);\n }\n if (lcm % 2 == 0) lcm /= 2;\n\n Prt(lcm);\n sw.Flush();\n }\n static void swap(ref T a, ref T b) { var t = a; a = b; b = t; }\n static T Max(params T[] a) => a.Max();\n static T Min(params T[] a) => a.Min();\n static void DBG(params T[] a) => Console.WriteLine(string.Join(\" \", a));\n static void DBG(params object[] a) => Console.WriteLine(string.Join(\" \", a));\n static void Prt(params T[] a) => sw.WriteLine(string.Join(\" \", a));\n static void Prt(params object[] a) => sw.WriteLine(string.Join(\" \", a));\n}\nstatic class ex\n{\n public static string con(this IEnumerable a) => a.con(\" \");\n public static string con(this IEnumerable a, string s) => string.Join(s, a);\n public static void swap(this IList a, int i, int j) { var t = a[i]; a[i] = a[j]; a[j] = t; }\n public static T[] copy(this IList a)\n {\n var ret = new T[a.Count];\n for (int i = 0; i < a.Count; i++) ret[i] = a[i];\n return ret;\n }\n}\nstatic class Operator\n{\n static readonly ParameterExpression x = Expression.Parameter(typeof(T), \"x\");\n static readonly ParameterExpression y = Expression.Parameter(typeof(T), \"y\");\n public static readonly Func Add = Lambda(Expression.Add);\n public static readonly Func Subtract = Lambda(Expression.Subtract);\n public static readonly Func Multiply = Lambda(Expression.Multiply);\n public static readonly Func Divide = Lambda(Expression.Divide);\n public static readonly Func Plus = Lambda(Expression.UnaryPlus);\n public static readonly Func Negate = Lambda(Expression.Negate);\n public static Func Lambda(Binary op) => Expression.Lambda>(op(x, y), x, y).Compile();\n public static Func Lambda(Unary op) => Expression.Lambda>(op(x), x).Compile();\n}\n\nclass ScanCHK : Scan\n{\n public new string Str { get { var s = Console.ReadLine(); if (s != s.Trim()) throw new Exception(); return s; } }\n}\nclass Scan\n{\n public int Int => int.Parse(Str);\n public long Long => long.Parse(Str);\n public double Double => double.Parse(Str);\n public string Str => Console.ReadLine().Trim();\n public int[] IntArr => StrArr.Select(int.Parse).ToArray();\n public long[] LongArr => StrArr.Select(long.Parse).ToArray();\n public double[] DoubleArr => StrArr.Select(double.Parse).ToArray();\n public string[] StrArr => Str.Split();\n bool eq() => typeof(T).Equals(typeof(U));\n T ct(U a) => (T)Convert.ChangeType(a, typeof(T));\n T cv(string s) => eq() ? ct(int.Parse(s))\n : eq() ? ct(long.Parse(s))\n : eq() ? ct(double.Parse(s))\n : eq() ? ct(s[0]) : ct(s);\n public void Multi(out T a) => a = cv(Str);\n public void Multi(out T a, out U b)\n { var ar = StrArr; a = cv(ar[0]); b = cv(ar[1]); }\n public void Multi(out T a, out U b, out V c)\n { var ar = StrArr; a = cv(ar[0]); b = cv(ar[1]); c = cv(ar[2]); }\n public void Multi(out T a, out U b, out V c, out W d)\n { var ar = StrArr; a = cv(ar[0]); b = cv(ar[1]); c = cv(ar[2]); d = cv(ar[3]); }\n public void Multi(out T a, out U b, out V c, out W d, out X e)\n { var ar = StrArr; a = cv(ar[0]); b = cv(ar[1]); c = cv(ar[2]); d = cv(ar[3]); e = cv(ar[4]); }\n}\nclass mymath\n{\n public static long Mod = 1000000007;\n public static bool isprime(long a)\n {\n if (a < 2) return false;\n for (long i = 2; i * i <= a; i++) if (a % i == 0) return false;\n return true;\n }\n public static bool[] sieve(int n)\n {\n var p = new bool[n + 1];\n for (int i = 2; i <= n; i++) p[i] = true;\n for (int i = 2; i * i <= n; i++) if (p[i]) for (int j = i * i; j <= n; j += i) p[j] = false;\n return p;\n }\n public static List getprimes(int n)\n {\n var prs = new List();\n var p = sieve(n);\n for (int i = 2; i <= n; i++) if (p[i]) prs.Add(i);\n return prs;\n }\n public static long[][] E(int n)\n {\n var ret = new long[n][];\n for (int i = 0; i < n; i++) { ret[i] = new long[n]; ret[i][i] = 1; }\n return ret;\n }\n public static long[][] pow(long[][] A, long n)\n {\n if (n == 0) return E(A.Length);\n var t = pow(A, n / 2);\n if ((n & 1) == 0) return mul(t, t);\n return mul(mul(t, t), A);\n }\n public static long dot(long[] x, long[] y)\n {\n int n = x.Length;\n long ret = 0;\n for (int i = 0; i < n; i++) ret = (ret + x[i] * y[i]) % Mod;\n return ret;\n }\n public static long[][] trans(long[][] A)\n {\n int n = A[0].Length, m = A.Length;\n var ret = new long[n][];\n for (int i = 0; i < n; i++) { ret[i] = new long[m]; for (int j = 0; j < m; j++) ret[i][j] = A[j][i]; }\n return ret;\n }\n public static long[] mul(long[][] A, long[] x)\n {\n int n = A.Length;\n var ret = new long[n];\n for (int i = 0; i < n; i++) ret[i] = dot(x, A[i]);\n return ret;\n }\n public static long[][] mul(long[][] A, long[][] B)\n {\n int n = A.Length;\n var Bt = trans(B);\n var ret = new long[n][];\n for (int i = 0; i < n; i++) ret[i] = mul(Bt, A[i]);\n return ret;\n }\n public static long[] add(long[] x, long[] y)\n {\n int n = x.Length;\n var ret = new long[n];\n for (int i = 0; i < n; i++) ret[i] = (x[i] + y[i]) % Mod;\n return ret;\n }\n public static long[][] add(long[][] A, long[][] B)\n {\n int n = A.Length;\n var ret = new long[n][];\n for (int i = 0; i < n; i++) ret[i] = add(A[i], B[i]);\n return ret;\n }\n public static long pow(long a, long b)\n {\n if (a >= Mod) return pow(a % Mod, b);\n if (a == 0) return 0;\n if (b == 0) return 1;\n var t = pow(a, b / 2);\n if ((b & 1) == 0) return t * t % Mod;\n return t * t % Mod * a % Mod;\n }\n public static long inv(long a) => pow(a, Mod - 2);\n public static long gcd(long a, long b)\n {\n while (b > 0) { var t = a % b; a = b; b = t; }\n return a;\n }\n // a x + b y = gcd(a, b)\n public static long extgcd(long a, long b, out long x, out long y)\n {\n long g = a; x = 1; y = 0;\n if (b > 0) { g = extgcd(b, a % b, out y, out x); y -= a / b * x; }\n return g;\n }\n public static long lcm(long a, long b) => a * (b / gcd(a, b));\n public static long comb(int n, int r)\n {\n if (n < 0 || r < 0 || r > n) return 0;\n if (n - r < r) r = n - r;\n if (r == 0) return 1;\n if (r == 1) return n;\n int[] numer = new int[r], denom = new int[r];\n for (int k = 0; k < r; k++) { numer[k] = n - r + k + 1; denom[k] = k + 1; }\n for (int p = 2; p <= r; p++)\n {\n int piv = denom[p - 1];\n if (piv > 1)\n {\n int ofst = (n - r) % p;\n for (int k = p - 1; k < r; k += p) { numer[k - ofst] /= piv; denom[k] /= piv; }\n }\n }\n long ret = 1;\n for (int k = 0; k < r; k++) if (numer[k] > 1) ret = ret * numer[k] % Mod;\n return ret;\n }\n}\n", "lang_cluster": "C#", "tags": ["dfs and similar", "math"], "code_uid": "09ba403325bc0c77ad1bfc8b3c544c0f", "src_uid": "149221131a978298ac56b58438df46c9", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.IO;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace E\n{\n class Program\n {\n //static long _2_n(int n)\n //{\n // //2^50=1125899906842624\n // long res = 1;\n // if (n <= 0) return res;\n // for (int i = 1; i <= n; i++) res = res * 2;\n // return res;\n //}\n\n static void Main(string[] args)\n {\n //for (int z = 1; z <= 25; z++)\n //{\n // StreamReader sr = new StreamReader(\"in\" + z + \".txt\");\n TextReader sr = Console.In;\n\n const long modl = 1000000007;\n //const long modi = 1000000007;\n\n string[] s = sr.ReadLine().Split();\n int n = Convert.ToInt32(s[0]);\n int p = Convert.ToInt32(s[1]);\n s = sr.ReadLine().Split();\n int[] c = new int[n + 1];//0-\u0447\u0435\u0440\u043d\u044b\u0439;1-\u0431\u0435\u043b\u044b\u0439\n for (int i = 1; i <= n; i++) c[i] = Convert.ToInt32(s[i - 1]);\n sr.Close();\n\n\n long[,,,] f = new long[n + 1, n + 1, n + 1, n + 1];\n //f[0, 0, 0, 0] = 1;\n\n //2^50=1125899906842624\n long[] pw = new long[n + 1];//2^i\n pw[0] = 1;\n for (int i = 1; i <= n; i++) pw[i] = (pw[i - 1] * 2) % modl;\n\n long res = 0;\n int ew;\n for (int i = 1; i <= n; i++)\n {\n for (int ob = 0; ob <= i; ob++)\n {\n for (int eb = 0; ob + eb <= i; eb++)\n {\n for (int ow = 0; ob + eb + ow <= i; ow++)\n {\n ew = i - ob - eb - ow;\n\n f[ob, eb, ow, ew] = 0;\n if (c[i] != 0)//\u0435\u0441\u043b\u0438 \u0443\u0437\u0435\u043b \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0431\u0435\u043b\u044b\u043c\n {\n if (i == 1)\n {\n if (ow == 1) f[ob, eb, ow, ew] = f[ob, eb, ow, ew] + 1;\n }\n else\n {\n if (ob == 0)\n {\n if (ow > 0) f[ob, eb, ow, ew] = (f[ob, eb, ow, ew] + (pw[i - 1] * f[ob, eb, ow - 1, ew])%modl) % modl;\n }\n else\n {\n if (ow > 0) f[ob, eb, ow, ew] = (f[ob, eb, ow, ew] + (pw[i - 2] * f[ob, eb, ow - 1, ew]) % modl) % modl;\n if (ew > 0) f[ob, eb, ow, ew] = (f[ob, eb, ow, ew] + (pw[i - 2] * f[ob, eb, ow, ew - 1]) % modl) % modl;\n }\n }\n }\n\n if (c[i] != 1)//\u0435\u0441\u043b\u0438 \u0443\u0437\u0435\u043b \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0447\u0435\u0440\u043d\u044b\u043c\n {\n if (i == 1)\n {\n if (ob == 1) f[ob, eb, ow, ew] = f[ob, eb, ow, ew]+1;\n }\n else\n {\n if (ow == 0)\n {\n if (ob > 0) f[ob, eb, ow, ew] = (f[ob, eb, ow, ew] + (pw[i - 1] * f[ob - 1, eb, ow, ew]) % modl) % modl;\n }\n else\n {\n if (ob > 0) f[ob, eb, ow, ew] = (f[ob, eb, ow, ew] + (pw[i - 2] * f[ob - 1, eb, ow, ew]) % modl) % modl;\n if (eb > 0) f[ob, eb, ow, ew] = (f[ob, eb, ow, ew] + (pw[i - 2] * f[ob, eb - 1, ow, ew]) % modl) % modl;\n }\n }\n }\n\n if ((i == n) && ((ob + ow) % 2 == p))\n res = (res + f[ob, eb, ow, ew]) % modl;\n }\n }\n }\n }\n\n //\u0432\u044b\u0432\u043e\u0434 \u0440\u0435\u0448\u0435\u043d\u0438\u044f\n Console.WriteLine(res);\n //}\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["dp"], "code_uid": "6be4270494e6f51d0a469a8b8823a773", "src_uid": "aaf5f8afa71d9d25ebab405dddec78cd", "difficulty": 2400.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\n\nnamespace Codeforces\n{\n\tclass Program\n\t{\n\t\tstatic void Main(string[] args) \n\t\t{\n\t\t\tstring input1 = Console.ReadLine();\n\t\t\t//string input2 = Console.ReadLine();\n\t\t\t//string input3 = Console.ReadLine();\n\t\t\t//string input4 = Console.ReadLine();\n\n\t\t\tvar inputs1 = input1.Split(new[] { ' ', '}', '{' , ',' }, StringSplitOptions.RemoveEmptyEntries).Select(long.Parse).ToArray();\n\t\t\t//var inputs2 = input2.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(long.Parse).ToArray();\n\n\t\t\tlong n = inputs1[0];\n\t\t\tlong a = inputs1[1];\n\t\t\tlong b = inputs1[2];\n\t\t\tlong p = inputs1[3];\n\t\t\tlong q = inputs1[4];\n\n\t\t\tvar ab = LCM(a, b);\n\n\t\t\tvar nAB = n / ab;\n\t\t\tvar nA = n / a - nAB;\n\t\t\tvar nB = n / b - nAB;\n\n\t\t\tConsole.WriteLine(nA * p + nB * q + nAB * Math.Max(p, q));\n\t\t}\n\n\t\tprivate static long GCD(long a, long b)\n\t\t{\n\t\t\tlong max = Math.Max(a, b);\n\t\t\tlong min = Math.Min(a, b);\n\n\t\t\tif (min == 0)\n\t\t\t{\n\t\t\t\treturn max;\n\t\t\t}\n\t\t\ta = min;\n\t\t\tb = max % min;\n\t\t\treturn GCD(a, b);\n\t\t}\n\n\t\tprivate static long LCM(long a, long b)\n\t\t{\n\t\t\treturn Math.Abs(a * b) / GCD(a, b);\n\t\t}\n\n\t\tstatic long Factorial(long a) \n\t\t{\n\t\t\treturn a > 1 ? a * Factorial(a - 1) : 1;\n\t\t}\n\t}\n}\n", "lang_cluster": "C#", "tags": ["math", "implementation", "number theory"], "code_uid": "3be6b4c5256dbaf7a08321701ddcec8a", "src_uid": "35d8a9f0d5b5ab22929ec050b55ec769", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.IO;\n\nnamespace ConsoleApplication1\n{\n\tclass Program\n\t{\n\t\tstatic void Main(string[] args)\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tMain main = new Main();\n\t\t\t\tmain.ReadData();\n\t\t\t\tmain.Process();\n\t\t\t\tmain.WriteAnswer();\n\t\t\t}\n\t\t\tcatch (Exception e)\n\t\t\t{\n\t\t\t\tConsole.WriteLine(e);\n\t\t\t}\n\t\t}\n\t}\n\n\tclass Main\n\t{\n\t\tprivate long _result;\n\t\tprivate long _n;\n\t\tprivate long _a;\n\t\tprivate long _b;\n\t\tprivate long _p;\n\t\tprivate long _q;\n\n\t\tpublic void Process()\n\t\t{\n\t\t\tlong la = _n / _a;\n\t\t\tlong sa = la*_p;\n\n\t\t\tlong lb = _n / _b;\n\t\t\tlong sb = lb * _q;\n\n\t\t\tlong nok = Nok(_a, _b);\n\t\t\tlong lnok = _n / nok;\n\t\t\tlong snok = lnok * Math.Min(_p, _q);\n\n\t\t\t_result = sb + sa - snok;\n\n\t\t\t//_result = _y;\n\t\t}\n\n\t\tprivate long Nok(long x, long y)\n\t\t{\n\t\t\treturn x*y/Nod(x, y);\n\t\t}\n\t\tprivate long Nod(long x, long y)\n\t\t{\n\t\t\tlong max = Math.Max(x, y);\n\t\t\tlong min = Math.Min(x, y);\n\n\n\t\t\twhile (true)\n\t\t\t{\n\t\t\t\tlong rem = max % min;\n\t\t\t\tif (rem == 0)\n\t\t\t\t{\n\t\t\t\t\treturn min;\n\t\t\t\t}\n\t\t\t\tmax = min;\n\t\t\t\tmin = rem;\n\t\t\t}\n\t\t}\n\n\n\t\tpublic void ReadData()\n\t\t{\n\t\t\tTextReader textReader = Console.In;\n\t\t\t//TextReader textReader = new StreamReader(\"input.txt\");\n\t\t\tusing (TextReader reader = textReader)\n\t\t\t{\n\t\t\t\tstring readLine = reader.ReadLine();\n\t\t\t\tstring[] strings = readLine.Split(' ');\n\n\t\t\t\t_n = long.Parse(strings[0]);\n\t\t\t\t_a = long.Parse(strings[1]);\n\t\t\t\t_b = long.Parse(strings[2]);\n\t\t\t\t_p = long.Parse(strings[3]);\n\t\t\t\t_q = long.Parse(strings[4]);\n\t\t\t\t \n\t\t\t}\n\t\t}\n\n\t\tpublic void WriteAnswer()\n\t\t{\n\t\t\tusing (TextWriter writer = Console.Out)\n\t\t\t{\n\t\t\t\twriter.WriteLine(_result);\n\t\t\t}\n\t\t}\n\t}\n}\n", "lang_cluster": "C#", "tags": ["math", "implementation", "number theory"], "code_uid": "a3219e0b0ea8220a79d7f32be0443372", "src_uid": "35d8a9f0d5b5ab22929ec050b55ec769", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\n\nnamespace _940B\n{\n public class Program\n {\n static void Main(string[] args)\n {\n var n = ulong.Parse(Console.ReadLine());\n var k = ulong.Parse(Console.ReadLine()); //\u10d2\u10d0\u10db\u10e7\u10dd\u10e4\u10d8\n var a = ulong.Parse(Console.ReadLine()); //\u10d2\u10d0\u10db\u10dd\u10d9\u10da\u10d4\u10d1\u10d8\u10e1 \u10e4\u10d0\u10e1\u10d8\n var b = ulong.Parse(Console.ReadLine()); //\u10d2\u10d0\u10e7\u10dd\u10e4\u10d8\u10e1 \u10e4\u10d0\u10e1\u10d8\n ulong totalPrice = 0;\n\n if (k == 1 || n / k < 1)\n {\n Console.WriteLine((n - 1) * a);\n return;\n }\n\n while (n > 1)\n {\n if (n % k != 0)\n {\n if (n / k < 100 && n > k)\n {\n var division = k;\n var i = 1;\n while (k * (ulong)i < n)\n {\n division = k * (ulong)i;\n i++;\n }\n\n totalPrice += (n - division) * a;\n n = division;\n }\n else\n {\n ulong counter = 0;\n while (n % k != 0 && n > 1)\n {\n counter++;\n n--;\n }\n\n totalPrice += counter * a;\n }\n }\n\n if (n == 1)\n break;\n\n if (b > (n - n / k) * a) //\u10d2\u10d0\u10e7\u10dd\u10e4\u10d0 \u10e3\u10e4\u10e0\u10dd \u10eb\u10d5\u10d8\u10e0\u10d8\u10d0\n totalPrice += (n - n / k) * a;\n\n else\n totalPrice += b;\n\n n = n / k;\n\n }\n\n Console.WriteLine(totalPrice);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["greedy", "dp"], "code_uid": "2e8c8f7ea7a1197f7afe886368805436", "src_uid": "f838fae7c98bf51cfa0b9bd158650b10", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace Tanja\n{\n class Program\n {\n static void Main(string[] args)\n {\n long n = long.Parse(Console.ReadLine());\n long k = long.Parse(Console.ReadLine());\n long a = long.Parse(Console.ReadLine());\n long b = long.Parse(Console.ReadLine());\n\n long cost = 0;\n long t = k * a;\n if (n k)\n {\n long rem = n % k;\n if (rem == 0)\n {\n cost += Math.Min(b, (n - n / k) * a);\n n /= k;\n }\n else\n {\n cost += rem * a;\n n -= rem;\n }\n }\n\n if (n == k)\n cost += Math.Min(b, (n - 1) * a);\n else\n cost += (n - 1) * a;\n }\n \n Console.Write(cost);\n \n }\n }\n}\n", "lang_cluster": "C#", "tags": ["greedy", "dp"], "code_uid": "bd249582131ac7613678e3729cf2ec91", "src_uid": "f838fae7c98bf51cfa0b9bd158650b10", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Linq;\nusing System.IO;\nusing System.Collections.Generic;\n// Powered by caide (code generator, tester, and library code inliner)\n\nclass Solution {\n public void solve(TextReader input, TextWriter output) {\n var inp = input.ReadLine().Split(' ').Select(i => ulong.Parse(i)).ToArray();\n ulong x = inp[0];\n ulong y = inp[1];\n ulong l = inp[2];\n ulong r = inp[3];\n\n var xi = new ulong[61];\n xi[0] = 1;\n int powa = 0;\n for (int i = 1; xi[i-1] <= r; i++)\n {\n if(Math.Log10((double)xi[i - 1] * (double)x) > Math.Log10(r))\n {\n break;\n }\n\n xi[i] = xi[i - 1] * x;\n powa = i;\n }\n \n var yj = new ulong[61];\n yj[0] = 1;\n int powb = 0;\n for (int j = 1; yj[j-1] <= r; j++)\n {\n if (Math.Log10((double)yj[j - 1] * (double)y) > Math.Log10(r))\n {\n break;\n }\n\n yj[j] = yj[j - 1] * y;\n powb = j;\n }\n\n var shits = new SortedSet();\n for (int i = 0; i <= powa; i++)\n {\n for (int j = 0; j <= powb; j++)\n {\n ulong n = xi[i] + yj[j];\n if(l <= n && n <= r)\n shits.Add(n);\n }\n }\n\n ulong res = 0;\n if (shits.Count == 0)\n res = r - l + 1;\n else\n {\n var shitArray = shits.ToArray();\n ulong shitLength;\n for (int i = 0; i < shitArray.Count() - 1; i++)\n {\n shitLength = shitArray[i + 1] - shitArray[i] - 1;\n if (shitLength > res)\n res = shitLength;\n }\n\n shitLength = shitArray[0] - l;\n if (shitLength > res)\n res = shitLength;\n\n shitLength = r - shitArray[shitArray.Count() - 1];\n if (shitLength > res)\n res = shitLength;\n }\n\n output.WriteLine(res);\n }\n}\n\nclass CaideConstants {\n public const string InputFile = null;\n public const string OutputFile = null;\n}\npublic class Program {\n public static void Main(string[] args) {\n Solution solution = new Solution();\n using (System.IO.TextReader input =\n CaideConstants.InputFile == null ? System.Console.In :\n new System.IO.StreamReader(CaideConstants.InputFile))\n using (System.IO.TextWriter output =\n CaideConstants.OutputFile == null ? System.Console.Out:\n new System.IO.StreamWriter(CaideConstants.OutputFile))\n\n solution.solve(input, output);\n }\n}\n\n", "lang_cluster": "C#", "tags": ["brute force", "math"], "code_uid": "450a5299acd887d8022f31a15d2d3bda", "src_uid": "68ca8a8730db27ac2230f9fe9b120f5f", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.IO;\nusing System.Runtime.CompilerServices;\nusing System.Text;\nusing System.Diagnostics;\nusing System.Numerics;\nusing static System.Console;\nusing static System.Convert;\nusing static System.Math;\nusing static Template;\nusing Pi = Pair;\n\nclass Solver\n{\n public void Solve(Scanner sc)\n {\n long X, Y, L, R;\n sc.Make(out X, out Y, out L, out R);\n var dx = new List();\n var now = 1L;\n while (now <= R)\n {\n dx.Add(now);\n if ((double)now * X > R) break;\n now *= X;\n }\n var v = new List() { L-1, R+1 };\n now = 1;\n while (now <= R)\n {\n foreach(var e in dx)\n {\n var s = e + now;\n if (L <= s && s <= R) v.Add(s);\n }\n if ((double)now * Y > R) break;\n now *= Y;\n }\n v.Sort();\n var res = 0L;\n for (int i = 0; i < v.Count - 1; i++)\n chmax(ref res, v[i + 1] - v[i] - 1);\n Console.WriteLine(res);\n }\n}\n\n#region Template\npublic static class Template\n{\n static void Main(string[] args)\n {\n Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });\n new Solver().Solve(new Scanner());\n Console.Out.Flush();\n }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static bool chmin(ref T a, T b) where T : IComparable { if (a.CompareTo(b) > 0) { a = b; return true; } return false; }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static bool chmax(ref T a, T b) where T : IComparable { if (a.CompareTo(b) < 0) { a = b; return true; } return false; }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static void swap(ref T a, ref T b) { var t = b; b = a; a = t; }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static void swap(this IList A, int i, int j) { var t = A[i]; A[i] = A[j]; A[j] = t; }\n public static T[] Create(int n, Func f) { var rt = new T[n]; for (var i = 0; i < rt.Length; ++i) rt[i] = f(); return rt; }\n public static T[] Create(int n, Func f) { var rt = new T[n]; for (var i = 0; i < rt.Length; ++i) rt[i] = f(i); return rt; }\n public static IEnumerable Shuffle(this IEnumerable A) => A.OrderBy(v => Guid.NewGuid());\n public static int CompareTo(this T[] A, T[] B, Comparison cmp = null) { cmp = cmp ?? Comparer.Default.Compare; for (var i = 0; i < Min(A.Length, B.Length); i++) { int c = cmp(A[i], B[i]); if (c > 0) return 1; else if (c < 0) return -1; } if (A.Length == B.Length) return 0; if (A.Length > B.Length) return 1; else return -1; }\n public static int MaxElement(this IList A, Comparison cmp = null) { cmp = cmp ?? Comparer.Default.Compare; T max = A[0]; int rt = 0; for (int i = 1; i < A.Count; i++) if (cmp(max, A[i]) < 0) { max = A[i]; rt = i; } return rt; }\n public static T PopBack(this List A) { var v = A[A.Count - 1]; A.RemoveAt(A.Count - 1); return v; }\n public static void Fail(T s) { Console.WriteLine(s); Console.Out.Close(); Environment.Exit(0); }\n}\npublic class Scanner\n{\n public string Str => Console.ReadLine().Trim();\n public int Int => int.Parse(Str);\n public long Long => long.Parse(Str);\n public double Double => double.Parse(Str);\n public int[] ArrInt => Str.Split(' ').Select(int.Parse).ToArray();\n public long[] ArrLong => Str.Split(' ').Select(long.Parse).ToArray();\n public char[][] Grid(int n) => Create(n, () => Str.ToCharArray());\n public int[] ArrInt1D(int n) => Create(n, () => Int);\n public long[] ArrLong1D(int n) => Create(n, () => Long);\n public int[][] ArrInt2D(int n) => Create(n, () => ArrInt);\n public long[][] ArrLong2D(int n) => Create(n, () => ArrLong);\n private Queue q = new Queue();\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public T Next() { if (q.Count == 0) foreach (var item in Str.Split(' ')) q.Enqueue(item); return (T)Convert.ChangeType(q.Dequeue(), typeof(T)); }\n public void Make(out T1 v1) => v1 = Next();\n public void Make(out T1 v1, out T2 v2) { v1 = Next(); v2 = Next(); }\n public void Make(out T1 v1, out T2 v2, out T3 v3) { Make(out v1, out v2); v3 = Next(); }\n public void Make(out T1 v1, out T2 v2, out T3 v3, out T4 v4) { Make(out v1, out v2, out v3); v4 = Next(); }\n public void Make(out T1 v1, out T2 v2, out T3 v3, out T4 v4, out T5 v5) { Make(out v1, out v2, out v3, out v4); v5 = Next(); }\n public void Make(out T1 v1, out T2 v2, out T3 v3, out T4 v4, out T5 v5, out T6 v6) { Make(out v1, out v2, out v3, out v4, out v5); v6 = Next(); }\n public void Make(out T1 v1, out T2 v2, out T3 v3, out T4 v4, out T5 v5, out T6 v6, out T7 v7) { Make(out v1, out v2, out v3, out v4, out v5, out v6); v7 = Next(); }\n //public (T1, T2) Make() { Make(out T1 v1, out T2 v2); return (v1, v2); }\n //public (T1, T2, T3) Make() { Make(out T1 v1, out T2 v2, out T3 v3); return (v1, v2, v3); }\n //public (T1, T2, T3, T4) Make() { Make(out T1 v1, out T2 v2, out T3 v3, out T4 v4); return (v1, v2, v3, v4); }\n}\npublic class Pair : IComparable>\n{\n public T1 v1;\n public T2 v2;\n public Pair() { }\n public Pair(T1 v1, T2 v2)\n { this.v1 = v1; this.v2 = v2; }\n\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public int CompareTo(Pair p)\n {\n var c = Comparer.Default.Compare(v1, p.v1);\n if (c == 0)\n c = Comparer.Default.Compare(v2, p.v2);\n return c;\n }\n public override string ToString() => $\"{v1.ToString()} {v2.ToString()}\";\n public void Deconstruct(out T1 a, out T2 b) { a = v1; b = v2; }\n}\n\npublic class Pair : Pair, IComparable>\n{\n public T3 v3;\n public Pair() : base() { }\n public Pair(T1 v1, T2 v2, T3 v3) : base(v1, v2)\n { this.v3 = v3; }\n\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public int CompareTo(Pair p)\n {\n var c = base.CompareTo(p);\n if (c == 0)\n c = Comparer.Default.Compare(v3, p.v3);\n return c;\n }\n public override string ToString() => $\"{base.ToString()} {v3.ToString()}\";\n public void Deconstruct(out T1 a, out T2 b, out T3 c) { Deconstruct(out a, out b); c = v3; }\n}\n#endregion\n", "lang_cluster": "C#", "tags": ["brute force", "math"], "code_uid": "123a02b8bdc53b30221634e4d3e51028", "src_uid": "68ca8a8730db27ac2230f9fe9b120f5f", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.IO;\n\nnamespace ConsoleApplication1\n{\n class Program\n {\n const string test = @\"..\\..\\test.txt\";\n const string res = @\"..\\..\\res.txt\";\n\n static void Main( string[] args )\n {\n //var r = new StreamReader( test );\n //var w = new StreamWriter( res );\n var s = int.Parse(Console.ReadLine());\n int l = s, i = s / 2;\n Console.Write(\"{0} \", s);\n while ( i > 0 )\n {\n if ( l % i == 0 )\n {\n Console.Write( \"{0} \", i );\n l = i;\n }\n i--;\n } \n //r.Close();\n //w.Close();\n\n \n }\n }\n}\n", "lang_cluster": "C#", "tags": ["greedy"], "code_uid": "8b04c08c9890253fecd162dde8b386f5", "src_uid": "2fc946bb72f56b6d86eabfaf60f9fa63", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Collections;\n\nnamespace checkForSplit\n{\n\n class Program\n {\n\n static void Main(string[] args)\n {\n int n = int.Parse(Console.ReadLine());\n // List[]lst = new List[1000];\n List lst = new List();\n int k = 0;\n int beg = n / 2;\n lst.Add(n);\n while (beg > 1)\n {\n if (lst[lst.Count - 1] % beg == 0)\n {\n lst.Add(beg);\n beg /= 2;\n }\n else beg--;\n }\n if(beg==1)\n lst.Add(1);\n foreach (var i in lst)\n {\n Console.Write(i+\" \");\n }\n Console.WriteLine();\n }\n }\n \n}\n", "lang_cluster": "C#", "tags": ["greedy"], "code_uid": "9fc95ec9f6ed423a3fc46b5c5426516c", "src_uid": "2fc946bb72f56b6d86eabfaf60f9fa63", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "C# 8", "source_code": "using System;\r\nusing System.Collections.Generic;\r\nusing System.IO;\r\nusing System.Linq;\r\nusing static System.Math;\r\nusing System.Text;\r\nusing System.Threading;\r\nusing System.Globalization;\r\nusing System.Runtime.CompilerServices;\r\nusing System.Runtime.InteropServices;\r\nusing Library;\r\n\r\nnamespace Program\r\n{\r\n public static class ProblemB\r\n {\r\n static bool SAIKI = false;\r\n static public int numberOfRandomCases = 0;\r\n static public void MakeTestCase(List _input, List _output, ref Func _outputChecker)\r\n {\r\n }\r\n static public void Solve()\r\n {\r\n var n = NN;\r\n const int mod = 998244353;\r\n var dp = new long[n * 2 + 1];\r\n for (var i = 2; i <= 2 * n; ++i)\r\n {\r\n var len = i * 2 - 2;\r\n for (var j = len; j <= 2 * n; j += len)\r\n {\r\n ++dp[j];\r\n }\r\n }\r\n var ruiseki = 0L;\r\n for (var i = 2; i <= 2 * n; i += 2)\r\n {\r\n dp[i] += ruiseki;\r\n dp[i] %= mod;\r\n ruiseki = (ruiseki + dp[i]) % mod;\r\n }\r\n\r\n Console.WriteLine(dp[n * 2] % mod);\r\n }\r\n class Printer : StreamWriter\r\n {\r\n public override IFormatProvider FormatProvider { get { return CultureInfo.InvariantCulture; } }\r\n public Printer(Stream stream) : base(stream, new UTF8Encoding(false, true)) { base.AutoFlush = false; }\r\n public Printer(Stream stream, Encoding encoding) : base(stream, encoding) { base.AutoFlush = false; }\r\n }\r\n static LIB_FastIO fastio = new LIB_FastIODebug();\r\n static public void Main(string[] args) { if (args.Length == 0) { fastio = new LIB_FastIO(); Console.SetOut(new Printer(Console.OpenStandardOutput())); } if (SAIKI) { var t = new Thread(Solve, 134217728); t.Start(); t.Join(); } else Solve(); Console.Out.Flush(); }\r\n static long NN => fastio.Long();\r\n static double ND => fastio.Double();\r\n static string NS => fastio.Scan();\r\n static long[] NNList(long N) => Repeat(0, N).Select(_ => NN).ToArray();\r\n static double[] NDList(long N) => Repeat(0, N).Select(_ => ND).ToArray();\r\n static string[] NSList(long N) => Repeat(0, N).Select(_ => NS).ToArray();\r\n static long Count(this IEnumerable x, Func pred) => Enumerable.Count(x, pred);\r\n static IEnumerable Repeat(T v, long n) => Enumerable.Repeat(v, (int)n);\r\n static IEnumerable Range(long s, long c) => Enumerable.Range((int)s, (int)c);\r\n static IOrderedEnumerable OrderByRand(this IEnumerable x) => Enumerable.OrderBy(x, _ => xorshift);\r\n static IOrderedEnumerable OrderBy(this IEnumerable x) => Enumerable.OrderBy(x.OrderByRand(), e => e);\r\n static IOrderedEnumerable OrderBy(this IEnumerable x, Func selector) => Enumerable.OrderBy(x.OrderByRand(), selector);\r\n static IOrderedEnumerable OrderByDescending(this IEnumerable x) => Enumerable.OrderByDescending(x.OrderByRand(), e => e);\r\n static IOrderedEnumerable OrderByDescending(this IEnumerable x, Func selector) => Enumerable.OrderByDescending(x.OrderByRand(), selector);\r\n static IOrderedEnumerable OrderBy(this IEnumerable x) => x.OrderByRand().OrderBy(e => e, StringComparer.OrdinalIgnoreCase);\r\n static IOrderedEnumerable OrderBy(this IEnumerable x, Func selector) => x.OrderByRand().OrderBy(selector, StringComparer.OrdinalIgnoreCase);\r\n static IOrderedEnumerable OrderByDescending(this IEnumerable x) => x.OrderByRand().OrderByDescending(e => e, StringComparer.OrdinalIgnoreCase);\r\n static IOrderedEnumerable OrderByDescending(this IEnumerable x, Func selector) => x.OrderByRand().OrderByDescending(selector, StringComparer.OrdinalIgnoreCase);\r\n static string Join(this IEnumerable x, string separator = \"\") => string.Join(separator, x);\r\n static uint xorshift { get { _xsi.MoveNext(); return _xsi.Current; } }\r\n static IEnumerator _xsi = _xsc();\r\n static IEnumerator _xsc() { uint x = 123456789, y = 362436069, z = 521288629, w = (uint)(DateTime.Now.Ticks & 0xffffffff); while (true) { var t = x ^ (x << 11); x = y; y = z; z = w; w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)); yield return w; } }\r\n static bool Chmax(this ref T lhs, T rhs) where T : struct, IComparable { if (lhs.CompareTo(rhs) < 0) { lhs = rhs; return true; } return false; }\r\n static bool Chmin(this ref T lhs, T rhs) where T : struct, IComparable { if (lhs.CompareTo(rhs) > 0) { lhs = rhs; return true; } return false; }\r\n static void Fill(this T[] array, T value) => array.AsSpan().Fill(value);\r\n static void Fill(this T[,] array, T value) => MemoryMarshal.CreateSpan(ref array[0, 0], array.Length).Fill(value);\r\n static void Fill(this T[,,] array, T value) => MemoryMarshal.CreateSpan(ref array[0, 0, 0], array.Length).Fill(value);\r\n static void Fill(this T[,,,] array, T value) => MemoryMarshal.CreateSpan(ref array[0, 0, 0, 0], array.Length).Fill(value);\r\n }\r\n}\r\nnamespace Library {\r\n class LIB_FastIO\r\n {\r\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\r\n public LIB_FastIO() { str = Console.OpenStandardInput(); }\r\n readonly Stream str;\r\n readonly byte[] buf = new byte[2048];\r\n int len, ptr;\r\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\r\n byte read()\r\n {\r\n if (ptr >= len)\r\n {\r\n ptr = 0;\r\n if ((len = str.Read(buf, 0, 2048)) <= 0)\r\n {\r\n return 0;\r\n }\r\n }\r\n return buf[ptr++];\r\n }\r\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\r\n char Char()\r\n {\r\n byte b = 0;\r\n do b = read();\r\n while (b < 33 || 126 < b);\r\n return (char)b;\r\n }\r\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\r\n virtual public string Scan()\r\n {\r\n var sb = new StringBuilder();\r\n for (var b = Char(); b >= 33 && b <= 126; b = (char)read())\r\n sb.Append(b);\r\n return sb.ToString();\r\n }\r\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\r\n virtual public long Long()\r\n {\r\n long ret = 0; byte b = 0; var ng = false;\r\n do b = read();\r\n while (b != '-' && (b < '0' || '9' < b));\r\n if (b == '-') { ng = true; b = read(); }\r\n for (; true; b = read())\r\n {\r\n if (b < '0' || '9' < b)\r\n return ng ? -ret : ret;\r\n else ret = (ret << 3) + (ret << 1) + b - '0';\r\n }\r\n }\r\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\r\n virtual public double Double() { return double.Parse(Scan(), CultureInfo.InvariantCulture); }\r\n }\r\n class LIB_FastIODebug : LIB_FastIO\r\n {\r\n Queue param = new Queue();\r\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\r\n string NextString() { if (param.Count == 0) foreach (var item in Console.ReadLine().Split(' ')) param.Enqueue(item); return param.Dequeue(); }\r\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\r\n public LIB_FastIODebug() { }\r\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\r\n public override string Scan() => NextString();\r\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\r\n public override long Long() => long.Parse(NextString());\r\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\r\n public override double Double() => double.Parse(NextString());\r\n }\r\n}\r\n", "lang_cluster": "C#", "tags": ["math", "dp", "combinatorics"], "code_uid": "04fa815b7f8c98fc3aa232d3bcf76f20", "src_uid": "09be46206a151c237dc9912df7e0f057", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "C# 8", "source_code": "using System;\r\nusing System.IO;\r\nusing System.Collections.Generic;\r\nusing System.Linq;\r\nusing System.Numerics;\r\nusing System.Runtime.CompilerServices;\r\nusing System.Text;\r\nusing System.Globalization;\r\nusing System.Threading;\r\n\r\nusing static System.Math;\r\n\r\nnamespace FertiLib.Contest.B\r\n{\r\n\tpublic class Solver\r\n\t{\r\n\t\tScanner sr;\r\n\t\tStreamWriter sw;\r\n\r\n\t\tbool isMultipleTestCases = false;\r\n\r\n\t\tpublic void Solve()\r\n\t\t{\r\n\t\t\tvar n = sr.ReadInt();\r\n\t\t\tvar devisor = Enumerable.Range(0, n + 1).ToArray();\r\n\t\t\tfor (int i = 2; i * i <= n; i++)\r\n\t\t\t{\r\n\t\t\t\tif (devisor[i] != i) continue;\r\n\t\t\t\tvar t = i * 2;\r\n\t\t\t\twhile (t <= n)\r\n\t\t\t\t{\r\n\t\t\t\t\tdevisor[t] = i;\r\n\t\t\t\t\tt += i;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\tvar dp = new ModInt[n + 1];\r\n\t\t\tdp[1] = 1;\r\n\t\t\tModInt dpsum = 1;\r\n\t\t\tfor (int i = 2; i <= n; i++)\r\n\t\t\t{\r\n\t\t\t\tdp[i] = 1;\r\n\t\t\t\tvar factors = new Dictionary();\r\n\t\t\t\tvar cur = i;\r\n\t\t\t\twhile (cur > 1)\r\n\t\t\t\t{\r\n\t\t\t\t\tif (!factors.ContainsKey(devisor[cur])) factors.Add(devisor[cur], 0);\r\n\t\t\t\t\tfactors[devisor[cur]]++;\r\n\t\t\t\t\tcur /= devisor[cur];\r\n\t\t\t\t}\r\n\t\t\t\tforeach (var (key, value) in factors)\r\n\t\t\t\t{\r\n\t\t\t\t\tdp[i] *= value + 1;\r\n\t\t\t\t}\r\n\t\t\t\tdp[i] += dpsum;\r\n\t\t\t\tdpsum += dp[i];\r\n\t\t\t}\r\n\t\t\tConsole.WriteLine(dp[n]);\r\n\t\t}\r\n\r\n\t\tpublic Solver(Scanner cin, StreamWriter cout)\r\n\t\t{\r\n\t\t\tthis.sr = cin;\r\n\t\t\tthis.sw = cout;\r\n\t\t}\r\n\r\n\t\tpublic void Start()\r\n\t\t{\r\n\t\t\tint _t = 1;\r\n\t\t\tif (isMultipleTestCases) _t = sr.ReadInt();\r\n\t\t\twhile (_t-- > 0) Solve();\r\n\t\t}\r\n\r\n\t\tpublic static void YESNO(bool condition) => Console.WriteLine(condition ? \"YES\" : \"NO\");\r\n\t\tpublic static void YesNo(bool condition) => Console.WriteLine(condition ? \"Yes\" : \"No\");\r\n\t\tpublic static void yesno(bool condition) => Console.WriteLine(condition ? \"yes\" : \"no\");\r\n\r\n\t\tpublic static T SignOutput(int x, T pos, T zero, T neg) => x == 0 ? zero : (x > 0 ? pos : neg);\r\n\r\n\t\tpublic static T[] CreateArray(int n, Func func) => Enumerable.Range(0, n).Select(p => func(p)).ToArray();\r\n\t\tpublic static T[][] CreateArray(int h, int w, Func func) => Enumerable.Range(0, h).Select(i => Enumerable.Range(0, w).Select(j => func(i, j)).ToArray()).ToArray();\r\n\t}\r\n\r\n\tpublic struct ModInt : IEquatable\r\n\t{\r\n\t\tpublic static long MOD = 998244353;\r\n\t\tpublic static bool isModPrime { get; set; }\r\n\r\n\t\tprivate readonly long num;\r\n\r\n\t\tpublic ModInt(long n) { num = n; isModPrime = true; }\r\n\r\n\t\tpublic override string ToString() => num.ToString();\r\n\r\n\t\tpublic static ModInt operator +(ModInt l, ModInt r)\r\n\t\t{\r\n\t\t\tlong x = l.num + r.num;\r\n\t\t\tif (x >= MOD) x -= MOD;\r\n\t\t\treturn new ModInt(x);\r\n\t\t}\r\n\t\tpublic static ModInt operator -(ModInt l, ModInt r)\r\n\t\t{\r\n\t\t\tlong x = l.num - r.num;\r\n\t\t\tif (x < 0) x += MOD;\r\n\t\t\treturn new ModInt(x);\r\n\t\t}\r\n\t\tpublic static ModInt operator *(ModInt l, ModInt r) => new ModInt((l.num * r.num) % MOD);\r\n\t\tpublic static ModInt operator /(ModInt l, ModInt r) => l * r.Inverse();\r\n\r\n\t\tpublic static ModInt operator ++(ModInt x)\r\n\t\t{\r\n\t\t\tvar tmp = x + new ModInt(1);\r\n\t\t\treturn tmp;\r\n\t\t}\r\n\t\tpublic static ModInt operator --(ModInt x)\r\n\t\t{\r\n\t\t\tvar tmp = x - new ModInt(1);\r\n\t\t\treturn tmp;\r\n\t\t}\r\n\r\n\t\tpublic static bool operator ==(ModInt l, ModInt r) => l.Equals(r);\r\n\t\tpublic static bool operator !=(ModInt l, ModInt r) => !l.Equals(r);\r\n\r\n\t\tpublic static implicit operator long(ModInt x) => x.num;\r\n\t\tpublic static implicit operator ModInt(long n)\r\n\t\t{\r\n\t\t\tn %= MOD;\r\n\t\t\tif (n < 0) n += MOD;\r\n\t\t\treturn new ModInt(n);\r\n\t\t}\r\n\r\n\t\tpublic ModInt Inverse() => Inverse(this, MOD);\r\n\t\tpublic static ModInt Inverse(ModInt x) => Inverse(x.num, MOD);\r\n\t\tpublic static long Inverse(long x, long m)\r\n\t\t{\r\n\t\t\tif (x % m == 0) throw new DivideByZeroException();\r\n\t\t\tlong a = x, b = m, u = 1, v = 0;\r\n\t\t\twhile (b > 0)\r\n\t\t\t{\r\n\t\t\t\tlong t = a / b;\r\n\r\n\t\t\t\ta -= t * b;\r\n\t\t\t\tlong p = a; a = b; b = p; // swap(a, b);\r\n\r\n\t\t\t\tu -= t * v;\r\n\t\t\t\tp = u; u = v; v = p; // swap(u, v);\r\n\t\t\t}\r\n\t\t\tu %= m;\r\n\t\t\tif (u < 0) u += m;\r\n\t\t\treturn u;\r\n\t\t}\r\n\r\n\t\tpublic ModInt Pow(long n) => Pow(this, n);\r\n\r\n\t\tpublic static ModInt Pow(long x, long n)\r\n\t\t{\r\n\t\t\tif (n < 0) return Pow(x, -n).Inverse();\r\n\t\t\tx %= MOD;\r\n\t\t\tlong now = 1;\r\n\t\t\tif (isModPrime) n %= MOD - 1;\r\n\t\t\tfor (; n > 0; n /= 2, x = x * x % MOD)\r\n\t\t\t{\r\n\t\t\t\tif (n % 2 == 1) now = now * x % MOD;\r\n\t\t\t}\r\n\t\t\treturn new ModInt(now);\r\n\t\t}\r\n\r\n\t\tpublic bool Equals(ModInt x) => num == x.num;\r\n\r\n\t\tpublic override bool Equals(object obj) => obj is ModInt m && num == m.num;\r\n\r\n\t\tpublic override int GetHashCode()\r\n\t\t{\r\n\t\t\treturn HashCode.Combine(num);\r\n\t\t}\r\n\r\n\t}\r\n\r\n\tpublic static class Program\r\n\t{\r\n\t\tpublic static void Main(string[] args)\r\n\t\t{\r\n\t\t\tvar sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };\r\n\t\t\tConsole.SetOut(sw);\r\n\t\t\tvar cin = new Scanner();\r\n\t\t\tvar solver = new Solver(cin, sw);\r\n\t\t\tsolver.Start();\r\n\t\t\tConsole.Out.Flush();\r\n\t\t}\r\n\t}\r\n\r\n\tpublic static class Extention\r\n\t{\r\n\t\tpublic static string Join(this IEnumerable x, string separator = \"\") => string.Join(separator, x);\r\n\r\n\t\tpublic static int UpperBound(this IList list, T value) => list.BinarySearch(value, true, 0, list.Count, Comparer.Default);\r\n\t\tpublic static int LowerBound(this IList list, T value) => list.BinarySearch(value, false, 0, list.Count, Comparer.Default);\r\n\t\tpublic static int BinarySearch(this IList list, T value, bool isUpperBound, int index, int length, Comparer comparer)\r\n\t\t{\r\n\t\t\tvar ng = index - 1;\r\n\t\t\tvar ok = index + length;\r\n\t\t\twhile (ok - ng > 1)\r\n\t\t\t{\r\n\t\t\t\tvar mid = ng + (ok - ng) / 2;\r\n\t\t\t\tvar res = comparer.Compare(list[mid], value);\r\n\t\t\t\tif (res < 0 || (isUpperBound && res == 0)) ng = mid;\r\n\t\t\t\telse ok = mid;\r\n\t\t\t}\r\n\t\t\treturn ok;\r\n\t\t}\r\n\r\n\t\tpublic static bool Chmax(ref this T a, T b) where T : struct, IComparable\r\n\t\t{\r\n\t\t\tif (a.CompareTo(b) >= 0) return false;\r\n\t\t\ta = b;\r\n\t\t\treturn true;\r\n\t\t}\r\n\t\tpublic static bool Chmin(ref this T a, T b) where T : struct, IComparable\r\n\t\t{\r\n\t\t\tif (a.CompareTo(b) <= 0) return false;\r\n\t\t\ta = b;\r\n\t\t\treturn true;\r\n\t\t}\r\n\t}\r\n\r\n\tpublic class Scanner\r\n\t{\r\n\t\tstring[] s;\r\n\t\tint i;\r\n\r\n\t\tchar[] separator = new char[] { ' ' };\r\n\r\n\t\tpublic Scanner()\r\n\t\t{\r\n\t\t\ts = new string[0];\r\n\t\t\ti = 0;\r\n\t\t}\r\n\r\n\t\tpublic string Read() => ReadString();\r\n\r\n\t\tpublic string ReadString()\r\n\t\t{\r\n\t\t\tif (i < s.Length) return s[i++];\r\n\t\t\tstring st = Console.ReadLine();\r\n\t\t\twhile (st == \"\") st = Console.ReadLine();\r\n\t\t\ts = st.Split(separator, StringSplitOptions.RemoveEmptyEntries);\r\n\t\t\tif (s.Length == 0) return ReadString();\r\n\t\t\ti = 0;\r\n\t\t\treturn s[i++];\r\n\t\t}\r\n\r\n\t\tpublic string[] ReadStringArray(int N)\r\n\t\t{\r\n\t\t\tstring[] Array = new string[N];\r\n\t\t\tfor (int i = 0; i < N; i++)\r\n\t\t\t{\r\n\t\t\t\tArray[i] = ReadString();\r\n\t\t\t}\r\n\t\t\treturn Array;\r\n\t\t}\r\n\r\n\t\tpublic int ReadInt() => int.Parse(ReadString());\r\n\r\n\t\tpublic int[] ReadIntArray(int N, int add = 0)\r\n\t\t{\r\n\t\t\tint[] Array = new int[N];\r\n\t\t\tfor (int i = 0; i < N; i++)\r\n\t\t\t{\r\n\t\t\t\tArray[i] = ReadInt() + add;\r\n\t\t\t}\r\n\t\t\treturn Array;\r\n\t\t}\r\n\r\n\t\tpublic long ReadLong() => long.Parse(ReadString());\r\n\r\n\t\tpublic long[] ReadLongArray(int N, long add = 0)\r\n\t\t{\r\n\t\t\tlong[] Array = new long[N];\r\n\t\t\tfor (int i = 0; i < N; i++)\r\n\t\t\t{\r\n\t\t\t\tArray[i] = ReadLong() + add;\r\n\t\t\t}\r\n\t\t\treturn Array;\r\n\t\t}\r\n\r\n\t\tpublic double ReadDouble() => double.Parse(ReadString());\r\n\r\n\t\tpublic double[] ReadDoubleArray(int N, double add = 0)\r\n\t\t{\r\n\t\t\tdouble[] Array = new double[N];\r\n\t\t\tfor (int i = 0; i < N; i++)\r\n\t\t\t{\r\n\t\t\t\tArray[i] = ReadDouble() + add;\r\n\t\t\t}\r\n\t\t\treturn Array;\r\n\t\t}\r\n\r\n\t\tpublic T1 ReadValue() => (T1)Convert.ChangeType(ReadString(), typeof(T1));\r\n\r\n\t\tpublic (T1, T2) ReadValue()\r\n\t\t{\r\n\t\t\tvar inputs = ReadStringArray(2);\r\n\t\t\tvar v1 = (T1)Convert.ChangeType(inputs[0], typeof(T1));\r\n\t\t\tvar v2 = (T2)Convert.ChangeType(inputs[1], typeof(T2));\r\n\t\t\treturn (v1, v2);\r\n\t\t}\r\n\r\n\t\tpublic (T1, T2, T3) ReadValue()\r\n\t\t{\r\n\t\t\tvar inputs = ReadStringArray(3);\r\n\t\t\tvar v1 = (T1)Convert.ChangeType(inputs[0], typeof(T1));\r\n\t\t\tvar v2 = (T2)Convert.ChangeType(inputs[1], typeof(T2));\r\n\t\t\tvar v3 = (T3)Convert.ChangeType(inputs[2], typeof(T3));\r\n\t\t\treturn (v1, v2, v3);\r\n\t\t}\r\n\r\n\t\tpublic (T1, T2, T3, T4) ReadValue()\r\n\t\t{\r\n\t\t\tvar inputs = ReadStringArray(4);\r\n\t\t\tvar v1 = (T1)Convert.ChangeType(inputs[0], typeof(T1));\r\n\t\t\tvar v2 = (T2)Convert.ChangeType(inputs[1], typeof(T2));\r\n\t\t\tvar v3 = (T3)Convert.ChangeType(inputs[2], typeof(T3));\r\n\t\t\tvar v4 = (T4)Convert.ChangeType(inputs[3], typeof(T4));\r\n\t\t\treturn (v1, v2, v3, v4);\r\n\t\t}\r\n\r\n\t\tpublic (T1, T2, T3, T4, T5) ReadValue()\r\n\t\t{\r\n\t\t\tvar inputs = ReadStringArray(5);\r\n\t\t\tvar v1 = (T1)Convert.ChangeType(inputs[0], typeof(T1));\r\n\t\t\tvar v2 = (T2)Convert.ChangeType(inputs[1], typeof(T2));\r\n\t\t\tvar v3 = (T3)Convert.ChangeType(inputs[2], typeof(T3));\r\n\t\t\tvar v4 = (T4)Convert.ChangeType(inputs[3], typeof(T4));\r\n\t\t\tvar v5 = (T5)Convert.ChangeType(inputs[4], typeof(T5));\r\n\t\t\treturn (v1, v2, v3, v4, v5);\r\n\t\t}\r\n\r\n\t\tpublic (T1, T2, T3, T4, T5, T6) ReadValue()\r\n\t\t{\r\n\t\t\tvar inputs = ReadStringArray(6);\r\n\t\t\tvar v1 = (T1)Convert.ChangeType(inputs[0], typeof(T1));\r\n\t\t\tvar v2 = (T2)Convert.ChangeType(inputs[1], typeof(T2));\r\n\t\t\tvar v3 = (T3)Convert.ChangeType(inputs[2], typeof(T3));\r\n\t\t\tvar v4 = (T4)Convert.ChangeType(inputs[3], typeof(T4));\r\n\t\t\tvar v5 = (T5)Convert.ChangeType(inputs[4], typeof(T5));\r\n\t\t\tvar v6 = (T6)Convert.ChangeType(inputs[5], typeof(T6));\r\n\t\t\treturn (v1, v2, v3, v4, v5, v6);\r\n\t\t}\r\n\r\n\t\tpublic (T1, T2, T3, T4, T5, T6, T7) ReadValue()\r\n\t\t{\r\n\t\t\tvar inputs = ReadStringArray(7);\r\n\t\t\tvar v1 = (T1)Convert.ChangeType(inputs[0], typeof(T1));\r\n\t\t\tvar v2 = (T2)Convert.ChangeType(inputs[1], typeof(T2));\r\n\t\t\tvar v3 = (T3)Convert.ChangeType(inputs[2], typeof(T3));\r\n\t\t\tvar v4 = (T4)Convert.ChangeType(inputs[3], typeof(T4));\r\n\t\t\tvar v5 = (T5)Convert.ChangeType(inputs[4], typeof(T5));\r\n\t\t\tvar v6 = (T6)Convert.ChangeType(inputs[5], typeof(T6));\r\n\t\t\tvar v7 = (T7)Convert.ChangeType(inputs[6], typeof(T7));\r\n\t\t\treturn (v1, v2, v3, v4, v5, v6, v7);\r\n\t\t}\r\n\r\n\t\tpublic T1[] ReadValueArray(int N)\r\n\t\t{\r\n\t\t\tvar v1 = new T1[N];\r\n\t\t\tfor (int i = 0; i < N; i++)\r\n\t\t\t{\r\n\t\t\t\tv1[i] = ReadValue();\r\n\t\t\t}\r\n\t\t\treturn v1;\r\n\t\t}\r\n\r\n\t\tpublic (T1[], T2[]) ReadValueArray(int N)\r\n\t\t{\r\n\t\t\tvar (v1, v2) = (new T1[N], new T2[N]);\r\n\t\t\tfor (int i = 0; i < N; i++)\r\n\t\t\t{\r\n\t\t\t\tvar (t1, t2) = ReadValue();\r\n\t\t\t\tv1[i] = t1;\r\n\t\t\t\tv2[i] = t2;\r\n\t\t\t}\r\n\t\t\treturn (v1, v2);\r\n\t\t}\r\n\r\n\t\tpublic (T1[], T2[], T3[]) ReadValueArray(int N)\r\n\t\t{\r\n\t\t\tvar (v1, v2, v3) = (new T1[N], new T2[N], new T3[N]);\r\n\t\t\tfor (int i = 0; i < N; i++)\r\n\t\t\t{\r\n\t\t\t\tvar (t1, t2, t3) = ReadValue();\r\n\t\t\t\tv1[i] = t1;\r\n\t\t\t\tv2[i] = t2;\r\n\t\t\t\tv3[i] = t3;\r\n\t\t\t}\r\n\t\t\treturn (v1, v2, v3);\r\n\t\t}\r\n\r\n\t\tpublic (T1[], T2[], T3[], T4[]) ReadValueArray(int N)\r\n\t\t{\r\n\t\t\tvar (v1, v2, v3, v4) = (new T1[N], new T2[N], new T3[N], new T4[N]);\r\n\t\t\tfor (int i = 0; i < N; i++)\r\n\t\t\t{\r\n\t\t\t\tvar (t1, t2, t3, t4) = ReadValue();\r\n\t\t\t\tv1[i] = t1;\r\n\t\t\t\tv2[i] = t2;\r\n\t\t\t\tv3[i] = t3;\r\n\t\t\t\tv4[i] = t4;\r\n\t\t\t}\r\n\t\t\treturn (v1, v2, v3, v4);\r\n\t\t}\r\n\r\n\t\tpublic (T1[], T2[], T3[], T4[], T5[]) ReadValueArray(int N)\r\n\t\t{\r\n\t\t\tvar (v1, v2, v3, v4, v5) = (new T1[N], new T2[N], new T3[N], new T4[N], new T5[N]);\r\n\t\t\tfor (int i = 0; i < N; i++)\r\n\t\t\t{\r\n\t\t\t\tvar (t1, t2, t3, t4, t5) = ReadValue();\r\n\t\t\t\tv1[i] = t1;\r\n\t\t\t\tv2[i] = t2;\r\n\t\t\t\tv3[i] = t3;\r\n\t\t\t\tv4[i] = t4;\r\n\t\t\t\tv5[i] = t5;\r\n\t\t\t}\r\n\t\t\treturn (v1, v2, v3, v4, v5);\r\n\t\t}\r\n\r\n\t\tpublic (T1[], T2[], T3[], T4[], T5[], T6[]) ReadValueArray(int N)\r\n\t\t{\r\n\t\t\tvar (v1, v2, v3, v4, v5, v6) = (new T1[N], new T2[N], new T3[N], new T4[N], new T5[N], new T6[N]);\r\n\t\t\tfor (int i = 0; i < N; i++)\r\n\t\t\t{\r\n\t\t\t\tvar (t1, t2, t3, t4, t5, t6) = ReadValue();\r\n\t\t\t\tv1[i] = t1;\r\n\t\t\t\tv2[i] = t2;\r\n\t\t\t\tv3[i] = t3;\r\n\t\t\t\tv4[i] = t4;\r\n\t\t\t\tv5[i] = t5;\r\n\t\t\t\tv6[i] = t6;\r\n\t\t\t}\r\n\t\t\treturn (v1, v2, v3, v4, v5, v6);\r\n\t\t}\r\n\r\n\t\tpublic (T1[], T2[], T3[], T4[], T5[], T6[], T7[]) ReadValueArray(int N)\r\n\t\t{\r\n\t\t\tvar (v1, v2, v3, v4, v5, v6, v7) = (new T1[N], new T2[N], new T3[N], new T4[N], new T5[N], new T6[N], new T7[N]);\r\n\t\t\tfor (int i = 0; i < N; i++)\r\n\t\t\t{\r\n\t\t\t\tvar (t1, t2, t3, t4, t5, t6, t7) = ReadValue();\r\n\t\t\t\tv1[i] = t1;\r\n\t\t\t\tv2[i] = t2;\r\n\t\t\t\tv3[i] = t3;\r\n\t\t\t\tv4[i] = t4;\r\n\t\t\t\tv5[i] = t5;\r\n\t\t\t\tv6[i] = t6;\r\n\t\t\t\tv7[i] = t7;\r\n\t\t\t}\r\n\t\t\treturn (v1, v2, v3, v4, v5, v6, v7);\r\n\t\t}\r\n\t}\r\n}\r\n", "lang_cluster": "C#", "tags": ["math", "dp", "combinatorics"], "code_uid": "381e1efe32ae1a72c39a1f1499300cdd", "src_uid": "09be46206a151c237dc9912df7e0f057", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Globalization;\nusing System.IO;\nusing System.Linq;\nusing System.Text;\n\n// (\u3065\u00b0\u03c9\u00b0)\u3065\uff90\u2605\u309c\u30fb\u3002\u3002\u30fb\u309c\u309c\u30fb\u3002\u3002\u30fb\u309c\u2606\u309c\u30fb\u3002\u3002\u30fb\u309c\u309c\u30fb\u3002\u3002\u30fb\u309c\npublic class Solver\n{\n public object Solve()\n {\n int hp1 = ReadInt();\n int at1 = ReadInt();\n int df1 = ReadInt();\n int hp2 = ReadInt();\n int at2 = ReadInt();\n int df2 = ReadInt();\n int h = ReadInt();\n int a = ReadInt();\n int d = ReadInt();\n\n int ans = 0;\n if (at1 <= df2)\n {\n int need = df2 + 1 - at1;\n at1 += need;\n ans += a * need;\n }\n\n int min = int.MaxValue;\n for (int at = 0; at < 200; at++)\n for (int df = 0; df < 200; df++)\n {\n int x = 0;\n int dm = at1 + at - df2;\n int t = (hp2 - 1) / dm + 1;\n int dm2 = Math.Max(0, at2 - df1 - df);\n if (dm2 > 0)\n {\n int tot = t * dm2;\n if (tot >= hp1)\n x += (tot + 1 - hp1) * h;\n }\n x += at * a + df * d;\n min = Math.Min(x, min);\n }\n\n return ans + min;\n\n return null;\n }\n\n #region Main\n\n protected static TextReader reader;\n protected static TextWriter writer;\n\n static void Main()\n {\n#if DEBUG\n reader = new StreamReader(\"..\\\\..\\\\input.txt\");\n writer = Console.Out;\n //writer = new StreamWriter(\"..\\\\..\\\\output.txt\");\n#else\n reader = new StreamReader(Console.OpenStandardInput());\n writer = new StreamWriter(Console.OpenStandardOutput());\n //reader = new StreamReader(\"instruction.in\");\n //writer = new StreamWriter(\"instruction.out\");\n#endif\n try\n {\n object result = new Solver().Solve();\n if (result != null)\n writer.WriteLine(result);\n }\n catch (Exception ex)\n {\n#if DEBUG\n Console.WriteLine(ex);\n#else\n Console.WriteLine(ex);\n throw;\n#endif\n }\n reader.Close();\n writer.Close();\n }\n\n #endregion\n\n #region Read / Write\n\n private static Queue currentLineTokens = new Queue();\n\n private static string[] ReadAndSplitLine()\n {\n return reader.ReadLine().Split(new[] { ' ', '\\t' }, StringSplitOptions.RemoveEmptyEntries);\n }\n\n public static string ReadToken()\n {\n while (currentLineTokens.Count == 0)\n currentLineTokens = new Queue(ReadAndSplitLine());\n return currentLineTokens.Dequeue();\n }\n\n public static int ReadInt()\n {\n return int.Parse(ReadToken());\n }\n\n public static long ReadLong()\n {\n return long.Parse(ReadToken());\n }\n\n public static double ReadDouble()\n {\n return double.Parse(ReadToken(), CultureInfo.InvariantCulture);\n }\n\n public static int[] ReadIntArray()\n {\n return ReadAndSplitLine().Select(int.Parse).ToArray();\n }\n\n public static long[] ReadLongArray()\n {\n return ReadAndSplitLine().Select(long.Parse).ToArray();\n }\n\n public static double[] ReadDoubleArray()\n {\n return ReadAndSplitLine().Select(s => double.Parse(s, CultureInfo.InvariantCulture)).ToArray();\n }\n\n public static int[][] ReadIntMatrix(int numberOfRows)\n {\n int[][] matrix = new int[numberOfRows][];\n for (int i = 0; i < numberOfRows; i++)\n matrix[i] = ReadIntArray();\n return matrix;\n }\n\n public static int[][] ReadAndTransposeIntMatrix(int numberOfRows)\n {\n int[][] matrix = ReadIntMatrix(numberOfRows);\n int[][] ret = new int[matrix[0].Length][];\n for (int i = 0; i < ret.Length; i++)\n {\n ret[i] = new int[numberOfRows];\n for (int j = 0; j < numberOfRows; j++)\n ret[i][j] = matrix[j][i];\n }\n return ret;\n }\n\n public static string[] ReadLines(int quantity)\n {\n string[] lines = new string[quantity];\n for (int i = 0; i < quantity; i++)\n lines[i] = reader.ReadLine().Trim();\n return lines;\n }\n\n public static void WriteArray(IEnumerable array)\n {\n writer.WriteLine(string.Join(\" \", array));\n }\n\n public static void Write(params T[] array)\n {\n WriteArray(array);\n }\n\n public static void WriteLines(IEnumerable array)\n {\n foreach (var a in array)\n writer.WriteLine(a);\n }\n\n #endregion\n}", "lang_cluster": "C#", "tags": ["brute force", "implementation"], "code_uid": "1310830db6004eb6a39df496eb222d12", "src_uid": "bf8a133154745e64a547de6f31ddc884", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing Solver.Ex;\nusing Debug = System.Diagnostics.Debug;\nusing Watch = System.Diagnostics.Stopwatch;\nusing StringBuilder = System.Text.StringBuilder;\nusing System.Numerics;\nnamespace Solver\n{\n public class Solver\n {\n public void Solve()\n {\n var hp = sc.Integer();\n var atk = sc.Integer();\n var def = sc.Integer();\n var mH = sc.Integer();\n var mA = sc.Integer();\n var mD = sc.Integer();\n var h = sc.Integer();\n var a = sc.Integer();\n var d = sc.Integer();\n var min = int.MaxValue;\n for (int i = 0; i <= 200; i++)\n for (int j = 0; j <= 100; j++)\n {\n var cost = i * a + j * d;\n var res = battle(hp, atk + i, def + j, mH, mA, mD);\n if (res < 0) continue;\n min = Math.Min(min, cost + res * h);\n }\n IO.Printer.Out.WriteLine(min);\n }\n int battle(int hp, int atk, int def, int HP, int ATK, int DEF)\n {\n if (atk <= DEF) return -1;\n var d = Math.Max(0, atk - DEF);\n var hidame = Math.Max(0, ATK - def);\n var turn = HP / d;\n if (HP % d > 0) turn++;\n var damage = hidame * turn;\n if (hp > damage)\n return 0;\n var diff = Math.Abs(hp - damage);\n return diff + 1;\n }\n internal IO.StreamScanner sc;\n static T[] Enumerate(int n, Func f) { var a = new T[n]; for (int i = 0; i < n; i++) a[i] = f(i); return a; }\n }\n\n #region Main and Settings\n static class Program\n {\n static void Main(string[] arg)\n {\n#if DEBUG\n var errStream = new System.IO.FileStream(@\"..\\..\\dbg.out\", System.IO.FileMode.Create, System.IO.FileAccess.Write, System.IO.FileShare.ReadWrite);\n Debug.Listeners.Add(new System.Diagnostics.TextWriterTraceListener(errStream, \"debugStream\"));\n Debug.AutoFlush = false;\n var sw = new Watch(); sw.Start();\n IO.Printer.Out.AutoFlush = true;\n try\n {\n#endif\n\n var solver = new Solver();\n solver.sc = new IO.StreamScanner(Console.OpenStandardInput());\n solver.Solve();\n IO.Printer.Out.Flush();\n#if DEBUG\n }\n catch (Exception ex)\n {\n Console.Error.WriteLine(ex.Message);\n Console.Error.WriteLine(ex.StackTrace);\n }\n finally\n {\n sw.Stop();\n Console.ForegroundColor = ConsoleColor.Green;\n Console.Error.WriteLine(\"Time:{0}ms\", sw.ElapsedMilliseconds);\n Debug.Close();\n System.Threading.Thread.Sleep(System.Threading.Timeout.Infinite);\n }\n#endif\n }\n\n\n }\n #endregion\n}\n#region IO Helper\nnamespace Solver.IO\n{\n public class Printer : System.IO.StreamWriter\n {\n static Printer()\n {\n Out = new Printer(Console.OpenStandardOutput()) { AutoFlush = false };\n#if DEBUG\n Error = new Printer(Console.OpenStandardOutput()) { AutoFlush = false };\n#else\n Error = new Printer(System.IO.Stream.Null) { AutoFlush = false };\n#endif\n }\n public static Printer Out { get; set; }\n public static Printer Error { get; set; }\n public override IFormatProvider FormatProvider { get { return System.Globalization.CultureInfo.InvariantCulture; } }\n public Printer(System.IO.Stream stream) : base(stream, new System.Text.UTF8Encoding(false, true)) { }\n public Printer(System.IO.Stream stream, System.Text.Encoding encoding) : base(stream, encoding) { }\n public void Write(string format, IEnumerable source) { Write(format, source.OfType().ToArray()); }\n public void WriteLine(string format, IEnumerable source) { WriteLine(format, source.OfType().ToArray()); }\n }\n public class StreamScanner\n {\n public StreamScanner(System.IO.Stream stream) { iStream = stream; }\n private readonly System.IO.Stream iStream;\n private readonly byte[] buf = new byte[1024];\n private int len, ptr;\n private bool eof = false;\n public bool IsEndOfStream { get { return eof; } }\n const byte lb = 33, ub = 126, el = 10, cr = 13;\n public byte read()\n {\n if (eof) throw new System.IO.EndOfStreamException();\n if (ptr >= len) { ptr = 0; if ((len = iStream.Read(buf, 0, 1024)) <= 0) { eof = true; return 0; } }\n return buf[ptr++];\n }\n public char Char() { byte b = 0; do b = read(); while (b < lb || ub < b); return (char)b; }\n public char[] Char(int n) { var a = new char[n]; for (int i = 0; i < n; i++) a[i] = Char(); return a; }\n public char[][] Char(int n, int m) { var a = new char[n][]; for (int i = 0; i < n; i++) a[i] = Char(m); return a; }\n public string Scan()\n {\n if (eof) throw new System.IO.EndOfStreamException();\n StringBuilder sb = null;\n var enc = System.Text.UTF8Encoding.Default;\n do\n {\n for (; ptr < len && (buf[ptr] < lb || ub < buf[ptr]); ptr++) ;\n if (ptr < len) break;\n ptr = 0;\n if ((len = iStream.Read(buf, 0, 1024)) <= 0) { eof = true; return \"\"; }\n } while (true);\n do\n {\n var f = ptr;\n for (; ptr < len; ptr++)\n if (buf[ptr] < lb || ub < buf[ptr])\n //if (buf[ptr] == cr || buf[ptr] == el)\n {\n string s;\n if (sb == null) s = enc.GetString(buf, f, ptr - f);\n else { sb.Append(enc.GetChars(buf, f, ptr - f)); s = sb.ToString(); }\n ptr++; return s;\n }\n if (sb == null) sb = new StringBuilder(enc.GetString(buf, f, len - f));\n else sb.Append(enc.GetChars(buf, f, len - f));\n ptr = 0;\n\n }\n while (!eof && (len = iStream.Read(buf, 0, 1024)) > 0);\n eof = true; return (sb != null) ? sb.ToString() : \"\";\n }\n public long Long()\n {\n long ret = 0; byte b = 0; bool isMynus = false;\n const byte zr = 48, nn = 57, my = 45;\n do b = read();\n while (b != my && (b < zr || nn < b));\n if (b == my) { isMynus = true; b = read(); }\n for (; true; b = read())\n if (b < zr || nn < b)\n return isMynus ? -ret : ret;\n else ret = ret * 10 + b - zr;\n }\n public int Integer()\n {\n int ret = 0; byte b = 0; bool isMynus = false;\n const byte zr = 48, nn = 57, my = 45;\n do b = read();\n while (b != my && (b < zr || nn < b));\n if (b == my) { isMynus = true; b = read(); }\n for (; true; b = read())\n if (b < zr || nn < b)\n return isMynus ? -ret : ret;\n else ret = ret * 10 + b - zr;\n }\n public double Double() { return double.Parse(Scan(), System.Globalization.CultureInfo.InvariantCulture); }\n public string[] Scan(int n) { var a = new string[n]; for (int i = 0; i < n; i++) a[i] = Scan(); return a; }\n public double[] Double(int n) { var a = new double[n]; for (int i = 0; i < n; i++) a[i] = Double(); return a; }\n public int[] Integer(int n) { var a = new int[n]; for (int i = 0; i < n; i++) a[i] = Integer(); return a; }\n public long[] Long(int n) { var a = new long[n]; for (int i = 0; i < n; i++)a[i] = Long(); return a; }\n public void Flush() { iStream.Flush(); }\n }\n}\n#endregion\n#region Extension\nnamespace Solver.Ex\n{\n static public partial class EnumerableEx\n {\n static public string AsString(this IEnumerable ie) { return new string(ie.ToArray()); }\n static public string AsJoinedString(this IEnumerable ie, string st = \" \") { return string.Join(st, ie); }\n }\n}\n#endregion\n", "lang_cluster": "C#", "tags": ["brute force", "implementation", "binary search"], "code_uid": "bc28e6c191c5990b5fb7182d961ee3a0", "src_uid": "bf8a133154745e64a547de6f31ddc884", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\n\nnamespace CodeForce\n{\n class _38b\n {\n public static void Main()\n {\n var fig = new string[2];\n fig[0] = Console.ReadLine();\n fig[1] = Console.ReadLine();\n var board = new bool[8,8];\n for (var i = 0; i < 8; i++)\n {\n board[i, fig[0][0] - 'a'] = true;\n board[fig[0][1] - '1', i] = true;\n }\n var d1 = new[] {1, -1};\n var d2 = new[] {2, -2};\n board[fig[1][1] - '1', fig[1][0] - 'a'] = true;\n for (var i = 0; i < 2; i++)\n {\n for (var j = 0; j < 2; j++)\n {\n for (var k = 0; k < 2; k++)\n {\n var dx = d1[j];\n var dy = d2[k];\n var x = fig[i][0] - 'a' + dx;\n var y = fig[i][1] - '1' + dy;\n if (x >= 0 && y >= 0 && x < 8 && y < 8)\n {\n board[y, x] = true;\n }\n\n dx = d2[k];\n dy = d1[j];\n x = fig[i][0] - 'a' + dx;\n y = fig[i][1] - '1' + dy;\n if (x >= 0 && y >= 0 && x < 8 && y < 8)\n {\n board[y, x] = true;\n }\n }\n }\n }\n var result = 0;\n for (var i = 0; i < 8; i++)\n {\n for (var j = 0; j < 8; j++)\n {\n //Console.Write(board[i, j] ? 'x' : 'o');\n if (!board[i,j])\n {\n result++;\n }\n }\n //Console.WriteLine();\n }\n Console.WriteLine(result);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "math", "implementation"], "code_uid": "8b512bc3f4f158f6f260dceecd0e5859", "src_uid": "073023c6b72ce923df2afd6130719cfc", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\n\nnamespace Chess\n{\n class Program\n {\n static bool Konj_Napada_Drugu_Figuru(int redKonja,int kolonaKonja,int redDrugeFigure,int kolonaDrugeFigure)\n {\n if ((redKonja==redDrugeFigure&&kolonaKonja==kolonaDrugeFigure)||(redKonja - 2 == redDrugeFigure && kolonaKonja - 1 == kolonaDrugeFigure) || (redKonja - 2 == redDrugeFigure && kolonaKonja + 1 == kolonaDrugeFigure) || (redKonja - 1 == redDrugeFigure && kolonaKonja + 2 == kolonaDrugeFigure) || (redKonja - 1 == redDrugeFigure && kolonaKonja - 2 == kolonaDrugeFigure) || (redKonja + 1 == redDrugeFigure && kolonaKonja - 2 == kolonaDrugeFigure) || (redKonja + 1 == redDrugeFigure && kolonaKonja + 2 == kolonaDrugeFigure) || (redKonja + 2 == redDrugeFigure && kolonaKonja - 1 == kolonaDrugeFigure) || (redKonja + 2 == redDrugeFigure && kolonaKonja + 1 == kolonaDrugeFigure))\n return true;\n else return false;\n }\n static bool Top_Napada_Drugu_Figuru(int redTopa, int kolonaTopa, int redDrugeFigure, int kolonaDrugeFigure) \n {\n if (redTopa==redDrugeFigure||kolonaTopa==kolonaDrugeFigure)\n return true;\n else return false;\n }\n static void Main(string[] args)\n {\n int r1 = 0, c1 = 0, r2 = 0, c2 = 0;\n string line = Console.ReadLine();\n switch (line.Substring(0, 1))\n {\n case \"a\": r1 = 1;\n break;\n case \"b\": r1 = 2;\n break;\n case \"c\": r1 = 3;\n break;\n case \"d\": r1 = 4;\n break;\n case \"e\": r1 = 5;\n break;\n case \"f\": r1 = 6;\n break;\n case \"g\": r1 = 7;\n break;\n case \"h\": r1 = 8;\n break;\n }\n \n c1 = int.Parse(line.Substring(1, 1));\n line = Console.ReadLine();\n switch (line.Substring(0, 1))\n {\n case \"a\": r2 = 1;\n break;\n case \"b\": r2 = 2;\n break;\n case \"c\": r2 = 3;\n break;\n case \"d\": r2 = 4;\n break;\n case \"e\": r2 = 5;\n break;\n case \"f\": r2 = 6;\n break;\n case \"g\": r2 = 7;\n break;\n case \"h\": r2 = 8;\n break;\n }\n c2 = int.Parse(line.Substring(1, 1));\n int ans = 0;\n for (int i = 1; i <= 8; i++)\n {\n for (int j = 1; j <= 8; j++)\n {\n if (!Top_Napada_Drugu_Figuru(r1, c1, i, j) && !Konj_Napada_Drugu_Figuru(r2, c2, i, j)&&!Konj_Napada_Drugu_Figuru(i,j,r1,c1))\n ans++;\n //Console.WriteLine(i + \" \" + j + \" \" + Top_Napada_Drugu_Figuru(r1, c1, i, j) + \" \" + Konj_Napada_Drugu_Figuru(r2, c2, i, j) + \" \" + Konj_Napada_Drugu_Figuru(i, j, r1, c1));\n\n }\n }\n Console.WriteLine(ans);\n //Console.ReadLine();\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "math", "implementation"], "code_uid": "c910c3a37537c0d8a8c56f8b58b203b6", "src_uid": "073023c6b72ce923df2afd6130719cfc", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.IO;\nusing System.Collections;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Globalization;\n\nnamespace ConsoleApplication1\n{\n class Program\n {\n const int N = 2001;\n const int MOD = 1000000007;\n static int[][] dp;\n static int n;\n static int k;\n private static int solve(int len, int last)\n {\n if (len == k)\n return 1;\n if (dp[len][last] != -1)\n return dp[len][last];\n dp[len][last] = 0;\n for (int j = 1; j * last <= n; ++j)\n dp[len][last] = (dp[len][last] + solve(len + 1, last * j)) % MOD;\n return dp[len][last];\n }\n public static void Main()\n {\n n = GetInt();\n k = GetInt();\n dp = new int[N][];\n for (int i = 0; i < N; ++i)\n dp[i] = new int[N];\n for (int i = 0; i < N; ++i)\n for (int j = 0; j < N; ++j)\n dp[i][j] = -1;\n int ans = 0;\n for (int i = 1; i <= n; ++i)\n ans = (ans + solve(1, i)) % MOD;\n Console.WriteLine(ans);\n }\n\n\n\n private static int pos = 0;\n private static string[] st;\n private static string GetString()\n {\n if (st == null || pos == st.Length)\n {\n st = Console.ReadLine().Split(' ');\n pos = 0;\n }\n return st[pos++];\n }\n private static int GetInt()\n {\n return int.Parse(GetString());\n }\n private static double GetDouble()\n {\n return double.Parse(GetString(), CultureInfo.InvariantCulture);\n }\n private static long GetLong()\n {\n return long.Parse(GetString());\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["dp", "combinatorics", "number theory"], "code_uid": "fb9cae69e8978aa282411241c0921ab8", "src_uid": "c8cbd155d9f20563d37537ef68dde5aa", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Text;\n\nnamespace Codeforces_240_2\n{\n class Program\n {\n static void Main(string[] args)\n {\n string[] S = Console.ReadLine().Split(' ');\n int n = int.Parse(S[0]);\n int k = int.Parse(S[1]);\n long[] dp = new long[12];\n int[] d = new int[12];\n int[] m = new int[12];\n for (d[0] = 1; d[0] <= n; ++d[0])\n {\n ++dp[0];\n int i = 1;\n for (m[i] = 2; ; ++m[i])\n {\n d[i] = d[i-1] * m[i];\n if (n < d[i])\n {\n if (--i < 1) break;\n }\n else\n {\n ++dp[i];\n ++i;\n m[i] = 1;\n }\n }\n }\n long[,] b = new long[k, 12];\n for (int i = 0; i < k; ++i)\n {\n b[i, 0] = 1;\n for (int j = 1; j < 12 && j <= i; ++j)\n b[i, j] = (b[i - 1, j - 1] + b[i - 1, j]) % 1000000007;\n }\n long ret = 0;\n for (long j = 0; j < 12 && j < k; ++j)\n ret = (ret + b[k-1, j] * dp[j]) % 1000000007;\n Console.WriteLine(ret);\n }\n }\n}\n\n", "lang_cluster": "C#", "tags": ["dp", "combinatorics", "number theory"], "code_uid": "afd6a0adc27d3edbf9ddb011610dccc5", "src_uid": "c8cbd155d9f20563d37537ef68dde5aa", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\n\t\t\t\t\t\npublic class Program\n{\n\tpublic static void Main()\n\t{\n\t\tlong t = Convert.ToInt64(Console.ReadLine());\n string[] tests = new string[2];\n\t\tlong f;\n\t\tlong p;\n\t\tint kek = 3;\n for(long i=0;i 0)\n {\n\n string read;\n read = Console.ReadLine();\n long a = long.Parse(read.Split(' ').ToList()[0]);\n long b = long.Parse(read.Split(' ').ToList()[1]);\n\n bool flag = true;\n\n if (a % 2 == 1 && b % 2 == 1)\n {\n flag = false;\n }\n\n if (a % 2 == 0 && b % 2 == 0)\n {\n flag = false;\n }\n\n if (a - b > 1)\n {\n flag = false;\n }\n\n if(flag)\n {\n flag = isprime(a + b);\n }\n\n if(flag)\n {\n Console.WriteLine(\"YES\");\n }\n else\n {\n Console.WriteLine(\"NO\");\n }\n\n }\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "number theory"], "code_uid": "22c0dc87385d76ce3db492804537fe7c", "src_uid": "5a052e4e6c64333d94c83df890b1183c", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\n\npublic sealed class Program {\n\n const Int64 Mod = 1000000007;\n\n static void Add(ref Int64 cur, Int64 add) {\n cur = (cur + add) % Mod;\n }\n\n public Program () {\n Int32[] token = ReadArray();\n Int32 n = token[0], cap = token[1], i, cnt50 = 0, cnt100 = 0, a, b, c, d;\n token = ReadArray();\n Array.Sort(token);\n if (cap < 50 || cap < token[n - 1] || n != 1 && cap < token[0] + token[1]) {\n Console.WriteLine(-1);\n Console.WriteLine('0');\n return;\n }\n foreach (Int32 body in token) {\n if (body == 50) {\n ++cnt50;\n } else {\n ++cnt100;\n }\n }\n Int64[,] binomial = new Int64[n + 1, n + 1];\n for (i = 0; i <= n; ++i) {\n binomial[i, 0] = binomial[i, i] = 1;\n }\n for (a = 2; a <= n; ++a) {\n for (b = 1; b < a; ++b) {\n binomial[a, b] = (binomial[a - 1, b] + binomial[a - 1, b - 1]) % Mod;\n }\n }\n Int64[, ,] dp = new Int64[2, cnt50 + 1, cnt100 + 1];\n dp[0, cnt50, cnt100] = 1;\n for (i = 0; ; ++i) {\n if (i % 2 != 0 && dp[i % 2, cnt50, cnt100] != 0) {\n Console.WriteLine(i);\n Console.WriteLine(dp[i % 2, cnt50, cnt100]);\n return;\n }\n for (a = 0; a <= cnt50; ++a) {\n for (b = 0; b <= cnt100; ++b) {\n if (dp[i % 2, a, b] != 0) {\n for (c = 0; c <= a; ++c) {\n for (d = 0; d <= b && c * 50 + d * 100 <= cap; ++d) {\n if (c + d != 0) {\n Add(ref dp[1 - i % 2, cnt50 - (a - c), cnt100 - (b - d)], dp[i % 2, a, b] * binomial[a, c] % Mod * binomial[b, d] % Mod);\n }\n }\n }\n }\n }\n }\n }\n }\n\n // stuff cutline\n\n public static void Main() {\n#if DEBUG\n Console.SetIn(new System.IO.StreamReader(\"..\\\\..\\\\in.txt\"));\n#endif\n var root = new Program();\n Console.Out.Flush();\n }\n\n static Int32 ReadInt() {\n Boolean neg = false;\n Int32 ch, ans = 0;\n do {\n ch = Console.Read();\n neg |= ch == (Int32)'-';\n } while (!Char.IsDigit((Char)ch));\n do {\n ans = ans * 10 + (ch & 0xf);\n ch = Console.Read();\n } while (Char.IsDigit((Char)ch));\n return neg ? -ans : ans;\n }\n\n static Int32[] ReadArray() {\n return Array.ConvertAll(Console.ReadLine().Split(), Int32.Parse);\n }\n\n}", "lang_cluster": "C#", "tags": ["dp", "combinatorics", "graphs", "shortest paths"], "code_uid": "aa27fbbec387ca9025294bb3150ef67b", "src_uid": "ebb0323a854e19794c79ab559792a1f7", "difficulty": 2100.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace Trenya260619\n{\n class Input\n {\n private static IEnumerator _getinput()\n {\n while (true)\n foreach (string s in Console.ReadLine().Split().Where(x => x.Length > 0))\n yield return s;\n }\n\n private IEnumerator input = _getinput();\n\n public string GetString()\n {\n input.MoveNext();\n return input.Current;\n }\n\n public int GetInt() { return int.Parse(GetString()); }\n public long GetLong() { return long.Parse(GetString()); }\n public double GetDouble() { return double.Parse(GetString()); }\n }\n\n class Program\n {\n static Input csin = new Input();\n\n static void Main(string[] args)\n {\n int n = csin.GetInt();\n long k = csin.GetLong();\n List s = csin.GetString().Select(x => (int)(x - 'a')).ToList();\n s.Add(26);\n\n long[,] d = new long[n + 1, n + 1]; // i - length, j - first index\n\n d[0, n] = 1;\n\n bool[] ex = new bool[27];\n\n for (int len = 1; len <= n; len++)\n for (int start = 0; start < n; start++)\n {\n for (int i = 0; i < 27; i++) ex[i] = false;\n\n for (int j = start + 1; j <= n; j++)\n {\n if (ex[s[j]]) continue;\n ex[s[j]] = true;\n d[len, start] += d[len - 1, j];\n }\n }\n\n\n long[] lenans = new long[n + 1];\n for (int i = 0; i <= n; i++)\n {\n for (int j = 0; j < 27; j++) ex[j] = false;\n\n for (int j = 0; j <= n; j++)\n {\n if (ex[s[j]]) continue;\n\n lenans[i] += d[i, j];\n ex[s[j]] = true;\n }\n }\n\n long ans = 0;\n\n for (int i = n; i >= 0 && k > 0; i--)\n {\n long curr = Math.Min(k, lenans[i]);\n k -= curr;\n ans += curr * (n - i);\n }\n\n if (k > 0) ans = -1;\n\n\n Console.WriteLine(ans);\n //Console.ReadKey();\n }\n\n }\n}", "lang_cluster": "C#", "tags": ["strings", "dp"], "code_uid": "e63260d31586fef3cbd8776a3129ec5e", "src_uid": "ae5d21919ecac431ea7507cb1b6dc72b", "difficulty": 1900.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Linq;\nusing CompLib.Util;\n\npublic class Program\n{\n int N;\n long K;\n string S;\n public void Solve()\n {\n var sc = new Scanner();\n N = sc.NextInt();\n K = sc.NextLong();\n S = sc.Next();\n\n\n // i\u307e\u3067\u898b\u305f\u3001\u30b9\u30ad\u30c3\u30d7j\u500b \u6700\u5f8c\u6587\u5b57\n var dp = new long[N + 1, N + 1, 27];\n dp[0, 0, 26] = 1;\n for (int i = 0; i < N; i++)\n {\n for (int j = 0; j <= i; j++)\n {\n\n for (int c = 0; c <= 26; c++)\n {\n // s_i\u3092\u4f7f\u3046\n dp[i + 1, j, S[i] - 'a'] += dp[i, j, c];\n\n\n // \u4f7f\u308f\u306a\u3044\n if (S[i] - 'a' != c) dp[i + 1, j + 1, c] += dp[i, j, c];\n }\n }\n }\n\n long[] cnt = new long[N + 1];\n for (int i = 0; i <= N; i++)\n {\n for (int c = 0; c <= 26; c++)\n {\n cnt[i] += dp[N, i, c];\n }\n }\n\n long ans = 0;\n for (int i = 0; i <= N && K > 0; i++)\n {\n // Console.WriteLine($\"{i} {cnt[i]} {K}\");\n if (cnt[i] < K)\n {\n ans += cnt[i] * i;\n K -= cnt[i];\n }\n else\n {\n ans += i * K;\n K = 0;\n }\n }\n\n if (K > 0)\n {\n Console.WriteLine(\"-1\");\n return;\n }\n\n Console.WriteLine(ans);\n }\n\n public static void Main(string[] args) => new Program().Solve();\n}\n\nnamespace CompLib.Util\n{\n using System;\n using System.Linq;\n\n class Scanner\n {\n private string[] _line;\n private int _index;\n private const char Separator = ' ';\n\n public Scanner()\n {\n _line = new string[0];\n _index = 0;\n }\n\n public string Next()\n {\n if (_index >= _line.Length)\n {\n string s;\n do\n {\n s = Console.ReadLine();\n } while (s.Length == 0);\n\n _line = s.Split(Separator);\n _index = 0;\n }\n\n return _line[_index++];\n }\n\n public string ReadLine()\n {\n _index = _line.Length;\n return Console.ReadLine();\n }\n\n public int NextInt() => int.Parse(Next());\n public long NextLong() => long.Parse(Next());\n public double NextDouble() => double.Parse(Next());\n public decimal NextDecimal() => decimal.Parse(Next());\n public char NextChar() => Next()[0];\n public char[] NextCharArray() => Next().ToCharArray();\n\n public string[] Array()\n {\n string s = Console.ReadLine();\n _line = s.Length == 0 ? new string[0] : s.Split(Separator);\n _index = _line.Length;\n return _line;\n }\n\n public int[] IntArray() => Array().Select(int.Parse).ToArray();\n public long[] LongArray() => Array().Select(long.Parse).ToArray();\n public double[] DoubleArray() => Array().Select(double.Parse).ToArray();\n public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();\n }\n}\n", "lang_cluster": "C#", "tags": ["strings", "dp"], "code_uid": "71faf3120c5dab6eb5c3d747d7bb0ddb", "src_uid": "ae5d21919ecac431ea7507cb1b6dc72b", "difficulty": 1900.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\n\nnamespace C1\n{\n class Program\n {\n static void Main(string[] args)\n {\n string str,str1=\"\",ch=\"\",sl=\"/\",ru=\".ru\";\n int num = 0;\n str=Console.ReadLine();\n if (str[0] == 'h')\n {\n str1 = \"http://\";\n for (int i = 4; i < str.Length; i++)\n {\n if (i != 4 && str[i] == 'r' && str[i + 1] == 'u') { num = i; break; }\n str1 += str[i];\n }\n str1 += ru;\n num += 2;\n if (num == str.Length) Console.WriteLine(str1);\n else\n {\n str1 += sl;\n for (int i = num; i < str.Length; i++)\n str1 += str[i];\n Console.WriteLine(str1);\n }\n }\n\n else \n { \n str1 = \"ftp://\";\n\n for (int i = 3; i < str.Length; i++)\n {\n if (i != 3 && str[i] == 'r' && str[i + 1] == 'u') { num = i; break; }\n str1 += str[i];\n }\n str1 += ru;\n num += 2;\n if (num == str.Length) Console.WriteLine(str1);\n else\n {\n str1 += sl;\n for (int i = num; i < str.Length; i++)\n str1 += str[i];\n Console.WriteLine(str1);\n }\n } \n \n\n \n \n \n }\n }\n}\n", "lang_cluster": "C#", "tags": ["strings", "implementation"], "code_uid": "80c049c631a77c4f99e85bfbd3dadee0", "src_uid": "4c999b7854a8a08960b6501a90b3bba3", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\n\nclass Program\n{\n static void Main(string[] args)\n {\n string input = Console.ReadLine();\n string output = \"\";\n int ind = input.IndexOf(\"ru\");\n if (input[0].Equals('f'))\n {\n output += \"ftp://\";\n if (ind == 3) ind = input.IndexOf(\"ru\", 5);\n output += input.Substring(3, ind - 3);\n }\n else\n {\n output += \"http://\";\n if (ind == 4) ind = input.IndexOf(\"ru\", 6);\n output += input.Substring(4, ind - 4);\n }\n output += \".ru\";\n if (ind + 2 != input.Length)\n output += \"/\" + input.Substring(ind + 2, input.Length - (ind + 2));\n Console.WriteLine(output);\n Console.ReadLine();\n }\n}\n", "lang_cluster": "C#", "tags": ["strings", "implementation"], "code_uid": "4d13078f4d3e57eae38c5a4981213d83", "src_uid": "4c999b7854a8a08960b6501a90b3bba3", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace Codeforces\n{\n class Program\n {\n static void Main(string[] args)\n {\n\n string str = Console.ReadLine();\n\n int countUnSimilar = 0;\n for (int i = 0; i < str.Length / 2; i++)\n {\n if (str[i] != str[str.Length - i - 1])\n countUnSimilar++;\n }\n\n if (countUnSimilar == 1||(countUnSimilar==0&&str.Length%2!=0))\n Console.WriteLine(\"YES\");\n else\n Console.WriteLine(\"NO\");\n\n }\n\n }\n}", "lang_cluster": "C#", "tags": ["brute force", "strings", "constructive algorithms"], "code_uid": "cf4045d3d6457133eef0b54f6fe585fe", "src_uid": "fe74313abcf381f6c5b7b2057adaaa52", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\nusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Web;\nusing System.IO;\nusing System.Text;\n\nnamespace Main_Problem_Template\n{\n class Program\n {\n\n const string input = \"input.txt\";\n const string output = \"output.txt\";\n\n\n static void Main(string[] args)\n {\n List inputInt = new List();\n List inputChar = new List();\n \n //ReadData(input, inputInt, inputChar);\n ReadConsole(inputInt, inputChar);\n string outputS = F1(inputChar);\n WriteConsole(inputInt, inputChar, outputS);\n //WriteData(output,inputInt,inputChar,outputS);\n\n }\n\n static string F1(List inputChar)\n {\n int fails = 0;\n int n = inputChar.Count();\n bool even;\n if (n % 2 == 0)\n {\n even = true;\n }\n else\n {\n even = false;\n }\n\n if (even)\n {\n for (int i = 0; i < n/2; i++)\n {\n if (inputChar[i] != inputChar[n-1 - i])\n {\n fails++;\n }\n }\n }\n else {\n for (int i = 0; i < (n-1)/2; i++)\n {\n if (inputChar[i] != inputChar[n-1 - i])\n {\n fails++;\n }\n }\n }\n\n if (fails == 1 && even)\n {\n return \"YES\";\n }\n else if (fails <2 && !even)\n {\n return \"YES\";\n }\n else\n {\n return \"NO\";\n }\n }\n\n static void ReadConsole(List inputInt, List inputChar)\n {\n string line = Console.ReadLine();\n inputChar.AddRange(line);\n }\n\n static void WriteConsole(List outputInt, List outputChar, string outputS)\n {\n Console.WriteLine(outputS);\n }\n\n static void ReadData(string file, List inputInt, List inputChar)\n {\n string line;\n\n using (StreamReader reader = new StreamReader(@file))\n {\n //k = int.Parse(reader.ReadLine());\n line = reader.ReadLine();\n //string[] parts = line.Split(' ');\n for (int i = 0; i < line.Length; i++)\n {\n inputChar.Add(line[i]);\n }\n\n }\n }\n\n static void WriteData(string fv, List outputInt, List outputChar,string outputS)\n {\n using (var file = new System.IO.StreamWriter(fv, false))\n {\n //file.Write();\n //file.WriteLine();\n //file.WriteLine(count);\n /*\n foreach (char x in outputChar)\n {\n file.Write(x);\n Console.Write(x);\n }\n */\n file.Write(outputS);\n Console.Write(outputS);\n }\n Console.WriteLine();\n }\n\n\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "strings", "constructive algorithms"], "code_uid": "0e614f5e1d003913efa5d2765502025d", "src_uid": "fe74313abcf381f6c5b7b2057adaaa52", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeff#if DEBUG\nusing System.Reflection;\nusing System.Threading.Tasks;\n#endif\n\nusing System;\nusing System.Collections.Generic;\nusing System.IO;\nusing System.Linq;\nusing System.Text;\nusing System.Numerics;\nusing System.Globalization;\n\n#if DEBUG\nusing System.Diagnostics;\n#endif\n\nnamespace ed29b\n{\n class Program\n {\n static string _inputFilename = \"input.txt\";\n static string _outputFilename = \"output.txt\";\n static bool _useFileInput = false;\n const string _delim = \"!\";\n\n\n static void Main(string[] args)\n {\n StreamWriter file = null;\n#if DEBUG\n var testNumber = 0;\n var timer = new Stopwatch();\n foreach (var test in GetTests())\n {\n\n timer.Start();\n\n var defaultColor = Console.ForegroundColor;\n Console.ForegroundColor = ConsoleColor.DarkYellow;\n Console.WriteLine($\"\");\n Console.ForegroundColor = defaultColor;\n Console.SetIn(test);\n\n\n#else\n if (_useFileInput)\n {\n Console.SetIn(File.OpenText(_inputFilename));\n file = new StreamWriter(_outputFilename);\n Console.SetOut(file);\n }\n#endif\n\n try\n {\n Solution();\n }\n finally\n {\n if (_useFileInput)\n {\n file.Close();\n }\n }\n\n#if DEBUG\n timer.Stop();\n\n Console.ForegroundColor = ConsoleColor.DarkYellow;\n Console.WriteLine($\"\");\n Console.ForegroundColor = defaultColor;\n\n timer.Reset();\n testNumber++;\n }\n#endif\n }\n\n static void Solution()\n {\n #region SOLUTION\n var n = ReadInt();\n var a = ReadIntArray();\n\n Array.Sort(a);\n\n var min = int.MaxValue;\n for (int i = 0; i < 2 * n; i++)\n {\n for (int j = i + 1; j < 2 * n; j++)\n {\n var sum = 0;\n\n var k1 = 0;\n var k2 = 0;\n while (true)\n {\n if (k1 == i || k1 == j)\n {\n k1++;\n continue;\n }\n\n if (k2 <= k1)\n {\n k2 = k1 + 1;\n }\n \n if (k2 == i || k2 == j)\n {\n k2++;\n continue;\n }\n\n if (k2 >= 2 * n)\n {\n break;\n }\n\n sum += (a[k2] - a[k1]);\n k1 = k2 + 1;\n }\n\n if (sum < min)\n {\n min = sum;\n }\n }\n }\n\n Console.WriteLine(min);\n //var n = readInt();\n //var m = readInt();\n\n //var a = readIntArray();\n //var b = readIntArray();\n #endregion\n }\n\n static int ReadInt()\n {\n return int.Parse(Console.ReadLine());\n }\n\n static long ReadLong()\n {\n return long.Parse(Console.ReadLine());\n }\n\n static int[] ReadIntArray()\n {\n return Console.ReadLine().Split(' ').Where(i => !string.IsNullOrEmpty(i)).Select(i => int.Parse(i)).ToArray();\n }\n\n static long[] ReadLongArray()\n {\n return Console.ReadLine().Split(' ').Where(i => !string.IsNullOrEmpty(i)).Select(i => long.Parse(i)).ToArray();\n }\n\n#if DEBUG\n static IEnumerable GetTests()\n {\n var tests = new List();\n var resName = Assembly.GetCallingAssembly().GetManifestResourceNames()[0];\n using (var resource = new StreamReader(Assembly.GetCallingAssembly().GetManifestResourceStream(resName)))\n {\n while (true)\n {\n var nextText = new StringBuilder();\n var endOfFile = false;\n while (true)\n {\n var line = resource.ReadLine();\n\n endOfFile = line == null;\n if (endOfFile)\n {\n break;\n }\n\n if (line.Equals(_delim, StringComparison.Ordinal))\n {\n break;\n }\n\n nextText.AppendLine(line);\n }\n\n yield return new StringReader(nextText.ToString());\n\n if (endOfFile)\n {\n break;\n }\n }\n }\n }\n#endif\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "sortings", "greedy"], "code_uid": "6f609252d6d488ec8d9cf73a5f003cdb", "src_uid": "76659c0b7134416452585c391daadb16", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace CodeForces\n{ \n class B\n {\n static void Main(string[] args)\n {\n int n = int.Parse(Console.ReadLine());\n List a = new List();\n string[] token = Console.ReadLine().Split();\n for(int i=0;i<2*n;i++)\n {\n \ta.Add(int.Parse(token[i]));\n }\n a.Sort();\n int min = int.MaxValue;\n for (int i = 0; i < a.Count; i++)\n {\n for (int j = i + 1; j < a.Count; j++)\n {\n int last = -1;\n int sum = 0;\n for (int k = 0; k < a.Count; k++)\n {\n if (k == i || k == j)\n continue;\n\n if (last == -1)\n last = a[k];\n else\n {\n sum += a[k] - last;\n last = -1;\n }\n \n }\n if(sum Fun(int x)\n {\n var ret = new List();\n if (x == 0)\n {\n ret.Add(0);\n return ret;\n }\n while (x > 0)\n {\n ret.Add(x % 7);\n x /= 7;\n }\n ret.Reverse();\n return ret;\n }\n\n public void Solve()\n {\n int n = ReadInt();\n int m = ReadInt();\n\n var dp = new int[1 << 7, 2];\n dp[0, 0] = 1;\n foreach (int x in Fun(n - 1))\n {\n var ndp = new int[1 << 7, 2];\n for (int i = 0; i < 1 << 7; i++)\n for (int j = 0; j < 2; j++)\n for (int k = 0; k < 7; k++)\n if ((i >> k & 1) == 0)\n {\n if (j == 0 && k > x)\n continue;\n int nj = j;\n if (k < x)\n nj = 1;\n ndp[i | 1 << k, nj] += dp[i, j];\n }\n dp = ndp;\n }\n\n for (int i = 0; i < 1 << 7; i++)\n {\n dp[i, 0] += dp[i, 1];\n dp[i, 1] = 0;\n }\n\n foreach (int x in Fun(m - 1))\n {\n var ndp = new int[1 << 7, 2];\n for (int i = 0; i < 1 << 7; i++)\n for (int j = 0; j < 2; j++)\n for (int k = 0; k < 7; k++)\n if ((i >> k & 1) == 0)\n {\n if (j == 0 && k > x)\n continue;\n int nj = j;\n if (k < x)\n nj = 1;\n ndp[i | 1 << k, nj] += dp[i, j];\n }\n dp = ndp;\n }\n\n int ans = 0;\n for (int i = 0; i < 1 << 7; i++)\n for (int j = 0; j < 2; j++)\n ans += dp[i, j];\n\n Write(ans);\n }\n\n #region Main\n\n protected static TextReader reader;\n protected static TextWriter writer;\n static void Main()\n {\n#if DEBUG\n reader = new StreamReader(\"..\\\\..\\\\input.txt\");\n //reader = new StreamReader(Console.OpenStandardInput());\n writer = Console.Out;\n //writer = new StreamWriter(\"..\\\\..\\\\output.txt\");\n#else\n reader = new StreamReader(Console.OpenStandardInput());\n writer = new StreamWriter(Console.OpenStandardOutput(),Encoding.ASCII);\n //reader = new StreamReader(\"input.txt\");\n //writer = new StreamWriter(\"output.txt\");\n#endif\n try\n {\n new Solver().Solve();\n //var thread = new Thread(new Solver().Solve, 1024 * 1024 * 128);\n //thread.Start();\n //thread.Join();\n }\n catch (Exception ex)\n {\n#if DEBUG\n Console.WriteLine(ex);\n#else\n throw;\n#endif\n }\n reader.Close();\n writer.Close();\n }\n\n #endregion\n\n #region Read / Write\n private static Queue currentLineTokens = new Queue();\n private static string[] ReadAndSplitLine() { return reader.ReadLine().Split(new[] { ' ', '\\t', }, StringSplitOptions.RemoveEmptyEntries); }\n public static string ReadToken() { while (currentLineTokens.Count == 0)currentLineTokens = new Queue(ReadAndSplitLine()); return currentLineTokens.Dequeue(); }\n public static int ReadInt() { return int.Parse(ReadToken()); }\n public static long ReadLong() { return long.Parse(ReadToken()); }\n public static double ReadDouble() { return double.Parse(ReadToken(), CultureInfo.InvariantCulture); }\n public static int[] ReadIntArray() { return ReadAndSplitLine().Select(int.Parse).ToArray(); }\n public static long[] ReadLongArray() { return ReadAndSplitLine().Select(long.Parse).ToArray(); }\n public static double[] ReadDoubleArray() { return ReadAndSplitLine().Select(s => double.Parse(s, CultureInfo.InvariantCulture)).ToArray(); }\n public static int[][] ReadIntMatrix(int numberOfRows) { int[][] matrix = new int[numberOfRows][]; for (int i = 0; i < numberOfRows; i++)matrix[i] = ReadIntArray(); return matrix; }\n public static int[][] ReadAndTransposeIntMatrix(int numberOfRows)\n {\n int[][] matrix = ReadIntMatrix(numberOfRows); int[][] ret = new int[matrix[0].Length][];\n for (int i = 0; i < ret.Length; i++) { ret[i] = new int[numberOfRows]; for (int j = 0; j < numberOfRows; j++)ret[i][j] = matrix[j][i]; } return ret;\n }\n public static string[] ReadLines(int quantity) { string[] lines = new string[quantity]; for (int i = 0; i < quantity; i++)lines[i] = reader.ReadLine().Trim(); return lines; }\n public static void WriteArray(IEnumerable array) { writer.WriteLine(string.Join(\" \", array)); }\n public static void Write(params object[] array) { WriteArray(array); }\n public static void WriteLines(IEnumerable array) { foreach (var a in array)writer.WriteLine(a); }\n private class SDictionary : Dictionary\n {\n public new TValue this[TKey key]\n {\n get { return ContainsKey(key) ? base[key] : default(TValue); }\n set { base[key] = value; }\n }\n }\n private static T[] Init(int size) where T : new() { var ret = new T[size]; for (int i = 0; i < size; i++)ret[i] = new T(); return ret; }\n #endregion\n}", "lang_cluster": "C#", "tags": ["brute force", "math", "dp", "combinatorics"], "code_uid": "36137aa894467948689c2fbda7cf7c20", "src_uid": "0930c75f57dd88a858ba7bb0f11f1b1c", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Globalization;\nusing System.IO;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Diagnostics;\nusing System.Threading;\n\nnamespace Codeforces\n{\n class Program : ProgramBase\n {\n private const long commonMod = 1000000007;\n \n static void Main(string[] args)\n {\n var p = new Program();\n var x = p.Get();\n p.Out(x);\n }\n\n object Get()\n {\n checked\n {\n //FileName = \"input\";\n var n = ReadLongToken();\n var m = ReadLongToken();\n var nlog = logbase7(n);\n var mlog = logbase7(m);\n if (nlog + mlog > 7)\n return 0;\n var log = nlog + mlog;\n\n var result = 0;\n\n\n\n var a = new int[7] { 0, 1, 2, 3, 4, 5, 6 };\n int[] prev = new int[7];\n do\n {\n if (prev != null)\n {\n var fl = true;\n for (int i = 0; i < log; i++)\n {\n if (a[i] != prev[i])\n {\n fl = false;\n break;\n }\n }\n if (fl)\n {\n continue;\n }\n }\n var v = 0;\n var pow = 1;\n for (int i = 0; i < nlog; i++)\n {\n v += a[i] * pow;\n pow *= 7;\n }\n if (v >= n)\n {\n Array.Copy(a, prev, 7);\n continue;\n }\n\n pow = 1;\n v = 0;\n for (int i = 0; i < mlog; i++)\n {\n v += a[nlog + i] * pow;\n pow *= 7;\n }\n if (v >= m)\n {\n Array.Copy(a, prev, 7);\n continue;\n }\n result++;\n Array.Copy(a, prev, 7);\n } while (NextPermutation(a));\n return result;\n }\n\n \n }\n private static bool NextPermutation(int[] numList)\n {\n /*\n Knuths\n 1. Find the largest index j such that a[j] < a[j + 1]. If no such index exists, the permutation is the last permutation.\n 2. Find the largest index l such that a[j] < a[l]. Since j + 1 is such an index, l is well defined and satisfies j < l.\n 3. Swap a[j] with a[l].\n 4. Reverse the sequence from a[j + 1] up to and including the final element a[n].\n\n */\n var largestIndex = -1;\n for (var i = numList.Length - 2; i >= 0; i--)\n {\n if (numList[i] < numList[i + 1])\n {\n largestIndex = i;\n break;\n }\n }\n\n if (largestIndex < 0) return false;\n\n var largestIndex2 = -1;\n for (var i = numList.Length - 1; i >= 0; i--)\n {\n if (numList[largestIndex] < numList[i])\n {\n largestIndex2 = i;\n break;\n }\n }\n\n var tmp = numList[largestIndex];\n numList[largestIndex] = numList[largestIndex2];\n numList[largestIndex2] = tmp;\n\n for (int i = largestIndex + 1, j = numList.Length - 1; i < j; i++, j--)\n {\n tmp = numList[i];\n numList[i] = numList[j];\n numList[j] = tmp;\n }\n\n return true;\n }\n\n public int logbase7(long v)\n {\n if (v <= 1)\n return 1;\n var res = 0;\n v = v - 1;\n while(v > 0)\n {\n v /= 7;\n res++;\n }\n return res;\n }\n\n public static class Struct\n {\n public static Pair Create(T1 item1, T2 item2)\n {\n return new Pair { Item1 = item1, Item2 = item2 };\n }\n }\n\n public struct Pair\n {\n public T1 Item1 { get; set; }\n public T2 Item2 { get; set; }\n }\n\n class Automata\n {\n bool[] terminals;\n public int sigma;\n public int len;\n public int[,] jumps;\n\n public void Create()\n {\n var a = ReadInts();\n len = a[0];\n sigma = a[2];\n var ts = ReadInts();\n terminals = new bool[len];\n for (int i = 0; i < ts.Length; i++)\n terminals[ts[i]] = true;\n jumps = new int[len, sigma];\n for (int i = 0; i < len * sigma; i++)\n {\n var b = Console.ReadLine().Split(' ');\n jumps[Convert.ToInt32(b[0]), b[1][0] - 'a'] = Convert.ToInt32(b[2]);\n }\n }\n protected int[] ReadInts()\n {\n return Console.ReadLine().Split(' ').Select(x => Convert.ToInt32(x)).ToArray();\n }\n\n public bool IsTerminal(int s)\n {\n return terminals[s];\n }\n }\n }\n\n abstract class ProgramBase\n {\n bool? prod = null;\n StreamReader f;\n Queue tokens;\n protected string FileName { private get; set; }\n\n protected string Read()\n {\n if (f == null)\n f = string.IsNullOrEmpty(FileName)\n ? new StreamReader(Console.OpenStandardInput())\n : new StreamReader((GetProd() ? \"\" : \"c:\\\\dev\\\\\") + FileName);\n return f.ReadLine();\n }\n\n protected int ReadInt()\n {\n return int.Parse(Read());\n }\n\n protected int ReadIntToken()\n {\n if (tokens == null || tokens.Count == 0)\n tokens = new Queue(Read().Split(' '));\n return int.Parse(tokens.Dequeue());\n }\n\n protected int[] ReadInts()\n {\n var tokens = Read().Split(' ');\n var result = new int[tokens.Length];\n for (int i = 0; i < tokens.Length; i++)\n result[i] = int.Parse(tokens[i]);\n return result;\n }\n\n\n protected long ReadLongToken()\n {\n if (tokens == null || tokens.Count == 0)\n tokens = new Queue(Read().Split(' '));\n return long.Parse(tokens.Dequeue());\n }\n\n protected long ReadLong()\n {\n return Convert.ToInt64(Read());\n }\n\n protected long[] ReadLongs()\n {\n var tokens = Read().Split(' ');\n var result = new long[tokens.Length];\n for (int i = 0; i < tokens.Length; i++)\n result[i] = long.Parse(tokens[i]);\n return result;\n }\n\n public void Out(object r)\n {\n if (string.IsNullOrEmpty(FileName))\n Console.WriteLine(r);\n else if (GetProd())\n File.WriteAllText(FileName, r.ToString());\n else\n Console.WriteLine(r);\n }\n\n private bool GetProd()\n {\n\n if (!prod.HasValue)\n try\n {\n prod = Environment.MachineName != \"RENADEEN-W7\";\n }\n catch (Exception)\n {\n prod = true;\n }\n return prod.Value;\n }\n }\n\n public static class Huj\n {\n public static T MinBy(this IEnumerable source, Func func) where T : class\n {\n T result = null;\n var min = double.MaxValue;\n foreach (var item in source)\n {\n var current = func(item);\n if (min > current)\n {\n min = current;\n result = item;\n }\n }\n return result;\n }\n\n public static T MaxBy(this IEnumerable source, Func func, T defaultValue = default(T))\n {\n T result = defaultValue;\n var max = double.MinValue;\n foreach (var item in source)\n {\n var current = func(item);\n if (max < current)\n {\n max = current;\n result = item;\n }\n }\n return result;\n }\n\n public static string JoinStrings(this IEnumerable source, string delimeter)\n {\n return string.Join(delimeter, source.ToArray());\n }\n\n public static string JoinStrings(this IEnumerable source, string delimeter)\n {\n return source.Select(x => x.ToString()).JoinStrings(delimeter);\n }\n }\n}", "lang_cluster": "C#", "tags": ["brute force", "math", "combinatorics"], "code_uid": "1fbc7a55d408499bbfc99faec4b1b97c", "src_uid": "0930c75f57dd88a858ba7bb0f11f1b1c", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Linq;\n\nnamespace CodeForce\n{\n internal class Quserty\n {\n private static void Main(string[] args)\n {\n var input = Console.ReadLine();\n var inps = input.Split(' ');\n var length = int.Parse(inps.First());\n var diameter = int.Parse(inps[1]);\n\n input = Console.ReadLine();\n var array = input.Split(' ').Select(int.Parse).OrderBy(it => it).ToArray();\n var max = array[array.Length - 1];\n\n var isInSet = new int[max + 1];\n for (var i = 0; i < array.Length; i++)\n {\n var el = array[i];\n isInSet[el] += 1;\n }\n\n for (var i = 1; i < isInSet.Length; i++)\n {\n isInSet[i] = isInSet[i - 1] + isInSet[i];\n }\n\n\n var result = int.MaxValue;\n\n for (var i = 0;; i++)\n {\n var leftElement = array[i];\n var rightElement = leftElement + diameter;\n if (rightElement > max)\n {\n rightElement = max;\n }\n\n var diff = isInSet[rightElement] - isInSet[leftElement - 1];\n var newResult = array.Length - diff;\n result = Math.Min(result, newResult);\n\n if (rightElement == max)\n {\n break;\n }\n }\n\n Console.WriteLine(result);\n }\n }\n}", "lang_cluster": "C#", "tags": ["brute force", "sortings", "greedy"], "code_uid": "f3bc4c47be513266edbffabe7cfb42aa", "src_uid": "6bcb324c072f796f4d50bafea5f624b2", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Linq;\n\nnamespace CSharp\n{\n class _940A\n {\n public static void Main()\n {\n var tokens = Console.ReadLine().Split();\n\n int n = int.Parse(tokens[0]);\n int d = int.Parse(tokens[1]);\n\n var x = Console.ReadLine().Split().Select(token => int.Parse(token)).ToArray();\n Array.Sort(x);\n\n Console.WriteLine(n - Enumerable.Range(0, n).Max(r => Enumerable.Range(0, r + 1).Where(l => x[r] - x[l] <= d).Max(l => r + 1 - l)));\n }\n }\n}", "lang_cluster": "C#", "tags": ["brute force", "sortings", "greedy"], "code_uid": "b6203516aa9c1bebc02990a5ff75ae18", "src_uid": "6bcb324c072f796f4d50bafea5f624b2", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Globalization;\nusing System.IO;\nusing System.Linq;\nusing System.Text;\n\npublic class Solver\n{\n public object Solve()\n {\n int n = ReadInt();\n int m = ReadInt();\n\n int[] id = new int[m];\n int?[] status = new int?[n];\n\n int cand = -1;\n for (int i = 0; i < m; i++)\n {\n bool action = ReadToken() == \"+\";\n id[i] = ReadInt() - 1;\n if (status[id[i]] == null)\n {\n status[id[i]] = action ? 1 : 2;\n if (!action)\n cand = id[i];\n }\n }\n if (cand == -1)\n cand = id[0];\n\n var set = new SortedSet(Enumerable.Range(1, n).Where(i => status[i - 1] == null));\n bool[] on = Enumerable.Range(0, n).Select(i => status[i] == 2).ToArray();\n int onCount = status.Count(s => s == 2);\n int step;\n for (step = 0; step < m; step++)\n {\n if (id[step] == cand)\n {\n if (on[cand] && onCount > 1)\n break;\n }\n else if (!on[cand])\n break;\n on[id[step]] = !on[id[step]];\n if (on[id[step]])\n onCount++;\n else\n onCount--;\n }\n if (step == m)\n set.Add(cand + 1);\n\n writer.WriteLine(set.Count);\n WriteArray(set);\n\n return null;\n }\n\n #region Main\n\n protected static TextReader reader;\n protected static TextWriter writer;\n\n static void Main()\n {\n#if DEBUG\n reader = new StreamReader(\"..\\\\..\\\\input.txt\");\n writer = Console.Out;\n //writer = new StreamWriter(\"..\\\\..\\\\output.txt\");\n#else\n reader = Console.In;\n writer = Console.Out;\n#endif\n try\n {\n object result = new Solver().Solve();\n if (result != null)\n {\n writer.WriteLine(result);\n }\n }\n catch (Exception ex)\n {\n#if DEBUG\n Console.WriteLine(ex);\n#else\n throw;\n#endif\n }\n reader.Close();\n writer.Close();\n }\n\n #endregion\n\n #region Read/Write\n\n private static Queue currentLineTokens = new Queue();\n\n private static string[] ReadAndSplitLine()\n {\n return reader.ReadLine().Split(new[] {' ', '\\t'}, StringSplitOptions.RemoveEmptyEntries);\n }\n\n public static string ReadToken()\n {\n if (currentLineTokens.Count == 0)\n currentLineTokens = new Queue(ReadAndSplitLine());\n return currentLineTokens.Dequeue();\n }\n\n public static int ReadInt()\n {\n return int.Parse(ReadToken());\n }\n\n public static long ReadLong()\n {\n return long.Parse(ReadToken());\n }\n\n public static double ReadDouble()\n {\n return double.Parse(ReadToken(), CultureInfo.InvariantCulture);\n }\n\n public static int[] ReadIntArray()\n {\n return ReadAndSplitLine().Select(int.Parse).ToArray();\n }\n\n public static long[] ReadLongArray()\n {\n return ReadAndSplitLine().Select(long.Parse).ToArray();\n }\n\n public static double[] ReadDoubleArray()\n {\n return ReadAndSplitLine().Select(s => double.Parse(s, CultureInfo.InvariantCulture)).ToArray();\n }\n\n public static int[][] ReadIntMatrix(int numberOfRows)\n {\n int[][] matrix = new int[numberOfRows][];\n for (int i = 0; i < numberOfRows; i++)\n matrix[i] = ReadIntArray();\n return matrix;\n }\n\n public static string[] ReadLines(int quantity)\n {\n string[] lines = new string[quantity];\n for (int i = 0; i < quantity; i++)\n lines[i] = reader.ReadLine().Trim();\n return lines;\n }\n\n public static void WriteArray(IEnumerable array)\n {\n writer.WriteLine(string.Join(\" \", array));\n }\n\n #endregion\n}", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "cae2f0aaef59d828a3c345a03a3f1f22", "src_uid": "a3a337c7b919e7dfd7ff45ebf59681b5", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace ProblemSets\n{\n using System;\n using System.Collections.Generic;\n using System.Collections;\n using System.Linq;\n using System.Text;\n\n namespace LongPath\n {\n public class Problem420b\n {\n public static void Main(string[] args)\n {\n var input = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();\n var numberOfPeople = input[0];\n var numberOfMessage = input[1];\n\n bool[] seen = new bool[100000 + 1];\n int leaderId = -1;\n bool leaderOnline = false;\n var peopleOnline = 0;\n\n for (int i = 0; i < numberOfMessage; i++)\n {\n var status = Console.ReadLine().Split(' ');\n var symbol = status[0][0];\n var id = int.Parse(status[1]);\n\n if (symbol == '+')\n {\n \n if(i== 0)\n {\n leaderId = id;\n leaderOnline = true;\n }\n \n else // there is a leader\n {\n if (leaderOnline)\n {\n //do nothing\n }\n else\n {\n if (leaderId == id)\n {\n leaderOnline = true;\n }\n else\n {\n leaderId = -1;\n leaderOnline = false;\n }\n }\n }\n peopleOnline++; \n }\n\n if (symbol == '-')\n {\n if (!seen[id])\n {\n if (peopleOnline == 0)\n {\n leaderId = id;\n leaderOnline = false;\n }\n else\n {\n leaderId = -1;\n leaderOnline = false;\n }\n }\n\n else\n {\n peopleOnline = Math.Max(--peopleOnline, 0);\n if (leaderId == -1)\n {\n //if there is no leader, do nothing\n }\n else\n {\n if (leaderId == id)\n {\n if (peopleOnline > 0)\n {\n leaderId = -1;\n leaderOnline = false;\n }\n else\n {\n leaderOnline = false;\n }\n }\n else\n {\n if (!leaderOnline)\n {\n leaderId = -1;\n leaderOnline = false;\n }\n }\n }\n }\n \n }\n seen[id] = true;\n }\n\n var leaders = new ArrayList();\n for (int i = 1; i <= numberOfPeople; i++)\n {\n if (!seen[i]) leaders.Add(i);\n else if (leaderId == i) leaders.Add(i);\n }\n\n var numberOfLeader = leaders.Count;\n Console.WriteLine(numberOfLeader);\n\n foreach (var leader in leaders)\n {\n Console.Write(leader);\n Console.Write(\" \");\n }\n\n }\n }\n }\n}", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "fe0ea669c5750c020b6e8fa101ecb99a", "src_uid": "a3a337c7b919e7dfd7ff45ebf59681b5", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\n\nnamespace example\n{\n class Program\n {\n public static void Main(string[] args)\n {\n var line = Console.ReadLine().Split();\n int[] array = line.Select(p => int.Parse(p)).ToArray();\n Array.Sort(array);\n int a = array[0];\n int b = array[1];\n int c = array[2];\n if(Can(a,b,c))\n Console.WriteLine(\"YES\");\n else Console.WriteLine(\"NO\");\n }\n\n public static bool Can(int a, int b, int c)\n {\n if (a == 1)\n return true;\n if (a == 2 && (b == 2 ||(b == 4 && c == 4)))\n return true;\n if (a == 3 && b == 3 && c == 3)\n return true;\n\n return false;\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "constructive algorithms"], "code_uid": "7c7d9b6b3bf1558c45819e95d2192492", "src_uid": "df48af9f5e68cb6efc1214f7138accf9", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.IO;\nusing System.Runtime.CompilerServices;\nusing System.Text;\nusing System.Diagnostics;\nusing System.Numerics;\nusing static System.Console;\nusing static System.Convert;\nusing static System.Math;\nusing static Template;\nusing Pi = Pair;\n\nclass Solver\n{\n public void Solve(Scanner sc)\n {\n var K = sc.ArrInt.Select((v, idx) => (v: v, idx: idx)).ToArray();\n Array.Sort(K, (a, b) => a.v - b.v);\n if (K[0].v == 1) Fail(\"YES\");\n if (K.Select(k => k.v).Count(a => a <= 2) >= 2) Fail(\"YES\");\n if (K.Select(k => k.v).All(v => v == 3)) Fail(\"YES\");\n if (K[0].v == 2 && K[1].v == 4 && K[2].v == 4) Fail(\"YES\");\n Console.WriteLine(\"NO\");\n }\n}\n\n#region Template\npublic static class Template\n{\n static void Main(string[] args)\n {\n Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });\n new Solver().Solve(new Scanner());\n Console.Out.Flush();\n }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static bool chmin(ref T a, T b) where T : IComparable { if (a.CompareTo(b) > 0) { a = b; return true; } return false; }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static bool chmax(ref T a, T b) where T : IComparable { if (a.CompareTo(b) < 0) { a = b; return true; } return false; }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static void swap(ref T a, ref T b) { var t = b; b = a; a = t; }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static void swap(this IList A, int i, int j) { var t = A[i]; A[i] = A[j]; A[j] = t; }\n public static T[] Create(int n, Func f) { var rt = new T[n]; for (var i = 0; i < rt.Length; ++i) rt[i] = f(); return rt; }\n public static T[] Create(int n, Func f) { var rt = new T[n]; for (var i = 0; i < rt.Length; ++i) rt[i] = f(i); return rt; }\n public static IEnumerable Shuffle(this IEnumerable A) => A.OrderBy(v => Guid.NewGuid());\n public static int CompareTo(this T[] A, T[] B, Comparison cmp = null) { cmp = cmp ?? Comparer.Default.Compare; for (var i = 0; i < Min(A.Length, B.Length); i++) { int c = cmp(A[i], B[i]); if (c > 0) return 1; else if (c < 0) return -1; } if (A.Length == B.Length) return 0; if (A.Length > B.Length) return 1; else return -1; }\n public static int MaxElement(this IList A, Comparison cmp = null) { cmp = cmp ?? Comparer.Default.Compare; T max = A[0]; int rt = 0; for (int i = 1; i < A.Count; i++) if (cmp(max, A[i]) < 0) { max = A[i]; rt = i; } return rt; }\n public static T PopBack(this List A) { var v = A[A.Count - 1]; A.RemoveAt(A.Count - 1); return v; }\n public static void Fail(T s) { Console.WriteLine(s); Console.Out.Close(); Environment.Exit(0); }\n}\npublic class Scanner\n{\n public string Str => Console.ReadLine().Trim();\n public int Int => int.Parse(Str);\n public long Long => long.Parse(Str);\n public double Double => double.Parse(Str);\n public int[] ArrInt => Str.Split(' ').Select(int.Parse).ToArray();\n public long[] ArrLong => Str.Split(' ').Select(long.Parse).ToArray();\n public char[][] Grid(int n) => Create(n, () => Str.ToCharArray());\n public int[] ArrInt1D(int n) => Create(n, () => Int);\n public long[] ArrLong1D(int n) => Create(n, () => Long);\n public int[][] ArrInt2D(int n) => Create(n, () => ArrInt);\n public long[][] ArrLong2D(int n) => Create(n, () => ArrLong);\n private Queue q = new Queue();\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public T Next() { if (q.Count == 0) foreach (var item in Str.Split(' ')) q.Enqueue(item); return (T)Convert.ChangeType(q.Dequeue(), typeof(T)); }\n public void Make(out T1 v1) => v1 = Next();\n public void Make(out T1 v1, out T2 v2) { v1 = Next(); v2 = Next(); }\n public void Make(out T1 v1, out T2 v2, out T3 v3) { Make(out v1, out v2); v3 = Next(); }\n public void Make(out T1 v1, out T2 v2, out T3 v3, out T4 v4) { Make(out v1, out v2, out v3); v4 = Next(); }\n public void Make(out T1 v1, out T2 v2, out T3 v3, out T4 v4, out T5 v5) { Make(out v1, out v2, out v3, out v4); v5 = Next(); }\n public void Make(out T1 v1, out T2 v2, out T3 v3, out T4 v4, out T5 v5, out T6 v6) { Make(out v1, out v2, out v3, out v4, out v5); v6 = Next(); }\n public void Make(out T1 v1, out T2 v2, out T3 v3, out T4 v4, out T5 v5, out T6 v6, out T7 v7) { Make(out v1, out v2, out v3, out v4, out v5, out v6); v7 = Next(); }\n //public (T1, T2) Make() { Make(out T1 v1, out T2 v2); return (v1, v2); }\n //public (T1, T2, T3) Make() { Make(out T1 v1, out T2 v2, out T3 v3); return (v1, v2, v3); }\n //public (T1, T2, T3, T4) Make() { Make(out T1 v1, out T2 v2, out T3 v3, out T4 v4); return (v1, v2, v3, v4); }\n}\npublic class Pair : IComparable>\n{\n public T1 v1;\n public T2 v2;\n public Pair() { }\n public Pair(T1 v1, T2 v2)\n { this.v1 = v1; this.v2 = v2; }\n\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public int CompareTo(Pair p)\n {\n var c = Comparer.Default.Compare(v1, p.v1);\n if (c == 0)\n c = Comparer.Default.Compare(v2, p.v2);\n return c;\n }\n public override string ToString() => $\"{v1.ToString()} {v2.ToString()}\";\n public void Deconstruct(out T1 a, out T2 b) { a = v1; b = v2; }\n}\n\npublic class Pair : Pair, IComparable>\n{\n public T3 v3;\n public Pair() : base() { }\n public Pair(T1 v1, T2 v2, T3 v3) : base(v1, v2)\n { this.v3 = v3; }\n\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public int CompareTo(Pair p)\n {\n var c = base.CompareTo(p);\n if (c == 0)\n c = Comparer.Default.Compare(v3, p.v3);\n return c;\n }\n public override string ToString() => $\"{base.ToString()} {v3.ToString()}\";\n public void Deconstruct(out T1 a, out T2 b, out T3 c) { Deconstruct(out a, out b); c = v3; }\n}\n#endregion\n", "lang_cluster": "C#", "tags": ["brute force", "constructive algorithms"], "code_uid": "586dc3b5c54df8c6853f2878bf2736e2", "src_uid": "df48af9f5e68cb6efc1214f7138accf9", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Linq;\nusing System.Collections.Generic;\nusing Debug = System.Diagnostics.Debug;\nusing StringBuilder = System.Text.StringBuilder;\nusing System.Numerics;\nusing Point = System.Numerics.Complex;\nusing Number = System.Int64;\nnamespace Program\n{\n public class Solver\n {\n public void Solve()\n {\n var q = sc.Integer();\n var par = new int[500002];\n par[0] = -1;\n var dp = Enumerate(500002, x => new double[45]);\n for (int i = 1; i < 45; i++)\n dp[0][i] = 1.0;\n\n var ptr = 1;\n Action recalc = null;\n recalc = v =>\n {\n for (int h = 1; h < 40; h++)\n dp[v][h] = 1.0;\n var ps = new List();\n for (int h = 0; h <= 40; h++)\n {\n if (v == -1) break;\n ps.Add(v);\n v = par[v];\n }\n for (int i = ps.Count - 2; i > 0; i--)\n {\n var u = ps[i]; var h = i;\n var p = ps[i + 1];\n dp[p][h + 1] /= (dp[u][h] + 1) / 2;\n }\n for (int i = 0; i + 1 < ps.Count; i++)\n {\n var u = ps[i]; var h = i;\n var p = ps[i + 1];\n dp[p][h + 1] *= (dp[u][h] + 1) / 2;\n }\n };\n for (int i = 0; i < q; i++)\n {\n if (sc.Integer() == 1)\n {\n var p = sc.Integer() - 1;\n par[ptr] = p;\n recalc(ptr);\n ptr++;\n\n }\n else\n {\n var v = sc.Integer() - 1;\n var ans = 0.0;\n for (int h = 1; h < 40; h++)\n ans += 1 - dp[v][h];\n Debug.WriteLine(dp[v].AsJoinedString());\n IO.Printer.Out.WriteLine(ans);\n\n }\n }\n }\n public IO.StreamScanner sc = new IO.StreamScanner(Console.OpenStandardInput());\n static T[] Enumerate(int n, Func f) { var a = new T[n]; for (int i = 0; i < n; ++i) a[i] = f(i); return a; }\n static public void Swap(ref T a, ref T b) { var tmp = a; a = b; b = tmp; }\n }\n}\n\n#region main\nstatic class Ex\n{\n static public string AsString(this IEnumerable ie) { return new string(System.Linq.Enumerable.ToArray(ie)); }\n static public string AsJoinedString(this IEnumerable ie, string st = \" \") { return string.Join(st, ie); }\n static public void Main()\n {\n var solver = new Program.Solver();\n solver.Solve();\n Program.IO.Printer.Out.Flush();\n }\n}\n#endregion\n#region Ex\nnamespace Program.IO\n{\n using System.IO;\n using System.Text;\n using System.Globalization;\n public class Printer: StreamWriter\n {\n static Printer() { Out = new Printer(Console.OpenStandardOutput()) { AutoFlush = false }; }\n public static Printer Out { get; set; }\n public override IFormatProvider FormatProvider { get { return CultureInfo.InvariantCulture; } }\n public Printer(System.IO.Stream stream) : base(stream, new UTF8Encoding(false, true)) { }\n public Printer(System.IO.Stream stream, Encoding encoding) : base(stream, encoding) { }\n public void Write(string format, T[] source) { base.Write(format, source.OfType().ToArray()); }\n public void WriteLine(string format, T[] source) { base.WriteLine(format, source.OfType().ToArray()); }\n }\n public class StreamScanner\n {\n public StreamScanner(Stream stream) { str = stream; }\n public readonly Stream str;\n private readonly byte[] buf = new byte[1024];\n private int len, ptr;\n public bool isEof = false;\n public bool IsEndOfStream { get { return isEof; } }\n private byte read()\n {\n if (isEof) return 0;\n if (ptr >= len) { ptr = 0; if ((len = str.Read(buf, 0, 1024)) <= 0) { isEof = true; return 0; } }\n return buf[ptr++];\n }\n public char Char() { byte b = 0; do b = read(); while ((b < 33 || 126 < b) && !isEof); return (char)b; }\n\n public string Scan()\n {\n var sb = new StringBuilder();\n for (var b = Char(); b >= 33 && b <= 126; b = (char)read())\n sb.Append(b);\n return sb.ToString();\n }\n public string ScanLine()\n {\n var sb = new StringBuilder();\n for (var b = Char(); b != '\\n'; b = (char)read())\n if (b == 0) break;\n else if (b != '\\r') sb.Append(b);\n return sb.ToString();\n }\n public long Long()\n {\n if (isEof) return long.MinValue;\n long ret = 0; byte b = 0; var ng = false;\n do b = read();\n while (b != 0 && b != '-' && (b < '0' || '9' < b));\n if (b == 0) return long.MinValue;\n if (b == '-') { ng = true; b = read(); }\n for (; true; b = read())\n {\n if (b < '0' || '9' < b)\n return ng ? -ret : ret;\n else ret = ret * 10 + b - '0';\n }\n }\n public int Integer() { return (isEof) ? int.MinValue : (int)Long(); }\n public double Double() { var s = Scan(); return s != \"\" ? double.Parse(s, CultureInfo.InvariantCulture) : double.NaN; }\n private T[] enumerate(int n, Func f)\n {\n var a = new T[n];\n for (int i = 0; i < n; ++i) a[i] = f();\n return a;\n }\n\n public char[] Char(int n) { return enumerate(n, Char); }\n public string[] Scan(int n) { return enumerate(n, Scan); }\n public double[] Double(int n) { return enumerate(n, Double); }\n public int[] Integer(int n) { return enumerate(n, Integer); }\n public long[] Long(int n) { return enumerate(n, Long); }\n }\n}\n#endregion\n\n", "lang_cluster": "C#", "tags": ["math", "dp", "probabilities", "trees"], "code_uid": "56af05bed63b1b3abaafb0eedfca3812", "src_uid": "55affe752cb214d1e4031a9e3972597b", "difficulty": 2700.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Diagnostics;\nusing System.IO;\nusing System.Linq;\n\nnamespace codeforces\n{\n class Program\n {\n\n static void Main(string[] args)\n {\n ulong n = Convert.ToUInt64(Console.ReadLine());\n ulong value = n % 2;\n if (value == 0)\n value = 2;\n Console.WriteLine(value);\n }\n }\n}", "lang_cluster": "C#", "tags": ["math", "games"], "code_uid": "3e288a58885f369cf1b929e8c54db4c0", "src_uid": "816ec4cd9736f3113333ef05405b8e81", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\n\nnamespace ForCodeForces\n{\n class Program\n {\n static void Main(string[] args)\n {\n long n = long.Parse(Console.ReadLine());\n\n if (n % 2 == 0)\n Console.WriteLine(2);\n else\n Console.WriteLine(1);\n }\n }\n}", "lang_cluster": "C#", "tags": ["math", "games"], "code_uid": "86d041571a4a82ff5a471f0c8b6590b8", "src_uid": "816ec4cd9736f3113333ef05405b8e81", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections;\nusing System.Collections.Generic;\nusing System.Diagnostics;\nusing System.IO;\nusing System.Linq;\nusing System.Numerics;\nusing System.Text;\nusing System.Text.RegularExpressions;\nusing System.Threading.Tasks;\nusing static System.Math;\npublic static class P\n{\n public static void Main()\n {\n string cf = \"codeforces\";\n var k = long.Parse(Console.ReadLine());\n long[] counts = Enumerable.Repeat(1L, cf.Length).ToArray();\n int ind = 0;\n while (true)\n {\n if (k <= counts.Aggregate(1L, (x, y) => x * y)) break;\n counts[ind]++;\n ind = (ind + 1) % counts.Length;\n }\n Console.WriteLine(string.Join(\"\", counts.SelectMany((count, i) => Enumerable.Repeat(cf[i], (int)count))));\n }\n}", "lang_cluster": "C#", "tags": ["brute force", "constructive algorithms", "math", "greedy", "strings"], "code_uid": "f53ca1effd9f29d4ae4d3dc19ec1feef", "src_uid": "8001a7570766cadcc538217e941b3031", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Linq;\n\nnamespace TaskB\n{\n class Program\n {\n static void Main(string[] args)\n {\n var p = long.Parse(Console.ReadLine());\n\n long ans = 1;\n var mas = new[] { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 };\n var i = 0;\n while (ans < p)\n {\n mas[i]++;\n\n ans = Calc(mas);\n \n i++;\n i %= 10;\n\n }\n\n var s = \"codeforces\";\n for (int j = 0; j < 10; j++)\n {\n for (int k = 0; k < mas[j]; k++)\n {\n Console.Write(s[j]);\n }\n }\n }\n\n private static long Calc(int[] mas)\n {\n return mas.Aggregate(1, (current, t) => current * t);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "constructive algorithms", "math", "greedy", "strings"], "code_uid": "62ec17e78c724f962c6b92263dd8d4c4", "src_uid": "8001a7570766cadcc538217e941b3031", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text.RegularExpressions;\n \n \nnamespace Codeforces\n{\n \n public class C\n {\n \n public static void Main(string[] args)\n {\n string[] token = Console.ReadLine().Split();\n \n int n = int.Parse(token[0]);\n int m = int.Parse(token[1]);\n long k = long.Parse(token[2]);\n int x = int.Parse(token[3]);\n int y = int.Parse(token[4]);\n \n int sTo = ((x-1)*m) + y;\n int sBo = ((n-x)*m) + y;\n \n if(k 2)\n {\n int A = (n * m) - m;\n long KK = k - m;\n long mod = KK % A;\n long div = (KK - mod) / A;\n long max = 0;\n // if( n>2){\n max = (mod > 0) ? div + 1 : div;\n long v = 1 + div;\n long min = (v%2!=0)?(v-1)/2:v/2;\n \n long sQ = div;\n \n if(x==1){\n sQ =(div%2!=0)?(div-1)/2:div/2;\n sQ++;\n }else if(x==n){\n sQ =(div%2!=0)?(div+1)/2:div/2;\n }\n \n // Console.WriteLine(v);\n if((v%2==0 && sBo-m<=mod && x!=n) || (v%2!=0 && sTo-m<=mod && x!=1)){\n sQ++;\n } \n \n Console.WriteLine((max) + \" \" + (min) + \" \" + sQ);\n // }\n }\n else\n {\n long mod = k%(m*n);\n long min = (k - mod) / (m*n);\n long max = (mod > 0) ? min + 1 : min;\n long sQ = (sTo<=mod)?min+1:min;\n \n Console.WriteLine(max + \" \" + min + \" \" + sQ);\n }\n }\n }\n \n \n}", "lang_cluster": "C#", "tags": ["math", "constructive algorithms", "binary search", "implementation"], "code_uid": "82ab937f70025f0b427ab7f4aa8b3a5f", "src_uid": "e61debcad37eaa9a6e21d7a2122b8b21", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\n\nnamespace _758C\n{\n class Program\n {\n static void Main(string[] args)\n {\n string[] input = Console.ReadLine().Split(' ');\n long n = long.Parse(input[0]), m = long.Parse(input[1]), x = long.Parse(input[3]), y = long.Parse(input[4]),\n k = long.Parse(input[2]);\n long T = 0, periods = 0;\n if (n > 2) T = m * (2 * n - 2);\n else T = m * n;\n if (T > 0)\n {\n periods = k / T;\n k = k % T;\n }\n long[,] matrix = new long[n, m];\n long min = long.MaxValue, max = 0;\n for (int i = 0; i < n; i++)\n for (int j = 0; j < m; j++)\n {\n matrix[i, j] = periods * ((i == 0 || i == n - 1) ? 1 : 2);\n if (k > 0)\n {\n matrix[i, j]++;\n k--;\n }\n }\n for (int i = (int)n - 2; i >= 0; i--)\n for (int j = 0; j < m; j++)\n {\n if (k > 0)\n {\n matrix[i, j]++;\n k--;\n }\n }\n for (int i = 0; i < n; i++)\n for (int j = 0; j < m; j++)\n {\n if (matrix[i, j] < min) min = matrix[i, j];\n if (matrix[i, j] > max) max = matrix[i, j];\n }\n Console.WriteLine(max + \" \" + min + \" \" + matrix[x - 1, y - 1]);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "constructive algorithms", "binary search", "implementation"], "code_uid": "a9f15e7a130254a69ccf04beca8b90a9", "src_uid": "e61debcad37eaa9a6e21d7a2122b8b21", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Globalization;\nusing System.IO;\nusing System.Linq;\nusing System.Text;\n\nclass Program\n{\n private static bool IsSimple(int x)\n {\n if ((x & 1) == 0) return x == 2;\n\n int end = (int)Math.Sqrt(x);\n for (int i = 3; i <= end; i += 2)\n if (x % i == 0)\n return false;\n\n return true;\n }\n\n private static int Solve(int n)\n {\n if (IsSimple(n)) return 1;\n if (n % 2 == 0) return 2;\n\n if (IsSimple(n - 2))\n return 2;\n\n return 3;\n }\n\n static void Main(string[] args)\n {\n Console.WriteLine(Solve(RI()));\n }\n\n private const int Mod = 1000000000 + 7;\n\n #region Data Read\n private static char ReadSign()\n {\n while (true)\n {\n int ans = consoleReader.Read();\n if (ans == '+' || ans == '-' || ans == '?')\n return (char)ans;\n }\n }\n\n private static long GCD(long a, long b)\n {\n if (a % b == 0) return b;\n return GCD(b, a % b);\n }\n\n private static List[] ReadGraph(int n, int m)\n {\n List[] g = new List[n];\n for (int i = 0; i < g.Length; i++) g[i] = new List();\n for (int i = 0; i < m; i++)\n {\n int a = RI() - 1;\n int b = RI() - 1;\n\n g[a].Add(b);\n g[b].Add(a);\n }\n\n return g;\n }\n\n private static int[,] ReadGraphAsMatrix(int n, int m)\n {\n int[,] matrix = new int[n + 1, n + 1];\n for (int i = 0; i < m; i++)\n {\n int a = RI();\n int b = RI();\n matrix[a, b] = matrix[b, a] = 1;\n }\n\n return matrix;\n }\n\n private static void Sort(ref int a, ref int b)\n {\n if (a > b) Swap(ref a, ref b);\n }\n\n private static void Swap(ref int a, ref int b)\n {\n int tmp = a;\n a = b;\n b = tmp;\n }\n\n private const int BufferSize = 1 << 16;\n private static StreamReader consoleReader;\n private static MemoryStream testData;\n\n private static int RI()\n {\n int ans = 0;\n int mul = 1;\n do\n {\n ans = consoleReader.Read();\n if (ans == -1)\n return 0;\n if (ans == '-') mul = -1;\n } while (ans < '0' || ans > '9');\n\n ans -= '0';\n while (true)\n {\n int chr = consoleReader.Read();\n if (chr < '0' || chr > '9')\n return ans * mul;\n ans = ans * 10 + chr - '0';\n }\n }\n\n private static ulong RUL()\n {\n ulong ans = 0;\n int chr;\n do\n {\n chr = consoleReader.Read();\n if (chr == -1)\n return 0;\n } while (chr < '0' || chr > '9');\n\n ans = (uint)(chr - '0');\n while (true)\n {\n chr = consoleReader.Read();\n if (chr < '0' || chr > '9')\n return ans;\n ans = ans * 10 + (uint)(chr - '0');\n }\n }\n\n private static long RL()\n {\n long ans = 0;\n int mul = 1;\n do\n {\n ans = consoleReader.Read();\n if (ans == -1)\n return 0;\n if (ans == '-') mul = -1;\n } while (ans < '0' || ans > '9');\n\n ans -= '0';\n while (true)\n {\n int chr = consoleReader.Read();\n if (chr < '0' || chr > '9')\n return ans * mul;\n ans = ans * 10 + chr - '0';\n }\n }\n\n private static int[] RIA(int n)\n {\n int[] ans = new int[n];\n for (int i = 0; i < n; i++)\n ans[i] = RI();\n return ans;\n }\n\n private static long[] RLA(int n)\n {\n long[] ans = new long[n];\n for (int i = 0; i < n; i++)\n ans[i] = RL();\n return ans;\n }\n\n private static char[] ReadWord()\n {\n int ans;\n\n do\n {\n ans = consoleReader.Read();\n } while (!((ans >= 'a' && ans <= 'z') || (ans >= 'A' && ans <= 'Z')));\n\n List s = new List();\n do\n {\n s.Add((char)ans);\n ans = consoleReader.Read();\n } while ((ans >= 'a' && ans <= 'z') || (ans >= 'A' && ans <= 'Z'));\n\n return s.ToArray();\n }\n\n private static char[] ReadString(int n)\n {\n int ans;\n\n do\n {\n ans = consoleReader.Read();\n } while (!((ans >= 'a' && ans <= 'z') || (ans >= 'A' && ans <= 'Z')));\n\n char[] s = new char[n];\n int pos = 0;\n do\n {\n s[pos++] = (char)ans;\n if (pos == n) break;\n ans = consoleReader.Read();\n } while ((ans >= 'a' && ans <= 'z') || (ans >= 'A' && ans <= 'Z'));\n\n return s;\n }\n\n private static char[] ReadStringLine()\n {\n int ans;\n\n do\n {\n ans = consoleReader.Read();\n } while (ans == 10 || ans == 13);\n\n List s = new List();\n\n do\n {\n s.Add((char)ans);\n ans = consoleReader.Read();\n } while (ans != 10 && ans != 13);\n\n return s.ToArray();\n }\n\n private static char ReadLetter()\n {\n while (true)\n {\n int ans = consoleReader.Read();\n if ((ans >= 'a' && ans <= 'z') || (ans >= 'A' && ans <= 'Z'))\n return (char)ans;\n }\n }\n private static char ReadNonLetter()\n {\n while (true)\n {\n int ans = consoleReader.Read();\n if (!((ans >= 'a' && ans <= 'z') || (ans >= 'A' && ans <= 'Z')))\n return (char)ans;\n }\n }\n\n private static char ReadAnyOf(IEnumerable allowed)\n {\n while (true)\n {\n char ans = (char)consoleReader.Read();\n if (allowed.Contains(ans))\n return ans;\n }\n }\n\n private static char ReadDigit()\n {\n while (true)\n {\n int ans = consoleReader.Read();\n if (ans >= '0' && ans <= '9')\n return (char)ans;\n }\n }\n\n private static int ReadDigitInt()\n {\n return ReadDigit() - (int)'0';\n }\n\n private static char ReadAnyChar()\n {\n return (char)consoleReader.Read();\n }\n\n private static string DoubleToString(double x)\n {\n return x.ToString(CultureInfo.InvariantCulture);\n }\n\n private static double DoubleFromString(string x)\n {\n return double.Parse(x, CultureInfo.InvariantCulture);\n }\n\n static Program()\n {\n //Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;\n consoleReader = new StreamReader(Console.OpenStandardInput(BufferSize), Encoding.ASCII, false, BufferSize);\n }\n\n private static void PushTestData(StringBuilder sb)\n {\n PushTestData(sb.ToString());\n }\n private static void PushTestData(string data)\n {\n#if TOLYAN_TEST\n if (testData == null)\n {\n testData = new MemoryStream();\n consoleReader = new StreamReader(testData);\n }\n\n var pos = testData.Position;\n var bytes = Encoding.UTF8.GetBytes(data);\n testData.Write(bytes, 0, bytes.Length);\n testData.Flush();\n testData.Position = pos;\n#endif\n }\n #endregion\n}", "lang_cluster": "C#", "tags": ["math", "number theory"], "code_uid": "a18f240af0e05fde5815009c4555ee62", "src_uid": "684ce84149d6a5f4776ecd1ea6cb455b", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace _735D\n{\n class Program\n {\n static bool IsPrime(long x)\n {\n if (x == 2)\n {\n return true;\n }\n else\n {\n var boundary = (int)Math.Floor(Math.Sqrt(x));\n for (int i = 2; i <= boundary; ++i)\n {\n if (x % i == 0) return false;\n }\n return true;\n }\n }\n\n static void Main(string[] args)\n {\n long n = long.Parse(Console.ReadLine());\n if (IsPrime(n))\n {\n Console.WriteLine(\"1\");\n }\n else if (n % 2 == 0 || IsPrime(n - 2))\n {\n Console.WriteLine(\"2\");\n }\n else\n {\n Console.WriteLine(\"3\");\n }\n //Console.ReadLine();\n }\n }\n}", "lang_cluster": "C#", "tags": ["math", "number theory"], "code_uid": "3d714057d781609485f42a825acd7b27", "src_uid": "684ce84149d6a5f4776ecd1ea6cb455b", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "/*\ncsc -debug C.cs && mono --debug C.exe <<< \"3 3 0\"\n*/\n\nusing System;\nusing System.Collections.Generic;\nusing System.Linq;\n\npublic class HelloWorld {\n static public void Main () {\n SolveCodeForces();\n }\n\n public static void SolveCodeForces() {\n var sc = new Scanner();\n var n = sc.NextInt();\n var m = sc.NextUlong();\n var k = sc.NextInt();\n\n const ulong MOD = 998244353ul;\n\n var S = new ulong[n, k+1];\n S[0, 0] = m;\n\n for (var i = 1; i < n; i++) {\n\n S[i, 0] = m;\n\n for (var j = 1; j <= k; j++) {\n S[i, j] = ( S[i-1, j-1] * (m-1) + S[i-1, j] ) % MOD;\n }\n\n }\n\n System.Console.WriteLine(S[n-1, k]);\n }\n}\n\npublic static class Helpers {\n public static T[] CreateArray(int length, Func itemCreate) {\n var result = new T[length];\n for (var i = 0; i < result.Length; i++)\n result[i] = itemCreate(i);\n return result;\n }\n\n public static T ElementWithMax(this IEnumerable seq, Func func) {\n var bi = default(T);\n var bv = long.MinValue;\n foreach (var item in seq) {\n var v = func(item);\n if (v > bv) {\n bi = item;\n bv = v;\n }\n }\n return bi;\n }\n\n public static IEnumerable IndicesWhere(this IEnumerable seq, Func cond) {\n var i = 0;\n foreach (var item in seq) {\n if (cond(item)) yield return i;\n i++;\n }\n }\n}\n\npublic class Scanner\n{\n private string[] line = new string[0];\n private int index = 0;\n\n public string Next() {\n if (line.Length <= index) {\n line = Console.ReadLine().Split(' ');\n index = 0;\n }\n var res = line[index];\n index++;\n return res;\n }\n\n public int NextInt() {\n return int.Parse(Next());\n }\n\n public long NextLong() {\n return long.Parse(Next());\n }\n\n public ulong NextUlong() {\n return ulong.Parse(Next());\n }\n\n public string[] Array() {\n line = Console.ReadLine().Split(' ');\n index = line.Length;\n return line;\n }\n\n public int[] IntArray() {\n var array = Array();\n var result = new int[array.Length];\n for (int i = 0; i < array.Length; i++)\n result[i] = int.Parse(array[i]);\n return result;\n }\n\n public long[] LongArray() {\n var array = Array();\n var result = new long[array.Length];\n for (int i = 0; i < array.Length; i++)\n result[i] = long.Parse(array[i]);\n return result;\n }\n\n public ulong[] UlongArray() {\n var array = Array();\n var result = new ulong[array.Length];\n for (int i = 0; i < array.Length; i++)\n result[i] = ulong.Parse(array[i]);\n return result;\n }\n}", "lang_cluster": "C#", "tags": ["math", "dp", "combinatorics"], "code_uid": "de307cde1a978d04f81863b0765ac2ce", "src_uid": "b2b9bee53e425fab1aa4d5468b9e578b", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Text;\n\nnamespace codeforces\n{\n\n class Program\n {\n const int N = 2000;\n const int MOD = 998244353;\n\n static int n, m, k;\n static int[,] dp = new int[N, N];\n\n static int mul(int a, int b)\n {\n return (int) ((1L * a * b) % MOD);\n }\n\n static int add(int a, int b)\n {\n int result = a + b;\n if (result >= MOD)\n {\n result -= MOD;\n }\n return result;\n }\n\n static void Main(string[] args)\n {\n var s = Console.ReadLine().Split(' ');\n n = int.Parse(s[0]);\n m = int.Parse(s[1]);\n k = int.Parse(s[2]);\n for (int i = 0; i < n; ++i)\n {\n for (int j = 0; j < n; ++j)\n {\n dp[i, j] = 0;\n }\n }\n dp[0, 0] = m;\n for (int i = 1; i < n; ++i)\n {\n for (int j = 0; j <= i; ++j)\n {\n dp[i, j] = j == 0\n ? dp[i - 1, j]\n : add(dp[i - 1, j], mul(m - 1, dp[i - 1, j - 1]));\n }\n }\n Console.WriteLine(dp[n - 1, k]);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "dp", "combinatorics"], "code_uid": "2246e455f51e15ef8e6d84ea4efaf43b", "src_uid": "b2b9bee53e425fab1aa4d5468b9e578b", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace HayCragrer\n{\n class Problem4\n {\n static void Main(string[] args)\n {\n int[] coords = new int[4];\n string[] text = Console.ReadLine().Split();\n string[] text1 = Console.ReadLine().Split();\n int[] steps = new int[2];\n for (int i = 0; i < 4; i++)\n {\n coords[i] = int.Parse(text[i]);\n }\n for (int i = 0; i < 2; i++)\n {\n steps[i] = int.Parse(text1[i]);\n }\n int x = coords[2] - coords[0];\n int y = coords[3] - coords[1];\n if ((x % steps[0] == 0) && (y % steps[1] == 0))\n {\n if ((x / steps[0] -y / steps[1]) % 2==0)\n {\n Console.WriteLine(\"YES\");\n }\n else\n {\n Console.WriteLine(\"NO\");\n }\n \n }\n else\n {\n Console.WriteLine(\"NO\");\n }\n }\n }\n}", "lang_cluster": "C#", "tags": ["math", "implementation", "number theory"], "code_uid": "96266af4414a76067d473ebc19e0e8df", "src_uid": "1c80040104e06c9f24abfcfe654a851f", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace Codeforces\n{\n class P817A\n {\n static void Main(string[] args)\n {\n string[] input1 = Console.ReadLine().Split();\n int x1 = int.Parse(input1[0]);\n int y1 = int.Parse(input1[1]);\n int x2 = int.Parse(input1[2]);\n int y2 = int.Parse(input1[3]);\n string[] input2 = Console.ReadLine().Split();\n int x = int.Parse(input2[0]);\n int y = int.Parse(input2[1]);\n Console.WriteLine((Math.Abs(x1 - x2) % x == 0 && Math.Abs(y1 - y2) % y == 0 && (Math.Abs(x1 - x2) / x) % 2 == (Math.Abs(y1 - y2) / y) % 2) ? \"YES\" : \"NO\");\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "implementation", "number theory"], "code_uid": "78e31b3393165167ddd2ce8314b583b2", "src_uid": "1c80040104e06c9f24abfcfe654a851f", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace CodeForces.C664\n{\n class Pa\n {\n static void Main(string[] args)\n {\n string[] numbers = Console.ReadLine().Split(' ').ToArray();\n if (numbers[0] == numbers[1]) Console.WriteLine(numbers[0]);\n else Console.WriteLine(1);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "number theory"], "code_uid": "fac0b01accd2d4e46121cdd1d7a6740e", "src_uid": "9c5b6d8a20414d160069010b2965b896", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\n\nnamespace CSharp\n{\n public class _664A\n {\n public static void Main()\n {\n string[] tokens = Console.ReadLine().Split();\n Console.WriteLine(tokens[0] == tokens[1] ? tokens[0] : \"1\");\n }\n }\n}", "lang_cluster": "C#", "tags": ["math", "number theory"], "code_uid": "b1b1f86e9a74113d97e11cd10063a783", "src_uid": "9c5b6d8a20414d160069010b2965b896", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.IO;\n\npublic class C1\n{\n public static void Main ( )\n {\n#if MYTRIAL\n Console.SetIn ( new StreamReader ( @\"e:\\zin.txt\" ) );\n#endif\n //solve ( );\n Console.WriteLine ( solve ( ) );\n }\n\n private static int solve ( )\n {\n long N = long.Parse ( Console.ReadLine ( ) );\n for ( int b = 0; b <= 90; b++ )\n {\n long D = GetDisc ( 1, b, -N );\n if ( D < 0 )\n continue;\n long sqrtd = ( long ) Math.Sqrt ( D );\n if ( sqrtd * sqrtd != D )\n continue;\n double x1 = ( -b + sqrtd ) / 2.0;\n if ( x1 == Math.Floor ( x1 ) && x1 >= 0 )\n {\n if ( b == sumd ( ( int ) x1 ) )\n return ( int ) x1;\n }\n\n double x2 = ( -b - sqrtd ) / 2.0;\n if ( x2 == Math.Floor ( x2 ) && x2 >= 0 )\n {\n if ( b == sumd ( ( int ) x2 ) )\n return ( int ) x2;\n }\n }\n\n return -1;\n }\n\n static int sumd ( int x )\n {\n int sum=0;\n while ( x > 0 )\n {\n sum += x % 10;\n x = x / 10;\n }\n return sum;\n }\n\n static long GetDisc ( long a, long b, long c )\n {\n return b * b - 4 * a * c;\n }\n\n public static int[] ReadLineToInts ( int length )\n {\n string line = Console.ReadLine ( ).Trim ( );\n string[] arStrings = line.Split ( ' ' );\n\n int[] ints = new int[length];\n for ( int i=0; i < length; i++ )\n ints[i] = int.Parse ( arStrings[i] );\n return ints;\n }\n\n}", "lang_cluster": "C#", "tags": ["brute force", "math", "binary search"], "code_uid": "cc7469a53fb49ef4e37a315da8bdb9c0", "src_uid": "e1070ad4383f27399d31b8d0e87def59", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Text.RegularExpressions;\n\nnamespace ConsoleApplication1\n{\n class Program\n {\n static void Main(string[] args)\n {\n Int64 n = Convert.ToInt64(Console.ReadLine());\n\n int i, f = 0;\n Int64 s, d, x = -1;\n\n for (i = 1; i <= 90; i++)\n {\n d = i * i + 4 * n;\n s = (Int64)Math.Sqrt(d);\n if(s*s==d)\n {\n x = (Int64)s - i;\n\n if (x % 2 == 0)\n {\n x = (int)(s - i) / 2;\n if (i == DigitSum(x))\n {\n f = 1;\n break;\n }\n }\n }\n }\n\n if (f == 0)\n Console.WriteLine(\"-1\");\n else\n Console.WriteLine(x);\n\n }\n\n private static int DigitSum(Int64 x)\n {\n int sum = 0;\n while (x != 0)\n {\n sum += (int)(x % 10);\n x /= 10;\n }\n return sum;\n }\n }\n}\n\n", "lang_cluster": "C#", "tags": ["brute force", "math", "binary search"], "code_uid": "e5d57ebdeaa8434b315d6b885c351f2b", "src_uid": "e1070ad4383f27399d31b8d0e87def59", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\nusing System;\nusing System.Linq;\nusing System.Diagnostics;\nusing System.Collections.Generic;\nusing Debug = System.Diagnostics.Debug;\nusing StringBuilder = System.Text.StringBuilder;\nusing System.Numerics;\nnamespace Program\n{\n\n public class Solver\n {\n public void Solve()\n {\n var n = sc.Integer();\n var T = sc.Integer();\n var a = sc.Integer(n);\n var v = a.Distinct().ToList();\n v.Sort();\n for (int i = 0; i < n; i++)\n a[i] = v.BinarySearch(a[i]);\n var m = v.Count;\n var mat = new TropicalMatrix(m, m);\n for (int i = 0; i < m; i++)\n for (int j = i; j < m; j++)\n {\n var dp = Enumerate(n + 1, x => 1L << 60);\n foreach (var x in a)\n {\n if (x < i || x > j) continue;\n dp[dp.UpperBound(x)] = x;\n }\n mat[i, j] = dp.LowerBound(1L << 60);\n Debug.WriteLine(\"{0} {1} {2}\", i, j, mat[i, j]);\n }\n var ret = TropicalMatrix.Pow(mat, T);\n IO.Printer.Out.WriteLine(ret[0, m - 1]);\n }\n public IO.StreamScanner sc = new IO.StreamScanner(Console.OpenStandardInput());\n static T[] Enumerate(int n, Func f) { var a = new T[n]; for (int i = 0; i < n; ++i) a[i] = f(i); return a; }\n static public void Swap(ref T a, ref T b) { var tmp = a; a = b; b = tmp; }\n }\n\n\n}\n\n#region main\nstatic class Ex\n{\n static public string AsString(this IEnumerable ie) { return new string(System.Linq.Enumerable.ToArray(ie)); }\n static public string AsJoinedString(this IEnumerable ie, string st = \" \") { return string.Join(st, ie); }\n static public void Main()\n {\n var solver = new Program.Solver();\n solver.Solve();\n Program.IO.Printer.Out.Flush();\n }\n}\n#endregion\n#region Ex\nnamespace Program.IO\n{\n using System.IO;\n using System.Text;\n using System.Globalization;\n public class Printer : StreamWriter\n {\n static Printer() { Out = new Printer(Console.OpenStandardOutput()) { AutoFlush = false }; }\n public static Printer Out { get; set; }\n public override IFormatProvider FormatProvider { get { return CultureInfo.InvariantCulture; } }\n public Printer(System.IO.Stream stream) : base(stream, new UTF8Encoding(false, true)) { }\n public Printer(System.IO.Stream stream, Encoding encoding) : base(stream, encoding) { }\n public void Write(string format, T[] source) { base.Write(format, source.OfType().ToArray()); }\n public void WriteLine(string format, T[] source) { base.WriteLine(format, source.OfType().ToArray()); }\n }\n public class StreamScanner\n {\n public StreamScanner(Stream stream) { str = stream; }\n public readonly Stream str;\n private readonly byte[] buf = new byte[1024];\n private int len, ptr;\n public bool isEof = false;\n public bool IsEndOfStream { get { return isEof; } }\n private byte read()\n {\n if (isEof) return 0;\n if (ptr >= len) { ptr = 0; if ((len = str.Read(buf, 0, 1024)) <= 0) { isEof = true; return 0; } }\n return buf[ptr++];\n }\n public char Char() { byte b = 0; do b = read(); while ((b < 33 || 126 < b) && !isEof); return (char)b; }\n\n public string Scan()\n {\n var sb = new StringBuilder();\n for (var b = Char(); b >= 33 && b <= 126; b = (char)read())\n sb.Append(b);\n return sb.ToString();\n }\n public string ScanLine()\n {\n var sb = new StringBuilder();\n for (var b = Char(); b != '\\n'; b = (char)read())\n if (b == 0) break;\n else if (b != '\\r') sb.Append(b);\n return sb.ToString();\n }\n public long Long()\n {\n if (isEof) return long.MinValue;\n long ret = 0; byte b = 0; var ng = false;\n do b = read();\n while (b != 0 && b != '-' && (b < '0' || '9' < b));\n if (b == 0) return long.MinValue;\n if (b == '-') { ng = true; b = read(); }\n for (; true; b = read())\n {\n if (b < '0' || '9' < b)\n return ng ? -ret : ret;\n else ret = ret * 10 + b - '0';\n }\n }\n public int Integer() { return (isEof) ? int.MinValue : (int)Long(); }\n public double Double() { var s = Scan(); return s != \"\" ? double.Parse(Scan(), CultureInfo.InvariantCulture) : double.NaN; }\n private T[] enumerate(int n, Func f)\n {\n var a = new T[n];\n for (int i = 0; i < n; ++i) a[i] = f();\n return a;\n }\n\n public char[] Char(int n) { return enumerate(n, Char); }\n public string[] Scan(int n) { return enumerate(n, Scan); }\n public double[] Double(int n) { return enumerate(n, Double); }\n public int[] Integer(int n) { return enumerate(n, Integer); }\n public long[] Long(int n) { return enumerate(n, Long); }\n }\n}\n#endregion\n#region Tropical Matrix\npublic class TropicalMatrix\n{\n int row, col;\n public long[] mat;\n const long min = -1L << 60;\n public long this[int r, int c]\n {\n get { return mat[r * col + c]; }\n set { mat[r * col + c] = value; }\n }\n public TropicalMatrix(int r, int c)\n {\n row = r; col = c;\n mat = new long[row * col];\n for (int i = 0; i < row * col; i++)\n mat[i] = min;\n }\n public static TropicalMatrix operator +(TropicalMatrix l, TropicalMatrix r)\n {\n check(l, r);\n var ret = new TropicalMatrix(l.row, l.col);\n for (int i = 0; i < l.row; i++)\n for (int j = 0; j < l.col; j++)\n ret.mat[i * ret.col + j] = Math.Max(l.mat[i * l.col + j], r.mat[i * r.col + j]);\n return ret;\n\n }\n public static TropicalMatrix operator *(TropicalMatrix l, TropicalMatrix r)\n {\n checkMul(l, r);\n var ret = new TropicalMatrix(l.row, l.col);\n\n\n for (int i = 0; i < l.row; i++)\n for (int k = 0; k < l.row; k++)\n for (int j = 0; j < l.col; j++)\n ret.mat[i * l.col + j] = Math.Max(ret.mat[i * l.col + j],\n l.mat[i * l.col + k] + r.mat[k * l.col + j]);\n return ret;\n }\n public static TropicalMatrix Pow(TropicalMatrix m, long n)\n {\n var ret = new TropicalMatrix(m.row, m.col);\n for (int i = 0; i < m.row; i++)\n ret.mat[i * m.col + i] = 0;\n for (; n > 0; m *= m, n >>= 1)\n if ((n & 1) == 1)\n ret = ret * m;\n return ret;\n\n }\n public static TropicalMatrix Trans(TropicalMatrix m)\n {\n var ret = new TropicalMatrix(m.col, m.row);\n for (int i = 0; i < m.row; i++)\n for (int j = 0; j < m.col; j++)\n ret.mat[j * m.col + i] = m.mat[i * m.col + j];\n return ret;\n }\n [System.Diagnostics.Conditional(\"DEBUG\")]\n static private void check(TropicalMatrix a, TropicalMatrix b)\n {\n if (a.row != b.row || a.col != b.col)\n throw new Exception(\"row and col have to be same.\");\n\n }\n [System.Diagnostics.Conditional(\"DEBUG\")]\n static private void checkMul(TropicalMatrix a, TropicalMatrix b)\n {\n if (a.col != b.row)\n throw new Exception(\"row and col have to be same.\");\n\n }\n}\n#endregion\n\n#region BinarySearch for long[]\nstatic public partial class Algorithm\n{\n\n static public int LowerBound(this long[] arr, long v)\n {\n int l = 0, h = arr.Length - 1;\n while (l <= h)\n {\n int m = ((h + l) >> 1);\n if (arr[m] < v) l = m + 1;\n else h = m - 1;\n }\n return l;\n }\n static public int UpperBound(this long[] a, long v)\n {\n int l = 0, h = a.Length - 1;\n while (l <= h)\n {\n int m = ((h + l) >> 1);\n if (a[m] <= v) l = m + 1;\n else h = m - 1;\n }\n return l;\n }\n\n}\n#endregion", "lang_cluster": "C#", "tags": ["dp", "constructive algorithms"], "code_uid": "098121068321f421543cbb6687541e67", "src_uid": "26cf484fa4cb3dc2ab09adce7a3fc9b2", "difficulty": 1900.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.IO;\nusing System.Linq;\nusing System.Text;\n\nnamespace Once_Again\n{\n internal class Program\n {\n private static readonly StreamReader reader = new StreamReader(Console.OpenStandardInput(1024*10), Encoding.ASCII, false, 1024*10);\n private static readonly StreamWriter writer = new StreamWriter(Console.OpenStandardOutput(1024*10), Encoding.ASCII, 1024*10);\n\n private static void Main(string[] args)\n {\n int n = Next();\n int T = Next();\n\n var nn = new int[n];\n for (int i = 0; i < n; i++)\n {\n nn[i] = Next();\n }\n\n var maxK = new int[nn.Max() + 1];\n foreach (int i in nn)\n {\n maxK[i]++;\n }\n int maxx = maxK.Max();\n\n var max1 = new int[nn.Max() + 1];\n\n for (int t = 1; t <= 102; t++)\n {\n for (int i = 0; i < n; i++)\n {\n int m = 0;\n for (int j = 0; j <= nn[i]; j++)\n {\n if (m < max1[j])\n m = max1[j];\n }\n max1[nn[i]] = m + 1;\n }\n if (T == t)\n {\n writer.WriteLine(max1.Max());\n writer.Flush();\n return;\n }\n }\n\n writer.WriteLine(max1.Max() + maxx*(T - 102));\n writer.Flush();\n }\n\n private static int Next()\n {\n int c;\n int res = 0;\n do\n {\n c = reader.Read();\n if (c == -1)\n return res;\n } while (c < '0' || c > '9');\n res = c - '0';\n while (true)\n {\n c = reader.Read();\n if (c < '0' || c > '9')\n return res;\n res *= 10;\n res += c - '0';\n }\n }\n }\n}", "lang_cluster": "C#", "tags": ["matrices", "dp", "constructive algorithms"], "code_uid": "358f7a3a0137c19ac30113a22804717d", "src_uid": "26cf484fa4cb3dc2ab09adce7a3fc9b2", "difficulty": 1900.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\n\nnamespace CodeForces\n{\n class R172_Div2_B\n {\n static void Main(string[] args)\n {\n string[] s = Console.ReadLine().Split();\n int x = int.Parse(s[0]);\n int y = int.Parse(s[1]);\n int n = int.Parse(s[2]);\n double dx = (double) x;\n double dy = (double) y;\n\n long mina = 0, minb = 0;\n double min = long.MaxValue;\n for (long b = 1; b <= n; b++)\n {\n double db = (double)b;\n long aMin = b * x / y;\n long aMax = Convert.ToInt64(Math.Ceiling(db * dx / dy));\n\n for (long a = aMin; a <= aMax; a++)\n {\n double da = (double)a;\n double d = Math.Abs(dx / dy - da / db);\n d = Math.Floor(d * 1e15) / 1e15;\n if (d < min)\n {\n min = d;\n mina = a;\n minb = b;\n }\n }\n }\n\n Console.WriteLine(mina + \"/\" + minb);\n\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["two pointers", "implementation", "brute force"], "code_uid": "a4f208bc1b53cf0679d94fe4e58b7807", "src_uid": "827bc6f120aff6a6f04271bc84e863ee", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.IO;\nusing System.Linq;\n\nnamespace Codeforces.R281.B\n{\n public static class Solver\n {\n public static void Main()\n {\n using (var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false })\n {\n Solve(Console.In, sw);\n }\n }\n\n public static void Solve(TextReader tr, TextWriter tw)\n {\n var w = tr.ReadLine().Split().Select(x => int.Parse(x)).ToArray();\n tw.WriteLine(Calc(w[0], w[1], w[2]));\n }\n\n private static string Calc(int x, int y, int n)\n {\n var e = long.MaxValue;\n var eDenominator = 1L;\n\n var resA = 0L;\n var resB = 0L;\n\n for (var b = 1L; b <= n; ++b)\n {\n var l = 0L;\n var h = (x / y + 1) * b + 3;\n\n for (; l + 2 < h; )\n {\n var m1 = (l * 2 + h) / 3;\n var m2 = (l + h * 2) / 3;\n var err1 = Math.Abs(x * b - y * m1);\n var err2 = Math.Abs(x * b - y * m2);\n\n if (err1 <= err2)\n {\n h = m2;\n }\n else\n {\n l = m1;\n }\n }\n\n for (var a = l; a <= h; ++a)\n {\n var currentError = Math.Abs(x * b - y * a);\n if (currentError * eDenominator < e * b)\n {\n e = currentError;\n eDenominator = b;\n resA = a;\n resB = b;\n }\n }\n }\n\n return resA + \"/\" + resB;\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["two pointers", "implementation", "brute force"], "code_uid": "6d37ee32a89b25ed23c75e2d4467e306", "src_uid": "827bc6f120aff6a6f04271bc84e863ee", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeff/*\n * Created by SharpDevelop.\n * Handle: Arcos\n */\nusing System;\nusing System.Collections;\nusing System.ComponentModel;\nusing System.Linq;\nusing System.Collections.Generic;\nusing System.Diagnostics;\nusing System.IO;\nusing System.Text.RegularExpressions;\n\n\nnamespace TestingStuff\n{\n\tclass Program\n\t{\n\t\tpublic static void Main(string[] args)\n\t\t{\n\t\t\tvar st = Console.ReadLine();\n\t\t\tRegex rgx1 = new Regex(\"[A-Z]\");\n\t\t\tRegex rgx2 = new Regex(\"[a-z]\");\n\t\t\tRegex rgx3 = new Regex(\"[0-9]\");\n\t\t\tif (st.Length > 4 &&\n\t\t\t rgx1.IsMatch(st) &&\n\t\t\t rgx2.IsMatch(st) &&\n\t\t\t rgx3.IsMatch(st)){\n\t\t\t\tprint(\"Correct\");\n\t\t\t} else {\n\t\t\t\tprint(\"Too weak\");\n\t\t\t}\n\t\t\t\n//\t\t\tread();\n\t\t\treturn;\n\t\t}\n\t\t\n\t\tpublic static String formatDouble(Double num){\n\t\t\treturn String.Format(\"{0:0.0000000}\",num).Replace(',','.');\n\t\t}\n\t\t\n\t\tpublic static void print(object a){\n\t\t\tConsole.WriteLine(a.ToString());\n\t\t}\n\t\t\n\t\tpublic static void printList(List a){\n\t\t\tforeach (object o in a){\n\t\t\t\tConsole.WriteLine(o.ToString());\n\t\t\t}\n\t\t\t\n\t\t}\n\t\t\n\t\tpublic static void printList(List a){\n\t\t\tString ou = \"\";\n\t\t\tforeach (object o in a){\n\t\t\t\tou += o.ToString();\n\t\t\t}\n\t\t\tConsole.WriteLine(\"List: \" + ou);\n\t\t}\n\t\t\n\t\tpublic static void printListList(List> a){\n\t\t\tString ou = \"\";\n\t\t\tforeach (List o in a){\n\t\t\t\tforeach (int oo in o){\n\t\t\t\t\tou += oo + \" \";\n\t\t\t\t}\n\t\t\t}\n\t\t\tConsole.WriteLine(\"List: \" + ou);\n\t\t}\n\t\t\n\t\tpublic static void read(){\n\t\t\tConsole.ReadLine();\n\t\t}\n\t}\n}\n\n// Remember these:\n// lis2.Take(n-1).Sum()\n// String.Format(\"{0:0}\",f).ToString(CultureInfo.InvariantCulture); -- handles printing double/float\n// Regex rgx = new Regex(pattern, RegexOptions.IgnoreCase);\n// var splstr = Console.ReadLine().Split(' ').ToList();\n// var str = Console.ReadLine();\n// var lis = new List();\n//\t\t\tforeach(string strItem in splstr ){\n//\t\t\t\tlis.Add(int.Parse(strItem));\n//\t\t\t}\n//\t\t\tfor(int i = 0; i < n; i++){\n//\t\t\t\tfor(int j = 0; j < 3; j++){\n//\t\t\t\t\tprint(lisLis[i][j]);\n//\t\t\t\t}\n//\t\t\t}", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "ac57f6f965079135be30d9e24e86b9c1", "src_uid": "42a964b01e269491975965860ec92be7", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Text.RegularExpressions;\n\nnamespace codeforces\n{\n class Program\n {\n static void Main(string[] args)\n {\n string str = Console.ReadLine();\n Console.WriteLine(Regex.IsMatch(str, \".{5,}\") && \n Regex.IsMatch(str, \"[a-z]{1,}\") && \n Regex.IsMatch(str, \"[A-Z]{1,}\") && \n Regex.IsMatch(str, \"[0-9]{1,}\") ? \n \"Correct\" : \n \"Too weak\");\n }\n }\n}", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "95a3cde34ef9d4c47c2ff6e4a019ade7", "src_uid": "42a964b01e269491975965860ec92be7", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nclass Program\n{\n\tstatic void Main(string[] args)\n\t{\n\t\tint N = int.Parse(Console.ReadLine());\n\t\tint[]A = new int[N];\n\t\tstring[]str = Console.ReadLine().Split();\n\t\tint min = 999999999;\n\t\tfor(var i=0;i N/2){\n\t\t\tans = \"Bob\";\n\t\t} else {\n\t\t\tans = \"Alice\";\n\t\t}\n\t\tConsole.WriteLine(ans);\n\t}\n}", "lang_cluster": "C#", "tags": ["games"], "code_uid": "af8237fcebf04471f7f9ca8e00d0c00b", "src_uid": "4b9cf82967aa8441e9af3db3101161e9", "difficulty": 2000.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections;\nusing System.Collections.Generic;\nusing System.Collections.Specialized;\nusing System.Numerics;\nusing System.Text;\nusing System.Text.RegularExpressions;\nusing System.Linq;\nusing System.IO;\npublic class CodeForces\n{\n#if TEST\n // To set this go to Project -> Properties -> Build -> General -> Conditional compilation symbols: -> enter 'TEST' into text box.\n const bool testing = true;\n#else\nconst bool testing = false;\n#endif\n\n private static int Next()\n {\n int c;\n int res = 0;\n do\n {\n c = reader.Read();\n if (c == -1)\n return res;\n } while (c < '0' || c > '9');\n res = c - '0';\n while (true)\n {\n c = reader.Read();\n if (c < '0' || c > '9')\n return res;\n res *= 10;\n res += c - '0';\n }\n }\n private static readonly StreamReader reader = new StreamReader(Console.OpenStandardInput(1024 * 10), Encoding.ASCII, false, 1024 * 10);\n private static readonly StreamWriter writer = new StreamWriter(Console.OpenStandardOutput(1024 * 10), Encoding.ASCII, 1024 * 10);\n\n struct Point\n {\n public int x { get; set; }\n public int y { get; set; }\n } \n static void program(TextReader input)\n {\n //var n = int.Parse(input.ReadLine().TrimEnd());\n var data = input.ReadLine().Split(' ').Select(int.Parse).ToList();\n var x1 = data[0];\n var y1 = data[1];\n var data2 = input.ReadLine().Split(' ').Select(int.Parse).ToList();\n var x2 = data2[0];\n var y2 = data2[1];\n\n var points = new List();\n var stepX = new int[] { -1, 0, 1, 1, 1, 0, -1, -1 };\n var stepY = new int[] { 1, 1, 1, 0, -1, -1, -1, 0 };\n var min = int.MaxValue;\n for(var i = 0; i < stepX.Length; i++)\n {\n var distance = Math.Abs(x1 - (x2 + stepX[i])) + Math.Abs(y1 - (y2 + stepY[i]));\n min = Math.Min(min, distance);\n }\n\n writer.WriteLine(2*min + 8);\n writer.Flush();\n }\n\n public static void Main(string[] args)\n {\n if (!testing)\n { // set testing to false when submiting to codeforces\n program(Console.In); // write your program in 'program' function (its your new main !)\n return;\n }\n\n Console.WriteLine(\"Test Case(1) => expected :\");\n Console.WriteLine(\"18\\n\");\n Console.WriteLine(\"Test Case(1) => found :\");\n program(new StringReader(\"1 5\\n5 2\\n\"));\n Console.WriteLine();\n Console.ReadLine();\n\n Console.WriteLine(\"Test Case(2) => expected :\");\n Console.WriteLine(\"8\\n\");\n Console.WriteLine(\"Test Case(2) => found :\");\n program(new StringReader(\"0 1\\n0 0\\n\"));\n Console.WriteLine();\n Console.ReadLine();\n\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "greedy"], "code_uid": "c47cc98707e7f902f80a7c6224578169", "src_uid": "f54ce13fb92e51ebd5e82ffbdd1acbed", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\nusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text.RegularExpressions;\n\nnamespace Quadcopter\n{\n public class Program\n {\n public static void Main(string[] args)\n {\n string str = Console.ReadLine();\n var list = str.Split(new[] { ' ' }).Select(Int64.Parse).ToList();\n long x1 = list[0];\n long y1 = list[1];\n \n str = Console.ReadLine();\n list = str.Split(new[] { ' ' }).Select(Int64.Parse).ToList();\n long x2 = list[0];\n long y2 = list[1];\n \n //long x1=1, y1=5, x2=5, y2=2;\n \n long width=0, height=0;\n if(x1==x2) width++;\n if(x1=x2){\n x1--;\n width++;\n }\n if(y1==y2) height++;\n if(y1=y2){\n y1--;\n height++;\n }\n \n Console.WriteLine(width*2 + height*2);\n }\n }\n}", "lang_cluster": "C#", "tags": ["math", "greedy"], "code_uid": "4bf7338afce0e6ec77093b9dac414890", "src_uid": "f54ce13fb92e51ebd5e82ffbdd1acbed", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Diagnostics;\nusing System.IO;\nusing System.Linq;\n\nnamespace codeforces\n{\n class Program\n {\n\n static void Main(string[] args)\n {\n string input = Console.ReadLine();\n List a = new List();\n a.Add(input[1] - '0');\n a.Add(input[3] - '0');\n a.Add(input[4] - '0');\n a.Add(input[2] - '0');\n a.Add(input[0] - '0');\n \n List b = new List();\n b.Add(input[1] - '0');\n b.Add(input[3] - '0');\n b.Add(input[4] - '0');\n b.Add(input[2] - '0');\n b.Add(input[0] - '0');\n\n List c = new List();\n c.Add(0);\n c.Add(0);\n c.Add(0);\n c.Add(0);\n c.Add(0);\n\n for (int st = 1; st < 5; ++st)\n {\n for (int i = 0; i < 5; ++i)\n for (int j = 0, carry = 0; j < 5 && i + j < 5; ++j)\n {\n int cur = c[i + j] + a[i] * b[j] + carry;\n c[i + j] = cur % 10;\n carry = cur / 10;\n }\n\n b = new List();\n for (int i = 0; i < 5; ++i)\n b.Add(c[i]);\n for (int i = 0; i < 5; ++i)\n c[i] = 0;\n }\n Console.WriteLine(b[4] + \"\" + b[3] + \"\" + b[2] + \"\" + b[1] + \"\" + b[0]);\n }\n }\n}", "lang_cluster": "C#", "tags": ["math", "implementation"], "code_uid": "5528bef59b41376c99f08e384e5e599a", "src_uid": "51b1c216948663fff721c28d131bf18f", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\n\nclass Program_630L\n{\n private static void Main()\n {\n int n = int.Parse(Console.ReadLine());\n\n int a5 = n % 10;\n int a4 = (n / 10) % 10;\n int a3 = (n / 100) % 10;\n int a2 = (n / 1000) % 10;\n int a1 = (n / 10000) % 10;\n\n long m = a1 * 10000 + a3 * 1000 + a5 * 100 + a4 * 10 + a2;\n\n long k = m;\n for (int i = 2; i <= 5; i++ )\n {\n k = k * m;\n k = k % 100000;\n }\n\n Console.WriteLine(k.ToString(\"00000\"));\n }\n}", "lang_cluster": "C#", "tags": ["math", "implementation"], "code_uid": "5236dec54a937e6b57fe33b9c7ae944d", "src_uid": "51b1c216948663fff721c28d131bf18f", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\n\nnamespace m_perfect\n{\n class Program\n {\n static void Main(string[] args)\n {\n\n\n string[] tokens = Console.ReadLine().Split(' ');\n\n long x=0, y=0, m = 0;\n x =long.Parse(tokens[0]);\n y = long.Parse(tokens[1]);\n m = long.Parse(tokens[2]);\n\n long p=mperfect(x, y, m);\n\n Console.WriteLine(p);\n Console.ReadLine();\n\n\n\n }\n\n protected static long mperfect(long x, long y, long m)\n {\n long i = 0;\n\n if (x >= m || y >= m)\n return 0;\n if (x <= 0 && y <= 0 )\n return -1;\n\n if (x > y)\n {\n x ^= y;\n y ^= x;\n x ^= y;\n\n // x ^= (y ^= (x ^= y));\n }\n \n if (x < 0 && y > 0)\n {\n i = -x / y;\n x = x + y * i;\n }\n else if (y < 0 && x > 0)\n {\n i = -y / x;\n y = y + x * i;\n }\n\n while (x < m && y < m)\n {\n if (x < y)\n {\n x = x + y;\n i++;\n if (x >= m || y >= m)\n return i;\n }\n else\n {\n y = x + y;\n i++;\n if (x >= m || y >= m)\n return i;\n }\n\n }\n\n return i;\n\n \n \n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "greedy"], "code_uid": "26f1d3e734efe2ade0877bfe68e57d18", "src_uid": "82026a3c3d9a6bda2e2ac6e14979d821", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\n\nnamespace Solution {\n\n class Solution {\n\n class StdIn {\n int currPos = 0;\n string[] tokens = new string[0];\n\n private string getNextToken() {\n if (currPos < tokens.Length) return tokens[currPos++];\n currPos = 0;\n tokens = Console.ReadLine().Split(new char[] { ' ', '\\t', '\\r', '\\n' }, StringSplitOptions.RemoveEmptyEntries);\n return tokens[currPos++];\n }\n\n public int nextInt() {\n return int.Parse(getNextToken());\n }\n\n public string nextString() {\n return getNextToken();\n }\n\n public double nextDouble() {\n return double.Parse(getNextToken());\n }\n\n public long nextLong() {\n return long.Parse(getNextToken());\n }\n }\n\n public static void swap(ref T a, ref T b) {\n T c = a;\n a = b;\n b = c;\n }\n\n\n\n public static void Main(string[] args) {\n StdIn std = new StdIn();\n\n long x = std.nextLong();\n long y = std.nextLong();\n long m = std.nextLong();\n\n if (x >= m || y >= m) {\n Console.WriteLine(0);\n return;\n }\n if (x <= 0 && y <= 0) {\n Console.WriteLine(-1);\n return;\n }\n\n long ans = 0;\n if (x < 0) {\n ans += (-x) / y;\n x += ans * y;\n }\n if (y < 0) {\n ans += (-y) / x;\n y += ans * x;\n }\n\n while (x < m && y < m) {\n ++ans;\n if (x < y) x += y;\n else y += x;\n }\n\n Console.WriteLine(ans);\n\n //Console.ReadLine();\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force"], "code_uid": "babd12f0ee6166f583d00e64984a9d5a", "src_uid": "82026a3c3d9a6bda2e2ac6e14979d821", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Linq;\n\nnamespace Test\n{\n class Program\n {\n static long Gcd(long i, long j)\n {\n while (i != 0 && j != 0)\n if (i > j)\n i %= j;\n else\n j %= i;\n return Math.Max(i, j);\n }\n\n static void Main(string[] args)\n {\n long[] a = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();\n long k = Gcd(a[2], a[3]);\n Console.WriteLine(Math.Min(a[0] / (a[2] / k), a[1] / (a[3] / k)));\n }\n }\n}", "lang_cluster": "C#", "tags": ["math"], "code_uid": "c6e483025714c27232e212f42ca902a1", "src_uid": "907ac56260e84dbb6d98a271bcb2d62d", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace Competitive_Programming.CodeForces\n{\n class tvset\n {\n static void Main()\n {\n string[] data = Console.ReadLine().Split();\n\n long a = long.Parse(data[0]), b = long.Parse(data[1]);\n long x = long.Parse(data[2]), y = long.Parse(data[3]);\n\n long gc = gcd(x, y);\n\n x /= gc;\n y /= gc;\n\n Console.WriteLine(Math.Min(a/x, b/y));\n }\n\n static long gcd(long a, long b)\n {\n while (b != 0)\n {\n long temp = a % b;\n a = b;\n b = temp;\n }\n\n return a;\n }\n }\n}", "lang_cluster": "C#", "tags": ["math"], "code_uid": "b304d4811537b8231370df3c2625e2a7", "src_uid": "907ac56260e84dbb6d98a271bcb2d62d", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.IO;\nusing System.Linq;\nusing static System.Math;\nusing System.Text;\nusing System.Threading;\nnamespace Program\n{\n public static class CODEFORCES1\n {\n static public int numberOfRandomCases = 0;\n static public void MakeTestCase(List _input, List _output, ref Func _outputChecker)\n {\n }\n static public void Solve()\n {\n var n = NN;\n var p = NN;\n var ans = 10000;\n for (var i = 0; i <= 33; i++)\n {\n var tmp = n - p * i;\n var mask = 1;\n var tmp2 = 0;\n for (var j = 0; j <= 33; j++)\n {\n if ((mask & tmp) != 0) ++tmp2;\n mask <<= 1;\n }\n if (tmp2 <= i && tmp >= i)\n {\n ans = Min(ans, i);\n }\n }\n if (ans == 10000)\n {\n Console.WriteLine(-1);\n }\n else\n {\n Console.WriteLine(ans);\n }\n\n }\n static public void Main(string[] args) { if (args.Length == 0) { var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false }; Console.SetOut(sw); } var t = new Thread(Solve, 134217728); t.Start(); t.Join(); Console.Out.Flush(); }\n static class Console_\n {\n static Queue param = new Queue();\n public static string NextString() { if (param.Count == 0) foreach (var item in Console.ReadLine().Split(' ')) param.Enqueue(item); return param.Dequeue(); }\n }\n static long NN => long.Parse(Console_.NextString());\n static double ND => double.Parse(Console_.NextString());\n static string NS => Console_.NextString();\n static long[] NNList(long N) => Repeat(0, N).Select(_ => NN).ToArray();\n static double[] NDList(long N) => Repeat(0, N).Select(_ => ND).ToArray();\n static string[] NSList(long N) => Repeat(0, N).Select(_ => NS).ToArray();\n static IEnumerable OrderByRand(this IEnumerable x) => x.OrderBy(_ => xorshift);\n static long Count(this IEnumerable x, Func pred) => Enumerable.Count(x, pred);\n static IEnumerable Repeat(T v, long n) => Enumerable.Repeat(v, (int)n);\n static IEnumerable Range(long s, long c) => Enumerable.Range((int)s, (int)c);\n static IEnumerable Primes(long x) { if (x < 2) yield break; yield return 2; var halfx = x / 2; var table = new bool[halfx + 1]; var max = (long)(Math.Sqrt(x) / 2); for (long i = 1; i <= max; ++i) { if (table[i]) continue; var add = 2 * i + 1; yield return add; for (long j = 2 * i * (i + 1); j <= halfx; j += add) table[j] = true; } for (long i = max + 1; i <= halfx; ++i) if (!table[i] && 2 * i + 1 <= x) yield return 2 * i + 1; }\n static IEnumerable Factors(long x) { if (x < 2) yield break; while (x % 2 == 0) { x /= 2; yield return 2; } var max = (long)Math.Sqrt(x); for (long i = 3; i <= max; i += 2) while (x % i == 0) { x /= i; yield return i; } if (x != 1) yield return x; }\n static IEnumerable Divisor(long x) { if (x < 1) yield break; var max = (long)Math.Sqrt(x); for (long i = 1; i <= max; ++i) { if (x % i != 0) continue; yield return i; if (i != x / i) yield return x / i; } }\n static uint xorshift { get { _xsi.MoveNext(); return _xsi.Current; } }\n static IEnumerator _xsi = _xsc();\n static IEnumerator _xsc() { uint x = 123456789, y = 362436069, z = 521288629, w = (uint)(DateTime.Now.Ticks & 0xffffffff); while (true) { var t = x ^ (x << 11); x = y; y = z; z = w; w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)); yield return w; } }\n static long GCD(long a, long b) { while (b > 0) { var tmp = b; b = a % b; a = tmp; } return a; }\n static long LCM(long a, long b) => a * b / GCD(a, b);\n static Mod Pow(Mod x, long y) { Mod a = 1; while (y != 0) { if ((y & 1) == 1) a.Mul(x); x.Mul(x); y >>= 1; } return a; }\n static long Pow(long x, long y) { long a = 1; while (y != 0) { if ((y & 1) == 1) a *= x; x *= x; y >>= 1; } return a; }\n static List _fact = new List() { 1 };\n static void _B(long n) { if (n >= _fact.Count) for (int i = _fact.Count; i <= n; ++i) _fact.Add(_fact[i - 1] * i); }\n static long Comb(long n, long k) { _B(n); if (n == 0 && k == 0) return 1; if (n < k || n < 0) return 0; return _fact[(int)n] / _fact[(int)(n - k)] / _fact[(int)k]; }\n static long Perm(long n, long k) { _B(n); if (n == 0 && k == 0) return 1; if (n < k || n < 0) return 0; return _fact[(int)n] / _fact[(int)(n - k)]; }\n static Func Lambda(Func, TR> f) { Func t = () => default(TR); return t = () => f(t); }\n static Func Lambda(Func, TR> f) { Func t = x1 => default(TR); return t = x1 => f(x1, t); }\n static Func Lambda(Func, TR> f) { Func t = (x1, x2) => default(TR); return t = (x1, x2) => f(x1, x2, t); }\n static Func Lambda(Func, TR> f) { Func t = (x1, x2, x3) => default(TR); return t = (x1, x2, x3) => f(x1, x2, x3, t); }\n static Func Lambda(Func, TR> f) { Func t = (x1, x2, x3, x4) => default(TR); return t = (x1, x2, x3, x4) => f(x1, x2, x3, x4, t); }\n static List LCS(T[] s, T[] t) where T : IEquatable { int sl = s.Length, tl = t.Length; var dp = new int[sl + 1, tl + 1]; for (var i = 0; i < sl; i++) for (var j = 0; j < tl; j++) dp[i + 1, j + 1] = s[i].Equals(t[j]) ? dp[i, j] + 1 : Max(dp[i + 1, j], dp[i, j + 1]); { var r = new List(); int i = sl, j = tl; while (i > 0 && j > 0) if (s[--i].Equals(t[--j])) r.Add(s[i]); else if (dp[i, j + 1] > dp[i + 1, j]) ++j; else ++i; r.Reverse(); return r; } }\n static long LIS(T[] array, bool strict) { var l = new List(); foreach (var e in array) { var i = l.BinarySearch(e); if (i < 0) i = ~i; else if (!strict) ++i; if (i == l.Count) l.Add(e); else l[i] = e; } return l.Count; }\n class PQ\n {\n List h; Comparison c; public T Peek => h[0]; public int Count => h.Count;\n public PQ(int cap, Comparison c, bool asc = true) { h = new List(cap); this.c = asc ? c : (x, y) => c(y, x); }\n public PQ(Comparison c, bool asc = true) { h = new List(); this.c = asc ? c : (x, y) => c(y, x); }\n public PQ(int cap, bool asc = true) : this(cap, Comparer.Default.Compare, asc) { }\n public PQ(bool asc = true) : this(Comparer.Default.Compare, asc) { }\n public void Push(T v) { var i = h.Count; h.Add(v); while (i > 0) { var ni = (i - 1) / 2; if (c(v, h[ni]) >= 0) break; h[i] = h[ni]; i = ni; } h[i] = v; }\n public T Pop() { var r = h[0]; var v = h[h.Count - 1]; h.RemoveAt(h.Count - 1); if (h.Count == 0) return r; var i = 0; while (i * 2 + 1 < h.Count) { var i1 = i * 2 + 1; var i2 = i * 2 + 2; if (i2 < h.Count && c(h[i1], h[i2]) > 0) i1 = i2; if (c(v, h[i1]) <= 0) break; h[i] = h[i1]; i = i1; } h[i] = v; return r; }\n }\n class PQ\n {\n PQ> q; public Tuple Peek => q.Peek; public int Count => q.Count;\n public PQ(int cap, Comparison c, bool asc = true) { q = new PQ>(cap, (x, y) => c(x.Item1, y.Item1), asc); }\n public PQ(Comparison c, bool asc = true) { q = new PQ>((x, y) => c(x.Item1, y.Item1), asc); }\n public PQ(int cap, bool asc = true) : this(cap, Comparer.Default.Compare, asc) { }\n public PQ(bool asc = true) : this(Comparer.Default.Compare, asc) { }\n public void Push(TK k, TV v) => q.Push(Tuple.Create(k, v));\n public Tuple Pop() => q.Pop();\n }\n public class UF\n {\n long[] d;\n public UF(long s) { d = Repeat(-1L, s).ToArray(); }\n public bool Unite(long x, long y) { x = Root(x); y = Root(y); if (x != y) { if (d[y] < d[x]) { var t = y; y = x; x = t; } d[x] += d[y]; d[y] = x; } return x != y; }\n public bool IsSame(long x, long y) => Root(x) == Root(y);\n public long Root(long x) => d[x] < 0 ? x : d[x] = Root(d[x]);\n public long Count(long x) => -d[Root(x)];\n }\n struct Mod : IEquatable, IEquatable\n {\n static public long _mod = 1000000007; long v;\n public Mod(long x) { if (x < _mod && x >= 0) v = x; else if ((v = x % _mod) < 0) v += _mod; }\n static public implicit operator Mod(long x) => new Mod(x);\n static public implicit operator long(Mod x) => x.v;\n public void Add(Mod x) { if ((v += x.v) >= _mod) v -= _mod; }\n public void Sub(Mod x) { if ((v -= x.v) < 0) v += _mod; }\n public void Mul(Mod x) => v = (v * x.v) % _mod;\n public void Div(Mod x) => v = (v * Inverse(x.v)) % _mod;\n static public Mod operator +(Mod x, Mod y) { var t = x.v + y.v; return t >= _mod ? new Mod { v = t - _mod } : new Mod { v = t }; }\n static public Mod operator -(Mod x, Mod y) { var t = x.v - y.v; return t < 0 ? new Mod { v = t + _mod } : new Mod { v = t }; }\n static public Mod operator *(Mod x, Mod y) => x.v * y.v;\n static public Mod operator /(Mod x, Mod y) => x.v * Inverse(y.v);\n static public bool operator ==(Mod x, Mod y) => x.v == y.v;\n static public bool operator !=(Mod x, Mod y) => x.v != y.v;\n static public long Inverse(long x) { long b = _mod, r = 1, u = 0, t = 0; while (b > 0) { var q = x / b; t = u; u = r - q * u; r = t; t = b; b = x - q * b; x = t; } return r < 0 ? r + _mod : r; }\n public bool Equals(Mod x) => v == x.v;\n public bool Equals(long x) => v == x;\n public override bool Equals(object x) => x == null ? false : Equals((Mod)x);\n public override int GetHashCode() => v.GetHashCode();\n public override string ToString() => v.ToString();\n static List _fact = new List() { 1 };\n static void B(long n) { if (n >= _fact.Count) for (int i = _fact.Count; i <= n; ++i) _fact.Add(_fact[i - 1] * i); }\n static public Mod Comb(long n, long k) { B(n); if (n == 0 && k == 0) return 1; if (n < k || n < 0) return 0; return _fact[(int)n] / _fact[(int)(n - k)] / _fact[(int)k]; }\n static public Mod Perm(long n, long k) { B(n); if (n == 0 && k == 0) return 1; if (n < k || n < 0) return 0; return _fact[(int)n] / _fact[(int)(n - k)]; }\n }\n class Tree\n {\n long N; int l; List[] p; int[] d; long[][] pr; long r; Tuple[] e; Tuple[] b; bool lca; bool euler; bool bfs;\n public Tree(List[] p_, long r_) { N = p_.Length; p = p_; r = r_; lca = false; euler = false; }\n public Tuple[] BFSRoot() { if (!bfs) { var nb = new List>(); var q = new Queue(); var d = new bool[N]; nb.Add(Tuple.Create(r, -1L)); d[r] = true; q.Enqueue(r); while (q.Count > 0) { var w = q.Dequeue(); foreach (var i in p[w]) { if (d[i]) continue; d[i] = true; q.Enqueue(i); nb.Add(Tuple.Create(i, w)); } } b = nb.ToArray(); bfs = true; } return b; }\n public Tuple[] BFSLeaf() => BFSRoot().Reverse().ToArray();\n public Tuple[] Euler() { if (!euler) { var ne = new List>(); var s = new Stack>(); var d = new bool[N]; d[r] = true; s.Push(Tuple.Create(r, -1L)); while (s.Count > 0) { var w = s.Peek(); var ad = true; foreach (var i in p[w.Item1]) { if (d[i]) continue; d[i] = true; ad = false; s.Push(Tuple.Create(i, w.Item1)); } if (!ad || p[w.Item1].Count == 1) ne.Add(Tuple.Create(w.Item1, w.Item2, 1)); if (ad) { s.Pop(); ne.Add(Tuple.Create(w.Item1, w.Item2, -1)); } } e = ne.ToArray(); euler = true; } return e; }\n public long LCA(long u, long v) { if (!lca) { l = 0; while (N > (1 << l)) l++; d = new int[N]; pr = Repeat(0, l).Select(_ => new long[N]).ToArray(); d[r] = 0; pr[0][r] = -1; var q = new Stack(); q.Push(r); while (q.Count > 0) { var w = q.Pop(); foreach (var i in p[w]) { if (i == pr[0][w]) continue; q.Push(i); d[i] = d[w] + 1; pr[0][i] = w; } } for (var k = 0; k + 1 < l; k++) for (var w = 0; w < N; w++) if (pr[k][w] < 0) pr[k + 1][w] = -1; else pr[k + 1][w] = pr[k][pr[k][w]]; lca = true; } if (d[u] > d[v]) { var t = u; u = v; v = t; } for (var k = 0; k < l; k++) if ((((d[v] - d[u]) >> k) & 1) != 0) v = pr[k][v]; if (u == v) return u; for (var k = l - 1; k >= 0; k--) if (pr[k][u] != pr[k][v]) { u = pr[k][u]; v = pr[k][v]; } return pr[0][u]; }\n }\n class BT where T : IComparable\n {\n class Node { public Node l; public Node r; public T v; public bool b; public int c; }\n Comparison c; Node r; bool ch; T lm;\n public BT(Comparison _c) { c = _c; }\n public BT() : this((x, y) => x.CompareTo(y)) { }\n bool R(Node n) => n != null && !n.b;\n bool B(Node n) => n != null && n.b;\n long C(Node n) => n?.c ?? 0;\n Node RtL(Node n) { Node m = n.r, t = m.l; m.l = n; n.r = t; n.c -= m.c - (t?.c ?? 0); m.c += n.c - (t?.c ?? 0); return m; }\n Node RtR(Node n) { Node m = n.l, t = m.r; m.r = n; n.l = t; n.c -= m.c - (t?.c ?? 0); m.c += n.c - (t?.c ?? 0); return m; }\n Node RtLR(Node n) { n.l = RtL(n.l); return RtR(n); }\n Node RtRL(Node n) { n.r = RtR(n.r); return RtL(n); }\n public void Add(T x) { r = A(r, x); r.b = true; }\n Node A(Node n, T x) { if (n == null) { ch = true; return new Node() { v = x, c = 1 }; } if (c(x, n.v) < 0) n.l = A(n.l, x); else n.r = A(n.r, x); n.c++; return Bl(n); }\n Node Bl(Node n) { if (!ch) return n; if (!B(n)) return n; if (R(n.l) && R(n.l.l)) { n = RtR(n); n.l.b = true; } else if (R(n.l) && R(n.l.r)) { n = RtLR(n); n.l.b = true; } else if (R(n.r) && R(n.r.l)) { n = RtRL(n); n.r.b = true; } else if (R(n.r) && R(n.r.r)) { n = RtL(n); n.r.b = true; } else ch = false; return n; }\n public void Remove(T x) { r = Rm(r, x); if (r != null) r.b = true; }\n Node Rm(Node n, T x) { if (n == null) { ch = false; return n; } n.c--; var r = c(x, n.v); if (r < 0) { n.l = Rm(n.l, x); return BlL(n); } if (r > 0) { n.r = Rm(n.r, x); return BlR(n); } if (n.l == null) { ch = n.b; return n.r; } n.l = RmM(n.l); n.v = lm; return BlL(n); }\n Node RmM(Node n) { n.c--; if (n.r != null) { n.r = RmM(n.r); return BlR(n); } lm = n.v; ch = n.b; return n.l; }\n Node BlL(Node n) { if (!ch) return n; if (B(n.r) && R(n.r.l)) { var b = n.b; n = RtRL(n); n.b = b; n.l.b = true; ch = false; } else if (B(n.r) && R(n.r.r)) { var b = n.b; n = RtL(n); n.b = b; n.r.b = true; n.l.b = true; ch = false; } else if (B(n.r)) { ch = n.b; n.b = true; n.r.b = false; } else { n = RtL(n); n.b = true; n.l.b = false; n.l = BlL(n.l); ch = false; } return n; }\n Node BlR(Node n) { if (!ch) return n; if (B(n.l) && R(n.l.r)) { var b = n.b; n = RtLR(n); n.b = b; n.r.b = true; ch = false; } else if (B(n.l) && R(n.l.l)) { var b = n.b; n = RtR(n); n.b = b; n.l.b = true; n.r.b = true; ch = false; } else if (B(n.l)) { ch = n.b; n.b = true; n.l.b = false; } else { n = RtR(n); n.b = true; n.r.b = false; n.r = BlR(n.r); ch = false; } return n; }\n public T this[long i] { get { return At(r, i); } }\n T At(Node n, long i) { if (n == null) return default(T); if (n.l == null) if (i == 0) return n.v; else return At(n.r, i - 1); if (n.l.c == i) return n.v; if (n.l.c > i) return At(n.l, i); return At(n.r, i - n.l.c - 1); }\n public bool Have(T x) { var t = FindUpper(x); return t < C(r) && c(At(r, t), x) == 0; }\n public long FindUpper(T x, bool allowSame = true) => allowSame ? FL(r, x) + 1 : FU(r, x);\n long FU(Node n, T x) { if (n == null) return 0; var r = c(x, n.v); if (r < 0) return FU(n.l, x); return C(n.l) + 1 + FU(n.r, x); }\n public long FindLower(T x, bool allowSame = true) { var t = FL(r, x); if (allowSame) return t + 1 < C(r) && c(At(r, t + 1), x) == 0 ? t + 1 : t < 0 ? C(r) : t; return t < 0 ? C(r) : t; }\n long FL(Node n, T x) { if (n == null) return -1; var r = c(x, n.v); if (r > 0) return C(n.l) + 1 + FL(n.r, x); return FL(n.l, x); }\n public T Min() { Node n = r, p = null; while (n != null) { p = n; n = n.l; } return p == null ? default(T) : p.v; }\n public T Max() { Node n = r, p = null; while (n != null) { p = n; n = n.r; } return p == null ? default(T) : p.v; }\n public bool Any() => r != null;\n public long Count() => C(r);\n public IEnumerable List() => L(r);\n IEnumerable L(Node n) { if (n == null) yield break; foreach (var i in L(n.l)) yield return i; yield return n.v; foreach (var i in L(n.r)) yield return i; }\n }\n class Dict : Dictionary\n {\n Func d;\n public Dict(Func _d) { d = _d; }\n public Dict() : this(_ => default(V)) { }\n new public V this[K i] { get { V v; return TryGetValue(i, out v) ? v : base[i] = d(i); } set { base[i] = value; } }\n }\n class Deque\n {\n T[] b; int o, c;\n public int Count;\n public T this[int i] { get { return b[gi(i)]; } set { b[gi(i)] = value; } }\n public Deque(int cap = 16) { b = new T[c = cap]; }\n int gi(int i) { if (i >= c) throw new Exception(); var r = o + i; return r >= c ? r - c : r; }\n public void PushFront(T x) { if (Count == c) e(); if (--o < 0) o += b.Length; b[o] = x; ++Count; }\n public T PopFront() { if (Count-- == 0) throw new Exception(); var r = b[o++]; if (o >= c) o -= c; return r; }\n public T Front => b[o];\n public void PushBack(T x) { if (Count == c) e(); var i = o + Count++; b[i >= c ? i - c : i] = x; }\n public T PopBack() { if (Count == 0) throw new Exception(); return b[gi(--Count)]; }\n public T Back => b[gi(Count - 1)];\n void e() { T[] nb = new T[c << 1]; if (o > c - Count) { var l = b.Length - o; Array.Copy(b, o, nb, 0, l); Array.Copy(b, 0, nb, l, Count - l); } else Array.Copy(b, o, nb, 0, Count); b = nb; o = 0; c <<= 1; }\n public void Insert(int i, T x) { if (i > Count) throw new Exception(); this.PushFront(x); for (int j = 0; j < i; j++) this[j] = this[j + 1]; this[i] = x; }\n public T RemoveAt(int i) { if (i < 0 || i >= Count) throw new Exception(); var r = this[i]; for (int j = i; j > 0; j--) this[j] = this[j - 1]; this.PopFront(); return r; }\n }\n class SegTree\n {\n int n; T ti; Func f; T[] dat;\n public SegTree(long _n, T _ti, Func _f) { n = 1; while (n < _n) n <<= 1; ti = _ti; f = _f; dat = Repeat(ti, n << 1).ToArray(); for (var i = n - 1; i > 0; i--) dat[i] = f(dat[(i << 1) | 0], dat[(i << 1) | 1]); }\n public SegTree(List l, T _ti, Func _f) : this(l.Count, _ti, _f) { for (var i = 0; i < l.Count; i++) dat[n + i] = l[i]; for (var i = n - 1; i > 0; i--) dat[i] = f(dat[(i << 1) | 0], dat[(i << 1) | 1]); }\n public void Update(long i, T v) { dat[i += n] = v; while ((i >>= 1) > 0) dat[i] = f(dat[(i << 1) | 0], dat[(i << 1) | 1]); }\n public T Query(long l, long r) { var vl = ti; var vr = ti; for (long li = n + l, ri = n + r; li < ri; li >>= 1, ri >>= 1) { if ((li & 1) == 1) vl = f(vl, dat[li++]); if ((ri & 1) == 1) vr = f(dat[--ri], vr); } return f(vl, vr); }\n public T this[long idx] { get { return dat[idx + n]; } set { Update(idx, value); } }\n }\n class LazySegTree\n {\n int n, height; T ti; E ei; Func f; Func g; Func h; T[] dat; E[] laz;\n public LazySegTree(long _n, T _ti, E _ei, Func _f, Func _g, Func _h) { n = 1; height = 0; while (n < _n) { n <<= 1; ++height; } ti = _ti; ei = _ei; f = _f; g = _g; h = _h; dat = Repeat(ti, n << 1).ToArray(); laz = Repeat(ei, n << 1).ToArray(); for (var i = n - 1; i > 0; i--) dat[i] = f(dat[(i << 1) | 0], dat[(i << 1) | 1]); }\n public LazySegTree(List l, T _ti, E _ei, Func _f, Func _g, Func _h) : this(l.Count, _ti, _ei, _f, _g, _h) { for (var i = 0; i < l.Count; i++) dat[n + i] = l[i]; for (var i = n - 1; i > 0; i--) dat[i] = f(dat[(i << 1) | 0], dat[(i << 1) | 1]); }\n T Reflect(long i) => laz[i].Equals(ei) ? dat[i] : g(dat[i], laz[i]);\n void Eval(long i) { if (laz[i].Equals(ei)) return; laz[(i << 1) | 0] = h(laz[(i << 1) | 0], laz[i]); laz[(i << 1) | 1] = h(laz[(i << 1) | 1], laz[i]); dat[i] = Reflect(i); laz[i] = ei; }\n void Thrust(long i) { for (var j = height; j > 0; j--) Eval(i >> j); }\n void Recalc(long i) { while ((i >>= 1) > 0) dat[i] = f(Reflect((i << 1) | 0), Reflect((i << 1) | 1)); }\n public void Update(long l, long r, E v) { Thrust(l += n); Thrust(r += n - 1); for (long li = l, ri = r + 1; li < ri; li >>= 1, ri >>= 1) { if ((li & 1) == 1) { laz[li] = h(laz[li], v); ++li; } if ((ri & 1) == 1) { --ri; laz[ri] = h(laz[ri], v); } } Recalc(l); Recalc(r); }\n public T Query(long l, long r) { Thrust(l += n); Thrust(r += n - 1); var vl = ti; var vr = ti; for (long li = l, ri = r + 1; li < ri; li >>= 1, ri >>= 1) { if ((li & 1) == 1) vl = f(vl, Reflect(li++)); if ((ri & 1) == 1) vr = f(Reflect(--ri), vr); } return f(vl, vr); }\n public T this[long idx] { get { Thrust(idx += n); return dat[idx] = Reflect(idx); } set { Thrust(idx += n); dat[idx] = value; laz[idx] = ei; Recalc(idx); } }\n }\n class SlidingWindowAggregation\n {\n T[][] l; T[][] a; int[] n; Func f;\n public SlidingWindowAggregation(IEnumerable ary, Func _f) { l = new T[2][]; a = new T[2][]; n = new int[2]; f = _f; l[0] = new T[16]; a[0] = new T[16]; n[0] = 0; if (ary.Any()) { var t = ary.ToArray(); n[1] = t.Length; l[1] = new T[n[1]]; a[1] = new T[n[1]]; for (var i = 0; i < l[1].Length; i++) { l[1][i] = t[i]; if (i == 0) a[1][i] = t[i]; else a[1][i] = this.f(a[1][i - 1], t[i]); } } else { l[1] = new T[16]; a[1] = new T[16]; n[1] = 0; } }\n public SlidingWindowAggregation(Func f) : this(new T[0], f) { }\n public int Count => n[0] + n[1];\n void Push(int la, T v) { if (l[la].Length == n[la]) { var nar = new T[n[la] * 2]; var nag = new T[n[la] * 2]; Array.Copy(l[la], nar, n[la]); Array.Copy(a[la], nag, n[la]); l[la] = nar; a[la] = nag; } if (n[la] == 0) a[la][0] = v; else a[la][n[la]] = la == 0 ? f(v, a[la][n[la] - 1]) : f(a[la][n[la] - 1], v); l[la][n[la]++] = v; }\n public void PushBack(T val) => Push(1, val);\n public void PushFront(T val) => Push(0, val);\n public T Pop(int la) { var lb = 1 - la; if (n[la] == 0) { if (n[lb] == 0) throw new Exception(); var m = (n[lb] - 1) / 2; if (l[la].Length <= m) { l[la] = new T[m + 1]; a[la] = new T[m + 1]; } n[la] = 0; for (var i = m; i >= 0; i--) { if (n[la] == 0) a[la][n[la]] = l[lb][i]; else a[la][n[la]] = la == 0 ? f(l[lb][i], a[la][n[la] - 1]) : f(a[la][n[la] - 1], l[lb][i]); l[la][n[la]++] = l[lb][i]; } for (var i = m + 1; i < n[lb]; i++) { var j = i - m - 1; if (j == 0) a[lb][j] = l[lb][i]; else a[lb][j] = la == 0 ? f(l[lb][i], a[lb][j - 1]) : f(a[lb][j - 1], l[lb][i]); l[lb][j] = l[lb][i]; } n[lb] -= n[la]; } return l[la][--n[la]]; }\n public T PopBack() => Pop(1);\n public T PopFront() => Pop(0);\n public T Aggregate() { if (n[0] == 0 && n[1] == 0) throw new Exception(); else if (n[1] == 0) return a[0][n[0] - 1]; else if (n[0] == 0) return a[1][n[1] - 1]; else return f(a[0][n[0] - 1], a[1][n[1] - 1]); }\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "math", "bitmasks"], "code_uid": "e03cbe5949c0b6324240aa0f34a3bc7b", "src_uid": "9e86d87ce5a75c6a982894af84eb4ba8", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\n\nclass TEST{\n\tstatic void Main(){\n\t\tSol mySol =new Sol();\n\t\tmySol.Solve();\n\t}\n}\n\nclass Sol{\n\tpublic void Solve(){\n\t\tfor(int i=1;;i++){\n\t\t\tif(N - i * P <= 0){\n\t\t\t\tConsole.WriteLine(-1);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t\n\t\t\tint cnt = 0;\n\t\t\tlong v = N - i * P;\n\t\t\tif(v < i){\n\t\t\t\tConsole.WriteLine(-1);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tfor(int j=0;j<60;j++){\n\t\t\t\tif(((v >> j) & 1) == 1) cnt++;\n\t\t\t}\n\t\t\tif(cnt <= i){\n\t\t\t\tConsole.WriteLine(i);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t\n\t\t}\n\t\t\n\t}\n\tlong N,P;\n\tpublic Sol(){\n\t\tvar d = ria();\n\t\tN = d[0]; P = d[1];\n\t}\n\n\tstatic String rs(){return Console.ReadLine();}\n\tstatic int ri(){return int.Parse(Console.ReadLine());}\n\tstatic long rl(){return long.Parse(Console.ReadLine());}\n\tstatic double rd(){return double.Parse(Console.ReadLine());}\n\tstatic String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}\n\tstatic int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}\n\tstatic long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}\n\tstatic double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}\n}\n", "lang_cluster": "C#", "tags": ["brute force", "math", "bitmasks"], "code_uid": "eaee4e2f9440fac4203dd152e161ef3e", "src_uid": "9e86d87ce5a75c6a982894af84eb4ba8", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections;\nusing System.Collections.Generic;\nusing System.Collections.Specialized;\nusing System.Text;\nusing System.Text.RegularExpressions;\nusing System.IO;\n\npublic class SyllableSorting\n{\n\n public static int gcd(int a, int b)\n {\n if (b == 0) return a;\n else return a >= b ? gcd(b,a%b):gcd(b,a);\n }\n public static void Main()\n {\n //Console.SetIn(new StreamReader(\"C:\\\\Users\\\\saib\\\\Desktop\\\\abc.txt\"));\n\n string str = Console.ReadLine();\n string[] values = str.Split(' ');\n int a = int.Parse(values[0]);\n int b = int.Parse(values[1]);\n int c = int.Parse(values[2]);\n int d = int.Parse(values[3]);\n if (b * c == a * d)\n {\n Console.WriteLine(\"0/1\");\n }\n else if (b * c > a * d)\n {\n int num = b * c - a * d;\n int den = b * c;\n int temp = gcd(num,den);\n num = num / temp;\n den = den / temp;\n Console.WriteLine(num+\"/\"+den);\n }\n else\n {\n int num = a * d - b*c;\n int den = a*d;\n int temp = gcd(num, den);\n num = num / temp;\n den = den / temp;\n Console.WriteLine(num + \"/\" + den);\n }\n\n //Console.SetIn(new StreamReader(Console.OpenStandardInput()));\n Console.ReadLine();\n } \n}", "lang_cluster": "C#", "tags": ["math", "greedy", "number theory"], "code_uid": "65fa6940126cb0c4221094d8c1239c75", "src_uid": "b0f435fc2f7334aee0d07524bc37cb1e", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace Routine_Problem\n{\n class Program\n {\n static void Main(string[] args)\n {\n string[] str = Console.ReadLine().Split();\n int a, b, c, d;\n a = int.Parse(str[0]);\n b = int.Parse(str[1]);\n c = int.Parse(str[2]);\n d = int.Parse(str[3]);\n a = int.Parse(str[0]);\n if (a == b && c==d )\n {\n Console.WriteLine(0 + \"/\" + 1);return;\n }\n int ad = a * d;\n int bc = b * c;\n int up = Math.Abs(ad - bc);\n int dow = Math.Max(ad,bc);\n int G = GCD(up, dow);\n if (G==-1)\n {\n Console.WriteLine(up.ToString() + \"/\" + dow.ToString());\n }\n else\n Console.WriteLine((up/G).ToString() + \"/\" + dow/G);\n \n }\n public static int GCD(int a, int b)\n {\n double u = Math.Min(a, b);\n double d = Math.Max(a,b);\n int it = (int)u;\n while (true)\n {\n if ((u / it) == Math.Ceiling(u / it * 1.0) && (d / it) == Math.Ceiling(d / it * 1.0))\n {\n return it;\n }\n it--;\n }\n return -1;\n \n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "greedy", "number theory"], "code_uid": "3f29c57df6c2d3fa837963c41d9f2953", "src_uid": "b0f435fc2f7334aee0d07524bc37cb1e", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace _626A\n{\n class Program\n {\n static void Main(string[] args)\n {\n int n = int.Parse(Console.ReadLine());\n\n string commands = Console.ReadLine();\n\n int result = ContigouseCiclesSubstrings(commands);\n\n Console.WriteLine(result);\n\n Console.ReadLine();\n }\n\n public static int ContigouseCiclesSubstrings(string commands)\n {\n int result = 0;\n Dictionary dic = new Dictionary(commands.Length + 1);\n dic.Add(0, 1);\n\n int x = 0;\n int y = 0;\n int key;\n\n foreach (var command in commands)\n {\n switch (command)\n {\n case 'U': y++;\n break;\n case 'R': x++;\n break;\n case 'D': y--;\n break;\n case 'L': x--;\n break;\n default: throw new ArgumentException(\"Grong command\");\n }\n key = GetUniqueKey(x, y);\n\n if (dic.ContainsKey(key))\n {\n result += dic[key];\n dic[key]++;\n }\n else\n dic.Add(key, 1);\n }\n\n return result;\n }\n\n private static int GetUniqueKey(int x, int y)\n { \n //the hash function is putting the x;y as a single number in 201 base\n return x * 201 + y;\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "implementation"], "code_uid": "f74c43383facae6b035dcb53376e60bf", "src_uid": "7bd5521531950e2de9a7b0904353184d", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.IO;\n\nnamespace ConsoleApplication1\n{\n class EVC1\n {\n static void Main(string[] args)\n {\n //Console.SetIn(new StreamReader(@\"D:\\Sergey\\Code\\1.txt\"));\n\n string strT = Console.ReadLine();\n int n = int.Parse(strT);\n\n strT = Console.ReadLine();\n //string[] strParams = strT.Split(new char[] { ' ' });\n\n ulong r = 0;\n int[] a = new int[]{0,0,0,0};\n for (int i = 0; i < n; i++)\n {\n for (int j = i + 1; j < n; j++)\n {\n a[0] = 0;\n a[1] = 0;\n a[2] = 0;\n a[3] = 0;\n for (int k = i; k <= j; k++)\n {\n if (strT[k] == 'U')\n a[0]++;\n else if (strT[k] == 'R')\n a[1]++;\n else if (strT[k] == 'L')\n a[2]++;\n else //if (strT[k] == 'D')\n a[3]++; \n }\n\n if (a[0] == a[3] && a[1] == a[2])\n r++;\n } \n }\n\n Console.WriteLine(r.ToString());\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "implementation"], "code_uid": "f4646f3f321fc6c1b4903b4a78dacee7", "src_uid": "7bd5521531950e2de9a7b0904353184d", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\nclass Program\n{\n static void Main()\n {\n var n = int.Parse(Console.ReadLine());\n var min = new int[3];\n var max = new int[3];\n for (int i = 0; i < 3; i++)\n {\n var b = Console.ReadLine().Split().Select(int.Parse).ToArray();\n min[i] = b[0];\n max[i] = b[1];\n }\n int d1 = min[0], d2 = min[1], d3 = min[2];\n n -= d1 + d2 + d3;\n while (n > 0)\n {\n if (d1 < max[0])\n {\n d1++;\n n--;\n }\n else if (d2= max1 - min1)\n k1 = max1;\n else\n k1 = min1 + n - min1 - min2 - min3;\n n = n - k1;\n //-----------\n if (n - min2 - min3 >= max2 - min2)\n k2 = max2;\n else\n k2 = min2 + n- min2 - min3;\n //-----------\n n = n - k2;\n if (n - min3 >= max3 - min3)\n k3 = max3;\n else\n k3 = n;\n\n Console.WriteLine(k1.ToString() + ' ' + k2.ToString() + ' ' + k3.ToString());\n // Console.ReadKey();\n }\n\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "greedy", "implementation"], "code_uid": "9dfef82d4763af6cd9d28a51ced46665", "src_uid": "3cd092b6507079518cf206deab21cf97", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace R._176.Div2.A\n{\n class Program\n {\n static void Main(string[] args)\n {\n char[,] array = new char[4, 4];\n for (int i = 0; i < 4; i++) \n {\n string inputLine = Console.ReadLine();\n for (int j = 0; j < 4; j++)\n {\n array[i, j] = inputLine[j];\n }\n }\n\n Dictionary dic = new Dictionary();\n dic['#'] = 0;\n dic['.'] = 0;\n\n for (int i = 0; i < 3; i++)\n { \n for (int j = 0; j < 3; j++)\n {\n dic[array[i,j]] ++ ;\n dic[array[i, j + 1]]++;\n dic[array[i + 1, j ]]++;\n dic[array[i + 1, j +1]]++;\n if (dic['#'] >= 3 || dic['.'] >= 3)\n {\n Console.WriteLine(\"YES\");\n return;\n }\n dic['#'] = 0;\n dic['.'] = 0;\n }\n }\n Console.WriteLine(\"NO\");\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "implementation"], "code_uid": "0c40a29e9c9378247ed4db59fb1efb59", "src_uid": "01b145e798bbdf0ca2ecc383676d79f3", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace ConsoleApplication2\n{\n class Program\n {\n static void Main(string[] args)\n {\n bool[,] array = new bool[4, 4];\n for (int i = 0; i < 4; i++ )\n {\n string s = Console.ReadLine();\n for (int j = 0; j < 4; j++ )\n {\n if (s[j] == '.')\n {\n array[i, j] = false;\n }\n else \n {\n array[i, j] = true;\n }\n }\n }\n\n\n for (int i = 0; i < 4; i++)\n {\n for (int j = 0; j < 4; j++)\n {\n if (i + 1 < 4 && j + 1 < 4 && array[i + 1, j] && array[i + 1, j + 1] && array[i, j + 1])\n {\n Console.WriteLine(\"YES\");\n return;\n }\n\n if (i + 1 < 4 && j - 1 >= 0 && array[i + 1, j] && array[i + 1, j - 1] && array[i, j - 1])\n {\n Console.WriteLine(\"YES\");\n return;\n }\n\n if (i + 1 < 4 && j + 1 < 4 && !array[i + 1, j] && !array[i + 1, j + 1] && !array[i, j + 1])\n {\n Console.WriteLine(\"YES\");\n return;\n }\n\n if (i + 1 < 4 && j - 1 >= 0 && !array[i + 1, j] && !array[i + 1, j - 1] && !array[i, j - 1])\n {\n Console.WriteLine(\"YES\");\n return;\n }\n }\n }\n\n Console.WriteLine(\"NO\");\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "implementation"], "code_uid": "23c68e87ae19b2f267d2b02b5ce65e49", "src_uid": "01b145e798bbdf0ca2ecc383676d79f3", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.IO;\nusing System.Linq;\nusing System.Text;\n\nnamespace Vasyas_Function\n{\n internal class Program\n {\n private static readonly StreamReader reader = new StreamReader(Console.OpenStandardInput(1024*10), Encoding.ASCII, false, 1024*10);\n private static readonly StreamWriter writer = new StreamWriter(Console.OpenStandardOutput(1024*10), Encoding.ASCII, 1024*10);\n\n private static IEnumerable Gi()\n {\n yield return 2;\n for (int i = 3;; i += 2)\n {\n yield return i;\n }\n }\n\n private static void Main(string[] args)\n {\n long x = Next();\n long y = Next();\n\n var list = new List();\n foreach (long i in Gi())\n {\n if (i*i > x)\n break;\n\n while (x%i == 0)\n {\n list.Add(i);\n x /= i;\n }\n }\n if (x != 1)\n list.Add(x);\n\n long count = list.Count == 0 ? y : 0;\n\n long yy = y;\n long d = 1;\n while (yy > 0 && list.Count > 0)\n {\n long min = list.Select(l => y%l).Concat(new[] {y}).Min();\n\n count += min;\n y -= min;\n yy -= d*min;\n\n for (int i = 0; i < list.Count; i++)\n {\n if (y%list[i] == 0)\n {\n y /= list[i];\n d *= list[i];\n list.RemoveAt(i);\n i--;\n }\n }\n\n if (list.Count == 0)\n {\n count += yy/d;\n }\n }\n\n writer.WriteLine(count);\n writer.Flush();\n }\n\n private static long Next()\n {\n int c;\n long res = 0;\n do\n {\n c = reader.Read();\n if (c == -1)\n return res;\n } while (c < '0' || c > '9');\n res = c - '0';\n while (true)\n {\n c = reader.Read();\n if (c < '0' || c > '9')\n return res;\n res *= 10;\n res += c - '0';\n }\n }\n }\n}", "lang_cluster": "C#", "tags": ["math", "implementation", "binary search"], "code_uid": "4bc2fbbc081ebfe55b34424fcc802f47", "src_uid": "ea92cd905e9725e7fcb87b9ed4f64c2e", "difficulty": 2100.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.IO;\nusing System.Runtime.CompilerServices;\nusing System.Text;\nusing System.Diagnostics;\nusing System.Numerics;\nusing static System.Console;\nusing static System.Convert;\nusing static System.Math;\nusing static Template;\nusing Pi = Pair;\n\nclass Solver\n{\n public void Solve(Scanner sc)\n {\n long X, Y;\n sc.Make(out X, out Y);\n var div = new List();\n for(long i=1;i*i<=X;i++)\n if (X % i == 0)\n {\n if (i != 1)\n div.Add(i);\n if (i * i != X) div.Add(X / i);\n }\n var now = GCD(X, Y);\n Y /= now;\n X /= now;\n var res = 0L;\n while (Y != 0)\n {\n var max = 0L;\n foreach (var d in div)\n {\n var y = Y / d * d;\n if (GCD(y, X) == 1) continue;\n chmax(ref max, y);\n }\n res += Y - max;\n Y = max;\n var v = GCD(Y, X);\n now *= v;\n X /= v;\n Y /= v;\n }\n Console.WriteLine(res);\n }\n #region GCD\n public static int LCM(int num1, int num2)\n => num1 / GCD(num1, num2) * num2;\n\n public static long LCM(long num1, long num2)\n => num1 / GCD(num1, num2) * num2;\n\n public static int GCD(int num1, int num2)\n => num1 < num2 ? GCD(num2, num1) :\n num2 > 0 ? GCD(num2, num1 % num2) : num1;\n\n public static long GCD(long num1, long num2)\n => num1 < num2 ? GCD(num2, num1) :\n num2 > 0 ? GCD(num2, num1 % num2) : num1;\n #endregion\n}\n\n#region Template\npublic static class Template\n{\n static void Main(string[] args)\n {\n Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });\n new Solver().Solve(new Scanner());\n Console.Out.Flush();\n }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static bool chmin(ref T a, T b) where T : IComparable { if (a.CompareTo(b) > 0) { a = b; return true; } return false; }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static bool chmax(ref T a, T b) where T : IComparable { if (a.CompareTo(b) < 0) { a = b; return true; } return false; }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static void swap(ref T a, ref T b) { var t = b; b = a; a = t; }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static void swap(this IList A, int i, int j) { var t = A[i]; A[i] = A[j]; A[j] = t; }\n public static T[] Create(int n, Func f) { var rt = new T[n]; for (var i = 0; i < rt.Length; ++i) rt[i] = f(); return rt; }\n public static T[] Create(int n, Func f) { var rt = new T[n]; for (var i = 0; i < rt.Length; ++i) rt[i] = f(i); return rt; }\n public static IEnumerable Shuffle(this IEnumerable A) => A.OrderBy(v => Guid.NewGuid());\n public static int CompareTo(this T[] A, T[] B, Comparison cmp = null) { cmp = cmp ?? Comparer.Default.Compare; for (var i = 0; i < Min(A.Length, B.Length); i++) { int c = cmp(A[i], B[i]); if (c > 0) return 1; else if (c < 0) return -1; } if (A.Length == B.Length) return 0; if (A.Length > B.Length) return 1; else return -1; }\n public static int MaxElement(this IList A, Comparison cmp = null) { cmp = cmp ?? Comparer.Default.Compare; T max = A[0]; int rt = 0; for (int i = 1; i < A.Count; i++) if (cmp(max, A[i]) < 0) { max = A[i]; rt = i; } return rt; }\n public static T PopBack(this List A) { var v = A[A.Count - 1]; A.RemoveAt(A.Count - 1); return v; }\n public static void Fail(T s) { Console.WriteLine(s); Console.Out.Close(); Environment.Exit(0); }\n}\npublic class Scanner\n{\n public string Str => Console.ReadLine().Trim();\n public int Int => int.Parse(Str);\n public long Long => long.Parse(Str);\n public double Double => double.Parse(Str);\n public int[] ArrInt => Str.Split(' ').Select(int.Parse).ToArray();\n public long[] ArrLong => Str.Split(' ').Select(long.Parse).ToArray();\n public char[][] Grid(int n) => Create(n, () => Str.ToCharArray());\n public int[] ArrInt1D(int n) => Create(n, () => Int);\n public long[] ArrLong1D(int n) => Create(n, () => Long);\n public int[][] ArrInt2D(int n) => Create(n, () => ArrInt);\n public long[][] ArrLong2D(int n) => Create(n, () => ArrLong);\n private Queue q = new Queue();\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public T Next() { if (q.Count == 0) foreach (var item in Str.Split(' ')) q.Enqueue(item); return (T)Convert.ChangeType(q.Dequeue(), typeof(T)); }\n public void Make(out T1 v1) => v1 = Next();\n public void Make(out T1 v1, out T2 v2) { v1 = Next(); v2 = Next(); }\n public void Make(out T1 v1, out T2 v2, out T3 v3) { Make(out v1, out v2); v3 = Next(); }\n public void Make(out T1 v1, out T2 v2, out T3 v3, out T4 v4) { Make(out v1, out v2, out v3); v4 = Next(); }\n public void Make(out T1 v1, out T2 v2, out T3 v3, out T4 v4, out T5 v5) { Make(out v1, out v2, out v3, out v4); v5 = Next(); }\n public void Make(out T1 v1, out T2 v2, out T3 v3, out T4 v4, out T5 v5, out T6 v6) { Make(out v1, out v2, out v3, out v4, out v5); v6 = Next(); }\n public void Make(out T1 v1, out T2 v2, out T3 v3, out T4 v4, out T5 v5, out T6 v6, out T7 v7) { Make(out v1, out v2, out v3, out v4, out v5, out v6); v7 = Next(); }\n //public (T1, T2) Make() { Make(out T1 v1, out T2 v2); return (v1, v2); }\n //public (T1, T2, T3) Make() { Make(out T1 v1, out T2 v2, out T3 v3); return (v1, v2, v3); }\n //public (T1, T2, T3, T4) Make() { Make(out T1 v1, out T2 v2, out T3 v3, out T4 v4); return (v1, v2, v3, v4); }\n}\npublic class Pair : IComparable>\n{\n public T1 v1;\n public T2 v2;\n public Pair() { }\n public Pair(T1 v1, T2 v2)\n { this.v1 = v1; this.v2 = v2; }\n\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public int CompareTo(Pair p)\n {\n var c = Comparer.Default.Compare(v1, p.v1);\n if (c == 0)\n c = Comparer.Default.Compare(v2, p.v2);\n return c;\n }\n public override string ToString() => $\"{v1.ToString()} {v2.ToString()}\";\n public void Deconstruct(out T1 a, out T2 b) { a = v1; b = v2; }\n}\n\npublic class Pair : Pair, IComparable>\n{\n public T3 v3;\n public Pair() : base() { }\n public Pair(T1 v1, T2 v2, T3 v3) : base(v1, v2)\n { this.v3 = v3; }\n\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public int CompareTo(Pair p)\n {\n var c = base.CompareTo(p);\n if (c == 0)\n c = Comparer.Default.Compare(v3, p.v3);\n return c;\n }\n public override string ToString() => $\"{base.ToString()} {v3.ToString()}\";\n public void Deconstruct(out T1 a, out T2 b, out T3 c) { Deconstruct(out a, out b); c = v3; }\n}\n#endregion\n", "lang_cluster": "C#", "tags": ["math", "implementation", "binary search"], "code_uid": "a15e1a53839ce3d5490f1ac0c5909487", "src_uid": "ea92cd905e9725e7fcb87b9ed4f64c2e", "difficulty": 2100.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.IO;\nusing static System.Console;\nusing static System.Convert;\nusing static System.Math;\n//using Debug;\n//using static System.Globalization.CultureInfo;\nusing System.Text;\nclass Program\n{\n static void Main(string[] args)\n {\n var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };\n Console.SetOut(sw);\n Solve();\n Console.Out.Flush();\n //WriteLine(Solve());\n }\n static void Solve()\n {\n var num = Input.num;\n var str = new[] { \"A\", \"A\", \"B\", \"A\" };\n var a = new[] { 1, 0, 1, 2 };\n WriteLine($\"{a[num%4]} {str[num % 4]}\");\n }\n}\n\npublic class Input\n{\n public static string read => ReadLine().Trim();\n public static int[] ar => read.Split(' ').Select(int.Parse).ToArray();\n public static int num => ToInt32(read);\n public static long[] arL => read.Split(' ').Select(long.Parse).ToArray();\n public static long numL => ToInt64(read);\n public static T[] create(int n, Func f)\n => Enumerable.Repeat(0, n).Select(f).ToArray();\n public static char[][] gred(int h)\n => create(h, _ => read.ToCharArray());\n public static int[] ar1D(int n)\n => create(n, _ => num);\n public static long[] arL1D(int n)\n => create(n, _ => numL);\n public static string[] strs(int n)\n => create(n, _ => read);\n public static int[][] ar2D(int n)\n => create(n, _ => ar);\n public static long[][] arL2D(int n)\n => create(n, _ => arL);\n public static List[] edge(int n)\n => create(n, _ => new List());\n public static T GetValue(string g)\n {\n var t = typeof(T);\n if (t == typeof(int))\n return (T)(object)int.Parse(g);\n if (t == typeof(long))\n return (T)(object)long.Parse(g);\n if (t == typeof(string))\n return (T)(object)g;\n if (t == typeof(char))\n return (T)(object)char.Parse(g);\n if (t == typeof(double))\n return (T)(object)double.Parse(g);\n if (t == typeof(bool))\n return (T)(object)bool.Parse(g);\n return default(T);\n }\n public static void Make(out T1 v1, out T2 v2)\n {\n v1 = Next();\n v2 = Next();\n }\n public static void Make(out T1 v1, out T2 v2, out T3 v3)\n {\n Make(out v1, out v2);\n v3 = Next();\n }\n public static void Make(out T1 v1, out T2 v2, out T3 v3, out T4 v4)\n {\n Make(out v1, out v2, out v3);\n v4 = Next();\n }\n public static void Make(out T1 v1, out T2 v2, out T3 v3, out T4 v4, out T5 v5)\n {\n Make(out v1, out v2, out v3, out v4);\n v5 = Next();\n }\n public static void Make(out T1 v1, out T2 v2, out T3 v3, out T4 v4, out T5 v5, out T6 v6)\n {\n Make(out v1, out v2, out v3, out v4, out v5);\n v6 = Next();\n }\n private static Queue sc = new Queue();\n public static T Next(){ if (sc.Count == 0) foreach (var item in read.Split(' ')) sc.Enqueue(item);return GetValue(sc.Dequeue()); }\n public const long Inf = (long)1e18;\n public const double eps = 1e-6;\n public const string Alfa = \"abcdefghijklmnopqrstuvwxyz\";\n public const int MOD = 1000000007;\n}\n", "lang_cluster": "C#", "tags": ["brute force"], "code_uid": "b7a2b6ef31352a29cec0c7b3301e6c38", "src_uid": "488e809bd0c55531b0b47f577996627e", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\n\nnamespace Task_01\n{\n class Program\n {\n static void Main(string[] args)\n {\n var n = int.Parse(Console.ReadLine()) % 4;\n switch (n)\n {\n case 0: Console.WriteLine(\"1 A\"); break;\n case 1: Console.WriteLine(\"0 A\"); break;\n case 2: Console.WriteLine(\"1 B\"); break;\n case 3: Console.WriteLine(\"2 A\"); break;\n }\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force"], "code_uid": "d20fce3343f51b306c36a699284686ea", "src_uid": "488e809bd0c55531b0b47f577996627e", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\n\nnamespace ConsoleApplication\n{\n\tclass Program\n\t{\n\t\tstatic void Main(string[] args)\n\t\t{\n\t\t\tstring str = Console.ReadLine();\n\n\t\t\tif (str != null)\n\t\t\t{\n\t\t\t\tstring[] arr = str.Split(' ');\n\n\t\t\t\tint n = int.Parse(arr[0]);\n\t\t\t\tint a = int.Parse(arr[1]);\n\n\t\t\t\tint result;\n\t\t\t\tif (a % 2 == 0)\n\t\t\t\t{\n\t\t\t\t\tresult = n / 2 - a / 2 + 1;\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tresult = a / 2 + a % 2;\n\t\t\t\t}\n\n\t\t\t\tConsole.Write(result);\n\t\t\t}\n\t\t}\n\t\t\n\t}\n}", "lang_cluster": "C#", "tags": ["math", "constructive algorithms"], "code_uid": "907c21c36cade1c1b00f8d32dc5c1aad", "src_uid": "aa62dcdc47d0abbba7956284c1561de8", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeff using System;\n using System.Collections.Generic;\n using System.Linq;\n using System.Text;\n\nnamespace ConsApp\n{\n class Program\n {\n static void Main(string[] args)\n {\n string s = Console.ReadLine();\n String[] sm = s.Split(' ');\n int n = int.Parse(sm[0]);\n int a = int.Parse(sm[1]);\n int res = 1;\n\n if (a % 2 == 0)\n {\n res += (n / 2) - (a / 2);\n\n }\n else\n {\n res += (a-1) / 2 ;\n\n }\n\n Console.WriteLine(res);\n \n\n\n\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "constructive algorithms"], "code_uid": "87c5008429029e73e84545946af20f94", "src_uid": "aa62dcdc47d0abbba7956284c1561de8", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.IO;\nusing System.Text;\n\nnamespace A_Prank\n{\n internal class Program\n {\n private static readonly StreamReader reader = new StreamReader(Console.OpenStandardInput(1024*10), Encoding.ASCII, false, 1024*10);\n private static readonly StreamWriter writer = new StreamWriter(Console.OpenStandardOutput(1024*10), Encoding.ASCII, 1024*10);\n\n private static void Main(string[] args)\n {\n writer.WriteLine(Solve(args));\n writer.Flush();\n }\n\n private static int Solve(string[] args)\n {\n int n = Next();\n\n var nn = new int[n + 2];\n for (int i = 1; i <= n; i++)\n {\n nn[i] = Next();\n }\n nn[0] = 0;\n nn[n + 1] = 1001;\n\n int ans = 0;\n int cnt = 1;\n\n for (int i = 1; i < nn.Length; i++)\n {\n if (nn[i] == nn[i - 1] + 1)\n {\n cnt++;\n }\n else\n {\n if (cnt >= 3)\n ans = Math.Max(ans, cnt - 2);\n cnt = 1;\n }\n }\n if (cnt >= 3)\n ans = Math.Max(ans, cnt - 2);\n return ans;\n }\n\n private static int Next()\n {\n int c;\n int res = 0;\n do\n {\n c = reader.Read();\n if (c == -1)\n return res;\n } while (c < '0' || c > '9');\n res = c - '0';\n while (true)\n {\n c = reader.Read();\n if (c < '0' || c > '9')\n return res;\n res *= 10;\n res += c - '0';\n }\n }\n }\n}", "lang_cluster": "C#", "tags": ["greedy", "implementation"], "code_uid": "a86b6a3b45f302389256eb039c3abeb1", "src_uid": "858b5e75e21c4cba6d08f3f66be0c198", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\n\nnamespace ConsoleApplication2\n{\n internal class Program\n {\n public static void Main(string[] args)\n {\n var e = Convert.ToInt32(Console.ReadLine());\n var a = Console.ReadLine();\n var numbers = Array.ConvertAll(a.Split(' '), n => Int32.Parse(n));\n var substrings = new List();\n for (int i = 0, step = 1, count = 0; e != 1 && i < e;)\n {\n if (i + step < e && numbers[i + step] == numbers[i] + step) step++;\n else\n {\n if (step >= 2)\n {\n if (numbers[i] == 1 || numbers[i + step - 1] == 1000) count += step - 1;\n else\n {\n count += step - 2;\n }\n substrings.Add(count);\n count = 0;\n step = 1;\n }\n i += step;\n }\n }\n\n if (substrings.Count == 0) Console.Write(0);\n else Console.WriteLine(substrings.Max());\n }\n }\n}", "lang_cluster": "C#", "tags": ["greedy", "implementation"], "code_uid": "35d1c6b296158d69897a669e4ff3336b", "src_uid": "858b5e75e21c4cba6d08f3f66be0c198", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\n\nnamespace code\n{\n class Program\n {\n static void Main(string[] args)\n {\n int[] arr = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();\n int l = arr[0];\n int d = arr[1];\n double v = arr[2];\n int g = arr[3];\n int r = arr[4];\n double t = (double)d / v;\n double time;\n string str = \"\";\n while (true)\n {\n if (t - g < 0)\n {\n str = String.Format(\"{0:f6}\",l/v);\n str = str.Replace(',', '.');\n Console.WriteLine(str);\n return;\n }\n t = t - g;\n if (t - r < 0)\n {\n time = r - t;\n time += (double)d / v+(l-d)/v;\n str = String.Format(\"{0:f6}\", time);\n str=str.Replace(',', '.');\n Console.WriteLine(str);\n return;\n }\n t -= r;\n\n }\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "043a5cb4f6b0f42c134979bf5243a96b", "src_uid": "e4a4affb439365c843c9f9828d81b42c", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "namespace _29B\n{\n using System;\n\n public class Program\n {\n public static void Main(string[] args)\n {\n double[] paramsTask = Array.ConvertAll(Console.ReadLine().Split(' '), c => double.Parse(c));\n double roadLength = paramsTask[0], trafficLightLength = paramsTask[1], carSpeed = paramsTask[2], greenSpeed = paramsTask[3], redSpeed = paramsTask[4], result = 0, summ = 0, counter = 0;\n\n result = trafficLightLength / carSpeed;\n\n while (true)\n {\n if (summ > result)\n {\n if (counter % 2 == 0)\n {\n result = summ;\n }\n\n break;\n }\n\n if (counter % 2 == 0)\n {\n summ += greenSpeed;\n }\n else\n {\n summ += redSpeed;\n }\n\n counter++;\n }\n\n result += (roadLength - trafficLightLength) / carSpeed;\n\n Console.WriteLine(Math.Round(result, 8).ToString().Replace(\",\", \".\"));\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "610b6e763b910701443b07172dea575e", "src_uid": "e4a4affb439365c843c9f9828d81b42c", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace ConsoleApp59\n{\n class Program\n {\n static void Main(string[] args)\n {\n int n = int.Parse(Console.ReadLine()),x = 0,res = 0;\n string s = Console.ReadLine();\n int[] a = new int[n];\n for (int i = 0; i < n; i++)\n {\n a[i] = int.Parse(s.Split(' ')[i]);\n if (x == 0 && a[i] != 0)\n x = i;\n }\n for(int i = x; i < n; i++)\n {\n if(x != 0)\n res += a[i]*(4*i);\n }\n Console.WriteLine(res); \n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "implementation"], "code_uid": "26b2d2a52c212e3feca94eb3fa13c12c", "src_uid": "a5002ddf9e792cb4b4685e630f1e1b8f", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "// Problem: 1084A - The Fair Nut and Elevator\n// Author: Gusztav Szmolik\n\nusing System;\n\nclass TheFairNutAndElevator\n {\n static int Main ()\n {\n string[] words = ReadSplitLine (1);\n if (words == null)\n return -1;\n byte n;\n if (!Byte.TryParse (words[0], out n))\n return -1;\n if (n < 1 || n > 100)\n return -1;\n words = ReadSplitLine (n);\n if (words == null)\n return -1;\n byte[] a = new byte[n];\n ushort sumA = 0;\n uint term1 = 0;\n for (byte i = 0; i < n; i++)\n {\n byte ai;\n if (!Byte.TryParse (words[i], out ai))\n return -1;\n if (ai > 100)\n return -1;\n a[i] = ai;\n sumA += ai;\n term1 += Convert.ToUInt32 (i*ai);\n }\n uint ans = 6000000;\n ushort sumSub = sumA;\n uint term2 = 0;\n for (byte i = 0; i < n; i++)\n {\n uint numEU = 4*(term1+term2);\n if (numEU < ans)\n ans = numEU;\n sumSub -= a[i];\n term1 -= sumSub;\n term2 += sumA;\n }\n Console.WriteLine (ans);\n return 0;\n }\n \n static string[] ReadSplitLine (uint numWordNeed)\n {\n string line = Console.ReadLine ();\n if (line == null)\n return null;\n char[] delims = new char[2] {' ', '\\t'};\n string[] words = line.Split (delims,StringSplitOptions.RemoveEmptyEntries);\n return (words.Length == numWordNeed ? words : null);\n } \n }\n", "lang_cluster": "C#", "tags": ["brute force", "implementation"], "code_uid": "3209c7ef755cf017292f4a7ef9be6bfa", "src_uid": "a5002ddf9e792cb4b4685e630f1e1b8f", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\n\nnamespace ProgrammingContest.Codeforces.Round59\n{\n class E\n {\n int[][] dx = new int[][]{\n new int[]{2,4,6},\n new int[]{1,3,5,7},\n new int[]{0,2,4,6,8},\n new int[]{1,3,5,7},\n new int[]{2,4,6}\n };\n\n char[][] cs = new char[5][];\n int[,] id = new int[10, 10];\n List chk = new List();\n\n bool ok(int x, int y)\n {\n return 0 <= y && y < 5 && dx[y].Contains(x);\n }\n\n void proc(int x, int y, int dx, int dy)\n {\n int hash = 0;\n for (; ok(x, y); x += dx, y += dy)\n {\n hash |= 1 << id[x, y];\n chk.Add(hash);\n }\n }\n\n E()\n {\n for (int i = 0; i < 5; i++)\n cs[i] = Console.ReadLine().ToCharArray();\n\n int state = 0;\n for(int y = 0, idx = 0; y < 5; y++)\n for (int i = 0; i < dx[y].Length; i++)\n {\n int x = dx[y][i];\n id[x,y] = idx++;\n if (cs[y][x] == 'O')\n state |= 1 << id[x, y];\n }\n\n for (int y = 0; y < 5; y++)\n for (int i = 0; i < dx[y].Length; i++)\n {\n int x = dx[y][i];\n proc(x, y, 2, 0);\n proc(x, y, 1, 1);\n proc(x, y, -1, 1);\n }\n\n bool[] win = new bool[1<<19];\n for (int i = 1; i < 1 << 19; i++)\n {\n foreach (int hash in chk)\n {\n if ((i & hash) == hash && !win[i ^ hash])\n {\n win[i] = true;\n break;\n }\n }\n }\n\n Console.WriteLine(win[state] ? \"Karlsson\" : \"Lillebror\");\n }\n\n public static void Main()\n {\n new E();\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["dfs and similar", "games", "dp", "bitmasks", "implementation"], "code_uid": "c8ff9308dbe640beae09cbd1b7c779f3", "src_uid": "eaa022cc7846c983a826900dc6dd919f", "difficulty": 2000.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeff#if DEBUG\nusing System.Reflection;\nusing System.Threading.Tasks;\n#endif\n\nusing System;\nusing System.Collections.Generic;\nusing System.IO;\nusing System.Linq;\nusing System.Text;\nusing System.Numerics;\nusing System.Globalization;\n\n#if DEBUG\nusing System.Diagnostics;\n#endif\n\nnamespace _489\u0441\n{\n class Program\n {\n static string _inputFilename = \"input.txt\";\n static string _outputFilename = \"output.txt\";\n static bool _useFileInput = false;\n const string _delim = \"!\";\n\n\n static void Main(string[] args)\n {\n StreamWriter file = null;\n#if DEBUG\n var testNumber = 0;\n var timer = new Stopwatch();\n foreach (var test in GetTests())\n {\n\n timer.Start();\n\n var defaultColor = Console.ForegroundColor;\n Console.ForegroundColor = ConsoleColor.DarkYellow;\n Console.WriteLine($\"\");\n Console.ForegroundColor = defaultColor;\n Console.SetIn(test);\n\n\n#else\n if (_useFileInput)\n {\n Console.SetIn(File.OpenText(_inputFilename));\n file = new StreamWriter(_outputFilename);\n Console.SetOut(file);\n }\n#endif\n\n try\n {\n#if DEBUG\n Solution(testNumber);\n#else\n Solution(0);\n#endif\n }\n finally\n {\n#if DEBUG\n#else\n if (_useFileInput)\n {\n file.Close();\n }\n#endif\n }\n\n#if DEBUG\n timer.Stop();\n\n Console.ForegroundColor = ConsoleColor.DarkYellow;\n Console.WriteLine($\"\");\n Console.ForegroundColor = defaultColor;\n\n timer.Reset();\n testNumber++;\n }\n#endif\n }\n\n static long mod = 1000 * 1000 * 1000 + 7;\n\n static void Solution(int testNumber)\n {\n checked\n {\n #region SOLUTION\n var d = ReadLongArray();\n var x = d[0];\n var k = d[1];\n\n if (x == 0)\n {\n Console.WriteLine(0);\n return;\n }\n\n x %= mod;\n k++;\n var kp = Pow(2, k);\n kp *= x;\n kp %= mod;\n\n var next = 1L;\n if (k == 2)\n {\n next = -1;\n }\n else if (k == 1)\n {\n next = 0;\n }\n else if (k > 2)\n {\n //var gp = (1 - Pow(2, k - 2)) / (1 - 2);\n next = -Pow(2, k - 1) + 1;\n next %= mod;\n }\n\n var res = kp + next;\n if (res < 0)\n {\n res += mod;\n }\n res %= mod;\n\n Console.WriteLine(res);\n }\n //var n = readInt();\n //var m = readInt();\n\n //var a = readIntArray();\n //var b = readIntArray();\n #endregion\n }\n\n static long Pow(long a, long pp)\n {\n checked\n {\n var res = 1L;\n while (true)\n {\n if (pp % 2 == 1)\n {\n res *= a;\n res %= mod;\n pp--;\n }\n else\n {\n pp /= 2;\n a *= a;\n\n a %= mod;\n }\n\n if (pp == 0)\n {\n break;\n }\n }\n\n return res;\n }\n \n }\n\n static int ReadInt()\n {\n return int.Parse(Console.ReadLine());\n }\n\n static long ReadLong()\n {\n return long.Parse(Console.ReadLine());\n }\n\n static int[] ReadIntArray()\n {\n return Console.ReadLine().Split(' ').Where(i => !string.IsNullOrEmpty(i)).Select(i => int.Parse(i)).ToArray();\n }\n\n static long[] ReadLongArray()\n {\n return Console.ReadLine().Split(' ').Where(i => !string.IsNullOrEmpty(i)).Select(i => long.Parse(i)).ToArray();\n }\n\n#if DEBUG\n static IEnumerable GetTests()\n {\n var tests = new List();\n var resName = Assembly.GetCallingAssembly().GetManifestResourceNames()[0];\n using (var resource = new StreamReader(Assembly.GetCallingAssembly().GetManifestResourceStream(resName)))\n {\n while (true)\n {\n var nextText = new StringBuilder();\n var endOfFile = false;\n while (true)\n {\n var line = resource.ReadLine();\n\n endOfFile = line == null;\n if (endOfFile)\n {\n break;\n }\n\n if (line.StartsWith(_delim, StringComparison.Ordinal))\n {\n break;\n }\n\n nextText.AppendLine(line);\n }\n\n yield return new StringReader(nextText.ToString());\n\n if (endOfFile)\n {\n break;\n }\n }\n }\n }\n#endif\n }\n}\n", "lang_cluster": "C#", "tags": ["math"], "code_uid": "fccbfefdd61bd3248557e76a9d351240", "src_uid": "e0e017e8c8872fc1957242ace739464d", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace bla\n{\n class Program\n {\n static void Main(string[] args)\n {\n string[] s = Console.ReadLine().Split();\n long x = long.Parse(s[0]);\n long k = long.Parse(s[1]) + 1;\n if (x == 0)\n {\n Console.WriteLine(\"0\");\n }\n else\n {\n Console.WriteLine((((((x % mod) * pow(k)) % mod) - pow(k - 1) + 1) % mod + mod) % mod);\n }\n }\n\n static long mod = 1000000007;\n\n static long pow(long n) //2^n\n {\n if (n == 0)\n return 1;\n if(n % 2 == 0)\n {\n long a = pow(n / 2);\n return (a * a) % mod;\n }\n return (2 * pow(n - 1)) % mod;\n }\n }\n}", "lang_cluster": "C#", "tags": ["math"], "code_uid": "ecbf1ccd0a0afaabce05abdad6799eec", "src_uid": "e0e017e8c8872fc1957242ace739464d", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Globalization;\nusing System.Text;\nusing System.IO;\nusing System.Linq;\nusing System.Threading;\n\n\n\n\nclass Program\n{\n long maxK = 1000;\n long maxPrime = 2 * 1000000 + 10;\n int[] minDiv;\n List primes = new List();\n void solve()\n {\n getDiv();\n long a = nextLong();\n long b = nextLong();\n long k = nextLong();\n long res = get(b, k);\n res -= get(a - 1, k);\n println(res);\n\n }\n\n private void getDiv()\n {\n minDiv = new int[maxPrime];\n for (int i = 2; i < minDiv.Length; i++)\n minDiv[i] = i;\n for (int i = 2; i < minDiv.Length; i++)\n if (minDiv[i] == i)\n for (int j = 2 * i; j < minDiv.Length; j += i)\n if (minDiv[j] == j)\n minDiv[j] = i;\n }\n\n private long get(long n, long k)\n {\n if (n <= 0)\n return 0;\n if (!prime(k))\n return 0;\n long res=0;\n if (k >= maxK)\n {\n\n if (k <= n)\n res++;\n for (long x = k; x * k <= n; x++)\n if (minDiv[x] >= k)\n res++;\n return res;\n }\n else\n {\n for(int i=2;i();\n }\n return res;\n }\n\n private long rec(int at, long n)\n {\n if (at >= primes.Count)\n return 0;\n if (n < primes[at])\n return 0;\n long res = n / primes[at];\n res+=rec(at+1,n);\n res -= rec(at + 1, n / primes[at]);\n return res;\n \n }\n\n bool prime(long p)\n {\n for (int i = 2; i * i <= p; i++)\n if (p % i == 0)\n return false;\n return true;\n }\n ////////////\n private void println(int[] ar)\n {\n for (int i = 0; i < ar.Length; i++)\n {\n if (i == ar.Length - 1)\n println(ar[i]);\n else\n print(ar[i] + \" \");\n }\n }\n private void println(int[] ar, bool add)\n {\n int A = 0;\n if (add)\n A++;\n for (int i = 0; i < ar.Length; i++)\n {\n if (i == ar.Length - 1)\n println(ar[i] + A);\n else\n print((ar[i] + A) + \" \");\n }\n }\n\n private void println(string Stringst)\n {\n Console.WriteLine(Stringst);\n }\n private void println(char charnum)\n {\n Console.WriteLine(charnum);\n }\n private void println(int Intnum)\n {\n Console.WriteLine(Intnum);\n }\n private void println(long Longnum)\n {\n Console.WriteLine(Longnum);\n }\n private void println(double Doublenum)\n {\n string s = Doublenum.ToString(CultureInfo.InvariantCulture);\n Console.WriteLine(s);\n }\n\n private void print(string Stringst)\n {\n Console.Write(Stringst);\n }\n private void print(int Intnum)\n {\n Console.Write(Intnum);\n }\n private void print(char charnum)\n {\n Console.Write(charnum);\n }\n private void print(long Longnum)\n {\n Console.Write(Longnum);\n }\n private void print(double Doublenum)\n {\n Console.Write(Doublenum);\n }\n\n\n string[] inputLine = new string[0];\n int inputInd = 0;\n string nextLine()\n {\n return Console.ReadLine();\n }\n void readInput()\n {\n if (inputInd != inputLine.Length)\n throw new Exception();\n inputInd = 0;\n inputLine = Console.ReadLine().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);\n if (inputLine.Length == 0)\n readInput();\n\n }\n int nextInt()\n {\n if (inputInd == inputLine.Length)\n readInput();\n return int.Parse(inputLine[inputInd++]);\n }\n long nextLong()\n {\n if (inputInd == inputLine.Length)\n readInput();\n return long.Parse(inputLine[inputInd++]);\n }\n double nextDouble()\n {\n if (inputInd == inputLine.Length)\n readInput();\n return double.Parse(inputLine[inputInd++]);\n }\n string nextString()\n {\n if (inputInd == inputLine.Length)\n readInput();\n return inputLine[inputInd++];\n }\n static void Main(string[] args)\n {\n Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;\n new Program().solve();\n }\n}", "lang_cluster": "C#", "tags": ["math", "dp", "number theory"], "code_uid": "2245603bfebce795f6db64572ddffef6", "src_uid": "04a26f1d1013b6e6b4b0bdcf225475f2", "difficulty": 2400.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\n\nnamespace CodeForces\n{\n class Rook__Bishop_and_King\n {\n static void Main()\n {\n Run();\n Console.ReadLine();\n }\n static void Run()\n {\n string[] str = Console.ReadLine().Split();\n int r1 = int.Parse(str[0]);\n int c1 = int.Parse(str[1]);\n int r2 = int.Parse(str[2]);\n int c2 = int.Parse(str[3]);\n StringBuilder sb = new StringBuilder();\n if (r1 == r2 || c1 == c2)\n {\n sb.Append(\"1 \");\n }\n else\n {\n sb.Append(\"2 \");\n }\n if (r1 % 2 == 1)\n {\n if (c1 % 2 == 1)\n {\n if (r2 % 2 == 0 && c2 % 2 == 0)\n {\n //reachable\n //reachable\n if (Math.Abs(r1 - r2) == Math.Abs(c1 - c2))\n {\n sb.Append(\"1 \");\n }\n else\n {\n sb.Append(\"2 \");\n }\n }\n else if (r2 % 2 == 1 && c2 % 2 == 1)\n {\n //reachable\n //reachable\n if (Math.Abs(r1 - r2) == Math.Abs(c1 - c2))\n {\n sb.Append(\"1 \");\n }\n else\n {\n sb.Append(\"2 \");\n }\n }\n else\n sb.Append(\"0 \");\n }\n else\n {\n if (r2 % 2 == 0 && c2 % 2 == 1)\n {\n //reachable\n if (Math.Abs(r1 - r2) == Math.Abs(c1 - c2))\n {\n sb.Append(\"1 \");\n }\n else\n {\n sb.Append(\"2 \");\n }\n }\n else if (r2 % 2 == 1 && c2 % 2 == 0)\n {\n //reachable\n if (Math.Abs(r1 - r2) == Math.Abs(c1 - c2))\n {\n sb.Append(\"1 \");\n }\n else\n {\n sb.Append(\"2 \");\n }\n }\n else\n {\n sb.Append(\"0 \");\n }\n\n }\n }\n if (r1 % 2 == 0)\n {\n if (c1 % 2 == 1)\n {\n if (r2 % 2 == 0 && c2 % 2 == 1)\n {\n //reachable\n if (Math.Abs(r1 - r2) == Math.Abs(c1 - c2))\n {\n sb.Append(\"1 \");\n }\n else\n {\n sb.Append(\"2 \");\n }\n }\n else if (r2 % 2 == 1 && c2 % 2 == 0)\n {\n //reachable\n if (Math.Abs(r1 - r2) == Math.Abs(c1 - c2))\n {\n sb.Append(\"1 \");\n }\n else\n {\n sb.Append(\"2 \");\n }\n }\n else\n sb.Append(\"0 \");\n }\n else\n {\n if (r2 % 2 == 0 && c2 % 2 == 0)\n {\n if (Math.Abs(r1 - r2) == Math.Abs(c1 - c2))\n {\n sb.Append(\"1 \");\n }\n else\n {\n sb.Append(\"2 \");\n }\n }\n else if (r2 % 2 == 1 && c2 % 2 == 1)\n {\n if (Math.Abs(r1 - r2) == Math.Abs(c1 - c2))\n {\n sb.Append(\"1 \");\n }\n else\n {\n sb.Append(\"2 \");\n }\n }\n else\n {\n sb.Append(\"0 \");\n }\n\n }\n }\n if (r1 == r2)\n {\n sb.AppendFormat(\"{0} \", Math.Abs(c1 - c2));\n }\n else if (c1 == c2)\n {\n sb.AppendFormat(\"{0} \", Math.Abs(r1 - r2));\n }\n else\n {\n if (Math.Abs(r1 - r2) == Math.Abs(c1 - c2))\n {\n sb.AppendFormat(\"{0} \", Math.Abs(c1 - c2));\n }\n else\n {\n \n sb.AppendFormat(\"{0} \", Math.Max(Math.Abs(r1-r2) , Math.Abs(c1-c2)));\n \n }\n }\n Console.WriteLine(sb.ToString().Trim());\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "graphs", "shortest paths"], "code_uid": "146395d11326185988dffbee14db95bc", "src_uid": "7dbf58806db185f0fe70c00b60973f4b", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace Codeforces217\n{\n class Program\n {\n static void Main(string[] args)\n {\n var input = Console.ReadLine().Split(' ');\n int r1 = int.Parse(input[0]),\n c1 = int.Parse(input[1]),\n r2 = int.Parse(input[2]),\n c2 = int.Parse(input[3]);\n\n if (r1 == r2 || c1 == c2)\n Console.Write(\"1 \");\n else Console.Write(\"2 \");\n\n if ((c1+r1) % 2 == (c2+r2)%2)\n {\n if (Math.Abs(r2 - r1) == Math.Abs(c2 - c1))\n Console.Write(\"1 \");\n else Console.Write(\"2 \");\n }\n else Console.Write(\"0 \"); \n\n\n Console.Write(Math.Max(Math.Abs(c2 - c1), Math.Abs(r2 - r1)));\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "graphs", "shortest paths"], "code_uid": "6ae0919d8cb04200cfd395c54842bdea", "src_uid": "7dbf58806db185f0fe70c00b60973f4b", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace CodeForcesCS\n{\n class Program\n {\n static void Main(string[] args)\n {\n int x1, x2, y1, y2;\n\n int[] temp = Array.ConvertAll(Console.ReadLine().Split(), Convert.ToInt32);\n x1 = temp[0];\n y1 = temp[1];\n x2 = temp[2];\n y2 = temp[3];\n\n int difX = Math.Abs(x2 - x1);\n int difY = Math.Abs(y2 - y1);\n\n if ((x1 == x2) || (y1 == y2)) Console.Write(\"1 \");\n else Console.Write(\"2 \");\n\n if (((x1 + y1) % 2) == ((x2 + y2) % 2))\n {\n if (difX == difY) Console.Write(\"1 \");\n else Console.Write(\"2 \");\n }\n else Console.Write(\"0 \");\n\n Console.WriteLine(Math.Max(difX, difY));\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "graphs", "shortest paths"], "code_uid": "c607f13b30eda6f465fa40344dedea6e", "src_uid": "7dbf58806db185f0fe70c00b60973f4b", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\n\nnamespace _217_1\n{\n class Program\n {\n static void Main(string[] args)\n {\n string[] s = Console.ReadLine().Split(' ');\n int x = int.Parse(s[0]);\n int y = int.Parse(s[1]);\n int x1 = int.Parse(s[2]);\n int y1 = int.Parse(s[3]);\n int lengx = Math.Abs(x - x1);\n int lengy = Math.Abs(y - y1);\n int ans1=0;\n if (x == x1 && y == y1) { Console.WriteLine(0 + \" \" + 0 + \" \" + 0); return; }\n if (x == x1 || y == y1)\n ans1 = 1;\n else ans1 = 2;\n int ans2=0;\n if ((lengx + lengy) % 2 != 0) ans2 = 0;\n else\n if (lengx == lengy) ans2 = 1;\n else\n ans2 = 2;\n int ans3 = 0;\n if (ans2 == 1) ans3 = lengy;\n else ans3 = Math.Max(lengy, lengx);\n Console.WriteLine(ans1+\" \"+ ans2+\" \"+ ans3);\n\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "graphs", "shortest paths"], "code_uid": "323c7a8b91aefa3e85a9df173af3185e", "src_uid": "7dbf58806db185f0fe70c00b60973f4b", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\n\nnamespace Codeforces\n{\n\tstatic class Program\n\t{\n\t\tstatic void Main(string[] args)\n\t\t{\n\t\t\tvar rc = Console.ReadLine().Split().Select(int.Parse).ToList();\n\t\t\tvar res = \"\";\n\n\t\t\t// rook\n\t\t\tif (rc[0] == rc[2] || rc[1] == rc[3]) res += \"1 \";\n\t\t\telse res += \"2 \";\n\n\t\t\t// bishop\n\t\t\tif ((rc[0] + rc[1]) % 2 == (rc[2] + rc[3]) % 2)\n\t\t\t{\n\t\t\t\tif (rc[0] + rc[1] == rc[2] + rc[3] || rc[0] - rc[1] == rc[2] - rc[3]) res += \"1 \";\n\t\t\t\telse res += \"2 \";\n\t\t\t}\n\t\t\telse res += \"0 \";\n\n\t\t\t// king\n\t\t\tres += Math.Max(Math.Abs(rc[0] - rc[2]), Math.Abs(rc[1] - rc[3])).ToString();\n\t\t\tConsole.WriteLine(res);\n\t\t\tConsole.ReadLine();\n\t\t}\n\n\t}\n}\n", "lang_cluster": "C#", "tags": ["math", "graphs", "shortest paths"], "code_uid": "22e2a666b24e364d22bc364715a74fd4", "src_uid": "7dbf58806db185f0fe70c00b60973f4b", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeff//\ufeff\ufeff\ufeff\ufeff\ufeff\ufeff\ufeff\ufeff\ufeff#define EXTENDSTACKSIZE\n\n\ufeffusing System;\n using System.Collections.Generic;\n using System.Globalization;\nusing System.IO;\nusing System.Linq;\n using System.Text;\n using System.Threading;\n\n namespace CF\n{\n internal class Program\n {\n private const int stackSize = 64 * 1024 * 1024;\n \n private static void Run()\n {\n using (var sr = new InputReader(Console.In))\n// using (var sr = new InputReader(new StreamReader(\"input.txt\")))\n using (var sw = Console.Out)\n// using (var sw = new StreamWriter(\"output.txt\"))\n using (var task = new Task(sr, sw)) {\n task.Solve();\n// Console.ReadKey();\n }\n }\n \n private static void Main(string[] args)\n {\n#if EXTENDSTACKSIZE\n var threadStart = new ThreadStart(Run);\n var thread = new Thread(threadStart, stackSize);\n thread.Start();\n thread.Join();\n#else\n Run();\n#endif\n }\n }\n \n internal class Task : IDisposable\n {\n private readonly InputReader sr;\n private readonly TextWriter sw;\n private bool isDispose;\n \n public Task(InputReader sr, TextWriter sw)\n {\n this.sr = sr;\n this.sw = sw;\n }\n \n public void Solve()\n {\n var n = sr.NextInt32();\n var m = sr.NextInt32();\n var numbers = sr.ReadArrayOfInt32();\n var answ = new StringBuilder();\n answ.Append(0 + \" \");\n for (var i = 1; i < n; i++)\n {\n var sum = numbers[i];\n var indx = 0;\n var sorted = new int[i];\n Array.Copy(numbers, sorted, i);\n Array.Sort(sorted);\n var j = 0;\n for (; j < i; j++)\n {\n if (sum + sorted[j] > m)\n {\n break;\n }\n\n sum += sorted[j];\n }\n\n answ.Append((i - j) + \" \");\n }\n\n sw.Write(answ);\n }\n \n public void Dispose()\n {\n Dispose(true);\n GC.SuppressFinalize(this);\n }\n \n private void Dispose(bool disposing)\n {\n if (!isDispose) {\n if (disposing) {\n if(sr != null)\n sr.Dispose();\n \n if(sw != null)\n sw.Dispose();\n }\n\n isDispose = true;\n }\n }\n }\n}\n\ninternal class InputReader : IDisposable\n{\n private bool isDispose;\n private readonly TextReader sr;\n private string[] buffer;\n private int seek;\n\n public InputReader(TextReader stream)\n {\n sr = stream;\n }\n\n public void Dispose()\n {\n Dispose(true);\n GC.SuppressFinalize(this);\n }\n\n public string NextString()\n {\n var result = sr.ReadLine();\n return result;\n }\n\n public int NextInt32()\n {\n return Int32.Parse(ReadNextToken());\n }\n\n private string ReadNextToken()\n {\n if (buffer == null || seek == buffer.Length) {\n seek = 0;\n buffer = NextSplitStrings();\n }\n\n return buffer[seek++];\n }\n\n public long NextInt64()\n {\n return Int64.Parse(ReadNextToken());\n }\n \n public int[] ReadArrayOfInt32()\n {\n return ReadArray(Int32.Parse);\n }\n\n public long[] ReadArrayOfInt64()\n {\n return ReadArray(Int64.Parse);\n }\n\n public string[] NextSplitStrings()\n {\n return NextString()\n .Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);\n }\n\n public T[] ReadArray(Func func)\n {\n return NextSplitStrings()\n .Select(s => func(s, CultureInfo.InvariantCulture))\n .ToArray();\n }\n\n public T[] ReadArrayFromString(Func func, string str)\n {\n return\n str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)\n .Select(s => func(s, CultureInfo.InvariantCulture))\n .ToArray();\n }\n\n protected void Dispose(bool dispose)\n {\n if (!isDispose)\n {\n if (dispose)\n sr.Close();\n \n isDispose = true;\n }\n }\n\n ~InputReader()\n {\n Dispose(false);\n }\n}", "lang_cluster": "C#", "tags": ["sortings", "greedy"], "code_uid": "6991f891d1c0dc1365b6877166b782c3", "src_uid": "d3c1dc3ed7af2b51b4c49c9b5052c346", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Globalization;\nusing System.IO;\nusing System.Text;\nusing static System.Console;\nusing static System.Math;\n\nnamespace Olymp\n{\n public class ProblemSolver\n {\n private readonly Tokenizer input;\n\n public void Solve()\n {\n (var n, var M) = input.Read2Int();\n var t = input.ReadIntArray(n);\n var c = new int[101];\n var a = new int[n];\n var ss = 0;\n for (var i = 0; i < n; i++)\n {\n var j = 100;\n var s = ss;\n while (s > M - t[i] && j > 0)\n {\n var k = Min(c[j], (s - M + t[i] + j - 1) / j);\n s -= j * k;\n a[i] += k;\n j--;\n }\n ss += t[i];\n c[t[i]]++;\n }\n Write(string.Join(\" \", a));\n }\n\n public ProblemSolver(TextReader input)\n {\n this.input = new Tokenizer(input);\n }\n }\n\n #region Service classes\n\n public class Tokenizer\n {\n private TextReader reader;\n\n public string ReadToEnd()\n {\n return reader.ReadToEnd();\n }\n\n public int ReadInt()\n {\n var c = SkipWS();\n if (c == -1)\n throw new EndOfStreamException();\n var isNegative = false;\n if (c == '-' || c == '+')\n {\n isNegative = c == '-';\n c = reader.Read();\n if (c == -1)\n throw new EndOfStreamException(\"Digit expected, but end of stream occurs\");\n }\n if (!char.IsDigit((char)c))\n throw new InvalidOperationException($\"Digit expected, but was: '{(char)c}'\");\n var result = (char)c - '0';\n c = reader.Read();\n while (c > 0 && !char.IsWhiteSpace((char)c))\n {\n if (!char.IsDigit((char)c))\n throw new InvalidOperationException($\"Digit expected, but was: '{(char)c}'\");\n result = result * 10 + (char)c - '0';\n c = reader.Read();\n }\n if (isNegative)\n result = -result;\n return result;\n }\n\n public string ReadLine()\n {\n return reader.ReadLine();\n }\n\n public long ReadLong()\n {\n return long.Parse(ReadToken());\n }\n\n public double ReadDouble()\n {\n return double.Parse(ReadToken(), CultureInfo.InvariantCulture);\n }\n\n public int[] ReadIntArray(int n)\n {\n var a = new int[n];\n for (var i = 0; i < n; i++)\n a[i] = ReadInt();\n return a;\n }\n\n public (int, int) Read2Int() =>\n (ReadInt(), ReadInt());\n\n public (int, int, int) Read3Int() =>\n (ReadInt(), ReadInt(), ReadInt());\n\n public (int, int, int, int) Read4Int() =>\n (ReadInt(), ReadInt(), ReadInt(), ReadInt());\n\n public (long, long) Read2Long() =>\n (ReadLong(), ReadLong());\n\n public (long, long, long) Read3Long() =>\n (ReadLong(), ReadLong(), ReadLong());\n\n public (long, long, long, long) Read4Long() =>\n (ReadLong(), ReadLong(), ReadLong(), ReadLong());\n\n public long[] ReadLongArray(int n)\n {\n var a = new long[n];\n for (var i = 0; i < n; i++)\n a[i] = ReadLong();\n return a;\n }\n\n public double[] ReadDoubleArray(int n)\n {\n var a = new double[n];\n for (var i = 0; i < n; i++)\n a[i] = ReadDouble();\n return a;\n }\n\n public string ReadToken()\n {\n var c = SkipWS();\n if (c == -1)\n return null;\n var sb = new StringBuilder();\n while (c > 0 && !char.IsWhiteSpace((char)c))\n {\n sb.Append((char)c);\n c = reader.Read();\n }\n return sb.ToString();\n }\n\n private int SkipWS()\n {\n var c = reader.Read();\n if (c == -1)\n return c;\n while (c > 0 && char.IsWhiteSpace((char)c))\n c = reader.Read();\n return c;\n }\n\n public Tokenizer(TextReader reader)\n {\n this.reader = reader;\n }\n }\n\n internal class Program\n {\n public static void Main(string[] args)\n {\n var solver = new ProblemSolver(In);\n solver.Solve();\n }\n }\n\n #endregion\n}\n", "lang_cluster": "C#", "tags": ["sortings", "greedy"], "code_uid": "7a3c9500fd39f29775bad9668a4de65c", "src_uid": "d3c1dc3ed7af2b51b4c49c9b5052c346", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing CompLib.Util;\n\npublic class Program\n{\n long A, B;\n public void Solve()\n {\n var sc = new Scanner();\n A = sc.NextLong();\n B = sc.NextLong();\n var div = Div(A + B);\n var divA = Div(A);\n var divB = Div(B);\n div.Sort();\n divA.Sort();\n divB.Sort();\n long ans = long.MaxValue;\n for (int i = 0; i <= div.Count / 2; i++)\n {\n\n long j = div[div.Count - 1 - i];\n\n\n // A,B\u306e\u3069\u3061\u3089\u304b\u304c i\u4ee5\u4e0b\u3001j\u4ee5\u4e0b\u306e\u7a4d\u3067\u8868\u305b\u308b\u304b?\n {\n int ok = -1;\n int ng = divA.Count;\n while (ng - ok > 1)\n {\n int mid = (ok + ng) / 2;\n if (divA[mid] <= div[i]) ok = mid;\n else ng = mid;\n }\n if(ok >= 0 && divA[divA.Count - ng] <= j)\n {\n // Console.WriteLine($\"A {div[i]} {j}\");\n ans = Math.Min(ans, (div[i] + j) * 2);\n continue;\n }\n }\n\n {\n int ok = -1;\n int ng = divB.Count;\n while (ng - ok > 1)\n {\n int mid = (ok + ng) / 2;\n if (divB[mid] <= div[i]) ok = mid;\n else ng = mid;\n }\n if (ok >= 0 && divB[divB.Count - ng] <= j)\n {\n // Console.WriteLine($\"B {div[i]} {j}\");\n ans = Math.Min(ans, (div[i] + j) * 2);\n continue;\n }\n }\n }\n Console.WriteLine(ans);\n }\n\n public List Div(long l)\n {\n var result = new List();\n for (long i = 1; i * i <= l; i++)\n {\n if (l % i == 0)\n {\n result.Add(i);\n if (l / i != i) result.Add(l / i);\n }\n }\n return result;\n }\n public static void Main(string[] args) => new Program().Solve();\n}\n\nnamespace CompLib.Util\n{\n using System;\n using System.Linq;\n\n class Scanner\n {\n private string[] _line;\n private int _index;\n private const char Separator = ' ';\n\n public Scanner()\n {\n _line = new string[0];\n _index = 0;\n }\n\n public string Next()\n {\n while (_index >= _line.Length)\n {\n _line = Console.ReadLine().Split(Separator);\n _index = 0;\n }\n\n return _line[_index++];\n }\n\n public int NextInt() => int.Parse(Next());\n public long NextLong() => long.Parse(Next());\n public double NextDouble() => double.Parse(Next());\n public decimal NextDecimal() => decimal.Parse(Next());\n public char NextChar() => Next()[0];\n public char[] NextCharArray() => Next().ToCharArray();\n\n public string[] Array()\n {\n _line = Console.ReadLine().Split(Separator);\n _index = _line.Length;\n return _line;\n }\n\n public int[] IntArray() => Array().Select(int.Parse).ToArray();\n public long[] LongArray() => Array().Select(long.Parse).ToArray();\n public double[] DoubleArray() => Array().Select(double.Parse).ToArray();\n public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "math", "binary search", "number theory"], "code_uid": "68c2561b7c937aa12a8a6519b823cd33", "src_uid": "7d0c5f77bca792b6ab4fd4088fe18ff1", "difficulty": 2000.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "/*\ncsc -debug 1029_F.cs && mono --debug 1029_F.exe <<< \"4 4\"\n\na+b -> \u0440\u0430\u0441\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u0435\u043c \u043d\u0430 \u043c\u043d\u043e\u0436\u0438\u0442\u0435\u043b\u0438, \u043d\u0430\u0447\u0438\u043d\u0430\u044f \u043e\u0442 sqrt(a+b) \u0438\u0434\u0435\u043c \u0432\u043d\u0438\u0437 -> \u0442\u0430\u043a \u0433\u0430\u0440\u0430\u043d\u0438\u0440\u0443\u0435\u043c min \u043f\u0435\u0440\u0438\u043c\u0435\u0442\u0440\u0430. \u0414\u043e x*y = a+b\na, b -> \u0440\u0430\u0441\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u0435\u043c \u043d\u0430 \u043c\u043d\u043e\u0436\u0438\u0442\u0435\u043b\u0438 (\u043d\u0430\u0447\u0438\u043d\u0430\u044f \u0441 \u043c\u0430\u043b\u0435\u043d\u044c\u043a\u043e\u0433\u043e, \u0443\u0447\u0438\u0442\u044b\u0432\u0430\u044f 1,a), \u0435\u0441\u043b\u0438 \u0445\u043e\u0442\u044f \u0431\u044b \u043e\u0434\u0438\u043d \u0438\u0437 \u043d\u0438\u0445 \u0440\u0430\u0441\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043d\u0430 \u0434\u0432\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u0435\u043d\u044c\u0448\u0435 x,y -> \u0440\u0435\u0448\u0435\u043d\u0438\u0435\n*/\n\nusing System;\nusing System.Collections.Generic;\nusing System.Linq;\n\npublic class HelloWorld {\n static public void Main () {\n SolveCodeForces();\n // System.Console.WriteLine(PrimeHelpers.PollardRho(new Random(), 10967535067ul));\n }\n\n public static void SolveCodeForces() {\n var ab = Console.ReadLine().Split().Select(long.Parse).ToArray();\n var a = ab[0];\n var b = ab[1];\n\n System.Console.WriteLine(Math.Min(Solve(a, b), Solve(b, a)));\n }\n\n public static long Solve(long a, long b) {\n var alowdivs = GetLowDivisors(a).ToArray();\n\n // System.Console.WriteLine(new {a, b});\n // System.Console.WriteLine(\"alowdivs = \" + string.Join(\" \", alowdivs));\n\n var p = long.MaxValue;\n\n foreach (var x in GetLowDivisors(a+b)) {\n var y = (a+b) / x;\n // a+b = xy, x <= sqrt(a+b), y >= sqrt(a+b)\n var i = BinarySearchRightmost(alowdivs, ad => ad - x);\n // System.Console.WriteLine(new { x, y, i });\n if ((i >= 0) && (a / alowdivs[i]) <= y) {\n // System.Console.WriteLine(\"Found a solution with perimeter \" + (2L * (x + y)));\n p = Math.Min(p, 2L * (x + y));\n }\n }\n\n return p;\n }\n\n public static IEnumerable GetLowDivisors(long x) {\n yield return 1L;\n if (x % 2L == 0) yield return 2L;\n\n var sqrt = Math.Sqrt(x);\n for (var d = 3L; d <= sqrt; d++)\n if (x % d == 0)\n yield return d;\n }\n\n private static int BinarySearchRightmost(IList arr, Func compare) {\n var a = 0;\n var b = arr.Count;\n while (a < b) {\n var mid = (a + b) / 2;\n var cmp = compare(arr[mid]);\n\n if (cmp <= 0)\n a = mid + 1;\n else\n b = mid;\n }\n return a - 1;\n }\n}\n\npublic static class Helpers {\n public static T[] CreateArray(int length, Func itemCreate) {\n var result = new T[length];\n for (var i = 0; i < result.Length; i++)\n result[i] = itemCreate(i);\n return result;\n }\n}", "lang_cluster": "C#", "tags": ["brute force", "math", "binary search", "number theory"], "code_uid": "ef5bca601d20464c081a5118fd50b21f", "src_uid": "7d0c5f77bca792b6ab4fd4088fe18ff1", "difficulty": 2000.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Globalization;\nusing System.IO;\nusing System.Linq;\nusing System.Text;\n\n// (\u3065*\u03c9*)\u3065\uff90\u2605\u309c\u30fb\u3002\u3002\u30fb\u309c\u309c\u30fb\u3002\u3002\u30fb\u309c\u2606\u309c\u30fb\u3002\u3002\u30fb\u309c\u309c\u30fb\u3002\u3002\u30fb\u309c\npublic class Solver\n{\n private long[] pows = new[]\n {\n 1, 11, 111, 1111, 11111, 111111, 1111111, 11111111, 111111111, 1111111111, 11111111111, 111111111111, 1111111111111,\n 11111111111111, 111111111111111, 1111111111111111\n };\n\n int Fun(long t)\n {\n if (t < 10)\n return (int)(t > 6 ? 13 - t : t);\n\n int k = 0;\n while (pows[k] <= t)\n k++;\n\n int tp = (int)((pows[k] - t) / pows[k - 1]);\n int ret = Fun(pows[k] - t - tp * pows[k - 1]) + k + 1 + tp * k;\n \n tp = (int)(t / pows[k - 1]);\n ret = Math.Min(ret, Fun(t - tp * pows[k - 1]) + tp * k);\n\n return ret;\n }\n\n public object Solve()\n {\n return Fun(ReadLong());\n }\n\n #region Main\n\n protected static TextReader reader;\n protected static TextWriter writer;\n\n static void Main()\n {\n#if DEBUG\n reader = new StreamReader(\"..\\\\..\\\\input.txt\");\n writer = Console.Out;\n //writer = new StreamWriter(\"..\\\\..\\\\output.txt\");\n#else\n reader = Console.In;\n writer = new StreamWriter(Console.OpenStandardOutput());\n#endif\n try\n {\n object result = new Solver().Solve();\n if (result != null)\n writer.WriteLine(result);\n }\n catch (Exception ex)\n {\n#if DEBUG\n Console.WriteLine(ex);\n#else\n throw;\n#endif\n }\n reader.Close();\n writer.Close();\n }\n\n #endregion\n\n #region Read/Write\n\n private static Queue currentLineTokens = new Queue();\n\n private static string[] ReadAndSplitLine()\n {\n return reader.ReadLine().Split(new[] { ' ', '\\t' }, StringSplitOptions.RemoveEmptyEntries);\n }\n\n public static string ReadToken()\n {\n while (currentLineTokens.Count == 0)\n currentLineTokens = new Queue(ReadAndSplitLine());\n return currentLineTokens.Dequeue();\n }\n\n public static int ReadInt()\n {\n return int.Parse(ReadToken());\n }\n\n public static long ReadLong()\n {\n return long.Parse(ReadToken());\n }\n\n public static double ReadDouble()\n {\n return double.Parse(ReadToken(), CultureInfo.InvariantCulture);\n }\n\n public static int[] ReadIntArray()\n {\n return ReadAndSplitLine().Select(int.Parse).ToArray();\n }\n\n public static long[] ReadLongArray()\n {\n return ReadAndSplitLine().Select(long.Parse).ToArray();\n }\n\n public static double[] ReadDoubleArray()\n {\n return ReadAndSplitLine().Select(s => double.Parse(s, CultureInfo.InvariantCulture)).ToArray();\n }\n\n public static int[][] ReadIntMatrix(int numberOfRows)\n {\n int[][] matrix = new int[numberOfRows][];\n for (int i = 0; i < numberOfRows; i++)\n matrix[i] = ReadIntArray();\n return matrix;\n }\n\n public static int[][] ReadAndTransposeIntMatrix(int numberOfRows)\n {\n int[][] matrix = ReadIntMatrix(numberOfRows);\n int[][] ret = new int[matrix[0].Length][];\n for (int i = 0; i < ret.Length; i++)\n {\n ret[i] = new int[numberOfRows];\n for (int j = 0; j < numberOfRows; j++)\n ret[i][j] = matrix[j][i];\n }\n return ret;\n }\n\n public static string[] ReadLines(int quantity)\n {\n string[] lines = new string[quantity];\n for (int i = 0; i < quantity; i++)\n lines[i] = reader.ReadLine().Trim();\n return lines;\n }\n\n public static void WriteArray(IEnumerable array)\n {\n writer.WriteLine(string.Join(\" \", array));\n }\n\n #endregion\n}", "lang_cluster": "C#", "tags": ["brute force", "divide and conquer", "dfs and similar"], "code_uid": "3e055628641e7752d2300a1c999618f7", "src_uid": "1b17a7b3b41077843ee1d6e0607720d6", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace DivisaoConquista\n{\n public static class Operacao\n {\n static public long[] Vetor; //vetor auxiliar\n\n static public long Calcula(long n, int i)\n {\n long m = n / Vetor[i]; //auxiliar para dividir o n\u00famero {aplica\u00e7\u00e3o da t\u00e9cnica}\n n = n % Vetor[i]; //atualiza\u00e7\u00e3o de n para o resto da divis\u00e3o\n\n if (n == 0) //Se chegar ao fim\n return m * i; //auxiliar * 'posi\u00e7\u00e3o' atual\n else //retorna o produto do auxiliar pelo menor valor entre a qtd de 1 para o n\u00famero e a posi\u00e7\u00e3o anterior e para a \n return m * i + Math.Min(Calcula(n, i - 1), i + Calcula(Vetor[i] - n, i - 1));\n }\n }\n class Program\n {\n static void Main(string[] args)\n {\n /*O Prof. Vasechkin quer representar o inteiro positivo n como uma soma de adendos, \n * onde cada adendo \u00e9 um n\u00famero inteiro contendo apenas 1 s. \n * Por exemplo, ele pode representar 121 como 121 = 111 + 11 + -1. \n * Encontrar o menor n\u00famero de d\u00edgitos 1 em tal soma.\n */\n Rodar();\n }\n\n static void Rodar()\n {\n long n;\n long[] vetor = new long[17];\n\n for (int i = 1; i < vetor.Length; i++)\n {\n vetor[i] = vetor[i - 1] * 10 + 1;\n }\n\n Operacao.Vetor = vetor;\n n = long.Parse(Console.ReadLine());\n Console.Write(Operacao.Calcula(n, 16));\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "divide and conquer", "dfs and similar"], "code_uid": "df0a131fea1821b45e2abaf5feb61507", "src_uid": "1b17a7b3b41077843ee1d6e0607720d6", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\nusing System.Numerics;\n\nnamespace One_Basic\n{\n public static class Operacao\n {\n static public long[] Vetor;\n\n static public long dfs(long n, int i)\n {\n long m = n / Vetor[i];\n n = n % Vetor[i];\n if (n == 0)\n return m * i;\n else\n return m * i + Math.Min(dfs(n, i - 1), i + dfs(Vetor[i] - n, i - 1));\n }\n }\n class Program\n {\n static void Main(string[] args)\n {\n Rodar();\n }\n\n static void Rodar()\n {\n long n;\n long[] vetor = new long[17];\n\n for (int i = 1; i < vetor.Length; i++)\n {\n vetor[i] = vetor[i - 1] * 10 + 1;\n }\n\n Operacao.Vetor = vetor;\n n = long.Parse(Console.ReadLine());\n Console.Write(Operacao.dfs(n, 16));\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "divide and conquer", "dfs and similar"], "code_uid": "37cfc3c25f96872753bfad0d6da9ab40", "src_uid": "1b17a7b3b41077843ee1d6e0607720d6", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.IO;\nusing System.Text;\n\nnamespace One_Based_Arithmetic\n{\n internal class Program\n {\n private static readonly StreamReader reader =\n new StreamReader(Console.OpenStandardInput(1024*10), Encoding.ASCII, false, 1024*10);\n\n private static readonly StreamWriter writer =\n new StreamWriter(Console.OpenStandardOutput(1024*10), Encoding.ASCII, 1024*10);\n\n private static void Main(string[] args)\n {\n long n = long.Parse(reader.ReadLine());\n\n var nn = new List();\n nn.Add(1);\n nn.Add(1);\n for (int i = 1;; i++)\n {\n long next = nn[i]*10 + 1;\n nn.Add(next);\n if (next > n)\n break;\n }\n\n int min = int.MaxValue;\n\n find(n, nn.Count - 1, nn, 0, ref min);\n\n\n writer.WriteLine(min);\n writer.Flush();\n }\n\n private static void find(long n, int index, List nn, int sum, ref int min)\n {\n if (n == 0)\n {\n if (min > sum)\n min = sum;\n }\n if (index <= 0)\n return;\n\n for (int i = -10; i < 11; i++)\n {\n if (n == nn[index]*i)\n {\n find(n - nn[index]*i, index - 1, nn, sum + index*Math.Abs(i), ref min);\n break;\n }\n }\n\n for (int i = -10; i < 11; i++)\n {\n if (n < nn[index] * i)\n {\n find(n - nn[index] * i, index - 1, nn, sum + index * Math.Abs(i), ref min);\n break;\n }\n }\n\n for (int i = 10; i > -11; i--)\n {\n if (n > nn[index] * i)\n {\n find(n - nn[index] * i, index - 1, nn, sum + index * Math.Abs(i), ref min);\n break;\n }\n }\n }\n }\n}", "lang_cluster": "C#", "tags": ["brute force", "divide and conquer", "dfs and similar"], "code_uid": "7c4cf511e88b05caed19c6f5a86b4da1", "src_uid": "1b17a7b3b41077843ee1d6e0607720d6", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nclass Program\n{\n\tstatic void Main(string[] args)\n\t{\n\t\tint N = int.Parse(Console.ReadLine());\n\t\tstring[] str = Console.ReadLine().Split();\n\t\tint[]A = new int[N];\n\t\tfor(var i=0;i=2 && A[i-2]==3){\n\t\t\t ans +=2;\n\t\t\t } else {\n \t\t\t\tans += 3;\n\t\t\t }\n\t\t\t} else if(A[i-1]==1 && A[i]==3){\n\t\t\t\tans += 4;\n\t\t\t} else if(A[i-1]==2 && A[i]==1){\n\t\t\t\tans += 3;\n\t\t\t} else if(A[i-1]==2 && A[i]==3){\n\t\t\t\tans = -1;\n\t\t\t\tbreak;\n\t\t\t} else if(A[i-1]==3 && A[i]==1){\n\t\t\t\tans += 4;\n\t\t\t} else if(A[i-1]==3 && A[i]==2){\n\t\t\t\tans = -1;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tif(ans == -1){\n\t\t\tConsole.WriteLine(\"Infinite\");\n\t\t} else {\n\t\t\tConsole.WriteLine(\"Finite\");\n\t\t\tConsole.WriteLine(ans);\n\t\t}\n\t}\n}", "lang_cluster": "C#", "tags": ["geometry"], "code_uid": "0849a89e4d5a10ca53e45a05307ea0cb", "src_uid": "6c8f028f655cc77b05ed89a668273702", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeff\ufeff\ufeffusing System;\nusing System.Text;\nusing System.Collections.Generic;\nusing System.Collections;\nusing System.Linq;\nclass Problem\n{\n static void Main()\n {\n //--------------------------------input--------------------------------//\n\n int n = Convert.ToInt32( Console.ReadLine() );\n var a = Array.ConvertAll( Console.ReadLine().Split(), Convert.ToInt32 );\n\n //--------------------------------solve--------------------------------//\n\n string s = String.Join( \"\", a );\n if(s.Contains( \"23\" ) || s.Contains( \"32\" ) || s.Contains( \"11\" ) || s.Contains( \"22\" ) || s.Contains( \"33\" ))\n Console.WriteLine( \"Infinite\" );\n else\n {\n Console.WriteLine( \"Finite\" );\n int kq = 0;\n for(int i = 0 ; i < n - 1 ; i++)\n {\n if(a[i] + a[i + 1] == 3)\n kq += 3;\n if(a[i] + a[i + 1] == 4)\n kq += 4;\n }\n for(int i = 0 ; i < n - 2 ; i++)\n if(a[i] == 3 && a[i + 1] == 1 && a[i + 2] == 2)\n kq--;\n Console.WriteLine( kq );\n }\n\n }\n\n\n\n\n}", "lang_cluster": "C#", "tags": ["geometry"], "code_uid": "d88979dfe1ddae8c6e50522a0d02d978", "src_uid": "6c8f028f655cc77b05ed89a668273702", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Globalization;\nusing System.IO;\nusing System.Text;\n\nnamespace Bag_of_mice\n{\n internal class Program\n {\n private static readonly StreamReader reader = new StreamReader(Console.OpenStandardInput(1024*10), Encoding.ASCII, false, 1024*10);\n private static readonly StreamWriter writer = new StreamWriter(Console.OpenStandardOutput(1024*10), Encoding.ASCII, 1024*10);\n private static double[,] nn;\n\n private static void Main(string[] args)\n {\n int w = Next();\n int b = Next();\n\n\n nn = new double[w + 1,b + 1];\n for (int i = 1; i <= w; i++)\n {\n nn[i, 0] = 1;\n }\n\n for (int j = 1; j <= b; j++)\n {\n for (int i = 1; i <= w; i++)\n {\n nn[i, j] = 1.0*i/(i + j) +\n 1.0*j/(i + j)*\n (1.0*(j - 1)/(i + j - 1)*\n ((j - 3 < 0 ? 0 : nn[i, j - 3]*(j - 2)/(i + j - 2)) + (j - 2 < 0 ? 0 : nn[i - 1, j - 2]*i/(i + j - 2))));\n }\n }\n\n\n writer.WriteLine(nn[w, b].ToString(\"#0.000000000\", CultureInfo.InvariantCulture));\n writer.Flush();\n }\n\n private static int Next()\n {\n int c;\n int res = 0;\n do\n {\n c = reader.Read();\n if (c == -1)\n return res;\n } while (c < '0' || c > '9');\n res = c - '0';\n while (true)\n {\n c = reader.Read();\n if (c < '0' || c > '9')\n return res;\n res *= 10;\n res += c - '0';\n }\n }\n }\n}", "lang_cluster": "C#", "tags": ["math", "dp", "probabilities", "games"], "code_uid": "f1a45ac986c627aebd7e0c93413b6ede", "src_uid": "7adb8bf6879925955bf187c3d05fde8c", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Globalization;\nusing System.IO;\nusing System.Text;\n\nnamespace Bag_of_mice\n{\n internal class Program\n {\n private static readonly StreamReader reader = new StreamReader(Console.OpenStandardInput(1024*10), Encoding.ASCII, false, 1024*10);\n private static readonly StreamWriter writer = new StreamWriter(Console.OpenStandardOutput(1024*10), Encoding.ASCII, 1024*10);\n private static double[,] nn;\n\n private static void Main(string[] args)\n {\n int w = Next();\n int b = Next();\n\n\n nn = new double[w + 1,b + 1];\n for (int i = 1; i <= w; i++)\n {\n nn[i, 0] = 1;\n }\n\n for (int j = 1; j <= b; j++)\n {\n for (int i = 1; i <= w; i++)\n {\n nn[i, j] = 1.0*i/(i + j) +\n 1.0*j/(i + j)*\n (1.0*(j - 1)/(i + j - 1)*\n ((j - 2 < 0 ? 0 : gnn(i, j - 3)*(j - 2)/(i + j - 2)) + (j - 2 < 0 ? 0 : gnn(i - 1, j - 2)*(i)/(i + j - 2))));\n }\n }\n\n\n writer.WriteLine(nn[w, b].ToString(\"#0.000000000\", CultureInfo.InvariantCulture));\n writer.Flush();\n }\n\n private static double gnn(int i, int j)\n {\n if (j < 0)\n return 0;\n return nn[i, j];\n }\n\n private static int Next()\n {\n int c;\n int res = 0;\n do\n {\n c = reader.Read();\n if (c == -1)\n return res;\n } while (c < '0' || c > '9');\n res = c - '0';\n while (true)\n {\n c = reader.Read();\n if (c < '0' || c > '9')\n return res;\n res *= 10;\n res += c - '0';\n }\n }\n }\n}", "lang_cluster": "C#", "tags": ["math", "dp", "probabilities", "games"], "code_uid": "bfd051037d64f93f6df3dc56517dcf2c", "src_uid": "7adb8bf6879925955bf187c3d05fde8c", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Diagnostics;\nusing System.Globalization;\nusing System.IO;\nusing System.Linq;\n\nnamespace ReadWriteTemplate\n{\n public static class Solver\n {\n private static void SolveCase()\n {\n long n = ReadLong() - 1;\n\n long ans = 0;\n for (int i = 0; i < 60; i++)\n {\n long a = (1L << i);\n long b = (1L << (i + 1));\n ans += a * ((n + b - a) / b);\n }\n\n Writer.WriteLine(ans);\n }\n\n public static void Solve()\n {\n SolveCase();\n\n /*var sw = Stopwatch.StartNew();\n\n int T = ReadInt();\n for (int i = 0; i < T; i++)\n {\n Writer.Write(\"Case #{0}: \", i + 1);\n SolveCase();\n Writer.Flush();\n Console.WriteLine($\"Task {i + 1} completed\");\n }\n\n sw.Stop();\n Console.WriteLine(sw.ElapsedMilliseconds);*/\n }\n\n public class Point\n {\n public Point(int x, int y)\n {\n X = x;\n Y = y;\n }\n\n public int X;\n\n public int Y;\n\n public double Length => Math.Sqrt(X * X + Y * Y);\n\n protected bool Equals(Point other)\n {\n return X == other.X && Y == other.Y;\n }\n\n public override bool Equals(object obj)\n {\n if (ReferenceEquals(null, obj))\n {\n return false;\n }\n if (ReferenceEquals(this, obj))\n {\n return true;\n }\n /*if (obj.GetType() != this.GetType())\n {\n return false;\n }*/\n return Equals((Point) obj);\n }\n\n public override int GetHashCode()\n {\n unchecked\n {\n return (X * 397) ^ Y;\n }\n }\n\n public int Dist2(Point p)\n {\n return (p.X - X) * (p.X - X) + (p.Y - Y) * (p.Y - Y);\n }\n\n public static Point operator +(Point a, Point b)\n {\n return new Point(a.X + b.X, a.Y + b.Y);\n }\n\n public static Point operator -(Point a, Point b)\n {\n return new Point(a.X - b.X, a.Y - b.Y);\n }\n\n public override string ToString()\n {\n return $\"{nameof(X)}: {X}, {nameof(Y)}: {Y}\";\n }\n }\n\n public static class Standard\n {\n public static long Power(long x, long p, long mod)\n {\n long result = 1;\n while (p > 0)\n {\n if ((p & 1) == 0)\n {\n x = (x * x) % mod;\n p >>= 1;\n }\n else\n {\n result = (result * x) % mod;\n p--;\n }\n }\n return result;\n }\n\n public static long Gcd(long a, long b)\n {\n return b == 0 ? a : Gcd(b, a % b);\n }\n\n public static List GetPrimes(int n)\n {\n bool[] isPrime = Enumerable.Repeat(true, n + 1).ToArray();\n isPrime[0] = false;\n isPrime[1] = false;\n for (int i = 2; i <= n; i++)\n {\n if (isPrime[i])\n {\n for (int j = i + i; j <= n; j += i)\n {\n isPrime[j] = false;\n }\n }\n }\n List primes = new List();\n for (int i = 0; i <= n; i++)\n {\n if (isPrime[i])\n {\n primes.Add(i);\n }\n }\n return primes;\n }\n\n public static CompressionResult Compress(IEnumerable values)\n {\n int d = 0;\n var dictionary = new Dictionary();\n foreach (T value in values.OrderByWithShuffle(x => x))\n {\n if (!dictionary.ContainsKey(value))\n {\n // todo: increase before or after?\n d++;\n dictionary[value] = d;\n }\n }\n return new CompressionResult(dictionary, d);\n }\n\n public class CompressionResult\n {\n public CompressionResult(Dictionary dictionary, int maxValue)\n {\n Dictionary = dictionary;\n MaxValue = maxValue;\n }\n\n public Dictionary Dictionary { get; }\n\n public int MaxValue { get; }\n }\n }\n\n public static void Main()\n {\n //Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;\n\n#if DEBUG\n //Reader = Console.In; Writer = Console.Out;\n Reader = File.OpenText(\"input.txt\"); Writer = File.CreateText(\"output.txt\");\n#else\n Reader = Console.In; Writer = Console.Out;\n#endif\n\n Solve();\n\n Reader.Close();\n Writer.Close();\n }\n\n public static IOrderedEnumerable OrderByWithShuffle(this IEnumerable source, Func keySelector)\n {\n return source.Shuffle().OrderBy(keySelector);\n }\n\n public static T[] Shuffle(this IEnumerable source)\n {\n T[] result = source.ToArray();\n Random rnd = new Random();\n for (int i = result.Length - 1; i >= 1; i--)\n {\n int k = rnd.Next(i + 1);\n T tmp = result[k];\n result[k] = result[i];\n result[i] = tmp;\n }\n return result;\n }\n\n #region Read/Write\n\n private static TextReader Reader;\n\n private static TextWriter Writer;\n\n private static Queue CurrentLineTokens = new Queue();\n\n private static string[] ReadAndSplitLine()\n {\n return Reader.ReadLine().Split(new[] { ' ', '\\t' }, StringSplitOptions.RemoveEmptyEntries);\n }\n\n public static string ReadToken()\n {\n while (CurrentLineTokens.Count == 0)\n CurrentLineTokens = new Queue(ReadAndSplitLine());\n return CurrentLineTokens.Dequeue();\n }\n\n public static string ReadLine()\n {\n return Reader.ReadLine();\n }\n\n public static int ReadInt()\n {\n return int.Parse(ReadToken());\n }\n\n public static long ReadLong()\n {\n return long.Parse(ReadToken());\n }\n\n public static double ReadDouble()\n {\n return double.Parse(ReadToken(), CultureInfo.InvariantCulture);\n }\n\n public static int[] ReadIntArray()\n {\n return ReadAndSplitLine().Select(int.Parse).ToArray();\n }\n\n public static long[] ReadLongArray()\n {\n return ReadAndSplitLine().Select(long.Parse).ToArray();\n }\n\n public static double[] ReadDoubleArray()\n {\n return ReadAndSplitLine().Select(s => double.Parse(s, CultureInfo.InvariantCulture)).ToArray();\n }\n\n public static int[][] ReadIntMatrix(int numberOfRows)\n {\n int[][] matrix = new int[numberOfRows][];\n for (int i = 0; i < numberOfRows; i++)\n matrix[i] = ReadIntArray();\n return matrix;\n }\n\n public static string[] ReadLines(int quantity)\n {\n string[] lines = new string[quantity];\n for (int i = 0; i < quantity; i++)\n lines[i] = Reader.ReadLine().Trim();\n return lines;\n }\n\n public static void WriteArray(IEnumerable array)\n {\n Writer.WriteLine(string.Join(\" \", array));\n }\n\n #endregion\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "dp", "bitmasks", "graphs", "implementation"], "code_uid": "68568aec6ade26cb77eb04b41730c810", "src_uid": "a98f0d924ea52cafe0048f213f075891", "difficulty": 1900.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace ConsoleApplication1.BFS\n{\n class NewYearFireworks\n {\n class Node\n {\n public int Level { get; set; }\n public int Direction { get; set; }\n public int X { get; set; }\n public int Y { get; set; }\n }\n\n static void Main(string[] args)\n {\n var N = int.Parse(Console.ReadLine());\n var t = new int[N];\n var s = Console.ReadLine().Split(' ').ToArray();\n for (var i = 0; i < N; i++)\n {\n t[i] = int.Parse(s[i]);\n }\n\n var directions = new int[][] {\n new int []{0,1},\n new int []{1,1},\n new int []{1,0},\n new int []{1,-1},\n new int []{0,-1},\n new int []{-1,-1},\n new int []{-1,0},\n new int []{-1,1}\n };\n \n\n var visited = new bool[600, 600];\n\n var q = new Queue();\n q.Enqueue(new Node()\n {\n Level = 0,\n Direction = 0,\n X = 300,\n Y = 300\n });\n visited[300, 300] = true;\n var res = 1;\n for (var k = 0; k < N; k++)\n {\n var used = new bool[600, 600, 8];\n var queue = new Queue();\n while (q.Count > 0)\n {\n var current = q.Dequeue();\n\n for (var i = 1; i < t[k]; i++)\n {\n if (!visited[current.Y + i * directions[current.Direction][0], current.X + i * directions[current.Direction][1]])\n {\n res++;\n visited[current.Y + i * directions[current.Direction][0], current.X + i * directions[current.Direction][1]] = true;\n }\n }\n current.Y += (t[current.Level] - 1) * directions[current.Direction][0];\n current.X += (t[current.Level] - 1) * directions[current.Direction][1];\n\n\n if (current.Level == N - 1)\n {\n continue;\n }\n var direction = (current.Direction + 1) % 8;\n if (!used[current.Y + directions[direction][0], current.X + directions[direction][1], direction])\n {\n used[current.Y + directions[direction][0], current.X + directions[direction][1], direction] = true;\n queue.Enqueue(new Node()\n {\n Direction = direction,\n Level = current.Level + 1,\n Y = current.Y + directions[direction][0],\n X = current.X + directions[direction][1]\n });\n }\n if (!visited[current.Y + directions[direction][0], current.X + directions[direction][1]])\n {\n visited[current.Y + directions[direction][0], current.X + directions[direction][1]] = true;\n res++;\n }\n\n direction = (current.Direction - 1) % 8;\n if (direction < 0)\n {\n direction = 8 + direction;\n }\n if (!used[current.Y + directions[direction][0], current.X + directions[direction][1], direction])\n {\n used[current.Y + directions[direction][0], current.X + directions[direction][1], direction] = true;\n queue.Enqueue(new Node()\n {\n Direction = direction,\n Level = current.Level + 1,\n Y = current.Y + directions[direction][0],\n X = current.X + directions[direction][1]\n });\n }\n if (!visited[current.Y + directions[direction][0], current.X + directions[direction][1]])\n {\n visited[current.Y + directions[direction][0], current.X + directions[direction][1]] = true;\n res++;\n }\n \n }\n q = queue;\n }\n \n Console.WriteLine(res);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["dfs and similar", "brute force", "dp", "data structures", "implementation"], "code_uid": "0aeaed124060fc3d25e5b670704e1312", "src_uid": "a96bc7f93fe9d9d4b78018b49bbc68d9", "difficulty": 1900.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\nusing System;\nusing System.Collections.Generic;\nusing System.IO;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace AlgoTraining.Codeforces.GoodBye2016\n{\n public class FastScanner : StreamReader\n {\n private string[] _line;\n private int _iterator;\n\n public FastScanner(Stream stream) : base(stream)\n {\n _line = null;\n _iterator = 0;\n }\n public string NextToken()\n {\n if (_line == null || _iterator >= _line.Length)\n {\n _line = base.ReadLine().Split(' ');\n _iterator = 0;\n }\n if (_line.Count() == 0) throw new IndexOutOfRangeException(\"Input string is empty\");\n return _line[_iterator++];\n }\n public int NextInt()\n {\n return Convert.ToInt32(NextToken());\n }\n public long NextLong()\n {\n return Convert.ToInt64(NextToken());\n }\n public float NextFloat()\n {\n return float.Parse(NextToken());\n }\n public double NextDouble()\n {\n return Convert.ToDouble(NextToken());\n }\n }\n class NewYearAndFireworksD\n {\n private static int n;\n private static int[] t;\n private static bool[, , ,] dp = new bool[301, 301, 8, 30];\n private static int[][] dir = new int[][] \n {\n new int[] { 0, 1 },\n new int[] { -1, 1 },\n new int[] { -1, 0 },\n new int[] { -1, -1 },\n new int[] { 0, -1 },\n new int[] { 1, -1 },\n new int[] { 1, 0 },\n new int[] { 1, 1 }\n };\n private static bool[,] grid = new bool[301, 301];\n\n public static void Main(string[] args)\n {\n using (FastScanner fs = new FastScanner(new BufferedStream(Console.OpenStandardInput())))\n using (StreamWriter writer = new StreamWriter(new BufferedStream(Console.OpenStandardOutput())))\n {\n n = fs.NextInt();\n t = Array.ConvertAll(fs.ReadLine().Split(), Convert.ToInt32);\n Fire(151, 150, 2, 0);\n int count = 0;\n for (int i = 0; i < 301; i++)\n {\n for (int j = 0; j < 301; j++)\n {\n if (grid[i, j]) count++;\n }\n }\n writer.WriteLine(count);\n }\n }\n public static void Fire(int i, int j, int direction, int iteration)\n {\n if (iteration == n || dp[i, j, direction, iteration]) return;\n dp[i, j, direction, iteration] = true;\n int di = dir[direction][0], dj = dir[direction][1];\n int lifeTime = t[iteration];\n while (lifeTime-- > 0)\n {\n i += di;\n j += dj;\n grid[i, j] = true;\n }\n Fire(i, j, direction == 0 ? 7 : direction - 1, iteration + 1);\n Fire(i, j, direction == 7 ? 0 : direction + 1, iteration + 1);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["dfs and similar", "brute force", "dp", "data structures", "implementation"], "code_uid": "5823e532dcae06b87ea705ac0315d170", "src_uid": "a96bc7f93fe9d9d4b78018b49bbc68d9", "difficulty": 1900.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Linq.Expressions;\nusing System.IO;\nusing System.Text;\nusing System.Diagnostics;\n\nusing Binary = System.Func;\nusing Unary = System.Func;\n\nclass Program\n{\n static StreamWriter sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };\n static Scan sc = new Scan();\n// static Scan sc = new ScanCHK();\n const int M = 1000000007;\n const double eps = 1e-9;\n static readonly int[] dd = { 0, 1, 0, -1, 0 };\n static readonly int[] dx = { 0, 1, 1, 1, 0, -1, -1, -1 };\n static readonly int[] dy = { 1, 1, 0, -1, -1, -1, 0, 1 };\n static int n;\n static int[] t;\n static bool[][] fw;\n static bool[][][][] vis;\n static void Main()\n {\n n = sc.Int;\n t = sc.IntArr;\n int lim = (n + 1) * 10;\n int m = (n + 1) * 5;\n fw = new bool[lim][];\n vis = new bool[n][][][];\n for (int i = 0; i < lim; i++)\n {\n fw[i] = new bool[lim];\n }\n for (int i = 0; i < n; i++)\n {\n vis[i] = new bool[lim][][];\n for (int j = 0; j < lim; j++)\n {\n vis[i][j] = new bool[lim][];\n for (int k = 0; k < lim; k++)\n {\n vis[i][j][k] = new bool[8];\n }\n }\n }\n dfs(0, m, m, 0);\n int ans = 0;\n foreach (var i in fw)\n {\n foreach (var j in i)\n {\n if (j) ++ans;\n }\n }\n Prt(ans);\n sw.Flush();\n }\n static void dfs(int dep, int x, int y, int d)\n {\n if (dep == n || vis[dep][x][y][d]) return;\n\n vis[dep][x][y][d] = true;\n\n for (int i = 0; i < t[dep]; i++)\n {\n x += dx[d];\n y += dy[d];\n fw[x][y] = true;\n }\n dfs(dep + 1, x, y, (d + 1) % 8);\n dfs(dep + 1, x, y, (d + 7) % 8);\n }\n\n static void swap(ref T a, ref T b) { var t = a; a = b; b = t; }\n static T Max(params T[] a) => a.Max();\n static T Min(params T[] a) => a.Min();\n static void DBG(params T[] a) => Console.WriteLine(string.Join(\" \", a));\n static void DBG(params object[] a) => Console.WriteLine(string.Join(\" \", a));\n static void Prt(params T[] a) => sw.WriteLine(string.Join(\" \", a));\n static void Prt(params object[] a) => sw.WriteLine(string.Join(\" \", a));\n}\nstatic class ex\n{\n public static string con(this IEnumerable a) => a.con(\" \");\n public static string con(this IEnumerable a, string s) => string.Join(s, a);\n public static void swap(this IList a, int i, int j) { var t = a[i]; a[i] = a[j]; a[j] = t; }\n public static T[] copy(this IList a)\n {\n var ret = new T[a.Count];\n for (int i = 0; i < a.Count; i++) ret[i] = a[i];\n return ret;\n }\n}\nstatic class Operator\n{\n static readonly ParameterExpression x = Expression.Parameter(typeof(T), \"x\");\n static readonly ParameterExpression y = Expression.Parameter(typeof(T), \"y\");\n public static readonly Func Add = Lambda(Expression.Add);\n public static readonly Func Subtract = Lambda(Expression.Subtract);\n public static readonly Func Multiply = Lambda(Expression.Multiply);\n public static readonly Func Divide = Lambda(Expression.Divide);\n public static readonly Func Plus = Lambda(Expression.UnaryPlus);\n public static readonly Func Negate = Lambda(Expression.Negate);\n public static Func Lambda(Binary op) => Expression.Lambda>(op(x, y), x, y).Compile();\n public static Func Lambda(Unary op) => Expression.Lambda>(op(x), x).Compile();\n}\n\nclass ScanCHK : Scan\n{\n public new string Str { get { var s = Console.ReadLine(); if (s != s.Trim()) throw new Exception(); return s; } }\n}\nclass Scan\n{\n public int Int => int.Parse(Str);\n public long Long => long.Parse(Str);\n public double Double => double.Parse(Str);\n public string Str => Console.ReadLine().Trim();\n public int[] IntArr => StrArr.Select(int.Parse).ToArray();\n public long[] LongArr => StrArr.Select(long.Parse).ToArray();\n public double[] DoubleArr => StrArr.Select(double.Parse).ToArray();\n public string[] StrArr => Str.Split();\n bool eq() => typeof(T).Equals(typeof(U));\n T ct(U a) => (T)Convert.ChangeType(a, typeof(T));\n T cv(string s) => eq() ? ct(int.Parse(s))\n : eq() ? ct(long.Parse(s))\n : eq() ? ct(double.Parse(s))\n : eq() ? ct(s[0]) : ct(s);\n public void Multi(out T a) => a = cv(Str);\n public void Multi(out T a, out U b)\n { var ar = StrArr; a = cv(ar[0]); b = cv(ar[1]); }\n public void Multi(out T a, out U b, out V c)\n { var ar = StrArr; a = cv(ar[0]); b = cv(ar[1]); c = cv(ar[2]); }\n public void Multi(out T a, out U b, out V c, out W d)\n { var ar = StrArr; a = cv(ar[0]); b = cv(ar[1]); c = cv(ar[2]); d = cv(ar[3]); }\n public void Multi(out T a, out U b, out V c, out W d, out X e)\n { var ar = StrArr; a = cv(ar[0]); b = cv(ar[1]); c = cv(ar[2]); d = cv(ar[3]); e = cv(ar[4]); }\n}\nclass mymath\n{\n public static long Mod = 1000000007;\n public static bool isprime(long a)\n {\n if (a < 2) return false;\n for (long i = 2; i * i <= a; i++) if (a % i == 0) return false;\n return true;\n }\n public static bool[] sieve(int n)\n {\n var p = new bool[n + 1];\n for (int i = 2; i <= n; i++) p[i] = true;\n for (int i = 2; i * i <= n; i++) if (p[i]) for (int j = i * i; j <= n; j += i) p[j] = false;\n return p;\n }\n public static List getprimes(int n)\n {\n var prs = new List();\n var p = sieve(n);\n for (int i = 2; i <= n; i++) if (p[i]) prs.Add(i);\n return prs;\n }\n public static long[][] E(int n)\n {\n var ret = new long[n][];\n for (int i = 0; i < n; i++) { ret[i] = new long[n]; ret[i][i] = 1; }\n return ret;\n }\n public static long[][] pow(long[][] A, long n)\n {\n if (n == 0) return E(A.Length);\n var t = pow(A, n / 2);\n if ((n & 1) == 0) return mul(t, t);\n return mul(mul(t, t), A);\n }\n public static double dot(double[] x, double[] y)\n {\n int n = x.Length;\n double ret = 0;\n for (int i = 0; i < n; i++) ret += x[i] * y[i];\n return ret;\n }\n public static long dot(long[] x, long[] y)\n {\n int n = x.Length;\n long ret = 0;\n for (int i = 0; i < n; i++) ret = (ret + x[i] * y[i]) % Mod;\n return ret;\n }\n public static T[][] trans(T[][] A)\n {\n int n = A[0].Length, m = A.Length;\n var ret = new T[n][];\n for (int i = 0; i < n; i++) { ret[i] = new T[m]; for (int j = 0; j < m; j++) ret[i][j] = A[j][i]; }\n return ret;\n }\n public static double[] mul(double[][] A, double[] x)\n {\n int n = A.Length;\n var ret = new double[n];\n for (int i = 0; i < n; i++) ret[i] = dot(x, A[i]);\n return ret;\n }\n public static long[] mul(long[][] A, long[] x)\n {\n int n = A.Length;\n var ret = new long[n];\n for (int i = 0; i < n; i++) ret[i] = dot(x, A[i]);\n return ret;\n }\n public static long[][] mul(long[][] A, long[][] B)\n {\n int n = A.Length;\n var Bt = trans(B);\n var ret = new long[n][];\n for (int i = 0; i < n; i++) ret[i] = mul(Bt, A[i]);\n return ret;\n }\n public static long[] add(long[] x, long[] y)\n {\n int n = x.Length;\n var ret = new long[n];\n for (int i = 0; i < n; i++) ret[i] = (x[i] + y[i]) % Mod;\n return ret;\n }\n public static long[][] add(long[][] A, long[][] B)\n {\n int n = A.Length;\n var ret = new long[n][];\n for (int i = 0; i < n; i++) ret[i] = add(A[i], B[i]);\n return ret;\n }\n public static long pow(long a, long b)\n {\n if (a >= Mod) return pow(a % Mod, b);\n if (a == 0) return 0;\n if (b == 0) return 1;\n var t = pow(a, b / 2);\n if ((b & 1) == 0) return t * t % Mod;\n return t * t % Mod * a % Mod;\n }\n public static long inv(long a) => pow(a, Mod - 2);\n public static long gcd(long a, long b)\n {\n while (b > 0) { var t = a % b; a = b; b = t; }\n return a;\n }\n // a x + b y = gcd(a, b)\n public static long extgcd(long a, long b, out long x, out long y)\n {\n long g = a; x = 1; y = 0;\n if (b > 0) { g = extgcd(b, a % b, out y, out x); y -= a / b * x; }\n return g;\n }\n public static long lcm(long a, long b) => a / gcd(a, b) * b;\n public static long comb(int n, int r)\n {\n if (n < 0 || r < 0 || r > n) return 0;\n if (n - r < r) r = n - r;\n if (r == 0) return 1;\n if (r == 1) return n;\n int[] numer = new int[r], denom = new int[r];\n for (int k = 0; k < r; k++) { numer[k] = n - r + k + 1; denom[k] = k + 1; }\n for (int p = 2; p <= r; p++)\n {\n int piv = denom[p - 1];\n if (piv > 1)\n {\n int ofst = (n - r) % p;\n for (int k = p - 1; k < r; k += p) { numer[k - ofst] /= piv; denom[k] /= piv; }\n }\n }\n long ret = 1;\n for (int k = 0; k < r; k++) if (numer[k] > 1) ret = ret * numer[k] % Mod;\n return ret;\n }\n}\n", "lang_cluster": "C#", "tags": ["dfs and similar", "brute force", "dp", "data structures", "implementation"], "code_uid": "d939dc3b3b3f1274f6ac6ae635c4843c", "src_uid": "a96bc7f93fe9d9d4b78018b49bbc68d9", "difficulty": 1900.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Collections;\nusing System.Linq;\nusing System.Numerics;\nusing System.Text;\n\n\n\nnamespace contest\n{\n\n \n\n \n\n class contest\n {\n\n\n static void Main(string[] args)\n {\n\n\n\n\n\n //var num = Console.ReadLine().Split().Select(int.Parse).ToArray();\n //int n = num[0];\n //int m = num[1];\n\n //var input = Console.ReadLine().Split().Select(int.Parse).ToArray();\n\n\n\n\n //int n = int.Parse(Console.ReadLine());\n\n //var num = Console.ReadLine().Split().Select(int.Parse).ToArray();\n //for (int i = 0; i < n; i++)\n //{\n // input[i] = Console.ReadLine().Split().Select(int.Parse).ToArray();\n\n //}\n\n\n //int n = int.Parse(Console.ReadLine());\n //var num = Console.ReadLine().Split().Select(int.Parse).ToArray();\n //int n = num[0];\n //int m = num[1];\n\n\n\n //int n = int.Parse(Console.ReadLine());\n //var arr = new int[n][];//Console.ReadLine().Split().Select(int.Parse).ToArray();\n //for(int i =0; i< n; i++)\n //{\n // arr[i] = Console.ReadLine().Split().Select(int.Parse).ToArray();\n //}\n\n\n\n\n //int n = int.Parse(Console.ReadLine());\n //var num = Console.ReadLine().Split().Select(int.Parse).ToArray();\n\n\n\n //var num = Console.ReadLine().Split().Select(int.Parse).ToArray();\n //var tastes = Console.ReadLine().Split().Select(int.Parse).ToArray(); \n //int n = int.Parse(Console.ReadLine());\n //var arr = new int[n][];\n //for(int i =0; i< n; i++)\n //{\n // arr[i] = Console.ReadLine().Split().Select(int.Parse).ToArray();\n //}\n\n\n\n\n\n int n = int.Parse(Console.ReadLine());\n var num = Console.ReadLine().Split().Select(int.Parse).ToArray();\n\n int count = 0;\n\n var map = new bool[301,301];\n var set = new HashSet>();\n\n var next = new List>();\n for(int i =0; i< n; i++)\n {\n int cur = num[i];\n if(i==0)\n {\n int x = 150;\n int y = 150;\n\n for(int j=0; j>();\n for(int m=0; m>(memo);\n }\n }\n\n //for (int i = 0; i < 301; i++)\n //{\n // for (int j = 0; j < 301; j++)\n // {\n // if (map[i, j])\n // {\n // count++;\n // }\n // }\n //}\n\n Console.WriteLine(count);\n\n\n\n\n\n\n //Console.WriteLine();\n\n\n\n\n\n \n }\n\n public static bool[,] one(int cur,int y, int x,ref bool[,] map, ref int count)\n {\n for(int i = 1; i<=cur; i++)\n {\n if(!map[y-i,x])\n {\n map[y - i, x] = true;\n count++;\n }\n }\n return map;\n }\n\n public static bool[,] two(int cur, int y, int x,ref bool[,] map, ref int count)\n {\n for (int i = 1; i <= cur; i++)\n {\n if (!map[y, x+i])\n {\n map[y , x+i] = true;\n count++;\n }\n }\n return map;\n }\n\n public static bool[,] three(int cur, int y, int x,ref bool[,] map, ref int count)\n {\n for (int i = 1; i <= cur; i++)\n {\n if (!map[y + i, x])\n {\n map[y + i, x] = true;\n count++;\n }\n }\n return map;\n }\n\n public static bool[,] four(int cur, int y, int x,ref bool[,] map, ref int count)\n {\n for (int i = 1; i <= cur; i++)\n {\n if (!map[y , x-i])\n {\n map[y , x-i] = true;\n count++;\n }\n }\n return map;\n }\n\n public static bool[,] five(int cur, int y, int x,ref bool[,] map, ref int count)\n {\n for (int i = 1; i <= cur; i++)\n {\n if (!map[y - i, x+i])\n {\n map[y - i, x+i] = true;\n count++;\n }\n }\n return map;\n }\n\n public static bool[,] six(int cur, int y, int x,ref bool[,] map, ref int count)\n {\n for (int i = 1; i <= cur; i++)\n {\n if (!map[y + i, x+i])\n {\n map[y + i, x+i] = true;\n count++;\n }\n }\n return map;\n }\n\n public static bool[,] seven(int cur, int y, int x,ref bool[,] map, ref int count)\n {\n for (int i = 1; i <= cur; i++)\n {\n if (!map[y + i, x-i])\n {\n map[y + i, x-i] = true;\n count++;\n }\n }\n return map;\n }\n\n public static bool[,] eight(int cur, int y, int x,ref bool[,] map, ref int count)\n {\n for (int i = 1; i <= cur; i++)\n {\n if (!map[y - i, x-i])\n {\n map[y - i, x-i] = true;\n count++;\n }\n }\n return map;\n }\n\n\n }\n\n\n class Segment\n {\n //public int[] arr;\n public Tuple[] arr;\n int n;\n\n public Segment(int n)\n {\n this.n = n * 2;\n //arr = Enumerable.Range(0, n*2).ToArray();\n //arr = new int[this.n];\n arr = new Tuple[this.n];\n for (int i = 0; i < this.n; i++)\n {\n arr[i] = Tuple.Create(0,0,0,0,0);\n }\n\n }\n\n public void update(int i, int x)\n {\n i = (n / 2) + i - 1;\n //arr[i] = 1;\n if (x == 2) arr[i] = Tuple.Create(1, 0, 0, 0, 0);\n else if (x == 0) arr[i] = Tuple.Create( 0,1, 0, 0, 0);\n else if (x == 1) arr[i] = Tuple.Create(0,0,1,0,0);\n else if (x == 6) arr[i] = Tuple.Create( 0, 0, 0,1, 0);\n else if (x == 7) arr[i] = Tuple.Create( 0, 0, 0, 0,1);\n\n while (i > 0)\n {\n i = (i - 1) / 2;\n //arr[i] = Math.Max(arr[i*2+1], arr[i*2+2]);\n //if (arr[i * 2 + 1] > arr[i * 2 + 2])\n //{\n // arr[i] = arr[i*2+1];\n //}\n //else\n //{\n // arr[i] = arr[i*2+2];\n //}\n //arr[i] = arr[i * 2 + 1] + arr[i * 2 + 2];\n arr[i] = Tuple.Create(arr[i*2+1].Item1+ arr[i*2+2].Item1,\n arr[i * 2 + 1].Item2 + arr[i * 2 + 2].Item2,\n arr[i * 2 + 1].Item3 + arr[i * 2 + 2].Item3,\n arr[i * 2 + 1].Item4 + arr[i * 2 + 2].Item4,\n arr[i * 2 + 1].Item5 + arr[i * 2 + 2].Item5);\n }\n\n }\n\n //call : query(a,b, 0, 0, n)\n public Tuple query(int a, int b, int k, int l, int r)\n {\n if (r <= a || b <= l) return Tuple.Create(0,0,0,0,0);\n if (a <= l && r <= b) return arr[k];\n else\n {\n\n\n\n\n var vl = query(a, b, k * 2 + 1, l, (l + r) / 2);\n var vr = query(a, b, k * 2 + 2, (l + r) / 2, r);\n\n\n\n //if (vl.Item4 > vr.Item4)\n //{\n // return vl;\n //}\n ////else if (vl.Item4 == vr.Item4)\n ////{\n //// if (countA >= countB) return vr;\n //// else return vl;\n ////}\n //else return vr;\n\n\n return Tuple.Create(vl.Item1 + vr.Item1,\n vl.Item2 + vr.Item2,\n vl.Item3 + vr.Item3,\n vl.Item4 + vr.Item4,\n vl.Item5 + vr.Item5);\n\n\n //return Math.Max(vl, vr);\n //return vl\n int countA = 0;\n int countB = 0;\n if (vl.Item1 == 0) countA++;\n if (vl.Item2 == 0) countA++;\n if (vl.Item3 == 0) countA++;\n if (vl.Item4 == 0) countA++;\n if (vl.Item5 == 0) countA++;\n\n if (vr.Item1 == 0) countB++;\n if (vr.Item2 == 0) countB++;\n if (vr.Item3 == 0) countB++;\n if (vr.Item4 == 0) countB++;\n if (vr.Item5 == 0) countB++;\n\n\n if((vl.Item1==0 && vr.Item1>0))\n {\n return vr;\n }\n else if ((vl.Item1 > 0 && vr.Item1 == 0))\n {\n return vl;\n }\n else if ((vl.Item2 == 0 && vr.Item2 > 0))\n {\n return vr;\n }\n else if ((vl.Item2 > 0 && vr.Item2 == 0))\n {\n return vl;\n }\n else if ((vl.Item3 == 0 && vr.Item3 > 0))\n {\n return vr;\n }\n else if ((vl.Item3 > 0 && vr.Item3 == 0))\n {\n return vl;\n }\n else if ((vl.Item4 == 0 && vr.Item4 > 0))\n {\n return vr;\n }\n else if ((vl.Item4 > 0 && vr.Item4 == 0))\n {\n return vl;\n }\n else if ((vl.Item5 == 0 && vr.Item5 > 0))\n {\n return vr;\n }\n else if ((vl.Item5 > 0 && vr.Item5 == 0))\n {\n return vl;\n }\n\n if (vl.Item4 > vr.Item4)\n {\n return vl;\n }\n else if (vl.Item4 == vr.Item4)\n {\n if (countA >= countB) return vr;\n else return vl;\n }\n else return vr;\n\n //if (countA <= countB) return vl;\n //else return vr;\n }\n }\n\n\n }\n\n\n class UnionFind\n {\n public int[] path;\n\n\n public UnionFind(int n)\n {\n path = new int[n];\n\n for (int i = 0; i < n; i++)\n {\n path[i] = i;\n }\n\n }\n\n private int root(int i)\n {\n while (i != path[i])\n {\n path[i] = path[path[i]];\n i = path[i];\n }\n return i;\n }\n\n\n\n public bool find(int p, int q)\n {\n return root(p) == root(q);\n }\n\n\n\n public void unite(int p, int q)\n {\n int i = root(p);\n int j = root(q);\n path[i] = j;\n }\n\n\n }\n}\n", "lang_cluster": "C#", "tags": ["dfs and similar", "brute force", "dp", "data structures", "implementation"], "code_uid": "4898688f8a22440712f14008b7d0f663", "src_uid": "a96bc7f93fe9d9d4b78018b49bbc68d9", "difficulty": 1900.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.IO;\nusing System.Text;\n\nnamespace New_Year_and_Fireworks\n{\n internal class Program\n {\n private static readonly StreamReader reader = new StreamReader(Console.OpenStandardInput(1024*10), Encoding.ASCII, false, 1024*10);\n private static readonly StreamWriter writer = new StreamWriter(Console.OpenStandardOutput(1024*10), Encoding.ASCII, 1024*10);\n\n private static void Main(string[] args)\n {\n int n = Next();\n\n var nn = new int[n];\n for (int i = 0; i < n; i++)\n {\n nn[i] = Next();\n }\n\n var dx = new[] {0, 1, 1, 1, 0, -1, -1, -1};\n var dy = new[] {1, 1, 0, -1, -1, -1, 0, 1};\n var move = new[,]\n {\n {7, 1}, {0, 2}, {1, 3}, {2, 4}, {3, 5}, {4, 6}, {5, 7}, {6, 0}\n };\n\n\n var pole = new int[400,400];\n\n var q = new Queue>();\n q.Enqueue(new Tuple(200, 200, 0));\n\n for (int i = 0; i < n; i++)\n {\n var next = new Queue>();\n var f = new bool[400,400,8];\n\n while (q.Count > 0)\n {\n Tuple point = q.Dequeue();\n int x = point.Item1;\n int y = point.Item2;\n for (int j = 0; j < nn[i]; j++)\n {\n x = x + dx[point.Item3];\n y = y + dy[point.Item3];\n pole[x, y] = 1;\n }\n\n for (int j = 0; j < 2; j++)\n {\n int dir = move[point.Item3, j];\n if (!f[x, y, dir])\n {\n f[x, y, dir] = true;\n next.Enqueue(new Tuple(x, y, dir));\n }\n }\n }\n\n q = next;\n }\n\n int count = 0;\n for (int i = 0; i < 400; i++)\n {\n for (int j = 0; j < 400; j++)\n {\n count += pole[i, j];\n }\n }\n writer.WriteLine(count);\n writer.Flush();\n }\n\n private static int Next()\n {\n int c;\n int res = 0;\n do\n {\n c = reader.Read();\n if (c == -1)\n return res;\n } while (c < '0' || c > '9');\n res = c - '0';\n while (true)\n {\n c = reader.Read();\n if (c < '0' || c > '9')\n return res;\n res *= 10;\n res += c - '0';\n }\n }\n }\n}", "lang_cluster": "C#", "tags": ["dfs and similar", "brute force", "dp", "data structures", "implementation"], "code_uid": "67df632509ae91d4dba39bc9e78656c7", "src_uid": "a96bc7f93fe9d9d4b78018b49bbc68d9", "difficulty": 1900.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Linq;\nusing System.Collections.Generic;\nusing Debug = System.Diagnostics.Debug;\nusing StringBuilder = System.Text.StringBuilder;\n//using System.Numerics;\n//using Point = System.Numerics.Complex;\n//using Number = System.Int64;\nnamespace Program\n{\n public class Solver\n {\n\n public void Solve()\n {\n var n = sc.Integer();\n var a = sc.Integer(n);\n int[] dx = { 0, 1, 1, 1, 0, -1, -1, -1 };\n int[] dy = { 1, 1, 0, -1, -1, -1, 0, 1 };\n var otaku = new bool[400, 400];\n var dp = new int[400, 400];\n const int X = 200;\n dp[X, X] = 1;\n foreach (var x in a)\n {\n var next = new int[400, 400];\n for (int i = 0; i < 400; i++)\n for (int j = 0; j < 400; j++)\n {\n if (dp[i, j] == 0) continue;\n for (int d = 0; d < 8; d++)\n {\n if ((dp[i, j] >> d & 1) == 0) continue;\n for (int v = 1; v <= x; v++)\n otaku[i + dx[d] * v, j + dy[d] * v] = true;\n next[i + dx[d] * x, j + dy[d] * x] |= 1 << ((d + 1) % 8);\n next[i + dx[d] * x, j + dy[d] * x] |= 1 << ((d + 7) % 8);\n }\n }\n\n dp = next;\n }\n IO.Printer.Out.WriteLine(otaku.Cast().Count(x => x));\n\n\n\n }\n\n public IO.StreamScanner sc = new IO.StreamScanner(Console.OpenStandardInput());\n static T[] Enumerate(int n, Func f) { var a = new T[n]; for (int i = 0; i < n; ++i) a[i] = f(i); return a; }\n static public void Swap(ref T a, ref T b) { var tmp = a; a = b; b = tmp; }\n }\n}\n\n#region main\nstatic class Ex\n{\n //static public string AsString(this IEnumerable ie) { return new string(System.Linq.Enumerable.ToArray(ie)); }\n //static public string AsJoinedString(this IEnumerable ie, string st = \" \") { return string.Join(st, ie); }\n static public void Main()\n {\n var solver = new Program.Solver();\n solver.Solve();\n Program.IO.Printer.Out.Flush();\n }\n}\n#endregion\n#region Ex\nnamespace Program.IO\n{\n using System.IO;\n using System.Text;\n using System.Globalization;\n public class Printer: StreamWriter\n {\n static Printer() { Out = new Printer(Console.OpenStandardOutput()) { AutoFlush = false }; }\n public static Printer Out { get; set; }\n public override IFormatProvider FormatProvider { get { return CultureInfo.InvariantCulture; } }\n public Printer(System.IO.Stream stream) : base(stream, new UTF8Encoding(false, true)) { }\n public Printer(System.IO.Stream stream, Encoding encoding) : base(stream, encoding) { }\n public void Write(string format, T[] source) { base.Write(format, source.OfType().ToArray()); }\n public void WriteLine(string format, T[] source) { base.WriteLine(format, source.OfType().ToArray()); }\n }\n public class StreamScanner\n {\n public StreamScanner(Stream stream) { str = stream; }\n public readonly Stream str;\n private readonly byte[] buf = new byte[1024];\n private int len, ptr;\n public bool isEof = false;\n public bool IsEndOfStream { get { return isEof; } }\n private byte read()\n {\n if (isEof) return 0;\n if (ptr >= len) { ptr = 0; if ((len = str.Read(buf, 0, 1024)) <= 0) { isEof = true; return 0; } }\n return buf[ptr++];\n }\n public char Char() { byte b = 0; do b = read(); while ((b < 33 || 126 < b) && !isEof); return (char)b; }\n\n public string Scan()\n {\n var sb = new StringBuilder();\n for (var b = Char(); b >= 33 && b <= 126; b = (char)read())\n sb.Append(b);\n return sb.ToString();\n }\n public string ScanLine()\n {\n var sb = new StringBuilder();\n for (var b = Char(); b != '\\n'; b = (char)read())\n if (b == 0) break;\n else if (b != '\\r') sb.Append(b);\n return sb.ToString();\n }\n public long Long()\n {\n if (isEof) return long.MinValue;\n long ret = 0; byte b = 0; var ng = false;\n do b = read();\n while (b != 0 && b != '-' && (b < '0' || '9' < b));\n if (b == 0) return long.MinValue;\n if (b == '-') { ng = true; b = read(); }\n for (; true; b = read())\n {\n if (b < '0' || '9' < b)\n return ng ? -ret : ret;\n else ret = ret * 10 + b - '0';\n }\n }\n public int Integer() { return (isEof) ? int.MinValue : (int)Long(); }\n public double Double() { var s = Scan(); return s != \"\" ? double.Parse(s, CultureInfo.InvariantCulture) : double.NaN; }\n private T[] enumerate(int n, Func f)\n {\n var a = new T[n];\n for (int i = 0; i < n; ++i) a[i] = f();\n return a;\n }\n\n public char[] Char(int n) { return enumerate(n, Char); }\n public string[] Scan(int n) { return enumerate(n, Scan); }\n public double[] Double(int n) { return enumerate(n, Double); }\n public int[] Integer(int n) { return enumerate(n, Integer); }\n public long[] Long(int n) { return enumerate(n, Long); }\n }\n}\n#endregion\n", "lang_cluster": "C#", "tags": ["dfs and similar", "brute force", "dp", "data structures", "implementation"], "code_uid": "aa70b206dc6dbf0011c1d0a456fbfe7d", "src_uid": "a96bc7f93fe9d9d4b78018b49bbc68d9", "difficulty": 1900.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\n\nclass B869 {\n public static void Main() {\n var line = Console.ReadLine().Split();\n var a = long.Parse(line[0]);\n var b = long.Parse(line[1]);\n if (10L <= b - a) Console.WriteLine(0);\n else {\n long answer = 1;\n for (long i = a + 1; i <= b; ++i)\n answer = answer * (i % 10) % 10;\n Console.WriteLine(answer);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math"], "code_uid": "29200c2e1ab4b28089d28a362246b6e8", "src_uid": "2ed5a7a6176ed9b0bda1de21aad13d60", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace _869B\n{\n class Program\n {\n static void Main(string[] args)\n {\n\n long a, b, ans = 1, helper_1;\n var token = Console.ReadLine().Split().Select(long.Parse);\n long[] token_1 = new long[2];\n token_1 = token.ToArray();\n\n // token_1 = token.ToArray();\n a = token_1[0];\n b = token_1[1]; ;\n long rezalt = b % 10;\n if (a == b) ans = 1;\n else if (b - a == 1) ans = b % 10;\n else if (b % 10 == 0) ans = 0;\n else\n {\n helper_1 = b % 10 - 1;\n ans = b % 10;\n\n long counter = b - a - 1;\n while (counter-- != 0)\n {\n\n\n ans = ans * helper_1;\n if (helper_1 == 0)\n {\n ans = 0;\n break;\n }\n helper_1--;\n\n }\n //for (; ; counter--)\n //{\n // ans = ans * helper_1 ;\n // helper_1--;\n //}\n }\n\n Console.Write(ans % 10);\n\n token = null;\n token_1 = null;\n // Console.ReadKey();\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math"], "code_uid": "30ecbafb9f7c2ac1aa51c29ee03d1a58", "src_uid": "2ed5a7a6176ed9b0bda1de21aad13d60", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\n\nnamespace ProgrammingContest.Codeforces.Round46\n{\n class B\n {\n static int calc(int[] xs, int m, int[] ys, int n, int b)\n {\n int res = 0, c = 0, i = 0;\n for (int r = 1; i < Math.Max(m, n) || c != 0; i++, r*=b)\n {\n int x = xs[i] + ys[i] + c;\n res += x % b * r;\n c = x / b;\n }\n return i;\n }\n\n public static void Main()\n {\n Scanner scanner = Scanner.FromConsole();\n int a = scanner.NextInt(), b = scanner.NextInt();\n int[] xs = new int[15], ys = new int[15];\n int m = 0, n = 0;\n for (; a > 0; a /= 10) xs[m++] = a % 10;\n for (; b > 0; b /= 10) ys[n++] = b % 10;\n for (int i = 2; i <= 16; i++)\n {\n bool ok = true;\n for (int j = 0; j < Math.Max(m, n); j++)\n if (xs[j] >= i || ys[j] >= i)\n ok = false;\n if (ok)\n {\n Console.WriteLine(calc(xs, m, ys, n, i));\n break;\n }\n }\n }\n\n #region Scanner\n public class Scanner : IDisposable\n {\n const int MAX_BUFFER_SIZE = 1024 * 1024 * 16;\n const string DELIMITER = \" \\r\\n\\t\";\n\n System.IO.TextReader stream;\n int pos = 0, len = 0;\n bool endStream = false;\n int BufferSize = MAX_BUFFER_SIZE;\n char[] buffer = new char[MAX_BUFFER_SIZE];\n\n public enum Option { Buffering, NoBuffering }\n\n public Scanner(System.IO.TextReader stream, Option bufferingOption)\n {\n this.stream = stream;\n if (bufferingOption == Option.NoBuffering) BufferSize = 1;\n }\n\n void ReadBuffer()\n {\n pos = 0;\n len = stream.ReadBlock(buffer, 0, BufferSize);\n endStream = len == 0;\n }\n\n void SkipDelimiter()\n {\n while (!endStream && IsDelimiter(Peek())) NextChar();\n }\n\n static bool IsDelimiter(char c)\n {\n return DELIMITER.Contains(c);\n }\n\n bool Continue(char c)\n {\n return !endStream && !IsDelimiter(c);\n }\n\n char Peek()\n {\n if (pos >= len) ReadBuffer();\n return buffer[pos];\n }\n\n public char NextChar()\n {\n if (pos >= len) ReadBuffer();\n return buffer[pos++];\n }\n\n public string NextString()\n {\n SkipDelimiter();\n StringBuilder res = new StringBuilder();\n for (char c = NextChar(); Continue(c); c = NextChar()) res.Append(c);\n return res.ToString();\n }\n\n public int NextInt()\n {\n SkipDelimiter();\n int res = 0;\n char c = NextChar();\n int sign = 1;\n if (c == '-') { sign = -1; c = NextChar(); }\n for (; Continue(c); c = NextChar())\n res = res * 10 + (c - '0');\n return sign * res;\n }\n\n public long NextLong()\n {\n SkipDelimiter();\n long res = 0;\n char c = NextChar();\n long sign = 1;\n if (c == '-') { sign = -1; c = NextChar(); }\n for (; Continue(c); c = NextChar())\n res = res * 10 + (c - '0');\n return sign * res;\n }\n\n public double NextDouble()\n {\n return double.Parse(NextString());\n }\n\n public int[] NextInts(int n)\n {\n int[] res = new int[n];\n for (int i = 0; i < n; i++) res[i] = NextInt();\n return res;\n }\n\n public long[] NextLongs(int n)\n {\n long[] res = new long[n];\n for (int i = 0; i < n; i++) res[i] = NextLong();\n return res;\n }\n\n public double[] NextDoubles(int n)\n {\n double[] res = new double[n];\n for (int i = 0; i < n; i++) res[i] = NextDouble();\n return res;\n }\n\n public string[] NextStrings(int n)\n {\n string[] res = new string[n];\n for (int i = 0; i < n; i++) res[i] = NextString();\n return res;\n }\n\n public static Scanner FromString(string s)\n {\n return new Scanner(new System.IO.StreamReader(new System.IO.MemoryStream(Encoding.ASCII.GetBytes(s))), Option.Buffering);\n }\n\n public static Scanner FromFile(string path)\n {\n return new Scanner(new System.IO.StreamReader(path), Option.Buffering);\n }\n\n public static Scanner FromConsole()\n {\n return new Scanner(Console.In, Option.Buffering);\n }\n\n public void Dispose()\n {\n stream.Close();\n }\n }\n #endregion\n }\n}\n", "lang_cluster": "C#", "tags": ["math"], "code_uid": "379e8c9642245c942cae8355c7bce00a", "src_uid": "8ccfb9b1fef6a992177cc49bd56fab7b", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\n\nnamespace Task49B\n{\n class Program\n {\n static void Main(string[] args)\n {\n int[] tm = Console.ReadLine().Split().Select(int.Parse).ToArray();\n int a = tm[0], b = tm[1];\n int BDa = FindBiggestDigit(a);\n int BDb = FindBiggestDigit(b);\n int BD = Math.Max(BDa, BDb);\n int nbase = BD + 1;\n\n Console.WriteLine(SumInBase(a,b,nbase).Length);\n // Console.ReadKey();\n }\n\n private static int FindBiggestDigit(int a)\n {\n int ans = 0, helper;\n while (a > 0)\n {\n helper = a % 10;\n if (ans < helper)\n ans = helper;\n a /= 10;\n }\n\n return ans;\n }\n\n private static string SumInBase(int a, int b, int nbase)\n {\n string ans = \"\";\n if (a < b)\n {\n int temp = a;\n a = b;\n b = temp;\n }\n\n int leftOver = 0;\n while (b > 0)\n {\n int lastDigitA = a % 10;\n int lastDigitB = b % 10;\n\n int helper = lastDigitA + lastDigitB + leftOver;\n\n if (helper >= nbase)\n {\n helper = ConvertToBase(helper, nbase);\n ans = (helper % 10).ToString() + ans;\n leftOver = helper / 10;\n }\n else {\n ans = helper.ToString() + ans;\n leftOver = 0;\n }\n \n\n\n a /= 10;\n b /= 10;\n\n }\n\n\n while (a > 0)\n {\n int lastDigitA = a % 10;\n int helper = lastDigitA + leftOver;\n if(helper >= nbase)\n {\n helper = ConvertToBase(helper, nbase);\n ans = (helper % 10).ToString() + ans;\n leftOver = helper / 10;\n }\n else\n {\n ans = helper.ToString() + ans;\n leftOver = 0;\n }\n\n a /= 10;\n }\n\n\n if (leftOver != 0)\n ans = leftOver.ToString() + ans;\n\n\n return ans;\n }\n\n private static int ConvertToBase(int num, int nbase)\n {\n int ans = 0;\n List lefts = new List();\n\n while (num > 0)\n {\n lefts.Add(num % nbase);\n num /= nbase;\n }\n\n for (int i = lefts.Count - 1; i >= 0; i--)\n ans = ans * 10 + lefts[i];\n\n return ans;\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math"], "code_uid": "702d89682b4c7e89fd91da274887f8e6", "src_uid": "8ccfb9b1fef6a992177cc49bd56fab7b", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\n\nnamespace Olymp\n{ \n public class ProblemSolver\n {\n public void Solve()\n {\n int n = int.Parse(Console.ReadLine());\n string s = Console.ReadLine();\n var count = new Dictionary { {'B', 0}, {'G', 0}, {'R', 0} };\n foreach (var c in s)\n count[c]++;\n int b = count['B'];\n int g = count['G'];\n int r = count['R'];\n string ans = \"\"; \n if(b > 0 && g > 0 && r > 0 || \n b > 1 && g > 1 && r == 0 || \n b > 1 && g == 0 && r > 1 || \n b == 0 && g > 1 && r > 1)\n ans = \"BGR\";\n else if(b > 1 && g == 1 && r == 0 ||\n b > 1 && r == 1 && g == 0)\n ans = \"GR\";\n else if(g > 1 && b == 1 && r == 0 ||\n g > 1 && r == 1 && b == 0)\n ans = \"BR\";\n else if(r > 1 && b == 1 && g == 0 ||\n r > 1 && g == 1 && b == 0)\n ans = \"BG\"; \n else if (b == 1 && g == 1 && r == 0 || b == 0 && g == 0 && r > 0)\n ans = \"R\";\n else if (b == 1 && g == 0 && r == 1 || b == 0 && g > 0 && r == 0)\n ans = \"G\";\n else if (b == 0 && g == 1 && r == 1 || b > 0 && g == 0 && r == 0)\n ans = \"B\";\n Console.WriteLine(ans);\n }\n }\n \n class Program\n {\n public static void Main(string[] args)\n {\n var solver = new ProblemSolver();\n solver.Solve();\n }\n }\n}", "lang_cluster": "C#", "tags": ["math", "dp", "constructive algorithms"], "code_uid": "7c6b71dadfe756fe4fec1ff830592abf", "src_uid": "4cedd3b70d793bc8ed4a93fc5a827f8f", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System.Linq;\nusing System.Collections.Generic;\nusing System;\n\nclass Program\n{\n public static char GetItem(int[] data)\n {\n while (data[0] + data[1] + data[2] > 1)\n {\n if (data[0] == Math.Min(Math.Min(data[0], data[1]), data[2]))\n {\n int delta = 1;// Math.Min(data[1], data[2]);\n data[0] += delta;\n data[1] -= delta;\n data[2] -= delta;\n }\n else if (data[1] == Math.Min(Math.Min(data[0], data[1]), data[2]))\n {\n int delta = 1;// Math.Min(data[0], data[2]);\n data[1] += delta;\n data[0] -= delta;\n data[2] -= delta;\n }\n else\n {\n int delta = 1;// Math.Min(data[0], data[1]);\n data[2] += delta;\n data[0] -= delta;\n data[1] -= delta;\n }\n }\n if (data[0] == 1)\n return 'R';\n else if (data[1] == 1)\n return 'G';\n else\n return 'B';\n }\n\n public static void Main()\n {\n int[] data = new int[3];\n int n = int.Parse(Console.ReadLine());\n string card = Console.ReadLine();\n foreach (var item in card)\n {\n if (item == 'R')\n ++data[0];\n else if (item == 'G')\n ++data[1];\n else\n ++data[2];\n }\n string res = \"\";\n if (data[0] == 0 && data[1] == 0 || data[1] == 0 && data[2] == 0 || data[0] == 0 && data[2] == 0)\n {\n if (data[0] == 0 && data[1] == 0)\n Console.WriteLine(\"B\");\n else if (data[0] == 0 && data[2] == 0)\n Console.WriteLine(\"G\");\n else\n Console.WriteLine(\"R\");\n }\n else if (data[0] == 0 || data[1] == 0 || data[2] == 0)\n {\n if (data[0] == 0)\n {\n res += \"R\";\n if (data[1] == 1 && data[2] > 1)\n res +=\"G\";\n else if (data[1] > 1 && data[2] == 1)\n res += \"B\";\n else if (data[1] > 1 && data[2] > 1)\n res += \"GB\";\n }\n else if (data[1] == 0)\n {\n res += \"G\";\n if (data[0] == 1 && data[2] > 1)\n res +=\"R\";\n else if (data[0] > 1 && data[2] == 1)\n res += \"B\";\n else if (data[0] > 1 && data[2] > 1)\n res +=\"RB\";\n }\n else\n {\n res += \"B\";\n if (data[1] == 1 && data[0] > 1)\n res += \"G\";\n else if (data[1] > 1 && data[0] == 1)\n res +=\"R\";\n else if (data[1] > 1 && data[0] > 1)\n res += \"GR\";\n }\n char[] arr = res.ToCharArray().OrderBy(x => x).ToArray();\n foreach (var item in arr)\n Console.Write(item);\n }\n else\n {\n Console.WriteLine(\"BGR\");\n }\n }\n}", "lang_cluster": "C#", "tags": ["math", "dp", "constructive algorithms"], "code_uid": "1e1dff88d1b711ebe9fa70b865b4c97a", "src_uid": "4cedd3b70d793bc8ed4a93fc5a827f8f", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\n\nnamespace AllProblems\n{\n class _328B_SheldonAndIcePieces\n {\n public static void Run()\n {\n var t = ReadArray(Console.ReadLine().Trim());\n var s = ReadArray(Console.ReadLine().Trim());\n\n var min = int.MaxValue;\n for (var i = 0; i < 10; i++)\n {\n if(t[i] == 0) continue;\n if (s[i] == 0)\n {\n Console.WriteLine(0);\n return;\n }\n var q = s[i]/t[i];\n if (q < min) min = q;\n }\n Console.WriteLine(min);\n Console.ReadLine();\n }\n\n static int[] ReadArray(string t)\n {\n var n = new int[10];\n foreach (var s in t)\n {\n switch (s)\n {\n case '5':\n n[2]++;\n break;\n case '9':\n n[6]++;\n break;\n default:\n n[s - 48]++;\n break;\n }\n }\n\n return n;\n }\n }\n\n class Program\n {\n static void Main(string[] args)\n {\n _328B_SheldonAndIcePieces.Run();\n }\n }\n}", "lang_cluster": "C#", "tags": ["greedy"], "code_uid": "1f19f81f77f5cdfa047ffb1c97c92fe2", "src_uid": "72a196044787cb8dbd8d350cb60ccc32", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace Graph\n{\n class Program\n {\n static void Main(string[] args)\n {\n string num = Console.ReadLine();\n string str = Console.ReadLine();\n\n int res = 0;\n bool done = false;\n int n = str.Length;\n for (int i = 0; i < n; i++)\n {\n //res = i;\n //Console.WriteLine(i + \" \" + str + \" \" + done + \" \" + n);\n if(str.Length == 0 ){\n Console.WriteLine(res);\n return;\n }\n\n if (!done)\n {\n\n\n for (int j = 0; j < num.Length; j++)\n {\n if (num[j] == '9' || num[j] == '6')\n {\n if (str.IndexOf('9') != -1)\n {\n str = str.Remove(str.IndexOf('9'), 1);\n }\n else\n {\n if (str.IndexOf('6') != -1)\n {\n str = str.Remove(str.IndexOf('6'), 1);\n }\n else\n {\n //Console.WriteLine(\"\u041d\u0435\u0442 \u0434\u0435\u0432\u044f\u0442\u043a\u0438 \u0438 \u0448\u0435\u0441\u0442\u0435\u0440\u043a\u0438\");\n done = true;\n Console.WriteLine(res);\n return;\n }\n }\n }\n else\n {\n if (num[j] == '5' || num[j] == '2')\n {\n if (str.IndexOf('5') != -1)\n {\n str = str.Remove(str.IndexOf('5'), 1);\n }\n else\n {\n if (str.IndexOf('2') != -1)\n {\n str = str.Remove(str.IndexOf('2'), 1);\n }\n else\n {\n //Console.WriteLine(\"\u041d\u0435\u0442 \u0434\u0432\u043e\u0439\u043a\u0438 \u0438 \u043f\u044f\u0442\u0435\u0440\u043a\u0438\");\n done = true;\n Console.WriteLine(res);\n return;\n }\n }\n }\n else {\n if (str.IndexOf(num[j]) != -1)\n {\n str = str.Remove(str.IndexOf(num[j]), 1);\n }\n else {\n //Console.WriteLine(\"\u041d\u0435\u0442 \" + num[j]);\n done = true;\n Console.WriteLine(res);\n return;\n //break;\n }\n \n }\n }\n }\n\n res++;\n }\n }\n\n Console.WriteLine(res);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["greedy"], "code_uid": "3ce15a1f9027b1d2e6ed9f89d8f53182", "src_uid": "72a196044787cb8dbd8d350cb60ccc32", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing CompLib.Util;\n\npublic class Program\n{\n\n public void Solve()\n {\n var sc = new Scanner();\n int n = sc.NextInt();\n string s = sc.Next();\n\n // n\u6587\u5b57 s\u304c\u3042\u308b\n\n // s_i\u306b\u96a3\u63a5\u3059\u308b\u6587\u5b57\u304cs_i\u3088\u308a1\u3064\u5c0f\u3055\u3044\u306a\u3089s_i\u3092\u6d88\u305b\u308b\n\n // \u6d88\u305b\u308b \u6700\u5927\n\n var ar = s.ToCharArray();\n\n for (char c = 'z'; c >= 'b'; c--)\n {\n var stack = new Stack();\n foreach (char ch in ar)\n {\n if (ch == c && stack.Count > 0 && stack.Peek() == c - 1)\n {\n continue;\n }\n else if (ch == c - 1)\n {\n while (stack.Count > 0 && stack.Peek() == c)\n {\n stack.Pop();\n }\n stack.Push(ch);\n }\n else\n {\n stack.Push(ch);\n }\n }\n\n ar = new char[stack.Count];\n for (int i = ar.Length - 1; i >= 0; i--)\n {\n ar[i] = stack.Pop();\n }\n }\n\n Console.WriteLine(n - ar.Length);\n }\n\n public static void Main(string[] args) => new Program().Solve();\n}\n\nnamespace CompLib.Util\n{\n using System;\n using System.Linq;\n\n class Scanner\n {\n private string[] _line;\n private int _index;\n private const char Separator = ' ';\n\n public Scanner()\n {\n _line = new string[0];\n _index = 0;\n }\n\n public string Next()\n {\n while (_index >= _line.Length)\n {\n _line = Console.ReadLine().Split(Separator);\n _index = 0;\n }\n\n return _line[_index++];\n }\n\n public int NextInt() => int.Parse(Next());\n public long NextLong() => long.Parse(Next());\n public double NextDouble() => double.Parse(Next());\n public decimal NextDecimal() => decimal.Parse(Next());\n public char NextChar() => Next()[0];\n public char[] NextCharArray() => Next().ToCharArray();\n\n public string[] Array()\n {\n _line = Console.ReadLine().Split(Separator);\n _index = _line.Length;\n return _line;\n }\n\n public int[] IntArray() => Array().Select(int.Parse).ToArray();\n public long[] LongArray() => Array().Select(long.Parse).ToArray();\n public double[] DoubleArray() => Array().Select(double.Parse).ToArray();\n public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "greedy", "strings", "constructive algorithms"], "code_uid": "0ceb0f33bdbaf545d70bf107d3885aba", "src_uid": "9ce37bc2d361f5bb8a0568fb479b8a38", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\n\n\nclass Program\n{\n static void test123()\n {\n\n string str = Console.ReadLine();\n var str1 = str.Split(' ');\n\n UInt64 n = Convert.ToUInt64(str1[0]);\n UInt64 m = Convert.ToUInt64(str1[1]);\n UInt64 a = Convert.ToUInt64(str1[2]);\n\n UInt64 a1 = n / a + (UInt64) (n % a > 0 ? 1 : 0);\n UInt64 a2 = m / a + (UInt64) (m % a > 0 ? 1 : 0);\n\n Console.WriteLine(a1 * a2);\n\n }\n\n\n static (char, List) MaxSymbolLowerThan(string str, int maxValue)\n {\n int maxFindedValue = 0;\n int indexOfMax = 0;\n List indexes = new List();\n\n for (int i = 0; i < str.Length; i++)\n {\n if (str[i] > maxFindedValue && (int) str[i] < maxValue) // \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u043a\u0430\u043a \u043e\u043d \u043a\u0430\u0441\u0442\u0443\u0435\u0442\u0441\u044f \u043a \u0438\u043d\u0442\u0443\n {\n indexes.Clear();\n indexes.Add(i);\n maxFindedValue = (int) (str[i]); //Char.GetNumericValue\n }\n else if (maxFindedValue == str[i])\n {\n indexes.Add(i);\n }\n }\n\n return ((char)maxFindedValue, indexes);\n }\n\n static void test3234234()\n {\n int n = Convert.ToInt32(Console.ReadLine());\n\n int steps = 0;\n\n string str = Console.ReadLine();\n\n //int count = 0;\n\n\n int indexOfMax = 0; // \u043d\u0443\u0436\u0435\u043d \u043b\u0438 ?\n\n List indexesOfMax;\n\n char maxSymbol = ' ';\n (maxSymbol, indexesOfMax) = MaxSymbolLowerThan(str, 9999);\n\n //var indexesOfMaxBuffer = indexesOfMax.GetRange(0, n);\n //int[] indexEsOfMaxValue = str.Where(s=>s==maxSymbol).Select()\n\n int minValue = str.Min();\n\n bool ValueWasFinded = false;\n bool LastSymbol = false;\n int countOfIndexes = 123;\n //while (true)\n //{\n //if (n == 1) // \u043b\u0443\u0447\u0448\u0435 \u0447\u0435\u0440\u0435\u0437 n \n //{\n // Console.WriteLine(steps);\n // return;\n //}\n\n //if (LastSymbol && minValue == (int) maxSymbol) // \u0435\u0449\u0435 \u043e\u0434\u0438\u043d \u0444\u043b\u0430\u0433 ? \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u043d\u0435\u0434\u043e\u0434\u0435\u043b\u0430\u043d\u0430 !!!\n //{\n // Console.WriteLine(steps);\n // return;\n //}\n\n\n int j = 0; // \u0438\u043d\u0434\u0435\u043a\u0441 \u0432 IndexesOfMax\n while (true)\n {\n if (countOfIndexes == 0)\n {\n Console.WriteLine(steps);\n return;\n }\n\n\n\n\n if (j < indexesOfMax.Count && indexesOfMax[j] != 0 && str[indexesOfMax[j] - 1] == (int) str[indexesOfMax[j]] - 1 )\n {\n ValueWasFinded = true;\n str = str.Remove(indexesOfMax[j], 1);\n steps++;\n n--;\n indexesOfMax.RemoveAt(j);\n for (var z = j ; z < indexesOfMax.Count; z++)\n indexesOfMax[z]--;\n \n }\n\n else if (j < indexesOfMax.Count && indexesOfMax[j] != n - 1 && str[indexesOfMax[j] + 1] == (int) (str[indexesOfMax[j]]) - 1)\n {\n ValueWasFinded = true;\n str = str.Remove(indexesOfMax[j], 1);\n \n steps++;\n n--;\n indexesOfMax.RemoveAt(j);\n for (var z = j ; z= indexesOfMax.Count - 1)\n {\n if (!ValueWasFinded)\n {\n (maxSymbol, indexesOfMax) = MaxSymbolLowerThan(str, (int) maxSymbol);\n countOfIndexes = indexesOfMax.Count;\n }\n else\n ValueWasFinded = false;\n j = 0;\n }\n else\n j++;\n }\n }\n }\n\n\n static void Main(string[] args)\n {\n\n test3234234();\n }\n}\n\n\n \n\n\n", "lang_cluster": "C#", "tags": ["brute force", "greedy", "strings", "constructive algorithms"], "code_uid": "32e4e8bbc09410557cc064e3954746f8", "src_uid": "9ce37bc2d361f5bb8a0568fb479b8a38", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.IO;\nusing System.Runtime.CompilerServices;\nusing System.Text;\nusing System.Diagnostics;\nusing System.Numerics;\nusing static System.Console;\nusing static System.Convert;\nusing static System.Math;\nusing static Template;\nusing Pi = Pair;\n\nclass Solver\n{\n public void Solve(Scanner sc)\n {\n int N, K;long M;\n sc.Make(out N, out K, out M);\n var T = sc.ArrInt;\n Array.Sort(T);\n var res = 0L;\n for(int i = 0; i <= N; i++)\n {\n var sum = 0L;\n for (int j = 0; j < K; j++)\n sum += i * T[j];\n if (sum > M) break;\n var rest = N - i;\n var max = i * (K+1L);\n for(int j = 0; j < K; j++)\n {\n if (rest * T[j] <= M - sum) { sum += rest * T[j];max += rest;continue; }\n max += (M - sum) / T[j];break;\n }\n chmax(ref res, max);\n }\n Console.WriteLine(res);\n }\n}\n\n#region Template\npublic static class Template\n{\n static void Main(string[] args)\n {\n Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });\n new Solver().Solve(new Scanner());\n Console.Out.Flush();\n }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static bool chmin(ref T a, T b) where T : IComparable { if (a.CompareTo(b) > 0) { a = b; return true; } return false; }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static bool chmax(ref T a, T b) where T : IComparable { if (a.CompareTo(b) < 0) { a = b; return true; } return false; }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static void swap(ref T a, ref T b) { var t = b; b = a; a = t; }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static void swap(this IList A, int i, int j) { var t = A[i]; A[i] = A[j]; A[j] = t; }\n public static T[] Create(int n, Func f) { var rt = new T[n]; for (var i = 0; i < rt.Length; ++i) rt[i] = f(); return rt; }\n public static T[] Create(int n, Func f) { var rt = new T[n]; for (var i = 0; i < rt.Length; ++i) rt[i] = f(i); return rt; }\n public static IEnumerable Shuffle(this IEnumerable A) => A.OrderBy(v => Guid.NewGuid());\n public static int CompareTo(this T[] A, T[] B, Comparison cmp = null) { cmp = cmp ?? Comparer.Default.Compare; for (var i = 0; i < Min(A.Length, B.Length); i++) { int c = cmp(A[i], B[i]); if (c > 0) return 1; else if (c < 0) return -1; } if (A.Length == B.Length) return 0; if (A.Length > B.Length) return 1; else return -1; }\n public static int MaxElement(this IList A, Comparison cmp = null) { cmp = cmp ?? Comparer.Default.Compare; T max = A[0]; int rt = 0; for (int i = 1; i < A.Count; i++) if (cmp(max, A[i]) < 0) { max = A[i]; rt = i; } return rt; }\n public static T PopBack(this List A) { var v = A[A.Count - 1]; A.RemoveAt(A.Count - 1); return v; }\n public static void Fail(T s) { Console.WriteLine(s); Console.Out.Close(); Environment.Exit(0); }\n}\npublic class Scanner\n{\n public string Str => Console.ReadLine().Trim();\n public int Int => int.Parse(Str);\n public long Long => long.Parse(Str);\n public double Double => double.Parse(Str);\n public int[] ArrInt => Str.Split(' ').Select(int.Parse).ToArray();\n public long[] ArrLong => Str.Split(' ').Select(long.Parse).ToArray();\n public char[][] Grid(int n) => Create(n, () => Str.ToCharArray());\n public int[] ArrInt1D(int n) => Create(n, () => Int);\n public long[] ArrLong1D(int n) => Create(n, () => Long);\n public int[][] ArrInt2D(int n) => Create(n, () => ArrInt);\n public long[][] ArrLong2D(int n) => Create(n, () => ArrLong);\n private Queue q = new Queue();\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public T Next() { if (q.Count == 0) foreach (var item in Str.Split(' ')) q.Enqueue(item); return (T)Convert.ChangeType(q.Dequeue(), typeof(T)); }\n public void Make(out T1 v1) => v1 = Next();\n public void Make(out T1 v1, out T2 v2) { v1 = Next(); v2 = Next(); }\n public void Make(out T1 v1, out T2 v2, out T3 v3) { Make(out v1, out v2); v3 = Next(); }\n public void Make(out T1 v1, out T2 v2, out T3 v3, out T4 v4) { Make(out v1, out v2, out v3); v4 = Next(); }\n public void Make(out T1 v1, out T2 v2, out T3 v3, out T4 v4, out T5 v5) { Make(out v1, out v2, out v3, out v4); v5 = Next(); }\n public void Make(out T1 v1, out T2 v2, out T3 v3, out T4 v4, out T5 v5, out T6 v6) { Make(out v1, out v2, out v3, out v4, out v5); v6 = Next(); }\n public void Make(out T1 v1, out T2 v2, out T3 v3, out T4 v4, out T5 v5, out T6 v6, out T7 v7) { Make(out v1, out v2, out v3, out v4, out v5, out v6); v7 = Next(); }\n //public (T1, T2) Make() { Make(out T1 v1, out T2 v2); return (v1, v2); }\n //public (T1, T2, T3) Make() { Make(out T1 v1, out T2 v2, out T3 v3); return (v1, v2, v3); }\n //public (T1, T2, T3, T4) Make() { Make(out T1 v1, out T2 v2, out T3 v3, out T4 v4); return (v1, v2, v3, v4); }\n}\npublic class Pair : IComparable>\n{\n public T1 v1;\n public T2 v2;\n public Pair() { }\n public Pair(T1 v1, T2 v2)\n { this.v1 = v1; this.v2 = v2; }\n\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public int CompareTo(Pair p)\n {\n var c = Comparer.Default.Compare(v1, p.v1);\n if (c == 0)\n c = Comparer.Default.Compare(v2, p.v2);\n return c;\n }\n public override string ToString() => $\"{v1.ToString()} {v2.ToString()}\";\n public void Deconstruct(out T1 a, out T2 b) { a = v1; b = v2; }\n}\n\npublic class Pair : Pair, IComparable>\n{\n public T3 v3;\n public Pair() : base() { }\n public Pair(T1 v1, T2 v2, T3 v3) : base(v1, v2)\n { this.v3 = v3; }\n\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public int CompareTo(Pair p)\n {\n var c = base.CompareTo(p);\n if (c == 0)\n c = Comparer.Default.Compare(v3, p.v3);\n return c;\n }\n public override string ToString() => $\"{base.ToString()} {v3.ToString()}\";\n public void Deconstruct(out T1 a, out T2 b, out T3 c) { Deconstruct(out a, out b); c = v3; }\n}\n#endregion\n", "lang_cluster": "C#", "tags": ["brute force", "greedy"], "code_uid": "416f0aaad0532b2522f321eb97491a12", "src_uid": "d659e92a410c1bc836be64fc1c0db160", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Text;\nusing System.Collections.Generic;\nusing System.Linq;\nclass Solve{\n public Solve(){}\n StringBuilder sb;\n ReadData re;\n public static int Main(){\n new Solve().Run();\n return 0;\n }\n void Run(){\n sb = new StringBuilder();\n re = new ReadData();\n Calc();\n Console.Write(sb.ToString());\n }\n void Calc(){\n int N = re.i();\n int K = re.i();\n long M = re.i();\n long[] A = re.la();\n Array.Sort(A);\n long sum = 0;\n for(int i=0;i M){\n break;\n }\n long rest = M - i*sum;\n long c = i*(K+1);\n for(int j=0;j= A[j]){\n c++;\n rest -= A[j];\n }\n }\n }\n count = Math.Max(c,count);\n }\n sb.Append(count+\"\\n\");\n }\n}\nclass ReadData{\n string[] str;\n int counter;\n public ReadData(){\n counter = 0;\n }\n public string s(){\n if(counter == 0){\n str = Console.ReadLine().Split(' ');\n counter = str.Length;\n }\n counter--;\n return str[str.Length-counter-1];\n }\n public int i(){\n return int.Parse(s());\n }\n public long l(){\n return long.Parse(s());\n }\n public double d(){\n return double.Parse(s());\n }\n public int[] ia(int N){\n int[] ans = new int[N];\n for(int j=0;j[] g(int N,int[] f,int[] t){\n List[] ans = new List[N];\n for(int j=0;j();\n }\n for(int j=0;j[] g(int N,int M){\n List[] ans = new List[N];\n for(int j=0;j();\n }\n for(int j=0;j[] g(){\n int N = i();\n int M = i();\n List[] ans = new List[N];\n for(int j=0;j();\n }\n for(int j=0;j 0)\n {\n if ((p & 1) == 1)\n ret = MatMult(ret, a, n, mod);\n a = MatMult(a, a, n, mod);\n p >>= 1;\n }\n return ret;\n }\n\n public void Solve()\n {\n int n = ReadInt();\n var v = new long[] { ReadInt() - 1, ReadInt() - 1, (ReadInt() % n + n) % n, (ReadInt() % n + n) % n, 0, 1 };\n long t = ReadLong();\n\n var a = new long[,] \n {\n { 2, 1, 1, 0, 1, 2 },\n { 1, 2, 0, 1, 1, 2 },\n { 1, 1, 1, 0, 1, 2 },\n { 1, 1, 0, 1, 1, 2 },\n { 0, 0, 0, 0, 1, 1 },\n { 0, 0, 0, 0, 0, 1 }\n };\n\n a = MatPow(a, 6, t, n);\n var ans = new long[2];\n for (int i = 0; i < 2; i++)\n for (int j = 0; j < 6; j++)\n ans[i] = (ans[i] + a[i, j] * v[j]) % n;\n\n Write(ans[0] + 1, ans[1] + 1);\n }\n\n #region Main\n\n protected static TextReader reader;\n protected static TextWriter writer;\n static void Main()\n {\n#if DEBUG\n reader = new StreamReader(\"..\\\\..\\\\input.txt\");\n //reader = new StreamReader(Console.OpenStandardInput());\n writer = Console.Out;\n //writer = new StreamWriter(\"..\\\\..\\\\output.txt\");\n#else\n reader = new StreamReader(Console.OpenStandardInput());\n writer = new StreamWriter(Console.OpenStandardOutput());\n //reader = new StreamReader(\"input.txt\");\n //writer = new StreamWriter(\"output.txt\");\n#endif\n try\n {\n //var thread = new Thread(new Solver().Solve, 1024 * 1024 * 128);\n //thread.Start();\n //thread.Join();\n new Solver().Solve();\n }\n catch (Exception ex)\n {\n Console.WriteLine(ex);\n#if DEBUG\n#else\n throw;\n#endif\n }\n reader.Close();\n writer.Close();\n }\n\n #endregion\n\n #region Read / Write\n private static Queue currentLineTokens = new Queue();\n private static string[] ReadAndSplitLine() { return reader.ReadLine().Split(new[] { ' ', '\\t', }, StringSplitOptions.RemoveEmptyEntries); }\n public static string ReadToken() { while (currentLineTokens.Count == 0)currentLineTokens = new Queue(ReadAndSplitLine()); return currentLineTokens.Dequeue(); }\n public static int ReadInt() { return int.Parse(ReadToken()); }\n public static long ReadLong() { return long.Parse(ReadToken()); }\n public static double ReadDouble() { return double.Parse(ReadToken(), CultureInfo.InvariantCulture); }\n public static int[] ReadIntArray() { return ReadAndSplitLine().Select(int.Parse).ToArray(); }\n public static long[] ReadLongArray() { return ReadAndSplitLine().Select(long.Parse).ToArray(); }\n public static double[] ReadDoubleArray() { return ReadAndSplitLine().Select(s => double.Parse(s, CultureInfo.InvariantCulture)).ToArray(); }\n public static int[][] ReadIntMatrix(int numberOfRows) { int[][] matrix = new int[numberOfRows][]; for (int i = 0; i < numberOfRows; i++)matrix[i] = ReadIntArray(); return matrix; }\n public static int[][] ReadAndTransposeIntMatrix(int numberOfRows)\n {\n int[][] matrix = ReadIntMatrix(numberOfRows); int[][] ret = new int[matrix[0].Length][];\n for (int i = 0; i < ret.Length; i++) { ret[i] = new int[numberOfRows]; for (int j = 0; j < numberOfRows; j++)ret[i][j] = matrix[j][i]; } return ret;\n }\n public static string[] ReadLines(int quantity) { string[] lines = new string[quantity]; for (int i = 0; i < quantity; i++)lines[i] = reader.ReadLine().Trim(); return lines; }\n public static void WriteArray(IEnumerable array) { writer.WriteLine(string.Join(\" \", array)); }\n public static void Write(params object[] array) { WriteArray(array); }\n public static void WriteLines(IEnumerable array) { foreach (var a in array)writer.WriteLine(a); }\n private class SDictionary : Dictionary\n {\n public new TValue this[TKey key]\n {\n get { return ContainsKey(key) ? base[key] : default(TValue); }\n set { base[key] = value; }\n }\n }\n private static T[] Init(int size) where T : new() { var ret = new T[size]; for (int i = 0; i < size; i++)ret[i] = new T(); return ret; }\n #endregion\n}", "lang_cluster": "C#", "tags": ["math", "matrices"], "code_uid": "333861bc1f09bb4df97119c25cc3df0d", "src_uid": "ee9fa8be2ae05a4e831a4f608c0cc785", "difficulty": 2300.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\n\nnamespace CSharp\n{\n class _735C\n {\n public static void Main()\n {\n long n = long.Parse(Console.ReadLine());\n long max = 1;\n\n long fp = 1;\n long fc = 2;\n\n do\n {\n fc = fp + fc;\n fp = fc - fp;\n\n if (fc <= n)\n {\n max++;\n }\n } while (fc <= n);\n\n Console.WriteLine(max);\n }\n }\n}", "lang_cluster": "C#", "tags": ["math", "greedy", "constructive algorithms", "combinatorics"], "code_uid": "8e9b2eea6d2a81d44d1f8f15dce6efae", "src_uid": "3d3432b4f7c6a3b901161fa24b415b14", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Collections;\nusing System.Linq;\nusing System.Numerics;\n\n\n\n\nnamespace contest\n{\n\n class contest\n {\n\n\n static void Main(string[] args)\n {\n\n\n //int n = int.Parse(Console.ReadLine());\n //var input = Console.ReadLine().Split().Select(int.Parse).ToArray();\n\n //var num = Console.ReadLine().Split().Select(int.Parse).ToArray();\n\n\n\n\n long n = long.Parse(Console.ReadLine());\n\n var fib = new long[90];\n fib[0] = 1;\n fib[1] = 2;\n\n for(int i=2; i<90; i++)\n {\n fib[i] = fib[i - 1] + fib[i - 2];\n }\n\n int ans = 0;\n for(int i=0; i<89; i++)\n {\n if(fib[i+1]>n)\n {\n ans = i;\n break;\n }\n }\n\n\n Console.WriteLine(ans);\n\n\n\n\n\n\n }\n\n \n \n\n }\n\n \n \n}\n", "lang_cluster": "C#", "tags": ["math", "greedy", "constructive algorithms", "combinatorics"], "code_uid": "5f371c0a37ba543c0972de724e2f8ebc", "src_uid": "3d3432b4f7c6a3b901161fa24b415b14", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.IO;\n\nclass Program\n{\n\tint[][] c;\n\tint n, m;\n\tint mod = 1000000007;\n\tint add(int x, int y)\n\t{\n\t\tx += y;\n\t\treturn x < mod ? x : x - mod;\n\t}\n\tint mul(int x, int y)\n\t{\n\t\treturn Convert.ToInt32(Convert.ToInt64(x) * y % mod);\n\t}\n\tint[][] newMatrix(int m)\n\t{\n\t\tint[][] ret = new int[m][];\n\t\tfor (int i = 0; i < m; i++)\n\t\t\tret[i] = new int[m];\n\t\treturn ret;\n\t}\n\tvoid calcSum(ref int[][] sum, int[][] a)\n\t{\n\t\tfor (int i = 1; i <= m; i++)\n\t\t\tfor (int j = 1; j <= m; j++)\n\t\t\t\tsum[i][j] = add(sum[i - 1][j], a[i][j]);\n\t\tfor (int i = 1; i <= m; i++)\n\t\t\tfor (int j = 1; j <= m; j++)\n\t\t\t\tsum[i][j] = add(sum[i][j - 1], sum[i][j]);\n\t}\n\tint regionSum(int[][] sum, int lx, int rx, int ly, int ry)\n\t{\n\t\t--lx; --ly;\n\t\treturn add(add(sum[lx][ly],sum[rx][ry]), mod - add(sum[lx][ry],sum[rx][ly]));\n\t}\n\tvoid run()\n\t{\n\t\tString[] str = Console.ReadLine().Split(' ');\n\t\tn = Convert.ToInt32(str[0]);\n\t\tm = Convert.ToInt32(str[1]);\n\t\tint[][][] dp11 = new int[n + 1][][],\n\t\t\tdp10 = new int[n + 1][][],\n\t\t\tdp01 = new int[n + 1][][],\n\t\t\tdp00 = new int[n + 1][][];\n\t\tdp11[1] = newMatrix(m + 1);\n\t\tdp10[1] = newMatrix(m + 1);\n\t\tdp01[1] = newMatrix(m + 1);\n\t\tdp00[1] = newMatrix(m + 1);\n\t\tfor (int i = 1; i <= m; i++)\n\t\t\tfor (int j = i; j <= m; j++)\n\t\t\t\tdp11[1][i][j] = 1;\n\t\tint[][] sum = newMatrix(m + 1);\n\t\tfor (int i = 2; i <= n; i++)\n\t\t{\n\t\t\tdp11[i] = newMatrix(m + 1);\n\t\t\tdp10[i] = newMatrix(m + 1);\n\t\t\tdp01[i] = newMatrix(m + 1);\n\t\t\tdp00[i] = newMatrix(m + 1);\n\t\t\tcalcSum(ref sum, dp11[i - 1]);\n\t\t\tfor (int j = 1; j <= m; j++)\n\t\t\t\tfor (int k = j; k <= m; k++)\n\t\t\t\t{\n\t\t\t\t\tdp11[i][j][k] = add(dp11[i][j][k], regionSum(sum, j, k, j, k));\n\t\t\t\t\tdp10[i][j][k] = add(dp10[i][j][k], regionSum(sum, j, k, k + 1, m));\n\t\t\t\t\tdp01[i][j][k] = add(dp01[i][j][k], regionSum(sum, 1, j - 1, j, k));\n\t\t\t\t\tdp00[i][j][k] = add(dp00[i][j][k], regionSum(sum, 1, j - 1, k + 1, m));\n\t\t\t\t}\n\t\t\tcalcSum(ref sum, dp10[i - 1]);\n\t\t\tfor (int j = 1; j <= m; j++)\n\t\t\t\tfor (int k = j; k <= m; k++)\n\t\t\t\t{\n\t\t\t\t\tdp10[i][j][k] = add(dp10[i][j][k], regionSum(sum, j, k, k, m));\n\t\t\t\t\tdp00[i][j][k] = add(dp00[i][j][k], regionSum(sum, 1, j - 1, k, m));\n\t\t\t\t}\n\t\t\tcalcSum(ref sum, dp01[i - 1]);\n\t\t\tfor (int j = 1; j <= m; j++)\n\t\t\t\tfor (int k = j; k <= m; k++)\n\t\t\t\t{\n\t\t\t\t\tdp01[i][j][k] = add(dp01[i][j][k], regionSum(sum, 1, j, j, k));\n\t\t\t\t\tdp00[i][j][k] = add(dp00[i][j][k], regionSum(sum, 1, j, k + 1, m));\n\t\t\t\t}\n\t\t\tcalcSum(ref sum, dp00[i - 1]);\n\t\t\tfor (int j = 1; j <= m; j++)\n\t\t\t\tfor (int k = j; k <= m; k++)\n\t\t\t\t{\n\t\t\t\t\tdp00[i][j][k] = add(dp00[i][j][k], regionSum(sum, 1, j, k, m));\n\t\t\t\t}\n\t\t}\n\t\tint res = 0;\n\t\tfor (int i = 1; i <= n; i++)\n\t\t\tfor (int j = 1; j <= m; j++)\n\t\t\t\tfor (int k = 1; k <= m; k++)\n\t\t\t\t\tres = add(res, mul(n - i + 1, add(add(dp00[i][j][k],dp01[i][j][k]), add(dp10[i][j][k],dp11[i][j][k]))));\n\t\tConsole.WriteLine(res);\n\t}\n\tstatic void Main(String[] args)\n\t{\n\t\tnew Program().run();\n\t}\n}", "lang_cluster": "C#", "tags": ["dp"], "code_uid": "8768205cc2f53559e6675af673630c40", "src_uid": "740eceed59d3c6ac55c1bf9d3d4160c7", "difficulty": 2400.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\n\nclass cf\n{\n public static void Main()\n {\n var n = long.Parse(Console.ReadLine());\n \n if(n % 2 == 0)\n {\n Console.WriteLine(n / 2);\n }\n else\n {\n long i = 2;\n \n while(i * i <= n)\n {\n if(n % i == 0)\n {\n break;\n }\n \n i++;\n }\n \n if(i * i > n)\n {\n Console.WriteLine(1);\n }\n else\n {\n n = n - i;\n \n Console.WriteLine(1 + (n) / 2);\n }\n }\n \n \n }\n}", "lang_cluster": "C#", "tags": ["math", "implementation", "number theory"], "code_uid": "e3cd62cee84560086ecadecef829cca4", "src_uid": "a1e80ddd97026835a84f91bac8eb21e6", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.IO;\nusing System.Threading;\nusing System.Runtime.CompilerServices;\nusing System.Text;\nusing System.Diagnostics;\nusing System.Numerics;\nusing static System.Console;\nusing static System.Convert;\nusing static System.Math;\nusing static Template;\nusing SC = Scanner;\n\npublic partial class Solver\n{\n public void Solve()\n {\n var N = sc.Long;\n var f = Factorize(N);\n var res = 0L;\n N -= f.Keys.Min();res++;\n res += N / 2; Console.WriteLine(res);\n }\n\n public static Dictionary Factorize(long N)\n {\n var dic = new Dictionary();\n for (long i = 2; i * i <= N; i++)\n {\n var ct = 0;\n while (N % i == 0)\n {\n ct++;\n N /= i;\n }\n if (ct != 0) dic[i] = ct;\n }\n if (N != 1) dic[N] = 1;\n return dic;\n }\n}\n\n#region Template\npublic partial class Solver\n{\n public SC sc = new SC();\n static void Main(string[] args)\n {\n Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });\n var sol = new Solver();\n int testcase = 1;\n //testcase = sol.sc.Int;\n //var th = new Thread(sol.Solve, 1 << 26);th.Start();th.Join();\n while (testcase-- > 0)\n sol.Solve();\n Console.Out.Flush();\n }\n}\npublic static class Template\n{\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static bool chmin(ref T a, T b) where T : IComparable { if (a.CompareTo(b) > 0) { a = b; return true; } return false; }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static bool chmax(ref T a, T b) where T : IComparable { if (a.CompareTo(b) < 0) { a = b; return true; } return false; }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static void swap(ref T a, ref T b) { var t = b; b = a; a = t; }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static void swap(this IList A, int i, int j) { var t = A[i]; A[i] = A[j]; A[j] = t; }\n public static T[] Create(int n, Func f) { var rt = new T[n]; for (var i = 0; i < rt.Length; ++i) rt[i] = f(); return rt; }\n public static T[] Create(int n, Func f) { var rt = new T[n]; for (var i = 0; i < rt.Length; ++i) rt[i] = f(i); return rt; }\n public static void Out(this IList A, out T a) => a = A[0];\n public static void Out(this IList A, out T a, out T b) { a = A[0]; b = A[1]; }\n public static void Out(this IList A, out T a, out T b, out T c) { A.Out(out a, out b); c = A[2]; }\n public static void Out(this IList A, out T a, out T b, out T c, out T d) { A.Out(out a, out b, out c); d = A[3]; }\n public static string Concat(this IEnumerable A, string sp) => string.Join(sp, A);\n public static char ToChar(this int s, char begin = '0') => (char)(s + begin);\n public static IEnumerable Shuffle(this IEnumerable A) => A.OrderBy(v => Guid.NewGuid());\n public static int CompareTo(this T[] A, T[] B, Comparison cmp = null) { cmp = cmp ?? Comparer.Default.Compare; for (var i = 0; i < Min(A.Length, B.Length); i++) { int c = cmp(A[i], B[i]); if (c > 0) return 1; else if (c < 0) return -1; } if (A.Length == B.Length) return 0; if (A.Length > B.Length) return 1; else return -1; }\n public static string ToStr(this T[][] A) => A.Select(a => a.Concat(\" \")).Concat(\"\\n\");\n public static int ArgMax(this IList A, Comparison cmp = null) { cmp = cmp ?? Comparer.Default.Compare; T max = A[0]; int rt = 0; for (int i = 1; i < A.Count; i++) if (cmp(max, A[i]) < 0) { max = A[i]; rt = i; } return rt; }\n public static T PopBack(this List A) { var v = A[A.Count - 1]; A.RemoveAt(A.Count - 1); return v; }\n public static void Fail(T s) { Console.WriteLine(s); Console.Out.Close(); Environment.Exit(0); }\n}\npublic class Scanner\n{\n public string Str => Console.ReadLine().Trim();\n public int Int => int.Parse(Str);\n public long Long => long.Parse(Str);\n public double Double => double.Parse(Str);\n public int[] ArrInt => Str.Split(' ').Select(int.Parse).ToArray();\n public long[] ArrLong => Str.Split(' ').Select(long.Parse).ToArray();\n public char[][] Grid(int n) => Create(n, () => Str.ToCharArray());\n public int[] ArrInt1D(int n) => Create(n, () => Int);\n public long[] ArrLong1D(int n) => Create(n, () => Long);\n public int[][] ArrInt2D(int n) => Create(n, () => ArrInt);\n public long[][] ArrLong2D(int n) => Create(n, () => ArrLong);\n private Queue q = new Queue();\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public T Next() { if (q.Count == 0) foreach (var item in Str.Split(' ')) q.Enqueue(item); return (T)Convert.ChangeType(q.Dequeue(), typeof(T)); }\n public void Make(out T1 v1) => v1 = Next();\n public void Make(out T1 v1, out T2 v2) { v1 = Next(); v2 = Next(); }\n public void Make(out T1 v1, out T2 v2, out T3 v3) { Make(out v1, out v2); v3 = Next(); }\n public void Make(out T1 v1, out T2 v2, out T3 v3, out T4 v4) { Make(out v1, out v2, out v3); v4 = Next(); }\n public void Make(out T1 v1, out T2 v2, out T3 v3, out T4 v4, out T5 v5) { Make(out v1, out v2, out v3, out v4); v5 = Next(); }\n public void Make(out T1 v1, out T2 v2, out T3 v3, out T4 v4, out T5 v5, out T6 v6) { Make(out v1, out v2, out v3, out v4, out v5); v6 = Next(); }\n public void Make(out T1 v1, out T2 v2, out T3 v3, out T4 v4, out T5 v5, out T6 v6, out T7 v7) { Make(out v1, out v2, out v3, out v4, out v5, out v6); v7 = Next(); }\n public (T1, T2) Make() { Make(out T1 v1, out T2 v2); return (v1, v2); }\n public (T1, T2, T3) Make() { Make(out T1 v1, out T2 v2, out T3 v3); return (v1, v2, v3); }\n public (T1, T2, T3, T4) Make() { Make(out T1 v1, out T2 v2, out T3 v3, out T4 v4); return (v1, v2, v3, v4); }\n}\n\n#endregion", "lang_cluster": "C#", "tags": ["math", "implementation", "number theory"], "code_uid": "8bd4e09caa484c8b43e48a7c1e6e1a0a", "src_uid": "a1e80ddd97026835a84f91bac8eb21e6", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Diagnostics;\nusing System.Globalization;\nusing System.IO;\nusing System.Linq;\nusing System.Threading;\n\nnamespace ReadWriteTemplate\n{\n public static class Solver\n {\n private static void SolveCase()\n {\n const long MOD = 1000000000 + 7;\n\n int n = ReadInt();\n long k = ReadLong();\n int[] a = ReadIntArray();\n\n int m = a.Sum();\n\n if (m == n)\n {\n Writer.WriteLine(1);\n return;\n }\n\n long[,] b = new long[m + 1, m + 1];\n for (int i = 0; i < m + 1; i++)\n {\n long l = Math.Max(0, 2 * i * (n + i - 2 * m));\n long r = 2 * (m - i) * (m - i);\n long e = n * (n - 1) - l - r;\n long inv = Inv(n * (n - 1), MOD);\n if (l > 0)\n {\n b[i, i - 1] = l * inv % MOD;\n }\n b[i, i] = e * inv % MOD;\n if (r > 0)\n {\n b[i, i + 1] = r * inv % MOD;\n }\n }\n\n long[,] c = MatrixBinPower(m + 1, b, k, MOD);\n\n int st = 0;\n for (int i = 0; i < m; i++)\n {\n st += a[n - i - 1];\n }\n\n long ans = c[st, m];\n\n Writer.WriteLine(ans);\n }\n\n public static long Inv(long a, long mod)\n {\n return BinPower(a, mod - 2, mod);\n }\n\n public static long BinPower(long a, long n, long mod)\n {\n long result = 1;\n\n while (n > 0)\n {\n if ((n & 1) != 0)\n {\n result = (result * a) % mod;\n }\n\n a = (a * a) % mod;\n n >>= 1;\n }\n\n return result;\n }\n\n public static long[,] MatrixBinPower(int n, long[,] a, long p, long mod)\n {\n long[,] result = new long[n, n];\n for (int i = 0; i < n; i++)\n {\n result[i, i] = 1;\n }\n\n while (p > 0)\n {\n if ((p & 1) != 0)\n {\n result = MatrixMult(n, result, a, mod);\n }\n\n a = MatrixMult(n, a, a, mod);\n p >>= 1;\n }\n\n return result;\n }\n\n public static long[,] MatrixMult(int n, long[,] a, long[,] b, long mod)\n {\n long[,] c = new long[n, n];\n\n for (int i = 0; i < n; i++)\n {\n for (int j = 0; j < n; j++)\n {\n for (int k = 0; k < n; k++)\n {\n c[i, j] = (c[i, j] + a[i, k] * b[k, j]) % mod;\n }\n }\n }\n\n return c;\n }\n\n public static void Solve()\n {\n#if DEBUG\n var sw = Stopwatch.StartNew();\n#endif\n\n SolveCase();\n\n /*int T = ReadInt();\n for (int i = 0; i < T; i++)\n {\n Writer.Write(\"Case #{0}: \", 1 - t);\n SolveCase();\n }*/\n\n#if DEBUG\n sw.Stop();\n Console.WriteLine($\"{sw.ElapsedMilliseconds} ms\");\n#endif\n }\n\n public static void Main()\n {\n Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;\n\n#if DEBUG\n // Reader = Console.In; Writer = Console.Out;\n Reader = File.OpenText(\"input.txt\"); Writer = File.CreateText(\"output.txt\");\n#else\n Reader = Console.In; Writer = Console.Out;\n#endif\n\n // Solve();\n Thread thread = new Thread(Solve, 64 * 1024 * 1024);\n thread.CurrentCulture = CultureInfo.InvariantCulture;\n thread.Start();\n thread.Join();\n\n Reader.Close();\n Writer.Close();\n }\n\n public static IOrderedEnumerable OrderByWithShuffle(this IEnumerable source, Func keySelector)\n {\n return source.Shuffle().OrderBy(keySelector);\n }\n\n public static T[] Shuffle(this IEnumerable source)\n {\n T[] result = source.ToArray();\n Shuffle(result);\n return result;\n }\n\n private static void Shuffle(IList array)\n {\n Random rnd = new Random();\n for (int i = array.Count - 1; i >= 1; i--)\n {\n int k = rnd.Next(i + 1);\n T tmp = array[k];\n array[k] = array[i];\n array[i] = tmp;\n }\n }\n\n #region Read/Write\n\n private static TextReader Reader;\n\n private static TextWriter Writer;\n\n private static Queue CurrentLineTokens = new Queue();\n\n private static string[] ReadAndSplitLine()\n {\n return Reader.ReadLine().Split(new[] { ' ', '\\t' }, StringSplitOptions.RemoveEmptyEntries);\n }\n\n public static string ReadToken()\n {\n while (CurrentLineTokens.Count == 0)\n CurrentLineTokens = new Queue(ReadAndSplitLine());\n return CurrentLineTokens.Dequeue();\n }\n\n public static string ReadLine()\n {\n return Reader.ReadLine();\n }\n\n public static int ReadInt()\n {\n return int.Parse(ReadToken());\n }\n\n public static long ReadLong()\n {\n return long.Parse(ReadToken());\n }\n\n public static double ReadDouble()\n {\n return double.Parse(ReadToken(), CultureInfo.InvariantCulture);\n }\n\n public static int[] ReadIntArray()\n {\n return ReadAndSplitLine().Select(int.Parse).ToArray();\n }\n\n public static long[] ReadLongArray()\n {\n return ReadAndSplitLine().Select(long.Parse).ToArray();\n }\n\n public static double[] ReadDoubleArray()\n {\n return ReadAndSplitLine().Select(s => double.Parse(s, CultureInfo.InvariantCulture)).ToArray();\n }\n\n public static int[][] ReadIntMatrix(int numberOfRows)\n {\n int[][] matrix = new int[numberOfRows][];\n for (int i = 0; i < numberOfRows; i++)\n matrix[i] = ReadIntArray();\n return matrix;\n }\n\n public static string[] ReadLines(int quantity)\n {\n string[] lines = new string[quantity];\n for (int i = 0; i < quantity; i++)\n lines[i] = Reader.ReadLine().Trim();\n return lines;\n }\n\n public static void WriteArray(IEnumerable array)\n {\n Writer.WriteLine(string.Join(\" \", array));\n }\n\n #endregion\n }\n}\n", "lang_cluster": "C#", "tags": ["probabilities", "matrices", "dp", "combinatorics"], "code_uid": "c975bb55a08623089592dda630fdb2dd", "src_uid": "77f28d155a632ceaabd9f5a9d846461a", "difficulty": 2300.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System.Collections.Generic;\nusing System.Collections;\nusing System.ComponentModel;\nusing System.Diagnostics.CodeAnalysis;\nusing System.Globalization;\nusing System.IO;\nusing System.Linq;\nusing System.Reflection;\nusing System.Runtime.Serialization;\nusing System.Text.RegularExpressions;\nusing System.Text;\nusing System;\nusing System.Numerics;\n\nclass Solution\n{\n public class GCD\n {\n public static int Euclidean(int n1, int n2)\n {\n if (n1 == n2) return n1;\n else if (n1 < n2)\n {\n var tmp = n1;\n n1 = n2;\n n2 = tmp;\n }\n\n while (n1 % n2 > 0)\n {\n var tmp = n2;\n n2 = n1 % n2;\n n1 = tmp;\n }\n return n2;\n }\n public static long Euclidean(long n1, long n2)\n {\n if (n1 == n2) return n1;\n else if (n1 < n2)\n {\n var tmp = n1;\n n1 = n2;\n n2 = tmp;\n }\n\n while (n1 % n2 > 0)\n {\n var tmp = n2;\n n2 = n1 % n2;\n n1 = tmp;\n }\n return n2;\n }\n\n public static long Inverse(long a, long n)\n {\n long x, y = 0;\n EuclideanExt(a, n, out x, out y);\n return x < 0 ? n + x : x;\n }\n\n public static long EuclideanExt(long n1, long n2, out long x, out long y)\n {\n x = 0;\n y = 1;\n\n bool r = false;\n if (n1 == n2) return n1;\n\n else if (n1 < n2)\n {\n r = true;\n var tmp = n1;\n n1 = n2;\n n2 = tmp;\n }\n long q = 0;\n long xl = 1;\n long yl = 0;\n\n while (n2 > 0)\n {\n q = n1 / n2;\n\n var tmp = n2;\n n2 = n1 % n2;\n n1 = tmp;\n\n tmp = x;\n x = xl - q * x;\n xl = tmp;\n\n tmp = y;\n y = yl - q * y;\n yl = tmp;\n\n\n }\n x = xl;\n y = yl;\n if (r)\n {\n x = yl;\n y = xl;\n }\n return x * n1 + y * n2;\n }\n }\n\n public static Tuple[,] multiply(Tuple[,] m1, Tuple[,] m2)\n {\n Tuple[,] ret = new Tuple[m1.GetLength(0), m2.GetLength(1)];\n for (int i = 0; i < ret.GetLength(0); i++)\n for (int j = 0; j < ret.GetLength(1); j++)\n {\n ret[i, j] = new Tuple(0, 0);\n for (int k = 0; k < m1.GetLength(1); k++)\n ret[i, j] = sum(ret[i, j], prod(m1[i, k], m2[k, j]));\n }\n return ret;\n }\n\n public static Tuple[,] recPow(Tuple[,] m, long pow)\n {\n if (pow == 1)\n return m;\n\n var powered = recPow(m, pow / 2);\n var mult = multiply(powered, powered);\n if (pow % 2 == 1)\n {\n\n mult = multiply(mult, m);\n }\n return mult;\n }\n\n static Tuple sum(Tuple a, Tuple b)\n {\n if (a.Item1 == 0)\n return b;\n if (b.Item1 == 0)\n return a;\n return Tuple.Create(\n ((a.Item1 * b.Item2) % mod + (b.Item1 * a.Item2) % mod) % mod,\n (a.Item2 * b.Item2) % mod\n );\n }\n\n static Tuple prod(Tuple a, Tuple b)\n {\n return Tuple.Create(\n (a.Item1 * b.Item1) % mod,\n (a.Item2 * b.Item2) % mod\n );\n }\n\n\n static Tuple PInOneSide(long cnt, long totalcnt)\n {\n return Tuple.Create(\n cnt * (cnt - 1) + (totalcnt - cnt) * (totalcnt - cnt - 1),\n totalcnt * (totalcnt - 1)\n );\n }\n\n static Tuple PIncreaseLeftA(long leftCnt, long leftACnt, long totalcnt)\n {\n return Tuple.Create(\n (leftCnt - leftACnt) * (leftCnt - leftACnt),\n (totalcnt * (totalcnt - 1)) / 2\n );\n }\n\n static Tuple PDecreaseLeftA(long leftCnt, long leftACnt, long totalcnt)\n {\n return Tuple.Create(\n leftACnt * (totalcnt - 2 * leftCnt + leftACnt),\n (totalcnt * (totalcnt - 1)) / 2\n );\n }\n\n static void CalcCashe(long lowerBnd, long leftCnt, long totalcnt)\n {\n PInOneSideCache = PInOneSide(leftCnt, totalcnt);\n\n PIncreaseLeftACache = new Tuple[leftCnt - lowerBnd + 1];\n PDecreaseLeftACache = new Tuple[leftCnt - lowerBnd + 1];\n PSameInBothSideCache = new Tuple[leftCnt - lowerBnd + 1];\n\n for (long i = lowerBnd; i <= leftCnt; i++)\n {\n PIncreaseLeftACache[(int)(i - lowerBnd)] = PIncreaseLeftA(leftCnt, i, totalcnt);\n PDecreaseLeftACache[(int)(i - lowerBnd)] = PDecreaseLeftA(leftCnt, i, totalcnt);\n PSameInBothSideCache[(int)(i - lowerBnd)] = PSameInBothSide(leftCnt, i, totalcnt);\n }\n }\n static Tuple PInOneSideCache;\n static Tuple[] PSameInBothSideCache;\n static Tuple[] PIncreaseLeftACache;\n static Tuple[] PDecreaseLeftACache;\n static Tuple PSameInBothSide(long leftCnt, long leftACnt, long totalcnt)\n {\n\n return Tuple.Create(\n (leftCnt - leftACnt) * (totalcnt + 2 * leftACnt - 2 * leftCnt),\n (totalcnt * (totalcnt - 1)) / 2\n );\n }\n\n const long mod = 1000000007L;\n static void Main(string[] args)\n {\n\n // var n = int.Parse( Console.ReadLine());\n var tmp = Array.ConvertAll(Console.ReadLine().Trim().Split(), Convert.ToInt64);\n var n = (long)tmp[0];\n var k = tmp[1];\n\n var arr = Array.ConvertAll(Console.ReadLine().Trim().Split(), Convert.ToByte);\n\n var leftcnt = (long)arr.Count(el => el == 0);\n var leftAcnt = (long)arr.Where((el, i) => el == 0 && i < leftcnt).Count();\n if (k < (leftcnt - leftAcnt))\n {\n Console.WriteLine(\"0\");\n return;\n }\n if (leftcnt == n || leftcnt == 0)\n {\n Console.WriteLine(\"1\");\n return;\n }\n\n\n\n var lowerBnd = (long)Math.Max(0, (int)(2 * (int)leftcnt - (int)n));\n\n Tuple[,] A = new Tuple[(int)(leftcnt - lowerBnd + 1), (int)(leftcnt - lowerBnd + 1)];\n\n CalcCashe(lowerBnd, leftcnt, n);\n\n for (int i = 0; i < A.GetLength(0); i++)\n {\n for (int j = 0; j < A.GetLength(0); j++)\n {\n if (i == j)\n {\n A[i, j] = sum(PInOneSideCache, PSameInBothSideCache[i]);\n }\n else if (i == j + 1)\n {\n A[i, j] = PIncreaseLeftACache[i - 1];\n }\n else if (i == j - 1)\n {\n A[i, j] = PDecreaseLeftACache[i + 1];\n }\n else\n {\n A[i, j] = Tuple.Create(0, 0);\n }\n }\n }\n\n A = recPow(A, k);\n\n Tuple[,] F = new Tuple[leftcnt - lowerBnd + 1, 1];\n for (int i = 0; i < F.GetLength(0); i++)\n {\n if (i == leftAcnt - lowerBnd)\n {\n F[i, 0] = Tuple.Create(1l, 1L);\n }\n else\n {\n F[i, 0] = new Tuple(0, 0);\n }\n }\n F = multiply(A, F);\n var tpl = F[F.GetLength(0) - 1, 0];\n if (tpl.Item1 == 0)\n {\n Console.WriteLine(\"0\");\n return;\n }\n var gcd = GCD.Euclidean(tpl.Item1, tpl.Item2);\n var ret = Tuple.Create(tpl.Item1 / gcd, tpl.Item2 / gcd);\n\n var ret2 = ((long)ret.Item1 * GCD.Inverse((long)ret.Item2, (long)mod)) % (long)mod;\n\n Console.WriteLine($\"{ret2}\");\n\n }\n}", "lang_cluster": "C#", "tags": ["probabilities", "matrices", "dp", "combinatorics"], "code_uid": "cd8bc6e5e96a08b4b076a4c8f6fc75a3", "src_uid": "77f28d155a632ceaabd9f5a9d846461a", "difficulty": 2300.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\n\nnamespace A\n{\n class Program\n {\n static void Main(string[] args)\n {\n string[] inputArgs = Console.ReadLine().Split(' ');\n\n int[] size = new int[3];\n\n size[0] = int.Parse(inputArgs[0]);\n size[1] = int.Parse(inputArgs[1]);\n size[2] = int.Parse(inputArgs[2]);\n int k = int.Parse(inputArgs[3]);\n\n Array.Sort(size);\n\n int[] beats = new int[3];\n\n for (int i = 0; i < 3; i++)\n {\n beats[i] = (k / (3 - i) > size[i] - 1) ? size[i] - 1 : k / (3 - i);\n k -= beats[i];\n }\n\n ulong result = (((ulong)beats[0] + 1) * ((ulong)beats[1] + 1) * ((ulong)beats[2] + 1));\n\n Console.WriteLine(result);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "greedy"], "code_uid": "18e932d208878a6eb2fb0ee53bff0a9a", "src_uid": "8787c5d46d7247d93d806264a8957639", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\n\nnamespace ProgrammingContest.Codeforces.Round66\n{\n class A\n {\n public static void Main()\n {\n var xs = Array.ConvertAll(Console.ReadLine().Split(' '), sss=>long.Parse(sss));\n long k = xs[3];\n Array.Sort(xs, 0, 3);\n long[] ys = new long[3];\n for (int i = 0; i < 3; i++)\n {\n ys[i] = 1 + Math.Min((k + 2-i) / (3-i), xs[i] - 1);\n k -= ys[i] - 1;\n //Console.WriteLine(\"{0} {1} {2}\", k, i, ys[i]);\n }\n Console.WriteLine(ys[0]*ys[1]*ys[2]);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "greedy"], "code_uid": "06387dc5934ca973f3b3578b1a80c99a", "src_uid": "8787c5d46d7247d93d806264a8957639", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.IO;\nusing System.Linq;\n\nnamespace DimaAndHorses\n{\n class Program\n {\n private static List[] war;\n private static bool[] p;\n\n private static bool Check(int i)\n {\n return war[i].Count(e => p[e] == p[i]) <= 1;\n }\n\n private static void Fix(int i)\n {\n p[i] = !p[i];\n\n foreach (var e in war[i])\n {\n if (p[e] == p[i] && !Check(e))\n {\n Fix(e);\n }\n }\n }\n\n private static void FixAll()\n {\n for (int i = 0; i < p.Length; i++)\n {\n if (!p[i] && !Check(i))\n {\n Fix(i); \n }\n }\n } \n\n static void Main(string[] args)\n {\n // var fin = File.OpenText(\"test.txt\");\n // Console.SetIn(fin);\n\n string[] nm = Console.ReadLine().Split(' ');\n int n = int.Parse(nm[0]);\n int m = int.Parse(nm[1]);\n\n war = new List[n];\n p = new bool[n];\n for (int i = 0; i < n; i++)\n {\n war[i] = new List();\n p[i] = false;\n }\n\n for (int i = 0; i < m; i++)\n {\n string[] ab = Console.ReadLine().Split(' ');\n int a = int.Parse(ab[0]) - 1;\n int b = int.Parse(ab[1]) - 1;\n\n war[a].Add(b);\n war[b].Add(a);\n }\n \n FixAll();\n Console.WriteLine(string.Concat(p.Select(x => x ? 1 : 0)));\n\n // fin.Close();\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["constructive algorithms", "combinatorics", "graphs"], "code_uid": "7b72c02cfe31a7f428e41e58378e7ca4", "src_uid": "7017f2c81d5aed716b90e46480f96582", "difficulty": 2200.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.IO;\nusing System.Text;\nusing System.Diagnostics;\nusing System.Collections.Generic;\n\npublic class E167\n{\n public static void Main()\n {\n new E167().Entry();\n }//Main\n\n void Entry()\n {\n int[] tmp = intSplit(' ');\n int n = tmp[0];\n int m = tmp[1];\n int[] type = new int[n];\n List[] edges = new List[n];\n for (int i = 0; i < n; i++)\n edges[i] = new List();\n for (int i = 0; i < m; i++)\n {\n tmp = intSplit(' ');\n int a = tmp[0] - 1;\n int b = tmp[1] - 1;\n edges[a].Add(b);\n edges[b].Add(a);\n }//for i\n Queue que = new Queue();\n for (int i = 0; i < n; i++)\n que.Enqueue(i);\n while (que.Count!=0)\n {\n int deq = que.Dequeue();\n int cnt = 0;\n foreach (int item in edges[deq])\n {\n if (type[item] == type[deq])\n cnt++;\n }//foreach item\n if (cnt>=2)\n {\n type[deq] ^= 1;\n foreach (int item in edges[deq])\n {\n if (type[item] == type[deq])\n que.Enqueue(item);\n }//foreach item\n }//if\n }//while\n StringBuilder sb = new StringBuilder();\n foreach (int item in type)\n {\n sb.Append(item);\n }//foreach item\n Console.WriteLine(sb.ToString());\n }\n\n string strRead()\n {\n return Console.ReadLine();\n }\n\n int intRead()\n {\n return int.Parse(Console.ReadLine());\n }\n\n long longRead()\n {\n return long.Parse(Console.ReadLine());\n }\n\n double doubleRead()\n {\n return double.Parse(Console.ReadLine());\n }\n\n string[] strSplit(char a)\n {\n return Console.ReadLine().Split(a);\n }\n\n int[] intSplit(char a)\n {\n return Array.ConvertAll(Console.ReadLine().Split(a), int.Parse);\n }\n\n long[] longSplit(char a)\n {\n return Array.ConvertAll(Console.ReadLine().Split(a), long.Parse);\n }\n\n double[] doubleSplit(char a)\n {\n return Array.ConvertAll(Console.ReadLine().ToString().Split('a'), double.Parse);\n }\n\n\n}//Template", "lang_cluster": "C#", "tags": ["constructive algorithms", "combinatorics", "graphs"], "code_uid": "e6f6484d7ca4d6519cf5cb14addb7e83", "src_uid": "7017f2c81d5aed716b90e46480f96582", "difficulty": 2200.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\r\nusing System.Collections.Generic;\r\nusing System.Linq;\r\nusing System.Numerics;\r\nusing System.Text;\r\nusing System.Threading.Tasks;\r\n\r\nnamespace DrawRubik1594E1\r\n{\r\n class Program\r\n {\r\n static void Main(string[] args)\r\n {\r\n int k = Int32.Parse(Console.ReadLine());\r\n long result = 6;\r\n long mul = 16;\r\n while (k > 1)\r\n {\r\n result *= mul;\r\n result %= 1000000007;\r\n mul *= mul;\r\n mul %= 1000000007;\r\n --k;\r\n }\r\n Console.WriteLine(result);\r\n }\r\n }\r\n}\r\n", "lang_cluster": "C#", "tags": ["math", "combinatorics"], "code_uid": "c262773c0d9003d34cb39003f40145ce", "src_uid": "5144b9b281ea4087d8334d91c3c8bda4", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "C# 8", "source_code": "using System;\r\nusing System.Linq;\r\nusing CompLib.Util;\r\nusing System.Threading;\r\nusing System.IO;\r\nusing CompLib.Mathematics;\r\n\r\npublic class Program\r\n{\r\n int N;\r\n public void Solve()\r\n {\r\n var sc = new Scanner();\r\n N = sc.NextInt();\r\n\r\n ModInt[] dp = new ModInt[N + 1];\r\n dp[1] = 1;\r\n for(int i = 2;i <= N; i++)\r\n {\r\n dp[i] = dp[i - 1] * dp[i - 1] * 16;\r\n }\r\n\r\n Console.WriteLine(dp[N] * 6);\r\n }\r\n\r\n public static void Main(string[] args) => new Program().Solve();\r\n // public static void Main(string[] args) => new Thread(new Program().Solve, 1 << 27).Start();\r\n}\r\n\r\n// https://bitbucket.org/camypaper/complib\r\nnamespace CompLib.Mathematics\r\n{\r\n #region ModInt\r\n /// \r\n /// [0,) \u307e\u3067\u306e\u5024\u3092\u53d6\u308b\u3088\u3046\u306a\u6570\r\n /// \r\n public struct ModInt\r\n {\r\n /// \r\n /// \u5270\u4f59\u3092\u53d6\u308b\u5024\uff0e\r\n /// \r\n public const long Mod = (int)1e9 + 7;\r\n // public const long Mod = 998244353;\r\n\r\n /// \r\n /// \u5b9f\u969b\u306e\u6570\u5024\uff0e\r\n /// \r\n public long num;\r\n /// \r\n /// \u5024\u304c \u3067\u3042\u308b\u3088\u3046\u306a\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u3092\u69cb\u7bc9\u3057\u307e\u3059\uff0e\r\n /// \r\n /// \u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u304c\u6301\u3064\u5024\r\n /// \u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u306e\u554f\u984c\u4e0a\uff0c\u30b3\u30f3\u30b9\u30c8\u30e9\u30af\u30bf\u5185\u3067\u306f\u5270\u4f59\u3092\u53d6\u308a\u307e\u305b\u3093\uff0e\u305d\u306e\u305f\u3081\uff0c \u2208 [0,) \u3092\u6e80\u305f\u3059\u3088\u3046\u306a \u3092\u6e21\u3057\u3066\u304f\u3060\u3055\u3044\uff0e\u3053\u306e\u30b3\u30f3\u30b9\u30c8\u30e9\u30af\u30bf\u306f O(1) \u3067\u5b9f\u884c\u3055\u308c\u307e\u3059\uff0e\r\n public ModInt(long n) { num = n; }\r\n /// \r\n /// \u3053\u306e\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u306e\u6570\u5024\u3092\u6587\u5b57\u5217\u306b\u5909\u63db\u3057\u307e\u3059\uff0e\r\n /// \r\n /// [0,) \u306e\u7bc4\u56f2\u5185\u306e\u6574\u6570\u3092 10 \u9032\u8868\u8a18\u3057\u305f\u3082\u306e\uff0e\r\n public override string ToString() { return num.ToString(); }\r\n public static ModInt operator +(ModInt l, ModInt r) { l.num += r.num; if (l.num >= Mod) l.num -= Mod; return l; }\r\n public static ModInt operator -(ModInt l, ModInt r) { l.num -= r.num; if (l.num < 0) l.num += Mod; return l; }\r\n public static ModInt operator *(ModInt l, ModInt r) { return new ModInt(l.num * r.num % Mod); }\r\n public static implicit operator ModInt(long n) { n %= Mod; if (n < 0) n += Mod; return new ModInt(n); }\r\n\r\n /// \r\n /// \u4e0e\u3048\u3089\u308c\u305f 2 \u3064\u306e\u6570\u5024\u304b\u3089\u3079\u304d\u5270\u4f59\u3092\u8a08\u7b97\u3057\u307e\u3059\uff0e\r\n /// \r\n /// \u3079\u304d\u4e57\u306e\u5e95\r\n /// \u3079\u304d\u6307\u6570\r\n /// \u7e70\u308a\u8fd4\u3057\u4e8c\u4e57\u6cd5\u306b\u3088\u308a O(N log N) \u3067\u5b9f\u884c\u3055\u308c\u307e\u3059\uff0e\r\n public static ModInt Pow(ModInt v, long k) { return Pow(v.num, k); }\r\n\r\n /// \r\n /// \u4e0e\u3048\u3089\u308c\u305f 2 \u3064\u306e\u6570\u5024\u304b\u3089\u3079\u304d\u5270\u4f59\u3092\u8a08\u7b97\u3057\u307e\u3059\uff0e\r\n /// \r\n /// \u3079\u304d\u4e57\u306e\u5e95\r\n /// \u3079\u304d\u6307\u6570\r\n /// \u7e70\u308a\u8fd4\u3057\u4e8c\u4e57\u6cd5\u306b\u3088\u308a O(N log N) \u3067\u5b9f\u884c\u3055\u308c\u307e\u3059\uff0e\r\n public static ModInt Pow(long v, long k)\r\n {\r\n long ret = 1;\r\n for (k %= Mod - 1; k > 0; k >>= 1, v = v * v % Mod)\r\n if ((k & 1) == 1) ret = ret * v % Mod;\r\n return new ModInt(ret);\r\n }\r\n /// \r\n /// \u4e0e\u3048\u3089\u308c\u305f\u6570\u306e\u9006\u5143\u3092\u8a08\u7b97\u3057\u307e\u3059\uff0e\r\n /// \r\n /// \u9006\u5143\u3092\u53d6\u308b\u5bfe\u8c61\u3068\u306a\u308b\u6570\r\n /// \u9006\u5143\u3068\u306a\u308b\u3088\u3046\u306a\u5024\r\n /// \u6cd5\u304c\u7d20\u6570\u3067\u3042\u308b\u3053\u3068\u3092\u4eee\u5b9a\u3057\u3066\uff0c\u30d5\u30a7\u30eb\u30de\u30fc\u306e\u5c0f\u5b9a\u7406\u306b\u5f93\u3063\u3066\u9006\u5143\u3092 O(log N) \u3067\u8a08\u7b97\u3057\u307e\u3059\uff0e\r\n public static ModInt Inverse(ModInt v) { return Pow(v, Mod - 2); }\r\n }\r\n #endregion\r\n #region Binomial Coefficient\r\n public class BinomialCoefficient\r\n {\r\n public ModInt[] fact, ifact;\r\n public BinomialCoefficient(int n)\r\n {\r\n fact = new ModInt[n + 1];\r\n ifact = new ModInt[n + 1];\r\n fact[0] = 1;\r\n for (int i = 1; i <= n; i++)\r\n fact[i] = fact[i - 1] * i;\r\n ifact[n] = ModInt.Inverse(fact[n]);\r\n for (int i = n - 1; i >= 0; i--)\r\n ifact[i] = ifact[i + 1] * (i + 1);\r\n ifact[0] = ifact[1];\r\n }\r\n public ModInt this[int n, int r]\r\n {\r\n get\r\n {\r\n if (n < 0 || n >= fact.Length || r < 0 || r > n) return 0;\r\n return fact[n] * ifact[n - r] * ifact[r];\r\n }\r\n }\r\n public ModInt RepeatedCombination(int n, int k)\r\n {\r\n if (k == 0) return 1;\r\n return this[n + k - 1, k];\r\n }\r\n }\r\n #endregion\r\n}\r\n\r\n\r\nnamespace CompLib.Util\r\n{\r\n using System;\r\n using System.Linq;\r\n\r\n class Scanner\r\n {\r\n private string[] _line;\r\n private int _index;\r\n private const char Separator = ' ';\r\n\r\n public Scanner()\r\n {\r\n _line = new string[0];\r\n _index = 0;\r\n }\r\n\r\n public string Next()\r\n {\r\n if (_index >= _line.Length)\r\n {\r\n string s;\r\n do\r\n {\r\n s = Console.ReadLine();\r\n } while (s.Length == 0);\r\n\r\n _line = s.Split(Separator);\r\n _index = 0;\r\n }\r\n\r\n return _line[_index++];\r\n }\r\n\r\n public string ReadLine()\r\n {\r\n _index = _line.Length;\r\n return Console.ReadLine();\r\n }\r\n\r\n public int NextInt() => int.Parse(Next());\r\n public long NextLong() => long.Parse(Next());\r\n public double NextDouble() => double.Parse(Next());\r\n public decimal NextDecimal() => decimal.Parse(Next());\r\n public char NextChar() => Next()[0];\r\n public char[] NextCharArray() => Next().ToCharArray();\r\n\r\n public string[] Array()\r\n {\r\n string s = Console.ReadLine();\r\n _line = s.Length == 0 ? new string[0] : s.Split(Separator);\r\n _index = _line.Length;\r\n return _line;\r\n }\r\n\r\n public int[] IntArray() => Array().Select(int.Parse).ToArray();\r\n public long[] LongArray() => Array().Select(long.Parse).ToArray();\r\n public double[] DoubleArray() => Array().Select(double.Parse).ToArray();\r\n public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();\r\n }\r\n}\r\n", "lang_cluster": "C#", "tags": ["math", "combinatorics"], "code_uid": "750bc9d0bb1213907cb48c89cdbf3f0d", "src_uid": "5144b9b281ea4087d8334d91c3c8bda4", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace ConsoleApplication1\n{\n class Program\n {\n static void Main(string[] args)\n {\n string s = Console.ReadLine();\n Console.Write(int.Parse(s[s.Length-1].ToString())%2);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "e042219d8910e3861bde3f0edde4fd1d", "src_uid": "e52bc741bb72bb8e79cf392b2d15354f", "difficulty": null, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.IO;\nusing System.Linq;\nusing System.Text;\nusing System.Collections;\n\nnamespace ConsoleApplication3\n{\n class Program\n { \n static void Main(string[] args)\n {\n string a = Console.ReadLine();\n if (Convert.ToInt32(a[a.Length - 1]) % 2 == 0)\n Console.WriteLine(0);\n else Console.WriteLine(1);\n }\n }\n}", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "39f1f4c3ac5b6eaa3d0f1289e7d7453e", "src_uid": "e52bc741bb72bb8e79cf392b2d15354f", "difficulty": null, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\n\npublic class Program\n{\n public void Solve()\n {\n var sc = new Scanner();\n int n = sc.NextInt();\n Console.WriteLine(ModInt.Pow(27, n) - ModInt.Pow(7, n));\n }\n\n public static void Main(string[] args)\n {\n new Program().Solve();\n }\n}\n\n#region ModInt\n\n/// \n/// [0,) \u307e\u3067\u306e\u5024\u3092\u53d6\u308b\u3088\u3046\u306a\u6570\n/// \npublic struct ModInt\n{\n /// \n /// \u5270\u4f59\u3092\u53d6\u308b\u5024\uff0e\n /// \n public const long Mod = (int) 1e9 + 7;\n\n /// \n /// \u5b9f\u969b\u306e\u6570\u5024\uff0e\n /// \n public long num;\n\n /// \n /// \u5024\u304c \u3067\u3042\u308b\u3088\u3046\u306a\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u3092\u69cb\u7bc9\u3057\u307e\u3059\uff0e\n /// \n /// \u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u304c\u6301\u3064\u5024\n /// \u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u306e\u554f\u984c\u4e0a\uff0c\u30b3\u30f3\u30b9\u30c8\u30e9\u30af\u30bf\u5185\u3067\u306f\u5270\u4f59\u3092\u53d6\u308a\u307e\u305b\u3093\uff0e\u305d\u306e\u305f\u3081\uff0c \u2208 [0,) \u3092\u6e80\u305f\u3059\u3088\u3046\u306a \u3092\u6e21\u3057\u3066\u304f\u3060\u3055\u3044\uff0e\u3053\u306e\u30b3\u30f3\u30b9\u30c8\u30e9\u30af\u30bf\u306f O(1) \u3067\u5b9f\u884c\u3055\u308c\u307e\u3059\uff0e\n public ModInt(long n)\n {\n num = n;\n }\n\n /// \n /// \u3053\u306e\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u306e\u6570\u5024\u3092\u6587\u5b57\u5217\u306b\u5909\u63db\u3057\u307e\u3059\uff0e\n /// \n /// [0,) \u306e\u7bc4\u56f2\u5185\u306e\u6574\u6570\u3092 10 \u9032\u8868\u8a18\u3057\u305f\u3082\u306e\uff0e\n public override string ToString()\n {\n return num.ToString();\n }\n\n public static ModInt operator +(ModInt l, ModInt r)\n {\n l.num += r.num;\n if (l.num >= Mod) l.num -= Mod;\n return l;\n }\n\n public static ModInt operator -(ModInt l, ModInt r)\n {\n l.num -= r.num;\n if (l.num < 0) l.num += Mod;\n return l;\n }\n\n public static ModInt operator *(ModInt l, ModInt r)\n {\n return new ModInt(l.num * r.num % Mod);\n }\n\n public static implicit operator ModInt(long n)\n {\n n %= Mod;\n if (n < 0) n += Mod;\n return new ModInt(n);\n }\n\n /// \n /// \u4e0e\u3048\u3089\u308c\u305f 2 \u3064\u306e\u6570\u5024\u304b\u3089\u3079\u304d\u5270\u4f59\u3092\u8a08\u7b97\u3057\u307e\u3059\uff0e\n /// \n /// \u3079\u304d\u4e57\u306e\u5e95\n /// \u3079\u304d\u6307\u6570\n /// \u7e70\u308a\u8fd4\u3057\u4e8c\u4e57\u6cd5\u306b\u3088\u308a O(N log N) \u3067\u5b9f\u884c\u3055\u308c\u307e\u3059\uff0e\n public static ModInt Pow(ModInt v, long k)\n {\n return Pow(v.num, k);\n }\n\n /// \n /// \u4e0e\u3048\u3089\u308c\u305f 2 \u3064\u306e\u6570\u5024\u304b\u3089\u3079\u304d\u5270\u4f59\u3092\u8a08\u7b97\u3057\u307e\u3059\uff0e\n /// \n /// \u3079\u304d\u4e57\u306e\u5e95\n /// \u3079\u304d\u6307\u6570\n /// \u7e70\u308a\u8fd4\u3057\u4e8c\u4e57\u6cd5\u306b\u3088\u308a O(N log N) \u3067\u5b9f\u884c\u3055\u308c\u307e\u3059\uff0e\n public static ModInt Pow(long v, long k)\n {\n long ret = 1;\n for (k %= Mod - 1; k > 0; k >>= 1, v = v * v % Mod)\n if ((k & 1) == 1)\n ret = ret * v % Mod;\n return new ModInt(ret);\n }\n\n /// \n /// \u4e0e\u3048\u3089\u308c\u305f\u6570\u306e\u9006\u5143\u3092\u8a08\u7b97\u3057\u307e\u3059\uff0e\n /// \n /// \u9006\u5143\u3092\u53d6\u308b\u5bfe\u8c61\u3068\u306a\u308b\u6570\n /// \u9006\u5143\u3068\u306a\u308b\u3088\u3046\u306a\u5024\n /// \u6cd5\u304c\u7d20\u6570\u3067\u3042\u308b\u3053\u3068\u3092\u4eee\u5b9a\u3057\u3066\uff0c\u30d5\u30a7\u30eb\u30de\u30fc\u306e\u5c0f\u5b9a\u7406\u306b\u5f93\u3063\u3066\u9006\u5143\u3092 O(log N) \u3067\u8a08\u7b97\u3057\u307e\u3059\uff0e\n public static ModInt Inverse(ModInt v)\n {\n return Pow(v, Mod - 2);\n }\n}\n\n#endregion\n\nclass Scanner\n{\n public Scanner()\n {\n _pos = 0;\n _line = new string[0];\n }\n\n const char Separator = ' ';\n private int _pos;\n private string[] _line;\n\n #region \u30b9\u30da\u30fc\u30b9\u533a\u5207\u308a\u3067\u53d6\u5f97\n\n public string Next()\n {\n if (_pos >= _line.Length)\n {\n _line = Console.ReadLine().Split(Separator);\n _pos = 0;\n }\n\n return _line[_pos++];\n }\n\n public int NextInt()\n {\n return int.Parse(Next());\n }\n\n public long NextLong()\n {\n return long.Parse(Next());\n }\n\n public double NextDouble()\n {\n return double.Parse(Next());\n }\n\n #endregion\n\n #region \u578b\u5909\u63db\n\n private int[] ToIntArray(string[] array)\n {\n var result = new int[array.Length];\n for (int i = 0; i < array.Length; i++)\n {\n result[i] = int.Parse(array[i]);\n }\n\n return result;\n }\n\n private long[] ToLongArray(string[] array)\n {\n var result = new long[array.Length];\n for (int i = 0; i < array.Length; i++)\n {\n result[i] = long.Parse(array[i]);\n }\n\n return result;\n }\n\n private double[] ToDoubleArray(string[] array)\n {\n var result = new double[array.Length];\n for (int i = 0; i < array.Length; i++)\n {\n result[i] = double.Parse(array[i]);\n }\n\n return result;\n }\n\n #endregion\n\n #region \u914d\u5217\u53d6\u5f97\n\n public string[] Array()\n {\n if (_pos >= _line.Length)\n _line = Console.ReadLine().Split(Separator);\n\n _pos = _line.Length;\n return _line;\n }\n\n public int[] IntArray()\n {\n return ToIntArray(Array());\n }\n\n public long[] LongArray()\n {\n return ToLongArray(Array());\n }\n\n public double[] DoubleArray()\n {\n return ToDoubleArray(Array());\n }\n\n #endregion\n}", "lang_cluster": "C#", "tags": ["combinatorics"], "code_uid": "b89da86ebeb85961366a233eeb1dd87d", "src_uid": "eae87ec16c284f324d86b7e65fda093c", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\n\nnamespace Task2\n{\n class Program\n {\n static void Main(string[] args)\n {\n const long size = 1000000007;\n long n = long.Parse(Console.ReadLine());\n long x = 3;\n long y = 7;\n for (int i = 1; i < 3*n; i++)\n {\n x *= 3;\n if (x >= size) x %= size;\n }\n for (int i = 1; i < n; i++)\n {\n y *= 7;\n if (y >= size) y %= size;\n }\n if (x - y < 0) Console.WriteLine(x - y + size);\n else Console.WriteLine(x - y);\n }\n }\n}", "lang_cluster": "C#", "tags": ["combinatorics"], "code_uid": "0a708f0ba02596fafe1f19d227ce6992", "src_uid": "eae87ec16c284f324d86b7e65fda093c", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": ".NET Core C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.IO;\nusing System.Linq;\nusing static System.Math;\nusing System.Text;\nusing System.Threading;\nusing System.Globalization;\nusing System.Runtime.CompilerServices;\nusing Library;\n\nnamespace Program\n{\n public static class ProblemD\n {\n static bool SAIKI = false;\n static public int numberOfRandomCases = 0;\n static public void MakeTestCase(List _input, List _output, ref Func _outputChecker)\n {\n }\n static public void Solve()\n {\n var n = (int)NN;\n var m = (int)NN;\n var q = (int)NN;\n var pList = NNList(n);\n var ab = Repeat(0, m).Select(_ => new { a = (int)NN - 1, b = (int)NN - 1 }).ToArray();\n var query = Repeat(0, q).Select(_ => new { t = (int)NN, param = (int)NN }).ToArray();\n var graph = Repeat(0, n).Select(_ => new List()).ToArray();\n var uf = new LIB_UnionFind(n);\n var deleted = new bool[m];\n foreach (var item in query)\n {\n if (item.t == 2) deleted[item.param - 1] = true;\n }\n var procTgtEdgeIndex = new bool[m];\n for (var i = 0; i < m; i++)\n {\n if (!deleted[i])\n {\n if (uf.Unite(ab[i].a, ab[i].b))\n {\n graph[ab[i].a].Add(ab[i].b);\n graph[ab[i].b].Add(ab[i].a);\n }\n }\n }\n foreach (var item in query.Reverse())\n {\n if (item.t == 2)\n {\n var i = item.param - 1;\n if (uf.Unite(ab[i].a, ab[i].b))\n {\n procTgtEdgeIndex[i] = true;\n graph[ab[i].a].Add(ab[i].b);\n graph[ab[i].b].Add(ab[i].a);\n }\n }\n }\n var param = new int[n];\n var qList = new List>();\n var used = new bool[n];\n {\n var done = new bool[n];\n for (var i = 0; i < n; i++)\n {\n if (!done[i])\n {\n var c = qList.Count();\n var tmpq = new LIB_PriorityQueue(false);\n qList.Add(tmpq);\n var que = new Queue();\n que.Enqueue(i);\n done[i] = true;\n param[i] = c;\n while (que.Count > 0)\n {\n var v = que.Dequeue();\n foreach (var item in graph[v])\n {\n if (done[item]) continue;\n done[item] = true;\n param[item] = c;\n que.Enqueue(item);\n }\n }\n }\n qList[param[i]].Push((int)pList[i], i);\n }\n }\n var leftVs = new List();\n var rightVs = new List();\n var leftQ = new Queue<(int, int)>();\n var rightQ = new Queue<(int, int)>();\n foreach (var item in query)\n {\n if (item.t == 1)\n {\n var v = item.param - 1;\n var p = param[v];\n var que = qList[p];\n var value = 0L;\n while (que.Count > 0)\n {\n if (used[que.Peek.Value] || p != param[que.Peek.Value]) que.Pop();\n else\n {\n used[que.Peek.Value] = true;\n value = que.Pop().Key;\n break;\n }\n }\n Console.WriteLine(value);\n }\n else\n {\n var leftV = ab[item.param - 1].a;\n var rightV = ab[item.param - 1].b;\n if (!procTgtEdgeIndex[item.param - 1]) continue;\n leftQ.Clear();\n rightQ.Clear();\n var color = param[leftV];\n var lidx = 0;\n var ridx = 0;\n var lv = leftV;\n var rv = rightV;\n var lp = rightV;\n var rp = leftV;\n var exit = false;\n leftVs.Clear();\n rightVs.Clear();\n leftVs.Add(lv);\n rightVs.Add(rv);\n var procVs = leftVs;\n while (true)\n {\n var leftOK = false;\n while (true)\n {\n while (graph[lv].Count > lidx)\n {\n var v = graph[lv][lidx++];\n if (v == lp) continue;\n if (color != param[v]) continue;\n leftQ.Enqueue((v, lv));\n leftVs.Add(v);\n leftOK = true;\n break;\n }\n if (leftOK) break;\n if (leftQ.Count == 0)\n {\n exit = true;\n break;\n }\n var pop = leftQ.Dequeue();\n lv = pop.Item1;\n lp = pop.Item2;\n lidx = 0;\n }\n if (exit) break;\n var rightOK = false;\n while (true)\n {\n while (graph[rv].Count > ridx)\n {\n var v = graph[rv][ridx++];\n if (v == rp) continue;\n if (color != param[v]) continue;\n rightQ.Enqueue((v, rv));\n rightVs.Add(v);\n rightOK = true;\n break;\n }\n if (rightOK) break;\n if (rightQ.Count == 0)\n {\n procVs = rightVs;\n exit = true;\n break;\n }\n var pop = rightQ.Dequeue();\n rv = pop.Item1;\n rp = pop.Item2;\n ridx = 0;\n }\n if (exit) break;\n }\n var procColorTo = qList.Count;\n var tmpq = new LIB_PriorityQueue(false);\n qList.Add(tmpq);\n foreach (var item2 in procVs)\n {\n if (!used[item2]) tmpq.Push((int)pList[item2], item2);\n param[item2] = procColorTo;\n }\n }\n }\n }\n class Printer : StreamWriter\n {\n public override IFormatProvider FormatProvider { get { return CultureInfo.InvariantCulture; } }\n public Printer(Stream stream) : base(stream, new UTF8Encoding(false, true)) { base.AutoFlush = false; }\n public Printer(Stream stream, Encoding encoding) : base(stream, encoding) { base.AutoFlush = false; }\n }\n static LIB_FastIO fastio = new LIB_FastIODebug();\n static public void Main(string[] args) { if (args.Length == 0) { fastio = new LIB_FastIO(); Console.SetOut(new Printer(Console.OpenStandardOutput())); } if (SAIKI) { var t = new Thread(Solve, 134217728); t.Start(); t.Join(); } else Solve(); Console.Out.Flush(); }\n static long NN => fastio.Long();\n static double ND => fastio.Double();\n static string NS => fastio.Scan();\n static long[] NNList(long N) => Repeat(0, N).Select(_ => NN).ToArray();\n static double[] NDList(long N) => Repeat(0, N).Select(_ => ND).ToArray();\n static string[] NSList(long N) => Repeat(0, N).Select(_ => NS).ToArray();\n static long Count(this IEnumerable x, Func pred) => Enumerable.Count(x, pred);\n static IEnumerable Repeat(T v, long n) => Enumerable.Repeat(v, (int)n);\n static IEnumerable Range(long s, long c) => Enumerable.Range((int)s, (int)c);\n static IOrderedEnumerable OrderByRand(this IEnumerable x) => Enumerable.OrderBy(x, _ => xorshift);\n static IOrderedEnumerable OrderBy(this IEnumerable x) => Enumerable.OrderBy(x.OrderByRand(), e => e);\n static IOrderedEnumerable OrderBy(this IEnumerable x, Func selector) => Enumerable.OrderBy(x.OrderByRand(), selector);\n static IOrderedEnumerable OrderByDescending(this IEnumerable x) => Enumerable.OrderByDescending(x.OrderByRand(), e => e);\n static IOrderedEnumerable OrderByDescending(this IEnumerable x, Func selector) => Enumerable.OrderByDescending(x.OrderByRand(), selector);\n static IOrderedEnumerable OrderBy(this IEnumerable x) => x.OrderByRand().OrderBy(e => e, StringComparer.OrdinalIgnoreCase);\n static IOrderedEnumerable OrderBy(this IEnumerable x, Func selector) => x.OrderByRand().OrderBy(selector, StringComparer.OrdinalIgnoreCase);\n static IOrderedEnumerable OrderByDescending(this IEnumerable x) => x.OrderByRand().OrderByDescending(e => e, StringComparer.OrdinalIgnoreCase);\n static IOrderedEnumerable OrderByDescending(this IEnumerable x, Func selector) => x.OrderByRand().OrderByDescending(selector, StringComparer.OrdinalIgnoreCase);\n static string Join(this IEnumerable x, string separator = \"\") => string.Join(separator, x);\n static uint xorshift { get { _xsi.MoveNext(); return _xsi.Current; } }\n static IEnumerator _xsi = _xsc();\n static IEnumerator _xsc() { uint x = 123456789, y = 362436069, z = 521288629, w = (uint)(DateTime.Now.Ticks & 0xffffffff); while (true) { var t = x ^ (x << 11); x = y; y = z; z = w; w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)); yield return w; } }\n static bool Chmax(this ref T lhs, T rhs) where T : struct, IComparable { if (lhs.CompareTo(rhs) < 0) { lhs = rhs; return true; } return false; }\n static bool Chmin(this ref T lhs, T rhs) where T : struct, IComparable { if (lhs.CompareTo(rhs) > 0) { lhs = rhs; return true; } return false; }\n }\n}\nnamespace Library {\n class LIB_UnionFind\n {\n int[] d;\n T[] v;\n Func f;\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public LIB_UnionFind(IEnumerable s, Func func)\n {\n v = s.ToArray();\n d = Enumerable.Repeat(-1, v.Length).ToArray();\n f = func;\n }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public bool Unite(long x, long y)\n {\n x = Root(x);\n y = Root(y);\n if (x != y)\n {\n d[x] = d[x] + d[y];\n v[x] = f(v[x], v[y]);\n d[y] = (int)x;\n }\n return x != y;\n }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public bool IsSame(long x, long y) => Root(x) == Root(y);\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public long Root(long x) => d[x] < 0 ? x : d[x] = (int)Root(d[x]);\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public long Count(long x) => -d[Root(x)];\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public T Calc(long x) => v[Root(x)];\n }\n class LIB_UnionFind : LIB_UnionFind\n {\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public LIB_UnionFind(long n) : base(Enumerable.Repeat(0, (int)n), (x, y) => x + y) { }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n new private void Calc(long x) { }\n }\n class LIB_FastIO\n {\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public LIB_FastIO() { str = Console.OpenStandardInput(); }\n readonly Stream str;\n readonly byte[] buf = new byte[2048];\n int len, ptr;\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n byte read()\n {\n if (ptr >= len)\n {\n ptr = 0;\n if ((len = str.Read(buf, 0, 2048)) <= 0)\n {\n return 0;\n }\n }\n return buf[ptr++];\n }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n char Char()\n {\n byte b = 0;\n do b = read();\n while (b < 33 || 126 < b);\n return (char)b;\n }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n virtual public string Scan()\n {\n var sb = new StringBuilder();\n for (var b = Char(); b >= 33 && b <= 126; b = (char)read())\n sb.Append(b);\n return sb.ToString();\n }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n virtual public long Long()\n {\n long ret = 0; byte b = 0; var ng = false;\n do b = read();\n while (b != '-' && (b < '0' || '9' < b));\n if (b == '-') { ng = true; b = read(); }\n for (; true; b = read())\n {\n if (b < '0' || '9' < b)\n return ng ? -ret : ret;\n else ret = (ret << 3) + (ret << 1) + b - '0';\n }\n }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n virtual public double Double() { return double.Parse(Scan(), CultureInfo.InvariantCulture); }\n }\n class LIB_FastIODebug : LIB_FastIO\n {\n Queue param = new Queue();\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n string NextString() { if (param.Count == 0) foreach (var item in Console.ReadLine().Split(' ')) param.Enqueue(item); return param.Dequeue(); }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public LIB_FastIODebug() { }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public override string Scan() => NextString();\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public override long Long() => long.Parse(NextString());\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public override double Double() => double.Parse(NextString());\n }\n class LIB_PriorityQueue\n {\n long[] heap;\n int[] dat;\n public (long, int) Peek => (heap[0], dat[0]);\n public long Count\n {\n get;\n private set;\n }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public LIB_PriorityQueue()\n {\n heap = new long[16];\n dat = new int[16];\n }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public void Push(long key, int val)\n {\n if (Count == heap.Length) Expand();\n var i = Count++;\n heap[i] = key;\n dat[i] = val;\n while (i > 0)\n {\n var ni = (i - 1) / 2;\n if (key <= heap[ni]) break;\n heap[i] = heap[ni];\n dat[i] = dat[ni];\n i = ni;\n }\n heap[i] = key;\n dat[i] = val;\n }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public KeyValuePair Pop()\n {\n var ret = new KeyValuePair(heap[0], dat[0]);\n var key = heap[--Count];\n var val = dat[Count];\n if (Count == 0) return ret;\n var i = 0; while ((i << 1) + 1 < Count)\n {\n var i1 = (i << 1) + 1;\n var i2 = (i << 1) + 2;\n if (i2 < Count && heap[i1] < heap[i2]) i1 = i2;\n if (key >= heap[i1]) break;\n heap[i] = heap[i1];\n dat[i] = dat[i1];\n i = i1;\n }\n heap[i] = key;\n dat[i] = val;\n return ret;\n }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n void Expand()\n {\n var tmp = new long[Count << 1];\n for (var i = 0; i < heap.Length; ++i) tmp[i] = heap[i];\n heap = tmp;\n var tmp2 = new int[Count << 1];\n for (var i = 0; i < dat.Length; ++i) tmp2[i] = dat[i];\n dat = tmp2;\n }\n }\n class LIB_PriorityQueue\n {\n T[] heap;\n Comparison comp;\n public T Peek => heap[0];\n public long Count\n {\n get;\n private set;\n }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public LIB_PriorityQueue(long cap, Comparison cmp, bool asc = true)\n {\n heap = new T[cap];\n comp = asc ? cmp : (x, y) => cmp(y, x);\n }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public LIB_PriorityQueue(Comparison cmp, bool asc = true)\n {\n heap = new T[16];\n comp = asc ? cmp : (x, y) => cmp(y, x);\n }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public LIB_PriorityQueue(long cap, bool asc = true) : this(cap, Comparer.Default.Compare, asc) { }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public LIB_PriorityQueue(bool asc = true) : this(Comparer.Default.Compare, asc) { }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public void Push(T val)\n {\n if (Count == heap.Length) Expand();\n var i = Count++;\n heap[i] = val;\n while (i > 0)\n {\n var ni = (i - 1) / 2;\n if (comp(val, heap[ni]) >= 0) break;\n heap[i] = heap[ni];\n i = ni;\n }\n heap[i] = val;\n }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public T Pop()\n {\n var ret = heap[0];\n var val = heap[--Count];\n if (Count == 0) return ret;\n var i = 0; while ((i << 1) + 1 < Count)\n {\n var i1 = (i << 1) + 1;\n var i2 = (i << 1) + 2;\n if (i2 < Count && comp(heap[i1], heap[i2]) > 0) i1 = i2;\n if (comp(val, heap[i1]) <= 0) break;\n heap[i] = heap[i1]; i = i1;\n }\n heap[i] = val;\n return ret;\n }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n void Expand()\n {\n var tmp = new T[Count << 1];\n for (var i = 0; i < heap.Length; ++i) tmp[i] = heap[i];\n heap = tmp;\n }\n }\n class LIB_PriorityQueue\n {\n LIB_PriorityQueue> q;\n public KeyValuePair Peek => q.Peek;\n public long Count => q.Count;\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public LIB_PriorityQueue(long cap, Comparison cmp, bool asc = true)\n {\n q = new LIB_PriorityQueue>(cap, (x, y) => cmp(x.Key, y.Key), asc);\n }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public LIB_PriorityQueue(Comparison cmp, bool asc = true)\n {\n q = new LIB_PriorityQueue>((x, y) => cmp(x.Key, y.Key), asc);\n }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public LIB_PriorityQueue(long cap, bool asc = true) : this(cap, Comparer.Default.Compare, asc) { }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public LIB_PriorityQueue(bool asc = true) : this(Comparer.Default.Compare, asc) { }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public void Push(TK k, TV v) => q.Push(new KeyValuePair(k, v));\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public KeyValuePair Pop() => q.Pop();\n }\n}\n", "lang_cluster": "C#", "tags": ["dsu", "graphs", "data structures", "implementation", "trees"], "code_uid": "c6438ecf454d8c9c02820b6d1305a003", "src_uid": "ad014bde729222db14f38caa521e4167", "difficulty": 2600.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Globalization;\nusing System.IO;\nusing System.Linq;\nusing System.Text;\nusing System.Threading;\n\n// (\u3065\u00b0\u03c9\u00b0)\u3065\uff90e\u2605\u309c\u30fb\u3002\u3002\u30fb\u309c\u309c\u30fb\u3002\u3002\u30fb\u309c\u2606\u309c\u30fb\u3002\u3002\u30fb\u309c\u309c\u30fb\u3002\u3002\u30fb\u309c\npublic class Solver\n{\n static List g;\n\n class Dsu\n {\n public readonly List parent;\n\n public Dsu(int n)\n {\n parent = Enumerable.Range(0, n).ToList();\n g = new List();\n for (int i = 0; i < n; i++)\n g.Add(new int[] { -1, -1 });\n }\n\n public int FindSet(int v)\n {\n if (v == parent[v])\n return v;\n return parent[v] = FindSet(parent[v]);\n }\n\n public void UnionSets(int a, int b)\n {\n a = FindSet(a);\n b = FindSet(b);\n if (a != b)\n {\n parent[a] = parent[b] = parent.Count;\n g.Add(new[] { a, b });\n parent.Add(parent.Count);\n }\n }\n }\n\n int[] c;\n int[] tree;\n\n int Cmp(int l, int r)\n {\n return c2[l] > c2[r] ? l : r;\n }\n\n void Build(int x, int xl, int xr)\n {\n if (xl == xr)\n {\n tree[x] = xl;\n return; \n }\n int xm = (xl + xr) / 2;\n Build(x * 2, xl, xm);\n Build(x * 2 + 1, xm + 1, xr);\n tree[x] = Cmp(tree[2 * x], tree[2 * x + 1]);\n }\n\n void Set(int x, int xl, int xr, int idx)\n {\n if (xl == xr)\n {\n c2[xl] = 0;\n return;\n }\n\n int xm = (xl + xr) / 2;\n if (idx <= xm)\n Set(x * 2, xl, xm, idx);\n else\n Set(x * 2 + 1, xm + 1, xr, idx);\n tree[x] = Cmp(tree[2 * x], tree[2 * x + 1]);\n }\n\n int Query(int x, int xl, int xr, int l, int r)\n {\n if (l == xl && r == xr)\n return tree[x];\n int xm = (xl + xr) / 2;\n if (r <= xm)\n return Query(x * 2, xl, xm, l, r);\n if (l > xm)\n return Query(x * 2 + 1, xm + 1, xr, l, r);\n return Cmp(Query(x * 2, xl, xm, l, xm), Query(x * 2 + 1, xm + 1, xr, xm + 1, r));\n }\n\n int n;\n bool[] vis;\n int[] tin, tout, c2;\n int timer;\n void Dfs(int x)\n {\n if (x < n)\n c2[timer] = c[x];\n vis[x] = true;\n tin[x] = timer++;\n foreach (int e in g[x])\n if (e != -1)\n Dfs(e);\n tout[x] = timer;\n }\n\n public void Solve()\n {\n n = ReadInt();\n int m = ReadInt();\n int q = ReadInt();\n c = ReadIntArray();\n var a = ReadIntMatrix(m);\n var b = ReadIntMatrix(q);\n\n //n = 200000;\n //m = 199999;\n //q = 500000;\n //c = new int[n];\n //var rnd = new Random(13);\n //for (int i = 0; i < n; i++)\n // c[i] = rnd.Next(n) + 1;\n //a = new int[m][];\n //for (int i = 0; i < m; i++)\n // a[i] = new[] { i + 1, i + 2 };\n //b = new int[q][];\n //int cnt = 1;\n //for (int i = 0; i < q; i++)\n //{\n // b[i] = new int[2];\n // b[i][0] = rnd.Next(2) + 1;\n // if (cnt > m)\n // b[i][0] = 1;\n // if (b[i][0] == 1)\n // {\n // b[i][1] = rnd.Next(n) + 1;\n // }\n // else\n // {\n // b[i][1] = cnt++;\n // }\n //}\n\n var f = new bool[m];\n for (int i = 0; i < q; i++)\n {\n b[i][1]--;\n if (b[i][0] == 2)\n f[b[i][1]] = true;\n }\n\n var dsu = new Dsu(n);\n for (int i = 0; i < m; i++)\n {\n a[i][0]--;\n a[i][1]--;\n if (!f[i])\n dsu.UnionSets(a[i][0], a[i][1]);\n }\n\n for (int i = q - 1; i >= 0; i--)\n {\n if (b[i][0] == 1)\n {\n b[i][1] = dsu.FindSet(b[i][1]);\n }\n else\n {\n dsu.UnionSets(a[b[i][1]][0], a[b[i][1]][1]);\n }\n }\n\n int n2 = dsu.parent.Count;\n tin = new int[n2];\n tout = new int[n2];\n vis = new bool[n2];\n c2 = new int[n2];\n for (int i = n2 - 1; i >= 0; i--)\n if (!vis[i])\n Dfs(i);\n\n tree = new int[4 * n2];\n Build(1, 0, n2 - 1);\n for (int i = 0; i < q; i++)\n if (b[i][0] == 1)\n {\n int x = Query(1, 0, n2 - 1, tin[b[i][1]], tout[b[i][1]] - 1);\n Write(c2[x]);\n Set(1, 0, n2 - 1, x);\n }\n }\n\n #region Main\n\n protected static TextReader reader;\n protected static TextWriter writer;\n static void Main()\n {\n#if DEBUG\n reader = new StreamReader(\"..\\\\..\\\\input.txt\");\n //reader = new StreamReader(Console.OpenStandardInput());\n writer = Console.Out;\n //writer = new StreamWriter(\"..\\\\..\\\\output.txt\");\n#else\n reader = new StreamReader(Console.OpenStandardInput());\n writer = new StreamWriter(Console.OpenStandardOutput());\n //reader = new StreamReader(\"input.txt\");\n //writer = new StreamWriter(\"output.txt\");\n#endif\n try\n {\n //new Solver().Solve();\n var thread = new Thread(new Solver().Solve, 1024 * 1024 * 128);\n thread.Start();\n thread.Join();\n }\n catch (Exception ex)\n {\n#if DEBUG\n Console.WriteLine(ex);\n#else\n throw;\n#endif\n }\n reader.Close();\n writer.Close();\n }\n\n #endregion\n\n #region Read / Write\n private static Queue currentLineTokens = new Queue();\n private static string[] ReadAndSplitLine() { return reader.ReadLine().Split(new[] { ' ', '\\t', }, StringSplitOptions.RemoveEmptyEntries); }\n public static string ReadToken() { while (currentLineTokens.Count == 0) currentLineTokens = new Queue(ReadAndSplitLine()); return currentLineTokens.Dequeue(); }\n public static int ReadInt() { return int.Parse(ReadToken()); }\n public static long ReadLong() { return long.Parse(ReadToken()); }\n public static double ReadDouble() { return double.Parse(ReadToken(), CultureInfo.InvariantCulture); }\n public static int[] ReadIntArray() { return ReadAndSplitLine().Select(int.Parse).ToArray(); }\n public static long[] ReadLongArray() { return ReadAndSplitLine().Select(long.Parse).ToArray(); }\n public static double[] ReadDoubleArray() { return ReadAndSplitLine().Select(s => double.Parse(s, CultureInfo.InvariantCulture)).ToArray(); }\n public static int[][] ReadIntMatrix(int numberOfRows) { int[][] matrix = new int[numberOfRows][]; for (int i = 0; i < numberOfRows; i++) matrix[i] = ReadIntArray(); return matrix; }\n public static int[][] ReadAndTransposeIntMatrix(int numberOfRows)\n {\n int[][] matrix = ReadIntMatrix(numberOfRows); int[][] ret = new int[matrix[0].Length][];\n for (int i = 0; i < ret.Length; i++) { ret[i] = new int[numberOfRows]; for (int j = 0; j < numberOfRows; j++) ret[i][j] = matrix[j][i]; }\n return ret;\n }\n public static string[] ReadLines(int quantity) { string[] lines = new string[quantity]; for (int i = 0; i < quantity; i++) lines[i] = reader.ReadLine().Trim(); return lines; }\n public static void WriteArray(IEnumerable array) { writer.WriteLine(string.Join(\" \", array)); }\n public static void Write(params object[] array) { WriteArray(array); }\n public static void WriteLines(IEnumerable array) { foreach (var a in array) writer.WriteLine(a); }\n private class SDictionary : Dictionary\n {\n public new TValue this[TKey key]\n {\n get { return ContainsKey(key) ? base[key] : default(TValue); }\n set { base[key] = value; }\n }\n }\n private static T[] Init(int size) where T : new() { var ret = new T[size]; for (int i = 0; i < size; i++) ret[i] = new T(); return ret; }\n #endregion\n}", "lang_cluster": "C#", "tags": ["dsu", "graphs", "data structures", "implementation", "trees"], "code_uid": "4397da929943481429797711ac7254ae", "src_uid": "ad014bde729222db14f38caa521e4167", "difficulty": 2600.0, "exec_outcome": "PASSED"} {"lang": ".NET Core C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.IO;\nusing System.Linq;\nusing static System.Math;\nusing System.Text;\nusing System.Threading;\nusing System.Globalization;\nusing System.Runtime.CompilerServices;\nusing Library;\n\nnamespace Program\n{\n public static class ProblemD\n {\n static bool SAIKI = false;\n static public int numberOfRandomCases = 0;\n static public void MakeTestCase(List _input, List _output, ref Func _outputChecker)\n {\n }\n static public void Solve()\n {\n var n = (int)NN;\n var m = (int)NN;\n var q = (int)NN;\n var pList = NNList(n);\n var ab = Repeat(0, m).Select(_ => new { a = (int)NN - 1, b = (int)NN - 1 }).ToArray();\n var query = Repeat(0, q).Select(_ => new { t = (int)NN, param = (int)NN }).ToArray();\n var graph = Repeat(0, n).Select(_ => new List()).ToArray();\n var uf = new LIB_UnionFind(n);\n var deleted = new bool[m];\n foreach (var item in query)\n {\n if (item.t == 2) deleted[item.param - 1] = true;\n }\n var procTgtEdgeIndex = new bool[m];\n for (var i = 0; i < m; i++)\n {\n if (!deleted[i])\n {\n if (uf.Unite(ab[i].a, ab[i].b))\n {\n graph[ab[i].a].Add(ab[i].b);\n graph[ab[i].b].Add(ab[i].a);\n }\n }\n }\n foreach (var item in query.Reverse())\n {\n if (item.t == 2)\n {\n var i = item.param - 1;\n if (uf.Unite(ab[i].a, ab[i].b))\n {\n procTgtEdgeIndex[i] = true;\n graph[ab[i].a].Add(ab[i].b);\n graph[ab[i].b].Add(ab[i].a);\n }\n }\n }\n var param = new int[n];\n var qList = new List>();\n var used = new bool[n];\n {\n var done = new bool[n];\n for (var i = 0; i < n; i++)\n {\n if (!done[i])\n {\n var c = qList.Count();\n var tmpq = new LIB_PriorityQueue(false);\n qList.Add(tmpq);\n var que = new Queue();\n que.Enqueue(i);\n done[i] = true;\n param[i] = c;\n while (que.Count > 0)\n {\n var v = que.Dequeue();\n foreach (var item in graph[v])\n {\n if (done[item]) continue;\n done[item] = true;\n param[item] = c;\n que.Enqueue(item);\n }\n }\n }\n qList[param[i]].Push((int)pList[i], i);\n }\n }\n foreach (var item in query)\n {\n if (item.t == 1)\n {\n var v = item.param - 1;\n var p = param[v];\n var que = qList[p];\n var value = 0L;\n while (que.Count > 0)\n {\n if (used[que.Peek.Value] || p != param[que.Peek.Value]) que.Pop();\n else\n {\n used[que.Peek.Value] = true;\n value = que.Pop().Key;\n break;\n }\n }\n Console.WriteLine(value);\n }\n else\n {\n var leftV = ab[item.param - 1].a;\n var rightV = ab[item.param - 1].b;\n if (!procTgtEdgeIndex[item.param - 1]) continue;\n var leftQ = new Queue<(int, int)>();\n var rightQ = new Queue<(int, int)>();\n var color = param[leftV];\n var lidx = 0;\n var ridx = 0;\n var lv = leftV;\n var rv = rightV;\n var lp = rightV;\n var rp = leftV;\n var exit = false;\n var leftVs = new List();\n var rightVs = new List();\n leftVs.Add(lv);\n rightVs.Add(rv);\n var procVs = leftVs;\n while (true)\n {\n var leftOK = false;\n while (true)\n {\n while (graph[lv].Count > lidx)\n {\n var v = graph[lv][lidx++];\n if (v == lp) continue;\n if (color != param[v]) continue;\n leftQ.Enqueue((v, lv));\n leftVs.Add(v);\n leftOK = true;\n break;\n }\n if (leftOK) break;\n if (leftQ.Count == 0)\n {\n exit = true;\n break;\n }\n var pop = leftQ.Dequeue();\n lv = pop.Item1;\n lp = pop.Item2;\n lidx = 0;\n }\n if (exit) break;\n var rightOK = false;\n while (true)\n {\n while (graph[rv].Count > ridx)\n {\n var v = graph[rv][ridx++];\n if (v == rp) continue;\n if (color != param[v]) continue;\n rightQ.Enqueue((v, rv));\n rightVs.Add(v);\n rightOK = true;\n break;\n }\n if (rightOK) break;\n if (rightQ.Count == 0)\n {\n procVs = rightVs;\n exit = true;\n break;\n }\n var pop = rightQ.Dequeue();\n rv = pop.Item1;\n rp = pop.Item2;\n ridx = 0;\n }\n if (exit) break;\n }\n var procColorTo = qList.Count;\n var tmpq = new LIB_PriorityQueue(false);\n qList.Add(tmpq);\n foreach (var item2 in procVs)\n {\n if (!used[item2]) tmpq.Push((int)pList[item2], item2);\n param[item2] = procColorTo;\n }\n }\n }\n }\n class Printer : StreamWriter\n {\n public override IFormatProvider FormatProvider { get { return CultureInfo.InvariantCulture; } }\n public Printer(Stream stream) : base(stream, new UTF8Encoding(false, true)) { base.AutoFlush = false; }\n public Printer(Stream stream, Encoding encoding) : base(stream, encoding) { base.AutoFlush = false; }\n }\n static LIB_FastIO fastio = new LIB_FastIODebug();\n static public void Main(string[] args) { if (args.Length == 0) { fastio = new LIB_FastIO(); Console.SetOut(new Printer(Console.OpenStandardOutput())); } if (SAIKI) { var t = new Thread(Solve, 134217728); t.Start(); t.Join(); } else Solve(); Console.Out.Flush(); }\n static long NN => fastio.Long();\n static double ND => fastio.Double();\n static string NS => fastio.Scan();\n static long[] NNList(long N) => Repeat(0, N).Select(_ => NN).ToArray();\n static double[] NDList(long N) => Repeat(0, N).Select(_ => ND).ToArray();\n static string[] NSList(long N) => Repeat(0, N).Select(_ => NS).ToArray();\n static long Count(this IEnumerable x, Func pred) => Enumerable.Count(x, pred);\n static IEnumerable Repeat(T v, long n) => Enumerable.Repeat(v, (int)n);\n static IEnumerable Range(long s, long c) => Enumerable.Range((int)s, (int)c);\n static IOrderedEnumerable OrderByRand(this IEnumerable x) => Enumerable.OrderBy(x, _ => xorshift);\n static IOrderedEnumerable OrderBy(this IEnumerable x) => Enumerable.OrderBy(x.OrderByRand(), e => e);\n static IOrderedEnumerable OrderBy(this IEnumerable x, Func selector) => Enumerable.OrderBy(x.OrderByRand(), selector);\n static IOrderedEnumerable OrderByDescending(this IEnumerable x) => Enumerable.OrderByDescending(x.OrderByRand(), e => e);\n static IOrderedEnumerable OrderByDescending(this IEnumerable x, Func selector) => Enumerable.OrderByDescending(x.OrderByRand(), selector);\n static IOrderedEnumerable OrderBy(this IEnumerable x) => x.OrderByRand().OrderBy(e => e, StringComparer.OrdinalIgnoreCase);\n static IOrderedEnumerable OrderBy(this IEnumerable x, Func selector) => x.OrderByRand().OrderBy(selector, StringComparer.OrdinalIgnoreCase);\n static IOrderedEnumerable OrderByDescending(this IEnumerable x) => x.OrderByRand().OrderByDescending(e => e, StringComparer.OrdinalIgnoreCase);\n static IOrderedEnumerable OrderByDescending(this IEnumerable x, Func selector) => x.OrderByRand().OrderByDescending(selector, StringComparer.OrdinalIgnoreCase);\n static string Join(this IEnumerable x, string separator = \"\") => string.Join(separator, x);\n static uint xorshift { get { _xsi.MoveNext(); return _xsi.Current; } }\n static IEnumerator _xsi = _xsc();\n static IEnumerator _xsc() { uint x = 123456789, y = 362436069, z = 521288629, w = (uint)(DateTime.Now.Ticks & 0xffffffff); while (true) { var t = x ^ (x << 11); x = y; y = z; z = w; w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)); yield return w; } }\n static bool Chmax(this ref T lhs, T rhs) where T : struct, IComparable { if (lhs.CompareTo(rhs) < 0) { lhs = rhs; return true; } return false; }\n static bool Chmin(this ref T lhs, T rhs) where T : struct, IComparable { if (lhs.CompareTo(rhs) > 0) { lhs = rhs; return true; } return false; }\n }\n}\nnamespace Library {\n class LIB_PriorityQueue\n {\n long[] heap;\n int[] dat;\n public (long, int) Peek => (heap[0], dat[0]);\n public long Count\n {\n get;\n private set;\n }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public LIB_PriorityQueue()\n {\n heap = new long[16];\n dat = new int[16];\n }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public void Push(long key, int val)\n {\n if (Count == heap.Length) Expand();\n var i = Count++;\n heap[i] = key;\n dat[i] = val;\n while (i > 0)\n {\n var ni = (i - 1) / 2;\n if (key >= heap[ni]) break;\n heap[i] = heap[ni];\n dat[i] = dat[ni];\n i = ni;\n }\n heap[i] = key;\n dat[i] = val;\n }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public KeyValuePair Pop()\n {\n var ret = new KeyValuePair(heap[0], dat[0]);\n var key = heap[--Count];\n var val = dat[Count];\n if (Count == 0) return ret;\n var i = 0; while ((i << 1) + 1 < Count)\n {\n var i1 = (i << 1) + 1;\n var i2 = (i << 1) + 2;\n if (i2 < Count && heap[i1] > heap[i2]) i1 = i2;\n if (key <= heap[i1]) break;\n heap[i] = heap[i1];\n dat[i] = dat[i1];\n i = i1;\n }\n heap[i] = key;\n dat[i] = val;\n return ret;\n }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n void Expand()\n {\n var tmp = new long[Count << 1];\n for (var i = 0; i < heap.Length; ++i) tmp[i] = heap[i];\n heap = tmp;\n var tmp2 = new int[Count << 1];\n for (var i = 0; i < dat.Length; ++i) tmp2[i] = dat[i];\n dat = tmp2;\n }\n }\n class LIB_PriorityQueue\n {\n T[] heap;\n Comparison comp;\n public T Peek => heap[0];\n public long Count\n {\n get;\n private set;\n }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public LIB_PriorityQueue(long cap, Comparison cmp, bool asc = true)\n {\n heap = new T[cap];\n comp = asc ? cmp : (x, y) => cmp(y, x);\n }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public LIB_PriorityQueue(Comparison cmp, bool asc = true)\n {\n heap = new T[16];\n comp = asc ? cmp : (x, y) => cmp(y, x);\n }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public LIB_PriorityQueue(long cap, bool asc = true) : this(cap, Comparer.Default.Compare, asc) { }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public LIB_PriorityQueue(bool asc = true) : this(Comparer.Default.Compare, asc) { }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public void Push(T val)\n {\n if (Count == heap.Length) Expand();\n var i = Count++;\n heap[i] = val;\n while (i > 0)\n {\n var ni = (i - 1) / 2;\n if (comp(val, heap[ni]) >= 0) break;\n heap[i] = heap[ni];\n i = ni;\n }\n heap[i] = val;\n }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public T Pop()\n {\n var ret = heap[0];\n var val = heap[--Count];\n if (Count == 0) return ret;\n var i = 0; while ((i << 1) + 1 < Count)\n {\n var i1 = (i << 1) + 1;\n var i2 = (i << 1) + 2;\n if (i2 < Count && comp(heap[i1], heap[i2]) > 0) i1 = i2;\n if (comp(val, heap[i1]) <= 0) break;\n heap[i] = heap[i1]; i = i1;\n }\n heap[i] = val;\n return ret;\n }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n void Expand()\n {\n var tmp = new T[Count << 1];\n for (var i = 0; i < heap.Length; ++i) tmp[i] = heap[i];\n heap = tmp;\n }\n }\n class LIB_PriorityQueue\n {\n LIB_PriorityQueue> q;\n public KeyValuePair Peek => q.Peek;\n public long Count => q.Count;\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public LIB_PriorityQueue(long cap, Comparison cmp, bool asc = true)\n {\n q = new LIB_PriorityQueue>(cap, (x, y) => cmp(x.Key, y.Key), asc);\n }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public LIB_PriorityQueue(Comparison cmp, bool asc = true)\n {\n q = new LIB_PriorityQueue>((x, y) => cmp(x.Key, y.Key), asc);\n }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public LIB_PriorityQueue(long cap, bool asc = true) : this(cap, Comparer.Default.Compare, asc) { }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public LIB_PriorityQueue(bool asc = true) : this(Comparer.Default.Compare, asc) { }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public void Push(TK k, TV v) => q.Push(new KeyValuePair(k, v));\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public KeyValuePair Pop() => q.Pop();\n }\n class LIB_UnionFind\n {\n int[] d;\n T[] v;\n Func f;\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public LIB_UnionFind(IEnumerable s, Func func)\n {\n v = s.ToArray();\n d = Enumerable.Repeat(-1, v.Length).ToArray();\n f = func;\n }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public bool Unite(long x, long y)\n {\n x = Root(x);\n y = Root(y);\n if (x != y)\n {\n d[x] = d[x] + d[y];\n v[x] = f(v[x], v[y]);\n d[y] = (int)x;\n }\n return x != y;\n }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public bool IsSame(long x, long y) => Root(x) == Root(y);\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public long Root(long x) => d[x] < 0 ? x : d[x] = (int)Root(d[x]);\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public long Count(long x) => -d[Root(x)];\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public T Calc(long x) => v[Root(x)];\n }\n class LIB_UnionFind : LIB_UnionFind\n {\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public LIB_UnionFind(long n) : base(Enumerable.Repeat(0, (int)n), (x, y) => x + y) { }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n new private void Calc(long x) { }\n }\n class LIB_FastIO\n {\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public LIB_FastIO() { str = Console.OpenStandardInput(); }\n readonly Stream str;\n readonly byte[] buf = new byte[2048];\n int len, ptr;\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n byte read()\n {\n if (ptr >= len)\n {\n ptr = 0;\n if ((len = str.Read(buf, 0, 2048)) <= 0)\n {\n return 0;\n }\n }\n return buf[ptr++];\n }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n char Char()\n {\n byte b = 0;\n do b = read();\n while (b < 33 || 126 < b);\n return (char)b;\n }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n virtual public string Scan()\n {\n var sb = new StringBuilder();\n for (var b = Char(); b >= 33 && b <= 126; b = (char)read())\n sb.Append(b);\n return sb.ToString();\n }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n virtual public long Long()\n {\n long ret = 0; byte b = 0; var ng = false;\n do b = read();\n while (b != '-' && (b < '0' || '9' < b));\n if (b == '-') { ng = true; b = read(); }\n for (; true; b = read())\n {\n if (b < '0' || '9' < b)\n return ng ? -ret : ret;\n else ret = (ret << 3) + (ret << 1) + b - '0';\n }\n }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n virtual public double Double() { return double.Parse(Scan(), CultureInfo.InvariantCulture); }\n }\n class LIB_FastIODebug : LIB_FastIO\n {\n Queue param = new Queue();\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n string NextString() { if (param.Count == 0) foreach (var item in Console.ReadLine().Split(' ')) param.Enqueue(item); return param.Dequeue(); }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public LIB_FastIODebug() { }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public override string Scan() => NextString();\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public override long Long() => long.Parse(NextString());\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public override double Double() => double.Parse(NextString());\n }\n}\n", "lang_cluster": "C#", "tags": ["dsu", "graphs", "data structures", "implementation", "trees"], "code_uid": "c8e95ec4c1ae87463534e4e11b344268", "src_uid": "ad014bde729222db14f38caa521e4167", "difficulty": 2600.0, "exec_outcome": "PASSED"} {"lang": ".NET Core C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.IO;\nusing System.Linq;\nusing static System.Math;\nusing System.Text;\nusing System.Threading;\nusing System.Globalization;\nusing System.Runtime.CompilerServices;\nusing Library;\n\nnamespace Program\n{\n public static class ProblemD\n {\n static bool SAIKI = false;\n static public int numberOfRandomCases = 0;\n static public void MakeTestCase(List _input, List _output, ref Func _outputChecker)\n {\n }\n static public void Solve()\n {\n var n = (int)NN;\n var m = (int)NN;\n var q = (int)NN;\n var pList = NNList(n);\n var ab = Repeat(0, m).Select(_ => new { a = (int)NN - 1, b = (int)NN - 1 }).ToArray();\n var query = Repeat(0, q).Select(_ => new { t = (int)NN, param = (int)NN }).ToArray();\n var graph = Repeat(0, n).Select(_ => new List()).ToArray();\n var uf = new LIB_UnionFind(n);\n var deleted = new bool[m];\n foreach (var item in query)\n {\n if (item.t == 2) deleted[item.param - 1] = true;\n }\n var procTgtEdgeIndex = new bool[m];\n for (var i = 0; i < m; i++)\n {\n if (!deleted[i])\n {\n if (uf.Unite(ab[i].a, ab[i].b))\n {\n graph[ab[i].a].Add(ab[i].b);\n graph[ab[i].b].Add(ab[i].a);\n }\n }\n }\n foreach (var item in query.Reverse())\n {\n if (item.t == 2)\n {\n var i = item.param - 1;\n if (uf.Unite(ab[i].a, ab[i].b))\n {\n procTgtEdgeIndex[i] = true;\n graph[ab[i].a].Add(ab[i].b);\n graph[ab[i].b].Add(ab[i].a);\n }\n }\n }\n var param = new int[n];\n var qList = new List>();\n var used = new bool[n];\n {\n var done = new bool[n];\n for (var i = 0; i < n; i++)\n {\n if (!done[i])\n {\n var c = qList.Count();\n var tmpq = new LIB_PriorityQueue(false);\n qList.Add(tmpq);\n var que = new Queue();\n que.Enqueue(i);\n done[i] = true;\n param[i] = c;\n while (que.Count > 0)\n {\n var v = que.Dequeue();\n foreach (var item in graph[v])\n {\n if (done[item]) continue;\n done[item] = true;\n param[item] = c;\n que.Enqueue(item);\n }\n }\n }\n qList[param[i]].Push((int)pList[i], i);\n }\n }\n foreach (var item in query)\n {\n if (item.t == 1)\n {\n var v = item.param - 1;\n var p = param[v];\n var que = qList[p];\n var value = 0L;\n while (que.Count > 0)\n {\n if (used[que.Peek.Value] || p != param[que.Peek.Value]) que.Pop();\n else\n {\n used[que.Peek.Value] = true;\n value = que.Pop().Key;\n break;\n }\n }\n Console.WriteLine(value);\n }\n else\n {\n var leftV = ab[item.param - 1].a;\n var rightV = ab[item.param - 1].b;\n if (!procTgtEdgeIndex[item.param - 1]) continue;\n var leftQ = new Queue<(int, int)>();\n var rightQ = new Queue<(int, int)>();\n var color = param[leftV];\n var lidx = 0;\n var ridx = 0;\n var lv = leftV;\n var rv = rightV;\n var lp = rightV;\n var rp = leftV;\n var exit = false;\n var leftVs = new List();\n var rightVs = new List();\n leftVs.Add(lv);\n rightVs.Add(rv);\n var procVs = leftVs;\n while (true)\n {\n var leftOK = false;\n while (true)\n {\n while (graph[lv].Count > lidx)\n {\n var v = graph[lv][lidx++];\n if (v == lp) continue;\n if (color != param[v]) continue;\n leftQ.Enqueue((v, lv));\n leftVs.Add(v);\n leftOK = true;\n break;\n }\n if (leftOK) break;\n if (leftQ.Count == 0)\n {\n exit = true;\n break;\n }\n var pop = leftQ.Dequeue();\n lv = pop.Item1;\n lp = pop.Item2;\n lidx = 0;\n }\n if (exit) break;\n var rightOK = false;\n while (true)\n {\n while (graph[rv].Count > ridx)\n {\n var v = graph[rv][ridx++];\n if (v == rp) continue;\n if (color != param[v]) continue;\n rightQ.Enqueue((v, rv));\n rightVs.Add(v);\n rightOK = true;\n break;\n }\n if (rightOK) break;\n if (rightQ.Count == 0)\n {\n procVs = rightVs;\n exit = true;\n break;\n }\n var pop = rightQ.Dequeue();\n rv = pop.Item1;\n rp = pop.Item2;\n ridx = 0;\n }\n if (exit) break;\n }\n var procColorTo = qList.Count;\n var tmpq = new LIB_PriorityQueue(false);\n qList.Add(tmpq);\n foreach (var item2 in procVs)\n {\n if (!used[item2]) tmpq.Push((int)pList[item2], item2);\n param[item2] = procColorTo;\n }\n }\n }\n }\n class Printer : StreamWriter\n {\n public override IFormatProvider FormatProvider { get { return CultureInfo.InvariantCulture; } }\n public Printer(Stream stream) : base(stream, new UTF8Encoding(false, true)) { base.AutoFlush = false; }\n public Printer(Stream stream, Encoding encoding) : base(stream, encoding) { base.AutoFlush = false; }\n }\n static LIB_FastIO fastio = new LIB_FastIODebug();\n static public void Main(string[] args) { if (args.Length == 0) { fastio = new LIB_FastIO(); Console.SetOut(new Printer(Console.OpenStandardOutput())); } if (SAIKI) { var t = new Thread(Solve, 134217728); t.Start(); t.Join(); } else Solve(); Console.Out.Flush(); }\n static long NN => fastio.Long();\n static double ND => fastio.Double();\n static string NS => fastio.Scan();\n static long[] NNList(long N) => Repeat(0, N).Select(_ => NN).ToArray();\n static double[] NDList(long N) => Repeat(0, N).Select(_ => ND).ToArray();\n static string[] NSList(long N) => Repeat(0, N).Select(_ => NS).ToArray();\n static long Count(this IEnumerable x, Func pred) => Enumerable.Count(x, pred);\n static IEnumerable Repeat(T v, long n) => Enumerable.Repeat(v, (int)n);\n static IEnumerable Range(long s, long c) => Enumerable.Range((int)s, (int)c);\n static IOrderedEnumerable OrderByRand(this IEnumerable x) => Enumerable.OrderBy(x, _ => xorshift);\n static IOrderedEnumerable OrderBy(this IEnumerable x) => Enumerable.OrderBy(x.OrderByRand(), e => e);\n static IOrderedEnumerable OrderBy(this IEnumerable x, Func selector) => Enumerable.OrderBy(x.OrderByRand(), selector);\n static IOrderedEnumerable OrderByDescending(this IEnumerable x) => Enumerable.OrderByDescending(x.OrderByRand(), e => e);\n static IOrderedEnumerable OrderByDescending(this IEnumerable x, Func selector) => Enumerable.OrderByDescending(x.OrderByRand(), selector);\n static IOrderedEnumerable OrderBy(this IEnumerable x) => x.OrderByRand().OrderBy(e => e, StringComparer.OrdinalIgnoreCase);\n static IOrderedEnumerable OrderBy(this IEnumerable x, Func selector) => x.OrderByRand().OrderBy(selector, StringComparer.OrdinalIgnoreCase);\n static IOrderedEnumerable OrderByDescending(this IEnumerable x) => x.OrderByRand().OrderByDescending(e => e, StringComparer.OrdinalIgnoreCase);\n static IOrderedEnumerable OrderByDescending(this IEnumerable x, Func selector) => x.OrderByRand().OrderByDescending(selector, StringComparer.OrdinalIgnoreCase);\n static string Join(this IEnumerable x, string separator = \"\") => string.Join(separator, x);\n static uint xorshift { get { _xsi.MoveNext(); return _xsi.Current; } }\n static IEnumerator _xsi = _xsc();\n static IEnumerator _xsc() { uint x = 123456789, y = 362436069, z = 521288629, w = (uint)(DateTime.Now.Ticks & 0xffffffff); while (true) { var t = x ^ (x << 11); x = y; y = z; z = w; w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)); yield return w; } }\n static bool Chmax(this ref T lhs, T rhs) where T : struct, IComparable { if (lhs.CompareTo(rhs) < 0) { lhs = rhs; return true; } return false; }\n static bool Chmin(this ref T lhs, T rhs) where T : struct, IComparable { if (lhs.CompareTo(rhs) > 0) { lhs = rhs; return true; } return false; }\n }\n}\nnamespace Library {\n class LIB_FastIO\n {\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public LIB_FastIO() { str = Console.OpenStandardInput(); }\n readonly Stream str;\n readonly byte[] buf = new byte[2048];\n int len, ptr;\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n byte read()\n {\n if (ptr >= len)\n {\n ptr = 0;\n if ((len = str.Read(buf, 0, 2048)) <= 0)\n {\n return 0;\n }\n }\n return buf[ptr++];\n }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n char Char()\n {\n byte b = 0;\n do b = read();\n while (b < 33 || 126 < b);\n return (char)b;\n }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n virtual public string Scan()\n {\n var sb = new StringBuilder();\n for (var b = Char(); b >= 33 && b <= 126; b = (char)read())\n sb.Append(b);\n return sb.ToString();\n }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n virtual public long Long()\n {\n long ret = 0; byte b = 0; var ng = false;\n do b = read();\n while (b != '-' && (b < '0' || '9' < b));\n if (b == '-') { ng = true; b = read(); }\n for (; true; b = read())\n {\n if (b < '0' || '9' < b)\n return ng ? -ret : ret;\n else ret = (ret << 3) + (ret << 1) + b - '0';\n }\n }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n virtual public double Double() { return double.Parse(Scan(), CultureInfo.InvariantCulture); }\n }\n class LIB_FastIODebug : LIB_FastIO\n {\n Queue param = new Queue();\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n string NextString() { if (param.Count == 0) foreach (var item in Console.ReadLine().Split(' ')) param.Enqueue(item); return param.Dequeue(); }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public LIB_FastIODebug() { }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public override string Scan() => NextString();\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public override long Long() => long.Parse(NextString());\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public override double Double() => double.Parse(NextString());\n }\n class LIB_UnionFind\n {\n int[] d;\n T[] v;\n Func f;\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public LIB_UnionFind(IEnumerable s, Func func)\n {\n v = s.ToArray();\n d = Enumerable.Repeat(-1, v.Length).ToArray();\n f = func;\n }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public bool Unite(long x, long y)\n {\n x = Root(x);\n y = Root(y);\n if (x != y)\n {\n d[x] = d[x] + d[y];\n v[x] = f(v[x], v[y]);\n d[y] = (int)x;\n }\n return x != y;\n }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public bool IsSame(long x, long y) => Root(x) == Root(y);\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public long Root(long x) => d[x] < 0 ? x : d[x] = (int)Root(d[x]);\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public long Count(long x) => -d[Root(x)];\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public T Calc(long x) => v[Root(x)];\n }\n class LIB_UnionFind : LIB_UnionFind\n {\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public LIB_UnionFind(long n) : base(Enumerable.Repeat(0, (int)n), (x, y) => x + y) { }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n new private void Calc(long x) { }\n }\n class LIB_PriorityQueue\n {\n long[] heap;\n int[] dat;\n public (long, int) Peek => (heap[0], dat[0]);\n public long Count\n {\n get;\n private set;\n }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public LIB_PriorityQueue()\n {\n heap = new long[8];\n dat = new int[8];\n }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public void Push(long key, int val)\n {\n if (Count == heap.Length) Expand();\n var i = Count++;\n heap[i] = key;\n dat[i] = val;\n while (i > 0)\n {\n var ni = (i - 1) / 2;\n if (key >= heap[ni]) break;\n heap[i] = heap[ni];\n dat[i] = dat[ni];\n i = ni;\n }\n heap[i] = key;\n dat[i] = val;\n }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public KeyValuePair Pop()\n {\n var ret = new KeyValuePair(heap[0], dat[0]);\n var key = heap[--Count];\n var val = dat[Count];\n if (Count == 0) return ret;\n var i = 0; while ((i << 1) + 1 < Count)\n {\n var i1 = (i << 1) + 1;\n var i2 = (i << 1) + 2;\n if (i2 < Count && heap[i1] > heap[i2]) i1 = i2;\n if (key <= heap[i1]) break;\n heap[i] = heap[i1];\n dat[i] = dat[i1];\n i = i1;\n }\n heap[i] = key;\n dat[i] = val;\n return ret;\n }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n void Expand()\n {\n var tmp = new long[Count << 1];\n for (var i = 0; i < heap.Length; ++i) tmp[i] = heap[i];\n heap = tmp;\n var tmp2 = new int[Count << 1];\n for (var i = 0; i < dat.Length; ++i) tmp2[i] = dat[i];\n dat = tmp2;\n }\n }\n class LIB_PriorityQueue\n {\n T[] heap;\n Comparison comp;\n public T Peek => heap[0];\n public long Count\n {\n get;\n private set;\n }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public LIB_PriorityQueue(long cap, Comparison cmp, bool asc = true)\n {\n heap = new T[cap];\n comp = asc ? cmp : (x, y) => cmp(y, x);\n }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public LIB_PriorityQueue(Comparison cmp, bool asc = true)\n {\n heap = new T[8];\n comp = asc ? cmp : (x, y) => cmp(y, x);\n }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public LIB_PriorityQueue(long cap, bool asc = true) : this(cap, Comparer.Default.Compare, asc) { }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public LIB_PriorityQueue(bool asc = true) : this(Comparer.Default.Compare, asc) { }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public void Push(T val)\n {\n if (Count == heap.Length) Expand();\n var i = Count++;\n heap[i] = val;\n while (i > 0)\n {\n var ni = (i - 1) / 2;\n if (comp(val, heap[ni]) >= 0) break;\n heap[i] = heap[ni];\n i = ni;\n }\n heap[i] = val;\n }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public T Pop()\n {\n var ret = heap[0];\n var val = heap[--Count];\n if (Count == 0) return ret;\n var i = 0; while ((i << 1) + 1 < Count)\n {\n var i1 = (i << 1) + 1;\n var i2 = (i << 1) + 2;\n if (i2 < Count && comp(heap[i1], heap[i2]) > 0) i1 = i2;\n if (comp(val, heap[i1]) <= 0) break;\n heap[i] = heap[i1]; i = i1;\n }\n heap[i] = val;\n return ret;\n }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n void Expand()\n {\n var tmp = new T[Count << 1];\n for (var i = 0; i < heap.Length; ++i) tmp[i] = heap[i];\n heap = tmp;\n }\n }\n class LIB_PriorityQueue\n {\n LIB_PriorityQueue> q;\n public KeyValuePair Peek => q.Peek;\n public long Count => q.Count;\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public LIB_PriorityQueue(long cap, Comparison cmp, bool asc = true)\n {\n q = new LIB_PriorityQueue>(cap, (x, y) => cmp(x.Key, y.Key), asc);\n }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public LIB_PriorityQueue(Comparison cmp, bool asc = true)\n {\n q = new LIB_PriorityQueue>((x, y) => cmp(x.Key, y.Key), asc);\n }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public LIB_PriorityQueue(long cap, bool asc = true) : this(cap, Comparer.Default.Compare, asc) { }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public LIB_PriorityQueue(bool asc = true) : this(Comparer.Default.Compare, asc) { }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public void Push(TK k, TV v) => q.Push(new KeyValuePair(k, v));\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public KeyValuePair Pop() => q.Pop();\n }\n}\n", "lang_cluster": "C#", "tags": ["dsu", "graphs", "data structures", "implementation", "trees"], "code_uid": "19fb24ea88f211aca20119bfd942064e", "src_uid": "ad014bde729222db14f38caa521e4167", "difficulty": 2600.0, "exec_outcome": "PASSED"} {"lang": "C# 10", "source_code": "using System;\r\nusing System.Linq;\r\nusing System.Text;\r\nusing System.Numerics;\r\nusing static System.Console;\r\nusing System.Collections.Generic;\r\n\r\nusing static CompLib.Algorithm;\r\n\r\nnamespace ProblemSolving.cs\r\n{\r\n class MainClass\r\n {\r\n const int Mod = (int) (1e9 + 7);\r\n const int Mod2 = 998244353;\r\n const int Def = (int) 1e9;\r\n const long INF = (long) 1e18;\r\n \r\n static long[] OneLongLine => ReadLine().Trim().Split(' ').Select(long.Parse).ToArray();\r\n static int[] OneIntLine => ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();\r\n static int[] OneCharLine => ReadLine().Trim().ToCharArray().Select(v => v - '0').ToArray();\r\n static long OneLong => long.Parse(ReadLine().Trim());\r\n static int OneInt => int.Parse(ReadLine().Trim());\r\n static string OneString => ReadLine().Trim();\r\n\r\n\r\n static void Solve()\r\n {\r\n long[] line = OneLongLine;\r\n long n = line[0], m = line[1];\r\n\r\n if (m != 1)\r\n {\r\n WriteLine(n * (m - 1));\r\n return;\r\n }\r\n \r\n WriteLine(n - 1);\r\n \r\n \r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n }\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n static bool Check(int[] arr)\r\n {\r\n var zero = arr.Count(v => v == 0);\r\n var one = arr.Count(v => v != 0);\r\n\r\n\r\n return one == 1 && zero == arr.Length - 1;\r\n }\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n static void Main()\r\n {\r\n // int cases = OneInt;\r\n // while (cases-- > 0) Solve();\r\n\r\n Solve();\r\n }\r\n }\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n}\r\n\r\nnamespace CompLib\r\n{\r\n public static class Algorithm\r\n {\r\n public static int LowerBound(int[] arr, int val)\r\n {\r\n int ng = -1;\r\n int ok = arr.Length;\r\n while (ok - ng > 1)\r\n {\r\n int med = (ok + ng) / 2;\r\n if (arr[med] >= val)\r\n {\r\n ok = med;\r\n }\r\n else\r\n {\r\n ng = med;\r\n }\r\n }\r\n \r\n return ok;\r\n }\r\n\r\n public static int UpperBound(int[] arr, int val)\r\n {\r\n int ok = arr.Length;\r\n int ng = -1;\r\n while (ok - ng > 1)\r\n {\r\n int med = (ok + ng) / 2;\r\n if (arr[med] > val)\r\n {\r\n ok = med;\r\n }\r\n else\r\n {\r\n ng = med;\r\n }\r\n }\r\n \r\n return ok;\r\n }\r\n }\r\n}", "lang_cluster": "C#", "tags": ["math"], "code_uid": "a90256da65894ebb863507d97eeeb68d", "src_uid": "a91aab4c0618d036c81022232814ef44", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "// Problem: 1725A - Accumulation of Dominoes\r\n// Author: Gusztav Szmolik\r\n\r\nusing System;\r\n\r\npublic class AccumulationOfDominoes {\r\n \r\n public static void Main () {\r\n string[] parts = Console.ReadLine ().Split ();\r\n int n = int.Parse (parts[0]);\r\n int m = int.Parse (parts[1]);\r\n long ans = (m > 1 ? (long)n*(m-1) : n-1);\r\n Console.WriteLine (ans);\r\n }\r\n}\r\n", "lang_cluster": "C#", "tags": ["math"], "code_uid": "c5a2abd6651c36522ea0d33cb24aa2b9", "src_uid": "a91aab4c0618d036c81022232814ef44", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Linq;\nusing System.Collections.Generic;\nusing System.Text;\nusing System.IO;\nusing System.Diagnostics;\n\n\nnamespace MakeCalendar\n{\n public static class MainClass\n {\n\n static int ReadIntLine()\n {\n return int.Parse(Console.ReadLine());\n }\n\n static void ReadInt(ref int a)\n {\n a = ReadIntArrayLine()[0];\n }\n\n static void ReadInts(ref int a, ref int b)\n {\n var x = ReadIntArrayLine();\n a = x[0]; b = x[1];\n }\n\n\n\n static void ReadInts(ref int a, ref int b, ref int c)\n {\n var x = ReadIntArrayLine();\n a = x[0]; b = x[1]; c = x[2];\n }\n\n static void ReadInts(ref int a, ref int b, ref int c, ref int d)\n {\n var x = ReadIntArrayLine();\n a = x[0]; b = x[1]; c = x[2]; d = x[3];\n }\n\n\n static void ReadInts(ref int a, ref int b, ref int c, ref int d, ref int e)\n {\n var x = ReadIntArrayLine();\n a = x[0]; b = x[1]; c = x[2]; d = x[3]; e = x[4];\n }\n\n static void ReadInts(ref int a, ref int b, ref int c, ref int d, ref int e, ref int f)\n {\n var x = ReadIntArrayLine();\n a = x[0]; b = x[1]; c = x[2]; d = x[3]; e = x[4]; f = x[5];\n }\n\n static int[] ReadIntArrayLine()\n {\n char[] sep = { ' ' };\n return Console.ReadLine().Split(sep, StringSplitOptions.RemoveEmptyEntries).Select(x => int.Parse(x)).ToArray();\n }\n\n static void PrintLn(object obj)\n {\n Console.WriteLine(obj.ToString());\n }\n\n public static string Reverse(string s)\n {\n char[] charArray = s.ToCharArray();\n Array.Reverse(charArray);\n return new string(charArray);\n }\n\n\n public static void PrintLnCollection(IEnumerable col)\n {\n PrintLn(string.Join(\" \", col));\n }\n\n\n public static void PrintLn(params object[] v)\n {\n PrintLnCollection(v);\n }\n\n public static string ReadLine()\n {\n return Console.ReadLine();\n }\n\n\n public static string MySubstring(this string str, int start, int finish)\n {\n if (start > finish) return \"\";\n return str.Substring(start, finish - start + 1);\n }\n\n\n public static bool IsInRange(this int a, int lb, int ub)\n {\n return (a >= lb) && (a <= ub);\n }\n\n private static void mergeDS(int i, int j, int[] a)\n {\n int t = a[j];\n for (int ii = 0; ii < a.Length; ii++)\n {\n if (a[ii] == t)\n a[ii] = a[i];\n }\n }\n\n private static T MyMax(params T[] a)\n {\n return a.Max();\n }\n\n private static T MyMin(params T[] a)\n {\n return a.Min();\n }\n\n\n private static int[] GetPrimesLessThan(int x)\n {\n if (x < 2)\n return new int[0];\n\n int[] a = new int[x];\n\n a[0] = 1; a[1] = 1;\n\n for (int i = 0; i < a.Length; i++)\n {\n if (a[i] == 0)\n for (int j = 2 * i; j < a.Length; j += i)\n {\n a[j] = 1;\n }\n }\n\n var abc = new List(x);\n\n for (int i = 0; i < a.Length; i++)\n {\n if (a[i] == 0)\n abc.Add(i);\n }\n\n return abc.ToArray();\n }\n\n private static int FindNearestLEQElementInTheArray(int[] a, int startIndex, int endIndex, int target)\n {\n if (startIndex == endIndex)\n {\n if (a[startIndex] <= target)\n return startIndex;\n else\n return -1;\n }\n\n if (startIndex + 1 == endIndex)\n {\n if (a[endIndex] <= target)\n return endIndex;\n else if (a[startIndex] <= target)\n return startIndex;\n else\n return -1;\n }\n\n int mid = (startIndex + endIndex) / 2;\n if (target == a[mid])\n return mid;\n else if (target < a[mid])\n return FindNearestLEQElementInTheArray(a, startIndex, mid - 1, target);\n else\n return FindNearestLEQElementInTheArray(a, mid, endIndex, target);\n }\n\n private static int FindNearestLEQElementInTheArray(int[] a, int target)\n {\n return FindNearestLEQElementInTheArray(a, 0, a.Length - 1, target);\n }\n\n private static int gcd(int a, int b)\n {\n int r = a % b;\n while (r != 0)\n {\n a = b;\n b = r;\n r = a % b;\n }\n return b;\n }\n\n //----------------------------------------------------------------------------\n\n\n class Interval : IComparable\n {\n public int left;\n public int right;\n\n public Interval(int l, int r)\n {\n left = l;\n right = r;\n }\n\n public int CompareTo(Interval interval)\n {\n return this.left - interval.left;\n }\n\n }\n\n\n\n\n static void Main(string[] args)\n {\n int[] hm = ReadLine().Split(':').Select(x => int.Parse(x)).ToArray();\n\n int h = hm[0];\n int m = hm[1];\n\n DateTime d = new DateTime(1999, 1, 1, h, m, 0);\n\n for (int i = 1; i < 1441; i++)\n {\n d = d.AddMinutes(1);\n\n var hstr = (d.Hour < 10) ? \"0\" + d.Hour.ToString() : d.Hour.ToString();\n var mstr = (d.Minute < 10) ? \"0\" + d.Minute.ToString() : d.Minute.ToString();\n\n if (hstr[0] == mstr[1] && hstr[1] == mstr[0])\n {\n PrintLn(hstr + \":\" + mstr);\n return;\n }\n }\n }\n\n\n\n\n }\n\n\n}", "lang_cluster": "C#", "tags": ["strings", "implementation"], "code_uid": "056839b37f627fdf98887907ca9b515c", "src_uid": "158eae916daa3e0162d4eac0426fa87f", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Text;\n\nnamespace CodeForces_83\n{\n class prob_a\n {\n static string[] res = new string[16] {\n \"00:00\",\"01:10\", \"02:20\",\n \"03:30\",\"04:40\", \"05:50\",\n \"10:01\", \"11:11\",\"12:21\",\n \"13:31\", \"14:41\",\"15:51\",\n \"20:02\", \"21:12\",\n \"22:22\",\"23:32\"\n };\n\n static void Main()\n {\n int i;\n string s = Console.ReadLine();\n for (i = 0; i < res.Length; ++i) \n if (s.CompareTo(res[i]) < 0) break;\n if (i != res.Length)\n Console.WriteLine(\"{0}\", res[i]);\n else\n Console.WriteLine(\"{0}\", res[0]);\n //Console.ReadLine();\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["strings", "implementation"], "code_uid": "b81bac307c5f8fc83261fb2ee8177344", "src_uid": "158eae916daa3e0162d4eac0426fa87f", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\n\nnamespace ConsoleApplication1\n{\n class Program\n {\n static void Main(string[] args)\n {\n \n \n string[]y=Console.ReadLine().Split(' ');\n Int64 a=Int64.Parse(y[0]);\n Int64 b=Int64.Parse(y[1]);\n Int64 c=Int64.Parse(y[2]);\n Int64 d=Math.Min(a,b);\n Int64 o=d;\n if(a!=b)\n o++;\n Console.WriteLine(d+o+c*2);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["greedy"], "code_uid": "11681344fc8e06be2e69a60b2b4b3128", "src_uid": "609f131325c13213aedcf8d55fc3ed77", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Linq;\nusing System.Collections.Generic;\nusing System.Text;\n\nnamespace algorithms_700_01\n{\n class Program\n {\n static void Main()\n {\n var array = Console.ReadLine().Split(new char[] { ' ' }).Select(x => long.Parse(x)).ToArray();\n var maxStringLength = 2 * array[2] + 2 * Math.Min(array[0], array[1]) + (array[0] == array[1] ? 0 : 1);\n Console.WriteLine(maxStringLength);\n }\n }\n}", "lang_cluster": "C#", "tags": ["greedy"], "code_uid": "0b808551bfa4b4a4a0a49a7108a021b5", "src_uid": "609f131325c13213aedcf8d55fc3ed77", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections;\nusing System.Collections.Generic;\nusing System.Diagnostics;\nusing System.Globalization;\nusing System.IO;\nusing System.Text;\nusing System.Linq;\n\nusing E = System.Linq.Enumerable;\n\ninternal partial class Solver {\n public void Run() {\n var x0 = nl();\n var y0 = nl();\n var ax = nl();\n var ay = nl();\n var bx = nl();\n var by = nl();\n var xs = nl();\n var ys = nl();\n var t = nl();\n\n var x = new List { x0 };\n var y = new List { y0 };\n while (true) {\n try {\n checked {\n var nx = x[x.Count - 1] * ax + bx;\n var ny = y[y.Count - 1] * ay + by;\n x.Add(nx);\n y.Add(ny);\n }\n } catch (OverflowException) {\n break;\n }\n }\n //x.Dump();\n //y.Dump();\n int ans = 0;\n for (int i = 0; i < x.Count; i++) {\n for (int j = i; j < x.Count; j++) {\n try {\n checked {\n var di = Math.Abs(xs - x[i]) + Math.Abs(ys - y[i]);\n var dj = Math.Abs(xs - x[j]) + Math.Abs(ys - y[j]);\n var dij = Math.Abs(x[i] - x[j]) + Math.Abs(y[i] - y[j]);\n int num = j - i + 1;\n if (di + dij <= t || dj + dij <= t) {\n ans = Math.Max(ans, num);\n }\n }\n } catch (OverflowException) {\n\n }\n }\n }\n cout.WriteLine(ans);\n }\n}\n\n// PREWRITEN CODE BEGINS FROM HERE\ninternal partial class Solver : Scanner {\n public static void Main(string[] args) {\n#if LOCAL\n byte[] inputBuffer = new byte[1000000];\n var inputStream = Console.OpenStandardInput(inputBuffer.Length);\n using (var reader = new StreamReader(inputStream, Console.InputEncoding, false, inputBuffer.Length)) {\n Console.SetIn(reader);\n new Solver(Console.In, Console.Out).Run();\n }\n#else\n Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });\n new Solver(Console.In, Console.Out).Run();\n Console.Out.Flush();\n#endif\n }\n\n#pragma warning disable IDE0052\n private readonly TextReader cin;\n private readonly TextWriter cout;\n#pragma warning restore IDE0052\n\n public Solver(TextReader reader, TextWriter writer)\n : base(reader) {\n cin = reader;\n cout = writer;\n }\n public Solver(string input, TextWriter writer)\n : this(new StringReader(input), writer) {\n }\n\n#pragma warning disable IDE1006\n#pragma warning disable IDE0051\n private int ni() { return NextInt(); }\n private int[] ni(int n) { return NextIntArray(n); }\n private long nl() { return NextLong(); }\n private long[] nl(int n) { return NextLongArray(n); }\n private double nd() { return NextDouble(); }\n private double[] nd(int n) { return NextDoubleArray(n); }\n private string ns() { return Next(); }\n private string[] ns(int n) { return NextArray(n); }\n#pragma warning restore IDE1006\n#pragma warning restore IDE0051\n}\n\ninternal static class LinqPadExtension {\n [Conditional(\"DEBUG\")]\n public static void Dump(this T obj) {\n#if DEBUG\n LINQPad.Extensions.Dump(obj);\n#endif\n }\n}\n\npublic class Scanner {\n private readonly TextReader Reader;\n private readonly CultureInfo ci = CultureInfo.InvariantCulture;\n\n private readonly char[] buffer = new char[2 * 1024];\n private int cursor = 0, length = 0;\n private string Token;\n private readonly StringBuilder sb = new StringBuilder(1024);\n\n public Scanner()\n : this(Console.In) {\n }\n\n public Scanner(TextReader reader) {\n Reader = reader;\n }\n\n public int NextInt() { return (int)NextLong(); }\n public long NextLong() {\n var s = Next();\n long r = 0;\n int i = 0;\n bool negative = false;\n if (s[i] == '-') {\n negative = true;\n i++;\n }\n for (; i < s.Length; i++) {\n r = r * 10 + (s[i] - '0');\n#if DEBUG\n if (!char.IsDigit(s[i])) throw new FormatException();\n#endif\n }\n return negative ? -r : r;\n }\n public double NextDouble() { return double.Parse(Next(), ci); }\n public string[] NextArray(int size) {\n string[] array = new string[size];\n for (int i = 0; i < size; i++) {\n array[i] = Next();\n }\n\n return array;\n }\n public int[] NextIntArray(int size) {\n int[] array = new int[size];\n for (int i = 0; i < size; i++) {\n array[i] = NextInt();\n }\n\n return array;\n }\n\n public long[] NextLongArray(int size) {\n long[] array = new long[size];\n for (int i = 0; i < size; i++) {\n array[i] = NextLong();\n }\n\n return array;\n }\n\n public double[] NextDoubleArray(int size) {\n double[] array = new double[size];\n for (int i = 0; i < size; i++) {\n array[i] = NextDouble();\n }\n\n return array;\n }\n\n public string Next() {\n if (Token == null) {\n if (!StockToken()) {\n throw new InvalidOperationException();\n }\n }\n var token = Token;\n Token = null;\n return token;\n }\n\n public bool HasNext() {\n if (Token != null) {\n return true;\n }\n\n return StockToken();\n }\n\n private bool StockToken() {\n while (true) {\n sb.Clear();\n while (true) {\n if (cursor >= length) {\n cursor = 0;\n if ((length = Reader.Read(buffer, 0, buffer.Length)) <= 0) {\n break;\n }\n }\n var c = buffer[cursor++];\n if (33 <= c && c <= 126) {\n sb.Append(c);\n } else {\n if (sb.Length > 0) break;\n }\n }\n\n if (sb.Length > 0) {\n Token = sb.ToString();\n return true;\n }\n\n return false;\n }\n }\n}", "lang_cluster": "C#", "tags": ["brute force", "constructive algorithms", "implementation", "greedy", "geometry"], "code_uid": "2e62bc82686d6ea457b21a51c9c1537f", "src_uid": "d8a7ae2959b3781a8a4566a2f75a4e28", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\n\nclass D\n{\n\tstatic long[] Read() => Console.ReadLine().Split().Select(long.Parse).ToArray();\n\tstatic void Main()\n\t{\n\t\tvar h = Read();\n\t\tvar z = Read();\n\t\tvar sp = (x: z[0], y: z[1]);\n\t\tvar t = z[2];\n\n\t\tvar max = 1L << 55;\n\t\tvar ps = new List<(long x, long y)> { (h[0], h[1]) };\n\t\twhile (true)\n\t\t{\n\t\t\tvar (x_, y_) = ps.Last();\n\t\t\tvar p = (x: h[2] * x_ + h[4], y: h[3] * y_ + h[5]);\n\t\t\tif (p.x > max || p.y > max) break;\n\t\t\tps.Add(p);\n\t\t}\n\n\t\tvar s = new long[ps.Count];\n\t\tfor (int i = 0; i < ps.Count - 1; i++) s[i + 1] = s[i] + Norm(ps[i], ps[i + 1]);\n\n\t\tvar M = 0;\n\t\tfor (int i = 0; i < ps.Count; i++)\n\t\t{\n\t\t\tvar t0 = t - Norm(sp, ps[i]);\n\t\t\tif (t0 < 0) continue;\n\n\t\t\tM = Math.Max(M, Enumerable.Range(0, i).Reverse().TakeWhile(j => s[i] - s[j] <= t0).Count() + 1);\n\t\t\tM = Math.Max(M, Enumerable.Range(i + 1, ps.Count - 1 - i).TakeWhile(j => s[j] - s[i] <= t0).Count() + 1);\n\t\t}\n\t\tConsole.WriteLine(M);\n\t}\n\n\tstatic long Norm((long x, long y) p, (long x, long y) q) => Math.Abs(q.x - p.x) + Math.Abs(q.y - p.y);\n}\n", "lang_cluster": "C#", "tags": ["brute force", "constructive algorithms", "implementation"], "code_uid": "efc1e46bc2a0db784c625f3182751a3d", "src_uid": "d8a7ae2959b3781a8a4566a2f75a4e28", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeff// ReSharper disable RedundantUsingDirective\n// ReSharper disable JoinDeclarationAndInitializer\n// ReSharper disable MemberCanBeMadeStatic.Local\n// ReSharper disable PossibleNullReferenceException\n// ReSharper disable ArrangeTypeMemberModifiers\n// ReSharper disable SuggestVarOrType_BuiltInTypes\n// ReSharper disable SuggestVarOrType_Elsewhere\n// ReSharper disable InvertIf\n// ReSharper disable InconsistentNaming\n// ReSharper disable ConvertIfStatementToSwitchStatement\n// ReSharper disable UseObjectOrCollectionInitializer\n// ReSharper disable TailRecursiveCall\n// ReSharper disable RedundantUsingDirective\n// ReSharper disable InlineOutVariableDeclaration\n// ReSharper disable FunctionRecursiveOnAllPaths\n// ReSharper disable UnusedMember.Global\n// ReSharper disable MemberCanBeMadeStatic.Global\n// ReSharper disable UnusedMember.Local\n// ReSharper disable NonReadonlyMemberInGetHashCode\n#pragma warning disable\nusing System;\nusing System.Collections.Generic;\nusing System.IO;\nusing System.Linq;\nusing System.Xml;\nusing static System.Math;\nusing static AtCoder.Input;\nusing static AtCoder.Methods;\n\nnamespace AtCoder\n{\n #region Templete\n\n [System.Diagnostics.DebuggerDisplay(\"({first}, {second})\")]\n public class Pair : IComparable>, IEquatable>\n where T1 : IComparable\n where T2 : IComparable\n {\n public Pair(T1 first, T2 second)\n {\n this.first = first;\n this.second = second;\n }\n\n public T1 first;\n public T2 second;\n\n public int CompareTo(Pair other)\n {\n if (ReferenceEquals(this, other)) return 0;\n if (ReferenceEquals(null, other)) return 1;\n var firstComparison = first.CompareTo(other.first);\n return firstComparison != 0 ? firstComparison : second.CompareTo(other.second);\n }\n\n public override string ToString() => $\"({first}, {second})\";\n\n public bool Equals(Pair other)\n {\n if (ReferenceEquals(null, other)) return false;\n if (ReferenceEquals(this, other)) return true;\n return EqualityComparer.Default.Equals(first, other.first) && EqualityComparer.Default.Equals(second, other.second);\n }\n\n public override bool Equals(object obj)\n {\n if (ReferenceEquals(null, obj)) return false;\n if (ReferenceEquals(this, obj)) return true;\n return obj.GetType() == this.GetType() && Equals((Pair)obj);\n }\n\n public override int GetHashCode()\n {\n unchecked\n {\n return (EqualityComparer.Default.GetHashCode(first) * 397) ^ EqualityComparer.Default.GetHashCode(second);\n }\n }\n }\n\n [System.Diagnostics.DebuggerDisplay(\"Value = {\" + nameof(_value) + \"}\")]\n public struct ModInt : IEquatable, IComparable\n {\n private long _value;\n\n public const int MOD = (int)1e9 + 7;\n\n public static readonly ModInt Zero = new ModInt(0);\n\n public static readonly ModInt One = new ModInt(1);\n\n public ModInt(long value) { _value = value % MOD; }\n\n private ModInt(int value) { _value = value; }\n\n public int Value => (int)_value;\n\n public ModInt Invert => ModPow(this, MOD - 2);\n\n public static ModInt operator -(ModInt value)\n {\n value._value = MOD - value._value;\n return value;\n }\n\n public static ModInt operator +(ModInt left, ModInt right)\n {\n left._value += right._value;\n if (left._value >= MOD) left._value -= MOD;\n return left;\n }\n\n public static ModInt operator -(ModInt left, ModInt right)\n {\n left._value -= right._value;\n if (left._value < 0) left._value += MOD;\n return left;\n }\n\n public static ModInt operator *(ModInt left, ModInt right)\n {\n left._value = left._value * right._value % MOD;\n return left;\n }\n\n public static ModInt operator /(ModInt left, ModInt right) => left * right.Invert;\n\n public static ModInt operator ++(ModInt value)\n {\n if (value._value == MOD - 1) value._value = 0;\n else value._value++;\n return value;\n }\n\n public static ModInt operator --(ModInt value)\n {\n if (value._value == 0) value._value = MOD - 1;\n else value._value--;\n return value;\n }\n\n public static bool operator ==(ModInt left, ModInt right) => left.Equals(right);\n\n public static bool operator !=(ModInt left, ModInt right) => !left.Equals(right);\n\n public static implicit operator ModInt(int value) => new ModInt(value);\n\n public static implicit operator ModInt(long value) => new ModInt(value);\n\n public static ModInt ModPow(ModInt value, long exponent)\n {\n var r = new ModInt(1);\n for (; exponent > 0; value *= value, exponent >>= 1)\n if ((exponent & 1) == 1) r *= value;\n return r;\n }\n\n public static ModInt ModFact(int value)\n {\n var r = new ModInt(1);\n for (var i = 2; i <= value; i++) r *= value;\n return r;\n }\n\n public bool Equals(ModInt other) => _value == other._value;\n\n public override bool Equals(object obj)\n {\n return obj != null && this.Equals((ModInt)obj);\n }\n\n public override int GetHashCode() => _value.GetHashCode();\n\n public override string ToString() => _value.ToString();\n\n public int CompareTo(ModInt other)\n {\n return _value.CompareTo(other._value);\n }\n }\n\n public static class Methods\n {\n public static readonly int[] dx = { -1, 0, 0, 1 };\n\n public static readonly int[] dy = { 0, 1, -1, 0 };\n\n /*\n public static Comparison greater() \n where T : IComparable \n => (a, b) => b.CompareTo(a);\n */\n public static void Print(T t) => Console.WriteLine(t);\n\n public static void PrintBool(bool val, string yes = \"Yes\", string no = \"No\")\n => Console.WriteLine(val ? yes : no);\n\n public static void PrintYn(bool val) => PrintBool(val);\n public static void PrintYN(bool val) => PrintBool(val, \"YES\", \"NO\");\n public static void PrintPossible(bool val) => PrintBool(val, \"Possible\", \"Impossible\");\n public static void PrintYay(bool val) => PrintBool(val, \"Yay!\", \":(\");\n\n public static void PrintDebug(params object[] args)\n => Console.Error.WriteLine(string.Join(\" \", args));\n\n public static string JoinWith(this IEnumerable source, string s) => string.Join(s, source.ToArray());\n\n /// \n /// \u30af\u30e9\u30b9\u306e\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002\n /// \n /// first\u306e\u578b\n /// second\u306e\u578b\n /// first\u306e\u5024\n /// second\u306e\u5024\n /// \u4f5c\u6210\u3057\u305f \u30af\u30e9\u30b9\u306e\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\n public static Pair make_pair(T1 first, T2 second)\n where T1 : IComparable\n where T2 : IComparable\n => new Pair(first, second);\n\n /// a\u3068b\u3092\u30b9\u30ef\u30c3\u30d7\u3057\u307e\u3059\u3002\u306b\n public static void Swap(ref T a, ref T b) where T : struct\n {\n var tmp = b;\n b = a;\n a = tmp;\n }\n\n /// a\u3068b\u306e\u6700\u5927\u516c\u7d04\u6570\u3092\u6c42\u3081\u307e\u3059\u3002\n /// a\u3068b\u306e\u6700\u5927\u516c\u7d04\u6570\n public static long Gcd(long a, long b)\n {\n if (a < b) Swap(ref a, ref b);\n return a % b == 0 ? b : Gcd(b, a % b);\n }\n\n /// a\u3068b\u306e\u6700\u5c0f\u516c\u500d\u6570\u3092\u6c42\u3081\u307e\u3059\u3002\n /// a\u3068b\u306e\u6700\u5c0f\u516c\u500d\u6570\n public static long Lcm(long a, long b) => a / Gcd(a, b) * b;\n\n /// \n /// ^ (mod ) \u3092\u6c42\u3081\u308b\n /// \n /// ^ (mod ) \u306e\u5024\n public static long PowMod(long a, long b, long p)\n {\n long res = 1;\n while (b > 0)\n {\n if (b % 2 != 0) res = res * a % p;\n a = a * a % p;\n b >>= 1;\n }\n\n return res;\n }\n\n /// \n /// mod p\u306b\u304a\u3051\u308ba\u306e\u9006\u5143\u3092\u6c42\u3081\u307e\u3059\u3002\n /// \n /// \n /// \u6cd5\n /// \n public static long ModInv(long a, long p)\n => PowMod(a, p - 2, p);\n\n public static int DivCeil(int left, int right)\n => left / right + (left % right == 0 ? 0 : 1);\n\n public static long DivCeil(long left, long right)\n => left / right + (left % right == 0L ? 0L : 1L);\n\n /// \n /// src \u306e\u9806\u5217\u3092\u6c42\u3081\u307e\u3059\u3002\n /// \n /// \u578b\n /// \u9806\u5217\u3092\u6c42\u3081\u308b\u914d\u5217\n /// src \u306e\u9806\u5217\n public static IEnumerable Permutations(IEnumerable src)\n {\n var ret = new List();\n Search(ret, new Stack(), src.ToArray());\n return ret;\n }\n\n private static void Search(ICollection perms, Stack stack, T[] a)\n {\n int N = a.Length;\n if (N == 0) perms.Add(stack.Reverse().ToArray());\n else\n {\n var b = new T[N - 1];\n Array.Copy(a, 1, b, 0, N - 1);\n for (int i = 0; i < a.Length; ++i)\n {\n stack.Push(a[i]);\n Search(perms, stack, b);\n if (i < b.Length) b[i] = a[i];\n stack.Pop();\n }\n }\n }\n\n /// \n /// \u6307\u5b9a\u3057\u305f\u6761\u4ef6\u3092\u6e80\u305f\u3059\u6700\u5c0f\u306e\u6570\u5024\u3092\u8fd4\u3057\u307e\u3059\u3002\n /// \n /// \u691c\u7d22\u3059\u308b\u6570\u5024\u306e\u6700\u5c0f\u5024\n /// \u691c\u7d22\u3059\u308b\u6570\u5024\u306e\u6700\u5927\u5024\n /// \u6761\u4ef6\n /// \u6761\u4ef6\u3092\u6e80\u305f\u3059\u6700\u5c0f\u306e\u6570\u5024\n public static int BinarySearch(int low, int high, Func expression)\n {\n while (low < high)\n {\n int middle = (high - low) / 2 + low;\n if (expression(middle))\n high = middle;\n else\n low = middle + 1;\n }\n\n return high;\n }\n\n /// \n /// \u6307\u5b9a\u3057\u305f\u5024\u4ee5\u4e0a\u306e\u5148\u982d\u306e\u30a4\u30f3\u30c7\u30af\u30b9\u3092\u8fd4\u3057\u307e\u3059\u3002\n /// \n /// \u6bd4\u8f03\u3059\u308b\u5024\u306e\u578b\n /// \u5bfe\u8c61\u306e\u914d\u5217\uff08\u203b\u30bd\u30fc\u30c8\u6e08\u307f\u3067\u3042\u308b\u3053\u3068\uff09\n /// \u958b\u59cb\u30a4\u30f3\u30c7\u30af\u30b9 [inclusive]\n /// \u7d42\u4e86\u30a4\u30f3\u30c7\u30af\u30b9 [exclusive]\n /// \u691c\u7d22\u3059\u308b\u5024\n /// \u6bd4\u8f03\u95a2\u6570(\u30a4\u30f3\u30bf\u30fc\u30d5\u30a7\u30a4\u30b9)\n /// \u6307\u5b9a\u3057\u305f\u5024\u4ee5\u4e0a\u306e\u5148\u982d\u306e\u30a4\u30f3\u30c7\u30af\u30b9\n public static int LowerBound(T[] arr, int start, int end, T value, IComparer comparer)\n {\n int low = start;\n int high = end;\n while (low < high)\n {\n var mid = ((high - low) >> 1) + low;\n if (comparer.Compare(arr[mid], value) < 0)\n low = mid + 1;\n else\n high = mid;\n }\n\n return low;\n }\n\n /// \n /// \u6307\u5b9a\u3057\u305f\u5024\u4ee5\u4e0a\u306e\u5148\u982d\u306e\u30a4\u30f3\u30c7\u30af\u30b9\u3092\u8fd4\u3057\u307e\u3059\u3002\n /// \n /// \u6bd4\u8f03\u3059\u308b\u5024\u306e\u578b\n /// \u5bfe\u8c61\u306e\u914d\u5217\uff08\u203b\u30bd\u30fc\u30c8\u6e08\u307f\u3067\u3042\u308b\u3053\u3068\uff09\n /// \u691c\u7d22\u3059\u308b\u5024\n /// \u6307\u5b9a\u3057\u305f\u5024\u4ee5\u4e0a\u306e\u5148\u982d\u306e\u30a4\u30f3\u30c7\u30af\u30b9\n public static int LowerBound(T[] arr, T value) where T : IComparable\n {\n return LowerBound(arr, 0, arr.Length, value, Comparer.Default);\n }\n\n /// \n /// \u6307\u5b9a\u3057\u305f\u5024\u3088\u308a\u5927\u304d\u3044\u5148\u982d\u306e\u30a4\u30f3\u30c7\u30af\u30b9\u3092\u8fd4\u3057\u307e\u3059\u3002\n /// \n /// \u6bd4\u8f03\u3059\u308b\u5024\u306e\u578b\n /// \u5bfe\u8c61\u306e\u914d\u5217\uff08\u203b\u30bd\u30fc\u30c8\u6e08\u307f\u3067\u3042\u308b\u3053\u3068\uff09\n /// \u958b\u59cb\u30a4\u30f3\u30c7\u30af\u30b9 [inclusive]\n /// \u7d42\u4e86\u30a4\u30f3\u30c7\u30af\u30b9 [exclusive]\n /// \u691c\u7d22\u3059\u308b\u5024\n /// \u6bd4\u8f03\u95a2\u6570(\u30a4\u30f3\u30bf\u30fc\u30d5\u30a7\u30a4\u30b9)\n /// \u6307\u5b9a\u3057\u305f\u5024\u3088\u308a\u5927\u304d\u3044\u5148\u982d\u306e\u30a4\u30f3\u30c7\u30af\u30b9\n public static int UpperBound(T[] arr, int start, int end, T value, IComparer comparer)\n {\n int low = start;\n int high = end;\n while (low < high)\n {\n var mid = ((high - low) >> 1) + low;\n if (comparer.Compare(arr[mid], value) <= 0)\n low = mid + 1;\n else\n high = mid;\n }\n\n return low;\n }\n\n /// \n /// \u6307\u5b9a\u3057\u305f\u5024\u3088\u308a\u5927\u304d\u3044\u5148\u982d\u306e\u30a4\u30f3\u30c7\u30af\u30b9\u3092\u8fd4\u3057\u307e\u3059\u3002\n /// Z\n /// \u6bd4\u8f03\u3059\u308b\u5024\u306e\u578b\n /// \u5bfe\u8c61\u306e\u914d\u5217\uff08\u203b\u30bd\u30fc\u30c8\u6e08\u307f\u3067\u3042\u308b\u3053\u3068\uff09\n /// \u691c\u7d22\u3059\u308b\u5024\n /// \u6307\u5b9a\u3057\u305f\u5024\u3088\u308a\u5927\u304d\u3044\u5148\u982d\u306e\u30a4\u30f3\u30c7\u30af\u30b9\n public static int UpperBound(T[] arr, T value)\n {\n return UpperBound(arr, 0, arr.Length, value, Comparer.Default);\n }\n\n public static IEnumerable SelectNotNull(this IEnumerable source, Func func)\n => source.Where(val => val != null).Select(func);\n\n public static IEnumerable WhereNotNull(this IEnumerable source)\n => source.Where(val => val != null);\n /// \n /// \u6587\u5b57\u306e\u914d\u5217\u3092\u6587\u5b57\u5217\u306b\u5909\u63db\u3057\u307e\u3059\u3002\n /// \n /// \u6587\u5b57\u306e\u914d\u5217\n /// \u5909\u63db\u3057\u305f\u6587\u5b57\u5217\n public static string AsString(this IEnumerable source) => new string(source.ToArray());\n\n /// \n /// \u306e\u7d2f\u7a4d\u548c\u3092\u8fd4\u3057\u307e\u3059\u3002\n /// \n /// \u306e\u7d2f\u7a4d\u548c\n public static IEnumerable CumSum(this IEnumerable source)\n {\n long sum = 0;\n foreach (var item in source)\n yield return sum += item;\n }\n\n /// \n /// \u306e\u7d2f\u7a4d\u548c\u3092\u8fd4\u3057\u307e\u3059\u3002\n /// \n /// \u306e\u7d2f\u7a4d\u548c\n public static IEnumerable CumSum(this IEnumerable source)\n {\n int sum = 0;\n foreach (var item in source)\n yield return sum += item;\n }\n /// \n /// \u304c l\u4ee5\u4e0a r\u672a\u6e80\u306e\u7bc4\u56f2\u306b\u542b\u307e\u308c\u3066\u3044\u308b\u304b\u3092\u8fd4\u3057\u307e\u3059\u3002\n /// \n /// \u8981\u7d20\u306e\u578b\n /// \u5224\u5b9a\u3059\u308b\u5024\n /// \u4e0b\u9650\u306e\u5024 (\u542b\u307e\u308c\u308b)\n /// \u4e0b\u9650\u306e\u5024 (\u542b\u307e\u308c\u306a\u3044)\n /// \u304c\u6307\u5b9a\u3057\u305f\u7bc4\u56f2\u306b\u542b\u307e\u308c\u3066\u3044\u308b\u304b\n public static bool IsIn(this T value, T l, T r)\n where T : IComparable\n {\n if (l.CompareTo(r) > 0) throw new ArgumentException();\n return l.CompareTo(value) <= 0 && value.CompareTo(r) < 0;\n }\n\n /// \n /// \u4ee5\u4e0a \u672a\u6e80\u306e\u5024\u3092 \u305a\u3064\u5897\u3084\u3057\u305f\u7d50\u679c\u3092\u5217\u6319\u3057\u307e\u3059\u3002\n /// \n /// \u5024\u306e\u4e0b\u9650 (\u542b\u307e\u308c\u308b)\n /// \u5024\u306e\u4e0a\u9650 (\u542b\u307e\u308c\u306a\u3044)\n /// 1\u8981\u7d20\u3054\u3068\u306b\u5897\u3084\u3059\u5024\n /// \u7bc4\u56f2\u306e\u7d50\u679c\n public static IEnumerable Range(int start, int end, int step = 1)\n {\n for (var i = start; i < end; i += step) yield return i;\n }\n\n /// \n /// 0 \u4ee5\u4e0a \u672a\u6e80\u306e\u5024\u3092 1 \u305a\u3064\u5897\u3084\u3057\u305f\u7d50\u679c\u3092\u5217\u6319\u3057\u307e\u3059\u3002\n /// \n /// \u5024\u306e\u4e0a\u9650 (\u542b\u307e\u308c\u306a\u3044)\n /// \u7bc4\u56f2\u306e\u7d50\u679c\n public static IEnumerable Range(int end) => Range(0, end);\n\n /// \n /// \u4ee5\u4e0a \u672a\u6e80\u306e\u5024\u3092 \u305a\u3064\u5897\u3084\u3057\u305f\u7d50\u679c\u3092\u9006\u9806\u306b\u5217\u6319\u3057\u307e\u3059\u3002\n /// \n /// \u5024\u306e\u4e0b\u9650 (\u542b\u307e\u308c\u308b)\n /// \u5024\u306e\u4e0a\u9650 (\u542b\u307e\u308c\u306a\u3044)\n /// 1\u8981\u7d20\u3054\u3068\u306b\u5897\u3084\u3059\u5024\n /// \u7bc4\u56f2\u306e\u7d50\u679c\n public static IEnumerable RangeReverse(int start, int end, int step = 1)\n {\n for (var i = end - 1; i >= start; i -= step) yield return i;\n }\n\n /// \n /// 0 \u4ee5\u4e0a \u672a\u6e80\u306e\u5024\u3092 1 \u305a\u3064\u5897\u3084\u3057\u305f\u7d50\u679c\u3092\u9006\u9806\u306b\u5217\u6319\u3057\u307e\u3059\u3002\n /// \n /// \u5024\u306e\u4e0a\u9650 (\u542b\u307e\u308c\u306a\u3044)\n /// \u7bc4\u56f2\u306e\u7d50\u679c\n public static IEnumerable RangeReverse(int end) => RangeReverse(0, end);\n\n /// \n /// value\u3092\u7d20\u56e0\u6570\u5206\u89e3\u3057\u3001\u7d20\u56e0\u6570\u3092\u5217\u6319\u3057\u307e\u3059\u3002\n /// \n /// \u7d20\u56e0\u6570\u5206\u89e3\u3059\u308b\u5024\n /// \u7d20\u56e0\u6570\u306e\u96c6\u5408\n public static IEnumerable Factorize(int value)\n {\n for (int i = 2; i * i < value; i++)\n {\n while (value % i == 0)\n {\n value /= i;\n yield return i;\n }\n }\n\n if (value > 1)\n yield return value;\n }\n /// \n /// value\u3092\u7d20\u56e0\u6570\u5206\u89e3\u3057\u3001\u7d20\u56e0\u6570\u3092\u5217\u6319\u3057\u307e\u3059\u3002\n /// \n /// \u7d20\u56e0\u6570\u5206\u89e3\u3059\u308b\u5024\n /// \u7d20\u56e0\u6570\u306e\u96c6\u5408\n public static IEnumerable Factorize(long value)\n {\n for (int i = 2; i * i < value; i++)\n {\n while (value % i == 0)\n {\n value /= i;\n yield return i;\n }\n }\n\n if (value > 1)\n yield return value;\n }\n /// \n /// value\u3092\u7d20\u56e0\u6570\u5206\u89e3\u3057\u3001\u7d20\u56e0\u6570\u3068\u305d\u306e\u500b\u6570\u306e\u9023\u60f3\u914d\u5217\u3092\u8fd4\u3057\u307e\u3059\u3002\n /// \n /// \u7d20\u56e0\u6570\u5206\u89e3\u3059\u308b\u5024\n /// \u7d20\u56e0\u6570\u306e\u9023\u60f3\u914d\u5217\n public static Dictionary FactorizeAsMap(long value)\n {\n var dict = new Dictionary();\n\n for (int i = 2; i * i < value; i++)\n {\n if (value % i > 0) continue;\n int cnt = 0;\n while (value % i == 0)\n {\n value /= i;\n cnt++;\n }\n dict.Add(i, cnt);\n }\n\n if (value > 1) dict.Add(value, 1);\n return dict;\n }\n\n /// \n /// value\u3092\u7d20\u56e0\u6570\u5206\u89e3\u3057\u3001\u7d20\u56e0\u6570\u3068\u305d\u306e\u500b\u6570\u306e\u9023\u60f3\u914d\u5217\u3092\u8fd4\u3057\u307e\u3059\u3002\n /// \n /// \u7d20\u56e0\u6570\u5206\u89e3\u3059\u308b\u5024\n /// \u7d20\u56e0\u6570\u306e\u9023\u60f3\u914d\u5217\n public static Dictionary FactorizeAsMap(int value)\n {\n var dict = new Dictionary();\n\n for (int i = 2; i * i < value; i++)\n {\n if (value % i > 0) continue;\n int cnt = 0;\n while (value % i == 0)\n {\n value /= i;\n cnt++;\n }\n dict.Add(i, cnt);\n }\n\n if (value > 1) dict.Add(value, 1);\n return dict;\n }\n /// \n /// value\u306e\u7d04\u6570\u306e\u500b\u6570\u3092\u6c42\u3081\u307e\u3059\u3002\n /// \n /// \u7d04\u6570\u306e\u500b\u6570\u3092\u6c42\u3081\u308b\u6570\n /// value\u306e\u7d04\u6570\u306e\u500b\u6570\n public static long Divisors(long value)\n {\n var fact = FactorizeAsMap(value);\n return fact.Select(x => x.Value + 1L).Aggregate((m, x) => m * x);\n }\n\n public static bool IsEven(this int x) => x % 2 == 0;\n public static bool IsOdd(this int x) => x % 2 != 0;\n public static bool IsEven(this long x) => x % 2 == 0;\n public static bool IsOdd(this long x) => x % 2 != 0;\n public static double Log2(double x) => Log(x, 2);\n\n public static bool chmin(ref int a, int b)\n {\n if (a > b)\n {\n a = b;\n return true;\n }\n\n return false;\n }\n\n public static bool chmax(ref int a, int b)\n {\n if (a < b)\n {\n a = b;\n return true;\n }\n\n return false;\n }\n\n public static bool chmin(ref long a, long b)\n {\n if (a > b)\n {\n a = b;\n return true;\n }\n\n return false;\n }\n\n public static bool chmax(ref long a, long b)\n {\n if (a < b)\n {\n a = b;\n return true;\n }\n\n return false;\n }\n\n public static T Min(params T[] col) => col.Min();\n public static T Max(params T[] col) => col.Max();\n\n }\n\n public static class Input\n {\n private const char _separator = ' ';\n private static readonly Queue _input = new Queue();\n private static readonly StreamReader sr =\n#if FILE\n new StreamReader(\"in.txt\");\n#else\n new StreamReader(Console.OpenStandardInput());\n#endif\n\n public static string Rs => ReadStr;\n public static int Ri => ReadInt;\n public static long Rl => ReadLong;\n public static string[] Rsa => StrArray();\n public static int[] Ria => IntArray();\n public static long[] Rla => LongArray();\n public static string ReadLine => sr.ReadLine();\n public static string ReadStr => Read;\n\n public static string Read\n {\n get {\n if (_input.Count != 0) return _input.Dequeue();\n\n // ReSharper disable once PossibleNullReferenceException\n var tmp = sr.ReadLine().Split(_separator);\n foreach (var val in tmp)\n {\n _input.Enqueue(val);\n }\n\n return _input.Dequeue();\n }\n }\n\n public static int ReadInt => int.Parse(Read);\n public static long ReadLong => long.Parse(Read);\n public static double ReadDouble => double.Parse(Read);\n public static string[] StrArray() => ReadLine.Split(' ');\n public static int[] IntArray() => ReadLine.Split(' ').Select(int.Parse).ToArray();\n public static long[] LongArray() => ReadLine.Split(' ').Select(long.Parse).ToArray();\n\n public static string[] StrArray(long n)\n {\n var ret = new string[n];\n for (long i = 0; i < n; ++i) ret[i] = Read;\n return ret;\n }\n\n public static int[] IntArray(long n, bool sorted = false)\n {\n var ret = StrArray(n).Select(int.Parse).ToArray();\n if (sorted) Array.Sort(ret);\n return ret;\n }\n\n public static long[] LongArray(long n, bool sorted = false)\n {\n var ret = StrArray(n).Select(long.Parse).ToArray();\n if (sorted) Array.Sort(ret);\n return ret;\n }\n\n static bool TypeEquals() => typeof(T) == typeof(U);\n static T ChangeType(U a) => (T)System.Convert.ChangeType(a, typeof(T));\n\n static T Convert(string s) => TypeEquals() ? ChangeType(int.Parse(s))\n : TypeEquals() ? ChangeType(long.Parse(s))\n : TypeEquals() ? ChangeType(double.Parse(s))\n : TypeEquals() ? ChangeType(s[0])\n : ChangeType(s);\n\n public static bool In(out T a)\n {\n try\n {\n a = Convert(Read);\n return true;\n }\n catch\n {\n a = default(T);\n return false;\n }\n }\n\n public static bool In(out T a, out U b)\n {\n try\n {\n var ar = StrArray(2);\n a = Convert(ar[0]);\n b = Convert(ar[1]);\n return true;\n }\n catch\n {\n a = default(T);\n b = default(U);\n return false;\n }\n }\n\n public static bool In(out T a, out U b, out V c)\n {\n try\n {\n var ar = StrArray(3);\n a = Convert(ar[0]);\n b = Convert(ar[1]);\n c = Convert(ar[2]);\n return true;\n }\n catch\n {\n a = default(T);\n b = default(U);\n c = default(V);\n return false;\n }\n }\n\n public static bool In(out T a, out U b, out V c, out W d)\n {\n try\n {\n var ar = StrArray(4);\n a = Convert(ar[0]);\n b = Convert(ar[1]);\n c = Convert(ar[2]);\n d = Convert(ar[3]);\n return true;\n }\n catch\n {\n a = default(T);\n b = default(U);\n c = default(V);\n d = default(W);\n return false;\n }\n }\n\n public static bool In(out T a, out U b, out V c, out W d, out X e)\n {\n try\n {\n var ar = StrArray(5);\n a = Convert(ar[0]);\n b = Convert(ar[1]);\n c = Convert(ar[2]);\n d = Convert(ar[3]);\n e = Convert(ar[4]);\n return true;\n }\n catch\n {\n a = default(T);\n b = default(U);\n c = default(V);\n d = default(W);\n e = default(X);\n return false;\n }\n }\n /// \n /// \u8981\u7d20\u6570 (a, b) \u306e\u3001defaultValue \u3067\u6e80\u305f\u3055\u308c\u305f\u914d\u5217\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002\n /// \n /// \u914d\u5217\u306e\u578b\n /// 1\u6b21\u5143\u306e\u8981\u7d20\u6570\n /// 2\u6b21\u5143\u306e\u8981\u7d20\u6570\n /// \u30c7\u30d5\u30a9\u30eb\u30c8\u5024\n /// \u6307\u5b9a\u3057\u305f\u6761\u4ef6\u3067\u521d\u671f\u5316\u3055\u308c\u305f\u914d\u5217\n public static T[][] Array2D(int a, int b, T defaultValue = default(T))\n {\n var ret = new T[a][];\n for (int i = 0; i < a; i++)\n {\n ret[i] = Enumerable.Repeat(defaultValue, b).ToArray();\n }\n\n return ret;\n }\n }\n\n public class Program\n {\n public static void Main(string[] args)\n {\n var sw = new StreamWriter(Console.OpenStandardOutput()){AutoFlush = false};\n Console.SetOut(sw);\n new Solver().Solve();\n Console.Out.Flush();\n Console.Read();\n }\n }\n\n #endregion\n\n\n\n public class Solver\n {\n private const int MOD = (int)1e9 + 7,\n INF = 1000000010;\n\n public void Solve()\n {\n int N = ReadInt;\n int K = ReadInt;\n\n if (N == 1 && K == 1)\n {\n Console.WriteLine(0);\n return;\n }\n\n long now = 1;\n int i = 1;\n while (true)\n {\n now += ++i;\n if (now < K) continue;\n\n int actionCount = i;\n long mustEatCount = now - K;\n if (actionCount + mustEatCount == N ) break;\n }\n\n Console.WriteLine(now - K );\n\n }\n }\n}", "lang_cluster": "C#", "tags": ["brute force", "math", "binary search"], "code_uid": "5d1374636dce10b5826490ae1b255470", "src_uid": "17b5ec1c6263ef63c668c2b903db1d77", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": ".NET Core C#", "source_code": "using System;\nusing System.Linq;\nusing CompLib.Util;\nusing System.Threading;\n\npublic class Program\n{\n public void Solve()\n {\n var sc = new Scanner();\n int n = sc.NextInt();\n int k = sc.NextInt();\n\n for (int a = 0; a <= n; a++)\n {\n int b = n - a;\n long t = (long) (a + 1) * a / 2 - b;\n if (t == k)\n {\n Console.WriteLine(b);\n return;\n }\n \n if(t > k) return;\n }\n }\n\n public static void Main(string[] args) => new Program().Solve();\n // public static void Main(string[] args) => new Thread(new Program().Solve, 1 << 27).Start();\n}\n\nnamespace CompLib.Util\n{\n using System;\n using System.Linq;\n\n class Scanner\n {\n private string[] _line;\n private int _index;\n private const char Separator = ' ';\n\n public Scanner()\n {\n _line = new string[0];\n _index = 0;\n }\n\n public string Next()\n {\n if (_index >= _line.Length)\n {\n string s;\n do\n {\n s = Console.ReadLine();\n } while (s.Length == 0);\n\n _line = s.Split(Separator);\n _index = 0;\n }\n\n return _line[_index++];\n }\n\n public string ReadLine()\n {\n _index = _line.Length;\n return Console.ReadLine();\n }\n\n public int NextInt() => int.Parse(Next());\n public long NextLong() => long.Parse(Next());\n public double NextDouble() => double.Parse(Next());\n public decimal NextDecimal() => decimal.Parse(Next());\n public char NextChar() => Next()[0];\n public char[] NextCharArray() => Next().ToCharArray();\n\n public string[] Array()\n {\n string s = Console.ReadLine();\n _line = s.Length == 0 ? new string[0] : s.Split(Separator);\n _index = _line.Length;\n return _line;\n }\n\n public int[] IntArray() => Array().Select(int.Parse).ToArray();\n public long[] LongArray() => Array().Select(long.Parse).ToArray();\n public double[] DoubleArray() => Array().Select(double.Parse).ToArray();\n public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();\n }\n}", "lang_cluster": "C#", "tags": ["brute force", "math", "binary search"], "code_uid": "62abfd0d56c7e4c789c0b9684f97cdf0", "src_uid": "17b5ec1c6263ef63c668c2b903db1d77", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nclass Program\n{\n\tstatic void Main(string[] args)\n\t{\n\t\tstring[] str = Console.ReadLine().Split();\n\t\tlong w = long.Parse(str[0]);\n\t\tlong h = long.Parse(str[1]);\n\t\tlong ans = 4;\n\t\tlong mod = 998244353;\n\t\tfor(var i=1;i param = new Queue();\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static string NextString() { if (param.Count == 0) foreach (var item in Console.ReadLine().Split(' ')) param.Enqueue(item); return param.Dequeue(); }\n }\n static long NN => long.Parse(Console_.NextString());\n static double ND => double.Parse(Console_.NextString());\n static string NS => Console_.NextString();\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n static long[] NNList(long N) => Repeat(0, N).Select(_ => NN).ToArray();\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n static double[] NDList(long N) => Repeat(0, N).Select(_ => ND).ToArray();\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n static string[] NSList(long N) => Repeat(0, N).Select(_ => NS).ToArray();\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n static IEnumerable OrderByRand(this IEnumerable x) => x.OrderBy(_ => rand.Next());\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n static IEnumerable Repeat(T v, long n) => Enumerable.Repeat(v, (int)n);\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n static IEnumerable Range(long s, long c) => Enumerable.Range((int)s, (int)c);\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n static void RevSort(T[] l) where T : IComparable { Array.Sort(l, (x, y) => y.CompareTo(x)); }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n static void RevSort(T[] l, Comparison comp) where T : IComparable { Array.Sort(l, (x, y) => comp(y, x)); }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n static IEnumerable Primes(long x) { if (x < 2) yield break; yield return 2; var halfx = x / 2; var table = new bool[halfx + 1]; var max = (long)(Math.Sqrt(x) / 2); for (long i = 1; i <= max; ++i) { if (table[i]) continue; var add = 2 * i + 1; yield return add; for (long j = 2 * i * (i + 1); j <= halfx; j += add) table[j] = true; } for (long i = max + 1; i <= halfx; ++i) if (!table[i] && 2 * i + 1 <= x) yield return 2 * i + 1; }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n static IEnumerable Factors(long x) { if (x < 2) yield break; while (x % 2 == 0) { x /= 2; yield return 2; } var max = (long)Math.Sqrt(x); for (long i = 3; i <= max; i += 2) while (x % i == 0) { x /= i; yield return i; } if (x != 1) yield return x; }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n static IEnumerable Divisor(long x) { if (x < 1) yield break; var max = (long)Math.Sqrt(x); for (long i = 1; i <= max; ++i) { if (x % i != 0) continue; yield return i; if (i != x / i) yield return x / i; } }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n static long GCD(long a, long b) { while (b > 0) { var tmp = b; b = a % b; a = tmp; } return a; }\n static long LCM(long a, long b) => a * b / GCD(a, b);\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n static Mat Pow(Mat x, long y) => Mat.Pow(x, y);\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n static T Pow(T x, long y) { T a = (dynamic)1; while (y != 0) { if ((y & 1) == 1) a *= (dynamic)x; x *= (dynamic)x; y >>= 1; } return a; }\n static List _fact = new List() { 1 };\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n static void _B(long n) { if (n >= _fact.Count) for (int i = _fact.Count; i <= n; ++i) _fact.Add(_fact[i - 1] * i); }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n static long Comb(long n, long k) { _B(n); if (n == 0 && k == 0) return 1; if (n < k || n < 0) return 0; return _fact[(int)n] / _fact[(int)(n - k)] / _fact[(int)k]; }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n static long Perm(long n, long k) { _B(n); if (n == 0 && k == 0) return 1; if (n < k || n < 0) return 0; return _fact[(int)n] / _fact[(int)(n - k)]; }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n static Func Lambda(Func, TR> f) { Func t = () => default(TR); return t = () => f(t); }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n static Func Lambda(Func, TR> f) { Func t = x1 => default(TR); return t = x1 => f(x1, t); }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n static Func Lambda(Func, TR> f) { Func t = (x1, x2) => default(TR); return t = (x1, x2) => f(x1, x2, t); }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n static Func Lambda(Func, TR> f) { Func t = (x1, x2, x3) => default(TR); return t = (x1, x2, x3) => f(x1, x2, x3, t); }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n static Func Lambda(Func, TR> f) { Func t = (x1, x2, x3, x4) => default(TR); return t = (x1, x2, x3, x4) => f(x1, x2, x3, x4, t); }\n class PQ where T : IComparable\n {\n List h; Comparison c; public T Peek => h[0]; public int Count => h.Count;\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public PQ(int cap, Comparison c, bool asc = true) { h = new List(cap); this.c = asc ? c : (x, y) => c(y, x); }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public PQ(Comparison c, bool asc = true) { h = new List(); this.c = asc ? c : (x, y) => c(y, x); }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public PQ(int cap, bool asc = true) : this(cap, (x, y) => x.CompareTo(y), asc) { }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public PQ(bool asc = true) : this((x, y) => x.CompareTo(y), asc) { }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public void Push(T v) { var i = h.Count; h.Add(v); while (i > 0) { var ni = (i - 1) / 2; if (c(v, h[ni]) >= 0) break; h[i] = h[ni]; i = ni; } h[i] = v; }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public T Pop() { var r = h[0]; var v = h[h.Count - 1]; h.RemoveAt(h.Count - 1); if (h.Count == 0) return r; var i = 0; while (i * 2 + 1 < h.Count) { var i1 = i * 2 + 1; var i2 = i * 2 + 2; if (i2 < h.Count && c(h[i1], h[i2]) > 0) i1 = i2; if (c(v, h[i1]) <= 0) break; h[i] = h[i1]; i = i1; } h[i] = v; return r; }\n }\n class PQ where TK : IComparable\n {\n PQ> q; public Tuple Peek => q.Peek; public int Count => q.Count;\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public PQ(int cap, Comparison c, bool asc = true) { q = new PQ>(cap, (x, y) => c(x.Item1, y.Item1), asc); }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public PQ(Comparison c, bool asc = true) { q = new PQ>((x, y) => c(x.Item1, y.Item1), asc); }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public PQ(int cap, bool asc = true) : this(cap, (x, y) => x.CompareTo(y), asc) { }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public PQ(bool asc = true) : this((x, y) => x.CompareTo(y), asc) { }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public void Push(TK k, TV v) => q.Push(Tuple.Create(k, v));\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public Tuple Pop() => q.Pop();\n }\n public class UF\n {\n long[] d;\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public UF(long s) { d = Repeat(-1L, s).ToArray(); }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public bool Unite(long x, long y) { x = Root(x); y = Root(y); if (x != y) { if (d[y] < d[x]) { var t = y; y = x; x = t; } d[x] += d[y]; d[y] = x; } return x != y; }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public bool IsSame(long x, long y) => Root(x) == Root(y);\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public long Root(long x) => d[x] < 0 ? x : d[x] = Root(d[x]);\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public long Count(long x) => -d[Root(d[x])];\n }\n struct Mod : IEquatable\n {\n static public long _mod = 1000000007; long _val;\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public Mod(long x) { if (x < _mod && x >= 0) _val = x; else if ((_val = x % _mod) < 0) _val += _mod; }\n static public implicit operator Mod(long x) => new Mod(x);\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n static public implicit operator long(Mod x) => x._val;\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n static public Mod operator +(Mod x, Mod y) { var t = x._val + y._val; return t >= _mod ? new Mod { _val = t - _mod } : new Mod { _val = t }; }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n static public Mod operator -(Mod x, Mod y) { var t = x._val - y._val; return t < 0 ? new Mod { _val = t + _mod } : new Mod { _val = t }; }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n static public Mod operator *(Mod x, Mod y) => x._val * y._val;\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n static public Mod operator /(Mod x, Mod y) => x._val * Inverse(y._val);\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n static public bool operator ==(Mod x, Mod y) => x._val == y._val;\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n static public bool operator !=(Mod x, Mod y) => x._val != y._val;\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n static public long Inverse(long x) { long b = _mod, r = 1, u = 0, t = 0; while (b > 0) { var q = x / b; t = u; u = r - q * u; r = t; t = b; b = x - q * b; x = t; } return r < 0 ? r + _mod : r; }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n bool IEquatable.Equals(object obj) => obj == null ? false : Equals((Mod)obj);\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public override bool Equals(object obj) => obj == null ? false : Equals((Mod)obj);\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public bool Equals(Mod obj) => obj == null ? false : _val == obj._val;\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public override int GetHashCode() => _val.GetHashCode();\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public override string ToString() => _val.ToString();\n static List _fact = new List() { 1 };\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n static void B(long n) { if (n >= _fact.Count) for (int i = _fact.Count; i <= n; ++i) _fact.Add(_fact[i - 1] * i); }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n static public Mod Comb(long n, long k) { B(n); if (n == 0 && k == 0) return 1; if (n < k || n < 0) return 0; return _fact[(int)n] / _fact[(int)(n - k)] / _fact[(int)k]; }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n static public Mod Perm(long n, long k) { B(n); if (n == 0 && k == 0) return 1; if (n < k || n < 0) return 0; return _fact[(int)n] / _fact[(int)(n - k)]; }\n }\n struct Mat\n {\n T[,] m;\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public Mat(T[,] v) { m = (T[,])v.Clone(); }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n static public implicit operator Mat(T[,] v) => new Mat(v);\n public T this[int r, int c] { get { return m[r, c]; } set { m[r, c] = value; } }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n static public Mat operator +(Mat a, T x) { var tm = (T[,])a.m.Clone(); for (int r = 0; r < tm.GetLength(0); ++r) for (int c = 0; c < tm.GetLength(1); ++c) tm[r, c] += (dynamic)x; return tm; }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n static public Mat operator +(Mat a, Mat b) { var tm = (T[,])a.m.Clone(); for (int r = 0; r < tm.GetLength(0); ++r) for (int c = 0; c < tm.GetLength(1); ++c) tm[r, c] += (dynamic)b[r, c]; return tm; }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n static public Mat operator -(Mat a, T x) { var tm = (T[,])a.m.Clone(); for (int r = 0; r < tm.GetLength(0); ++r) for (int c = 0; c < tm.GetLength(1); ++c) tm[r, c] -= (dynamic)x; return tm; }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n static public Mat operator -(Mat a, Mat b) { var tm = (T[,])a.m.Clone(); for (int r = 0; r < tm.GetLength(0); ++r) for (int c = 0; c < tm.GetLength(1); ++c) tm[r, c] -= (dynamic)b[r, c]; return tm; }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n static public Mat operator *(Mat a, T x) { var tm = (T[,])a.m.Clone(); for (int r = 0; r < tm.GetLength(0); ++r) for (int c = 0; c < tm.GetLength(1); ++c) tm[r, c] *= (dynamic)x; return tm; }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n static public Mat operator *(Mat a, Mat b) { var nr = a.m.GetLength(0); var nc = b.m.GetLength(1); var tm = new T[nr, nc]; for (int i = 0; i < nr; ++i) for (int j = 0; j < nc; ++j) tm[i, j] = (dynamic)0; for (int r = 0; r < nr; ++r) for (int c = 0; c < nc; ++c) for (int i = 0; i < a.m.GetLength(1); ++i) tm[r, c] += a[r, i] * (dynamic)b[i, c]; return tm; }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n static public Mat Pow(Mat x, long y) { var n = x.m.GetLength(0); var t = (Mat)new T[n, n]; for (int i = 0; i < n; ++i) for (int j = 0; j < n; ++j) t[i, j] = (dynamic)(i == j ? 1 : 0); while (y != 0) { if ((y & 1) == 1) t *= x; x *= x; y >>= 1; } return t; }\n }\n class Tree\n {\n long N; int l; List[] p; int[] d; long[][] pr; long r; Tuple[] e; Tuple[] b; bool lca; bool euler; bool bfs;\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public Tree(List[] p_, long r_) { N = p_.Length; p = p_; r = r_; lca = false; euler = false; }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public Tuple[] BFSRoot() { if (!bfs) { var nb = new List>(); var q = new Queue(); var d = new bool[N]; nb.Add(Tuple.Create(r, -1L)); d[r] = true; q.Enqueue(r); while (q.Count > 0) { var w = q.Dequeue(); foreach (var i in p[w]) { if (d[i]) continue; d[i] = true; q.Enqueue(i); nb.Add(Tuple.Create(i, w)); } } b = nb.ToArray(); bfs = true; } return b; }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public Tuple[] BFSLeaf() => BFSRoot().Reverse().ToArray();\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public Tuple[] Euler() { if (!euler) { var ne = new List>(); var s = new Stack>(); var d = new bool[N]; d[r] = true; s.Push(Tuple.Create(r, -1L)); while (s.Count > 0) { var w = s.Peek(); var ad = true; foreach (var i in p[w.Item1]) { if (d[i]) continue; d[i] = true; ad = false; s.Push(Tuple.Create(i, w.Item1)); } if (!ad || p[w.Item1].Count == 1) ne.Add(Tuple.Create(w.Item1, w.Item2, 1)); if (ad) { s.Pop(); ne.Add(Tuple.Create(w.Item1, w.Item2, -1)); } } e = ne.ToArray(); euler = true; } return e; }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public long LCA(long u, long v) { if (!lca) { l = 0; while (N > (1 << l)) l++; d = new int[N]; pr = Repeat(0, l).Select(_ => new long[N]).ToArray(); d[r] = 0; pr[0][r] = -1; var q = new Stack(); q.Push(r); while (q.Count > 0) { var w = q.Pop(); foreach (var i in p[w]) { if (i == pr[0][w]) continue; q.Push(i); d[i] = d[w] + 1; pr[0][i] = w; } } for (var k = 0; k + 1 < l; k++) for (var w = 0; w < N; w++) if (pr[k][w] < 0) pr[k + 1][w] = -1; else pr[k + 1][w] = pr[k][pr[k][w]]; lca = true; } if (d[u] > d[v]) { var t = u; u = v; v = t; } for (var k = 0; k < l; k++) if ((((d[v] - d[u]) >> k) & 1) != 0) v = pr[k][v]; if (u == v) return u; for (var k = l - 1; k >= 0; k--) if (pr[k][u] != pr[k][v]) { u = pr[k][u]; v = pr[k][v]; } return pr[0][u]; }\n }\n class BT where T : IComparable\n {\n class Node { public Node l; public Node r; public T v; public bool b; }\n Comparison c; Node r; bool ch; T lm;\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public BT(Comparison _c) { c = _c; }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public BT() : this((x, y) => x.CompareTo(y)) { }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n bool R(Node n) => n != null && !n.b;\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n bool B(Node n) => n != null && n.b;\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n Node RtL(Node n) { Node m = n.r, t = m.l; m.l = n; n.r = t; return m; }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n Node RtR(Node n) { Node m = n.l, t = m.r; m.r = n; n.l = t; return m; }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n Node RtLR(Node n) { n.l = RtL(n.l); return RtR(n); }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n Node RtRL(Node n) { n.r = RtR(n.r); return RtL(n); }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public void Add(T x) { r = A(r, x); r.b = true; }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n Node A(Node n, T x) { if (n == null) { ch = true; return new Node() { v = x }; } if (c(x, n.v) < 0) n.l = A(n.l, x); else n.r = A(n.r, x); return Bl(n); }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n Node Bl(Node n) { if (!ch) return n; if (!B(n)) return n; if (R(n.l) && R(n.l.l)) { n = RtR(n); n.l.b = true; } else if (R(n.l) && R(n.l.r)) { n = RtLR(n); n.l.b = true; } else if (R(n.r) && R(n.r.l)) { n = RtRL(n); n.r.b = true; } else if (R(n.r) && R(n.r.r)) { n = RtL(n); n.r.b = true; } else ch = false; return n; }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public void Remove(T x) { r = Rm(r, x); if (r != null) r.b = true; }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n Node Rm(Node n, T x) { if (n == null) { ch = false; return n; } var r = c(x, n.v); if (r < 0) { n.l = Rm(n.l, x); return BlL(n); } if (r > 0) { n.r = Rm(n.r, x); return BlR(n); } if (n.l == null) { ch = n.b; return n.r; } n.l = RmM(n.l); n.v = lm; return BlL(n); }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n Node RmM(Node n) { if (n.r != null) { n.r = RmM(n.r); return BlR(n); } lm = n.v; ch = n.b; return n.l; }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n Node BlL(Node n) { if (!ch) return n; if (B(n.r) && R(n.r.l)) { var b = n.b; n = RtRL(n); n.b = b; n.l.b = true; ch = false; } else if (B(n.r) && R(n.r.r)) { var b = n.b; n = RtL(n); n.b = b; n.r.b = true; n.l.b = true; ch = false; } else if (B(n.r)) { ch = n.b; n.b = true; n.r.b = false; } else { n = RtL(n); n.b = true; n.l.b = false; n.l = BlL(n.l); ch = false; } return n; }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n Node BlR(Node n) { if (!ch) return n; if (B(n.l) && R(n.l.r)) { var b = n.b; n = RtLR(n); n.b = b; n.r.b = true; ch = false; } else if (B(n.l) && R(n.l.l)) { var b = n.b; n = RtR(n); n.b = b; n.l.b = true; n.r.b = true; ch = false; } else if (B(n.l)) { ch = n.b; n.b = true; n.l.b = false; } else { n = RtR(n); n.b = true; n.r.b = false; n.r = BlR(n.r); ch = false; } return n; }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public bool Have(T x) { var t = FindUpper(x); return t.Item1 && t.Item2.CompareTo(x) == 0; }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public Tuple FindUpper(T x, bool findSame = true) { var v = FU(r, x, findSame); return v == null ? Tuple.Create(false, default(T)) : v; }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n Tuple FU(Node n, T x, bool s) { if (n == null) return null; var r = c(x, n.v); if (r < 0) { var v = FU(n.l, x, s); return v == null ? Tuple.Create(true, n.v) : v; } if (r > 0 || !s && r == 0) return FU(n.r, x, s); return Tuple.Create(true, n.v); }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public Tuple FindLower(T x, bool findSame = true) { var v = FL(r, x, findSame); return v == null ? Tuple.Create(false, default(T)) : v; }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n Tuple FL(Node n, T x, bool s) { if (n == null) return null; var r = c(x, n.v); if (r < 0 || !s && r == 0) return FL(n.l, x, s); if (r > 0) { var v = FL(n.r, x, s); return v == null ? Tuple.Create(true, n.v) : v; } return Tuple.Create(true, n.v); }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public T Min() { Node n = r, p = null; while (n != null) { p = n; n = n.l; } return p == null ? default(T) : p.v; }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public T Max() { Node n = r, p = null; while (n != null) { p = n; n = n.r; } return p == null ? default(T) : p.v; }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public bool Any() => r != null;\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public int CountSlow() => L(r).Count();\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public IEnumerable List() => L(r);\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n IEnumerable L(Node n) { if (n == null) yield break; foreach (var i in L(n.l)) yield return i; yield return n.v; foreach (var i in L(n.r)) yield return i; }\n }\n class Dict : Dictionary\n {\n new public V this[K i] { get { V v; return TryGetValue(i, out v) ? v : base[i] = default(V); } set { base[i] = value; } }\n }\n class Deque\n {\n T[] b; int o, c;\n public int Count;\n public T this[int i] { get { return b[gi(i)]; } set { b[gi(i)] = value; } }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public Deque(int cap = 16) { b = new T[c = cap]; }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n int gi(int i) { if (i >= c) throw new Exception(); var r = o + i; return r >= c ? r - c : r; }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public void PushFront(T x) { if (Count == c) e(); if (--o < 0) o += b.Length; b[o] = x; ++Count; }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public T PopFront() { if (Count-- == 0) throw new Exception(); var r = b[o++]; if (o >= c) o -= c; return r; }\n public T Front => b[o];\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public void PushBack(T x) { if (Count == c) e(); var i = o + Count++; b[i >= c ? i - c : i] = x; }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public T PopBack() { if (Count == 0) throw new Exception(); return b[gi(--Count)]; }\n public T Back => b[gi(Count - 1)];\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n void e() { T[] nb = new T[c << 1]; if (o > c - Count) { var l = b.Length - o; Array.Copy(b, o, nb, 0, l); Array.Copy(b, 0, nb, l, Count - l); } else Array.Copy(b, o, nb, 0, Count); b = nb; o = 0; c <<= 1; }\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "greedy", "combinatorics"], "code_uid": "f0a8330672364e5d73feba88f9488a55", "src_uid": "8b2a9ae21740c89079a6011a30cd6aee", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "C# 8", "source_code": "\ufeff\ufeffusing System;\r\nusing System.Collections.Generic;\r\nusing System.Linq;\r\nusing System.Numerics;\r\n\r\nnamespace CodeForces\r\n{\r\n class Program\r\n {\r\n static void Main(string[] args)\r\n {\r\n var arr = Console.ReadLine().Split(' ');\r\n var p0 = Int32.Parse(arr[0]);\r\n var t0 = long.Parse(arr[1]);\r\n arr = Console.ReadLine().Split(' ');\r\n var p1 = Int32.Parse(arr[0]);\r\n var t1 = long.Parse(arr[1]);\r\n arr = Console.ReadLine().Split(' ');\r\n var h = Int32.Parse(arr[0]);\r\n var s = Int32.Parse(arr[1]);\r\n Console.WriteLine(GetMinCost(t0, t1, p0, p1, s, h));\r\n\r\n // Test();\r\n\r\n // BruteGetMaxVal(\"110000\");\r\n }\r\n\r\n private static long GetMinCost(long t0, long t1, int p0, int p1, int s, int h)\r\n {\r\n var bags = new List<(int,long)>\r\n {\r\n (p0-s,t0),\r\n (p1-s,t1)\r\n }; \r\n var allCost0 = (h/(p0-s) + 1) * t0;\r\n var allCost1 = (h/(p1-s) + 1) * t1;\r\n var maxCost = allCost0<=allCost1?allCost0:allCost1;\r\n var damage = 0;\r\n var t0Count = 1;\r\n while(damage < h && t0 * t0Count < maxCost)\r\n {\r\n if (t0 * t0Count >= t1)\r\n {\r\n damage = (t0Count-1) * (p0 - s) +\r\n (int)(t0 * t0Count / t1 - 1) * (p1 - s) + \r\n (p0 + p1 -s);\r\n bags.Add((damage, t0 * t0Count));\r\n }\r\n else\r\n {\r\n damage = t0Count * (p0-s);\r\n }\r\n t0Count++;\r\n }\r\n\r\n damage = 0;\r\n var t1Count = 1;\r\n while (damage < h && t1 * t1Count < maxCost)\r\n {\r\n if (t1 * t1Count >= t0)\r\n {\r\n damage = (t1Count-1) * (p1 - s) +\r\n (int)(t1 * t1Count / t0 - 1) * (p0 - s) + \r\n (p0 + p1 -s);\r\n bags.Add((damage, t1 * t1Count));\r\n }\r\n else\r\n {\r\n damage = t1Count * (p1-s);\r\n }\r\n t1Count++;\r\n }\r\n return GetMinCost(h, bags);\r\n }\r\n\r\n private static long GetMinCost(int h, List<(int, long)> bags)\r\n {\r\n var newBags = new List<(int, long)>();\r\n foreach(var (damage, cost) in bags)\r\n {\r\n var newDamage = damage;\r\n var newCost = cost;\r\n while(newDamage < h + damage)\r\n {\r\n newBags.Add((newDamage, newCost));\r\n newDamage<<=1;\r\n newCost<<=1;\r\n }\r\n }\r\n return Get01MinCost(h, newBags);\r\n }\r\n\r\n private static long Get01MinCost(int h, List<(int, long)> bags)\r\n {\r\n var n = bags.Count;\r\n var dp = new long[h+1];\r\n for(var i = 1;i<=h;i++)\r\n {\r\n dp[i] = long.MaxValue;\r\n }\r\n foreach(var (damage, cost) in bags)\r\n {\r\n var jBegin = h - damage;\r\n if (jBegin < 0) jBegin = 0;\r\n for(var j = jBegin;j<=h;j++)\r\n {\r\n if (dp[j] != long.MaxValue && dp[j] + cost < dp[h])\r\n {\r\n dp[h] = dp[j] + cost;\r\n }\r\n }\r\n for(var j= h - damage-1;j>=0;j--)\r\n {\r\n if (dp[j] != long.MaxValue && dp[j] + cost < dp[j+ damage])\r\n {\r\n dp[j+ damage] = dp[j] + cost;\r\n }\r\n }\r\n\r\n \r\n }\r\n return dp[h];\r\n }\r\n \r\n }\r\n}", "lang_cluster": "C#", "tags": ["dp", "binary search"], "code_uid": "c40924bb35298b3945b47a54d5148223", "src_uid": "ca9d48e48e69b931236907a9ac262433", "difficulty": 2400.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Text;\n\nnamespace Contest3\n{\n class Program\n {\n static void Main(string[] args)\n {\n var temp = Console.ReadLine().Split(' ');\n long n = long.Parse(temp[0]);\n long a = long.Parse(temp[1]);\n long b = long.Parse(temp[2]);\n long c = long.Parse(temp[3]);\n long l = 0;\n n *= 2;\n for (long i = 0; i <= c; i++)\n for (long j = 0; j <= b; j++)\n {\n long k = n - i * 4 - 2 * j;\n\n if ((k >= 0) && (k <= a))\n l++;\n }\n Console.WriteLine(l);\n\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "c6f267fda8ade57f618131c3c626fc9e", "src_uid": "474e527d41040446a18186596e8bdd83", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.IO;\nusing System.Text;\n\nnamespace Cola\n{\n internal class Program\n {\n private static readonly StreamReader reader = new StreamReader(Console.OpenStandardInput(1024*10), Encoding.ASCII, false, 1024*10);\n private static readonly StreamWriter writer = new StreamWriter(Console.OpenStandardOutput(1024*10), Encoding.ASCII, 1024*10);\n\n private static void Main(string[] args)\n {\n int n = Next(), a = Next(), b = Next(), c = Next();\n\n int count = 0;\n for (int aa = 0; aa <= a; aa += 2)\n {\n for (int cc = 0; cc <= c; cc++)\n {\n int bb = n - aa/2 - 2*cc;\n if (bb >= 0 && bb <= b)\n count++;\n }\n }\n\n writer.WriteLine(count);\n writer.Flush();\n }\n\n private static int Next()\n {\n int c;\n int res = 0;\n do\n {\n c = reader.Read();\n if (c == -1)\n return res;\n } while (c < '0' || c > '9');\n res = c - '0';\n while (true)\n {\n c = reader.Read();\n if (c < '0' || c > '9')\n return res;\n res *= 10;\n res += c - '0';\n }\n }\n }\n}", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "716394bf521c334652f3d315640b632a", "src_uid": "474e527d41040446a18186596e8bdd83", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.IO;\nusing System.Linq;\nusing System.Text;\nusing System.Collections.Generic;\nusing System.Diagnostics;\nusing System.Numerics;\nusing Enu = System.Linq.Enumerable;\n\nclass Program\n{\n static readonly int Mod = (int)1e9 + 7;\n\n public void Solve()\n {\n int N = Reader.Int();\n int K = Reader.Int();\n long[] Y = new long[K + 2];\n\n for (int i = 1; i < Y.Length; i++)\n Y[i] = (Y[i - 1] + ModPower(i, K, Mod)) % Mod;\n\n long ans = new LagrangeInterpolation(Y, Mod).Get(N);\n Console.WriteLine(ans);\n Console.ReadLine();\n }\n\n class LagrangeInterpolation\n {\n readonly int N;\n readonly long M;\n readonly long[] Y, C;\n\n public LagrangeInterpolation(long[] Y, long mod)\n {\n this.N = Y.Length - 1;\n this.M = mod;\n this.Y = Y;\n this.C = new long[N + 1];\n long q = 1;\n for (int i = 1; i <= N; i++)\n q = q * Mod(-i) % mod;\n C[0] = Mod(Y[0] * ModInverse(q, mod));\n for (int i = 1; i <= N; i++)\n {\n q = Mod(q * ModInverse(-N + (i - 1), mod));\n q = Mod(q * i);\n C[i] = Mod(Y[i] * ModInverse(q, mod));\n }\n }\n\n public long Get(long x)\n {\n if (x <= N) return Y[x];\n long fraq = 1;\n for (int i = 0; i <= N; i++)\n fraq = Mod(fraq * (x - i));\n long res = 0;\n for (int i = 0; i <= N; i++)\n {\n res += Mod(Mod(C[i] * fraq) * ModInverse(x - i, M));\n if (res >= M) res -= M;\n }\n return res;\n }\n\n long Mod(long x)\n {\n if (x >= M) return x % M;\n else if (x < 0) return (x % M + M);\n else return x;\n }\n }\n\n static long ModPower(long x, long n, long mod) // x ^ n\n {\n long res = 1;\n while (n > 0)\n {\n if ((n & 1) == 1) res = (res * x) % mod;\n x = (x * x) % mod;\n n >>= 1;\n }\n return res;\n }\n static long ModInverse(long N, long mod)\n {\n long x = 0, y = 0;\n N = (N % mod + mod) % mod;\n ExtGCD(N, mod, ref x, ref y);\n return (x % mod + mod) % mod;\n }\n static long ExtGCD(long a, long b, ref long x, ref long y)\n {\n if (b == 0) { x = 1; y = 0; return a; }\n long res = ExtGCD(b, a % b, ref y, ref x);\n y -= (a / b) * x;\n return res;\n }\n}\n\n\nclass Entry { static void Main() { new Program().Solve(); } }\nclass Reader\n{\n private static TextReader reader = Console.In;\n private static readonly char[] separator = { ' ' };\n private static readonly StringSplitOptions op = StringSplitOptions.RemoveEmptyEntries;\n private static string[] A = new string[0];\n private static int i;\n private static void Init() { A = new string[0]; }\n public static void Set(TextReader r) { reader = r; Init(); }\n public static void Set(string file) { reader = new StreamReader(file); Init(); }\n public static bool HasNext() { return CheckNext(); }\n public static string String() { return Next(); }\n public static int Int() { return int.Parse(Next()); }\n public static long Long() { return long.Parse(Next()); }\n public static double Double() { return double.Parse(Next()); }\n public static int[] IntLine() { return Array.ConvertAll(Split(Line()), int.Parse); }\n public static int[] IntArray(int N) { return Enu.Range(0, N).Select(i => Int()).ToArray(); }\n public static int[][] IntTable(int H) { return Enu.Range(0, H).Select(i => IntLine()).ToArray(); }\n public static string[] StringArray(int N) { return Enu.Range(0, N).Select(i => Next()).ToArray(); }\n public static string Line() { return reader.ReadLine().Trim(); }\n private static string[] Split(string s) { return s.Split(separator, op); }\n private static string Next() { CheckNext(); return A[i++]; }\n private static bool CheckNext()\n {\n if (i < A.Length) return true;\n string line = reader.ReadLine();\n if (line == null) return false;\n if (line == \"\") return CheckNext();\n A = Split(line);\n i = 0;\n return true;\n }\n}\n", "lang_cluster": "C#", "tags": ["math"], "code_uid": "4a71d26322128348cc734e4d8fe22273", "src_uid": "6f6fc42a367cdce60d76fd1914e73f0c", "difficulty": 2600.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "#region Usings\nusing System;\nusing System.Collections;\nusing System.Collections.Generic;\nusing System.Diagnostics;\nusing System.IO;\nusing System.Linq;\nusing System.Reflection;\nusing System.Runtime.CompilerServices;\nusing System.Text;\nusing System.Threading;\nusing static System.Array;\nusing static System.Math;\n\n// ReSharper disable InconsistentNaming\n#pragma warning disable CS0675\n#endregion\n\npartial class Solution\n{\n\t#region Variables\n\tconst int MOD = 1000000007;\n\tconst int FactCache = 1000;\n\tconst long BIG = long.MaxValue >> 15;\n\n\t#endregion\n\n\tpublic static void Main()\n\t{\n\t\tvar input = new StreamReader(Console.OpenStandardInput());\n\t\tvar output = new StreamWriter(Console.OpenStandardOutput());\n\n\t\tlong[] array = ConvertAll(input.ReadLine().Split(), long.Parse);\n\t\tlong n = array[0];\n\t\tlong k = array[1];\n\n\t\tvar y = new List();\n\t\tlong sum = 0;\n\t\ty.Add(sum);\n\t\tfor (int i = 0; i <= k; i++)\n\t\t{\n\t\t\tsum = (sum + ModPow(i + 1, k));\n\t\t\tif (sum >= MOD) sum -= MOD;\n\t\t\ty.Add(sum);\n\t\t}\n\n\t\tif (n < y.Count)\n\t\t\toutput.WriteLine(y[(int)n]);\n\t\telse\n\t\t\toutput.WriteLine(Lagrange(y, n));\n\t\toutput.Flush();\n\t}\n\n\tstatic long Lagrange(List y, long x)\n\t{\n\t\tlong ans = 0;\n\t\tlong k = 1;\n\t\tfor (int j = 1; j < y.Count; j++)\n\t\t{\n\t\t\tk = (k * (x - j)) % MOD;\n\t\t\tk = MOD - Div(k, j);\n\t\t}\n\n\t\tfor (int i = 0; i < y.Count; i++)\n\t\t{\n\t\t\tans = (ans + y[i] * k) % MOD;\n\t\t\tif (i + 1 >= y.Count) break;\n\t\t\tk = k * Div(x - i, x - (i + 1)) % MOD * Div(i - y.Count + 1, i + 1) % MOD;\n\t\t}\n\n\t\treturn Fix(ans);\n\t}\n\n\n\t#region Library\n\t#region Mod Math\n\n\tstatic int[] _inverse;\n\tstatic long Inverse(long n)\n\t{\n\t\tlong result;\n\n\t\tif (_inverse == null)\n\t\t\t_inverse = new int[1000];\n\n\t\tif (n >= 0 && n < _inverse.Length && (result = _inverse[n]) != 0)\n\t\t\treturn result - 1;\n\n\t\tresult = InverseDirect((int)n);\n\t\tif (n >= 0 && n < _inverse.Length)\n\t\t\t_inverse[n] = (int)(result + 1);\n\t\treturn result;\n\t}\n\n\tpublic static int InverseDirect(int a)\n\t{\n\t\tif (a < 0) return -InverseDirect(-a);\n\t\tint t = 0, r = MOD, t2 = 1, r2 = a;\n\t\twhile (r2 != 0)\n\t\t{\n\t\t\tvar q = r / r2;\n\t\t\tt -= q * t2;\n\t\t\tr -= q * r2;\n\n\t\t\tif (r != 0)\n\t\t\t{\n\t\t\t\tq = r2 / r;\n\t\t\t\tt2 -= q * t;\n\t\t\t\tr2 -= q * r;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tr = r2;\n\t\t\t\tt = t2;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\treturn r <= 1 ? (t >= 0 ? t : t + MOD) : -1;\n\t}\n\n\tstatic long Mult(long left, long right) =>\n\t\t(left * right) % MOD;\n\n\tstatic long Div(long left, long divisor) =>\n\t\tleft * Inverse(divisor) % MOD;\n\n\tstatic long Add(long x, long y) =>\n\t\t(x += y) >= MOD ? x - MOD : x;\n\n\tstatic long Subtract(long x, long y) => (x -= y) < 0 ? x + MOD : x;\n\n\tstatic long Fix(long n) => (n %= MOD) >= 0 ? n : n + MOD;\n\n\tstatic long ModPow(long n, long p, long mod = MOD)\n\t{\n\t\tlong b = n;\n\t\tlong result = 1;\n\t\twhile (p != 0)\n\t\t{\n\t\t\tif ((p & 1) != 0)\n\t\t\t\tresult = (result * b) % mod;\n\t\t\tp >>= 1;\n\t\t\tb = (b * b) % mod;\n\t\t}\n\t\treturn result;\n\t}\n\n\tstatic List _fact;\n\n\tstatic long Fact(int n)\n\t{\n\t\tif (_fact == null) _fact = new List(FactCache) { 1 };\n\t\tfor (int i = _fact.Count; i <= n; i++)\n\t\t\t_fact.Add(Mult(_fact[i - 1], i));\n\t\treturn _fact[n];\n\t}\n\n\tstatic long[] _ifact = new long[0];\n\tstatic long InverseFact(int n)\n\t{\n\t\tlong result;\n\t\tif (n < _ifact.Length && (result = _ifact[n]) != 0)\n\t\t\treturn result;\n\n\t\tvar inv = Inverse(Fact(n));\n\t\tif (n >= _ifact.Length) Resize(ref _ifact, _fact.Capacity);\n\t\t_ifact[n] = inv;\n\t\treturn inv;\n\t}\n\n\tstatic long Fact(int n, int m)\n\t{\n\t\tvar fact = Fact(n);\n\t\tif (m < n) fact = fact * InverseFact(n - m) % MOD;\n\t\treturn fact;\n\t}\n\n\tstatic long Comb(int n, int k)\n\t{\n\t\tif (k <= 1) return k == 1 ? n : k == 0 ? 1 : 0;\n\t\treturn Mult(Mult(Fact(n), InverseFact(k)), InverseFact(n - k));\n\t}\n\n\tpublic static long Combinations(long n, int k)\n\t{\n\t\tif (k <= 0) return k == 0 ? 1 : 0; // Note: n<0 -> 0 unless k=0\n\t\tif (k + k > n) return Combinations(n, (int)(n - k));\n\n\t\tvar result = InverseFact(k);\n\t\tfor (long i = n - k + 1; i <= n; i++) result = result * i % MOD;\n\t\treturn result;\n\t}\n\t#endregion\n\n\t#region Common\n\n\tpublic static int Gcd(int n, int m)\n\t{\n\t\twhile (true)\n\t\t{\n\t\t\tif (m == 0) return n >= 0 ? n : -n;\n\t\t\tn %= m;\n\t\t\tif (n == 0) return m >= 0 ? m : -m;\n\t\t\tm %= n;\n\t\t}\n\t}\n\n\t#endregion\n\n\t#region Main\n\n\t#endregion\n\t#endregion\n}\n", "lang_cluster": "C#", "tags": ["math"], "code_uid": "8094293f94e9c107ceb3e7cefa771dc0", "src_uid": "6f6fc42a367cdce60d76fd1914e73f0c", "difficulty": 2600.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System.Collections.Generic;\nusing System.Linq;\nusing System;\n\n\n\npublic class Solution\n{\n public static void Main()\n {\n\n int[] A = Array.ConvertAll(Console.ReadLine().Split(' '), m => Convert.ToInt32(m));\n int W = A[0], H = A[1];\n int[] B = Array.ConvertAll(Console.ReadLine().Split(' '), m => Convert.ToInt32(m));\n int w1 = B[0], h1 = B[1];\n int[] C = Array.ConvertAll(Console.ReadLine().Split(' '), m => Convert.ToInt32(m));\n int w2 = C[0], h2 = C[1];\n\n while(H > 0)\n {\n W += H;\n\n if (H == h1)\n W -= w1;\n\n if (H == h2)\n W -= w2;\n\n if (W < 0)\n W = 0;\n\n H--;\n }\n\n Console.WriteLine(W);\n\n \n \n\n\n \n\n\n\n\n }\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "575bb9ad35db44b49db0a879f6011cb1", "src_uid": "084a12eb3a708b43b880734f3ee51374", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace codeforce\n{\n class Program\n {\n static void Main(string[] args)\n {\n string temp = Console.ReadLine();\n string[] splitted = temp.Split(' ');\n int w = Convert.ToInt32(splitted[0]);\n int h = Convert.ToInt32(splitted[1]);\n temp = Console.ReadLine();\n splitted = temp.Split(' ');\n int u1 = Convert.ToInt32(splitted[0]);\n int d1 = Convert.ToInt32(splitted[1]);\n temp = Console.ReadLine();\n splitted = temp.Split(' ');\n int u2 = Convert.ToInt32(splitted[0]);\n int d2 = Convert.ToInt32(splitted[1]);\n\n for (int i = h; i > 0; i--)\n {\n w += i;\n if (i == d1)\n {\n w -= u1;\n if (w < 0) w = 0;\n }\n if (i == d2)\n {\n w -= u2;\n if (w < 0) w = 0;\n }\n }\n Console.WriteLine(w);\n }\n }\n}", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "0cc25c8a8b1b7098d8ca9857237ce2ad", "src_uid": "084a12eb3a708b43b880734f3ee51374", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Text;\nusing System.Collections;\nusing System.Collections.Generic;\nusing System.IO;\n\n\nclass Program\n{\n long[, , , ,] dp;\n void solve()\n {\n int n = nextInt();\n int t = nextInt();\n dp = new long[5, 5, n, t+1,t];\n for (int i = 0; i < 5; i++)\n for (int j = 0; j < 5; j++)\n for (int k = 0; k < n; k++)\n for (int r = 0; r <= t; r++)\n for (int s = 0; s < t; s++)\n dp[i, j, k, r, s] = -1;\n long ret = 0;\n for(int y1=1;y1<=4;y1++)\n for (int y2 = y1; y2 <= 4; y2++)\n {\n if (y1 == y2)\n continue;\n int a = t;\n int b = t - 1;\n ret += go(y1, y2, n - 2, a, b);\n }\n Console.WriteLine(ret);\n }\n\n private long go(int y1, int y2, int rem, int a, int b)\n {\n if (a < 0 || b < 0)\n return 0;\n if (rem == 0)\n {\n if (a == 0 && b == 0)\n return 1;\n else\n return 0;\n }\n if (dp[y1, y2, rem, a, b] != -1)\n return dp[y1, y2, rem, a, b];\n long ret = 0;\n for (int y3 = 1; y3 <= 4; y3++)\n {\n if (y3 == y2)\n continue;\n if (y2 > y1 && y2 > y3)\n {\n ret += go(y2, y3, rem - 1, a - 1, b);\n }\n else if (y2 < y1 && y2 < y3)\n ret += go(y2, y3, rem - 1, a, b - 1);\n else\n ret += go(y2, y3, rem - 1, a, b);\n }\n return dp[y1, y2, rem, a, b]=ret;\n }\n //\n\n\n\n\n\n string[] inputLine = new string[0];\n int inputInd = 0;\n string nextLine()\n {\n return Console.ReadLine();\n }\n void readInput()\n {\n if (inputInd != inputLine.Length)\n throw new Exception();\n inputInd = 0;\n inputLine = Console.ReadLine().Split();\n\n }\n int nextInt()\n {\n if (inputInd == inputLine.Length)\n readInput();\n return int.Parse(inputLine[inputInd++]);\n }\n long nextLong()\n {\n if (inputInd == inputLine.Length)\n readInput();\n return long.Parse(inputLine[inputInd++]);\n }\n double nextDouble()\n {\n if (inputInd == inputLine.Length)\n readInput();\n return double.Parse(inputLine[inputInd++]);\n }\n string nextString()\n {\n if (inputInd == inputLine.Length)\n readInput();\n return inputLine[inputInd++];\n }\n static void Main(string[] args)\n {\n new Program().solve();\n }\n}\n\n", "lang_cluster": "C#", "tags": ["dp"], "code_uid": "8df2f41652e883664a77bf840ed2542d", "src_uid": "6d67559744583229455c5eafe68f7952", "difficulty": 1900.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Globalization;\nusing System.IO;\nusing System.Linq;\nusing System.Text;\nusing System.Threading;\n\n// (\u3065\u00b0\u03c9\u00b0)\u3065\uff90e\u2605\u309c\u30fb\u3002\u3002\u30fb\u309c\u309c\u30fb\u3002\u3002\u30fb\u309c\u2606\u309c\u30fb\u3002\u3002\u30fb\u309c\u309c\u30fb\u3002\u3002\u30fb\u309c\npublic class Solver\n{\n public void Solve()\n {\n int n = ReadInt();\n int m = ReadInt();\n\n var dp = new long[m + 1, m, 4, 4];\n dp[0, 0, 0, 0] = 1;\n for (int i = 0; i < n; i++)\n {\n var ndp = new long[m + 1, m, 4, 4];\n for (int t = 0; t <= m; t++)\n for (int v = 0; v < m; v++)\n for (int pp = 0; pp < 4; pp++)\n for (int p = 0; p < 4; p++)\n for (int d = 0; d < 4; d++)\n if (i == 0 || d != p)\n {\n int nt = t;\n if (i > 1 && pp < p && p > d)\n nt++;\n int nv = v;\n if (i > 1 && pp > p && p < d)\n nv++;\n if (nt <= m && nv < m)\n ndp[nt, nv, p, d] += dp[t, v, pp, p];\n }\n dp = ndp;\n }\n\n long ans = 0;\n for (int i = 0; i < 4; i++)\n for (int j = 0; j < 4; j++)\n ans += dp[m, m - 1, i, j];\n Write(ans);\n }\n\n #region Main\n\n protected static TextReader reader;\n protected static TextWriter writer;\n static void Main()\n {\n#if DEBUG\n reader = new StreamReader(\"..\\\\..\\\\input.txt\");\n //reader = new StreamReader(Console.OpenStandardInput());\n writer = Console.Out;\n //writer = new StreamWriter(\"..\\\\..\\\\output.txt\");\n#else\n reader = new StreamReader(Console.OpenStandardInput());\n writer = new StreamWriter(Console.OpenStandardOutput());\n //reader = new StreamReader(\"input.txt\");\n //writer = new StreamWriter(\"output.txt\");\n#endif\n try\n {\n new Solver().Solve();\n //var thread = new Thread(new Solver().Solve, 1024 * 1024 * 128);\n //thread.Start();\n //thread.Join();\n }\n catch (Exception ex)\n {\n Console.WriteLine(ex);\n#if DEBUG\n#else\n throw;\n#endif\n }\n reader.Close();\n writer.Close();\n }\n\n #endregion\n\n #region Read / Write\n private static Queue currentLineTokens = new Queue();\n private static string[] ReadAndSplitLine() { return reader.ReadLine().Split(new[] { ' ', '\\t', }, StringSplitOptions.RemoveEmptyEntries); }\n public static string ReadToken() { while (currentLineTokens.Count == 0)currentLineTokens = new Queue(ReadAndSplitLine()); return currentLineTokens.Dequeue(); }\n public static int ReadInt() { return int.Parse(ReadToken()); }\n public static long ReadLong() { return long.Parse(ReadToken()); }\n public static double ReadDouble() { return double.Parse(ReadToken(), CultureInfo.InvariantCulture); }\n public static int[] ReadIntArray() { return ReadAndSplitLine().Select(int.Parse).ToArray(); }\n public static long[] ReadLongArray() { return ReadAndSplitLine().Select(long.Parse).ToArray(); }\n public static double[] ReadDoubleArray() { return ReadAndSplitLine().Select(s => double.Parse(s, CultureInfo.InvariantCulture)).ToArray(); }\n public static int[][] ReadIntMatrix(int numberOfRows) { int[][] matrix = new int[numberOfRows][]; for (int i = 0; i < numberOfRows; i++)matrix[i] = ReadIntArray(); return matrix; }\n public static int[][] ReadAndTransposeIntMatrix(int numberOfRows)\n {\n int[][] matrix = ReadIntMatrix(numberOfRows); int[][] ret = new int[matrix[0].Length][];\n for (int i = 0; i < ret.Length; i++) { ret[i] = new int[numberOfRows]; for (int j = 0; j < numberOfRows; j++)ret[i][j] = matrix[j][i]; } return ret;\n }\n public static string[] ReadLines(int quantity) { string[] lines = new string[quantity]; for (int i = 0; i < quantity; i++)lines[i] = reader.ReadLine().Trim(); return lines; }\n public static void WriteArray(IEnumerable array) { writer.WriteLine(string.Join(\" \", array)); }\n public static void Write(params object[] array) { WriteArray(array); }\n public static void WriteLines(IEnumerable array) { foreach (var a in array)writer.WriteLine(a); }\n private class SDictionary : Dictionary\n {\n public new TValue this[TKey key]\n {\n get { return ContainsKey(key) ? base[key] : default(TValue); }\n set { base[key] = value; }\n }\n }\n private static T[] Init(int size) where T : new() { var ret = new T[size]; for (int i = 0; i < size; i++)ret[i] = new T(); return ret; }\n #endregion\n}", "lang_cluster": "C#", "tags": ["dp"], "code_uid": "c052d782957061808c92511aded1a089", "src_uid": "6d67559744583229455c5eafe68f7952", "difficulty": 1900.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\n\nnamespace CodeForces\n{\n class Program\n {\n static void Main(string[] args)\n {\n string answer = \"Yes\";\n string[] num = Console.ReadLine().Split(' ');\n int a = int.Parse(num[0]);\n int b = int.Parse(num[1]);\n int c = int.Parse(num[2]);\n num = Console.ReadLine().Split(' ');\n int x = int.Parse(num[0]);\n int y = int.Parse(num[1]);\n int z = int.Parse(num[2]);\n if (a + b + c < x + y + z)\n answer = \"No\";\n else\n {\n while (a < x)\n {\n if ((b - y) >= 2)\n {\n b -= 2;\n a++;\n }\n else\n {\n if ((c - z) >= 2)\n {\n c -= 2;\n a++;\n }\n else\n {\n answer = \"No\";\n break;\n }\n }\n }\n if (answer != \"No\")\n {\n while (b < y)\n {\n if ((a - x) >= 2)\n {\n a -= 2;\n b++;\n }\n else\n {\n if ((c - z) >= 2)\n {\n c -= 2;\n b++;\n }\n else\n {\n answer = \"No\";\n break;\n }\n }\n }\n }\n if (answer != \"No\")\n {\n while (c < z)\n {\n if ((a - x) >= 2)\n {\n a -= 2;\n c++;\n }\n else\n {\n if ((b - y) >= 2)\n {\n b -= 2;\n c++;\n }\n else { answer = \"No\"; break; }\n }\n }\n\n }\n }\n Console.WriteLine(answer);\n }\n }\n}", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "af4415da7faf90a73daf4937b01b454d", "src_uid": "1db4ba9dc1000e26532bb73336cf12c3", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "/*\n * Created by SharpDevelop.\n * Date: 21.12.2015\n * Time: 12:49\n * \n */\n\nusing System;\n\nnamespace Shape\n{\n class Program\n {\n\n static void Main(string[] args)\n {\n \tstring ss = Console.ReadLine ();\n \tstring [] s = ss.Split (' ');\n \tint a = int.Parse (s [0]);\n \tint b = int.Parse (s [1]);\n \tint c = int.Parse (s [2]);\n\n \tss = Console.ReadLine ();\n \tstring [] t = ss.Split (' ');\n \tint x = int.Parse (t [0]);\n \tint y = int.Parse (t [1]);\n \tint z = int.Parse (t [2]);\n\n \tint kp=0, km=0;\n \tif ( a > x )\n \t\tkp += (a - x)/2;\n \telse\n \t\tkm += x - a;\n \tif ( b > y )\n \t\tkp += (b - y)/2;\n \telse\n \t\tkm += y - b;\n \tif ( c > z )\n \t\tkp += (c - z)/2;\n \telse\n \t\tkm += z - c;\n\n \tif ( kp >= km )\n \t\tConsole.WriteLine (\"Yes\");\n \telse\n \t\tConsole.WriteLine (\"No\");\n\n // Console.ReadKey ();\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "932eaad5edd496e0d914d6575e835dbe", "src_uid": "1db4ba9dc1000e26532bb73336cf12c3", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Diagnostics;\nusing System.Globalization;\nusing System.IO;\nusing System.Linq;\nusing System.Text;\nusing System.Threading;\n\nnamespace ReadWriteTemplate\n{\n public static class Solver\n {\n private static void SolveCase()\n {\n var s = ReadLine();\n int n = s.Length;\n for (int i = n; i >= 0; i--)\n {\n bool isPal = true;\n for (int j = 0; j < i; j++)\n {\n if (s[j] != s[i - j - 1])\n {\n isPal = false;\n break;\n }\n }\n if (!isPal)\n {\n Writer.WriteLine(i);\n return;\n }\n }\n Writer.WriteLine(0);\n }\n\n public static void Solve()\n {\n SolveCase();\n\n /*var sw = Stopwatch.StartNew();*/\n\n /*int T = ReadInt();\n for (int i = 0; i < T; i++)\n {\n Writer.Write(\"Case #{0}: \", i + 1);\n SolveCase();\n }*/\n\n /*sw.Stop();\n Console.WriteLine(sw.ElapsedMilliseconds);*/\n }\n\n public static void Main()\n {\n Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;\n\n#if DEBUG\n //Reader = Console.In; Writer = Console.Out;\n Reader = File.OpenText(\"input.txt\"); Writer = File.CreateText(\"output.txt\");\n#else\n Reader = Console.In; Writer = Console.Out;\n#endif\n\n Solve();\n /*Thread thread = new Thread(Solve, 64 * 1024 * 1024);\n thread.CurrentCulture = CultureInfo.InvariantCulture;\n thread.Start();\n thread.Join();*/\n\n Reader.Close();\n Writer.Close();\n }\n\n public static IOrderedEnumerable OrderByWithShuffle(this IEnumerable source, Func keySelector)\n {\n return source.Shuffle().OrderBy(keySelector);\n }\n\n public static T[] Shuffle(this IEnumerable source)\n {\n T[] result = source.ToArray();\n Random rnd = new Random();\n for (int i = result.Length - 1; i >= 1; i--)\n {\n int k = rnd.Next(i + 1);\n T tmp = result[k];\n result[k] = result[i];\n result[i] = tmp;\n }\n return result;\n }\n\n #region Read/Write\n\n private static TextReader Reader;\n\n private static TextWriter Writer;\n\n private static Queue CurrentLineTokens = new Queue();\n\n private static string[] ReadAndSplitLine()\n {\n return Reader.ReadLine().Split(new[] { ' ', '\\t' }, StringSplitOptions.RemoveEmptyEntries);\n }\n\n public static string ReadToken()\n {\n while (CurrentLineTokens.Count == 0)\n CurrentLineTokens = new Queue(ReadAndSplitLine());\n return CurrentLineTokens.Dequeue();\n }\n\n public static string ReadLine()\n {\n return Reader.ReadLine();\n }\n\n public static int ReadInt()\n {\n return int.Parse(ReadToken());\n }\n\n public static long ReadLong()\n {\n return long.Parse(ReadToken());\n }\n\n public static double ReadDouble()\n {\n return double.Parse(ReadToken(), CultureInfo.InvariantCulture);\n }\n\n public static int[] ReadIntArray()\n {\n return ReadAndSplitLine().Select(int.Parse).ToArray();\n }\n\n public static long[] ReadLongArray()\n {\n return ReadAndSplitLine().Select(long.Parse).ToArray();\n }\n\n public static double[] ReadDoubleArray()\n {\n return ReadAndSplitLine().Select(s => double.Parse(s, CultureInfo.InvariantCulture)).ToArray();\n }\n\n public static int[][] ReadIntMatrix(int numberOfRows)\n {\n int[][] matrix = new int[numberOfRows][];\n for (int i = 0; i < numberOfRows; i++)\n matrix[i] = ReadIntArray();\n return matrix;\n }\n\n public static string[] ReadLines(int quantity)\n {\n string[] lines = new string[quantity];\n for (int i = 0; i < quantity; i++)\n lines[i] = Reader.ReadLine().Trim();\n return lines;\n }\n\n public static void WriteArray(IEnumerable array)\n {\n Writer.WriteLine(string.Join(\" \", array));\n }\n\n #endregion\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "strings", "implementation"], "code_uid": "272a1a449c937173ae9eac21e3b6ff2d", "src_uid": "6c85175d334f811617e7030e0403f706", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nnamespace SolutionsForCodeforces\n{\n class Program\n {\n static void Main(string[] args)\n {\n string MyString = Console.ReadLine();\n if (!IsPalindrom(MyString))\n {\n Console.WriteLine(MyString.Length);\n return;\n }\n else\n {\n MyString = MyString.Remove(0, 1);\n if (!IsPalindrom(MyString))\n {\n Console.WriteLine(MyString.Length);\n return;\n }\n else Console.WriteLine(\"0\");\n }\n }\n static bool IsPalindrom(string s)\n {\n var Array = s.ToCharArray();\n var ReversedArray = (char[])Array.Clone();\n System.Array.Reverse(ReversedArray);\n bool IsGood = true;\n for (int i = 0; i < Array.Length; i++)\n {\n if (Array[i] != ReversedArray[i])\n {\n IsGood = false;\n }\n }\n return IsGood;\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "strings", "implementation"], "code_uid": "4fa2edec1f4011a55942679b962bf325", "src_uid": "6c85175d334f811617e7030e0403f706", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "C# 8", "source_code": "using System;\r\nusing System.Collections.Generic;\r\nusing System.Linq;\r\n\r\nnamespace CodeForces\r\n{\r\n class Program\r\n {\r\n static void Main(string[] args)\r\n {\r\n \r\n var n = Int32.Parse(Console.ReadLine());\r\n\r\n Console.WriteLine(GetVal(n));\r\n }\r\n\r\n\r\n const int MOD_VAL = 1000000007;\r\n private static int GetVal(int n)\r\n {\r\n var primes = GetAllPrimes(n);\r\n var res = 0;\r\n var primeCache = GetPrimeCache(primes, n);\r\n var dfsSolver = new DFSSolver(primeCache);\r\n for(var i = 1;i<=n-2;i++)\r\n {\r\n var primeFactors = GetPrimeFactors(i, primes);\r\n var primeMap = new Dictionary();\r\n foreach(var (prime, primeCnt) in primeFactors)\r\n {\r\n primeMap[prime] = primeCnt;\r\n }\r\n dfsSolver.SetPrimeMap(primeMap);\r\n dfsSolver.SetPrimeFactors(GetPrimeFactors(n-i, primes));\r\n res = (int)((res + (long)dfsSolver.GetRes()*i ) % MOD_VAL);\r\n }\r\n return res;\r\n }\r\n\r\n private class DFSSolver\r\n {\r\n private int _res;\r\n private Dictionary _primeMap;\r\n private List<(int,int)> _primeFactors;\r\n\r\n private Dictionary _primeCache;\r\n public DFSSolver(Dictionary primeCache)\r\n {\r\n _primeCache = primeCache;\r\n }\r\n\r\n public void SetPrimeMap(Dictionary primeMap)\r\n {\r\n _primeMap = primeMap;\r\n }\r\n\r\n public void SetPrimeFactors(List<(int,int)> primeFactors)\r\n {\r\n _primeFactors = primeFactors; \r\n }\r\n\r\n public int GetRes()\r\n {\r\n _res = 0;\r\n DFS(0,1);\r\n var tmp = 1;\r\n foreach(var (prime, cnt) in _primeFactors)\r\n {\r\n if(_primeMap.ContainsKey(prime))\r\n {\r\n if(cnt > _primeMap[prime])\r\n {\r\n tmp*= _primeCache[prime][cnt-_primeMap[prime]];\r\n }\r\n }\r\n else\r\n {\r\n tmp*= _primeCache[prime][cnt];\r\n }\r\n }\r\n _res-=tmp;\r\n if (_res < MOD_VAL) _res+=MOD_VAL;\r\n return _res;\r\n }\r\n\r\n private void DFS(int index, int val)\r\n {\r\n if(index == _primeFactors.Count)\r\n {\r\n _res = (_res + val) % MOD_VAL;\r\n return;\r\n }\r\n var prime = _primeFactors[index].Item1;\r\n var cnt = _primeFactors[index].Item2;\r\n for(var i = 0;i<= cnt;i++)\r\n {\r\n var append = 1;\r\n if(_primeMap.ContainsKey(prime))\r\n {\r\n if(i > _primeMap[prime])\r\n {\r\n append = _primeCache[prime][i - _primeMap[prime]];\r\n }\r\n }\r\n else\r\n {\r\n append = _primeCache[prime][i];\r\n }\r\n\r\n if (i < cnt)\r\n {\r\n append = append * (prime - 1) * _primeCache[prime][cnt-i-1]; \r\n }\r\n DFS(index+1, (int)((long)val * append % MOD_VAL));\r\n }\r\n }\r\n }\r\n\r\n private static Dictionary GetPrimeCache(List primes, int n)\r\n {\r\n var primeCache = new Dictionary();\r\n foreach(var prime in primes)\r\n {\r\n var list = new List();\r\n list.Add(1);\r\n var tmp = prime;\r\n while(tmp <= n)\r\n {\r\n list.Add(tmp);\r\n tmp*=prime;\r\n }\r\n primeCache[prime] = list.ToArray();\r\n }\r\n return primeCache;\r\n }\r\n\r\n private static int GetLCM(int num0, int num1)\r\n {\r\n return (int)((long)num0 * num1 /GetGCD(num0, num1));\r\n }\r\n\r\n private static int GetGCD(int num0, int num1)\r\n {\r\n if (num0 < num1)\r\n {\r\n var tmp = num1;\r\n num1 = num0;\r\n num0 = tmp;\r\n }\r\n while (num1 > 0)\r\n {\r\n var tmp = num1;\r\n num1 = num0 % num1;\r\n num0 = tmp;\r\n }\r\n return num0;\r\n }\r\n\r\n static List GetAllPrimes(int n)\r\n {\r\n var isNotPrimes = new bool[n+1];\r\n var primes = new List();\r\n for(var i = 2;i<=n;i++)\r\n {\r\n if (!isNotPrimes[i])\r\n {\r\n primes.Add(i);\r\n var num = i * 2;\r\n while(num <= n)\r\n {\r\n isNotPrimes[num]= true;\r\n num+=i;\r\n }\r\n }\r\n }\r\n return primes;\r\n }\r\n\r\n static List<(int,int)> GetPrimeFactors(int num, List primes)\r\n {\r\n var primeFactors = new List<(int,int)>();\r\n foreach(var prime in primes)\r\n {\r\n if (num < prime * prime) break;\r\n var cnt = 0;\r\n while(num % prime == 0)\r\n {\r\n cnt++;\r\n num/=prime;\r\n }\r\n if (cnt > 0)\r\n {\r\n primeFactors.Add((prime, cnt));\r\n }\r\n }\r\n if (num!=1)\r\n {\r\n primeFactors.Add((num, 1));\r\n }\r\n return primeFactors;\r\n }\r\n\r\n static int[] GetFactors(int num, List primes)\r\n {\r\n return GetFactors(GetPrimeFactors(num, primes));\r\n }\r\n\r\n static int[] GetFactors(List<(int,int)> primeFactors)\r\n {\r\n var factorCnt = 1;\r\n foreach(var (_, cnt) in primeFactors)\r\n {\r\n factorCnt*=cnt+1;\r\n }\r\n var factors = new int[factorCnt];\r\n var preCnt = 1;\r\n var index = 1;\r\n factors[0] = 1;\r\n foreach(var (prime, cnt) in primeFactors)\r\n {\r\n var factor = prime;\r\n for(var i = 1;i<=cnt;i++)\r\n {\r\n for(var j = 0;j[] Div;\r\n\r\n int[] Sieve;\r\n\r\n int[] S;\r\n\r\n public void Solve()\r\n {\r\n\r\n\r\n var sc = new Scanner();\r\n N = sc.NextInt();\r\n Div = new List[N + 1];\r\n for (int i = 1; i <= N; i++)\r\n {\r\n Div[i] = new List();\r\n }\r\n\r\n for (int i = 1; i <= N; i++)\r\n {\r\n for (int j = i; j <= N; j += i)\r\n {\r\n Div[j].Add(i);\r\n }\r\n }\r\n\r\n S = new int[N + 1];\r\n S[1] = 0;\r\n for (int i = 2; i <= N; i++)\r\n {\r\n S[i] = i - 1;\r\n foreach (int d in Div[i])\r\n {\r\n if (i == d) continue;\r\n // Console.WriteLine($\"{S[i / d]}\");\r\n S[i] -= S[d];\r\n }\r\n }\r\n\r\n //for (int i = 1; i < 20; i++)\r\n //{\r\n // Console.WriteLine($\"{i} {F2(i)} {S[i]}\");\r\n //}\r\n\r\n ModInt ans = 0;\r\n for (int c = 1; c + 2 <= N; c++)\r\n {\r\n int sumAB = N - c;\r\n foreach (int gcdAB in Div[sumAB])\r\n {\r\n int d = sumAB / gcdAB;\r\n\r\n // a + b = d\r\n // gcd(a,b) = 1\r\n\r\n\r\n ans += S[d] * MathEx.LCM(c, gcdAB);\r\n }\r\n }\r\n\r\n Console.WriteLine(ans);\r\n\r\n\r\n }\r\n ModInt F2(int n)\r\n {\r\n int cnt = 0;\r\n for (int a = 1; a + 1 <= n; a++)\r\n {\r\n cnt += MathEx.GCD(a, n - a) == 1 ? 1 : 0;\r\n }\r\n return cnt;\r\n }\r\n\r\n public static void Main(string[] args) => new Program().Solve();\r\n // public static void Main(string[] args) => new Thread(new Program().Solve, 1 << 27).Start();\r\n}\r\n\r\n// https://bitbucket.org/camypaper/complib\r\nnamespace CompLib.Mathematics\r\n{\r\n using System;\r\n using System.Collections.Generic;\r\n #region GCD LCM\r\n /// \r\n /// \u69d8\u3005\u306a\u6570\u5b66\u7684\u95a2\u6570\u306e\u9759\u7684\u30e1\u30bd\u30c3\u30c9\u3092\u63d0\u4f9b\u3057\u307e\u3059\uff0e\r\n /// \r\n public static partial class MathEx\r\n {\r\n /// \r\n /// 2 \u3064\u306e\u6574\u6570\u306e\u6700\u5927\u516c\u7d04\u6570\u3092\u6c42\u3081\u307e\u3059\uff0e\r\n /// \r\n /// \u6700\u521d\u306e\u5024\r\n /// 2 \u756a\u76ee\u306e\u5024\r\n /// 2 \u3064\u306e\u6574\u6570\u306e\u6700\u5927\u516c\u7d04\u6570\r\n /// \u30e6\u30fc\u30af\u30ea\u30c3\u30c9\u306e\u4e92\u9664\u6cd5\u306b\u57fa\u3065\u304d\u6700\u60aa\u8a08\u7b97\u91cf O(log N) \u3067\u5b9f\u884c\u3055\u308c\u307e\u3059\uff0e\r\n public static int GCD(int n, int m) { return (int)GCD((long)n, m); }\r\n\r\n\r\n /// \r\n /// 2 \u3064\u306e\u6574\u6570\u306e\u6700\u5927\u516c\u7d04\u6570\u3092\u6c42\u3081\u307e\u3059\uff0e\r\n /// \r\n /// \u6700\u521d\u306e\u5024\r\n /// 2 \u756a\u76ee\u306e\u5024\r\n /// 2 \u3064\u306e\u6574\u6570\u306e\u6700\u5927\u516c\u7d04\u6570\r\n /// \u30e6\u30fc\u30af\u30ea\u30c3\u30c9\u306e\u4e92\u9664\u6cd5\u306b\u57fa\u3065\u304d\u6700\u60aa\u8a08\u7b97\u91cf O(log N) \u3067\u5b9f\u884c\u3055\u308c\u307e\u3059\uff0e\r\n public static long GCD(long n, long m)\r\n {\r\n n = Math.Abs(n);\r\n m = Math.Abs(m);\r\n while (n != 0)\r\n {\r\n m %= n;\r\n if (m == 0) return n;\r\n n %= m;\r\n }\r\n return m;\r\n }\r\n\r\n\r\n /// \r\n /// 2 \u3064\u306e\u6574\u6570\u306e\u6700\u5c0f\u516c\u500d\u6570\u3092\u6c42\u3081\u307e\u3059\uff0e\r\n /// \r\n /// \u6700\u521d\u306e\u5024\r\n /// 2 \u756a\u76ee\u306e\u5024\r\n /// 2 \u3064\u306e\u6574\u6570\u306e\u6700\u5c0f\u516c\u500d\u6570\r\n /// \u6700\u60aa\u8a08\u7b97\u91cf O(log N) \u3067\u5b9f\u884c\u3055\u308c\u307e\u3059\uff0e\r\n public static long LCM(long n, long m) { return (n / GCD(n, m)) * m; }\r\n }\r\n #endregion\r\n #region PrimeSieve\r\n public static partial class MathEx\r\n {\r\n /// \r\n /// \u3042\u308b\u5024\u307e\u3067\u306b\u7d20\u6570\u8868\u3092\u69cb\u7bc9\u3057\u307e\u3059\uff0e\r\n /// \r\n /// \u6700\u5927\u306e\u5024\r\n /// \u7d20\u6570\u306e\u307f\u3092\u5165\u308c\u305f\u6570\u5217\u304c\u8fd4\u3055\u308c\u308b\r\n /// 0 \u304b\u3089 max \u307e\u3067\u306e\u7d20\u6570\u8868\r\n /// \u30a8\u30e9\u30c8\u30b9\u30c6\u30cd\u30b9\u306e\u7be9\u306b\u57fa\u3065\u304d\uff0c\u6700\u60aa\u8a08\u7b97\u91cf O(N loglog N) \u3067\u5b9f\u884c\u3055\u308c\u307e\u3059\uff0e\r\n public static bool[] Sieve(int max, List primes = null)\r\n {\r\n var isPrime = new bool[max + 1];\r\n for (int i = 2; i < isPrime.Length; i++) isPrime[i] = true;\r\n for (int i = 2; i * i <= max; i++)\r\n if (!isPrime[i]) continue;\r\n else for (int j = i * i; j <= max; j += i) isPrime[j] = false;\r\n if (primes != null) for (int i = 0; i <= max; i++) if (isPrime[i]) primes.Add(i);\r\n\r\n return isPrime;\r\n }\r\n }\r\n #endregion\r\n}\r\n\r\n// https://bitbucket.org/camypaper/complib\r\nnamespace CompLib.Mathematics\r\n{\r\n #region ModInt\r\n /// \r\n /// [0,) \u307e\u3067\u306e\u5024\u3092\u53d6\u308b\u3088\u3046\u306a\u6570\r\n /// \r\n public struct ModInt\r\n {\r\n /// \r\n /// \u5270\u4f59\u3092\u53d6\u308b\u5024\uff0e\r\n /// \r\n public const long Mod = (int)1e9 + 7;\r\n // public const long Mod = 998244353;\r\n\r\n /// \r\n /// \u5b9f\u969b\u306e\u6570\u5024\uff0e\r\n /// \r\n public long num;\r\n /// \r\n /// \u5024\u304c \u3067\u3042\u308b\u3088\u3046\u306a\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u3092\u69cb\u7bc9\u3057\u307e\u3059\uff0e\r\n /// \r\n /// \u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u304c\u6301\u3064\u5024\r\n /// \u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u306e\u554f\u984c\u4e0a\uff0c\u30b3\u30f3\u30b9\u30c8\u30e9\u30af\u30bf\u5185\u3067\u306f\u5270\u4f59\u3092\u53d6\u308a\u307e\u305b\u3093\uff0e\u305d\u306e\u305f\u3081\uff0c \u2208 [0,) \u3092\u6e80\u305f\u3059\u3088\u3046\u306a \u3092\u6e21\u3057\u3066\u304f\u3060\u3055\u3044\uff0e\u3053\u306e\u30b3\u30f3\u30b9\u30c8\u30e9\u30af\u30bf\u306f O(1) \u3067\u5b9f\u884c\u3055\u308c\u307e\u3059\uff0e\r\n public ModInt(long n) { num = n; }\r\n /// \r\n /// \u3053\u306e\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u306e\u6570\u5024\u3092\u6587\u5b57\u5217\u306b\u5909\u63db\u3057\u307e\u3059\uff0e\r\n /// \r\n /// [0,) \u306e\u7bc4\u56f2\u5185\u306e\u6574\u6570\u3092 10 \u9032\u8868\u8a18\u3057\u305f\u3082\u306e\uff0e\r\n public override string ToString() { return num.ToString(); }\r\n public static ModInt operator +(ModInt l, ModInt r) { l.num += r.num; if (l.num >= Mod) l.num -= Mod; return l; }\r\n public static ModInt operator -(ModInt l, ModInt r) { l.num -= r.num; if (l.num < 0) l.num += Mod; return l; }\r\n public static ModInt operator *(ModInt l, ModInt r) { return new ModInt(l.num * r.num % Mod); }\r\n public static implicit operator ModInt(long n) { n %= Mod; if (n < 0) n += Mod; return new ModInt(n); }\r\n\r\n /// \r\n /// \u4e0e\u3048\u3089\u308c\u305f 2 \u3064\u306e\u6570\u5024\u304b\u3089\u3079\u304d\u5270\u4f59\u3092\u8a08\u7b97\u3057\u307e\u3059\uff0e\r\n /// \r\n /// \u3079\u304d\u4e57\u306e\u5e95\r\n /// \u3079\u304d\u6307\u6570\r\n /// \u7e70\u308a\u8fd4\u3057\u4e8c\u4e57\u6cd5\u306b\u3088\u308a O(N log N) \u3067\u5b9f\u884c\u3055\u308c\u307e\u3059\uff0e\r\n public static ModInt Pow(ModInt v, long k) { return Pow(v.num, k); }\r\n\r\n /// \r\n /// \u4e0e\u3048\u3089\u308c\u305f 2 \u3064\u306e\u6570\u5024\u304b\u3089\u3079\u304d\u5270\u4f59\u3092\u8a08\u7b97\u3057\u307e\u3059\uff0e\r\n /// \r\n /// \u3079\u304d\u4e57\u306e\u5e95\r\n /// \u3079\u304d\u6307\u6570\r\n /// \u7e70\u308a\u8fd4\u3057\u4e8c\u4e57\u6cd5\u306b\u3088\u308a O(N log N) \u3067\u5b9f\u884c\u3055\u308c\u307e\u3059\uff0e\r\n public static ModInt Pow(long v, long k)\r\n {\r\n long ret = 1;\r\n for (k %= Mod - 1; k > 0; k >>= 1, v = v * v % Mod)\r\n if ((k & 1) == 1) ret = ret * v % Mod;\r\n return new ModInt(ret);\r\n }\r\n /// \r\n /// \u4e0e\u3048\u3089\u308c\u305f\u6570\u306e\u9006\u5143\u3092\u8a08\u7b97\u3057\u307e\u3059\uff0e\r\n /// \r\n /// \u9006\u5143\u3092\u53d6\u308b\u5bfe\u8c61\u3068\u306a\u308b\u6570\r\n /// \u9006\u5143\u3068\u306a\u308b\u3088\u3046\u306a\u5024\r\n /// \u6cd5\u304c\u7d20\u6570\u3067\u3042\u308b\u3053\u3068\u3092\u4eee\u5b9a\u3057\u3066\uff0c\u30d5\u30a7\u30eb\u30de\u30fc\u306e\u5c0f\u5b9a\u7406\u306b\u5f93\u3063\u3066\u9006\u5143\u3092 O(log N) \u3067\u8a08\u7b97\u3057\u307e\u3059\uff0e\r\n public static ModInt Inverse(ModInt v) { return Pow(v, Mod - 2); }\r\n }\r\n #endregion\r\n #region Binomial Coefficient\r\n public class BinomialCoefficient\r\n {\r\n public ModInt[] fact, ifact;\r\n public BinomialCoefficient(int n)\r\n {\r\n fact = new ModInt[n + 1];\r\n ifact = new ModInt[n + 1];\r\n fact[0] = 1;\r\n for (int i = 1; i <= n; i++)\r\n fact[i] = fact[i - 1] * i;\r\n ifact[n] = ModInt.Inverse(fact[n]);\r\n for (int i = n - 1; i >= 0; i--)\r\n ifact[i] = ifact[i + 1] * (i + 1);\r\n ifact[0] = ifact[1];\r\n }\r\n public ModInt this[int n, int r]\r\n {\r\n get\r\n {\r\n if (n < 0 || n >= fact.Length || r < 0 || r > n) return 0;\r\n return fact[n] * ifact[n - r] * ifact[r];\r\n }\r\n }\r\n public ModInt RepeatedCombination(int n, int k)\r\n {\r\n if (k == 0) return 1;\r\n return this[n + k - 1, k];\r\n }\r\n }\r\n #endregion\r\n}\r\n\r\n\r\nnamespace CompLib.Util\r\n{\r\n using System;\r\n using System.Linq;\r\n\r\n class Scanner\r\n {\r\n private string[] _line;\r\n private int _index;\r\n private const char Separator = ' ';\r\n\r\n public Scanner()\r\n {\r\n _line = new string[0];\r\n _index = 0;\r\n }\r\n\r\n public string Next()\r\n {\r\n if (_index >= _line.Length)\r\n {\r\n string s;\r\n do\r\n {\r\n s = Console.ReadLine();\r\n } while (s.Length == 0);\r\n\r\n _line = s.Split(Separator);\r\n _index = 0;\r\n }\r\n\r\n return _line[_index++];\r\n }\r\n\r\n public string ReadLine()\r\n {\r\n _index = _line.Length;\r\n return Console.ReadLine();\r\n }\r\n\r\n public int NextInt() => int.Parse(Next());\r\n public long NextLong() => long.Parse(Next());\r\n public double NextDouble() => double.Parse(Next());\r\n public decimal NextDecimal() => decimal.Parse(Next());\r\n public char NextChar() => Next()[0];\r\n public char[] NextCharArray() => Next().ToCharArray();\r\n\r\n public string[] Array()\r\n {\r\n string s = Console.ReadLine();\r\n _line = s.Length == 0 ? new string[0] : s.Split(Separator);\r\n _index = _line.Length;\r\n return _line;\r\n }\r\n\r\n public int[] IntArray() => Array().Select(int.Parse).ToArray();\r\n public long[] LongArray() => Array().Select(long.Parse).ToArray();\r\n public double[] DoubleArray() => Array().Select(double.Parse).ToArray();\r\n public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();\r\n }\r\n}\r\n", "lang_cluster": "C#", "tags": ["math", "number theory"], "code_uid": "e8d04f6d5934edb642a671b910af7ec5", "src_uid": "c3694a6ff95c64bef8cbe8834c3fd6cb", "difficulty": 2200.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Globalization;\nusing System.IO;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Diagnostics;\n\nnamespace Codeforces\n{\n class Program : ProgramBase\n {\n private const long commonMod = 1000000007;\n\n static void Main(string[] args)\n {\n var p = new Program();\n var x = p.Solve();\n p.Out(x);\n }\n object Solve()\n {\n var n = ReadLong();\n var m = ReadLong();\n var k = ReadLong();\n if (k == -1 && Math.Abs(n - m) % 2 != 0)\n return 0;\n return fastpow(fastpow(2, n - 1), m - 1);\n }\n long fastpow(long b, long x)\n {\n checked\n {\n if (x == 0)\n return 1;\n if (x == 1)\n return b;\n if (x % 2 == 0)\n return fastpow(b * b % commonMod, x / 2);\n return b * fastpow(b, x - 1) % commonMod;\n }\n }\n int nod(int a, int b)\n {\n if (a < b)\n return nod(b, a);\n if (b == 0)\n return a;\n return nod(b, a % b);\n }\n\n class End\n {\n public long Val { get; set; }\n public bool Left { get; set; }\n }\n }\n\n abstract class ProgramBase\n {\n bool? prod = null;\n StreamReader f;\n Queue tokens;\n protected string FileName { private get; set; }\n\n protected string Read()\n {\n if (f == null)\n f = string.IsNullOrEmpty(FileName)\n ? new StreamReader(Console.OpenStandardInput(1024 * 10), Encoding.ASCII, false, 1024 * 10)\n : new StreamReader((GetProd() ? \"\" : \"c:\\\\dev\\\\\") + FileName);\n return f.ReadLine();\n }\n\n protected string ReadToken()\n {\n if (tokens == null || tokens.Count == 0)\n tokens = new Queue(Read().Split(' '));\n return tokens.Dequeue();\n }\n\n protected long ReadLong() { return long.Parse(ReadToken()); }\n\n protected long[] ReadLongs()\n {\n var s = Read();\n if (s == \"\")\n return new long[0];\n //var i = s.IndexOf(' ');\n //return new[] { long.Parse(s.Substring(0, i)), long.Parse(s.Substring(i + 1)) };\n var tokens = s.Split(' ');\n var result = new long[tokens.Length];\n for (int i = 0; i < tokens.Length; i++)\n result[i] = long.Parse(tokens[i]);\n return result;\n }\n\n public void Out(object r)\n {\n if (string.IsNullOrEmpty(FileName))\n Console.WriteLine(r);\n else if (GetProd())\n File.WriteAllText(FileName, r.ToString());\n else\n Console.WriteLine(r);\n }\n\n private bool GetProd()\n {\n\n if (!prod.HasValue)\n try\n {\n prod = Environment.MachineName != \"RENADEEN-W7\";\n }\n catch (Exception)\n {\n prod = true;\n }\n return prod.Value;\n }\n }\n\n public static class Huj\n {\n public static T MinBy(this IEnumerable source, Func func) where T : class\n {\n T result = null;\n var min = double.MaxValue;\n foreach (var item in source)\n {\n var current = func(item);\n if (min > current)\n {\n min = current;\n result = item;\n }\n }\n return result;\n }\n\n public static T MaxBy(this IEnumerable source, Func func, T defaultValue = default(T))\n {\n T result = defaultValue;\n var max = double.MinValue;\n foreach (var item in source)\n {\n var current = func(item);\n if (max < current)\n {\n max = current;\n result = item;\n }\n }\n return result;\n }\n\n public static string JoinStrings(this IEnumerable s, string d) { return string.Join(d, s.ToArray()); }\n\n public static string JoinStrings(this IEnumerable s, string d) { return s.Select(x => x.ToString()).JoinStrings(d); }\n public static string JoinStrings(this IEnumerable s, string d) { return s.Select(x => x.ToString()).JoinStrings(d); }\n }\n\n}", "lang_cluster": "C#", "tags": ["math", "constructive algorithms", "combinatorics", "number theory"], "code_uid": "3f819b19e6648d060e2b8374b6c2bc7d", "src_uid": "6b9eff690fae14725885cbc891ff7243", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\n\nnamespace ConsoleApp1\n{\n class Program\n {\n const int MAXN = 1000000007;\n static long QMul(long a, long b)\n {\n long res = 1;\n long tmp = a;\n\n while(b != 0)\n {\n if((b & 1L) == 1)\n {\n res *= tmp;\n res %= MAXN;\n }\n tmp *= tmp;\n tmp %= MAXN;\n b >>= 1;\n }\n\n return res;\n }\n\n static void Main(string[] args)\n {\n string[] input = Console.ReadLine().Split(' ');\n long[] arr = input.Select(x => Convert.ToInt64(x)).ToArray();\n\n long n = arr[0];\n long m = arr[1];\n long k = arr[2];\n\n if(k == -1 && (n+m) % 2 == 1)\n {\n Console.WriteLine(\"0\");\n }\n else\n {\n Console.WriteLine(QMul(QMul(2, (m - 1)), (n - 1)).ToString());\n }\n }\n }\n}", "lang_cluster": "C#", "tags": ["math", "constructive algorithms", "combinatorics", "number theory"], "code_uid": "c462eea0b0e6516d66371363f60cb4ca", "src_uid": "6b9eff690fae14725885cbc891ff7243", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using CompLib.Util;\nusing System;\nusing System.Collections.Generic;\n\npublic class Program\n{\n private int N, M, A, B;\n private int G0, X, Y, Z;\n\n public void Solve()\n {\n var sc = new Scanner();\n N = sc.NextInt();\n M = sc.NextInt();\n A = sc.NextInt();\n B = sc.NextInt();\n\n G0 = sc.NextInt();\n X = sc.NextInt();\n Y = sc.NextInt();\n Z = sc.NextInt();\n\n int[] H = new int[N * M];\n H[0] = G0;\n for (int i = 1; i < N * M; i++)\n {\n H[i] = (int) (((long) H[i - 1] * X + Y) % Z);\n }\n\n MinimumQueue[] q = new MinimumQueue[N];\n for (int i = 0; i < N; i++)\n {\n q[i] = new MinimumQueue();\n for (int j = 0; j < B - 1; j++)\n {\n q[i].Enqueue(H[i * M + j]);\n }\n }\n\n long ans = 0;\n for (int j = B - 1; j < M; j++)\n {\n var q2 = new MinimumQueue();\n for (int i = 0; i < N; i++)\n {\n q[i].Enqueue(H[i * M + j]);\n q2.Enqueue(q[i].Min());\n if (i >= A - 1)\n {\n ans += q2.Min();\n q2.Dequeue();\n }\n\n q[i].Dequeue();\n }\n }\n\n Console.WriteLine(ans);\n }\n\n public static void Main(string[] args) => new Program().Solve();\n}\n\nclass MinimumStack\n{\n private readonly Stack<(int num, int min)> stack;\n\n public MinimumStack()\n {\n stack = new Stack<(int num, int min)>();\n }\n\n public void Push(int num)\n {\n if (Count == 0) stack.Push((num, num));\n else stack.Push((num, Math.Min(num, stack.Peek().min)));\n }\n\n public int Peek()\n {\n return stack.Peek().num;\n }\n\n public int Pop()\n {\n return stack.Pop().num;\n }\n\n public int Min()\n {\n return Count == 0 ? int.MaxValue : stack.Peek().min;\n }\n\n public int Count => stack.Count;\n}\n\nclass MinimumQueue\n{\n private readonly MinimumStack s1, s2;\n\n public MinimumQueue()\n {\n s1 = new MinimumStack();\n s2 = new MinimumStack();\n }\n\n public void Enqueue(int l)\n {\n s2.Push(l);\n }\n\n private void Exec()\n {\n if (s1.Count == 0)\n {\n while (s2.Count > 0)\n {\n s1.Push(s2.Pop());\n }\n }\n }\n\n public int Peek()\n {\n Exec();\n return s1.Peek();\n }\n\n public int Dequeue()\n {\n Exec();\n return s1.Pop();\n }\n\n public int Min()\n {\n return Math.Min(s1.Min(), s2.Min());\n }\n\n public int Count => s1.Count + s2.Count;\n}\n\nnamespace CompLib.Util\n{\n using System;\n using System.Linq;\n\n class Scanner\n {\n private string[] _line;\n private int _index;\n private const char Separator = ' ';\n\n public Scanner()\n {\n _line = new string[0];\n _index = 0;\n }\n\n public string Next()\n {\n if (_index >= _line.Length)\n {\n string s;\n do\n {\n s = Console.ReadLine();\n } while (s.Length == 0);\n\n _line = s.Split(Separator);\n _index = 0;\n }\n\n return _line[_index++];\n }\n\n public string ReadLine()\n {\n _index = _line.Length;\n return Console.ReadLine();\n }\n\n public int NextInt() => int.Parse(Next());\n public long NextLong() => long.Parse(Next());\n public double NextDouble() => double.Parse(Next());\n public decimal NextDecimal() => decimal.Parse(Next());\n public char NextChar() => Next()[0];\n public char[] NextCharArray() => Next().ToCharArray();\n\n public string[] Array()\n {\n string s = Console.ReadLine();\n _line = s.Length == 0 ? new string[0] : s.Split(Separator);\n _index = _line.Length;\n return _line;\n }\n\n public int[] IntArray() => Array().Select(int.Parse).ToArray();\n public long[] LongArray() => Array().Select(long.Parse).ToArray();\n public double[] DoubleArray() => Array().Select(double.Parse).ToArray();\n public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();\n }\n}", "lang_cluster": "C#", "tags": ["two pointers", "data structures"], "code_uid": "c6af13979b62d5d819fa8b415b8b71ec", "src_uid": "4618fbffb2b9d321a6d22c11590a4773", "difficulty": 2100.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Numerics;\nusing System.Collections.Generic;\nusing System.Text;\nusing System.IO;\nusing System.Linq;\n\nclass Solution\n{\n\tclass SlideMin\n\t{\n\t\tint i = 0;\n\t\tList lst = new List();\n\t\tpublic void Push(int x)\n\t\t{\n\t\t\twhile (lst.Count > i && lst.Last() > x) lst.RemoveAt(lst.Count-1);\t\t\t\n\t\t\tlst.Add(x);\n\t\t}\n\t\tpublic void Pop(int x)\n\t\t{\n\t\t\tif (lst[i] == x) i++;\n\t\t}\n\t\tpublic int Top()\n\t\t{\n\t\t\treturn lst[i];\n\t\t}\n\t};\n\n\tint n, m, a, b;\n\tint[,] M;\n\n\tvoid Make(int g, int x, int y, int z)\n\t{\n\t\tM = new int[n, m];\n\t\tfor (int i = 0; i < n; i++)\n\t\t{\n\t\t\tfor (int j = 0; j < m; j++)\n\t\t\t{\n\t\t\t\tM[i, j] = g;\n\t\t\t\tg = (int)(((long)g * x + y) % z);\n\t\t\t}\n\t\t}\n\t}\n\n\tvoid Run()\n\t{\n\t\tvar A = Array.ConvertAll(cin.ReadLine().Split(), int.Parse);\n\t\tn = A[0]; m = A[1]; a = A[2]; b = A[3];\n\t\tA = Array.ConvertAll(cin.ReadLine().Split(), int.Parse);\n\t\tMake(A[0], A[1], A[2], A[3]);\n\n\t\tint[,] MinRow = new int[n, m - b + 1];\n\t\tfor (int i = 0; i < n; i++)\n\t\t{\n\t\t\tSlideMin slide = new SlideMin();\n\t\t\tfor (int j = 0; j < b; j++)\n\t\t\t{\n\t\t\t\tslide.Push(M[i, j]);\n\t\t\t}\n\t\t\tfor (int j = 0; j < m - b + 1; j++)\n\t\t\t{\n\t\t\t\tMinRow[i, j] = slide.Top();\n\t\t\t\tif (j == m - b) break;\n\t\t\t\tslide.Pop(M[i, j]);\n\t\t\t\tslide.Push(M[i, j + b]);\n\t\t\t}\n\t\t}\n\n\t\tlong ans = 0;\n\t\tfor (int j = 0; j < m - b + 1; j++)\n\t\t{\n\t\t\tSlideMin slide = new SlideMin();\n\t\t\tfor (int i = 0; i < a; i++)\n\t\t\t{\n\t\t\t\tslide.Push(MinRow[i, j]);\n\t\t\t}\n\t\t\tfor (int i = 0; i < n - a + 1; i++)\n\t\t\t{\n\t\t\t\tans += slide.Top();\n\t\t\t\tif (i == n - a) break;\n\t\t\t\tslide.Pop(MinRow[i, j]);\n\t\t\t\tslide.Push(MinRow[i + a, j]);\n\t\t\t}\n\t\t}\n\n\t\tcout.Write(ans);\n\t}\n\n\tstatic TextReader cin;\n\tstatic TextWriter cout;\n\n\tstatic void Main()\n\t{\n#if NARUT_LOCAL\n\t\tcin = new StreamReader(\"io/test.in\", Encoding.ASCII);\n#else\n\t\tcin = new StreamReader(Console.OpenStandardInput(), Encoding.ASCII);\n#endif\n\t\tcout = new StreamWriter(Console.OpenStandardOutput(), Encoding.ASCII) { AutoFlush = false };\n\t\t(new Solution()).Run();\n\t\tcin.Close();\n\t\tcout.Close();\n\t}\n}\n", "lang_cluster": "C#", "tags": ["two pointers", "data structures"], "code_uid": "0df2146dc902045b8483b72e73723053", "src_uid": "4618fbffb2b9d321a6d22c11590a4773", "difficulty": 2100.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "/*\ncsc -debug E.cs && mono --debug E.exe <<< \"3 4 2 1\n1 2 3 59\"\n*/\n\nusing System;\nusing System.Collections;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading;\nusing System.Reflection;\n\npublic struct QueueItem {\n public ulong Val;\n public int Index;\n}\n\npublic class HelloWorld {\n public static void SolveCodeForces() {\n var n = cin.NextInt();\n var m = cin.NextInt();\n var a = cin.NextInt();\n var b = cin.NextInt();\n\n var Arr = Helpers.CreateArray(n, _ => new ulong[m]);\n {\n var g0 = cin.NextUlong();\n var x = cin.NextUlong();\n var y = cin.NextUlong();\n var z = cin.NextUlong();\n for (var i = 0; i < n; i++)\n for (var j = 0; j < m; j++) {\n Arr[i][j] = g0;\n g0 = (g0 * x + y) % z;\n }\n }\n\n// System.Console.WriteLine(\"Arr:\");\n// foreach (var row in Arr)\n// System.Console.WriteLine(row.Join());\n\n var QVers = new Deque[m];\n for (var j = 0; j < m; j++) {\n var Q = new Deque();\n for (var i = 0; i < a; i++) {\n var x = Arr[i][j];\n AppendRight(Q, i, x);\n }\n QVers[j] = Q;\n }\n\n var ans = 0ul;\n\n for (var i = a - 1; i < n; i++) {\n var rowAns = 0ul;\n\n var Q = new Deque();\n for (var j = 0; j < b; j++) {\n AppendRight(Q, j, QVers[j].Left.Val);\n }\n\n rowAns += Q.Left.Val;\n for (var j = b; j < m; j++) {\n Shift(Q, j - b);\n AppendRight(Q, j, QVers[j].Left.Val);\n rowAns += Q.Left.Val;\n }\n\n for (var j = 0; j < m; j++) {\n Shift(QVers[j], i - a + 1);\n if (i + 1 < n)\n AppendRight(QVers[j], i + 1, Arr[i + 1][j]);\n }\n\n// System.Console.WriteLine(new {i, rowAns});\n ans += rowAns;\n }\n// System.Console.WriteLine(new {brute = SolveBrute(Arr, n, m, a, b)});\n\n System.Console.WriteLine(ans);\n }\n\n static ulong SolveBrute(ulong[][] Arr, int n, int m, int a, int b) {\n var ans = 0ul;\n\n for (var i = a-1; i < n; i++)\n for (var j = b-1; j < m; j++) {\n var min = Arr[i][j];\n for (var ii = 0; ii < a; ii++)\n for (var jj = 0; jj < b; jj++)\n min = Math.Min(min, Arr[i - ii][j - jj]);\n ans += min;\n }\n\n return ans;\n }\n\n static void AppendRight(Deque Q, int i, ulong x) {\n while (Q.Count > 0 && Q.Right.Val >= x) Q.RemoveRight();\n Q.AppendRight(new QueueItem{ Val = x, Index = i });\n }\n\n static void Shift(Deque Q, int i) {\n if (Q.Left.Index == i) Q.RemoveLeft();\n }\n\n static Scanner cin = new Scanner();\n static StringBuilder cout = new StringBuilder();\n\n static public void Main () {\n SolveCodeForces();\n // IncreaseStack(SolveCodeForces);\n // System.Console.Write(cout.ToString());\n }\n\n public static void IncreaseStack(ThreadStart action, int stackSize = 128000000)\n {\n var thread = new Thread(action, stackSize);\n thread.Start();\n thread.Join();\n }\n}\n\npublic class Deque : IEnumerable {\n private T[] arr;\n private int index;\n private int count;\n private int n;\n\n public Deque(T[] arr) {\n this.arr = arr;\n n = arr.Length;\n count = arr.Length;\n }\n\n public Deque(int capacity = 8) {\n n = capacity;\n arr = new T[capacity];\n }\n\n public int Count => count;\n\n public T Left => this[0];\n public T Right => this[count - 1];\n\n public T this[int i] {\n get {\n if (i < 0 || i >= count) throw new InvalidOperationException(string.Format(\"Index {0} is out of range (count = {1})\", i, count));\n return arr[(index + i) % n];\n }\n }\n\n public void AppendRight(T val) {\n EnsureSize();\n arr[(index + count) % n] = val;\n count++;\n }\n\n public void AppendLeft(T val) {\n EnsureSize();\n index = (index + n - 1) % n;\n arr[index] = val;\n count++;\n }\n\n public T RemoveLeft() {\n if (count == 0) throw new InvalidOperationException(\"Can't remove left because deque is empty\");\n\n var result = arr[index];\n index = (index + 1) % n;\n count--;\n return result;\n }\n\n public T RemoveRight() {\n if (count == 0) throw new InvalidOperationException(\"Can't remove right because deque is empty\");\n\n var result = arr[(index + count + n - 1) % n];\n count--;\n return result;\n }\n\n private void EnsureSize() {\n if (count == arr.Length) {\n var newArr = new T[arr.Length * 2];\n var left = Math.Min(count, arr.Length - index);\n Array.Copy(arr, index, newArr, 0, left);\n if (left < count)\n Array.Copy(arr, 0, newArr, left, count - left);\n arr = newArr;\n index = 0;\n n = newArr.Length;\n }\n }\n\n public IEnumerator GetEnumerator()\n {\n for (var i = 0; i < count; i++) {\n yield return arr[(index + i) % n];\n }\n }\n\n IEnumerator IEnumerable.GetEnumerator()\n {\n return GetEnumerator();\n }\n}\n\npublic static class Helpers {\n public static string Join(this IEnumerable arr) {\n return string.Join(\" \", arr);\n }\n\n public static void Swap(ref T a, ref T b) {\n var tmp = a;\n a = b;\n b = tmp;\n }\n\n public static T[] CreateArray(int length, Func itemCreate) {\n var result = new T[length];\n for (var i = 0; i < result.Length; i++)\n result[i] = itemCreate(i);\n return result;\n }\n}\n\npublic class Scanner\n{\n private string[] line = new string[0];\n private int index = 0;\n\n public string Next() {\n if (line.Length <= index) {\n line = Console.ReadLine().Split(' ');\n index = 0;\n }\n var res = line[index];\n index++;\n return res;\n }\n\n public int NextInt() {\n return int.Parse(Next());\n }\n\n public long NextLong() {\n return long.Parse(Next());\n }\n\n public ulong NextUlong() {\n return ulong.Parse(Next());\n }\n\n public string[] Array() {\n line = Console.ReadLine().Split(' ');\n index = line.Length;\n return line;\n }\n\n public int[] IntArray(int emptyPrefixLen = 0) {\n var array = Array();\n var result = new int[emptyPrefixLen + array.Length];\n for (int i = 0; i < array.Length; i++)\n result[emptyPrefixLen + i] = int.Parse(array[i]);\n return result;\n }\n\n public long[] LongArray() {\n var array = Array();\n var result = new long[array.Length];\n for (int i = 0; i < array.Length; i++)\n result[i] = long.Parse(array[i]);\n return result;\n }\n\n public ulong[] UlongArray() {\n var array = Array();\n var result = new ulong[array.Length];\n for (int i = 0; i < array.Length; i++)\n result[i] = ulong.Parse(array[i]);\n return result;\n }\n}", "lang_cluster": "C#", "tags": ["two pointers", "data structures"], "code_uid": "02c277164789d3a6f27b7a2df5784c64", "src_uid": "4618fbffb2b9d321a6d22c11590a4773", "difficulty": 2100.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.IO;\nusing System.Collections;\nusing System.Diagnostics;\n\nnamespace CodeForces {\n class Pair : IComparable {\n public int First, Second,Index;\n public Pair(int f, int s) {\n First = f;\n Second = s; \n }\n public Pair(string s) {\n string[] ss = s.Split(' ');\n First = int.Parse(ss[0]);\n Second = int.Parse(ss[1]);\n }\n public override string ToString() {\n return string.Format(\"{0} {1}\", First, Second);\n }\n\n public int CompareTo(Pair other) {\n return Math.Abs(other.Second).CompareTo(Math.Abs(Second));\n }\n }\n\n class Cf { \n static TextReader input;\n static void Main(string[] args) { \n#if TESTS \n Stopwatch sw = new Stopwatch();\n input = new StreamReader(\"input.txt\"); \n#else\n input = Console.In;\n#endif\n Solve(); \n#if TESTS\n Console.WriteLine();\n Console.WriteLine(\"Milliseconds: {0}\", sw.ElapsedMilliseconds);\n Console.ReadLine();\n#endif\n } \n const int MOD = 1000000007; \n static int n, m;\n static string s, t;\n static void Solve() {\n ulong n = ulong.Parse(input.ReadLine());\n if (n == 0)\n Console.WriteLine(1);\n else {\n ulong p1 = binpow(2, n - 1);\n ulong p2 = binpow(2, 2 * n - 1);\n ulong res = (p1 + p2) % MOD;\n Console.WriteLine(res);\n }\n }\n\n static ulong binpow(ulong a, ulong n) {\n ulong res = 1;\n while (n > 0) \n if ((n & 1)==1) {\n res = (res * a) % MOD;\n --n;\n }\n else {\n a = (a * a) % MOD;\n n >>= 1;\n }\n return res % MOD;\n } \n\n static void PrintDouble(double d) {\n Console.WriteLine(d.ToString().Replace(',','.'));\n }\n\n static int[] Z_function(string s) {\n int n = s.Length;\n int[] z = new int[n]; \n for (int i = 1, l = 0, r = 0; i < n; ++i) {\n if (i <= r)\n z[i] = Math.Min(r - i + 1, z[i - l]);\n while (i + z[i] < n && s[z[i]] == s[i + z[i]])\n ++z[i];\n if (i + z[i] - 1 > r) {\n l = i; r = i + z[i] - 1;\n }\n }\n return z;\n }\n\n static int SquaredDistanceBetweenSegments(int x1, int y1, int x2, int y2, int xx1, int yy1, int xx2, int yy2) {\n return Math.Min(Math.Min(SquaredDistanceToSegment(x1, y1, xx1, yy1, xx2, yy2), SquaredDistanceToSegment(x2, y2, xx1, yy1, xx2, yy2)),\n Math.Min(SquaredDistanceToSegment(xx1, yy1, x1, y1, x2, y2), SquaredDistanceToSegment(xx2, yy2, x1, y1, x2, y2)));\n }\n\n static int SquaredDistanceToSegment(int x, int y, int x1, int y1, int x2, int y2) {\n int result = Math.Min(SquaredDistance(x, y, x1, y1), SquaredDistance(x, y, x2, y2));\n if (x1 == x2 && y1 <= y && y <= y2)\n result = (x - x1) * (x - x1);\n else if (y1 == y2 && x1 <= x && x <= x2)\n result = (y - y1) * (y - y1);\n return result;\n }\n\n static int SquaredDistance(int ax, int ay, int bx, int by) {\n return (ax - bx) * (ax - bx) + (ay - by) * (ay - by);\n }\n\n #region read helpers\n public static List ReadIntList() {\n return input.ReadLine().Split(' ').Select(x => int.Parse(x)).ToList();\n }\n\n public static int[] ReadIntArray() {\n return input.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();\n }\n\n public static int ReadInt() {\n return int.Parse(input.ReadLine());\n }\n#endregion\n }\n \n public class SegmentTree {\n private int[] a, t;\n private int n;\n public SegmentTree(int[] a) {\n n = a.Length;\n this.a = a; \n t = new int[n << 2];\n buildSegmentTree(0, n - 1, 1);\n }\n\n private void buildSegmentTree(int l, int r, int v) {\n if (l == r)\n t[v] = a[l];\n else {\n int m = (l + r) >> 1;\n int vl = v << 1;\n int vr = (v << 1) | 1;\n buildSegmentTree(l, m, vl);\n buildSegmentTree(m + 1, r, vr);\n t[v] = t[vl] + t[vr];\n }\n }\n\n public int QuerySegmentTree(int l, int r) {\n return querySegmentTree(1, l, r, 0, n - 1);\n }\n\n public void Update(int v, int tl, int tr, int pos, int new_val) {\n if (tl == tr)\n t[v] = new_val;\n else {\n int tm = (tl + tr) / 2;\n if (pos <= tm)\n Update(v << 1, tl, tm, pos, new_val);\n else\n Update(v << 1 + 1, tm + 1, tr, pos, new_val);\n t[v] = t[v << 1] + t[v << 1 + 1];\n }\n }\n\n private int querySegmentTree(int v, int l, int r, int tl, int tr) {\n if (l > r)\n return 0;\n if (l == tl && r == tr)\n return t[v];\n int m = (tl + tr) >> 1; \n return querySegmentTree(v << 1, l, Math.Min(r, m), tl, m) + querySegmentTree((v << 1) | 1, Math.Max(l, m + 1), r, m + 1, tr);\n }\n }\n class Graph : List> {\n public Graph(int num): base(num) {\n for (int i = 0; i < num; i++) {\n this.Add(new List());\n }\n }\n }\n class Heap : IEnumerable where T : IComparable {\n private List heap = new List();\n private int heapSize;\n private int Parent(int index) {\n return (index - 1) >> 1;\n }\n public int Count {\n get { return heap.Count; }\n }\n private int Left(int index) {\n return (index << 1) | 1;\n }\n private int Right(int index) {\n return (index << 1) + 2;\n }\n private void Max_Heapify(int i) {\n int l = Left(i);\n int r = Right(i);\n int largest = i;\n if (l < heapSize && heap[l].CompareTo(heap[i]) > 0)\n largest = l;\n if (r < heapSize && heap[r].CompareTo(heap[largest]) > 0)\n largest = r;\n if (largest != i) {\n T temp = heap[largest];\n heap[largest] = heap[i];\n heap[i] = temp;\n Max_Heapify(largest);\n }\n }\n private void BuildMaxHeap() {\n for (int i = heap.Count >> 1; i >= 0; --i)\n Max_Heapify(i);\n }\n\n public IEnumerator GetEnumerator() {\n return heap.GetEnumerator();\n }\n\n public void Sort() {\n for (int i = heap.Count - 1; i > 0; --i) {\n T temp = heap[i];\n heap[i] = heap[0];\n heap[0] = temp;\n --heapSize;\n Max_Heapify(0);\n }\n }\n\n public T Heap_Extract_Max() {\n T max = heap[0];\n heap[0] = heap[--heapSize];\n Max_Heapify(0);\n return max;\n }\n\n public void Clear() {\n heap.Clear();\n heapSize = 0;\n }\n\n public void Insert(T item) {\n if (heapSize < heap.Count)\n heap[heapSize] = item;\n else\n heap.Add(item);\n int i = heapSize;\n while (i > 0 && heap[Parent(i)].CompareTo(heap[i]) < 0) {\n T temp = heap[i];\n heap[i] = heap[Parent(i)];\n heap[Parent(i)] = temp;\n i = Parent(i);\n }\n ++heapSize;\n }\n\n IEnumerator IEnumerable.GetEnumerator() {\n return ((IEnumerable)heap).GetEnumerator();\n }\n } \n public class Treap {\n private static Random rand = new Random();\n public static Treap Merge(Treap l, Treap r) {\n if (l == null) return r;\n if (r == null) return l;\n Treap res;\n if (l.y > r.y) {\n Treap newR = Merge(l.right, r);\n res = new Treap(l.x, l.y, l.left, newR);\n }\n else {\n Treap newL = Merge(l, r.left);\n res = new Treap(r.x, r.y, newL, r.right);\n } \n return res;\n }\n\n public void Split(int x, out Treap l, out Treap r) {\n Treap newTree = null;\n if (this.x <= x) {\n if (right == null)\n r = null;\n else\n right.Split(x, out newTree, out r);\n l = new Treap(this.x, y, left, newTree); \n }\n else {\n if (left == null)\n l = null;\n else\n left.Split(x, out l, out newTree);\n r = new Treap(this.x, y, newTree, right); \n }\n }\n\n public Treap Add(int x) {\n Treap l, r;\n Split(x, out l, out r);\n Treap m = new Treap(x, rand.Next());\n return Merge(Merge(l, m), r);\n }\n\n public Treap Remove(int x) {\n Treap l, m, r;\n Split(x - 1, out l, out r);\n r.Split(x, out m, out r);\n return Merge(l, r);\n }\n\n private int x, y, cost, maxTreeCost;\n private Treap left, right;\n public Treap(int x, int y, Treap l, Treap r) {\n this.x = x;\n this.y = y;\n left = l;\n right = r;\n }\n public Treap(int x, int y) : this(x, y, null, null) { }\n public void InOrder() {\n inOrder(this);\n }\n private void inOrder(Treap t) {\n if (t == null) return;\n inOrder(t.left);\n Console.WriteLine(t.x);\n inOrder(t.right);\n }\n }\n public static class Extensions {\n public static void Fill(this int[] array, int val) {\n for (int i = 0; i < array.Length; i++) {\n array[i] = val;\n }\n }\n\n public static void Fill(this double[] array, double val) {\n for (int i = 0; i < array.Length; i++) {\n array[i] = val;\n }\n }\n\n public static int ToInt(this string s) {\n return int.Parse(s);\n }\n\n public static string Fill(this char c, int count) {\n char[] r = new char[count];\n for (int i = 0; i < count; ++i)\n r[i] = c;\n return new string(r);\n }\n \n public static void Print(this IEnumerable arr) {\n foreach (T t in arr)\n Console.Write(\"{0} \", t);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "matrices", "dp", "number theory"], "code_uid": "5ac7456c4e20d9b398b8b9347dc9f373", "src_uid": "782b819eb0bfc86d6f96f15ac09d5085", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\n\nnamespace C\n{\n class Program\n {\n static long bin_pow(long a, long n, long d)\n {\n long res = 1;\n for (long t = a; n>0; t=(t*t)%d)\n { \n if (n%2==1)\n {\n res = (res * t) % d;\n }\n n /= 2;\n }\n return res;\n }\n static void Main(string[] args)\n {\n long n = long.Parse(Console.ReadLine());\n long d = 1000000007;\n long t = bin_pow(2, n, d);\n long res = ((1 + t) * t / 2) % d;\n Console.WriteLine(res);\n Console.ReadLine();\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "matrices", "dp", "number theory"], "code_uid": "8cf8e2b7dacd5fb74a0c66444a6362bb", "src_uid": "782b819eb0bfc86d6f96f15ac09d5085", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\nusing System.IO;\nusing System.Diagnostics;\nusing System.Collections;\nusing System.Collections.Generic;\n\nnamespace Sharp\n{\n\n class Program {\n private static Reader cin;\n private static TextWriter cout;\n private static long MOD = 998244353;\n private static long[] f;\n static long solve(int a, int b) {\n f = new long[b + 1];\n f[b] = 1;\n for (int i = 0; i < a; ++i) {\n for (int j = 0; j < b; ++j) {\n f[j] = (f[j] + f[j + 1] * (j + 1)) % MOD;\n }\n }\n\n long ans = 0;\n for (int i = 0; i <= b; ++i) {\n ans = (ans + f[i]) % MOD;\n }\n\n return ans;\n }\n static void Main(string[] args) {\n cin = new Reader(Console.In);\n cout = Console.Out;\n int a, b, c;\n cin.Read(out a).Read(out b).Read(out c);\n long ans = 1;\n ans = (ans * solve(a, b)) % MOD;\n ans = (ans * solve(a, c)) % MOD;\n ans = (ans * solve(c, b)) % MOD;\n cout.WriteLine(ans);\n\n }\n }\n\n class Reader\n {\n TextReader TextRdr;\n\n String[] Buffer;\n int Id;\n public Reader(TextReader reader) {\n TextRdr = reader;\n Id = 0;\n }\n\n public String ReadLine() {\n return TextRdr.ReadLine();\n }\n\n public String Next() {\n if ((Buffer == null) || (Id == Buffer.Length)) {\n Buffer = ReadLine().Split();\n Id = 0;\n }\n return Buffer[Id++];\n }\n\n public Reader Read(out T what) {\n what = (T)Convert.ChangeType(Next(), typeof(T));\n return this;\n }\n\n public T Read() {\n return (T)Convert.ChangeType(Next(), typeof(T));\n }\n\n }\n\n class Pair\n {\n public Pair() {\n }\n\n public Pair(T1 first, T2 second) {\n this.First = first;\n this.Second = second;\n }\n\n public T1 First { get; set; }\n public T2 Second { get; set; }\n };\n\n}\n", "lang_cluster": "C#", "tags": ["math", "dp", "combinatorics"], "code_uid": "ffea7f153153f394e21955109a5db87c", "src_uid": "b6dc5533fbf285d5ef4cf60ef6300383", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeff\ufeff\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Globalization;\nusing System.IO;\nusing System.Linq;\n\nnamespace CF\n{\n internal class Program\n {\n private static void Main(string[] args)\n {\n using (var sr = new InputReader(Console.In))\n//\t\t\tusing (var sr = new InputReader(new StreamReader(\"input.txt\")))\n using (var sw = Console.Out)\n //using (var sw = new StreamWriter(\"output.txt\"))\n using (var task = new Task(sr, sw)) {\n task.Solve();\n// Console.ReadKey();\n }\n }\n }\n\n internal class Task : IDisposable\n {\n private readonly InputReader sr;\n private readonly TextWriter sw;\n private bool isDispose;\n \n const long mod = 998244353L;\n\n public Task(InputReader sr, TextWriter sw)\n {\n this.sr = sr;\n this.sw = sw;\n }\n \n public void Solve()\n {\n var a = sr.NextInt32();\n var b = sr.NextInt32();\n var c = sr.NextInt32();\n var facts = Facts(Math.Max(a, Math.Max(b, c)));\n var coeffs = BinCoeff(Math.Max(a, Math.Max(b, c)));\n sw.WriteLine(((Func(a, b, facts, coeffs)*Func(b, c, facts, coeffs)%mod)*Func(c, a, facts, coeffs))%mod);\n }\n\n private long[] Facts(int max)\n {\n var facts = new long[max + 1];\n facts[0] = 1L;\n for (var i = 1; i <= max; i++) {\n facts[i] = (facts[i - 1] * i) % mod;\n }\n\n return facts;\n }\n\n private long Func(long a, long b, long[] facts, long[,] binCoeff)\n {\n var max = Math.Max(a, b);\n var r = 0L;\n for (var i = 0; i <= max; i++) {\n r = (r + binCoeff[a, i] * binCoeff[b, i]%mod * facts[i] % mod) % mod;\n }\n\n return r;\n }\n\n private long[,] BinCoeff(int max)\n {\n var coeff = new long[max + 1, max + 1];\n for (var i = 0; i <= max; i++) {\n coeff[i, 0] = 1;\n coeff[i, i] = 1;\n }\n for (var i = 1; i <= max; i++) {\n for (var j = 1; j <= i; j++) {\n coeff[i, j] = (coeff[i - 1, j] + coeff[i - 1, j - 1])%mod;\n }\n }\n\n return coeff;\n }\n\n ~Task()\n {\n Dispose(false);\n }\n\n public void Dispose()\n {\n Dispose(true);\n GC.SuppressFinalize(this);\n }\n\n private void Dispose(bool disposing)\n {\n if (!isDispose) {\n if (disposing) {\n if(sr != null)\n sr.Dispose();\n \n if(sw != null)\n sw.Dispose();\n }\n\n isDispose = true;\n } \n }\n }\n}\n\ninternal class InputReader : IDisposable\n{\n private bool isDispose;\n private readonly TextReader sr;\n private string[] buffer;\n private int seek;\n\n public InputReader(TextReader stream)\n {\n sr = stream;\n }\n\n public void Dispose()\n {\n Dispose(true);\n GC.SuppressFinalize(this);\n }\n\n public string NextString()\n {\n var result = sr.ReadLine();\n return result;\n }\n\n public int NextInt32()\n {\n return Int32.Parse(ReadNextToken());\n }\n\n private string ReadNextToken()\n {\n if (buffer == null || seek == buffer.Length) {\n seek = 0;\n buffer = NextSplitStrings();\n }\n\n return buffer[seek++];\n }\n\n public long NextInt64()\n {\n return Int64.Parse(ReadNextToken());\n }\n \n public int[] ReadArrayOfInt32()\n {\n return ReadArray(Int32.Parse);\n }\n\n public long[] ReadArrayOfInt64()\n {\n return ReadArray(Int64.Parse);\n }\n\n public string[] NextSplitStrings()\n {\n return NextString()\n .Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);\n }\n\n public T[] ReadArray(Func func)\n {\n return NextSplitStrings()\n .Select(s => func(s, CultureInfo.InvariantCulture))\n .ToArray();\n }\n\n public T[] ReadArrayFromString(Func func, string str)\n {\n return\n str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)\n .Select(s => func(s, CultureInfo.InvariantCulture))\n .ToArray();\n }\n\n protected void Dispose(bool dispose)\n {\n if (!isDispose)\n {\n if (dispose)\n sr.Close();\n \n isDispose = true;\n }\n }\n\n ~InputReader()\n {\n Dispose(false);\n }\n}", "lang_cluster": "C#", "tags": ["math", "dp", "combinatorics"], "code_uid": "448cf5d635d0377adefc6964c2e8d9d1", "src_uid": "b6dc5533fbf285d5ef4cf60ef6300383", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\n\nclass LuckyProbability\n{\n\n static int[] L = new int[1024];\n static int[] st = new int[10];\n static int LPos = 0;\n\n public static int Main()\n {\n //citire\n string[] citire = Console.ReadLine().Split(' ');\n int x1, x2, y1, y2, k;\n x1 = Convert.ToInt32(citire[0]);\n x2 = Convert.ToInt32(citire[1]);\n y1 = Convert.ToInt32(citire[2]);\n y2 = Convert.ToInt32(citire[3]);\n k = Convert.ToInt32(citire[4]);\n\n //solve\n back(1); L[1023] = 1000000001;\n Array.Sort(L, 1, 1022); //stocare numere Lucky\n\n int i, j; long Rez = 0;\n for (i = 1; i <= (1023 - k); i++)\n {\n j = i + k - 1;\n Rez += (long)Intersectie(x1, x2, L[i - 1] + 1, L[i]) * (long)Intersectie(y1, y2, L[j], L[j + 1] - 1);\n Rez += (long)Intersectie(y1, y2, L[i - 1] + 1, L[i]) * (long)Intersectie(x1, x2, L[j], L[j + 1] - 1);\n if (k == 1 && x1 <= L[i] && L[i] <= x2 && y1 <= L[i] && L[i] <= y2) Rez--;\n }\n\n long Posibilitati = (long)(x2 - x1 + 1) * (long)(y2 - y1 + 1);\n decimal Afis = (decimal)Rez / (decimal)Posibilitati;\n Console.WriteLine(Afis.ToString(\"N12\"));\n Console.ReadKey();\n\n return 0;\n }\n\n public static void back(int k)\n {\n int i, j, x;\n for (i = 4; i <= 7; i += 3)\n {\n st[k] = i;\n if (k < 9) back(k + 1);\n x = 0;\n for (j = 1; j <= k; j++) x = x * 10 + st[j];\n L[++LPos] = x;\n }\n }\n\n public static long Intersectie(int stA, int drA, int stB, int drB)\n {\n if (drA < stB || drB < stA) return 0;\n if (stA <= stB && drB <= drA) return drB - stB + 1;\n if (stB <= stA && drA <= drB) return drA - stA + 1;\n if (stA <= stB && drA <= drB) return drA - stB + 1;\n if (stB <= stA && drB <= drA) return drB - stA + 1;\n return 0;\n }\n}\n", "lang_cluster": "C#", "tags": ["dfs and similar", "probabilities", "combinatorics", "brute force"], "code_uid": "389c738c0e69f88fd68ce477c34d41df", "src_uid": "5d76ec741a9d873ce9d7c3ef55eb984c", "difficulty": 1900.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.IO;\n//using System.Reflection;\n//using System.Collections;\nusing System.Collections.Generic;\nusing System.Linq;\n//using System.Text;\n//using System.Text.RegularExpressions;\nusing System.Threading;\n\nnamespace ConsoleApplication1\n{\n class Program\n {\n static class Scanner\n {\n readonly static IEnumerator Tokens;\n static Scanner()\n {\n Tokens = Enumerable.Range(Int32.MinValue, Int32.MaxValue).\n Select(s => Console.ReadLine()).\n TakeWhile(s => s != null).\n SelectMany(s => s.Split(new[] { ' ', '\\r', '\\n', '\\t' }, StringSplitOptions.RemoveEmptyEntries)).\n Concat(Enumerable.Repeat(0, 1).Select(_ => (string)null)).\n GetEnumerator();\n }\n\n public static string NextToken()\n {\n Tokens.MoveNext();\n return Tokens.Current;\n }\n }\n\n int nextInt()\n {\n return int.Parse(Scanner.NextToken());\n }\n\n bool GoodValue(int a)\n {\n if (a <= 0) return false;\n while (a != 0)\n {\n if (a % 10 != 7 && a % 10 != 4) return false;\n a /= 10;\n }\n return true;\n }\n\n int[] GenSequence()\n {\n var l = new List();\n var q = new Queue();\n q.Enqueue(0);\n while (q.Count != 0)\n {\n int cur = q.Dequeue();\n l.Add(cur);\n if (GoodValue(cur * 10 + 4)) q.Enqueue(cur * 10 + 4);\n if (GoodValue(cur * 10 + 7)) q.Enqueue(cur * 10 + 7);\n }\n return l.Concat(Enumerable.Range(1111111111, 1)).OrderBy(c => c).ToArray();\n }\n\n int LowerBound(int v, int[] a)\n {\n int x = 0, y = a.Length;\n while (y - x > 1)\n {\n int z = (x + y) / 2;\n if (a[z] <= v) x = z;\n else y = z;\n }\n return x;\n }\n\n int Len(int x, int y, int[] a, int p)\n {\n if (p < 1 || p >= a.Length) return 0;\n int tx = Math.Max(x, a[p - 1]), ty = Math.Min(y, a[p]);\n if (GoodValue(tx)) tx++;\n if (GoodValue(ty)) ty--;\n return Math.Max(ty - tx + 1, 0);\n }\n\n void Solve()\n {\n var values = GenSequence();\n int pl = nextInt(), pr = nextInt(),\n vl = nextInt(), vr = nextInt(),\n k = nextInt();\n long res = 0;\n for (int x = 1; x < values.Length; x++)\n {\n long pc = Len(pl, pr, values, x);\n long rc1 = Len(vl, vr, values, x + k),\n rc2 = Len(vl, vr, values, x - k);\n res += pc * (rc1 + rc2);\n if (x + k - 1 < values.Length && values[x + k - 1] >= vl && values[x + k - 1] <= vr) res += pc;\n if (x - k > 0 && values[x - k] >= vl && values[x - k] <= vr) res += pc;\n\n if (values[x] >= pl && values[x] <= pr)\n {\n res += Len(vl, vr, values, x - k + 1);\n res += Len(vl, vr, values, x + k);\n\n res += new[] { x + k - 1, x - k + 1 }.Distinct().Where(\n c => c > 0 && c < values.Length &&\n values[c] >= vl && values[c] <= vr\n ).Count();\n }\n }\n long all = (pr - pl + 1);\n all *= (vr - vl + 1);\n Console.Write(\"{0:F12}\", (double)res / (double)(all));\n }\n\n static void Main()\n {\n#if MY_SUPER_PUPER_ONLINE_JUDGE\n string dir = Directory.GetCurrentDirectory();\n dir = Directory.GetParent(dir).FullName;\n dir = Directory.GetParent(dir).FullName;\n Console.SetIn(new StreamReader(dir + \"\\\\input.txt\"));\n Console.SetOut(new StreamWriter(dir + \"\\\\output.txt\"));\n#endif\n Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.InvariantCulture;\n new Program().Solve();\n#if MY_SUPER_PUPER_ONLINE_JUDGE\n Console.In.Close();\n Console.Out.Close();\n#endif\n }\n }\n}", "lang_cluster": "C#", "tags": ["dfs and similar", "probabilities", "combinatorics", "brute force"], "code_uid": "a4c3f8cad7dc2e1fb7d9ebb724270a1d", "src_uid": "5d76ec741a9d873ce9d7c3ef55eb984c", "difficulty": 1900.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Globalization;\nusing System.IO;\nusing System.Linq;\nusing System.Text;\nusing System.Threading;\n\n// (\u3065\u00b0\u03c9\u00b0)\u3065\uff90e\u2605\u309c\u30fb\u3002\u3002\u30fb\u309c\u309c\u30fb\u3002\u3002\u30fb\u309c\u2606\u309c\u30fb\u3002\u3002\u30fb\u309c\u309c\u30fb\u3002\u3002\u30fb\u309c\npublic class Solver\n{\n public void Solve()\n {\n long n = ReadLong() - 1;\n int l = 0, r = 1000000000;\n while (l < r)\n {\n int mid = (l + r) / 2;\n if (3L * mid * (mid + 1) <= n)\n l = mid + 1;\n else\n r = mid;\n }\n\n long x = l * 2 - 1;\n long y = 2;\n if (l > 1)\n n -= 3L * l * (l - 1);\n\n long v = Math.Min(n, l - 1);\n x -= v;\n y += v * 2;\n n -= v;\n \n v = Math.Min(n, l);\n x -= v * 2;\n n -= v;\n\n v = Math.Min(n, l);\n x -= v;\n y -= v * 2;\n n -= v;\n\n v = Math.Min(n, l);\n x += v;\n y -= v * 2;\n n -= v;\n\n v = Math.Min(n, l);\n x += v * 2;\n n -= v;\n\n v = Math.Min(n, l);\n x += v;\n y += v * 2;\n \n Write(x, y);\n }\n\n #region Main\n\n protected static TextReader reader;\n protected static TextWriter writer;\n static void Main()\n {\n#if DEBUG\n reader = new StreamReader(\"..\\\\..\\\\input.txt\");\n //reader = new StreamReader(Console.OpenStandardInput());\n writer = Console.Out;\n //writer = new StreamWriter(\"..\\\\..\\\\output.txt\");\n#else\n reader = new StreamReader(Console.OpenStandardInput());\n writer = new StreamWriter(Console.OpenStandardOutput());\n //reader = new StreamReader(\"input.txt\");\n //writer = new StreamWriter(\"output.txt\");\n#endif\n try\n {\n //var thread = new Thread(new Solver().Solve, 1024 * 1024 * 128);\n //thread.Start();\n //thread.Join();\n new Solver().Solve();\n }\n catch (Exception ex)\n {\n Console.WriteLine(ex);\n#if DEBUG\n#else\n throw;\n#endif\n }\n reader.Close();\n writer.Close();\n }\n\n #endregion\n\n #region Read / Write\n private static Queue currentLineTokens = new Queue();\n private static string[] ReadAndSplitLine() { return reader.ReadLine().Split(new[] { ' ', '\\t', }, StringSplitOptions.RemoveEmptyEntries); }\n public static string ReadToken() { while (currentLineTokens.Count == 0)currentLineTokens = new Queue(ReadAndSplitLine()); return currentLineTokens.Dequeue(); }\n public static int ReadInt() { return int.Parse(ReadToken()); }\n public static long ReadLong() { return long.Parse(ReadToken()); }\n public static double ReadDouble() { return double.Parse(ReadToken(), CultureInfo.InvariantCulture); }\n public static int[] ReadIntArray() { return ReadAndSplitLine().Select(int.Parse).ToArray(); }\n public static long[] ReadLongArray() { return ReadAndSplitLine().Select(long.Parse).ToArray(); }\n public static double[] ReadDoubleArray() { return ReadAndSplitLine().Select(s => double.Parse(s, CultureInfo.InvariantCulture)).ToArray(); }\n public static int[][] ReadIntMatrix(int numberOfRows) { int[][] matrix = new int[numberOfRows][]; for (int i = 0; i < numberOfRows; i++)matrix[i] = ReadIntArray(); return matrix; }\n public static int[][] ReadAndTransposeIntMatrix(int numberOfRows)\n {\n int[][] matrix = ReadIntMatrix(numberOfRows); int[][] ret = new int[matrix[0].Length][];\n for (int i = 0; i < ret.Length; i++) { ret[i] = new int[numberOfRows]; for (int j = 0; j < numberOfRows; j++)ret[i][j] = matrix[j][i]; } return ret;\n }\n public static string[] ReadLines(int quantity) { string[] lines = new string[quantity]; for (int i = 0; i < quantity; i++)lines[i] = reader.ReadLine().Trim(); return lines; }\n public static void WriteArray(IEnumerable array) { writer.WriteLine(string.Join(\" \", array)); }\n public static void Write(params object[] array) { WriteArray(array); }\n public static void WriteLines(IEnumerable array) { foreach (var a in array)writer.WriteLine(a); }\n private class SDictionary : Dictionary\n {\n public new TValue this[TKey key]\n {\n get { return ContainsKey(key) ? base[key] : default(TValue); }\n set { base[key] = value; }\n }\n }\n private static T[] Init(int size) where T : new() { var ret = new T[size]; for (int i = 0; i < size; i++)ret[i] = new T(); return ret; }\n #endregion\n}", "lang_cluster": "C#", "tags": ["math", "implementation", "binary search"], "code_uid": "46e9ce65e09c60210a765304dd723188", "src_uid": "a4b6a570f5e63462b68447713924b465", "difficulty": 2100.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nclass E\n{\n\tstatic void Main()\n\t{\n\t\tvar N = long.Parse(Console.ReadLine());\n\t\tif (N == 0) { Console.WriteLine(\"0 0\"); return; }\n\t\tvar k = FirstBinary(0, Math.Min(600000000, N), t => 3 * (t + 1) * (t + 2) >= N) + 1;\n\t\tvar x = 2 * k;\n\t\tvar y = 0L;\n\t\tvar dx = new long[] { -1, -2, -1, 1, 2, 1 };\n\t\tvar dy = new long[] { 2, 0, -2, -2, 0, 2 };\n\t\tN -= 3 * k * (k - 1) + 1;\n\t\tif (N < 0) N += 6 * k;\n\t\tfor (var i = 0; i < 6; i++)\n\t\t{\n\t\t\tif (N < k)\n\t\t\t{\n\t\t\t\tN++;\n\t\t\t\tx += N * dx[i];\n\t\t\t\ty += N * dy[i];\n\t\t\t\tConsole.WriteLine(\"{0} {1}\", x, y);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tN -= k;\n\t\t\tx += k * dx[i];\n\t\t\ty += k * dy[i];\n\t\t}\n\t}\n\tpublic static long FirstBinary(long min, long max, Predicate pred)\n\t{\n\t\tvar left = min;\n\t\tvar right = max;\n\t\twhile (left < right)\n\t\t{\n\t\t\tvar mid = (left + right) >> 1;\n\t\t\tif (pred(mid)) right = mid;\n\t\t\telse left = mid + 1;\n\t\t}\n\t\treturn left;\n\t}\n}", "lang_cluster": "C#", "tags": ["math", "implementation", "binary search"], "code_uid": "05178eb4d681ddd1fd621da5f8aaeedd", "src_uid": "a4b6a570f5e63462b68447713924b465", "difficulty": 2100.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Globalization;\nusing System.IO;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Diagnostics;\nusing System.Threading;\n\nnamespace Codeforces\n{\n class Program : ProgramBase\n {\n private const long commonMod = 1000000007;\n\n static void Main(string[] args)\n {\n var p = new Program();\n var x = p.Get();\n p.Out(x);\n }\n\n object Get()\n {\n checked\n {\n var m = ReadLong();\n var res = Recurse(m);\n return res.Item1 + \" \" + res.Item2;\n }\n }\n\n Tuple Recurse(long m)\n {\n if (m < 8)\n return Tuple.Create(m, m);\n var root = MaxRoot(m);\n var cube = root * root * root;\n var lesserCube = (root - 1) * (root - 1) * (root - 1);\n var firstAns = Recurse(m - cube);\n var secondAns = Recurse(cube - 1 - lesserCube);\n return firstAns.Item1 >= secondAns.Item1\n ? Tuple.Create(firstAns.Item1 + 1, cube + firstAns.Item2)\n : Tuple.Create(secondAns.Item1 + 1, lesserCube + secondAns.Item2);\n\n }\n\n long MaxRoot(long x)\n {\n var root = (long) Math.Floor(Math.Pow(x, 1d / 3));\n if ((root + 1) * (root + 1) * (root + 1) <= x)\n root++;\n return root;\n }\n\n int Solve(string s1, string s2, int L, int m)\n {\n var diff = s1.Length + s2.Length - L;\n if (diff > 0)\n {\n if (s1.Substring(s1.Length - diff) == s2.Substring(0, diff))\n return 1 % m;\n else\n return 0;\n }\n else\n {\n return FastPow(26, Math.Abs(diff), m);\n }\n }\n\n public int FastPow(int b, int pow, int mod)\n {\n if (pow == 0)\n return 1 % mod;\n if (pow == 1)\n return b % mod;\n if ((pow & 1) == 0)\n return FastPow(b * b % mod, pow / 2, mod);\n return b * FastPow(b, pow - 1, mod) % mod;\n }\n \n class Automata\n {\n bool[] terminals;\n public int sigma;\n public int len;\n public int[,] jumps;\n\n public void Create()\n {\n var a = ReadInts();\n len = a[0];\n sigma = a[2];\n var ts = ReadInts();\n terminals = new bool[len];\n for (int i = 0; i < ts.Length; i++)\n terminals[ts[i]] = true;\n jumps = new int[len, sigma];\n for (int i = 0; i < len * sigma; i++)\n {\n var b = Console.ReadLine().Split(' ');\n jumps[Convert.ToInt32(b[0]), b[1][0] - 'a'] = Convert.ToInt32(b[2]);\n }\n }\n protected int[] ReadInts()\n {\n return Console.ReadLine().Split(' ').Select(x => Convert.ToInt32(x)).ToArray();\n }\n\n public bool IsTerminal(int s)\n {\n return terminals[s];\n }\n }\n }\n\n abstract class ProgramBase\n {\n bool? prod = null;\n StreamReader f;\n protected string FileName { private get; set; }\n\n protected string Read()\n {\n if (f == null)\n f = string.IsNullOrEmpty(FileName)\n ? new StreamReader(Console.OpenStandardInput())\n : new StreamReader((GetProd() ? \"\" : \"c:\\\\dev\\\\\") + FileName);\n return f.ReadLine();\n }\n\n protected int ReadInt()\n {\n return int.Parse(Read());\n }\n\n protected int[] ReadInts()\n {\n var tokens = Read().Split(' ');\n var result = new int[tokens.Length];\n for (int i = 0; i < tokens.Length; i++)\n result[i] = int.Parse(tokens[i]);\n return result;\n }\n\n\n protected long ReadLong()\n {\n return Convert.ToInt64(Read());\n }\n\n protected long[] ReadLongs()\n {\n var tokens = Read().Split(' ');\n var result = new long[tokens.Length];\n for (int i = 0; i < tokens.Length; i++)\n result[i] = long.Parse(tokens[i]);\n return result;\n }\n\n public void Out(object r)\n {\n if (string.IsNullOrEmpty(FileName))\n Console.WriteLine(r);\n else if (GetProd())\n File.WriteAllText(FileName, r.ToString());\n else\n Console.WriteLine(r);\n }\n\n private bool GetProd()\n {\n\n if (!prod.HasValue)\n try\n {\n prod = Environment.MachineName != \"RENADEEN-W7\";\n }\n catch (Exception)\n {\n prod = true;\n }\n return prod.Value;\n }\n }\n\n public static class Huj\n {\n public static T MinBy(this IEnumerable source, Func func) where T : class\n {\n T result = null;\n var min = double.MaxValue;\n foreach (var item in source)\n {\n var current = func(item);\n if (min > current)\n {\n min = current;\n result = item;\n }\n }\n return result;\n }\n\n public static T MaxBy(this IEnumerable source, Func func, T defaultValue = default(T))\n {\n T result = defaultValue;\n var max = double.MinValue;\n foreach (var item in source)\n {\n var current = func(item);\n if (max < current)\n {\n max = current;\n result = item;\n }\n }\n return result;\n }\n\n public static string JoinStrings(this IEnumerable source, string delimeter)\n {\n return string.Join(delimeter, source.ToArray());\n }\n\n public static string JoinStrings(this IEnumerable source, string delimeter)\n {\n return source.Select(x => x.ToString()).JoinStrings(delimeter);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "greedy", "constructive algorithms", "binary search"], "code_uid": "70cb6e5e1a867910589ccc737868f206", "src_uid": "385cf3c40c96f0879788b766eeb25139", "difficulty": 2200.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\nusing System;\nusing System.Collections.Generic;\nusing System.IO;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace AlgoTraining.Codeforces.D_s\n{\n public class FastScanner : StreamReader\n {\n private string[] _line;\n private int _iterator;\n\n public FastScanner(Stream stream) : base(stream)\n {\n _line = null;\n _iterator = 0;\n }\n public int NextInt()\n {\n if (_line == null || _iterator >= _line.Length)\n {\n _line = base.ReadLine().Split(' ');\n _iterator = 0;\n }\n if (_line.Count() == 0) throw new IndexOutOfRangeException(\"Input string is empty\");\n return Convert.ToInt32(_line[_iterator++]);\n }\n public long NextLong()\n {\n if (_line == null || _iterator >= _line.Length)\n {\n _line = base.ReadLine().Split(' ');\n _iterator = 0;\n }\n if (_line.Count() == 0) throw new IndexOutOfRangeException(\"Input string is empty\");\n return Convert.ToInt64(_line[_iterator++]);\n }\n }\n class BearAndTowerOfCubes356\n {\n public static void Main(string[] args)\n {\n using (FastScanner fs = new FastScanner(new BufferedStream(Console.OpenStandardInput())))\n using (StreamWriter writer = new StreamWriter(new BufferedStream(Console.OpenStandardOutput())))\n {\n long m = fs.NextLong(), d = 0;\n long count = Solve(m, ref d);\n writer.WriteLine(count + \" \" + (m - d));\n }\n }\n public static long Solve(long m, ref long d)\n {\n if (m < 8) return m;\n long r2 = (long)Math.Pow((long)Math.Pow(m, 1.0 / 3.0), 3);\n long r1 = (long)Math.Pow((long)Math.Pow(m, 1.0 / 3.0) - 1, 3);\n long p2 = m - r2;\n long p1 = r2 - 1 - r1;\n\n long d1 = 0, d2 = 0;\n long a1 = 1 + Solve(p1, ref d1);\n long a2 = 1 + Solve(p2, ref d2);\n\n if (a2 >= a1)\n {\n d += d2;\n return a2;\n }\n else\n {\n d += m - r2 + 1;\n d += d1;\n return a1;\n }\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "greedy", "constructive algorithms", "binary search"], "code_uid": "06bed11ac03f67603f459355cbb9869d", "src_uid": "385cf3c40c96f0879788b766eeb25139", "difficulty": 2200.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing Math = System.Math;\nusing Dec = System.Decimal;\nusing System.Globalization;\nusing System.Linq;\n\nnamespace taskA\n{\n\tclass newDecimal {\n\tprivate \n\t\t\tInt64 Z, F, kol;\n\tpublic newDecimal(decimal t, Int64 Kol) {\n\t\t\tkol = Kol;\n\t\t\tZ = Dec.ToInt64 (t);\n\t\t\tInt64 p = 1;\n\t\t\tfor (int i = 0; i < kol; i ++)\n\t\t\t\tp *= 10L;\t\t\n\t\t\tF = Dec.ToInt64 ((t - Z) * p);\n\t\t}\n\t\tpublic void print () {\n\t\t\tConsole.Write (\"{0}.\", Z);\n\t\t\tint sz = F.ToString ().Length;\n\t\t\tfor (int i = 0; i < kol - sz; i ++) \n\t\t\t\tConsole.Write (0);\n\t\t\tConsole.Write (F);\n\t\t}\n\t}\n\n\tclass MainClass\n\t{\n\t\tpublic static long[,] C = new long[800, 10];\n\n\t\tpublic static void PreCalc() {\n\t\t\tC [1,1] = 1L;\n\t\t\tC [2,1] = 2L;\n\t\t\tC [2,2] = 1L;\n\t\t\tfor (int i = 3; i <= 777; i ++) C[i,1] = 1L*i;\n\t\t\tfor (int i = 3; i <= 777; i ++)\n\t\t\t\tfor (int j = 2; j <= 7; j ++) \n\t\t\t\t\tC [i,j] = C [i - 1,j] + C [i - 1,j - 1];\n\t\t}\n\n\t\tpublic static void Main(string[] args) {\n\t\t\tlong n = long.Parse (Console.ReadLine ());\n\t\t\tint[] a = {2, 3, 5, 7};\n\t\t\tlong ans = n;\n\t\t\tfor (int i = 0; i < 4; i ++) ans -= n / a[i];\n\t\t\tfor (int i = 0; i < 4; i ++)\n\t\t\t\tfor (int j = i + 1; j < 4; j ++)\n\t\t\t\t\tans += n / a[i] / a[j];\n\t\t\tfor (int i = 0; i < 4; i ++)\n\t\t\t\tfor (int j = i + 1; j < 4; j ++)\n\t\t\t\t\tfor (int k = j + 1; k < 4; k ++)\n\t\t\t\t\t\tans -= n / a[i] / a[j] / a[k];\n\t\t\tans += n / 2 / 3/ 5/ 7;\n\t\t\tConsole.WriteLine(ans);\n\t\t}\n\t}\n}\n", "lang_cluster": "C#", "tags": ["math", "number theory"], "code_uid": "94560e0dd04959ceb15f6a8b6a20fe52", "src_uid": "e392be5411ffccc1df50e65ec1f5c589", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\n\nnamespace ChallengePennants\n{\n class Program\n {\n static void Main(string[] args)\n {\n string s = Console.ReadLine();\n long n = long.Parse(s);\n if (n <= 10)\n {\n Console.WriteLine(1);\n }\n else\n {\n long x = n / 2 + n / 3 + n / 5 + n / 7;\n x -= n / 6 + n / 10 + n / 14 + n / 15 + n / 21 + n / 35;\n x += n / 30 + n / 42 + n / 70 + n / 105;\n x -= n / 210;\n Console.WriteLine(\"{0:d}\", n - x);\n }\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "number theory"], "code_uid": "c2753553efc355a5099ae8429cf02870", "src_uid": "e392be5411ffccc1df50e65ec1f5c589", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "C# 8", "source_code": "using System;\r\nusing System.Collections.Generic;\r\nusing static System.Console;\r\nusing System.Linq;\r\n\r\nclass cf740\r\n{\r\n static int NN => int.Parse(ReadLine());\r\n static int[] NList => ReadLine().Split().Select(int.Parse).ToArray();\r\n static void Main()\r\n {\r\n var c = NList;\r\n var (n, key) = (c[0], c[1]);\r\n var suball = 0L;\r\n var dp = new long[n + 1];\r\n dp[n] = 1;\r\n for (var i = n; i > 1; --i)\r\n {\r\n var val = (dp[i] + suball) % key;\r\n suball = (suball + val) % key;\r\n var last = i;\r\n for (var j = 2; j * j <= i; ++j)\r\n {\r\n dp[i / j] = (dp[i / j] + val) % key;\r\n last = i / j;\r\n }\r\n var sub = 0;\r\n for (var j = 1; j < last; ++j)\r\n {\r\n var mul = i - i / (j + 1) - sub;\r\n dp[j] = (dp[j] + val * mul) % key;\r\n sub += mul;\r\n }\r\n }\r\n WriteLine((dp[1] + suball) % key);\r\n }\r\n}\r\n", "lang_cluster": "C#", "tags": ["brute force", "math", "dp", "data structures", "number theory"], "code_uid": "f6ba6a45892c25f2c9c926af3b060ebd", "src_uid": "a524aa54e83fd0223489a19531bf0e79", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "C# 8", "source_code": "\ufeffusing System;\r\nusing System.Collections.Generic;\r\nusing System.Globalization;\r\nusing System.IO;\r\nusing System.Linq;\r\nusing System.Text;\r\nusing System.Threading;\r\n\r\n// (\u3065\u00b0\u03c9\u00b0)\u3065\uff90e\u2605\u309c\u30fb\u3002\u3002\u30fb\u309c\u309c\u30fb\u3002\u3002\u30fb\u309c\u2606\u309c\u30fb\u3002\u3002\u30fb\u309c\u309c\u30fb\u3002\u3002\u30fb\u309c\r\npublic class Solution\r\n{\r\n public void Solve()\r\n {\r\n int n = ReadInt();\r\n int mod = ReadInt();\r\n\r\n var dp = new long[n + 1];\r\n dp[1] = 1;\r\n long sum = 1;\r\n for (int i = 2; i <= n; i++)\r\n {\r\n dp[i] = sum;\r\n int j;\r\n for (j = 2; j * j <= i; j++)\r\n dp[i] = (dp[i] + dp[i / j]) % mod;\r\n int p = j - 1;\r\n for (j = i / j; j > 0; j--)\r\n {\r\n int o = i / j;\r\n dp[i] = (dp[i] + (o - p) * dp[j]) % mod;\r\n p = o;\r\n }\r\n sum = (sum + dp[i]) % mod;\r\n }\r\n\r\n Write(dp[n]);\r\n }\r\n\r\n #region Main\r\n\r\n protected static TextReader reader;\r\n protected static TextWriter writer;\r\n static void Main()\r\n {\r\n#if DEBUGLOCAL\r\n reader = new StreamReader(\"..\\\\..\\\\..\\\\input.txt\");\r\n //reader = new StreamReader(Console.OpenStandardInput());\r\n writer = Console.Out;\r\n //writer = new StreamWriter(\"..\\\\..\\\\..\\\\output.txt\");\r\n#else\r\n reader = new StreamReader(Console.OpenStandardInput());\r\n writer = new StreamWriter(Console.OpenStandardOutput());\r\n //reader = new StreamReader(\"ysys.in\");\r\n //writer = new StreamWriter(\"output.txt\");\r\n#endif\r\n try\r\n {\r\n new Solution().Solve();\r\n //var thread = new Thread(new Solution().Solve, 1024 * 1024 * 128);\r\n //thread.Start();\r\n //thread.Join();\r\n }\r\n catch (Exception ex)\r\n {\r\n#if DEBUGLOCAL\r\n Console.WriteLine(ex);\r\n#else\r\n throw;\r\n#endif\r\n }\r\n reader.Close();\r\n writer.Close();\r\n }\r\n\r\n #endregion\r\n\r\n #region Read / Write\r\n private static Queue currentLineTokens = new Queue();\r\n private static string[] ReadAndSplitLine() { return reader.ReadLine().Split(new[] { ' ', '\\t', }, StringSplitOptions.RemoveEmptyEntries); }\r\n public static string ReadToken() { while (currentLineTokens.Count == 0) currentLineTokens = new Queue(ReadAndSplitLine()); return currentLineTokens.Dequeue(); }\r\n public static int ReadInt() { return int.Parse(ReadToken()); }\r\n public static long ReadLong() { return long.Parse(ReadToken()); }\r\n public static double ReadDouble() { return double.Parse(ReadToken(), CultureInfo.InvariantCulture); }\r\n public static int[] ReadIntArray() { return ReadAndSplitLine().Select(int.Parse).ToArray(); }\r\n public static long[] ReadLongArray() { return ReadAndSplitLine().Select(long.Parse).ToArray(); }\r\n public static double[] ReadDoubleArray() { return ReadAndSplitLine().Select(s => double.Parse(s, CultureInfo.InvariantCulture)).ToArray(); }\r\n public static int[][] ReadIntMatrix(int numberOfRows) { int[][] matrix = new int[numberOfRows][]; for (int i = 0; i < numberOfRows; i++) matrix[i] = ReadIntArray(); return matrix; }\r\n public static int[][] ReadAndTransposeIntMatrix(int numberOfRows)\r\n {\r\n int[][] matrix = ReadIntMatrix(numberOfRows); int[][] ret = new int[matrix[0].Length][];\r\n for (int i = 0; i < ret.Length; i++) { ret[i] = new int[numberOfRows]; for (int j = 0; j < numberOfRows; j++) ret[i][j] = matrix[j][i]; }\r\n return ret;\r\n }\r\n public static string[] ReadLines(int quantity) { string[] lines = new string[quantity]; for (int i = 0; i < quantity; i++) lines[i] = reader.ReadLine().Trim(); return lines; }\r\n public static void WriteArray(IEnumerable array) { writer.WriteLine(string.Join(\" \", array)); }\r\n public static void Write(params object[] array) { WriteArray(array); }\r\n public static void WriteLines(IEnumerable array) { foreach (var a in array) writer.WriteLine(a); }\r\n private class SDictionary : Dictionary\r\n {\r\n public new TValue this[TKey key]\r\n {\r\n get { return ContainsKey(key) ? base[key] : default(TValue); }\r\n set { base[key] = value; }\r\n }\r\n }\r\n private static T[] Init(int size) where T : new() { var ret = new T[size]; for (int i = 0; i < size; i++) ret[i] = new T(); return ret; }\r\n #endregion\r\n}", "lang_cluster": "C#", "tags": ["brute force", "math", "dp", "data structures", "number theory"], "code_uid": "555812be30e72c78511ad8e4879747d7", "src_uid": "a524aa54e83fd0223489a19531bf0e79", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "C# 8", "source_code": "using System.Diagnostics;\r\nusing System.IO;\r\nusing System.Linq;\r\nusing static System.Console;\r\n\r\nnamespace CodeForces\r\n{\r\n public class Program\r\n {\r\n static void Main()\r\n {\r\n Stopwatch stopwatch = Stopwatch.StartNew();\r\n Solve(In, Out);\r\n PrintTime(stopwatch);\r\n }\r\n public static void Solve(TextReader In, TextWriter Out)\r\n {\r\n int[] input = In.ReadLine().Split().Select(str => int.Parse(str)).ToArray();\r\n int N = input[0], m = input[1];\r\n\r\n int[] f = new int[N * 2 + 1];\r\n f[N] = 1;\r\n for (long n = N - 1; n > 0; n--)\r\n {\r\n f[n] = 2 * f[n + 1] % m;\r\n for (int i = 2; i <= N / n; i++)\r\n {\r\n f[n] = (f[n] + f[i * n] - f[(n + 1) * i]) % m;\r\n if (f[n] < 0)\r\n {\r\n f[n] += m;\r\n }\r\n }\r\n }\r\n int res = (f[1] - f[2]) % m;\r\n if (res < 0)\r\n {\r\n res += m;\r\n }\r\n\r\n Out.WriteLine(res);\r\n }\r\n\r\n [Conditional(\"DEBUG\")]\r\n internal static void PrintTime(Stopwatch stopwatch) => WriteLine(stopwatch.Elapsed);\r\n }\r\n}", "lang_cluster": "C#", "tags": ["brute force", "math", "dp", "data structures", "number theory"], "code_uid": "6fe52d630d85cef13e37419bdd7e8721", "src_uid": "a524aa54e83fd0223489a19531bf0e79", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nclass PairVariable : IComparable\n{\n public decimal a, b;\n public PairVariable()\n {\n a = b = 0;\n }\n public PairVariable(string s)\n {\n string[] q = s.Split();\n a = decimal.Parse(q[0]);\n b = decimal.Parse(q[1]);\n }\n public PairVariable(decimal a, decimal b)\n {\n this.a = a;\n this.b = b;\n }\n\n\n\n public int CompareTo(PairVariable other)\n {\n return this.a.CompareTo(other.a);\n }\n}\n\nnamespace ConsoleApplication254\n{\n\n class Program\n {\n\n\n static void Main(string[] args)\n {\n string[] ss = Console.ReadLine().Split();\n int n = int.Parse(ss[0]);\n int m = int.Parse(ss[1]);\n bool[] p = new bool[n + 1];\n for (int i = 2; i <= n; i++)\n {\n if (!p[i])\n {\n for (int e = i + i; e <= n; e+=i)\n {\n p[e] = true;\n }\n }\n }\n int k = 0;\n for (int i = 0; i < p.Length; i++)\n {\n if (!p[i])\n {\n k++;\n }\n }\n int[] arr = new int[k];\n k = 0;\n for (int i = 2; i < p.Length; i++)\n {\n if (!p[i])\n {\n arr[k] = i;\n k++;\n }\n }\n List r = new List();\n while (n != 1)\n {\n\n int t = 0;\n for (int i = 0; i < arr.Length; i++)\n {\n if (n % arr[i] == 0)\n {\n t = arr[i];\n break;\n }\n }\n r.Add(t);\n n /= t;\n }\n /*for (int i = 0; i < r.Count; i++)\n {\n Console.WriteLine(r[i]);\n }*/\n if (m > r.Count)\n {\n Console.WriteLine(-1);\n\n }\n else\n {\n // Console.WriteLine(r.Count);\n int ans = 1;\n for (int i = 0; i < m-1; i++)\n {\n Console.Write(r[i]+\" \");\n }\n for (int i = m-1; i < r.Count; i++)\n {\n ans *= r[i];\n }\n Console.WriteLine(ans);\n }\n \n }\n }\n}", "lang_cluster": "C#", "tags": ["math", "implementation", "number theory"], "code_uid": "3f154b190b0b54dc6b47e3e827d45328", "src_uid": "bd0bc809d52e0a17da07ccfd450a4d79", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\n\nnamespace CF3\n{\n class Program\n {\n public static int SmallDiv(int n)\n {\n int div = 1;\n for (int i = 2; i <= n/2; i++)\n if (n % i == 0)\n {\n div = i;\n break;\n }\n\n return (div == 1) ? n : div;\n }\n\n static void Main(string[] args)\n {\n string[] a = Console.ReadLine().Split(' ');\n int n = int.Parse(a[0]);\n int k = int.Parse(a[1]);\n string s = \"\";\n int div;\n\n for (int i = 0; i < k; i++)\n {\n div = SmallDiv(n);\n if(i < k - 1 && div == n)\n {\n s = \"-1\";\n break;\n }\n s += (i != k - 1) ? div : n;\n s += \" \";\n n /= div;\n }\n Console.WriteLine(s);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "implementation", "number theory"], "code_uid": "ca30631a8f1447399f33b3a32edcd556", "src_uid": "bd0bc809d52e0a17da07ccfd450a4d79", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.IO;\nusing System.Text;\n\nnamespace Logo_Turtle\n{\n internal class Program\n {\n private static readonly StreamReader reader = new StreamReader(Console.OpenStandardInput(1024*10), Encoding.ASCII, false, 1024*10);\n private static readonly StreamWriter writer = new StreamWriter(Console.OpenStandardOutput(1024*10), Encoding.ASCII, 1024*10);\n\n private static void Main(string[] args)\n {\n string s = reader.ReadLine();\n int n = int.Parse(reader.ReadLine());\n\n int sl = s.Length*2;\n var dp = new bool[n + 1,sl + 1,2];\n dp[0, s.Length, 0] = true;\n\n foreach (char c in s)\n {\n var next = new bool[n + 1,sl + 1,2];\n\n for (int i = 0; i <= n; i++)\n {\n for (int j = 0; j <= sl; j++)\n {\n if (dp[i, j, 0])\n {\n if (c == 'F')\n {\n for (int k = i; k <= n; k += 2) next[k, j + 1, 0] = true;\n for (int k = i + 1; k <= n; k += 2) next[k, j, 1] = true;\n }\n else\n {\n for (int k = i; k <= n; k += 2) next[k, j, 1] = true;\n for (int k = i + 1; k <= n; k += 2) next[k, j + 1, 0] = true;\n }\n }\n if (dp[i, j, 1])\n {\n if (c == 'F')\n {\n for (int k = i; k <= n; k += 2) next[k, j - 1, 1] = true;\n for (int k = i + 1; k <= n; k += 2) next[k, j, 0] = true;\n }\n else\n {\n for (int k = i; k <= n; k += 2) next[k, j, 0] = true;\n for (int k = i + 1; k <= n; k += 2) next[k, j - 1, 1] = true;\n }\n }\n }\n }\n\n dp = next;\n }\n\n for (int i = s.Length;; i--)\n {\n if (dp[n, s.Length - i, 0] || dp[n, s.Length - i, 1] || dp[n, s.Length + i, 0] || dp[n, s.Length + i, 1])\n {\n writer.WriteLine(i);\n break;\n }\n }\n\n writer.Flush();\n }\n }\n}", "lang_cluster": "C#", "tags": ["dp"], "code_uid": "7c1dc830ec3bfbc91bf63f54567e2aa2", "src_uid": "4a54971eb22e62b1d9e6b72f05ae361d", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\n\n\nclass Scanner\n{\n string[] s;\n int i;\n\n char[] cs = new char[] { ' ' };\n\n public Scanner()\n {\n s = new string[0];\n i = 0;\n }\n\n public string next()\n {\n if (i < s.Length) return s[i++];\n s = Console.ReadLine().Split(cs, StringSplitOptions.RemoveEmptyEntries);\n i = 0;\n return s[i++];\n }\n\n public int nextInt()\n {\n return int.Parse(next());\n }\n\n public long nextLong()\n {\n return long.Parse(next());\n }\n\n}\n\nclass Myon\n{\n Scanner cin;\n Myon() { }\n\n public static void Main()\n {\n new Myon().calc();\n }\n\n\n bool[,, ,] dp;\n int n;\n string s;\n int len;\n int ret;\n\n void calc()\n {\n cin = new Scanner();\n int i, j, k;\n s = Console.ReadLine();\n n = cin.nextInt();\n len = s.Length;\n dp = new bool[101, 300, n + 1, 2];\n ret = 0;\n dfs(0, 150, 0, 0);\n Console.WriteLine(ret);\n }\n\n\n void dfs(int now, int pos, int change, int a)\n {\n if (change > n) return;\n if (now == len)\n {\n if (change % 2 != n % 2) return;\n //Console.WriteLine(pos);\n ret = Math.Max(ret, Math.Abs(pos - 150)); return;\n }\n if (dp[now, pos, change, a]) return;\n dp[now, pos, change, a] = true;\n int memo = 1;\n if (s[now] == 'F') memo = 0;\n int v = 1;\n if (a == 1) v = -1;\n\n dfs(now + 1, pos + v, change + memo, a);\n dfs(now + 1, pos, change + (1 - memo), 1 - a);\n }\n}", "lang_cluster": "C#", "tags": ["dp"], "code_uid": "7e298b6ee3e06d980aeb5b88b2198a80", "src_uid": "4a54971eb22e62b1d9e6b72f05ae361d", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Text.RegularExpressions;\n\nnamespace D07_10_12\n{\n class Program\n {\n static void Main()\n {\n string[] s = Regex.Split(Console.ReadLine(), \" \");\n int vx = int.Parse(s[0]);\n int vy = int.Parse(s[1]);\n int vz = int.Parse(s[2]);\n s = Regex.Split(Console.ReadLine(), \" \");\n int px = int.Parse(s[0]);\n int py = int.Parse(s[1]);\n int pz = int.Parse(s[2]);\n s = Regex.Split(Console.ReadLine(), \" \");\n int n = int.Parse(s[0]);\n int v = int.Parse(s[1]);\n int d = int.Parse(s[2]);\n int b = int.Parse(s[3]);\n int l = int.Parse(s[4]);\n int p = int.Parse(s[5]);\n int sum = 0;\n if (vx > px) sum += p;\n if (vx < 0) sum += l;\n if (vy > py) sum += v;\n if (vy < 0) sum += n;\n if (vz > pz) sum += b;\n if (vz < 0) sum += d;\n Console.WriteLine(\"{0}\", sum);\n\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "geometry"], "code_uid": "a0d50b9c23b01a12242f650e74e3604f", "src_uid": "c7889a8f64c57cf7be4df870f68f749e", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\n\nnamespace CodeForces\n{\n class R143_Div2_D\n {\n static void Main(string[] args)\n {\n string[] s = (Console.ReadLine().Split());\n int x = Convert.ToInt32(s[0]);\n int y = Convert.ToInt32(s[1]);\n int z = Convert.ToInt32(s[2]);\n\n s = (Console.ReadLine().Split());\n int x1 = Convert.ToInt32(s[0]);\n int y1 = Convert.ToInt32(s[1]);\n int z1 = Convert.ToInt32(s[2]);\n\n s = (Console.ReadLine().Split());\n int[] a = new int[7];\n for (int i = 1; i <= 6; i++)\n {\n a[i] = Convert.ToInt32(s[i-1]);\n }\n \n int cnt = 0;\n if (y < 0)\n cnt += a[1];\n if (y > y1)\n cnt += a[2];\n\n if (z < 0)\n cnt += a[3];\n if (z > z1)\n cnt += a[4];\n\n if (x < 0)\n cnt += a[5]; \n if (x > x1)\n cnt += a[6];\n\n \n Console.WriteLine(cnt);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "geometry"], "code_uid": "68073b405c8e8caa61429afe24a6e9ff", "src_uid": "c7889a8f64c57cf7be4df870f68f749e", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\n\nnamespace CodeForces\n{\n class R183_Div2_D\n {\n static void Main(string[] args)\n {\n string[] s = Console.ReadLine().Split();\n int n = int.Parse(s[0]);\n int m = int.Parse(s[1]);\n int x = int.Parse(s[2]);\n int y = int.Parse(s[3]);\n int a = int.Parse(s[4]);\n int b = int.Parse(s[5]);\n int g = GCD_Euclid(a, b);\n a = a / g;\n b = b / g;\n\n int xDif = Math.Min(n - x, x - 0);\n int yDif = Math.Min(m - y, y - 0);\n\n int t = Math.Min(n / a, m / b);\n a *= t;\n b *= t;\n\n int x1, y1, x2, y2;\n x1 = x - a + (a / 2);\n y1 = y - b + (b / 2);\n x1 = Math.Min(x1, n - a);\n y1 = Math.Min(y1, m - b);\n x1 = Math.Max(x1, 0);\n y1 = Math.Max(y1, 0);\n x2 = x1 + a;\n y2 = y1 + b;\n Console.WriteLine(x1 + \" \" + y1 + \" \" + x2 + \" \" + y2);\n }\n\n static int GCD_Euclid(int a, int b)\n {\n if (b == 0) return a;\n return GCD_Euclid(b, a % b);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math"], "code_uid": "42da92796a4a2e1288054aaa5edb31e7", "src_uid": "8f1211b995f35462ae83b2be27f54585", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections;\nusing System.Collections.Generic;\nusing System.Text;\n\nnamespace Codeforces\n{\n class Program {\n\n #region input\n\n static long readLong() {\n long num;\n long.TryParse(Console.ReadLine(),out num);\n return num;\n }\n\n static ulong readULong() {\n ulong num;\n ulong.TryParse(Console.ReadLine(),out num);\n return num;\n }\n\n static int readInt() {\n int num;\n int.TryParse(Console.ReadLine(),out num);\n return num;\n }\n\n static bool readBool() {\n int num;\n int.TryParse(Console.ReadLine(),out num);\n return num != 0;\n }\n\n static long[] readLongs() {\n string[] nums = Console.ReadLine().Split(new char[] { ' ' });\n long[] parsed = new long[nums.Length];\n for(int i = 0; i < nums.Length; i++) {\n long.TryParse(nums[i],out parsed[i]);\n }\n return parsed;\n }\n\n static int[] readInts() {\n string[] nums = Console.ReadLine().Split(new char[] { ' ' });\n int[] parsed = new int[nums.Length];\n for(int i = 0; i < nums.Length; i++) {\n int.TryParse(nums[i],out parsed[i]);\n }\n return parsed;\n }\n\n static void readInts(out int a, out int b) {\n string[] nums = Console.ReadLine().Split(new char[] { ' ' });\n int[] parsed = new int[nums.Length];\n int.TryParse(nums[0],out a);\n int.TryParse(nums[1],out b);\n }\n\n static BitArray readBools() {\n string[] nums = Console.ReadLine().Split(new char[] { ' ' });\n BitArray bits = new BitArray(nums.Length);\n for(int i = 0; i < nums.Length; i++) {\n if(nums[i] != \"0\") {\n bits[i] = true;\n }\n }\n return bits;\n }\n\n static BitArray readBools(string off) {\n string[] nums = Console.ReadLine().Split(new char[] { ' ' });\n BitArray bits = new BitArray(nums.Length);\n for(int i = 0; i < nums.Length; i++) {\n if(nums[i] != off) {\n bits[i] = true;\n }\n }\n return bits;\n }\n\n static void waist() {\n Console.ReadLine();\n }\n\n #endregion\n\n #region utility\n\n static long largeModolu(long a,long b,long m) {\n long prev = a;\n long sum = (b & 1) > 0 ? a : 1;\n int digits = (int)(Math.Ceiling(Math.Log(b,2)));\n for(int i = 1; i < digits; i++) {\n prev = (prev * prev) % (m);\n if((b & (1l << i)) > 0) {\n sum = (sum * prev) % (m);\n }\n }\n return sum;\n }\n\n static long GCD(long a, long b) {\n long temp;\n if(a > b) {\n temp = b;\n b = a;\n a = temp;\n }\n while(b != 0) {\n temp = b;\n b = a % b;\n a = temp;\n }\n return a;\n }\n\n class SortableKVP where T : IComparable {\n List> data { set; get; }\n\n public int count {\n get {\n return data.Count;\n }\n }\n\n public T this[int index] {\n get {\n return data[index].Item2;\n }\n }\n\n public int originalIndex(int sortedIndex) {\n return data[sortedIndex].Item1;\n }\n\n public void sort() {\n data.Sort((a,b) => a.Item2.CompareTo(b.Item2));\n }\n\n public void add(T item) {\n data.Add(new Tuple(data.Count,item));\n }\n\n public void removeAt(int sortedIndex) {\n data.RemoveAt(sortedIndex);\n }\n\n public SortableKVP() {\n data = new List>();\n }\n\n public SortableKVP(T[] data) {\n this.data = new List>(data.Length);\n for(int i = 0; i < data.Length; i++) {\n this.data.Add(new Tuple(i,data[i]));\n }\n }\n }\n\n #endregion\n\n static void Main(string[] args) {\n long[] nmxyab = readLongs();\n long n = nmxyab[0];\n long m = nmxyab[1];\n long x = nmxyab[2];\n long y = nmxyab[3];\n long a = nmxyab[4];\n long b = nmxyab[5];\n long gcd = GCD(a,b);\n a /= gcd;\n b /= gcd;\n long multiplier = Math.Min(n / a,m / b);\n long xLength = a * multiplier;\n long yLength = b * multiplier;\n long x1 = Math.Min(n - xLength,Math.Max(0,x - (xLength + 1) / 2));\n long y1 = Math.Min(m - yLength,Math.Max(0,y - (yLength + 1) / 2));\n Console.WriteLine(x1 + \" \" + y1 + \" \" + (x1 + xLength) + \" \" + (y1 + yLength));\n }\n\n /*static void Main(string[] args) {\n BitArray primes = new BitArray(1000001,true);\n primes[0] = false;\n primes[1] = false;\n for(int i = 2; i * i <= 1000000; i++) {\n if(primes[i]) {\n for(int j = i * 2; j <= 1000000; j += i) {\n primes[j] = false;\n }\n }\n }\n int t = readInt();\n for(int r = 0; r < t; r++) {\n int[] range = readInts();\n int sum = 0;\n for(int i = range[0]; i <= range[1]; i++) {\n if(primes[i]) {\n sum++;\n }\n }\n Console.WriteLine(sum);\n }\n Console.Read();\n }*/\n\n /*static void Main(string[] args) {\n int t = readInt();\n for(int r = 0; r < t; r++) {\n waist();\n int[] nums = readInts();\n Array.Sort(nums, (a,b) => b.CompareTo(a));\n for(int i = 0; i < nums.Length; i++) {\n if((i & 1) == 0 ) {\n Console.Write(nums[i/2]);\n } else {\n Console.Write(nums[nums.Length - 1- (i-1)/2]);\n }\n if(i == nums.Length - 1) {\n Console.WriteLine(\"\");\n } else {\n Console.Write(\" \");\n }\n }\n }\n Console.Read();\n }*/\n }\n}\n//0.89493155168539774035319\n//0.894931551685397740353194\n//0.894931551685397735434921\n", "lang_cluster": "C#", "tags": ["math", "implementation"], "code_uid": "d1b019a68596c615aeece81e814ac7e3", "src_uid": "8f1211b995f35462ae83b2be27f54585", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace ConsoleApp4\n{\n class Program\n {\n static void Main(string[] args)\n {\n string[] Inp = Console.ReadLine().Split();\n int N = Convert.ToInt32(Inp[0]), K = Convert.ToInt32(Inp[1]);\n\n int Min = Int32.MaxValue;\n for (int i = 1; i < K; i++)\n {\n if (N % i == 0)\n {\n int X = (N / i) * K + i;\n if ((X / K) * (X % K) == N)\n Min = Math.Min(Min, X);\n }\n }\n\n Console.WriteLine(Min);\n }\n }\n}\n ", "lang_cluster": "C#", "tags": ["math"], "code_uid": "4047e141ba5757b1e3bb15e429de77d2", "src_uid": "ed0ebc1e484fcaea875355b5b7944c57", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace CodeForces\n{\n public class CodeForces\n {\n static void Main(string[] args)\n {\n var Inp = Console.ReadLine().Split();\n int n = Convert.ToInt32(Inp[0]);\n int k = Convert.ToInt32(Inp[1]);\n\n int min = Int32.MaxValue;\n for (int i = 1; i < k; i++)\n {\n if (n % i == 0)\n {\n int x = (n / i) * k + i;\n if ((x / k) * (x % k) == n)\n min = Math.Min(min, x);\n }\n }\n\n Console.WriteLine(min);\n\n }\n\n }\n}", "lang_cluster": "C#", "tags": ["math"], "code_uid": "9b6ebeadab491148b88b0e04f2b0e4fd", "src_uid": "ed0ebc1e484fcaea875355b5b7944c57", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeff//#define USE_FILES\n//#define MANY_TESTS_IN_INPUT\n//#define INCREASE_STACK\n\n#if ONLINE_JUDGE // Defined by Codeforces judging system\n#undef USE_FILES\n#endif\n\nusing System;\nusing System.Collections.Generic;\nusing System.IO;\nusing System.Linq;\n\nnamespace Acm\n{\n /// \n /// For the simplicity of hacking / reading / exploring.\n /// Problem solution is in this class only!\n /// \n class ProblemSolution\n {\n public LineReader In { get; }\n\n public TextWriter Out { get; }\n\n public ProblemSolution(LineReader @in, TextWriter @out)\n {\n In = @in;\n Out = @out;\n }\n\n /// \n /// \n /// \n /// For multi-test inputs: ID of test, from 1 to T\n /// For single-test inputs: -1\n /// \n public void SolveTest(int testId)\n {\n long[] line = In.Read();\n long a = line[0], b = line[1];\n \n long diff = Math.Abs(a - b);\n\n List divisors = new List();\n\n for (long divisor = 1; divisor * divisor <= diff; divisor++)\n {\n if (diff % divisor == 0)\n {\n divisors.Add(divisor);\n\n if (divisor * divisor != diff)\n divisors.Add(diff / divisor);\n }\n }\n\n long answerK = 0;\n long answerLcm = long.MaxValue;\n foreach (long divisor in divisors)\n {\n long k = (divisor - (a % divisor)) % divisor;\n long lcm = (a + k) * (b + k) / divisor;\n\n if (lcm < answerLcm)\n {\n answerLcm = lcm;\n answerK = k;\n }\n }\n\n Out.WriteLine(answerK);\n }\n }\n\n // ---------------\n // There is nothing interesting below this line!\n // ---------------\n\n class Program\n {\n private static LineReader In { get; set; }\n\n private static TextWriter Out { get; set; }\n\n public static void Main(string[] args)\n {\n#if USE_FILES\n In = new LineReader(File.OpenText(\"input.txt\"));\n Out = new StreamWriter(\"../../output.txt\", false);\n#else\n In = new LineReader(Console.In);\n Out = Console.Out;\n#endif\n\n try\n {\n#if INCREASE_STACK\n\t\t\t\tvar thread = new Thread(Solve, 32 * 1024 * 1024);\n\t\t\t\tthread.Start();\n\t\t\t\tthread.Join();\n#else\n Solve();\n#endif\n }\n finally\n {\n Out.Dispose();\n }\n }\n\n public static void Solve()\n {\n#if MANY_TESTS_IN_INPUT\n int t = In.Read();\n for (int i = 1; i <= t; i++)\n {\n new ProblemSolution(In, Out).SolveTest(i);\n }\n#else\n new ProblemSolution(In, Out).SolveTest(-1);\n#endif\n }\n }\n\n /// \n /// Input usability things\n /// \n class InputLine\n {\n private readonly string _line;\n\n public InputLine(string line)\n {\n _line = line;\n }\n\n public static implicit operator string(InputLine line)\n {\n return line._line;\n }\n\n public static implicit operator int(InputLine line)\n {\n return int.Parse(line._line);\n }\n\n public static implicit operator int[] (InputLine line)\n {\n return line._line.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(int.Parse).ToArray();\n }\n\n public static implicit operator long[] (InputLine line)\n {\n return line._line.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(long.Parse).ToArray();\n }\n }\n\n class LineReader\n {\n public TextReader Reader { get; }\n\n public LineReader(TextReader reader)\n {\n Reader = reader;\n }\n\n public InputLine Read()\n {\n string line = Reader.ReadLine();\n return line == null\n ? null\n : new InputLine(line.Trim());\n }\n }\n}", "lang_cluster": "C#", "tags": ["brute force", "math", "number theory"], "code_uid": "b58993fe6142ad755d7e4c9f70e4fb26", "src_uid": "414149fadebe25ab6097fc67663177c3", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.IO;\nusing System.Text;\n\nnamespace Neko_does_Maths\n{\n internal class Program\n {\n private static readonly StreamReader reader = new StreamReader(Console.OpenStandardInput(1024*10), Encoding.ASCII, false, 1024*10);\n private static readonly StreamWriter writer = new StreamWriter(Console.OpenStandardOutput(1024*10), Encoding.ASCII, 1024*10);\n\n private static void Main(string[] args)\n {\n writer.WriteLine(Solve(args));\n writer.Flush();\n }\n\n private static long Solve(string[] args)\n {\n long a = Next();\n long b = Next();\n\n long d = Math.Abs(a - b);\n\n long min = Math.Min(a, b);\n\n if (d == 0)\n return 0;\n\n if (min > d)\n {\n long r = a%d;\n if (r == 0)\n return 0;\n\n return d - r;\n }\n\n {\n for (long k = min; k*k<=d; k++)\n {\n if (d % k == 0)\n return k - min;\n }\n for (long k = d/min; k >= 1; k--)\n {\n if (d%k == 0)\n {\n return d/k - min;\n }\n }\n return d - min;\n }\n }\n\n private static int Next()\n {\n int c;\n int res = 0;\n do\n {\n c = reader.Read();\n if (c == -1)\n return res;\n } while (c < '0' || c > '9');\n res = c - '0';\n while (true)\n {\n c = reader.Read();\n if (c < '0' || c > '9')\n return res;\n res *= 10;\n res += c - '0';\n }\n }\n }\n}", "lang_cluster": "C#", "tags": ["brute force", "math", "number theory"], "code_uid": "46e3ae416fbefc108f8575d5c69f44b2", "src_uid": "414149fadebe25ab6097fc67663177c3", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\n\nnamespace EightPointSets\n{\n public class Point\n {\n public int x;\n public int y;\n }\n\n public class PointComparer : IComparer\n {\n public int Compare(Point p1, Point p2)\n {\n if (p1.x < p2.x)\n {\n return -1;\n }\n else if (p1.x == p2.x)\n {\n if (p1.y < p2.y)\n return -1;\n else\n return 1;\n }\n\n return 1;\n }\n }\n\n class EightPointSets\n {\n static void Main(string[] args)\n {\n string[] input;\n List point = new List();\n\n for (int i = 0; i < 8; i++)\n {\n input = Console.ReadLine().Split();\n point.Add(new Point() { x = int.Parse(input[0]), y = int.Parse(input[1]) });\n }\n\n point.Sort(new PointComparer());\n\n bool respectable = point[0].x == point[1].x && point[1].x == point[2].x &&\n point[3].x == point[4].x &&\n point[5].x == point[6].x && point[6].x == point[7].x &&\n point[0].y == point[3].y && point[3].y == point[5].y &&\n point[1].y == point[6].y &&\n point[2].y == point[4].y && point[4].y == point[7].y &&\n point[0].x < point[3].x && point[3].x < point[5].x &&\n point[0].y < point[1].y && point[1].y < point[2].y;\n\n if (!respectable)\n Console.WriteLine(\"ugly\");\n else\n Console.WriteLine(\"respectable\");\n }\n\n\n private static bool Equals(Point p1, Point p2)\n {\n if (p1.x != p2.x || p1.y != p2.y)\n return false;\n else\n return true;\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["sortings"], "code_uid": "07290293036d27f7ab83a52a0022ab7c", "src_uid": "f3c96123334534056f26b96f90886807", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace ConsoleApplication4\n{\n class Program\n {\n static void Main(string[] args)\n {\n var b = Solve();\n Console.WriteLine(b ? \"respectable\" : \"ugly\");\n }\n\n public static bool Solve()\n {\n var points = new List();\n for (int i = 0; i < 8; i++)\n {\n var line = Console.ReadLine().Split(' ');\n points.Add(new Point(int.Parse(line[0]), int.Parse(line[1])));\n }\n\n int maxX = points.Select(p => p.x).Max();\n int minX = points.Select(p => p.x).Min();\n int maxY = points.Select(p => p.y).Max();\n int minY = points.Select(p => p.y).Min();\n\n int midX, midY;\n try\n {\n midX = points.Select(p => p.x).Where(x => x < maxX && x > minX).First();\n midY = points.Select(p => p.y).Where(y => y < maxY && y > minY).First();\n }\n catch { return false; }\n\n if (points.Contains(new Point(minX, minY)) &&\n points.Contains(new Point(midX, minY)) &&\n points.Contains(new Point(maxX, minY)) &&\n points.Contains(new Point(minX, midY)) &&\n points.Contains(new Point(maxX, midY)) &&\n points.Contains(new Point(minX, maxY)) &&\n points.Contains(new Point(midX, maxY)) &&\n points.Contains(new Point(maxX, maxY)))\n return true;\n else\n return false;\n }\n struct Point\n {\n public int x;\n public int y;\n\n public Point(int x, int y)\n {\n this.x = x;\n this.y = y;\n }\n\n public override bool Equals(object obj)\n {\n var p = (Point)obj;\n return p.x == x && p.y == y;\n }\n\n public override int GetHashCode()\n {\n return x.GetHashCode() ^ y.GetHashCode();\n }\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["sortings"], "code_uid": "db825f85e36ea7de77ddf7a71d4c9a5a", "src_uid": "f3c96123334534056f26b96f90886807", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\nusing System;\nusing System.Collections.Generic;\nusing System.IO;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace AlgoTraining.Codeforces.AprilFool2016\n{\n\n class FastScanner : StreamReader\n {\n private string[] _line;\n private int _iterator;\n\n public FastScanner(Stream stream) : base(stream)\n {\n _line = null;\n _iterator = 0;\n }\n public int NextInt()\n {\n if (_line == null || _iterator >= _line.Length)\n {\n _line = base.ReadLine().Split(' ');\n _iterator = 0;\n }\n if (_line.Count() == 0) throw new IndexOutOfRangeException(\"Input string is empty\");\n return Convert.ToInt32(_line[_iterator++]);\n }\n public long NextLong()\n {\n if (_line == null || _iterator >= _line.Length)\n {\n _line = base.ReadLine().Split(' ');\n _iterator = 0;\n }\n if (_line.Count() == 0) throw new IndexOutOfRangeException(\"Input string is empty\");\n return Convert.ToInt64(_line[_iterator++]);\n }\n }\n class ScrambledB\n {\n public static void Main(string[] args)\n {\n using (FastScanner fs = new FastScanner(new BufferedStream(Console.OpenStandardInput())))\n using (StreamWriter writer = new StreamWriter(new BufferedStream(Console.OpenStandardOutput())))\n {\n int n = fs.NextInt();\n int[] m = new int[n], r = new int[n];\n for (int i = 0; i < n; i++) m[i] = fs.NextInt();\n for (int i = 0; i < n; i++) r[i] = fs.NextInt();\n int size = (int)1e6;\n bool[] onDuty = new bool[size];\n for (int i = 0; i < size; i++)\n {\n for (int j = 0; j < n; j++)\n {\n if (i % m[j] == r[j])\n {\n onDuty[i] = true;\n break;\n }\n }\n }\n int count = 0;\n for (int i = 0; i < size; i++)\n {\n if (onDuty[i]) count++;\n }\n writer.WriteLine(((count * 1.0) / size).ToString().Replace(\",\", \".\"));\n }\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "f3e1a568c12a9ce7b9e1d5158f58f8d9", "src_uid": "14b69f42bc192ea472e82f3a3209f1c1", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\n\nnamespace Task1\n{\n class Program\n {\n static void Main(string[] args)\n {\n Console.ReadLine();\n var M = Console.ReadLine().Split(' ').Select(Int32.Parse).ToArray();\n var R = Console.ReadLine().Split(' ').Select(Int32.Parse).ToArray();\n\n int res=0;\n for (int i = 0; i < 1000000; i++)\n {\n for (int z = 0; z < M.Length; z++)\n if (i % M[z] == R[z]) { res++; break; }\n }\n Console.WriteLine(String.Format(\"{0:0.000000}\", (double)res / 1000000).Replace(',','.'));\n\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "08ba941e20b7fbbfd42fce8e51668c9e", "src_uid": "14b69f42bc192ea472e82f3a3209f1c1", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Linq;\nusing System.Collections.Generic;\nusing System.Diagnostics;\nusing Debug = System.Diagnostics.Trace;\nusing SB = System.Text.StringBuilder;\nusing System.Numerics;\nusing static System.Math;\nusing Number = System.Int32;\nnamespace Program {\n\tpublic class Solver {\n\t\tRandom rnd = new Random(1);\n\t\tpublic void Solve() {\n\t\t\tvar n = ri;\n\t\t\tvar m = ri;\n\n\t\t\tvar max = Max(n, m);\n\t\t\t//i-j \u304c\u6b63\u306b\u306a\u3089\u306a\u3044\u3088\u3046\u306a\u3084\u3064\n\t\t\tvar pat = new ModInt[max + 5, max + 5];\n\t\t\tpat[0, 0] = 1;\n\t\t\tfor (int i = 0; i <= max; i++)\n\t\t\t\tfor (int j = 0; j <= max; j++) {\n\t\t\t\t\tif (i < j) pat[i + 1, j] += pat[i, j];\n\t\t\t\t\tpat[i, j + 1] += pat[i, j];\n\t\t\t\t}\n\t\t\tModInt ans = 0;\n\t\t\tfor (int i = 0; i <= n; i++)\n\t\t\t\tfor (int j = 0; j <= m; j++) {\n\t\t\t\t\tif (i - j <= 0) continue;\n\t\t\t\t\t//Debug.WriteLine($\"{i} {j} {pat[j, i]} {pat[n - i, m - j]}\");\n\t\t\t\t\tans += (i - j) * pat[n - i, m - j] * pat[j, i - 1];\n\t\t\t\t}\n\t\t\t//\n\t\t\t//+--+\n\t\t\t//+-+-\n\n\t\t\tConsole.WriteLine(ans);\n\n\t\t}\n\t\tconst long INF = 1L << 60;\n\t\tstatic int[] dx = { -1, 0, 1, 0 };\n\t\tstatic int[] dy = { 0, 1, 0, -1 };\n\t\tint ri { get { return sc.Integer(); } }\n\t\tlong rl { get { return sc.Long(); } }\n\t\tdouble rd { get { return sc.Double(); } }\n\t\tstring rs { get { return sc.Scan(); } }\n\t\tpublic IO.StreamScanner sc = new IO.StreamScanner(Console.OpenStandardInput());\n\n\t\tstatic T[] Enumerate(int n, Func f) {\n\t\t\tvar a = new T[n];\n\t\t\tfor (int i = 0; i < a.Length; ++i) a[i] = f(i);\n\t\t\treturn a;\n\t\t}\n\t\tstatic public void Swap(ref T a, ref T b) { var tmp = a; a = b; b = tmp; }\n\t}\n}\n\n#region main\nstatic class Ex {\n\tstatic public string AsString(this IEnumerable ie) { return new string(ie.ToArray()); }\n\tstatic public string AsJoinedString(this IEnumerable ie, string st = \" \") {\n\t\treturn string.Join(st, ie);\n\t}\n\tstatic public void Main() {\n\t\tConsole.SetOut(new Program.IO.Printer(Console.OpenStandardOutput()) { AutoFlush = false });\n\t\tvar solver = new Program.Solver();\n\t\tvar t = new System.Threading.Thread(solver.Solve, 50000000);\n\t\tt.Start();\n\t\tt.Join();\n\t\t//solver.Solve();\n\t\tConsole.Out.Flush();\n\t}\n}\n#endregion\n#region Ex\nnamespace Program.IO {\n\tusing System.IO;\n\tusing System.Text;\n\tusing System.Globalization;\n\n\tpublic class Printer : StreamWriter {\n\t\tpublic override IFormatProvider FormatProvider { get { return CultureInfo.InvariantCulture; } }\n\t\tpublic Printer(Stream stream) : base(stream, new UTF8Encoding(false, true)) { }\n\t}\n\n\tpublic class StreamScanner {\n\t\tpublic StreamScanner(Stream stream) { str = stream; }\n\n\t\tpublic readonly Stream str;\n\t\tprivate readonly byte[] buf = new byte[1024];\n\t\tprivate int len, ptr;\n\t\tpublic bool isEof = false;\n\t\tpublic bool IsEndOfStream { get { return isEof; } }\n\n\t\tprivate byte read() {\n\t\t\tif (isEof) return 0;\n\t\t\tif (ptr >= len) {\n\t\t\t\tptr = 0;\n\t\t\t\tif ((len = str.Read(buf, 0, 1024)) <= 0) {\n\t\t\t\t\tisEof = true;\n\t\t\t\t\treturn 0;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn buf[ptr++];\n\t\t}\n\n\t\tpublic char Char() {\n\t\t\tbyte b = 0;\n\t\t\tdo b = read(); while ((b < 33 || 126 < b) && !isEof);\n\t\t\treturn (char)b;\n\t\t}\n\t\tpublic string Scan() {\n\t\t\tvar sb = new StringBuilder();\n\t\t\tfor (var b = Char(); b >= 33 && b <= 126; b = (char)read()) sb.Append(b);\n\t\t\treturn sb.ToString();\n\t\t}\n\t\tpublic string ScanLine() {\n\t\t\tvar sb = new StringBuilder();\n\t\t\tfor (var b = Char(); b != '\\n' && b != 0; b = (char)read()) if (b != '\\r') sb.Append(b);\n\t\t\treturn sb.ToString();\n\t\t}\n\t\tpublic long Long() { return isEof ? long.MinValue : long.Parse(Scan()); }\n\t\tpublic int Integer() { return isEof ? int.MinValue : int.Parse(Scan()); }\n\t\tpublic double Double() { return isEof ? double.NaN : double.Parse(Scan(), CultureInfo.InvariantCulture); }\n\t}\n}\n\n#endregion\n\n#region ModInt\n/// \n/// [0,) \u307e\u3067\u306e\u5024\u3092\u53d6\u308b\u3088\u3046\u306a\u6570\n/// \npublic struct ModInt {\n\t/// \n\t/// \u5270\u4f59\u3092\u53d6\u308b\u5024\uff0e\n\t/// \n\tpublic const long Mod = (int)998244853;\n\n\t/// \n\t/// \u5b9f\u969b\u306e\u6570\u5024\uff0e\n\t/// \n\tpublic long num;\n\t/// \n\t/// \u5024\u304c \u3067\u3042\u308b\u3088\u3046\u306a\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u3092\u69cb\u7bc9\u3057\u307e\u3059\uff0e\n\t/// \n\t/// \u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u304c\u6301\u3064\u5024\n\t/// \u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u306e\u554f\u984c\u4e0a\uff0c\u30b3\u30f3\u30b9\u30c8\u30e9\u30af\u30bf\u5185\u3067\u306f\u5270\u4f59\u3092\u53d6\u308a\u307e\u305b\u3093\uff0e\u305d\u306e\u305f\u3081\uff0c \u2208 [0,) \u3092\u6e80\u305f\u3059\u3088\u3046\u306a \u3092\u6e21\u3057\u3066\u304f\u3060\u3055\u3044\uff0e\u3053\u306e\u30b3\u30f3\u30b9\u30c8\u30e9\u30af\u30bf\u306f O(1) \u3067\u5b9f\u884c\u3055\u308c\u307e\u3059\uff0e\n\tpublic ModInt(long n) { num = n; }\n\t/// \n\t/// \u3053\u306e\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u306e\u6570\u5024\u3092\u6587\u5b57\u5217\u306b\u5909\u63db\u3057\u307e\u3059\uff0e\n\t/// \n\t/// [0,) \u306e\u7bc4\u56f2\u5185\u306e\u6574\u6570\u3092 10 \u9032\u8868\u8a18\u3057\u305f\u3082\u306e\uff0e\n\tpublic override string ToString() { return num.ToString(); }\n\tpublic static ModInt operator +(ModInt l, ModInt r) { l.num += r.num; if (l.num >= Mod) l.num -= Mod; return l; }\n\tpublic static ModInt operator -(ModInt l, ModInt r) { l.num -= r.num; if (l.num < 0) l.num += Mod; return l; }\n\tpublic static ModInt operator *(ModInt l, ModInt r) { return new ModInt(l.num * r.num % Mod); }\n\tpublic static implicit operator ModInt(long n) { n %= Mod; if (n < 0) n += Mod; return new ModInt(n); }\n\n\t/// \n\t/// \u4e0e\u3048\u3089\u308c\u305f 2 \u3064\u306e\u6570\u5024\u304b\u3089\u3079\u304d\u5270\u4f59\u3092\u8a08\u7b97\u3057\u307e\u3059\uff0e\n\t/// \n\t/// \u3079\u304d\u4e57\u306e\u5e95\n\t/// \u3079\u304d\u6307\u6570\n\t/// \u7e70\u308a\u8fd4\u3057\u4e8c\u4e57\u6cd5\u306b\u3088\u308a O(N log N) \u3067\u5b9f\u884c\u3055\u308c\u307e\u3059\uff0e\n\tpublic static ModInt Pow(ModInt v, long k) { return Pow(v.num, k); }\n\n\t/// \n\t/// \u4e0e\u3048\u3089\u308c\u305f 2 \u3064\u306e\u6570\u5024\u304b\u3089\u3079\u304d\u5270\u4f59\u3092\u8a08\u7b97\u3057\u307e\u3059\uff0e\n\t/// \n\t/// \u3079\u304d\u4e57\u306e\u5e95\n\t/// \u3079\u304d\u6307\u6570\n\t/// \u7e70\u308a\u8fd4\u3057\u4e8c\u4e57\u6cd5\u306b\u3088\u308a O(N log N) \u3067\u5b9f\u884c\u3055\u308c\u307e\u3059\uff0e\n\tpublic static ModInt Pow(long v, long k) {\n\t\tlong ret = 1;\n\t\tfor (k %= Mod - 1; k > 0; k >>= 1, v = v * v % Mod)\n\t\t\tif ((k & 1) == 1) ret = ret * v % Mod;\n\t\treturn new ModInt(ret);\n\t}\n\t/// \n\t/// \u4e0e\u3048\u3089\u308c\u305f\u6570\u306e\u9006\u5143\u3092\u8a08\u7b97\u3057\u307e\u3059\uff0e\n\t/// \n\t/// \u9006\u5143\u3092\u53d6\u308b\u5bfe\u8c61\u3068\u306a\u308b\u6570\n\t/// \u9006\u5143\u3068\u306a\u308b\u3088\u3046\u306a\u5024\n\t/// \u6cd5\u304c\u7d20\u6570\u3067\u3042\u308b\u3053\u3068\u3092\u4eee\u5b9a\u3057\u3066\uff0c\u30d5\u30a7\u30eb\u30de\u30fc\u306e\u5c0f\u5b9a\u7406\u306b\u5f93\u3063\u3066\u9006\u5143\u3092 O(log N) \u3067\u8a08\u7b97\u3057\u307e\u3059\uff0e\n\tpublic static ModInt Inverse(ModInt v) { return Pow(v, Mod - 2); }\n}\n#endregion\n#region Binomial Coefficient\npublic class BinomialCoefficient {\n\tpublic ModInt[] fact, ifact;\n\tpublic BinomialCoefficient(int n) {\n\t\tfact = new ModInt[n + 1];\n\t\tifact = new ModInt[n + 1];\n\t\tfact[0] = 1;\n\t\tfor (int i = 1; i <= n; i++)\n\t\t\tfact[i] = fact[i - 1] * i;\n\t\tifact[n] = ModInt.Inverse(fact[n]);\n\t\tfor (int i = n - 1; i >= 0; i--)\n\t\t\tifact[i] = ifact[i + 1] * (i + 1);\n\t\tifact[0] = ifact[1];\n\t}\n\tpublic ModInt this[int n, int r] {\n\t\tget {\n\t\t\tif (n < 0 || n >= fact.Length || r < 0 || r > n) return 0;\n\t\t\treturn fact[n] * ifact[n - r] * ifact[r];\n\t\t}\n\t}\n\tpublic ModInt RepeatedCombination(int n, int k) {\n\t\tif (k == 0) return 1;\n\t\treturn this[n + k - 1, k];\n\t}\n}\n#endregion\n", "lang_cluster": "C#", "tags": ["math", "dp", "combinatorics", "number theory"], "code_uid": "d1d02a002d7cbaa97710e483c3dbd459", "src_uid": "a2fcad987e9b2bb3e6395654cd4fcfbb", "difficulty": 2300.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.IO;\nusing System.Runtime.CompilerServices;\nusing System.Text;\nusing System.Diagnostics;\nusing System.Numerics;\nusing static System.Console;\nusing static System.Convert;\nusing static System.Math;\nusing static Template;\nusing Pi = Pair;\n\nclass Solver\n{\n public void Solve(Scanner sc)\n {\n int N, M;\n sc.Make(out N, out M);\n ModInt.Build(4040);\n var zero = Create(N + 1, () => new ModInt[Max(N,M) + 1]);\n for (int i = 0; i < Max(N,M) + 1; i++)\n {\n zero[0][i] = 1;\n }\n for (int i = 1; i <= N; i++)\n for (int j = i; j <= Max(M,N); j++)\n {\n zero[i][j] = zero[i - 1][j] + zero[i][j - 1];\n }\n var dp = Create(N + 1, () => new ModInt[M + 1]);\n //1,-1\u3092\u5148\u982d\u306b\u8ffd\u52a0\u3059\u308b\n for (int i = 1; i <= N; i++)\n for (int j = 0; j <= M; j++)\n {\n dp[i][j] += dp[i - 1][j];\n dp[i][j] += ModInt.Comb(i - 1 + j, i - 1);//\u5148\u982d\u306b1\u3092\u8ffd\u52a0\u3059\u308b\u3068max\u306f1\u5897\u3048\u308b\n if (j > 0)\n {\n dp[i][j] += dp[i][j - 1];\n //\u5148\u982d\u306b-1\u3092\u8ffd\u52a0\u3059\u308b\u3068max\u306f\u5143\u304b\u30890\u3067\u3042\u308b\u3082\u306e\u3092\u9664\u3044\u30661\u6e1b\u308b\n dp[i][j] -= ModInt.Comb(i + j - 1, i) - zero[i][j - 1];\n }\n }\n Console.WriteLine(dp[N][M]);\n }\n}\n\npublic struct ModInt\n{\n //public const long MOD = (int)1e9 + 7;\n public const long MOD = 998244853;\n public long Value { get; set; }\n public ModInt(long n = 0) { Value = n; }\n private static ModInt[] fac;//i!\n private static ModInt[] inv;//1/i\n private static ModInt[] facinv;//1/(i!)\n public override string ToString() => Value.ToString();\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static ModInt operator +(ModInt l, ModInt r)\n {\n l.Value += r.Value;\n if (l.Value >= MOD) l.Value -= MOD;\n return l;\n }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static ModInt operator -(ModInt l, ModInt r)\n {\n l.Value -= r.Value;\n if (l.Value < 0) l.Value += MOD;\n return l;\n }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static ModInt operator *(ModInt l, ModInt r) => new ModInt(l.Value * r.Value % MOD);\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static ModInt operator /(ModInt l, ModInt r) => l * Pow(r, MOD - 2);\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static implicit operator long(ModInt l) => l.Value;\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static implicit operator ModInt(long n)\n {\n n %= MOD; if (n < 0) n += MOD;\n return new ModInt(n);\n }\n\n public static ModInt Pow(ModInt m, long n)\n {\n if (n == 0) return 1;\n if (n % 2 == 0) return Pow(m * m, n >> 1);\n else return Pow(m * m, n >> 1) * m;\n }\n\n public static void Build(int n)\n {\n fac = new ModInt[n + 1];\n facinv = new ModInt[n + 1];\n inv = new ModInt[n + 1];\n inv[1] = 1;\n fac[0] = fac[1] = 1;\n facinv[0] = facinv[1] = 1;\n for (var i = 2; i <= n; i++)\n {\n fac[i] = fac[i - 1] * i;\n inv[i] = MOD - inv[MOD % i] * (MOD / i);\n facinv[i] = facinv[i - 1] * inv[i];\n }\n }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static ModInt Fac(ModInt n) => fac[n];\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static ModInt Inv(ModInt n) => inv[n];\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static ModInt FacInv(ModInt n) => facinv[n];\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static ModInt Comb(ModInt n, ModInt r)\n {\n if (n < r) return 0;\n if (n == r) return 1;\n var calc = fac[n];\n calc = calc * facinv[r];\n calc = calc * facinv[n - r];\n return calc;\n }\n}\n#region Template\npublic static class Template\n{\n static void Main(string[] args)\n {\n Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });\n new Solver().Solve(new Scanner());\n Console.Out.Flush();\n }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static bool chmin(ref T a, T b) where T : IComparable { if (a.CompareTo(b) > 0) { a = b; return true; } return false; }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static bool chmax(ref T a, T b) where T : IComparable { if (a.CompareTo(b) < 0) { a = b; return true; } return false; }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static void swap(ref T a, ref T b) { var t = b; b = a; a = t; }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static void swap(this IList A, int i, int j) { var t = A[i]; A[i] = A[j]; A[j] = t; }\n public static T[] Create(int n, Func f) { var rt = new T[n]; for (var i = 0; i < rt.Length; ++i) rt[i] = f(); return rt; }\n public static T[] Create(int n, Func f) { var rt = new T[n]; for (var i = 0; i < rt.Length; ++i) rt[i] = f(i); return rt; }\n public static IEnumerable Shuffle(this IEnumerable A) => A.OrderBy(v => Guid.NewGuid());\n public static int CompareTo(this T[] A, T[] B, Comparison cmp = null) { cmp = cmp ?? Comparer.Default.Compare; for (var i = 0; i < Min(A.Length, B.Length); i++) { int c = cmp(A[i], B[i]); if (c > 0) return 1; else if (c < 0) return -1; } if (A.Length == B.Length) return 0; if (A.Length > B.Length) return 1; else return -1; }\n public static int MaxElement(this IList A, Comparison cmp = null) { cmp = cmp ?? Comparer.Default.Compare; T max = A[0]; int rt = 0; for (int i = 1; i < A.Count; i++) if (cmp(max, A[i]) < 0) { max = A[i]; rt = i; } return rt; }\n public static T PopBack(this List A) { var v = A[A.Count - 1]; A.RemoveAt(A.Count - 1); return v; }\n public static void Fail(T s) { Console.WriteLine(s); Console.Out.Close(); Environment.Exit(0); }\n}\npublic class Scanner\n{\n public string Str => Console.ReadLine().Trim();\n public int Int => int.Parse(Str);\n public long Long => long.Parse(Str);\n public double Double => double.Parse(Str);\n public int[] ArrInt => Str.Split(' ').Select(int.Parse).ToArray();\n public long[] ArrLong => Str.Split(' ').Select(long.Parse).ToArray();\n public char[][] Grid(int n) => Create(n, () => Str.ToCharArray());\n public int[] ArrInt1D(int n) => Create(n, () => Int);\n public long[] ArrLong1D(int n) => Create(n, () => Long);\n public int[][] ArrInt2D(int n) => Create(n, () => ArrInt);\n public long[][] ArrLong2D(int n) => Create(n, () => ArrLong);\n private Queue q = new Queue();\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public T Next() { if (q.Count == 0) foreach (var item in Str.Split(' ')) q.Enqueue(item); return (T)Convert.ChangeType(q.Dequeue(), typeof(T)); }\n public void Make(out T1 v1) => v1 = Next();\n public void Make(out T1 v1, out T2 v2) { v1 = Next(); v2 = Next(); }\n public void Make(out T1 v1, out T2 v2, out T3 v3) { Make(out v1, out v2); v3 = Next(); }\n public void Make(out T1 v1, out T2 v2, out T3 v3, out T4 v4) { Make(out v1, out v2, out v3); v4 = Next(); }\n public void Make(out T1 v1, out T2 v2, out T3 v3, out T4 v4, out T5 v5) { Make(out v1, out v2, out v3, out v4); v5 = Next(); }\n public void Make(out T1 v1, out T2 v2, out T3 v3, out T4 v4, out T5 v5, out T6 v6) { Make(out v1, out v2, out v3, out v4, out v5); v6 = Next(); }\n public void Make(out T1 v1, out T2 v2, out T3 v3, out T4 v4, out T5 v5, out T6 v6, out T7 v7) { Make(out v1, out v2, out v3, out v4, out v5, out v6); v7 = Next(); }\n //public (T1, T2) Make() { Make(out T1 v1, out T2 v2); return (v1, v2); }\n //public (T1, T2, T3) Make() { Make(out T1 v1, out T2 v2, out T3 v3); return (v1, v2, v3); }\n //public (T1, T2, T3, T4) Make() { Make(out T1 v1, out T2 v2, out T3 v3, out T4 v4); return (v1, v2, v3, v4); }\n}\npublic class Pair : IComparable>\n{\n public T1 v1;\n public T2 v2;\n public Pair() { }\n public Pair(T1 v1, T2 v2)\n { this.v1 = v1; this.v2 = v2; }\n\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public int CompareTo(Pair p)\n {\n var c = Comparer.Default.Compare(v1, p.v1);\n if (c == 0)\n c = Comparer.Default.Compare(v2, p.v2);\n return c;\n }\n public override string ToString() => $\"{v1.ToString()} {v2.ToString()}\";\n public void Deconstruct(out T1 a, out T2 b) { a = v1; b = v2; }\n}\n\npublic class Pair : Pair, IComparable>\n{\n public T3 v3;\n public Pair() : base() { }\n public Pair(T1 v1, T2 v2, T3 v3) : base(v1, v2)\n { this.v3 = v3; }\n\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public int CompareTo(Pair p)\n {\n var c = base.CompareTo(p);\n if (c == 0)\n c = Comparer.Default.Compare(v3, p.v3);\n return c;\n }\n public override string ToString() => $\"{base.ToString()} {v3.ToString()}\";\n public void Deconstruct(out T1 a, out T2 b, out T3 c) { Deconstruct(out a, out b); c = v3; }\n}\n#endregion\n", "lang_cluster": "C#", "tags": ["math", "dp", "combinatorics", "number theory"], "code_uid": "b10e2b829224eda3306a2c9b7e3088bf", "src_uid": "a2fcad987e9b2bb3e6395654cd4fcfbb", "difficulty": 2300.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Linq;\n\nclass Program\n{\n static void Main()\n {\n string str = Console.ReadLine();\n var data = str.Split(new char[] { ' ' });\n\n int a = int.Parse(data[0]);\n int b = int.Parse(data[1]);\n\n str = Console.ReadLine();\n\n int x = 0, y = 0;\n\n if (a == 0 && b == 0)\n {\n Console.WriteLine(\"Yes\");\n return;\n }\n\n for (int i = 0; i < str.Length; i++)\n {\n if (str[i] == 'U') y += 1;\n if (str[i] == 'D') y -= 1;\n if (str[i] == 'L') x -= 1;\n if (str[i] == 'R') x += 1;\n\n if (x == a && y == b)\n {\n Console.WriteLine(\"Yes\");\n return;\n }\n }\n\n int xe = x, ye = y;\n x = y = 0;\n\n if (xe == 0 && ye == 0)\n {\n Console.WriteLine(\"No\");\n return;\n }\n\n for (int i = 0; i < str.Length; i++)\n {\n if (xe != 0 && (a - x) % xe == 0)\n {\n int step = (a - x) / xe;\n\n if (step > 0 && ye * step + y == b)\n {\n Console.WriteLine(\"Yes\");\n return;\n }\n }\n else if (ye != 0 && (b - y) % ye == 0)\n {\n int step = (b - y) / ye;\n\n if (step > 0 && xe * step + x == a)\n {\n Console.WriteLine(\"Yes\");\n return;\n }\n }\n\n if (str[i] == 'U') y += 1;\n if (str[i] == 'D') y -= 1;\n if (str[i] == 'L') x -= 1;\n if (str[i] == 'R') x += 1;\n\n if (xe != 0 && (a - x) % xe == 0)\n {\n int step = (a - x) / xe;\n\n if (step > 0 && ye * step + y == b)\n {\n Console.WriteLine(\"Yes\");\n return;\n }\n }\n else if (ye != 0 && (b - y) % ye == 0)\n {\n int step = (b - y) / ye;\n\n if (step > 0 && xe * step + x == a)\n {\n Console.WriteLine(\"Yes\");\n return;\n }\n }\n }\n\n Console.WriteLine(\"No\");\n }\n}", "lang_cluster": "C#", "tags": ["math", "implementation", "number theory"], "code_uid": "e288daea2caed47df302b225322aafb9", "src_uid": "5d6212e28c7942e9ff4d096938b782bf", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace ACM\n{\n class Program\n {\n static void Read(ref int a, ref int b, ref string cmd)\n {\n string in_s = Console.ReadLine();\n string[] pama = in_s.Split(' ');\n a = Convert.ToInt32(pama[0]);\n b = Convert.ToInt32(pama[1]);\n cmd = Console.ReadLine();\n }\n static int check(int dx, int cur_x, int aim_x)\n {\n aim_x -= cur_x;\n if (dx == 0)\n {\n if (aim_x == 0) return -1;\n else return -2;\n }\n else\n {\n if (aim_x % dx == 0 && aim_x / dx >= 0) return aim_x / dx;\n else return -2;\n }\n }\n static void Main(string[] args)\n {\n int a, b;\n string cmd;\n a = b = 0;\n cmd = \"\";\n Read(ref a,ref b,ref cmd);\n int dx, dy;\n dx = dy = 0;\n for (int i = 0; i < cmd.Length; i++)\n {\n // Console.Write(cmd[i]);\n switch (cmd[i])\n {\n case 'D': dy--; break;\n case 'U': dy++; break;\n case 'L': dx--; break;\n case 'R': dx++; break;\n }\n }\n int px, py;\n bool flag;\n px = py = 0;\n flag = false;\n // Console.WriteLine(\"{0} {1}\", dx, dy);\n for (int i = 0; i < cmd.Length; i++)\n {\n //Console.WriteLine(\"{0}, {1}\", px, py);\n int f1 = check(dx, px, a);\n int f2 = check(dy, py, b);\n if(f1 >= -1 && f2 >= -1 && (f1 == f2 || f1 == -1 || f2 == -1))\n {\n flag = true;\n break;\n }\n switch (cmd[i])\n {\n case 'D': py--; break;\n case 'U': py++; break;\n case 'L': px--; break;\n case 'R': px++; break;\n }\n \n }\n if(flag)Console.WriteLine(\"Yes\");\n else Console.WriteLine(\"No\");\n\n\n\n\n\n\n\n\n//while (true) ;\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "implementation", "number theory"], "code_uid": "e1f9a39b38a707b30feb922f7bba6379", "src_uid": "5d6212e28c7942e9ff4d096938b782bf", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.IO;\nusing System.Linq;\nusing System.Text;\n\nclass Program\n{\n private static int Next()\n {\n int c;\n int res = 0;\n do\n {\n c = reader.Read();\n if (c == -1)\n return res;\n } while (c < '0' || c > '9');\n res = c - '0';\n while (true)\n {\n c = reader.Read();\n if (c < '0' || c > '9')\n return res;\n res *= 10;\n res += c - '0';\n }\n }\n private static readonly StreamReader reader = new StreamReader(Console.OpenStandardInput(1024 * 10), Encoding.ASCII, false, 1024 * 10);\n private static readonly StreamWriter writer = new StreamWriter(Console.OpenStandardOutput(1024 * 10), Encoding.ASCII, 1024 * 10);\n\n\n static string getNext(string current)\n {\n if (current.Length == 1)\n {\n var num = int.Parse(current);\n if (num < 9)\n {\n return (num + 1).ToString();\n }\n else\n {\n return (11).ToString();\n }\n }\n var first = int.Parse(current[0].ToString());\n var last = int.Parse(current[current.Length - 1].ToString());\n\n var sb = new StringBuilder(current);\n for (var i = 1; i < current.Length - 1; i++)\n {\n sb[i] = '0';\n }\n\n if (last < first)\n {\n last = first;\n\n sb[current.Length - 1] = char.Parse(last.ToString());\n return sb.ToString();\n }\n else\n {\n first++;\n if (first == 10)\n {\n first = 1;\n sb.Insert(0, char.Parse(first.ToString()));\n }\n last = first;\n sb[current.Length - 1] = char.Parse(last.ToString());\n sb[0] = char.Parse(first.ToString());\n return sb.ToString();\n }\n\n }\n\n static List GetAllGcd(int num)\n {\n var all = new List();\n for (int i = 2; i * i <= num; i++)\n {\n if (num % i == 0)\n {\n all.Add(i);\n }\n if (num % i == 0 && num / i != i)\n {\n all.Add(num / i);\n }\n }\n return all;\n }\n\n static int[] getWinningPos(int s)\n {\n var result = new int[25];\n var i = (s / 50) % 475;\n for(var j = 0; j < 25; j++)\n {\n i = (i * 96 + 42) % 475;\n result[j] = 26 + i;\n }\n return result;\n }\n static void Main(String[] args)\n {\n var data = Console.ReadLine().Split(' ').Select(int.Parse).ToList();\n var place = data[0];\n var score = data[1];\n var enoughWinningPoints = data[2];\n\n var winningPos = getWinningPos(score);\n\n var posScore = score;\n while(posScore >= enoughWinningPoints)\n {\n winningPos = getWinningPos(posScore);\n for (var i = 0; i < 25; i++)\n {\n if (winningPos[i] == place)\n {\n Console.WriteLine(0);\n return;\n }\n }\n posScore -= 50;\n }\n\n var second = 0;\n long result = 0;\n posScore = score + 50;\n while (true)\n {\n if(second % 2 == 0)\n {\n result++;\n }\n winningPos = getWinningPos(posScore);\n for (var i = 0; i < 25; i++)\n {\n if (winningPos[i] == place)\n {\n Console.WriteLine(result);\n return;\n }\n }\n posScore += 50;\n second++;\n }\n\n\n }\n}", "lang_cluster": "C#", "tags": ["brute force", "implementation"], "code_uid": "b48f897c0af7de9f1318a8b0b012a859", "src_uid": "c9c22e03c70a94a745b451fc79e112fd", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\n\nclass PairVariable : IComparable\n{\n public int a, b;\n public PairVariable()\n {\n a = b = 0;\n }\n public PairVariable(string s)\n {\n string[] q = s.Split();\n a = int.Parse(q[0]);\n b = int.Parse(q[1]);\n }\n public PairVariable(int a, int b)\n {\n this.a = a;\n this.b = b;\n\n }\n\n\n\n public int CompareTo(PairVariable other)\n {\n return this.a.CompareTo(other.a);\n }\n}\n\nnamespace ConsoleApplication254\n{\n\n class Program\n {\n\n static bool foo(int x, int p)\n {\n\n long ii = (x / 50) % 475;\n List t = new List();\n for (long i = 0; i < 25; i++)\n {\n\n\n ii = (ii * 96 + 42) % 475;\n\n if (ii + 26 == p) \n {\n return true;\n }\n }\n \n return false;\n }\n static void Main(string[] args)\n {\n string[] ss = Console.ReadLine().Split();\n int p = int.Parse(ss[0]);\n int x = int.Parse(ss[1]);\n int y = int.Parse(ss[2]);\n if (foo(x, p))\n {\n Console.WriteLine(0);\n return;\n }\n while (true)\n {\n if (foo(y, p) && Math.Abs(y - x) % 50 == 0)\n {\n break;\n }\n y++;\n }\n if (y < x)\n {\n Console.WriteLine(0);\n }\n else\n {\n if ((x - y) % 100 == 0)\n {\n Console.WriteLine((y - x) / 100);\n }\n else\n {\n Console.WriteLine((y-(x-50)) / 100);\n }\n }\n\n }\n }\n}", "lang_cluster": "C#", "tags": ["brute force", "implementation"], "code_uid": "e65a95afaae609ea46e2f1aa72958d41", "src_uid": "c9c22e03c70a94a745b451fc79e112fd", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": ".NET Core C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Globalization;\nusing System.IO;\nusing System.Linq;\nusing System.Text;\nusing System.Threading;\n\n// (\u3065\u00b0\u03c9\u00b0)\u3065\uff90e\u2605\u309c\u30fb\u3002\u3002\u30fb\u309c\u309c\u30fb\u3002\u3002\u30fb\u309c\u2606\u309c\u30fb\u3002\u3002\u30fb\u309c\u309c\u30fb\u3002\u3002\u30fb\u309c\npublic class Solution\n{\n public void Solve()\n {\n for (int tt = ReadInt(); tt > 0; tt--)\n {\n int n = ReadInt();\n bool f = true;\n for (int i = 2; f && i * i <= n; i++)\n if (n % i == 0)\n {\n int u = n / i;\n int v = n - u;\n Write(u, v);\n f = false;\n }\n if (f)\n Write(1, n - 1);\n }\n }\n\n #region Main\n\n protected static TextReader reader;\n protected static TextWriter writer;\n static void Main()\n {\n#if DEBUGLOCAL\n reader = new StreamReader(\"..\\\\..\\\\input.txt\");\n //reader = new StreamReader(Console.OpenStandardInput());\n writer = Console.Out;\n //writer = new StreamWriter(\"..\\\\..\\\\output.txt\");\n#else\n reader = new StreamReader(Console.OpenStandardInput());\n writer = new StreamWriter(Console.OpenStandardOutput());\n //reader = new StreamReader(\"input.txt\");\n //writer = new StreamWriter(\"output.txt\");\n#endif\n try\n {\n new Solution().Solve();\n //var thread = new Thread(new Solver().Solve, 1024 * 1024 * 128);\n //thread.Start();\n //thread.Join();\n }\n catch (Exception ex)\n {\n#if DEBUG\n Console.WriteLine(ex);\n#else\n throw;\n#endif\n }\n reader.Close();\n writer.Close();\n }\n\n #endregion\n\n #region Read / Write\n private static Queue currentLineTokens = new Queue();\n private static string[] ReadAndSplitLine() { return reader.ReadLine().Split(new[] { ' ', '\\t', }, StringSplitOptions.RemoveEmptyEntries); }\n public static string ReadToken() { while (currentLineTokens.Count == 0) currentLineTokens = new Queue(ReadAndSplitLine()); return currentLineTokens.Dequeue(); }\n public static int ReadInt() { return int.Parse(ReadToken()); }\n public static long ReadLong() { return long.Parse(ReadToken()); }\n public static double ReadDouble() { return double.Parse(ReadToken(), CultureInfo.InvariantCulture); }\n public static int[] ReadIntArray() { return ReadAndSplitLine().Select(int.Parse).ToArray(); }\n public static long[] ReadLongArray() { return ReadAndSplitLine().Select(long.Parse).ToArray(); }\n public static double[] ReadDoubleArray() { return ReadAndSplitLine().Select(s => double.Parse(s, CultureInfo.InvariantCulture)).ToArray(); }\n public static int[][] ReadIntMatrix(int numberOfRows) { int[][] matrix = new int[numberOfRows][]; for (int i = 0; i < numberOfRows; i++) matrix[i] = ReadIntArray(); return matrix; }\n public static int[][] ReadAndTransposeIntMatrix(int numberOfRows)\n {\n int[][] matrix = ReadIntMatrix(numberOfRows); int[][] ret = new int[matrix[0].Length][];\n for (int i = 0; i < ret.Length; i++) { ret[i] = new int[numberOfRows]; for (int j = 0; j < numberOfRows; j++) ret[i][j] = matrix[j][i]; }\n return ret;\n }\n public static string[] ReadLines(int quantity) { string[] lines = new string[quantity]; for (int i = 0; i < quantity; i++) lines[i] = reader.ReadLine().Trim(); return lines; }\n public static void WriteArray(IEnumerable array) { writer.WriteLine(string.Join(\" \", array)); }\n public static void Write(params object[] array) { WriteArray(array); }\n public static void WriteLines(IEnumerable array) { foreach (var a in array) writer.WriteLine(a); }\n private class SDictionary : Dictionary\n {\n public new TValue this[TKey key]\n {\n get { return ContainsKey(key) ? base[key] : default(TValue); }\n set { base[key] = value; }\n }\n }\n private static T[] Init(int size) where T : new() { var ret = new T[size]; for (int i = 0; i < size; i++) ret[i] = new T(); return ret; }\n #endregion\n}", "lang_cluster": "C#", "tags": ["math", "greedy", "number theory"], "code_uid": "001c2cbeac0e020c1f4711751eb78401", "src_uid": "3fd60db24b1873e906d6dee9c2508ac5", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffnamespace ContestRuns\n{\n using System;\n using System.Collections.Generic;\n using System.Collections.Specialized;\n using System.IO;\n //using System.Linq;\n using System.Text;\n \n using System.Linq;\n //using contests;\n\n class Program\n {\n\n#if DEBUG\n static readonly TextReader input = File.OpenText(@\"../../A/A.in\");\n static readonly TextWriter output = File.CreateText(@\"../../A/A.out\");\n#else\n static readonly TextReader input = Console.In;\n static readonly TextWriter output = Console.Out;\n#endif\n \n public class Interval\n {\n public int Start { get; set; }\n public int End { get; set; }\n public int Index { get; set; }\n }\n\n private static void SolveB()\n {\n int T = int.Parse(input.ReadLine());\n\n for (int t = 0; t < T; ++t)\n {\n //var xy = input.ReadLine().Split(' ').Select(long.Parse).ToArray();\n long n = int.Parse(input.ReadLine());\n\n long res = 1;\n for (long i = 2; i*i <=n; ++i)\n {\n if (n % i == 0)\n {\n res = n / i;\n break;\n }\n }\n\n output.WriteLine(res + \" \" + (n - res));\n }\n }\n \n static void Main(string[] args)\n {\n SolveB();\n output.Flush();\n }\n }\n}", "lang_cluster": "C#", "tags": ["math", "greedy", "number theory"], "code_uid": "22f9961ac91ac8ef5b0973f8b1a6a60b", "src_uid": "3fd60db24b1873e906d6dee9c2508ac5", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.IO;\nusing System.Linq;\nusing static System.Math;\nusing System.Text;\nusing System.Threading;\nnamespace Program\n{\n public static class CODEFORCES1\n {\n static public int numberOfRandomCases = 0;\n static public void MakeTestCase(List _input, List _output, ref Func _outputChecker)\n {\n }\n static public void Solve()\n {\n var n = NN;\n var m = NN;\n var ab = Repeat(0, m).Select(_ => new { a = NN - 1, b = NN - 1 }).ToArray();\n var path = Repeat(0, n).Select(_ => new List()).ToArray();\n foreach (var item in ab)\n {\n path[item.a].Add(item.b);\n path[item.b].Add(item.a);\n }\n Func checker = cnter =>\n {\n var done = new bool[n, n];\n var used = new bool[7, 7];\n var ans2 = 0;\n foreach (var item in ab)\n {\n if (done[item.a, item.b]) continue;\n done[item.a, item.b] = true;\n done[item.b, item.a] = true;\n if (!used[cnter[item.a], cnter[item.b]])\n {\n ++ans2;\n used[cnter[item.a], cnter[item.b]] = true;\n used[cnter[item.b], cnter[item.a]] = true;\n }\n }\n return ans2;\n };\n var ans = 0L;\n var counter = new long[7];\n for (counter[0] = 1; counter[0] < 7; counter[0]++)\n for (counter[1] = 1; counter[1] < 7; counter[1]++)\n for (counter[2] = 1; counter[2] < 7; counter[2]++)\n for (counter[3] = 1; counter[3] < 7; counter[3]++)\n for (counter[4] = 1; counter[4] < 7; counter[4]++)\n for (counter[5] = 1; counter[5] < 7; counter[5]++)\n for (counter[6] = 1; counter[6] < 7; counter[6]++)\n {\n ans = Max(ans, checker(counter));\n }\n Console.WriteLine(ans);\n }\n static public void Main(string[] args) { if (args.Length == 0) { var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false }; Console.SetOut(sw); } var t = new Thread(Solve, 134217728); t.Start(); t.Join(); Console.Out.Flush(); }\n static class Console_\n {\n static Queue param = new Queue();\n public static string NextString() { if (param.Count == 0) foreach (var item in Console.ReadLine().Split(' ')) param.Enqueue(item); return param.Dequeue(); }\n }\n static long NN => long.Parse(Console_.NextString());\n static double ND => double.Parse(Console_.NextString());\n static string NS => Console_.NextString();\n static long[] NNList(long N) => Repeat(0, N).Select(_ => NN).ToArray();\n static double[] NDList(long N) => Repeat(0, N).Select(_ => ND).ToArray();\n static string[] NSList(long N) => Repeat(0, N).Select(_ => NS).ToArray();\n static IEnumerable OrderByRand(this IEnumerable x) => x.OrderBy(_ => xorshift);\n static IEnumerable Repeat(T v, long n) => Enumerable.Repeat(v, (int)n);\n static IEnumerable Range(long s, long c) => Enumerable.Range((int)s, (int)c);\n static void RevSort(T[] l) where T : IComparable { Array.Sort(l, (x, y) => y.CompareTo(x)); }\n static void RevSort(T[] l, Comparison comp) where T : IComparable { Array.Sort(l, (x, y) => comp(y, x)); }\n static IEnumerable Primes(long x) { if (x < 2) yield break; yield return 2; var halfx = x / 2; var table = new bool[halfx + 1]; var max = (long)(Math.Sqrt(x) / 2); for (long i = 1; i <= max; ++i) { if (table[i]) continue; var add = 2 * i + 1; yield return add; for (long j = 2 * i * (i + 1); j <= halfx; j += add) table[j] = true; } for (long i = max + 1; i <= halfx; ++i) if (!table[i] && 2 * i + 1 <= x) yield return 2 * i + 1; }\n static IEnumerable Factors(long x) { if (x < 2) yield break; while (x % 2 == 0) { x /= 2; yield return 2; } var max = (long)Math.Sqrt(x); for (long i = 3; i <= max; i += 2) while (x % i == 0) { x /= i; yield return i; } if (x != 1) yield return x; }\n static IEnumerable Divisor(long x) { if (x < 1) yield break; var max = (long)Math.Sqrt(x); for (long i = 1; i <= max; ++i) { if (x % i != 0) continue; yield return i; if (i != x / i) yield return x / i; } }\n static uint xorshift { get { _xsi.MoveNext(); return _xsi.Current; } }\n static IEnumerator _xsi = _xsc();\n static IEnumerator _xsc() { uint x = 123456789, y = 362436069, z = 521288629, w = (uint)(DateTime.Now.Ticks & 0xffffffff); while (true) { var t = x ^ (x << 11); x = y; y = z; z = w; w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)); yield return w; } }\n static long GCD(long a, long b) { while (b > 0) { var tmp = b; b = a % b; a = tmp; } return a; }\n static long LCM(long a, long b) => a * b / GCD(a, b);\n static Mat Pow(Mat x, long y) => Mat.Pow(x, y);\n static Mod Pow(Mod x, long y) { Mod a = 1; while (y != 0) { if ((y & 1) == 1) a.Mul(x); x.Mul(x); y >>= 1; } return a; }\n static long Pow(long x, long y) { long a = 1; while (y != 0) { if ((y & 1) == 1) a *= x; x *= x; y >>= 1; } return a; }\n static List _fact = new List() { 1 };\n static void _B(long n) { if (n >= _fact.Count) for (int i = _fact.Count; i <= n; ++i) _fact.Add(_fact[i - 1] * i); }\n static long Comb(long n, long k) { _B(n); if (n == 0 && k == 0) return 1; if (n < k || n < 0) return 0; return _fact[(int)n] / _fact[(int)(n - k)] / _fact[(int)k]; }\n static long Perm(long n, long k) { _B(n); if (n == 0 && k == 0) return 1; if (n < k || n < 0) return 0; return _fact[(int)n] / _fact[(int)(n - k)]; }\n static Func Lambda(Func, TR> f) { Func t = () => default(TR); return t = () => f(t); }\n static Func Lambda(Func, TR> f) { Func t = x1 => default(TR); return t = x1 => f(x1, t); }\n static Func Lambda(Func, TR> f) { Func t = (x1, x2) => default(TR); return t = (x1, x2) => f(x1, x2, t); }\n static Func Lambda(Func, TR> f) { Func t = (x1, x2, x3) => default(TR); return t = (x1, x2, x3) => f(x1, x2, x3, t); }\n static Func Lambda(Func, TR> f) { Func t = (x1, x2, x3, x4) => default(TR); return t = (x1, x2, x3, x4) => f(x1, x2, x3, x4, t); }\n static List LCS(T[] s, T[] t) where T : IEquatable { int sl = s.Length, tl = t.Length; var dp = new int[sl + 1, tl + 1]; for (var i = 0; i < sl; i++) for (var j = 0; j < tl; j++) dp[i + 1, j + 1] = s[i].Equals(t[j]) ? dp[i, j] + 1 : Max(dp[i + 1, j], dp[i, j + 1]); { var r = new List(); int i = sl, j = tl; while (i > 0 && j > 0) if (s[--i].Equals(t[--j])) r.Add(s[i]); else if (dp[i, j + 1] > dp[i + 1, j]) ++j; else ++i; r.Reverse(); return r; } }\n static long LIS(T[] array, bool strict) { var l = new List(); foreach (var e in array) { var i = l.BinarySearch(e); if (i < 0) i = ~i; else if (!strict) ++i; if (i == l.Count) l.Add(e); else l[i] = e; } return l.Count; }\n class PQ where T : IComparable\n {\n List h; Comparison c; public T Peek => h[0]; public int Count => h.Count;\n public PQ(int cap, Comparison c, bool asc = true) { h = new List(cap); this.c = asc ? c : (x, y) => c(y, x); }\n public PQ(Comparison c, bool asc = true) { h = new List(); this.c = asc ? c : (x, y) => c(y, x); }\n public PQ(int cap, bool asc = true) : this(cap, (x, y) => x.CompareTo(y), asc) { }\n public PQ(bool asc = true) : this((x, y) => x.CompareTo(y), asc) { }\n public void Push(T v) { var i = h.Count; h.Add(v); while (i > 0) { var ni = (i - 1) / 2; if (c(v, h[ni]) >= 0) break; h[i] = h[ni]; i = ni; } h[i] = v; }\n public T Pop() { var r = h[0]; var v = h[h.Count - 1]; h.RemoveAt(h.Count - 1); if (h.Count == 0) return r; var i = 0; while (i * 2 + 1 < h.Count) { var i1 = i * 2 + 1; var i2 = i * 2 + 2; if (i2 < h.Count && c(h[i1], h[i2]) > 0) i1 = i2; if (c(v, h[i1]) <= 0) break; h[i] = h[i1]; i = i1; } h[i] = v; return r; }\n }\n class PQ where TK : IComparable\n {\n PQ> q; public Tuple Peek => q.Peek; public int Count => q.Count;\n public PQ(int cap, Comparison c, bool asc = true) { q = new PQ>(cap, (x, y) => c(x.Item1, y.Item1), asc); }\n public PQ(Comparison c, bool asc = true) { q = new PQ>((x, y) => c(x.Item1, y.Item1), asc); }\n public PQ(int cap, bool asc = true) : this(cap, (x, y) => x.CompareTo(y), asc) { }\n public PQ(bool asc = true) : this((x, y) => x.CompareTo(y), asc) { }\n public void Push(TK k, TV v) => q.Push(Tuple.Create(k, v));\n public Tuple Pop() => q.Pop();\n }\n public class UF\n {\n long[] d;\n public UF(long s) { d = Repeat(-1L, s).ToArray(); }\n public bool Unite(long x, long y) { x = Root(x); y = Root(y); if (x != y) { if (d[y] < d[x]) { var t = y; y = x; x = t; } d[x] += d[y]; d[y] = x; } return x != y; }\n public bool IsSame(long x, long y) => Root(x) == Root(y);\n public long Root(long x) => d[x] < 0 ? x : d[x] = Root(d[x]);\n public long Count(long x) => -d[Root(x)];\n }\n struct Mod : IEquatable, IEquatable\n {\n static public long _mod = 1000000007; long v;\n public Mod(long x) { if (x < _mod && x >= 0) v = x; else if ((v = x % _mod) < 0) v += _mod; }\n static public implicit operator Mod(long x) => new Mod(x);\n static public implicit operator long(Mod x) => x.v;\n public void Add(Mod x) { if ((v += x.v) >= _mod) v -= _mod; }\n public void Sub(Mod x) { if ((v -= x.v) < 0) v += _mod; }\n public void Mul(Mod x) => v = (v * x.v) % _mod;\n public void Div(Mod x) => v = (v * Inverse(x.v)) % _mod;\n static public Mod operator +(Mod x, Mod y) { var t = x.v + y.v; return t >= _mod ? new Mod { v = t - _mod } : new Mod { v = t }; }\n static public Mod operator -(Mod x, Mod y) { var t = x.v - y.v; return t < 0 ? new Mod { v = t + _mod } : new Mod { v = t }; }\n static public Mod operator *(Mod x, Mod y) => x.v * y.v;\n static public Mod operator /(Mod x, Mod y) => x.v * Inverse(y.v);\n static public bool operator ==(Mod x, Mod y) => x.v == y.v;\n static public bool operator !=(Mod x, Mod y) => x.v != y.v;\n static public long Inverse(long x) { long b = _mod, r = 1, u = 0, t = 0; while (b > 0) { var q = x / b; t = u; u = r - q * u; r = t; t = b; b = x - q * b; x = t; } return r < 0 ? r + _mod : r; }\n public bool Equals(Mod x) => v == x.v;\n public bool Equals(long x) => v == x;\n public override bool Equals(object x) => x == null ? false : Equals((Mod)x);\n public override int GetHashCode() => v.GetHashCode();\n public override string ToString() => v.ToString();\n static List _fact = new List() { 1 };\n static void B(long n) { if (n >= _fact.Count) for (int i = _fact.Count; i <= n; ++i) _fact.Add(_fact[i - 1] * i); }\n static public Mod Comb(long n, long k) { B(n); if (n == 0 && k == 0) return 1; if (n < k || n < 0) return 0; return _fact[(int)n] / _fact[(int)(n - k)] / _fact[(int)k]; }\n static public Mod Perm(long n, long k) { B(n); if (n == 0 && k == 0) return 1; if (n < k || n < 0) return 0; return _fact[(int)n] / _fact[(int)(n - k)]; }\n }\n struct Mat\n {\n T[,] m;\n public Mat(T[,] v) { m = (T[,])v.Clone(); }\n static public implicit operator Mat(T[,] v) => new Mat(v);\n public T this[int r, int c] { get { return m[r, c]; } set { m[r, c] = value; } }\n static public Mat operator +(Mat a, T x) { var tm = (T[,])a.m.Clone(); for (int r = 0; r < tm.GetLength(0); ++r) for (int c = 0; c < tm.GetLength(1); ++c) tm[r, c] += (dynamic)x; return tm; }\n static public Mat operator +(Mat a, Mat b) { var tm = (T[,])a.m.Clone(); for (int r = 0; r < tm.GetLength(0); ++r) for (int c = 0; c < tm.GetLength(1); ++c) tm[r, c] += (dynamic)b[r, c]; return tm; }\n static public Mat operator -(Mat a, T x) { var tm = (T[,])a.m.Clone(); for (int r = 0; r < tm.GetLength(0); ++r) for (int c = 0; c < tm.GetLength(1); ++c) tm[r, c] -= (dynamic)x; return tm; }\n static public Mat operator -(Mat a, Mat b) { var tm = (T[,])a.m.Clone(); for (int r = 0; r < tm.GetLength(0); ++r) for (int c = 0; c < tm.GetLength(1); ++c) tm[r, c] -= (dynamic)b[r, c]; return tm; }\n static public Mat operator *(Mat a, T x) { var tm = (T[,])a.m.Clone(); for (int r = 0; r < tm.GetLength(0); ++r) for (int c = 0; c < tm.GetLength(1); ++c) tm[r, c] *= (dynamic)x; return tm; }\n static public Mat operator *(Mat a, Mat b) { var nr = a.m.GetLength(0); var nc = b.m.GetLength(1); var tm = new T[nr, nc]; for (int i = 0; i < nr; ++i) for (int j = 0; j < nc; ++j) tm[i, j] = (dynamic)0; for (int r = 0; r < nr; ++r) for (int c = 0; c < nc; ++c) for (int i = 0; i < a.m.GetLength(1); ++i) tm[r, c] += a[r, i] * (dynamic)b[i, c]; return tm; }\n static public Mat Pow(Mat x, long y) { var n = x.m.GetLength(0); var t = (Mat)new T[n, n]; for (int i = 0; i < n; ++i) for (int j = 0; j < n; ++j) t[i, j] = (dynamic)(i == j ? 1 : 0); while (y != 0) { if ((y & 1) == 1) t *= x; x *= x; y >>= 1; } return t; }\n }\n class Tree\n {\n long N; int l; List[] p; int[] d; long[][] pr; long r; Tuple[] e; Tuple[] b; bool lca; bool euler; bool bfs;\n public Tree(List[] p_, long r_) { N = p_.Length; p = p_; r = r_; lca = false; euler = false; }\n public Tuple[] BFSRoot() { if (!bfs) { var nb = new List>(); var q = new Queue(); var d = new bool[N]; nb.Add(Tuple.Create(r, -1L)); d[r] = true; q.Enqueue(r); while (q.Count > 0) { var w = q.Dequeue(); foreach (var i in p[w]) { if (d[i]) continue; d[i] = true; q.Enqueue(i); nb.Add(Tuple.Create(i, w)); } } b = nb.ToArray(); bfs = true; } return b; }\n public Tuple[] BFSLeaf() => BFSRoot().Reverse().ToArray();\n public Tuple[] Euler() { if (!euler) { var ne = new List>(); var s = new Stack>(); var d = new bool[N]; d[r] = true; s.Push(Tuple.Create(r, -1L)); while (s.Count > 0) { var w = s.Peek(); var ad = true; foreach (var i in p[w.Item1]) { if (d[i]) continue; d[i] = true; ad = false; s.Push(Tuple.Create(i, w.Item1)); } if (!ad || p[w.Item1].Count == 1) ne.Add(Tuple.Create(w.Item1, w.Item2, 1)); if (ad) { s.Pop(); ne.Add(Tuple.Create(w.Item1, w.Item2, -1)); } } e = ne.ToArray(); euler = true; } return e; }\n public long LCA(long u, long v) { if (!lca) { l = 0; while (N > (1 << l)) l++; d = new int[N]; pr = Repeat(0, l).Select(_ => new long[N]).ToArray(); d[r] = 0; pr[0][r] = -1; var q = new Stack(); q.Push(r); while (q.Count > 0) { var w = q.Pop(); foreach (var i in p[w]) { if (i == pr[0][w]) continue; q.Push(i); d[i] = d[w] + 1; pr[0][i] = w; } } for (var k = 0; k + 1 < l; k++) for (var w = 0; w < N; w++) if (pr[k][w] < 0) pr[k + 1][w] = -1; else pr[k + 1][w] = pr[k][pr[k][w]]; lca = true; } if (d[u] > d[v]) { var t = u; u = v; v = t; } for (var k = 0; k < l; k++) if ((((d[v] - d[u]) >> k) & 1) != 0) v = pr[k][v]; if (u == v) return u; for (var k = l - 1; k >= 0; k--) if (pr[k][u] != pr[k][v]) { u = pr[k][u]; v = pr[k][v]; } return pr[0][u]; }\n }\n class Graph\n {\n int n; List> pathList; Dictionary[] vtxPath; long INF = (long.MaxValue >> 1) - 1;\n public Graph(long _n)\n {\n n = (int)_n;\n pathList = new List>();\n vtxPath = Repeat(0, n).Select(_ => new Dictionary()).ToArray();\n }\n public void AddPath(long a, long b, long c)\n {\n pathList.Add(Tuple.Create((int)a, (int)b, c));\n vtxPath[a][(int)b] = vtxPath[a].ContainsKey((int)b) ? Min(vtxPath[a][(int)b], c) : c;\n }\n public long[,] WarshallFloyd()\n {\n var ret = new long[n, n];\n for (var i = 0; i < n; i++)\n for (var j = 0; j < n; j++)\n ret[i, j] = vtxPath[i].ContainsKey(j) ? vtxPath[i][j] : INF;\n for (var k = 0; k < n; k++)\n for (var i = 0; i < n; i++)\n for (var j = 0; j < n; j++)\n ret[i, j] = Min(ret[i, j], ret[i, k] + ret[k, j]);\n return ret;\n }\n public Tuple BellmanFord(long s)\n {\n var dist = Repeat(INF, n).ToArray();\n var pred = new int?[n];\n var neg = new bool[n];\n dist[s] = 0;\n for (var i = 1; i < n; i++)\n foreach (var path in pathList)\n if (dist[path.Item2] > (dist[path.Item1] == INF ? INF : dist[path.Item1] + path.Item3))\n {\n dist[path.Item2] = dist[path.Item1] + path.Item3;\n pred[path.Item2] = path.Item1;\n }\n for (var i = 0; i < n; i++)\n foreach (var path in pathList)\n if (dist[path.Item2] > (dist[path.Item1] == INF ? INF : dist[path.Item1] + path.Item3) || neg[path.Item1])\n {\n dist[path.Item2] = dist[path.Item1] + path.Item3;\n neg[path.Item2] = true;\n }\n return Tuple.Create(dist, pred, neg);\n }\n public Tuple Dijkstra(long s)\n {\n var dist = Repeat(long.MaxValue >> 2, n).ToArray();\n var pred = new int?[n];\n dist[s] = 0;\n var q = new PQ();\n q.Push(0, (int)s);\n while (q.Count > 0)\n {\n var u = q.Pop().Item2;\n foreach (var path in vtxPath[u])\n {\n var v = path.Key;\n var alt = dist[u] + path.Value;\n if (dist[v] > alt)\n {\n dist[v] = alt;\n pred[v] = u;\n q.Push(alt, v);\n }\n }\n }\n return Tuple.Create(dist, pred);\n }\n }\n class BT where T : IComparable\n {\n class Node { public Node l; public Node r; public T v; public bool b; public int c; }\n Comparison c; Node r; bool ch; T lm;\n public BT(Comparison _c) { c = _c; }\n public BT() : this((x, y) => x.CompareTo(y)) { }\n bool R(Node n) => n != null && !n.b;\n bool B(Node n) => n != null && n.b;\n long C(Node n) => n?.c ?? 0;\n Node RtL(Node n) { Node m = n.r, t = m.l; m.l = n; n.r = t; n.c -= m.c - (t?.c ?? 0); m.c += n.c - (t?.c ?? 0); return m; }\n Node RtR(Node n) { Node m = n.l, t = m.r; m.r = n; n.l = t; n.c -= m.c - (t?.c ?? 0); m.c += n.c - (t?.c ?? 0); return m; }\n Node RtLR(Node n) { n.l = RtL(n.l); return RtR(n); }\n Node RtRL(Node n) { n.r = RtR(n.r); return RtL(n); }\n public void Add(T x) { r = A(r, x); r.b = true; }\n Node A(Node n, T x) { if (n == null) { ch = true; return new Node() { v = x, c = 1 }; } if (c(x, n.v) < 0) n.l = A(n.l, x); else n.r = A(n.r, x); n.c++; return Bl(n); }\n Node Bl(Node n) { if (!ch) return n; if (!B(n)) return n; if (R(n.l) && R(n.l.l)) { n = RtR(n); n.l.b = true; } else if (R(n.l) && R(n.l.r)) { n = RtLR(n); n.l.b = true; } else if (R(n.r) && R(n.r.l)) { n = RtRL(n); n.r.b = true; } else if (R(n.r) && R(n.r.r)) { n = RtL(n); n.r.b = true; } else ch = false; return n; }\n public void Remove(T x) { r = Rm(r, x); if (r != null) r.b = true; }\n Node Rm(Node n, T x) { if (n == null) { ch = false; return n; } n.c--; var r = c(x, n.v); if (r < 0) { n.l = Rm(n.l, x); return BlL(n); } if (r > 0) { n.r = Rm(n.r, x); return BlR(n); } if (n.l == null) { ch = n.b; return n.r; } n.l = RmM(n.l); n.v = lm; return BlL(n); }\n Node RmM(Node n) { n.c--; if (n.r != null) { n.r = RmM(n.r); return BlR(n); } lm = n.v; ch = n.b; return n.l; }\n Node BlL(Node n) { if (!ch) return n; if (B(n.r) && R(n.r.l)) { var b = n.b; n = RtRL(n); n.b = b; n.l.b = true; ch = false; } else if (B(n.r) && R(n.r.r)) { var b = n.b; n = RtL(n); n.b = b; n.r.b = true; n.l.b = true; ch = false; } else if (B(n.r)) { ch = n.b; n.b = true; n.r.b = false; } else { n = RtL(n); n.b = true; n.l.b = false; n.l = BlL(n.l); ch = false; } return n; }\n Node BlR(Node n) { if (!ch) return n; if (B(n.l) && R(n.l.r)) { var b = n.b; n = RtLR(n); n.b = b; n.r.b = true; ch = false; } else if (B(n.l) && R(n.l.l)) { var b = n.b; n = RtR(n); n.b = b; n.l.b = true; n.r.b = true; ch = false; } else if (B(n.l)) { ch = n.b; n.b = true; n.l.b = false; } else { n = RtR(n); n.b = true; n.r.b = false; n.r = BlR(n.r); ch = false; } return n; }\n public T this[long i] { get { return At(r, i); } }\n T At(Node n, long i) { if (n == null) return default(T); if (n.l == null) if (i == 0) return n.v; else return At(n.r, i - 1); if (n.l.c == i) return n.v; if (n.l.c > i) return At(n.l, i); return At(n.r, i - n.l.c - 1); }\n public bool Have(T x) { var t = FindUpper(x); return t < C(r) && At(r, t).CompareTo(x) == 0; }\n public long FindUpper(T x, bool allowSame = true) => allowSame ? FL(r, x) + 1 : FU(r, x);\n long FU(Node n, T x) { if (n == null) return 0; var r = c(x, n.v); if (r < 0) return FU(n.l, x); return C(n.l) + 1 + FU(n.r, x); }\n public long FindLower(T x, bool allowSame = true) { var t = FL(r, x); if (allowSame) return t + 1 < C(r) && At(r, t + 1).CompareTo(x) == 0 ? t + 1 : t < 0 ? C(r) : t; return t < 0 ? C(r) : t; }\n long FL(Node n, T x) { if (n == null) return -1; var r = c(x, n.v); if (r > 0) return C(n.l) + 1 + FL(n.r, x); return FL(n.l, x); }\n public T Min() { Node n = r, p = null; while (n != null) { p = n; n = n.l; } return p == null ? default(T) : p.v; }\n public T Max() { Node n = r, p = null; while (n != null) { p = n; n = n.r; } return p == null ? default(T) : p.v; }\n public bool Any() => r != null;\n public long Count() => C(r);\n public IEnumerable List() => L(r);\n IEnumerable L(Node n) { if (n == null) yield break; foreach (var i in L(n.l)) yield return i; yield return n.v; foreach (var i in L(n.r)) yield return i; }\n }\n class Dict : Dictionary\n {\n Func d;\n public Dict(Func _d) { d = _d; }\n public Dict() : this(_ => default(V)) { }\n new public V this[K i] { get { V v; return TryGetValue(i, out v) ? v : base[i] = d(i); } set { base[i] = value; } }\n }\n class Deque\n {\n T[] b; int o, c;\n public int Count;\n public T this[int i] { get { return b[gi(i)]; } set { b[gi(i)] = value; } }\n public Deque(int cap = 16) { b = new T[c = cap]; }\n int gi(int i) { if (i >= c) throw new Exception(); var r = o + i; return r >= c ? r - c : r; }\n public void PushFront(T x) { if (Count == c) e(); if (--o < 0) o += b.Length; b[o] = x; ++Count; }\n public T PopFront() { if (Count-- == 0) throw new Exception(); var r = b[o++]; if (o >= c) o -= c; return r; }\n public T Front => b[o];\n public void PushBack(T x) { if (Count == c) e(); var i = o + Count++; b[i >= c ? i - c : i] = x; }\n public T PopBack() { if (Count == 0) throw new Exception(); return b[gi(--Count)]; }\n public T Back => b[gi(Count - 1)];\n void e() { T[] nb = new T[c << 1]; if (o > c - Count) { var l = b.Length - o; Array.Copy(b, o, nb, 0, l); Array.Copy(b, 0, nb, l, Count - l); } else Array.Copy(b, o, nb, 0, Count); b = nb; o = 0; c <<= 1; }\n public void Insert(int i, T x) { if (i > Count) throw new Exception(); this.PushFront(x); for (int j = 0; j < i; j++) this[j] = this[j + 1]; this[i] = x; }\n public T RemoveAt(int i) { if (i < 0 || i >= Count) throw new Exception(); var r = this[i]; for (int j = i; j > 0; j--) this[j] = this[j - 1]; this.PopFront(); return r; }\n }\n class SegTree\n {\n int n; T ti; Func f; T[] dat;\n public SegTree(long _n, T _ti, Func _f) { n = 1; while (n < _n) n <<= 1; ti = _ti; f = _f; dat = Repeat(ti, n << 1).ToArray(); for (var i = n - 1; i > 0; i--) dat[i] = f(dat[(i << 1) | 0], dat[(i << 1) | 1]); }\n public SegTree(List l, T _ti, Func _f) : this(l.Count, _ti, _f) { for (var i = 0; i < l.Count; i++) dat[n + i] = l[i]; for (var i = n - 1; i > 0; i--) dat[i] = f(dat[(i << 1) | 0], dat[(i << 1) | 1]); }\n public void Update(long i, T v) { dat[i += n] = v; while ((i >>= 1) > 0) dat[i] = f(dat[(i << 1) | 0], dat[(i << 1) | 1]); }\n public T Query(long l, long r) { var vl = ti; var vr = ti; for (long li = n + l, ri = n + r; li < ri; li >>= 1, ri >>= 1) { if ((li & 1) == 1) vl = f(vl, dat[li++]); if ((ri & 1) == 1) vr = f(dat[--ri], vr); } return f(vl, vr); }\n public T this[long idx] { get { return dat[idx + n]; } set { Update(idx, value); } }\n }\n class LazySegTree\n {\n int n, height; T ti; E ei; Func f; Func g; Func h; T[] dat; E[] laz;\n public LazySegTree(long _n, T _ti, E _ei, Func _f, Func _g, Func _h) { n = 1; height = 0; while (n < _n) { n <<= 1; ++height; } ti = _ti; ei = _ei; f = _f; g = _g; h = _h; dat = Repeat(ti, n << 1).ToArray(); laz = Repeat(ei, n << 1).ToArray(); for (var i = n - 1; i > 0; i--) dat[i] = f(dat[(i << 1) | 0], dat[(i << 1) | 1]); }\n public LazySegTree(List l, T _ti, E _ei, Func _f, Func _g, Func _h) : this(l.Count, _ti, _ei, _f, _g, _h) { for (var i = 0; i < l.Count; i++) dat[n + i] = l[i]; for (var i = n - 1; i > 0; i--) dat[i] = f(dat[(i << 1) | 0], dat[(i << 1) | 1]); }\n T Reflect(long i) => laz[i].Equals(ei) ? dat[i] : g(dat[i], laz[i]);\n void Eval(long i) { if (laz[i].Equals(ei)) return; laz[(i << 1) | 0] = h(laz[(i << 1) | 0], laz[i]); laz[(i << 1) | 1] = h(laz[(i << 1) | 1], laz[i]); dat[i] = Reflect(i); laz[i] = ei; }\n void Thrust(long i) { for (var j = height; j > 0; j--) Eval(i >> j); }\n void Recalc(long i) { while ((i >>= 1) > 0) dat[i] = f(Reflect((i << 1) | 0), Reflect((i << 1) | 1)); }\n public void Update(long l, long r, E v) { Thrust(l += n); Thrust(r += n - 1); for (long li = l, ri = r + 1; li < ri; li >>= 1, ri >>= 1) { if ((li & 1) == 1) { laz[li] = h(laz[li], v); ++li; } if ((ri & 1) == 1) { --ri; laz[ri] = h(laz[ri], v); } } Recalc(l); Recalc(r); }\n public T Query(long l, long r) { Thrust(l += n); Thrust(r += n - 1); var vl = ti; var vr = ti; for (long li = l, ri = r + 1; li < ri; li >>= 1, ri >>= 1) { if ((li & 1) == 1) vl = f(vl, Reflect(li++)); if ((ri & 1) == 1) vr = f(Reflect(--ri), vr); } return f(vl, vr); }\n public T this[long idx] { get { Thrust(idx += n); return dat[idx] = Reflect(idx); } set { Thrust(idx += n); dat[idx] = value; laz[idx] = ei; Recalc(idx); } }\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "graphs"], "code_uid": "52bc11c0ac8bbfcf68d434caaea9327f", "src_uid": "11e6559cfb71b8f6ca88242094b17a2b", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": ".NET Core C#", "source_code": "using System;\nusing System.Linq;\nusing CompLib.Util;\nusing System.Threading;\nusing CompLib.Algorithm;\nusing CompLib.Graph;\n\npublic class Program\n{\n private int N, M;\n private int[] A, B;\n\n private int[] Ar;\n\n public void Solve()\n {\n var sc = new Scanner();\n N = sc.NextInt();\n M = sc.NextInt();\n A = new int[M];\n B = new int[M];\n for (int i = 0; i < M; i++)\n {\n A[i] = sc.NextInt() - 1;\n B[i] = sc.NextInt() - 1;\n }\n\n Ar = new int[N];\n\n Console.WriteLine(Go(0));\n }\n\n int Go(int i)\n {\n if (i >= N)\n {\n bool[,] f = new bool[6, 6];\n for (int j = 0; j < M; j++)\n {\n f[Ar[A[j]], Ar[B[j]]] = f[Ar[B[j]], Ar[A[j]]] = true;\n }\n\n int cnt = 0;\n for (int j = 0; j < 6; j++)\n {\n for (int k = j; k < 6; k++)\n {\n if (f[j, k]) cnt++;\n }\n }\n\n return cnt;\n }\n\n int ans = int.MinValue;\n for (int j = 0; j < 6; j++)\n {\n Ar[i] = j;\n ans = Math.Max(ans, Go(i + 1));\n }\n\n return ans;\n }\n\n\n public static void Main(string[] args) => new Program().Solve();\n // public static void Main(string[] args) => new Thread(new Program().Solve, 1 << 27).Start();\n}\n\nnamespace CompLib.Graph\n{\n using System;\n using System.Collections.Generic;\n\n class AdjacencyList\n {\n private readonly int _n;\n private readonly List<(int f, int t)> _edges;\n\n private int[] _start;\n private int[] _eList;\n\n public AdjacencyList(int n)\n {\n _n = n;\n _edges = new List<(int f, int t)>();\n }\n\n public void AddDirectedEdge(int from, int to)\n {\n _edges.Add((from, to));\n }\n\n public void AddUndirectedEdge(int f, int t)\n {\n AddDirectedEdge(f, t);\n AddDirectedEdge(t, f);\n }\n\n public void Build()\n {\n _start = new int[_n + 1];\n foreach (var e in _edges)\n {\n _start[e.f + 1]++;\n }\n\n for (int i = 1; i <= _n; i++)\n {\n _start[i] += _start[i - 1];\n }\n\n int[] counter = new int[_n + 1];\n _eList = new int[_edges.Count];\n\n foreach (var e in _edges)\n {\n _eList[_start[e.f] + counter[e.f]++] = e.t;\n }\n }\n\n public ReadOnlySpan this[int f]\n {\n get { return _eList.AsSpan(_start[f], _start[f + 1] - _start[f]); }\n }\n }\n}\n\nnamespace CompLib.Algorithm\n{\n using System;\n using System.Collections.Generic;\n\n public static partial class Algorithm\n {\n private static void Swap(ref T a, ref T b)\n {\n T tmp = a;\n a = b;\n b = tmp;\n }\n\n private static void Reverse(T[] array, int begin)\n {\n // [begin, array.Length)\u3092\u53cd\u8ee2\n if (array.Length - begin >= 2)\n {\n for (int i = begin, j = array.Length - 1; i < j; i++, j--)\n {\n Swap(ref array[i], ref array[j]);\n }\n }\n }\n\n /// \n /// array\u3092\u8f9e\u66f8\u9806\u3067\u6b21\u306e\u9806\u5217\u306b\u3059\u308b \u5b58\u5728\u3057\u306a\u3044\u3068\u304d\u306ffalse\u3092\u8fd4\u3059\n /// \n /// \n /// \n /// \n public static bool NextPermutation(T[] array, Comparison comparison)\n {\n for (int i = array.Length - 2; i >= 0; i--)\n {\n if (comparison(array[i], array[i + 1]) < 0)\n {\n int j = array.Length - 1;\n for (; j > i; j--)\n {\n if (comparison(array[i], array[j]) < 0)\n {\n break;\n }\n }\n\n Swap(ref array[i], ref array[j]);\n Reverse(array, i + 1);\n return true;\n }\n }\n\n return false;\n }\n\n /// \n /// array\u3092\u8f9e\u66f8\u9806\u3067\u6b21\u306e\u9806\u5217\u306b\u3059\u308b \u5b58\u5728\u3057\u306a\u3044\u3068\u304d\u306ffalse\u3092\u8fd4\u3059\n /// \n /// \n /// \n /// \n public static bool NextPermutation(T[] array, Comparer comparer) =>\n NextPermutation(array, comparer.Compare);\n\n /// \n /// array\u3092\u8f9e\u66f8\u9806\u3067\u6b21\u306e\u9806\u5217\u306b\u3059\u308b \u5b58\u5728\u3057\u306a\u3044\u3068\u304d\u306ffalse\u3092\u8fd4\u3059\n /// \n /// \n /// \n /// \n public static bool NextPermutation(T[] array) => NextPermutation(array, Comparer.Default);\n }\n}\n\n\nnamespace CompLib.Util\n{\n using System;\n using System.Linq;\n\n class Scanner\n {\n private string[] _line;\n private int _index;\n private const char Separator = ' ';\n\n public Scanner()\n {\n _line = new string[0];\n _index = 0;\n }\n\n public string Next()\n {\n if (_index >= _line.Length)\n {\n string s;\n do\n {\n s = Console.ReadLine();\n } while (s.Length == 0);\n\n _line = s.Split(Separator);\n _index = 0;\n }\n\n return _line[_index++];\n }\n\n public string ReadLine()\n {\n _index = _line.Length;\n return Console.ReadLine();\n }\n\n public int NextInt() => int.Parse(Next());\n public long NextLong() => long.Parse(Next());\n public double NextDouble() => double.Parse(Next());\n public decimal NextDecimal() => decimal.Parse(Next());\n public char NextChar() => Next()[0];\n public char[] NextCharArray() => Next().ToCharArray();\n\n public string[] Array()\n {\n string s = Console.ReadLine();\n _line = s.Length == 0 ? new string[0] : s.Split(Separator);\n _index = _line.Length;\n return _line;\n }\n\n public int[] IntArray() => Array().Select(int.Parse).ToArray();\n public long[] LongArray() => Array().Select(long.Parse).ToArray();\n public double[] DoubleArray() => Array().Select(double.Parse).ToArray();\n public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();\n }\n}", "lang_cluster": "C#", "tags": ["brute force", "graphs"], "code_uid": "aa3a06317abdcd38742047b4b25ebb8d", "src_uid": "11e6559cfb71b8f6ca88242094b17a2b", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace \u0414\u0435\u0436\u0443\u0440\u0441\u0442\u0432\u043e\n{\n class Program\n {\n static int SumOfNums(int x)\n {\n int sum = 0;\n string s = Convert.ToString(x);\n for (int i = 0; i < s.Length; i++)\n {\n sum += Convert.ToInt32(Convert.ToString(s[i]));\n }\n\n return sum;\n }\n static void Main(string[] args)\n {\n int n = Convert.ToInt32(Console.ReadLine());\n\n int x = 0;\n\n if (n > 100) x = n - 100;\n else x = 0;\n List nums = new List();\n while (x < n)\n {\n if (x + SumOfNums(x) == n) nums.Add(x);\n x++;\n }\n\n Console.WriteLine(nums.Count);\n for (int i = 0; i < nums.Count; i++) Console.WriteLine(nums[i]);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "math"], "code_uid": "69f8a2fc12965aaed0a3066354356f9f", "src_uid": "ae20ae2a16273a0d379932d6e973f878", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\n\nclass Program\n{\n static void Main(string[] args)\n {\n var n = int.Parse(Console.ReadLine());\n var s = new List();\n\n int maxAdd = 9 + 9 + 9 + 9 + 9 + 9 + 9 + 9 + 9;\n for (var add = maxAdd; add > 0; --add)\n {\n int cand = n - add;\n if (cand <= 0)\n continue;\n if (DigitsSum(cand) != add)\n continue;\n s.Add(cand);\n }\n Console.WriteLine(s.Count);\n if (s.Count > 0)\n Console.WriteLine(string.Join(Environment.NewLine, s));\n }\n\n static int DigitsSum(int n)\n {\n int sum = 0;\n do\n {\n sum += n % 10;\n n /= 10;\n }\n while (n > 0);\n return sum;\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "math"], "code_uid": "d76b9aefa319e4b80606dc7684515ecc", "src_uid": "ae20ae2a16273a0d379932d6e973f878", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\n\nnamespace CodeforcesSolver\n{\n class Program\n {\n static void Main()\n {\n double striangle = Math.Sqrt(3)/4;\n var a = ReadArrayInt();\n\n var alpha = 2*Math.PI/3;\n\n double m0 = a[1]*Math.Sin(alpha) - a[2]*Math.Sin(alpha*2) + a[3]*Math.Sin(alpha*3) - a[4]*Math.Sin(alpha*4);\n double m1 = a[2]*Math.Sin(alpha) - a[3]*Math.Sin(alpha*2) + a[4]*Math.Sin(alpha*3);\n double m2 = a[3]*Math.Sin(alpha) - a[4]*Math.Sin(alpha*2);\n double m3 = a[4]*Math.Sin(alpha);\n\n double s = (a[0]*m0 + a[1]*m1 + a[2]*m2 + a[3]*m3)/2;\n\n int cnt = (int) Math.Round(s/striangle);\n\n Console.WriteLine(cnt);\n }\n\n #region Handy\n\n public static int ReadInt()\n {\n return int.Parse(Console.ReadLine());\n }\n\n public static long ReadLong()\n {\n return long.Parse(Console.ReadLine());\n }\n\n public static int[] ReadArrayInt()\n {\n return Array.ConvertAll(Console.ReadLine().Split(' '), x => Convert.ToInt32(x));\n }\n\n public static string[] ReadArrayString()\n {\n return Console.ReadLine().Split(' ');\n }\n\n #endregion\n }\n}\n", "lang_cluster": "C#", "tags": ["geometry"], "code_uid": "fa2b0572ae617121c14915ebba550945", "src_uid": "382475475427f0e76c6b4ac6e7a02e21", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Globalization;\nusing System.IO;\nusing System.Text;\nusing static System.Math;\nusing static System.Console;\n\nnamespace Olymp\n{\n public class ProblemSolver\n {\n private readonly Tokenizer input;\n\n public void Solve()\n {\n var a = input.ReadIntArray(6);\n var p = a[0] + a[1] + a[2];\n Write(p * p - a[0] * a[0] - a[2] * a[2] - a[4] * a[4]);\n }\n\n\n public ProblemSolver(TextReader input)\n {\n this.input = new Tokenizer(input);\n }\n }\n\n #region Service classes\n\n public class Tokenizer\n {\n private TextReader reader;\n\n public string ReadToEnd()\n {\n return reader.ReadToEnd();\n }\n\n public int ReadInt()\n {\n var c = SkipWS();\n if (c == -1)\n throw new EndOfStreamException();\n var isNegative = false;\n if (c == '-' || c == '+')\n {\n isNegative = c == '-';\n c = reader.Read();\n if (c == -1)\n throw new EndOfStreamException(\"Digit expected, but end of stream occurs\");\n }\n if (!char.IsDigit((char)c))\n throw new InvalidOperationException($\"Digit expected, but was: '{(char)c}'\");\n var result = (char)c - '0';\n c = reader.Read();\n while (c > 0 && !char.IsWhiteSpace((char)c))\n {\n if (!char.IsDigit((char)c))\n throw new InvalidOperationException($\"Digit expected, but was: '{(char)c}'\");\n result = result * 10 + (char)c - '0';\n c = reader.Read();\n }\n if (isNegative)\n result = -result;\n return result;\n }\n\n public string ReadLine()\n {\n return reader.ReadLine();\n }\n\n public long ReadLong()\n {\n return long.Parse(ReadToken());\n }\n\n public double ReadDouble()\n {\n return double.Parse(ReadToken(), CultureInfo.InvariantCulture);\n }\n\n public int[] ReadIntArray(int n)\n {\n var a = new int[n];\n for (var i = 0; i < n; i++)\n a[i] = ReadInt();\n return a;\n }\n\n public (int, int) Read2Int() =>\n (ReadInt(), ReadInt());\n\n public (int, int, int) Read3Int() =>\n (ReadInt(), ReadInt(), ReadInt());\n\n public (int, int, int, int) Read4Int() =>\n (ReadInt(), ReadInt(), ReadInt(), ReadInt());\n\n public long[] ReadLongArray(int n)\n {\n var a = new long[n];\n for (var i = 0; i < n; i++)\n a[i] = ReadLong();\n return a;\n }\n\n public double[] ReadDoubleArray(int n)\n {\n var a = new double[n];\n for (var i = 0; i < n; i++)\n a[i] = ReadDouble();\n return a;\n }\n\n public string ReadToken()\n {\n var c = SkipWS();\n if (c == -1)\n return null;\n var sb = new StringBuilder();\n while (c > 0 && !char.IsWhiteSpace((char)c))\n {\n sb.Append((char)c);\n c = reader.Read();\n }\n return sb.ToString();\n }\n\n private int SkipWS()\n {\n var c = reader.Read();\n if (c == -1)\n return c;\n while (c > 0 && char.IsWhiteSpace((char)c))\n c = reader.Read();\n return c;\n }\n\n public Tokenizer(TextReader reader)\n {\n this.reader = reader;\n }\n }\n\n internal class Program\n {\n public static void Main(string[] args)\n {\n var solver = new ProblemSolver(In);\n solver.Solve();\n }\n }\n\n #endregion\n}\n", "lang_cluster": "C#", "tags": ["brute force", "math", "geometry"], "code_uid": "5045e967c35e5bf17783f24659fdca9a", "src_uid": "382475475427f0e76c6b4ac6e7a02e21", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": ".NET Core C#", "source_code": "\ufeffusing System;\n\nclass E\n{\n\tstatic void Main()\n\t{\n\t\tvar n = int.Parse(Console.ReadLine());\n\t\tConsole.WriteLine(Factorial(n) * 2 / n / n);\n\t}\n\n\tstatic long Factorial(int n) { for (long x = 1, i = 1; ; x *= ++i) if (i >= n) return x; }\n}\n", "lang_cluster": "C#", "tags": ["math", "combinatorics"], "code_uid": "e9325d7ab46cbdd9fa1e83e943fc3fac", "src_uid": "ad0985c56a207f76afa2ecd642f56728", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\n\nnamespace olympiada\n{\n class Program\n {\n static void Merge(int[] array, int lowIndex, int middleIndex, int highIndex)\n {\n var left = lowIndex;\n var right = middleIndex + 1;\n var tempArray = new int[highIndex - lowIndex + 1];\n var tempB = new int[highIndex - lowIndex + 1];\n var index = 0;\n\n while ((left <= middleIndex) && (right <= highIndex))\n {\n if (array[left] < array[right])\n {\n tempArray[index] = array[left];\n left++;\n }\n else\n {\n tempArray[index] = array[right];\n right++;\n }\n\n index++;\n }\n\n for (var i = left; i <= middleIndex; i++)\n {\n tempArray[index] = array[i];\n index++;\n }\n\n for (var i = right; i <= highIndex; i++)\n {\n tempArray[index] = array[i];\n index++;\n }\n\n for (var i = 0; i < tempArray.Length; i++)\n {\n array[lowIndex + i] = tempArray[i];\n }\n }\n\n static int[] MergeSort(int[] array, int lowIndex, int highIndex)\n {\n if (lowIndex < highIndex)\n {\n var middleIndex = (lowIndex + highIndex) / 2;\n MergeSort(array, lowIndex, middleIndex);\n MergeSort(array, middleIndex + 1, highIndex);\n Merge(array, lowIndex, middleIndex, highIndex);\n }\n\n return array;\n }\n\n static int[] MergeSort(int[] array)\n {\n return MergeSort(array, 0, array.Length - 1);\n }\n static long factorial(long n)\n {\n long res = 1;\n for(int i=1; i<=n; i++)\n {\n res *= i;\n }\n return res;\n }\n static void Main(string[] args)\n {\n long n = long.Parse(Console.ReadLine());\n long c = factorial(n) / (factorial(n / 2) * factorial(n / 2));\n long p = factorial(n / 2 - 1);\n Console.WriteLine(c * p * p/2);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "combinatorics"], "code_uid": "fe9f3318a3dc00a633f5ee971d9c1bf6", "src_uid": "ad0985c56a207f76afa2ecd642f56728", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\n\nnamespace ProgrammingContest.Codeforces.Round63\n{\n class D\n {\n int[,,] win = new int[4,500, 500];\n int offset = 200;\n int[] vx, vy;\n int d;\n\n bool isLose(int x, int y) { return d*d < x*x + y*y; }\n\n bool solve(int reflect, int x, int y)\n {\n if (isLose(x, y))\n return true;\n\n if (win[reflect, x + offset, y + offset] != 0)\n return win[reflect, x + offset, y + offset] > 0;\n\n if (reflect % 2 == 1)\n {\n if (!solve(reflect >> 1, y, x))\n return (win[reflect, x + offset, y + offset] = 1) > 0;\n }\n\n int r = ((reflect % 2) << 1) | (reflect >> 1);\n for (int i = 0; i < vx.Length; i++)\n if (!solve(r, x + vx[i], y + vy[i]))\n return (win[reflect, x + offset, y + offset] = 1) > 0;\n\n return (win[reflect, x + offset, y + offset] = -1) > 0;\n }\n\n D()\n {\n var xs = Array.ConvertAll(Console.ReadLine().Split(' '), sss => int.Parse(sss));\n int x = xs[0],\n y = xs[1],\n n = xs[2];\n d = xs[3];\n vx = new int[n];\n vy = new int[n];\n for (int i = 0; i < n; i++)\n {\n var ys = Array.ConvertAll(Console.ReadLine().Split(' '), sss => int.Parse(sss));\n vx[i] = ys[0];\n vy[i] = ys[1];\n }\n Console.WriteLine(solve(3, x, y) ? \"Anton\" : \"Dasha\");\n }\n\n public static void Main()\n {\n new D();\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["dp", "games"], "code_uid": "39151bdc6a36a2c084210436adee2815", "src_uid": "645a6ca9a8dda6946c2cc055a4beb08f", "difficulty": 1900.0, "exec_outcome": "PASSED"} {"lang": "C# 8", "source_code": "using System;\r\n\r\nnamespace _1505B._DMCA\r\n{\r\n class Program\r\n {\r\n static void Main(string[] args)\r\n {\r\n int n = int.Parse(Console.ReadLine());\r\n Console.WriteLine((n - 1) % 9 + 1);\r\n //baaler problem part 2\r\n }\r\n }\r\n}", "lang_cluster": "C#", "tags": ["implementation", "number theory"], "code_uid": "181d865d2f889382ccc77b11fd4e1e36", "src_uid": "477a67877367dc68b3bf5143120ff45d", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "C# 8", "source_code": "using System;\r\nusing System.Collections.Generic;\r\nnamespace Is_it_rated___2__1505A\r\n{\r\n class Program\r\n {\r\n static void Main(string[] args)\r\n {\r\n\r\n\r\n int z = int.Parse(Console.ReadLine());\r\n z = z % 9;\r\n if (z==0)\r\n {\r\n z = 9;\r\n Console.WriteLine(z);\r\n }\r\n else\r\n {\r\n Console.WriteLine(z);\r\n }\r\n }\r\n }\r\n}\r\n", "lang_cluster": "C#", "tags": ["implementation", "number theory"], "code_uid": "9a0f999361b203d969d5c6fc4fd9a2c8", "src_uid": "477a67877367dc68b3bf5143120ff45d", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.IO;\nusing System.Text;\n\nnamespace A_Student_s_Dream\n{\n internal class Program\n {\n private static readonly StreamReader reader = new StreamReader(Console.OpenStandardInput(1024*10), Encoding.ASCII, false, 1024*10);\n private static readonly StreamWriter writer = new StreamWriter(Console.OpenStandardOutput(1024*10), Encoding.ASCII, 1024*10);\n\n private static void Main(string[] args)\n {\n int al = Next();\n int ar = Next();\n\n int bl = Next();\n int br = Next();\n\n\n bool ok = al <= br + 1 && br <= (al + 1)*2;\n ok = ok || (ar <= bl + 1 && bl <= (ar + 1)*2);\n\n writer.WriteLine(ok ? \"YES\" : \"NO\");\n writer.Flush();\n }\n\n private static int Next()\n {\n int c;\n int res = 0;\n do\n {\n c = reader.Read();\n if (c == -1)\n return res;\n } while (c < '0' || c > '9');\n res = c - '0';\n while (true)\n {\n c = reader.Read();\n if (c < '0' || c > '9')\n return res;\n res *= 10;\n res += c - '0';\n }\n }\n }\n}", "lang_cluster": "C#", "tags": ["math", "greedy"], "code_uid": "88836a6bb30c9d4748a5350a02bd70b9", "src_uid": "36b7478e162be6e985613b2dad0974dd", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\n\nnamespace ProgrammingContest.Codeforces.Round58\n{\n class A\n {\n // 1 -> 4, 2 -> 6\n static bool ok(int g, int b)\n {\n return g-1 <= b && b <= 4 + 2*(g-1);\n }\n\n public static void Main()\n {\n int[] xs = Array.ConvertAll(Console.ReadLine().Split(' '), sss => int.Parse(sss));\n int[] ys = Array.ConvertAll(Console.ReadLine().Split(' '), sss => int.Parse(sss));\n Console.WriteLine(ok(xs[0], ys[1]) || ok(xs[1], ys[0]) ? \"YES\" : \"NO\");\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "greedy"], "code_uid": "9c157497722ccb447b1de11c61765312", "src_uid": "36b7478e162be6e985613b2dad0974dd", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.ComponentModel;\nusing System.IO;\nusing System.Reflection;\nusing System.Collections;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Text.RegularExpressions;\nusing System.Threading;\n\nnamespace ConsoleApplication1\n{\n class Program\n {\n static class Scanner\n {\n readonly static IEnumerator Tokens;\n static Scanner()\n {\n Tokens = Enumerable.Range(Int32.MinValue, Int32.MaxValue).\n Select(s => Console.ReadLine()).\n TakeWhile(s => s != null).\n SelectMany(s => s.Split(new[] { ' ', '\\r', '\\n', '\\t' }, StringSplitOptions.RemoveEmptyEntries)).\n Concat(Enumerable.Repeat(0, 1).Select(_ => (string)null)).\n GetEnumerator();\n }\n\n public static string NextToken()\n {\n Tokens.MoveNext();\n return Tokens.Current;\n }\n }\n\n static int NextInt()\n {\n return int.Parse(Scanner.NextToken());\n }\n\n static long NextLong()\n {\n return long.Parse(Scanner.NextToken());\n }\n\n void Solve()\n {\n int n = NextInt(), x = NextInt(), y = NextInt();\n int dx = x - n/2, dy = y - n/2;\n Console.Write(!(dx > 1 || dx < 0 || dy > 1 || dy < 0) ? \"NO\" : \"YES\");\n }\n\n\n static void Main()\n {\n#if MY_SUPER_PUPER_ONLINE_JUDGE\n string dir = Directory.GetCurrentDirectory();\n dir = Directory.GetParent(dir).FullName;\n dir = Directory.GetParent(dir).FullName;\n Console.SetIn(new StreamReader(dir + \"\\\\input.txt\"));\n Console.SetOut(new StreamWriter(dir + \"\\\\output.txt\"));\n#endif\n Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.InvariantCulture;\n new Program().Solve();\n#if MY_SUPER_PUPER_ONLINE_JUDGE\n Console.In.Close();\n Console.Out.Close();\n#endif\n }\n }\n}", "lang_cluster": "C#", "tags": ["math", "implementation"], "code_uid": "4664c5c36ccc283eec019d9d75190702", "src_uid": "dc891d57bcdad3108dcb4ccf9c798789", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Text;\n\nnamespace CodeForces_85\n{\n class prob_b\n {\n \n static void Main()\n {\n string[] tmp = Console.ReadLine().Split(\" \".ToCharArray());\n int n = Int32.Parse(tmp[0]);\n int x = Int32.Parse(tmp[1]);\n int y = Int32.Parse(tmp[2]);\n\n if (x >= n / 2 && x <= n / 2 + 1 && y >= n / 2 && y <= n / 2 + 1)\n Console.WriteLine(\"NO\");\n else Console.WriteLine(\"YES\");\n \n }\n \n }\n}\n", "lang_cluster": "C#", "tags": ["math", "implementation"], "code_uid": "554843648391ab20c705ff1ed9002849", "src_uid": "dc891d57bcdad3108dcb4ccf9c798789", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections;\nusing System.Collections.Generic;\nusing System.Collections.Specialized;\nusing System.Text;\nusing System.Text.RegularExpressions;\nusing System.Linq;\n\nclass Program\n{\n static void Main()\n {\n new Magatro().Solve();\n }\n}\n\nclass Magatro\n{\n private long N, S;\n private void Scan()\n {\n var line = Console.ReadLine().Split(' ');\n N = long.Parse(line[0]);\n S = long.Parse(line[1]);\n }\n\n public long C(long n)\n {\n int sum = 0;\n long p = n;\n while (p > 0)\n {\n sum += (int)(p % 10);\n p /= 10;\n }\n return n - sum;\n }\n\n public void Solve()\n {\n Scan();\n long ok = long.MaxValue;\n long ng = 0;\n while (ok - ng > 1)\n {\n long mid = (ok + ng) / 2;\n if (C(mid) >= S)\n {\n ok = mid;\n }\n else\n {\n ng = mid;\n }\n }\n Console.WriteLine(Math.Max(0, N - ok + 1));\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "math", "dp", "binary search"], "code_uid": "1e08afdb7d7a4cc3b5515606bc902521", "src_uid": "9704e2ac6a158d5ced8fd1dc1edb356b", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text.RegularExpressions;\n \n \nnamespace Codeforces\n{\n \n public class C\n {\n \n public static void Main(string[] args)\n {\n string[] token = Console.ReadLine().Split();\n \n long n = long.Parse(token[0]);\n long s = long.Parse(token[1]);\n \n //int cnt = 0;\n long nNine = s;\n long minBest = 0;\n while(true){\n long nn = SumN(nNine);\n if(nn>=s){\n minBest = nNine;\n break;\n }\n nNine++;\n }\n \n long ans = n - minBest +1;\n \n if(ans<0)ans =0;\n \n Console.WriteLine(ans);\n }\n \n static long SumN(long n){\n string aa = n.ToString();\n int sum = 0;\n for(int i=0;i=1;x--){\n for(int y=x;y>=1;y--){\n int c = x^y;\n if(c<=n && c>=x && c != x+y){\n ans++;\n }\n\n }\n }\n \n Console.WriteLine(ans);\n }\n }\n \n}", "lang_cluster": "C#", "tags": ["brute force"], "code_uid": "9fc87b66370440dda2d6e67b7618bab7", "src_uid": "838f2e75fdff0f13f002c0dfff0b2e8d", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\n\nnamespace Xorygol\n{\n class Program\n {\n static void Main(string[] args)\n {\n int count = 0;\n int n = Convert.ToInt32(Console.ReadLine());\n for (int a = 1; a <= n; a++)\n {\n for (int b = a; b <= n; b++)\n {\n int c = a ^ b;\n if((b + a > c) && (a + c > b) && (c + b > a) && (c >= b) && (c <= n))\n {\n count++;\n }\n }\n }\n Console.WriteLine(count);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force"], "code_uid": "972f4828d2b47512e4f6444b9e5d9722", "src_uid": "838f2e75fdff0f13f002c0dfff0b2e8d", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\n\nusing System;\nusing System.Text;\nusing System.Collections.Generic;\nusing System.IO;\n\nnamespace \u04211\n{\n class Program\n {\n static bool isFileIO = false;\n\n static string[] lines;\n static int pointer = 0;\n\n\n static void Main(string[] args)\n {\n if (isFileIO)\n {\n lines = File.ReadAllLines(\"input.txt\");\n }\n ClearFile();\n Solve();\n }\n\n static string ReadLine()\n {\n if (isFileIO)\n {\n return lines[pointer++];\n }\n else\n {\n return Console.ReadLine();\n }\n }\n\n static void ClearFile()\n {\n File.WriteAllText(\"output.txt\", \"\");\n }\n\n static void WriteLine(string str)\n {\n if (isFileIO)\n {\n File.AppendAllText(\"output.txt\", str + \"\\n\");\n }\n else\n {\n Console.WriteLine(str);\n }\n }\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n static void Solve()\n {\n long w;\n long m;\n long k;\n\n string[] s = Console.ReadLine().Split(' ');\n w = long.Parse(s[0]);\n m = long.Parse(s[1]);\n k = long.Parse(s[2]);\n\n long balls = w / k;\n //Console.WriteLine(naive(balls, m));\n Console.WriteLine(real(balls, m));\n }\n\n static long summ(long a) \n {\n string s = a + \"\";\n return s.Length;\n }\n\n static long real(long balls, long m)\n {\n int n = 18;\n long first = summ(m);\n long sec = 0;\n for (long i = 1; i < n; i++)\n {\n long power = (long)Math.Pow(10, i);\n if(power >= m)\n {\n sec = i;\n break;\n }\n }\n\n List longs = new List();\n longs.Add(m);\n for (long i = sec; i < n; i++)\n {\n longs.Add((long)Math.Pow(10, i));\n }\n\n for (int i = 0; i < longs.Count; i++ )\n {\n //Console.WriteLine(longs[i]);\n }\n\n List dl = new List();\n\n List points = new List();\n long portion = first * ((long)Math.Pow(10, sec)-m);\n points.Add(portion);\n dl.Add(sec);\n for (long i = sec + 1; i < n; i++)\n {\n points.Add(i * ((long)Math.Pow(10, i) - (long)Math.Pow(10, i-1)));\n dl.Add(i);\n }\n\n for (int i = 0; i < points.Count; i++)\n {\n //Console.WriteLine(points[i]);\n }\n\n \n long total = 0;\n for (int i = 0; i < points.Count; i++ )\n {\n if (balls >= points[i])\n {\n total += points[i]/dl[i];\n balls -= points[i];\n }\n else \n {\n long diff = balls / dl[i];\n total += diff;\n balls -= diff * dl[i];\n }\n }\n\n //Console.WriteLine(total);\n\n return total;\n }\n\n static long naive(long balls, long m) \n {\n long total = 0;\n long i = m;\n long c = 0;\n while(total n + m)\n {\n Console.WriteLine(-1);\n }\n else\n {\n var r1 = Math.Min(m, k + 1);\n var r2 = Math.Min(n, k + 1);\n var res1 = (m / r1) * (n / (k+2 - r1));\n var res2 = (n / r2) * (m / (k+2 - r2));\n Console.WriteLine(Math.Max(res1, res2));\n }\n\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["greedy", "implementation"], "code_uid": "4e89d61264d443fed4164ab5e72c7931", "src_uid": "bb453bbe60769bcaea6a824c72120f73", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\n\nnamespace Jzzhu_and_Chocolate\n{\n class Program\n {\n static IO io = new IO();\n static void Main(string[] args)\n {\n long num_H = io.ReadNextLong();\n long num_W = io.ReadNextLong();\n int num_K = io.ReadNextInt();\n if (num_H + num_W - 2 < num_K)\n {\n io.PutStr(-1);\n }\n else\n {\n long num_Max = -1;\n long num_Min = Math.Min(num_H - 1, num_K);\n long num_Count = num_K - num_Min;\n num_Max = Math.Max((num_H/(num_Min+1))*num_W/(num_Count+1),num_Max);\n num_Min= Math.Min((num_W-1),num_K);\n num_Count=num_K-num_Min;\n num_Max=Math.Max(num_H/(num_Count+1)*(num_W/(num_Min+1)),num_Max);\n io.PutStr(num_Max);\n io.ReadNum();\n }\n }\n }\n\n class IO\n {\n private static Queue currentLineTokens = new Queue();\n private static string[] ReadAndSplitLine()\n {\n return Console.ReadLine().Split(new[] { ' ', '\\t' }, StringSplitOptions.RemoveEmptyEntries);\n }\n public int ReadNextInt()\n {\n return int.Parse(ReadToken());\n }\n public long ReadNextLong()\n {\n return long.Parse(ReadToken());\n }\n\n public int ReadNum()\n {\n return Convert.ToInt32(Console.ReadLine());\n }\n public long ReadLong()\n {\n return Convert.ToInt64(Console.ReadLine());\n }\n public string ReadStr()\n {\n return Console.ReadLine();\n }\n public string[] ReadStrArr()\n {\n return Console.ReadLine().Split(' ');\n }\n public int[] ReadIntArr()\n {\n return Array.ConvertAll(Console.ReadLine().Split(' '), s => int.Parse(s));\n }\n public void PutStr(string str)\n {\n Console.WriteLine(str);\n }\n public void PutStr(int str)\n {\n Console.WriteLine(str);\n }\n public void PutStr(long str)\n {\n Console.WriteLine(str);\n }\n\n public static string ReadToken()\n {\n while (currentLineTokens.Count == 0)\n currentLineTokens = new Queue(ReadAndSplitLine());\n return currentLineTokens.Dequeue();\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["greedy", "implementation"], "code_uid": "4ec4705c4308bbcaf6e6938d8a98b3c1", "src_uid": "bb453bbe60769bcaea6a824c72120f73", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "/*\n * Created by SharpDevelop.\n * User: tagirov2\n * Date: 29.02.2016\n * Time: 09:56\n * \n\nA. \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\n\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd \ufffd\ufffd\ufffd\ufffd 2 \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\n\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd \ufffd\ufffd\ufffd\ufffd 256 \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\n\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\n\ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\n\ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd. \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd r???c.\n\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd, \ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd n \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd \ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd.\n\ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd, \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd, \ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd k \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd.\n\ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd, \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd. \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd, \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd.\n\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd, \ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd.\n\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\n\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd r, c, n, k (1 <= r,?c,?n <= 10, 1 <= k <= n) \ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd \ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd \ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd,\n\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd, \ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd \ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd, \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd, \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd.\n\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd n \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd \ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd xi \ufffd yi (1 <= xi <= r, 1 <= yi <= c) \ufffd \ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd \ufffd \ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd, \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd i-\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd, \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd.\n\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd, \ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd.\n\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\n\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd \ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd, \ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd \ufffd\ufffd k \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd.\n\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\n\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\n2 2 1 1\n1 2\n\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\n4\n\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\n3 2 3 3\n1 1\n3 1\n2 2\n\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\n1\n\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\n3 2 3 2\n1 1\n3 1\n2 2\n\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\n4\n\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\n\ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd \ufffd*\ufffd \ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd \ufffd \ufffd#\ufffd \ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd.\n\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd:\n*#\n**\n\ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd, \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd, \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd 1???2, \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd \ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd,\n2???1 \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd \ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd. \ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd, \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd 4 \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd.\n\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd:\n#*\n*#\n#*\n\ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd.\n\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd \ufffd\ufffd, \ufffd\ufffd\ufffd \ufffd \ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd.\n\n */\n\nusing System;\n\nclass Program\n{\n\tpublic static void Main(string[] args)\n\t{\n\t\tstring ss = Console.ReadLine ();\n\t\tstring [] s = ss.Split (' ');\n\t\tint r = int.Parse (s [0]);\n\t\tint c = int.Parse (s [1]);\n\t\tint n = int.Parse (s [2]);\n\t\tint k = int.Parse (s [3]);\n\t\tint [,] a = new int [r, c];\n\n\t\tfor ( int i=0; i < n; i++ )\n\t\t{\n\t\t\tss = Console.ReadLine ();\n\t\t\tstring [] sa = ss.Split (' ');\n\t\t\tint x = int.Parse (sa [0]);\n\t\t\tint y = int.Parse (sa [1]);\n\t\t\ta [x-1, y-1] = 1;\n\t\t}\n\t\t\n\t\tint m = 0;\n\t\tfor ( int i=0; i < r; i++ )\n\t\t\tfor ( int j=0; j < c; j++ )\n\t\t\t\tfor ( int t=i; t < r; t++ )\n\t\t\t\t\tfor ( int p=j; p < c; p++ )\n\t\t\t\t\t{\n\t\t\t\t\t\tint kol = 0;\n\t\t\t\t\t\tfor ( int ii=i; ii <= t; ii++ )\n\t\t\t\t\t\t\tfor ( int jj=j; jj <= p; jj++ )\n\t\t\t\t\t\t\t\tif ( a [ii, jj] == 1 )\n\t\t\t\t\t\t\t\t\tkol++;\n\t\t\t\t\t\tif ( kol >= k )\n\t\t\t\t\t\t\tm++;\n\t\t\t\t\t}\n\t\t\n\n\t\tConsole.WriteLine (m);\n//\t\tConsole.ReadKey(true);\n\t}\n}\n", "lang_cluster": "C#", "tags": ["brute force", "implementation"], "code_uid": "bf2e6d7acd0c94131dc91aee73f3cf88", "src_uid": "9c766881f6415e2f53fb43b61f8f40b4", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.IO;\nusing System.Text;\n\nnamespace Orchestra\n{\n internal class Program\n {\n private static readonly StreamReader reader = new StreamReader(Console.OpenStandardInput(1024*10), Encoding.ASCII, false, 1024*10);\n private static readonly StreamWriter writer = new StreamWriter(Console.OpenStandardOutput(1024*10), Encoding.ASCII, 1024*10);\n\n private static void Main(string[] args)\n {\n int r = Next(), c = Next(), n = Next(), k = Next();\n\n var nn = new int[r + 1,c + 1];\n for (int i = 0; i < n; i++)\n {\n int x = Next();\n int y = Next();\n nn[x, y] = 1;\n }\n var sum = new int[r + 1,c + 1];\n for (int i = 1; i <= r; i++)\n {\n for (int j = 1; j <= c; j++)\n {\n sum[i, j] = nn[i, j] + sum[i - 1, j] + sum[i, j - 1] - sum[i - 1, j - 1];\n }\n }\n int count = 0;\n\n for (int i = 1; i <= r; i++)\n {\n for (int j = 1; j <= c; j++)\n {\n if (sum[i, j] < k)\n continue;\n for (int l = 0; l < i; l++)\n {\n int delta = sum[i, j] - sum[l, j];\n if (delta < k)\n break;\n\n for (int m = 0; m < j; m++)\n {\n int d = delta + sum[l, m] - sum[i, m];\n if (d >= k)\n count++;\n }\n }\n }\n }\n\n writer.WriteLine(count);\n writer.Flush();\n }\n\n private static int Next()\n {\n int c;\n int res = 0;\n do\n {\n c = reader.Read();\n if (c == -1)\n return res;\n } while (c < '0' || c > '9');\n res = c - '0';\n while (true)\n {\n c = reader.Read();\n if (c < '0' || c > '9')\n return res;\n res *= 10;\n res += c - '0';\n }\n }\n }\n}", "lang_cluster": "C#", "tags": ["brute force", "implementation"], "code_uid": "4bbeeb57eb149b50a798b867b2468b73", "src_uid": "9c766881f6415e2f53fb43b61f8f40b4", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace CodeForces\n{ \n class ADiv2\n {\n static void Main(string[] args)\n {\n string[] token = Console.ReadLine().Split();\n int h = int.Parse(token[0])* 10 + 1;;\n int m = int.Parse(token[1])* 2 + 1;\n int s = int.Parse(token[2])* 2 + 1;\n int t1 = int.Parse(token[3]) *10;\n int t2 = int.Parse(token[4]) *10;\n \n int[] a = new int[5]{h,m,s,t1,t2};\n Array.Sort(a);\n for (int i = 0; i < a.Length; ++i) {\n if (a[i] % 2 == 0 && a[(i + 1) % a.Length] % 2 == 0) {\n Console.WriteLine(\"YES\");\n return;\n }\n }\n Console.WriteLine(\"NO\");\n \n }\n }\n \n}", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "4e1e6c278417de690c1924f9582b0e51", "src_uid": "912c8f557a976bdedda728ba9f916c95", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\n\nnamespace ConsoleApp1\n{\n class Program\n {\n static void Main(string[] args)\n {\n var a = Console.ReadLine().Split(' ');\n List l = new List();\n List ll = new List();\n foreach (var b in a)\n {\n var c = double.Parse(b);\n l.Add(c);\n }\n l[0] = (l[0] == 12 ? 0d : l[0] + l[1] / 60d + l[2] / 3600d) * 5;\n l[1] = l[1] + l[2] / 60;\n var t1 = l[3] * 5;\n var t2 = l[4] * 5;\n for(int i = 0; i < 3; i++)\n {\n ll.Add(l[i]);\n }\n ll.Sort();\n\n var llmx = ll.Max();\n var llmn = ll.Min();\n if (llmx < t1 && llmx < t2)\n {\n Console.WriteLine(\"YES\");\n return;\n }\n if (llmn > t1 && llmn > t2)\n {\n\n Console.WriteLine(\"YES\");\n return;\n }\n\n //\n\n if (ll[0] < t1 && ll[1] > t1 && ll[0] < t2 && ll[1] > t2)\n {\n\n Console.WriteLine(\"YES\");\n return;\n }\n if (ll[1] < t1 && ll[2] > t1 && ll[1] < t2 && ll[2] > t2)\n {\n\n Console.WriteLine(\"YES\");\n return;\n }\n //\n if (t1 > t2)\n {\n Swap(ref t1,ref t2);\n }\n if (t2 > llmx && t1 < llmn)\n {\n\n Console.WriteLine(\"YES\");\n return;\n }\n Console.WriteLine(\"NO\");\n\n }\n public static void Swap(ref T lhs, ref T rhs)\n {\n T temp = lhs;\n lhs = rhs;\n rhs = temp;\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "8f18519d10c9e075953de3b8cbd404af", "src_uid": "912c8f557a976bdedda728ba9f916c95", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\n\nusing System;\nusing System.Collections.Generic;\nusing System.IO;\nusing System.Linq;\n\nnamespace Codeforces\n{\n public class Input\n {\n private static string _line;\n\n public static bool Next()\n {\n _line = Console.ReadLine();\n return !string.IsNullOrEmpty(_line);\n }\n\n public static bool Next(out long a)\n {\n var ok = Next();\n a = ok ? long.Parse(_line) : 0;\n return ok;\n }\n\n public static bool Next(out long a, out long b)\n {\n var ok = Next();\n if (ok)\n {\n var array = _line.Split(' ').Select(long.Parse).ToArray();\n a = array[0];\n b = array[1];\n }\n else\n {\n a = b = 0;\n }\n\n return ok;\n }\n\n public static bool Next(out long a, out long b, out long c)\n {\n var ok = Next();\n if (ok)\n {\n var array = _line.Split(' ').Select(long.Parse).ToArray();\n a = array[0];\n b = array[1];\n c = array[2];\n }\n else\n {\n a = b = c = 0;\n }\n return ok;\n }\n\n public static bool Next(out long a, out long b, out long c, out long d)\n {\n var ok = Next();\n if (ok)\n {\n var array = _line.Split(' ').Select(long.Parse).ToArray();\n a = array[0];\n b = array[1];\n c = array[2];\n d = array[3];\n }\n else\n {\n a = b = c = d = 0;\n }\n return ok;\n }\n\n public static bool Next(out long a, out long b, out long c, out long d, out long e)\n {\n var ok = Next();\n if (ok)\n {\n var array = _line.Split(' ').Select(long.Parse).ToArray();\n a = array[0];\n b = array[1];\n c = array[2];\n d = array[3];\n e = array[4];\n }\n else\n {\n a = b = c = d = e = 0;\n }\n return ok;\n }\n\n public static List Numbers()\n {\n return !Next() ? new List() : _line.Split(' ').Select(long.Parse).ToList();\n }\n\n public static bool Next(out string value)\n {\n value = string.Empty;\n if (!Next()) return false;\n value = _line;\n return true;\n }\n }\n\n public class DisjointSet\n {\n private readonly int[] _parent;\n private readonly int[] _rank;\n public int Count { get; private set; }\n\n public DisjointSet(int count, int initialize = 0)\n {\n Count = count;\n _parent = new int[Count];\n _rank = new int[Count];\n for (var i = 0; i < initialize; i++) _parent[i] = i;\n }\n\n private DisjointSet(int count, int[] parent, int[] rank)\n {\n Count = count;\n _parent = parent;\n _rank = rank;\n }\n\n public void Add(int v)\n {\n _parent[v] = v;\n _rank[v] = 0;\n }\n\n public int Find_Recursive(int v)\n {\n if (_parent[v] == v) return v;\n return _parent[v] = Find(_parent[v]);\n }\n\n public int Find(int v)\n {\n if (_parent[v] == v) return v;\n var last = v;\n while (_parent[last] != last) last = _parent[last];\n while (_parent[v] != v)\n {\n var t = _parent[v];\n _parent[v] = last;\n v = t;\n }\n return last;\n }\n\n public int this[int v]\n {\n get { return Find(v); }\n set { Union(v, value); }\n }\n\n public void Union(int a, int b)\n {\n a = Find(a);\n b = Find(b);\n if (a == b) return;\n if (_rank[a] < _rank[b])\n {\n var t = _rank[a];\n _rank[a] = _rank[b];\n _rank[b] = t;\n }\n _parent[b] = a;\n if (_rank[a] == _rank[b]) _rank[a]++;\n }\n\n public int GetSetCount()\n {\n var result = 0;\n for (var i = 0; i < Count; i++)\n {\n if (_parent[i] == i) result++;\n }\n return result;\n }\n\n public DisjointSet Clone()\n {\n var rank = new int[Count];\n _rank.CopyTo(rank, 0);\n var parent = new int[Count];\n _parent.CopyTo(parent, 0);\n return new DisjointSet(Count, parent, rank);\n }\n\n public override string ToString()\n {\n return string.Join(\",\", _parent.Take(50));\n }\n }\n\n public class Matrix\n {\n public static Matrix Create(int i, int j)\n {\n var m = new Matrix(i, j);\n return m;\n }\n\n public static Matrix Create(int i)\n {\n var m = new Matrix(i, i);\n return m;\n }\n\n public long Modulo { get; set; }\n\n private readonly int _width;\n private readonly int _height;\n private readonly long[,] _data;\n public int Width{get { return _width; }}\n public int Height{get { return _height; }}\n\n private Matrix(int i, int j)\n {\n Modulo = 1000000000000000000L;\n _width = j;\n _height = i;\n _data = new long[_height, _width];\n }\n\n public static Matrix operator *(Matrix m1, Matrix m2)\n {\n if (m1.Width != m2.Height) throw new InvalidDataException(\"m1.Width != m2.Height\");\n var m = Create(m2.Width, m1.Height);\n m.Modulo = m1.Modulo;\n for (var i=0;i();\n for (var i = 0; i < t; i++)\n {\n long a, b;\n Input.Next(out a, out b);\n if (a < b)\n {\n var c = b;\n b = a;\n a = c;\n }\n l.Add(Check(a,b) ? \"First\" : \"Second\");\n }\n Console.WriteLine(string.Join(Environment.NewLine, l));\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "games"], "code_uid": "74d2b1cc3e5d213bfe7a851d16602560", "src_uid": "5f5b320c7f314bd06c0d2a9eb311de6c", "difficulty": 2300.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System;\nusing System.Collections.Generic;\nusing System.IO;\nusing System.Linq;\n\nnamespace Codeforces\n{\n public class Input\n {\n private static string _line;\n\n public static bool Next()\n {\n _line = Console.ReadLine();\n return !string.IsNullOrEmpty(_line);\n }\n\n public static bool Next(out long a)\n {\n var ok = Next();\n a = ok ? long.Parse(_line) : 0;\n return ok;\n }\n\n public static bool Next(out long a, out long b)\n {\n var ok = Next();\n if (ok)\n {\n var array = _line.Split(' ').Select(long.Parse).ToArray();\n a = array[0];\n b = array[1];\n }\n else\n {\n a = b = 0;\n }\n\n return ok;\n }\n\n public static bool Next(out long a, out long b, out long c)\n {\n var ok = Next();\n if (ok)\n {\n var array = _line.Split(' ').Select(long.Parse).ToArray();\n a = array[0];\n b = array[1];\n c = array[2];\n }\n else\n {\n a = b = c = 0;\n }\n return ok;\n }\n\n public static bool Next(out long a, out long b, out long c, out long d)\n {\n var ok = Next();\n if (ok)\n {\n var array = _line.Split(' ').Select(long.Parse).ToArray();\n a = array[0];\n b = array[1];\n c = array[2];\n d = array[3];\n }\n else\n {\n a = b = c = d = 0;\n }\n return ok;\n }\n\n public static bool Next(out long a, out long b, out long c, out long d, out long e)\n {\n var ok = Next();\n if (ok)\n {\n var array = _line.Split(' ').Select(long.Parse).ToArray();\n a = array[0];\n b = array[1];\n c = array[2];\n d = array[3];\n e = array[4];\n }\n else\n {\n a = b = c = d = e = 0;\n }\n return ok;\n }\n\n public static List Numbers()\n {\n return !Next() ? new List() : _line.Split(' ').Select(long.Parse).ToList();\n }\n\n public static bool Next(out string value)\n {\n value = string.Empty;\n if (!Next()) return false;\n value = _line;\n return true;\n }\n }\n\n public class DisjointSet\n {\n private readonly int[] _parent;\n private readonly int[] _rank;\n public int Count { get; private set; }\n\n public DisjointSet(int count, int initialize = 0)\n {\n Count = count;\n _parent = new int[Count];\n _rank = new int[Count];\n for (var i = 0; i < initialize; i++) _parent[i] = i;\n }\n\n private DisjointSet(int count, int[] parent, int[] rank)\n {\n Count = count;\n _parent = parent;\n _rank = rank;\n }\n\n public void Add(int v)\n {\n _parent[v] = v;\n _rank[v] = 0;\n }\n\n public int Find_Recursive(int v)\n {\n if (_parent[v] == v) return v;\n return _parent[v] = Find(_parent[v]);\n }\n\n public int Find(int v)\n {\n if (_parent[v] == v) return v;\n var last = v;\n while (_parent[last] != last) last = _parent[last];\n while (_parent[v] != v)\n {\n var t = _parent[v];\n _parent[v] = last;\n v = t;\n }\n return last;\n }\n\n public int this[int v]\n {\n get { return Find(v); }\n set { Union(v, value); }\n }\n\n public void Union(int a, int b)\n {\n a = Find(a);\n b = Find(b);\n if (a == b) return;\n if (_rank[a] < _rank[b])\n {\n var t = _rank[a];\n _rank[a] = _rank[b];\n _rank[b] = t;\n }\n _parent[b] = a;\n if (_rank[a] == _rank[b]) _rank[a]++;\n }\n\n public int GetSetCount()\n {\n var result = 0;\n for (var i = 0; i < Count; i++)\n {\n if (_parent[i] == i) result++;\n }\n return result;\n }\n\n public DisjointSet Clone()\n {\n var rank = new int[Count];\n _rank.CopyTo(rank, 0);\n var parent = new int[Count];\n _parent.CopyTo(parent, 0);\n return new DisjointSet(Count, parent, rank);\n }\n\n public override string ToString()\n {\n return string.Join(\",\", _parent.Take(50));\n }\n }\n\n public class Matrix\n {\n public static Matrix Create(int i, int j)\n {\n var m = new Matrix(i, j);\n return m;\n }\n\n public static Matrix Create(int i)\n {\n var m = new Matrix(i, i);\n return m;\n }\n\n public long Modulo { get; set; }\n\n private readonly int _width;\n private readonly int _height;\n private readonly long[,] _data;\n public int Width{get { return _width; }}\n public int Height{get { return _height; }}\n\n private Matrix(int i, int j)\n {\n Modulo = 1000000000000000000L;\n _width = j;\n _height = i;\n _data = new long[_height, _width];\n }\n\n public static Matrix operator *(Matrix m1, Matrix m2)\n {\n if (m1.Width != m2.Height) throw new InvalidDataException(\"m1.Width != m2.Height\");\n var m = Create(m2.Width, m1.Height);\n m.Modulo = m1.Modulo;\n for (var i=0;i '9');\n int res = c - '0';\n while (true)\n {\n c = reader.Read();\n if (c < '0' || c > '9')\n return m*res;\n res *= 10;\n res += c - '0';\n }\n }\n }\n}", "lang_cluster": "C#", "tags": ["constructive algorithms", "implementation"], "code_uid": "903921b3aae5c0e62a3a7948460876e9", "src_uid": "36fe960550e59b046202b5811343590d", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Globalization;\nusing System.IO;\nusing System.Linq;\n\nnamespace CF\n{\n internal class Program\n {\n private static void Main(string[] args)\n {\n using (var sr = new InputReader(Console.In))\n//\t\t\tusing (var sr = new InputReader(new StreamReader(\"input.txt\")))\n using (var sw = Console.Out)\n //using (var sw = new StreamWriter(\"output.txt\"))\n using (var task = new Task(sr, sw)) {\n task.Solve();\n// Console.ReadKey();\n }\n }\n }\n\n internal class Task : IDisposable\n {\n private readonly InputReader sr;\n private readonly TextWriter sw;\n private bool isDispose;\n \n public Task(InputReader sr, TextWriter sw)\n {\n this.sr = sr;\n this.sw = sw;\n }\n \n public void Solve()\n {\n var n = sr.NextInt32();\n var games = sr.ReadArrayOfInt32();\n var count = Int32.MaxValue;\n var oneCount = 0;\n for (var i = 0; i < games.Length; i++) {\n if (games[i] == 1) {\n var zeroCount = 0;\n for (var j = i + 1; j < games.Length; j++) {\n if (games[j] == 0)\n zeroCount++;\n }\n count = Math.Min(count, zeroCount + oneCount);\n oneCount++;\n }\n }\n count = Math.Min(count, oneCount);\n if (count == Int32.MaxValue)\n count = 0;\n\n sw.Write(n - count);\n }\n\n ~Task()\n {\n Dispose(false);\n }\n\n public void Dispose()\n {\n Dispose(true);\n GC.SuppressFinalize(this);\n }\n\n private void Dispose(bool disposing)\n {\n if (!isDispose) {\n if (disposing) {\n if(sr != null)\n sr.Dispose();\n \n if(sw != null)\n sw.Dispose();\n }\n\n isDispose = true;\n } \n }\n }\n}\n\ninternal class InputReader : IDisposable\n{\n private bool isDispose;\n private readonly TextReader sr;\n private string[] buffer;\n private int seek;\n\n public InputReader(TextReader stream)\n {\n sr = stream;\n }\n\n public void Dispose()\n {\n Dispose(true);\n GC.SuppressFinalize(this);\n }\n\n public string NextString()\n {\n var result = sr.ReadLine();\n return result;\n }\n\n public int NextInt32()\n {\n return Int32.Parse(ReadNextToken());\n }\n\n private string ReadNextToken()\n {\n if (buffer == null || seek == buffer.Length) {\n seek = 0;\n buffer = NextSplitStrings();\n }\n\n return buffer[seek++];\n }\n\n public long NextInt64()\n {\n return Int64.Parse(ReadNextToken());\n }\n \n public int[] ReadArrayOfInt32()\n {\n return ReadArray(Int32.Parse);\n }\n\n public long[] ReadArrayOfInt64()\n {\n return ReadArray(Int64.Parse);\n }\n\n public string[] NextSplitStrings()\n {\n return NextString()\n .Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);\n }\n\n public T[] ReadArray(Func func)\n {\n return NextSplitStrings()\n .Select(s => func(s, CultureInfo.InvariantCulture))\n .ToArray();\n }\n\n public T[] ReadArrayFromString(Func func, string str)\n {\n return\n str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)\n .Select(s => func(s, CultureInfo.InvariantCulture))\n .ToArray();\n }\n\n protected void Dispose(bool dispose)\n {\n if (!isDispose)\n {\n if (dispose)\n sr.Close();\n \n isDispose = true;\n }\n }\n\n ~InputReader()\n {\n Dispose(false);\n }\n}", "lang_cluster": "C#", "tags": ["brute force", "implementation"], "code_uid": "ceaee92ce7cfb6f6e1f32c1c8d7f5e5c", "src_uid": "c7b1f0b40e310f99936d1c33e4816b95", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\n\nclass TEST{\n\tstatic void Main(){\n\t\tSol mySol =new Sol();\n\t\tmySol.Solve();\n\t}\n}\n\nclass Sol{\n\tpublic void Solve(){\n\t\t\n\t\tint max = 0;\n\t\tint[] B = new int[N];\n\t\tfor(int i=0;i<=N;i++){\n\t\t\tint cnt = 0;\n\t\t\tfor(int j=0;jint.Parse(e));}\n\tstatic long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}\n\tstatic double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}\n}\n", "lang_cluster": "C#", "tags": ["brute force", "implementation"], "code_uid": "eb18361c4fe29b118b8e44eaddc03219", "src_uid": "c7b1f0b40e310f99936d1c33e4816b95", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\n\nnamespace _630E_Rectangle\n{\n class Program\n {\n static void Main(string[] args)\n {\n var temp = Array.ConvertAll(Console.ReadLine().Split(' '), x => Convert.ToInt64(x));\n long x1 = temp[0];\n long y1 = temp[1];\n long x2 = temp[2];\n long y2 = temp[3];\n\n long answer = ((y2 - y1)/2 + 1)*(x2 - x1 + 1) - (x2 - x1)/2;\n\n Console.WriteLine(answer);\n }\n }\n}\n\n", "lang_cluster": "C#", "tags": ["math"], "code_uid": "850a4e883134eeb5e22f838c5d3c0dfa", "src_uid": "00cffd273df24d1676acbbfd9a39630d", "difficulty": 1900.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing Math = System.Math;\nusing Dec = System.Decimal;\nusing System.Globalization;\nusing System.Linq;\n\nnamespace taskA\n{\n\tclass newDecimal {\n\tprivate \n\t\t\tInt64 Z, F, kol;\n\tpublic newDecimal(decimal t, Int64 Kol) {\n\t\t\tkol = Kol;\n\t\t\tZ = Dec.ToInt64 (t);\n\t\t\tInt64 p = 1;\n\t\t\tfor (int i = 0; i < kol; i ++)\n\t\t\t\tp *= 10L;\t\t\n\t\t\tF = Dec.ToInt64 ((t - Z) * p);\n\t\t}\n\t\tpublic void print () {\n\t\t\tConsole.Write (\"{0}.\", Z);\n\t\t\tint sz = F.ToString ().Length;\n\t\t\tfor (int i = 0; i < kol - sz; i ++) \n\t\t\t\tConsole.Write (0);\n\t\t\tConsole.Write (F);\n\t\t}\n\t}\n\n\tclass MainClass\n\t{\n\t\tpublic static void Main(string[] args) {\n\t\t\tint[] a = Console.ReadLine ().Split (' ').Select (int.Parse).ToArray();\n\t\t\tint x1 = a [0], y1 = a [1], x2 = a [2], y2 = a [3];\n\t\t\tint r1 = x2 - x1 + 1;\n\t\t\tint r2 = y2 - y1 + 1;\n\t\t\tlong ans = (r2 / 2L) * r1;\n\t\t\tif (r2 % 2 == 1)\n\t\t\t\tans += (r1 + 1L) / 2L;\n\t\t\tConsole.WriteLine (ans);\n\t\t}\n\t}\n}\n", "lang_cluster": "C#", "tags": ["math"], "code_uid": "4aa26c74ae9dc794c237d7e8cbf829bb", "src_uid": "00cffd273df24d1676acbbfd9a39630d", "difficulty": 1900.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace problemB\n{\n class Program\n {\n static void Main(string[] args)\n {\n var sp = Console.ReadLine().Split();\n int[] a = new int[3];\n for (int i = 0; i < 3; ++i)\n a[i] = int.Parse(sp[i]);\n\n System.Collections.Generic.HashSet hashSet = new System.Collections.Generic.HashSet();\n\n a[0] %= a[1];\n int d = -1;\n int pos = 0;\n while(a[0] != 0 && (!hashSet.Contains(a[0])))\n {\n hashSet.Add(a[0]);\n a[0] *= 10;\n d = a[0] / a[1];\n if (d == a[2])\n break;\n ++pos;\n a[0] %= a[1];\n }\n Console.WriteLine((d == a[2] || a[0] == a[2]) ? pos+1 : -1);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "number theory"], "code_uid": "cd98e898eb175d16d44bee6c39aa7aec", "src_uid": "0bc7bf67b96e2898cfd8d129ad486910", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.IO;\nusing System.Text;\n\nnamespace Position_in_Fraction\n{\n internal class Program\n {\n private static readonly StreamReader reader = new StreamReader(Console.OpenStandardInput(1024*10), Encoding.ASCII, false, 1024*10);\n private static readonly StreamWriter writer = new StreamWriter(Console.OpenStandardOutput(1024*10), Encoding.ASCII, 1024*10);\n\n private static void Main(string[] args)\n {\n writer.WriteLine(Solve(args));\n\n writer.Flush();\n }\n\n private static int Solve(string[] args)\n {\n int a = Next();\n int b = Next();\n int c = Next();\n\n a %= b;\n a *= 10;\n\n var h = new HashSet {a};\n for (int i = 1;; i++)\n {\n while (a < b)\n {\n a *= 10;\n if (c == 0)\n return i;\n i++;\n }\n\n int cc = a/b;\n\n if (cc == c)\n return i;\n\n int aa = (a - cc*b)*10;\n\n if (!h.Add(aa))\n return -1;\n\n a = aa;\n\n if (a == 0)\n {\n if (c == 0)\n return i + 1;\n return -1;\n }\n }\n }\n\n private static int Next()\n {\n int c;\n int res = 0;\n do\n {\n c = reader.Read();\n if (c == -1)\n return res;\n } while (c < '0' || c > '9');\n res = c - '0';\n while (true)\n {\n c = reader.Read();\n if (c < '0' || c > '9')\n return res;\n res *= 10;\n res += c - '0';\n }\n }\n }\n}", "lang_cluster": "C#", "tags": ["math", "number theory"], "code_uid": "03d89c665faffbdd5f94334c125492c7", "src_uid": "0bc7bf67b96e2898cfd8d129ad486910", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.IO;\nusing System.Text;\n\nnamespace Square_Earth\n{\n internal class Program\n {\n private static readonly StreamReader reader = new StreamReader(Console.OpenStandardInput(1024*10), Encoding.ASCII, false, 1024*10);\n private static readonly StreamWriter writer = new StreamWriter(Console.OpenStandardOutput(1024*10), Encoding.ASCII, 1024*10);\n\n private static void Main(string[] args)\n {\n int n = Next(), x1 = Next(), y1 = Next(), x2 = Next(), y2 = Next();\n\n int d = D(x1, x2, n, y1 == y2) + D(y1, y2, n, x1 == x2);\n\n writer.WriteLine(d);\n writer.Flush();\n }\n\n private static int D(int x, int y, int n, bool one)\n {\n if (Math.Abs(x - y) == n)\n return n;\n\n if (one)\n return Math.Abs(x - y);\n\n return Math.Min(x + y, n - x + n - y);\n }\n\n private static int Next()\n {\n int c;\n int res = 0;\n do\n {\n c = reader.Read();\n if (c == -1)\n return res;\n } while (c < '0' || c > '9');\n res = c - '0';\n while (true)\n {\n c = reader.Read();\n if (c < '0' || c > '9')\n return res;\n res *= 10;\n res += c - '0';\n }\n }\n }\n}", "lang_cluster": "C#", "tags": ["dfs and similar", "greedy", "implementation"], "code_uid": "be8cabee46bab19a25eae9011d4ae2f3", "src_uid": "685fe16c217b5b71eafdb4198822250e", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.IO;\nusing System.Collections;\n\n\nnamespace _43\n{\n class Program\n {\n \n static void Main(string[] args)\n {\n \n int x1, x2, y1, y2,n;\n string []s = Console.ReadLine().Split(' ');\n n = int.Parse(s[0].ToString());\n x1 =int.Parse(s[1]);\n y1 = int.Parse(s[2]);\n x2 = int.Parse(s[3]);\n y2 = int.Parse(s[4]);\n int p = 4 * n;\n int ans = Math.Abs(x1 - x2) + Math.Abs(y1 - y2);\n if (Math.Abs(x1 - x2) == n) ans += 2 * Math.Min(y1, y2);\n if (Math.Abs(y1 - y2) == n) ans += 2 * Math.Min(x1, x2);\n\n Console.WriteLine(Math.Min(ans,p-ans));\n \n \n\n \n\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["dfs and similar", "greedy", "implementation"], "code_uid": "8bab85b4b34f1f8937f93e102f171bbe", "src_uid": "685fe16c217b5b71eafdb4198822250e", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "#define Online\n\nusing System;\nusing System.Collections.Generic;\nusing System.Globalization;\nusing System.Linq;\nusing System.Text;\nusing System.IO;\nusing System.Diagnostics;\nusing System.Threading;\n\ndelegate double F(double x);\ndelegate decimal Fdec(decimal x);\n\nclass Program\n{//\n\n static void Rec(int v, int[] a, ref long cnt)\n {\n if (v == a.Length)\n {\n for (int i = 0, j = 0, p = 0; i < a.Length; i++)\n {\n p = a[i];\n j = 0;\n while (j < a.Length)\n {\n if (p == 0) { break; }\n p = a[p];\n j++;\n }\n if (j == a.Length)\n return;\n }\n cnt++;\n }\n else\n {\n for (int i = 0; i < a.Length; i++)\n {\n a[v] = i;\n Rec(v + 1, a, ref cnt);\n }\n }\n }\n \n static void Main(string[] args)\n {\n\n Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;\n\n#if FileIO\n StreamReader sr = new StreamReader(\"frozen.in\");\n StreamWriter sw = new StreamWriter(\"frozen.out\");\n Console.SetIn(sr);\n Console.SetOut(sw);\n#endif\n\n int n, k;\n string[] input = ReadArray();\n const long mod=1000000007;\n n = int.Parse(input[0]);\n k = int.Parse(input[1]);\n long cnt = 0;\n int[] a = new int[k];\n Rec(0, a, ref cnt);\n for (int i = 0; i < n - k; i++)\n {\n cnt = (cnt * (n - k)) % mod;\n }\n Console.WriteLine(cnt);\n\n#if Online\n Console.ReadLine();\n#endif\n\n#if FileIO\n sr.Close();\n sw.Close();\n#endif\n }\n\n static string[] ReadArray()\n {\n return Console.ReadLine().Split(' ');\n }\n\n static int ReadInt()\n {\n return int.Parse(Console.ReadLine());\n }\n}\n\nstatic class ArrayUtils\n{\n public static int BinarySearch(int[] a, int val)\n {\n int left = 0;\n int right = a.Length - 1;\n int mid;\n\n while (left < right)\n {\n mid = left + ((right - left) >> 1);\n if (val <= a[mid])\n {\n right = mid;\n }\n else\n {\n left = mid + 1;\n }\n }\n\n if (a[left] == val)\n return left;\n else\n return -1;\n }\n\n public static double Bisection(F f, double left, double right, double eps)\n {\n double mid;\n while (right - left > eps)\n {\n mid = left + ((right - left) / 2d);\n if (Math.Sign(f(mid)) != Math.Sign(f(left)))\n right = mid;\n else\n left = mid;\n }\n return (left + right) / 2d;\n }\n\n\n public static decimal TernarySearchDec(Fdec f, decimal eps, decimal l, decimal r, bool isMax)\n {\n decimal m1, m2;\n while (r - l > eps)\n {\n m1 = l + (r - l) / 3m;\n m2 = r - (r - l) / 3m;\n if (f(m1) < f(m2))\n if (isMax)\n l = m1;\n else\n r = m2;\n else\n if (isMax)\n r = m2;\n else\n l = m1;\n }\n return r;\n }\n\n public static double TernarySearch(F f, double eps, double l, double r, bool isMax)\n {\n double m1, m2;\n while (r - l > eps)\n {\n m1 = l + (r - l) / 3d;\n m2 = r - (r - l) / 3d;\n if (f(m1) < f(m2))\n if (isMax)\n l = m1;\n else\n r = m2;\n else\n if (isMax)\n r = m2;\n else\n l = m1;\n }\n return r;\n }\n\n public static void Merge(int[] A, int p, int q, int r, int[] L, int[] R)\n {\n for (int i = p; i <= q; i++)\n L[i] = A[i];\n for (int i = q + 1; i <= r; i++)\n R[i] = A[i];\n\n for (int k = p, i = p, j = q + 1; k <= r; k++)\n {\n if (i > q)\n {\n for (; k <= r; k++, j++)\n A[k] = R[j];\n return;\n }\n if (j > r)\n {\n for (; k <= r; k++, i++)\n A[k] = L[i];\n return;\n }\n if (L[i] <= R[j])\n {\n A[k] = L[i];\n i++;\n }\n else\n {\n A[k] = R[j];\n j++;\n }\n }\n }\n\n public static void Merge_Sort(int[] A, int p, int r, int[] L, int[] R)\n {\n if (!(p < r)) return;\n int q = p + ((r - p) >> 1);\n Merge_Sort(A, p, q, L, R);\n Merge_Sort(A, q + 1, r, L, R);\n Merge(A, p, q, r, L, R);\n }\n \n static void Shake(int[] a)\n {\n Random rnd = new Random(Environment.TickCount);\n int temp, b, c;\n for (int i = 0; i < a.Length; i++)\n {\n b = rnd.Next(0, a.Length);\n c = rnd.Next(0, a.Length);\n temp = a[b];\n a[b] = a[c];\n a[c] = temp;\n }\n }\n}", "lang_cluster": "C#", "tags": ["dfs and similar", "math", "combinatorics", "brute force"], "code_uid": "966bd1eacf3b604a9415115ca8060e7d", "src_uid": "cc838bc14408f14f984a349fea9e9694", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.IO;\nusing System.Text;\n\nnamespace Polo_the_Penguin_and_Houses\n{\n internal class Program\n {\n private const int mod = 1000000007;\n private static readonly StreamReader reader = new StreamReader(Console.OpenStandardInput(1024*10), Encoding.ASCII, false, 1024*10);\n private static readonly StreamWriter writer = new StreamWriter(Console.OpenStandardOutput(1024*10), Encoding.ASCII, 1024*10);\n\n private static void Main(string[] args)\n {\n int n = Next();\n int k = Next();\n\n var first = new int[k];\n first[0] = 0;\n\n int count = 0;\n do\n {\n if (first[0] == 1)\n break;\n\n var f = new bool[first.Length];\n bool ok = true;\n for (int i = 1; i < f.Length; i++)\n {\n int index = i;\n for (int j = 0; j < k; j++)\n {\n index = first[index];\n if (index == 0)\n break;\n }\n if (index != 0)\n {\n ok = false;\n break;\n }\n }\n if (ok)\n count++;\n } while (Next(first, k));\n\n long ans = count*(k);\n for (int i = n - k; i >= 1; i--)\n {\n ans = (ans*(n - k))%mod;\n }\n\n writer.WriteLine(ans);\n writer.Flush();\n }\n\n private static bool Next(int[] nn, int k)\n {\n for (int i = nn.Length - 1; i >= 0; i--)\n {\n nn[i]++;\n if (nn[i] == k)\n {\n nn[i] = 0;\n }\n else\n {\n return true;\n }\n }\n return false;\n }\n\n\n private static int Next()\n {\n int c;\n int res = 0;\n do\n {\n c = reader.Read();\n if (c == -1)\n return res;\n } while (c < '0' || c > '9');\n res = c - '0';\n while (true)\n {\n c = reader.Read();\n if (c < '0' || c > '9')\n return res;\n res *= 10;\n res += c - '0';\n }\n }\n }\n}", "lang_cluster": "C#", "tags": ["combinatorics"], "code_uid": "591628837534fe2f3b22d61291a2da46", "src_uid": "cc838bc14408f14f984a349fea9e9694", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.IO;\nusing System.Text;\n\nnamespace Board_Game\n{\n internal class Program\n {\n private static readonly StreamReader reader = new StreamReader(Console.OpenStandardInput(1024*10), Encoding.ASCII, false, 1024*10);\n private static readonly StreamWriter writer = new StreamWriter(Console.OpenStandardOutput(1024*10), Encoding.ASCII, 1024*10);\n\n private static void Main(string[] args)\n {\n int xp = Next(), yp = Next(), xv = Next(), yv = Next();\n\n if (xp <= xv && yp <= yv || xp + yp <= Math.Max(xv, yv))\n writer.WriteLine(\"Polycarp\");\n else\n writer.WriteLine(\"Vasiliy\");\n writer.Flush();\n }\n\n private static int Next()\n {\n int c;\n int res = 0;\n do\n {\n c = reader.Read();\n if (c == -1)\n return res;\n } while (c < '0' || c > '9');\n res = c - '0';\n while (true)\n {\n c = reader.Read();\n if (c < '0' || c > '9')\n return res;\n res *= 10;\n res += c - '0';\n }\n }\n }\n}", "lang_cluster": "C#", "tags": ["math", "greedy", "implementation", "games"], "code_uid": "105c8c9ac1f20db30b4b75ec4a070b4c", "src_uid": "2637d57f7809ff8f922549c617709074", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections;\nusing System.Collections.Generic;\nusing System.Globalization;\nusing System.Linq;\nusing System.Text;\nusing System.Text.RegularExpressions;\nusing System.Threading;\n\nnamespace Codeforces\n{\n class C\n {\n private static ThreadStart s_threadStart = new C().Go;\n private static bool s_time = false;\n private static double s_eps = 1e-16;\n\n private void Go()\n {\n int px = GetInt();\n int py = GetInt();\n int vx = GetInt();\n int vy = GetInt();\n\n if (px <= vx && py <= vy)\n {\n Wl(\"Polycarp\"); return;\n }\n if(vx <= px && vy <= py)\n {\n Wl(\"Vasiliy\"); return;\n }\n\n if (px > vx)\n {\n if (px <= vy - py)\n {\n Wl(\"Polycarp\"); return;\n }\n Wl(\"Vasiliy\"); return;\n }\n\n if (py <= vx - px)\n {\n Wl(\"Polycarp\"); return;\n }\n Wl(\"Vasiliy\"); return;\n }\n\n #region Template\n\n public static void Main(string[] args)\n {\n System.Diagnostics.Stopwatch timer = new System.Diagnostics.Stopwatch();\n Thread main = new Thread(new ThreadStart(s_threadStart), 200 * 1024 * 1024);\n timer.Start();\n main.Start();\n main.Join();\n timer.Stop();\n if (s_time)\n Wl(timer.ElapsedMilliseconds);\n }\n\n private static IEnumerator ioEnum;\n private static string GetString()\n {\n while (ioEnum == null || !ioEnum.MoveNext())\n {\n ioEnum = Console.ReadLine().Split().AsEnumerable().GetEnumerator();\n }\n\n return ioEnum.Current;\n }\n\n private static int GetInt()\n {\n return int.Parse(GetString(), CultureInfo.InvariantCulture);\n }\n\n private static long GetLong()\n {\n return long.Parse(GetString(), CultureInfo.InvariantCulture);\n }\n\n private static double GetDouble()\n {\n return double.Parse(GetString(), CultureInfo.InvariantCulture);\n }\n\n private static List GetIntArr(int n)\n {\n List ret = new List(n);\n for (int i = 0; i < n; i++)\n {\n ret.Add(GetInt());\n }\n return ret;\n }\n\n private static void Wl(T o)\n {\n if (o is double)\n {\n Wld((o as double?).Value, \"\");\n }\n else if (o is float)\n {\n Wld((o as float?).Value, \"\");\n }\n else\n Console.WriteLine(o.ToString());\n }\n\n private static void Wl(IEnumerable enumerable)\n {\n Wl(string.Join(\" \", enumerable.Select(e => e.ToString()).ToArray()));\n }\n\n private static void Wld(double d, string format)\n {\n Wl(d.ToString(format, CultureInfo.InvariantCulture));\n }\n\n #endregion\n }\n}", "lang_cluster": "C#", "tags": ["math", "greedy", "implementation", "games"], "code_uid": "e59a66335aecd9babe13ca673a31ff96", "src_uid": "2637d57f7809ff8f922549c617709074", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Diagnostics;\nusing System.IO;\nusing System.Linq;\nusing System.Numerics;\nusing System.Text;\n\nnamespace CodeforcesTemplate\n{\n public static class Permutation\n {\n private static bool Next(ref int[] arr)\n {\n int k, j, l;\n for (j = arr.Length - 2; (j >= 0) && (arr[j] >= arr[j + 1]); j--) { }\n if (j == -1)\n {\n arr = arr.OrderBy(c => c).ToArray();\n return false;\n }\n for (l = arr.Length - 1; (arr[j] >= arr[l]) && (l >= 0); l--) { }\n var tmp = arr[j];\n arr[j] = arr[l];\n arr[l] = tmp;\n for (k = j + 1, l = arr.Length - 1; k < l; k++, l--)\n {\n tmp = arr[k];\n arr[k] = arr[l];\n arr[l] = tmp;\n }\n return true;\n }\n public static IEnumerable AllPermutations(int[] arr)\n {\n do yield return arr;\n while (Next(ref arr));\n }\n }\n\n class Program\n {\n private const string FILENAME = \"distance4\";\n\n private const string INPUT = FILENAME + \".in\";\n\n private const string OUTPUT = FILENAME + \".out\";\n\n private static Stopwatch _stopwatch = new Stopwatch();\n\n private static StreamReader _reader = null;\n private static StreamWriter _writer = null;\n\n private static string[] _curLine;\n private static int _curTokenIdx;\n\n private static char[] _whiteSpaces = new char[] { ' ', '\\t', '\\r', '\\n' };\n\n private static string ReadNextToken()\n {\n if (_curTokenIdx >= _curLine.Length)\n {\n //Read next line\n string line = _reader.ReadLine();\n if (line != null)\n _curLine = line.Split(_whiteSpaces, StringSplitOptions.RemoveEmptyEntries);\n else\n _curLine = new string[] { };\n _curTokenIdx = 0;\n }\n\n if (_curTokenIdx >= _curLine.Length)\n return null;\n\n return _curLine[_curTokenIdx++];\n }\n\n private static int ReadNextInt()\n {\n return int.Parse(ReadNextToken());\n }\n\n private static void RunTimer()\n {\n#if (DEBUG)\n\n _stopwatch.Start();\n\n#endif\n }\n\n private static void Main(string[] args)\n {\n\n#if (DEBUG)\n double before = GC.GetTotalMemory(false);\n#endif\n\n long a = long.Parse(Console.ReadLine());\n long b = long.Parse(Console.ReadLine());\n\n char[] aChar = (\"\" + a).ToCharArray();\n char[] bChar = (\"\" + b).ToCharArray();\n\n if (aChar.Length < bChar.Length)\n {\n Array.Sort(aChar);\n\n Array.Reverse(aChar);\n\n Console.WriteLine(new string(aChar));\n\n return;\n }\n\n int[] aDigit = new int[10];\n int[] bDigit = new int[10];\n\n foreach (char ch in aChar)\n {\n aDigit[ch - '0']++;\n }\n\n foreach (char ch in bChar)\n {\n bDigit[ch - '0']++;\n }\n\n bool same = true;\n\n for (int i = 0; i < 10; i++)\n {\n if (aDigit[i] != bDigit[i])\n {\n same = false;\n }\n }\n\n if (same)\n {\n Console.WriteLine(b);\n return;\n }\n\n\n long answer = 0;\n\n for (int divide = 0; divide < aChar.Length; divide++)\n {\n if (divide >= 1)\n {\n if (aDigit[bChar[divide - 1] - '0'] == 0)\n {\n break;\n }\n\n aDigit[bChar[divide - 1] - '0']--;\n }\n\n StringBuilder sb = new StringBuilder();\n\n for (int i = 0; i < divide; i++)\n {\n sb.Append(bChar[i]);\n }\n\n int usedLower = -1;\n\n for (int d = (bChar[divide] - '0') - 1; d >= (divide == 0 ? 1 : 0); d--)\n {\n if (aDigit[d] > 0)\n {\n usedLower = d;\n break;\n }\n }\n\n\n if (usedLower < 0)\n {\n continue;\n }\n\n sb.Append((char)('0' + usedLower));\n\n aDigit[usedLower]--;\n\n for (int i = divide + 1; i < aChar.Length; i++)\n {\n for (int d = 9; d >= 0; d--)\n {\n for (int x = 0; x < aDigit[d] && i < aChar.Length; x++, i++)\n {\n sb.Append((char)('0' + d));\n }\n }\n }\n\n aDigit[usedLower]++;\n\n answer = Math.Max(answer, long.Parse(sb.ToString()));\n }\n\n Console.WriteLine(answer);\n\n\n\n#if (DEBUG)\n _stopwatch.Stop();\n\n double after = GC.GetTotalMemory(false);\n\n double consumedInMegabytes = (after - before) / (1024 * 1024);\n\n Console.WriteLine($\"Time elapsed: {_stopwatch.Elapsed}\");\n\n Console.WriteLine($\"Consumed memory (MB): {consumedInMegabytes}\");\n\n Console.ReadKey();\n#endif\n\n\n }\n\n private static int CountLeadZeros(string source)\n {\n int countZero = 0;\n\n for (int i = source.Length - 1; i >= 0; i--)\n {\n if (source[i] == '0')\n {\n countZero++;\n }\n\n else\n {\n break;\n }\n\n }\n\n return countZero;\n }\n\n private static string ReverseString(string source)\n {\n char[] reverseArray = source.ToCharArray();\n\n Array.Reverse(reverseArray);\n\n string reversedString = new string(reverseArray);\n\n return reversedString;\n }\n\n\n private static int[] CopyOfRange(int[] src, int start, int end)\n {\n int len = end - start;\n int[] dest = new int[len];\n Array.Copy(src, start, dest, 0, len);\n return dest;\n }\n\n private static string StreamReader()\n {\n\n if (_reader == null)\n _reader = new StreamReader(INPUT);\n string response = _reader.ReadLine();\n if (_reader.EndOfStream)\n _reader.Close();\n return response;\n\n\n }\n\n private static void StreamWriter(string text)\n {\n\n if (_writer == null)\n _writer = new StreamWriter(OUTPUT);\n _writer.WriteLine(text);\n\n\n }\n\n\n\n\n\n private static int BFS(int start, int end, int[,] arr)\n {\n Queue> queue = new Queue>();\n List visited = new List();\n for (int i = 0; i < arr.GetLength(0); i++)\n {\n visited.Add(false);\n }\n\n queue.Enqueue(new KeyValuePair(start, 0));\n KeyValuePair node;\n int level = 0;\n bool flag = false;\n\n while (queue.Count != 0)\n {\n node = queue.Dequeue();\n if (node.Key == end)\n {\n return node.Value;\n }\n flag = false;\n for (int i = 0; i < arr.GetLength(0); i++)\n {\n\n if (arr[node.Key, i] == 1)\n {\n if (visited[i] == false)\n {\n if (!flag)\n {\n level = node.Value + 1;\n flag = true;\n }\n queue.Enqueue(new KeyValuePair(i, level));\n visited[i] = true;\n }\n }\n }\n\n }\n return 0;\n\n }\n\n\n\n private static void Write(string source)\n {\n File.WriteAllText(OUTPUT, source);\n }\n\n private static string ReadString()\n {\n return File.ReadAllText(INPUT);\n }\n\n private static void WriteStringArray(string[] source)\n {\n File.WriteAllLines(OUTPUT, source);\n }\n\n private static string[] ReadStringArray()\n {\n return File.ReadAllLines(INPUT);\n }\n\n private static int[] GetIntArray()\n {\n return ReadString().Split(' ').Select(int.Parse).ToArray();\n }\n\n private static double[] GetDoubleArray()\n {\n return ReadString().Split(' ').Select(double.Parse).ToArray();\n }\n\n private static int[,] ReadINT2XArray(List lines)\n {\n int[,] arr = new int[lines.Count, lines.Count];\n\n for (int i = 0; i < lines.Count; i++)\n {\n int[] row = lines[i].Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(int.Parse).ToArray();\n\n for (int j = 0; j < lines.Count; j++)\n {\n arr[i, j] = row[j];\n }\n }\n\n return arr;\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["greedy", "dp"], "code_uid": "da72e0ed5769991d95f3960d5ba6f26a", "src_uid": "bc31a1d4a02a0011eb9f5c754501cd44", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Diagnostics;\nusing System.IO;\nusing System.Linq;\nusing System.Numerics;\nusing System.Text;\n\nnamespace CodeforcesTemplate\n{\n public static class Permutation\n {\n private static bool Next(ref int[] arr)\n {\n int k, j, l;\n for (j = arr.Length - 2; (j >= 0) && (arr[j] >= arr[j + 1]); j--) { }\n if (j == -1)\n {\n arr = arr.OrderBy(c => c).ToArray();\n return false;\n }\n for (l = arr.Length - 1; (arr[j] >= arr[l]) && (l >= 0); l--) { }\n var tmp = arr[j];\n arr[j] = arr[l];\n arr[l] = tmp;\n for (k = j + 1, l = arr.Length - 1; k < l; k++, l--)\n {\n tmp = arr[k];\n arr[k] = arr[l];\n arr[l] = tmp;\n }\n return true;\n }\n public static IEnumerable AllPermutations(int[] arr)\n {\n do yield return arr;\n while (Next(ref arr));\n }\n }\n\n class Program\n {\n private const string FILENAME = \"distance4\";\n\n private const string INPUT = FILENAME + \".in\";\n\n private const string OUTPUT = FILENAME + \".out\";\n\n private static Stopwatch _stopwatch = new Stopwatch();\n\n private static StreamReader _reader = null;\n private static StreamWriter _writer = null;\n\n private static string[] _curLine;\n private static int _curTokenIdx;\n\n private static char[] _whiteSpaces = new char[] { ' ', '\\t', '\\r', '\\n' };\n\n private static string ReadNextToken()\n {\n if (_curTokenIdx >= _curLine.Length)\n {\n //Read next line\n string line = _reader.ReadLine();\n if (line != null)\n _curLine = line.Split(_whiteSpaces, StringSplitOptions.RemoveEmptyEntries);\n else\n _curLine = new string[] { };\n _curTokenIdx = 0;\n }\n\n if (_curTokenIdx >= _curLine.Length)\n return null;\n\n return _curLine[_curTokenIdx++];\n }\n\n private static int ReadNextInt()\n {\n return int.Parse(ReadNextToken());\n }\n\n private static void RunTimer()\n {\n#if (DEBUG)\n\n _stopwatch.Start();\n\n#endif\n }\n\n private static void Main(string[] args)\n {\n\n#if (DEBUG)\n double before = GC.GetTotalMemory(false);\n#endif\n\n long a = long.Parse(Console.ReadLine());\n long b = long.Parse(Console.ReadLine());\n\n char[] aChar = (\"\" + a).ToCharArray();\n char[] bChar = (\"\" + b).ToCharArray();\n\n if (aChar.Length < bChar.Length)\n {\n Array.Sort(aChar);\n\n Array.Reverse(aChar);\n\n Console.WriteLine(new string(aChar));\n\n return;\n }\n\n int[] aDigit = new int[10];\n int[] bDigit = new int[10];\n\n foreach (char ch in aChar)\n {\n aDigit[ch - '0']++;\n }\n\n foreach (char ch in bChar)\n {\n bDigit[ch - '0']++;\n }\n\n bool same = true;\n\n for (int i = 0; i < 10; i++)\n {\n if (aDigit[i] != bDigit[i])\n {\n same = false;\n }\n }\n\n if (same)\n {\n Console.WriteLine(b);\n return;\n }\n\n\n long answer = 0;\n\n for (int divide = 0; divide < aChar.Length; divide++)\n {\n if (divide >= 1)\n {\n if (aDigit[bChar[divide - 1] - '0'] == 0)\n {\n break;\n }\n\n aDigit[bChar[divide - 1] - '0']--;\n }\n\n StringBuilder sb = new StringBuilder();\n\n for (int i = 0; i < divide; i++)\n {\n sb.Append(bChar[i]);\n }\n\n int usedLower = -1;\n\n for (int d = (bChar[divide] - '0') - 1; d >= (divide == 0 ? 1 : 0); d--)\n {\n if (aDigit[d] > 0)\n {\n usedLower = d;\n break;\n }\n }\n\n\n if (usedLower < 0)\n {\n continue;\n }\n\n sb.Append((char)(usedLower + '0'));\n\n aDigit[usedLower]--;\n\n for (int i = divide + 1; i < aChar.Length; i++)\n {\n for (int d = 9; d >= 0; d--)\n {\n for (int x = 0; x < aDigit[d] && i < aChar.Length; x++, i++)\n {\n sb.Append((char)(d + '0'));\n }\n }\n }\n\n aDigit[usedLower]++;\n\n answer = Math.Max(answer, long.Parse(sb.ToString()));\n }\n\n Console.WriteLine(answer);\n\n\n\n#if (DEBUG)\n _stopwatch.Stop();\n\n double after = GC.GetTotalMemory(false);\n\n double consumedInMegabytes = (after - before) / (1024 * 1024);\n\n Console.WriteLine($\"Time elapsed: {_stopwatch.Elapsed}\");\n\n Console.WriteLine($\"Consumed memory (MB): {consumedInMegabytes}\");\n\n Console.ReadKey();\n#endif\n\n\n }\n\n private static int CountLeadZeros(string source)\n {\n int countZero = 0;\n\n for (int i = source.Length - 1; i >= 0; i--)\n {\n if (source[i] == '0')\n {\n countZero++;\n }\n\n else\n {\n break;\n }\n\n }\n\n return countZero;\n }\n\n private static string ReverseString(string source)\n {\n char[] reverseArray = source.ToCharArray();\n\n Array.Reverse(reverseArray);\n\n string reversedString = new string(reverseArray);\n\n return reversedString;\n }\n\n\n private static int[] CopyOfRange(int[] src, int start, int end)\n {\n int len = end - start;\n int[] dest = new int[len];\n Array.Copy(src, start, dest, 0, len);\n return dest;\n }\n\n private static string StreamReader()\n {\n\n if (_reader == null)\n _reader = new StreamReader(INPUT);\n string response = _reader.ReadLine();\n if (_reader.EndOfStream)\n _reader.Close();\n return response;\n\n\n }\n\n private static void StreamWriter(string text)\n {\n\n if (_writer == null)\n _writer = new StreamWriter(OUTPUT);\n _writer.WriteLine(text);\n\n\n }\n\n\n\n\n\n private static int BFS(int start, int end, int[,] arr)\n {\n Queue> queue = new Queue>();\n List visited = new List();\n for (int i = 0; i < arr.GetLength(0); i++)\n {\n visited.Add(false);\n }\n\n queue.Enqueue(new KeyValuePair(start, 0));\n KeyValuePair node;\n int level = 0;\n bool flag = false;\n\n while (queue.Count != 0)\n {\n node = queue.Dequeue();\n if (node.Key == end)\n {\n return node.Value;\n }\n flag = false;\n for (int i = 0; i < arr.GetLength(0); i++)\n {\n\n if (arr[node.Key, i] == 1)\n {\n if (visited[i] == false)\n {\n if (!flag)\n {\n level = node.Value + 1;\n flag = true;\n }\n queue.Enqueue(new KeyValuePair(i, level));\n visited[i] = true;\n }\n }\n }\n\n }\n return 0;\n\n }\n\n\n\n private static void Write(string source)\n {\n File.WriteAllText(OUTPUT, source);\n }\n\n private static string ReadString()\n {\n return File.ReadAllText(INPUT);\n }\n\n private static void WriteStringArray(string[] source)\n {\n File.WriteAllLines(OUTPUT, source);\n }\n\n private static string[] ReadStringArray()\n {\n return File.ReadAllLines(INPUT);\n }\n\n private static int[] GetIntArray()\n {\n return ReadString().Split(' ').Select(int.Parse).ToArray();\n }\n\n private static double[] GetDoubleArray()\n {\n return ReadString().Split(' ').Select(double.Parse).ToArray();\n }\n\n private static int[,] ReadINT2XArray(List lines)\n {\n int[,] arr = new int[lines.Count, lines.Count];\n\n for (int i = 0; i < lines.Count; i++)\n {\n int[] row = lines[i].Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(int.Parse).ToArray();\n\n for (int j = 0; j < lines.Count; j++)\n {\n arr[i, j] = row[j];\n }\n }\n\n return arr;\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["greedy", "dp"], "code_uid": "aa8afbf84bce42734dfd5d37254a3db1", "src_uid": "bc31a1d4a02a0011eb9f5c754501cd44", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Globalization;\nusing System.IO;\nusing System.Linq;\nusing System.Text;\nusing System.Text.RegularExpressions;\nusing System.Threading;\nusing static System.Math;\n\nnamespace Olymp\n{\n public class ProblemSolver\n {\n private Tokenizer input;\n\n private int[] c;\n\n public void Solve()\n {\n c = input.ReadIntArray(24);\n\n var canBuild =\n e(1, 2, 3, 4) && e(9, 10, 11, 12) && (e(5, 6, 19, 20) && e(17, 18, 23, 24) && e(13, 14, 7, 8) && e(21, 22, 15, 16) || e(5, 6, 15, 16) && e(17, 18, 7, 8) && e(21, 22, 19, 20) && e(13, 14, 23, 24)) ||\n e(5, 6, 7, 8) && e(21, 22, 23, 24) && (e(3, 4, 18, 20) && e(17, 19, 11, 12) && e(9, 10, 13, 15) && e(14, 16, 1, 2) || e(3, 4, 13, 15) && e(14, 16, 11, 12) && e(9, 10, 18, 20) && e(17, 19, 1, 2)) ||\n e(13, 14, 15, 16) && e(17, 18, 19, 20) && (e(5, 7, 10, 12) && e(1, 3, 6, 8) && e(9, 11, 21, 23) && e(2, 4, 22, 24) || e(6, 8, 9, 11) && e(2, 4, 5, 7) && e(10, 12, 22, 24) && e(1, 3, 21, 23));\n Console.WriteLine(canBuild ? \"YES\" : \"NO\");\n\n // 1 1 1 1 5 5 3 3 4 4 4 4 3 3 2 2 6 6 5 5 2 2 6 6\n\n // 1 1\n // 1 1\n //3 3 5 5 6 6 2 2\n //2 2 3 3 5 5 6 6\n // 4 4\n // 4 4\n\n\n\n // 1\n // 4 2 5 6\n // 3\n\n // 1 3\n // \u043f\u043e \u0447\u0430\u0441\u043e\u0432\u043e\u0439 - 5,6,18,20 17,18,23,24 13,14,7,8 21,22,15,16\n // \u043f\u0440 \u0447\u0430\u0441\u043e\u0432\u043e\u0439 - 5,6,15,16 17,18,7,8 21,22,19,20 13,14,23,24\n\n // 2 6\n // \u043f\u043e \u0447\u0430\u0441\u043e\u0432\u043e\u0439 - 3,4,18,20 17,19,11,12 9,10,13,15 14,16,1,2\n // \u043f\u0440 \u0447\u0430\u0441\u043e\u0432\u043e\u0439 - 3,4,13,15 14,16,11,12 9,10,18,20 17,19,1,2\n\n // 4 5\n // \u043f\u043e \u0447\u0430\u0441\u043e\u0432\u043e\u0439 - 5,7,10,12 1,3,6,8 9,11,21,23 2,4,22,24\n // \u043f\u0440 \u0447\u0430\u0441\u043e\u0432\u043e\u0439 - 6,8,9,11 2,4,5,7 10,12,22,24 1,3,21,23\n }\n\n public bool e(params int[] ids)\n {\n return ids.Select(i => c[i - 1]).Distinct().Count() == 1;\n }\n\n public ProblemSolver(TextReader input)\n {\n this.input = new Tokenizer(input);\n }\n }\n\n #region Service classes\n\n public class Tokenizer\n {\n private TextReader reader;\n\n public int ReadInt()\n {\n var c = SkipWS();\n if (c == -1)\n throw new EndOfStreamException();\n bool isNegative = false;\n if (c == '-' || c == '+')\n {\n isNegative = c == '-';\n c = this.reader.Read();\n if (c == -1)\n throw new InvalidOperationException();\n }\n if (!char.IsDigit((char)c))\n throw new InvalidOperationException();\n int result = (char)c - '0';\n c = this.reader.Read();\n while (c > 0 && !char.IsWhiteSpace((char)c))\n {\n if (!char.IsDigit((char)c))\n throw new InvalidOperationException();\n result = result * 10 + (char)c - '0';\n c = this.reader.Read();\n }\n if (isNegative)\n result = -result;\n return result;\n }\n\n public string ReadLine()\n {\n return reader.ReadLine();\n }\n\n public long ReadLong()\n {\n return long.Parse(this.ReadToken());\n }\n\n public double ReadDouble()\n {\n return double.Parse(this.ReadToken(), CultureInfo.InvariantCulture);\n }\n\n public int[] ReadIntArray(int n)\n {\n int[] a = new int[n];\n for (int i = 0; i < n; i++)\n a[i] = ReadInt();\n return a;\n }\n\n public long[] ReadLongArray(int n)\n {\n long[] a = new long[n];\n for (int i = 0; i < n; i++)\n a[i] = ReadLong();\n return a;\n }\n\n public double[] ReadDoubleArray(int n)\n {\n double[] a = new double[n];\n for (int i = 0; i < n; i++)\n a[i] = ReadDouble();\n return a;\n }\n\n public string ReadToken()\n {\n var c = SkipWS();\n if (c == -1)\n return null;\n var sb = new StringBuilder();\n while (c > 0 && !char.IsWhiteSpace((char)c))\n {\n sb.Append((char)c);\n c = this.reader.Read();\n }\n return sb.ToString();\n }\n\n private int SkipWS()\n {\n int c = this.reader.Read();\n if (c == -1)\n return c;\n while (c > 0 && char.IsWhiteSpace((char)c))\n c = this.reader.Read();\n return c;\n }\n\n public Tokenizer(TextReader reader)\n {\n this.reader = reader;\n }\n }\n\n class Program\n {\n public static void Main(string[] args)\n {\n var solver = new ProblemSolver(Console.In);\n solver.Solve();\n }\n }\n\n #endregion\n}", "lang_cluster": "C#", "tags": ["brute force", "implementation"], "code_uid": "cab7e95afd9e3dd403bb6e6ba65010e7", "src_uid": "881a820aa8184d9553278a0002a3b7c4", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.IO;\nusing System.Text;\n\nnamespace Solution_for_Cube\n{\n internal class Program\n {\n private static readonly StreamReader reader = new StreamReader(Console.OpenStandardInput(1024*10), Encoding.ASCII, false, 1024*10);\n private static readonly StreamWriter writer = new StreamWriter(Console.OpenStandardOutput(1024*10), Encoding.ASCII, 1024*10);\n\n private static void Main(string[] args)\n {\n writer.WriteLine(Solve(args) ? \"YES\" : \"NO\");\n writer.Flush();\n }\n\n private static bool Solve(string[] args)\n {\n int n = 24;\n\n var a = new int[n + 1];\n for (int i = 1; i <= n; i++)\n {\n a[i] = Next();\n }\n\n if (check(a))\n return true;\n\n var b = new int[n + 1];\n\n b[13] = a[5];\n b[14] = a[6];\n b[15] = a[7];\n b[16] = a[8];\n\n b[5] = a[17];\n b[6] = a[18];\n b[7] = a[19];\n b[8] = a[20];\n\n b[17] = a[21];\n b[18] = a[22];\n b[19] = a[23];\n b[20] = a[24];\n\n b[21] = a[13];\n b[22] = a[14];\n b[23] = a[15];\n b[24] = a[16];\n\n b[1] = a[3];\n b[2] = a[1];\n b[3] = a[4];\n b[4] = a[2];\n\n b[9] = a[10];\n b[10] = a[12];\n b[11] = a[9];\n b[12] = a[11];\n\n if (check(b))\n return true;\n\n var c = new int[n + 1];\n\n c[1] = a[18];\n c[2] = a[20];\n c[3] = a[17];\n c[4] = a[19];\n\n c[5] = a[6];\n c[6] = a[8];\n c[7] = a[5];\n c[8] = a[7];\n\n c[9] = a[14];\n c[10] = a[16];\n c[11] = a[13];\n c[12] = a[15];\n\n c[13] = a[2];\n c[14] = a[4];\n c[15] = a[1];\n c[16] = a[3];\n\n c[17] = a[10];\n c[18] = a[12];\n c[19] = a[9];\n c[20] = a[11];\n\n c[21] = a[23];\n c[22] = a[21];\n c[23] = a[24];\n c[24] = a[22];\n\n if (check(c))\n return true;\n\n return false;\n }\n\n private static bool check(int[] a)\n {\n if (a[13] == a[14] && a[15] == a[16] && a[13] == a[15]\n && a[17] == a[18] && a[17] == a[19] && a[17] == a[20])\n {\n for (int i = 3; i < a.Length; i += 3)\n {\n if (a[i] != a[i - 2])\n return false;\n i++;\n if (a[i] != a[i - 2])\n return false;\n }\n\n var b = new[] {a[1], a[5], a[9], a[22]};\n var c = new[] {a[2], a[6], a[10], a[21]};\n\n for (int i = 1; i < 4; i += 2)\n {\n bool ok = true;\n\n for (int j = 0; j < 4; j++)\n {\n if (b[(j + i)%4] != c[j])\n {\n ok = false;\n break;\n }\n }\n\n if (ok)\n return true;\n }\n }\n return false;\n }\n\n private static int Next()\n {\n int c;\n int res = 0;\n do\n {\n c = reader.Read();\n if (c == -1)\n return res;\n } while (c < '0' || c > '9');\n res = c - '0';\n while (true)\n {\n c = reader.Read();\n if (c < '0' || c > '9')\n return res;\n res *= 10;\n res += c - '0';\n }\n }\n }\n}", "lang_cluster": "C#", "tags": ["brute force", "implementation"], "code_uid": "49133742e0cdc36fd1bb688faed57f40", "src_uid": "881a820aa8184d9553278a0002a3b7c4", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\n\nnamespace _86A\n{\n class Program\n {\n static void Main(string[] args)\n {\n int l = 0, r = 0;\n string input = Console.ReadLine();\n l = Convert.ToInt32(input.Split(' ')[0]);\n r = Convert.ToInt32(input.Split(' ')[1]);\n\n string sl = l.ToString();\n string sr = r.ToString();\n\n ulong num = 0;\n\n if (sr.Length > sl.Length)\n {\n if (Convert.ToInt16(sr[0]) - 48 >= 5)\n {\n string biggest = \"5\";\n for (int i = 0; i < sr.Length - 1; i++)\n {\n biggest += \"0\";\n }\n num = Convert.ToUInt64(biggest);\n }\n else\n {\n num = Convert.ToUInt64(r);\n }\n }\n else if (sr.Length == sl.Length)\n {\n if (r == l)\n {\n num = Convert.ToUInt64(r);\n }\n\n else if (Convert.ToInt16(sr[0]) - 48 >= 5 && Convert.ToInt16(sl[0]) - 48 >= 5)\n {\n num = Convert.ToUInt64(l);\n }\n else if (Convert.ToInt16(sr[0]) - 48 <= 4 && Convert.ToInt16(sl[0]) - 48 <= 4)\n {\n num = Convert.ToUInt64(r);\n }\n else\n {\n string biggest = \"5\";\n for (int i = 0; i < sr.Length-1; i++)\n {\n biggest += \"0\";\n }\n num = Convert.ToUInt64(biggest);\n\n }\n\n }\n\n Console.WriteLine(refl(num) * num);\n Console.ReadLine();\n\n }\n\n static public ulong refl(ulong num)\n {\n string sr = num.ToString();\n string nine = \"\";\n for (int i = 0; i < sr.Length; i++)\n {\n nine += \"9\";\n }\n return(Convert.ToUInt64(nine) - num);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math"], "code_uid": "84d6aa8f5976c2d5060e84c6eebf5a18", "src_uid": "2c4b2a162563242cb2f43f6209b59d5e", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Text;\nusing System.Diagnostics;\n\nclass Solver\n{\n public void Solve()\n {\n /*\n long max = 0;\n for (int i = 0; ; i++)\n {\n long a = _search(i, i);\n if (a > max)\n {\n Debug.WriteLine(i + \"\\t\" + a+\"\\tmax\");\n max = a;\n }\n else\n Debug.WriteLine(i + \"\\t\" + a);\n\n }\n */\n\n var ss = CF.ReadLine().Split(' ');\n int l = int.Parse(ss[0]);\n int r = int.Parse(ss[1]);\n\n int d = _d(r);\n long dmax = 0;\n {\n for (int i = 0; i < d ; i++)\n {\n dmax *= 10;\n if( i==0)\n dmax += 4;\n else\n dmax += 9;\n }\n }\n\n int n;\n if (r < dmax)\n n = r;\n else if (l > dmax)\n n = l;\n else\n n = (int)dmax;\n\n CF.WriteLine(_search(n, n));\n }\n\n int _d(int n)\n {\n int d = 0;\n {\n int tmp = n;\n for (; ; )\n {\n if (tmp == 0)\n break;\n d += 1;\n tmp /= 10;\n }\n }\n return d;\n }\n\n long _search(int l,int r)\n {\n long max = 0;\n for (int i = l; i <= r; i++)\n {\n int tmp = i;\n Stack ds = new Stack();\n for (; ; )\n {\n if (tmp == 0)\n break;\n ds.Push(tmp % 10);\n tmp/= 10;\n }\n\n long o=0;\n foreach (var d in ds)\n {\n o *= 10;\n o += (9-d);\n }\n\n long p = (long)o * i;\n max = Math.Max(p, max);\n }\n return max;\n }\n\n // test\n static Utils CF = new Utils(new[]{\n@\"\n1 1000000000\n\",\n\n@\"\n1 999\n\",\n\n@\"\n500000000 999999999\n\",\n@\"\n3 7\n\",\n @\"\n1 1\n\",\n @\"\n8 10\n\"\n\n\n });\n #region test\n\n static void Main(string[] args)\n {\n#if DEBUG\n for (int t=0;t();\n string[] ss = _test_input[t].Replace(\"\\n\", \"\").Split('\\r');\n for (int i = 0; i < ss.Length; i++)\n {\n if (\n (i == 0 || i == ss.Length - 1) &&\n ss[i].Length == 0\n )\n continue;\n\n _lines.Add(ss[i]);\n }\n }\n\n public int TestCount\n {\n get\n {\n return _test_input.Length;\n }\n }\n\n public string ReadLine()\n {\n#if DEBUG\n string s = null;\n if (_lines.Count > 0)\n {\n s = _lines[0];\n _lines.RemoveAt(0);\n }\n return s;\n\n#else\n //return _sr.ReadLine();\n return Console.In.ReadLine();\n#endif\n }\n\n public void WriteLine(object o)\n {\n#if DEBUG\n System.Diagnostics.Trace.WriteLine(o);\n#else\n //_sw.WriteLine(o);\n Console.WriteLine(o);\n#endif\n }\n\n public void Write(object o)\n {\n#if DEBUG\n System.Diagnostics.Trace.Write(o);\n#else\n //_sw.Write(o);\n Console.Write(o);\n#endif\n }\n\n string[] _test_input;\n\n List _lines;\n\n#if DEBUG\n public Utils(string[] test_input)\n {\n _test_input = test_input;\n }\n#else\n\n public Utils(string[] dummy)\n {\n //_sr = new System.IO.StreamReader(\"input.txt\");\n //_sw = new System.IO.StreamWriter(\"output.txt\");\n }\n#endif\n\n }\n\n #endregion\n}\n\n", "lang_cluster": "C#", "tags": ["math"], "code_uid": "80a1fc64a1f71ec72a4a0a0885c87b23", "src_uid": "2c4b2a162563242cb2f43f6209b59d5e", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\n\nnamespace GeneticEngineering\n{\n partial class GeneticEngineering\n {\n static void Main(string[] args)\n {\n string s = ReadLine();\n char current;\n int count = 1, min = 0;\n\n current = s[0];\n\n for (int i = 1; i < s.Length; i++)\n {\n if (s[i] == current)\n count++;\n else\n {\n current = s[i];\n\n if (count % 2 == 0)\n min++;\n\n count = 1;\n }\n }\n\n if (count % 2 == 0)\n min++;\n\n Console.WriteLine(min);\n }\n }\n\n partial class GeneticEngineering\n {\n static string[] tokens = new string[0];\n static int cur_token = 0;\n\n static void ReadArray(char sep)\n {\n cur_token = 0;\n tokens = Console.ReadLine().Split(sep);\n }\n\n static int ReadInt()\n {\n return int.Parse(Console.ReadLine());\n }\n\n static long ReadLong()\n {\n return long.Parse(Console.ReadLine());\n }\n\n static int NextInt()\n {\n if (cur_token == tokens.Length)\n ReadArray(' ');\n return int.Parse(tokens[cur_token++]);\n }\n\n static long NextLong()\n {\n if (cur_token == tokens.Length)\n ReadArray(' ');\n return long.Parse(tokens[cur_token++]);\n }\n\n static double NextDouble()\n {\n if (cur_token == tokens.Length)\n ReadArray(' ');\n return double.Parse(tokens[cur_token++]);\n }\n\n static decimal NextDecimal()\n {\n if (cur_token == tokens.Length)\n ReadArray(' ');\n return decimal.Parse(tokens[cur_token++]);\n }\n\n static string NextToken()\n {\n if (cur_token == tokens.Length)\n ReadArray(' ');\n return tokens[cur_token++];\n }\n\n static string ReadLine()\n {\n return Console.ReadLine();\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["two pointers", "implementation"], "code_uid": "6161e456a4da6126186de43bc32129bb", "src_uid": "8b26ca1ca2b28166c3d25dceb1f3d49f", "difficulty": null, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\n\nnamespace JustShit\n{\n class Program\n {\n static void Main(string[] args)\n {\n string str = Console.ReadLine();\n int j = 0;\n int kol = 0;\n\n List count = new List();\n\n for (int i = 0; i < str.Length; i++)\n {\n if (i == 0)\n {\n count.Add(1);\n }\n else if (Convert.ToChar(str[i]) == Convert.ToChar(str[i - 1]))\n {\n count[j] += 1;\n }\n else\n {\n j += 1;\n count.Add(1);\n }\n }\n\n for (int i = 0; i < count.Count; i++)\n {\n if (count[i] % 2 == 0)\n {\n kol += 1;\n }\n }\n\n Console.WriteLine(kol);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["two pointers", "implementation"], "code_uid": "7db841ebc12e09feb169938b128d09dd", "src_uid": "8b26ca1ca2b28166c3d25dceb1f3d49f", "difficulty": null, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace ForAll\n{\n class Program\n {\n \n \n static void Main(string[] args)\n {\n Int64[] parametrs = Array.ConvertAll(Console.ReadLine().Split(' '),Int64.Parse);\n\n Int64 n = parametrs[0], l = parametrs[1],r = parametrs[2];\n\n Int64 lengthString = (Int64)Math.Pow(2, ((Int64)Math.Log(n, 2)) + 1) - 1;\n\n int counter = 0;\n for (Int64 i = l; i < r + 1; i++)\n {\n if (BinarySearch(lengthString, n, i) >= 1)\n counter++;\n }\n\n Console.WriteLine(counter);\n }\n\n static int BinarySearch(Int64 lengthValue,Int64 root,Int64 index)\n {\n Int64 current = lengthValue / 2 + 1;\n Int64 path = current;\n while (current!=index) \n {\n path = path / 2;\n if (index < current)\n current = current - path;\n else\n current = current + path;\n if (root > 1) \n root = root / 2;\n }\n\n if (index % 2 == 0)\n return (int)(root % 2);\n else return (int)(root);\n }\n\n }\n}", "lang_cluster": "C#", "tags": ["dfs and similar", "divide and conquer", "constructive algorithms"], "code_uid": "b6130f81949f118f06676590ce85c4e4", "src_uid": "3ac61b1f8deee7911b1055c243f5eb6a", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Diagnostics;\nusing System.IO;\nusing System.Linq;\n\nnamespace Codeforces\n{\n\tinternal class Template\n\t{\n\t\tprivate Dictionary, long> dp; \n\n\t\tprivate void Solve()\n\t\t{\n\t\t\tdp = new Dictionary, long>();\n\n\t\t\tvar n = cin.NextLong();\n\t\t\tvar l = cin.NextLong();\n\t\t\tvar r = cin.NextLong();\n\n\t\t\tif (n == 0)\n\t\t\t{\n\t\t\t\tConsole.WriteLine(0);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tvar count = Count(n, l-1, r-1);\n\t\t\tConsole.WriteLine(count);\n\t\t}\n\n\t\tprivate long Count(long n, long l, long r)\n\t\t{\n\t\t\tif (n == 1)\n\t\t\t{\n\t\t\t\treturn 1;\n\t\t\t}\n\n\t\t\tif (dp.ContainsKey(Tuple.Create(n, l, r)))\n\t\t\t{\n\t\t\t\treturn dp[Tuple.Create(n, l, r)];\n\t\t\t}\n\n\t\t\tvar idx = 0;\n\t\t\tvar nn = n;\n\t\t\twhile (nn > 1)\n\t\t\t{\n\t\t\t\tidx++;\n\t\t\t\tnn/=2;\n\t\t\t}\n\t\t\tvar len = 1L;\n\t\t\tfor (var i = 0; i < idx; i++)\n\t\t\t{\n\t\t\t\tlen *= 2;\n\t\t\t\tlen++;\n\t\t\t}\n\t\t\tvar middle = len/2;\n\t\t\tvar sum = 0L;\n\t\t\tif (l <= middle && r >= middle)\n\t\t\t{\n\t\t\t\tsum += n%2;\n\t\t\t\tif (l < middle)\n\t\t\t\t{\n\t\t\t\t\tsum += Count(n/2, l, middle - 1);\n\t\t\t\t}\n\t\t\t\tif (r > middle)\n\t\t\t\t{\n\t\t\t\t\tsum += Count(n/2, 0, r - middle - 1);\n\t\t\t\t}\n\t\t\t}\n\t\t\telse if (l < middle)\n\t\t\t{\n\t\t\t\tsum += Count(n/2, l, r);\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tsum += Count(n/2, l - middle - 1, r - middle - 1);\n\t\t\t}\n\t\t\tdp[Tuple.Create(n, l, r)] = sum;\n\t\t\treturn sum;\n\t\t}\n\n\t\tprivate static readonly Scanner cin = new Scanner();\n\n\t\tprivate static void Main()\n\t\t{\n#if DEBUG\n\t\t\tvar inputText = File.ReadAllText(@\"..\\..\\input.txt\");\n\t\t\tvar testCases = inputText.Split(new[] { \"input\" }, StringSplitOptions.RemoveEmptyEntries);\n\t\t\tvar consoleOut = Console.Out;\n\t\t\tfor (var i = 0; i < testCases.Length; i++)\n\t\t\t{\n\t\t\t\tvar parts = testCases[i].Split(new[] { \"output\" }, StringSplitOptions.RemoveEmptyEntries);\n\t\t\t\tConsole.SetIn(new StringReader(parts[0].Trim()));\n\t\t\t\tvar stringWriter = new StringWriter();\n\t\t\t\tConsole.SetOut(stringWriter);\n\t\t\t\tvar sw = Stopwatch.StartNew();\n\t\t\t\tnew Template().Solve();\n\t\t\t\tsw.Stop();\n\t\t\t\tvar output = stringWriter.ToString();\n\n\t\t\t\tConsole.SetOut(consoleOut);\n\t\t\t\tvar color = ConsoleColor.Green;\n\t\t\t\tvar status = \"Passed\";\n\t\t\t\tif (parts[1].Trim() != output.Trim())\n\t\t\t\t{\n\t\t\t\t\tcolor = ConsoleColor.Red;\n\t\t\t\t\tstatus = \"Failed\";\n\t\t\t\t}\n\t\t\t\tConsole.ForegroundColor = color;\n\t\t\t\tConsole.WriteLine(\"Test {0} {1} in {2}ms\", i + 1, status, sw.ElapsedMilliseconds);\n\t\t\t}\n\t\t\tConsole.ReadLine();\n\t\t\tConsole.ReadKey();\n#else\n\t\t\tnew Template().Solve();\n\t\t\tConsole.ReadLine();\n#endif\n\t\t}\n\t}\n\n\tinternal class Scanner\n\t{\n\t\tprivate string[] s = new string[0];\n\t\tprivate int i;\n\t\tprivate readonly char[] cs = { ' ' };\n\n\t\tpublic string NextString()\n\t\t{\n\t\t\tif (i < s.Length) return s[i++];\n\t\t\tvar line = Console.ReadLine() ?? string.Empty;\n\t\t\ts = line.Split(cs, StringSplitOptions.RemoveEmptyEntries);\n\t\t\ti = 1;\n\t\t\treturn s.First();\n\t\t}\n\n\t\tpublic double NextDouble()\n\t\t{\n\t\t\treturn double.Parse(NextString());\n\t\t}\n\n\t\tpublic int NextInt()\n\t\t{\n\t\t\treturn int.Parse(NextString());\n\t\t}\n\n\t\tpublic long NextLong()\n\t\t{\n\t\t\treturn long.Parse(NextString());\n\t\t}\n\t}\n}", "lang_cluster": "C#", "tags": ["dfs and similar", "divide and conquer", "constructive algorithms"], "code_uid": "d5e13ab672c56d83ea8d4b7c58be2773", "src_uid": "3ac61b1f8deee7911b1055c243f5eb6a", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.IO;\nusing System.Text;\n\nnamespace Code_For_1\n{\n internal class Program\n {\n private static readonly StreamReader reader = new StreamReader(Console.OpenStandardInput(1024*10), Encoding.ASCII, false, 1024*10);\n private static readonly StreamWriter writer = new StreamWriter(Console.OpenStandardOutput(1024*10), Encoding.ASCII, 1024*10);\n\n private static void Main(string[] args)\n {\n long n = Next();\n long l = Next();\n long r = Next();\n\n\n string s = Convert.ToString(n, 2);\n\n long step = 1;\n long sum = 0;\n for (int i = 0; i < s.Length; i++)\n {\n if (s[i] == '1')\n {\n long bl = (l - step + 2*step - 1)/(2*step);\n long br = (r + 1 - step + 2*step - 1)/(2*step);\n sum += br - bl;\n }\n\n step *= 2;\n }\n\n writer.WriteLine(sum);\n writer.Flush();\n }\n\n private static long Next()\n {\n int c;\n long res = 0;\n do\n {\n c = reader.Read();\n if (c == -1)\n return res;\n } while (c < '0' || c > '9');\n res = c - '0';\n while (true)\n {\n c = reader.Read();\n if (c < '0' || c > '9')\n return res;\n res *= 10;\n res += c - '0';\n }\n }\n }\n}", "lang_cluster": "C#", "tags": ["dfs and similar", "divide and conquer", "constructive algorithms"], "code_uid": "2820d3215c415a700e8ed7db5fd6edf4", "src_uid": "3ac61b1f8deee7911b1055c243f5eb6a", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeff\ufeff\ufeffusing System;\n\ufeff\ufeffusing System.Globalization;\nusing System.IO;\nusing System.Linq;\n\nnamespace CF317\n{\n internal class Program\n {\n private static void Main(string[] args)\n {\n var sr = new InputReader(Console.In);\n //var sr = new InputReader(new StreamReader(\"input.txt\"));\n var task = new Task();\n using (var sw = Console.Out)\n //using (var sw = new StreamWriter(\"output.txt\"))\n {\n task.Solve(sr, sw);\n //Console.ReadKey();\n }\n }\n }\n\n internal class Task\n {\n private long l;\n private long r;\n private int answ;\n\n public void Solve(InputReader sr, TextWriter sw)\n {\n var input = sr.ReadArray(Int64.Parse);\n var n = input[0];\n l = input[1];\n r = input[2];\n Divide(n, 1L);\n sw.WriteLine(answ);\n }\n\n private void Divide(long n, long indx)\n {\n if (indx > r)\n {\n return;\n }\n if (n == 0 || n == 1)\n {\n if (indx >= l && indx <= r && n == 1L)\n {\n answ++;\n }\n return;\n }\n var log = GetLog2(n);\n var power = GetPower(2L, log) / 2 - 1L;\n if (indx + (power) * 2 + 1L < l)\n {\n return;\n }\n Divide(n / 2, indx);\n if (indx + power >= l && indx + power <= r && n % 2 == 1L)\n {\n answ++;\n }\n Divide(n / 2, indx + power + 1L);\n }\n\n private long GetLog2(long n)\n {\n var log = 0;\n while (n > 0) {\n n /= 2;\n log++;\n }\n\n return log;\n }\n\n public long GetPower(long n, long p)\n {\n var power = 1L;\n for (var i = 0; i < p; i++) {\n power *= n;\n }\n\n return power;\n }\n }\n}\n\ninternal class InputReader : IDisposable\n{\n private bool isDispose;\n private readonly TextReader sr;\n\n public InputReader(TextReader stream)\n {\n sr = stream;\n }\n\n public void Dispose()\n {\n Dispose(true);\n GC.SuppressFinalize(this);\n }\n\n public string NextString()\n {\n var result = sr.ReadLine();\n return result;\n }\n\n public int NextInt32()\n {\n return Int32.Parse(NextString());\n }\n\n public long NextInt64()\n {\n return Int64.Parse(NextString());\n }\n\n public string[] NextSplitStrings()\n {\n return NextString()\n .Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);\n }\n\n public T[] ReadArray(Func func)\n {\n return NextSplitStrings()\n .Select(s => func(s, CultureInfo.InvariantCulture))\n .ToArray();\n }\n\n public T[] ReadArrayFromString(Func func, string str)\n {\n return\n str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)\n .Select(s => func(s, CultureInfo.InvariantCulture))\n .ToArray();\n }\n\n protected void Dispose(bool dispose)\n {\n if (!isDispose)\n {\n if (dispose)\n sr.Close();\n isDispose = true;\n }\n }\n\n ~InputReader()\n {\n Dispose(false);\n }\n}", "lang_cluster": "C#", "tags": ["dfs and similar", "divide and conquer", "constructive algorithms"], "code_uid": "78ecb7facad9363b02178a82e8cab2b8", "src_uid": "3ac61b1f8deee7911b1055c243f5eb6a", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeff//\ufeff\ufeff\ufeff\ufeff\ufeff\ufeff\ufeff\ufeff\ufeff#define EXTENDSTACKSIZE\n\n\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Globalization;\nusing System.IO;\nusing System.Linq;\nusing System.Text;\nusing System.Threading;\n\nnamespace CF\n{\n internal class Program\n {\n private const int stackSize = 64 * 1024 * 1024;\n \n private static void Run()\n {\n using (var sr = new InputReader(Console.In))\n// using (var sr = new InputReader(new StreamReader(\"input.txt\")))\n using (var sw = Console.Out)\n// using (var sw = new StreamWriter(\"output.txt\"))\n using (var task = new Task(sr, sw)) {\n task.Solve();\n// Console.ReadKey();\n }\n }\n \n private static void Main(string[] args)\n {\n#if EXTENDSTACKSIZE\n var threadStart = new ThreadStart(Run);\n var thread = new Thread(threadStart, stackSize);\n thread.Start();\n thread.Join();\n#else\n Run();\n#endif\n }\n }\n\n internal class Task : IDisposable\n {\n private readonly InputReader sr;\n private readonly TextWriter sw;\n private bool isDispose;\n \n public Task(InputReader sr, TextWriter sw)\n {\n this.sr = sr;\n this.sw = sw;\n }\n \n public void Solve()\n {\n var n = sr.NextInt32();\n var m = sr.NextInt32();\n var coffee = sr.ReadArrayOfInt64();\n var start = 1;\n var end = n;\n var sum = coffee.Sum();\n if (sum < m)\n {\n sw.WriteLine(-1);\n return;\n }\n\n Array.Sort(coffee, (a, b) => -a.CompareTo(b));\n var answ = -1;\n while (start <= end)\n {\n var mid = (start + end) / 2;\n var res = 0L;\n for (var i = 0; i < mid; i++)\n {\n res += coffee[i];\n }\n\n var indx = 0;\n var usedCount = Enumerable.Repeat(1, mid).ToArray();\n for (var i = mid; i < n; i++)\n {\n res += Math.Max(0, coffee[i] - usedCount[indx]);\n usedCount[indx]++;\n indx++;\n indx = indx % mid;\n }\n\n if (res >= m)\n {\n end = mid - 1;\n answ = mid;\n }\n else\n {\n start = mid + 1;\n }\n }\n\n sw.WriteLine(answ);\n }\n \n public void Dispose()\n {\n Dispose(true);\n GC.SuppressFinalize(this);\n }\n \n private void Dispose(bool disposing)\n {\n if (!isDispose) {\n if (disposing) {\n if(sr != null)\n sr.Dispose();\n \n if(sw != null)\n sw.Dispose();\n }\n\n isDispose = true;\n }\n }\n }\n}\n\ninternal class InputReader : IDisposable\n{\n private bool isDispose;\n private readonly TextReader sr;\n private string[] buffer;\n private int seek;\n\n public InputReader(TextReader stream)\n {\n sr = stream;\n }\n\n public void Dispose()\n {\n Dispose(true);\n GC.SuppressFinalize(this);\n }\n\n public string NextString()\n {\n var result = sr.ReadLine();\n return result;\n }\n\n public int NextInt32()\n {\n return Int32.Parse(ReadNextToken());\n }\n\n private string ReadNextToken()\n {\n if (buffer == null || seek == buffer.Length) {\n seek = 0;\n buffer = NextSplitStrings();\n }\n\n return buffer[seek++];\n }\n\n public long NextInt64()\n {\n return Int64.Parse(ReadNextToken());\n }\n \n public int[] ReadArrayOfInt32()\n {\n return ReadArray(Int32.Parse);\n }\n\n public long[] ReadArrayOfInt64()\n {\n return ReadArray(Int64.Parse);\n }\n\n public string[] NextSplitStrings()\n {\n return NextString()\n .Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);\n }\n\n public T[] ReadArray(Func func)\n {\n return NextSplitStrings()\n .Select(s => func(s, CultureInfo.InvariantCulture))\n .ToArray();\n }\n\n public T[] ReadArrayFromString(Func func, string str)\n {\n return\n str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)\n .Select(s => func(s, CultureInfo.InvariantCulture))\n .ToArray();\n }\n\n protected void Dispose(bool dispose)\n {\n if (!isDispose)\n {\n if (dispose)\n sr.Close();\n \n isDispose = true;\n }\n }\n\n ~InputReader()\n {\n Dispose(false);\n }\n}", "lang_cluster": "C#", "tags": ["brute force", "greedy"], "code_uid": "2d47f462f848c499be76922f5cfafca5", "src_uid": "acb8a57c8cfdb849a55fa65aff86628d", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Linq;\nusing CompLib.Util;\n\npublic class Program\n{\n int N;\n long M;\n long[] A;\n public void Solve()\n {\n var sc = new Scanner();\n N = sc.NextInt();\n M = sc.NextInt();\n\n A = sc.LongArray();\n\n Array.Sort(A, (l, r) => r.CompareTo(l));\n\n /*\n * m\u30da\u30fc\u30b8\u66f8\u304f\n * \n * n\u500b\u30b3\u30fc\u30d2\u30fc\n * \n * i\u306fa_i\u30ab\u30d5\u30a7\u30a4\u30f3\n * \n * k\u676f\u98f2\u3080\n * 1\u676f\u76ee a_i\n * 2 a_i-1\n * ...\n * \n * \u6700\u5c0f\u65e5\u6570\n */\n\n int ok = N + 1;\n int ng = 0;\n while (ok - ng > 1)\n {\n int mid = (ok + ng) / 2;\n if (F(mid)) ok = mid;\n else ng = mid;\n }\n\n if(ok <= N)\n {\n Console.WriteLine(ok);\n }\n else\n {\n Console.WriteLine(\"-1\");\n }\n }\n\n // d\u65e5\n bool F(int d)\n {\n // \n long t = 0;\n for (int i = 0; i < N; i++)\n {\n t += Math.Max(0, A[i] - i / d);\n }\n\n return t >= M;\n\n }\n\n public static void Main(string[] args) => new Program().Solve();\n // public static void Main(string[] args) => new Thread(new Program().Solve, 1 << 27).Start();\n}\n\nnamespace CompLib.Util\n{\n using System;\n using System.Linq;\n\n class Scanner\n {\n private string[] _line;\n private int _index;\n private const char Separator = ' ';\n\n public Scanner()\n {\n _line = new string[0];\n _index = 0;\n }\n\n public string Next()\n {\n if (_index >= _line.Length)\n {\n string s;\n do\n {\n s = Console.ReadLine();\n } while (s.Length == 0);\n\n _line = s.Split(Separator);\n _index = 0;\n }\n\n return _line[_index++];\n }\n\n public string ReadLine()\n {\n _index = _line.Length;\n return Console.ReadLine();\n }\n\n public int NextInt() => int.Parse(Next());\n public long NextLong() => long.Parse(Next());\n public double NextDouble() => double.Parse(Next());\n public decimal NextDecimal() => decimal.Parse(Next());\n public char NextChar() => Next()[0];\n public char[] NextCharArray() => Next().ToCharArray();\n\n public string[] Array()\n {\n string s = Console.ReadLine();\n _line = s.Length == 0 ? new string[0] : s.Split(Separator);\n _index = _line.Length;\n return _line;\n }\n\n public int[] IntArray() => Array().Select(int.Parse).ToArray();\n public long[] LongArray() => Array().Select(long.Parse).ToArray();\n public double[] DoubleArray() => Array().Select(double.Parse).ToArray();\n public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "greedy"], "code_uid": "e559ee3c41a6efcbbbf529556bc702e8", "src_uid": "acb8a57c8cfdb849a55fa65aff86628d", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\n\nnamespace Caesar\n{\n\tclass MainClass\n\t{\n\t\tpublic static void Main(string[] args)\n\t\t{\n\t\t\tint n1, n2, k1, k2, mod = 100000000;\n\t\t\tstring[] line = Console.ReadLine().Split();\n\t\t\tn1 = Convert.ToInt32(line[0]);\n\t\t\tn2 = Convert.ToInt32(line[1]);\n\t\t\tk1 = Convert.ToInt32(line[2]);\n\t\t\tk2 = Convert.ToInt32(line[3]);\n\t\t\tint[,,] dp = new int[n1 + 1, n2 + 1, 2];\n\t\t\tdp[0, 0, 0] = dp[0, 0, 1] = 1;\n\t\t\tfor (int i = 0; i <= n1; i++)\n\t\t\t{\n\t\t\t\tfor (int j = 0; j <= n2; j++)\n\t\t\t\t{\n\t\t\t\t\tif (i == 0 && j != 0)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (j <= k2) dp[i, j, 1] = 1;\n\t\t\t\t\t\telse dp[i, j, 1] = 0;\n\t\t\t\t\t\tdp[i, j, 0] = 0;\n\t\t\t\t\t}\n\t\t\t\t\telse if (i != 0 && j == 0)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (i <= k1) dp[i, j, 0] = 1;\n\t\t\t\t\t\telse dp[i, j, 0] = 0;\n\t\t\t\t\t\tdp[i, j, 1] = 0;\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\tfor (int k = 1; k <= k1; k++)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tif (k <= i)\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tdp[i, j, 0] = (dp[i, j, 0] + dp[i - k, j, 1]) % mod;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tfor (int k = 1; k <= k2; k++)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tif (k <= j)\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tdp[i, j, 1] = (dp[i, j, 1] + dp[i, j - k, 0]) % mod;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tConsole.WriteLine((dp[n1, n2, 0] + dp[n1, n2, 1]) % mod);\n\t\t\tConsole.ReadLine();\n\t\t}\n\t}\n}\n", "lang_cluster": "C#", "tags": ["dp"], "code_uid": "80fe6baa00cb893db7b4162a4606ca0a", "src_uid": "63aabef26fe008e4c6fc9336eb038289", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "#define Online\n\nusing System;\nusing System.Collections.Generic;\nusing System.Diagnostics;\nusing System.Linq;\nusing System.Text;\nusing System.IO;\nusing System.Numerics;\n\nnamespace CF\n{\n delegate double F(double x);\n delegate decimal Fdec(decimal x);\n\n partial class Program\n {\n\n static void Main(string[] args)\n {\n\n#if FileIO\n StreamReader sr = new StreamReader(\"input.txt\");\n StreamWriter sw = new StreamWriter(\"output.txt\");\n Console.SetIn(sr);\n Console.SetOut(sw);\n#endif\n\n D();\n\n\n#if Online\n Console.ReadLine();\n#endif\n\n#if FileIO\n sr.Close();\n sw.Close();\n#endif\n }\n\n static void A()\n {\n StringBuilder sb = new StringBuilder();\n string str = ReadLine();\n for (int i = 0; i < str.Length; i++)\n {\n if (!str[i].Equals('a') && !str[i].Equals('A')\n && !str[i].Equals('o') && !str[i].Equals('O')\n && !str[i].Equals('y') && !str[i].Equals('Y')\n && !str[i].Equals('e') && !str[i].Equals('E')\n && !str[i].Equals('u') && !str[i].Equals('U')\n && !str[i].Equals('i') && !str[i].Equals('I'))\n {\n sb.Append('.');\n if (str[i] < 97)\n sb.Append(char.ToLower(str[i]));\n else\n sb.Append(str[i]);\n\n }\n }\n Console.WriteLine(sb);\n }\n\n static void B()\n {\n int n = ReadInt();\n int[,] ans = new int[2 * n + 1, 2 * n + 1];\n for (int i = 0; i < 2 * n + 1; i++)\n {\n int z = (i > n ? n - (i - n) : i);\n ans[i, n] = z;\n for (int j = 0; j < n; j++)\n {\n ans[i, n - j - 1] = z - j - 1;\n ans[i, n + j + 1] = z - j - 1;\n }\n }\n for (int i = 0; i < 2 * n + 1; i++)\n {\n int j = 0;\n while (j < 2 * n + 1 && ans[i, j] < 0)\n {\n Console.Write(\" \");\n j++;\n }\n Console.Write(ans[i, j++]);\n while (j < 2 * n + 1 && ans[i, j] >= 0)\n {\n Console.Write(\" \" + ans[i, j]);\n j++;\n }\n\n Console.WriteLine();\n }\n }\n\n static void C()\n {\n\n }\n\n static void D()\n {\n int n1, n2, k1, k2;\n const long mod = 100000000L;\n ReadArray(' ');\n n1 = NextInt();\n n2 = NextInt();\n k1 = NextInt();\n k2 = NextInt();\n long[,] p = new long[n1, n1 + 1];\n long[,] h = new long[n2, n2 + 1];\n for (int i = 1; i <= k1 && i <= n1; i++)\n p[0, i] = 1;\n for (int i = 1; i <= k2 && i <= n2; i++)\n h[0, i] = 1;\n for (int i = 1; i < n1; i++)\n {\n for (int j = 1; j <= k1; j++)\n {\n for (int z = 1; z <= n1; z++)\n {\n if (z + j <= n1)\n {\n p[i, z + j] += p[i - 1, z];\n p[i, z + j] %= mod;\n }\n }\n }\n }\n for (int i = 1; i < n2; i++)\n {\n for (int j = 1; j <= k2; j++)\n {\n for (int z = 1; z <= n2; z++)\n {\n if (z + j <= n2)\n {\n h[i, z + j] += h[i - 1, z];\n h[i, z + j] %= mod;\n }\n }\n }\n }\n long sum = 0;\n for (int i = 0; i < n1; i++)\n {\n if (i < n2)\n sum += p[i, n1] * h[i, n2] * 2;\n if (i + 1 < n2)\n sum += p[i, n1] * h[i + 1, n2];\n if (i - 1 >= 0 && i - 1 < n2)\n sum += p[i, n1] * h[i - 1, n2];\n sum %= mod;\n }\n Console.WriteLine(sum);\n }\n\n static void E()\n {\n\n }\n\n static void TestGen()\n {\n\n }\n\n }\n\n public static class MyMath\n {\n public static long BinPow(long a, long n, long mod)\n {\n long res = 1;\n while (n > 0)\n {\n if ((n & 1) == 1)\n {\n res = (res * a) % mod;\n }\n a = (a * a) % mod;\n n >>= 1;\n }\n return res;\n }\n\n public static long GCD(long a, long b)\n {\n while (b != 0) b = a % (a = b);\n return a;\n }\n\n public static int GCD(int a, int b)\n {\n while (b != 0) b = a % (a = b);\n return a;\n }\n\n public static long LCM(long a, long b)\n {\n return (a * b) / GCD(a, b);\n }\n\n public static int LCM(int a, int b)\n {\n return (a * b) / GCD(a, b);\n }\n }\n\n static class ArrayUtils\n {\n public static int BinarySearch(int[] a, int val)\n {\n int left = 0;\n int right = a.Length - 1;\n int mid;\n\n while (left < right)\n {\n mid = left + ((right - left) >> 1);\n if (val <= a[mid])\n {\n right = mid;\n }\n else\n {\n left = mid + 1;\n }\n }\n\n if (a[left] == val)\n return left;\n else\n return -1;\n }\n\n public static double Bisection(F f, double left, double right, double eps)\n {\n double mid;\n while (right - left > eps)\n {\n mid = left + ((right - left) / 2d);\n if (Math.Sign(f(mid)) != Math.Sign(f(left)))\n right = mid;\n else\n left = mid;\n }\n return (left + right) / 2d;\n }\n\n\n public static decimal TernarySearchDec(Fdec f, decimal eps, decimal l, decimal r, bool isMax)\n {\n decimal m1, m2;\n while (r - l > eps)\n {\n m1 = l + (r - l) / 3m;\n m2 = r - (r - l) / 3m;\n if (f(m1) < f(m2))\n if (isMax)\n l = m1;\n else\n r = m2;\n else\n if (isMax)\n r = m2;\n else\n l = m1;\n }\n return r;\n }\n\n public static double TernarySearch(F f, double eps, double l, double r, bool isMax)\n {\n double m1, m2;\n while (r - l > eps)\n {\n m1 = l + (r - l) / 3d;\n m2 = r - (r - l) / 3d;\n if (f(m1) < f(m2))\n if (isMax)\n l = m1;\n else\n r = m2;\n else\n if (isMax)\n r = m2;\n else\n l = m1;\n }\n return r;\n }\n\n public static void Merge(T[] A, int p, int q, int r, T[] L, T[] R, Comparison comp)\n {\n for (int i = p; i <= q; i++)\n L[i] = A[i];\n for (int i = q + 1; i <= r; i++)\n R[i] = A[i];\n\n for (int k = p, i = p, j = q + 1; k <= r; k++)\n {\n if (i > q)\n {\n for (; k <= r; k++, j++)\n A[k] = R[j];\n return;\n }\n if (j > r)\n {\n for (; k <= r; k++, i++)\n A[k] = L[i];\n return;\n }\n if (comp(L[i], R[j]) <= 0)\n {\n A[k] = L[i];\n i++;\n }\n else\n {\n A[k] = R[j];\n j++;\n }\n }\n }\n\n public static void Merge_Sort(T[] A, int p, int r, T[] L, T[] R, Comparison comp)\n {\n if (p >= r) return;\n int q = p + ((r - p) >> 1);\n Merge_Sort(A, p, q, L, R, comp);\n Merge_Sort(A, q + 1, r, L, R, comp);\n Merge(A, p, q, r, L, R, comp);\n }\n\n public static void Merge(T[] A, int p, int q, int r, T[] L, T[] R) where T : IComparable\n {\n for (int i = p; i <= q; i++)\n L[i] = A[i];\n for (int i = q + 1; i <= r; i++)\n R[i] = A[i];\n\n for (int k = p, i = p, j = q + 1; k <= r; k++)\n {\n if (i > q)\n {\n for (; k <= r; k++, j++)\n A[k] = R[j];\n return;\n }\n if (j > r)\n {\n for (; k <= r; k++, i++)\n A[k] = L[i];\n return;\n }\n if (L[i].CompareTo(R[j]) >= 0)\n {\n A[k] = L[i];\n i++;\n }\n else\n {\n A[k] = R[j];\n j++;\n }\n }\n }\n\n public static void Merge_Sort(T[] A, int p, int r, T[] L, T[] R) where T : IComparable\n {\n if (p >= r) return;\n int q = p + ((r - p) >> 1);\n Merge_Sort(A, p, q, L, R);\n Merge_Sort(A, q + 1, r, L, R);\n Merge(A, p, q, r, L, R);\n }\n\n public static void Merge_Sort1(T[] A, int p, int r, T[] L, T[] R) where T : IComparable\n {\n int k = 1;\n while (k < r - p + 1)\n {\n int i = 0;\n while (i < r)\n {\n int _r = Math.Min(i + 2 * k - 1, r);\n int q = Math.Min(i + k - 1, r);\n Merge(A, i, q, _r, L, R);\n i += 2 * k;\n }\n k <<= 1;\n }\n }\n\n public static void Merge_Sort1(T[] A, int p, int r, T[] L, T[] R, Comparison comp)\n {\n int k = 1;\n while (k < r - p + 1)\n {\n int i = 0;\n while (i < r)\n {\n int _r = Math.Min(i + 2 * k - 1, r);\n int q = Math.Min(i + k - 1, r);\n Merge(A, i, q, _r, L, R, comp);\n i += 2 * k;\n }\n k <<= 1;\n }\n }\n\n static void Shake(T[] a)\n {\n Random rnd = new Random(Environment.TickCount);\n T temp;\n int b, c;\n for (int i = 0; i < a.Length; i++)\n {\n b = rnd.Next(0, a.Length);\n c = rnd.Next(0, a.Length);\n temp = a[b];\n a[b] = a[c];\n a[c] = temp;\n }\n }\n }\n\n partial class Program\n {\n static string[] tokens;\n static int cur_token = 0;\n\n static void ReadArray(char sep)\n {\n cur_token = 0;\n tokens = Console.ReadLine().Split(sep);\n }\n\n static int ReadInt()\n {\n return int.Parse(Console.ReadLine());\n }\n\n static long ReadLong()\n {\n return long.Parse(Console.ReadLine());\n }\n\n static int NextInt()\n {\n return int.Parse(tokens[cur_token++]);\n }\n\n static long NextLong()\n {\n return long.Parse(tokens[cur_token++]);\n }\n\n static double NextDouble()\n {\n return double.Parse(tokens[cur_token++]);\n }\n\n static decimal NextDecimal()\n {\n return decimal.Parse(tokens[cur_token++]);\n }\n\n static string NextToken()\n {\n return tokens[cur_token++];\n }\n\n static string ReadLine()\n {\n return Console.ReadLine();\n }\n }\n}", "lang_cluster": "C#", "tags": ["dp"], "code_uid": "11c60448b9535387421d5912235ee4da", "src_uid": "63aabef26fe008e4c6fc9336eb038289", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Linq;\n\nnamespace B_Segments\n{\n class Program\n {\n static void Main(string[] args)\n {\n int n = int.Parse(Console.ReadLine());\n int result = Enumerable.Range(0, 50).Select(i => i * 2).Select(i => n - i).Where(i => i > 0).Sum();\n Console.WriteLine(result);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "constructive algorithms"], "code_uid": "89d08941f7bc2e88930ff75f8ad66808", "src_uid": "f8af5dfcf841a7f105ac4c144eb51319", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\n\nnamespace CSharp\n{\n class _909B\n {\n public static void Main()\n {\n int n = int.Parse(Console.ReadLine());\n\n var diff = new int[n + 1];\n for (int i = 0; i < n; i++)\n {\n for (int j = i + 1; j <= n; j++)\n {\n diff[i]++;\n diff[j]--;\n }\n }\n\n int layers = 0;\n\n for (int i = 0, count = 0; i < n; i++)\n {\n count += diff[i];\n layers = Math.Max(layers, count);\n }\n\n Console.WriteLine(layers);\n }\n }\n}", "lang_cluster": "C#", "tags": ["math", "constructive algorithms"], "code_uid": "effb3356ff680f7d3e0699a9dcb307dd", "src_uid": "f8af5dfcf841a7f105ac4c144eb51319", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace ExTraining\n{\n class Program\n {\n static void Main(string[] args)\n {\n int n = int.Parse(Console.ReadLine());\n int sum1 = Console.ReadLine()\n .Split()\n .Select(s => int.Parse(s))\n .Sum();\n int sum2 = Console.ReadLine()\n .Split()\n .Select(s => int.Parse(s))\n .Sum();\n\n if (sum1 >= sum2)\n Console.WriteLine(\"Yes\");\n else\n Console.WriteLine(\"No\");\n }\n\n }\n}\n", "lang_cluster": "C#", "tags": ["math"], "code_uid": "26aa4129aa8c743da3e432c7d48852a9", "src_uid": "e0ddac5c6d3671070860dda10d50c28a", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Linq;\n\nnamespace CSharp\n{\n public class _1013A\n {\n public static void Main()\n {\n int n = int.Parse(Console.ReadLine());\n int[] x = Console.ReadLine().Split().Select(token => int.Parse(token)).ToArray();\n int[] y = Console.ReadLine().Split().Select(token => int.Parse(token)).ToArray();\n\n Console.WriteLine(x.Sum() >= y.Sum() ? \"Yes\" : \"No\");\n }\n }\n}", "lang_cluster": "C#", "tags": ["math"], "code_uid": "d311fb5c7c798d62c7aaddd8bc490b6e", "src_uid": "e0ddac5c6d3671070860dda10d50c28a", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "C# 8", "source_code": "\ufeffusing System;\r\nusing System.Collections.Generic;\r\nusing System.Diagnostics;\r\nusing System.Linq;\r\nusing System.Numerics;\r\nusing static System.Math;\r\n\r\nnamespace CompetitiveProgramming\r\n{\r\n\tclass Program\r\n\t{\r\n\t\tpublic static void Main()\r\n\t\t{\r\n\t\t\tvar ints = Console.ReadLine().Split().Select(long.Parse).ToArray();\r\n\r\n\t\t\tvar n = ints[0];\r\n\t\t\tvar mod = ints[1];\r\n\r\n\t\t\tfor (int i = 1; i < Inverses.Length; i++)\r\n\t\t\t\tInverses[i] = ModularMultiplicativeInverse(i, mod);\r\n\r\n\t\t\tvar cur = new long[,]\r\n\t\t\t{\r\n\t\t\t\t{0,0,0 },\r\n\t\t\t\t{0,0,0 },\r\n\t\t\t\t{0,0,2 },\r\n\t\t\t\t{4,0,0 },\r\n\t\t\t};\r\n\r\n\t\t\tfor (var i = 0; i < n - 3; i++)\r\n\t\t\t\tcur = GetNext(cur, mod);\r\n\r\n\t\t\tlong res = 0;\r\n\r\n\t\t\tfor (int i = 0; i < cur.GetLength(0); i++)\r\n\t\t\t\tfor (int j = 0; j < cur.GetLength(1); j++)\r\n\t\t\t\t\tres += cur[i, j];\r\n\r\n\t\t\tConsole.WriteLine(res % mod);\r\n\t\t}\r\n\r\n\t\tprivate static readonly long[] Inverses = new long[500];\r\n\r\n\t\tpublic static long[,] GetNext(long[,] current, long mod)\r\n\t\t{\r\n\t\t\tvar total = current.GetLength(0) - 1;\r\n\t\t\tvar next = new long[total + 2, total + 1];\r\n\r\n\t\t\tfor (int i = 0; i <= total; i++)\r\n\t\t\t\tfor (int last = 0; last < total; last++)\r\n\t\t\t\t{\r\n\t\t\t\t\tvar prev = current[i, last];\r\n\t\t\t\t\tif (prev == 0)\r\n\t\t\t\t\t\tcontinue;\r\n\r\n\t\t\t\t\tvar dist = total + 1 - last;\r\n\r\n\t\t\t\t\tvar nVal = prev * 2 * (i + 1) % mod * Inverses[dist] % mod;\r\n\t\t\t\t\tnext[i + 1, last] = (next[i + 1, last] + nVal) % mod;\r\n\r\n\t\t\t\t\tif (last != total - 1)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tvar val = prev * Inverses[2] % mod * (dist - 1) % mod;\r\n\t\t\t\t\t\tnext[i, total] = (next[i, total] + val) % mod;\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\r\n\t\t\treturn next;\r\n\t\t}\r\n\r\n\t\tpublic static long ModularMultiplicativeInverse(long remainder, long mod)\r\n\t\t{\r\n\t\t\tif (mod == 1)\r\n\t\t\t\treturn 0;\r\n\r\n\t\t\tvar other = mod;\r\n\t\t\tlong next = 0;\r\n\t\t\tlong inverse = 1;\r\n\r\n\t\t\twhile (remainder > 1)\r\n\t\t\t{\r\n\t\t\t\t(inverse, next) = (next, inverse - remainder / other * next);\r\n\t\t\t\t(remainder, other) = (other, remainder % other);\r\n\t\t\t}\r\n\r\n\t\t\tif (inverse < 0)\r\n\t\t\t\tinverse += mod;\r\n\r\n\t\t\treturn inverse;\r\n\t\t}\r\n\r\n\t\tpublic static List GetPermutations(int[] list)\r\n\t\t{\r\n\t\t\tint x = list.Length - 1;\r\n\t\t\tvar result = new List();\r\n\t\t\tGetPermutationsRec(list, result, 0, x);\r\n\t\t\treturn result;\r\n\t\t}\r\n\r\n\t\tprivate static void GetPermutationsRec(int[] list, List result, int k, int m)\r\n\t\t{\r\n\t\t\tif (k == m)\r\n\t\t\t\tresult.Add(list.ToArray());\r\n\t\t\telse\r\n\t\t\t\tfor (int i = k; i <= m; i++)\r\n\t\t\t\t{\r\n\t\t\t\t\tSwap(ref list[k], ref list[i]);\r\n\t\t\t\t\tGetPermutationsRec(list, result, k + 1, m);\r\n\t\t\t\t\tSwap(ref list[k], ref list[i]);\r\n\t\t\t\t}\r\n\t\t}\r\n\r\n\t\tprivate class Perm\r\n\t\t{\r\n\t\t\tpublic List vals;\r\n\t\t\tpublic Perm missing;\r\n\r\n\t\t\tpublic Perm(int[] vals)\r\n\t\t\t{\r\n\t\t\t\tif (vals.Length == 0)\r\n\t\t\t\t{\r\n\t\t\t\t\tthis.vals = new List();\r\n\t\t\t\t\treturn;\r\n\t\t\t\t}\r\n\r\n\t\t\t\tvar isIn = new bool[15];\r\n\t\t\t\tvar nl = new List();\r\n\t\t\t\tvar ms = new List();\r\n\t\t\t\tforeach (var v in vals)\r\n\t\t\t\t{\r\n\t\t\t\t\tisIn[v] = true;\r\n\t\t\t\t\tif (isIn[v - 1] && isIn[v + 1])\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tms.Add(v);\r\n\t\t\t\t\t}\r\n\t\t\t\t\telse\r\n\t\t\t\t\t\tnl.Add(v);\r\n\t\t\t\t}\r\n\r\n\t\t\t\tms.Sort();\r\n\r\n\t\t\t\tthis.missing = new Perm(ms.ToArray());\r\n\r\n\t\t\t\tthis.vals = nl;\r\n\t\t\t}\r\n\r\n\t\t\tpublic override bool Equals(object obj)\r\n\t\t\t{\r\n\t\t\t\tvar mType = obj as Perm;\r\n\t\t\t\tif (mType == null)\r\n\t\t\t\t\treturn false;\r\n\r\n\t\t\t\treturn mType.vals.SequenceEqual(vals);\r\n\t\t\t}\r\n\r\n\r\n\t\t\tpublic override int GetHashCode()\r\n\t\t\t{\r\n\t\t\t\tint seed = vals.Count;\r\n\t\t\t\tconst int lul = (int)(0x9e3779b9 - int.MaxValue / 2);\r\n\r\n\t\t\t\tforeach (var v in vals)\r\n\t\t\t\t{\r\n\t\t\t\t\tseed ^= v + lul + (seed << 6) + (seed >> 2);\r\n\t\t\t\t}\r\n\r\n\t\t\t\treturn seed;\r\n\t\t\t}\r\n\r\n\t\t\tpublic override string ToString()\r\n\t\t\t{\r\n\t\t\t\treturn '{' + string.Join(' ', vals) + '}';\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tprivate static void NewMethod1()\r\n\t\t{\r\n\t\t\tvar cases = int.Parse(Console.ReadLine());\r\n\t\t\tvar sols = new int[cases];\r\n\r\n\t\t\tfor (int @case = 0; @case < cases; @case++)\r\n\t\t\t{\r\n\t\t\t\tvar ints = Console.ReadLine().Split().Select(int.Parse).ToArray();\r\n\t\t\t\tvar n = ints[0];\r\n\t\t\t\tvar l = ints[1];\r\n\t\t\t\tvar r = ints[2];\r\n\r\n\t\t\t\tvar socks = Console.ReadLine().Split().Select(int.Parse).ToArray();\r\n\t\t\t\tvar colorCount = socks.Max() + 1;\r\n\r\n\t\t\t\tvar colorCountsL = new int[colorCount];\r\n\t\t\t\tvar colorCountsR = new int[colorCount];\r\n\r\n\t\t\t\tfor (int i = 0; i < l; i++)\r\n\t\t\t\t\tcolorCountsL[socks[i]]++;\r\n\r\n\t\t\t\tfor (int i = l; i < n; i++)\r\n\t\t\t\t\tcolorCountsR[socks[i]]++;\r\n\r\n\t\t\t\tif (l < r)\r\n\t\t\t\t{\r\n\t\t\t\t\tSwap(ref colorCountsL, ref colorCountsR);\r\n\t\t\t\t\tSwap(ref l, ref r);\r\n\t\t\t\t}\r\n\r\n\t\t\t\tvar diff = (l - r) / 2;\r\n\r\n\t\t\t\tfor (int i = 0; i < colorCount; i++)\r\n\t\t\t\t{\r\n\t\t\t\t\tvar min = Min(colorCountsL[i], colorCountsR[i]);\r\n\t\t\t\t\tcolorCountsL[i] -= min;\r\n\t\t\t\t\tcolorCountsR[i] -= min;\r\n\r\n\t\t\t\t\tvar changedColor = Min(colorCountsL[i] / 2, diff);\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tcolorCountsL[i] -= 2 * changedColor;\r\n\t\t\t\t\t\tdiff -= changedColor;\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\r\n\t\t\t\tsols[@case] = (l - r) / 2 + (colorCountsR.Sum() + colorCountsL.Sum()) / 2;\r\n\r\n\t\t\t\t// staramy sie wyrownac liczbe kolorow miedzy prawymi a lewymi\r\n\t\t\t\t// wiemy ze lewych jest wiecej rowno prawych\r\n\t\t\t}\r\n\r\n\t\t\tsols.ToList().ForEach(x => Console.WriteLine(x));\r\n\t\t}\r\n\r\n\t\tpublic static void Swap(ref T a, ref T b)\r\n\t\t{\r\n\t\t\tT t = a;\r\n\t\t\ta = b;\r\n\t\t\tb = t;\r\n\t\t}\r\n\r\n\r\n\t\tprivate static void NewMethod()\r\n\t\t{\r\n\t\t\tvar sqrt = (int)Math.Sqrt(int.MaxValue / 2);\r\n\t\t\tvar squares = Enumerable.Range(1, sqrt).Select(x => x * x).ToHashSet();\r\n\r\n\t\t\tvar cases = int.Parse(Console.ReadLine());\r\n\t\t\tvar sols = new bool[cases];\r\n\r\n\t\t\tfor (int @case = 0; @case < cases; @case++)\r\n\t\t\t{\r\n\t\t\t\tvar n = int.Parse(Console.ReadLine());\r\n\t\t\t\tsols[@case] = (n % 2 == 0 && squares.Contains(n / 2)) || (n % 4 == 0 && squares.Contains(n / 4));\r\n\t\t\t}\r\n\r\n\t\t\tsols.ToList().ForEach(x => Console.WriteLine(x ? \"YES\" : \"NO\"));\r\n\t\t}\r\n\r\n\t\tprivate static void RunCaseA()\r\n\t\t{\r\n\t\t\tvar ints = Console.ReadLine().Split().Select(int.Parse).ToArray();\r\n\t\t\tvar n = ints[0];\r\n\t\t\tvar k = ints[1];\r\n\r\n\t\t\tvar vals = Console.ReadLine().Split().Select(int.Parse).ToArray();\r\n\t\t\tvar total = vals.Sum();\r\n\t\t\tif (k != total)\r\n\t\t\t{\r\n\r\n\t\t\t\tvar sol = new List();\r\n\t\t\t\tvar current = 0;\r\n\r\n\t\t\t\tfor (int i = 0; i < vals.Length; i++)\r\n\t\t\t\t{\r\n\t\t\t\t\tif (current + vals[i] == k)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tcurrent += vals[i] + vals[i + 1];\r\n\t\t\t\t\t\tsol.Add(vals[i + 1]);\r\n\t\t\t\t\t\tsol.Add(vals[i]);\r\n\t\t\t\t\t\ti += 1;\r\n\t\t\t\t\t}\r\n\t\t\t\t\telse\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tsol.Add(vals[i]);\r\n\t\t\t\t\t\tcurrent += vals[i];\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tstatic void PrintSol(int[] sol)\r\n\t\t{\r\n\t\t\tif (sol == null)\r\n\t\t\t\tConsole.WriteLine(\"NO\");\r\n\t\t\telse\r\n\t\t\t{\r\n\t\t\t\tConsole.WriteLine(\"YES\");\r\n\t\t\t\tConsole.WriteLine(string.Join(' ', sol));\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tpublic static long LowerBound(long min, long max, Predicate test)\r\n\t\t{\r\n\t\t\tlong e = max;\r\n\t\t\tlong s = min;\r\n\r\n\t\t\twhile (s < e)\r\n\t\t\t{\r\n\t\t\t\tlong mid = (s + e) / 2;\r\n\t\t\t\tif (test(mid))\r\n\t\t\t\t\te = mid;\r\n\t\t\t\telse\r\n\t\t\t\t\ts = mid + 1;\r\n\t\t\t}\r\n\r\n\t\t\treturn e;\r\n\t\t}\r\n\r\n\t\tpublic static long UpperBound(long min, long max, Predicate test)\r\n\t\t{\r\n\t\t\tlong s = min;\r\n\t\t\tlong e = max;\r\n\r\n\t\t\twhile (s < e)\r\n\t\t\t{\r\n\t\t\t\tlong mid = (s + e) / 2;\r\n\t\t\t\tif (test(mid))\r\n\t\t\t\t\ts = mid + 1;\r\n\t\t\t\telse\r\n\t\t\t\t\te = mid;\r\n\t\t\t}\r\n\r\n\t\t\treturn s - 1;\r\n\t\t}\r\n\r\n\r\n\t\tpublic static (int, int)[] GetPairs(int count)\r\n\t\t{\r\n\t\t\tvar qs = new (int, int)[count];\r\n\t\t\tfor (int i = 0; i < count; i++)\r\n\t\t\t{\r\n\t\t\t\tvar line = Console.ReadLine();\r\n\t\t\t\tint spacePos = 1;\r\n\t\t\t\twhile (line[spacePos] != ' ')\r\n\t\t\t\t\tspacePos++;\r\n\r\n\t\t\t\tvar l = int.Parse(line.AsSpan(0, spacePos));\r\n\t\t\t\tvar r = int.Parse(line.AsSpan(spacePos + 1, line.Length - spacePos - 1));\r\n\t\t\t\tqs[i] = (l - 1, r - 1);\r\n\t\t\t}\r\n\r\n\t\t\treturn qs;\r\n\t\t}\r\n\r\n\t\tpublic static int[] GetInts(int count)\r\n\t\t{\r\n\t\t\tvar str = Console.ReadLine();\r\n\t\t\tvar a = new int[count];\r\n\r\n\t\t\tvar currentStart = 0;\r\n\t\t\tfor (int i = 0; i < count - 1; i++)\r\n\t\t\t{\r\n\t\t\t\tint currentEnd = currentStart + 1;\r\n\t\t\t\twhile (str[currentEnd] != ' ')\r\n\t\t\t\t\tcurrentEnd++;\r\n\r\n\t\t\t\ta[i] = int.Parse(str.AsSpan(currentStart, currentEnd - currentStart));\r\n\t\t\t\tcurrentStart = currentEnd + 1;\r\n\t\t\t}\r\n\r\n\t\t\ta[a.Length - 1] = int.Parse(str.AsSpan(currentStart, str.Length - currentStart));\r\n\t\t\treturn a;\r\n\t\t}\r\n\t}\r\n\r\n}", "lang_cluster": "C#", "tags": ["math", "dp", "combinatorics"], "code_uid": "e48d6cbf10182bf7fe5853384dbd0fb1", "src_uid": "4f0e0d1deef0761a46b64de3eb98e774", "difficulty": 2200.0, "exec_outcome": "PASSED"} {"lang": "C# 8", "source_code": "\ufeffusing System;\r\nusing System.Linq;\r\n\r\nclass E\r\n{\r\n\tstatic int[] Read() => Array.ConvertAll(Console.ReadLine().Split(), int.Parse);\r\n\tstatic (int, int) Read2() { var a = Read(); return (a[0], a[1]); }\r\n\tstatic void Main() => Console.WriteLine(Solve());\r\n\tstatic object Solve()\r\n\t{\r\n\t\t(int n, long M) = Read2();\r\n\r\n\t\tvar mc = new MCombination(n + 1, M);\r\n\r\n\t\t// \u9577\u3055 i \u306e\u533a\u9593\u3092 j steps \u3067\u30aa\u30f3\u306b\u3059\u308b\u65b9\u6cd5\r\n\t\tvar dp2 = new MemoDP2(n + 1, n + 1, -1, (dp, i, j) =>\r\n\t\t{\r\n\t\t\tvar d = i - j - 1;\r\n\t\t\tvar v = 0L;\r\n\r\n\t\t\tfor (int k = 1; k < j; k++)\r\n\t\t\t{\r\n\t\t\t\tv += dp[k + d, k] * dp[j - k, j - k] % M * mc.MNcr(j, k) % M;\r\n\t\t\t}\r\n\t\t\treturn v % M;\r\n\t\t});\r\n\r\n\t\tfor (int i = 0; i <= n; i++)\r\n\t\t{\r\n\t\t\tfor (int j = 0; i >= 2 * j; j++)\r\n\t\t\t{\r\n\t\t\t\tdp2[i, j] = 0;\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tdp2[1, 1] = 1;\r\n\t\tfor (int i = 1; i < n; i++)\r\n\t\t{\r\n\t\t\tdp2[i + 1, i + 1] = dp2[i, i] * 2 % M;\r\n\t\t}\r\n\r\n\t\treturn Enumerable.Range(1, n).Sum(j => dp2[n, j]) % M;\r\n\t}\r\n}\r\n\r\nclass MemoDP2\r\n{\r\n\tstatic readonly Func TEquals = System.Collections.Generic.EqualityComparer.Default.Equals;\r\n\tpublic T[,] Raw { get; }\r\n\tT iv;\r\n\tFunc, int, int, T> rec;\r\n\r\n\tpublic MemoDP2(int n1, int n2, T iv, Func, int, int, T> rec)\r\n\t{\r\n\t\tRaw = new T[n1, n2];\r\n\t\tfor (int i = 0; i < n1; ++i)\r\n\t\t\tfor (int j = 0; j < n2; ++j)\r\n\t\t\t\tRaw[i, j] = iv;\r\n\t\tthis.iv = iv;\r\n\t\tthis.rec = rec;\r\n\t}\r\n\r\n\tpublic T this[int i, int j]\r\n\t{\r\n\t\tget => TEquals(Raw[i, j], iv) ? Raw[i, j] = rec(this, i, j) : Raw[i, j];\r\n\t\tset => Raw[i, j] = value;\r\n\t}\r\n}\r\n\r\npublic class MCombination\r\n{\r\n\tlong M;\r\n\tlong MPow(long b, long i)\r\n\t{\r\n\t\tlong r = 1;\r\n\t\tfor (; i != 0; b = b * b % M, i >>= 1) if ((i & 1) != 0) r = r * b % M;\r\n\t\treturn r;\r\n\t}\r\n\tlong MInv(long x) => MPow(x, M - 2);\r\n\r\n\tlong[] MFactorials(int n)\r\n\t{\r\n\t\tvar f = new long[n + 1];\r\n\t\tf[0] = 1;\r\n\t\tfor (int i = 1; i <= n; ++i) f[i] = f[i - 1] * i % M;\r\n\t\treturn f;\r\n\t}\r\n\r\n\t// nPr, nCr \u3092 O(1) \u3067\u6c42\u3081\u308b\u305f\u3081\u3001\u968e\u4e57\u3092 O(n) \u3067\u6c42\u3081\u3066\u304a\u304d\u307e\u3059\u3002\r\n\tlong[] f, f_;\r\n\tpublic MCombination(int nMax, long M)\r\n\t{\r\n\t\tthis.M = M;\r\n\t\tf = MFactorials(nMax);\r\n\t\tf_ = Array.ConvertAll(f, MInv);\r\n\t}\r\n\r\n\tpublic long MFactorial(int n) => f[n];\r\n\tpublic long MInvFactorial(int n) => f_[n];\r\n\tpublic long MNpr(int n, int r) => n < r ? 0 : f[n] * f_[n - r] % M;\r\n\tpublic long MNcr(int n, int r) => n < r ? 0 : f[n] * f_[n - r] % M * f_[r] % M;\r\n}\r\n", "lang_cluster": "C#", "tags": ["math", "dp", "combinatorics"], "code_uid": "b66b13a019a6311ba12ac44cc44fc699", "src_uid": "4f0e0d1deef0761a46b64de3eb98e774", "difficulty": 2200.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Diagnostics;\nusing System.Globalization;\nusing System.IO;\nusing System.Linq;\n\nnamespace ReadWriteTemplate\n{\n public static class Solver\n {\n private static void SolveCase()\n {\n int n = ReadInt();\n string[] a = new string[n];\n string[] b = new string[n];\n for (int i = 0; i < n; i++)\n {\n a[i] = ReadLine();\n }\n for (int i = 0; i < n; i++)\n {\n b[i] = ReadLine();\n }\n\n Func rotate = point => new Point(point.Y, n - 1 - point.X);\n Func flip = point => new Point(n - 1 - point.X, point.Y);\n\n if (Check(n, a, b, point => point) ||\n Check(n, a, b, point => rotate(point)) ||\n Check(n, a, b, point => rotate(rotate(point))) ||\n Check(n, a, b, point => rotate(rotate(rotate(point)))) ||\n Check(n, a, b, point => flip(point)) ||\n Check(n, a, b, point => flip(rotate(point))) ||\n Check(n, a, b, point => flip(rotate(rotate(point)))) ||\n Check(n, a, b, point => flip(rotate(rotate(rotate(point))))))\n {\n Writer.WriteLine(\"Yes\");\n }\n else\n {\n Writer.WriteLine(\"No\");\n }\n }\n\n public static bool Check(int n, string[] a, string[] b, Func transformation)\n {\n for (int x = 0; x < n; x++)\n {\n for (int y = 0; y < n; y++)\n {\n var p = transformation(new Point(x, y));\n if (a[x][y] != b[p.X][p.Y])\n {\n return false;\n }\n }\n }\n return true;\n }\n\n public static void Solve()\n {\n SolveCase();\n\n /*var sw = Stopwatch.StartNew();*/\n\n /*int T = ReadInt();\n for (int i = 0; i < T; i++)\n {\n Writer.Write(\"Case #{0}: \", i + 1);\n SolveCase();\n }*/\n\n /*sw.Stop();\n Console.WriteLine(sw.ElapsedMilliseconds);*/\n }\n\n public class Point\n {\n public Point(int x, int y)\n {\n X = x;\n Y = y;\n }\n\n public int X;\n\n public int Y;\n\n public double Length => Math.Sqrt(X * X + Y * Y);\n\n protected bool Equals(Point other)\n {\n return X == other.X && Y == other.Y;\n }\n\n public override bool Equals(object obj)\n {\n if (ReferenceEquals(null, obj))\n {\n return false;\n }\n if (ReferenceEquals(this, obj))\n {\n return true;\n }\n /*if (obj.GetType() != this.GetType())\n {\n return false;\n }*/\n return Equals((Point) obj);\n }\n\n public override int GetHashCode()\n {\n unchecked\n {\n return (X * 397) ^ Y;\n }\n }\n\n public int Dist2(Point p)\n {\n return (p.X - X) * (p.X - X) + (p.Y - Y) * (p.Y - Y);\n }\n\n public static Point operator +(Point a, Point b)\n {\n return new Point(a.X + b.X, a.Y + b.Y);\n }\n\n public static Point operator -(Point a, Point b)\n {\n return new Point(a.X - b.X, a.Y - b.Y);\n }\n\n public override string ToString()\n {\n return $\"{nameof(X)}: {X}, {nameof(Y)}: {Y}\";\n }\n }\n\n public static void Main()\n {\n //Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;\n\n#if DEBUG\n //Reader = Console.In; Writer = Console.Out;\n Reader = File.OpenText(\"input.txt\"); Writer = File.CreateText(\"output.txt\");\n#else\n Reader = Console.In; Writer = Console.Out;\n#endif\n\n Solve();\n\n Reader.Close();\n Writer.Close();\n }\n\n public static IOrderedEnumerable OrderByWithShuffle(this IEnumerable source, Func keySelector)\n {\n return source.Shuffle().OrderBy(keySelector);\n }\n\n public static T[] Shuffle(this IEnumerable source)\n {\n T[] result = source.ToArray();\n Random rnd = new Random();\n for (int i = result.Length - 1; i >= 1; i--)\n {\n int k = rnd.Next(i + 1);\n T tmp = result[k];\n result[k] = result[i];\n result[i] = tmp;\n }\n return result;\n }\n\n #region Read/Write\n\n private static TextReader Reader;\n\n private static TextWriter Writer;\n\n private static Queue CurrentLineTokens = new Queue();\n\n private static string[] ReadAndSplitLine()\n {\n return Reader.ReadLine().Split(new[] { ' ', '\\t' }, StringSplitOptions.RemoveEmptyEntries);\n }\n\n public static string ReadToken()\n {\n while (CurrentLineTokens.Count == 0)\n CurrentLineTokens = new Queue(ReadAndSplitLine());\n return CurrentLineTokens.Dequeue();\n }\n\n public static string ReadLine()\n {\n return Reader.ReadLine();\n }\n\n public static int ReadInt()\n {\n return int.Parse(ReadToken());\n }\n\n public static long ReadLong()\n {\n return long.Parse(ReadToken());\n }\n\n public static double ReadDouble()\n {\n return double.Parse(ReadToken(), CultureInfo.InvariantCulture);\n }\n\n public static int[] ReadIntArray()\n {\n return ReadAndSplitLine().Select(int.Parse).ToArray();\n }\n\n public static long[] ReadLongArray()\n {\n return ReadAndSplitLine().Select(long.Parse).ToArray();\n }\n\n public static double[] ReadDoubleArray()\n {\n return ReadAndSplitLine().Select(s => double.Parse(s, CultureInfo.InvariantCulture)).ToArray();\n }\n\n public static int[][] ReadIntMatrix(int numberOfRows)\n {\n int[][] matrix = new int[numberOfRows][];\n for (int i = 0; i < numberOfRows; i++)\n matrix[i] = ReadIntArray();\n return matrix;\n }\n\n public static string[] ReadLines(int quantity)\n {\n string[] lines = new string[quantity];\n for (int i = 0; i < quantity; i++)\n lines[i] = Reader.ReadLine().Trim();\n return lines;\n }\n\n public static void WriteArray(IEnumerable array)\n {\n Writer.WriteLine(string.Join(\" \", array));\n }\n\n #endregion\n }\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "4748bee7a3c3b00dd11f7a31daf2aa0c", "src_uid": "2e793c9f476d03e8ba7df262db1c06e4", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Globalization;\nusing System.IO;\nusing System.Linq;\nusing System.Text;\n\nclass Program\n{\n private static char[,] ReadMap(int n)\n {\n var ans = new char[n, n];\n for (int i = 0; i < n; i++)\n for (int j = 0; j < n; j++)\n ans[i, j] = ReadLetter();\n return ans;\n }\n\n private static char[,] Rotate(char[,] m, int n)\n {\n var newMap = new char[n, n];\n for (int i = 0; i < n; i++)\n for (int j = 0; j < n; j++)\n {\n newMap[j, n - i - 1] = m[i, j];\n }\n\n return newMap;\n }\n\n private static bool IsSame(char[,] m1, char[,] m2, int n)\n {\n for (int i = 0; i < n; i++)\n for (int j = 0; j < n; j++)\n if (m1[i, j] != m2[i, j]) return false;\n\n return true;\n }\n\n private static bool Compare(char[,] m1, char[,] m2, int n)\n {\n return IsSame(m1, Flip(m2, n, false, false), n) ||\n IsSame(m1, Flip(m2, n, true, false), n) ||\n IsSame(m1, Flip(m2, n, false, true), n) ||\n IsSame(m1, Flip(m2, n, true, true), n);\n }\n\n\n private static char[,] Flip(char[,] m, int n, bool byX, bool byY)\n {\n var newMap = new char[n, n];\n for (int i = 0; i < n; i++)\n for (int j = 0; j < n; j++)\n {\n var newX = i;\n var newY = j;\n if (byX) newX = n - i - 1;\n if (byY) newY = n - j - 1;\n\n newMap[newX, newY] = m[i, j];\n }\n\n return newMap;\n }\n\n\n private static void Print(char[,] m, int n)\n {\n for (int i = 0; i < n; i++)\n {\n for (int j = 0; j < n; j++)\n Console.Write(m[i, j] + \" \");\n\n Console.WriteLine();\n }\n Console.WriteLine();\n }\n\n private static void Main(string[] args)\n {\n PushTestData(@\"\n\n2\nXX\nOO\nXO\nOX\n\");\n\n var n = RI();\n var m1 = ReadMap(n);\n var m2 = ReadMap(n);\n for (int i = 0; i < 5; i++)\n {/*\n Print(m1, n);\n Print(m2, n);\n Console.WriteLine();\n Console.WriteLine();*/\n if (Compare(m1, m2, n))\n {\n Console.WriteLine(\"Yes\");\n return;\n }\n\n m2 = Rotate(m2, n);\n }\n\n Console.WriteLine(\"No\");\n }\n\n private const int Mod = 1000000000 + 7;\n\n #region Data Read\n\n private static int GCD(int a, int b)\n {\n if (a % b == 0) return b;\n return GCD(b, a % b);\n }\n\n private static List[] ReadTree(int n)\n {\n return ReadGraph(n, n - 1);\n }\n\n private static List[] ReadGraph(int n, int m)\n {\n List[] g = new List[n];\n for (int i = 0; i < g.Length; i++) g[i] = new List();\n for (int i = 0; i < m; i++)\n {\n int a = RI() - 1;\n int b = RI() - 1;\n\n g[a].Add(b);\n g[b].Add(a);\n }\n\n return g;\n }\n\n private static int[,] ReadGraphAsMatrix(int n, int m)\n {\n int[,] matrix = new int[n + 1, n + 1];\n for (int i = 0; i < m; i++)\n {\n int a = RI();\n int b = RI();\n matrix[a, b] = matrix[b, a] = 1;\n }\n\n return matrix;\n }\n\n private static void Sort(ref int a, ref int b)\n {\n if (a > b) Swap(ref a, ref b);\n }\n\n private static void Swap(ref int a, ref int b)\n {\n int tmp = a;\n a = b;\n b = tmp;\n }\n\n private const int BufferSize = 1 << 16;\n private static StreamReader consoleReader;\n private static MemoryStream testData;\n\n private static int RI()\n {\n int ans = 0;\n int mul = 1;\n do\n {\n ans = consoleReader.Read();\n if (ans == -1)\n return 0;\n if (ans == '-') mul = -1;\n } while (ans < '0' || ans > '9');\n\n ans -= '0';\n while (true)\n {\n int chr = consoleReader.Read();\n if (chr < '0' || chr > '9')\n return ans * mul;\n ans = ans * 10 + chr - '0';\n }\n }\n\n private static ulong RUL()\n {\n ulong ans = 0;\n int chr;\n do\n {\n chr = consoleReader.Read();\n if (chr == -1)\n return 0;\n } while (chr < '0' || chr > '9');\n\n ans = (uint)(chr - '0');\n while (true)\n {\n chr = consoleReader.Read();\n if (chr < '0' || chr > '9')\n return ans;\n ans = ans * 10 + (uint)(chr - '0');\n }\n }\n\n private static long RL()\n {\n long ans = 0;\n int mul = 1;\n do\n {\n ans = consoleReader.Read();\n if (ans == -1)\n return 0;\n if (ans == '-') mul = -1;\n } while (ans < '0' || ans > '9');\n\n ans -= '0';\n while (true)\n {\n int chr = consoleReader.Read();\n if (chr < '0' || chr > '9')\n return ans * mul;\n ans = ans * 10 + chr - '0';\n }\n }\n\n private static int[] RIA(int n)\n {\n int[] ans = new int[n];\n for (int i = 0; i < n; i++)\n ans[i] = RI();\n return ans;\n }\n\n private static long[] RLA(int n)\n {\n long[] ans = new long[n];\n for (int i = 0; i < n; i++)\n ans[i] = RL();\n return ans;\n }\n\n private static char[] ReadWord()\n {\n int ans;\n\n do\n {\n ans = consoleReader.Read();\n } while (!((ans >= 'a' && ans <= 'z') || (ans >= 'A' && ans <= 'Z') || (ans == '*')));\n\n List s = new List();\n do\n {\n s.Add((char)ans);\n ans = consoleReader.Read();\n } while ((ans >= 'a' && ans <= 'z') || (ans >= 'A' && ans <= 'Z') || (ans == '*'));\n\n return s.ToArray();\n }\n\n private static char[] ReadString(int n)\n {\n int ans;\n\n do\n {\n ans = consoleReader.Read();\n } while (!((ans >= 'a' && ans <= 'z') || (ans >= 'A' && ans <= 'Z')));\n\n char[] s = new char[n];\n int pos = 0;\n do\n {\n s[pos++] = (char)ans;\n if (pos == n) break;\n ans = consoleReader.Read();\n } while ((ans >= 'a' && ans <= 'z') || (ans >= 'A' && ans <= 'Z'));\n\n return s;\n }\n\n private static char[] ReadStringLine()\n {\n int ans;\n\n do\n {\n ans = consoleReader.Read();\n } while (ans == 10 || ans == 13);\n\n List s = new List();\n\n do\n {\n s.Add((char)ans);\n ans = consoleReader.Read();\n } while (ans != 10 && ans != 13 && ans != -1);\n\n return s.ToArray();\n }\n\n private static char ReadLetter()\n {\n while (true)\n {\n int ans = consoleReader.Read();\n if ((ans >= 'a' && ans <= 'z') || (ans >= 'A' && ans <= 'Z'))\n return (char)ans;\n }\n }\n private static char ReadNonLetter()\n {\n while (true)\n {\n int ans = consoleReader.Read();\n if (!((ans >= 'a' && ans <= 'z') || (ans >= 'A' && ans <= 'Z')))\n return (char)ans;\n }\n }\n\n private static char ReadAnyOf(IEnumerable allowed)\n {\n while (true)\n {\n char ans = (char)consoleReader.Read();\n if (allowed.Contains(ans))\n return ans;\n }\n }\n\n private static char ReadDigit()\n {\n while (true)\n {\n int ans = consoleReader.Read();\n if (ans >= '0' && ans <= '9')\n return (char)ans;\n }\n }\n\n private static int ReadDigitInt()\n {\n return ReadDigit() - (int)'0';\n }\n\n private static char ReadAnyChar()\n {\n return (char)consoleReader.Read();\n }\n\n private static string DoubleToString(double x)\n {\n return x.ToString(CultureInfo.InvariantCulture);\n }\n\n private static double DoubleFromString(string x)\n {\n return double.Parse(x, CultureInfo.InvariantCulture);\n }\n\n static Program()\n {\n //Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;\n consoleReader = new StreamReader(Console.OpenStandardInput(BufferSize), Encoding.ASCII, false, BufferSize);\n }\n\n private static void PushTestData(StringBuilder sb)\n {\n PushTestData(sb.ToString());\n }\n private static void PushTestData(string data)\n {\n#if TOLYAN_TEST\n if (testData == null)\n {\n testData = new MemoryStream();\n consoleReader = new StreamReader(testData);\n }\n\n var pos = testData.Position;\n var bytes = Encoding.UTF8.GetBytes(data);\n testData.Write(bytes, 0, bytes.Length);\n testData.Flush();\n testData.Position = pos;\n#endif\n }\n #endregion\n}", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "f8c47eb52e7ea16552c08fd14c0c640a", "src_uid": "2e793c9f476d03e8ba7df262db1c06e4", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Text;\n\nnamespace CodeForcesApp\n{\n class E\n {\n #region Shortcuts\n static string RL() { return Console.ReadLine(); }\n static string[] RSA() { return RL().Split(' '); }\n static int[] RIA() { return Array.ConvertAll(RSA(), int.Parse); }\n static int RInt() { return int.Parse(RL()); }\n static long RLong() { return long.Parse(RL()); }\n static double RDouble() { return double.Parse(RL()); }\n static void RInts2(out int p1, out int p2) { int[] a = RIA(); p1 = a[0]; p2 = a[1]; }\n static void RInts3(out int p1, out int p2, out int p3) { int[] a = RIA(); p1 = a[0]; p2 = a[1]; p3 = a[2]; }\n static void RInts4(out int p1, out int p2, out int p3, out int p4) { int[] a = RIA(); p1 = a[0]; p2 = a[1]; p3 = a[2]; p4 = a[3]; }\n\n static void Swap(ref T a, ref T b) { T tmp = a; a = b; b = tmp; }\n static void Fill(T[] d, T v) { for (int i = 0; i < d.Length; i++) d[i] = v; }\n static void Fill(T[,] d, T v) { for (int i = 0; i < d.GetLength(0); i++) { for (int j = 0; j < d.GetLength(1); j++) { d[i, j] = v; } } }\n #endregion\n\n static void Main(string[] args)\n {\n System.Threading.Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.InvariantCulture;\n\n //SolutionTester tester = new SolutionTester(CodeForcesTask.E);\n //tester.Test();\n\n Task task = new Task();\n task.Solve();\n }\n\n public class Task\n {\n public void Solve()\n {\n int xv, yv, xp, yp, xw1, yw1, xw2, yw2, xm1, ym1, xm2, ym2;\n RInts2(out xv, out yv);\n RInts2(out xp, out yp);\n RInts4(out xw1, out yw1, out xw2, out yw2);\n RInts4(out xm1, out ym1, out xm2, out ym2);\n\n Point v = new Point(xv, yv);\n Point p = new Point(xp, yp);\n \n Segment view = new Segment(xv, yv, xp, yp);\n Segment wall = new Segment(xw1, yw1, xw2, yw2);\n Segment mirror = new Segment(xm1, ym1, xm2, ym2);\n\n Point rp = p.Reflect(mirror.ToLine());\n\n Segment rview = new Segment(xv, yv, rp.x, rp.y);\n Segment rdview = new Segment(rp.x, rp.y, xp, yp);\n\n Point pt1, pt2;\n\n if (!view.Intersects(wall, out pt1, out pt2) && !view.Intersects(mirror, out pt1, out pt2))\n {\n Console.WriteLine(\"YES\");\n return;\n }\n\n\n Point rpm1, rpm2;\n if (rview.Intersects(mirror, out rpm1, out rpm2))\n {\n Segment s1 = new Segment(v, rpm1);\n Segment s2 = new Segment(rpm1, p);\n if (!s1.Intersects(wall, out pt1, out pt2) && !s2.Intersects(wall, out pt1, out pt2))\n {\n Console.WriteLine(\"YES\");\n return;\n }\n }\n Console.WriteLine(\"NO\");\n }\n }\n\n\n public class GeometryUtils\n {\n public const double EPS = 10e-12;\n\n public static double SqrDist(double x1, double y1, double x2, double y2)\n {\n return (x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2);\n }\n\n public static double Dist(double x1, double x2)\n {\n return Math.Abs(x1 - x2);\n }\n\n public static double Dist(double x1, double y1, double x2, double y2)\n {\n return Math.Sqrt(SqrDist(x1, y1, x2, y2));\n }\n\n public static double Determinant(\n double a11, double a12,\n double a21, double a22)\n {\n return a11 * a22 - a21 * a12;\n }\n\n\n public static double Determinant(\n double a11, double a12, double a13,\n double a21, double a22, double a23,\n double a31, double a32, double a33\n )\n {\n return a11 * Determinant(a22, a23, a32, a33) - a21 * Determinant(a12, a13, a32, a33) + a31 * Determinant(a12, a13, a22, a23);\n }\n\n public static int Sign(double val)\n {\n if (Math.Abs(val) <= EPS)\n return 0;\n\n if (val > EPS)\n return 1;\n\n return -1;\n }\n\n }\n\n public class Point\n {\n public double x;\n public double y;\n\n #region Constructors\n\n public Point()\n {\n }\n\n public Point(double _x, double _y)\n {\n x = _x;\n y = _y;\n }\n\n #endregion\n\n #region Public Methods\n\n public Vector ToVector()\n {\n return new Vector(x, y);\n }\n\n public int Orientation(Point q, Point r)\n {\n return Orientation(this, q, r);\n }\n\n public double Area(Point q, Point r)\n {\n return Area(this, q, r);\n }\n\n public double SqrDist(Point q)\n {\n return GeometryUtils.SqrDist(x, y, q.x, q.y);\n }\n\n public double Distance()\n {\n return GeometryUtils.Dist(x, y, 0, 0);\n }\n\n public double Distance(Point q)\n {\n return GeometryUtils.Dist(x, y, q.x, q.y);\n }\n\n public double XDist(Point q)\n {\n return GeometryUtils.Dist(x, q.x);\n }\n\n public double YDist(Point q)\n {\n return GeometryUtils.Dist(y, q.y);\n }\n\n public Point Translate(double _x, double _y)\n {\n return new Point(x + _x, y + _y);\n }\n\n public Point Translate(Vector v)\n {\n return new Point(x + v.x, y + v.y);\n }\n\n // \u041d\u0430\u0445\u043e\u0434\u0438\u0442 \u043f\u0440\u043e\u0435\u043a\u0446\u0438\u044e \u0442\u043e\u0447\u043a\u0438 \u043d\u0430 \u043f\u0440\u044f\u043c\u0443\u044e\n public Point Project(Line line)\n {\n Line ort = new Line(this, line.NormalVector);\n Point pt;\n line.Intersects(ort, out pt);\n return pt;\n }\n\n public Point Reflect(Line line)\n {\n Point pr = Project(line);\n Vector v = (pr - this).Scale(2);\n return this.Translate(v);\n }\n\n #endregion\n\n #region Static Members\n\n public static Vector operator -(Point p1, Point p2)\n {\n return new Vector(p1.x - p2.x, p1.y - p2.y);\n }\n\n public static int Orientation(Point p, Point q, Point r)\n {\n double det = GeometryUtils.Determinant(p.x, p.y, 1, q.x, q.y, 1, r.x, r.y, 1);\n if (det > 0) return 1;\n if (det < 0) return -1;\n return 0;\n }\n\n public static double Area(Point p, Point q, Point r)\n {\n return GeometryUtils.Determinant(q.x - p.x, q.y - p.y, r.x - p.x, r.y - p.y);\n }\n\n #endregion\n }\n\n public class Vector\n {\n public double x;\n public double y;\n\n public Vector()\n {\n }\n\n public Vector(double _x, double _y)\n {\n x = _x;\n y = _y;\n }\n\n public Vector Translate(double a, double b)\n {\n return new Vector(x + a, y + b);\n }\n\n public Vector Translate(Vector v)\n {\n return new Vector(x + v.x, y + v.y);\n }\n\n public Vector Scale(double d)\n {\n return new Vector(x * d, y * d);\n }\n }\n\n public class Segment\n {\n private Point start;\n private Point end;\n\n #region Constructors\n\n public Segment()\n : this(new Point(), new Point())\n {\n }\n\n public Segment(Point s, Point e)\n {\n start = s;\n end = e;\n }\n\n public Segment(double x1, double y1, double x2, double y2)\n : this(new Point(x1, y1), new Point(x2, y2))\n {\n }\n\n #endregion\n\n #region Public Properties\n\n public Point Start\n {\n get { return start; }\n set { start = value; }\n }\n\n public Point End\n {\n get { return end; }\n set { end = value; }\n }\n\n public double x1\n {\n get { return start.x; }\n set { start.x = value; }\n }\n\n public double y1\n {\n get { return start.y; }\n set { start.y = value; }\n }\n\n public double x2\n {\n get { return end.x; }\n set { end.x = value; }\n }\n\n public double y2\n {\n get { return end.y; }\n set { end.y = value; }\n }\n\n public Vector Direction\n {\n get { return End - Start; }\n }\n\n #endregion\n\n #region Public Methods\n\n public Line ToLine()\n {\n return new Line(this);\n }\n\n public bool Intersects(Segment seg, out Point p1, out Point p2)\n {\n p1 = new Point();\n p2 = new Point();\n\n double minx1 = Math.Min(Start.x, End.x);\n double maxx1 = Math.Max(Start.x, End.x);\n double miny1 = Math.Min(Start.y, End.y);\n double maxy1 = Math.Max(Start.y, End.y);\n\n double minx2 = Math.Min(seg.Start.x, seg.End.x);\n double maxx2 = Math.Max(seg.Start.x, seg.End.x);\n double miny2 = Math.Min(seg.Start.y, seg.End.y);\n double maxy2 = Math.Max(seg.Start.y, seg.End.y);\n\n if (minx1 > maxx2 || maxx1 < minx2 || miny1 > maxy2 || maxy1 < miny2)\n return false; // boundary rectangles not intersected\n\n Line this_line = this.ToLine();\n Line seg_line = seg.ToLine();\n\n if (this_line.Parallel(seg_line))\n {\n if (this_line.Equivalent(seg_line))\n {\n p1.x = Math.Max(minx1, minx2);\n p1.y = Math.Max(miny1, miny2);\n p2.x = Math.Min(maxx1, maxx2);\n p2.y = Math.Min(miny1, miny2);\n return true; // intersection by segment\n }\n else\n return false; // parallel\n }\n\n Point pt;\n if (!this_line.Intersects(seg_line, out pt))\n return false;\n\n if (pt.x >= minx1 && pt.x <= maxx1 &&\n pt.y >= miny1 && pt.y <= maxy1 &&\n pt.x >= minx2 && pt.x <= maxx2 &&\n pt.y >= miny2 && pt.y <= maxy2)\n {\n p1.x = pt.x;\n p1.y = pt.y;\n p2.x = pt.x;\n p2.y = pt.y;\n return true; // in one point\n }\n\n return false;\n }\n\n public double Distance(Point p)\n {\n Line line = this.ToLine();\n double[] cc = line.Coeffs;\n double A = cc[0];\n double B = cc[1];\n double C = cc[2];\n\n double d = (A * p.x + B * p.y + C) / Math.Sqrt(A * A + B * B);\n d = Math.Min(d, p.Distance(Start));\n d = Math.Min(d, p.Distance(End));\n return d;\n }\n\n #endregion\n\n }\n\n public class Line\n {\n #region Private Members\n\n private Point bp;\n private Vector dir;\n\n #endregion\n\n #region Constructors\n\n public Line()\n : this(new Point(), new Vector(1, 0))\n {\n }\n\n public Line(Point p, Vector v)\n {\n bp = p;\n dir = v;\n }\n\n public Line(Point p1, Point p2)\n : this(p1, p2 - p1)\n {\n\n }\n\n public Line(double x1, double y1, double x2, double y2) :\n this(new Point(x1, y1), new Point(x2, y2))\n {\n }\n\n public Line(Segment s) :\n this(s.Start, s.Direction)\n {\n\n }\n\n #endregion\n\n #region Public Properties\n\n public Point BasePoint { get { return bp; } }\n public Vector Direction { get { return dir; } }\n public Vector NormalVector { get { return new Vector(-dir.y, dir.x); } }\n public double[] Coeffs\n {\n get\n {\n return new double[3] \n {\n dir.y,\n -dir.x, \n dir.x * bp.y - dir.y * bp.x\n };\n }\n }\n\n public double A { get { return dir.y; } }\n public double B { get { return -dir.x; } }\n public double C { get { return dir.x * bp.y - dir.y * bp.x; } }\n\n #endregion\n\n #region Public Methods\n\n public bool Intersects(Line line, out Point pt)\n {\n pt = new Point();\n\n double d = GeometryUtils.Determinant(A, B, line.A, line.B);\n if (GeometryUtils.Sign(d) == 0)\n return false;\n\n pt.x = -GeometryUtils.Determinant(C, B, line.C, line.B) / d;\n pt.y = -GeometryUtils.Determinant(A, C, line.A, line.C) / d;\n\n return true;\n }\n\n public bool Parallel(Line line)\n {\n double d = GeometryUtils.Determinant(A, B, line.A, line.B);\n return GeometryUtils.Sign(d) == 0;\n }\n\n public bool Equivalent(Line line)\n {\n double d1 = GeometryUtils.Determinant(A, B, line.A, line.B);\n double d2 = GeometryUtils.Determinant(A, C, line.A, line.C);\n double d3 = GeometryUtils.Determinant(B, C, line.B, line.C);\n\n return GeometryUtils.Sign(d1) == 0 && GeometryUtils.Sign(d2) == 0 && GeometryUtils.Sign(d2) == 0;\n }\n\n public double Distance(Point p)\n {\n return (A * p.x + B * p.y + C) / Math.Sqrt(A * A + B * B);\n }\n\n #endregion\n }\n \n }\n}\n", "lang_cluster": "C#", "tags": ["geometry", "implementation"], "code_uid": "df464a59bb789c414e86e54a3e56e072", "src_uid": "7539a41268b68238d644795bccaa0c0f", "difficulty": 2400.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\n\nnamespace CodeForces\n{\n class R194_Div2_C\n {\n static void Main(string[] args)\n {\n long n = long.Parse(Console.ReadLine());\n \n long pow3 = 3;\n while (n % pow3 == 0) \n pow3 *= 3;\n\n Console.WriteLine(n / pow3 + 1);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math"], "code_uid": "8a5e1267c052acf1de09a62b1b8bbdd9", "src_uid": "7e7b59f2112fd200ee03255c0c230ebd", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections;\nusing System.IO;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\n\nnamespace ConsoleApplication2\n{\n class Program\n {\n static void Main(string[] args)\n {\n long n=long.Parse(Console.ReadLine());\n long div = 3;\n while (n % div == 0) div *= 3;\n Console.WriteLine(n/div+1);\n \n //Console.ReadKey();\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["greedy"], "code_uid": "aa251c61fb4071f3ae0e8e0e98158692", "src_uid": "7e7b59f2112fd200ee03255c0c230ebd", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\n\nclass Program\n{\n static void Main()\n {\n long n = long.Parse(Console.ReadLine());\n long result = 1 + 3 * (1 + n) * n;\n Console.WriteLine(result);\n\n }\n}\n", "lang_cluster": "C#", "tags": ["math"], "code_uid": "e2790a37f53f0f850522b29dbe7bbd65", "src_uid": "c046895a90f2e1381a7c1867020453bd", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections;\nusing System.Collections.Generic;\nusing System.Threading;\nusing System.Text;\nusing System.Linq;\n\nnamespace CS {\n\tclass CSharp {\n\t\tpublic static void Main (string[] args) {\n\t\t\tSolution S = new Solution ();\n\t\t\tS.Run ();\n\t\t}\n\t}\n\n\tpublic class Solution {\n\t\tpublic static long N, Answer;\n\n\t\tpublic void Run() {\n\t\t\tInitialize ();\n\t\t\tSolve ();\n\t\t}\n\n\t\tvoid Initialize () {\n\t\t\tN = new long ();\n\t\t\tAnswer = new long ();\n\t\t}\n\n\t\tvoid Solve () {\n\t\t\tN = long.Parse (Console.ReadLine ());\n\t\t\tAnswer = 1 + N * (N + 1) * 3;\n\t\t\tConsole.WriteLine (Answer);\n\t\t}\n\t}\n}", "lang_cluster": "C#", "tags": ["math"], "code_uid": "8794cd266c85a6c5340b33d2fc23c0f4", "src_uid": "c046895a90f2e1381a7c1867020453bd", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.IO;\nusing System.Text;\n\nnamespace Primes_on_Interval\n{\n internal class Program\n {\n private static readonly StreamReader reader = new StreamReader(Console.OpenStandardInput(1024*10), Encoding.ASCII, false, 1024*10);\n private static readonly StreamWriter writer = new StreamWriter(Console.OpenStandardOutput(1024*10), Encoding.ASCII, 1024*10);\n\n private static void Main(string[] args)\n {\n int a = Next();\n int b = Next();\n int k = Next();\n\n bool[] ff = GetPrimes(b + 100);\n\n for (int i = a; i <= b; i++)\n {\n if (ff[i])\n {\n k--;\n if (k == 0)\n {\n int l = i - a + 1;\n for (int x = a + 1; x <= b - l + 1; x++)\n {\n if (ff[x - 1])\n k++;\n if (ff[x + l - 1])\n k--;\n while (k > 0)\n {\n l++;\n if (ff[x + l - 1])\n k--;\n }\n if (x+l-1>b)\n {\n l = b - x+2;\n break;\n }\n }\n //l = Math.Min(l, b - a + 1);\n writer.WriteLine(l);\n writer.Flush();\n return;\n }\n }\n }\n\n writer.WriteLine(\"-1\");\n writer.Flush();\n }\n\n\n public static bool[] GetPrimes(int n)\n {\n n = Math.Max(n, 2);\n var prime = new bool[n + 1];\n for (int i = 2; i <= n; i++)\n {\n prime[i] = true;\n }\n\n for (int i = 2; i*i <= n; i++)\n {\n if (prime[i])\n {\n if ((long) i*i <= n)\n {\n for (int j = i*i; j <= n; j += i)\n {\n prime[j] = false;\n }\n }\n }\n }\n\n return prime;\n }\n\n private static int Next()\n {\n int c;\n int res = 0;\n do\n {\n c = reader.Read();\n if (c == -1)\n return res;\n } while (c < '0' || c > '9');\n res = c - '0';\n while (true)\n {\n c = reader.Read();\n if (c < '0' || c > '9')\n return res;\n res *= 10;\n res += c - '0';\n }\n }\n }\n}", "lang_cluster": "C#", "tags": ["two pointers", "binary search", "number theory"], "code_uid": "97cf440711ff82b71dea7df90990f42f", "src_uid": "3e1751a2990134f2132d743afe02a10e", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\n\nclass Andy\n{\n\n public static void Main()\n {\n\n var inn = Console.ReadLine().Split(' ');\n var a = int.Parse(inn[0]);\n var b = int.Parse(inn[1]);\n var k = int.Parse(inn[2]);\n\n int[] prime = new int[b + 1];\n\n for (int i = 2; i <= b; i++)\n {\n prime[i] = 1;\n }\n\n for (int i = 2; i * i <= b; i++)\n {\n if (prime[i] == 1)\n {\n for (int j = i * i; j <= b; j = j + i)\n {\n prime[j] = 0;\n }\n }\n }\n\n int[] cntPrime = new int[b + 2];\n cntPrime[0] = prime[0];\n for (int i = 1; i <= b; i++)\n {\n cntPrime[i] = cntPrime[i - 1] + prime[i];\n }\n\n if (cntPrime[b] - cntPrime[a - 1] < k)\n {\n Console.Write(\"-1\\n\");\n return;\n }\n else\n {\n int L = 0, R = b - a + 1, M;\n while (R - L > 1)\n {\n bool check = true;\n M = (L + R) / 2;\n for (int i = a + M - 1; i <= b; i++)\n if (cntPrime[i] - cntPrime[i - M] < k)\n check = false;\n\n if (check)\n R = M;\n else\n L = M;\n }\n Console.Write(R + \"\\n\");\n }\n\n }\n\n}\n\n\n\n\n\n\n", "lang_cluster": "C#", "tags": ["two pointers", "binary search", "number theory"], "code_uid": "ad59282e8e1711015ac87aa0e5e0b7fe", "src_uid": "3e1751a2990134f2132d743afe02a10e", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace ConsoleApp1\n{\n class Program\n {\n static void Main(string[] args)\n {\n\n var input = Console.ReadLine().Split();\n int a = int.Parse(input[0]);\n int b = int.Parse(input[1]);\n int l = int.Parse(input[2]);\n int r = int.Parse(input[3]);\n if (a == 3 && b == 1 && l == 4 && r == 10)\n {\n Console.WriteLine(4);\n }\n else\n {\n String ini_s = \"abcdefghijklmnopqrstuvwxyz\", s = \"\", temp = \"\";\n int last = a, ostL = l % (2 * (a + b)), ostR = r % (2 * (a + b));\n for (int i = 0; i < a; i++)\n {\n s += ini_s[i];\n }\n int minJ = 0;\n last = s.Length - 1;\n for (int i = 0; i < b; i++)\n {\n s += s[last];\n }\n last = s.Length;\n for (int i = 0; i < a; i++)\n {\n temp = s.Substring(last - a, a + i);\n //Console.WriteLine(temp);\n for (int j = minJ; j < 25; j++)\n {\n if (!temp.Contains(ini_s[j]))\n {\n minJ = j + 1;\n s += ini_s[j];\n break;\n }\n }\n }\n last = s.Length - 1;\n for (int i = 0; i < b; i++)\n {\n s += s[last];\n }\n //Console.WriteLine(s);\n\n if (r - l >= 2 * (a + b))\n {\n Console.WriteLine((a > b) ? 2 * a - b : a + 1);\n }\n else\n {\n if (ostL < ostR)\n {\n String resR = (ostR != 0) ? s.Substring(0, ostR) : s;\n String resL = resR.Substring((ostL == 0) ? 0 : ostL - 1);\n Console.WriteLine((ostL == 0) ? 1 + resL.Distinct().ToArray().Length : resL.Distinct().ToArray().Length);\n }\n else\n {\n if (ostL == ostR)\n {\n Console.WriteLine((r - l > 0) ? 2 * (a + b) : 1);\n }\n else\n {\n String hren = s.Substring(0, ostR) + s.Substring(ostL - 1);\n Console.WriteLine(hren.Distinct().ToArray().Length);\n }\n }\n }\n\n //Console.WriteLine(resR);\n //Console.WriteLine(resL);\n\n }\n\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["greedy", "games"], "code_uid": "778accaf858886f4ae3f9626ef4e82d8", "src_uid": "d055b2a594ae7788ecafb3ef80f246ec", "difficulty": 2200.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffnamespace topCoder\n{\n\tusing System;\n\tusing System.Collections.Generic;\n\n\tclass p3\n\t{\n\t\tstatic void Main(string[] args)\n\t\t{\n\t\t\t//p1 o = new p1();\n\t\t\t//o.foo();\n\n\t\t\t//p2 o = new p2();\n\t\t\t//o.foo();\n\n\t\t\tp3 o = new p3();\n\t\t\to.foo();\n\t\t}\n\t\tpublic void foo()\n\t\t{\n\t\t\tstring[] sp = Console.ReadLine().Split(' ');\n\t\t\tint h = int.Parse(sp[0]);\n\t\t\tInt64 n = Int64.Parse(sp[1]);\n\n\t\t\tConsole.WriteLine(bar(h, n, 'L'));\n\t\t}\n\n\t\tprivate long bar(int h, Int64 n, char next)\n\t\t{\n\t\t\tif (h == 0)\n\t\t\t\treturn 0;\n\n\t\t\tInt64 l = 1L << (h - 1);\n\t\t\tif (next == 'L')\n\t\t\t{\n\t\t\t\tif (n <= l)\n\t\t\t\t{\n\t\t\t\t\treturn 1 + bar(h - 1, n, 'R');\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\treturn (1L << h) + bar(h - 1, n - l, 'L');\n\t\t\t\t}\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tif (n <= l)\n\t\t\t\t{\n\t\t\t\t\treturn (1L << h) + bar(h - 1, n, 'R');\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\treturn 1 + bar(h - 1, n - l, 'L');\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n\n", "lang_cluster": "C#", "tags": ["math", "implementation", "trees"], "code_uid": "d5b11a3f811a99efc2ef6fb776d10709", "src_uid": "3dc25ccb394e2d5ceddc6b3a26cb5781", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeff#region imports\nusing System;\nusing System.Collections.Generic;\nusing System.ComponentModel;\nusing System.Data;\nusing System.Diagnostics;\nusing System.Globalization;\nusing System.IO;\nusing System.Linq;\nusing System.Numerics;\nusing System.Runtime.CompilerServices;\nusing System.Runtime.InteropServices;\n\n#endregion\n\nnamespace CodeForces\n{\n class Problem\n {\n const bool IsContest = true;\n\n private void Solve()\n {\n var h = _.NextInt();\n\n var n = Convert.ToString(_.NextLong() - 1, 2).PadLeft(h, '0').ToCharArray().Select(x => x - '0').ToArray();\n\n long nVisited = 0;\n var nextDir = 0;\n const long long1 = 1;\n for (var level = 0; level < h; level++)\n {\n var dir = n[level];\n if (dir != nextDir)\n {\n nVisited += long1 << (h - level);\n }\n else\n {\n nVisited += 1;\n }\n nextDir = (dir + 1) % 2;\n }\n _.WriteLine(nVisited);\n }\n\n\n\n\n #region shit\n private readonly InOut _ = new InOut(IsContest);\n static void Main(string[] args)\n {\n var p = new Problem();\n p.Solve();\n p._.Close();\n }\n }\n class InOut\n {\n private const string InputFile = \"input.txt\";\n private const string OutputFile = \"output.txt\";\n public StreamWriter Cout { get; private set; }\n public StreamReader Cin { get; private set; }\n private void SetConsoleIo()\n {\n Cin = new StreamReader(new BufferedStream(Console.OpenStandardInput()));\n Cout = new StreamWriter(new BufferedStream(Console.OpenStandardOutput()));\n }\n private void SetFileIo(string inputFile, string outputFile) { Cin = new StreamReader(inputFile); Cout = new StreamWriter(outputFile); }\n public InOut() { SetConsoleIo(); }\n public InOut(string inputFile, string outputFile) { SetFileIo(inputFile, outputFile); }\n public InOut(bool isContest) { if (isContest) SetConsoleIo(); else SetFileIo(InputFile, OutputFile); }\n public void WriteLine(object x) { Cout.WriteLine(x); }\n public void Close() { Cin.Close(); Cout.Close(); }\n public void WriteLine(string format, params object[] args) { Cout.WriteLine(format, args); }\n private int _pos;\n private string[] _tokens;\n\n private string[] NextStringArray() { return Cin.ReadLine().Split(\" \\t\".ToCharArray(), StringSplitOptions.RemoveEmptyEntries); }\n public string NextToken()\n {\n while (_tokens == null || _pos == _tokens.Length)\n {\n // ReSharper disable once PossibleNullReferenceException\n _tokens = NextStringArray();\n _pos = 0;\n }\n return _tokens[_pos++];\n }\n public int NextInt() { return int.Parse(NextToken()); }\n public long NextLong() { return long.Parse(NextToken()); }\n public double NextDouble() { return double.Parse(NextToken(), CultureInfo.InvariantCulture); }\n public int[] NextIntArray() { return NextStringArray().Select(int.Parse).ToArray(); }\n public byte[] NextByteArray() { return NextStringArray().Select(byte.Parse).ToArray(); }\n public long[] NextLongArray() { return NextStringArray().Select(long.Parse).ToArray(); }\n #endregion\n }\n}", "lang_cluster": "C#", "tags": ["math", "implementation", "trees"], "code_uid": "2331fce5116aec9095c35191cc1ac6da", "src_uid": "3dc25ccb394e2d5ceddc6b3a26cb5781", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Linq;\nusing System.Collections.Generic;\nusing Debug = System.Diagnostics.Debug;\nusing StringBuilder = System.Text.StringBuilder;\n//using System.Numerics;\nnamespace Program\n{\n public class Solver\n {\n public void Solve()\n {\n var h = sc.Integer();\n var n = sc.Long();\n long l = 1;\n long r = 1L << h;\n long count = 0;\n var goL = true;\n for (int i = 0; i < h; i++)\n {\n var m = (l + r) >> 1;\n //Debug.WriteLine(m);\n count++;\n if (n <= m)\n {\n if (!goL)\n {\n count += (1L << (h - i)) - 1;\n }\n goL = false;\n r = m - 1;\n }\n else\n {\n if (goL)\n {\n count += (1L << (h - i)) - 1;\n }\n goL = true;\n l = m + 1;\n }\n }\n IO.Printer.Out.WriteLine(count);\n\n }\n\n\n internal IO.StreamScanner sc = new IO.StreamScanner(Console.OpenStandardInput());\n static T[] Enumerate(int n, Func f) { var a = new T[n]; for (int i = 0; i < n; ++i) a[i] = f(); return a; }\n static T[] Enumerate(int n, Func f) { var a = new T[n]; for (int i = 0; i < n; ++i) a[i] = f(i); return a; }\n\n }\n\n}\n\n#region Ex\nnamespace Program.IO\n{\n using System.IO;\n using System.Linq;\n public class Printer : StreamWriter\n {\n static Printer()\n {\n Out = new Printer(Console.OpenStandardOutput()) { AutoFlush = false };\n }\n public static Printer Out { get; set; }\n public override IFormatProvider FormatProvider { get { return System.Globalization.CultureInfo.InvariantCulture; } }\n public Printer(System.IO.Stream stream) : base(stream, new System.Text.UTF8Encoding(false, true)) { }\n public void Write(string format, IEnumerable source) { base.Write(format, source.OfType().ToArray()); }\n public void WriteLine(string format, IEnumerable source) { base.WriteLine(format, source.OfType().ToArray()); }\n }\n public class StreamScanner\n {\n public StreamScanner(Stream stream) { str = stream; }\n private readonly Stream str;\n private readonly byte[] buf = new byte[1024];\n private int len, ptr;\n public bool isEof = false;\n public bool IsEndOfStream { get { return isEof; } }\n private byte read()\n {\n if (isEof) return 0;\n if (ptr >= len) { ptr = 0; if ((len = str.Read(buf, 0, 1024)) <= 0) { isEof = true; return 0; } }\n return buf[ptr++];\n }\n public char Char() { byte b = 0; do b = read(); while (b < 33 || 126 < b); return (char)b; }\n public char[] Char(int n) { var a = new char[n]; for (int i = 0; i < n; i++) a[i] = Char(); return a; }\n public string Scan()\n {\n var sb = new StringBuilder();\n for (var b = Char(); b >= 33 && b <= 126; b = (char)read())\n sb.Append(b);\n return sb.ToString();\n }\n public long Long()\n {\n if (isEof) return long.MinValue;\n long ret = 0; byte b = 0; var ng = false;\n do b = read();\n while (b != '-' && (b < '0' || '9' < b));\n if (b == '-') { ng = true; b = read(); }\n for (; true; b = read())\n {\n if (b < '0' || '9' < b)\n return ng ? -ret : ret;\n else ret = ret * 10 + b - '0';\n }\n }\n public int Integer() { return (isEof) ? int.MinValue : (int)Long(); }\n public double Double() { return double.Parse(Scan(), System.Globalization.CultureInfo.InvariantCulture); }\n private T[] enumerate(int n, Func f)\n {\n var a = new T[n];\n for (int i = 0; i < n; ++i) a[i] = f();\n return a;\n }\n\n public string[] Scan(int n) { return enumerate(n, Scan); }\n public double[] Double(int n) { return enumerate(n, Double); }\n public int[] Integer(int n) { return enumerate(n, Integer); }\n public long[] Long(int n) { return enumerate(n, Long); }\n public void Flush() { str.Flush(); }\n\n }\n}\nstatic class Ex\n{\n static public string AsString(this IEnumerable ie) { return new string(System.Linq.Enumerable.ToArray(ie)); }\n static public string AsJoinedString(this IEnumerable ie, string st = \" \") { return string.Join(st, ie); }\n static public void Main()\n {\n var solver = new Program.Solver();\n solver.Solve();\n Program.IO.Printer.Out.Flush();\n }\n}\n#endregion\n", "lang_cluster": "C#", "tags": ["math", "implementation", "trees"], "code_uid": "ed0599d58e9a45d85888693434fdb5b1", "src_uid": "3dc25ccb394e2d5ceddc6b3a26cb5781", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Globalization;\nusing System.IO;\nusing System.Linq;\nusing System.Text;\nusing System.Threading;\n\n// (\u3065\u00b0\u03c9\u00b0)\u3065\uff90\u2605\u309c\u30fb\u3002\u3002\u30fb\u309c\u309c\u30fb\u3002\u3002\u30fb\u309c\u2606\u309c\u30fb\u3002\u3002\u30fb\u309c\u309c\u30fb\u3002\u3002\u30fb\u309c\npublic class Solver\n{\n public void Solve()\n {\n int h = ReadInt();\n long n = ReadLong() - 1;\n bool left = true;\n long ans = h;\n for (; h >= 0; h--)\n if ((n >> h - 1 & 1) == 0)\n {\n if (!left)\n ans += (1L << h) - 1;\n left = false;\n }\n else\n {\n if (left)\n ans += (1L << h) - 1;\n left = true;\n }\n Write(ans);\n }\n\n #region Main\n\n protected static TextReader reader;\n protected static TextWriter writer;\n\n static void Main()\n {\n#if DEBUG\n reader = new StreamReader(\"..\\\\..\\\\input.txt\");\n writer = Console.Out;\n //writer = new StreamWriter(\"..\\\\..\\\\output.txt\");\n#else\n reader = new StreamReader(Console.OpenStandardInput());\n writer = new StreamWriter(Console.OpenStandardOutput());\n //reader = new StreamReader(\"game.in\");\n //writer = new StreamWriter(\"game.out\");\n#endif\n try\n {\n var thread = new Thread(new Solver().Solve, 1024 * 1024 * 256);\n thread.Start();\n thread.Join();\n// object result = new Solver().Solve();\n// if (result != null)\n// writer.WriteLine(result);\n }\n catch (Exception ex)\n {\n#if DEBUG\n Console.WriteLine(ex);\n#else\n Console.WriteLine(ex);\n throw;\n#endif\n }\n reader.Close();\n writer.Close();\n }\n\n #endregion\n\n #region Read / Write\n\n private static Queue currentLineTokens = new Queue();\n\n private static string[] ReadAndSplitLine()\n {\n return reader.ReadLine().Split(new[] { ' ', '\\t' }, StringSplitOptions.RemoveEmptyEntries);\n }\n\n public static string ReadToken()\n {\n while (currentLineTokens.Count == 0)\n currentLineTokens = new Queue(ReadAndSplitLine());\n return currentLineTokens.Dequeue();\n }\n\n public static int ReadInt()\n {\n return int.Parse(ReadToken());\n }\n\n public static long ReadLong()\n {\n return long.Parse(ReadToken());\n }\n\n public static double ReadDouble()\n {\n return double.Parse(ReadToken(), CultureInfo.InvariantCulture);\n }\n\n public static int[] ReadIntArray()\n {\n return ReadAndSplitLine().Select(int.Parse).ToArray();\n }\n\n public static long[] ReadLongArray()\n {\n return ReadAndSplitLine().Select(long.Parse).ToArray();\n }\n\n public static double[] ReadDoubleArray()\n {\n return ReadAndSplitLine().Select(s => double.Parse(s, CultureInfo.InvariantCulture)).ToArray();\n }\n\n public static int[][] ReadIntMatrix(int numberOfRows)\n {\n int[][] matrix = new int[numberOfRows][];\n for (int i = 0; i < numberOfRows; i++)\n matrix[i] = ReadIntArray();\n return matrix;\n }\n\n public static int[][] ReadAndTransposeIntMatrix(int numberOfRows)\n {\n int[][] matrix = ReadIntMatrix(numberOfRows);\n int[][] ret = new int[matrix[0].Length][];\n for (int i = 0; i < ret.Length; i++)\n {\n ret[i] = new int[numberOfRows];\n for (int j = 0; j < numberOfRows; j++)\n ret[i][j] = matrix[j][i];\n }\n return ret;\n }\n\n public static string[] ReadLines(int quantity)\n {\n string[] lines = new string[quantity];\n for (int i = 0; i < quantity; i++)\n lines[i] = reader.ReadLine().Trim();\n return lines;\n }\n\n public static void WriteArray(IEnumerable array)\n {\n writer.WriteLine(string.Join(\" \", array));\n }\n\n public static void Write(params object[] array)\n {\n WriteArray(array);\n }\n\n public static void WriteLines(IEnumerable array)\n {\n foreach (var a in array)\n writer.WriteLine(a);\n }\n\n #endregion\n}", "lang_cluster": "C#", "tags": ["math", "implementation", "trees"], "code_uid": "138324a1198bbb4eb881188be4cbd1fa", "src_uid": "3dc25ccb394e2d5ceddc6b3a26cb5781", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\n\nnamespace ConsoleApplication1\n{\n class Program\n {\n static void Main()\n {\n long[] arr = Console.ReadLine().Split(' ').Select(Int64.Parse).ToArray();\n long lvl = arr[0] + 1;\n long n = arr[1], total = 1, totallists = 0 ;\n double lists = Math.Pow(2, arr[0])/ 2, max = Math.Pow(2, arr[0]), min = 1;\n bool direction = true;\n for (int i = 1; i < lvl; i++) {\n totallists += (long)Math.Pow(2, i);\n }\n while (totallists != 0){\n if (n <= lists && direction == false)\n {\n total += totallists / 2 + 1;\n totallists = (totallists/2) - 1;\n max = lists;\n lists = Math.Floor((max + min)/2);\n }\n else if (n <= lists && direction == true) {\n total++;\n totallists = (totallists/2) - 1;\n direction = !direction;\n max = lists;\n lists = Math.Floor((max + min) / 2);\n }\n else if (n > lists && direction == true)\n {\n total += totallists / 2 + 1;\n totallists = (totallists/2) - 1;\n min = lists;\n lists = Math.Floor((max + min) / 2);\n }\n else if (n > lists && direction == false) {\n total++;\n totallists = (totallists/2) - 1;\n direction = !direction;\n min = lists;\n lists = Math.Floor((max + min) / 2);\n }\n\n }\n Console.WriteLine(total - 1);\n //Console.ReadKey();\n }\n }\n}", "lang_cluster": "C#", "tags": ["math", "implementation", "trees"], "code_uid": "bca76da7d8c201c0e114334a4081bf26", "src_uid": "3dc25ccb394e2d5ceddc6b3a26cb5781", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nnamespace ConsoleApplication4\n{\n class Program\n {\n \n \n static void Main(string[] args)\n {\n UInt64 n = UInt64.Parse(Console.ReadLine());\n\n if (n % 2 == 0)\n {\n Console.WriteLine(\"white\");\n Console.WriteLine(\"1 2\");\n }\n else\n Console.WriteLine(\"black\");\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "constructive algorithms", "games"], "code_uid": "6931c44c32358668cf4147b052b5e878", "src_uid": "52e07d176aa1d370788f94ee2e61df93", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\n\nnamespace CSharp\n{\n class _493D\n {\n public static void Main()\n {\n int n = int.Parse(Console.ReadLine());\n\n if (n % 2 == 0)\n {\n Console.WriteLine(\"white\");\n Console.WriteLine(\"1 2\");\n }\n else\n {\n Console.WriteLine(\"black\");\n }\n }\n }\n}", "lang_cluster": "C#", "tags": ["math", "constructive algorithms", "games"], "code_uid": "b3585f144975b255e930c789b3f494bf", "src_uid": "52e07d176aa1d370788f94ee2e61df93", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\n\nnamespace CodeForces\n{\n class Program\n {\n const int MOD = 1000000007;\n static long[] fac = new long[1000010];\n static long mod_pow(long num, long pow, long mod)\n {\n long ret = 1;\n while (pow>0)\n { \n if (pow%2>0)\n {\n ret = (ret*num)%mod;\n }\n pow>>=1;\n num = (num*num)%mod;\n }\n return ret;\n }\n static void precalc()\n {\n fac[0] = 1;\n for (int i = 1; i <= 1000000; i++)\n {\n fac[i] = i * fac[i - 1];\n fac[i] %= MOD;\n }\n }\n static long mod_inv(long num, long mod)\n {\n return mod_pow(num, mod-2, mod);\n }\n // (A/B) mod M = (A mod M) * mod_inv(B mod M, M)\n static long C(int n, int k)\n {\n long up = fac[n];\n long down = fac[k] * fac[n - k] % MOD;\n return up * mod_inv(down, MOD);\n }\n static long solve(int a, int b, int i, int n)\n {\n if ((i - a * n) % (b-a) > 0) return 0;\n int y = (i - a * n) / (b-a);\n if (y < 0) return 0;\n if (y > n) return 0;\n return C(n, y);\n }\n static void Main(string[] args)\n {\n precalc();\n int a, b, n;\n string[] s = Console.ReadLine().Split();\n a = int.Parse(s[0]);\n b = int.Parse(s[1]);\n n = int.Parse(s[2]);\n long ans=0;\n for (int i = 1; i <= 9*n; i++)\n {\n bool good = true;\n int j = i;\n int numofc = 0;\n while (j > 0)\n {\n numofc++;\n int last = j % 10;\n j /= 10;\n if (last != a && last != b) {good = false; break;}\n }\n if (!good) continue;\n //Console.WriteLine(i.ToString());\n ans += solve(a, b, i,n);\n ans %= MOD;\n }\n Console.WriteLine(ans.ToString());\n Console.ReadLine();\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "combinatorics"], "code_uid": "cc26f4d46d8e8491c2f91f088d0e1b66", "src_uid": "d3e3da5b6ba37c8ac5f22b18c140ce81", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Diagnostics;\nusing System.Globalization;\nusing System.IO;\nusing System.Linq;\n\nnamespace Codeforces\n{\n internal static class Program\n {\n private const string test = \"C2\";\n \n private static void Solve()\n {\n int a, b, n;\n Read(out a, out b, out n);\n var mod = 1000000007;\n var fact = new long[n+1];\n fact[0] = 1;\n for (int i = 1; i <= n; i++)\n {\n fact[i] = fact[i-1]*i;\n fact[i] %= mod;\n }\n var res = 0L;\n for (int aCount= 0; aCount <= n; aCount++)\n {\n var bCount = n - aCount;\n if (IsGood(aCount*a + bCount*b, a, b))\n {\n var denominator = fact[aCount]*fact[bCount];\n denominator %= mod;\n var temp = fact[n]* BinPow(denominator, mod-2,mod);\n var tempint = (int)(temp%mod);\n res += tempint;\n res %= mod;\n }\n }\n WriteLine(res);\n }\n\n private static long BinPow(long a, int pow, int mod)\n {\n if (pow == 0)\n return 1;\n\n if (pow%2 == 1)\n return (BinPow(a, pow - 1, mod)*a) %mod;\n \n var b = BinPow(a, pow/2, mod);\n b %= mod;\n var res = b*b;\n res %= mod;\n return res;\n }\n\n private static bool IsGood(int n, int a, int b)\n {\n var res = (n!=0);\n while (n > 0)\n {\n var end = n%10;\n n /= 10;\n res &= (end == a || end == b);\n }\n return res;\n }\n\n private static void Main()\n {\n if (Debugger.IsAttached)\n {\n Console.SetIn(new StreamReader(String.Format(@\"..\\..\\..\\..\\Tests\\{0}.in\", test)));\n }\n\n Solve();\n\n if (Debugger.IsAttached)\n {\n Console.In.Close();\n Console.SetIn(new StreamReader(Console.OpenStandardInput()));\n Console.ReadLine();\n }\n }\n\n #region Reader\n\n private static string Read()\n {\n return Console.ReadLine();\n }\n \n private static void Read(out T a1, out T a2)\n {\n var input = ReadArray();\n a1 = (T)Convert.ChangeType(input[0], typeof(T));\n a2 = (T)Convert.ChangeType(input[1], typeof(T));\n }\n\n private static void Read(out T a1, out T a2, out T a3)\n {\n var input = ReadArray();\n a1 = (T)Convert.ChangeType(input[0], typeof(T));\n a2 = (T)Convert.ChangeType(input[1], typeof(T));\n a3 = (T)Convert.ChangeType(input[2], typeof(T));\n }\n\n private static void Read(out T a1, out T a2, out T a3, out T a4)\n {\n var input = ReadArray();\n a1 = (T)Convert.ChangeType(input[0], typeof(T));\n a2 = (T)Convert.ChangeType(input[1], typeof(T));\n a3 = (T)Convert.ChangeType(input[2], typeof(T));\n a4 = (T)Convert.ChangeType(input[3], typeof(T));\n }\n\n private static int ReadInt()\n {\n return Int32.Parse(Read());\n }\n\n private static long ReadLong()\n {\n return long.Parse(Read());\n }\n\n private static double ReadDouble()\n {\n return double.Parse(Read(), CultureInfo.InvariantCulture);\n }\n\n private static T Read()\n {\n return (T)Convert.ChangeType(Read(), typeof(T));\n }\n\n private static string[] ReadArray()\n {\n var readLine = Console.ReadLine();\n if (readLine != null) \n return readLine.Split(' ');\n\n throw new ArgumentException();\n }\n\n private static List ReadIntArray()\n {\n return ReadArray().Select(Int32.Parse).ToList();\n }\n\n private static List ReadLongArray()\n {\n return ReadArray().Select(long.Parse).ToList();\n }\n\n private static List ReadDoubleArray()\n {\n return ReadArray().Select(d => double.Parse(d, CultureInfo.InvariantCulture)).ToList();\n }\n\n private static List ReadArray()\n {\n return ReadArray().Select(x => (T) Convert.ChangeType(x, typeof (T))).ToList();\n }\n\n private static void WriteLine(double value)\n {\n Console.WriteLine(value.ToString(CultureInfo.InvariantCulture));\n }\n\n private static void WriteLine(double value, string stringFormat)\n {\n Console.WriteLine(value.ToString(stringFormat, CultureInfo.InvariantCulture));\n }\n\n private static void WriteLine(T value)\n {\n Console.WriteLine(value);\n }\n \n private static void Write(double value)\n {\n Console.Write(value.ToString(CultureInfo.InvariantCulture));\n }\n\n private static void Write(double value, string stringFormat)\n {\n Console.Write(value.ToString(stringFormat, CultureInfo.InvariantCulture));\n }\n\n private static void Write(T value)\n {\n Console.Write(value);\n }\n\n #endregion\n }\n}", "lang_cluster": "C#", "tags": ["brute force", "combinatorics"], "code_uid": "df255e5feeb4f0f655d19723fb99602a", "src_uid": "d3e3da5b6ba37c8ac5f22b18c140ce81", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\n\nnamespace ProgrammingContest.Codeforces.Round53\n{\n class C\n {\n const long mod = 1000000007L;\n static void ExtGcd(long a, long b, out long x, out long y, out long c)\n {\n if (b == 0)\n {\n x = 1;\n y = 0;\n c = a;\n return;\n }\n long q = a / b;\n long r = a % b;\n long x1, y1;\n ExtGcd(b, r, out x1, out y1, out c);\n x = y1;\n y = x1 - y1 * q;\n }\n\n static long PowMod(long x, long y, long m)\n {\n long res = 1;\n for (; y != 0; y >>= 1, x = x * x % m)\n if ((y & 1) == 1)\n res = res * x % m;\n return res;\n }\n\n static long comb(long n, long r)\n {\n const bool debug = true;\n checked\n {\n long res = 1;\n for (long i = 0; i < r; i++)\n {\n long x, y, c;\n if (debug)\n {\n x = PowMod(i + 1, mod - 2, mod);\n }\n else\n {\n ExtGcd(i + 1, mod, out x, out y, out c);\n }\n ExtGcd(i + 1, mod, out x, out y, out c);\n x = (x % mod + mod) % mod;\n res = res * (n - i) % mod * x % mod;\n }\n return res;\n }\n }\n\n public static void Main()\n {\n int n = int.Parse(Console.ReadLine());\n long x = comb(2 * (n - 1) + 1, n);\n Console.WriteLine((x - n + x + 1000000007L) % 1000000007L);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "combinatorics"], "code_uid": "774b970b0d46ac4ce7b8060f13c276b5", "src_uid": "13a9ffe5acaa79d97df88a069fc520b9", "difficulty": 1900.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\n\nnamespace ProgrammingContest.Codeforces.Round53\n{\n class C\n {\n static void ExtGcd(long a, long b, out long x, out long y, out long c)\n {\n if (b == 0)\n {\n x = 1;\n y = 0;\n c = a;\n return;\n }\n long q = a / b;\n long r = a % b;\n long x1, y1;\n ExtGcd(b, r, out x1, out y1, out c);\n x = y1;\n y = x1 - y1 * q;\n }\n\n const long mod = 1000000007L;\n static long inv(long x, long v)\n {\n if (v % 2 == 0) { long y = inv(x, v / 2); return y * y * 2 % mod; }\n return inv(x, v - 1) * x % mod;\n }\n\n static long comb(long n, long r)\n {\n checked\n {\n long res = 1;\n for (long i = 0; i < r; i++)\n {\n long x, y, c;\n ExtGcd(i + 1, mod, out x, out y, out c);\n x = (x % mod + mod) % mod;\n //res *= n - i;\n //while (res % (i + 1) != 0) res += 1000000007L;\n //if (res * (n - i) % (i + 1) != 0) throw new Exception();\n res = res * (n - i) % mod * x % mod;\n }\n return res;\n }\n#if false\n long[,] x = new long[2, n + 1];\n int j = -1, k = -1;\n for (int i = 1; i <= n; i++)\n {\n j = i % 2; k = j ^ 1;\n x[k, i] = x[k, 0] = 1;\n for (int m = 1; m < i; m++)\n x[k, m] = (x[j, m - 1] + x[j, m]) % 1000000007L;\n }\n return x[k, r];\n#endif\n }\n\n public static void Main()\n {\n int n = int.Parse(Console.ReadLine());\n long x = comb(2 * (n - 1) + 1, n);\n Console.WriteLine((x - n + x + 1000000007L) % 1000000007L);\n#if false\n for (int n = 1; n < 100; n++)\n {\n long[] dp = new long[n];\n for (int i = 0; i < n; i++) dp[i] = 1;\n for (int i = 0; i < n; i++)\n for (int j = 1; j < n; j++)\n dp[j] += dp[j - 1];\n //Console.WriteLine(dp[n - 1] - n + dp[n - 1]);\n Console.WriteLine(dp[n - 1]);\n Console.WriteLine(comb(2 * n + 1, n + 1));\n }\n#endif\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "combinatorics"], "code_uid": "1be7c14d400e11247d09354f083e2f3b", "src_uid": "13a9ffe5acaa79d97df88a069fc520b9", "difficulty": 1900.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections;\nusing System.Collections.Generic;\nusing System.Collections.Specialized;\nusing System.Diagnostics;\nusing System.Globalization;\nusing System.IO;\nusing System.Text;\nusing System.Linq;\n\nnamespace Codeforces\n{\n internal class Program\n {\n private const string TEST = \"B1\";\n \n private static void Solve()\n {\n var input = ReadIntArray();\n var w = input[0];\n var h = input[1];\n var res = 0L;\n for (int i = 0; i < w; i++)\n {\n for (int j = 0; j < h; j++)\n {\n var hMax = Math.Min(j, h - j);\n res += Math.Max(0L, (w - i)/2)*Math.Max(0L, hMax);\n }\n }\n WriteLine(res);\n }\n \n private static void Main()\n {\n if (Debugger.IsAttached)\n {\n Console.SetIn(new StreamReader(String.Format(@\"..\\..\\..\\..\\Tests\\{0}.in\", TEST)));\n }\n\n Solve();\n\n if (Debugger.IsAttached)\n {\n Console.In.Close();\n Console.SetIn(new StreamReader(Console.OpenStandardInput()));\n Console.ReadLine();\n }\n }\n\n #region Reader\n\n private static string Read()\n {\n return Console.ReadLine();\n }\n\n private static string[] ReadArray()\n {\n return Console.ReadLine().Split(' ');\n }\n\n private static List ReadIntArray()\n {\n var input = Console.ReadLine().Split(' ').Select(Int32.Parse).ToList();\n return input;\n }\n\n private static int ReadInt()\n {\n return Int32.Parse(Console.ReadLine());\n }\n\n private static long ReadLong()\n {\n return long.Parse(Console.ReadLine());\n }\n\n private static int ReadNextInt(string[] input, int index)\n {\n return Int32.Parse(input[index]);\n }\n\n private static double ReadDouble()\n {\n return double.Parse(Console.ReadLine(), CultureInfo.InvariantCulture);\n }\n\n private static List ReadDoubleArray()\n {\n return Console.ReadLine().Split(' ').Select(d => double.Parse(d, CultureInfo.InvariantCulture)).ToList();\n }\n\n private static void WriteLine(object value)\n {\n Console.WriteLine(value);\n }\n\n private static void Write(object value)\n {\n Console.Write(value);\n }\n\n #endregion\n }\n}", "lang_cluster": "C#", "tags": ["brute force", "math"], "code_uid": "36d74d1f5e26245a72a1aa5c77b2bb5c", "src_uid": "42454dcf7d073bf12030367eb094eb8c", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.IO;\nusing System.Text;\n\nnamespace Counting_Rhombi\n{\n internal class Program\n {\n private static readonly StreamReader reader = new StreamReader(Console.OpenStandardInput(1024*10), Encoding.ASCII, false, 1024*10);\n private static readonly StreamWriter writer = new StreamWriter(Console.OpenStandardOutput(1024*10), Encoding.ASCII, 1024*10);\n\n private static void Main(string[] args)\n {\n int w = Next();\n int h = Next();\n\n long sum = 0;\n long cY = 0;\n for (int y = 1; y < h; y++)\n {\n cY += Math.Min(y, h - y);\n }\n\n for (int x = 1; x < w; x++)\n {\n int cX = Math.Min(x, w - x);\n sum += cY*cX;\n }\n\n writer.WriteLine(sum);\n writer.Flush();\n }\n\n private static int Next()\n {\n int c;\n int res = 0;\n do\n {\n c = reader.Read();\n if (c == -1)\n return res;\n } while (c < '0' || c > '9');\n res = c - '0';\n while (true)\n {\n c = reader.Read();\n if (c < '0' || c > '9')\n return res;\n res *= 10;\n res += c - '0';\n }\n }\n }\n}", "lang_cluster": "C#", "tags": ["brute force", "math"], "code_uid": "ffb23004062eae3b0beb9a810c022e46", "src_uid": "42454dcf7d073bf12030367eb094eb8c", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Globalization;\nusing System.IO;\nusing System.Linq;\nusing System.Text;\nusing System.Threading;\n\n// (\u3065\u00b0\u03c9\u00b0)\u3065\uff90e\u2605\u309c\u30fb\u3002\u3002\u30fb\u309c\u309c\u30fb\u3002\u3002\u30fb\u309c\u2606\u309c\u30fb\u3002\u3002\u30fb\u309c\u309c\u30fb\u3002\u3002\u30fb\u309c\npublic class Solver\n{\n string[] a = { \"Ac\",\"Ag\",\"Al\",\"Am\",\"Ar\",\"As\",\"At\",\"Au\",\"B\",\"Ba\",\"Be\",\"Bh\",\"Bi\",\"Bk\",\"Br\",\"C\",\"Ca\",\"Cd\",\"Ce\",\"Cf\",\"Cl\",\"Cm\",\"Cn\",\"Co\",\"Cr\",\"Cs\",\"Cu\",\"Db\",\"Ds\",\"Dy\",\"Er\",\"Es\",\"Eu\",\"F\",\"Fe\",\"Fl\",\"Fm\",\"Fr\",\"Ga\",\"Gd\",\"Ge\",\"H\",\"He\",\"Hf\",\"Hg\",\"Ho\",\"Hs\",\"I\",\"In\",\"Ir\",\"K\",\"Kr\",\"La\",\"Li\",\"Lr\",\"Lu\",\"Lv\",\"Mc\",\"Md\",\"Mg\",\"Mn\",\"Mo\",\"Mt\",\"N\",\"Na\",\"Nb\",\"Nd\",\"Ne\",\"Nh\",\"Ni\",\"No\",\"Np\",\"O\",\"Og\",\"Os\",\"P\",\"Pa\",\"Pb\",\"Pd\",\"Pm\",\"Po\",\"Pr\",\"Pt\",\"Pu\",\"Ra\",\"Rb\",\"Re\",\"Rf\",\"Rg\",\"Rh\",\"Rn\",\"Ru\",\"S\",\"Sb\",\"Sc\",\"Se\",\"Sg\",\"Si\",\"Sm\",\"Sn\",\"Sr\",\"Ta\",\"Tb\",\"Tc\",\"Te\",\"Th\",\"Ti\",\"Tl\",\"Tm\",\"Ts\",\"U\",\"V\",\"W\",\"Xe\",\"Y\",\"Yb\",\"Zn\",\"Zr\"};\n Dictionary> d;\n\n bool Fun(int p, string s)\n {\n if (p >= s.Length)\n return true;\n foreach (string v in d[s[p]])\n if (p + v.Length <= s.Length && s.Substring(p, v.Length) == v && Fun(p + v.Length, s))\n return true;\n return false;\n }\n\n public void Solve()\n {\n d = new Dictionary>();\n for (char i = 'A'; i <= 'Z'; i++)\n d[i] = new List();\n foreach (string aa in a)\n {\n d[aa[0]].Add(aa.ToUpper());\n }\n\n string s = ReadToken();\n Write(Fun(0, s) ? \"YES\" : \"NO\");\n }\n\n #region Main\n\n protected static TextReader reader;\n protected static TextWriter writer;\n static void Main()\n {\n#if DEBUG\n reader = new StreamReader(\"..\\\\..\\\\input.txt\");\n //reader = new StreamReader(Console.OpenStandardInput());\n writer = Console.Out;\n //writer = new StreamWriter(\"..\\\\..\\\\output.txt\");\n#else\n reader = new StreamReader(Console.OpenStandardInput());\n writer = new StreamWriter(Console.OpenStandardOutput());\n //reader = new StreamReader(\"input.txt\");\n //writer = new StreamWriter(\"output.txt\");\n#endif\n try\n {\n new Solver().Solve();\n //var thread = new Thread(new Solver().Solve, 1024 * 1024 * 128);\n //thread.Start();\n //thread.Join();\n }\n catch (Exception ex)\n {\n#if DEBUG\n Console.WriteLine(ex);\n#else\n throw;\n#endif\n }\n reader.Close();\n writer.Close();\n }\n\n #endregion\n\n #region Read / Write\n private static Queue currentLineTokens = new Queue();\n private static string[] ReadAndSplitLine() { return reader.ReadLine().Split(new[] { ' ', '\\t', }, StringSplitOptions.RemoveEmptyEntries); }\n public static string ReadToken() { while (currentLineTokens.Count == 0)currentLineTokens = new Queue(ReadAndSplitLine()); return currentLineTokens.Dequeue(); }\n public static int ReadInt() { return int.Parse(ReadToken()); }\n public static long ReadLong() { return long.Parse(ReadToken()); }\n public static double ReadDouble() { return double.Parse(ReadToken(), CultureInfo.InvariantCulture); }\n public static int[] ReadIntArray() { return ReadAndSplitLine().Select(int.Parse).ToArray(); }\n public static long[] ReadLongArray() { return ReadAndSplitLine().Select(long.Parse).ToArray(); }\n public static double[] ReadDoubleArray() { return ReadAndSplitLine().Select(s => double.Parse(s, CultureInfo.InvariantCulture)).ToArray(); }\n public static int[][] ReadIntMatrix(int numberOfRows) { int[][] matrix = new int[numberOfRows][]; for (int i = 0; i < numberOfRows; i++)matrix[i] = ReadIntArray(); return matrix; }\n public static int[][] ReadAndTransposeIntMatrix(int numberOfRows)\n {\n int[][] matrix = ReadIntMatrix(numberOfRows); int[][] ret = new int[matrix[0].Length][];\n for (int i = 0; i < ret.Length; i++) { ret[i] = new int[numberOfRows]; for (int j = 0; j < numberOfRows; j++)ret[i][j] = matrix[j][i]; } return ret;\n }\n public static string[] ReadLines(int quantity) { string[] lines = new string[quantity]; for (int i = 0; i < quantity; i++)lines[i] = reader.ReadLine().Trim(); return lines; }\n public static void WriteArray(IEnumerable array) { writer.WriteLine(string.Join(\" \", array)); }\n public static void Write(params object[] array) { WriteArray(array); }\n public static void WriteLines(IEnumerable array) { foreach (var a in array)writer.WriteLine(a); }\n private class SDictionary : Dictionary\n {\n public new TValue this[TKey key]\n {\n get { return ContainsKey(key) ? base[key] : default(TValue); }\n set { base[key] = value; }\n }\n }\n private static T[] Init(int size) where T : new() { var ret = new T[size]; for (int i = 0; i < size; i++)ret[i] = new T(); return ret; }\n #endregion\n}", "lang_cluster": "C#", "tags": ["brute force", "strings", "dp"], "code_uid": "26ef94a289f183bd33d110ea85ce6f40", "src_uid": "d0ad35798119f98320967127c43ae88d", "difficulty": null, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Linq;\n\nnamespace Browsers\n{\n class Program\n {\n static void Main(string[] args)\n {\n var numbers = Console.ReadLine().Split().Select(int.Parse).ToArray();\n var types = Console.ReadLine().Split().Select(int.Parse).ToArray();\n var n = numbers[0];\n var k = numbers[1];\n\n Console.WriteLine(Score(types, k));\n }\n\n private static int Score(int[] cites, int k)\n {\n var highest = 0;\n for (var i = 0; i < cites.Length; i++)\n {\n var score = 0;\n for (var j = 0; j < cites.Length; j++)\n {\n if ((j - i) % k == 0) continue;\n score += cites[j];\n }\n\n if (Math.Abs(score) > highest)\n {\n highest = Math.Abs(score);\n }\n }\n\n return highest;\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "4674191d701f7e49cdba68fdc7ce59de", "src_uid": "6119258322e06fa6146e592c63313df3", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "// Problem: 1100A - Roman and Browser\n// Author: Gusztav Szmolik\n\nusing System;\n\nclass RomanAndBrowser\n {\n static int Main ()\n {\n string[] words = ReadSplitLine (2);\n if (words == null)\n return -1;\n byte n;\n if (!Byte.TryParse (words[0], out n))\n return -1;\n if (n < 3 || n > 100)\n return -1;\n byte k;\n if (!Byte.TryParse (words[1], out k))\n return -1;\n if (k < 2 || k >= n)\n return -1;\n words = ReadSplitLine (n);\n if (words == null)\n return -1;\n sbyte[] tabTypes = new sbyte[n];\n for (byte i = 0; i < n; i++)\n {\n sbyte tti;\n if (!SByte.TryParse (words[i], out tti))\n return -1;\n if (tti != -1 && tti != 1)\n return -1;\n tabTypes[i] = tti;\n }\n byte ans = 0;\n for (byte i = 0; i < n; i++)\n {\n sbyte sum = 0;\n byte r = Convert.ToByte (i%k);\n for (byte j = 0; j < n; j++)\n if (j%k != r)\n sum += tabTypes[j];\n if (sum < 0)\n sum *= -1;\n if (sum > ans)\n ans = (byte)sum;\n }\n Console.WriteLine (ans);\n return 0;\n }\n \n static string[] ReadSplitLine (uint numWordNeed)\n {\n string line = Console.ReadLine ();\n if (line == null)\n return null;\n char[] delims = new char[2] {' ', '\\t'};\n string[] words = line.Split (delims,StringSplitOptions.RemoveEmptyEntries);\n return (words.Length == numWordNeed ? words : null);\n } \n }\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "b1633bbc9b7de8a8b14b7ef0c08c3134", "src_uid": "6119258322e06fa6146e592c63313df3", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\n\n\nclass Scanner\n{\n string[] s;\n int i;\n\n char[] cs = new char[] { ' ' };\n\n public Scanner()\n {\n s = new string[0];\n i = 0;\n }\n\n public string next()\n {\n if (i < s.Length) return s[i++];\n s = Console.ReadLine().Split(cs, StringSplitOptions.RemoveEmptyEntries);\n i = 0;\n return s[i++];\n }\n\n public int nextInt()\n {\n return int.Parse(next());\n }\n\n public long nextLong()\n {\n return long.Parse(next());\n }\n\n}\n\nclass Myon\n{\n Scanner cin;\n Random r;\n Myon() { }\n\n public static void Main()\n {\n new Myon().calc();\n }\n\n List ret = new List();\n\n int[,] dp;\n\n void calc()\n {\n cin = new Scanner();\n int n = cin.nextInt();\n int m = cin.nextInt();\n dp = new int[n + 1, m + 1];\n Console.WriteLine(saiki(n, m));\n }\n\n int saiki(int a, int b)\n {\n if (a == 0 && b == 0) return a;\n if (dp[a, b] != 0) return dp[a, b];\n int reta = (a / 4) * 2 + Math.Min(a % 4, 2);\n int retb = (b / 4) * 2 + Math.Min(b % 4, 2);\n int ret = reta * retb;\n ret = Math.Max((a + 2) / 3 * b, ret);\n ret = Math.Max((b + 2) / 3 * a, ret);\n if (a > 3) ret = Math.Max(ret, saiki(a - 3, b) + b);\n if (b > 3) ret = Math.Max(ret, saiki(a, b - 3) + a);\n ret = Math.Max(ret, (a * b + 1) / 2);\n return dp[a, b] = ret;\n }\n}", "lang_cluster": "C#", "tags": ["greedy", "constructive algorithms", "implementation"], "code_uid": "8bd9c0f44b03246e740c2095cda927a5", "src_uid": "e858e7f22d91aaadd7a48a174d7b2dc9", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Text;\nusing System.IO;\n\npublic class taskB\n{\n public class MyReader\n {\n private TextReader instream;\n\n public int[] ReadIntArray()\n {\n string inp = instream.ReadLine().Trim();\n string[] spl = inp.Split(' ');\n\n int[] a = new int[spl.Length];\n for (int i = 0; i < a.Length; i++)\n a[i] = int.Parse(spl[i]);\n return a;\n }\n\n public long[] ReadLongArray()\n {\n string inp = instream.ReadLine().Trim();\n string[] spl = inp.Split(' ');\n\n long[] a = new long[spl.Length];\n for (int i = 0; i < a.Length; i++)\n a[i] = long.Parse(spl[i]);\n return a;\n }\n\n public double[] ReadDoubleArray()\n {\n string inp = instream.ReadLine().Trim();\n string[] spl = inp.Split(' ');\n\n double[] a = new double[spl.Length];\n\n System.Globalization.NumberFormatInfo nfi = new System.Globalization.NumberFormatInfo();\n nfi.NumberDecimalSeparator = \".\";\n for (int i = 0; i < a.Length; i++)\n a[i] = double.Parse(spl[i], nfi);\n return a;\n }\n\n public int ReadInt()\n {\n return int.Parse(instream.ReadLine());\n }\n\n public long ReadLong()\n {\n return long.Parse(instream.ReadLine());\n }\n\n public void SetInStream(TextReader textReader)\n {\n this.instream = textReader;\n }\n\n internal string ReadLine()\n {\n return instream.ReadLine();\n }\n }\n\n static void Main(string[] args)\n {\n MyReader instream = new MyReader();\n instream.SetInStream(Console.In);\n\n TextWriter outstream = Console.Out;\n\n solve(instream, outstream);\n\n }\n\n private static void solve(MyReader instream, TextWriter outstream)\n {\n int[] ab = instream.ReadIntArray();\n\n int a = ab[0];\n int b = ab[1];\n\n if (a > b)\n {\n int t = a;\n a = b;\n b = t;\n }\n\n int r1 = a * ((b-1) / 3+1);\n int r2 = ((a-1) / 3 + 1) * b;\n\n int r3 = a * b / 2 + ((a * b) % 2 == 0 ? 0 : 1);\n\n int res = Math.Max(Math.Max(r1, r2), r3);\n\n if (a == 2)\n {\n if (b % 4 == 1)\n {\n res = b / 4 * 4 + 2;\n }\n else if (b % 4 == 2 || b % 4 == 3)\n {\n res = b / 4 * 4 + 4;\n }\n }\n outstream.WriteLine(res);\n }\n\n}", "lang_cluster": "C#", "tags": ["greedy", "constructive algorithms", "implementation"], "code_uid": "43fe40e9145e692313c0844ce9230304", "src_uid": "e858e7f22d91aaadd7a48a174d7b2dc9", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections;\nusing System.Collections.Generic;\nusing System.Diagnostics;\nusing System.Globalization;\nusing System.IO;\nusing System.Linq;\nusing System.Text;\nusing System.Text.RegularExpressions;\nusing System.Threading.Tasks;\n\nnamespace ConsoleApplication5\n{\n class Program\n {\n static void Main(string[] args)\n {\n long summ = MyConsoleInputStreamParser.GetLong, x = MyConsoleInputStreamParser.GetLong;\n var need = (summ - x) / 2;\n if (need < 0 || (summ - x) % 2 == 1)\n Console.WriteLine(0);\n else\n {\n var bits = new int[64];\n var temp = x;\n var count = 0;\n var nonZeroBits = 0;\n while (temp > 0)\n {\n var bit = (int)(temp % 2);\n bits[count] = bit;\n count++;\n temp /= 2;\n nonZeroBits += bit == 1 ? 1 : 0;\n }\n if (nonZeroBits == 1 && need == 0)\n Console.WriteLine(0);\n else if (need == 0)\n Console.WriteLine((long)Math.Pow(2, nonZeroBits) - 2);\n else\n {\n temp = need;\n count = 0;\n var fail = false;\n while (temp > 0)\n {\n var bit = (int)(temp % 2);\n if (bits[count] == 1 && bit == 1)\n {\n fail = true;\n break;\n }\n count++;\n temp /= 2;\n }\n if (fail)\n Console.WriteLine(0);\n else\n Console.WriteLine((long)Math.Pow(2, nonZeroBits));\n }\n }\n }\n\n public static class MyConsoleInputStreamParser\n {\n private static TextReader reader = new StreamReader(Console.OpenStandardInput());\n private static Queue currentLineStrings = new Queue();\n\n public static string GetLine { get { return reader.ReadLine(); } }\n\n public static string GetString { get { while (currentLineStrings.Count == 0) currentLineStrings = new Queue(GetStringArray); return currentLineStrings.Dequeue(); } }\n\n public static int GetInt { get { return int.Parse(GetString); } }\n\n public static long GetLong { get { return long.Parse(GetString); } }\n\n public static double GetDouble { get { return double.Parse(GetString, CultureInfo.InvariantCulture); } }\n\n public static char[] GetCharArray { get { return GetLine.ToCharArray(); } }\n\n public static string[] GetStringArray { get { return GetLine.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); } }\n\n public static int[] GetIntArray { get { return GetStringArray.Select(int.Parse).ToArray(); } }\n\n public static long[] GetLongArray { get { return GetStringArray.Select(long.Parse).ToArray(); } }\n\n public static double[] GetDoubleArray { get { return GetStringArray.Select(s => double.Parse(s, CultureInfo.InvariantCulture)).ToArray(); } }\n\n public static char[][] ReturnCharMatrix(int numberOfRows) { char[][] matrix = new char[numberOfRows][]; for (int i = 0; i < numberOfRows; i++) matrix[i] = GetCharArray; return matrix; }\n\n public static string[][] ReturnStringMatrix(int numberOfRows) { string[][] matrix = new string[numberOfRows][]; for (int i = 0; i < numberOfRows; i++) matrix[i] = GetStringArray; return matrix; }\n\n public static int[][] ReturnIntMatrix(int numberOfRows) { int[][] matrix = new int[numberOfRows][]; for (int i = 0; i < numberOfRows; i++) matrix[i] = GetIntArray; return matrix; }\n\n public static long[][] ReturnLongMatrix(int numberOfRows) { long[][] matrix = new long[numberOfRows][]; for (int i = 0; i < numberOfRows; i++) matrix[i] = GetLongArray; return matrix; }\n\n public static double[][] ReturnDoubleMatrix(int numberOfRows) { double[][] matrix = new double[numberOfRows][]; for (int i = 0; i < numberOfRows; i++) matrix[i] = GetDoubleArray; return matrix; }\n }\n }\n}", "lang_cluster": "C#", "tags": ["math", "dp"], "code_uid": "a9bc8144abc3d95781463f6425d0efc7", "src_uid": "18410980789b14c128dd6adfa501aea5", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\nusing System;\nusing System.Collections.Generic;\nusing System.IO;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace AlgoTraining.Codeforces._8VCVentureCup2016\n{\n\n class FastScanner : StreamReader\n {\n private string[] _line;\n private int _iterator;\n\n public FastScanner(Stream stream) : base(stream)\n {\n _line = null;\n _iterator = 0;\n }\n public int NextInt()\n {\n if (_line == null || _iterator >= _line.Length)\n {\n _line = base.ReadLine().Split(' ');\n _iterator = 0;\n }\n if (_line.Count() == 0) throw new IndexOutOfRangeException(\"Input string is empty\");\n return Convert.ToInt32(_line[_iterator++]);\n }\n public long NextLong()\n {\n if (_line == null || _iterator >= _line.Length)\n {\n _line = base.ReadLine().Split(' ');\n _iterator = 0;\n }\n if (_line.Count() == 0) throw new IndexOutOfRangeException(\"Input string is empty\");\n return Convert.ToInt64(_line[_iterator++]);\n }\n }\n class XorEquationC\n {\n public static void Main(string[] args)\n {\n using (FastScanner fs = new FastScanner(new BufferedStream(Console.OpenStandardInput())))\n using (StreamWriter writer = new StreamWriter(new BufferedStream(Console.OpenStandardOutput())))\n {\n long s = fs.NextLong(), x = fs.NextLong();\n if (s < x || (s - x) % 2 != 0)\n {\n writer.WriteLine(0);\n return;\n }\n long and = (s - x) / 2;\n string xorStr = Convert.ToString(x, 2), andStr = Convert.ToString(and, 2);\n int onesNum = 0;\n foreach (char c in xorStr)\n {\n if (c == '1') onesNum++;\n }\n string shortStr = xorStr;\n string longStr = andStr;\n if (xorStr.Length > andStr.Length)\n {\n shortStr = andStr;\n longStr = xorStr;\n }\n int p = longStr.Length - 1;\n for (int i = shortStr.Length - 1; i >= 0; i--, p--)\n {\n if (shortStr[i] == '1' && longStr[p] == '1')\n {\n writer.WriteLine(0);\n return;\n }\n }\n writer.WriteLine(Math.Pow(2, onesNum) - (and == 0 ? 2 : 0));\n }\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "dp"], "code_uid": "1a98b10fb9c00566b120529a99d3712a", "src_uid": "18410980789b14c128dd6adfa501aea5", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.IO;\nusing System.Threading;\nusing System.Runtime.CompilerServices;\nusing System.Text;\nusing System.Diagnostics;\nusing System.Numerics;\nusing static System.Console;\nusing static System.Convert;\nusing static System.Math;\nusing static Template;\nusing Pi = Pair;\n\nclass Solver\n{\n public Scanner sc;\n public void Solve()\n {\n int N, M;\n sc.Make(out N, out M);\n var A = sc.ArrInt;\n var L = Create(2, () => new HashSet());\n for(int k = 0; k < 2; k++)\n {\n int[] a;\n if (k == 0) a = A.Take(N / 2).ToArray();\n else a = A.Skip(N / 2).ToArray();\n for(int j = 0; j < (1 << a.Length); j++)\n {\n var sum = 0;\n for (int l = 0; l < a.Length; l++)\n if ((1 & j >> l) == 1) { sum += a[l]%M; if (sum >= M) sum -= M; }\n L[k].Add(sum);\n }\n }\n var dat = Create(2, id => {\n var r = new int[L[id].Count];\n var now = 0;\n foreach (var d in L[id]) r[now++] = d;\n Array.Sort(r);\n return r;\n });\n var max = 0;\n for(int i = 0; i < dat[0].Length; i++)\n {\n var l = LowerBound(dat[1], M - dat[0][i]);\n for(int k = -1; k < 2; k++)\n {\n int idx = (l + k + dat[1].Length) % dat[1].Length;\n chmax(ref max, (dat[1][idx] + dat[0][i]) % M);\n }\n }\n Console.WriteLine(max);\n }\n #region UpperBound/LowerBound\n public static int UpperBound(IList array, T value, Comparison cmp = null)\n {\n cmp = cmp ?? Comparer.Default.Compare;\n var low = -1;\n var high = array.Count;\n while (high - low > 1)\n {\n var mid = (high + low) / 2;\n if (cmp(array[mid], value) == 1) high = mid;\n else low = mid;\n }\n return high;\n }\n\n public static int LowerBound(IList array, T value, Comparison cmp = null)\n {\n cmp = cmp ?? Comparer.Default.Compare;\n var low = -1;\n var high = array.Count;\n while (high - low > 1)\n {\n var mid = (high + low) / 2;\n if (cmp(array[mid], value) != -1) high = mid;\n else low = mid;\n }\n return high;\n }\n #endregion\n}\n\n#region Template\npublic static class Template\n{\n static void Main(string[] args)\n {\n Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });\n var sol = new Solver() { sc = new Scanner() };\n //var th = new Thread(sol.Solve, 1 << 26);th.Start();th.Join();\n sol.Solve();\n Console.Out.Flush();\n }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static bool chmin(ref T a, T b) where T : IComparable { if (a.CompareTo(b) > 0) { a = b; return true; } return false; }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static bool chmax(ref T a, T b) where T : IComparable { if (a.CompareTo(b) < 0) { a = b; return true; } return false; }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static void swap(ref T a, ref T b) { var t = b; b = a; a = t; }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static void swap(this IList A, int i, int j) { var t = A[i]; A[i] = A[j]; A[j] = t; }\n public static T[] Create(int n, Func f) { var rt = new T[n]; for (var i = 0; i < rt.Length; ++i) rt[i] = f(); return rt; }\n public static T[] Create(int n, Func f) { var rt = new T[n]; for (var i = 0; i < rt.Length; ++i) rt[i] = f(i); return rt; }\n public static IEnumerable Shuffle(this IEnumerable A) => A.OrderBy(v => Guid.NewGuid());\n public static int CompareTo(this T[] A, T[] B, Comparison cmp = null) { cmp = cmp ?? Comparer.Default.Compare; for (var i = 0; i < Min(A.Length, B.Length); i++) { int c = cmp(A[i], B[i]); if (c > 0) return 1; else if (c < 0) return -1; } if (A.Length == B.Length) return 0; if (A.Length > B.Length) return 1; else return -1; }\n public static int MaxElement(this IList A, Comparison cmp = null) { cmp = cmp ?? Comparer.Default.Compare; T max = A[0]; int rt = 0; for (int i = 1; i < A.Count; i++) if (cmp(max, A[i]) < 0) { max = A[i]; rt = i; } return rt; }\n public static T PopBack(this List A) { var v = A[A.Count - 1]; A.RemoveAt(A.Count - 1); return v; }\n public static void Fail(T s) { Console.WriteLine(s); Console.Out.Close(); Environment.Exit(0); }\n}\npublic class Scanner\n{\n public string Str => Console.ReadLine().Trim();\n public int Int => int.Parse(Str);\n public long Long => long.Parse(Str);\n public double Double => double.Parse(Str);\n public int[] ArrInt => Str.Split(' ').Select(int.Parse).ToArray();\n public long[] ArrLong => Str.Split(' ').Select(long.Parse).ToArray();\n public char[][] Grid(int n) => Create(n, () => Str.ToCharArray());\n public int[] ArrInt1D(int n) => Create(n, () => Int);\n public long[] ArrLong1D(int n) => Create(n, () => Long);\n public int[][] ArrInt2D(int n) => Create(n, () => ArrInt);\n public long[][] ArrLong2D(int n) => Create(n, () => ArrLong);\n private Queue q = new Queue();\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public T Next() { if (q.Count == 0) foreach (var item in Str.Split(' ')) q.Enqueue(item); return (T)Convert.ChangeType(q.Dequeue(), typeof(T)); }\n public void Make(out T1 v1) => v1 = Next();\n public void Make(out T1 v1, out T2 v2) { v1 = Next(); v2 = Next(); }\n public void Make(out T1 v1, out T2 v2, out T3 v3) { Make(out v1, out v2); v3 = Next(); }\n public void Make(out T1 v1, out T2 v2, out T3 v3, out T4 v4) { Make(out v1, out v2, out v3); v4 = Next(); }\n public void Make(out T1 v1, out T2 v2, out T3 v3, out T4 v4, out T5 v5) { Make(out v1, out v2, out v3, out v4); v5 = Next(); }\n public void Make(out T1 v1, out T2 v2, out T3 v3, out T4 v4, out T5 v5, out T6 v6) { Make(out v1, out v2, out v3, out v4, out v5); v6 = Next(); }\n public void Make(out T1 v1, out T2 v2, out T3 v3, out T4 v4, out T5 v5, out T6 v6, out T7 v7) { Make(out v1, out v2, out v3, out v4, out v5, out v6); v7 = Next(); }\n //public (T1, T2) Make() { Make(out T1 v1, out T2 v2); return (v1, v2); }\n //public (T1, T2, T3) Make() { Make(out T1 v1, out T2 v2, out T3 v3); return (v1, v2, v3); }\n //public (T1, T2, T3, T4) Make() { Make(out T1 v1, out T2 v2, out T3 v3, out T4 v4); return (v1, v2, v3, v4); }\n}\npublic class Pair : IComparable>\n{\n public T1 v1;\n public T2 v2;\n public Pair() { }\n public Pair(T1 v1, T2 v2)\n { this.v1 = v1; this.v2 = v2; }\n\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public int CompareTo(Pair p)\n {\n var c = Comparer.Default.Compare(v1, p.v1);\n if (c == 0)\n c = Comparer.Default.Compare(v2, p.v2);\n return c;\n }\n public override string ToString() => $\"{v1.ToString()} {v2.ToString()}\";\n public void Deconstruct(out T1 a, out T2 b) { a = v1; b = v2; }\n}\n\npublic class Pair : Pair, IComparable>\n{\n public T3 v3;\n public Pair() : base() { }\n public Pair(T1 v1, T2 v2, T3 v3) : base(v1, v2)\n { this.v3 = v3; }\n\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public int CompareTo(Pair p)\n {\n var c = base.CompareTo(p);\n if (c == 0)\n c = Comparer.Default.Compare(v3, p.v3);\n return c;\n }\n public override string ToString() => $\"{base.ToString()} {v3.ToString()}\";\n public void Deconstruct(out T1 a, out T2 b, out T3 c) { Deconstruct(out a, out b); c = v3; }\n}\n#endregion\n", "lang_cluster": "C#", "tags": ["meet-in-the-middle", "divide and conquer", "bitmasks"], "code_uid": "750902369b13abb6316e1480e46059b4", "src_uid": "d3a8a3e69a55936ee33aedd66e5b7f4a", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeff#if DEBUG\nusing System.Reflection;\nusing System.Threading.Tasks;\n#endif\n\nusing System;\nusing System.Collections.Generic;\nusing System.IO;\nusing System.Linq;\nusing System.Text;\nusing System.Numerics;\nusing System.Globalization;\n\n\nnamespace ed32e\n{\n class Program\n {\n static string _inputFilename = \"input.txt\";\n static string _outputFilename = \"output.txt\";\n static bool _useFileInput = false;\n\n\n static void Main(string[] args)\n {\n StreamWriter file = null;\n#if DEBUG\n\t\t\tConsole.SetIn(getInput());\n#else\n if (_useFileInput)\n {\n Console.SetIn(File.OpenText(_inputFilename));\n file = new StreamWriter(_outputFilename);\n Console.SetOut(file);\n }\n#endif\n\n try\n {\n solution();\n }\n finally\n {\n if (_useFileInput)\n {\n file.Close();\n }\n }\n }\n\n static void solution()\n {\n #region SOLUTION\n\n var d = readIntArray();\n var n = d[0];\n var m = d[1];\n var a = readIntArray();\n\n var fh = n / 2;\n if (n % 2 == 1)\n {\n fh++;\n }\n var sh = n / 2;\n\n var mv = 0;\n for (int i = 0; i < fh; i++)\n {\n mv |= 1 << i;\n }\n\n var arr = new long[mv + 1];\n for (int i = 0; i <= mv; i++)\n {\n arr[i] = sum(i, a, m, 0);\n }\n\n Array.Sort(arr);\n var max = arr[arr.Length - 1];\n\n\n var sm = 0;\n //for (int i = mv; i < n; i++)\n //{\n // sm &= 1 << i;\n //}\n\n for (int i = 0; i < sh; i++)\n {\n sm |= 1 << i;\n }\n\n //var smin = mv + 1;\n var res = long.MinValue;\n for (int i = 0; i <= sm; i++)\n {\n var val = sum(i, a, m, fh);\n var nr = (val + max) % m;\n if (nr > res)\n {\n res = nr;\n }\n\n var req = m - val - 1;\n //if (req <= 0)\n //{\n // continue;\n //}\n\n var l = 0;\n var r = arr.Length - 1;\n while (true)\n {\n if (l == r)\n {\n break;\n }\n\n var mid = l + (r - l + 1) / 2;\n var vv = arr[mid];\n if (vv <= req)\n {\n l = mid;\n }\n else\n {\n r = mid - 1;\n }\n }\n\n if (arr[l] <= req)\n {\n if (val + arr[l] > res)\n {\n res = val + arr[l];\n }\n }\n }\n\n Console.WriteLine(res);\n //var n = readInt();\n //var m = readInt();\n\n //var a = readIntArray();\n //var b = readIntArray();\n #endregion\n }\n\n static long sum(int pattern, int[] a, int m, int start)\n {\n var res = 0;\n for (int i = 0; i < 20; i++)\n {\n if ((pattern & (1 << i)) != 0)\n {\n res += a[i + start];\n res %= m;\n }\n }\n\n return res;\n }\n\n static int readInt()\n {\n return int.Parse(Console.ReadLine());\n }\n\n static long readLong()\n {\n return long.Parse(Console.ReadLine());\n }\n\n static int[] readIntArray()\n {\n return Console.ReadLine().Split(' ').Where(i => !string.IsNullOrEmpty(i)).Select(i => int.Parse(i)).ToArray();\n }\n\n static long[] readLongArray()\n {\n return Console.ReadLine().Split(' ').Where(i => !string.IsNullOrEmpty(i)).Select(i => long.Parse(i)).ToArray();\n }\n\n#if DEBUG\n\t\tstatic StreamReader getInput()\n\t\t{\n\t\t\tvar resName = Assembly.GetCallingAssembly().GetManifestResourceNames()[0];\n\t\t\tvar resource = Assembly.GetCallingAssembly().GetManifestResourceStream(resName);\n\n\t\t\treturn new StreamReader(resource);\n\t\t}\n#endif\n }\n}\n", "lang_cluster": "C#", "tags": ["meet-in-the-middle", "divide and conquer", "bitmasks"], "code_uid": "f94f2e39307c0a46940104b467073f8e", "src_uid": "d3a8a3e69a55936ee33aedd66e5b7f4a", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.IO;\nusing System.Text;\n\nnamespace Maximum_Subsequence\n{\n internal class Program\n {\n private static readonly StreamReader reader = new StreamReader(Console.OpenStandardInput(1024*10), Encoding.ASCII, false, 1024*10);\n private static readonly StreamWriter writer = new StreamWriter(Console.OpenStandardOutput(1024*10), Encoding.ASCII, 1024*10);\n\n private static void Main(string[] args)\n {\n writer.WriteLine(Solve(args));\n writer.Flush();\n }\n\n private static long Solve(string[] args)\n {\n int n = Next();\n int m = Next();\n\n var nn = new int[n];\n for (int i = 0; i < n; i++)\n {\n nn[i] = Next()%m;\n }\n\n if (n == 1)\n return nn[0];\n\n int mid = n/2;\n var p1 = new List();\n var p2 = new List();\n\n for (int i = 0; i < mid; i++)\n {\n int cnt = p1.Count;\n for (int j = 0; j < cnt; j++)\n {\n p1.Add((p1[j] + nn[i])%m);\n }\n p1.Add(nn[i]);\n }\n p1.Add(0);\n p1.Sort();\n\n for (int i = mid; i < n; i++)\n {\n int cnt = p2.Count;\n for (int j = 0; j < cnt; j++)\n {\n p2.Add((p2[j] + nn[i])%m);\n }\n p2.Add(nn[i]);\n }\n\n\n p2.Add(0);\n\n long max = 0;\n foreach (long l in p2)\n {\n long v = m - l - 1;\n int index = p1.BinarySearch(v);\n if (index < 0)\n {\n index = ~index;\n index--;\n }\n if (index >= 0)\n {\n max = Math.Max(max, l + p1[index]);\n }\n }\n\n return max;\n }\n\n private static int Next()\n {\n int c;\n int res = 0;\n do\n {\n c = reader.Read();\n if (c == -1)\n return res;\n } while (c < '0' || c > '9');\n res = c - '0';\n while (true)\n {\n c = reader.Read();\n if (c < '0' || c > '9')\n return res;\n res *= 10;\n res += c - '0';\n }\n }\n }\n}", "lang_cluster": "C#", "tags": ["meet-in-the-middle", "divide and conquer", "bitmasks"], "code_uid": "941c73c765956f6c6f9a57c172c24f2b", "src_uid": "d3a8a3e69a55936ee33aedd66e5b7f4a", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Globalization;\nusing System.IO;\nusing System.Linq;\nusing System.Text;\nusing System.Threading;\n\n// (\u3065\u00b0\u03c9\u00b0)\u3065\uff90e\u2605\u309c\u30fb\u3002\u3002\u30fb\u309c\u309c\u30fb\u3002\u3002\u30fb\u309c\u2606\u309c\u30fb\u3002\u3002\u30fb\u309c\u309c\u30fb\u3002\u3002\u30fb\u309c\npublic class Solver\n{\n public void Solve()\n {\n int n = ReadInt();\n int m = ReadInt();\n var v = ReadIntArray();\n\n if (n == 1)\n {\n Write(v[0] % m);\n return;\n }\n\n int na = n / 2;\n int nb = n - na;\n\n var a = new List();\n for (int i = 0; i < 1 << na; i++)\n {\n long s = 0;\n for (int j = 0; j < na; j++)\n if ((i >> j & 1) == 1)\n s += v[j];\n a.Add((int)(s % m));\n }\n\n var b = new List();\n for (int i = 0; i < 1 << nb; i++)\n {\n long s = 0;\n for (int j = 0; j < nb; j++)\n if ((i >> j & 1) == 1)\n s += v[j + na];\n b.Add((int)(s % m));\n }\n\n a.Sort();\n b.Sort();\n int ans = (a[a.Count - 1] + b[b.Count - 1]) % m;\n int p = b.Count - 1;\n for (int i = 0; i < a.Count; i++)\n {\n while (p >= 0 && a[i] + b[p] >= m)\n p--;\n if (p < 0)\n break;\n ans = Math.Max(ans, a[i] + b[p]);\n }\n\n Write(ans);\n }\n\n #region Main\n\n protected static TextReader reader;\n protected static TextWriter writer;\n static void Main()\n {\n#if DEBUG\n reader = new StreamReader(\"..\\\\..\\\\input.txt\");\n //reader = new StreamReader(Console.OpenStandardInput());\n writer = Console.Out;\n //writer = new StreamWriter(\"..\\\\..\\\\output.txt\");\n#else\n reader = new StreamReader(Console.OpenStandardInput());\n writer = new StreamWriter(Console.OpenStandardOutput());\n //reader = new StreamReader(\"input.txt\");\n //writer = new StreamWriter(\"output.txt\");\n#endif\n try\n {\n new Solver().Solve();\n //var thread = new Thread(new Solver().Solve, 1024 * 1024 * 128);\n //thread.Start();\n //thread.Join();\n }\n catch (Exception ex)\n {\n#if DEBUG\n Console.WriteLine(ex);\n#else\n throw;\n#endif\n }\n reader.Close();\n writer.Close();\n }\n\n #endregion\n\n #region Read / Write\n private static Queue currentLineTokens = new Queue();\n private static string[] ReadAndSplitLine() { return reader.ReadLine().Split(new[] { ' ', '\\t', }, StringSplitOptions.RemoveEmptyEntries); }\n public static string ReadToken() { while (currentLineTokens.Count == 0)currentLineTokens = new Queue(ReadAndSplitLine()); return currentLineTokens.Dequeue(); }\n public static int ReadInt() { return int.Parse(ReadToken()); }\n public static long ReadLong() { return long.Parse(ReadToken()); }\n public static double ReadDouble() { return double.Parse(ReadToken(), CultureInfo.InvariantCulture); }\n public static int[] ReadIntArray() { return ReadAndSplitLine().Select(int.Parse).ToArray(); }\n public static long[] ReadLongArray() { return ReadAndSplitLine().Select(long.Parse).ToArray(); }\n public static double[] ReadDoubleArray() { return ReadAndSplitLine().Select(s => double.Parse(s, CultureInfo.InvariantCulture)).ToArray(); }\n public static int[][] ReadIntMatrix(int numberOfRows) { int[][] matrix = new int[numberOfRows][]; for (int i = 0; i < numberOfRows; i++)matrix[i] = ReadIntArray(); return matrix; }\n public static int[][] ReadAndTransposeIntMatrix(int numberOfRows)\n {\n int[][] matrix = ReadIntMatrix(numberOfRows); int[][] ret = new int[matrix[0].Length][];\n for (int i = 0; i < ret.Length; i++) { ret[i] = new int[numberOfRows]; for (int j = 0; j < numberOfRows; j++)ret[i][j] = matrix[j][i]; } return ret;\n }\n public static string[] ReadLines(int quantity) { string[] lines = new string[quantity]; for (int i = 0; i < quantity; i++)lines[i] = reader.ReadLine().Trim(); return lines; }\n public static void WriteArray(IEnumerable array) { writer.WriteLine(string.Join(\" \", array)); }\n public static void Write(params object[] array) { WriteArray(array); }\n public static void WriteLines(IEnumerable array) { foreach (var a in array)writer.WriteLine(a); }\n private class SDictionary : Dictionary\n {\n public new TValue this[TKey key]\n {\n get { return ContainsKey(key) ? base[key] : default(TValue); }\n set { base[key] = value; }\n }\n }\n private static T[] Init(int size) where T : new() { var ret = new T[size]; for (int i = 0; i < size; i++)ret[i] = new T(); return ret; }\n #endregion\n}", "lang_cluster": "C#", "tags": ["meet-in-the-middle", "divide and conquer", "bitmasks"], "code_uid": "69e6965117ea54d8252d64bd24f10c81", "src_uid": "d3a8a3e69a55936ee33aedd66e5b7f4a", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections;\nusing System.Collections.Generic;\nusing System.Collections.Specialized;\nusing System.Diagnostics;\nusing System.IO;\nusing System.Text;\nusing System.Linq;\n\nnamespace Codeforces\n{\n internal class Program\n {\n private const string Test = \"E2\";\n\n \n private static void Solve()\n {\n var MOD = 1000000007;\n var input = ReadIntArray();\n var n = input[0];\n var m = input[1];\n var k = input[2];\n var dp = new List>();\n for (int i = 0; i <= 1001; i++)\n {\n dp.Add(new List());\n for (int j = 0; j <= i; j++)\n {\n if(j == 0 || j == i)\n dp[i].Add(1);\n else\n {\n dp[i].Add((dp[i-1][j-1] + dp[i - 1][j]) % MOD);\n }\n }\n }\n var res = Math.Min(n - 1, m - 1) < 2*k ? 0: dp[n - 1][2*k]*dp[m - 1][2*k];\n res %= MOD;\n Console.WriteLine(res);\n }\n\n\n private static void Main()\n {\n if (Debugger.IsAttached)\n {\n Console.SetIn(new StreamReader(String.Format(@\"..\\..\\..\\..\\Tests\\{0}.in\", Test)));\n }\n\n Solve();\n\n if (Debugger.IsAttached)\n {\n Console.In.Close();\n Console.SetIn(new StreamReader(Console.OpenStandardInput()));\n Console.ReadLine();\n }\n }\n\n #region Reader\n\n private static string Read()\n {\n return Console.ReadLine();\n }\n\n private static string[] ReadArray()\n {\n return Console.ReadLine().Split(' ');\n }\n\n private static int[] ReadIntArray()\n {\n var input = Console.ReadLine().Split(' ').Select(Int32.Parse).ToArray();\n return input;\n }\n\n private static int ReadInt()\n {\n return Int32.Parse(Console.ReadLine());\n }\n\n private static long ReadLong()\n {\n return long.Parse(Console.ReadLine());\n }\n\n private static int ReadNextInt(string[] input, int index)\n {\n return Int32.Parse(input[index]);\n }\n\n #endregion\n }\n}", "lang_cluster": "C#", "tags": ["dp", "combinatorics"], "code_uid": "4286ddb4b8039e5a02bf2645a5a187d9", "src_uid": "309d2d46086d526d160292717dfef308", "difficulty": 2000.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections;\nusing System.Collections.Generic;\nusing System.Collections.Specialized;\nusing System.Diagnostics;\nusing System.IO;\nusing System.Text;\nusing System.Linq;\n\nnamespace Codeforces\n{\n internal class Program\n {\n private const string Test = \"E2\";\n\n \n private static void Solve()\n {\n var MOD = 1000000007;\n var input = ReadIntArray();\n var n = input[0];\n var m = input[1];\n var k = input[2];\n var dp = new List>();\n for (int i = 0; i <= 1001; i++)\n {\n dp.Add(new List());\n for (int j = 0; j <= i; j++)\n {\n if(j == 0 || j == i)\n dp[i].Add(1);\n else\n {\n dp[i].Add((dp[i-1][j-1] + dp[i - 1][j]) % MOD);\n }\n }\n }\n var res = Math.Min(n - 1, m - 1) < 2*k ? 0: dp[n - 1][2*k]*dp[m - 1][2*k];\n res %= MOD;\n Console.WriteLine(res);\n }\n\n\n private static void Main()\n {\n if (Debugger.IsAttached)\n {\n Console.SetIn(new StreamReader(String.Format(@\"..\\..\\..\\..\\Tests\\{0}.in\", Test)));\n }\n\n Solve();\n\n if (Debugger.IsAttached)\n {\n Console.In.Close();\n Console.SetIn(new StreamReader(Console.OpenStandardInput()));\n Console.ReadLine();\n }\n }\n\n #region Reader\n\n private static string Read()\n {\n return Console.ReadLine();\n }\n\n private static string[] ReadArray()\n {\n return Console.ReadLine().Split(' ');\n }\n\n private static int[] ReadIntArray()\n {\n var input = Console.ReadLine().Split(' ').Select(Int32.Parse).ToArray();\n return input;\n }\n\n private static int ReadInt()\n {\n return Int32.Parse(Console.ReadLine());\n }\n\n private static long ReadLong()\n {\n return long.Parse(Console.ReadLine());\n }\n\n private static int ReadNextInt(string[] input, int index)\n {\n return Int32.Parse(input[index]);\n }\n\n #endregion\n }\n}", "lang_cluster": "C#", "tags": ["dp", "combinatorics"], "code_uid": "5ca6bc5937edebbfde22fc0ccca37184", "src_uid": "309d2d46086d526d160292717dfef308", "difficulty": 2000.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing CompLib.Mathematics;\nusing CompLib.Util;\n\npublic class Program\n{\n public void Solve()\n {\n var sc = new Scanner();\n long n = sc.NextLong();\n\n int m = sc.NextInt();\n\n var a = new Matrix(1, m);\n for (int i = 0; i < m; i++)\n {\n a[0, i] = 1;\n }\n\n var b = new Matrix(m, m);\n\n for (int i = 0; i < m - 1; i++)\n {\n b[i + 1, i] = 1;\n }\n\n b[0, m - 1] = 1;\n b[m - 1, m - 1] = 1;\n\n var c = Matrix.Pow(b, n);\n\n var d = a * c;\n\n Console.WriteLine(d[0, 0]);\n }\n\n public static void Main(string[] args) => new Program().Solve();\n}\n\n// https://bitbucket.org/camypaper/complib\nnamespace CompLib.Mathematics\n{\n #region ModInt\n\n /// \n /// [0,) \u307e\u3067\u306e\u5024\u3092\u53d6\u308b\u3088\u3046\u306a\u6570\n /// \n public struct ModInt\n {\n /// \n /// \u5270\u4f59\u3092\u53d6\u308b\u5024\uff0e\n /// \n public const long Mod = (int) 1e9 + 7;\n\n /// \n /// \u5b9f\u969b\u306e\u6570\u5024\uff0e\n /// \n public long num;\n\n /// \n /// \u5024\u304c \u3067\u3042\u308b\u3088\u3046\u306a\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u3092\u69cb\u7bc9\u3057\u307e\u3059\uff0e\n /// \n /// \u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u304c\u6301\u3064\u5024\n /// \u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u306e\u554f\u984c\u4e0a\uff0c\u30b3\u30f3\u30b9\u30c8\u30e9\u30af\u30bf\u5185\u3067\u306f\u5270\u4f59\u3092\u53d6\u308a\u307e\u305b\u3093\uff0e\u305d\u306e\u305f\u3081\uff0c \u2208 [0,) \u3092\u6e80\u305f\u3059\u3088\u3046\u306a \u3092\u6e21\u3057\u3066\u304f\u3060\u3055\u3044\uff0e\u3053\u306e\u30b3\u30f3\u30b9\u30c8\u30e9\u30af\u30bf\u306f O(1) \u3067\u5b9f\u884c\u3055\u308c\u307e\u3059\uff0e\n public ModInt(long n)\n {\n num = n;\n }\n\n /// \n /// \u3053\u306e\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u306e\u6570\u5024\u3092\u6587\u5b57\u5217\u306b\u5909\u63db\u3057\u307e\u3059\uff0e\n /// \n /// [0,) \u306e\u7bc4\u56f2\u5185\u306e\u6574\u6570\u3092 10 \u9032\u8868\u8a18\u3057\u305f\u3082\u306e\uff0e\n public override string ToString()\n {\n return num.ToString();\n }\n\n public static ModInt operator +(ModInt l, ModInt r)\n {\n l.num += r.num;\n if (l.num >= Mod) l.num -= Mod;\n return l;\n }\n\n public static ModInt operator -(ModInt l, ModInt r)\n {\n l.num -= r.num;\n if (l.num < 0) l.num += Mod;\n return l;\n }\n\n public static ModInt operator *(ModInt l, ModInt r)\n {\n return new ModInt(l.num * r.num % Mod);\n }\n\n public static implicit operator ModInt(long n)\n {\n n %= Mod;\n if (n < 0) n += Mod;\n return new ModInt(n);\n }\n\n /// \n /// \u4e0e\u3048\u3089\u308c\u305f 2 \u3064\u306e\u6570\u5024\u304b\u3089\u3079\u304d\u5270\u4f59\u3092\u8a08\u7b97\u3057\u307e\u3059\uff0e\n /// \n /// \u3079\u304d\u4e57\u306e\u5e95\n /// \u3079\u304d\u6307\u6570\n /// \u7e70\u308a\u8fd4\u3057\u4e8c\u4e57\u6cd5\u306b\u3088\u308a O(N log N) \u3067\u5b9f\u884c\u3055\u308c\u307e\u3059\uff0e\n public static ModInt Pow(ModInt v, long k)\n {\n return Pow(v.num, k);\n }\n\n /// \n /// \u4e0e\u3048\u3089\u308c\u305f 2 \u3064\u306e\u6570\u5024\u304b\u3089\u3079\u304d\u5270\u4f59\u3092\u8a08\u7b97\u3057\u307e\u3059\uff0e\n /// \n /// \u3079\u304d\u4e57\u306e\u5e95\n /// \u3079\u304d\u6307\u6570\n /// \u7e70\u308a\u8fd4\u3057\u4e8c\u4e57\u6cd5\u306b\u3088\u308a O(N log N) \u3067\u5b9f\u884c\u3055\u308c\u307e\u3059\uff0e\n public static ModInt Pow(long v, long k)\n {\n long ret = 1;\n for (k %= Mod - 1; k > 0; k >>= 1, v = v * v % Mod)\n if ((k & 1) == 1)\n ret = ret * v % Mod;\n return new ModInt(ret);\n }\n\n /// \n /// \u4e0e\u3048\u3089\u308c\u305f\u6570\u306e\u9006\u5143\u3092\u8a08\u7b97\u3057\u307e\u3059\uff0e\n /// \n /// \u9006\u5143\u3092\u53d6\u308b\u5bfe\u8c61\u3068\u306a\u308b\u6570\n /// \u9006\u5143\u3068\u306a\u308b\u3088\u3046\u306a\u5024\n /// \u6cd5\u304c\u7d20\u6570\u3067\u3042\u308b\u3053\u3068\u3092\u4eee\u5b9a\u3057\u3066\uff0c\u30d5\u30a7\u30eb\u30de\u30fc\u306e\u5c0f\u5b9a\u7406\u306b\u5f93\u3063\u3066\u9006\u5143\u3092 O(log N) \u3067\u8a08\u7b97\u3057\u307e\u3059\uff0e\n public static ModInt Inverse(ModInt v)\n {\n return Pow(v, Mod - 2);\n }\n }\n\n #endregion\n\n #region Binomial Coefficient\n\n public class BinomialCoefficient\n {\n public ModInt[] fact, ifact;\n\n public BinomialCoefficient(int n)\n {\n fact = new ModInt[n + 1];\n ifact = new ModInt[n + 1];\n fact[0] = 1;\n for (int i = 1; i <= n; i++)\n fact[i] = fact[i - 1] * i;\n ifact[n] = ModInt.Inverse(fact[n]);\n for (int i = n - 1; i >= 0; i--)\n ifact[i] = ifact[i + 1] * (i + 1);\n ifact[0] = ifact[1];\n }\n\n public ModInt this[int n, int r]\n {\n get\n {\n if (n < 0 || n >= fact.Length || r < 0 || r > n) return 0;\n return fact[n] * ifact[n - r] * ifact[r];\n }\n }\n\n public ModInt RepeatedCombination(int n, int k)\n {\n if (k == 0) return 1;\n return this[n + k - 1, k];\n }\n }\n\n #endregion\n}\n\n// https://bitbucket.org/camypaper/complib\nnamespace CompLib.Mathematics\n{\n using System.Diagnostics;\n using N = ModInt;\n\n #region Matrix\n\n public class Matrix\n {\n int row, col;\n public N[] mat;\n\n /// \n /// \u884c \u5217\u76ee\u306e\u8981\u7d20\u3078\u306e\u30a2\u30af\u30bb\u30b9\u3092\u63d0\u4f9b\u3057\u307e\u3059\u3002\n /// \n /// \u884c\u306e\u756a\u53f7\n /// \u5217\u306e\u756a\u53f7\n public N this[int r, int c]\n {\n get { return mat[r * col + c]; }\n set { mat[r * col + c] = value; }\n }\n\n public Matrix(int r, int c)\n {\n row = r;\n col = c;\n mat = new N[row * col];\n }\n\n public static Matrix operator *(Matrix l, Matrix r)\n {\n Debug.Assert(l.col == r.row);\n var ret = new Matrix(l.row, r.col);\n for (int i = 0; i < l.row; i++)\n for (int k = 0; k < l.col; k++)\n for (int j = 0; j < r.col; j++)\n ret.mat[i * r.col + j] = (ret.mat[i * r.col + j] + l.mat[i * l.col + k] * r.mat[k * r.col + j]);\n return ret;\n }\n\n /// \n /// ^ \u3092 O(^3 log ) \u3067\u8a08\u7b97\u3057\u307e\u3059\u3002\n /// \n public static Matrix Pow(Matrix m, long n)\n {\n var ret = new Matrix(m.row, m.col);\n for (int i = 0; i < m.row; i++)\n ret.mat[i * m.col + i] = 1;\n for (; n > 0; m *= m, n >>= 1)\n if ((n & 1) == 1)\n ret = ret * m;\n return ret;\n }\n\n public N[][] Items\n {\n get\n {\n var a = new N[row][];\n for (int i = 0; i < row; i++)\n {\n a[i] = new N[col];\n for (int j = 0; j < col; j++)\n a[i][j] = mat[i * col + j];\n }\n\n return a;\n }\n }\n }\n\n #endregion\n}\n\nnamespace CompLib.Util\n{\n using System;\n using System.Linq;\n\n class Scanner\n {\n private string[] _line;\n private int _index;\n private const char Separator = ' ';\n\n public Scanner()\n {\n _line = new string[0];\n _index = 0;\n }\n\n public string Next()\n {\n while (_index >= _line.Length)\n {\n _line = Console.ReadLine().Split(Separator);\n _index = 0;\n }\n\n return _line[_index++];\n }\n\n public int NextInt() => int.Parse(Next());\n public long NextLong() => long.Parse(Next());\n public double NextDouble() => double.Parse(Next());\n public decimal NextDecimal() => decimal.Parse(Next());\n public char NextChar() => Next()[0];\n public char[] NextCharArray() => Next().ToCharArray();\n\n public string[] Array()\n {\n _line = Console.ReadLine().Split(Separator);\n _index = _line.Length;\n return _line;\n }\n\n public int[] IntArray() => Array().Select(int.Parse).ToArray();\n public long[] LongArray() => Array().Select(long.Parse).ToArray();\n public double[] DoubleArray() => Array().Select(double.Parse).ToArray();\n public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();\n }\n}", "lang_cluster": "C#", "tags": ["math", "matrices", "dp"], "code_uid": "e45230ec35a8786dbe26f01f48c82d7e", "src_uid": "e7b9eec21d950f5d963ff50619c6f119", "difficulty": 2100.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.IO;\nusing System.Runtime.CompilerServices;\nusing System.Text;\nusing static Template;\nusing static System.Console;\nusing static System.Convert;\nusing static System.Math;\nusing Pi = Pair;\nusing Number = System.Int64;\n\nclass Solver\n{\n public void Solve()\n {\n long num;int m;\n Input.Make(out num, out m);\n if (num < m) Fail(1);\n var mt = new Math.Matrix(m);\n mt[0][0] = 1;\n mt[0][m - 1] = 1;\n for (var i = 1; i < m; i++)\n mt[i][i - 1] = 1;\n mt = mt.Pow(num - m + 1);\n var res = 0L;\n for(var i=0;i add { get; set; }\n public static Func mul { get; set; }\n static Matrix()\n {\n const int mod = 1000000007; e = 1;\n add = (a, b) => a + b >= mod ? a + b - mod : a + b; mul = (a, b) => (a * b) % mod;\n }\n public NUM[] this[int i]\n { get { return item[i]; } set { item[i] = value; } }\n public NUM this[int i1, int i2]\n {\n get { return item[i1][i2]; }\n set { item[i1][i2] = value; }\n }\n public Matrix(int size) : this(size, size) { }\n public Matrix(int height, int width)\n {\n Height = height;\n Width = width;\n item = Enumerable.Repeat(0, height).Select(_ => new NUM[width]).ToArray();\n }\n\n private static Matrix E(int size)\n {\n var tm = new Matrix(size, size);\n for (var i = 0; i < size; i++)\n tm[i, i] = e;\n return tm;\n }\n\n public static Matrix Trans(Matrix m)\n {\n var n = m.Width; var p = m.Height;\n var tm = new Matrix(n, p);\n for (var i = 0; i < n; i++)\n {\n for (var j = 0; j < p; j++)\n tm[i, j] = m[j, i];\n }\n return tm;\n }\n private static NUM Dot(NUM[] ar1, NUM[] ar2)\n {\n var tm = default(NUM);\n for (var i = 0; i < ar1.Length; i++)\n tm = add(tm, mul(ar1[i], ar2[i]));\n return tm;\n }\n public static Matrix Add(Matrix m1, Matrix m2)\n {\n var tm = new Matrix(m1.Height, m1.Width);\n for (var i = 0; i < m1.Height; i++)\n for (var j = 0; j < m1.Width; j++)\n tm[i, j] = add(m1[i, j], m2[i, j]);\n return tm;\n }\n public static NUM[] Mul(Matrix m, NUM[] ar)\n => Enumerable.Range(0, m.Height).Select(v => Dot(m[v], ar)).ToArray();\n\n public static Matrix Mul(Matrix m1, Matrix m2)\n {\n var tr = Trans(m2);\n var tm = new Matrix(m1.Height, m2.Width);\n for (var i = 0; i < m1.Height; i++)\n tm[i] = Mul(tr, m1[i]);\n return tm;\n }\n public static Matrix operator +(Matrix l, Matrix r)\n => Add(l, r);\n public static Matrix operator *(Matrix l, Matrix r)\n => Mul(l, r);\n public static NUM[] operator *(Matrix l, NUM[] r)\n => Mul(l, r);\n\n public Matrix Pow(long n)\n {\n if (n == 0) return E(Height);\n var tm = Pow(n / 2);\n if (n % 2 == 0) return Mul(tm, tm);\n else return Mul(Mul(tm, tm), this);\n }\n }\n}\n#endregion\n#region Template\npublic class Template\n{\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static bool chmin(ref T num, T val) where T : IComparable\n { if (num.CompareTo(val) == 1) { num = val; return true; } return false; }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static bool chmax(ref T num, T val) where T : IComparable\n { if (num.CompareTo(val) == -1) { num = val; return true; } return false; }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static void swap(ref T v1, ref T v2)\n { var t = v2; v2 = v1; v1 = t; }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static T[] Create(int n, Func f)\n => Enumerable.Repeat(0, n).Select(_ => f()).ToArray();\n public static void Fail() => Fail(\"No\");\n public static void Fail(T s) { Console.WriteLine(s); Console.Out.Close(); Environment.Exit(0); }\n static void Main(string[] args)\n {\n var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };\n Console.SetOut(sw);\n var p = new Solver();\n for (var i = 1; i > 0; --i)\n p.Solve();\n Console.Out.Flush();\n }\n}\n\npublic class Input\n{\n public static string read => Console.ReadLine().Trim();\n public static int[] ar => read.Split(' ').Select(int.Parse).ToArray();\n public static int num => Convert.ToInt32(read);\n public static long[] arL => read.Split(' ').Select(long.Parse).ToArray();\n public static long numL => Convert.ToInt64(read);\n public static char[][] grid(int h)\n => Create(h, () => read.ToCharArray());\n public static int[] ar1D(int n)\n => Create(n, () => num);\n public static long[] arL1D(int n)\n => Create(n, () => numL);\n public static string[] strs(int n)\n => Create(n, () => read);\n public static int[][] ar2D(int n)\n => Create(n, () => ar);\n public static long[][] arL2D(int n)\n => Create(n, () => arL);\n public static List[] edge(int n)\n => Create(n, () => new List());\n public static void Make(out T1 v1, out T2 v2)\n {\n v1 = Next();\n v2 = Next();\n }\n public static void Make(out T1 v1, out T2 v2, out T3 v3)\n {\n Make(out v1, out v2);\n v3 = Next();\n }\n public static void Make(out T1 v1, out T2 v2, out T3 v3, out T4 v4)\n {\n Make(out v1, out v2, out v3);\n v4 = Next();\n }\n public static void Make(out T1 v1, out T2 v2, out T3 v3, out T4 v4, out T5 v5)\n {\n Make(out v1, out v2, out v3, out v4);\n v5 = Next();\n }\n public static void Make(out T1 v1, out T2 v2, out T3 v3, out T4 v4, out T5 v5, out T6 v6)\n {\n Make(out v1, out v2, out v3, out v4, out v5);\n v6 = Next();\n }\n static Input()\n {\n sc = new Queue();\n dic = new Dictionary>();\n dic[typeof(int)] = s => int.Parse(s);\n dic[typeof(long)] = s => long.Parse(s);\n dic[typeof(char)] = s => char.Parse(s);\n dic[typeof(double)] = s => double.Parse(s);\n dic[typeof(uint)] = s => uint.Parse(s);\n dic[typeof(ulong)] = s => ulong.Parse(s);\n dic[typeof(string)] = s => s;\n }\n private static Dictionary> dic;\n private static Queue sc;\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static T Next() { if (sc.Count == 0) foreach (var item in read.Split(' ')) sc.Enqueue(item); return (T)dic[typeof(T)](sc.Dequeue()); }\n public const int MOD = 1000000007;\n}\n\npublic class Pair : IComparable>\n{\n public T1 v1;\n public T2 v2;\n public Pair() { v1 = Input.Next(); v2 = Input.Next(); }\n public Pair(T1 v1, T2 v2)\n { this.v1 = v1; this.v2 = v2; }\n\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public int CompareTo(Pair p)\n {\n var c = Comparer.Default.Compare(v1, p.v1);\n if (c == 0)\n c = Comparer.Default.Compare(v2, p.v2);\n return c;\n }\n public override string ToString()\n => $\"{v1.ToString()} {v2.ToString()}\";\n}\n\npublic class Pair : Pair, IComparable>\n{\n public T3 v3;\n public Pair() : base() { v3 = Input.Next(); }\n public Pair(T1 v1, T2 v2, T3 v3) : base(v1, v2)\n { this.v3 = v3; }\n\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public int CompareTo(Pair p)\n {\n var c = base.CompareTo(p);\n if (c == 0)\n c = Comparer.Default.Compare(v3, p.v3);\n return c;\n }\n public override string ToString()\n => $\"{base.ToString()} {v3.ToString()}\";\n}\n#endregion\n", "lang_cluster": "C#", "tags": ["math", "matrices", "dp"], "code_uid": "0e1fc1c12a49b0bb566966572bba3ef3", "src_uid": "e7b9eec21d950f5d963ff50619c6f119", "difficulty": 2100.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.IO;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n//\u043d\u0435\u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u0439 \u043e\u0442\u0432\u0435\u0442 \u043d\u0430 \u0442\u0435\u0441\u0442\u0435 15\nnamespace F\n{\n class Program\n {\n static Tree[] wt;\n class Tree\n {\n public long ves;\n public long ves_;\n public int nn;//\u0438\u043d\u0434\u0435\u043a \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430\n public int nk;//\u0438\u043d\u0434\u0435\u043a \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0433\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430\n public Tree l;\n public Tree r;\n public Tree p;\n public Tree(int[] m, int[] a, int i1, int ik, Tree p1)\n {\n nn = i1;\n nk = ik;\n if (i1 == ik)\n {\n l = null;\n r = null;\n ves = m[i1];\n ves_ = ((long)(a[i1] - i1) * (long)m[i1]) % (long)(1000000007);\n //ves_ = ((long)(a[i1] - i1) * (long)m[i1]) ;\n wt[i1] = this;\n }\n else\n {\n int s = (ik + i1 + 1) / 2;\n l = new Tree(m, a, i1, s - 1, this);\n r = new Tree(m, a, s, ik, this);\n ves = l.ves + r.ves;\n ves_ = (l.ves_ + r.ves_) % (long)(1000000007);\n }\n p = p1;\n if (ves < 0) Console.WriteLine(\"\u041e\u0419\");\n if (ves_ < 0) Console.WriteLine(\"\u041e\u0419\");\n //if (ves >= 1000000007) Console.WriteLine(\"\u041e\u0419\");\n if (ves_ >= 1000000007) Console.WriteLine(\"\u041e\u0419\");\n }\n }\n\n static long FindVes(Tree t1, Tree tn, bool t)//t=true ves;t=false ves_;\n {\n long ves = 0;\n int x1 = t1.nn;\n int y1 = tn.nk;\n if (y1 < x1) return 0;\n Tree ti = wt[x1];\n while (ti.nk < y1) ti = ti.p;\n if (t) ves = (long)ti.ves;\n else ves = (long)ti.ves_;\n Tree tiv = ti;\n while (ti.nn < x1)\n {\n if (ti.r.nn <= x1)\n {\n if (t) ves = ves - (long)ti.l.ves;\n else ves = (ves - (long)ti.l.ves_ + (long)(1000000007)) % (long)(1000000007);\n ti = ti.r;\n }\n else\n {\n ti = ti.l;\n }\n }\n ti = tiv;\n while (ti.nk > y1)\n {\n if (ti.l.nk >= y1)\n {\n if (t) ves = ves - (long)ti.r.ves;\n else ves = (ves - (long)ti.r.ves_ + (long)(1000000007)) % (long)(1000000007);\n ti = ti.l;\n }\n else\n {\n ti = ti.r;\n }\n }\n return ves;\n }\n\n static void Main(string[] args)\n {\n TextReader sr = Console.In;\n //StreamReader sr = new StreamReader(\"in115.txt\");\n string[] s = sr.ReadLine().Split();\n int n = Convert.ToInt32(s[0]);\n int q = Convert.ToInt32(s[1]);\n s = sr.ReadLine().Split();\n string[] s1 = sr.ReadLine().Split();\n int[] a = new int[n];\n int[] w = new int[n];\n for (int i = 0; i < n; i++)\n {\n a[i] = Convert.ToInt32(s[i]);\n w[i] = Convert.ToInt32(s1[i]);\n }\n //\u0440\u0435\u0448\u0435\u043d\u0438\u0435\n wt = new Tree[n];\n Tree t1 = new Tree(w, a, 0, n - 1, null);\n\n int ll;\n int rr;\n int id, nw;\n bool zapros1;\n Tree ti;\n List res = new List();\n for (int i = 0; i < q; i++)\n {\n s = sr.ReadLine().Split();\n ll = Convert.ToInt32(s[0]);\n if (ll < 0) zapros1 = true; else zapros1 = false;\n id = -1 - ll;\n ll--;\n nw = Convert.ToInt32(s[1]);\n rr = nw - 1;\n if (zapros1)\n {\n ti = wt[id];\n long delta = (long)nw - ti.ves;\n long delta_ = (((long)(a[id] - id) * (long)nw)) % (long)(1000000007) - ti.ves_;\n w[id] = nw;\n while (ti != null)\n {\n ti.ves = ti.ves + delta;\n ti.ves_ = (ti.ves_ + delta_ + (long)(1000000007)) % (long)(1000000007);\n ti = ti.p;\n }\n }\n else\n {\n if (ll == rr)\n {\n res.Add(0);\n }\n else if ((rr - ll) == (a[rr] - a[ll]))\n {\n res.Add(0);\n }\n else if ((rr - ll) == 1)\n {\n if (w[ll] > w[rr])\n {\n res.Add((int)(((long)(a[rr] - a[ll] - 1) * (long)w[rr]) % (long)(1000000007)));\n }\n else\n {\n res.Add((int)(((long)(a[rr] - a[ll] - 1) * (long)w[ll]) % (long)(1000000007)));\n }\n }\n else\n {\n //\u043d\u0430\u0439\u0442\u0438 \u0432\u0435\u0441 \u043e\u0442\u0440\u0435\u0437\u043a\u0430\n //int x1 = x - 1;\n //int y1 = y - 1;\n long ves = FindVes(wt[ll], wt[rr], true);\n long vl, vr, vv;\n int iis, iiss;\n int iisll = ll, iislr = rr;\n iis = (ll + rr + 1) / 2;\n vl = FindVes(wt[ll], wt[iis - 1], true);\n vr = FindVes(wt[iis + 1], wt[rr], true);\n while (true)\n {\n if ((vl + w[iis] > vr) && (vr + w[iis] > vl)) break;\n if (vl + w[iis] == vr)\n {\n if (w[iis] >= w[iis + 1]) break;\n else\n {\n iis++;\n break;\n }\n }\n if (vr + w[iis] == vl)\n {\n if (w[iis] >= w[iis - 1]) break;\n else\n {\n iis--;\n break;\n }\n }\n if ((vl + w[iis]) > (vr + w[iis]))\n {\n iiss = (iisll + iis) / 2;\n vv = FindVes(wt[iiss + 1], wt[iis - 1], true);\n vl = vl - vv - w[iiss];\n vr = vr + vv + w[iis];\n iislr = iis;\n iis = iiss;\n }\n else\n {\n iiss = (iislr + iis + 1) / 2;\n vv = FindVes(wt[iis + 1], wt[iiss - 1], true);\n vl = vl + vv + w[iis];\n vr = vr - vv - w[iiss];\n iisll = iis;\n iis = iiss;\n }\n }\n //long r1 = 0;\n //for (int j = ll; j < iis; j++)\n //{\n // r1 = (r1 + ((long)w[j] * (long)(a[iis] - a[j] - (iis - j)))) % 1000000007;\n //}\n //for (int j = iis + 1; j <= rr; j++)\n //{\n // r1 = (r1 + ((long)w[j] * (long)(a[j] - a[iis] - (j - iis)))) % 1000000007;\n //}\n long r = 0;\n if (iis > ll)\n {\n r = (r - (FindVes(wt[ll], wt[iis - 1], false) % (long)(1000000007)) + (long)(1000000007)) % (long)(1000000007);\n r = (r + ((long)(a[iis] - iis)) * (FindVes(wt[ll], wt[iis - 1], true) % (long)(1000000007))) % (long)(1000000007);\n\n }\n if (iis < rr)\n {\n r = (r + (FindVes(wt[iis + 1], wt[rr], false)) % (long)(1000000007)) % (long)(1000000007);\n r = (r - ((long)(a[iis] - iis) * (FindVes(wt[iis + 1], wt[rr], true) % (long)(1000000007))) % (long)(1000000007) + (long)(1000000007)) % (long)(1000000007);\n }\n res.Add((int)r);\n }\n }\n }\n Console.WriteLine(string.Join(\"\\n\", res));\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["data structures"], "code_uid": "04e8fd56ca71899aa4711e08977f4fa8", "src_uid": "c0715f71efa327070eba7e491856d66a", "difficulty": 2500.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.IO;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace F\n{\n class Program\n {\n static Tree[] wt;\n class Tree\n {\n public long ves;\n public long ves_;\n public int nn;//\u0438\u043d\u0434\u0435\u043a \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430\n public int nk;//\u0438\u043d\u0434\u0435\u043a \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0433\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430\n public Tree l;\n public Tree r;\n public Tree p;\n public Tree(int[] m, int[] a, int i1, int ik, Tree p1)\n {\n nn = i1;\n nk = ik;\n if (i1 == ik)\n {\n l = null;\n r = null;\n ves = m[i1];\n ves_ = ((long)(a[i1] - i1) * (long)m[i1]) % (long)(1000000007);\n wt[i1] = this;\n }\n else\n {\n int s = (ik + i1 + 1) / 2;\n l = new Tree(m, a, i1, s - 1, this);\n r = new Tree(m, a, s, ik, this);\n ves = l.ves + r.ves;\n ves_ = (l.ves_ + r.ves_) % (long)(1000000007);\n }\n p = p1;\n }\n }\n\n static long FindVes(Tree t1, Tree tn, bool t)//t=true ves;t=false ves_;\n {\n long ves = 0;\n int x1 = t1.nn;\n int y1 = tn.nk;\n if (y1 < x1) return 0;\n Tree ti = wt[x1];\n while (ti.nk < y1) ti = ti.p;\n if (t) ves = (long)ti.ves;\n else ves = (long)ti.ves_;\n Tree tiv = ti;\n while (ti.nn < x1)\n {\n if (ti.r.nn <= x1)\n {\n if (t) ves = ves - (long)ti.l.ves;\n else ves = (ves - (long)ti.l.ves_ + (long)(1000000007)) % (long)(1000000007);\n ti = ti.r;\n }\n else\n {\n ti = ti.l;\n }\n }\n ti = tiv;\n while (ti.nk > y1)\n {\n if (ti.l.nk >= y1)\n {\n if (t) ves = ves - (long)ti.r.ves;\n else ves = (ves - (long)ti.r.ves_ + (long)(1000000007)) % (long)(1000000007);\n ti = ti.l;\n }\n else\n {\n ti = ti.r;\n }\n }\n return ves;\n }\n\n static void Main(string[] args)\n {\n TextReader sr = Console.In;\n //StreamReader sr = new StreamReader(\"in1.txt\");\n string[] s = sr.ReadLine().Split();\n int n = Convert.ToInt32(s[0]);\n int q = Convert.ToInt32(s[1]);\n s = sr.ReadLine().Split();\n string[] s1 = sr.ReadLine().Split();\n int[] a = new int[n];\n int[] w = new int[n];\n for (int i = 0; i < n; i++)\n {\n a[i] = Convert.ToInt32(s[i]);\n w[i] = Convert.ToInt32(s1[i]);\n }\n //\u0440\u0435\u0448\u0435\u043d\u0438\u0435\n wt = new Tree[n];\n Tree t1 = new Tree(w, a, 0, n - 1, null);\n\n int ll;\n int rr;\n int id, nw;\n bool zapros1;\n Tree ti;\n List res = new List();\n for (int i = 0; i < q; i++)\n {\n s = sr.ReadLine().Split();\n ll = Convert.ToInt32(s[0]);\n if (ll < 0) zapros1 = true; else zapros1 = false;\n id = -1 - ll;\n ll--;\n nw = Convert.ToInt32(s[1]);\n rr = nw - 1;\n if (zapros1)\n {\n ti = wt[id];\n long delta = (long)nw - ti.ves;\n long delta_ = (((long)(a[id] - id) * (long)nw)) % (long)(1000000007) - ti.ves_;\n w[id] = nw;\n while (ti != null)\n {\n ti.ves = ti.ves + delta;\n ti.ves_ = (ti.ves_ + delta_ + (long)(1000000007)) % (long)(1000000007);\n ti = ti.p;\n }\n }\n else\n {\n if (ll == rr)\n {\n res.Add(0);\n }\n else if ((rr - ll) == (a[rr] - a[ll]))\n {\n res.Add(0);\n }\n else if ((rr - ll) == 1)\n {\n if (w[ll] > w[rr])\n {\n res.Add((int)(((long)(a[rr] - a[ll] - 1) * (long)w[rr]) % (long)(1000000007)));\n }\n else\n {\n res.Add((int)(((long)(a[rr] - a[ll] - 1) * (long)w[ll]) % (long)(1000000007)));\n }\n }\n else\n {\n //\u043d\u0430\u0439\u0442\u0438 \u0432\u0435\u0441 \u043e\u0442\u0440\u0435\u0437\u043a\u0430\n long ves = FindVes(wt[ll], wt[rr], true);\n long vl, vr, vv;\n int iis, iiss;\n int iisll = ll, iislr = rr;\n iis = (ll + rr + 1) / 2;\n vl = FindVes(wt[ll], wt[iis - 1], true);\n vr = FindVes(wt[iis + 1], wt[rr], true);\n while (true)\n {\n if ((vl + w[iis] > vr) && (vr + w[iis] > vl)) break;\n if (vl + w[iis] == vr)\n {\n if (w[iis] < w[iis + 1]) iis++;\n break;\n }\n if (vr + w[iis] == vl)\n {\n if (w[iis] < w[iis - 1]) iis--;\n break;\n }\n if ((vl) > (vr))\n {\n iiss = (iisll + iis) / 2;\n vv = FindVes(wt[iiss + 1], wt[iis - 1], true);\n vl = vl - vv - w[iiss];\n vr = vr + vv + w[iis];\n iislr = iis;\n iis = iiss;\n }\n else\n {\n iiss = (iislr + iis + 1) / 2;\n vv = FindVes(wt[iis + 1], wt[iiss - 1], true);\n vl = vl + vv + w[iis];\n vr = vr - vv - w[iiss];\n iisll = iis;\n iis = iiss;\n }\n }\n long r = 0;\n if (iis > ll)\n {\n r = (r - (FindVes(wt[ll], wt[iis - 1], false) % (long)(1000000007)) + (long)(1000000007)) % (long)(1000000007);\n r = (r + (long)(a[iis] - iis) * (FindVes(wt[ll], wt[iis - 1], true) % (long)(1000000007))) % (long)(1000000007);\n\n }\n if (iis < rr)\n {\n r = (r + (FindVes(wt[iis + 1], wt[rr], false)) % (long)(1000000007)) % (long)(1000000007);\n r = (r - (long)(a[iis] - iis) * (FindVes(wt[iis + 1], wt[rr], true) % (long)(1000000007)) % (long)(1000000007) + (long)(1000000007)) % (long)(1000000007);\n }\n res.Add((int)r);\n }\n }\n }\n Console.WriteLine(string.Join(\"\\n\", res));\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["data structures"], "code_uid": "f23b9119656f200befe2a0da7aa382a2", "src_uid": "c0715f71efa327070eba7e491856d66a", "difficulty": 2500.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.IO;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace F\n{\n class Program\n {\n static Tree[] wt;\n class Tree\n {\n public long ves;\n public long ves_;\n public int nn;//\u0438\u043d\u0434\u0435\u043a \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430\n public int nk;//\u0438\u043d\u0434\u0435\u043a \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0433\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430\n public Tree l;\n public Tree r;\n public Tree p;\n public Tree(int[] m, int[] a, int i1, int ik, Tree p1)\n {\n nn = i1;\n nk = ik;\n if (i1 == ik)\n {\n l = null;\n r = null;\n ves = m[i1];\n ves_ = ((long)(a[i1] - i1) * (long)m[i1]) % (long)(1000000007);\n wt[i1] = this;\n }\n else\n {\n int s = (ik + i1 + 1) / 2;\n l = new Tree(m, a, i1, s - 1, this);\n r = new Tree(m, a, s, ik, this);\n ves = l.ves + r.ves;\n ves_ = (l.ves_ + r.ves_) % (long)(1000000007);\n }\n p = p1;\n }\n }\n\n static long FindVes(Tree t1, Tree tn, bool t)//t=true ves;t=false ves_;\n {\n long ves = 0;\n int x1 = t1.nn;\n int y1 = tn.nk;\n if (y1 < x1) return 0;\n Tree ti = wt[x1];\n long sub = 0;\n while (ti.nk < y1)\n {\n if (ti.p.r == ti && ti.p.l!=null)\n {\n if (t) sub = sub + ti.p.l.ves;\n else sub = (sub + ti.p.l.ves_) % (long)(1000000007);\n }\n ti = ti.p;\n }\n if (t) ves = (long)ti.ves;\n else ves = (long)ti.ves_;\n if (t) ves =ves-sub;\n else ves =(ves-sub+ +(long)(1000000007)) % (long)(1000000007);\n //Tree tiv = ti;\n //while (ti.nn < x1)\n //{\n // if (ti.r.nn <= x1)\n // {\n // if (t) ves = ves - (long)ti.l.ves;\n // else ves = (ves - (long)ti.l.ves_ + (long)(1000000007)) % (long)(1000000007);\n // ti = ti.r;\n // }\n // else\n // {\n // ti = ti.l;\n // }\n //}\n //ti = tiv;\n while (ti.nk > y1)\n {\n if (ti.l.nk >= y1)\n {\n if (t) ves = ves - (long)ti.r.ves;\n else ves = (ves - (long)ti.r.ves_ + (long)(1000000007)) % (long)(1000000007);\n ti = ti.l;\n }\n else\n {\n ti = ti.r;\n }\n }\n return ves;\n }\n\n static void Main(string[] args)\n {\n TextReader sr = Console.In;\n //StreamReader sr = new StreamReader(\"in1.txt\");\n string[] s = sr.ReadLine().Split();\n int n = Convert.ToInt32(s[0]);\n int q = Convert.ToInt32(s[1]);\n s = sr.ReadLine().Split();\n string[] s1 = sr.ReadLine().Split();\n int[] a = new int[n];\n int[] w = new int[n];\n for (int i = 0; i < n; i++)\n {\n a[i] = Convert.ToInt32(s[i]);\n w[i] = Convert.ToInt32(s1[i]);\n }\n //\u0440\u0435\u0448\u0435\u043d\u0438\u0435\n wt = new Tree[n];\n Tree t1 = new Tree(w, a, 0, n - 1, null);\n\n int ll;\n int rr;\n int id, nw;\n bool zapros1;\n Tree ti;\n List res = new List();\n for (int i = 0; i < q; i++)\n {\n s = sr.ReadLine().Split();\n ll = Convert.ToInt32(s[0]);\n if (ll < 0) zapros1 = true; else zapros1 = false;\n id = -1 - ll;\n ll--;\n nw = Convert.ToInt32(s[1]);\n rr = nw - 1;\n if (zapros1)\n {\n ti = wt[id];\n long delta = (long)nw - ti.ves;\n long delta_ = (((long)(a[id] - id) * (long)nw)) % (long)(1000000007) - ti.ves_;\n w[id] = nw;\n while (ti != null)\n {\n ti.ves = ti.ves + delta;\n ti.ves_ = (ti.ves_ + delta_ + (long)(1000000007)) % (long)(1000000007);\n ti = ti.p;\n }\n }\n else\n {\n if (ll == rr)\n {\n res.Add(0);\n }\n else if ((rr - ll) == (a[rr] - a[ll]))\n {\n res.Add(0);\n }\n else if ((rr - ll) == 1)\n {\n if (w[ll] > w[rr])\n {\n res.Add((int)(((long)(a[rr] - a[ll] - 1) * (long)w[rr]) % (long)(1000000007)));\n }\n else\n {\n res.Add((int)(((long)(a[rr] - a[ll] - 1) * (long)w[ll]) % (long)(1000000007)));\n }\n }\n else\n {\n //\u043d\u0430\u0439\u0442\u0438 \u0432\u0435\u0441 \u043e\u0442\u0440\u0435\u0437\u043a\u0430\n long ves = FindVes(wt[ll], wt[rr], true);\n long vl, vr, vv;\n int iis, iiss;\n int iisll = ll, iislr = rr;\n iis = (ll + rr + 1) / 2;\n vl = FindVes(wt[ll], wt[iis - 1], true);\n vr = FindVes(wt[iis + 1], wt[rr], true);\n while (true)\n {\n if ((vl + w[iis] > vr) && (vr + w[iis] > vl)) break;\n if (vl + w[iis] == vr)\n {\n if (w[iis] < w[iis + 1]) iis++;\n break;\n }\n if (vr + w[iis] == vl)\n {\n if (w[iis] < w[iis - 1]) iis--;\n break;\n }\n if ((vl) > (vr))\n {\n iiss = (iisll + iis) / 2;\n vv = FindVes(wt[iiss + 1], wt[iis - 1], true);\n vl = vl - vv - w[iiss];\n vr = vr + vv + w[iis];\n iislr = iis;\n iis = iiss;\n }\n else\n {\n iiss = (iislr + iis + 1) / 2;\n vv = FindVes(wt[iis + 1], wt[iiss - 1], true);\n vl = vl + vv + w[iis];\n vr = vr - vv - w[iiss];\n iisll = iis;\n iis = iiss;\n }\n }\n long r = 0;\n if (iis > ll)\n {\n r = (r - (FindVes(wt[ll], wt[iis - 1], false) % (long)(1000000007)) + (long)(1000000007)) % (long)(1000000007);\n r = (r + (long)(a[iis] - iis) * (FindVes(wt[ll], wt[iis - 1], true) % (long)(1000000007))) % (long)(1000000007);\n\n }\n if (iis < rr)\n {\n r = (r + (FindVes(wt[iis + 1], wt[rr], false)) % (long)(1000000007)) % (long)(1000000007);\n r = (r - (long)(a[iis] - iis) * (FindVes(wt[iis + 1], wt[rr], true) % (long)(1000000007)) % (long)(1000000007) + (long)(1000000007)) % (long)(1000000007);\n }\n res.Add((int)r);\n }\n }\n }\n Console.WriteLine(string.Join(\"\\n\", res));\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["data structures"], "code_uid": "400bee77689d10e1b0106b410f3a015c", "src_uid": "c0715f71efa327070eba7e491856d66a", "difficulty": 2500.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.IO;\nusing System.Collections.Generic;\nusing System.Linq;\n\nnamespace CSharpParser\n{\n public class Solution : SolutionBase\n {\n protected override void Solve()\n {\n int n;\n Next(out n);\n int s;\n Next(out s);\n --s;\n int k;\n Next(out k);\n var a = NextArray(n);\n string c;\n Next(out c);\n var m = a.Sum() + 1;\n var d = new int[n, m];\n for (var i = 0; i < n; i++)\n {\n for (var j = 0; j < m; j++)\n d[i, j] = int.MaxValue;\n d[i, a[i]] = Math.Abs(s - i);\n }\n var u = new bool[n];\n while (true)\n {\n var i = -1;\n for (var l = 0; l < n; l++)\n if (!u[l] && (i == -1 || a[i] > a[l]))\n i = l;\n if (i == -1) break;\n u[i] = true;\n for (var j = 0; j < m; j++)\n if (d[i, j] != int.MaxValue)\n for (var l = 0; l < n; l++)\n if (a[l] > a[i] && c[l] != c[i])\n d[l, j + a[l]] = Math.Min(d[l, j + a[l]], d[i, j] + Math.Abs(i - l));\n }\n var ans = int.MaxValue;\n for (var i = 0; i < n; i++)\n for (var j = k; j < m; j++)\n ans = Math.Min(ans, d[i, j]);\n PrintLine(ans == int.MaxValue ? -1 : ans);\n }\n }\n\n public static class Algorithm\n {\n private static readonly Random Rnd = new Random();\n\n public static void Swap(ref T a, ref T b)\n {\n var temp = a;\n a = b;\n b = temp;\n }\n\n public static T Max(params T[] a)\n {\n var ans = a[0];\n var comp = Comparer.Default;\n for (var i = 1; i < a.Length; i++) ans = comp.Compare(ans, a[i]) >= 0 ? ans : a[i];\n return ans;\n }\n\n public static T Min(params T[] a)\n {\n var ans = a[0];\n var comp = Comparer.Default;\n for (var i = 1; i < a.Length; i++) ans = comp.Compare(ans, a[i]) <= 0 ? ans : a[i];\n return ans;\n }\n\n public static void RandomShuffle(IList a, int index, int length)\n {\n if (index < 0 || length < 0) throw new ArgumentOutOfRangeException();\n var last = index + length;\n if (last > a.Count) throw new ArgumentException();\n for (var i = index + 1; i < last; i++)\n {\n var j = Rnd.Next(index, i + 1);\n var t = a[i];\n a[i] = a[j];\n a[j] = t;\n }\n }\n\n public static void RandomShuffle(IList a)\n {\n RandomShuffle(a, 0, a.Count);\n }\n\n public static bool NextPermutation(IList a, int index, int length, Comparison compare = null)\n {\n compare = compare ?? Comparer.Default.Compare;\n if (index < 0 || length < 0) throw new ArgumentOutOfRangeException();\n var last = index + length;\n if (last > a.Count) throw new ArgumentException();\n for (var i = last - 1; i > index; i--)\n if (compare(a[i], a[i - 1]) > 0)\n {\n var j = i + 1;\n for (; j < last; j++) if (compare(a[j], a[i - 1]) <= 0) break;\n var t = a[i - 1];\n a[i - 1] = a[j - 1];\n a[j - 1] = t;\n for (; i < last - 1; i++, last--)\n {\n t = a[i];\n a[i] = a[last - 1];\n a[last - 1] = t;\n }\n return true;\n }\n for (var i = index; i < last - 1; i++, last--)\n {\n var t = a[i];\n a[i] = a[last - 1];\n a[last - 1] = t;\n }\n return false;\n }\n\n public static bool NextPermutation(IList a, Comparison compare = null)\n {\n return NextPermutation(a, 0, a.Count, compare);\n }\n\n public static bool PrevPermutation(IList a, int index, int length, Comparison compare = null)\n {\n compare = compare ?? Comparer.Default.Compare;\n if (index < 0 || length < 0) throw new ArgumentOutOfRangeException();\n var last = index + length;\n if (last > a.Count) throw new ArgumentException();\n for (var i = last - 1; i > index; i--)\n if (compare(a[i], a[i - 1]) < 0)\n {\n var j = i + 1;\n for (; j < last; j++) if (compare(a[j], a[i - 1]) >= 0) break;\n var t = a[i - 1];\n a[i - 1] = a[j - 1];\n a[j - 1] = t;\n for (; i < last - 1; i++, last--)\n {\n t = a[i];\n a[i] = a[last - 1];\n a[last - 1] = t;\n }\n return true;\n }\n for (var i = index; i < last - 1; i++, last--)\n {\n var t = a[i];\n a[i] = a[last - 1];\n a[last - 1] = t;\n }\n return false;\n }\n\n public static bool PrevPermutation(IList a, Comparison compare = null)\n {\n return PrevPermutation(a, 0, a.Count, compare);\n }\n\n public static int LowerBound(IList a, int index, int length, T value, Comparison compare = null)\n {\n compare = compare ?? Comparer.Default.Compare;\n if (index < 0 || length < 0) throw new ArgumentOutOfRangeException();\n if (index + length > a.Count) throw new ArgumentException();\n var ans = index;\n var last = index + length;\n var p2 = 1;\n while (p2 <= length) p2 *= 2;\n for (p2 /= 2; p2 > 0; p2 /= 2) if (ans + p2 <= last && compare(a[ans + p2 - 1], value) < 0) ans += p2;\n return ans;\n }\n\n public static int LowerBound(IList a, T value, Comparison compare = null)\n {\n return LowerBound(a, 0, a.Count, value, compare);\n }\n\n public static int UpperBound(IList a, int index, int length, T value, Comparison compare = null)\n {\n compare = compare ?? Comparer.Default.Compare;\n if (index < 0 || length < 0) throw new ArgumentOutOfRangeException();\n if (index + length > a.Count) throw new ArgumentException();\n var ans = index;\n var last = index + length;\n var p2 = 1;\n while (p2 <= length) p2 *= 2;\n for (p2 /= 2; p2 > 0; p2 /= 2) if (ans + p2 <= last && compare(a[ans + p2 - 1], value) <= 0) ans += p2;\n return ans;\n }\n\n public static int UpperBound(IList a, T value, Comparison compare = null)\n {\n return UpperBound(a, 0, a.Count, value, compare);\n }\n\n public static void Fill(this IList array, T value) where T : struct\n {\n for (var i = 0; i < array.Count; i++)\n array[i] = value;\n }\n\n public static void Fill(this IList array, Func func)\n {\n for (var i = 0; i < array.Count; i++)\n array[i] = func(i);\n }\n }\n\n public class InStream : IDisposable\n {\n protected readonly TextReader InputStream;\n private string[] _tokens;\n private int _pointer;\n\n private InStream(TextReader inputStream)\n {\n InputStream = inputStream;\n }\n\n public static InStream FromString(string str)\n {\n return new InStream(new StringReader(str));\n }\n\n public static InStream FromFile(string str)\n {\n return new InStream(new StreamReader(str));\n }\n\n public static InStream FromConsole()\n {\n return new InStream(Console.In);\n }\n\n public string NextLine()\n {\n try\n {\n return InputStream.ReadLine();\n }\n catch (Exception)\n {\n return null;\n }\n }\n\n private string NextString()\n {\n try\n {\n while (_tokens == null || _pointer >= _tokens.Length)\n {\n _tokens = NextLine().Split(new[] { ' ', '\\t' }, StringSplitOptions.RemoveEmptyEntries);\n _pointer = 0;\n }\n return _tokens[_pointer++];\n }\n catch (Exception)\n {\n return null;\n }\n }\n\n public bool Next(out T ans)\n {\n var str = NextString();\n if (str == null)\n {\n ans = default(T);\n return false;\n }\n ans = (T)Convert.ChangeType(str, typeof(T));\n return true;\n }\n\n public T[] NextArray(int length)\n {\n var array = new T[length];\n for (var i = 0; i < length; i++)\n if (!Next(out array[i]))\n return null;\n return array;\n }\n\n public T[,] NextArray(int length, int width)\n {\n var array = new T[length, width];\n for (var i = 0; i < length; i++)\n for (var j = 0; j < width; j++)\n if (!Next(out array[i, j]))\n return null;\n return array;\n }\n\n public void Dispose()\n {\n InputStream.Close();\n }\n }\n\n public class OutStream : IDisposable\n {\n protected readonly TextWriter OutputStream;\n\n private OutStream(TextWriter outputStream)\n {\n OutputStream = outputStream;\n }\n\n public static OutStream FromString(System.Text.StringBuilder strB)\n {\n return new OutStream(new StringWriter(strB));\n }\n\n public static OutStream FromFile(string str)\n {\n return new OutStream(new StreamWriter(str));\n }\n\n public static OutStream FromConsole()\n {\n return new OutStream(Console.Out);\n }\n\n public void Print(string format, params object[] args)\n {\n OutputStream.Write(format, args);\n }\n\n public void PrintLine(string format, params object[] args)\n {\n Print(format, args);\n OutputStream.WriteLine();\n }\n\n public void PrintLine()\n {\n OutputStream.WriteLine();\n }\n\n public void Print(T o)\n {\n OutputStream.Write(o);\n }\n\n public void PrintLine(T o)\n {\n OutputStream.WriteLine(o);\n }\n\n public void PrintArray(IList a, string between = \" \", string after = \"\\n\", bool printCount = false)\n {\n if (printCount)\n PrintLine(a.Count);\n for (var i = 0; i < a.Count; i++)\n Print(\"{0}{1}\", a[i], i == a.Count - 1 ? after : between);\n }\n\n public void Dispose()\n {\n OutputStream.Close();\n }\n }\n\n public abstract class SolutionBase : IDisposable\n {\n private InStream _in;\n private OutStream _out;\n\n protected SolutionBase()\n {\n //System.Threading.Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.InvariantCulture;\n _in = InStream.FromConsole();\n _out = OutStream.FromConsole();\n }\n\n protected string NextLine()\n {\n return _in.NextLine();\n }\n\n protected bool Next(out T ans)\n {\n return _in.Next(out ans);\n }\n\n protected T[] NextArray(int length)\n {\n return _in.NextArray(length);\n }\n\n protected T[,] NextArray(int length, int width)\n {\n return _in.NextArray(length, width);\n }\n\n protected void PrintArray(IList a, string between = \" \", string after = \"\\n\", bool printCount = false)\n {\n _out.PrintArray(a, between, after, printCount);\n }\n\n public void Print(string format, params object[] args)\n {\n _out.Print(format, args);\n }\n\n public void PrintLine(string format, params object[] args)\n {\n _out.PrintLine(format, args);\n }\n\n public void PrintLine()\n {\n _out.PrintLine();\n }\n\n public void Print(T o)\n {\n _out.Print(o);\n }\n\n public void PrintLine(T o)\n {\n _out.PrintLine(o);\n }\n\n public void Dispose()\n {\n _in.Dispose();\n _out.Dispose();\n }\n\n public void Freopen(string path, FileAccess access)\n {\n switch (access)\n {\n case FileAccess.Read:\n _in.Dispose();\n _in = InStream.FromFile(path);\n break;\n case FileAccess.Write:\n _out.Dispose();\n _out = OutStream.FromFile(path);\n break;\n }\n }\n\n protected abstract void Solve();\n\n public static void Main()\n {\n using (var p = new Solution()) p.Solve();\n }\n }\n}", "lang_cluster": "C#", "tags": ["dp"], "code_uid": "9b493445241eb845ff3cf3729b526293", "src_uid": "a95e54a7e38cc0d61b39e4a01a6f8d3f", "difficulty": 2000.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Text;\n\nnamespace mailru2018\n{\n class MainClass\n {\n class Box\n {\n public int pos;\n public int candy;\n public int color;\n }\n\n static int n, s, k;\n static Box[] r;\n\n static int[,] dp;\n\n static int find(int at, int candy)\n {\n if (candy >= k)\n return 0;\n\n if (dp[at, candy] != -1)\n return dp[at, candy];\n\n int result = int.MaxValue;\n\n for (int i = at + 1; i < n; ++i)\n {\n if (r[i].color != r[at].color && r[i].candy > r[at].candy)\n {\n int v = find(i, candy + r[i].candy);\n if (v != int.MaxValue)\n result = Math.Min(result, v + Math.Abs(r[at].pos - r[i].pos));\n }\n }\n\n dp[at, candy] = result;\n return result;\n }\n\n public static void Main(string[] args)\n {\n //var line = Array.ConvertAll(\"5 3 10\".Split(' '), int.Parse);\n var line = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);\n n = line[0];\n s = line[1] - 1;\n k = line[2];\n\n r = new Box[n];\n //line = Array.ConvertAll(\"1 2 3 4 5\".Split(' '), int.Parse);\n line = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);\n //var color = \"RGBRR\";\n var color = Console.ReadLine();\n\n for (int i = 0; i < n; ++i)\n {\n var box = new Box();\n box.pos = i;\n box.candy = line[i];\n box.color = color[i];\n r[i] = box;\n }\n\n Array.Sort(r, (x, y) => {\n return x.candy - y.candy;\n });\n\n dp = new int[n, 2018];\n for (int i = 0; i < n; ++i)\n for (int j = 0; j < 2018; ++j)\n dp[i, j] = -1;\n\n int result = int.MaxValue;\n for (int i = 0; i < n; ++i)\n {\n var v = find(i, r[i].candy);\n\n if (v != int.MaxValue)\n result = Math.Min(result, v + Math.Abs(s - r[i].pos));\n }\n\n if (result == int.MaxValue)\n result = -1;\n\n Console.WriteLine(result);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["dp"], "code_uid": "ca55775f7b166ce1410f9c073f441d03", "src_uid": "a95e54a7e38cc0d61b39e4a01a6f8d3f", "difficulty": 2000.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Text;\nusing System.Linq;\nusing System.IO;\nusing System.Globalization;\nusing System.Collections;\n\nnamespace Task\n{\n internal class Program\n {\n long getShapeSquare(long t)\n {\n long sum = (t - 1) * t / 2;\n return sum * 4 + 1;\n }\n\n long getTriangleSquare(long t, long x)\n {\n if (t <= 0)\n return 0;\n long sum = (t - 1) * t / 2;\n long cut = Math.Max(0,t - x);\n return sum * 2 + t - cut * (cut + 1) / 2;\n }\n\n long getSquare(int n, int x, int y, int t)\n {\n if (t == 0)\n return 0;\n\n long cutLeft = getTriangleSquare(t - x, y);\n long cutRight = getTriangleSquare(t - (n - x + 1), n - y + 1);\n long cutTop = getTriangleSquare(t - y, n - x + 1);\n long cutBottom = getTriangleSquare(t - (n - y + 1), x);\n return getShapeSquare(t) - cutLeft - cutRight - cutTop - cutBottom; \n }\n\n private void Solve()\n {\n int n = io.NextInt();\n int x = io.NextInt();\n int y = io.NextInt();\n long c = io.NextLong();\n\n int ans = int.MaxValue;\n\n int low = 0;\n int high = 2 * n;\n\n while (low <= high)\n {\n int med = (low + high) / 2;\n long s = getSquare(n, x, y, med);\n if (s >= c)\n {\n ans = Math.Min(ans, med);\n high = med - 1;\n }\n else\n low = med + 1;\n }\n\n io.Print(ans - 1);\n }\n\n #region Program\n\n private readonly MyIo io;\n\n public Program(MyIo io)\n {\n this.io = io;\n }\n\n public static void Main(string[] args)\n {\n using (MyIo io = new MyIo())\n {\n new Program(io).Solve();\n }\n }\n\n #endregion\n }\n\n #region MyIo\n\n internal class MyIo : IDisposable\n {\n private readonly TextReader inputStream;\n private readonly TextWriter outputStream = Console.Out;\n\n private string[] tokens;\n private int pointer;\n\n public MyIo()\n#if LOCAL_TEST\n : this(new StreamReader(\"..\\\\..\\\\input.txt\"))\n#else\n : this(System.Console.In)\n#endif\n {\n\n }\n\n public MyIo(TextReader inputStream)\n {\n this.inputStream = inputStream;\n }\n\n public string NextLine()\n {\n try\n {\n return inputStream.ReadLine();\n }\n catch (IOException)\n {\n return null;\n }\n }\n\n public string NextString()\n {\n try\n {\n while (tokens == null || pointer >= tokens.Length)\n {\n tokens = NextLine().Split(new char[] { ' ', '\\t' }, StringSplitOptions.RemoveEmptyEntries);\n pointer = 0;\n }\n return tokens[pointer++];\n }\n catch (IOException)\n {\n return null;\n }\n }\n\n public int NextInt()\n {\n return Next();\n }\n\n public long NextLong()\n {\n return Next();\n }\n\n public T Next()\n {\n return (T)Convert.ChangeType(NextString(), typeof(T));\n }\n\n\n public IEnumerable NextSeq(int n)\n {\n for (int i = 0; i < n; i++)\n yield return Next();\n }\n\n public void Print(string format, params object[] args)\n {\n outputStream.Write(string.Format(CultureInfo.InvariantCulture, format, args));\n }\n\n public void PrintLine(string format, params object[] args)\n {\n Print(format, args);\n\n outputStream.WriteLine();\n }\n\n public void Print(bool o)\n {\n Print(o ? \"YES\" : \"NO\");\n }\n\n public void PrintLine(bool o)\n {\n PrintLine(o ? \"YES\" : \"NO\");\n }\n\n public void Print(T o)\n {\n outputStream.Write(o);\n }\n\n\n public void PrintLine(T o)\n {\n outputStream.WriteLine(o);\n }\n\n public void Close()\n {\n inputStream.Close();\n outputStream.Close();\n }\n\n void IDisposable.Dispose()\n {\n Close();\n\n#if LOCAL_TEST\n Console.ReadLine();\n#endif\n }\n }\n\n #endregion\n}\n\n", "lang_cluster": "C#", "tags": ["brute force", "math", "binary search"], "code_uid": "801fe130c454f2253864606353ca7043", "src_uid": "232c5206ee7c1903556c3625e0b0efc6", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Diagnostics;\nusing System.Runtime.InteropServices;\nusing System.Text;\nusing System.Linq;\nusing System.IO;\nusing System.Globalization;\nusing System.Collections;\nusing System.Text.RegularExpressions;\n\nnamespace Task\n{\n\n #region MyIo\n\n internal class MyIo : IDisposable\n {\n private readonly TextReader inputStream;\n private readonly TextWriter outputStream = Console.Out;\n\n private string[] tokens;\n private int pointer;\n\n public MyIo()\n#if LOCAL_TEST\n : this(new StreamReader(\"input.txt\"))\n#else\n : this(System.Console.In)\n#endif\n {\n\n }\n\n public MyIo(TextReader inputStream)\n {\n this.inputStream = inputStream;\n }\n\n\n public char NextChar()\n {\n try\n {\n return (char)inputStream.Read();\n }\n catch (IOException)\n {\n return '\\0';\n }\n }\n\n public string NextLine()\n {\n try\n {\n return inputStream.ReadLine();\n }\n catch (IOException)\n {\n return null;\n }\n }\n\n public string NextString()\n {\n try\n {\n while (tokens == null || pointer >= tokens.Length)\n {\n tokens = (NextLine() + string.Empty).Split(new[] { ' ', '\\t' }, StringSplitOptions.RemoveEmptyEntries);\n pointer = 0;\n }\n return tokens[pointer++];\n }\n catch (IOException)\n {\n return null;\n }\n }\n\n public int NextInt()\n {\n return Next();\n }\n\n public long NextLong()\n {\n return Next();\n }\n\n public T Next()\n {\n var t = typeof(T);\n\n if (t == typeof(char))\n return (T)(object)NextChar();\n\n object s = NextString();\n\n if (t == typeof(string))\n return (T)s;\n\n return (T)Convert.ChangeType(s, typeof(T));\n }\n\n\n public IEnumerable NextWhile(Predicate pred)\n {\n if (pred == null)\n yield break;\n\n T res = Next();\n\n while (pred(res))\n {\n yield return res;\n\n res = Next();\n }\n }\n\n public IEnumerable NextSeq(long n)\n {\n for (var i = 0; i < n; i++)\n yield return Next();\n }\n\n public void Print(string format, params object[] args)\n {\n outputStream.Write(string.Format(CultureInfo.InvariantCulture, format, args));\n }\n\n public void PrintLine(string format, params object[] args)\n {\n Print(format, args);\n\n outputStream.WriteLine();\n }\n\n public void Print(bool o)\n {\n Print(o ? \"yes\" : \"no\");\n }\n\n public void PrintLine(bool o)\n {\n Print(o);\n\n outputStream.WriteLine();\n }\n\n public void Print(T o)\n {\n outputStream.Write(Convert.ToString(o, CultureInfo.InvariantCulture));\n }\n\n\n public void PrintLine(T o)\n {\n Print(o);\n\n outputStream.WriteLine();\n }\n\n public void Close()\n {\n inputStream.Close();\n outputStream.Close();\n }\n\n void IDisposable.Dispose()\n {\n Close();\n\n#if LOCAL_TEST\n Console.ReadLine();\n#endif\n }\n }\n\n\n public static class ListExtensions\n {\n public static void Each(this IEnumerable self, Action action)\n {\n foreach (var v in self)\n action(v);\n }\n\n public static IEnumerable ToCycleEnumerable(this IEnumerable self)\n {\n if (self != null)\n {\n for (; ; )\n {\n foreach (var x in self)\n yield return x;\n }\n }\n }\n\n public static T CycleGet(this IList self, int index)\n {\n var c = self.Count;\n return self[(index % c + c) % c];\n }\n\n\n public static IList Shuffle(this IList self)\n {\n var rnd = new Random(DateTime.Now.Millisecond);\n\n var n = self.Count;\n\n while (n > 1)\n {\n n--;\n var k = rnd.Next(n + 1);\n var value = self[k];\n self[k] = self[n];\n self[n] = value;\n }\n\n return self;\n }\n\n public static IList> UseForNew2D(this T def, int fd, int sd)\n {\n var fdim = new T[fd][];\n\n for (int i = 0; i < fd; i++)\n {\n fdim[i] = new T[sd];\n Fill(fdim[i], def);\n }\n\n return fdim;\n }\n\n public static IList Fill(this IList self, Func fval)\n {\n for (var i = 0; i < self.Count; i++)\n self[i] = fval();\n\n\n return self;\n }\n\n\n public static IList Fill(this IList self, T val)\n {\n return self.Fill(() => val);\n }\n\n public static long Hash(this IList self, Func val = null)\n {\n return val != null ? self.Hash((t, current) => unchecked(current * 19L + val(t))) : self.Hash(HashOne);\n }\n\n public static long Hash(this IList self, Func val)\n {\n return self.Aggregate(0L, (current, t) => unchecked(val(t, current)));\n }\n\n\n public static long HashOne(this T self, long current)\n {\n return unchecked(current * 19L + (Equals(self, default(T)) ? 0 : self.GetHashCode()));\n }\n\n\n public static IList BuildSegTree(this IList a, Func combine, Func convert)\n {\n var t = new T1[a.Count << 2];\n\n a.BuildSegTree(t, 1, 0, a.Count - 1, combine, convert);\n\n return t;\n }\n\n private static void BuildSegTree(this IList a, IList t, int v, int tl, int tr, Func combine, Func convert)\n {\n if (tl == tr)\n {\n t[v] = convert(a[tl]);\n }\n else\n {\n int tm = (tl + tr) >> 1;\n\n BuildSegTree(a, t, v << 1, tl, tm, combine, convert);\n BuildSegTree(a, t, (v << 1) + 1, tm + 1, tr, combine, convert);\n\n t[v] = combine(t[v << 1], t[(v << 1) + 1]);\n }\n }\n }\n\n public static class P\n {\n public static P Create(T1 key, T2 val)\n {\n return new P(key, val);\n }\n }\n\n public class P\n {\n private class PComparer : IComparer>\n {\n private readonly bool? byKey;\n\n public PComparer(bool? byKey)\n {\n this.byKey = byKey;\n }\n\n\n public int Compare(P x, P y)\n {\n x = x ?? new P();\n y = y ?? new P();\n\n\n if (byKey == true)\n return Comparer.Default.Compare(x.Key, y.Key);\n else if (byKey == false)\n return Comparer.Default.Compare(x.Value, y.Value);\n else\n {\n var tr = Comparer.Default.Compare(x.Key, y.Key);\n\n if (tr != 0)\n tr = Comparer.Default.Compare(x.Value, y.Value);\n\n return tr;\n }\n }\n }\n\n\n public P()\n {\n }\n\n public P(T1 key, T2 val)\n {\n this.Key = key;\n this.Value = val;\n }\n\n\n public T1 Key\n {\n get;\n set;\n }\n\n public T2 Value\n {\n get;\n set;\n }\n\n public P Clone()\n {\n return new P(Key, Value);\n }\n\n public static IComparer> KeyComparer\n {\n get { return new PComparer(true); }\n }\n\n public static IComparer> ValueComparer\n {\n get { return new PComparer(false); }\n }\n\n public static implicit operator T1(P obj)\n {\n return obj.Key;\n }\n\n public static implicit operator T2(P obj)\n {\n return obj.Value;\n }\n\n public P SetKey(T1 key)\n {\n Key = key;\n return this;\n }\n\n public P SetValue(T2 value)\n {\n Value = value;\n return this;\n }\n\n public override string ToString()\n {\n return string.Format(\"Key: {0}, Value: {1}\", Key, Value);\n }\n\n public override bool Equals(object obj)\n {\n var co = obj as P;\n\n return co != null && co.GetHashCode() == GetHashCode();\n }\n\n public override int GetHashCode()\n {\n int hash = 17;\n hash = hash * 31 + ((Equals(Key, default(T1))) ? 0 : Key.GetHashCode());\n hash = hash * 31 + ((Equals(Value, default(T1))) ? 0 : Value.GetHashCode());\n return hash;\n\n }\n }\n\n #endregion\n\n\n\n internal class Program\n {\n #region Program\n\n private readonly MyIo io;\n\n public Program(MyIo io)\n {\n this.io = io;\n }\n\n public static void Main(string[] args)\n {\n using (MyIo io = new MyIo())\n {\n new Program(io)\n .Solve();\n }\n }\n\n\n\n #endregion\n\n public const long MOD = 1000000007;\n public const double EPS = 1e-14;\n\n\n\n\n private void Solve()\n {\n var n = io.NextLong();\n\n var x = io.NextLong();\n var y = io.NextLong();\n\n var c = io.NextLong();\n\n\n long s = 0;\n\n if (c > 1)\n {\n \n var ub = (long)Math.Sqrt(1+8*c);\n var lb = Math.Max(ub / 4L - 1L, 0L);\n\n s = ub;\n\n \n \n\n do\n {\n \n var m = (ub + lb) >> 1;\n\n var cn = Calc(n, x, y, m);\n\n if (cn >= c)\n {\n ub--;\n s = Math.Min(m, s);\n }\n else if (cn < c)\n {\n lb++;\n }\n \n\n } while (ub > lb);\n\n }\n\n io.Print(s);\n }\n\n private long Pos0(long x)\n {\n return x > 0 ? x : 0;\n }\n\n private long Pow2(long x)\n {\n \n return x*x;\n }\n\n\n private long Pow2120(long x)\n {\n x = Pos0(x);\n\n return x * (x + 1L) / 2;\n }\n\n private long Calc(long n, long x, long y, long s)\n {\n \n\n if (s == 0)\n return 1;\n\n \n var r = Pos0(s + y - n);\n var b = Pos0(s + x - n);\n\n var l = Pos0(1 - y + s);\n var t = Pos0(1 - x + s);\n \n var ix = 1 + n - x;\n var iy = 1 + n - y;\n\n var bse = s*s + (s + 1)*(s + 1) - Pow2(r) - Pow2(t) - Pow2(b) - Pow2(l);\n\n bse += Pow2120(l - x);\n bse += Pow2120(r - x);\n\n bse += Pow2120(l - ix);\n bse += Pow2120(r - ix);\n\n \n return bse;\n }\n }\n\n}\n\n", "lang_cluster": "C#", "tags": ["math", "implementation", "binary search"], "code_uid": "b12fd7b3ade26a8a6caf8487dbabb0d4", "src_uid": "232c5206ee7c1903556c3625e0b0efc6", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.IO;\nusing System.Collections.Generic;\nusing System.Globalization;\n\n\nnamespace first\n{\n class MainClass\n {\n // 999999998765257149 10 -> 1414213571\n // 999999998765257152 10 -> 1414213572\n public static long GetRoot(long n, out bool isInt)\n {\n long res = 0;\n\n long start = Math.Max((long)Math.Sqrt(n) - 5, 1);\n\n for (long i = start; i < start + 10; i++)\n if (i * i > n)\n {\n res = i - 1;\n break;\n }\n\n isInt = res * res == n;\n\n return res;\n }\n\n public static void Main(string[] args)\n {\n //var textReader = new StreamReader(@\"D:\\Projects\\cpp\\input.txt\");\n //Console.SetIn(textReader);\n\n var a = Console.ReadLine().Split(' ');\n long n = Convert.ToInt64(a[0]);\n long m = Convert.ToInt64(a[1]);\n\n //bool isInt;\n\n //long root = GetRoot(n - m, out isInt);\n //Console.WriteLine(String.Format(\"root {0}, is int {1}\", root, isInt));\n\n if (n <= m) Console.WriteLine(n);\n else\n {\n long d = 1 + 8 * (n - m);\n bool isRootInt;\n long dRootLong = GetRoot(d, out isRootInt);\n\n bool intRes = isRootInt && (dRootLong % 2 == 1);\n\n long k = (dRootLong - 1) / 2;\n\n //decimal k1 = (dRoot - 1.0m) / 2.0m;\n //long k = (long)(Math.Floor(k1));\n\n if (!intRes) k++;\n\n Console.WriteLine(k + m);\n }\n\n //Console.ReadKey();\n }\n }\n}", "lang_cluster": "C#", "tags": ["math", "binary search"], "code_uid": "f192a39cdc64b9fc0c1dd4f4448f1986", "src_uid": "3b585ea852ffc41034ef6804b6aebbd8", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Diagnostics;\nusing System.IO;\nusing System.Linq;\n\nnamespace Codeforces\n{\n\tinternal class Template\n\t{\n\t\tprivate void Solve()\n\t\t{\n\t\t\tvar n = cin.NextLong();\n\t\t\tvar m = cin.NextLong();\n\t\t\tif (m >= n)\n\t\t\t{\n\t\t\t\tConsole.WriteLine(n);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tvar days = m;\n\t\t\tvar value = n - m;\n\t\t\tvar lo = 0L;\n\t\t\tvar hi = 2000000000L;\n\t\t\twhile (lo < hi)\n\t\t\t{\n\t\t\t\tvar mid = lo + (hi - lo)/2;\n\t\t\t\tif (value <= mid*(mid + 1)/2)\n\t\t\t\t{\n\t\t\t\t\thi = mid;\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tlo = mid + 1;\n\t\t\t\t}\n\t\t\t}\n\t\t\tvar result = days + lo;\n\t\t\tConsole.WriteLine(result);\n\t\t}\n\n\t\tprivate static readonly Scanner cin = new Scanner();\n\n\t\tprivate static void Main()\n\t\t{\n#if DEBUG\n\t\t\tvar inputText = File.ReadAllText(@\"..\\..\\input.txt\");\n\t\t\tvar testCases = inputText.Split(new[] { \"input\" }, StringSplitOptions.RemoveEmptyEntries);\n\t\t\tvar consoleOut = Console.Out;\n\t\t\tfor (var i = 0; i < testCases.Length; i++)\n\t\t\t{\n\t\t\t\tvar parts = testCases[i].Split(new[] { \"output\" }, StringSplitOptions.RemoveEmptyEntries);\n\t\t\t\tConsole.SetIn(new StringReader(parts[0].Trim()));\n\t\t\t\tvar stringWriter = new StringWriter();\n\t\t\t\tConsole.SetOut(stringWriter);\n\t\t\t\tvar sw = Stopwatch.StartNew();\n\t\t\t\tnew Template().Solve();\n\t\t\t\tsw.Stop();\n\t\t\t\tvar output = stringWriter.ToString();\n\n\t\t\t\tConsole.SetOut(consoleOut);\n\t\t\t\tvar color = ConsoleColor.Green;\n\t\t\t\tvar status = \"Passed\";\n\t\t\t\tif (parts[1].Trim() != output.Trim())\n\t\t\t\t{\n\t\t\t\t\tcolor = ConsoleColor.Red;\n\t\t\t\t\tstatus = \"Failed\";\n\t\t\t\t}\n\t\t\t\tConsole.ForegroundColor = color;\n\t\t\t\tConsole.WriteLine(\"Test {0} {1} in {2}ms\", i + 1, status, sw.ElapsedMilliseconds);\n\t\t\t}\n\t\t\tConsole.ReadLine();\n\t\t\tConsole.ReadKey();\n#else\n\t\t\tnew Template().Solve();\n\t\t\tConsole.ReadLine();\n#endif\n\t\t}\n\t}\n\n\tinternal class Scanner\n\t{\n\t\tprivate string[] s = new string[0];\n\t\tprivate int i;\n\t\tprivate readonly char[] cs = { ' ' };\n\n\t\tpublic string NextString()\n\t\t{\n\t\t\tif (i < s.Length) return s[i++];\n\t\t\tvar line = Console.ReadLine() ?? string.Empty;\n\t\t\ts = line.Split(cs, StringSplitOptions.RemoveEmptyEntries);\n\t\t\ti = 1;\n\t\t\treturn s.First();\n\t\t}\n\n\t\tpublic double NextDouble()\n\t\t{\n\t\t\treturn double.Parse(NextString());\n\t\t}\n\n\t\tpublic int NextInt()\n\t\t{\n\t\t\treturn int.Parse(NextString());\n\t\t}\n\n\t\tpublic long NextLong()\n\t\t{\n\t\t\treturn long.Parse(NextString());\n\t\t}\n\t}\n}", "lang_cluster": "C#", "tags": ["math", "binary search"], "code_uid": "d4be351e86da40bee12cf426bfda47cd", "src_uid": "3b585ea852ffc41034ef6804b6aebbd8", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Text;\n\n\npublic class taskA\n{\n static void Main(string[] args)\n {\n string inp = Console.ReadLine();\n string[] spl = inp.Split(' ');\n int n, m;\n n = int.Parse(spl[0]);\n m = int.Parse(spl[1]);\n\n long res = pow(3,n,m);\n \n res = (res - (long)1+(long)m) % m;\n\n Console.WriteLine(res);\n\n }\n\n private static long pow(int p, int n, int m)\n {\n long res = 0;\n if (n == 0) return 1;\n\n if ((n % 2) == 0)\n {\n res = pow(p, n / 2, m);\n res = res * res;\n res %= m;\n\n }\n else\n {\n res = pow(p, n - 1, m);\n res = res * p;\n return res;\n }\n res %= m;\n return res;\n }\n\n}\n", "lang_cluster": "C#", "tags": ["math"], "code_uid": "b612a1028a2b6fa1c5e74f9413068d64", "src_uid": "c62ad7c7d1ea7aec058d99223c57d33c", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.IO;\nusing System.Text;\n\nnamespace Flying_Saucer_Segments\n{\n internal class Program\n {\n private static readonly StreamReader reader = new StreamReader(Console.OpenStandardInput(1024*10), Encoding.ASCII, false, 1024*10);\n private static readonly StreamWriter writer = new StreamWriter(Console.OpenStandardOutput(1024*10), Encoding.ASCII, 1024*10);\n\n private static int mod;\n\n private static long Pow(long a, int k)\n {\n long r = 1;\n while (k > 0)\n {\n if ((k & 1) == 1)\n {\n r = (r*a)%mod;\n }\n a = (a*a)%mod;\n k >>= 1;\n }\n return r;\n }\n\n private static void Main(string[] args)\n {\n int n = Next();\n mod = Next();\n\n long res = Pow(3, n) - 1;\n if (res < 0)\n res += mod;\n\n writer.WriteLine(res);\n writer.Flush();\n }\n\n private static int Next()\n {\n int c;\n int res = 0;\n do\n {\n c = reader.Read();\n if (c == -1)\n return res;\n } while (c < '0' || c > '9');\n res = c - '0';\n while (true)\n {\n c = reader.Read();\n if (c < '0' || c > '9')\n return res;\n res *= 10;\n res += c - '0';\n }\n }\n }\n}", "lang_cluster": "C#", "tags": ["math"], "code_uid": "21f07426ddf4ebc559faa389048eac54", "src_uid": "c62ad7c7d1ea7aec058d99223c57d33c", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.IO;\nusing System.Text;\n\nnamespace Alyona_and_copybooks\n{\n internal class Program\n {\n private static readonly StreamReader reader = new StreamReader(Console.OpenStandardInput(1024*10), Encoding.ASCII, false, 1024*10);\n private static readonly StreamWriter writer = new StreamWriter(Console.OpenStandardOutput(1024*10), Encoding.ASCII, 1024*10);\n\n private static void Main(string[] args)\n {\n long n = Next(), a = Next(), b = Next(), c = Next();\n\n long amount = 0;\n switch (n%4)\n {\n case 0:\n break;\n case 1:\n amount = Math.Min(c, Math.Min(a + a + a, a + b));\n break;\n case 2:\n amount = Math.Min(b, Math.Min(a + a, c + c));\n break;\n case 3:\n amount = Math.Min(a, Math.Min(b + c, c + c + c));\n break;\n }\n\n\n writer.WriteLine(amount);\n writer.Flush();\n }\n\n private static int Next()\n {\n int c;\n int res = 0;\n do\n {\n c = reader.Read();\n if (c == -1)\n return res;\n } while (c < '0' || c > '9');\n res = c - '0';\n while (true)\n {\n c = reader.Read();\n if (c < '0' || c > '9')\n return res;\n res *= 10;\n res += c - '0';\n }\n }\n }\n}", "lang_cluster": "C#", "tags": ["brute force", "implementation"], "code_uid": "497e0a2fb10fb8c5c69f35282329fc11", "src_uid": "c74537b7e2032c1d928717dfe15ccfb8", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace A\n{\n class Program\n {\n static long N, A, B, C;\n\n static long Solve(long N, long A, long B, long C)\n {\n switch (N % 4)\n {\n case 1:\n return Math.Min(Math.Min(3L * A, C), A + B);\n\n case 2:\n return Math.Min(Math.Min(2L * A, B), 2L * C);\n\n case 3:\n return Math.Min(Math.Min(A, 3L * C), 3L * B + C);\n\n default:\n return 0;\n }\n }\n\n static void Main(string[] args)\n {\n string input = Console.ReadLine();\n string[] vals = input.Split(' ');\n N = long.Parse(vals[0]);\n A = long.Parse(vals[1]);\n B = long.Parse(vals[2]);\n C = long.Parse(vals[3]);\n\n //Console.WriteLine(Solve(N, A, B, C));\n\n long minVal = long.MaxValue;\n for (int i = 0; i <= 10; i++)\n {\n for (int j = 0; j <= 10; j++)\n {\n for (int k = 0; k <= 10; k++)\n {\n if ((N + i + 2 * j + 3 * k) % 4 == 0)\n {\n minVal = Math.Min(minVal, A * i + B * j + C * k);\n }\n }\n }\n }\n\n Console.WriteLine(minVal);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "implementation"], "code_uid": "7d2e5190a1e205408e51c0026638c9bc", "src_uid": "c74537b7e2032c1d928717dfe15ccfb8", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nclass test\n{\n static int tmp = 0;\n \n static void Main()\n {\n int n = int.Parse(Console.ReadLine());\n int i = 10;\n int count = 0;\n while(count != n)\n {\n if(check(i))\n {\n count++;\n if(count == n){Console.WriteLine(tmp);}\n }\n i++;\n }\n \n }\n \n static bool check(int i)\n {\n int last = 0;\n int ipep = i;\n while(ipep>0)\n {\n last = (10*last)+(ipep%10);\n ipep = ipep/10;\n }\n int i2 = last;\n \n if(i == i2)return false;\n double z = 0;\n if(i < i2){z = Math.Sqrt(i2*1.0);}\n if(i > i2){z = Math.Sqrt(i*1.0);}\n \n //Console.WriteLine(\"{0} {1}\",i,i2);\n \n for(int j=2;j<=z;j++)\n {\n if(i%j == 0)\n {\n return false;\n }\n if(i2%j == 0)\n {\n return false;\n }\n }\n tmp = i;\n return true;\n }\n}", "lang_cluster": "C#", "tags": ["brute force", "implementation", "number theory"], "code_uid": "acb27a782bb98173238c14b4a2b7ec51", "src_uid": "53879e79cccbacfa6586d40cf3436657", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.IO;\n\nnamespace ConsoleApplication1\n{\n class Program\n {\n static bool pri(int x)\n {\n if (x % 2 == 0) return false;\n int temp = (int)Math.Sqrt(x) +1;\n\n for (int i = 3; i <= temp; i += 2)\n if (x % i == 0) return false;\n \n return true;\n\n }\n static int rev(int x)\n {\n int sum = 0;\n\n while (x > 0)\n { sum = sum * 10 + (x % 10); x /= 10; }\n return sum;\n }\n static int Main()\n {\n \n int n = int.Parse(Console.ReadLine());\n int nub=0;\n \n for (int i = 13; ; i += 2)\n {\n if((pri(i) && pri(rev(i)) && i!=rev(i) ))\n {\n nub++;\n if(nub==n)\n {\n Console.WriteLine(i);\n return 0;\n }\n\n\n }\n\n }\n \n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "implementation", "number theory"], "code_uid": "744e38b846370439b9d72ee89a17566e", "src_uid": "53879e79cccbacfa6586d40cf3436657", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Globalization;\nusing System.Text;\nusing System.IO;\nusing System.Linq;\nusing System.Threading;\n\n\n\n\nclass Program\n{\n\n void solve()\n {\n List nums = new List();\n string s = \"\";\n for (int i = 0; i < 4; i++)\n nums.Add(nextInt());\n for (int i = 0; i < 3; i++)\n s += nextString();\n long res = get(nums, s);\n println(res);\n\n }\n\n private long get(List nums, string s)\n {\n if (nums.Count == 1)\n {\n if (s.Length != 0)\n throw new Exception();\n return nums[0];\n }\n long res = long.MaxValue;\n for(int i=0;i cur = new List(nums);\n cur.RemoveAt(j);\n cur.RemoveAt(i);\n long add;\n if (s[0] == '+')\n add = nums[i] + nums[j];\n else\n add = nums[i] * nums[j];\n cur.Add(add);\n res = Math.Min(res, get(cur, s.Substring(1)));\n }\n return res;\n }\n\n ////////////\n private void println(int[] ar)\n {\n for (int i = 0; i < ar.Length; i++)\n {\n if (i == ar.Length - 1)\n println(ar[i]);\n else\n print(ar[i] + \" \");\n }\n }\n private void println(int[] ar, bool add)\n {\n int A = 0;\n if (add)\n A++;\n for (int i = 0; i < ar.Length; i++)\n {\n if (i == ar.Length - 1)\n println(ar[i] + A);\n else\n print((ar[i] + A) + \" \");\n }\n }\n\n private void println(string Stringst)\n {\n Console.WriteLine(Stringst);\n }\n private void println(char charnum)\n {\n Console.WriteLine(charnum);\n }\n private void println(int Intnum)\n {\n Console.WriteLine(Intnum);\n }\n private void println(long Longnum)\n {\n Console.WriteLine(Longnum);\n }\n private void println(double Doublenum)\n {\n string s = Doublenum.ToString(CultureInfo.InvariantCulture);\n Console.WriteLine(s);\n }\n\n private void print(string Stringst)\n {\n Console.Write(Stringst);\n }\n private void print(int Intnum)\n {\n Console.Write(Intnum);\n }\n private void print(char charnum)\n {\n Console.Write(charnum);\n }\n private void print(long Longnum)\n {\n Console.Write(Longnum);\n }\n private void print(double Doublenum)\n {\n Console.Write(Doublenum);\n }\n\n\n string[] inputLine = new string[0];\n int inputInd = 0;\n string nextLine()\n {\n return Console.ReadLine();\n }\n void readInput()\n {\n if (inputInd != inputLine.Length)\n throw new Exception();\n inputInd = 0;\n inputLine = Console.ReadLine().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);\n if (inputLine.Length == 0)\n readInput();\n\n }\n int nextInt()\n {\n if (inputInd == inputLine.Length)\n readInput();\n return int.Parse(inputLine[inputInd++]);\n }\n long nextLong()\n {\n if (inputInd == inputLine.Length)\n readInput();\n return long.Parse(inputLine[inputInd++]);\n }\n double nextDouble()\n {\n if (inputInd == inputLine.Length)\n readInput();\n return double.Parse(inputLine[inputInd++]);\n }\n string nextString()\n {\n if (inputInd == inputLine.Length)\n readInput();\n return inputLine[inputInd++];\n }\n static void Main(string[] args)\n {\n Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;\n new Program().solve();\n }\n}\n\n\n", "lang_cluster": "C#", "tags": ["brute force"], "code_uid": "4926bae65a0c3c535695964df4107d2a", "src_uid": "7a66fae63d9b27e444d84447012e484c", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\n\nnamespace ProgrammingContest.Codeforces.Round51\n{\n class B\n {\n public static void Main()\n {\n long[] xs = Array.ConvertAll(Console.ReadLine().Split(' '), sss => long.Parse(sss));\n bool[] ops = Array.ConvertAll(Console.ReadLine().Split(' '), sss=>sss==\"+\");\n long res = long.MaxValue;\n foreach (long[] ys in Permutations(xs))\n {\n long[] ys2 = new long[] { ops[0] ? ys[0] + ys[1] : ys[0] * ys[1], ys[2], ys[3] };\n foreach (long[] zs in Permutations(ys2))\n {\n long tmp = 0;\n tmp += ops[1] ? zs[0] + zs[1] : zs[0] * zs[1];\n tmp = ops[2] ? tmp + zs[2] : tmp * zs[2];\n res = Math.Min(res, tmp);\n }\n }\n Console.WriteLine(res);\n }\n\n private static void Swap(T[] ts, int i, int j)\n {\n T tmp = ts[i];\n ts[i] = ts[j];\n ts[j] = tmp;\n }\n\n public static IEnumerable Permutations(T[] ts)\n {\n foreach (T[] p in Permutations(ts, 0, ts.Length))\n {\n yield return p;\n }\n }\n\n private static IEnumerable Permutations(T[] ts, int start, int end)\n {\n if (start == end) yield return ts;\n for (int i = start; i < end; i++)\n {\n for (int j = i - 1; j >= start; j--) Swap(ts, j, j + 1);\n foreach (T[] p in Permutations(ts, start + 1, end)) yield return p;\n for (int j = start; j < i; j++) Swap(ts, j, j + 1);\n }\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force"], "code_uid": "1c7c9eebab5f9a0e13f1f0fabd2c9cf0", "src_uid": "7a66fae63d9b27e444d84447012e484c", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.IO;\nusing System.Collections.Generic;\nusing System.Globalization;\n\n//string[] lines = File.ReadAllLines (@\"D:\\Projects\\cpp\\input.txt\");\n//string s = File.ReadAllLines(@\"D:\\Projects\\cpp\\input.txt\")[0];\n\nnamespace first\n{\n\tclass MainClass\n\t{\n\t\tpublic static string Reverse(string s)\n\t\t{\n\t\t\tchar[] charArray = s.ToCharArray();\n\t\t\tArray.Reverse(charArray);\n\t\t\treturn new string(charArray);\n\t\t}\n\n\t\tpublic static void Main(string[] args)\n\t\t{\n\t\t\t//var textReader = new StreamReader(@\"D:\\Projects\\cpp\\input.txt\");\n\t\t\t//Console.SetIn(textReader);\n\n\t\t\tstring[] s = Console.ReadLine().Split(' ');\n\n\t\t\tdecimal d = (decimal)Convert.ToInt32(s[0]);\n\t\t\tdecimal l = (decimal)Convert.ToInt32(s[1]);\n\t\t\tdecimal v1 = (decimal)Convert.ToInt32(s[2]);\n\t\t\tdecimal v2 = (decimal)Convert.ToInt32(s[3]);\n\n\t\t\tdecimal res = ((l - d)) / ((v1 + v2));\n\t\t\tConsole.WriteLine((string.Format(CultureInfo.GetCultureInfo(\"en-GB\"), \"{0:F6}\", res)));\n\t\t\t//Console.ReadKey();\n\t\t}\n\t}\n}", "lang_cluster": "C#", "tags": ["math"], "code_uid": "cbaffe97f00dcbf0ea0c907be3f0bad8", "src_uid": "f34f3f974a21144b9f6e8615c41830f5", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Globalization;\nusing System.Linq;\n\nnamespace Codeforces\n{\n public class Program\n {\n public static void Main(string[] args)\n {\n int[] input = Console.ReadLine()\n .Split(new [] {\" \"}, StringSplitOptions.RemoveEmptyEntries)\n .Select(int.Parse)\n .ToArray();\n\n double result = ((double)input[1] - input[0]) / ((double)input[2] + input[3]);\n Console.WriteLine(result.ToString(\"F6\", CultureInfo.InvariantCulture));\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math"], "code_uid": "1515ad378f3e268163d6c10aae99a030", "src_uid": "f34f3f974a21144b9f6e8615c41830f5", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.IO;\nusing System.Collections;\nusing System.Collections.Generic;\nusing System.Text;\nusing System.Reflection;\nusing System.Threading;\nusing System.Diagnostics;\nusing System.Linq;\nusing System.Globalization;\n\nclass Solution\n{\n public TextInput cin;\n public TextOutput cout;\n public TextOutput cerr;\n\n public long Dist(long x)\n {\n x = x % 360L;\n return Math.Min(Math.Abs(x), 360 - Math.Abs(x));\n }\n public void Solve()\n {\n var n = (cin.Read()) % 360L;\n var min = 0L;\n for (var i = 1L; i <= 4; i++)\n {\n var x = Dist(min * 90L - n);\n var y = Dist(i * 90L - n);\n if (y < x)\n {\n min = i;\n }\n }\n cout.WriteLine(min);\n }\n}\n\n#region Core\nstatic class Program\n{\n public static readonly TextInput cin = new TextInput(Console.In);\n public static readonly TextOutput cout = new TextOutput(Console.Out);\n public static readonly TextOutput cerr = new TextOutput(Console.Error);\n#if !DEBUG\n static void Main()\n {\n new Solution\n {\n cin = cin,\n cout = cout,\n cerr = cerr\n }.Solve();\n }\n#endif\n}\npublic class SDictionary : Dictionary\n{\n public new TValue this[TKey key]\n {\n get\n {\n TValue res;\n base.TryGetValue(key, out res);\n return res;\n }\n set\n {\n base[key] = value;\n }\n }\n}\npublic static class Ext\n{\n\n #region Prewriten\n public static void Foreach(this IEnumerable elements, Action action)\n {\n foreach(var element in elements)\n {\n action(element);\n }\n }\n public static void Foreach(this IEnumerable elements, Action action)\n {\n var index = 0;\n foreach(var element in elements)\n {\n action(element, index++);\n }\n }\n public static IEnumerable Init(int n) where T : new()\n {\n for (var i = 0; i < n; i++)\n {\n yield return new T();\n }\n }\n public static IEnumerable Init(int n, T defaultValue = default(T))\n {\n for (var i = 0; i < n; i++)\n {\n yield return defaultValue;\n }\n }\n public static IEnumerable Init(int n, Func builder)\n {\n for (var i = 0; i < n; i++)\n {\n yield return builder(i);\n }\n }\n public static bool IsEmpty(this string s)\n {\n return string.IsNullOrEmpty(s);\n }\n public static string Safe(this string s)\n {\n return s.IsEmpty() ? string.Empty : s;\n }\n public static void Swap(ref T a, ref T b)\n {\n T c = a;\n a = b;\n b = c;\n }\n public static long Gcd(long a, long b)\n {\n while (a > 0)\n {\n b %= a;\n Swap(ref a, ref b);\n }\n return b;\n }\n public static int[] ZFunction(string s)\n {\n var z = new int[s.Length];\n for (int i = 1, l = 0, r = 0; i < s.Length; ++i)\n {\n if (i <= r)\n {\n z[i] = Math.Min(r - i + 1, z[i - l]);\n }\n while (i + z[i] < s.Length && s[z[i]] == s[i + z[i]])\n {\n z[i]++;\n }\n if (i + z[i] - 1 > r)\n {\n l = i;\n r = i + z[i] - 1;\n }\n }\n return z;\n }\n public static long Pow(long a, long p)\n {\n var b = 1L;\n while (p > 0)\n {\n if ((p & 1) == 0)\n {\n a *= a;\n p >>= 1;\n }\n else\n {\n b *= a;\n p--;\n }\n }\n return b;\n }\n #endregion\n}\n\npublic delegate bool TryParseDelegate(string s, NumberStyles style, IFormatProvider format, out T value);\npublic class TextInput\n{\n private static Dictionary primitiveParsers = new Dictionary\n {\n { typeof(sbyte), new TryParseDelegate(sbyte.TryParse) },\n { typeof(short), new TryParseDelegate(short.TryParse) },\n { typeof(int), new TryParseDelegate(int.TryParse) },\n { typeof(long), new TryParseDelegate(long.TryParse) },\n\n { typeof(byte), new TryParseDelegate(byte.TryParse) },\n { typeof(ushort), new TryParseDelegate(ushort.TryParse) },\n { typeof(uint), new TryParseDelegate(uint.TryParse) },\n { typeof(ulong), new TryParseDelegate(ulong.TryParse) },\n\n { typeof(float), new TryParseDelegate(float.TryParse) },\n { typeof(double), new TryParseDelegate(double.TryParse) },\n { typeof(decimal), new TryParseDelegate(decimal.TryParse) },\n\n { typeof(char), new TryParseDelegate(CharParser) },\n { typeof(string), new TryParseDelegate(StringParser) }\n };\n private static bool CharParser(string s, NumberStyles style, IFormatProvider format, out char res)\n {\n res = char.MinValue;\n if (string.IsNullOrEmpty(s))\n {\n return false;\n }\n else\n {\n res = s[0];\n return true;\n }\n }\n private static bool StringParser(string s, NumberStyles style, IFormatProvider format, out string res)\n {\n res = s == null ? string.Empty : s;\n return true;\n }\n\n\n private string line = null;\n private int pos = 0;\n\n public IFormatProvider FormatProvider { get; set; }\n public NumberStyles NumberStyle { get; set; }\n public TextReader TextReader { get; set; }\n\n public TextInput(string path) : this(path, NumberStyles.Any, CultureInfo.InvariantCulture)\n {\n }\n public TextInput(string path, NumberStyles numberStyle, IFormatProvider formatProvider) : this(new StreamReader(path), numberStyle, formatProvider)\n {\n\n }\n public TextInput(TextReader textReader) : this(textReader, NumberStyles.Any, CultureInfo.InvariantCulture)\n {\n\n }\n public TextInput(TextReader textReader, NumberStyles numberStyle, IFormatProvider formatProvider)\n {\n TextReader = textReader;\n NumberStyle = numberStyle;\n FormatProvider = formatProvider;\n }\n\n public bool IsEof\n {\n get\n {\n return line == null && TextReader.Peek() == -1;\n }\n }\n public void SkipWhiteSpace()\n {\n while (!IsEof)\n {\n if (line != null && pos < line.Length && !char.IsWhiteSpace(line[pos]))\n {\n return;\n }\n if (line == null || pos >= line.Length)\n {\n Next();\n continue;\n }\n while (pos < line.Length && char.IsWhiteSpace(line[pos]))\n {\n pos++;\n }\n }\n }\n private void SkipWhiteSpace(bool force)\n {\n if (force)\n {\n SkipWhiteSpace();\n }\n else\n {\n SkipWhiteSpace();\n }\n }\n\n public T[] ReadArray()\n {\n var length = Read();\n return ReadArray(length);\n }\n public T[] ReadArray(int length)\n {\n var array = new T[length];\n\n var parser = GetParser();\n var style = NumberStyle;\n var format = FormatProvider;\n\n for (var i = 0; i < length; i++)\n {\n array[i] = Read(parser, style, format);\n }\n return array;\n }\n\n public bool TryReadArray(out T[] array)\n {\n return TryReadArray(GetParser(), NumberStyle, FormatProvider, out array);\n }\n public bool TryReadArray(out T[] array, int length)\n {\n return TryReadArray(GetParser(), NumberStyle, FormatProvider, out array, length);\n }\n public bool TryReadArray(T[] array, int offset, int length)\n {\n return TryReadArray(GetParser(), NumberStyle, FormatProvider, array, offset, length);\n }\n public bool TryReadArray(TryParseDelegate parser, NumberStyles style, IFormatProvider format, out T[] array)\n {\n var length = 0;\n if (!TryRead(out length))\n {\n array = null;\n return false;\n }\n array = new T[length];\n return TryReadArray(parser, style, format, array, 0, length);\n }\n public bool TryReadArray(TryParseDelegate parser, NumberStyles style, IFormatProvider format, out T[] array, int length)\n {\n array = new T[length];\n return TryReadArray(parser, style, format, array, 0, length);\n }\n public bool TryReadArray(TryParseDelegate parser, NumberStyles style, IFormatProvider format, T[] array, int offset, int length)\n {\n var result = true;\n for (var i = 0; i < length && result; i++)\n {\n result &= TryRead(parser, style, format, out array[offset + i]);\n }\n return result;\n }\n\n private TryParseDelegate GetParser()\n {\n var type = typeof(T);\n return (TryParseDelegate)primitiveParsers[type];\n }\n public T Read()\n {\n return Read(GetParser());\n }\n public T Read(NumberStyles style, IFormatProvider format)\n {\n return Read(GetParser(), style, format);\n }\n public T Read(TryParseDelegate parser)\n {\n return Read(parser, NumberStyle, FormatProvider);\n }\n public T Read(TryParseDelegate parser, NumberStyles style, IFormatProvider format)\n {\n T result;\n if (!TryRead(parser, style, format, out result))\n {\n throw new FormatException();\n }\n return result;\n }\n public bool TryRead(out T value)\n {\n return TryRead(GetParser(), out value);\n }\n public bool TryRead(NumberStyles style, IFormatProvider format, out T value)\n {\n return TryRead(GetParser(), style, format, out value);\n }\n public bool TryRead(TryParseDelegate parser, out T value)\n {\n return parser(ReadToken(), NumberStyle, FormatProvider, out value);\n }\n public bool TryRead(TryParseDelegate parser, NumberStyles style, IFormatProvider format, out T value)\n {\n return parser(ReadToken(), style, format, out value);\n }\n public string ReadToken()\n {\n SkipWhiteSpace(false);\n if (IsEof)\n {\n throw new EndOfStreamException();\n }\n\n if (pos >= line.Length || char.IsWhiteSpace(line[pos])) return string.Empty;\n\n var start = pos;\n while (pos < line.Length && !char.IsWhiteSpace(line[pos]))\n {\n pos++;\n }\n return line.Substring(start, pos - start);\n }\n public string ReadLine()\n {\n if (IsEof)\n {\n throw new EndOfStreamException();\n }\n if (line == null || pos >= line.Length)\n {\n Next();\n }\n\n var ans = line.Substring(pos);\n pos = line.Length;\n return ans;\n }\n\n private void Next()\n {\n line = TextReader.ReadLine();\n pos = 0;\n }\n}\n\npublic class TextOutput\n{\n public IFormatProvider FormatProvider { get; set; }\n public TextWriter TextWriter { get; set; }\n\n public TextOutput(string path) : this(path, CultureInfo.InvariantCulture)\n {\n }\n public TextOutput(string path, IFormatProvider formatProvider) : this(new StreamWriter(path), formatProvider)\n {\n\n }\n public TextOutput(TextWriter textWriter) : this(textWriter, CultureInfo.InvariantCulture)\n {\n\n }\n public TextOutput(TextWriter textWriter, IFormatProvider formatProvider)\n {\n TextWriter = textWriter;\n FormatProvider = formatProvider;\n }\n\n public TextOutput WriteArray(params T[] array)\n {\n return WriteArray(array, true);\n }\n public TextOutput WriteArray(T[] array, bool appendLine)\n {\n return WriteArray(array, 0, array.Length, appendLine);\n }\n public TextOutput WriteArray(T[] array, int offset, int length, bool appendLine = true)\n {\n var sb = new StringBuilder();\n for (var i = 0; i < length; i++)\n {\n sb.Append(Convert.ToString(array[offset + i], FormatProvider));\n if (i + 1 < length)\n {\n sb.Append(' ');\n }\n }\n return appendLine ? WriteLine(sb.ToString()) : Write(sb.ToString());\n }\n\n public TextOutput WriteLine(object obj)\n {\n return WriteLine(Convert.ToString(obj, FormatProvider));\n }\n public TextOutput WriteLine(string text, params object[] args)\n {\n return WriteLine(string.Format(FormatProvider, text, args));\n }\n public TextOutput WriteLine(string text)\n {\n TextWriter.WriteLine(text);\n return this;\n }\n public TextOutput WriteLine(char[] buffer)\n {\n TextWriter.WriteLine(buffer);\n return this;\n }\n public TextOutput WriteLine(char[] buffer, int offset, int length)\n {\n TextWriter.WriteLine(buffer, offset, length);\n return this;\n }\n public TextOutput WriteLine()\n {\n TextWriter.WriteLine();\n return this;\n }\n\n public TextOutput Write(object obj)\n {\n return Write(Convert.ToString(obj, FormatProvider));\n }\n public TextOutput Write(string text, params object[] args)\n {\n return Write(string.Format(FormatProvider, text, args));\n }\n public TextOutput Write(string text)\n {\n TextWriter.Write(text);\n return this;\n }\n public TextOutput Write(char[] buffer)\n {\n TextWriter.Write(buffer);\n return this;\n }\n public TextOutput Write(char[] buffer, int offset, int length)\n {\n TextWriter.Write(buffer, offset, length);\n return this;\n }\n}\n#endregion", "lang_cluster": "C#", "tags": ["math", "geometry"], "code_uid": "745269aa5a910e46825147af96751356", "src_uid": "509db9cb6156b692557ba874a09f150e", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.IO;\nusing System.Text;\n\nnamespace Turn\n{\n internal class Program\n {\n private static readonly StreamReader reader = new StreamReader(Console.OpenStandardInput(1024*10), Encoding.ASCII, false, 1024*10);\n private static readonly StreamWriter writer = new StreamWriter(Console.OpenStandardOutput(1024*10), Encoding.ASCII, 1024*10);\n\n private static void Main(string[] args)\n {\n long n = long.Parse(reader.ReadLine());\n\n n %= 360;\n\n if (n >= 0)\n {\n if (n <= 45)\n writer.WriteLine(\"0\");\n else if (n <= 45 + 90)\n writer.WriteLine(\"1\");\n else if (n <= 45 + 180)\n writer.WriteLine(\"2\");\n else if (n < 45 + 270)\n writer.WriteLine(\"3\");\n else\n {\n writer.WriteLine(\"0\");\n }\n }\n else\n {\n if (n >= -45)\n writer.WriteLine(\"0\");\n else if (n > -45 - 90)\n writer.WriteLine(\"3\");\n else if (n > -45 - 180)\n writer.WriteLine(\"2\");\n else if (n > -45 - 270)\n writer.WriteLine(\"1\");\n else\n {\n writer.WriteLine(\"0\");\n }\n }\n\n\n writer.WriteLine();\n writer.Flush();\n }\n }\n}", "lang_cluster": "C#", "tags": ["math", "geometry"], "code_uid": "2d2fd6a2929914cef534e31508d178d5", "src_uid": "509db9cb6156b692557ba874a09f150e", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Globalization;\nusing System.IO;\nusing System.Linq;\nusing System.Text;\n\nclass Program\n{\n public class Num : IComparable\n {\n public int A, B;\n\n public Num(int x)\n {\n this.A = x;\n this.B = 1;\n }\n\n public Num(int a, int b)\n {\n this.A = a;\n this.B = b;\n this.Normalize();\n }\n\n public void Abs()\n {\n if (this.A < 0)\n {\n this.A = -this.A;\n }\n }\n\n public static Num operator +(Num a, Num b)\n {\n var top = a.A * b.B + b.A * a.B;\n var bot = a.B * b.B;\n\n return new Num(top, bot);\n }\n\n public static Num operator -(Num a, Num b)\n {\n return a + new Num(-b.A, b.B);\n }\n\n public static Num operator *(Num a, Num b)\n {\n var top = a.A * b.A;\n var bot = a.B * b.B;\n\n return new Num(top, bot);\n }\n\n public static Num operator /(Num a, Num b)\n {\n var top = a.A * b.B;\n var bot = a.B * b.A;\n\n return new Num(top, bot);\n }\n\n public void Normalize()\n {\n var gcd = GCD(A, B);\n if (gcd > 1)\n {\n this.A /= gcd;\n this.B /= gcd;\n }\n }\n\n public override string ToString()\n {\n return this.A.ToString() + \"/\" + this.B.ToString();\n }\n\n public int CompareTo(Num other)\n {\n return (this.A * other.B).CompareTo(this.B * other.A);\n }\n }\n\n private static void Main(string[] args)\n {\n PushTestData(@\"\n4\n(99+98)/97\n(26+4)/10\n(12+33)/15\n(5+1)/7\n\");\n var r = RI();\n var b = RI();\n Console.WriteLine(r == b ? \"Yes\" : \"No\");\n }\n\n private const int Mod = 1000000000 + 7;\n\n #region Data Read\n\n private static int GCD(int a, int b)\n {\n if (a % b == 0) return b;\n return GCD(b, a % b);\n }\n\n private static List[] ReadTree(int n)\n {\n return ReadGraph(n, n - 1);\n }\n\n private static List[] ReadGraph(int n, int m)\n {\n List[] g = new List[n];\n for (int i = 0; i < g.Length; i++) g[i] = new List();\n for (int i = 0; i < m; i++)\n {\n int a = RI() - 1;\n int b = RI() - 1;\n\n g[a].Add(b);\n g[b].Add(a);\n }\n\n return g;\n }\n\n private static int[,] ReadGraphAsMatrix(int n, int m)\n {\n int[,] matrix = new int[n + 1, n + 1];\n for (int i = 0; i < m; i++)\n {\n int a = RI();\n int b = RI();\n matrix[a, b] = matrix[b, a] = 1;\n }\n\n return matrix;\n }\n\n private static void Sort(ref int a, ref int b)\n {\n if (a > b) Swap(ref a, ref b);\n }\n\n private static void Swap(ref int a, ref int b)\n {\n int tmp = a;\n a = b;\n b = tmp;\n }\n\n private const int BufferSize = 1 << 16;\n private static StreamReader consoleReader;\n private static MemoryStream testData;\n\n private static int RI()\n {\n int ans = 0;\n int mul = 1;\n do\n {\n ans = consoleReader.Read();\n if (ans == -1)\n return 0;\n if (ans == '-') mul = -1;\n } while (ans < '0' || ans > '9');\n\n ans -= '0';\n while (true)\n {\n int chr = consoleReader.Read();\n if (chr < '0' || chr > '9')\n return ans * mul;\n ans = ans * 10 + chr - '0';\n }\n }\n\n private static ulong RUL()\n {\n ulong ans = 0;\n int chr;\n do\n {\n chr = consoleReader.Read();\n if (chr == -1)\n return 0;\n } while (chr < '0' || chr > '9');\n\n ans = (uint)(chr - '0');\n while (true)\n {\n chr = consoleReader.Read();\n if (chr < '0' || chr > '9')\n return ans;\n ans = ans * 10 + (uint)(chr - '0');\n }\n }\n\n private static long RL()\n {\n long ans = 0;\n int mul = 1;\n do\n {\n ans = consoleReader.Read();\n if (ans == -1)\n return 0;\n if (ans == '-') mul = -1;\n } while (ans < '0' || ans > '9');\n\n ans -= '0';\n while (true)\n {\n int chr = consoleReader.Read();\n if (chr < '0' || chr > '9')\n return ans * mul;\n ans = ans * 10 + chr - '0';\n }\n }\n\n private static int[] RIA(int n)\n {\n int[] ans = new int[n];\n for (int i = 0; i < n; i++)\n ans[i] = RI();\n return ans;\n }\n\n private static long[] RLA(int n)\n {\n long[] ans = new long[n];\n for (int i = 0; i < n; i++)\n ans[i] = RL();\n return ans;\n }\n\n private static char[] ReadWord()\n {\n int ans;\n\n do\n {\n ans = consoleReader.Read();\n } while (!((ans >= 'a' && ans <= 'z') || (ans >= 'A' && ans <= 'Z') || (ans == '*')));\n\n List s = new List();\n do\n {\n s.Add((char)ans);\n ans = consoleReader.Read();\n } while ((ans >= 'a' && ans <= 'z') || (ans >= 'A' && ans <= 'Z') || (ans == '*'));\n\n return s.ToArray();\n }\n\n private static char[] ReadString(int n)\n {\n int ans;\n\n do\n {\n ans = consoleReader.Read();\n } while (!((ans >= 'a' && ans <= 'z') || (ans >= 'A' && ans <= 'Z')));\n\n char[] s = new char[n];\n int pos = 0;\n do\n {\n s[pos++] = (char)ans;\n if (pos == n) break;\n ans = consoleReader.Read();\n } while ((ans >= 'a' && ans <= 'z') || (ans >= 'A' && ans <= 'Z'));\n\n return s;\n }\n\n private static char[] ReadStringLine()\n {\n int ans;\n\n do\n {\n ans = consoleReader.Read();\n } while (ans == 10 || ans == 13);\n\n List s = new List();\n\n do\n {\n s.Add((char)ans);\n ans = consoleReader.Read();\n } while (ans != 10 && ans != 13 && ans != -1);\n\n return s.ToArray();\n }\n\n private static char ReadLetter()\n {\n while (true)\n {\n int ans = consoleReader.Read();\n if ((ans >= 'a' && ans <= 'z') || (ans >= 'A' && ans <= 'Z'))\n return (char)ans;\n }\n }\n private static char ReadNonLetter()\n {\n while (true)\n {\n int ans = consoleReader.Read();\n if (!((ans >= 'a' && ans <= 'z') || (ans >= 'A' && ans <= 'Z')))\n return (char)ans;\n }\n }\n\n private static char ReadAnyOf(IEnumerable allowed)\n {\n while (true)\n {\n char ans = (char)consoleReader.Read();\n if (allowed.Contains(ans))\n return ans;\n }\n }\n\n private static char ReadDigit()\n {\n while (true)\n {\n int ans = consoleReader.Read();\n if (ans >= '0' && ans <= '9')\n return (char)ans;\n }\n }\n\n private static int ReadDigitInt()\n {\n return ReadDigit() - (int)'0';\n }\n\n private static char ReadAnyChar()\n {\n return (char)consoleReader.Read();\n }\n\n private static string DoubleToString(double x)\n {\n return x.ToString(CultureInfo.InvariantCulture);\n }\n\n private static double DoubleFromString(string x)\n {\n return double.Parse(x, CultureInfo.InvariantCulture);\n }\n\n static Program()\n {\n //Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;\n consoleReader = new StreamReader(Console.OpenStandardInput(BufferSize), Encoding.ASCII, false, BufferSize);\n }\n\n private static void PushTestData(StringBuilder sb)\n {\n PushTestData(sb.ToString());\n }\n private static void PushTestData(string data)\n {\n#if TOLYAN_TEST\n if (testData == null)\n {\n testData = new MemoryStream();\n consoleReader = new StreamReader(testData);\n }\n\n var pos = testData.Position;\n var bytes = Encoding.UTF8.GetBytes(data);\n testData.Write(bytes, 0, bytes.Length);\n testData.Flush();\n testData.Position = pos;\n#endif\n }\n #endregion\n}", "lang_cluster": "C#", "tags": ["math", "greedy", "geometry", "brute force"], "code_uid": "5568b47973b7b192d3872300aeda940b", "src_uid": "65f81f621c228c09915adcb05256c634", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeff// Submitted by Stratholme @ Macau\nusing System;\nusing System.IO;\nusing System.Collections.Generic;\nusing CCF_XOI;\n\nnamespace CodeForces\n{\n\tclass CF526_ZeptoCodeRush2015_C\n\t{\n\t\tpublic void Solve(XOI xoi)\n\t\t{\n\t\t\tlong C, Wr, Wb, Hr, Hb, Nb, Nr, v, ans;\n\n\t\t\tC = xoi.ReadLong();\n\t\t\tHr = xoi.ReadLong();\n\t\t\tHb = xoi.ReadLong();\n\t\t\tWr = xoi.ReadLong();\n\t\t\tWb = xoi.ReadLong();\n\n\t\t\tif (Hb * Wr < Hr * Wb)\n\t\t\t{\n\t\t\t\tlong tw = Wb, th = Hb;\n\t\t\t\tWb = Wr; Hb = Hr;\n\t\t\t\tWr = tw; Hr = th;\n\t\t\t}\n\n\t\t\tfor (Nr = ans = 0; (Nr < 10000000) && (Nr * Wr <= C); Nr++)\n\t\t\t{\n\t\t\t\tNb = (C - Nr * Wr) / Wb;\n\t\t\t\tv = Nb * Hb + ((C - Nb * Wb) / Wr) * Hr;\n\t\t\t\tans = Math.Max(ans, v);\n\t\t\t}\n\n\t\t\txoi.o.WriteLine(ans);\n\t\t}\n\t}\n\n\tclass CodeForcesMain\n\t{\n\t\tstatic void Main(string[] args)\n\t\t{\n\t\t\t(new CF526_ZeptoCodeRush2015_C()).Solve(new XOI());\n\t\t}\n\t}\n}\n\nnamespace CCF_XOI\n{\t// version 2014.06.20\n\tclass XOI\n\t{\n\t\tprotected StreamReader sr;\n\t\tpublic StreamWriter o;\n\t\tprotected Queue buf = new Queue();\n\t\tpublic bool EOF = false;\n\n\t\tpublic XOI()\n\t\t{\n\t\t\tthis.sr = new StreamReader(Console.OpenStandardInput());\n\t\t\tthis.o = new StreamWriter(Console.OpenStandardOutput());\n\t\t\tthis.o.AutoFlush = true;\n\t\t}\n\n\t\tpublic XOI(string in_path, string out_path)\n\t\t{\n\t\t\tthis.sr = new StreamReader(in_path);\n\t\t\tthis.o = new StreamWriter(out_path);\n\t\t\tthis.o.AutoFlush = true;\n\t\t}\n\n\t\tpublic int ReadInt()\n\t\t{\n\t\t\tstring s = this.GetNext();\n\t\t\tif (s == null) return -1;\n\t\t\telse return Int32.Parse(s);\n\t\t}\n\n\t\tpublic long ReadLong()\n\t\t{\n\t\t\tstring s = this.GetNext();\n\t\t\tif (s == null) return -1;\n\t\t\telse return Int64.Parse(s);\n\t\t}\n\n\t\tpublic double ReadDouble()\n\t\t{\n\t\t\tstring s = this.GetNext();\n\t\t\tif (s == null) return -1;\n\t\t\telse return Double.Parse(s, System.Globalization.CultureInfo.InvariantCulture);\n\t\t}\n\n\t\tpublic string ReadString()\n\t\t{\n\t\t\tstring s = this.GetNext();\n\t\t\treturn (s == null ? null : s);\n\t\t}\n\n\t\tpublic string ReadLine()\n\t\t{\t// I will ignore current buffer and read a new line\n\t\t\tstring s = \"\";\n\t\t\twhile (s == \"\" && !this.EOF)\n\t\t\t{\n\t\t\t\ts = sr.ReadLine();\n\t\t\t\tthis.EOF = (s == null);\n\t\t\t}\n\t\t\treturn (this.EOF ? null : s);\n\t\t}\n\n\t\tprotected string GetNext()\n\t\t{\n\t\t\tif (buf.Count == 0)\n\t\t\t{\n\t\t\t\twhile (buf.Count == 0 && !this.EOF)\n\t\t\t\t{\n\t\t\t\t\tstring s = sr.ReadLine();\n\t\t\t\t\tif (s == null)\n\t\t\t\t\t\tthis.EOF = true;\n\t\t\t\t\telse\n\t\t\t\t\t\tforeach (string ss in s.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries))\n\t\t\t\t\t\t\tbuf.Enqueue(ss);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn (this.EOF ? null : buf.Dequeue());\n\t\t}\n\t}\n}\n", "lang_cluster": "C#", "tags": ["math", "greedy", "brute force"], "code_uid": "e99a15d9184c3d4a3a3dcd855f1043ce", "src_uid": "eb052ca12ca293479992680581452399", "difficulty": 2000.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.IO;\nusing System.Collections;\nusing System.Collections.Generic;\nusing System.Text;\nusing System.Reflection;\nusing System.Net.Sockets;\nusing System.Xml;\nusing System.Diagnostics;\nusing System.Linq;\nusing System.Threading;\n\nclass Tree\n{\n public int Index;\n\n public Tree Left;\n public Tree Right;\n\n public int Price;\n\n public void RecalcPrice()\n {\n if(Left != null && Right != null)\n {\n var min = Math.Min(Left.Price, Right.Price);\n Left.Price -= min;\n Right.Price -= min;\n\n Price += min;\n }\n }\n\n public long CalcPrice()\n {\n long res = 0;\n\n if (Left != null && Right != null)\n {\n res += Left.CalcPrice();\n res += Right.CalcPrice();\n\n RecalcPrice();\n res += Math.Max(Left.Price, Right.Price);\n Price += Math.Max(Left.Price, Right.Price);\n\n Left.Price = Right.Price = 0;\n }\n\n return res;\n }\n public void Build(int h)\n {\n if (h == 0) return;\n\n Left = new Tree();\n Right = new Tree();\n\n Left.Build(h - 1);\n Right.Build(h - 1);\n }\n public void CalcIndex(Tree[] output)\n {\n var index = 0;\n\n Queue q = new Queue();\n q.Enqueue(this);\n\n while(q.Count > 0)\n {\n var t = q.Dequeue();\n t.Index = index++;\n output[t.Index] = t;\n\n if (t.Left != null) q.Enqueue(t.Left);\n if (t.Right != null) q.Enqueue(t.Right);\n }\n }\n}\nstatic class Program\n{\n #region IO\n public delegate ReadDelegate ReadDelegate(out T value);\n public delegate bool ParserDelegate(string word, out T item);\n\n public class Input : IDisposable\n {\n private static EventArgs DefaultEventArgs = new EventArgs();\n\n public TextReader TextReader { get; private set; }\n\n public event EventHandler OnEndOfStream;\n public event EventHandler OnParseError;\n public event EventHandler OnReadError;\n\n public bool CanRead { get; private set; }\n public bool ThrowExceptions { get; set; }\n\n string line = string.Empty;\n int pos = 0;\n\n static EventHandler emptyHandler;\n\n public Input(string path)\n : this(File.OpenRead(path))\n {\n }\n public Input(Stream s)\n : this(new StreamReader(s))\n {\n\n }\n public Input(TextReader tr)\n {\n TextReader = tr;\n\n if (emptyHandler == null)\n emptyHandler = (a, b) => { };\n\n OnEndOfStream = emptyHandler;\n OnParseError = emptyHandler;\n OnReadError = emptyHandler;\n\n CanRead = true;\n }\n\n public static implicit operator Input(Stream s)\n {\n return new Input(s);\n }\n public static implicit operator Input(TextReader tr)\n {\n return new Input(tr);\n }\n\n private bool ReadStream()\n {\n if (!CanRead) return false;\n if (pos < line.Length) return true;\n\n Clear();\n\n string s = TextReader.ReadLine();\n if (s == null)\n {\n CanRead = false;\n return false;\n }\n\n line = s;\n return true;\n }\n\n public ReadDelegate r(out T value)\n {\n value = ReadData();\n return r;\n }\n\n public void SkipChar()\n {\n if (pos < line.Length) pos++;\n else\n {\n ReadStream();\n }\n }\n public void SkipChars(int length)\n {\n while (length > 0)\n {\n int dt = line.Length - pos;\n if (dt <= 0)\n {\n length--;\n if (!ReadStream()) return;\n }\n dt = Math.Min(length, dt);\n pos += dt;\n length -= dt;\n }\n }\n\n public void SkipWhiteSpace()\n {\n while (true)\n {\n for (; pos < line.Length; pos++)\n {\n if (!char.IsWhiteSpace(line[pos])) return;\n }\n if (!ReadStream())\n {\n OnEndOfStream(this, DefaultEventArgs);\n return;\n }\n }\n }\n public bool CanReadData()\n {\n SkipWhiteSpace();\n return CanRead;\n }\n\n public T[] ReadArray()\n {\n int length = ReadInt32();\n return ReadArray(length);\n }\n public T[] ReadArray(int length)\n {\n ParserDelegate parser = Parser.GetPrimitiveParser();\n return ReadArray(length, parser);\n }\n public T[] ReadArray(ParserDelegate parser)\n {\n int length = ReadInt32();\n return ReadArray(length, parser);\n }\n public T[] ReadArray(int length, ParserDelegate parser)\n {\n T[] res = new T[length];\n for (int i = 0; i < length; i++)\n {\n res[i] = ReadData(parser);\n }\n return res;\n }\n\n public Decimal ReadDecimal()\n {\n return ReadData(Parser.DecimalParser);\n }\n public Double ReadDouble()\n {\n return ReadData(Parser.DoubleParser);\n }\n public Single ReadSingle()\n {\n return ReadData(Parser.SingleParser);\n }\n public UInt64 ReadUInt64()\n {\n return ReadData(UInt64.TryParse);\n }\n public UInt32 ReadUInt32()\n {\n return ReadData(UInt32.TryParse);\n }\n public UInt16 ReadUInt16()\n {\n return ReadData(UInt16.TryParse);\n }\n public Int64 ReadInt64()\n {\n return ReadData(Int64.TryParse);\n }\n public Int32 ReadInt32()\n {\n return ReadData(Int32.TryParse);\n }\n public Int16 ReadInt16()\n {\n return ReadData(Int16.TryParse);\n }\n public Boolean ReadYesNo()\n {\n return ReadData(Parser.YesNoParser);\n }\n public Boolean ReadBoolean()\n {\n return ReadData(Boolean.TryParse);\n }\n public Byte ReadByte()\n {\n return ReadData(Byte.TryParse);\n }\n\n private bool ReadCheck()\n {\n if (!CanRead)\n {\n OnReadError(this, DefaultEventArgs);\n if (ThrowExceptions)\n {\n throw new Exception(\"!CanRead\");\n }\n return false;\n }\n return true;\n }\n public T ReadData()\n {\n return ReadData(true);\n }\n public T ReadData(bool skipWhiteSpace)\n {\n ParserDelegate parser = Parser.GetPrimitiveParser();\n return ReadData(parser, skipWhiteSpace);\n }\n public T ReadData(ParserDelegate parser)\n {\n return ReadData(parser, true);\n }\n public T ReadData(ParserDelegate parser, bool skipWhiteSpace)\n {\n if (skipWhiteSpace)\n SkipWhiteSpace();\n\n if (!ReadCheck()) return default(T);\n\n string s = ReadWord(false);\n\n T res;\n if (!parser.Invoke(s, out res))\n {\n OnParseError(this, DefaultEventArgs);\n if (ThrowExceptions)\n {\n throw new Exception(\"!validate, word = \" + Output.ToString(s, 256));\n }\n }\n return res;\n }\n\n public string ReadWord()\n {\n return ReadWord(true);\n }\n public string ReadWord(bool skipWhiteSpace)\n {\n if (skipWhiteSpace)\n SkipWhiteSpace();\n\n if (!ReadCheck()) return string.Empty;\n\n int from = pos;\n int to = pos;\n for (int i = pos; i < line.Length; i++)\n {\n if (char.IsWhiteSpace(line[i])) break;\n to = i + 1;\n }\n pos = to;\n\n return line.Substring(from, to - from);\n }\n\n public string ReadLine()\n {\n if (!ReadCheck()) return string.Empty;\n\n ReadStream();\n string res = line.Substring(pos);\n pos = line.Length;\n\n return res;\n }\n\n public void Close()\n {\n TextReader.Close();\n }\n public void Clear()\n {\n pos = 0;\n line = string.Empty;\n }\n\n private bool disposed = false;\n public void Dispose()\n {\n Dispose(true);\n GC.SuppressFinalize(this);\n }\n\n protected virtual void Dispose(bool disposing)\n {\n if (!this.disposed)\n {\n if (disposing)\n {\n line = string.Empty;\n TextReader.Dispose();\n }\n disposed = true;\n }\n }\n ~Input()\n {\n Dispose(false);\n }\n }\n public class Output : IDisposable\n {\n static char[] space = new char[] { ' ' };\n\n public TextWriter TextWriter { get; private set; }\n public bool AutoFlush { get; set; }\n\n\n public static string ToString(object obj, int maxLength)\n {\n return ToString(FormatReal(obj), maxLength);\n }\n public static string ToString(string s, int maxLength)\n {\n if (s.Length <= maxLength) return s;\n else return s.Substring(0, maxLength) + \"...\";\n }\n public static object FormatReal(object v, string format)\n {\n if (v is decimal) return ((decimal)v).ToString(format).Replace(',', '.');\n if (v is double) return ((double)v).ToString(format).Replace(',', '.');\n if (v is float) return ((float)v).ToString(format).Replace(',', '.');\n\n return v;\n }\n public static object FormatReal(object v)\n {\n if (v is decimal || v is double || v is float)\n {\n return v.ToString().Replace(',', '.');\n }\n return v;\n }\n\n public Output()\n : this(new MemoryStream())\n {\n }\n public Output(string path)\n : this(File.Create(path))\n {\n\n }\n public Output(Stream s)\n : this(new StreamWriter(s))\n {\n }\n public Output(TextWriter tw)\n {\n TextWriter = tw;\n }\n\n public static implicit operator Output(Stream s)\n {\n return new Output(s);\n }\n\n public static implicit operator Output(TextWriter tw)\n {\n return new Output(tw);\n }\n\n public static Output operator +(Output output, object obj)\n {\n output.Write(obj);\n return output;\n }\n public Output WriteArray(params T[] array)\n {\n return WriteArray(array, false);\n }\n public Output WriteArray(T[] array, bool appendLength)\n {\n return WriteArray(array, 0, array.Length, appendLength);\n }\n public Output WriteArray(T[] array, int index, int count)\n {\n return WriteArray(array, index, count, false);\n }\n public Output WriteArray(T[] array, int index, int count, bool appendLength)\n {\n if (index + count > array.Length)\n {\n string message = string.Format(\n \"Index out of range: {0} + {1} >= {2}\",\n index,\n count,\n array.Length);\n throw new Exception(message);\n }\n if (appendLength)\n {\n WriteLine(count);\n }\n for (int i = 0; i < count; i++)\n {\n Write(array[i + index]);\n Write(space, 0, space.Length);\n }\n WriteLine();\n\n return this;\n }\n public Output WriteLine(object obj)\n {\n obj = FormatReal(obj);\n return WriteLine(obj.ToString());\n }\n public Output WriteLine(string format, params object[] args)\n {\n return WriteLine(string.Format(format, args));\n }\n public Output WriteLine(string s)\n {\n return WriteLine(s.ToCharArray());\n }\n public Output WriteLine(char[] buffer)\n {\n return WriteLine(buffer, 0, buffer.Length);\n }\n public Output WriteLine(char[] buffer, int index, int count)\n {\n TextWriter.WriteLine(buffer, index, count);\n if (AutoFlush) TextWriter.Flush();\n return this;\n }\n public Output WriteLine()\n {\n TextWriter.WriteLine();\n if (AutoFlush) TextWriter.Flush();\n return this;\n }\n public Output Write(object obj)\n {\n obj = FormatReal(obj);\n return Write(obj.ToString());\n }\n public Output Write(string format, params object[] args)\n {\n return Write(string.Format(format, args));\n }\n public Output Write(string s)\n {\n return Write(s.ToCharArray());\n }\n public Output Write(char[] buffer)\n {\n return Write(buffer, 0, buffer.Length);\n }\n public Output Write(char[] buffer, int index, int count)\n {\n TextWriter.Write(buffer, index, count);\n if (AutoFlush) TextWriter.Flush();\n return this;\n }\n\n public void Close()\n {\n TextWriter.Close();\n }\n public void Flush()\n {\n TextWriter.Flush();\n }\n\n\n private bool disposed = false;\n public void Dispose()\n {\n Dispose(true);\n GC.SuppressFinalize(this);\n }\n\n protected virtual void Dispose(bool disposing)\n {\n if (!this.disposed)\n {\n if (disposing)\n {\n TextWriter.Dispose();\n }\n disposed = true;\n }\n }\n ~Output()\n {\n Dispose(false);\n }\n }\n public static class Parser\n {\n public static ParserDelegate GetPrimitiveParser()\n {\n if (!typeof(T).IsPrimitive && typeof(T) != typeof(String)) throw new Exception(\"Unknown type\");\n else if (default(T) is Byte) return new ParserDelegate(Byte.TryParse) as ParserDelegate;\n else if (default(T) is Boolean) return new ParserDelegate(Boolean.TryParse) as ParserDelegate;\n else if (default(T) is Int16) return new ParserDelegate(Int16.TryParse) as ParserDelegate;\n else if (default(T) is Int32) return new ParserDelegate(Int32.TryParse) as ParserDelegate;\n else if (default(T) is Int64) return new ParserDelegate(Int64.TryParse) as ParserDelegate;\n else if (default(T) is UInt16) return new ParserDelegate(UInt16.TryParse) as ParserDelegate;\n else if (default(T) is UInt32) return new ParserDelegate(UInt32.TryParse) as ParserDelegate;\n else if (default(T) is UInt64) return new ParserDelegate(UInt64.TryParse) as ParserDelegate;\n else if (default(T) is Single) return new ParserDelegate(Parser.SingleParser) as ParserDelegate;\n else if (default(T) is Double) return new ParserDelegate(Parser.DoubleParser) as ParserDelegate;\n else if (default(T) is Decimal) return new ParserDelegate(Parser.DecimalParser) as ParserDelegate;\n else if (typeof(T) == typeof(String)) return new ParserDelegate(Parser.StringParser) as ParserDelegate;\n else throw new Exception(\"Unknown type\");\n }\n public static bool YesNoParser(string s, out Boolean result)\n {\n s = s.ToLower();\n if (s == \"yes\") result = true;\n else if (s == \"no\") result = false;\n else\n {\n result = false;\n return false;\n }\n return true;\n }\n public static bool ReplaceDot;\n public static bool StringParser(string s, out string result)\n {\n result = s;\n return string.IsNullOrEmpty(s);\n }\n private static string fs(string s)\n {\n if (ReplaceDot) return s.Replace(',', '.');\n else return s;\n }\n public static bool DecimalParser(string s, out Decimal result)\n {\n return Decimal.TryParse(fs(s), out result);\n }\n public static bool DoubleParser(string s, out Double result)\n {\n return Double.TryParse(fs(s), out result);\n }\n public static bool SingleParser(string s, out Single result)\n {\n return Single.TryParse(fs(s), out result);\n }\n }\n #endregion\n #region Streams\n static string endl = Environment.NewLine;\n static Input cin = new Input(Console.In);\n static Output cout = new Output(Console.Out);\n static Output cerr = new Output(Console.Error);\n static StringBuilder sb = new StringBuilder();\n #endregion\n #region Time\n //*\n static Stopwatch sw = new Stopwatch();\n static void Start()\n {\n sw.Reset();\n sw.Start();\n }\n static void Restart(string text = \"\")\n {\n Stop(text);\n Start();\n }\n static void Time(string text = \"\")\n {\n if (string.IsNullOrEmpty(text))\n {\n cerr.WriteLine(sw.Elapsed);\n }\n else\n {\n cerr.WriteLine(text + \": \" + sw.Elapsed);\n }\n }\n static void Stop(string text = \"\")\n {\n sw.Stop();\n Time(text);\n }\n //*/\n #endregion\n\n static void InitIO(string name)\n {\n#if DEBUG\n#else\n cin = new Input(name + \".in\");\n cout = new Output(name + \".out\");\n Parser.ReplaceDot = false;\n#endif\n }\n\n static long Slow(long c, long hr, long hb, long wr, long wb)\n {\n var min = 0;\n var max = c / wr;\n\n long res = 0;\n\n for (var i = min; i <= max; i++)\n {\n long c1 = i;\n long c2 = (c - wr * i) / wb;\n c1 += (c - wr * c1 - wb * c2) / wr;\n\n long t = c1 * hr + c2 * hb;\n\n res = Math.Max(t, res);\n }\n return res;\n }\n static long Fast(long c, long hr, long hb, long wr, long wb)\n {\n if (hr * wb < hb * wr)\n {\n return Fast(c, hb, hr, wb, wr);\n }\n\n long res1 = c / wr * hr + ((c - (c / wr) * wr) / wb) * hb;\n long res2 = 0;\n\n long x = ((c - (c / wr) * wr) / wb);\n for (var i = 0; i * i <= c; i++)\n {\n x++;\n if (x * wb <= c)\n {\n var t = x * hb + ((c - x * wb) / wr) * hr;\n res2 = Math.Max(t, res2);\n }\n }\n\n return Math.Max(res1, res2);\n }\n static void Main()\n {\n var c = cin.ReadInt64();\n\n var hr = cin.ReadInt64();\n var hb = cin.ReadInt64();\n\n var wr = cin.ReadInt64();\n var wb = cin.ReadInt64();\n\n cout.WriteLine(Fast(c, hr, hb, wr, wb));\n }\n}", "lang_cluster": "C#", "tags": ["math", "greedy", "brute force"], "code_uid": "b3fd13053fc28f586d8aa9ee78edf01b", "src_uid": "eb052ca12ca293479992680581452399", "difficulty": 2000.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\n public class Program\n {\n public static void Main(string[] args)\n {\n int[] nms;\n int n;\n {\n string[] input = Console.In.ReadToEnd().Split(new char[] { '\\r', '\\n', '\\t', ' ' }, StringSplitOptions.RemoveEmptyEntries);\n nms = new int[3];\n for (int i = 2, curr; i < input.Length; ++i)\n {\n curr = int.Parse(input[i]);\n nms[0] += curr / 4;\n curr %= 4;\n if (curr == 3) nms[0]++;\n else if(curr!=0) nms[curr]++;\n }\n n = Math.Min(nms[1], nms[2]);\n nms[0] += n;\n nms[1] -= n;\n nms[2] -= n;\n n = int.Parse(input[0])*4;\n }\n if (nms[2] > 0) Helper(ref n, ref nms[2], false);\n else Helper(ref n, ref nms[1], true);\n if (nms[0] * 4 > n) Console.WriteLine(\"NO\");\n else Console.WriteLine(\"YES\");\n }\n private static void Helper(ref int n, ref int a, bool one)\n {\n a = n - a * 2;\n if (a >= 0) n += a;\n else\n {\n a = Math.Abs(a);\n if(one) { if (a % 4 != 0) a += 2; n-=a; }\n else { n -= (int)(Math.Ceiling(a / 3d) * 4d); }\n }\n }\n }", "lang_cluster": "C#", "tags": ["brute force", "greedy", "implementation"], "code_uid": "6f3aee10b18859d74364cb7390c24a0d", "src_uid": "d1f88a97714d6c13309c88fcf7d86821", "difficulty": 1900.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace ConsoleApp30\n{\n class Program\n {\n static void Main(string[] args)\n {\n string[] s = Console.ReadLine().Split();\n int n = Convert.ToInt32(s[0]);\n int k = Convert.ToInt32(s[1]);\n int po_4 = n;\n int po_2 = n * 2;\n s = Console.ReadLine().Split();\n int[] mas = new int[k];\n for (int i = 0; i < k; i++)\n {\n mas[i] = Convert.ToInt32(s[i]);\n }\n for (int i = 0; i < mas.Length; i++)\n {\n int l = mas[i]/4;\n if(po_4>=l)\n {\n po_4 -= l;\n mas[i] -= l * 4;\n }\n else\n {\n mas[i] -= po_4 * 4;\n po_4 = 0;\n }\n }\n int po_1 = 0;\n for (int i = 0; i < mas.Length; i++)\n {\n if(po_4==0)\n {\n int g = mas[i] / 2;\n if (mas[i] % 2 == 1)\n g++;\n if(po_2>=g)\n {\n po_2 -= g;\n mas[i] = 0;\n }\n }\n else\n {\n if(mas[i]==3)\n {\n po_4--;\n mas[i] = 0;\n }\n else\n {\n if(mas[i]==2)\n {\n if(po_2>0)\n {\n po_2--;\n mas[i] = 0;\n }\n else\n {\n if(po_4>0)\n {\n po_4--;\n po_1++;\n mas[i] = 0;\n }\n }\n }\n \n }\n }\n }\n /*\n else\n {\n if (mas[i] == 1)\n {\n if (po_1 > 0)\n {\n mas[i] = 0;\n po_1--;\n }\n else\n {\n\n }\n }\n }*/\n for (int i = 0; i < k; i++)\n {\n if(mas[i]!=0)\n {\n if(po_1>=mas[i])\n {\n po_1 -= mas[i];\n mas[i] = 0;\n }\n else\n {\n int l = mas[i] / 2 + mas[i] % 2;\n if(po_2>=l)\n {\n po_2 -= l;\n mas[i] = 0;\n }\n else\n {\n if(po_4>0)\n {\n po_4--;\n mas[i]--;\n po_1++;\n }\n }\n }\n }\n }\n if (mas.Max()==0)\n {\n Console.WriteLine(\"YES\");\n \n }\n else\n {\n Console.WriteLine(\"NO\");\n }\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "greedy", "implementation"], "code_uid": "f6f45ff1309c3812eafeafcfe34f65dd", "src_uid": "d1f88a97714d6c13309c88fcf7d86821", "difficulty": 1900.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\n\nnamespace cforce135bb\n{\n class Program\n {\n static void Main(string[] args)\n {\n string[] tmp = Console.ReadLine().Split(' ');\n long p = long.Parse(tmp[0]), d = long.Parse(tmp[1]), i=p, n=p, k, f=10;\n int count = 1;\n while (i>=p-d)\n {\n check:\n k=(long)((i + 1) % f);\n if (k == 0)\n {\n count++;\n n = i;\n f = (long)Math.Pow(10, count);\n goto check;\n }\n i -= (long)Math.Pow(10, count - 1);\n }\n Console.WriteLine(n);\n Console.ReadLine();\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "7247ae6778c18178d7b4f49ffeac2c19", "src_uid": "c706cfcd4c37fbc1b1631aeeb2c02b6a", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections;\nusing System.Collections.Generic;\nusing System.IO;\nusing System.Linq;\nusing System.Threading;\n\nnamespace Temp\n{ \n struct PointInt\n {\n public long X;\n\n public long Y;\n\n public PointInt(long x, long y)\n : this()\n {\n this.X = x;\n this.Y = y;\n }\n\n public static PointInt operator +(PointInt a, PointInt b)\n {\n return new PointInt(a.X + b.X, a.Y + b.Y);\n }\n\n public static PointInt operator -(PointInt a, PointInt b)\n {\n return new PointInt(a.X - b.X, a.Y - b.Y);\n }\n\n public static PointInt operator *(PointInt a, long k)\n {\n return new PointInt(k * a.X, k * a.Y);\n }\n\n public static PointInt operator *(long k, PointInt a)\n {\n return new PointInt(k * a.X, k * a.Y);\n }\n\n public bool IsInsideRectangle(long l, long b, long r, long t)\n {\n return (l <= X) && (X <= r) && (b <= Y) && (Y <= t);\n }\n }\n\n struct LineInt\n {\n public LineInt(PointInt a, PointInt b)\n : this()\n {\n A = a.Y - b.Y;\n B = b.X - a.X;\n C = a.X * b.Y - a.Y * b.X;\n }\n\n public long A, B, C;\n\n public bool ContainsPoint(PointInt p)\n {\n return A * p.X + B * p.Y + C == 0;\n }\n }\n\n class MatrixInt\n {\n private long[,] m_Matrix;\n\n public int Size\n {\n get\n {\n return m_Matrix.GetLength(0) - 1;\n }\n }\n\n public long Mod { get; private set; }\n\n public MatrixInt(int size, long mod = 0)\n {\n m_Matrix = new long[size + 1, size + 1];\n Mod = mod;\n }\n\n public MatrixInt(long[,] matrix, long mod = 0)\n {\n this.m_Matrix = matrix;\n Mod = mod;\n }\n\n public static MatrixInt GetIdentityMatrix(int size, long mod = 0)\n {\n long[,] matrix = new long[size + 1, size + 1];\n\n for (int i = 1; i <= size; i++)\n {\n matrix[i, i] = 1;\n }\n\n return new MatrixInt(matrix, mod);\n }\n\n public long this[int i, int j]\n {\n get\n {\n return m_Matrix[i, j];\n }\n\n set\n {\n m_Matrix[i, j] = value;\n }\n }\n\n public static MatrixInt operator +(MatrixInt a, MatrixInt b)\n {\n int n = a.Size;\n long mod = Math.Max(a.Mod, b.Mod);\n long[,] c = new long[n, n];\n for (int i = 1; i <= n; i++)\n {\n for (int j = 1; j <= n; j++)\n {\n c[i, j] = a[i, j] + b[i, j]; \n }\n }\n\n if (mod > 0)\n {\n for (int i = 1; i <= n; i++)\n {\n for (int j = 1; j <= n; j++)\n {\n c[i, j] %= mod;\n }\n }\n }\n\n return new MatrixInt(c, mod);\n }\n\n public static MatrixInt operator *(MatrixInt a, MatrixInt b)\n {\n int n = a.Size;\n long mod = Math.Max(a.Mod, b.Mod);\n\n long[,] c = new long[n, n];\n\n for (int i = 1; i <= n; i++)\n {\n for (int j = 1; j <= n; j++)\n {\n for (int k = 1; k <= n; k++)\n {\n c[i, j] += a[i, k] * b[k, j];\n if (mod > 0)\n {\n c[i, j] %= mod;\n }\n } \n }\n }\n\n return new MatrixInt(c, mod);\n }\n }\n\n static class Algebra\n {\n public static long Phi(long n)\n {\n long result = n;\n for (long i = 2; i * i <= n; i++)\n {\n if (n % i == 0)\n {\n while (n % i == 0)\n {\n n /= i;\n }\n\n result -= result / i;\n }\n }\n\n if (n > 1)\n {\n result -= result / n;\n }\n\n return result;\n }\n\n public static long BinPower(long a, long n, long mod)\n {\n long result = 1;\n\n while (n > 0)\n {\n if ((n & 1) != 0)\n {\n result = (result * a) % mod;\n }\n\n a = (a * a) % mod;\n n >>= 1;\n }\n\n return result;\n }\n\n public static class Permutations\n {\n public static int[] GetRandomPermutation(int n)\n {\n int[] p = new int[n];\n for (int i = 0; i < n; i++)\n {\n p[i] = i;\n }\n\n Random random = new Random();\n for (int i = n - 1; i > 0; i--)\n {\n int j = random.Next(i + 1);\n int tmp = p[i];\n p[i] = p[j];\n p[j] = tmp;\n }\n\n return p;\n }\n }\n\n public static T[] Shuffle(this T[] array)\n {\n int length = array.Length;\n int[] p = Permutations.GetRandomPermutation(length);\n T[] result = new T[length];\n for (int i = 0; i < length; i++)\n {\n result[i] = array[p[i]];\n }\n\n return result;\n }\n\n public static MatrixInt MatrixBinPower(MatrixInt a, long n)\n {\n MatrixInt result = new MatrixInt(a.Size);\n\n while (n > 0)\n {\n if ((n & 1) != 0)\n {\n result *= a;\n }\n\n a *= a;\n n >>= 1;\n }\n\n return result;\n }\n\n public static long Gcd(long a, long b)\n {\n return b == 0 ? a : Gcd(b, a % b);\n }\n\n public static long ExtendedGcd(long a, long b, out long x, out long y)\n {\n if (b == 0)\n {\n x = 1;\n y = 0;\n return a;\n }\n\n long x1;\n long y1;\n long d = ExtendedGcd(b, a % b, out x1, out y1);\n x = y1;\n y = x1 - (a / b) * y1;\n return d;\n }\n\n public static long Lcm(long a, long b)\n {\n return (a / Gcd(a, b)) * b;\n }\n\n public static bool[] GetPrimes(int n)\n {\n n = Math.Max(n, 2);\n bool[] prime = new bool[n + 1];\n for (int i = 2; i <= n; i++)\n {\n prime[i] = true;\n }\n\n for (int i = 2; i * i <= n; i++)\n {\n if (prime[i])\n {\n if ((long)i * i <= n)\n {\n for (int j = i * i; j <= n; j += i)\n {\n prime[j] = false;\n }\n }\n }\n }\n\n return prime;\n }\n\n public static long GetFibonacciNumber(long n, long mod = 0)\n {\n long[,] matrix = new long[,] { { 0, 0, 0 }, { 0, 0, 1 }, { 0, 1, 1 } };\n\n MatrixInt result = MatrixBinPower(new MatrixInt(matrix, mod), n);\n\n return result[2, 2];\n }\n\n public static long[] GetFibonacciSequence(int n)\n {\n long[] result = new long[n];\n result[0] = result[1] = 1;\n\n for (int i = 2; i < n; i++)\n {\n result[i] = result[i - 1] + result[i - 2];\n }\n\n return result;\n }\n\n public static long GetInverseElement(long a, long mod)\n {\n long x, y;\n long g = ExtendedGcd(a, mod, out x, out y);\n\n if (g != 1)\n {\n return -1;\n }\n\n return ((x % mod) + mod) % mod;\n }\n\n public static long[] GetAllInverseElements(long mod)\n {\n long[] result = new long[mod];\n result[1] = 1;\n for (int i = 2; i < mod; i++)\n {\n result[i] = (mod - (((mod / i) * result[mod % i]) % mod)) % mod;\n }\n\n return result;\n }\n }\n\n internal static class Reader\n {\n public static void ReadInt(out int a)\n {\n int[] number = new int[1];\n ReadInt(number);\n a = number[0];\n }\n\n public static void ReadInt(out int a, out int b)\n {\n int[] numbers = new int[2];\n ReadInt(numbers);\n a = numbers[0];\n b = numbers[1];\n }\n\n public static void ReadInt(out int int1, out int int2, out int int3)\n {\n int[] numbers = new int[3];\n ReadInt(numbers);\n int1 = numbers[0];\n int2 = numbers[1];\n int3 = numbers[2];\n }\n\n public static void ReadInt(out int int1, out int int2, out int int3, out int int4)\n {\n int[] numbers = new int[4];\n ReadInt(numbers);\n int1 = numbers[0];\n int2 = numbers[1];\n int3 = numbers[2];\n int4 = numbers[3];\n }\n\n public static void ReadLong(out long a)\n {\n long[] number = new long[1];\n ReadLong(number);\n a = number[0];\n }\n\n public static void ReadLong(out long a, out long b)\n {\n long[] numbers = new long[2];\n ReadLong(numbers);\n a = numbers[0];\n b = numbers[1];\n }\n\n public static void ReadLong(out long int1, out long int2, out long int3)\n {\n long[] numbers = new long[3];\n ReadLong(numbers);\n int1 = numbers[0];\n int2 = numbers[1];\n int3 = numbers[2];\n }\n\n public static void ReadLong(out long int1, out long int2, out long int3, out long int4)\n {\n long[] numbers = new long[4];\n ReadLong(numbers);\n int1 = numbers[0];\n int2 = numbers[1];\n int3 = numbers[2];\n int4 = numbers[3];\n }\n\n public static void ReadInt(int[] numbers)\n {\n // ReSharper disable PossibleNullReferenceException\n var list = Console.ReadLine().Split();\n // ReSharper restore PossibleNullReferenceException\n\n int count = Math.Min(numbers.Length, list.Length);\n\n for (int i = 0; i < count; i++)\n {\n numbers[i] = int.Parse(list[i]);\n }\n }\n\n public static int[] ReadDigits()\n {\n // ReSharper disable AssignNullToNotNullAttribute\n return Console.ReadLine().Select(x => int.Parse(x.ToString())).ToArray();\n // ReSharper restore AssignNullToNotNullAttribute\n }\n\n public static void ReadLong(long[] numbers)\n {\n // ReSharper disable PossibleNullReferenceException\n var list = Console.ReadLine().Split();\n // ReSharper restore PossibleNullReferenceException\n\n int count = Math.Min(numbers.Length, list.Length);\n\n for (int i = 0; i < count; i++)\n {\n numbers[i] = long.Parse(list[i]);\n }\n }\n\n public static void ReadDouble(double[] numbers)\n {\n // ReSharper disable PossibleNullReferenceException\n var list = Console.ReadLine().Split();\n // ReSharper restore PossibleNullReferenceException\n\n int count = Math.Min(numbers.Length, list.Length);\n\n for (int i = 0; i < count; i++)\n {\n numbers[i] = double.Parse(list[i]);\n }\n }\n\n public static void ReadDouble(out double a, out double b)\n {\n double[] numbers = new double[2];\n ReadDouble(numbers);\n a = numbers[0];\n b = numbers[1];\n }\n\n public static void ReadDouble(out double int1, out double int2, out double int3)\n {\n double[] numbers = new double[3];\n ReadDouble(numbers);\n int1 = numbers[0];\n int2 = numbers[1];\n int3 = numbers[2];\n }\n\n public static string ReadLine()\n {\n return Console.ReadLine();\n }\n }\n\n static class MyMath\n {\n public static int GetMinimalPrimeDivisor(int n)\n { \n for (int i = 2; i * i <= n; i++)\n {\n if (n % i == 0)\n {\n return i;\n }\n }\n\n return n;\n }\n\n public static long Sqr(long x)\n {\n return x * x;\n }\n }\n\n public interface IGraph\n {\n int Vertices { get; set; }\n\n IList this[int i] { get; }\n\n void AddEdge(int u, int v);\n\n void AddOrientedEdge(int u, int v); \n }\n\n public class Graph : IGraph\n {\n private List[] m_Edges;\n\n public int Vertices { get; set; }\n\n public IList this[int i]\n {\n get\n {\n return this.m_Edges[i];\n }\n }\n\n public Graph(int vertices)\n {\n this.Vertices = vertices;\n\n this.m_Edges = new List[vertices];\n\n for (int i = 0; i < vertices; i++)\n {\n this.m_Edges[i] = new List();\n }\n }\n\n public void AddEdge(int u, int v)\n {\n this.AddOrientedEdge(u, v);\n this.AddOrientedEdge(v, u);\n }\n\n public void AddOrientedEdge(int first, int second)\n {\n this.m_Edges[first].Add(second); \n }\n\n public int[] Bfs(int start)\n {\n int[] d = new int[Vertices];\n for (int i = 0; i < Vertices; i++)\n {\n d[i] = -1;\n }\n\n Queue queue = new Queue();\n queue.Enqueue(start);\n d[start] = 0;\n\n while (queue.Count > 0)\n {\n int v = queue.Dequeue();\n foreach (int t in this.m_Edges[v].Where(t => d[t] == -1))\n {\n queue.Enqueue(t);\n d[t] = d[v] + 1;\n }\n }\n\n return d;\n }\n } \n\n class SimpleSumTable\n {\n private readonly int[,] m_Sum;\n\n public SimpleSumTable(int n, int m, int[,] table)\n {\n m_Sum = new int[n + 1, m + 1];\n\n for (int i = 1; i < n + 1; i++)\n {\n for (int j = 1; j < m + 1; j++)\n {\n m_Sum[i, j] = m_Sum[i, j - 1] + m_Sum[i - 1, j] - m_Sum[i - 1, j - 1] + table[i, j];\n }\n }\n }\n\n public int GetSum(int l, int b, int r, int t)\n {\n return m_Sum[r, t] - m_Sum[r, b] - m_Sum[l, t] + m_Sum[l, b];\n }\n }\n\n class SegmentTreeSimpleInt\n {\n public int Size { get; private set; }\n\n private readonly T[] m_Tree;\n\n private Func m_Operation;\n\n private T m_Null;\n\n public SegmentTreeSimpleInt(int size, Func operation, T nullElement, IList array = null)\n {\n this.Size = size;\n this.m_Operation = operation;\n this.m_Null = nullElement;\n\n m_Tree = new T[4 * size];\n if (array != null)\n {\n this.Build(array, 1, 0, size - 1); \n }\n }\n\n private void Build(IList array, int v, int tl, int tr)\n {\n if (tl == tr)\n {\n m_Tree[v] = array[tl];\n }\n else\n {\n int tm = (tl + tr) / 2;\n this.Build(array, 2 * v, tl, tm);\n this.Build(array, 2 * v + 1, tm + 1, tr);\n this.CalculateNode(v);\n }\n }\n\n public T GetSum(int l, int r)\n {\n return GetSum(1, 0, Size - 1, l, r);\n }\n\n private T GetSum(int v, int tl, int tr, int l, int r)\n {\n if (l > r)\n {\n return m_Null;\n }\n\n if (l == tl && r == tr)\n {\n return m_Tree[v];\n }\n\n int tm = (tl + tr) / 2;\n\n return this.m_Operation(GetSum(2 * v, tl, tm, l, Math.Min(r, tm)),GetSum(2 * v + 1, tm + 1, tr, Math.Max(l, tm + 1), r));\n }\n\n public void Update(int pos, T newValue)\n {\n Update(1, 0, Size - 1, pos, newValue);\n }\n\n private void Update(int v, int tl, int tr, int pos, T newValue)\n {\n if (tl == tr)\n {\n m_Tree[v] = newValue;\n }\n else\n {\n int tm = (tl + tr) / 2;\n if (pos <= tm)\n {\n Update(2 * v, tl, tm, pos, newValue);\n }\n else\n {\n Update(2 * v + 1, tm + 1, tr, pos, newValue);\n }\n this.CalculateNode(v);\n }\n }\n\n private void CalculateNode(int v)\n {\n m_Tree[v] = this.m_Operation(m_Tree[2 * v], m_Tree[2 * v + 1]);\n }\n }\n\n struct Pair\n {\n public Pair(TFirst first, TSecond second)\n : this()\n {\n this.First = first;\n this.Second = second;\n }\n\n public TFirst First { set; get; }\n\n public TSecond Second { set; get; }\n }\n\n internal class AccumulativeDictionary : Dictionary\n {\n public new void Add(TKey key, int value = 1)\n {\n if (this.ContainsKey(key))\n {\n base[key] += value;\n }\n else\n {\n base.Add(key, value);\n }\n }\n\n public new int this[TKey key]\n {\n get\n {\n return this.ContainsKey(key) ? base[key] : 0;\n }\n set\n {\n this.Add(key, value);\n }\n }\n }\n\n class PriorityQueue\n {\n public PriorityQueue(Comparison comparison = null)\n {\n if (comparison == null)\n {\n if (typeof(T).GetInterfaces().Any(i => i == typeof(IComparable)))\n {\n m_Comparison = (a, b) => ((IComparable)a).CompareTo(b);\n }\n else\n {\n throw new ApplicationException(\"Add comparer\");\n }\n }\n else\n {\n m_Comparison = comparison;\n }\n }\n\n public int Count { get; private set; }\n\n public void Enqueue(T item)\n {\n if (m_Indexes.ContainsKey(item))\n {\n this.Update(item);\n }\n else\n {\n m_List.Add(item);\n m_Indexes.Add(item, this.Count);\n this.Count++;\n Up(this.Count);\n }\n }\n \n public T Peek()\n {\n return m_List[0]; \n }\n\n public T Dequeue()\n {\n if (this.Count > 0)\n {\n var result = m_List[0];\n\n Swap(0, this.Count - 1);\n this.RemoveLast();\n this.Down(1);\n\n return result;\n }\n throw new ApplicationException(\"Couldn't get element from empty queue\");\n }\n\n public void Update(T item)\n {\n int index = m_Indexes[item];\n this.Up(index + 1);\n }\n\n public void Remove(T item)\n {\n if (m_Indexes.ContainsKey(item))\n {\n int index = m_Indexes[item];\n\n this.Swap(index, this.Count - 1);\n\n this.RemoveLast();\n }\n }\n\n private readonly List m_List = new List();\n\n private readonly Dictionary m_Indexes = new Dictionary();\n\n private readonly Comparison m_Comparison;\n\n private int Up(int index)\n {\n while (index > 1 && m_Comparison.Invoke(m_List[index - 1], m_List[index / 2 - 1]) < 0)\n {\n this.Swap(index - 1, index / 2 - 1);\n\n index = index / 2;\n }\n\n return index;\n }\n\n private int Down(int index)\n {\n while (2 * index <= this.Count && m_Comparison.Invoke(m_List[index - 1], m_List[2 * index - 1]) > 0 ||\n 2 * index + 1 <= this.Count && m_Comparison.Invoke(m_List[index - 1], m_List[2 * index]) > 0)\n {\n if (2 * index + 1 > this.Count || m_Comparison.Invoke(m_List[2 * index - 1], m_List[2 * index]) < 0)\n {\n this.Swap(index - 1, 2 * index - 1);\n index = 2 * index;\n }\n else\n {\n this.Swap(index - 1, 2 * index);\n index = 2 * index + 1;\n }\n }\n\n return index;\n }\n\n private void Swap(int i, int j)\n {\n var tmp = m_List[i];\n m_List[i] = m_List[j];\n m_List[j] = tmp;\n\n m_Indexes[m_List[i]] = i;\n m_Indexes[m_List[j]] = j;\n }\n\n private void RemoveLast()\n {\n m_Indexes.Remove(m_List[this.Count - 1]);\n m_List.RemoveAt(this.Count - 1);\n this.Count--;\n }\n }\n\n class Program\n { \n private static StreamReader m_InputStream;\n\n private static StreamWriter m_OutStream;\n\n private static void OpenFiles()\n {\n m_InputStream = File.OpenText(\"input.txt\");\n Console.SetIn(m_InputStream);\n\n m_OutStream = File.CreateText(\"output.txt\");\n Console.SetOut(m_OutStream);\n }\n\n private static void CloseFiles()\n {\n m_OutStream.Flush();\n\n m_InputStream.Dispose();\n m_OutStream.Dispose();\n }\n\n static void Main()\n {\n // OpenFiles();\n \n new Solution().Solve();\n\n // CloseFiles();\n }\n }\n\n internal class Solution\n {\n public void Solve()\n {\n long p, d;\n Reader.ReadLong(out p, out d);\n\n long m = p - d;\n\n string aa = p.ToString();\n string bb = m.ToString();\n while (bb.Length < aa.Length)\n {\n bb = \"0\" + bb;\n }\n\n char[] a = new char[aa.Length];\n for (int i = 0; i < aa.Length; i++)\n {\n a[i] = aa[i];\n }\n\n char[] b = new char[aa.Length];\n for (int i = 0; i < aa.Length; i++)\n {\n b[i] = bb[i];\n }\n\n for (int i = 0; i < a.Length - 1; i++)\n {\n if (a[i] > b[i])\n {\n bool ok = false;\n for (int j = i + 1; j < a.Length; j++)\n {\n if (a[j] != '9')\n {\n ok = true;\n }\n }\n\n if (!ok)\n {\n Console.WriteLine(p);\n return;\n }\n\n b[i] = (char)(a[i] - 1);\n for (int j = i + 1; j < a.Length; j++)\n {\n b[j] = '9';\n }\n string s = \"\";\n for (int j = 0; j < aa.Length; j++)\n {\n s = s + b[j];\n }\n\n Console.WriteLine(long.Parse(s));\n return;\n }\n }\n\n Console.WriteLine(p);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "c5fe93f4eef30d769607d1c3b9622ef5", "src_uid": "c706cfcd4c37fbc1b1631aeeb2c02b6a", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nnamespace Iran{\n class amir\n {\n public static void Main()\n {\n int x,y,s;\n string[] input=Console.ReadLine().Split(' ');\n x=Int32.Parse(input[0]);\n y=Int32.Parse(input[1]);\n s=Int32.Parse(input[2]);\n long yek,dow;\n if(x%s==0)\n yek=x;\n else\n {\n yek=(x%s)*(x/s+1);\n }\n if(y%s==0)\n dow=y;\n else\n {\n dow=(y%s)*(y/s+1);\n }\n long ans=dow*yek;\n Console.WriteLine(ans);\n \n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math"], "code_uid": "2dcd5e98f31de46377c7aeaa07874741", "src_uid": "e853733fb2ed87c56623ff9a5ac09c36", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Globalization;\nusing System.Text;\nusing System.IO;\nusing System.Linq;\n\n\n\n\nclass Program\n{\n\n void solve()\n {\n long n = nextInt();\n long m = nextInt();\n long s = nextInt();\n long res = get(n, s);\n res *= get(m, s);\n println(res);\n }\n\n private long get(long n, long s)\n {\n long most = (n - 1) / s;\n int res = 0;\n for (int i = 0; i < n; i++)\n {\n long cur = (n - 1 - i) / s;\n cur += i / s;\n if (cur == most)\n res++;\n }\n return res;\n }\n\n ////////////\n private void println(int[] ar)\n {\n for (int i = 0; i < ar.Length; i++)\n {\n if (i == ar.Length - 1)\n println(ar[i]);\n else\n print(ar[i] + \" \");\n }\n }\n private void println(int[] ar, bool add)\n {\n int A = 0;\n if (add)\n A++;\n for (int i = 0; i < ar.Length; i++)\n {\n if (i == ar.Length - 1)\n println(ar[i] + A);\n else\n print((ar[i] + A) + \" \");\n }\n }\n\n private void println(string Stringst)\n {\n Console.WriteLine(Stringst);\n }\n private void println(char charnum)\n {\n Console.WriteLine(charnum);\n }\n private void println(int Intnum)\n {\n Console.WriteLine(Intnum);\n }\n private void println(long Longnum)\n {\n Console.WriteLine(Longnum);\n }\n private void println(double Doublenum)\n {\n string s = Doublenum.ToString(CultureInfo.InvariantCulture);\n Console.WriteLine(s);\n }\n\n private void print(string Stringst)\n {\n Console.Write(Stringst);\n }\n private void print(int Intnum)\n {\n Console.Write(Intnum);\n }\n private void print(char charnum)\n {\n Console.Write(charnum);\n }\n private void print(long Longnum)\n {\n Console.Write(Longnum);\n }\n private void print(double Doublenum)\n {\n Console.Write(Doublenum);\n }\n\n\n string[] inputLine = new string[0];\n int inputInd = 0;\n string nextLine()\n {\n return Console.ReadLine();\n }\n void readInput()\n {\n if (inputInd != inputLine.Length)\n throw new Exception();\n inputInd = 0;\n inputLine = Console.ReadLine().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);\n if (inputLine.Length == 0)\n readInput();\n\n }\n int nextInt()\n {\n if (inputInd == inputLine.Length)\n readInput();\n return int.Parse(inputLine[inputInd++]);\n }\n long nextLong()\n {\n if (inputInd == inputLine.Length)\n readInput();\n return long.Parse(inputLine[inputInd++]);\n }\n double nextDouble()\n {\n if (inputInd == inputLine.Length)\n readInput();\n return double.Parse(inputLine[inputInd++]);\n }\n string nextString()\n {\n if (inputInd == inputLine.Length)\n readInput();\n return inputLine[inputInd++];\n }\n static void Main(string[] args)\n {\n new Program().solve();\n }\n}\n\n\n", "lang_cluster": "C#", "tags": ["math"], "code_uid": "4a6a002998781f862cacec031460284e", "src_uid": "e853733fb2ed87c56623ff9a5ac09c36", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "// \n\nusing System;\nusing System.Collections.Generic;\nusing System.Text;\nusing System.IO;\nusing System.Threading;\nusing System.Diagnostics;\nusing System.Globalization;\nusing System.Text.RegularExpressions;\nusing System.Linq;\n\nnamespace sar_cs\n{\n public class Program\n {\n public class Parser\n {\n const int BufSize = 25000;\n TextReader s;\n char[] buf = new char[BufSize];\n int bufPos;\n int bufDataSize;\n bool eos; // eos read to buffer\n int lastChar = -2;\n int nextChar = -2;\n StringBuilder sb = new StringBuilder();\n\n void FillBuf()\n {\n if (eos) return;\n bufDataSize = s.Read(buf, 0, BufSize);\n if (bufDataSize == 0) eos = true;\n bufPos = 0;\n }\n\n int Read()\n {\n if (nextChar != -2)\n {\n lastChar = nextChar;\n nextChar = -2;\n }\n else\n {\n if (bufPos == bufDataSize) FillBuf();\n if (eos) lastChar = -1;\n else lastChar = buf[bufPos++];\n }\n return lastChar;\n }\n\n void Back()\n {\n if (lastChar == -2) throw new Exception(); // no chars were ever read\n nextChar = lastChar;\n }\n\n public Parser()\n {\n s = Console.In;\n }\n\n public int ReadInt()\n {\n int res = 0;\n int sign = -1;\n int c;\n do { c = Read(); } while (c >= 0 && char.IsWhiteSpace((char)c));\n if (c == '-')\n {\n sign = -sign;\n c = Read();\n }\n int len = 0;\n while (c >= 0 && !char.IsWhiteSpace((char)c))\n {\n if ((uint)(c -= 48) >= 10) throw new InvalidDataException();\n len++;\n res = checked(res * 10 - c);\n c = Read();\n }\n if (len == 0) throw new InvalidDataException();\n Back();\n return checked(res * sign);\n }\n\n public long ReadLong()\n {\n long res = 0;\n int sign = -1;\n int c;\n do { c = Read(); } while (c >= 0 && char.IsWhiteSpace((char)c));\n if (c == '-')\n {\n sign = -sign;\n c = Read();\n }\n int len = 0;\n checked\n {\n while (c >= 0 && !char.IsWhiteSpace((char)c))\n {\n if ((uint)(c -= 48) >= 10) throw new InvalidDataException();\n len++;\n res = res * 10 - c;\n c = Read();\n }\n if (len == 0) throw new InvalidDataException();\n Back();\n return res * sign;\n }\n }\n\n public double ReadDouble()\n {\n int c;\n do { c = Read(); } while (c >= 0 && char.IsWhiteSpace((char)c));\n\n int sign = 1;\n if (c == '-')\n {\n sign = -1;\n c = Read();\n }\n\n sb.Length = 0;\n while (c >= 0 && !char.IsWhiteSpace((char)c))\n {\n sb.Append((char)c);\n c = Read();\n }\n\n Back();\n double res = double.Parse(sb.ToString(), CultureInfo.InvariantCulture);\n return res * sign;\n }\n\n public string ReadLine()\n {\n int c = Read();\n sb.Length = 0;\n while (c != -1 && c != 13 && c != 10)\n {\n sb.Append((char)c);\n c = Read();\n }\n if (c == 13)\n {\n c = Read();\n if (c != 10) Back();\n }\n return sb.ToString();\n }\n\n public bool EOF\n {\n get\n {\n if (Read() == -1) return true;\n Back();\n return false;\n }\n }\n\n public bool SeekEOF\n {\n get\n {\n L0:\n int c = Read();\n if (c == -1) return true;\n if (char.IsWhiteSpace((char)c)) goto L0;\n Back();\n return false;\n }\n }\n }\n\n static void pe()\n {\n Console.WriteLine(\"???\");\n Environment.Exit(0);\n }\n\n static void re()\n {\n Environment.Exit(55);\n }\n\n static int nosol()\n {\n Console.WriteLine(\"ERROR\");\n return 0;\n }\n\n static Stopwatch sw = Stopwatch.StartNew();\n\n static StringBuilder sb = new StringBuilder();\n static Random rand = new Random(52345235);\n\n static void Swap(ref T a, ref T b)\n {\n T t = a;\n a = b;\n b = t;\n }\n\n static int n;\n static int[] j = new int[6];\n static int[,] l = new int[6, 6];\n static int[,] h = new int[6, 6];\n static int[,] a = new int[6, 6];\n static int[,] flow = new int[6, 6];\n\n static int resultFlow;\n static int resultCost;\n\n static void per(int v, int w, int q)\n {\n if (q < 0) throw new Exception();\n\n int j_bak = j[w];\n\n if (w == n - 1)\n {\n if (q >= l[v, w] && q <= h[v, w])\n {\n flow[v, w] = q;\n j[w] = j_bak + q;\n visit(v + 1);\n }\n }\n else\n {\n for (int i = l[v, w]; i <= h[v, w]; i++)\n {\n if (i > q) break;\n if (q - i > 5 * (n - 1 - w)) continue;\n flow[v, w] = i;\n j[w] = j_bak + i;\n per(v, w + 1, q - i);\n }\n }\n\n flow[v, w] = 0;\n j[w] = j_bak;\n }\n\n static void visit(int v)\n {\n if (v == n - 1)\n {\n if (j[n - 1] != j[0]) throw new Exception();\n if (j[n - 1] <= resultFlow)\n {\n int cost = 0;\n for (v = 0; v < n; v++)\n for (int w = v + 1; w < n; w++)\n if (flow[v, w] > 0) cost += a[v, w] + flow[v, w] * flow[v, w];\n if (j[n - 1] < resultFlow || cost > resultCost) resultCost = cost;\n resultFlow = j[n - 1];\n }\n }\n else\n {\n per(v, v + 1, j[v]);\n }\n }\n\n static int Main(string[] args)\n {\n //Console.SetIn(File.OpenText(\"_input\"));\n Parser parser = new Parser();\n while (!parser.SeekEOF)\n {\n n = parser.ReadInt();\n for (int i = 0; i < n * (n - 1) / 2; i++)\n {\n int v = parser.ReadInt() - 1;\n int w = parser.ReadInt() - 1;\n l[v, w] = parser.ReadInt();\n h[v, w] = parser.ReadInt();\n a[v, w] = parser.ReadInt();\n }\n\n resultFlow = int.MaxValue;\n resultCost = 0;\n for (j[0] = 0; j[0] <= 25; j[0]++)\n visit(0);\n\n if (resultFlow == int.MaxValue) resultFlow = resultCost = -1;\n Console.WriteLine(resultFlow + \" \" + resultCost);\n }\n\n return 0;\n }\n }\n}", "lang_cluster": "C#", "tags": ["brute force"], "code_uid": "cbd6382a5847d3e0ac4481ffe99eaece", "src_uid": "38886ad7b0d83e66b77348be34828426", "difficulty": 2200.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\n\nnamespace ProgrammingContest.Codeforces.Round62\n{\n class C\n {\n static int n;\n static int[] fuel;\n static List[] xs;\n static int f,c;\n\n static void chk(int cost)\n {\n if (fuel[n - 1] < 0) return;\n if (f == fuel[n - 1] && c < cost) { c = cost; }\n if (f == -1 || f > fuel[n - 1]) { f = fuel[n - 1]; c = cost; }\n }\n\n static void dfs(int i, int j, int cost)\n {\n if (i >= n - 1) { chk(cost); return; }\n if (i == 1 && j == 0 && f != -1 && f < -fuel[0])\n return;\n if (j >= xs[i].Count)\n {\n if (i == 0 || fuel[i] == 0)\n dfs(i + 1, 0, cost);\n return;\n }\n\n int dst = xs[i][j][1];\n for (int k = xs[i][j][2]; k <= xs[i][j][3]; k++)\n if (i == 0 || k <= fuel[i])\n {\n fuel[i] -= k;\n fuel[dst] += k;\n\n int nc = k == 0 ? cost : (cost + k * k + xs[i][j][4]);\n dfs(i, j + 1, nc);\n\n fuel[dst] -= k;\n fuel[i] += k;\n }\n }\n\n public static void Main()\n {\n n = int.Parse(Console.ReadLine());\n xs = new List[n];\n fuel = new int[n];\n for (int i = 0; i < n; i++)\n xs[i] = new List();\n for (int i = 0; i < n * (n - 1) / 2; i++)\n {\n var ys = Array.ConvertAll(Console.ReadLine().Split(' '), sss => int.Parse(sss));\n ys[0]--; ys[1]--;\n xs[ys[0]].Add(ys);\n }\n f = -1; c = -1;\n dfs(0, 0, 0);\n Console.WriteLine(\"{0} {1}\", f, c);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force"], "code_uid": "a51815d08dee89abfd1ba41ef3c82016", "src_uid": "38886ad7b0d83e66b77348be34828426", "difficulty": 2200.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\n\nnamespace CodeForces\n{\n\tpublic class A\n\t{\n\t\tstatic void Main()\n\t\t{\n\t\t\tvar n = int.Parse( Console.ReadLine() );\n\t\t\tif ( n == 1 )\n\t\t\t{\n\t\t\t\tConsole.WriteLine( 0 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tint res = int.MaxValue;\n\t\t\tfor ( int i = 1; i < n; ++i )\n\t\t\t{\n\t\t\t\tvar x = i;\n\t\t\t\tvar cur = 0;\n\t\t\t\tvar y = n;\n\t\t\t\twhile ( x > 0 && y > 0 )\n\t\t\t\t{\n\t\t\t\t\tif ( x > y )\n\t\t\t\t\t{\n\t\t\t\t\t\tcur += x / y;\n\t\t\t\t\t\tx %= y;\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\tcur += y / x;\n\t\t\t\t\t\ty %= x;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif ( x + y == 1 )\n\t\t\t\t\tres = Math.Min( res, cur );\n\t\t\t}\n\t\t\tConsole.WriteLine( res - 1 );\n\t\t}\n\t}\n}\n", "lang_cluster": "C#", "tags": ["dfs and similar", "math", "number theory", "brute force"], "code_uid": "7b3187b52d3ebe81ec6a264b4e7657b9", "src_uid": "75739f77378b21c331b46b1427226fa1", "difficulty": 1900.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\n\nnamespace CodeForces\n{\n\tpublic class A\n\t{\n\t\tstatic void Main()\n\t\t{\n\t\t\tvar n = int.Parse( Console.ReadLine() );\n\t\t\tif ( n == 1 )\n\t\t\t{\n\t\t\t\tConsole.WriteLine( 0 );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tvar lst = new List();\n\t\t\tvar res = int.MaxValue;\n\t\t\tfor ( var i = 1; i < n; ++i )\n\t\t\t{\n\t\t\t\tlst.Add( i );\n\t\t\t\tvar x = i;\n\t\t\t\tvar cur = 0;\n\t\t\t\tvar y = n;\n\t\t\t\twhile ( x > 0 && y > 0 )\n\t\t\t\t{\n\t\t\t\t\tif ( x > y )\n\t\t\t\t\t{\n\t\t\t\t\t\tcur += x / y;\n\t\t\t\t\t\tx %= y;\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\tcur += y / x;\n\t\t\t\t\t\ty %= x;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif ( x + y == 1 )\n\t\t\t\t\tres = Math.Min( res, cur );\n\t\t\t}\n\n\t\t\tvar test = lst.Where( x => x % 5 == 1 ).OrderBy( x => x % 10 ).Take( 4 );\n\n\t\t\tif ( test.Any( x => x == res ) )\n\t\t\t{\n\t\t\t\tConsole.WriteLine( res - 1 );\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tConsole.WriteLine( res - 1 );\n\t\t\t}\n\t\t}\n\t}\n}\n", "lang_cluster": "C#", "tags": ["dfs and similar", "math", "number theory", "brute force"], "code_uid": "ea68b0be2769c093b6437fdb889e1275", "src_uid": "75739f77378b21c331b46b1427226fa1", "difficulty": 1900.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.IO;\nusing System.Text;\n\nnamespace My_pretty_girl_Noora\n{\n internal class Program\n {\n private static readonly StreamReader reader = new StreamReader(Console.OpenStandardInput(1024*10), Encoding.ASCII, false, 1024*10);\n private static readonly StreamWriter writer = new StreamWriter(Console.OpenStandardOutput(1024*10), Encoding.ASCII, 1024*10);\n\n private static void Main(string[] args)\n {\n int t = Next();\n int l = Next();\n int r = Next();\n\n var nn = new long[r + 1];\n for (int i = 2; i < nn.Length; i++)\n {\n nn[i] = long.MaxValue;\n }\n nn[1] = 1;\n for (long i = 2; i < nn.Length; i++)\n {\n nn[i] = Math.Min(nn[i], i*(i - 1)/2);\n\n long max = Math.Min(i*i, r);\n long y = 2;\n for (long j = i + i; j <= max; j += i, y++)\n {\n var tt = nn[i] + i*nn[y];\n if (nn[j] > tt)\n nn[j] = tt;\n //nn[j] = Math.Min(nn[j], nn[i] + i*nn[y]);\n }\n }\n\n long sum = 0;\n long k = 1;\n int mod = 1000000007;\n\n for (int i = l; i <= r; i++)\n {\n sum = (sum + k*(nn[i]%mod))%mod;\n k = (k*t)%mod;\n }\n\n writer.WriteLine(sum);\n writer.Flush();\n }\n\n private static int Next()\n {\n int c;\n int res = 0;\n do\n {\n c = reader.Read();\n if (c == -1)\n return res;\n } while (c < '0' || c > '9');\n res = c - '0';\n while (true)\n {\n c = reader.Read();\n if (c < '0' || c > '9')\n return res;\n res *= 10;\n res += c - '0';\n }\n }\n }\n}", "lang_cluster": "C#", "tags": ["brute force", "math", "dp", "greedy", "number theory"], "code_uid": "361438fbfe4f13c0b13879b12b415ffc", "src_uid": "c9d45dac4a22f8f452d98d05eca2e79b", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.IO;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace Test\n{\n class IOHelper : IDisposable\n {\n StreamReader reader;\n StreamWriter writer;\n\n public IOHelper(string inputFile, string outputFile, Encoding encoding)\n {\n StreamReader iReader;\n StreamWriter oWriter;\n if (inputFile == null)\n iReader = new StreamReader(Console.OpenStandardInput(), encoding);\n else\n iReader = new StreamReader(inputFile, encoding);\n\n if (outputFile == null)\n oWriter = new StreamWriter(Console.OpenStandardOutput(), encoding);\n else\n oWriter = new StreamWriter(outputFile, false, encoding);\n\n reader = iReader;\n writer = oWriter;\n\n curLine = new string[] { };\n curTokenIdx = 0;\n }\n\n\n string[] curLine;\n int curTokenIdx;\n\n char[] whiteSpaces = new char[] { ' ', '\\t', '\\r', '\\n' };\n\n public string ReadNextToken()\n {\n if (curTokenIdx >= curLine.Length)\n {\n //Read next line\n string line = reader.ReadLine();\n if (line != null)\n curLine = line.Split(whiteSpaces, StringSplitOptions.RemoveEmptyEntries);\n else\n curLine = new string[] { };\n curTokenIdx = 0;\n }\n\n if (curTokenIdx >= curLine.Length)\n return null;\n\n return curLine[curTokenIdx++];\n }\n\n public int ReadNextInt()\n {\n return int.Parse(ReadNextToken());\n }\n\n public double ReadNextDouble()\n {\n var nextToken = ReadNextToken();\n var result = 0.0;\n nextToken = nextToken.Replace(\".\", System.Threading.Thread.CurrentThread.CurrentCulture.NumberFormat.NumberDecimalSeparator);\n result = double.Parse(nextToken);\n return result;\n }\n\n public void Write(string stringToWrite)\n {\n writer.Write(stringToWrite);\n }\n\n public void WriteLine(string stringToWrite)\n {\n writer.WriteLine(stringToWrite);\n }\n\n public void WriteLine(double valueToWrite)\n {\n long intPart = (long)valueToWrite;\n double fracPart = valueToWrite - intPart;\n var fracPartStr = fracPart.ToString();\n if (fracPartStr.Length > 1)\n fracPartStr = fracPartStr.Substring(2);\n var strToWrite = string.Format(\"{0}.{1}\", intPart, fracPartStr);\n writer.WriteLine(strToWrite);\n }\n\n public void Dispose()\n {\n try\n {\n if (reader != null)\n {\n reader.Dispose();\n }\n if (writer != null)\n {\n writer.Dispose();\n }\n }\n catch { };\n }\n\n\n public void Flush()\n {\n if (writer != null)\n {\n writer.Flush();\n }\n }\n }\n\n class Program\n {\n protected IOHelper ioHelper;\n\n int t;\n int l, r;\n\n int prime = 1000000007;\n\n long[] ans;\n\n List primes = new List();\n\n int primeLimit;\n\n bool IsPrime(int i)\n {\n foreach(var prime in primes)\n {\n if (prime * prime > i)\n return true;\n\n if (i % prime == 0)\n return false;\n }\n\n return true;\n }\n\n public void Solve()\n {\n t = ioHelper.ReadNextInt();\n l = ioHelper.ReadNextInt();\n r = ioHelper.ReadNextInt();\n\n // n = p0 * p1 * ... * pk. pi = numar prim. p[i+1]>=p[i].\n // R = n/2 * ( (p0-1) + (p1-1)/p0 + (p2-1)/(p0*p1) + (p3-1)/(p0*p1*p2) + ... ).\n\n primeLimit = (int)Math.Ceiling(Math.Sqrt(r)+1);\n\n ans = new long[r+1];\n\n ans[0] = 0;\n ans[1] = 0;\n\n int i, j;\n\n primes.Add(2);\n\n for (i = 3; i <= primeLimit; i++)\n if (IsPrime(i))\n primes.Add(i);\n\n for (i = primeLimit + 1; i <= r; i++)\n if (IsPrime(i))\n ans[i] = (i * (long)(i - 1) / 2) % prime;\n\n for (j = primes.Count - 1; j >= 0; j--)\n for (i = 1; i * primes[j] <= r; i++)\n if (ans[i] > 0 || i==1)\n {\n var p = primes[j];\n var n = i * p;\n\n long rz = n * (long)(p - 1) / 2;\n rz += ans[i];\n\n rz %= prime;\n\n ans[n] = rz;\n }\n\n long coeff = 1;\n long rez = 0;\n\n for(i=l;i<=r;i++)\n {\n if (ans[i] == 0)\n ans[i] = i * (long)(i - 1) / 2;\n\n ans[i] %= prime;\n\n rez += (ans[i] * coeff) % prime;\n\n rez %= prime;\n\n coeff *= t;\n coeff %= prime;\n }\n\n ioHelper.WriteLine(rez.ToString());\n ioHelper.Flush();\n\n //Console.ReadKey();\n }\n\n public Program(string inputFile, string outputFile)\n {\n ioHelper = new IOHelper(inputFile, outputFile, Encoding.Default);\n Solve();\n ioHelper.Dispose();\n }\n\n static void Main(string[] args)\n {\n Program myProgram = new Program(null, null);\n }\n }\n}", "lang_cluster": "C#", "tags": ["brute force", "math", "dp", "greedy", "number theory"], "code_uid": "30f4b8dfcf807ced2ad8046bc7f07f6e", "src_uid": "c9d45dac4a22f8f452d98d05eca2e79b", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Text;\n\nnamespace A.Theatre_Square\n{\n class Program\n {\n\n\n static void Main(string[] args)\n {\n string[] data = Console.ReadLine().Split(' ');\n int n = Int32.Parse(data[0]);\n int m = Int32.Parse(data[1]);\n int k = Int32.Parse(data[2]);\n if (n % 2 == 0)\n {\n Console.WriteLine(\"Marsel\");\n return;\n }\n \n if (n % 2 == 1)\n {\n if (k == 1 && m!=1)\n {\n Console.WriteLine(\"Timur\");\n return;\n }\n for (int i = 2; i * i <= m; i++)\n {\n if (m % i == 0 && (m / i >= k || i >= k ) )\n {\n Console.WriteLine(\"Timur\");\n return ;\n }\n }\n }\n \n Console.WriteLine(\"Marsel\");\n \n Console.ReadKey();\n }\n\n }\n}\n", "lang_cluster": "C#", "tags": ["dp", "number theory", "games"], "code_uid": "f4b30cb2616461a42e54eb7df3abb0af", "src_uid": "4a3767011ddac874efa021fff7c94432", "difficulty": 2000.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Text;\n\nnamespace CodeForces\n{\n class Program\n {\n public static bool IsPrim(int n, int k)\n {\n if(k == 1)\n return false;\n \n if(n==2 && k <=2)\n return true;\n\n for (int i = 2; i <= Math.Sqrt(n); i++)\n if (n % i == 0 && (i >= k || n / i >= k))\n return false;\n return true;\n }\n static void Main()\n {\n var input = Console.ReadLine().Split(' ');\n var n = Int32.Parse(input[0]);\n var m = Int32.Parse(input[1]);\n var k = Int32.Parse(input[2]);\n\n if (m < 2 * k || n % 2 == 0 || IsPrim(m, k))\n {\n Console.WriteLine(\"Marsel\");\n return;\n }\n Console.WriteLine(\"Timur\"); \n }\n }\n}", "lang_cluster": "C#", "tags": ["dp", "number theory", "games"], "code_uid": "ec0d35c7c192d846b0f225207483156c", "src_uid": "4a3767011ddac874efa021fff7c94432", "difficulty": 2000.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Globalization;\nusing System.IO;\nusing System.Linq;\nusing System.Threading;\n\nnamespace CF317\n{\n\tinternal class Program\n\t{\n\t\tprivate static void Main(string[] args)\n\t\t{\n\t\t\tvar sr = new InputReader(Console.In);\n\t\t\t//var sr = new InputReader(new StreamReader(\"input.txt\"));\n\t\t\tvar task = new Task();\n\t\t\tusing (var sw = Console.Out)\n\t\t\t{\n\t\t\t//using (var sw = new StreamWriter(\"output.txt\")) {\n\t\t\t\ttask.Solve(1, sr, sw);\n\t\t\t}\n\t\t\t//Console.ReadKey();\n\t\t}\n\t}\n\n\tinternal class Task\n\t{\n\t\tpublic void Solve(int testNumber, InputReader sr, TextWriter sw)\n\t\t{\n\t\t\tvar input = sr.ReadArray(Int32.Parse);\n\t\t\tvar a = input[0];\n\t\t\tvar ta = input[1];\n\t\t\tinput = sr.ReadArray(Int32.Parse);\n\t\t\tvar b = input[0];\n\t\t\tvar tb = input[1];\n\t\t\tvar str = sr.NextString().Split(new[] { ':' }, StringSplitOptions.RemoveEmptyEntries);\n\t\t\tvar h = str[0][0] == '0' ? Int32.Parse(str[0][1].ToString(CultureInfo.InvariantCulture)) : Int32.Parse(str[0]);\n\t\t\tvar m = str[1][0] == '0' ? Int32.Parse(str[1][1].ToString(CultureInfo.InvariantCulture)) : Int32.Parse(str[1]);\n\t\t\tvar count = 0;\n\t\t\tvar start = h * 60 + m;\n\t\t\tint end =start + ta;\n\t\t\tvar bArr = new List>();\n\t\t\tfor (var startB = 5 * 60; startB <= 23*60 + 59; startB += b) {\n\t\t\t\tbArr.Add(new Tuple(startB, startB + tb));\n\t\t\t}\n\t\t\tfor (var i = 0; i < bArr.Count; i++) {\n\t\t\t\tvar next = bArr[i];\n\t\t\t\tif (start < next.Item2 && next.Item1 < end) {\n\t\t\t\t\tcount++;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tsw.WriteLine(count);\n\t\t}\n\t}\n\n\tinternal class InputReader : IDisposable\n\t{\n\t\tprivate bool isDispose;\n\t\tprivate readonly TextReader sr;\n\n\t\tpublic InputReader(TextReader stream)\n\t\t{\n\t\t\tsr = stream;\n\t\t}\n\n\t\tpublic void Dispose()\n\t\t{\n\t\t\tDispose(true);\n\t\t\tGC.SuppressFinalize(this);\n\t\t}\n\n\t\tpublic string NextString()\n\t\t{\n\t\t\tvar result = sr.ReadLine();\n\t\t\treturn result;\n\t\t}\n\n\t\tpublic int NextInt32()\n\t\t{\n\t\t\treturn Int32.Parse(NextString());\n\t\t}\n\n\t\tpublic long NextInt64()\n\t\t{\n\t\t\treturn Int64.Parse(NextString());\n\t\t}\n\n\t\tpublic string[] NextSplitStrings()\n\t\t{\n\t\t\treturn NextString()\n\t\t\t\t.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);\n\t\t}\n\n\t\tpublic T[] ReadArray(Func func)\n\t\t{\n\t\t\treturn NextSplitStrings()\n\t\t\t\t.Select(s => func(s, CultureInfo.InvariantCulture))\n\t\t\t\t.ToArray();\n\t\t}\n\n\t\tpublic T[] ReadArrayFromString(Func func, string str)\n\t\t{\n\t\t\treturn\n\t\t\t\tstr.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)\n\t\t\t\t\t.Select(s => func(s, CultureInfo.InvariantCulture))\n\t\t\t\t\t.ToArray();\n\t\t}\n\n\t\tprotected void Dispose(bool dispose)\n\t\t{\n\t\t\tif (!isDispose) {\n\t\t\t\tif (dispose)\n\t\t\t\t\tsr.Close();\n\t\t\t\tisDispose = true;\n\t\t\t}\n\t\t}\n\n\t\t~InputReader()\n\t\t{\n\t\t\tDispose(false);\n\t\t}\n\t}\n}", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "d23d5dba3b09ba916290c9c803ddf627", "src_uid": "1c4cf1c3cb464a483511a8a61f8685a7", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\n\nnamespace A\n{\n class Program\n {\n static void Main(string[] args)\n {\n\n string[] t_A = Console.ReadLine().Split(' ');\n string[] t_B = Console.ReadLine().Split(' ');\n string[] HHH = Console.ReadLine().Split(':');\n int hour = 0;\n if (HHH[0][0] == '0') hour = int.Parse(HHH[0][1].ToString());\n else\n hour = int.Parse(HHH[0][0].ToString()) * 10 + int.Parse(HHH[0][1].ToString());\n int minute = 0;\n if (HHH[1][0] == '0') minute = int.Parse(HHH[1][1].ToString());\n else\n minute = int.Parse(HHH[1][0].ToString()) * 10 + int.Parse(HHH[1][1].ToString());\n int starttime = hour * 60 + minute;\n int endtime = starttime + int.Parse(t_A[1].ToString());\n int ans = 0;\n int start = 300;\n int chastota = int.Parse(t_B[0].ToString());\n int time = int.Parse(t_B[1].ToString());\n while (true)\n {\n if (start >= endtime || start > 1439) break;\n if (start + time > starttime)\n {\n ans++;\n }\n start += chastota;\n }\n\n\n Console.WriteLine(ans);\n\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "600a7a95e72040d2df500355b7de2102", "src_uid": "1c4cf1c3cb464a483511a8a61f8685a7", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.IO;\nusing System.Linq;\nusing System.Text;\nusing System.Threading;\n\nnamespace Crunching_Numbers_Just_for_You\n{\n internal class Program\n {\n private static readonly StreamReader reader = new StreamReader(Console.OpenStandardInput(1024*10), Encoding.ASCII, false, 1024*10);\n private static readonly StreamWriter writer = new StreamWriter(Console.OpenStandardOutput(1024*10), Encoding.ASCII, 1024*10);\n\n private static void Main(string[] args)\n {\n int n = Next();\n\n var nn = new int[n];\n for (int i = 0; i < n; i++)\n {\n nn[i] = Next();\n }\n\n Array.Sort(nn);\n\n List s = nn.Select(t => t.ToString()).ToList();\n\n DateTime next = DateTime.UtcNow.AddSeconds(1);\n long k = 1;\n while (DateTime.UtcNow '9');\n res = c - '0';\n while (true)\n {\n c = reader.Read();\n if (c < '0' || c > '9')\n return res;\n res *= 10;\n res += c - '0';\n }\n }\n }\n}", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "f8a2dae3f8ef7104315d34f465a9e150", "src_uid": "29e481abfa9ad1f18e6157c9e833f16e", "difficulty": 1900.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Diagnostics;\nusing System.IO;\nusing System.Linq;\nusing System.Text;\n\nclass Solution\n{\n\n static void Main(String[] args)\n {\n Stopwatch e = new Stopwatch();\n e.Start();\n var n = Console.ReadLine().Split().Skip(1).Select(int.Parse).ToList();\n n.Sort();\n while (e.ElapsedMilliseconds < 1400)\n {\n\n }\n Console.WriteLine(string.Join(\" \", n));\n Console.Read();\n }\n}", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "dcc6feac03297e763d28dfeac7439ae1", "src_uid": "29e481abfa9ad1f18e6157c9e833f16e", "difficulty": 1900.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\n\nnamespace Codeforces\n{\n\n /*\n\nstring[] input = Console.ReadLine().Split(' ');\n int n = int.Parse(input[0]);\n string tt = Console.ReadLine();\n int[] a = tt.Split(' ').Select(q => Convert.ToInt32(q)).ToArray();\n int[] k = Enumerable.Repeat(0, n).ToArray();\n Array.Sort(a,\n new Comparison(\n (i1, i2) => i2.CompareTo(i1)\n ));\n */\n\n /*\n \n string r = Console.ReadLine();\n int n = int.Parse(r);\n \n string t = Console.ReadLine();\n int[] a = t.Split(' ').Select(q => Convert.ToInt32(q)).ToArray();\n */\n class B\n {\n private static void Main(string[] args)\n {\n string input = Console.ReadLine();\n int n = int.Parse(input);\n int res = 0;\n int k = (int)Math.Sqrt(n);\n int t = k * k;\n if (n - t > k)\n res = (k + 1) * 2;\n else if (t == n)\n res = k * 2;\n else\n res = k * 2 + 1;\n Console.WriteLine(res);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "constructive algorithms", "binary search"], "code_uid": "3746f1e567e88c6b2401f0655e6d0055", "src_uid": "eb8212aec951f8f69b084446da73eaf7", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\n\nnamespace Yuhao\n{\n class Program\n {\n static void Main(string[] args)\n {\n int n = Convert.ToInt32(Console.ReadLine());\n int sqr = (int)Math.Sqrt(n);\n if (sqr * sqr < n) sqr++;\n int X;\n X = 2 * sqr;\n if (sqr * (sqr - 1) >= n)\n X--;\n \n Console.WriteLine(X);\n\n // Console.ReadKey();\n\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "constructive algorithms", "binary search"], "code_uid": "3a6ddcf957683061a2e175b3048afd0b", "src_uid": "eb8212aec951f8f69b084446da73eaf7", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "/*\n\n */\nusing System;\nusing System.Collections.Generic;\nusing System.Globalization;\nusing System.IO;\nusing System.Linq;\nusing System.Text;\nusing System.Threading;\nusing System.Diagnostics;\n \n /// \n /// Keep track of tree size and take steps to avoid having tall trees.\n /// Smaller tree will connect to the root of the larger tree.\n /// Java implementation on p. 228\n /// Depth of any node x is at most lg N (lg = base-2 logarithms)\n /// If N is 1,000 its 10 (2^10 = 1000)\n /// If N is 1,000,000 its 20 (2^20)\n /// If N is 1,000,000,000 its 30 (2^30)\n /// Can also add path compression: just after computing root of p, \n /// set the id of each examined node to point to that root\n /// \n public class QuickUnionUF2 // Weighted Quick Union\n {\n private int[] id;\n private int[] sz;\n private int count; // number of components\n\n public QuickUnionUF2(int N)\n {\n id = new int[N];\n for (int i = 0; i < N; i++) id[i] = i;\n\n sz = new int[N];\n for (int i = 0; i < N; i++) sz[i] = 1;\n count = N;\n }\n\n public int Count() { return count; }\n\n private int Root(int i)\n {\n // Chase parent ID until reach the root (depth of i array accesses)\n while (i != id[i])\n {\n // Halves path length. No reason not to, keeps tree almost completely flat.\n id[i] = id[id[i]]; // Only 1 extra line of code to do path compression improvement! \n \n i = id[i];\n }\n return i;\n }\n\n public bool Connected(int p, int q) // Find\n {\n return Root(p) == Root(q);\n }\n\n public void Union(int p, int q)\n {\n int i = Root(p);\n int j = Root(q);\n\n if (i == j) return;\n\n // Make smaller root point to the larger root.\n if (sz[i] < sz[j]) // if i is smaller than j\n {\n id[i] = j; // point i to new root j\n sz[j] += sz[i]; // add the count of the smaller array to the count of the larger array\n }\n else // if j is smaller than i\n {\n id[j] = i;\n sz[i] += sz[j];\n }\n\n count--; // if we combine components, the count of components goes down by 1\n }\n }\n\npublic class Solver\n{\n public IEnumerable Factor(int number) {\n int max = (int)Math.Sqrt(number); //round down\n for(int factor = 2; factor <= max; ++factor) { //test from 1 to the square root, or the int below it, inclusive.\n if(number % factor == 0) {\n yield return factor;\n if(factor != number/factor) { // Don't add the square root twice! Thanks Jon\n yield return number/factor;\n }\n }\n }\n }\n\n public void Solve()\n {\n /*\n * a - b = c a = c + b\n * n % c == 0\n */\n long n = ReadLong();\n\n var primes = new Dictionary();\n long nn = n;\n long x = 2;\n while (1 < nn && x * x <= n) \n {\n while (nn % x == 0) \n {\n if (!primes.ContainsKey(x))\n primes[x] = 0;\n primes[x]++;\n nn /= x;\n }\n x++;\n }\n if (1 < nn)\n primes[nn] = 1;\n\n\n if (primes.Count() == 1)\n Write(primes.First().Key);\n else if (!primes.Any())\n Write(n);\n else\n Write(1);\n\n }\n\n #region Main\n\n protected static TextReader reader;\n protected static TextWriter writer;\n static void Main()\n {\n Debug.Listeners.Clear();\n Debug.Listeners.Add(new ConsoleTraceListener());\n Trace.Listeners.Clear();\n Trace.Listeners.Add(new ConsoleTraceListener());\n\n reader = new StreamReader(Console.OpenStandardInput());\n writer = new StreamWriter(Console.OpenStandardOutput());\n new Solver().Solve();\n reader.Close();\n writer.Close();\n }\n\n #endregion\n\n #region Read / Write\n private static Queue currentLineTokens = new Queue();\n private static string[] ReadAndSplitLine() { return reader.ReadLine().Split(new[] { ' ', '\\t', }, StringSplitOptions.RemoveEmptyEntries); }\n public static string ReadToken() { while (currentLineTokens.Count == 0)currentLineTokens = new Queue(ReadAndSplitLine()); return currentLineTokens.Dequeue(); }\n public static int ReadInt() { return int.Parse(ReadToken()); }\n public static long ReadLong() { return long.Parse(ReadToken()); }\n public static double ReadDouble() { return double.Parse(ReadToken(), CultureInfo.InvariantCulture); }\n public static int[] ReadIntArray() { return ReadAndSplitLine().Select(int.Parse).ToArray(); }\n public static long[] ReadLongArray() { return ReadAndSplitLine().Select(long.Parse).ToArray(); }\n public static double[] ReadDoubleArray() { return ReadAndSplitLine().Select(s => double.Parse(s, CultureInfo.InvariantCulture)).ToArray(); }\n public static int[][] ReadIntMatrix(int numberOfRows) { int[][] matrix = new int[numberOfRows][]; for (int i = 0; i < numberOfRows; i++)matrix[i] = ReadIntArray(); return matrix; }\n public static int[][] ReadAndTransposeIntMatrix(int numberOfRows)\n {\n int[][] matrix = ReadIntMatrix(numberOfRows); int[][] ret = new int[matrix[0].Length][];\n for (int i = 0; i < ret.Length; i++) { ret[i] = new int[numberOfRows]; for (int j = 0; j < numberOfRows; j++)ret[i][j] = matrix[j][i]; } return ret;\n }\n public static string[] ReadLines(int quantity) { string[] lines = new string[quantity]; for (int i = 0; i < quantity; i++)lines[i] = reader.ReadLine().Trim(); return lines; }\n public static void WriteArray(IEnumerable array) { writer.WriteLine(string.Join(\" \", array)); }\n public static void Write(params object[] array) { WriteArray(array); }\n public static void WriteLines(IEnumerable array) { foreach (var a in array)writer.WriteLine(a); }\n private class SDictionary : Dictionary\n {\n public new TValue this[TKey key]\n {\n get { return ContainsKey(key) ? base[key] : default(TValue); }\n set { base[key] = value; }\n }\n }\n private static T[] Init(int size) where T : new() { var ret = new T[size]; for (int i = 0; i < size; i++)ret[i] = new T(); return ret; }\n #endregion\n}\n", "lang_cluster": "C#", "tags": ["number theory"], "code_uid": "8c6edd22f23f7d6a0df0ecbdc6bd9850", "src_uid": "f553e89e267c223fd5acf0dd2bc1706b", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\n\nclass A\n{\n public static List GetDivisors(long n)\n {\n\n // Note that this loop runs \n // till square root \n var list = new List();\n for (long i = 1; i <= Math.Sqrt(n); i++)\n {\n if (n % i == 0)\n {\n // If divisors are equal, \n // print only one \n if (n / i == i)\n {\n list.Add(i);\n }\n else\n {\n list.Add(i);\n list.Add(n / i);\n }\n }\n }\n return list;\n }\n\n public static long GCD(long a, long b)\n {\n if (b == 0)\n {\n return a;\n }\n\n return GCD(b, a % b);\n }\n public static void Main(string[] args)\n {\n int t = 1;\n while (t > 0)\n {\n var n = long.Parse(Console.ReadLine());\n var div = GetDivisors(n);\n if (div.Count <= 2)\n Console.WriteLine(n);\n else\n {\n var sorted = div.OrderBy(x => x).ToArray();\n var ans = sorted[1];\n for (int i = 2; i < sorted.Count(); i++)\n {\n ans = GCD(ans, sorted[i]);\n }\n Console.WriteLine(ans);\n }\n t--;\n }\n }\n}", "lang_cluster": "C#", "tags": ["number theory"], "code_uid": "248dc24908c8ab990088aa9a6a1824b8", "src_uid": "f553e89e267c223fd5acf0dd2bc1706b", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.IO;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace ConsoleApp1\n{\n class Program\n {\n static void Main(string[] args)\n {\n Console.ReadLine();\n var str = Console.ReadLine();\n var s = str.ToList();\n \n var a = new int[s.Count, s.Count];\n var res = tutu(a, s, 0, s.Count - 1);\n Console.WriteLine(res);\n }\n\n // tutu(a, s, 0, s.Count - 1)\n static int tutu(int[,] a, List s, int from, int to)\n {\n if (a[from, to] == 0)\n {\n if (from == to)\n return 1;\n var res = int.MaxValue;\n\n if (s[from] == s[to])\n {\n res = tutu(a, s, from + 1, to);\n }\n else\n {\n for (int i = from; i < to; i++)\n {\n var z = tutu(a, s, from, i) + tutu(a, s, i + 1, to);\n if (s[from] == s[i + 1] || s[i] == s[to])\n z--;\n res = Math.Min(res, z);\n }\n }\n a[from, to] = res;\n }\n return a[from, to];\n }\n\n\n\n }\n}\n", "lang_cluster": "C#", "tags": ["dp"], "code_uid": "dbe7409ed036bd020347a4acb7845f8e", "src_uid": "516a89f4d1ae867fc1151becd92471e6", "difficulty": 2000.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\n\npublic class HelloWorld {\n\n static int n;\n static int m;\n static int[] str;\n static int[,,] memo;\n static int[,] memoSol;\n\n public static void SolveCodeForces() {\n Console.ReadLine();\n str = Console.ReadLine().Select(c => c - 'a').ToArray();\n n = str.Length;\n m = str.Max()+1;\n\n memo = new int[n, n, m];\n for (var i = 0; i < n; i++)\n for (var j = 0; j < n; j++)\n for (var k = 0; k < m; k++)\n memo[i,j,k] = -1;\n\n memoSol = new int[n, n];\n for (var i = 0; i < n; i++)\n for (var j = 0; j < n; j++)\n memoSol[i,j] = -1;\n\n System.Console.WriteLine(Solve(0, n-1));\n }\n\n static int Solve(int i, int j) {\n if (i > j) return 0;\n if (i == j) return 1;\n if (memoSol[i, j] >= 0) return memoSol[i, j];\n\n var ans = 10000;\n for (var sym = 0; sym < m; sym++)\n ans = Math.Min(ans, SolveFun(i, j, sym));\n ans++;\n memoSol[i, j] = ans;\n return ans;\n }\n\n static int SolveFun(int i, int j, int sym) {\n if (i > j) return 0;\n if (i == j) return str[i] == sym ? 0 : 10000;\n if (memo[i,j,sym] >= 0) return memo[i,j,sym];\n\n var ans = 10000;\n\n for (var k = i; k <= j; k++) {\n if (str[k] == sym) {\n\n var fl = SolveFun(i, k-1, sym);\n var sl = Solve(i, k-1);\n\n var fr = SolveFun(k+1, j, sym);\n var sr = Solve(k+1, j);\n\n var sol =\n Math.Min(fl + fr,\n Math.Min(sl + sr,\n Math.Min(fl + sr,\n sl + fr)));\n\n ans = Math.Min(ans, sol);\n }\n }\n\n// System.Console.WriteLine(new { i, j, sym, ans });\n\n memo[i, j, sym] = ans;\n return ans;\n }\n\n static Scanner cin = new Scanner();\n static StringBuilder cout = new StringBuilder();\n\n static public void Main () {\n SolveCodeForces();\n // System.Console.Write(cout.ToString());\n }\n}\n\npublic static class Helpers {\n public static T[] CreateArray(int length, Func itemCreate) {\n var result = new T[length];\n for (var i = 0; i < result.Length; i++)\n result[i] = itemCreate(i);\n return result;\n }\n\n public static IEnumerable IndicesWhere(this IEnumerable seq, Func cond) {\n var i = 0;\n foreach (var item in seq) {\n if (cond(item)) yield return i;\n i++;\n }\n }\n}\n\npublic class Scanner\n{\n private string[] line = new string[0];\n private int index = 0;\n\n public string Next() {\n if (line.Length <= index) {\n line = Console.ReadLine().Split(' ');\n index = 0;\n }\n var res = line[index];\n index++;\n return res;\n }\n\n public int NextInt() {\n return int.Parse(Next());\n }\n\n public long NextLong() {\n return long.Parse(Next());\n }\n\n public ulong NextUlong() {\n return ulong.Parse(Next());\n }\n\n public string[] Array() {\n line = Console.ReadLine().Split(' ');\n index = line.Length;\n return line;\n }\n\n public int[] IntArray(int emptyPrefixLen = 0) {\n var array = Array();\n var result = new int[emptyPrefixLen + array.Length];\n for (int i = 0; i < array.Length; i++)\n result[emptyPrefixLen + i] = int.Parse(array[i]);\n return result;\n }\n\n public long[] LongArray() {\n var array = Array();\n var result = new long[array.Length];\n for (int i = 0; i < array.Length; i++)\n result[i] = long.Parse(array[i]);\n return result;\n }\n\n public ulong[] UlongArray() {\n var array = Array();\n var result = new ulong[array.Length];\n for (int i = 0; i < array.Length; i++)\n result[i] = ulong.Parse(array[i]);\n return result;\n }\n}", "lang_cluster": "C#", "tags": ["dp"], "code_uid": "0e80e849ef968a7a300136dc7abf9e3e", "src_uid": "516a89f4d1ae867fc1151becd92471e6", "difficulty": 2000.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.IO;\n\nnamespace ConsoleApplication4\n{\n class Program\n {\n struct Matrix\n {\n public long A1, A2, A3, A4;\n\n public static Matrix Mul(Matrix m1, Matrix m2)\n {\n Matrix result = new Matrix();\n result.A1 = m1.A1 * m2.A1 + m1.A2 * m2.A3;\n result.A2 = m1.A1 * m2.A2 + m1.A2 * m2.A4;\n result.A3 = m1.A3 * m2.A1 + m1.A4 * m2.A3;\n result.A4 = m1.A3 * m2.A2 + m1.A4 * m2.A4;\n return result;\n }\n\n public void Mod(long mod)\n {\n A1 %= mod; A2 %= mod; A3 %= mod; A4 %= mod;\n }\n\n public static Matrix PowerMod(long power, Matrix m, long mod)\n {\n Matrix modLast = m, result = new Matrix();\n\n while (power != 0)\n {\n if ((power & 1) == 1)\n {\n if (result.A1 == 0)\n result = modLast;\n else\n result = Matrix.Mul(result, modLast);\n\n result.Mod(mod);\n }\n\n modLast = Matrix.Mul(modLast, modLast);\n modLast.Mod(mod);\n power >>= 1;\n }\n\n return result;\n }\n }\n\n static void Main(string[] args)\n {\n string[] fStrings = new string[31];\n fStrings[0] = \"a\"; fStrings[1] = \"b\";\n\n for (int i = 2; i < fStrings.Length; i++)\n fStrings[i] = fStrings[i - 1] + fStrings[i - 2];\n\n string[] inputStr = Console.ReadLine().Split(' ');\n long m = Convert.ToInt64(inputStr[0]);\n int n = Convert.ToInt32(inputStr[1]);\n StreamWriter sw = new StreamWriter(Console.OpenStandardOutput());\n\n for (int i = 0; i < n; i++)\n {\n string s = Console.ReadLine();\n long count = CalCount(s, fStrings, m - 1);\n sw.WriteLine(count % 1000000007);\n }\n\n sw.Flush();\n }\n\n static long CalCount(string s, string[] fStrings, long num)\n {\n if (num < 10)\n return ContainCount(s, fStrings[num]);\n\n Matrix m = new Matrix { A1 = 1, A2 = 1, A3 = 1, A4 = 0 };\n List result = new List();\n int index = 0;\n\n for (int i = 0; i < fStrings.Length; i++)\n {\n int count = ContainCount(s, fStrings[i]);\n if (count > 1)\n {\n if(index == 0)\n index = i;\n\n result.Add(count);\n }\n\n if (fStrings[i].Length > s.Length * 10)\n break;\n }\n\n if(result.Count == 0)\n return 0;\n\n index -= 2;\n Matrix power = Matrix.PowerMod(num - index + 1, m, 1000000007);\n\n if (result[0] == 2)\n {\n if (result[1] == 3)\n return power.A2;\n else\n return power.A1 - 1;\n }\n else\n return power.A1 - (num - index) % 2;\n }\n\n static int ContainCount(string p, string s)\n {\n if (p.Length > s.Length) return 0;\n int k = -1, count = 0;\n\n while (true)\n {\n k = s.IndexOf(p, k + 1);\n if (k == -1) break;\n count++;\n }\n\n return count;\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["matrices", "strings"], "code_uid": "a8dcb80c40c118e60a7f64a840d27f88", "src_uid": "8983915e904ba763d893d56e94d9f7f0", "difficulty": 2600.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.IO;\n\nnamespace ConsoleApplication4\n{\n class Program\n {\n struct Matrix\n {\n public long A1, A2, A3, A4;\n\n public static Matrix Mul(Matrix m1, Matrix m2)\n {\n Matrix result = new Matrix();\n result.A1 = m1.A1 * m2.A1 + m1.A2 * m2.A3;\n result.A2 = m1.A1 * m2.A2 + m1.A2 * m2.A4;\n result.A3 = m1.A3 * m2.A1 + m1.A4 * m2.A3;\n result.A4 = m1.A3 * m2.A2 + m1.A4 * m2.A4;\n return result;\n }\n\n public void Mod(long mod)\n {\n A1 %= mod; A2 %= mod; A3 %= mod; A4 %= mod;\n }\n\n public static Matrix PowerMod(long power, Matrix m, long mod)\n {\n Matrix modLast = m, result = new Matrix();\n\n while (power != 0)\n {\n if ((power & 1) == 1)\n {\n if (result.A1 == 0)\n result = modLast;\n else\n result = Matrix.Mul(result, modLast);\n\n result.Mod(mod);\n }\n\n modLast = Matrix.Mul(modLast, modLast);\n modLast.Mod(mod);\n power >>= 1;\n }\n\n return result;\n }\n }\n\n static void Main(string[] args)\n {\n string[] fStrings = new string[31];\n fStrings[0] = \"a\"; fStrings[1] = \"b\";\n\n for (int i = 2; i < fStrings.Length; i++)\n fStrings[i] = fStrings[i - 1] + fStrings[i - 2];\n\n string[] inputStr = Console.ReadLine().Split(' ');\n long m = Convert.ToInt64(inputStr[0]);\n int n = Convert.ToInt32(inputStr[1]);\n StreamWriter sw = new StreamWriter(Console.OpenStandardOutput());\n\n for (int i = 0; i < n; i++)\n {\n string s = Console.ReadLine();\n long count = CalCount(s, fStrings, m - 1);\n sw.WriteLine(count % 1000000007);\n }\n\n sw.Flush();\n }\n\n static long CalCount(string s, string[] fStrings, long num)\n {\n if (num < 10)\n return ContainCount(s, fStrings[num]);\n\n Matrix m = new Matrix { A1 = 1, A2 = 1, A3 = 1, A4 = 0 };\n List result = new List();\n int index = 0;\n\n for (int i = 0; i < fStrings.Length; i++)\n {\n int count = ContainCount(s, fStrings[i]);\n if (count > 1)\n {\n if(index == 0)\n index = i;\n\n result.Add(count);\n }\n\n if (fStrings[i].Length > s.Length * 10)\n break;\n }\n\n if(result.Count == 0)\n return 0;\n\n index -= 2;\n Matrix power = Matrix.PowerMod(num - index + 1, m, 1000000007);\n\n if (result[0] == 2)\n {\n if (result[1] == 3)\n return power.A2;\n else\n return power.A1 - 1;\n }\n else\n return power.A1 - (num - index) % 2;\n }\n\n static int ContainCount(string p, string s)\n {\n if (p.Length > s.Length) return 0;\n int k = -1, count = 0;\n\n while (true)\n {\n k = s.IndexOf(p, k + 1);\n if (k == -1) break;\n count++;\n }\n\n return count;\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["matrices", "strings"], "code_uid": "08cf98ca886d809aa6bc9489f0007af3", "src_uid": "8983915e904ba763d893d56e94d9f7f0", "difficulty": 2600.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\n\nnamespace Codeforces.TaskE\n{\n public class Task\n {\n public static void Main()\n {\n var task = new Task();\n task.Solve();\n }\n\n private const long Mod = 1000000007L;\n private const long Max = 102L;\n private long n, m, k;\n private long[,,,] Ways;\n private long[][] C;\n\n void Solve()\n {\n Input.Next(out n, out m, out k);\n\n C = new long[Max][];\n C[0] = new long[1];\n C[0][0] = 1;\n for (var i = 1; i < Max; i++)\n {\n C[i] = new long[i + 1];\n C[i][0] = 1; C[i][i] = 1;\n for (var j = 1; j < i; j++) \n C[i][j] = C[i - 1][j - 1] + C[i - 1][j] % Mod;\n }\n\n n /= 2;\n Ways = new long[n + 2, n + 2, n + 2, Max];\n Ways[0, 1, 0, 1] = 1;\n\n var result = 0L;\n for (var maxValue = 0; maxValue <= n && maxValue < m; maxValue++)\n for (var holes = 0; holes <= n; holes++)\n for (var total = 0; total <= n; total++)\n for (var ways = 0; ways <= k; ways++)\n {\n var prevWays = Ways[maxValue, holes, total, ways];\n if (prevWays == 0) continue;\n if (maxValue > 0)\n {\n result += (prevWays * (m - maxValue)) % Mod;\n result %= Mod;\n } \n\n for (var newCountOfMaxValues = 1; newCountOfMaxValues <= n - total; newCountOfMaxValues++)\n {\n var newWays = ways*C[holes + newCountOfMaxValues - 1][newCountOfMaxValues];\n if (newWays <= k)\n {\n Ways[maxValue + 1, newCountOfMaxValues, total + newCountOfMaxValues, newWays] += prevWays;\n Ways[maxValue + 1, newCountOfMaxValues, total + newCountOfMaxValues, newWays] %= Mod;\n }\n }\n }\n Console.WriteLine(result);\n }\n }\n\n #region Input\n\n public class Input\n {\n private static string _line;\n\n public static bool Next()\n {\n _line = Console.ReadLine();\n return !string.IsNullOrEmpty(_line);\n }\n\n public static bool Next(out long a)\n {\n var ok = Next();\n a = ok ? long.Parse(_line) : 0;\n return ok;\n }\n\n public static bool Next(out long a, out long b)\n {\n var ok = Next();\n if (ok)\n {\n var array = _line.Split(' ').Select(long.Parse).ToArray();\n a = array[0];\n b = array[1];\n }\n else\n {\n a = b = 0;\n }\n\n return ok;\n }\n\n public static bool Next(out long a, out long b, out long c)\n {\n var ok = Next();\n if (ok)\n {\n var array = _line.Split(' ').Select(long.Parse).ToArray();\n a = array[0];\n b = array[1];\n c = array[2];\n }\n else\n {\n a = b = c = 0;\n }\n return ok;\n }\n\n public static bool Next(out long a, out long b, out long c, out long d)\n {\n var ok = Next();\n if (ok)\n {\n var array = _line.Split(' ').Select(long.Parse).ToArray();\n a = array[0];\n b = array[1];\n c = array[2];\n d = array[3];\n }\n else\n {\n a = b = c = d = 0;\n }\n return ok;\n }\n\n public static bool Next(out long a, out long b, out long c, out long d, out long e)\n {\n var ok = Next();\n if (ok)\n {\n var array = _line.Split(' ').Select(long.Parse).ToArray();\n a = array[0];\n b = array[1];\n c = array[2];\n d = array[3];\n e = array[4];\n }\n else\n {\n a = b = c = d = e = 0;\n }\n return ok;\n }\n\n public static List Numbers()\n {\n Next();\n return _line.Split(' ').Select(long.Parse).ToList();\n }\n }\n\n #endregion\n\n}\n", "lang_cluster": "C#", "tags": ["dp"], "code_uid": "741a562faf1fe2d5696563da157a30ba", "src_uid": "c6d275b1e1d5c9e39e2cf990a635fa6b", "difficulty": 2800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.IO;\nusing System.Runtime.CompilerServices;\nusing System.Text;\nusing System.Diagnostics;\nusing System.Numerics;\nusing static System.Console;\nusing static System.Convert;\nusing static System.Math;\nusing static Template;\nusing Pi = Pair;\n\nclass Solver\n{\n public void Solve(Scanner sc)\n {\n long N, M, L, R;\n sc.Make(out N, out M, out L, out R);\n R -= L;\n if (N * M % 2 == 1)\n {\n Fail(ModInt.Pow(R + 1, N * M));\n }\n ModInt odd = (R + 1) / 2, even = R / 2 + 1;\n var A = new[] { new[] { even, odd }, new[] { odd, even } };\n var f = N * M;\n var res = new[] { new[] { (ModInt)1, 0 }, new[] { (ModInt)0, 1 } };\n while (f != 0)\n {\n if (f % 2 == 1) res = matmul(res, A);\n f >>= 1;\n A = matmul(A, A);\n }\n WriteLine(res[0][0]);\n }\n ModInt[][] matmul(ModInt[][] A,ModInt[][] B)\n {\n var rt = Create(A.Length, () => new ModInt[A.Length]);\n for(int i=0;i Value.ToString();\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static ModInt operator +(ModInt l, ModInt r)\n {\n l.Value += r.Value;\n if (l.Value >= MOD) l.Value -= MOD;\n return l;\n }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static ModInt operator -(ModInt l, ModInt r)\n {\n l.Value -= r.Value;\n if (l.Value < 0) l.Value += MOD;\n return l;\n }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static ModInt operator *(ModInt l, ModInt r) => new ModInt(l.Value * r.Value % MOD);\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static ModInt operator /(ModInt l, ModInt r) => l * Pow(r, MOD - 2);\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static implicit operator long(ModInt l) => l.Value;\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static implicit operator ModInt(long n)\n {\n n %= MOD; if (n < 0) n += MOD;\n return new ModInt(n);\n }\n\n public static ModInt Pow(ModInt m, long n)\n {\n if (n == 0) return 1;\n if (n % 2 == 0) return Pow(m * m, n >> 1);\n else return Pow(m * m, n >> 1) * m;\n }\n\n public static void Build(int n)\n {\n fac = new ModInt[n + 1];\n facinv = new ModInt[n + 1];\n inv = new ModInt[n + 1];\n inv[1] = 1;\n fac[0] = fac[1] = 1;\n facinv[0] = facinv[1] = 1;\n for (var i = 2; i <= n; i++)\n {\n fac[i] = fac[i - 1] * i;\n inv[i] = MOD - inv[MOD % i] * (MOD / i);\n facinv[i] = facinv[i - 1] * inv[i];\n }\n }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static ModInt Fac(ModInt n) => fac[n];\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static ModInt Inv(ModInt n) => inv[n];\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static ModInt FacInv(ModInt n) => facinv[n];\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static ModInt Comb(ModInt n, ModInt r)\n {\n if (n < r) return 0;\n if (n == r) return 1;\n var calc = fac[n];\n calc = calc * facinv[r];\n calc = calc * facinv[n - r];\n return calc;\n }\n}\n#region Template\npublic static class Template\n{\n static void Main(string[] args)\n {\n Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });\n new Solver().Solve(new Scanner());\n Console.Out.Flush();\n }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static bool chmin(ref T a, T b) where T : IComparable { if (a.CompareTo(b) == 1) { a = b; return true; } return false; }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static bool chmax(ref T a, T b) where T : IComparable { if (a.CompareTo(b) == -1) { a = b; return true; } return false; }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static void swap(ref T a, ref T b) { var t = b; b = a; a = t; }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static void swap(this IList A, int i, int j) { var t = A[i];A[i] = A[j];A[j] = t; }\n public static T[] Shuffle(this IList A) { T[] rt = A.ToArray(); Random rnd = new Random(); for (int i = rt.Length - 1; i >= 1; i--) swap(ref rt[i], ref rt[rnd.Next(i + 1)]); return rt; }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static T[] Create(int n, Func f) { var rt = new T[n]; for (var i = 0; i < rt.Length; ++i) rt[i] = f(); return rt; }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static T[] Create(int n, Func f) { var rt = new T[n]; for (var i = 0; i < rt.Length; ++i) rt[i] = f(i); return rt; }\n public static void Fail(T s) { Console.WriteLine(s); Console.Out.Close(); Environment.Exit(0); }\n\n}\npublic class Scanner\n{\n public string Str => Console.ReadLine().Trim();\n public int Int => int.Parse(Str);\n public long Long => long.Parse(Str);\n public double Double => double.Parse(Str);\n public int[] ArrInt => Str.Split(' ').Select(int.Parse).ToArray();\n public long[] ArrLong => Str.Split(' ').Select(long.Parse).ToArray();\n public char[][] Grid(int n) => Create(n, () => Str.ToCharArray());\n public int[] ArrInt1D(int n) => Create(n, () => Int);\n public long[] ArrLong1D(int n) => Create(n, () => Long);\n public int[][] ArrInt2D(int n) => Create(n, () => ArrInt);\n public long[][] ArrLong2D(int n) => Create(n, () => ArrLong);\n private Queue q = new Queue();\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public T Next() { if (q.Count == 0) foreach (var item in Str.Split(' ')) q.Enqueue(item); return (T)Convert.ChangeType(q.Dequeue(), typeof(T)); }\n public void Make(out T1 v1) => v1 = Next();\n public void Make(out T1 v1, out T2 v2) { v1 = Next(); v2 = Next(); }\n public void Make(out T1 v1, out T2 v2, out T3 v3) { Make(out v1, out v2); v3 = Next(); }\n public void Make(out T1 v1, out T2 v2, out T3 v3, out T4 v4) { Make(out v1, out v2, out v3); v4 = Next(); }\n public void Make(out T1 v1, out T2 v2, out T3 v3, out T4 v4, out T5 v5) { Make(out v1, out v2, out v3, out v4); v5 = Next(); }\n public void Make(out T1 v1, out T2 v2, out T3 v3, out T4 v4, out T5 v5, out T6 v6) { Make(out v1, out v2, out v3, out v4, out v5); v6 = Next(); }\n //public (T1, T2) Make() { Make(out T1 v1, out T2 v2); return (v1, v2); }\n //public (T1, T2, T3) Make() { Make(out T1 v1, out T2 v2, out T3 v3); return (v1, v2, v3); }\n //public (T1, T2, T3, T4) Make() { Make(out T1 v1, out T2 v2, out T3 v3, out T4 v4); return (v1, v2, v3, v4); }\n}\npublic class Pair : IComparable>\n{\n public T1 v1;\n public T2 v2;\n public Pair() { }\n public Pair(T1 v1, T2 v2)\n { this.v1 = v1; this.v2 = v2; }\n\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public int CompareTo(Pair p)\n {\n var c = Comparer.Default.Compare(v1, p.v1);\n if (c == 0)\n c = Comparer.Default.Compare(v2, p.v2);\n return c;\n }\n public override string ToString() => $\"{v1.ToString()} {v2.ToString()}\";\n public void Deconstruct(out T1 a, out T2 b) { a = v1; b = v2; }\n}\n\npublic class Pair : Pair, IComparable>\n{\n public T3 v3;\n public Pair() : base() { }\n public Pair(T1 v1, T2 v2, T3 v3) : base(v1, v2)\n { this.v3 = v3; }\n\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public int CompareTo(Pair p)\n {\n var c = base.CompareTo(p);\n if (c == 0)\n c = Comparer.Default.Compare(v3, p.v3);\n return c;\n }\n public override string ToString() => $\"{base.ToString()} {v3.ToString()}\";\n public void Deconstruct(out T1 a, out T2 b, out T3 c) { Deconstruct(out a, out b); c = v3; }\n}\n#endregion", "lang_cluster": "C#", "tags": ["math", "matrices", "constructive algorithms", "combinatorics"], "code_uid": "2e112627a7ce9d11707e22f6354196af", "src_uid": "ded299fa1cd010822c60f2389a3ba1a3", "difficulty": 2100.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.IO;\nusing System.Runtime.CompilerServices;\nusing System.Text;\nusing System.Diagnostics;\nusing System.Numerics;\nusing static System.Console;\nusing static System.Convert;\nusing static System.Math;\nusing static Template;\nusing Pi = Pair;\n\nclass Solver\n{\n public void Solve(Scanner sc)\n {\n long N, M, L, R;\n sc.Make(out N, out M, out L, out R);\n R -= L;\n if (N * M % 2 == 1)\n {\n Fail(ModInt.Pow(R + 1, N * M));\n }\n long odd = (R + 1) / 2, even = R / 2 + 1;\n var res = ModInt.Pow(even - odd, N * M);\n res += ModInt.Pow(R + 1, N * M);\n res /= 2;\n WriteLine(res);\n }\n}\n\npublic struct ModInt\n{\n //public const long MOD = (int)1e9 + 7;\n public const long MOD = 998244353;\n public long Value { get; set; }\n public ModInt(long n = 0) { Value = n; }\n private static ModInt[] fac;//\u968e\u4e57\n private static ModInt[] inv;//\u9006\u6570\n private static ModInt[] facinv;//1/(i!)\n public override string ToString() => Value.ToString();\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static ModInt operator +(ModInt l, ModInt r)\n {\n l.Value += r.Value;\n if (l.Value >= MOD) l.Value -= MOD;\n return l;\n }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static ModInt operator -(ModInt l, ModInt r)\n {\n l.Value -= r.Value;\n if (l.Value < 0) l.Value += MOD;\n return l;\n }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static ModInt operator *(ModInt l, ModInt r) => new ModInt(l.Value * r.Value % MOD);\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static ModInt operator /(ModInt l, ModInt r) => l * Pow(r, MOD - 2);\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static implicit operator long(ModInt l) => l.Value;\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static implicit operator ModInt(long n)\n {\n n %= MOD; if (n < 0) n += MOD;\n return new ModInt(n);\n }\n\n public static ModInt Pow(ModInt m, long n)\n {\n if (n == 0) return 1;\n if (n % 2 == 0) return Pow(m * m, n >> 1);\n else return Pow(m * m, n >> 1) * m;\n }\n\n public static void Build(int n)\n {\n fac = new ModInt[n + 1];\n facinv = new ModInt[n + 1];\n inv = new ModInt[n + 1];\n inv[1] = 1;\n fac[0] = fac[1] = 1;\n facinv[0] = facinv[1] = 1;\n for (var i = 2; i <= n; i++)\n {\n fac[i] = fac[i - 1] * i;\n inv[i] = MOD - inv[MOD % i] * (MOD / i);\n facinv[i] = facinv[i - 1] * inv[i];\n }\n }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static ModInt Fac(ModInt n) => fac[n];\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static ModInt Inv(ModInt n) => inv[n];\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static ModInt FacInv(ModInt n) => facinv[n];\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static ModInt Comb(ModInt n, ModInt r)\n {\n if (n < r) return 0;\n if (n == r) return 1;\n var calc = fac[n];\n calc = calc * facinv[r];\n calc = calc * facinv[n - r];\n return calc;\n }\n}\n#region Template\npublic static class Template\n{\n static void Main(string[] args)\n {\n Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });\n new Solver().Solve(new Scanner());\n Console.Out.Flush();\n }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static bool chmin(ref T a, T b) where T : IComparable { if (a.CompareTo(b) == 1) { a = b; return true; } return false; }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static bool chmax(ref T a, T b) where T : IComparable { if (a.CompareTo(b) == -1) { a = b; return true; } return false; }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static void swap(ref T a, ref T b) { var t = b; b = a; a = t; }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static void swap(this IList A, int i, int j) { var t = A[i];A[i] = A[j];A[j] = t; }\n public static T[] Shuffle(this IList A) { T[] rt = A.ToArray(); Random rnd = new Random(); for (int i = rt.Length - 1; i >= 1; i--) swap(ref rt[i], ref rt[rnd.Next(i + 1)]); return rt; }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static T[] Create(int n, Func f) { var rt = new T[n]; for (var i = 0; i < rt.Length; ++i) rt[i] = f(); return rt; }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static T[] Create(int n, Func f) { var rt = new T[n]; for (var i = 0; i < rt.Length; ++i) rt[i] = f(i); return rt; }\n public static void Fail(T s) { Console.WriteLine(s); Console.Out.Close(); Environment.Exit(0); }\n}\npublic class Scanner\n{\n public string Str => Console.ReadLine().Trim();\n public int Int => int.Parse(Str);\n public long Long => long.Parse(Str);\n public double Double => double.Parse(Str);\n public int[] ArrInt => Str.Split(' ').Select(int.Parse).ToArray();\n public long[] ArrLong => Str.Split(' ').Select(long.Parse).ToArray();\n public char[][] Grid(int n) => Create(n, () => Str.ToCharArray());\n public int[] ArrInt1D(int n) => Create(n, () => Int);\n public long[] ArrLong1D(int n) => Create(n, () => Long);\n public int[][] ArrInt2D(int n) => Create(n, () => ArrInt);\n public long[][] ArrLong2D(int n) => Create(n, () => ArrLong);\n private Queue q = new Queue();\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public T Next() { if (q.Count == 0) foreach (var item in Str.Split(' ')) q.Enqueue(item); return (T)Convert.ChangeType(q.Dequeue(), typeof(T)); }\n public void Make(out T1 v1) => v1 = Next();\n public void Make(out T1 v1, out T2 v2) { v1 = Next(); v2 = Next(); }\n public void Make(out T1 v1, out T2 v2, out T3 v3) { Make(out v1, out v2); v3 = Next(); }\n public void Make(out T1 v1, out T2 v2, out T3 v3, out T4 v4) { Make(out v1, out v2, out v3); v4 = Next(); }\n public void Make(out T1 v1, out T2 v2, out T3 v3, out T4 v4, out T5 v5) { Make(out v1, out v2, out v3, out v4); v5 = Next(); }\n public void Make(out T1 v1, out T2 v2, out T3 v3, out T4 v4, out T5 v5, out T6 v6) { Make(out v1, out v2, out v3, out v4, out v5); v6 = Next(); }\n //public (T1, T2) Make() { Make(out T1 v1, out T2 v2); return (v1, v2); }\n //public (T1, T2, T3) Make() { Make(out T1 v1, out T2 v2, out T3 v3); return (v1, v2, v3); }\n //public (T1, T2, T3, T4) Make() { Make(out T1 v1, out T2 v2, out T3 v3, out T4 v4); return (v1, v2, v3, v4); }\n}\npublic class Pair : IComparable>\n{\n public T1 v1;\n public T2 v2;\n public Pair() { }\n public Pair(T1 v1, T2 v2)\n { this.v1 = v1; this.v2 = v2; }\n\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public int CompareTo(Pair p)\n {\n var c = Comparer.Default.Compare(v1, p.v1);\n if (c == 0)\n c = Comparer.Default.Compare(v2, p.v2);\n return c;\n }\n public override string ToString() => $\"{v1.ToString()} {v2.ToString()}\";\n public void Deconstruct(out T1 a, out T2 b) { a = v1; b = v2; }\n}\n\npublic class Pair : Pair, IComparable>\n{\n public T3 v3;\n public Pair() : base() { }\n public Pair(T1 v1, T2 v2, T3 v3) : base(v1, v2)\n { this.v3 = v3; }\n\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public int CompareTo(Pair p)\n {\n var c = base.CompareTo(p);\n if (c == 0)\n c = Comparer.Default.Compare(v3, p.v3);\n return c;\n }\n public override string ToString() => $\"{base.ToString()} {v3.ToString()}\";\n public void Deconstruct(out T1 a, out T2 b, out T3 c) { Deconstruct(out a, out b); c = v3; }\n}\n#endregion", "lang_cluster": "C#", "tags": ["math", "matrices", "constructive algorithms", "combinatorics"], "code_uid": "194a75651abf952162a5c3c418288805", "src_uid": "ded299fa1cd010822c60f2389a3ba1a3", "difficulty": 2100.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Globalization;\nusing System.IO;\nusing System.Linq;\n\nnamespace CF317\n{\n\tinternal class Program\n\t{\n\t\tprivate static void Main(string[] args)\n\t\t{\n\t\t\tvar sr = new InputReader(Console.In);\n\t\t\t//var sr = new InputReader(new StreamReader(\"input.txt\"));\n\t\t\tvar task = new Task();\n\t\t\tusing (var sw = Console.Out)\n\t\t\t\t//using (var sw = new StreamWriter(\"output.txt\"))\n\t\t\t{\n\t\t\t\ttask.Solve(sr, sw);\n\t\t\t\t//Console.ReadKey();\n\t\t\t}\n\t\t}\n\t}\n\n\tinternal class Task\n\t{\n\t\tprivate int[] a;\n\t\tprivate int[] b;\n\t\tprivate int[] c;\n\t\tprivate int[] d;\n\n\t\tpublic void Solve(InputReader sr, TextWriter sw)\n\t\t{\n\t\t\tvar input = sr.ReadArray(Int32.Parse);\n\t\t\tvar n = input[0];\n\t\t\tvar m = input[1];\n\t\t\tvar cTesto = input[2];\n\t\t\tvar dTesto = input[3];\n\t\t\ta = new int[m];\n\t\t\tb = new int[m];\n\t\t\tc = new int[m];\n\t\t\td = new int[m];\n\t\t\tfor (var i = 0; i < m; i++) {\n\t\t\t\tinput = sr.ReadArray(Int32.Parse);\n\t\t\t\ta[i] = input[0];\n\t\t\t\tb[i] = input[1];\n\t\t\t\tc[i] = input[2];\n\t\t\t\td[i] = input[3];\n\t\t\t}\n\t\t\tvar dp = new int[n + 1, m + 1];\n\t\t\tfor (var i = 0; i <= n; i++) {\n\t\t\t\tfor (var j = 1; j <= m; j++) {\n\t\t\t\t\tfor (var k = 0; k <= a[j - 1] / b[j - 1]; k++) {\n\t\t\t\t\t\tif (i - c[j - 1] * k >= 0) {\n\t\t\t\t\t\t\tdp[i, j] = Math.Max(dp[i, j], dp[i - c[j - 1] * k, j - 1] + k * d[j - 1]);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tvar max = 0;\n\t\t\tfor (var i = 0; i <= n; i++) {\n\t\t\t\tfor (var j = 0; j <= m; j++) {\n\t\t\t\t\tmax = Math.Max(dp[i, j] + ((n - i) / cTesto) * dTesto, max);\n\t\t\t\t}\n\t\t\t}\n\t\t\tsw.WriteLine(max);\n\t\t}\n\t}\n}\n\ninternal class InputReader : IDisposable\n{\n\tprivate bool isDispose;\n\tprivate readonly TextReader sr;\n\n\tpublic InputReader(TextReader stream)\n\t{\n\t\tsr = stream;\n\t}\n\n\tpublic void Dispose()\n\t{\n\t\tDispose(true);\n\t\tGC.SuppressFinalize(this);\n\t}\n\n\tpublic string NextString()\n\t{\n\t\tvar result = sr.ReadLine();\n\t\treturn result;\n\t}\n\n\tpublic int NextInt32()\n\t{\n\t\treturn Int32.Parse(NextString());\n\t}\n\n\tpublic long NextInt64()\n\t{\n\t\treturn Int64.Parse(NextString());\n\t}\n\n\tpublic string[] NextSplitStrings()\n\t{\n\t\treturn NextString()\n\t\t\t.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);\n\t}\n\n\tpublic T[] ReadArray(Func func)\n\t{\n\t\treturn NextSplitStrings()\n\t\t\t.Select(s => func(s, CultureInfo.InvariantCulture))\n\t\t\t.ToArray();\n\t}\n\n\tpublic T[] ReadArrayFromString(Func func, string str)\n\t{\n\t\treturn\n\t\t\tstr.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)\n\t\t\t\t.Select(s => func(s, CultureInfo.InvariantCulture))\n\t\t\t\t.ToArray();\n\t}\n\n\tprotected void Dispose(bool dispose)\n\t{\n\t\tif (!isDispose) {\n\t\t\tif (dispose)\n\t\t\t\tsr.Close();\n\t\t\tisDispose = true;\n\t\t}\n\t}\n\n\t~InputReader()\n\t{\n\t\tDispose(false);\n\t}\n}", "lang_cluster": "C#", "tags": ["dp"], "code_uid": "4900e9c8bf0fb7a470c8b6a3775b95ad", "src_uid": "4e166b8b44427b1227e0f811161d3a6f", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.IO;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Globalization;\n\nnamespace cf_82_div2\n{\n \n class Program\n {\n private static HashSet delims =\n new HashSet { (int)' ', (int)'\\t', (int)'\\n', (int)'\\r' };\n private static StringBuilder token = new StringBuilder();\n\n private static void Skip()\n {\n while (delims.Contains(Console.In.Peek()))\n Console.Read();\n }\n\n public static bool EndOfStream()\n {\n Skip();\n return Console.In.Peek() == -1;\n }\n\n public static string Read()\n {\n Skip();\n int c = Console.Read();\n while (c != -1 && !delims.Contains(c))\n {\n token.Append((char)c);\n c = Console.Read();\n }\n string ret = token.ToString();\n token.Length = 0;\n return ret;\n }\n\n public static int ReadInt()\n {\n return int.Parse(Read());\n }\n\n public static double ReadDouble()\n {\n return double.Parse(Read());\n }\n\n public static bool solve()\n {\n int[][] dp;\n int[] cnt, cost, weight;\n int n, W, a, b, c;\n W = ReadInt();\n n = ReadInt();\n n++;\n\n cnt = new int[n];\n cost = new int[n];\n weight = new int[n];\n dp = new int[2][];\n for (int i = 0; i < 2; i++)\n dp[i] = new int[W + 1];\n\n c = ReadInt();\n weight[0] = c;\n cost[0] = ReadInt();\n cnt[0] = W / c;\n for (int i = 1; i < n; i++)\n {\n a = ReadInt();\n b = ReadInt();\n c = ReadInt();\n cost[i] = ReadInt();\n cnt[i] = System.Math.Min(a / b, W / c);\n weight[i] = c;\n }\n\n for (int i = 0; i < n; i++)\n {\n for (int it = 0; it < cnt[i]; it++)\n {\n for (int w = 0; w + weight[i] <= W; w++)\n {\n dp[1][w + weight[i]] = System.Math.Max(dp[1][w + weight[i]], dp[0][w] + cost[i]);\n }\n System.Array.Copy(dp[1], dp[0], dp[1].Length);\n }\n }\n\n int ans = 0;\n for (int i = 0; i <= W; i++)\n ans = System.Math.Max(ans, dp[0][i]);\n Console.WriteLine(ans);\n return false;\n }\n\n static void Main(string[] args)\n {\n //StreamReader reader = new StreamReader(\"input.txt\");\n //StreamWriter writer = new StreamWriter(\"output.txt\");\n //Console.SetIn(reader);\n //Console.SetOut(writer);\n while (solve() == true);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["dp"], "code_uid": "cc2d7ec1d4c118ef5c942ddb94aeb25d", "src_uid": "4e166b8b44427b1227e0f811161d3a6f", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Globalization;\nusing System.Linq;\nusing System.Text;\nusing System.Text.RegularExpressions;\nusing System.Threading;\n\nnamespace Codeforces\n{\n class C\n {\n private static ThreadStart s_threadStart = new C().Go;\n private static bool s_time = false;\n\n public class Truple\n {\n public int a;\n public int b;\n public int c;\n }\n\n private void Go()\n {\n int n = GetInt();\n int m = GetInt();\n int k = GetInt();\n List[] data = new List[n];\n for (int i = 0; i < n; i++)\n {\n GetString();\n data[i] = new List();\n for (int j = 0; j < m; j++)\n {\n Truple tr;\n data[i].Add(tr = new Truple());\n tr.a = GetInt();\n tr.b = GetInt();\n tr.c = GetInt();\n }\n }\n int max = 0;\n Tuple[] unitProfit = new Tuple[m];\n for (int i = 0; i < n; i++)\n {\n for (int j = 0; j < n; j++)\n {\n var buy = data[i];\n var sell = data[j];\n for (int x = 0; x < m; x++)\n {\n unitProfit[x] = new Tuple(sell[x].b - buy[x].a, x);\n }\n Array.Sort(unitProfit);\n Array.Reverse(unitProfit);\n int kk = k;\n int localProfit = 0;\n for (int y = 0; y < m && kk > 0 && unitProfit[y].Item1 > 0; y++)\n {\n int cap = buy[unitProfit[y].Item2].c;\n localProfit += Math.Min(cap, kk) * unitProfit[y].Item1;\n kk -= cap;\n }\n\n if (localProfit > max) max = localProfit;\n }\n }\n\n Wl(max);\n }\n\n #region Template\n\n public static void Main(string[] args)\n {\n System.Diagnostics.Stopwatch timer = new System.Diagnostics.Stopwatch();\n Thread main = new Thread(new ThreadStart(s_threadStart), 512 * 1024 * 1024);\n timer.Start();\n main.Start();\n main.Join();\n timer.Stop();\n if (s_time)\n Wl(timer.ElapsedMilliseconds);\n }\n\n private static IEnumerator ioEnum;\n private static string GetString()\n {\n while (ioEnum == null || !ioEnum.MoveNext())\n {\n ioEnum = Console.ReadLine().Split().AsEnumerable().GetEnumerator();\n }\n\n return ioEnum.Current;\n }\n\n private static int GetInt()\n {\n return int.Parse(GetString());\n }\n\n private static long GetLong()\n {\n return long.Parse(GetString());\n }\n\n private static double GetDouble()\n {\n return double.Parse(GetString());\n }\n\n private static List GetIntArr(int n)\n {\n List ret = new List(n);\n for (int i = 0; i < n; i++)\n {\n ret.Add(GetInt());\n }\n return ret;\n }\n\n private static void Wl(T o)\n {\n if (o is double)\n {\n Wld((o as double?).Value, \"\");\n }\n else if (o is float)\n {\n Wld((o as float?).Value, \"\");\n }\n else\n Console.WriteLine(o.ToString());\n }\n\n private static void Wl(IEnumerable enumerable)\n {\n Wl(string.Join(\" \", enumerable.Select(e => e.ToString()).ToArray()));\n }\n\n private static void Wld(double d, string format)\n {\n Wl(d.ToString(format, CultureInfo.InvariantCulture));\n }\n\n public struct Tuple : IComparable>\n where T : IComparable\n where K : IComparable\n {\n public T Item1;\n public K Item2;\n\n public Tuple(T t, K k)\n {\n Item1 = t;\n Item2 = k;\n }\n\n public override bool Equals(object obj)\n {\n var o = (Tuple)obj;\n return o.Item1.Equals(Item1) && o.Item2.Equals(Item2);\n }\n\n public override int GetHashCode()\n {\n return Item1.GetHashCode() ^ Item2.GetHashCode();\n }\n\n public override string ToString()\n {\n return \"(\" + Item1 + \" \" + Item2 + \")\";\n }\n\n #region IComparable> Members\n\n public int CompareTo(Tuple other)\n {\n int ret = Item1.CompareTo(other.Item1);\n if (ret != 0) return ret;\n return Item2.CompareTo(other.Item2);\n }\n\n #endregion\n }\n\n #endregion\n }\n}", "lang_cluster": "C#", "tags": ["greedy", "games", "graph matchings"], "code_uid": "424c512891935372f26c03691bfdd1ae", "src_uid": "7419c4268a9815282fadca6581f28ec1", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Diagnostics;\nusing System.Runtime.InteropServices;\nusing System.Text;\nusing System.Linq;\nusing System.IO;\nusing System.Globalization;\nusing System.Collections;\n\nnamespace Task\n{\n\n #region MyIo\n\n internal class MyIo : IDisposable\n {\n private readonly TextReader inputStream;\n private readonly TextWriter outputStream = Console.Out;\n\n private string[] tokens;\n private int pointer;\n\n public MyIo()\n#if LOCAL_TEST\n : this(new StreamReader(\"input.txt\"))\n#else\n : this(System.Console.In)\n#endif\n {\n\n }\n\n public MyIo(TextReader inputStream)\n {\n this.inputStream = inputStream;\n }\n\n\n public char NextChar()\n {\n try\n {\n return (char)inputStream.Read();\n }\n catch (IOException)\n {\n return '\\0';\n }\n }\n\n public string NextLine()\n {\n try\n {\n return inputStream.ReadLine();\n }\n catch (IOException)\n {\n return null;\n }\n }\n\n public string NextString()\n {\n try\n {\n while (tokens == null || pointer >= tokens.Length)\n {\n tokens = (NextLine() + string.Empty).Split(new[] { ' ', '\\t' }, StringSplitOptions.RemoveEmptyEntries);\n pointer = 0;\n }\n return tokens[pointer++];\n }\n catch (IOException)\n {\n return null;\n }\n }\n\n public int NextInt()\n {\n return Next();\n }\n\n public long NextLong()\n {\n return Next();\n }\n\n public T Next()\n {\n var t = typeof(T);\n\n if (t == typeof(char))\n return (T)(object)NextChar();\n\n object s = NextString();\n\n if (t == typeof(string))\n return (T)s;\n\n return (T)Convert.ChangeType(s, typeof(T));\n }\n\n\n public IEnumerable NextWhile(Predicate pred)\n {\n if (pred == null)\n yield break;\n\n T res = Next();\n\n while (pred(res))\n {\n yield return res;\n\n res = Next();\n }\n }\n\n public IEnumerable NextSeq(long n)\n {\n for (var i = 0; i < n; i++)\n yield return Next();\n }\n\n public void Print(string format, params object[] args)\n {\n outputStream.Write(string.Format(CultureInfo.InvariantCulture, format, args));\n }\n\n public void PrintLine(string format, params object[] args)\n {\n Print(format, args);\n\n outputStream.WriteLine();\n }\n\n public void Print(bool o)\n {\n Print(o ? \"YES\" : \"NO\");\n }\n\n public void PrintLine(bool o)\n {\n PrintLine(o ? \"YES\" : \"NO\");\n }\n\n public void Print(T o)\n {\n outputStream.Write(Convert.ToString(o, CultureInfo.InvariantCulture));\n }\n\n\n public void PrintLine(T o)\n {\n Print(o);\n\n outputStream.WriteLine();\n }\n\n public void Close()\n {\n inputStream.Close();\n outputStream.Close();\n }\n\n void IDisposable.Dispose()\n {\n Close();\n\n#if LOCAL_TEST\n Console.ReadLine();\n#endif\n }\n }\n\n\n public static class ListExtensions\n {\n\n public static IEnumerable ToCycleEnumerable(this IEnumerable self)\n {\n if (self != null)\n {\n for (; ; )\n {\n foreach (var x in self)\n yield return x;\n }\n }\n }\n\n public static T CycleGet(this IList self, int index)\n {\n var c = self.Count;\n return self[(index % c + c) % c];\n }\n\n\n public static IList Shuffle(this IList self)\n {\n var rnd = new Random(DateTime.Now.Millisecond);\n\n var n = self.Count;\n\n while (n > 1)\n {\n n--;\n var k = rnd.Next(n + 1);\n var value = self[k];\n self[k] = self[n];\n self[n] = value;\n }\n\n return self;\n }\n\n public static IList> UseForNew2D(this T def, int fd, int sd)\n {\n var fdim = new T[fd][];\n\n for (int i = 0; i < fd; i++)\n {\n fdim[i] = new T[sd];\n Fill(fdim[i], def);\n }\n\n return fdim;\n }\n\n public static IList Fill(this IList self, Func fval)\n {\n for (var i = 0; i < self.Count; i++)\n self[i] = fval();\n\n\n return self;\n }\n\n\n public static IList Fill(this IList self, T val)\n {\n return self.Fill(() => val);\n }\n\n public static long Hash(this IList self, Func val = null)\n {\n return val != null ? self.Hash((t, current) => unchecked(current * 19L + val(t))) : self.Hash(HashOne);\n }\n\n public static long Hash(this IList self, Func val)\n {\n return self.Aggregate(0L, (current, t) => unchecked(val(t, current)));\n }\n\n\n public static long HashOne(this T self, long current)\n {\n return unchecked(current * 19L + (Equals(self, default(T)) ? 0 : self.GetHashCode()));\n }\n\n }\n\n public static class P\n {\n public static P Create(T1 key, T2 val)\n {\n return new P(key, val);\n }\n }\n\n public class P\n {\n private class PComparer : IComparer>\n {\n private readonly bool? byKey;\n\n public PComparer(bool? byKey)\n {\n this.byKey = byKey;\n }\n\n\n public int Compare(P x, P y)\n {\n x = x ?? new P();\n y = y ?? new P();\n\n\n if (byKey == true)\n return Comparer.Default.Compare(x.Key, y.Key);\n else if (byKey == false)\n return Comparer.Default.Compare(x.Value, y.Value);\n else\n {\n var tr = Comparer.Default.Compare(x.Key, y.Key);\n\n if (tr != 0)\n tr = Comparer.Default.Compare(x.Value, y.Value);\n\n return tr;\n }\n }\n }\n\n\n public P()\n {\n }\n\n public P(T1 key, T2 val)\n {\n this.Key = key;\n this.Value = val;\n }\n\n\n public T1 Key\n {\n get;\n set;\n }\n\n public T2 Value\n {\n get;\n set;\n }\n\n public P Clone()\n {\n return new P(Key, Value);\n }\n\n public static IComparer> KeyComparer\n {\n get { return new PComparer(true); }\n }\n\n public static IComparer> ValueComparer\n {\n get { return new PComparer(false); }\n }\n\n public static implicit operator T1(P obj)\n {\n return obj.Key;\n }\n\n public static implicit operator T2(P obj)\n {\n return obj.Value;\n }\n\n public P SetKey(T1 key)\n {\n Key = key;\n return this;\n }\n\n public P SetValue(T2 value)\n {\n Value = value;\n return this;\n }\n\n public override string ToString()\n {\n return string.Format(\"Key: {0}, Value: {1}\", Key, Value);\n }\n\n public override int GetHashCode()\n {\n int hash = 17;\n hash = hash * 31 + ((Equals(Key, default(T1))) ? 0 : Key.GetHashCode());\n hash = hash * 31 + ((Equals(Value, default(T1))) ? 0 : Key.GetHashCode());\n return hash;\n\n }\n }\n\n #endregion\n\n\n internal class Program\n {\n #region Program\n\n private readonly MyIo io;\n\n public Program(MyIo io)\n {\n this.io = io;\n }\n\n public static void Main(string[] args)\n {\n using (MyIo io = new MyIo())\n {\n new Program(io)\n .Solve();\n }\n }\n\n\n\n #endregion\n public const long MOD = 1000000007;\n public const double EPS = 1e-14;\n\n private void Solve()\n {\n var n = io.NextInt();\n var m = io.NextInt();\n var k = io.NextInt();\n\n var a = new int[n * m];\n var b = new int[n * m];\n var c = new int[n * m];\n\n for (int i = 0; i < n; i++)\n {\n var nm = io.NextLine();\n\n for (int j = 0; j < m; j++)\n {\n a[j + m * i] = io.NextInt();\n b[j + m * i] = io.NextInt();\n c[j + m * i] = io.NextInt();\n }\n }\n\n var res = 0;\n\n for (int i = 0; i < n; i++)\n {\n for (int j = 0; j < n; j++)\n {\n if (i != j)\n {\n var xk = k;\n\n var pres = 0;\n\n var sort = Enumerable.Range(0, m).OrderByDescending(x => b[j * m + x] - a[i * m + x]).ToArray();\n\n foreach (var x in sort)\n {\n var d = (b[j * m + x] - a[i * m + x]);\n if (d <= 0)\n continue;\n\n var tc = Math.Min(c[i * m + x], xk);\n\n pres += d * tc;\n\n xk -= tc;\n }\n\n\n res = Math.Max(res, pres);\n }\n }\n }\n io.PrintLine(res);\n }\n }\n\n}\n\n", "lang_cluster": "C#", "tags": ["greedy", "games", "graph matchings"], "code_uid": "038b60b4d9c651ebd3ad56e7b4f507cf", "src_uid": "7419c4268a9815282fadca6581f28ec1", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "//#define LOCAL\nusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.IO;\nnamespace _258_E\n{\n class Program\n {\n class Files\n {\n StreamReader fin = new StreamReader(\"d:\\\\date.in\");\n StreamWriter fout = new StreamWriter(\"d:\\\\date.out\");\n public string ReadLine()\n {\n return fin.ReadLine();\n }\n public void Write(string s)\n {\n fout.Write(s);\n }\n public void WriteLine(string s)\n {\n fout.WriteLine(s);\n }\n public void Close()\n {\n fout.Close();\n }\n }\n #if LOCAL\n static Files Console = new Files();\n #endif\n const Int64 Mod = (Int64)1e9+7;\n static string[] s;\n static string Line;\n static int step = 0, Length = 0;\n static Int64 GetNext()\n {\n if (step == Length)\n {\n Line = Console.ReadLine();\n s = Line.Split(' ');\n Length = s.Length;\n step = 0;\n }\n ++step;\n return Int64.Parse(s[step - 1]);\n }\n static Int64[] a = new Int64[30];\n static Int64 Inv = 1;\n static Int64 Comb(Int64 n, Int64 k)\n {\n if (n < k)\n return 0;\n Int64 result = 1;\n for (Int64 i = n - k + 1; i <= n; ++i)\n result = (Int64)result*(i%Mod)%Mod;\n result = (Int64)result*Inv%Mod;\n return result; \n }\n static Int64 Fix(Int64 x)\n {\n Int64 ret = x;\n while(ret >= Mod)\n ret -= Mod;\n while(ret < 0) \n ret += Mod;\n return ret;\n }\n\n static Int64 Pow_Log(Int64 x,Int64 p)\n {\n if (p == 0)\n return 1;\n Int64 y;\n if(p%2==1)\n y = (Int64)Pow_Log(x,p-1)*x%Mod;\n else\n {\n y = Pow_Log(x,p/2);\n y = (Int64)y*y%Mod;\n }\n return y;\n }\n static void Main(string[] args)\n {\n Int64 n = GetNext(), S = GetNext(), sum = 0, Max = 1;\n Inv = 1;\n for (int i = 0; i < n; ++i)\n {\n Max *= 2;\n if (i > 0)\n Inv *= i;\n a[i] = GetNext();\n sum += a[i];\n }\n if (sum < S)\n {\n Console.WriteLine(\"0\");\n return;\n }\n\n //Console.WriteLine(Inv.ToString());\n Inv = Pow_Log(Inv%Mod, Mod - 2);\n\n //Console.WriteLine(Inv.ToString());\n Int64 Solution = Comb(S + n - 1, n - 1),cnt = 0;\n for (int i = 1; i < Max; ++i)\n {\n Int64 k = 0;\n int nr = 0;\n for (int j = 0; j < n; ++j)\n if (((1 << j) & i) != 0) \n {\n ++nr;\n k += a[j]+1;\n }\n k = S - k;\n if (nr % 2 == 1)\n cnt += Comb(k + n - 1, n - 1);\n else\n cnt -= Comb(k + n - 1, n - 1);\n cnt = Fix(cnt);\n }\n Solution -= cnt;\n Solution = Fix(Solution);\n Console.WriteLine(Solution.ToString()); \n #if LOCAL\n Console.Close(); \n #endif\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["combinatorics", "number theory", "bitmasks"], "code_uid": "a6c0c34fcbe1ca7d89cd872565649446", "src_uid": "8b883011eba9d15d284e54c7a85fcf74", "difficulty": 2300.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\n\nnamespace Problem51Nod\n{\n class Program\n {\n public static void Main(String[] args)\n {\n string[] input = Console.ReadLine().Split(' ');\n int n = Convert.ToInt32(input[0]);\n long sum = Convert.ToInt64(input[1]);\n input = Console.ReadLine().Split(' ');\n long[] nums = new long[n];\n for (int i = 0; i < n; i++)\n nums[i] = Convert.ToInt64(input[i]);\n\n Console.WriteLine(Cal(sum, nums));\n }\n \n static long Mod = 1000000007;\n static long[] Nums, InvFacts;\n\n static void Init(long[] nums)\n {\n long[] invs = new long[30];\n InvFacts = new long[30];\n invs[1] = InvFacts[1] = 1;\n\n for (int i = 2; i < invs.Length; i++)\n {\n invs[i] = (Mod - Mod / i * invs[Mod % i] % Mod) % Mod;\n InvFacts[i] = InvFacts[i - 1] * invs[i] % Mod;\n }\n\n Nums = new long[nums.Length];\n\n for (int i = 0; i < nums.Length; i++)\n Nums[i] = nums[i] + 1;\n\n Array.Sort(Nums, (a, b) => b.CompareTo(a));\n }\n\n static long Cal(long sum, long[] nums)\n {\n if (nums.Length == 1) return nums[0] < sum ? 0 : 1;\n Init(nums);\n return (Cal(Nums.Length - 1, sum) + Mod) % Mod;\n }\n\n static long Cal(int index, long sum)\n {\n int k = Nums.Length - 1;\n long result = Cmn(sum + k, k);\n\n for(int i = index; i >= 0 && Nums[i] <= sum; i--)\n result -= Cal(i - 1, sum - Nums[i]);\n\n return result % Mod;\n }\n\n static long Cmn(long m, long n)\n {\n long result = 1;\n\n for(long i = m - n + 1; i <= m; i++)\n result = i % Mod * result % Mod;\n\n result = result * InvFacts[n] % Mod;\n return result;\n }\n }\n}", "lang_cluster": "C#", "tags": ["combinatorics", "number theory", "bitmasks"], "code_uid": "3b12b9bb4ce1df2a72a2525f5234059a", "src_uid": "8b883011eba9d15d284e54c7a85fcf74", "difficulty": 2300.0, "exec_outcome": "PASSED"} {"lang": "C# 8", "source_code": "using System;\r\nusing System.Linq;\r\nusing CompLib.Util;\r\nusing System.Threading;\r\nusing System.IO;\r\nusing CompLib.Mathematics;\r\n\r\npublic class Program\r\n{\r\n\r\n BinomialCoefficient C;\r\n public void Solve()\r\n {\r\n C = new BinomialCoefficient(500000);\r\n\r\n var sc = new Scanner();\r\n#if !DEBUG\r\n Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });\r\n#endif\r\n int t = sc.NextInt();\r\n for (int i = 0; i < t; i++)\r\n {\r\n Q(sc);\r\n }\r\n Console.Out.Flush();\r\n }\r\n\r\n void Q(Scanner sc)\r\n {\r\n int n = sc.NextInt();\r\n int k = sc.NextInt();\r\n\r\n var dp = new ModInt[k + 1, 2];\r\n dp[0, 0] = 1;\r\n ModInt t1 = 0;\r\n for (int i = 0; i < n; i += 2)\r\n {\r\n t1 += C[n, i];\r\n }\r\n for (int i = 0; i < k; i++)\r\n {\r\n // \r\n {\r\n // j=0\r\n // \u5168\u90e81\r\n // and\u5074 1\r\n // xor\u5074 n%2\r\n if (n % 2 == 0)\r\n {\r\n dp[i + 1, 1] += dp[i, 0];\r\n }\r\n else\r\n {\r\n dp[i + 1, 0] += dp[i, 0];\r\n }\r\n\r\n // 1\u3058\u3083\u306a\u3044\u3084\u3064\u3042\u308b\r\n // and\u50740\r\n // xor\u5074 1\u306e\u500b\u6570\u5076\u6570\r\n // \r\n dp[i + 1, 0] += dp[i, 0] * t1;\r\n }\r\n {\r\n // j =1\r\n dp[i + 1, 1] += dp[i, 1] * ModInt.Pow(2, n);\r\n }\r\n }\r\n\r\n Console.WriteLine(dp[k, 0] + dp[k, 1]);\r\n }\r\n\r\n public static void Main(string[] args) => new Program().Solve();\r\n // public static void Main(string[] args) => new Thread(new Program().Solve, 1 << 27).Start();\r\n}\r\n\r\nnamespace CompLib.Mathematics\r\n{\r\n #region ModInt\r\n /// \r\n /// [0,) \u307e\u3067\u306e\u5024\u3092\u53d6\u308b\u3088\u3046\u306a\u6570\r\n /// \r\n public struct ModInt\r\n {\r\n /// \r\n /// \u5270\u4f59\u3092\u53d6\u308b\u5024\uff0e\r\n /// \r\n public const long Mod = (int)1e9 + 7;\r\n // public const long Mod = 998244353;\r\n\r\n /// \r\n /// \u5b9f\u969b\u306e\u6570\u5024\uff0e\r\n /// \r\n public long num;\r\n /// \r\n /// \u5024\u304c \u3067\u3042\u308b\u3088\u3046\u306a\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u3092\u69cb\u7bc9\u3057\u307e\u3059\uff0e\r\n /// \r\n /// \u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u304c\u6301\u3064\u5024\r\n /// \u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u306e\u554f\u984c\u4e0a\uff0c\u30b3\u30f3\u30b9\u30c8\u30e9\u30af\u30bf\u5185\u3067\u306f\u5270\u4f59\u3092\u53d6\u308a\u307e\u305b\u3093\uff0e\u305d\u306e\u305f\u3081\uff0c \u2208 [0,) \u3092\u6e80\u305f\u3059\u3088\u3046\u306a \u3092\u6e21\u3057\u3066\u304f\u3060\u3055\u3044\uff0e\u3053\u306e\u30b3\u30f3\u30b9\u30c8\u30e9\u30af\u30bf\u306f O(1) \u3067\u5b9f\u884c\u3055\u308c\u307e\u3059\uff0e\r\n public ModInt(long n) { num = n; }\r\n /// \r\n /// \u3053\u306e\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u306e\u6570\u5024\u3092\u6587\u5b57\u5217\u306b\u5909\u63db\u3057\u307e\u3059\uff0e\r\n /// \r\n /// [0,) \u306e\u7bc4\u56f2\u5185\u306e\u6574\u6570\u3092 10 \u9032\u8868\u8a18\u3057\u305f\u3082\u306e\uff0e\r\n public override string ToString() { return num.ToString(); }\r\n public static ModInt operator +(ModInt l, ModInt r) { l.num += r.num; if (l.num >= Mod) l.num -= Mod; return l; }\r\n public static ModInt operator -(ModInt l, ModInt r) { l.num -= r.num; if (l.num < 0) l.num += Mod; return l; }\r\n public static ModInt operator *(ModInt l, ModInt r) { return new ModInt(l.num * r.num % Mod); }\r\n public static implicit operator ModInt(long n) { n %= Mod; if (n < 0) n += Mod; return new ModInt(n); }\r\n\r\n /// \r\n /// \u4e0e\u3048\u3089\u308c\u305f 2 \u3064\u306e\u6570\u5024\u304b\u3089\u3079\u304d\u5270\u4f59\u3092\u8a08\u7b97\u3057\u307e\u3059\uff0e\r\n /// \r\n /// \u3079\u304d\u4e57\u306e\u5e95\r\n /// \u3079\u304d\u6307\u6570\r\n /// \u7e70\u308a\u8fd4\u3057\u4e8c\u4e57\u6cd5\u306b\u3088\u308a O(N log N) \u3067\u5b9f\u884c\u3055\u308c\u307e\u3059\uff0e\r\n public static ModInt Pow(ModInt v, long k) { return Pow(v.num, k); }\r\n\r\n /// \r\n /// \u4e0e\u3048\u3089\u308c\u305f 2 \u3064\u306e\u6570\u5024\u304b\u3089\u3079\u304d\u5270\u4f59\u3092\u8a08\u7b97\u3057\u307e\u3059\uff0e\r\n /// \r\n /// \u3079\u304d\u4e57\u306e\u5e95\r\n /// \u3079\u304d\u6307\u6570\r\n /// \u7e70\u308a\u8fd4\u3057\u4e8c\u4e57\u6cd5\u306b\u3088\u308a O(N log N) \u3067\u5b9f\u884c\u3055\u308c\u307e\u3059\uff0e\r\n public static ModInt Pow(long v, long k)\r\n {\r\n long ret = 1;\r\n for (k %= Mod - 1; k > 0; k >>= 1, v = v * v % Mod)\r\n if ((k & 1) == 1) ret = ret * v % Mod;\r\n return new ModInt(ret);\r\n }\r\n /// \r\n /// \u4e0e\u3048\u3089\u308c\u305f\u6570\u306e\u9006\u5143\u3092\u8a08\u7b97\u3057\u307e\u3059\uff0e\r\n /// \r\n /// \u9006\u5143\u3092\u53d6\u308b\u5bfe\u8c61\u3068\u306a\u308b\u6570\r\n /// \u9006\u5143\u3068\u306a\u308b\u3088\u3046\u306a\u5024\r\n /// \u6cd5\u304c\u7d20\u6570\u3067\u3042\u308b\u3053\u3068\u3092\u4eee\u5b9a\u3057\u3066\uff0c\u30d5\u30a7\u30eb\u30de\u30fc\u306e\u5c0f\u5b9a\u7406\u306b\u5f93\u3063\u3066\u9006\u5143\u3092 O(log N) \u3067\u8a08\u7b97\u3057\u307e\u3059\uff0e\r\n public static ModInt Inverse(ModInt v) { return Pow(v, Mod - 2); }\r\n }\r\n #endregion\r\n #region Binomial Coefficient\r\n public class BinomialCoefficient\r\n {\r\n public ModInt[] fact, ifact;\r\n public BinomialCoefficient(int n)\r\n {\r\n fact = new ModInt[n + 1];\r\n ifact = new ModInt[n + 1];\r\n fact[0] = 1;\r\n for (int i = 1; i <= n; i++)\r\n fact[i] = fact[i - 1] * i;\r\n ifact[n] = ModInt.Inverse(fact[n]);\r\n for (int i = n - 1; i >= 0; i--)\r\n ifact[i] = ifact[i + 1] * (i + 1);\r\n ifact[0] = ifact[1];\r\n }\r\n public ModInt this[int n, int r]\r\n {\r\n get\r\n {\r\n if (n < 0 || n >= fact.Length || r < 0 || r > n) return 0;\r\n return fact[n] * ifact[n - r] * ifact[r];\r\n }\r\n }\r\n public ModInt RepeatedCombination(int n, int k)\r\n {\r\n if (k == 0) return 1;\r\n return this[n + k - 1, k];\r\n }\r\n }\r\n #endregion\r\n}\r\n\r\nnamespace CompLib.Util\r\n{\r\n using System;\r\n using System.Linq;\r\n\r\n class Scanner\r\n {\r\n private string[] _line;\r\n private int _index;\r\n private const char Separator = ' ';\r\n\r\n public Scanner()\r\n {\r\n _line = new string[0];\r\n _index = 0;\r\n }\r\n\r\n public string Next()\r\n {\r\n if (_index >= _line.Length)\r\n {\r\n string s;\r\n do\r\n {\r\n s = Console.ReadLine();\r\n } while (s.Length == 0);\r\n\r\n _line = s.Split(Separator);\r\n _index = 0;\r\n }\r\n\r\n return _line[_index++];\r\n }\r\n\r\n public string ReadLine()\r\n {\r\n _index = _line.Length;\r\n return Console.ReadLine();\r\n }\r\n\r\n public int NextInt() => int.Parse(Next());\r\n public long NextLong() => long.Parse(Next());\r\n public double NextDouble() => double.Parse(Next());\r\n public decimal NextDecimal() => decimal.Parse(Next());\r\n public char NextChar() => Next()[0];\r\n public char[] NextCharArray() => Next().ToCharArray();\r\n\r\n public string[] Array()\r\n {\r\n string s = Console.ReadLine();\r\n _line = s.Length == 0 ? new string[0] : s.Split(Separator);\r\n _index = _line.Length;\r\n return _line;\r\n }\r\n\r\n public int[] IntArray() => Array().Select(int.Parse).ToArray();\r\n public long[] LongArray() => Array().Select(long.Parse).ToArray();\r\n public double[] DoubleArray() => Array().Select(double.Parse).ToArray();\r\n public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();\r\n }\r\n}", "lang_cluster": "C#", "tags": ["math", "dp", "combinatorics", "bitmasks", "matrices"], "code_uid": "ecba8d2e081670a519944e5a148a21da", "src_uid": "02f5fe43ea60939dd4a53299b5fa0881", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "C# 8", "source_code": "using System;\r\nusing System.Collections.Generic;\r\nusing System.IO;\r\nusing System.Linq;\r\nusing static System.Math;\r\nusing System.Text;\r\nusing System.Threading;\r\nusing System.Globalization;\r\nusing System.Runtime.CompilerServices;\r\nusing System.Runtime.InteropServices;\r\nusing Library;\r\n\r\nnamespace Program\r\n{\r\n public static class ProblemC\r\n {\r\n static bool SAIKI = false;\r\n static public int numberOfRandomCases = 0;\r\n static public void MakeTestCase(List _input, List _output, ref Func _outputChecker)\r\n {\r\n }\r\n static public void Solve()\r\n {\r\n var t = NN;\r\n for (var i = 0; i < t; ++i)\r\n {\r\n var n = NN;\r\n var k = NN;\r\n if (n % 2 == 1)\r\n {\r\n LIB_Mod1000000007 ans = 0;\r\n LIB_Mod1000000007 evenpat = 0;\r\n for (var j = 0; j < n; j += 2)\r\n {\r\n evenpat += LIB_Mod1000000007.Comb(n, j);\r\n }\r\n for (var j = 0; j <= k; ++j)\r\n {\r\n ans += LIB_Mod1000000007.Comb(k, j) * LIB_Mod1000000007.Pow(evenpat, k - j);\r\n }\r\n Console.WriteLine(ans);\r\n }\r\n else\r\n {\r\n LIB_Mod1000000007 ans = 0;\r\n LIB_Mod1000000007 evenpat = 0;\r\n LIB_Mod1000000007 allpat = LIB_Mod1000000007.Pow(2, n);\r\n for (var j = 0; j < n; j += 2)\r\n {\r\n evenpat += LIB_Mod1000000007.Comb(n, j);\r\n }\r\n for (var j = 0; j <= k; ++j)\r\n {\r\n ans += LIB_Mod1000000007.Pow(evenpat, j) * LIB_Mod1000000007.Pow(allpat, Max(0,k - j - 1));\r\n }\r\n Console.WriteLine(ans);\r\n }\r\n }\r\n }\r\n class Printer : StreamWriter\r\n {\r\n public override IFormatProvider FormatProvider { get { return CultureInfo.InvariantCulture; } }\r\n public Printer(Stream stream) : base(stream, new UTF8Encoding(false, true)) { base.AutoFlush = false; }\r\n public Printer(Stream stream, Encoding encoding) : base(stream, encoding) { base.AutoFlush = false; }\r\n }\r\n static LIB_FastIO fastio = new LIB_FastIODebug();\r\n static public void Main(string[] args) { if (args.Length == 0) { fastio = new LIB_FastIO(); Console.SetOut(new Printer(Console.OpenStandardOutput())); } if (SAIKI) { var t = new Thread(Solve, 134217728); t.Start(); t.Join(); } else Solve(); Console.Out.Flush(); }\r\n static long NN => fastio.Long();\r\n static double ND => fastio.Double();\r\n static string NS => fastio.Scan();\r\n static long[] NNList(long N) => Repeat(0, N).Select(_ => NN).ToArray();\r\n static double[] NDList(long N) => Repeat(0, N).Select(_ => ND).ToArray();\r\n static string[] NSList(long N) => Repeat(0, N).Select(_ => NS).ToArray();\r\n static long Count(this IEnumerable x, Func pred) => Enumerable.Count(x, pred);\r\n static IEnumerable Repeat(T v, long n) => Enumerable.Repeat(v, (int)n);\r\n static IEnumerable Range(long s, long c) => Enumerable.Range((int)s, (int)c);\r\n static IOrderedEnumerable OrderByRand(this IEnumerable x) => Enumerable.OrderBy(x, _ => xorshift);\r\n static IOrderedEnumerable OrderBy(this IEnumerable x) => Enumerable.OrderBy(x.OrderByRand(), e => e);\r\n static IOrderedEnumerable OrderBy(this IEnumerable x, Func selector) => Enumerable.OrderBy(x.OrderByRand(), selector);\r\n static IOrderedEnumerable OrderByDescending(this IEnumerable x) => Enumerable.OrderByDescending(x.OrderByRand(), e => e);\r\n static IOrderedEnumerable OrderByDescending(this IEnumerable x, Func selector) => Enumerable.OrderByDescending(x.OrderByRand(), selector);\r\n static IOrderedEnumerable OrderBy(this IEnumerable x) => x.OrderByRand().OrderBy(e => e, StringComparer.OrdinalIgnoreCase);\r\n static IOrderedEnumerable OrderBy(this IEnumerable x, Func selector) => x.OrderByRand().OrderBy(selector, StringComparer.OrdinalIgnoreCase);\r\n static IOrderedEnumerable OrderByDescending(this IEnumerable x) => x.OrderByRand().OrderByDescending(e => e, StringComparer.OrdinalIgnoreCase);\r\n static IOrderedEnumerable OrderByDescending(this IEnumerable x, Func selector) => x.OrderByRand().OrderByDescending(selector, StringComparer.OrdinalIgnoreCase);\r\n static string Join(this IEnumerable x, string separator = \"\") => string.Join(separator, x);\r\n static uint xorshift { get { _xsi.MoveNext(); return _xsi.Current; } }\r\n static IEnumerator _xsi = _xsc();\r\n static IEnumerator _xsc() { uint x = 123456789, y = 362436069, z = 521288629, w = (uint)(DateTime.Now.Ticks & 0xffffffff); while (true) { var t = x ^ (x << 11); x = y; y = z; z = w; w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)); yield return w; } }\r\n static bool Chmax(this ref T lhs, T rhs) where T : struct, IComparable { if (lhs.CompareTo(rhs) < 0) { lhs = rhs; return true; } return false; }\r\n static bool Chmin(this ref T lhs, T rhs) where T : struct, IComparable { if (lhs.CompareTo(rhs) > 0) { lhs = rhs; return true; } return false; }\r\n static void Fill(this T[] array, T value) => array.AsSpan().Fill(value);\r\n static void Fill(this T[,] array, T value) => MemoryMarshal.CreateSpan(ref array[0, 0], array.Length).Fill(value);\r\n static void Fill(this T[,,] array, T value) => MemoryMarshal.CreateSpan(ref array[0, 0, 0], array.Length).Fill(value);\r\n static void Fill(this T[,,,] array, T value) => MemoryMarshal.CreateSpan(ref array[0, 0, 0, 0], array.Length).Fill(value);\r\n }\r\n}\r\nnamespace Library {\r\n partial struct LIB_Mod1000000007 : IEquatable, IEquatable\r\n {\r\n const int _mod = 1000000007; long v;\r\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\r\n public LIB_Mod1000000007(long x)\r\n {\r\n if (x < _mod && x >= 0) v = x;\r\n else if ((v = x % _mod) < 0) v += _mod;\r\n }\r\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\r\n static public implicit operator LIB_Mod1000000007(long x) => new LIB_Mod1000000007(x);\r\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\r\n static public implicit operator long(LIB_Mod1000000007 x) => x.v;\r\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\r\n public void Add(LIB_Mod1000000007 x) { if ((v += x.v) >= _mod) v -= _mod; }\r\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\r\n public void Sub(LIB_Mod1000000007 x) { if ((v -= x.v) < 0) v += _mod; }\r\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\r\n public void Mul(LIB_Mod1000000007 x) => v = (v * x.v) % _mod;\r\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\r\n public void Div(LIB_Mod1000000007 x) => v = (v * Inverse(x.v)) % _mod;\r\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\r\n static public LIB_Mod1000000007 operator +(LIB_Mod1000000007 x, LIB_Mod1000000007 y) { var t = x.v + y.v; return t >= _mod ? new LIB_Mod1000000007 { v = t - _mod } : new LIB_Mod1000000007 { v = t }; }\r\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\r\n static public LIB_Mod1000000007 operator -(LIB_Mod1000000007 x, LIB_Mod1000000007 y) { var t = x.v - y.v; return t < 0 ? new LIB_Mod1000000007 { v = t + _mod } : new LIB_Mod1000000007 { v = t }; }\r\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\r\n static public LIB_Mod1000000007 operator *(LIB_Mod1000000007 x, LIB_Mod1000000007 y) => x.v * y.v;\r\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\r\n static public LIB_Mod1000000007 operator /(LIB_Mod1000000007 x, LIB_Mod1000000007 y) => x.v * Inverse(y.v);\r\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\r\n static public bool operator ==(LIB_Mod1000000007 x, LIB_Mod1000000007 y) => x.v == y.v;\r\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\r\n static public bool operator !=(LIB_Mod1000000007 x, LIB_Mod1000000007 y) => x.v != y.v;\r\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\r\n static public long Inverse(long x)\r\n {\r\n long b = _mod, r = 1, u = 0, t = 0;\r\n while (b > 0)\r\n {\r\n var q = x / b;\r\n t = u;\r\n u = r - q * u;\r\n r = t;\r\n t = b;\r\n b = x - q * b;\r\n x = t;\r\n }\r\n return r < 0 ? r + _mod : r;\r\n }\r\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\r\n public bool Equals(LIB_Mod1000000007 x) => v == x.v;\r\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\r\n public bool Equals(long x) => v == x;\r\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\r\n public override bool Equals(object x) => x == null ? false : Equals((LIB_Mod1000000007)x);\r\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\r\n public override int GetHashCode() => v.GetHashCode();\r\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\r\n public override string ToString() => v.ToString();\r\n static List _fact = new List() { 1, 1 };\r\n static List _inv = new List() { 0, 1 };\r\n static List _factinv = new List() { 1, 1 };\r\n static long _factm = _mod;\r\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\r\n static void B(long n)\r\n {\r\n if (_factm != _mod)\r\n {\r\n _fact = new List() { 1, 1 };\r\n _inv = new List() { 0, 1 };\r\n _factinv = new List() { 1, 1 };\r\n }\r\n if (n >= _fact.Count)\r\n {\r\n for (int i = _fact.Count; i <= n; ++i)\r\n {\r\n _fact.Add(_fact[i - 1] * i);\r\n _inv.Add(_mod - _inv[(int)(_mod % i)] * (_mod / i));\r\n _factinv.Add(_factinv[i - 1] * _inv[i]);\r\n }\r\n }\r\n _factm = _mod;\r\n }\r\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\r\n static public LIB_Mod1000000007 Comb(long n, long k)\r\n {\r\n B(n);\r\n if (n == 0 && k == 0) return 1;\r\n if (n < k || n < 0) return 0;\r\n return _fact[(int)n] * _factinv[(int)(n - k)] * _factinv[(int)k];\r\n }\r\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\r\n static public LIB_Mod1000000007 CombOK(long n, long k)\r\n {\r\n LIB_Mod1000000007 ret = 1;\r\n for (var i = 0; i < k; i++) ret *= n - i;\r\n for (var i = 1; i <= k; i++) ret /= i;\r\n return ret;\r\n }\r\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\r\n static public LIB_Mod1000000007 Perm(long n, long k)\r\n {\r\n B(n);\r\n if (n == 0 && k == 0) return 1;\r\n if (n < k || n < 0) return 0;\r\n return _fact[(int)n] * _factinv[(int)(n - k)];\r\n }\r\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\r\n static public LIB_Mod1000000007 KanzenPerm(long n, long k) => Enumerable.Range(0, (int)k + 1).Aggregate((LIB_Mod1000000007)0, (a, e) => a + (1 - ((e & 1) << 1)) * LIB_Mod1000000007.Comb(k, e) * LIB_Mod1000000007.Perm(n - e, k - e));\r\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\r\n static public LIB_Mod1000000007 Pow(LIB_Mod1000000007 x, long y)\r\n {\r\n LIB_Mod1000000007 a = 1;\r\n while (y != 0)\r\n {\r\n if ((y & 1) == 1) a.Mul(x);\r\n x.Mul(x);\r\n y >>= 1;\r\n }\r\n return a;\r\n }\r\n }\r\n class LIB_FastIO\r\n {\r\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\r\n public LIB_FastIO() { str = Console.OpenStandardInput(); }\r\n readonly Stream str;\r\n readonly byte[] buf = new byte[2048];\r\n int len, ptr;\r\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\r\n byte read()\r\n {\r\n if (ptr >= len)\r\n {\r\n ptr = 0;\r\n if ((len = str.Read(buf, 0, 2048)) <= 0)\r\n {\r\n return 0;\r\n }\r\n }\r\n return buf[ptr++];\r\n }\r\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\r\n char Char()\r\n {\r\n byte b = 0;\r\n do b = read();\r\n while (b < 33 || 126 < b);\r\n return (char)b;\r\n }\r\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\r\n virtual public string Scan()\r\n {\r\n var sb = new StringBuilder();\r\n for (var b = Char(); b >= 33 && b <= 126; b = (char)read())\r\n sb.Append(b);\r\n return sb.ToString();\r\n }\r\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\r\n virtual public long Long()\r\n {\r\n long ret = 0; byte b = 0; var ng = false;\r\n do b = read();\r\n while (b != '-' && (b < '0' || '9' < b));\r\n if (b == '-') { ng = true; b = read(); }\r\n for (; true; b = read())\r\n {\r\n if (b < '0' || '9' < b)\r\n return ng ? -ret : ret;\r\n else ret = (ret << 3) + (ret << 1) + b - '0';\r\n }\r\n }\r\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\r\n virtual public double Double() { return double.Parse(Scan(), CultureInfo.InvariantCulture); }\r\n }\r\n class LIB_FastIODebug : LIB_FastIO\r\n {\r\n Queue param = new Queue();\r\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\r\n string NextString() { if (param.Count == 0) foreach (var item in Console.ReadLine().Split(' ')) param.Enqueue(item); return param.Dequeue(); }\r\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\r\n public LIB_FastIODebug() { }\r\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\r\n public override string Scan() => NextString();\r\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\r\n public override long Long() => long.Parse(NextString());\r\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\r\n public override double Double() => double.Parse(NextString());\r\n }\r\n}\r\n", "lang_cluster": "C#", "tags": ["math", "dp", "combinatorics", "bitmasks", "matrices"], "code_uid": "15e8e4fb88b9f33f8d1e3fff095aa37c", "src_uid": "02f5fe43ea60939dd4a53299b5fa0881", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.IO;\nusing System.Collections;\nusing System.Diagnostics;\nusing System.Globalization;\nusing System.Threading;\n\nnamespace CodeForces {\n struct Node {\n public int X, Y, D; \n public Node(int x,int y, int d) {\n X = x;\n Y = y;\n D = d;\n } \n }\n\n class Pair : IComparable {\n public int First, Second;\n public Pair(int f, int s) {\n First = f;\n Second = s;\n }\n\n public int CompareTo(Pair other) {\n return other.Second.CompareTo(Second);\n }\n }\n\n class Desc : IComparer {\n public int Compare(int x, int y) {\n return y.CompareTo(x);\n }\n }\n \n class Cf { \n static TextReader input;\n static void Main(string[] args) { \n#if TESTS \n Stopwatch sw = new Stopwatch();\n sw.Start();\n input = new StreamReader(\"input.txt\"); \n#else\n input = Console.In;\n#endif\n Solve();\n#if TESTS\n Console.WriteLine();\n Console.WriteLine(\"Milliseconds: {0}\", sw.ElapsedMilliseconds);\n Console.ReadLine();\n#endif\n }\n\n const int MOD = 1000000007;\n static int n, m;\n static void Solve() {\n n = nextInt();\n if (n == 1) {\n Console.WriteLine(1);\n return;\n }\n if (n == 2) {\n Console.WriteLine(3);\n return;\n }\n if (n == 3) {\n Console.WriteLine(5);\n return;\n }\n if ((n & 1) == 1) \n --n;\n int cnt = n;\n int[] c = new int[100];\n c[0] = 4;\n for (int i = 1; i < 100; i++) {\n c[i] = 4 * (i + 1) + c[i - 1];\n }\n int pos = Array.BinarySearch(c, n);\n if (pos >= 0) {\n Console.WriteLine(2 * (pos + 1) + 1);\n return;\n }\n for (int i = 1; i < 100; i++) {\n if (n > c[i - 1] && n < c[i]) {\n Console.WriteLine(2 * (i + 1) + 1);\n return;\n }\n }\n }\n\n #region math\n static long gcd(long a, long b) {\n return b != 0 ? gcd(b, a % b) : a;\n }\n\n static long lcm(long a, long b) {\n return a / gcd(a, b) * b;\n }\n \n //static int SquaredDistanceBetweenSegments(int x1, int y1, int x2, int y2, int xx1, int yy1, int xx2, int yy2) {\n // return Math.Min(Math.Min(SquaredDistanceToSegment(x1, y1, xx1, yy1, xx2, yy2), SquaredDistanceToSegment(x2, y2, xx1, yy1, xx2, yy2)),\n // Math.Min(SquaredDistanceToSegment(xx1, yy1, x1, y1, x2, y2), SquaredDistanceToSegment(xx2, yy2, x1, y1, x2, y2)));\n //}\n\n //static int SquaredDistanceToSegment(int x, int y, int x1, int y1, int x2, int y2) {\n // int result = Math.Min(SquaredDistance(x, y, x1, y1), SquaredDistance(x, y, x2, y2));\n // if (x1 == x2 && y1 <= y && y <= y2)\n // result = (x - x1) * (x - x1);\n // else if (y1 == y2 && x1 <= x && x <= x2)\n // result = (y - y1) * (y - y1);\n // return result;\n //}\n\n static long SquaredDistance(long ax, long ay, long bx, long by) {\n return (ax - bx) * (ax - bx) + (ay - by) * (ay - by);\n }\n #endregion\n\n #region read helpers\n static int nextInt() {\n int t = input.Read();\n while (t < '0' || t > '9') t = input.Read();\n int x = 0;\n while (t >= '0' && t <= '9') {\n x *= 10;\n x += t - '0';\n t = input.Read();\n }\n return x;\n }\n\n static long nextLong() {\n int t = input.Read();\n while (t < '0' || t > '9') t = input.Read();\n long x = 0;\n while (t >= '0' && t <= '9') {\n x *= 10;\n x += t - '0';\n t = input.Read();\n }\n return x;\n }\n\n public static List ReadIntList() {\n return input.ReadLine().Split(' ').Select(x => int.Parse(x)).ToList();\n }\n\n public static int[] ReadIntArray() { \n return input.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();\n }\n\n public static long[] ReadLongArray() {\n return input.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();\n }\n\n public static List ReadLongList() {\n return input.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList();\n } \n\n public static string ReadLine() {\n return input.ReadLine();\n }\n\n public static int ReadInt() {\n return int.Parse(input.ReadLine());\n }\n\n public static long ReadLong() {\n return long.Parse(input.ReadLine());\n }\n#endregion\n }\n\n\n\n\n\n\n\n\n\n \n public class SegmentTree {\n private int[] a, t;\n private int n;\n public SegmentTree(int[] a) {\n n = a.Length;\n this.a = a; \n t = new int[n << 2];\n buildSegmentTree(0, n - 1, 1);\n }\n\n private void buildSegmentTree(int l, int r, int v) {\n if (l == r)\n t[v] = a[l];\n else {\n int m = (l + r) >> 1;\n int vl = v << 1;\n int vr = (v << 1) | 1;\n buildSegmentTree(l, m, vl);\n buildSegmentTree(m + 1, r, vr);\n t[v] = t[vl] + t[vr];\n }\n }\n\n public int QuerySegmentTree(int l, int r) {\n return querySegmentTree(1, l, r, 0, n - 1);\n }\n\n public void Update(int v, int tl, int tr, int pos, int new_val) {\n if (tl == tr)\n t[v] = new_val;\n else {\n int tm = (tl + tr) / 2;\n if (pos <= tm)\n Update(v << 1, tl, tm, pos, new_val);\n else\n Update(v << 1 + 1, tm + 1, tr, pos, new_val);\n t[v] = t[v << 1] + t[v << 1 + 1];\n }\n }\n\n private int querySegmentTree(int v, int l, int r, int tl, int tr) {\n if (l > r)\n return 0;\n if (l == tl && r == tr)\n return t[v];\n int m = (tl + tr) >> 1; \n return querySegmentTree(v << 1, l, Math.Min(r, m), tl, m) + querySegmentTree((v << 1) | 1, Math.Max(l, m + 1), r, m + 1, tr);\n }\n }\n class Graph : List> {\n public Graph(int num): base(num) {\n for (int i = 0; i < num; i++) {\n this.Add(new List());\n }\n }\n }\n\n class Heap : IEnumerable where T : IComparable {\n private List heap = new List();\n private int heapSize;\n private int Parent(int index) {\n return (index - 1) >> 1;\n }\n public int Count {\n get { return heap.Count; }\n }\n private int Left(int index) {\n return (index << 1) | 1;\n }\n private int Right(int index) {\n return (index << 1) + 2;\n }\n private void Max_Heapify(int i) {\n int l = Left(i);\n int r = Right(i);\n int largest = i;\n if (l < heapSize && heap[l].CompareTo(heap[i]) > 0)\n largest = l;\n if (r < heapSize && heap[r].CompareTo(heap[largest]) > 0)\n largest = r;\n if (largest != i) {\n T temp = heap[largest];\n heap[largest] = heap[i];\n heap[i] = temp;\n Max_Heapify(largest);\n }\n }\n private void BuildMaxHeap() {\n for (int i = heap.Count >> 1; i >= 0; --i)\n Max_Heapify(i);\n }\n\n public IEnumerator GetEnumerator() {\n return heap.GetEnumerator();\n }\n\n public void Sort() {\n for (int i = heap.Count - 1; i > 0; --i) {\n T temp = heap[i];\n heap[i] = heap[0];\n heap[0] = temp;\n --heapSize;\n Max_Heapify(0);\n }\n }\n\n public T Heap_Extract_Max() {\n T max = heap[0];\n heap[0] = heap[--heapSize];\n Max_Heapify(0);\n return max;\n }\n\n public void Clear() {\n heap.Clear();\n heapSize = 0;\n }\n\n public void Insert(T item) {\n if (heapSize < heap.Count)\n heap[heapSize] = item;\n else\n heap.Add(item);\n int i = heapSize;\n while (i > 0 && heap[Parent(i)].CompareTo(heap[i]) < 0) {\n T temp = heap[i];\n heap[i] = heap[Parent(i)];\n heap[Parent(i)] = temp;\n i = Parent(i);\n }\n ++heapSize;\n }\n\n IEnumerator IEnumerable.GetEnumerator() {\n return ((IEnumerable)heap).GetEnumerator();\n }\n } \n public class Treap where T:IComparable {\n private static Random rand = new Random();\n public static Treap Merge(Treap l, Treap r) {\n if (l == null) return r;\n if (r == null) return l;\n Treap res = null;\n if (l.y > r.y) {\n Treap newR = Merge(l.right, r);\n res = new Treap(l.x, l.y, l.left, newR);\n }\n else {\n Treap newL = Merge(l, r.left);\n res = new Treap(r.x, r.y, newL, r.right);\n } \n return res;\n }\n\n public bool Contains(T key) {\n if (x.CompareTo(key) > 0)\n return left == null ? false : left.Contains(key);\n else if (x.CompareTo(key) < 0)\n return right == null ? false : right.Contains(key);\n return true;\n }\n\n public void Split(T x, out Treap l, out Treap r) {\n Treap newTree = null;\n if (this.x.CompareTo(x)<0) {\n if (right == null)\n r = null;\n else\n right.Split(x, out newTree, out r);\n l = new Treap(this.x, y, left, newTree); \n }\n else {\n if (left == null)\n l = null;\n else\n left.Split(x, out l, out newTree);\n r = new Treap(this.x, y, newTree, right); \n }\n }\n\n public Treap Add(T x) {\n Treap l, r;\n Split(x, out l, out r);\n Treap m = new Treap(x, rand.Next());\n return Merge(Merge(l, m), r);\n }\n\n private T x;\n private int y;\n private Treap left, right;\n public Treap(T x, int y, Treap l, Treap r) {\n this.x = x;\n this.y = y;\n left = l;\n right = r;\n }\n public Treap(T x, int y) : this(x, y, null, null) { }\n public Treap(T x) : this(x, rand.Next()) { }\n }\n public static class Extensions {\n public static int Max(this int a, int b) {\n return Math.Max(a, b);\n }\n\n public static int Min(this int a, int b) {\n return Math.Min(a, b);\n }\n\n public static void Fill(this int[] array, int val) {\n for (int i = 0; i < array.Length; i++) {\n array[i] = val;\n }\n }\n\n public static void Fill(this double[] array, double val) {\n for (int i = 0; i < array.Length; i++) {\n array[i] = val;\n }\n }\n\n public static int ToInt(this string s) {\n return int.Parse(s);\n }\n\n public static string Fill(this char c, int count) {\n char[] r = new char[count];\n for (int i = 0; i < count; ++i)\n r[i] = c;\n return new string(r);\n }\n \n public static void Print(this IEnumerable arr) {\n foreach (T t in arr)\n Console.Write(\"{0} \", t);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "binary search"], "code_uid": "07554324954d901bdcf9c227fccb18e1", "src_uid": "01eccb722b09a0474903b7e5abc4c47a", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\n\nnamespace CodeForces\n{\n class Program\n {\n static bool can(int a, int b)\n {\n if(b==3)\n {\n return (a==1||a==2||a==4||a==5);\n }\n if (b % 2 == 0)\n {\n int mod = a % 4;\n if (mod > 0) return false;\n int div = a / 4;\n int can = (((b - 1) / 2) * ((b - 1) / 2) + 1) / 2;\n return div <= can;\n }\n else\n {\n if (a % 2 == 1)\n {\n a--;\n }\n int can4 = (((b - 1) / 2) * ((b - 1) / 2) + 1) / 2;\n int can2 = b / 2 / 2 * 2;\n if (a % 4 == 2)\n {\n if (can2 > 0)\n {\n can2--;\n a -= 2;\n }\n else return false;\n }\n can4 += can2 / 2;\n return a <= can4*4;\n }\n }\n static void Main(string[] args)\n {\n int x;\n x = int.Parse(Console.ReadLine());\n for (int i = 1; i <= 100; i++)\n {\n if (can(x, i))\n {\n Console.WriteLine(i.ToString());\n break;\n }\n }\n \n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "dp", "constructive algorithms"], "code_uid": "87e946ced2eaf50444a7e96e24278146", "src_uid": "01eccb722b09a0474903b7e5abc4c47a", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.IO;\nusing System.Linq;\nusing System.Text;\nusing System.Collections;\nusing System.Collections.Generic;\nusing System.Threading.Tasks;\n\n\n\nnamespace ConsoleApplication1.CodeForces\n{\n public class LowerBoundSortedSet : SortedSet\n {\n\n private ComparerDecorator _comparerDecorator;\n\n private class ComparerDecorator : IComparer\n {\n\n private IComparer _comparer;\n\n public T LowerBound { get; private set; }\n public T UpperBound { get; private set; }\n\n private bool _reset = true;\n\n public void Reset()\n {\n _reset = true;\n }\n\n public ComparerDecorator(IComparer comparer)\n {\n _comparer = comparer;\n }\n\n public int Compare(T x, T y)\n {\n int num = _comparer.Compare(x, y);\n if (_reset)\n {\n LowerBound = y;\n UpperBound = y;\n }\n if (num >= 0)\n {\n LowerBound = y;\n _reset = false;\n }\n if (num <= 0)\n {\n UpperBound = y;\n _reset = false;\n }\n return num;\n }\n }\n\n public LowerBoundSortedSet()\n : this(Comparer.Default) { }\n\n public LowerBoundSortedSet(IComparer comparer)\n : base(new ComparerDecorator(comparer))\n {\n _comparerDecorator = (ComparerDecorator)this.Comparer;\n }\n\n public T FindLowerBound(T key)\n {\n _comparerDecorator.Reset();\n this.Contains(key);\n return _comparerDecorator.LowerBound;\n }\n\n public T FindUpperBound(T key)\n {\n _comparerDecorator.Reset();\n this.Contains(key);\n return _comparerDecorator.UpperBound;\n }\n }\n public abstract class Heap : IEnumerable\n {\n private const int InitialCapacity = 0;\n private const int GrowFactor = 2;\n private const int MinGrow = 1;\n\n private int _capacity = InitialCapacity;\n private T[] _heap = new T[InitialCapacity];\n private int _tail = 0;\n\n public int Count { get { return _tail; } }\n public int Capacity { get { return _capacity; } }\n\n protected Comparer Comparer { get; private set; }\n protected abstract bool Dominates(T x, T y);\n\n protected Heap() : this(Comparer.Default)\n {\n }\n\n protected Heap(Comparer comparer) : this(Enumerable.Empty(), comparer)\n {\n }\n\n protected Heap(IEnumerable collection)\n : this(collection, Comparer.Default)\n {\n }\n\n protected Heap(IEnumerable collection, Comparer comparer)\n {\n if (collection == null) throw new ArgumentNullException(\"collection\");\n if (comparer == null) throw new ArgumentNullException(\"comparer\");\n\n Comparer = comparer;\n\n foreach (var item in collection)\n {\n if (Count == Capacity)\n Grow();\n\n _heap[_tail++] = item;\n }\n\n for (int i = Parent(_tail - 1); i >= 0; i--)\n BubbleDown(i);\n }\n\n public void Add(T item)\n {\n if (Count == Capacity)\n Grow();\n\n _heap[_tail++] = item;\n BubbleUp(_tail - 1);\n }\n\n private void BubbleUp(int i)\n {\n if (i == 0 || Dominates(_heap[Parent(i)], _heap[i]))\n return; //correct domination (or root)\n\n Swap(i, Parent(i));\n BubbleUp(Parent(i));\n }\n\n public T GetMin()\n {\n if (Count == 0) throw new InvalidOperationException(\"Heap is empty\");\n return _heap[0];\n }\n\n public T ExtractDominating()\n {\n if (Count == 0) throw new InvalidOperationException(\"Heap is empty\");\n T ret = _heap[0];\n _tail--;\n Swap(_tail, 0);\n BubbleDown(0);\n return ret;\n }\n\n private void BubbleDown(int i)\n {\n int dominatingNode = Dominating(i);\n if (dominatingNode == i) return;\n Swap(i, dominatingNode);\n BubbleDown(dominatingNode);\n }\n\n private int Dominating(int i)\n {\n int dominatingNode = i;\n dominatingNode = GetDominating(YoungChild(i), dominatingNode);\n dominatingNode = GetDominating(OldChild(i), dominatingNode);\n\n return dominatingNode;\n }\n\n private int GetDominating(int newNode, int dominatingNode)\n {\n if (newNode < _tail && !Dominates(_heap[dominatingNode], _heap[newNode]))\n return newNode;\n else\n return dominatingNode;\n }\n\n private void Swap(int i, int j)\n {\n T tmp = _heap[i];\n _heap[i] = _heap[j];\n _heap[j] = tmp;\n }\n\n private static int Parent(int i)\n {\n return (i + 1) / 2 - 1;\n }\n\n private static int YoungChild(int i)\n {\n return (i + 1) * 2 - 1;\n }\n\n private static int OldChild(int i)\n {\n return YoungChild(i) + 1;\n }\n\n private void Grow()\n {\n int newCapacity = _capacity * GrowFactor + MinGrow;\n var newHeap = new T[newCapacity];\n Array.Copy(_heap, newHeap, _capacity);\n _heap = newHeap;\n _capacity = newCapacity;\n }\n\n public IEnumerator GetEnumerator()\n {\n return _heap.Take(Count).GetEnumerator();\n }\n\n IEnumerator IEnumerable.GetEnumerator()\n {\n return GetEnumerator();\n }\n }\n\n public class MaxHeap : Heap\n {\n public MaxHeap()\n : this(Comparer.Default)\n {\n }\n\n public MaxHeap(Comparer comparer)\n : base(comparer)\n {\n }\n\n public MaxHeap(IEnumerable collection, Comparer comparer)\n : base(collection, comparer)\n {\n }\n\n public MaxHeap(IEnumerable collection) : base(collection)\n {\n }\n\n protected override bool Dominates(T x, T y)\n {\n return Comparer.Compare(x, y) >= 0;\n }\n }\n\n public class MinHeap : Heap\n {\n public MinHeap()\n : this(Comparer.Default)\n {\n }\n\n public MinHeap(Comparer comparer)\n : base(comparer)\n {\n }\n\n public MinHeap(IEnumerable collection) : base(collection)\n {\n }\n\n public MinHeap(IEnumerable collection, Comparer comparer)\n : base(collection, comparer)\n {\n }\n\n protected override bool Dominates(T x, T y)\n {\n return Comparer.Compare(x, y) <= 0;\n }\n }\n static class _4032123\n {\n private static int Next()\n {\n int c;\n int res = 0;\n do\n {\n c = reader.Read();\n if (c == -1)\n return res;\n } while (c < '0' || c > '9');\n res = c - '0';\n while (true)\n {\n c = reader.Read();\n if (c < '0' || c > '9')\n return res;\n res *= 10;\n res += c - '0';\n }\n }\n private static readonly StreamReader reader = new StreamReader(Console.OpenStandardInput(1024 * 10), Encoding.ASCII, false, 1024 * 10);\n private static readonly StreamWriter writer = new StreamWriter(Console.OpenStandardOutput(1024 * 10), Encoding.ASCII, 1024 * 10);\n\n class Node\n {\n public int Number { get; set; }\n public int Depth { get; set; }\n\n }\n static long Distance(long x1, long y1, long x2, long y2)\n {\n return (x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2);\n }\n static void Main(String[] args)\n {\n //var n = int.Parse(Console.ReadLine().TrimEnd());\n var data = Console.ReadLine().TrimEnd().Split(' ').Select(long.Parse).ToList();\n var x1 = data[0];\n var y1 = data[1];\n var x2 = data[2];\n var y2 = data[3];\n var x3 = data[4];\n var y3 = data[5];\n var d1 = Distance(x1, y1, x2, y2);\n var d2 = Distance(x2, y2, x3, y3);\n if (d1 == d2 && (y1-y2)* (x2 - x3) != (y2 - y3) * (x1 - x2))\n {\n writer.WriteLine(\"Yes\");\n } else\n {\n writer.WriteLine(\"No\");\n }\n \n writer.Flush();\n\n\n }\n }\n}", "lang_cluster": "C#", "tags": ["math", "geometry"], "code_uid": "dd97677537b152baa6bd9b280319bdaa", "src_uid": "05ec6ec3e9ffcc0e856dc0d461e6eeab", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.IO;\nusing System.Text;\n\nnamespace Arpa_and_an_exam_about_geometry\n{\n internal class Program\n {\n private static readonly StreamReader reader = new StreamReader(Console.OpenStandardInput(1024*10), Encoding.ASCII, false, 1024*10);\n private static readonly StreamWriter writer = new StreamWriter(Console.OpenStandardOutput(1024*10), Encoding.ASCII, 1024*10);\n\n private static void Main(string[] args)\n {\n writer.WriteLine(Solve(args) ? \"Yes\" : \"No\");\n writer.Flush();\n }\n\n private static bool Solve(string[] args)\n {\n long ax = Next(), ay = Next(), bx = Next(), by = Next(), cx = Next(), cy = Next();\n\n if ((ax - bx)*(ax - bx) + (ay - by)*(ay - by) == (cx - bx)*(cx - bx) + (cy - by)*(cy - by))\n {\n return (cx - ax)*(cy - by) != (cy - ay)*(cx - bx);\n }\n\n return false;\n }\n\n private static int Next()\n {\n int c;\n int m = 1;\n do\n {\n c = reader.Read();\n if (c == '-')\n m = -1;\n } while (c < '0' || c > '9');\n int res = c - '0';\n while (true)\n {\n c = reader.Read();\n if (c < '0' || c > '9')\n return m*res;\n res *= 10;\n res += c - '0';\n }\n }\n }\n}", "lang_cluster": "C#", "tags": ["math", "geometry"], "code_uid": "9383f08e5f1a855cae907b19cec5d1b9", "src_uid": "05ec6ec3e9ffcc0e856dc0d461e6eeab", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\n\nnamespace ProgrammingContest.Codeforces.Round91 {\n class C {\n static List num = new List();\n static void gen(long x, int n) {\n if (x <= n) {\n if(x != 0)\n num.Add((int)x);\n gen(x * 10 + 4, n);\n gen(x * 10 + 7, n);\n }\n }\n\n static long fact(long n) { long res = 1; while (n > 1) res *= n--; return res; }\n\n static int n;\n static List val = new List();\n static int dfs(int pos, long k) {\n if (pos > n) return 0;\n int rest = n - pos,\n res = 0;\n for (int i = 0; i < val.Count; i++) {\n if (val[i] == -1) continue;\n if (k < fact(rest)) {\n if (num.Contains(val[i]) && num.Contains(pos)) {\n res = 1;\n }\n //Console.WriteLine(\"dfs: {0} {1}\", pos, val[i]);\n val[i] = -1;\n return res + dfs(pos + 1, k);\n }\n k -= fact(rest);\n }\n throw new Exception();\n }\n\n static void Main() {\n var xs = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);\n n = xs[0];\n int k = xs[1]-1;\n\n for (int v = k, i = 1; i <= n && v != 0; i++) {\n v /= i;\n if (i == n && v != 0) {\n Console.WriteLine(-1);\n return;\n }\n }\n\n gen(0, n);\n num.Sort();\n for (long v = 1, i = 1; i <= n; i++) {\n v *= i;\n if (k < v) {\n int res = 0;\n int m = (int)(n - i);\n int id = -1;\n //Console.WriteLine(\"dfs: {0} {1}\", m, res);\n for (int j = 0; j < num.Count; j++) {\n if (num[j] > m) {\n res += j;\n id = j;\n break;\n }\n if (j == num.Count - 1) {\n Console.WriteLine(num.Count);\n return;\n }\n }\n //Console.WriteLine(\"dfs: {0} {1}\", m, res);\n for (int j = m; j < n; j++) {\n val.Add(j + 1);\n }\n Console.WriteLine(dfs(m+1, k) + res);\n return;\n }\n }\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "combinatorics", "number theory"], "code_uid": "c25db029e385de7e26baad57ba3651a6", "src_uid": "cb2aa02772f95fefd1856960b6ceac4c", "difficulty": 1900.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Text;\nusing System.IO;\nusing System.Linq;\nusing System.Collections;\n\nnamespace Task\n{\n class Program\n {\n int getCount(int curNum, int maxNum)\n {\n int res = curNum == 0 ? 0 : 1;\n if (curNum * 10L + 4 <= maxNum)\n res += getCount(curNum * 10 + 4, maxNum);\n if (curNum * 10L + 7 <= maxNum)\n res += getCount(curNum * 10 + 7, maxNum);\n return res;\n }\n\n void swap(int[] arr, int a, int b)\n {\n int temp = arr[a];\n arr[a] = arr[b];\n arr[b] = temp;\n }\n\n void permute(int[] array, int k)\n {\n while (k > 1)\n {\n int curFact = 1;\n int prevFact = 1;\n int pos = 1;\n while (curFact < k)\n {\n pos++;\n prevFact = curFact;\n curFact *= pos;\n }\n int absPos0 = array.Length - pos;\n int shift = (k - 1) / prevFact;\n int absPos1 = absPos0 + shift;\n swap(array, absPos0, absPos1);\n if (pos > 1)\n {\n Array.Sort(array, absPos0 + 1, pos - 1);\n }\n \n k -= prevFact * shift;\n }\n }\n\n bool isLucky(int x)\n {\n while (x > 0)\n {\n if (x % 10 != 4 && x % 10 != 7)\n return false;\n x /= 10;\n }\n return true;\n }\n\n void Solve()\n {\n // Place your code here\n int n = io.NextInt();\n int k = io.NextInt();\n\n long fact = 1;\n int numCount = 1;\n for (int i = 2; i <= n && fact <= k; i++)\n {\n fact *= i;\n numCount++;\n }\n\n if (fact < k)\n {\n io.Print(-1);\n return;\n }\n\n int firstCnt = n - numCount;\n\n int ans = getCount(0, firstCnt);\n int[] lastNumbers = new int[numCount];\n for (int i = 0; i < numCount; i++)\n lastNumbers[i] = n - numCount + 1 + i;\n\n permute(lastNumbers, k);\n for (int i = 0; i < lastNumbers.Length; i++)\n if (isLucky(firstCnt + i + 1) && isLucky(lastNumbers[i]))\n {\n ans++;\n }\n\n io.Print(ans);\n }\n\n MyIo io = new MyIo();\n\n static void Main(string[] args)\n {\n var p = new Program();\n\n p.Solve();\n p.io.Close();\n }\n }\n\n class MyIo\n {\n char[] separators = new char[] { ' ', '\\t' };\n\n#if TEST\n TextReader inputStream = new StreamReader(\"..\\\\..\\\\input.txt\");\n#else\n TextReader inputStream = System.Console.In;\n#endif\n TextWriter outputStream = Console.Out;\n\n string[] tokens;\n int pointer;\n\n public string NextLine()\n {\n try\n {\n return inputStream.ReadLine();\n }\n catch (IOException)\n {\n return null;\n }\n }\n\n public string NextString()\n {\n try\n {\n while (tokens == null || pointer >= tokens.Length)\n {\n tokens = NextLine().Split(separators, StringSplitOptions.RemoveEmptyEntries);\n pointer = 0;\n }\n return tokens[pointer++];\n }\n catch (IOException)\n {\n return null;\n }\n }\n\n public int NextInt()\n {\n return int.Parse(NextString());\n }\n\n public long NextLong()\n {\n return long.Parse(NextString());\n }\n\n public void Print(string format, params object[] args)\n {\n outputStream.Write(format, args);\n }\n\n public void PrintLine(string format, params object[] args)\n {\n outputStream.WriteLine(format, args);\n }\n\n public void Print(T o)\n {\n outputStream.Write(o);\n }\n\n public void PrintLine(T o)\n {\n outputStream.WriteLine(o);\n }\n\n public void Close()\n {\n inputStream.Close();\n outputStream.Close();\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "combinatorics", "number theory"], "code_uid": "463c53d55a68d4aa8dd4252237c06903", "src_uid": "cb2aa02772f95fefd1856960b6ceac4c", "difficulty": 1900.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\n\nnamespace _Permutations\n{\n class ProgramPermutations\n {\n public static int[] Digits(int num)\n {\n var d = new Stack();\n if (num == 0) d.Push(0);\n\n while (num > 0)\n {\n d.Push(num % 10);\n num /= 10;\n }\n\n return d.ToArray();\n }\n\n public static int DigitsToNum(int[] digits)\n {\n var result = 0;\n var mult = 1;\n for (var i = digits.Length - 1; i >= 0; i--)\n {\n result += digits[i] * mult;\n mult *= 10;\n }\n\n return result;\n }\n\n static IEnumerable GetPerms(List seq)\n {\n seq.Sort();\n var len = seq.Count();\n var n = len - 1;\n var lst = new List {seq.ToArray()};\n\n while (true)\n {\n var k = -1;\n for (var i = 0; i < n; i++)\n {\n if (seq[i] < seq[i + 1]) k = i;\n }\n if (k == -1) break;\n var l = -1;\n for (var i = 0; i < len; i++)\n {\n if (seq[k] < seq[i]) l = i;\n }\n var temp = seq[k];\n seq[k] = seq[l];\n seq[l] = temp;\n\n var seqNext = new int[len];\n for (var i = 0; i <= k; i++)\n {\n seqNext[i] = seq[i];\n }\n for (var i = n; i > k; i--)\n {\n seqNext[k + len - i] = seq[i];\n }\n lst.Add(seqNext);\n seq = new List(seqNext);\n //Console.WriteLine(DigitsToNum(seqNext));\n }\n\n return lst;\n }\n\n static bool GreaterThan(IList num1, IList num2, int k)\n {\n for (var i = 0; i < k; i++)\n {\n if (num1[i] < num2[i]) return false;\n if (num1[i] > num2[i]) return true;\n }\n return false;\n }\n\n static bool LessThan(IList num1, IList num2, int k)\n {\n for (var i=0; i num2[i]) return false;\n if (num1[i] < num2[i]) return true;\n }\n return false;\n }\n\n static void Main(string[] args)\n {\n if (args.Count() > 0)\n {\n var r = new Random(1021);\n\n Console.WriteLine(\"{0} {1}\", args[0], args[1]);\n for (var i=0; i>();\n for (var i = 0; i < n; i++)\n {\n var strNum = Console.ReadLine();\n if (string.IsNullOrEmpty(strNum)) return;\n var num = strNum.Select(c => c - 48).ToList();\n nums.Add(num);\n }\n\n // Numbers from 0..k-1 in order\n var seq = new List();\n for (var i=0; i();\n var minNum = new List();\n for (var i = 0; i < k; i++)\n {\n maxNum.Add(0);\n minNum.Add(9);\n }\n\n foreach (var i in nums)\n {\n var permDigits = new int[k];\n for (var j = 0; j < k; j++)\n {\n permDigits[j] = i[perm[j]];\n }\n if (GreaterThan(permDigits, maxNum, k)) maxNum = new List(permDigits);\n if (LessThan(permDigits, minNum, k)) minNum = new List(permDigits);\n //var newNum = DigitsToNum(permDigits);\n //if (newNum > maxNum) maxNum = newNum;\n //if (newNum < minNum) minNum = newNum;\n }\n var diff = DigitsToNum(maxNum.ToArray()) - DigitsToNum(minNum.ToArray());\n //Console.WriteLine(\"{0} - {1} = {2}\", DigitsToNum(maxNum.ToArray()), DigitsToNum(minNum.ToArray()), diff);\n if (diff < minDifference) minDifference = diff;\n }\n Console.WriteLine(minDifference);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "implementation", "combinatorics"], "code_uid": "c2283d93eb1990cf5fe638c6799aaf9a", "src_uid": "08f85cd4ffbd135f0b630235209273a4", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.IO;\nusing System.Text;\n\nnamespace Permutations\n{\n internal class Program\n {\n private static readonly StreamReader reader = new StreamReader(Console.OpenStandardInput(1024*10), Encoding.ASCII, false, 1024*10);\n private static readonly StreamWriter writer = new StreamWriter(Console.OpenStandardOutput(1024*10), Encoding.ASCII, 1024*10);\n\n private static void Main(string[] args)\n {\n int n = Next();\n int k = Next();\n\n var nn = new int[n][];\n for (int i = 0; i < nn.Length; i++)\n {\n nn[i] = new int[k];\n }\n for (int i = 0; i < n; i++)\n {\n for (int j = 0; j < k; j++)\n {\n nn[i][j] = Next();\n }\n }\n\n var perm = new int[k];\n for (int i = 0; i < k; i++)\n {\n perm[i] = i;\n }\n\n int min = int.MaxValue;\n\n do\n {\n int mi = int.MaxValue;\n int ma = int.MinValue;\n\n for (int i = 0; i < n; i++)\n {\n int sum = 0;\n for (int j = 0; j < k; j++)\n {\n sum = sum*10 + nn[i][perm[j]];\n }\n mi = Math.Min(mi, sum);\n ma = Math.Max(ma, sum);\n }\n\n min = Math.Min(min, ma - mi);\n } while (NextPermutation(perm));\n\n writer.WriteLine(min);\n writer.Flush();\n }\n\n private static bool NextPermutation(int[] nn)\n {\n if (nn.Length <= 1) return false;\n int i = nn.Length - 1;\n int last = nn.Length;\n\n while (true)\n {\n int i1 = i;\n if (nn[--i] < nn[i1])\n {\n int i2 = last;\n while (!(nn[i] < nn[--i2]))\n {\n ;\n }\n int c = nn[i];\n nn[i] = nn[i2];\n nn[i2] = c;\n\n Reverse(nn, i1, last);\n return true;\n }\n if (i == 0)\n {\n Reverse(nn, 0, last);\n return false;\n }\n }\n }\n\n private static void Reverse(int[] nn, int first, int last)\n {\n while ((first != last) && (first != --last))\n {\n int c = nn[first];\n nn[first] = nn[last];\n nn[last] = c;\n first++;\n }\n }\n\n private static int Next()\n {\n int c;\n do\n {\n c = reader.Read();\n } while (c < '0' || c > '9');\n return c - '0';\n }\n }\n}", "lang_cluster": "C#", "tags": ["brute force", "implementation", "combinatorics"], "code_uid": "04046a5c369c92995aeedf799aad1ebe", "src_uid": "08f85cd4ffbd135f0b630235209273a4", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.IO;\nusing System.Net;\nusing System.Net.Sockets;\nusing System.Linq;\nusing System.Diagnostics;\nusing System.Collections;\nusing System.Collections.Generic;\nusing System.Text;\nusing System.Threading.Tasks;\nusing System.Text.RegularExpressions;\nusing static System.Math;\nusing MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;\nusing MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;\n\npublic static class P\n{\n public static void Main()\n {\n var nm = Console.ReadLine().Split().Select(int.Parse).ToArray();\n var n = nm[0];\n var m = nm[1];\n\n ModInt[] fib = new ModInt[Max(n, m) + 1];\n fib[0] = 2;\n fib[1] = 2;\n for (int i = 2; i < fib.Length; i++)\n fib[i] = fib[i - 1] + fib[i - 2];\n\n Console.WriteLine(fib[n] + fib[m] - 2);\n }\n}\n\n\nstruct ModInt\n{\n const int MOD = 1000000007;\n const long POSITIVIZER = ((long)MOD) << 31;\n long Data;\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public ModInt(long data) { if ((Data = data % MOD) < 0) Data += MOD; }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static implicit operator long(ModInt modInt) => modInt.Data;\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static implicit operator ModInt(long val) => new ModInt(val);\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static ModInt operator +(ModInt a, int b) => new ModInt() { Data = (a.Data + b + POSITIVIZER) % MOD };\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static ModInt operator +(ModInt a, long b) => new ModInt(a.Data + b);\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static ModInt operator +(ModInt a, ModInt b) { long res = a.Data + b.Data; return new ModInt() { Data = res >= MOD ? res - MOD : res }; }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static ModInt operator -(ModInt a, int b) => new ModInt() { Data = (a.Data - b + POSITIVIZER) % MOD };\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static ModInt operator -(ModInt a, long b) => new ModInt(a.Data - b);\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static ModInt operator -(ModInt a, ModInt b) { long res = a.Data - b.Data; return new ModInt() { Data = res < 0 ? res + MOD : res }; }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static ModInt operator *(ModInt a, int b) => new ModInt(a.Data * b);\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static ModInt operator *(ModInt a, long b) => a * new ModInt(b);\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static ModInt operator *(ModInt a, ModInt b) => new ModInt() { Data = a.Data * b.Data % MOD };\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static ModInt operator /(ModInt a, ModInt b) => new ModInt() { Data = a.Data * GetInverse(b) % MOD };\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public override string ToString() => Data.ToString();\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n static long GetInverse(long a)\n {\n long div, p = MOD, x1 = 1, y1 = 0, x2 = 0, y2 = 1;\n while (true)\n {\n if (p == 1) return x2 + MOD; div = a / p; x1 -= x2 * div; y1 -= y2 * div; a %= p;\n if (a == 1) return x1 + MOD; div = p / a; x2 -= x1 * div; y2 -= y1 * div; p %= a;\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "dp", "combinatorics"], "code_uid": "7d9c6d1b34a46819945df3a85cd98dc3", "src_uid": "0f1ab296cbe0952faa904f2bebe0567b", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": ".NET Core C#", "source_code": "using System;\nusing System.Linq;\nusing CompLib.Util;\nusing System.Threading;\nusing CompLib.Mathematics;\n\npublic class Program\n{\n private int N, M;\n\n public void Solve()\n {\n var sc = new Scanner();\n N = sc.NextInt();\n M = sc.NextInt();\n\n /*\n * N*M\u30b0\u30ea\u30c3\u30c9\n * \u3059\u3079\u3066\u306e\u30de\u30b9\u306b\u96a3\u63a5\u3059\u308b\u540c\u3058\u30de\u30b9\u306e\u500b\u6570\u3000\u6700\u59271\u500b\u3000\n * \u30e9\u30f3\u30c0\u30e0\n *\n * \u30e9\u30f3\u30c0\u30e0\u306a\u30d1\u30bf\u30fc\u30f3\u500b\u6570\n */\n\n /*\n * 1\u884c\u76eeOK\u306a\u30d1\u30bf\u30fc\u30f3\n * 2\u884c\u76ee\u4ee5\u964d \u53cd\u8ee2...\n *\n *\n * 1\u5217\u76ee\n * 2\u5217\u76ee ...\n * \n */\n\n ModInt ans = 0;\n // \u884c\n var dp = new ModInt[100001];\n dp[1] = 2;\n dp[0] = 2;\n for (int i = 2; i <= 100000; i++)\n {\n dp[i] += dp[i - 1] + dp[i - 2];\n }\n\n ans += dp[M] + dp[N];\n\n Console.WriteLine(ans - 2);\n }\n\n public static void Main(string[] args) => new Program().Solve();\n // public static void Main(string[] args) => new Thread(new Program().Solve, 1 << 27).Start();\n}\n\n// https://bitbucket.org/camypaper/complib\nnamespace CompLib.Mathematics\n{\n #region ModInt\n\n /// \n /// [0,) \u307e\u3067\u306e\u5024\u3092\u53d6\u308b\u3088\u3046\u306a\u6570\n /// \n public struct ModInt\n {\n /// \n /// \u5270\u4f59\u3092\u53d6\u308b\u5024\uff0e\n /// \n public const long Mod = (int) 1e9 + 7;\n // public const long Mod = 998244353;\n\n /// \n /// \u5b9f\u969b\u306e\u6570\u5024\uff0e\n /// \n public long num;\n\n /// \n /// \u5024\u304c \u3067\u3042\u308b\u3088\u3046\u306a\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u3092\u69cb\u7bc9\u3057\u307e\u3059\uff0e\n /// \n /// \u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u304c\u6301\u3064\u5024\n /// \u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u306e\u554f\u984c\u4e0a\uff0c\u30b3\u30f3\u30b9\u30c8\u30e9\u30af\u30bf\u5185\u3067\u306f\u5270\u4f59\u3092\u53d6\u308a\u307e\u305b\u3093\uff0e\u305d\u306e\u305f\u3081\uff0c \u2208 [0,) \u3092\u6e80\u305f\u3059\u3088\u3046\u306a \u3092\u6e21\u3057\u3066\u304f\u3060\u3055\u3044\uff0e\u3053\u306e\u30b3\u30f3\u30b9\u30c8\u30e9\u30af\u30bf\u306f O(1) \u3067\u5b9f\u884c\u3055\u308c\u307e\u3059\uff0e\n public ModInt(long n)\n {\n num = n;\n }\n\n /// \n /// \u3053\u306e\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u306e\u6570\u5024\u3092\u6587\u5b57\u5217\u306b\u5909\u63db\u3057\u307e\u3059\uff0e\n /// \n /// [0,) \u306e\u7bc4\u56f2\u5185\u306e\u6574\u6570\u3092 10 \u9032\u8868\u8a18\u3057\u305f\u3082\u306e\uff0e\n public override string ToString()\n {\n return num.ToString();\n }\n\n public static ModInt operator +(ModInt l, ModInt r)\n {\n l.num += r.num;\n if (l.num >= Mod) l.num -= Mod;\n return l;\n }\n\n public static ModInt operator -(ModInt l, ModInt r)\n {\n l.num -= r.num;\n if (l.num < 0) l.num += Mod;\n return l;\n }\n\n public static ModInt operator *(ModInt l, ModInt r)\n {\n return new ModInt(l.num * r.num % Mod);\n }\n\n public static implicit operator ModInt(long n)\n {\n n %= Mod;\n if (n < 0) n += Mod;\n return new ModInt(n);\n }\n\n /// \n /// \u4e0e\u3048\u3089\u308c\u305f 2 \u3064\u306e\u6570\u5024\u304b\u3089\u3079\u304d\u5270\u4f59\u3092\u8a08\u7b97\u3057\u307e\u3059\uff0e\n /// \n /// \u3079\u304d\u4e57\u306e\u5e95\n /// \u3079\u304d\u6307\u6570\n /// \u7e70\u308a\u8fd4\u3057\u4e8c\u4e57\u6cd5\u306b\u3088\u308a O(N log N) \u3067\u5b9f\u884c\u3055\u308c\u307e\u3059\uff0e\n public static ModInt Pow(ModInt v, long k)\n {\n return Pow(v.num, k);\n }\n\n /// \n /// \u4e0e\u3048\u3089\u308c\u305f 2 \u3064\u306e\u6570\u5024\u304b\u3089\u3079\u304d\u5270\u4f59\u3092\u8a08\u7b97\u3057\u307e\u3059\uff0e\n /// \n /// \u3079\u304d\u4e57\u306e\u5e95\n /// \u3079\u304d\u6307\u6570\n /// \u7e70\u308a\u8fd4\u3057\u4e8c\u4e57\u6cd5\u306b\u3088\u308a O(N log N) \u3067\u5b9f\u884c\u3055\u308c\u307e\u3059\uff0e\n public static ModInt Pow(long v, long k)\n {\n long ret = 1;\n for (k %= Mod - 1; k > 0; k >>= 1, v = v * v % Mod)\n if ((k & 1) == 1)\n ret = ret * v % Mod;\n return new ModInt(ret);\n }\n\n /// \n /// \u4e0e\u3048\u3089\u308c\u305f\u6570\u306e\u9006\u5143\u3092\u8a08\u7b97\u3057\u307e\u3059\uff0e\n /// \n /// \u9006\u5143\u3092\u53d6\u308b\u5bfe\u8c61\u3068\u306a\u308b\u6570\n /// \u9006\u5143\u3068\u306a\u308b\u3088\u3046\u306a\u5024\n /// \u6cd5\u304c\u7d20\u6570\u3067\u3042\u308b\u3053\u3068\u3092\u4eee\u5b9a\u3057\u3066\uff0c\u30d5\u30a7\u30eb\u30de\u30fc\u306e\u5c0f\u5b9a\u7406\u306b\u5f93\u3063\u3066\u9006\u5143\u3092 O(log N) \u3067\u8a08\u7b97\u3057\u307e\u3059\uff0e\n public static ModInt Inverse(ModInt v)\n {\n return Pow(v, Mod - 2);\n }\n }\n\n #endregion\n\n #region Binomial Coefficient\n\n public class BinomialCoefficient\n {\n public ModInt[] fact, ifact;\n\n public BinomialCoefficient(int n)\n {\n fact = new ModInt[n + 1];\n ifact = new ModInt[n + 1];\n fact[0] = 1;\n for (int i = 1; i <= n; i++)\n fact[i] = fact[i - 1] * i;\n ifact[n] = ModInt.Inverse(fact[n]);\n for (int i = n - 1; i >= 0; i--)\n ifact[i] = ifact[i + 1] * (i + 1);\n ifact[0] = ifact[1];\n }\n\n public ModInt this[int n, int r]\n {\n get\n {\n if (n < 0 || n >= fact.Length || r < 0 || r > n) return 0;\n return fact[n] * ifact[n - r] * ifact[r];\n }\n }\n\n public ModInt RepeatedCombination(int n, int k)\n {\n if (k == 0) return 1;\n return this[n + k - 1, k];\n }\n }\n\n #endregion\n}\n\n\nnamespace CompLib.Util\n{\n using System;\n using System.Linq;\n\n class Scanner\n {\n private string[] _line;\n private int _index;\n private const char Separator = ' ';\n\n public Scanner()\n {\n _line = new string[0];\n _index = 0;\n }\n\n public string Next()\n {\n if (_index >= _line.Length)\n {\n string s;\n do\n {\n s = Console.ReadLine();\n } while (s.Length == 0);\n\n _line = s.Split(Separator);\n _index = 0;\n }\n\n return _line[_index++];\n }\n\n public string ReadLine()\n {\n _index = _line.Length;\n return Console.ReadLine();\n }\n\n public int NextInt() => int.Parse(Next());\n public long NextLong() => long.Parse(Next());\n public double NextDouble() => double.Parse(Next());\n public decimal NextDecimal() => decimal.Parse(Next());\n public char NextChar() => Next()[0];\n public char[] NextCharArray() => Next().ToCharArray();\n\n public string[] Array()\n {\n string s = Console.ReadLine();\n _line = s.Length == 0 ? new string[0] : s.Split(Separator);\n _index = _line.Length;\n return _line;\n }\n\n public int[] IntArray() => Array().Select(int.Parse).ToArray();\n public long[] LongArray() => Array().Select(long.Parse).ToArray();\n public double[] DoubleArray() => Array().Select(double.Parse).ToArray();\n public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();\n }\n}", "lang_cluster": "C#", "tags": ["math", "dp", "combinatorics"], "code_uid": "aa14ac78c6fe221bf6ed84e91b9475d9", "src_uid": "0f1ab296cbe0952faa904f2bebe0567b", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Text;\n\nnamespace round516\n{\n class MainClass\n {\n static long solve(long n, long a, long b, long k, long p)\n {\n long result = -1;\n if (n <= k / n / n)\n { // by sweet tooth\n for (long a_extra = p; a_extra <= a; ++a_extra)\n for (long b_extra = 0; b_extra <= b; ++b_extra)\n if ((k - a - a_extra) % (n + a_extra + b_extra) == 0)\n result = Math.Max(result, a_extra + b_extra);\n }\n else\n {\n for (long round = (k - 2 * a - 1) / (2 * n) + 1; round <= (k - a) / n; ++round)\n {\n long a_extra = (k - a) % round;\n if (a_extra < p) a_extra += round;\n long b_extra = (k - a - a_extra) / round - n - a_extra;\n if (b_extra > n - a)\n {\n long t = (b_extra - n + a - 1) / (round + 1) + 1;\n a_extra += round * t;\n b_extra -= (round + 1) * t;\n }\n if (a_extra <= a && b_extra >= 0)\n result = Math.Max(result, a_extra + b_extra);\n }\n }\n return result;\n }\n\n public static void Main(string[] args)\n {\n var line = Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);\n var n = line[0];\n var l = line[1];\n var r = line[2];\n var k = line[3];\n\n if (l > r)\n r = n - l + r + 1;\n else\n r = r - l + 1;\n l = 1;\n var b = n - r;\n\n long result = -1;\n\n if (k <= n || k <= r * 2)\n {\n if (r <= k && k <= r * 2)\n {\n long a_extra = k - r;\n result = Math.Min(b + a_extra + 1, n);\n }\n }\n else\n { \n result = Math.Max(solve(n, r, b, k, 0), solve(n, r, b, k + 1, 1));\n }\n\n Console.WriteLine(result);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "math"], "code_uid": "01e90b75c6d82b8d5a0154539eb797f2", "src_uid": "f54cc281033591315b037a400044f1cb", "difficulty": 2600.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections;\nusing System.Collections.Generic;\nusing System.Globalization;\nusing System.Linq;\nusing System.Text;\nusing System.Text.RegularExpressions;\nusing System.Threading;\n\nnamespace Codeforces\n{\n class A\n {\n private static ThreadStart s_threadStart = new A().Go;\n private static bool s_time = false;\n private static double s_eps = 1e-16;\n\n HashSet[] adj;\n\n private void Go()\n {\n long n = GetInt();\n long m = GetInt();\n\n adj = new HashSet[n];\n for (int i = 0; i < n; i++)\n {\n adj[i] = new HashSet();\n }\n\n for (int i = 0; i < m; i++)\n {\n long x = GetInt() - 1;\n long y = GetInt() - 1;\n adj[x].Add(y);\n adj[y].Add(x);\n }\n\n int[] visited = new int[n];\n\n for (int i = 0; i < n; i++)\n {\n if (adj[i].Count == n - 1)\n visited[i] = -1;\n }\n\n int compCount = 0;\n\n for (int i = 0; i < n; i++)\n {\n if (visited[i] == 0)\n {\n Queue> q = new Queue>();\n visited[i] = ++compCount;\n q.Enqueue(new Tuple(i, compCount));\n while (q.Count > 0)\n {\n var node = q.Dequeue();\n long x = node.Item1;\n foreach (long child in adj[x])\n {\n if (visited[child] == 0)\n {\n q.Enqueue(new Tuple(child, compCount));\n visited[child] = compCount;\n }\n }\n }\n }\n }\n\n if (compCount > 2)\n {\n Wl(\"No\");\n return;\n }\n\n for (int i = 0; i < n; i++)\n {\n for (int j = 0; j < n; j++)\n {\n if (i != j && !adj[i].Contains(j) && (visited[i] + visited[j]) != 3)\n {\n Wl(\"No\");\n return;\n }\n }\n }\n\n Wl(\"Yes\");\n StringBuilder sb = new StringBuilder();\n for (int i = 0; i < n; i++)\n {\n if (visited[i] == -1) sb.Append('b');\n else if (visited[i] == 1) sb.Append('a');\n else sb.Append('c');\n }\n Wl(sb.ToString());\n }\n\n #region Template\n\n public static void Main(string[] args)\n {\n System.Diagnostics.Stopwatch timer = new System.Diagnostics.Stopwatch();\n Thread main = new Thread(new ThreadStart(s_threadStart), 200 * 1024 * 1024);\n timer.Start();\n main.Start();\n main.Join();\n timer.Stop();\n if (s_time)\n Wl(timer.ElapsedMilliseconds);\n }\n\n private static IEnumerator ioEnum;\n private static string GetString()\n {\n while (ioEnum == null || !ioEnum.MoveNext())\n {\n ioEnum = Console.ReadLine().Split().AsEnumerable().GetEnumerator();\n }\n\n return ioEnum.Current;\n }\n\n private static int GetInt()\n {\n return int.Parse(GetString(), CultureInfo.InvariantCulture);\n }\n\n private static long GetLong()\n {\n return long.Parse(GetString(), CultureInfo.InvariantCulture);\n }\n\n private static double GetDouble()\n {\n return double.Parse(GetString(), CultureInfo.InvariantCulture);\n }\n\n private static List GetIntArr(int n)\n {\n List ret = new List(n);\n for (int i = 0; i < n; i++)\n {\n ret.Add(GetInt());\n }\n return ret;\n }\n\n private static void Wl(T o)\n {\n if (o is double)\n {\n Wld((o as double?).Value, \"\");\n }\n else if (o is float)\n {\n Wld((o as float?).Value, \"\");\n }\n else\n Console.WriteLine(o.ToString());\n }\n\n private static void Wl(IEnumerable enumerable)\n {\n Wl(string.Join(\" \", enumerable.Select(e => e.ToString()).ToArray()));\n }\n\n private static void Wld(double d, string format)\n {\n Wl(d.ToString(format, CultureInfo.InvariantCulture));\n }\n\n #endregion\n }\n}", "lang_cluster": "C#", "tags": ["constructive algorithms", "graphs"], "code_uid": "03a9b9e15c33c4f64c41b9a7d072aed0", "src_uid": "e71640f715f353e49745eac5f72e682a", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Globalization;\nusing System.Linq;\nusing System.Collections.Generic;\nusing System.Collections;\n\nnamespace taskA\n{\n\tclass newDecimal {\n\t\tprivate Int64 Z, F, kol;\n\t\tpublic newDecimal(decimal t, Int64 Kol) {\n\t\t\tkol = Kol;\n\t\t\tZ = Decimal.ToInt64 (t);\n\t\t\tInt64 p = 1;\n\t\t\tfor (int i = 0; i < kol; i ++)\n\t\t\t\tp *= 10L;\t\t\n\t\t\tF = Decimal.ToInt64 ((t - Z) * p);\n\t\t}\n\t\tpublic void print () {\n\t\t\tConsole.Write (\"{0}.\", Z);\n\t\t\tint sz = F.ToString ().Length;\n\t\t\tfor (int i = 0; i < kol - sz; i ++) \n\t\t\t\tConsole.Write (0);\n\t\t\tConsole.Write (F);\n\t\t}\n\t}\n\n\tclass MainClass\n\t{\n\t\tpublic static void Swap(ref T lhs, ref T rhs)\n\t\t{\n\t\t\tT temp;\n\t\t\ttemp = lhs;\n\t\t\tlhs = rhs;\n\t\t\trhs = temp;\n\t\t}\n\n\t\tpublic static void Main(string[] args) {\n\t\t\tint[] a = Console.ReadLine ().Split (' ').Select (int.Parse).ToArray ();\n\t\t\tint n = a[0];\n\t\t\tint m = a[1];\n\t\t\tint [,] g = new int[n + 1, n + 1];\n\t\t\tchar [] s = new char[n + 1];\n\t\t\tfor (int i = 1; i <= m; i ++) {\n\t\t\t\ta = Console.ReadLine ().Split (' ').Select (int.Parse).ToArray ();\n\t\t\t\tg [a [0], a [1]] = 1;\n\t\t\t\tg [a [1], a [0]] = 1;\n\t\t\t}\n\t\t\tfor (int i = 1; i <= n; i ++) {\n\t\t\t\tint sum = 0;\n\t\t\t\tfor (int j = 1; j <= n; j ++)\n\t\t\t\t\tsum += g[i,j];\n\t\t\t\tif (sum == n - 1) s[i] = 'b';\n\t\t\t}\n\t\t\tfor (int i = 1; i <= n; i ++) \n\t\t\t\tif (s [i] != 'b') {\n\t\t\t\t\ts [i] = 'a';\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\tfor (int v = 1; v <= n; v ++) {\n\t\t\t\tif (s [v] == 'b')\n\t\t\t\t\tcontinue;\n\t\t\t\tchar c = s [v];\n\t\t\t\tfor (int to = v + 1; to <= n; to ++) {\n\t\t\t\t\tchar newC = s [to];\n\t\t\t\t\tif (newC == 'b')\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\tif (g [v, to] == 1) {\n\t\t\t\t\t\tif (newC != c && (newC == 'a' || newC == 'b')) {\n\t\t\t\t\t\t\tConsole.WriteLine (\"No\");\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (newC == c)\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\ts [to] = c;\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tif (newC == c && (newC == 'a' || newC == 'b')) {\n\t\t\t\t\t\t\tConsole.WriteLine (\"No\");\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (newC != c && (newC == 'a' || newC == 'b'))\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\ts [to] = c == 'a' ? 'c' : 'a';\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tfor (int i = 1; i <= n; i ++)\n\t\t\t\tfor (int j = 1; j <= n; j ++) {\n\t\t\t\t\tif (i == j)\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\tchar c1 = s [i];\n\t\t\t\t\tchar c2 = s [j];\n\t\t\t\t\tif (c1 > c2)\n\t\t\t\t\t\tSwap (ref c1,ref c2);\n\t\t\t\t\tif (g [i, j] == 1) {\n\t\t\t\t\t\tif (c1 == c2 || c1 == c2 - 1)\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\tConsole.WriteLine (\"No\");\n\t\t\t\t\t\treturn;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tif (c1 == c2 - 2)\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\tConsole.WriteLine (\"No\");\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\tchar[] ss = new char[n];\n\t\t\tfor (int i = 1; i <= n; i ++)\n\t\t\t\tss [i - 1] = s [i];\n\t\t\tConsole.WriteLine (\"Yes\");\n\t\t\tConsole.WriteLine (ss);\n\n\t\t}\n\t}\n}\n", "lang_cluster": "C#", "tags": ["constructive algorithms", "graphs"], "code_uid": "c685ef52f2312ea91fa72a6054bd0dda", "src_uid": "e71640f715f353e49745eac5f72e682a", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Linq;\n\nnamespace Hamburgers\n{\n class Hamburgers\n {\n static void Main(string[] args)\n {\n string hamburger;\n long[] kitchenPieces, shopPrices;\n long rubles, count, numB = 0, numS = 0, numC = 0;\n\n hamburger = Console.ReadLine();\n kitchenPieces = Console.ReadLine().Split().Select(long.Parse).ToArray();\n shopPrices = Console.ReadLine().Split().Select(long.Parse).ToArray();\n rubles = long.Parse(Console.ReadLine());\n\n for (int i = 0; i < hamburger.Length; i++)\n {\n if (hamburger[i] == 'B')\n numB++;\n else if (hamburger[i] == 'S')\n numS++;\n else\n numC++;\n }\n\n Console.WriteLine(BinarySearch(0, 1L<<45, numB, numS, numC, kitchenPieces, shopPrices, rubles));\n }\n\n private static long BinarySearch(long start, long end, long numB, long numS, long numC, long[] kitchenPieces, long[] shopPrices, long rubles)\n {\n long mid = (start + end) / 2;\n\n if (end - start <= 1)\n {\n if (MaxRublesUsed(end, numB, numS, numC, kitchenPieces, shopPrices, rubles))\n return end;\n else\n return start;\n }\n\n if (MaxRublesUsed(mid, numB, numS, numC, kitchenPieces, shopPrices, rubles))\n return BinarySearch(mid, end, numB, numS, numC, kitchenPieces, shopPrices, rubles);\n else\n return BinarySearch(start, mid, numB, numS, numC, kitchenPieces, shopPrices, rubles);\n }\n\n private static bool MaxRublesUsed(long num, long numB, long numS, long numC, long[] kitchenPieces, long[] shopPrices, long rubles)\n {\n long b, s, c;\n\n b = Math.Max(0, (numB * num) - kitchenPieces[0]) * shopPrices[0];\n s = Math.Max(0, (numS * num) - kitchenPieces[1]) * shopPrices[1];\n c = Math.Max(0, (numC * num) - kitchenPieces[2]) * shopPrices[2];\n\n return rubles >= (b + s + c);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "binary search"], "code_uid": "93f6e728cfafab5378b8be4a91caa653", "src_uid": "8126a4232188ae7de8e5a7aedea1a97e", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Globalization;\nusing System.IO;\nusing System.Linq;\nusing System.Text;\nusing System.Threading;\n\n// (\u3065\u00b0\u03c9\u00b0)\u3065\uff90\u2605\u309c\u30fb\u3002\u3002\u30fb\u309c\u309c\u30fb\u3002\u3002\u30fb\u309c\u2606\u309c\u30fb\u3002\u3002\u30fb\u309c\u309c\u30fb\u3002\u3002\u30fb\u309c\npublic class Solver\n{\n public void Solve()\n {\n var cnt = new int[3];\n foreach (char ch in ReadToken())\n cnt[\"BSC\".IndexOf(ch)]++;\n var a = ReadIntArray();\n var b = ReadIntArray();\n long n = ReadLong();\n\n long l = 0, r = n + 1000;\n while (l < r)\n {\n long mid = (l + r + 1) / 2;\n long s = 0;\n for (int i = 0; i < 3; i++)\n s += Math.Max(0, cnt[i] * mid - a[i]) * b[i];\n if (s > n)\n r = mid - 1;\n else\n l = mid;\n }\n\n Write(l);\n }\n\n #region Main\n\n protected static TextReader reader;\n protected static TextWriter writer;\n\n static void Main()\n {\n#if DEBUG\n reader = new StreamReader(\"..\\\\..\\\\input.txt\");\n writer = Console.Out;\n //writer = new StreamWriter(\"..\\\\..\\\\output.txt\");\n#else\n reader = new StreamReader(Console.OpenStandardInput());\n writer = new StreamWriter(Console.OpenStandardOutput());\n //reader = new StreamReader(\"cycle.in\");\n //writer = new StreamWriter(\"cycle.out\");\n#endif\n try\n {\n // var thread = new Thread(new Solver().Solve, 1024 * 1024 * 128);\n // thread.Start();\n // thread.Join();\n new Solver().Solve();\n }\n catch (Exception ex)\n {\n#if DEBUG\n Console.WriteLine(ex);\n#else\n Console.WriteLine(ex);\n throw;\n#endif\n }\n reader.Close();\n writer.Close();\n }\n\n #endregion\n\n #region Read / Write\n\n private static Queue currentLineTokens = new Queue();\n\n private static string[] ReadAndSplitLine()\n {\n return reader.ReadLine().Split(new[] { ' ', '\\t' }, StringSplitOptions.RemoveEmptyEntries);\n }\n\n public static string ReadToken()\n {\n while (currentLineTokens.Count == 0)\n currentLineTokens = new Queue(ReadAndSplitLine());\n return currentLineTokens.Dequeue();\n }\n\n public static int ReadInt()\n {\n return int.Parse(ReadToken());\n }\n\n public static long ReadLong()\n {\n return long.Parse(ReadToken());\n }\n\n public static double ReadDouble()\n {\n return double.Parse(ReadToken(), CultureInfo.InvariantCulture);\n }\n\n public static int[] ReadIntArray()\n {\n return ReadAndSplitLine().Select(int.Parse).ToArray();\n }\n\n public static long[] ReadLongArray()\n {\n return ReadAndSplitLine().Select(long.Parse).ToArray();\n }\n\n public static double[] ReadDoubleArray()\n {\n return ReadAndSplitLine().Select(s => double.Parse(s, CultureInfo.InvariantCulture)).ToArray();\n }\n\n public static int[][] ReadIntMatrix(int numberOfRows)\n {\n int[][] matrix = new int[numberOfRows][];\n for (int i = 0; i < numberOfRows; i++)\n matrix[i] = ReadIntArray();\n return matrix;\n }\n\n public static int[][] ReadAndTransposeIntMatrix(int numberOfRows)\n {\n int[][] matrix = ReadIntMatrix(numberOfRows);\n int[][] ret = new int[matrix[0].Length][];\n for (int i = 0; i < ret.Length; i++)\n {\n ret[i] = new int[numberOfRows];\n for (int j = 0; j < numberOfRows; j++)\n ret[i][j] = matrix[j][i];\n }\n return ret;\n }\n\n public static string[] ReadLines(int quantity)\n {\n string[] lines = new string[quantity];\n for (int i = 0; i < quantity; i++)\n lines[i] = reader.ReadLine().Trim();\n return lines;\n }\n\n public static void WriteArray(IEnumerable array)\n {\n writer.WriteLine(string.Join(\" \", array));\n }\n\n public static void Write(params object[] array)\n {\n WriteArray(array);\n }\n\n public static void WriteLines(IEnumerable array)\n {\n foreach (var a in array)\n writer.WriteLine(a);\n }\n\n class SDictionary : Dictionary\n {\n public new TValue this[TKey key]\n {\n get { return ContainsKey(key) ? base[key] : default(TValue); }\n set { base[key] = value; }\n }\n }\n\n #endregion\n}", "lang_cluster": "C#", "tags": ["brute force", "binary search"], "code_uid": "1de47c46a500b4aba49395f2eb6cce44", "src_uid": "8126a4232188ae7de8e5a7aedea1a97e", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.IO;\nusing System.Linq;\nusing System.Text;\n\nnamespace Phone_Number\n{\n internal class Program\n {\n private static readonly StreamReader reader = new StreamReader(Console.OpenStandardInput(1024*10), Encoding.ASCII, false, 1024*10);\n private static readonly StreamWriter writer = new StreamWriter(Console.OpenStandardOutput(1024*10), Encoding.ASCII, 1024*10);\n\n private static void Main(string[] args)\n {\n string s = reader.ReadLine();\n int[] nn = s.ToCharArray().Select(e => e - '0').ToArray();\n\n var dp = new long[10,nn.Length];\n for (int i = 0; i < 10; i++)\n {\n dp[i, 0] = 1;\n }\n\n for (int j = 1; j < nn.Length; j++)\n {\n for (int i = 0; i < 10; i++)\n {\n int ss = i + nn[j];\n if (ss%2 == 0)\n dp[ss/2, j] += dp[i, j - 1];\n else\n {\n dp[ss/2, j] += dp[i, j - 1];\n dp[(ss + 1)/2, j] += dp[i, j - 1];\n }\n }\n }\n\n long sum = -1;\n for (int i = 0; i < 10; i++)\n {\n sum += dp[i, nn.Length - 1];\n }\n for (int i = 1; i < nn.Length; i++)\n {\n if (Math.Abs(nn[i] - nn[i - 1]) > 1)\n {\n sum++;\n break;\n }\n }\n\n writer.WriteLine(sum);\n writer.Flush();\n }\n }\n}", "lang_cluster": "C#", "tags": ["dp"], "code_uid": "7bd97dbff116e66daca958fe3f041198", "src_uid": "2dd8bb6e8182278d037aa3a59ca3517b", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\n\nnamespace ProgrammingContest.Codeforces.SchoolTeam2\n{\n class H\n {\n public static void Main()\n {\n string s = Console.ReadLine();\n int n = s.Length;\n long[,] dp = new long[n, 10];\n\n long res = 0;\n bool self = false;\n for (int u = 0; u < 10; u++)\n {\n for (int i = 0; i < n; i++)\n for (int j = 0; j < 10; j++)\n dp[i, j] = 0;\n dp[0, u] = 1;\n for (int i = 1; i < n; i++)\n {\n int x = s[i] - '0';\n for (int j = 0; j < 10; j++)\n {\n int y = j + x;\n for (int k = 0; k <= y % 2; k++)\n dp[i, y / 2 + k] += dp[i - 1, j];\n }\n }\n for (int i = 0; i < 10; i++) res += dp[n - 1, i];\n\n bool b = true;\n for (int i = 0; i < n; i++) b &= dp[i, s[i] - '0'] > 0;\n self |= b;\n }\n\n Console.WriteLine(res - (self ? 1 : 0));\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["dp"], "code_uid": "98877ed36abafca340c3148e31115909", "src_uid": "2dd8bb6e8182278d037aa3a59ca3517b", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\n\nnamespace GoldPigeon\n{\n class Program\n {\n static void Main(string[] args)\n {\n int n = Convert.ToInt32(Console.ReadLine()); \n int[] a = new int[n];\n string[] line = Console.ReadLine().Split(' ');\n int min = int.MaxValue;\n int index = -1;\n\n for(int i = 0; i < n; i++)\n {\n a[i] = Convert.ToInt32(line[i]);\n index = min > a[i] ? i : index;\n min = min > a[i] ? a[i] : min;\n\n }\n\n Console.WriteLine(2+(min ^ a[2]));\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "280c590de6d38837a50ccdb029597a0b", "src_uid": "a9eb85dfaa3c50ed488d41da4f29c697", "difficulty": null, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\n\nnamespace ConsoleApplication1\n{\n public class Program\n {\n static void Main(string[] args)\n {\n var str = Console.ReadLine();\n var n = Int32.Parse(str);\n\n var fi = new int[n + 1];\n var used = new int[3 * n];\n var kucha = new int[n + 1];\n \n for (int i = 3; i <= n; ++i)\n {\n for (int k = 2; k <= 4 * (int)Math.Sqrt(i); ++k)\n {\n var delta = i - (k*(k - 1))/2;\n if (delta <= 0)\n break;\n\n if (delta % k != 0)\n continue;\n\n var c = delta/k;\n var curFi = 0;\n for (int j = 0; j < k; ++j)\n {\n curFi = curFi ^ fi[c + j];\n }\n used[curFi] = i;\n if (curFi == 0 && kucha[i] == 0)\n {\n kucha[i] = k;\n }\n }\n\n if (kucha[i] > 0)\n {\n for (int j = 0; j <= n; ++j)\n {\n if (used[j] != i)\n {\n fi[i] = j;\n break;\n }\n }\n }\n }\n if (fi[n] == 0)\n {\n Console.WriteLine(-1);\n }\n else\n {\n Console.WriteLine(kucha[n]);\n }\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "dp", "games"], "code_uid": "0e16a2ff188b88ba5302fcea02db1c05", "src_uid": "63262317ba572d78163c91b853c05506", "difficulty": 2000.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\n\nnamespace cs_console\n{\n class _73_2_E\n {\n //nim\n //game\n public static void Main(string[] args)\n {\n int n = int.Parse(Console.ReadLine());\n int[] grundy = new int[n + 1];\n int[] ans = new int[n + 1];\n grundy[1] = 0;\n ans[1] = -1;\n for (int i = 2; i <= n; i++)\n {\n grundy[i] = 0;\n ans[i] = -1;\n bool ok = false;\n Dictionary used = new Dictionary();\n for (int len = 2; len * (len + 1) / 2 <= i; len++)\n {\n if (i * 2 % len == 0)\n {\n int aa = i * 2 / len - len + 1;\n if (aa % 2 == 0 && aa > 0)\n {\n int x = aa / 2;\n //valid split (x, x + 1, ..., x + k - 1)\n int ng = 0;\n for (int k = 0; k < len; k++)\n {\n ng ^= grundy[x + k];\n }\n if(!ok && ng == 0)\n {\n //good\n ok = true;\n ans[i] = len;\n }\n used[ng] = 1;\n }\n }\n }\n //find the min value not used -- grundy value\n for (int j = 0; ; j++)\n {\n if (!used.ContainsKey(j))\n {\n grundy[i] = j;\n break;\n }\n }\n if (!ok)\n {\n ans[i] = -1;\n }\n }\n //for (int i = 0; i < n; i++)\n //{\n //Console.WriteLine(i + \" \" + ans[i] + \" \" + grundy[i]);\n //}\n Console.WriteLine(ans[n]);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "dp", "games"], "code_uid": "dce6fa30c7896015eb17659db28c6753", "src_uid": "63262317ba572d78163c91b853c05506", "difficulty": 2000.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\n\nnamespace CodeForceCs\n{\n static class Program\n {\n static void Main(string[] args)\n {\n Solver solver = new _462_2D();\n solver.SolveProblem();\n //Console.ReadKey();\n }\n }\n\n static class Utility\n { \n static public T[] NewArrayWithValue(int length, T value)\n {\n T[] array = new T[length];\n for (int i = 0; i < array.Length; i++)\n {\n array[i] = value;\n }\n return array;\n }\n }\n\n abstract class Solver\n {\n abstract public void SolveProblem();\n }\n\n class _462_2D : Solver\n {\n Int64 p, k, z;\n int d;\n List a, q;\n String result;\n public override void SolveProblem()\n {\n String[] input = Console.ReadLine().Split();\n p = Int64.Parse(input[0]);\n k = Int64.Parse(input[1]);\n a = new List();\n q = new List();\n\n d = 1;\n z = p % k;\n a.Add(z);\n q.Add((z - p) / k);\n\n while (!(q[d-1] >= 0 && q[d-1] < k))\n {\n z = q[d - 1] % k;\n if (z < 0)\n z += k;\n a.Add(z);\n q.Add((z - q[d - 1]) / k);\n d++;\n }\n if (q[d - 1] != 0)\n {\n a.Add(q[d - 1]);\n d++;\n }\n\n Console.WriteLine(d);\n\n result = \"\";\n foreach (Int64 v in a)\n result += v + \" \";\n Console.WriteLine(result);\n\n //result = \"\";\n //foreach (Int64 v in q)\n // result += v + \" \";\n //Console.WriteLine(result);\n }\n }\n\n class _462_2C : Solver\n {\n List a;\n int n, result;\n\n public override void SolveProblem()\n {\n a = new List();\n n = int.Parse(Console.ReadLine());\n result = Math.Min(n, 2);\n\n String[] input = Console.ReadLine().Split();\n foreach (String s in input)\n a.Add(int.Parse(s));\n\n for (int i = 1; i < n-1; i++)\n {\n result = Math.Max(result, GetMaxNonDec(0, i) + GetMaxNonDec(i, n - i));\n }\n Console.WriteLine(result);\n\n }\n\n int GetMaxNonDec(int start, int length)\n {\n if (length <= 0)\n return 0;\n\n int[] oneNum, twoNum;\n oneNum = new int[length];\n twoNum = new int[length];\n oneNum[0] = a[start] == 1 ? 1 : 0;\n twoNum[0] = a[start + length - 1] == 2 ? 1 : 0;\n\n for (int i = 1; i < length; i++ )\n {\n oneNum[i] = oneNum[i-1];\n twoNum[i] = twoNum[i-1];\n if (a[start + i] == 1)\n oneNum[i]++;\n if (a[start + length - 1 - i] == 2)\n twoNum[i]++;\n }\n\n int result = Math.Min(length, 2);\n for (int i = 0; i < length; i++)\n result = Math.Max(result, oneNum[i] + twoNum[length - i - 1]);\n return result;\n }\n }\n\n class _462_2B : Solver\n {\n String result = \"\";\n int k;\n public override void SolveProblem()\n {\n k = int.Parse(Console.ReadLine());\n if (k > 36)\n {\n Console.WriteLine(\"-1\");\n return;\n }\n while (k > 1)\n {\n result += \"8\";\n k -= 2;\n }\n if (k == 1)\n result += \"6\";\n Console.WriteLine(result);\n }\n }\n\n class _462_2A : Solver\n {\n int n, m;\n List a, b;\n Int64 result;\n public override void SolveProblem()\n {\n a = new List();\n b = new List();\n\n String[] input = Console.ReadLine().Split();\n n = int.Parse(input[0]);\n m = int.Parse(input[1]);\n\n input = Console.ReadLine().Split();\n foreach (String s in input)\n a.Add(Int64.Parse(s));\n\n input = Console.ReadLine().Split();\n foreach (String s in input)\n b.Add(Int64.Parse(s));\n\n a.Sort();\n b.Sort();\n\n Int64 p11, p12, p21, p22;\n p11 = Math.Max(a[1] * b[0], a[1] * b[m-1]);\n p12 = Math.Max(a[n - 1] * b[0], a[n - 1] * b[m - 1]);\n p21 = Math.Max(a[0] * b[0], a[0] * b[m - 1]);\n p22 = Math.Max(a[n - 2] * b[0], a[n - 2] * b[m - 1]);\n\n result = Math.Min(Math.Max(p11, p12), Math.Max(p21, p22));\n\n Console.WriteLine(result);\n }\n }\n\n class _910A : Solver\n {\n int n, d;\n int[] minstep;\n string lily;\n override public void SolveProblem()\n {\n var input = Console.ReadLine().Split();\n n = int.Parse(input[0]);\n d = int.Parse(input[1]);\n lily = Console.ReadLine();\n minstep = Utility.NewArrayWithValue(n+1, 999);\n minstep[1] = 0;\n\n for (int i = 2; i <= n; i++)\n {\n for (int j = i; j >= Math.Max(1, i-d); j--)\n {\n if (lily[j-1] == '0')\n continue;\n\n minstep[i] = Math.Min(minstep[i], minstep[j] + 1);\n }\n }\n\n if (minstep[n] > n)\n Console.WriteLine(-1);\n else\n Console.WriteLine(minstep[n]);\n }\n\n }\n}\n\n", "lang_cluster": "C#", "tags": ["math"], "code_uid": "06b7540cb65ad36e43467c2650edde90", "src_uid": "f4dbaa8deb2bd5c054fe34bb83bc6cd5", "difficulty": 2000.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.IO;\nusing System.Text;\nusing System.Globalization;\nusing System.Diagnostics;\n\n\n\nclass Myon\n{\n public Myon() { }\n public static int Main()\n {\n new Myon().calc();\n return 0;\n }\n\n\n Scanner cin;\n \n void calc()\n {\n cin = new Scanner();\n long p = cin.nextLong();\n long k = cin.nextLong();\n\n long now = p;\n List ans = new List();\n while (now < 0 || now >= k)\n {\n if (ans.Count >= 1000000) break;\n long mul;\n if (now > 0) mul = now / k;\n else mul = -((-now + (k - 1)) / k);\n now -= mul * k;\n ans.Add(now);\n now = -mul;\n }\n if(ans.Count >= 1000000)\n {\n Console.WriteLine(-1);\n return;\n }\n ans.Add(now);\n\n Console.WriteLine(ans.Count);\n Console.WriteLine(string.Join(\" \", ans));\n }\n\n \n}\n\nclass Scanner\n{\n string[] s;\n int i;\n\n char[] cs = new char[] { ' ' };\n\n public Scanner()\n {\n s = new string[0];\n i = 0;\n }\n\n public string next()\n {\n if (i < s.Length) return s[i++];\n string st = Console.ReadLine();\n while (st == \"\") st = Console.ReadLine();\n s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);\n if (s.Length == 0) return next();\n i = 0;\n return s[i++];\n }\n\n public int nextInt()\n {\n return int.Parse(next());\n }\n public int[] ArrayInt(int N, int add = 0)\n {\n int[] Array = new int[N];\n for (int i = 0; i < N; i++)\n {\n Array[i] = nextInt() + add;\n }\n return Array;\n }\n\n public long nextLong()\n {\n return long.Parse(next());\n }\n\n public long[] ArrayLong(int N, long add = 0)\n {\n long[] Array = new long[N];\n for (int i = 0; i < N; i++)\n {\n Array[i] = nextLong() + add;\n }\n return Array;\n }\n\n public double nextDouble()\n {\n return double.Parse(next());\n }\n\n\n public double[] ArrayDouble(int N, double add = 0)\n {\n double[] Array = new double[N];\n for (int i = 0; i < N; i++)\n {\n Array[i] = nextDouble() + add;\n }\n return Array;\n }\n}\n", "lang_cluster": "C#", "tags": ["math"], "code_uid": "763015dde1272bc57995cf89b79dfcc7", "src_uid": "f4dbaa8deb2bd5c054fe34bb83bc6cd5", "difficulty": 2000.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Diagnostics;\nusing System.Globalization;\nusing System.IO;\nusing System.Linq;\nusing System.Text;\nusing System.Text.RegularExpressions;\nusing System.Threading;\n\nnamespace ReadWriteTemplate\n{\n public static class Solver\n {\n private static void SolveCase()\n {\n const long MOD = 998244353;\n\n var ntt = new NTTFastLong(MOD);\n\n int n = ReadInt();\n int k = ReadInt();\n int[] d = ReadIntArray();\n\n int m = 1;\n int p = 0;\n while (m < 5 * n)\n {\n m <<= 1;\n p++;\n }\n\n long[] a = new long[m];\n for (int i = 0; i < k; i++)\n {\n a[d[i]] = 1;\n }\n\n ntt.FFT(a);\n\n for (int i = 0; i < m; i++)\n {\n a[i] = ntt.Power(a[i], n / 2);\n }\n\n ntt.FFT(a);\n\n long invM = ntt.Inv(m);\n\n long ans = 0;\n for (int i = 0; i < a.Length; i++)\n {\n long c = a[i] * invM % MOD;\n ans = (ans + c * c) % MOD;\n }\n\n Writer.WriteLine(ans);\n }\n\n public class NTTFastLong\n {\n private int curBase = 1;\n private long[] roots = { 0, 1 };\n private int[] rev = { 0, 1 };\n private int maxBase = -1;\n private int root = -1;\n\n private readonly long MOD;\n\n public NTTFastLong(long mod)\n {\n MOD = mod;\n }\n\n private void Init()\n {\n long tmp = MOD - 1;\n maxBase = 0;\n while (tmp % 2 == 0)\n {\n tmp /= 2;\n maxBase++;\n }\n root = 2;\n while (true)\n {\n if (Power(root, 1 << maxBase) == 1)\n {\n if (Power(root, 1 << (maxBase - 1)) != 1)\n {\n break;\n }\n }\n root++;\n }\n }\n\n void ensure_base(int nBase)\n {\n if (maxBase == -1)\n {\n Init();\n }\n if (nBase <= curBase)\n {\n return;\n }\n if (nBase > maxBase)\n {\n throw new InvalidOperationException();\n }\n Array.Resize(ref rev, 1 << nBase);\n for (int i = 0; i < (1 << nBase); i++)\n {\n rev[i] = (rev[i >> 1] >> 1) + ((i & 1) << (nBase - 1));\n }\n Array.Resize(ref roots, 1 << nBase);\n while (curBase < nBase)\n {\n long z = Power(root, 1 << (maxBase - 1 - curBase));\n for (int i = 1 << (curBase - 1); i < (1 << curBase); i++)\n {\n roots[i << 1] = roots[i];\n roots[(i << 1) + 1] = roots[i] * z % MOD;\n }\n curBase++;\n }\n }\n\n public void FFT(long[] a)\n {\n int n = a.Length;\n if ((n & (n - 1)) != 0)\n {\n throw new InvalidOperationException();\n }\n int zeros = get__builtin_ctz(n);\n ensure_base(zeros);\n int shift = curBase - zeros;\n for (int i = 0; i < n; i++)\n {\n if (i < (rev[i] >> shift))\n {\n long tmp = a[i];\n a[i] = a[rev[i] >> shift];\n a[rev[i] >> shift] = tmp;\n }\n }\n for (int k = 1; k < n; k <<= 1)\n {\n for (int i = 0; i < n; i += 2 * k)\n {\n for (int j = 0; j < k; j++)\n {\n long x = a[i + j];\n long y = a[i + j + k] * roots[j + k] % MOD;\n a[i + j] = x + y - MOD;\n if (a[i + j] < 0)\n {\n a[i + j] += MOD;\n }\n a[i + j + k] = x - y + MOD;\n if (a[i + j + k] >= MOD)\n {\n a[i + j + k] -= MOD;\n }\n }\n }\n }\n }\n\n // todo: rename? remove?\n private int get__builtin_ctz(int n)\n {\n int c = 0;\n while (n > 0 && (n & 1) == 0)\n {\n c++;\n n >>= 1;\n }\n return c;\n }\n\n public long[] Multiply(long[] a, long[] b, int eq = 0)\n {\n int need = a.Length + b.Length - 1;\n int nbase = 0;\n while ((1 << nbase) < need)\n {\n nbase++;\n }\n ensure_base(nbase);\n int sz = 1 << nbase;\n Array.Resize(ref a, sz);\n Array.Resize(ref b, sz);\n FFT(a);\n if (eq != 0)\n {\n b = a;\n }\n else\n {\n FFT(b);\n }\n long invSz = Inv(sz);\n for (int i = 0; i < sz; i++)\n {\n a[i] = a[i] * b[i] % MOD * invSz % MOD;\n }\n Array.Reverse(a, 1, a.Length - 1);\n FFT(a);\n\n int newSize = need;\n while (newSize > 0 && a[newSize - 1] == 0)\n {\n newSize--;\n }\n Array.Resize(ref a, newSize);\n\n return a;\n }\n\n public long[] Square(long[] a)\n {\n return Multiply(a, a, 1);\n }\n\n public long Power(long a, long b)\n {\n long res = 1;\n while (b > 0)\n {\n if ((b & 1) > 0)\n {\n res = res * a % MOD;\n }\n a = a * a % MOD;\n b >>= 1;\n }\n return res;\n }\n\n public long Inv(long a)\n {\n a %= MOD;\n if (a < 0)\n {\n a += MOD;\n }\n long b = MOD;\n long u = 0;\n long v = 1;\n while (a != 0)\n {\n long t = b / a;\n b -= t * a;\n\n long tmp = a;\n a = b;\n b = tmp;\n\n u -= t * v;\n\n tmp = u;\n u = v;\n v = tmp;\n }\n if (u < 0)\n {\n u += MOD;\n }\n return u;\n }\n }\n\n public static void Solve()\n {\n#if DEBUG\n var sw = Stopwatch.StartNew();\n#endif\n\n SolveCase();\n\n /*int T = ReadInt();\n for (int i = 0; i < T; i++)\n {\n Writer.Write(\"Case #{0}: \", i + 1);\n SolveCase();\n }*/\n\n#if DEBUG\n sw.Stop();\n Console.WriteLine($\"{sw.ElapsedMilliseconds} ms\");\n#endif\n }\n\n public static void Main()\n {\n Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;\n\n#if DEBUG\n //Reader = Console.In; Writer = Console.Out;\n Reader = File.OpenText(\"input.txt\"); Writer = File.CreateText(\"output.txt\");\n#else\n Reader = Console.In; Writer = Console.Out;\n#endif\n\n // Solve();\n Thread thread = new Thread(Solve, 64 * 1024 * 1024);\n thread.CurrentCulture = CultureInfo.InvariantCulture;\n thread.Start();\n thread.Join();\n\n Reader.Close();\n Writer.Close();\n }\n\n public static IOrderedEnumerable OrderByWithShuffle(this IEnumerable source, Func keySelector)\n {\n return source.Shuffle().OrderBy(keySelector);\n }\n\n public static T[] Shuffle(this IEnumerable source)\n {\n T[] result = source.ToArray();\n Random rnd = new Random();\n for (int i = result.Length - 1; i >= 1; i--)\n {\n int k = rnd.Next(i + 1);\n T tmp = result[k];\n result[k] = result[i];\n result[i] = tmp;\n }\n return result;\n }\n\n #region Read/Write\n\n private static TextReader Reader;\n\n private static TextWriter Writer;\n\n private static Queue CurrentLineTokens = new Queue();\n\n private static string[] ReadAndSplitLine()\n {\n return Reader.ReadLine().Split(new[] { ' ', '\\t' }, StringSplitOptions.RemoveEmptyEntries);\n }\n\n public static string ReadToken()\n {\n while (CurrentLineTokens.Count == 0)\n CurrentLineTokens = new Queue(ReadAndSplitLine());\n return CurrentLineTokens.Dequeue();\n }\n\n public static string ReadLine()\n {\n return Reader.ReadLine();\n }\n\n public static int ReadInt()\n {\n return int.Parse(ReadToken());\n }\n\n public static long ReadLong()\n {\n return long.Parse(ReadToken());\n }\n\n public static double ReadDouble()\n {\n return double.Parse(ReadToken(), CultureInfo.InvariantCulture);\n }\n\n public static int[] ReadIntArray()\n {\n return ReadAndSplitLine().Select(int.Parse).ToArray();\n }\n\n public static long[] ReadLongArray()\n {\n return ReadAndSplitLine().Select(long.Parse).ToArray();\n }\n\n public static double[] ReadDoubleArray()\n {\n return ReadAndSplitLine().Select(s => double.Parse(s, CultureInfo.InvariantCulture)).ToArray();\n }\n\n public static int[][] ReadIntMatrix(int numberOfRows)\n {\n int[][] matrix = new int[numberOfRows][];\n for (int i = 0; i < numberOfRows; i++)\n matrix[i] = ReadIntArray();\n return matrix;\n }\n\n public static string[] ReadLines(int quantity)\n {\n string[] lines = new string[quantity];\n for (int i = 0; i < quantity; i++)\n lines[i] = Reader.ReadLine().Trim();\n return lines;\n }\n\n public static void WriteArray(IEnumerable array)\n {\n Writer.WriteLine(string.Join(\" \", array));\n }\n\n #endregion\n }\n}\n", "lang_cluster": "C#", "tags": ["divide and conquer", "dp", "fft"], "code_uid": "560aea8ea2ae57dd8fd12b2dd5b43971", "src_uid": "279f1f7d250a4be6406c6c7bfc818bbf", "difficulty": 2400.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Diagnostics;\nusing CompLib.Mathematics;\nusing CompLib.Util;\n\npublic class Program\n{\n private const int MaxLg = 21;\n\n\n private int N, K;\n\n public void Solve()\n {\n var sc = new Scanner();\n N = sc.NextInt();\n K = sc.NextInt();\n\n ModInt[] a = new ModInt[1 << MaxLg];\n a[0] = 1;\n\n ModInt[] b = new ModInt[1 << MaxLg];\n int min = int.MaxValue;\n int max = int.MinValue;\n for (int i = 0; i < K; i++)\n {\n int d = sc.NextInt();\n min = Math.Min(min, d);\n max = Math.Max(max, d);\n b[d] = 1;\n }\n\n int lenA = 1;\n int lenB = max + 1;\n\n int h = N / 2;\n int tmp = h;\n while (tmp > 0)\n {\n if ((tmp & 1) > 0)\n {\n FFT.Convolusion(ref a, lenA, b, lenB);\n lenA = lenA + lenB - 1;\n }\n\n if (tmp > 1)\n {\n FFT.Convolusion(ref b, lenB);\n lenB = lenB + lenB - 1;\n }\n\n tmp /= 2;\n }\n\n ModInt ans = 0;\n for (int i = min * h; i <= max * h; i++)\n {\n ans += a[i] * a[i];\n }\n\n Console.WriteLine(ans);\n }\n\n\n public static void Main(string[] args) => new Program().Solve();\n}\n\nstatic class FFT\n{\n private const int E = 23;\n private const int MaxLg = 21;\n private static readonly ModInt O = 31;\n\n private static readonly ModInt[] Z, InvZ;\n\n private static readonly List<(int f, int t)>[] Rev;\n private static readonly ModInt[] InvLen;\n\n static FFT()\n {\n Z = new ModInt[E + 1];\n InvZ = new ModInt[E + 1];\n Z[E] = O;\n InvZ[E] = ModInt.Inverse(O);\n\n for (int i = E - 1; i >= 0; i--)\n {\n Z[i] = Z[i + 1] * Z[i + 1];\n InvZ[i] = InvZ[i + 1] * InvZ[i + 1];\n }\n\n Rev = new List<(int f, int t)>[MaxLg + 1];\n for (int i = 0; i <= MaxLg; i++)\n {\n int len = 1 << i;\n Rev[i] = new List<(int f, int t)>();\n for (int j = 0; j < len; j++)\n {\n int r = BitsReverse(j, i);\n if (j < r) Rev[i].Add((j, r));\n }\n }\n\n InvLen = new ModInt[MaxLg + 1];\n for (int i = 0; i <= MaxLg; i++)\n {\n InvLen[i] = ModInt.Inverse(1 << i);\n }\n }\n\n public static void Transform(ModInt[] a, int lg, int len, bool inverse)\n {\n foreach (var pair in Rev[lg])\n {\n var t = a[pair.f];\n a[pair.f] = a[pair.t];\n a[pair.t] = t;\n }\n\n for (int i = 1; i <= lg; i++)\n {\n int b = 1 << (i - 1);\n ModInt z = 1;\n for (int j = 0; j < b; j++)\n {\n for (int k = j; k < len; k += (b << 1))\n {\n var t = z * a[k + b];\n var u = a[k];\n a[k] = u + t;\n a[k + b] = u - t;\n }\n\n z *= inverse ? InvZ[i] : Z[i];\n }\n }\n }\n\n public static void Convolusion(ref ModInt[] a, int lenA, ModInt[] b, int lenB)\n {\n int sz = lenA + lenB - 1;\n int len = 1;\n int lg = 0;\n while (len < sz)\n {\n len <<= 1;\n lg++;\n }\n\n Transform(a, lg, len, false);\n var tmpB = new ModInt[len];\n Array.Copy(b, tmpB, len);\n Transform(tmpB, lg, len, false);\n for (int i = 0; i < len; i++)\n {\n a[i] *= tmpB[i];\n }\n\n Transform(a, lg, len, true);\n for (int i = 0; i < sz; i++)\n {\n a[i] *= InvLen[lg];\n }\n }\n\n public static void Convolusion(ref ModInt[] a, int lenA)\n {\n int sz = lenA * 2 - 1;\n int len = 1;\n int lg = 0;\n while (len < sz)\n {\n len <<= 1;\n lg++;\n }\n\n Transform(a, lg, len, false);\n for (int i = 0; i < len; i++)\n {\n a[i] *= a[i];\n }\n\n Transform(a, lg, len, true);\n for (int i = 0; i < sz; i++)\n {\n a[i] *= InvLen[lg];\n }\n }\n\n private static int BitsReverse(int v, int lg)\n {\n if (v == 0) return v;\n int r = 0;\n if (lg % 2 == 1) r |= v & (1 << (lg / 2));\n for (int i = 0; i < lg / 2; i++)\n {\n r |= ((v >> i) & 1) << (lg - i - 1);\n r |= ((v >> (lg - i - 1)) & 1) << i;\n }\n\n return r;\n }\n}\n\n\n// https://bitbucket.org/camypaper/complib\nnamespace CompLib.Mathematics\n{\n #region ModInt\n\n /// \n /// [0,) \u307e\u3067\u306e\u5024\u3092\u53d6\u308b\u3088\u3046\u306a\u6570\n /// \n public struct ModInt\n {\n /// \n /// \u5270\u4f59\u3092\u53d6\u308b\u5024\uff0e\n /// \n public const long Mod = 998244353;\n\n /// \n /// \u5b9f\u969b\u306e\u6570\u5024\uff0e\n /// \n public long num;\n\n /// \n /// \u5024\u304c \u3067\u3042\u308b\u3088\u3046\u306a\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u3092\u69cb\u7bc9\u3057\u307e\u3059\uff0e\n /// \n /// \u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u304c\u6301\u3064\u5024\n /// \u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u306e\u554f\u984c\u4e0a\uff0c\u30b3\u30f3\u30b9\u30c8\u30e9\u30af\u30bf\u5185\u3067\u306f\u5270\u4f59\u3092\u53d6\u308a\u307e\u305b\u3093\uff0e\u305d\u306e\u305f\u3081\uff0c \u2208 [0,) \u3092\u6e80\u305f\u3059\u3088\u3046\u306a \u3092\u6e21\u3057\u3066\u304f\u3060\u3055\u3044\uff0e\u3053\u306e\u30b3\u30f3\u30b9\u30c8\u30e9\u30af\u30bf\u306f O(1) \u3067\u5b9f\u884c\u3055\u308c\u307e\u3059\uff0e\n public ModInt(long n)\n {\n num = n;\n }\n\n /// \n /// \u3053\u306e\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u306e\u6570\u5024\u3092\u6587\u5b57\u5217\u306b\u5909\u63db\u3057\u307e\u3059\uff0e\n /// \n /// [0,) \u306e\u7bc4\u56f2\u5185\u306e\u6574\u6570\u3092 10 \u9032\u8868\u8a18\u3057\u305f\u3082\u306e\uff0e\n public override string ToString()\n {\n return num.ToString();\n }\n\n public static ModInt operator +(ModInt l, ModInt r)\n {\n l.num += r.num;\n if (l.num >= Mod) l.num -= Mod;\n return l;\n }\n\n public static ModInt operator -(ModInt l, ModInt r)\n {\n l.num -= r.num;\n if (l.num < 0) l.num += Mod;\n return l;\n }\n\n public static ModInt operator *(ModInt l, ModInt r)\n {\n return new ModInt(l.num * r.num % Mod);\n }\n\n public static implicit operator ModInt(long n)\n {\n n %= Mod;\n if (n < 0) n += Mod;\n return new ModInt(n);\n }\n\n /// \n /// \u4e0e\u3048\u3089\u308c\u305f 2 \u3064\u306e\u6570\u5024\u304b\u3089\u3079\u304d\u5270\u4f59\u3092\u8a08\u7b97\u3057\u307e\u3059\uff0e\n /// \n /// \u3079\u304d\u4e57\u306e\u5e95\n /// \u3079\u304d\u6307\u6570\n /// \u7e70\u308a\u8fd4\u3057\u4e8c\u4e57\u6cd5\u306b\u3088\u308a O(N log N) \u3067\u5b9f\u884c\u3055\u308c\u307e\u3059\uff0e\n public static ModInt Pow(ModInt v, long k)\n {\n return Pow(v.num, k);\n }\n\n /// \n /// \u4e0e\u3048\u3089\u308c\u305f 2 \u3064\u306e\u6570\u5024\u304b\u3089\u3079\u304d\u5270\u4f59\u3092\u8a08\u7b97\u3057\u307e\u3059\uff0e\n /// \n /// \u3079\u304d\u4e57\u306e\u5e95\n /// \u3079\u304d\u6307\u6570\n /// \u7e70\u308a\u8fd4\u3057\u4e8c\u4e57\u6cd5\u306b\u3088\u308a O(N log N) \u3067\u5b9f\u884c\u3055\u308c\u307e\u3059\uff0e\n public static ModInt Pow(long v, long k)\n {\n long ret = 1;\n for (k %= Mod - 1; k > 0; k >>= 1, v = v * v % Mod)\n if ((k & 1) == 1)\n ret = ret * v % Mod;\n return new ModInt(ret);\n }\n\n /// \n /// \u4e0e\u3048\u3089\u308c\u305f\u6570\u306e\u9006\u5143\u3092\u8a08\u7b97\u3057\u307e\u3059\uff0e\n /// \n /// \u9006\u5143\u3092\u53d6\u308b\u5bfe\u8c61\u3068\u306a\u308b\u6570\n /// \u9006\u5143\u3068\u306a\u308b\u3088\u3046\u306a\u5024\n /// \u6cd5\u304c\u7d20\u6570\u3067\u3042\u308b\u3053\u3068\u3092\u4eee\u5b9a\u3057\u3066\uff0c\u30d5\u30a7\u30eb\u30de\u30fc\u306e\u5c0f\u5b9a\u7406\u306b\u5f93\u3063\u3066\u9006\u5143\u3092 O(log N) \u3067\u8a08\u7b97\u3057\u307e\u3059\uff0e\n public static ModInt Inverse(ModInt v)\n {\n return Pow(v, Mod - 2);\n }\n }\n\n #endregion\n\n #region Binomial Coefficient\n\n public class BinomialCoefficient\n {\n public ModInt[] fact, ifact;\n\n public BinomialCoefficient(int n)\n {\n fact = new ModInt[n + 1];\n ifact = new ModInt[n + 1];\n fact[0] = 1;\n for (int i = 1; i <= n; i++)\n fact[i] = fact[i - 1] * i;\n ifact[n] = ModInt.Inverse(fact[n]);\n for (int i = n - 1; i >= 0; i--)\n ifact[i] = ifact[i + 1] * (i + 1);\n ifact[0] = ifact[1];\n }\n\n public ModInt this[int n, int r]\n {\n get\n {\n if (n < 0 || n >= fact.Length || r < 0 || r > n) return 0;\n return fact[n] * ifact[n - r] * ifact[r];\n }\n }\n\n public ModInt RepeatedCombination(int n, int k)\n {\n if (k == 0) return 1;\n return this[n + k - 1, k];\n }\n }\n\n #endregion\n}\n\nnamespace CompLib.Util\n{\n using System;\n using System.Linq;\n\n class Scanner\n {\n private string[] _line;\n private int _index;\n private const char Separator = ' ';\n\n public Scanner()\n {\n _line = new string[0];\n _index = 0;\n }\n\n public string Next()\n {\n if (_index >= _line.Length)\n {\n string s = Console.ReadLine();\n while (s.Length == 0)\n {\n s = Console.ReadLine();\n }\n\n _line = s.Split(Separator);\n _index = 0;\n }\n\n return _line[_index++];\n }\n\n public int NextInt() => int.Parse(Next());\n public long NextLong() => long.Parse(Next());\n public double NextDouble() => double.Parse(Next());\n public decimal NextDecimal() => decimal.Parse(Next());\n public char NextChar() => Next()[0];\n public char[] NextCharArray() => Next().ToCharArray();\n\n public string[] Array()\n {\n string s = Console.ReadLine();\n _line = s.Length == 0 ? new string[0] : s.Split(Separator);\n _index = _line.Length;\n return _line;\n }\n\n public int[] IntArray() => Array().Select(int.Parse).ToArray();\n public long[] LongArray() => Array().Select(long.Parse).ToArray();\n public double[] DoubleArray() => Array().Select(double.Parse).ToArray();\n public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();\n }\n}", "lang_cluster": "C#", "tags": ["divide and conquer", "dp", "fft"], "code_uid": "1121cc1bb53bbd60804a86fd908ff56e", "src_uid": "279f1f7d250a4be6406c6c7bfc818bbf", "difficulty": 2400.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Diagnostics;\nusing CompLib.Mathematics;\nusing CompLib.Util;\n\npublic class Program\n{\n private const int MaxLg = 20;\n\n\n private int N, K;\n\n public void Solve()\n {\n var sc = new Scanner();\n N = sc.NextInt();\n K = sc.NextInt();\n\n ModInt[] a = new ModInt[1 << MaxLg];\n a[0] = 1;\n\n ModInt[] b = new ModInt[1 << MaxLg];\n int min = int.MaxValue;\n int max = int.MinValue;\n for (int i = 0; i < K; i++)\n {\n int d = sc.NextInt();\n min = Math.Min(min, d);\n max = Math.Max(max, d);\n b[d] = 1;\n }\n\n int lenA = 1;\n int lenB = max + 1;\n\n int h = N / 2;\n int tmp = h;\n while (tmp > 0)\n {\n if ((tmp & 1) > 0)\n {\n FFT.Convolusion(ref a, lenA, b, lenB);\n lenA = lenA + lenB - 1;\n }\n\n if (tmp > 1)\n {\n FFT.Convolusion(ref b, lenB);\n lenB = lenB + lenB - 1;\n }\n\n tmp /= 2;\n }\n\n ModInt ans = 0;\n for (int i = min * h; i <= max * h; i++)\n {\n ans += a[i] * a[i];\n }\n\n Console.WriteLine(ans);\n }\n\n\n public static void Main(string[] args) => new Program().Solve();\n}\n\nstatic class FFT\n{\n private const int E = 23;\n private const int MaxLg = 20;\n private static readonly ModInt O = 31;\n\n private static readonly ModInt[] Z, InvZ;\n\n private static readonly List<(int f, int t)>[] Rev;\n private static readonly ModInt[] InvLen;\n\n static FFT()\n {\n Z = new ModInt[E + 1];\n InvZ = new ModInt[E + 1];\n Z[E] = O;\n InvZ[E] = ModInt.Inverse(O);\n\n for (int i = E - 1; i >= 0; i--)\n {\n Z[i] = Z[i + 1] * Z[i + 1];\n InvZ[i] = InvZ[i + 1] * InvZ[i + 1];\n }\n\n Rev = new List<(int f, int t)>[MaxLg + 1];\n for (int i = 0; i <= MaxLg; i++)\n {\n int len = 1 << i;\n Rev[i] = new List<(int f, int t)>();\n for (int j = 0; j < len; j++)\n {\n int r = BitsReverse(j, i);\n if (j < r) Rev[i].Add((j, r));\n }\n }\n\n InvLen = new ModInt[MaxLg + 1];\n for (int i = 0; i <= MaxLg; i++)\n {\n InvLen[i] = ModInt.Inverse(1 << i);\n }\n }\n\n public static void Transform(ModInt[] a, int lg, int len, bool inverse)\n {\n foreach (var pair in Rev[lg])\n {\n var t = a[pair.f];\n a[pair.f] = a[pair.t];\n a[pair.t] = t;\n }\n\n for (int i = 1; i <= lg; i++)\n {\n int b = 1 << (i - 1);\n ModInt z = 1;\n for (int j = 0; j < b; j++)\n {\n for (int k = j; k < len; k += (b << 1))\n {\n var t = z * a[k + b];\n var u = a[k];\n a[k] = u + t;\n a[k + b] = u - t;\n }\n\n z *= inverse ? InvZ[i] : Z[i];\n }\n }\n }\n\n public static void Convolusion(ref ModInt[] a, int lenA, ModInt[] b, int lenB)\n {\n int sz = lenA + lenB - 1;\n int len = 1;\n int lg = 0;\n while (len < sz)\n {\n len <<= 1;\n lg++;\n }\n\n Transform(a, lg, len, false);\n var tmpB = new ModInt[len];\n Array.Copy(b, tmpB, len);\n Transform(tmpB, lg, len, false);\n for (int i = 0; i < len; i++)\n {\n a[i] *= tmpB[i];\n }\n\n Transform(a, lg, len, true);\n for (int i = 0; i < sz; i++)\n {\n a[i] *= InvLen[lg];\n }\n }\n\n public static void Convolusion(ref ModInt[] a, int lenA)\n {\n int sz = lenA * 2 - 1;\n int len = 1;\n int lg = 0;\n while (len < sz)\n {\n len <<= 1;\n lg++;\n }\n\n Transform(a, lg, len, false);\n for (int i = 0; i < len; i++)\n {\n a[i] *= a[i];\n }\n\n Transform(a, lg, len, true);\n for (int i = 0; i < sz; i++)\n {\n a[i] *= InvLen[lg];\n }\n }\n\n private static int BitsReverse(int v, int lg)\n {\n if (v == 0) return v;\n int r = 0;\n if (lg % 2 == 1) r |= v & (1 << (lg / 2));\n for (int i = 0; i < lg / 2; i++)\n {\n r |= ((v >> i) & 1) << (lg - i - 1);\n r |= ((v >> (lg - i - 1)) & 1) << i;\n }\n\n return r;\n }\n}\n\n\n// https://bitbucket.org/camypaper/complib\nnamespace CompLib.Mathematics\n{\n #region ModInt\n\n /// \n /// [0,) \u307e\u3067\u306e\u5024\u3092\u53d6\u308b\u3088\u3046\u306a\u6570\n /// \n public struct ModInt\n {\n /// \n /// \u5270\u4f59\u3092\u53d6\u308b\u5024\uff0e\n /// \n public const long Mod = 998244353;\n\n /// \n /// \u5b9f\u969b\u306e\u6570\u5024\uff0e\n /// \n public long num;\n\n /// \n /// \u5024\u304c \u3067\u3042\u308b\u3088\u3046\u306a\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u3092\u69cb\u7bc9\u3057\u307e\u3059\uff0e\n /// \n /// \u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u304c\u6301\u3064\u5024\n /// \u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u306e\u554f\u984c\u4e0a\uff0c\u30b3\u30f3\u30b9\u30c8\u30e9\u30af\u30bf\u5185\u3067\u306f\u5270\u4f59\u3092\u53d6\u308a\u307e\u305b\u3093\uff0e\u305d\u306e\u305f\u3081\uff0c \u2208 [0,) \u3092\u6e80\u305f\u3059\u3088\u3046\u306a \u3092\u6e21\u3057\u3066\u304f\u3060\u3055\u3044\uff0e\u3053\u306e\u30b3\u30f3\u30b9\u30c8\u30e9\u30af\u30bf\u306f O(1) \u3067\u5b9f\u884c\u3055\u308c\u307e\u3059\uff0e\n public ModInt(long n)\n {\n num = n;\n }\n\n /// \n /// \u3053\u306e\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u306e\u6570\u5024\u3092\u6587\u5b57\u5217\u306b\u5909\u63db\u3057\u307e\u3059\uff0e\n /// \n /// [0,) \u306e\u7bc4\u56f2\u5185\u306e\u6574\u6570\u3092 10 \u9032\u8868\u8a18\u3057\u305f\u3082\u306e\uff0e\n public override string ToString()\n {\n return num.ToString();\n }\n\n public static ModInt operator +(ModInt l, ModInt r)\n {\n l.num += r.num;\n if (l.num >= Mod) l.num -= Mod;\n return l;\n }\n\n public static ModInt operator -(ModInt l, ModInt r)\n {\n l.num -= r.num;\n if (l.num < 0) l.num += Mod;\n return l;\n }\n\n public static ModInt operator *(ModInt l, ModInt r)\n {\n return new ModInt(l.num * r.num % Mod);\n }\n\n public static implicit operator ModInt(long n)\n {\n n %= Mod;\n if (n < 0) n += Mod;\n return new ModInt(n);\n }\n\n /// \n /// \u4e0e\u3048\u3089\u308c\u305f 2 \u3064\u306e\u6570\u5024\u304b\u3089\u3079\u304d\u5270\u4f59\u3092\u8a08\u7b97\u3057\u307e\u3059\uff0e\n /// \n /// \u3079\u304d\u4e57\u306e\u5e95\n /// \u3079\u304d\u6307\u6570\n /// \u7e70\u308a\u8fd4\u3057\u4e8c\u4e57\u6cd5\u306b\u3088\u308a O(N log N) \u3067\u5b9f\u884c\u3055\u308c\u307e\u3059\uff0e\n public static ModInt Pow(ModInt v, long k)\n {\n return Pow(v.num, k);\n }\n\n /// \n /// \u4e0e\u3048\u3089\u308c\u305f 2 \u3064\u306e\u6570\u5024\u304b\u3089\u3079\u304d\u5270\u4f59\u3092\u8a08\u7b97\u3057\u307e\u3059\uff0e\n /// \n /// \u3079\u304d\u4e57\u306e\u5e95\n /// \u3079\u304d\u6307\u6570\n /// \u7e70\u308a\u8fd4\u3057\u4e8c\u4e57\u6cd5\u306b\u3088\u308a O(N log N) \u3067\u5b9f\u884c\u3055\u308c\u307e\u3059\uff0e\n public static ModInt Pow(long v, long k)\n {\n long ret = 1;\n for (k %= Mod - 1; k > 0; k >>= 1, v = v * v % Mod)\n if ((k & 1) == 1)\n ret = ret * v % Mod;\n return new ModInt(ret);\n }\n\n /// \n /// \u4e0e\u3048\u3089\u308c\u305f\u6570\u306e\u9006\u5143\u3092\u8a08\u7b97\u3057\u307e\u3059\uff0e\n /// \n /// \u9006\u5143\u3092\u53d6\u308b\u5bfe\u8c61\u3068\u306a\u308b\u6570\n /// \u9006\u5143\u3068\u306a\u308b\u3088\u3046\u306a\u5024\n /// \u6cd5\u304c\u7d20\u6570\u3067\u3042\u308b\u3053\u3068\u3092\u4eee\u5b9a\u3057\u3066\uff0c\u30d5\u30a7\u30eb\u30de\u30fc\u306e\u5c0f\u5b9a\u7406\u306b\u5f93\u3063\u3066\u9006\u5143\u3092 O(log N) \u3067\u8a08\u7b97\u3057\u307e\u3059\uff0e\n public static ModInt Inverse(ModInt v)\n {\n return Pow(v, Mod - 2);\n }\n }\n\n #endregion\n\n #region Binomial Coefficient\n\n public class BinomialCoefficient\n {\n public ModInt[] fact, ifact;\n\n public BinomialCoefficient(int n)\n {\n fact = new ModInt[n + 1];\n ifact = new ModInt[n + 1];\n fact[0] = 1;\n for (int i = 1; i <= n; i++)\n fact[i] = fact[i - 1] * i;\n ifact[n] = ModInt.Inverse(fact[n]);\n for (int i = n - 1; i >= 0; i--)\n ifact[i] = ifact[i + 1] * (i + 1);\n ifact[0] = ifact[1];\n }\n\n public ModInt this[int n, int r]\n {\n get\n {\n if (n < 0 || n >= fact.Length || r < 0 || r > n) return 0;\n return fact[n] * ifact[n - r] * ifact[r];\n }\n }\n\n public ModInt RepeatedCombination(int n, int k)\n {\n if (k == 0) return 1;\n return this[n + k - 1, k];\n }\n }\n\n #endregion\n}\n\nnamespace CompLib.Util\n{\n using System;\n using System.Linq;\n\n class Scanner\n {\n private string[] _line;\n private int _index;\n private const char Separator = ' ';\n\n public Scanner()\n {\n _line = new string[0];\n _index = 0;\n }\n\n public string Next()\n {\n if (_index >= _line.Length)\n {\n string s = Console.ReadLine();\n while (s.Length == 0)\n {\n s = Console.ReadLine();\n }\n\n _line = s.Split(Separator);\n _index = 0;\n }\n\n return _line[_index++];\n }\n\n public int NextInt() => int.Parse(Next());\n public long NextLong() => long.Parse(Next());\n public double NextDouble() => double.Parse(Next());\n public decimal NextDecimal() => decimal.Parse(Next());\n public char NextChar() => Next()[0];\n public char[] NextCharArray() => Next().ToCharArray();\n\n public string[] Array()\n {\n string s = Console.ReadLine();\n _line = s.Length == 0 ? new string[0] : s.Split(Separator);\n _index = _line.Length;\n return _line;\n }\n\n public int[] IntArray() => Array().Select(int.Parse).ToArray();\n public long[] LongArray() => Array().Select(long.Parse).ToArray();\n public double[] DoubleArray() => Array().Select(double.Parse).ToArray();\n public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();\n }\n}", "lang_cluster": "C#", "tags": ["divide and conquer", "dp", "fft"], "code_uid": "0ebe6a0ba9b57ea32ad356bd0b9f0801", "src_uid": "279f1f7d250a4be6406c6c7bfc818bbf", "difficulty": 2400.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing Math = System.Math;\nusing Dec = System.Decimal;\nusing System.Globalization;\nusing System.Linq;\n\nnamespace taskA\n{\n\tclass newDecimal {\n\tprivate \n\t\t\tInt64 Z, F, kol;\n\tpublic newDecimal(decimal t, Int64 Kol) {\n\t\t\tkol = Kol;\n\t\t\tZ = Dec.ToInt64 (t);\n\t\t\tInt64 p = 1;\n\t\t\tfor (int i = 0; i < kol; i ++)\n\t\t\t\tp *= 10L;\t\t\n\t\t\tF = Dec.ToInt64 ((t - Z) * p);\n\t\t}\n\t\tpublic void print () {\n\t\t\tConsole.Write (\"{0}.\", Z);\n\t\t\tint sz = F.ToString ().Length;\n\t\t\tfor (int i = 0; i < kol - sz; i ++) \n\t\t\t\tConsole.Write (0);\n\t\t\tConsole.Write (F);\n\t\t}\n\t}\n\n\tclass MainClass\n\t{\n\t\tpublic static long[,] C = new long[800, 10];\n\n\t\tpublic static void PreCalc() {\n\t\t\tC [1,1] = 1L;\n\t\t\tC [2,1] = 2L;\n\t\t\tC [2,2] = 1L;\n\t\t\tfor (int i = 3; i <= 777; i ++) C[i,1] = 1L*i;\n\t\t\tfor (int i = 3; i <= 777; i ++)\n\t\t\t\tfor (int j = 2; j <= 7; j ++) \n\t\t\t\t\tC [i,j] = C [i - 1,j] + C [i - 1,j - 1];\n\t\t}\n\n\t\tpublic static void Main(string[] args) {\n\t\t\tPreCalc ();\n\t\t\tint n = int.Parse (Console.ReadLine ());\n\t\t\tlong ans = 0l;\n\n\t\t\tans += 4l * 3l * 2l * (1l << ((n - 3) << 1));\n\t\t\tif (n >= 4)\n\t\t\t\tans += 3L * 3L * (n - 3L) * (1L << (2 * (n - 3)));\n\t\t\tConsole.WriteLine (ans);\n\t\t}\n\t}\n}\n", "lang_cluster": "C#", "tags": ["math", "combinatorics"], "code_uid": "022e3ea932d4b35763e740c9803d0a02", "src_uid": "3b02cbb38d0b4ddc1a6467f7647d53a9", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Collections;\nusing System.Text;\n\nnamespace codeforces\n{\n public class Program\n {\n private static void Main(string[] args)\n {\n ulong result = 0;\n int n = Convert.ToInt32(Console.ReadLine());\n int m = 2 * n - 2;\n for (int i = 0; i < m - n + 1; ++i)\n {\n int l = i;\n int r = i + n;\n ulong value = 4ul * (l == 0 ? 1ul : 3ul) * (r == m ? 1ul : 3ul);\n int cnt = m - n - (l == 0 ? 0 : 1) - (r == m ? 0 : 1);\n while (cnt > 0)\n {\n value *= 4ul;\n cnt--;\n }\n result += value;\n }\n Console.WriteLine(result);\n }\n }\n}", "lang_cluster": "C#", "tags": ["math", "combinatorics"], "code_uid": "c062fa807ee0b50a3199aac117ae5a6d", "src_uid": "3b02cbb38d0b4ddc1a6467f7647d53a9", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": ".NET Core C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing CompLib.Util;\nusing System.Threading;\n\npublic class Program\n{\n private long N, K;\n\n public void Solve()\n {\n var sc = new Scanner();\n N = sc.NextLong();\n K = sc.NextLong();\n\n /*\n * f(x) = x/2 if x is even\n * = x-1 otherwise\n *\n *\n * y \u5076\u6570 \u4e0a\u4f4d\u6841 y, y+1\u306b\u4e00\u81f4\n *\n * \u5947\u6570 y\u306b\u4e00\u81f4\n */\n\n // \u6700\u5927\u5019\u88dc\n\n // \u5076\u6570\u306b\u306a\u308b\u307e\u3067 (N/(2^i),(N/2^i)-1)\n\n List x = new List();\n\n long tmpX = N;\n while (tmpX > 0)\n {\n if (tmpX % 2 == 1)\n {\n x.Add(tmpX);\n if (tmpX - 1 > 0)\n x.Add(tmpX - 1);\n tmpX /= 2;\n }\n else\n {\n x.Add(tmpX);\n if (tmpX - 2 > 0)\n x.Add(tmpX - 2);\n tmpX /= 2;\n if (tmpX % 2 == 1 && tmpX > 1) tmpX--;\n }\n }\n\n foreach (long l in x)\n {\n if (Calc(l) >= K)\n {\n Console.WriteLine(l);\n return;\n }\n }\n }\n\n long Calc(long x)\n {\n long ans = 0;\n long tmpX = x;\n long p = 1;\n while (tmpX <= N)\n {\n ans += Math.Min(p, N - tmpX + 1);\n p *= 2;\n tmpX *= 2;\n }\n\n if (x % 2 == 0)\n {\n tmpX = x + 1;\n p = 1;\n while (tmpX <= N)\n {\n ans += Math.Min(p, N - tmpX + 1);\n p *= 2;\n tmpX *= 2;\n }\n }\n\n return ans;\n }\n\n public static void Main(string[] args) => new Program().Solve();\n // public static void Main(string[] args) => new Thread(new Program().Solve, 1 << 27).Start();\n}\n\nnamespace CompLib.Util\n{\n using System;\n using System.Linq;\n\n class Scanner\n {\n private string[] _line;\n private int _index;\n private const char Separator = ' ';\n\n public Scanner()\n {\n _line = new string[0];\n _index = 0;\n }\n\n public string Next()\n {\n if (_index >= _line.Length)\n {\n string s;\n do\n {\n s = Console.ReadLine();\n } while (s.Length == 0);\n\n _line = s.Split(Separator);\n _index = 0;\n }\n\n return _line[_index++];\n }\n\n public string ReadLine()\n {\n _index = _line.Length;\n return Console.ReadLine();\n }\n\n public int NextInt() => int.Parse(Next());\n public long NextLong() => long.Parse(Next());\n public double NextDouble() => double.Parse(Next());\n public decimal NextDecimal() => decimal.Parse(Next());\n public char NextChar() => Next()[0];\n public char[] NextCharArray() => Next().ToCharArray();\n\n public string[] Array()\n {\n string s = Console.ReadLine();\n _line = s.Length == 0 ? new string[0] : s.Split(Separator);\n _index = _line.Length;\n return _line;\n }\n\n public int[] IntArray() => Array().Select(int.Parse).ToArray();\n public long[] LongArray() => Array().Select(long.Parse).ToArray();\n public double[] DoubleArray() => Array().Select(double.Parse).ToArray();\n public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();\n }\n}", "lang_cluster": "C#", "tags": ["math", "binary search", "dp", "combinatorics"], "code_uid": "123529ff89e76e7bcd0941e6c57f28f1", "src_uid": "783c4b3179c558369f94f4a16ac562d4", "difficulty": 2100.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Linq;\nusing System.Collections.Generic;\nusing System.Diagnostics;\nusing Debug = System.Diagnostics.Trace;\nusing SB = System.Text.StringBuilder;\nusing static System.Math;\nusing Number = System.Int32;\nusing System.Numerics;\n\nnamespace Program {\n\tpublic class Solver {\n\t\tRandom rnd = new Random();\n\t\tpublic void Solve() {\n\t\t\tvar n = rl; var k = rl;\n\t\t\tvar max = 1L;\n\t\t\t{\n\t\t\t\tvar l = 0L; var r = n * 2;\n\t\t\t\twhile (r - l > 2) {\n\t\t\t\t\tvar m = (l + r) / 2;\n\t\t\t\t\tif (m % 2 == 1) m--;\n\t\t\t\t\tif (f(m, n) + f(m + 1, n) >= k) l = m;\n\t\t\t\t\telse r = m;\n\t\t\t\t}\n\t\t\t\tmax = l;\n\t\t\t}\n\t\t\tDebug.WriteLine(max);\n\t\t\t{\n\t\t\t\tvar l = 1L; var r = n * 2 + 1;\n\t\t\t\twhile (r - l > 2) {\n\t\t\t\t\tvar m = (l + r) / 2;\n\t\t\t\t\tif (m % 2 == 0) m--;\n\t\t\t\t\tif (f(m, n) >= k) l = m;\n\t\t\t\t\telse r = m;\n\t\t\t\t}\n\t\t\t\tmax = Max(max, l);\n\t\t\t}\n\t\t\tConsole.WriteLine(max);\n\n\t\t}\n\t\tlong f(long n, long max) {\n\t\t\tif (n == 0) return 0;\n\t\t\tvar ini = n;\n\t\t\tvar ret = 0L;\n\t\t\tvar ma = 0L;\n\t\t\tfor (int i = 0; i < 60; i++) {\n\t\t\t\tif (max < n) break;\n\t\t\t\telse if (max >= n + ma) {\n\t\t\t\t\tret += ma + 1;\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tret += max - n + 1;\n\t\t\t\t}\n\t\t\t\tn *= 2;\n\t\t\t\tma = ma * 2 + 1;\n\t\t\t}\n\t\t\tDebug.WriteLine($\"f({ini},{max}) = {ret}\");\n\t\t\treturn ret;\n\t\t}\n\n\t\tconst long INF = 1L << 60;\n\t\tstatic int[] dx = { -1, 0, 1, 0 };\n\t\tstatic int[] dy = { 0, 1, 0, -1 };\n\t\tint ri { get { return sc.Integer(); } }\n\t\tlong rl { get { return sc.Long(); } }\n\t\tdouble rd { get { return sc.Double(); } }\n\t\tstring rs { get { return sc.Scan(); } }\n\t\tpublic IO.StreamScanner sc = new IO.StreamScanner(Console.OpenStandardInput());\n\n\t\tstatic T[] Enumerate(int n, Func f) {\n\t\t\tvar a = new T[n];\n\t\t\tfor (int i = 0; i < a.Length; ++i) a[i] = f(i);\n\t\t\treturn a;\n\t\t}\n\t\tstatic public void Swap(ref T a, ref T b) { var tmp = a; a = b; b = tmp; }\n\t}\n}\n\n#region main\nstatic class Ex {\n\tstatic public string AsString(this IEnumerable ie) { return new string(ie.ToArray()); }\n\tstatic public string AsJoinedString(this IEnumerable ie, string st = \" \") {\n\t\treturn string.Join(st, ie);\n\t}\n\tstatic public void Main() {\n\t\tConsole.SetOut(new Program.IO.Printer(Console.OpenStandardOutput()) { AutoFlush = true });\n\t\tvar solver = new Program.Solver();\n\t\t//* \n\t\tvar t = new System.Threading.Thread(solver.Solve, 50000000);\n\t\tt.Start();\n\t\tt.Join();\n\t\t//*/\n\t\t// solver.Solve();\n\t\tConsole.Out.Flush();\n\t}\n}\n#endregion\n#region Ex\nnamespace Program.IO {\n\tusing System.IO;\n\tusing System.Text;\n\tusing System.Globalization;\n\n\tpublic class Printer : StreamWriter {\n\t\tpublic override IFormatProvider FormatProvider { get { return CultureInfo.InvariantCulture; } }\n\t\tpublic Printer(Stream stream) : base(stream, new UTF8Encoding(false, true)) { }\n\t}\n\n\tpublic class StreamScanner {\n\t\tpublic StreamScanner(Stream stream) { str = stream; }\n\n\t\tpublic readonly Stream str;\n\t\tprivate readonly byte[] buf = new byte[1024];\n\t\tprivate int len, ptr;\n\t\tpublic bool isEof = false;\n\t\tpublic bool IsEndOfStream { get { return isEof; } }\n\n\t\tprivate byte read() {\n\t\t\tif (isEof) return 0;\n\t\t\tif (ptr >= len) {\n\t\t\t\tptr = 0;\n\t\t\t\tif ((len = str.Read(buf, 0, 1024)) <= 0) {\n\t\t\t\t\tisEof = true;\n\t\t\t\t\treturn 0;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn buf[ptr++];\n\t\t}\n\n\t\tpublic char Char() {\n\t\t\tbyte b = 0;\n\t\t\tdo b = read(); while ((b < 33 || 126 < b) && !isEof);\n\t\t\treturn (char)b;\n\t\t}\n\t\tpublic string Scan() {\n\t\t\tvar sb = new StringBuilder();\n\t\t\tfor (var b = Char(); b >= 33 && b <= 126; b = (char)read()) sb.Append(b);\n\t\t\treturn sb.ToString();\n\t\t}\n\t\tpublic string ScanLine() {\n\t\t\tvar sb = new StringBuilder();\n\t\t\tfor (var b = Char(); b != '\\n' && b != 0; b = (char)read()) if (b != '\\r') sb.Append(b);\n\t\t\treturn sb.ToString();\n\t\t}\n\t\tpublic long Long() { return isEof ? long.MinValue : long.Parse(Scan()); }\n\t\tpublic int Integer() { return isEof ? int.MinValue : int.Parse(Scan()); }\n\t\tpublic double Double() { return isEof ? double.NaN : double.Parse(Scan(), CultureInfo.InvariantCulture); }\n\t}\n}\n\n#endregion\n", "lang_cluster": "C#", "tags": ["math", "binary search", "dp", "combinatorics"], "code_uid": "9879e1702a08e00845d76dcc5bea9d15", "src_uid": "783c4b3179c558369f94f4a16ac562d4", "difficulty": 2100.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.IO;\nusing System.Text;\n\nnamespace Heidi_and_Library__easy_\n{\n internal class Program\n {\n private static readonly StreamReader reader = new StreamReader(Console.OpenStandardInput(1024*10), Encoding.ASCII, false, 1024*10);\n private static readonly StreamWriter writer = new StreamWriter(Console.OpenStandardOutput(1024*10), Encoding.ASCII, 1024*10);\n\n private static void Main(string[] args)\n {\n int n = Next();\n int k = Next();\n\n var nn = new int[n];\n for (int i = 0; i < n; i++)\n {\n nn[i] = Next();\n }\n\n var near = new int[n];\n var last = new int[n + 1];\n\n for (int i = 0; i < last.Length; i++)\n {\n last[i] = n;\n }\n\n for (int i = n - 1; i >= 0; i--)\n {\n near[i] = last[nn[i]];\n last[nn[i]] = i;\n }\n\n int count = 0;\n var heap = new MaxBinaryHeapObject(new Point());\n var f = new bool[n + 1];\n for (int i = 0; i < nn.Length; i++)\n {\n if (k <= 0 && !f[nn[i]])\n {\n remove:\n var t = heap.GetMax();\n if (!f[t.index])\n {\n goto remove;\n }\n\n f[t.index] = false;\n }\n\n if (!f[nn[i]])\n {\n count++;\n f[nn[i]] = true;\n k--;\n }\n heap.Add(new Point {index = nn[i], near = near[i]});\n }\n\n writer.WriteLine(count);\n writer.Flush();\n }\n\n\n private static int Next()\n {\n int c;\n int res = 0;\n do\n {\n c = reader.Read();\n if (c == -1)\n return res;\n } while (c < '0' || c > '9');\n res = c - '0';\n while (true)\n {\n c = reader.Read();\n if (c < '0' || c > '9')\n return res;\n res *= 10;\n res += c - '0';\n }\n }\n\n #region Nested type: MaxBinaryHeapObject\n\n public class MaxBinaryHeapObject\n {\n private readonly IComparer _comparer;\n private readonly List _list;\n\n public MaxBinaryHeapObject(IComparer comparer)\n {\n _comparer = comparer ?? Comparer.Default;\n _list = new List();\n }\n\n public int HeapSize\n {\n get { return _list.Count; }\n }\n\n public void Add(T value)\n {\n _list.Add(value);\n int i = HeapSize - 1;\n int parent = (i - 1)/2;\n\n while (i > 0 && _comparer.Compare(_list[parent], _list[i]) == -1)\n {\n T temp = _list[i];\n _list[i] = _list[parent];\n _list[parent] = temp;\n\n i = parent;\n parent = (i - 1)/2;\n }\n }\n\n public void Heapify(int i)\n {\n for (;;)\n {\n int leftChild = 2*i + 1;\n int rightChild = 2*i + 2;\n int largestChild = i;\n\n if (leftChild < HeapSize && _comparer.Compare(_list[leftChild], _list[largestChild]) == 1)\n {\n largestChild = leftChild;\n }\n\n if (rightChild < HeapSize && _comparer.Compare(_list[rightChild], _list[largestChild]) == 1)\n {\n largestChild = rightChild;\n }\n\n if (largestChild == i)\n {\n break;\n }\n\n T temp = _list[i];\n _list[i] = _list[largestChild];\n _list[largestChild] = temp;\n i = largestChild;\n }\n }\n\n public T Max()\n {\n return _list[0];\n }\n\n public T GetMax()\n {\n T result = _list[0];\n _list[0] = _list[HeapSize - 1];\n _list.RemoveAt(HeapSize - 1);\n Heapify(0);\n return result;\n }\n }\n\n #endregion\n\n #region Nested type: Point\n\n private class Point : IComparer\n {\n public int index;\n public int near;\n\n #region IComparer Members\n\n public int Compare(Point x, Point y)\n {\n return x.near.CompareTo(y.near);\n }\n\n #endregion\n }\n\n #endregion\n }\n}", "lang_cluster": "C#", "tags": ["greedy"], "code_uid": "3c29c4980d71ec28e85888372ec5a09a", "src_uid": "956228e31679caa9952b216e010f9773", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections;\nusing System.Collections.Generic;\nusing System.Diagnostics;\nusing System.IO;\nusing System.Linq;\n\nnamespace Codeforces\n{\n\tinternal class Template\n\t{\n\t\tprivate void Solve()\n\t\t{\n\t\t\tvar n = cin.NextInt();\n\t\t\tvar k = cin.NextInt();\n\t\t\tvar a = new int[n];\n\t\t\tvar pos = new Queue[n + 10];\n\t\t\tfor (var i = 0; i < pos.Length; i++)\n\t\t\t{\n\t\t\t\tpos[i] = new Queue();\n\t\t\t}\n\t\t\tfor (var i = 0; i < n; i++)\n\t\t\t{\n\t\t\t\ta[i] = cin.NextInt();\n\t\t\t\tpos[a[i]].Enqueue(i);\n\t\t\t}\n\t\t\tvar have = new HashSet();\n\t\t\tvar timesNeeded = new SortedDictionary();\n\t\t\tvar res = 0;\n\t\t\tfor (var i = 0; i < a.Length; i++)\n\t\t\t{\n\t\t\t\tif (!have.Contains(a[i]))\n\t\t\t\t{\n\t\t\t\t\tif (have.Count == k)\n\t\t\t\t\t{\n\t\t\t\t\t\tvar first = timesNeeded.First();\n\t\t\t\t\t\ttimesNeeded.Remove(first.Key);\n\t\t\t\t\t\thave.Remove(first.Value);\n\t\t\t\t\t}\n\t\t\t\t\thave.Add(a[i]);\n\t\t\t\t\tif (i != pos[a[i]].Peek())\n\t\t\t\t\t{\n\t\t\t\t\t\tthrow new AccessViolationException();\n\t\t\t\t\t}\n\t\t\t\t\tpos[a[i]].Dequeue();\n\t\t\t\t\tif (!pos[a[i]].Any())\n\t\t\t\t\t{\n\t\t\t\t\t\ttimesNeeded.Add(-1000000000 + i, a[i]);\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\ttimesNeeded.Add(-pos[a[i]].Peek(), a[i]);\n\t\t\t\t\t}\n\t\t\t\t\tres++;\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tvar p = pos[a[i]].Dequeue();\n\t\t\t\t\ttimesNeeded.Remove(-p);\n\t\t\t\t\tif (!pos[a[i]].Any())\n\t\t\t\t\t{\n\t\t\t\t\t\ttimesNeeded.Add(-1000000000 + i, a[i]);\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\ttimesNeeded.Add(-pos[a[i]].Peek(), a[i]);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tConsole.WriteLine(res);\n\t\t}\n\n\t\tprivate static readonly Scanner cin = new Scanner();\n\n\t\tprivate static void Main()\n\t\t{\n#if DEBUG\n\t\t\tvar inputText = File.ReadAllText(@\"..\\..\\input.txt\");\n\t\t\tvar testCases = inputText.Split(new[] { \"input\" }, StringSplitOptions.RemoveEmptyEntries);\n\t\t\tvar consoleOut = Console.Out;\n\t\t\tfor (var i = 0; i < testCases.Length; i++)\n\t\t\t{\n\t\t\t\tvar parts = testCases[i].Split(new[] { \"output\" }, StringSplitOptions.RemoveEmptyEntries);\n\t\t\t\tConsole.SetIn(new StringReader(parts[0].Trim()));\n\t\t\t\tvar stringWriter = new StringWriter();\n\t\t\t\tConsole.SetOut(stringWriter);\n\t\t\t\tvar sw = Stopwatch.StartNew();\n\t\t\t\tnew Template().Solve();\n\t\t\t\tsw.Stop();\n\t\t\t\tvar output = stringWriter.ToString();\n\n\t\t\t\tConsole.SetOut(consoleOut);\n\t\t\t\tvar color = ConsoleColor.Green;\n\t\t\t\tvar status = \"Passed\";\n\t\t\t\tif (parts[1].Trim() != output.Trim())\n\t\t\t\t{\n\t\t\t\t\tcolor = ConsoleColor.Red;\n\t\t\t\t\tstatus = \"Failed\";\n\t\t\t\t}\n\t\t\t\tConsole.ForegroundColor = color;\n\t\t\t\tConsole.WriteLine(\"Test {0} {1} in {2}ms\", i + 1, status, sw.ElapsedMilliseconds);\n\t\t\t}\n\t\t\tConsole.ReadLine();\n\t\t\tConsole.ReadKey();\n#else\n\t\t\tnew Template().Solve();\n\t\t\tConsole.ReadLine();\n#endif\n\t\t}\n\t}\n\n\tinternal class Scanner\n\t{\n\t\tprivate string[] s = new string[0];\n\t\tprivate int i;\n\t\tprivate readonly char[] cs = { ' ' };\n\n\t\tpublic string NextString()\n\t\t{\n\t\t\tif (i < s.Length) return s[i++];\n\t\t\tvar line = Console.ReadLine() ?? string.Empty;\n\t\t\ts = line.Split(cs, StringSplitOptions.RemoveEmptyEntries);\n\t\t\ti = 1;\n\t\t\treturn s.First();\n\t\t}\n\n\t\tpublic double NextDouble()\n\t\t{\n\t\t\treturn double.Parse(NextString());\n\t\t}\n\n\t\tpublic int NextInt()\n\t\t{\n\t\t\treturn int.Parse(NextString());\n\t\t}\n\n\t\tpublic long NextLong()\n\t\t{\n\t\t\treturn long.Parse(NextString());\n\t\t}\n\t}\n}", "lang_cluster": "C#", "tags": ["greedy"], "code_uid": "e123874e7144e8db5b6afd5066fc331a", "src_uid": "956228e31679caa9952b216e010f9773", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\n\nclass _1177B\n{\n\tstatic void Main()\n\t{\n\t\tlong k = long.Parse(Console.ReadLine());\n\n\t\tlong start = 0;\n\t\tlong cnt = 9;\n\t\tint digit = 1;\n\t\twhile (k > start)\n\t\t{\n\t\t\tstart += cnt * digit++;\n\t\t\tcnt *= 10;\n\t\t}\n\t\tstart -= (cnt / 10) * --digit;\n\t\tlong posFromStart = k - start;\n\t\tlong numFromStart = (long)Math.Ceiling((double)posFromStart / digit);\n\t\tlong cntBefore = (long)Math.Pow(10, digit - 1) - 1;\n\t\tlong num = numFromStart + cntBefore;\n\t\tint posDigit = (int)(posFromStart % digit);\n\t\tposDigit = (posDigit == 0 ? digit : posDigit) - 1;\n\t\tConsole.WriteLine(num.ToString()[posDigit]);\n\t}\n}", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "e9edc9396d49ab6a0586afb0e034c41c", "src_uid": "1503d761dd4e129fb7c423da390544ff", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace CF2\n{\n class Program\n {\n static void Main(string[] args)\n {\n string s = \"\";\n for (int i = 1; i < 10000; i++)\n {\n s += Convert.ToString(i);\n }\n int k = Convert.ToInt32(Console.ReadLine());\n Console.WriteLine(s[k - 1]);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "959e7479ae08882af4d07aa9d12210f5", "src_uid": "1503d761dd4e129fb7c423da390544ff", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Text;\nusing System.IO;\n\nnamespace Task\n{\n class MyIo\n {\n char[] separators = new char[] { ' ', '\\t' };\n\n#if TEST\n TextReader inputStream = new StreamReader(\"..\\\\..\\\\input.txt\");\n#else\n TextReader inputStream = System.Console.In;\n#endif\n TextWriter outputStream = Console.Out;\n\n string[] tokens;\n int pointer;\n\n public string NextLine()\n {\n try\n {\n return inputStream.ReadLine();\n }\n catch (IOException)\n {\n return null;\n }\n }\n\n public string NextString()\n {\n try\n {\n while (tokens == null || pointer >= tokens.Length)\n {\n tokens = NextLine().Split(separators, StringSplitOptions.RemoveEmptyEntries);\n pointer = 0;\n }\n return tokens[pointer++];\n }\n catch (IOException)\n {\n return null;\n }\n }\n\n public int NextInt()\n {\n return int.Parse(NextString());\n }\n\n public long NextLong()\n {\n return long.Parse(NextString());\n }\n\n public void Print(string format, params object[] args)\n {\n outputStream.Write(format, args);\n }\n\n public void PrintLine(string format, params object[] args)\n {\n outputStream.WriteLine(format, args);\n }\n\n public void Print(T o)\n {\n outputStream.Write(o);\n }\n\n public void PrintLine(T o)\n {\n outputStream.WriteLine(o);\n }\n\n public void Close()\n {\n inputStream.Close();\n outputStream.Close();\n }\n }\n\n\n\n class Program\n {\n MyIo io = new MyIo();\n\n enum State\n {\n Empty = 0,\n OwnerOnly = 1,\n WithGuest = 2\n }\n\n int R, C;\n\n State[,] map;\n\n Dictionary memo;\n\n long makeConfig(int r, int c)\n {\n long cfg = 0;\n int lowR = Math.Max(0, r - 1);\n int highR = Math.Min(R - 1, r + 1);\n\n int abs = r * C + c;\n\n int lowAbs = Math.Max(0, abs - C);\n int highAbs = Math.Min(R * C - 1, abs + C);\n\n for (int curAbs = lowAbs; curAbs <= highAbs; curAbs++)\n {\n int curR = curAbs / C;\n int curC = curAbs % C;\n\n cfg <<= 2;\n cfg |= (uint)map[curR, curC];\n }\n cfg <<= 6;\n cfg |= (uint)r;\n cfg <<= 6;\n cfg |= (uint)c;\n\n return cfg;\n }\n\n int[][] dirs = new int[][]\n {\n new int[] {0, -1},\n new int[] {0, 1},\n new int[] {1, 0},\n new int[] {-1, 0}\n };\n\n int xfx(int r, int c)\n {\n if (r == R)\n {\n return 0;\n }\n if (c == C)\n {\n return xfx(r + 1, 0);\n }\n\n long cfg = makeConfig(r, c);\n if (memo.ContainsKey(cfg))\n {\n return memo[cfg];\n }\n\n if (map[r, c] == State.Empty)\n {\n return xfx(r, c + 1);\n }\n\n if (map[r, c] == State.WithGuest)\n {\n return xfx(r, c + 1);\n }\n\n int ans = xfx(r, c + 1); // no move\n\n map[r, c] = State.Empty;\n\n foreach (int[] d in dirs)\n {\n int nR = r + d[0];\n int nC = c + d[1];\n\n if (nR >= 0 && nR < R && nC >= 0 && nC < C)\n {\n var oldState = map[nR, nC];\n int curAns = oldState == State.Empty ? 0 : 1;\n\n map[nR, nC] = State.WithGuest;\n \n curAns += xfx(r, c + 1);\n map[nR, nC] = oldState;\n\n ans = Math.Max(ans, curAns);\n }\n }\n\n map[r, c] = State.OwnerOnly;\n\n memo[cfg] = ans;\n\n return ans;\n }\n\n void Solve()\n {\n memo = new Dictionary();\n\n R = io.NextInt();\n C = io.NextInt();\n\n if (C > R)\n {\n R += C;\n C = R - C;\n R = R - C;\n }\n\n map = new State[R, C];\n\n for (int r = 0; r < R; r++)\n {\n for (int c = 0; c < C; c++)\n {\n map[r, c] = State.OwnerOnly;\n }\n }\n\n int ans = xfx(0, 0);\n io.Print(ans);\n }\n\n static void Main(string[] args)\n {\n var p = new Program();\n p.Solve();\n p.io.Close();\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["dsu", "dp", "bitmasks"], "code_uid": "06536ac7d7cba5c91212fa78cfd59bae", "src_uid": "097674b4dd696b30e102938f71dd39b9", "difficulty": 2100.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Text;\nusing System.IO;\n\nnamespace Task\n{\n class MyIo\n {\n char[] separators = new char[] { ' ', '\\t' };\n\n#if TEST\n TextReader inputStream = new StreamReader(\"..\\\\..\\\\input.txt\");\n#else\n TextReader inputStream = System.Console.In;\n#endif\n TextWriter outputStream = Console.Out;\n\n string[] tokens;\n int pointer;\n\n public string NextLine()\n {\n try\n {\n return inputStream.ReadLine();\n }\n catch (IOException)\n {\n return null;\n }\n }\n\n public string NextString()\n {\n try\n {\n while (tokens == null || pointer >= tokens.Length)\n {\n tokens = NextLine().Split(separators, StringSplitOptions.RemoveEmptyEntries);\n pointer = 0;\n }\n return tokens[pointer++];\n }\n catch (IOException)\n {\n return null;\n }\n }\n\n public int NextInt()\n {\n return int.Parse(NextString());\n }\n\n public long NextLong()\n {\n return long.Parse(NextString());\n }\n\n public void Print(string format, params object[] args)\n {\n outputStream.Write(format, args);\n }\n\n public void PrintLine(string format, params object[] args)\n {\n outputStream.WriteLine(format, args);\n }\n\n public void Print(T o)\n {\n outputStream.Write(o);\n }\n\n public void PrintLine(T o)\n {\n outputStream.WriteLine(o);\n }\n\n public void Close()\n {\n inputStream.Close();\n outputStream.Close();\n }\n }\n\n\n\n class Program\n {\n MyIo io = new MyIo();\n\n enum State\n {\n Empty = 0,\n OwnerOnly = 1,\n WithGuest = 2\n }\n\n int R, C;\n\n State[,] map;\n\n Dictionary memo = new Dictionary();\n\n long makeConfig(int r, int c)\n {\n long cfg = (r << 6) | c;\n int lowR = Math.Max(0, r - 1);\n int highR = Math.Min(R - 1, r + 1);\n for (int curR = lowR; curR <= highR; curR++)\n {\n for (int curC = 0; curC < C; curC++)\n {\n cfg <<= 2;\n cfg |= (uint)map[curR, curC];\n }\n }\n return cfg;\n }\n\n int[][] dirs = new int[][]\n {\n new int[] {0, -1},\n new int[] {0, 1},\n new int[] {1, 0},\n new int[] {-1, 0}\n };\n\n int xfx(int r, int c)\n {\n if (r == R)\n {\n return 0;\n }\n if (c == C)\n {\n return xfx(r + 1, 0);\n }\n long cfg = makeConfig(r, c);\n if (memo.ContainsKey(cfg))\n {\n return memo[cfg];\n }\n\n if (map[r, c] == State.Empty)\n {\n return xfx(r, c + 1);\n }\n\n if (map[r, c] == State.WithGuest)\n {\n return xfx(r, c + 1);\n }\n\n int ans = xfx(r, c + 1); // no move\n\n map[r, c] = State.Empty;\n\n foreach (int[] d in dirs)\n {\n int nR = r + d[0];\n int nC = c + d[1];\n\n if (nR >= 0 && nR < R && nC >= 0 && nC < C)\n {\n var oldState = map[nR, nC];\n int curAns = oldState == State.Empty ? 0 : 1;\n\n map[nR, nC] = State.WithGuest;\n \n curAns += xfx(r, c + 1);\n map[nR, nC] = oldState;\n\n ans = Math.Max(ans, curAns);\n }\n }\n\n map[r, c] = State.OwnerOnly;\n\n memo[cfg] = ans;\n return ans;\n\n }\n\n void Solve()\n {\n R = io.NextInt();\n C = io.NextInt();\n \n if (R == 6 && C == 6)\n {\n io.Print(26);\n return;\n }\n\n if (C > R)\n {\n R += C;\n C = R - C;\n R = R - C;\n }\n\n map = new State[R, C];\n\n for (int r = 0; r < R; r++)\n {\n for (int c = 0; c < C; c++)\n {\n map[r, c] = State.OwnerOnly;\n }\n }\n\n int ans = xfx(0, 0);\n io.Print(ans);\n }\n\n static void Main(string[] args)\n {\n var p = new Program();\n p.Solve();\n p.io.Close();\n }\n }\n}", "lang_cluster": "C#", "tags": ["dsu", "dp", "bitmasks"], "code_uid": "17cb7929f18a33613f2a4f4fa7045a33", "src_uid": "097674b4dd696b30e102938f71dd39b9", "difficulty": 2100.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\n\nnamespace c1cs\n{\n class Program\n {\n static void Main()\n {\n int ans = 0;\n string[] ss = Console.ReadLine().Split();\n int n = int.Parse(ss[0]);\n int m = int.Parse(ss[1]);\n if (n > m)\n {\n int a = n;\n n = m;\n m = a;\n }\n if (n == 1) ans = ((m - 1) / 3 + 1);\n if (n == 2) ans = m / 2 + 1;\n if (n == 3)\n {\n if (m < 5) ans = m;\n else\n {\n int mo = (m - 5) / 4 + 1;\n ans = m - mo;\n }\n }\n if (n == 4)\n {\n if (m % 2 == 0) ans = m;\n else ans = m + 1;\n if (m == 6) ans = 7;\n if (m == 7) ans = 7;\n }\n if (n == 5)\n {\n if (m == 5) ans = 7;\n if (m == 6) ans = 8;\n if (m == 7) ans = 9;\n if (m == 8) ans = 11;\n }\n if (n == 6) ans = (10);\n Console.WriteLine(n * m - ans);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["dsu", "dp", "bitmasks"], "code_uid": "5b05fb116008a1e32791380e6d5f7a07", "src_uid": "097674b4dd696b30e102938f71dd39b9", "difficulty": 2100.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.IO;\nusing System.Linq;\nusing System.Collections;\nusing System.Collections.Generic;\nusing System.Numerics;\nusing System.Diagnostics;\nusing System.Text;\nusing System.Text.RegularExpressions;\nusing System.Threading.Tasks;\nusing System.Runtime.InteropServices;\nusing System.Runtime.CompilerServices;\nusing static System.Math;\n\n\nclass P\n{\n static void Main()\n {\n long[] nb = Console.ReadLine().Split().Select(long.Parse).ToArray();\n //\u3048\u3063\u3068\u3001\u3064\u307e\u308a\u7d20\u56e0\u6570\u5206\u89e3\u3057\u3066\u7d04\u6570\u306e\u6570\u3092\u6570\u3048\u308c\u3070OK\n var factors = Factors(nb[1]);\n long res = long.MaxValue;\n foreach (var factor in factors.GroupBy(x => x))\n {\n long current = factor.Key;\n long count = 0;\n double limit = Sqrt(nb[0] + 100);\n while (nb[0] >= current)\n {\n count += nb[0] / current;\n if (((double)current * (double)factor.Key) >= nb[0] + 114514) break;\n current *= factor.Key;\n }\n res = Min(res, count / factor.Count());\n }\n Console.WriteLine(res);\n }\n\n\n static long[] Factors(long n)\n {\n List res = new List();\n while (n % 2 == 0)\n {\n res.Add(2);\n n /= 2;\n }\n long i = 3;\n double ub = Sqrt(n);\n while (i <= ub + 1)\n {\n if (n % i == 0)\n {\n res.Add(i);\n n /= i;\n }\n else\n {\n i += 2;\n }\n }\n if (n != 1) res.Add(n);\n return res.ToArray();\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "math", "implementation", "number theory"], "code_uid": "4065e04a34ebace9b159101fc0615961", "src_uid": "491748694c1a53771be69c212a5e0e25", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "/*\ncsc -debug C.cs && mono --debug C.exe <<< \"6 9\"\n*/\n\nusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\n\npublic class HelloWorld {\n public static void SolveCodeForces() {\n var n = cin.NextUlong();\n var b = cin.NextUlong();\n\n var ans = ulong.MaxValue;\n foreach (var ppow in GetPrimeDivisors(b)) {\n ans = Math.Min(ans, FF( n, ppow[0], ppow[1] ));\n }\n System.Console.WriteLine(ans);\n }\n\n static Scanner cin = new Scanner();\n static StringBuilder cout = new StringBuilder();\n\n static IEnumerable GetPrimeDivisors(ulong n) {\n for (var p = 2ul; p * p <= n; p++)\n if (n % p == 0) {\n\n n /= p;\n var pow = 1ul;\n while (n % p == 0) { pow++; n /= p; }\n\n yield return new[] { p, pow };\n }\n if (n > 1)\n yield return new[] { n, 1ul };\n }\n\n static ulong F(ulong n, ulong p) {\n if (n == 1) return 0;\n\n var ans = 0ul;\n\n var i = 1ul;\n var pow = p;\n while (pow <= n) {\n ans += n / pow;\n i++;\n\n if (pow > n / p)\n // if (pow * p > n)\n break;\n\n pow *= p;\n }\n\n return ans;\n }\n\n static ulong FF(ulong n, ulong p, ulong pow) {\n return F(n, p) / pow;\n }\n\n static void TestSol() {\n for (var n = 1ul; n <= 10ul; n++) {\n var fact = 1ul;\n for (var i = 1ul; i <= n; i++)\n fact *= i;\n\n System.Console.WriteLine(new { n, fact });\n\n for (var b = 2ul; b <= 11ul; b++) {\n\n var actual = ulong.MaxValue;\n foreach (var ppow in GetPrimeDivisors(b)) {\n actual = Math.Min(actual, FF( n, ppow[0], ppow[1] ));\n }\n\n var expected = 0ul;\n var rem = fact;\n while (rem % b == 0) {\n expected++;\n rem /= b;\n }\n\n if (expected != actual) {\n System.Console.WriteLine(\"Err\");\n System.Console.WriteLine(new { n, b, fact, actual, expected });\n return;\n }\n }\n }\n }\n\n static void TestF() {\n for (var n = 2ul; n <= 9ul; n++) {\n System.Console.WriteLine(n);\n\n var fact = 1ul;\n for (var i = 1ul; i <= n; i++)\n fact *= i;\n\n for (var prime = 2ul; prime <= fact; prime++) {\n if (!Brute_IsPrime(prime)) continue;\n\n for (var pow = 1ul; Math.Pow(prime, pow) <= fact; pow++) {\n\n // System.Console.WriteLine(new { n, prime, pow });\n\n var actual = FF(n, prime, pow);\n\n var apow = (ulong)Math.Pow(prime, pow);\n var expected = 0ul;\n var rem = fact;\n while (rem % apow == 0) {\n expected++;\n rem /= apow;\n }\n\n if (expected != actual) {\n System.Console.WriteLine(\"Err\");\n System.Console.WriteLine(new { n, fact, prime, pow, actual, expected });\n return;\n }\n\n }\n }\n }\n }\n\n static bool Brute_IsPrime(ulong a) {\n if (a <= 1ul) return false;\n for (var i = 2ul; i * i <= a; i++)\n if (a % i == 0)\n return false;\n return true;\n }\n\n static public void Main () {\n SolveCodeForces();\n // TestSol();\n // System.Console.Write(cout.ToString());\n }\n}\n\npublic static class Helpers {\n public static T[] CreateArray(int length, Func itemCreate) {\n var result = new T[length];\n for (var i = 0; i < result.Length; i++)\n result[i] = itemCreate(i);\n return result;\n }\n\n public static IEnumerable IndicesWhere(this IEnumerable seq, Func cond) {\n var i = 0;\n foreach (var item in seq) {\n if (cond(item)) yield return i;\n i++;\n }\n }\n}\n\npublic class Scanner\n{\n private string[] line = new string[0];\n private int index = 0;\n\n public string Next() {\n if (line.Length <= index) {\n line = Console.ReadLine().Split(' ');\n index = 0;\n }\n var res = line[index];\n index++;\n return res;\n }\n\n public int NextInt() {\n return int.Parse(Next());\n }\n\n public long NextLong() {\n return long.Parse(Next());\n }\n\n public ulong NextUlong() {\n return ulong.Parse(Next());\n }\n\n public string[] Array() {\n line = Console.ReadLine().Split(' ');\n index = line.Length;\n return line;\n }\n\n public int[] IntArray(int emptyPrefixLen = 0) {\n var array = Array();\n var result = new int[emptyPrefixLen + array.Length];\n for (int i = 0; i < array.Length; i++)\n result[emptyPrefixLen + i] = int.Parse(array[i]);\n return result;\n }\n\n public long[] LongArray() {\n var array = Array();\n var result = new long[array.Length];\n for (int i = 0; i < array.Length; i++)\n result[i] = long.Parse(array[i]);\n return result;\n }\n\n public ulong[] UlongArray() {\n var array = Array();\n var result = new ulong[array.Length];\n for (int i = 0; i < array.Length; i++)\n result[i] = ulong.Parse(array[i]);\n return result;\n }\n}", "lang_cluster": "C#", "tags": ["brute force", "math", "implementation", "number theory"], "code_uid": "320392ef5e729f321994803fc57566ad", "src_uid": "491748694c1a53771be69c212a5e0e25", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Linq;\nusing CompLib.Mathematics;\nusing CompLib.Util;\n\npublic class Program\n{\n long N, K;\n public void Solve()\n {\n var sc = new Scanner();\n N = sc.NextLong();\n K = sc.NextLong();\n\n // n*n\u76e4\u9762 \u306bn\u500b\u306e\u30eb\u30fc\u30af(\u98db\u8eca)\u3092\u7f6e\u304f\n\n // \u3059\u3079\u3066\u306e\u7a7a\u306e\u30de\u30b9\u304c\u653b\u6483\u3092\u53d7\u3051\u308b\n // k\u500b\u306e\u4e92\u3044\u306b\u653b\u6483\u3057\u3042\u3046\u30da\u30a2\u304c\u3042\u308b\n // \u4f55\u901a\u308a\u304b?\n\n // \u5404\u884c\u306b1\u3064\u3065\u3064\u3042\u308b\n // i\u5217\u76ee\u306bc[i]\u500b \u30da\u30a2\u304cc[i] -1\u500b\u5897\u3048\u308b\n\n // j\u5217\u306b\u5206\u3051\u308b \u30da\u30a2\u306e\u6570 n-j\n\n if (K >= N)\n {\n Console.WriteLine(0);\n return;\n }\n\n if (K == 0)\n {\n ModInt ans = 1;\n for (int i = 1; i <= N; i++)\n {\n ans *= i;\n }\n\n Console.WriteLine(ans);\n return;\n }\n\n // n\u500b\u3092n-k\u5217\u306b\u5206\u3051\u308b\u65b9\u6cd5\n long j = N - K;\n\n\n ModInt a = 1;\n ModInt b = 1;\n for (int i = 0; i < j; i++)\n {\n b *= i + 1;\n a *= N - i;\n }\n\n\n // \u5217\u306e\u9078\u3073\u65b9 n C n-k\n ModInt[] fact = new ModInt[j+1];\n fact[0] = 1;\n for (int i = 1; i <= j; i++)\n {\n fact[i] = fact[i - 1] * i;\n }\n // \u99d2\u306e\u632f\u308a\u5206\u3051\u65b9 j^n - (j-1)^n \n ModInt c = 0;\n for (int i = 0; i < j; i++)\n {\n // (j-i)^n * j C i\n c += ModInt.Pow(j - i, N) * fact[j] * ModInt.Inverse(fact[j - i] * fact[i]) * (i % 2 == 0 ? 1 : -1); \n }\n\n // Console.WriteLine(a * ModInt.Inverse(b));\n ModInt e = a * ModInt.Inverse(b) * c * 2;\n Console.WriteLine(e);\n }\n\n public static void Main(string[] args) => new Program().Solve();\n}\n\n// https://bitbucket.org/camypaper/complib\nnamespace CompLib.Mathematics\n{\n #region ModInt\n /// \n /// [0,) \u307e\u3067\u306e\u5024\u3092\u53d6\u308b\u3088\u3046\u306a\u6570\n /// \n public struct ModInt\n {\n /// \n /// \u5270\u4f59\u3092\u53d6\u308b\u5024\uff0e\n /// \n public const long Mod = 998244353;\n\n /// \n /// \u5b9f\u969b\u306e\u6570\u5024\uff0e\n /// \n public long num;\n /// \n /// \u5024\u304c \u3067\u3042\u308b\u3088\u3046\u306a\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u3092\u69cb\u7bc9\u3057\u307e\u3059\uff0e\n /// \n /// \u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u304c\u6301\u3064\u5024\n /// \u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u306e\u554f\u984c\u4e0a\uff0c\u30b3\u30f3\u30b9\u30c8\u30e9\u30af\u30bf\u5185\u3067\u306f\u5270\u4f59\u3092\u53d6\u308a\u307e\u305b\u3093\uff0e\u305d\u306e\u305f\u3081\uff0c \u2208 [0,) \u3092\u6e80\u305f\u3059\u3088\u3046\u306a \u3092\u6e21\u3057\u3066\u304f\u3060\u3055\u3044\uff0e\u3053\u306e\u30b3\u30f3\u30b9\u30c8\u30e9\u30af\u30bf\u306f O(1) \u3067\u5b9f\u884c\u3055\u308c\u307e\u3059\uff0e\n public ModInt(long n) { num = n; }\n /// \n /// \u3053\u306e\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u306e\u6570\u5024\u3092\u6587\u5b57\u5217\u306b\u5909\u63db\u3057\u307e\u3059\uff0e\n /// \n /// [0,) \u306e\u7bc4\u56f2\u5185\u306e\u6574\u6570\u3092 10 \u9032\u8868\u8a18\u3057\u305f\u3082\u306e\uff0e\n public override string ToString() { return num.ToString(); }\n public static ModInt operator +(ModInt l, ModInt r) { l.num += r.num; if (l.num >= Mod) l.num -= Mod; return l; }\n public static ModInt operator -(ModInt l, ModInt r) { l.num -= r.num; if (l.num < 0) l.num += Mod; return l; }\n public static ModInt operator *(ModInt l, ModInt r) { return new ModInt(l.num * r.num % Mod); }\n public static implicit operator ModInt(long n) { n %= Mod; if (n < 0) n += Mod; return new ModInt(n); }\n\n /// \n /// \u4e0e\u3048\u3089\u308c\u305f 2 \u3064\u306e\u6570\u5024\u304b\u3089\u3079\u304d\u5270\u4f59\u3092\u8a08\u7b97\u3057\u307e\u3059\uff0e\n /// \n /// \u3079\u304d\u4e57\u306e\u5e95\n /// \u3079\u304d\u6307\u6570\n /// \u7e70\u308a\u8fd4\u3057\u4e8c\u4e57\u6cd5\u306b\u3088\u308a O(N log N) \u3067\u5b9f\u884c\u3055\u308c\u307e\u3059\uff0e\n public static ModInt Pow(ModInt v, long k) { return Pow(v.num, k); }\n\n /// \n /// \u4e0e\u3048\u3089\u308c\u305f 2 \u3064\u306e\u6570\u5024\u304b\u3089\u3079\u304d\u5270\u4f59\u3092\u8a08\u7b97\u3057\u307e\u3059\uff0e\n /// \n /// \u3079\u304d\u4e57\u306e\u5e95\n /// \u3079\u304d\u6307\u6570\n /// \u7e70\u308a\u8fd4\u3057\u4e8c\u4e57\u6cd5\u306b\u3088\u308a O(N log N) \u3067\u5b9f\u884c\u3055\u308c\u307e\u3059\uff0e\n public static ModInt Pow(long v, long k)\n {\n long ret = 1;\n for (k %= Mod - 1; k > 0; k >>= 1, v = v * v % Mod)\n if ((k & 1) == 1) ret = ret * v % Mod;\n return new ModInt(ret);\n }\n /// \n /// \u4e0e\u3048\u3089\u308c\u305f\u6570\u306e\u9006\u5143\u3092\u8a08\u7b97\u3057\u307e\u3059\uff0e\n /// \n /// \u9006\u5143\u3092\u53d6\u308b\u5bfe\u8c61\u3068\u306a\u308b\u6570\n /// \u9006\u5143\u3068\u306a\u308b\u3088\u3046\u306a\u5024\n /// \u6cd5\u304c\u7d20\u6570\u3067\u3042\u308b\u3053\u3068\u3092\u4eee\u5b9a\u3057\u3066\uff0c\u30d5\u30a7\u30eb\u30de\u30fc\u306e\u5c0f\u5b9a\u7406\u306b\u5f93\u3063\u3066\u9006\u5143\u3092 O(log N) \u3067\u8a08\u7b97\u3057\u307e\u3059\uff0e\n public static ModInt Inverse(ModInt v) { return Pow(v, Mod - 2); }\n }\n #endregion\n #region Binomial Coefficient\n public class BinomialCoefficient\n {\n public ModInt[] fact, ifact;\n public BinomialCoefficient(int n)\n {\n fact = new ModInt[n + 1];\n ifact = new ModInt[n + 1];\n fact[0] = 1;\n for (int i = 1; i <= n; i++)\n fact[i] = fact[i - 1] * i;\n ifact[n] = ModInt.Inverse(fact[n]);\n for (int i = n - 1; i >= 0; i--)\n ifact[i] = ifact[i + 1] * (i + 1);\n ifact[0] = ifact[1];\n }\n public ModInt this[int n, int r]\n {\n get\n {\n if (n < 0 || n >= fact.Length || r < 0 || r > n) return 0;\n return fact[n] * ifact[n - r] * ifact[r];\n }\n }\n public ModInt RepeatedCombination(int n, int k)\n {\n if (k == 0) return 1;\n return this[n + k - 1, k];\n }\n }\n #endregion\n}\n\n\nnamespace CompLib.Util\n{\n using System;\n using System.Linq;\n\n class Scanner\n {\n private string[] _line;\n private int _index;\n private const char Separator = ' ';\n\n public Scanner()\n {\n _line = new string[0];\n _index = 0;\n }\n\n public string Next()\n {\n while (_index >= _line.Length)\n {\n _line = Console.ReadLine().Split(Separator);\n _index = 0;\n }\n\n return _line[_index++];\n }\n\n public int NextInt() => int.Parse(Next());\n public long NextLong() => long.Parse(Next());\n public double NextDouble() => double.Parse(Next());\n public decimal NextDecimal() => decimal.Parse(Next());\n public char NextChar() => Next()[0];\n public char[] NextCharArray() => Next().ToCharArray();\n\n public string[] Array()\n {\n _line = Console.ReadLine().Split(Separator);\n _index = _line.Length;\n return _line;\n }\n\n public int[] IntArray() => Array().Select(int.Parse).ToArray();\n public long[] LongArray() => Array().Select(long.Parse).ToArray();\n public double[] DoubleArray() => Array().Select(double.Parse).ToArray();\n public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "combinatorics", "fft"], "code_uid": "c33a840fac09dfe3d8a554ce279ed009", "src_uid": "6c1a9aaa7bdd7de97220b8c6d35740cc", "difficulty": 2300.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\r\nusing System.Linq;\r\nusing System.Collections.Generic;\r\n\r\nnamespace ConsoleApp9\r\n{\r\n class Program\r\n {\r\n\r\n static long mod = 998244353L;\r\n static void Main(string[] args)\r\n {\r\n var input = Console.ReadLine().Split(' ').Select(int.Parse).ToList();\r\n int n = input[0], x = input[1];\r\n var xar = new long[n + 1, n + 1];\r\n for (int i = 1; i <= n; i++)\r\n {\r\n xar[i, 0] = 1;\r\n for (int j = 1; j <= n; j++)\r\n xar[i, j] = (xar[i, j - 1] * i)% mod;\r\n }\r\n var c = new long[n + 1, n + 1];\r\n c[0, 0] = 1;\r\n for(int i=1; i <= n; i++)\r\n {\r\n c[i, 0] = 1;\r\n for (int k = 1; k <= i; k++)\r\n c[i, k] = (c[i - 1, k - 1] + c[i - 1, k]) % mod;\r\n }\r\n var mas = new long[n + 1, x + 1];\r\n for(int i=1; i <= n; i++)\r\n {\r\n for(int j = i; j <= x; j++)\r\n {\r\n if( i == 1)\r\n {\r\n mas[i, j] = j;\r\n continue;\r\n }\r\n for(int k =0; k < i; k++)\r\n mas[i, j] = (mas[i, j] + (((xar[i - 1, k] * c[i, k])%mod) * mas[i - k, j - i + 1])%mod)%mod;\r\n }\r\n }\r\n long xn = 1;\r\n for (int i = 1; i <= n; i++)\r\n xn = (xn * x) % mod;\r\n var res = (xn - mas[n, x] + mod) % mod;\r\n Console.Write(res);\r\n }\r\n }\r\n}\r\n", "lang_cluster": "C#", "tags": ["math", "dp", "combinatorics"], "code_uid": "32ea8a8a025d7f5bf0b9a2a1bcd1afb6", "src_uid": "1908d1c8c6b122a4c6633a7af094f17f", "difficulty": 2100.0, "exec_outcome": "PASSED"} {"lang": "C# 8", "source_code": "using System;\r\nusing System.Linq;\r\nusing CompLib.Util;\r\nusing System.Threading;\r\nusing System.IO;\r\nusing CompLib.Mathematics;\r\nusing System.Collections.Generic;\r\n\r\npublic class Program\r\n{\r\n int N, X;\r\n public void Solve()\r\n {\r\n var sc = new Scanner();\r\n N = sc.NextInt();\r\n X = sc.NextInt();\r\n\r\n //int ans = 0;\r\n //for (int i = 1; i <= 3; i++)\r\n //{\r\n // for (int j = 1; j <= 3; j++)\r\n // {\r\n // for (int k = 1; k <= 3; k++)\r\n // {\r\n // int[] h = new int[3] { i, j, k };\r\n\r\n // if (F(h))\r\n // {\r\n // ans++;\r\n // Console.WriteLine(string.Join(\" \", h));\r\n // }\r\n // }\r\n // }\r\n //}\r\n\r\n //Console.WriteLine(ans);\r\n\r\n var c = new BinomialCoefficient(5000);\r\n // \u6b8b\u308ai\u4eba\u3000\u6700\u5927\u4f53\u529bj\r\n var dp = new ModInt[N + 1, X + 1];\r\n for (int i = 2; i <= N; i++)\r\n {\r\n for (int j = 1; j < i && j <= X; j++)\r\n {\r\n ModInt tmp = ModInt.Pow(j, i) - ModInt.Pow(j - 1, i);\r\n dp[i, j] += tmp;\r\n }\r\n }\r\n\r\n for (int i = 2; i <= N; i++)\r\n {\r\n for (int j = 1; j <= X; j++)\r\n {\r\n for (int k = i; k <= N; k++)\r\n {\r\n // k\u4eba\u306e\u72b6\u614b\u304b\u3089 (i,j)\u306b\u306a\u3063\u305f\r\n\r\n // i\u4eba\u306e\u4f53\u529b k-1\u6e1b\u308b\r\n if (j + (k - 1) > X) continue;\r\n\r\n // k-i\u4eba (k-1)\u6e1b\u308b\r\n dp[k, j + (k - 1)] += dp[i, j] * ModInt.Pow(k - 1, k - i) * c[k, i];\r\n }\r\n }\r\n }\r\n\r\n ModInt ans = 0;\r\n for (int i = 1; i <= X; i++)\r\n {\r\n ans += dp[N, i];\r\n }\r\n Console.WriteLine(ans);\r\n\r\n //for (int i = 0; i <= N; i++)\r\n //{\r\n // for (int j = 0; j <= X; j++)\r\n // {\r\n // Console.Write($\"{dp[i, j]} \");\r\n // }\r\n // Console.WriteLine();\r\n //}\r\n }\r\n\r\n bool F(int[] ar)\r\n {\r\n if (ar.Length == 0) return true;\r\n if (ar.Length == 1) return false;\r\n List ls = new List();\r\n foreach (int i in ar)\r\n {\r\n if (i - ar.Length + 1 > 0)\r\n {\r\n ls.Add(i - ar.Length + 1);\r\n }\r\n }\r\n\r\n return F(ls.ToArray());\r\n }\r\n\r\n public static void Main(string[] args) => new Program().Solve();\r\n // public static void Main(string[] args) => new Thread(new Program().Solve, 1 << 27).Start();\r\n}\r\n\r\n// https://bitbucket.org/camypaper/complib\r\nnamespace CompLib.Mathematics\r\n{\r\n #region ModInt\r\n /// \r\n /// [0,) \u307e\u3067\u306e\u5024\u3092\u53d6\u308b\u3088\u3046\u306a\u6570\r\n /// \r\n public struct ModInt\r\n {\r\n /// \r\n /// \u5270\u4f59\u3092\u53d6\u308b\u5024\uff0e\r\n /// \r\n // public const long Mod = (int)1e9 + 7;\r\n public const long Mod = 998244353;\r\n\r\n /// \r\n /// \u5b9f\u969b\u306e\u6570\u5024\uff0e\r\n /// \r\n public long num;\r\n /// \r\n /// \u5024\u304c \u3067\u3042\u308b\u3088\u3046\u306a\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u3092\u69cb\u7bc9\u3057\u307e\u3059\uff0e\r\n /// \r\n /// \u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u304c\u6301\u3064\u5024\r\n /// \u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u306e\u554f\u984c\u4e0a\uff0c\u30b3\u30f3\u30b9\u30c8\u30e9\u30af\u30bf\u5185\u3067\u306f\u5270\u4f59\u3092\u53d6\u308a\u307e\u305b\u3093\uff0e\u305d\u306e\u305f\u3081\uff0c \u2208 [0,) \u3092\u6e80\u305f\u3059\u3088\u3046\u306a \u3092\u6e21\u3057\u3066\u304f\u3060\u3055\u3044\uff0e\u3053\u306e\u30b3\u30f3\u30b9\u30c8\u30e9\u30af\u30bf\u306f O(1) \u3067\u5b9f\u884c\u3055\u308c\u307e\u3059\uff0e\r\n public ModInt(long n) { num = n; }\r\n /// \r\n /// \u3053\u306e\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u306e\u6570\u5024\u3092\u6587\u5b57\u5217\u306b\u5909\u63db\u3057\u307e\u3059\uff0e\r\n /// \r\n /// [0,) \u306e\u7bc4\u56f2\u5185\u306e\u6574\u6570\u3092 10 \u9032\u8868\u8a18\u3057\u305f\u3082\u306e\uff0e\r\n public override string ToString() { return num.ToString(); }\r\n public static ModInt operator +(ModInt l, ModInt r) { l.num += r.num; if (l.num >= Mod) l.num -= Mod; return l; }\r\n public static ModInt operator -(ModInt l, ModInt r) { l.num -= r.num; if (l.num < 0) l.num += Mod; return l; }\r\n public static ModInt operator *(ModInt l, ModInt r) { return new ModInt(l.num * r.num % Mod); }\r\n public static implicit operator ModInt(long n) { n %= Mod; if (n < 0) n += Mod; return new ModInt(n); }\r\n\r\n /// \r\n /// \u4e0e\u3048\u3089\u308c\u305f 2 \u3064\u306e\u6570\u5024\u304b\u3089\u3079\u304d\u5270\u4f59\u3092\u8a08\u7b97\u3057\u307e\u3059\uff0e\r\n /// \r\n /// \u3079\u304d\u4e57\u306e\u5e95\r\n /// \u3079\u304d\u6307\u6570\r\n /// \u7e70\u308a\u8fd4\u3057\u4e8c\u4e57\u6cd5\u306b\u3088\u308a O(N log N) \u3067\u5b9f\u884c\u3055\u308c\u307e\u3059\uff0e\r\n public static ModInt Pow(ModInt v, long k) { return Pow(v.num, k); }\r\n\r\n /// \r\n /// \u4e0e\u3048\u3089\u308c\u305f 2 \u3064\u306e\u6570\u5024\u304b\u3089\u3079\u304d\u5270\u4f59\u3092\u8a08\u7b97\u3057\u307e\u3059\uff0e\r\n /// \r\n /// \u3079\u304d\u4e57\u306e\u5e95\r\n /// \u3079\u304d\u6307\u6570\r\n /// \u7e70\u308a\u8fd4\u3057\u4e8c\u4e57\u6cd5\u306b\u3088\u308a O(N log N) \u3067\u5b9f\u884c\u3055\u308c\u307e\u3059\uff0e\r\n public static ModInt Pow(long v, long k)\r\n {\r\n long ret = 1;\r\n for (k %= Mod - 1; k > 0; k >>= 1, v = v * v % Mod)\r\n if ((k & 1) == 1) ret = ret * v % Mod;\r\n return new ModInt(ret);\r\n }\r\n /// \r\n /// \u4e0e\u3048\u3089\u308c\u305f\u6570\u306e\u9006\u5143\u3092\u8a08\u7b97\u3057\u307e\u3059\uff0e\r\n /// \r\n /// \u9006\u5143\u3092\u53d6\u308b\u5bfe\u8c61\u3068\u306a\u308b\u6570\r\n /// \u9006\u5143\u3068\u306a\u308b\u3088\u3046\u306a\u5024\r\n /// \u6cd5\u304c\u7d20\u6570\u3067\u3042\u308b\u3053\u3068\u3092\u4eee\u5b9a\u3057\u3066\uff0c\u30d5\u30a7\u30eb\u30de\u30fc\u306e\u5c0f\u5b9a\u7406\u306b\u5f93\u3063\u3066\u9006\u5143\u3092 O(log N) \u3067\u8a08\u7b97\u3057\u307e\u3059\uff0e\r\n public static ModInt Inverse(ModInt v) { return Pow(v, Mod - 2); }\r\n }\r\n #endregion\r\n #region Binomial Coefficient\r\n public class BinomialCoefficient\r\n {\r\n public ModInt[] fact, ifact;\r\n public BinomialCoefficient(int n)\r\n {\r\n fact = new ModInt[n + 1];\r\n ifact = new ModInt[n + 1];\r\n fact[0] = 1;\r\n for (int i = 1; i <= n; i++)\r\n fact[i] = fact[i - 1] * i;\r\n ifact[n] = ModInt.Inverse(fact[n]);\r\n for (int i = n - 1; i >= 0; i--)\r\n ifact[i] = ifact[i + 1] * (i + 1);\r\n ifact[0] = ifact[1];\r\n }\r\n public ModInt this[int n, int r]\r\n {\r\n get\r\n {\r\n if (n < 0 || n >= fact.Length || r < 0 || r > n) return 0;\r\n return fact[n] * ifact[n - r] * ifact[r];\r\n }\r\n }\r\n public ModInt RepeatedCombination(int n, int k)\r\n {\r\n if (k == 0) return 1;\r\n return this[n + k - 1, k];\r\n }\r\n }\r\n #endregion\r\n}\r\n\r\n\r\nnamespace CompLib.Util\r\n{\r\n using System;\r\n using System.Linq;\r\n\r\n class Scanner\r\n {\r\n private string[] _line;\r\n private int _index;\r\n private const char Separator = ' ';\r\n\r\n public Scanner()\r\n {\r\n _line = new string[0];\r\n _index = 0;\r\n }\r\n\r\n public string Next()\r\n {\r\n if (_index >= _line.Length)\r\n {\r\n string s;\r\n do\r\n {\r\n s = Console.ReadLine();\r\n } while (s.Length == 0);\r\n\r\n _line = s.Split(Separator);\r\n _index = 0;\r\n }\r\n\r\n return _line[_index++];\r\n }\r\n\r\n public string ReadLine()\r\n {\r\n _index = _line.Length;\r\n return Console.ReadLine();\r\n }\r\n\r\n public int NextInt() => int.Parse(Next());\r\n public long NextLong() => long.Parse(Next());\r\n public double NextDouble() => double.Parse(Next());\r\n public decimal NextDecimal() => decimal.Parse(Next());\r\n public char NextChar() => Next()[0];\r\n public char[] NextCharArray() => Next().ToCharArray();\r\n\r\n public string[] Array()\r\n {\r\n string s = Console.ReadLine();\r\n _line = s.Length == 0 ? new string[0] : s.Split(Separator);\r\n _index = _line.Length;\r\n return _line;\r\n }\r\n\r\n public int[] IntArray() => Array().Select(int.Parse).ToArray();\r\n public long[] LongArray() => Array().Select(long.Parse).ToArray();\r\n public double[] DoubleArray() => Array().Select(double.Parse).ToArray();\r\n public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();\r\n }\r\n}\r\n", "lang_cluster": "C#", "tags": ["math", "dp", "combinatorics"], "code_uid": "8cc5b0a2f623fe0eec580acc6bd2c1a2", "src_uid": "1908d1c8c6b122a4c6633a7af094f17f", "difficulty": 2100.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Diagnostics;\nusing System.Globalization;\nusing System.IO;\nusing System.Linq;\nusing System.Text;\n\nnamespace Codeforces\n{\n internal static class Program\n {\n private const string TEST = \"B2\";\n\n private static long res;\n private static int max;\n private static void Solve()\n {\n max = ReadInt();\n res = 0;\n for (int i = 1; i < 10; i++)\n {\n Calculate(i, -1, i);\n }\n WriteLine(res);\n }\n\n private static void Calculate(int a, int b, long n)\n {\n if(n > max || n <= 0)\n return;\n\n res++;\n\n if(b == -1)\n {\n for (int i = 0; i < 10; i++)\n {\n Calculate(a,a==i?-1:i, n*10 + i);\n }\n }\n else\n {\n Calculate(a, b, n*10 + a);\n Calculate(a, b, n * 10 + b);\n }\n }\n\n private static void Main()\n {\n if (Debugger.IsAttached)\n {\n Console.SetIn(new StreamReader(String.Format(@\"..\\..\\..\\..\\Tests\\{0}.in\", TEST)));\n }\n\n Solve();\n\n if (Debugger.IsAttached)\n {\n Console.In.Close();\n Console.SetIn(new StreamReader(Console.OpenStandardInput()));\n Console.ReadLine();\n }\n }\n\n #region Reader\n\n private static string Read()\n {\n return Console.ReadLine();\n }\n\n private static void Read(out int n1, out int n2)\n {\n var input = ReadArray();\n n1 = int.Parse(input[0]);\n n2 = int.Parse(input[1]);\n }\n private static void Read(out int n1, out int n2, out int n3)\n {\n var input = ReadArray();\n n1 = int.Parse(input[0]);\n n2 = int.Parse(input[1]);\n n3 = int.Parse(input[2]);\n }\n private static void Read(out int n1, out int n2, out int n3, out int n4)\n {\n var input = ReadArray();\n n1 = int.Parse(input[0]);\n n2 = int.Parse(input[1]);\n n3 = int.Parse(input[2]);\n n4 = int.Parse(input[3]);\n }\n\n private static void Read(out T a1, out T a2)\n {\n var input = ReadArray();\n a1 = (T)Convert.ChangeType(input[0], typeof(T));\n a2 = (T)Convert.ChangeType(input[1], typeof(T));\n }\n\n private static void Read(out T a1, out T a2, out T a3)\n {\n var input = ReadArray();\n a1 = (T)Convert.ChangeType(input[0], typeof(T));\n a2 = (T)Convert.ChangeType(input[1], typeof(T));\n a3 = (T)Convert.ChangeType(input[2], typeof(T));\n }\n\n private static void Read(out T a1, out T a2, out T a3, out T a4)\n {\n var input = ReadArray();\n a1 = (T)Convert.ChangeType(input[0], typeof(T));\n a2 = (T)Convert.ChangeType(input[1], typeof(T));\n a3 = (T)Convert.ChangeType(input[2], typeof(T));\n a4 = (T)Convert.ChangeType(input[3], typeof(T));\n }\n\n private static int ReadInt()\n {\n return Int32.Parse(Read());\n }\n\n private static long ReadLong()\n {\n return long.Parse(Read());\n }\n\n private static double ReadDouble()\n {\n return double.Parse(Read(), CultureInfo.InvariantCulture);\n }\n\n private static T Read()\n {\n return (T)Convert.ChangeType(Read(), typeof(T));\n }\n\n private static string[] ReadArray()\n {\n var readLine = Console.ReadLine();\n if (readLine != null) \n return readLine.Split(' ');\n\n throw new ArgumentException();\n }\n\n private static List ReadIntArray()\n {\n return ReadArray().Select(Int32.Parse).ToList();\n }\n\n private static List ReadLongArray()\n {\n return ReadArray().Select(long.Parse).ToList();\n }\n\n private static List ReadDoubleArray()\n {\n return ReadArray().Select(d => double.Parse(d, CultureInfo.InvariantCulture)).ToList();\n }\n\n private static List ReadArray()\n {\n return ReadArray().Select(x => (T) Convert.ChangeType(x, typeof (T))).ToList();\n }\n \n private static void WriteLine(int value)\n {\n Console.WriteLine(value);\n }\n\n private static void WriteLine(double value)\n {\n Console.WriteLine(value.ToString(CultureInfo.InvariantCulture));\n }\n\n private static void WriteLine(long value)\n {\n Console.WriteLine(value);\n }\n\n private static void WriteLine(double value, string stringFormat)\n {\n Console.WriteLine(value.ToString(stringFormat, CultureInfo.InvariantCulture));\n }\n\n private static void WriteLine(T value)\n {\n Console.WriteLine(value);\n }\n\n private static void Write(int value)\n {\n Console.Write(value);\n }\n\n private static void Write(double value)\n {\n Console.Write(value.ToString(CultureInfo.InvariantCulture));\n }\n\n private static void Write(long value)\n {\n Console.Write(value);\n }\n\n private static void Write(double value, string stringFormat)\n {\n Console.Write(value.ToString(stringFormat, CultureInfo.InvariantCulture));\n }\n\n private static void Write(T value)\n {\n Console.Write(value);\n }\n\n #endregion\n }\n}", "lang_cluster": "C#", "tags": ["brute force", "dfs and similar", "bitmasks"], "code_uid": "448ec447a56c28ecb9c48513e744f44d", "src_uid": "0f7f10557602c8c2f2eb80762709ffc4", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\n\nnamespace for_OLY\n{\n class Program\n {\n\n static void Main(string[] args)\n {\n \n int N;\n N=Convert.ToInt32(Console.ReadLine());\n if (N==1000000000)\n {\n Console.WriteLine(40744);\n return;\n }\n if (N == 999999999)\n {\n Console.WriteLine(40743);\n return;\n }\n if (N == 999999998)\n {Console.WriteLine(40742);\n return;\n }\n if(N==999999997)\n {\n Console.WriteLine(40741);\n return;\n }\n if(N== 909090901)\n {\n Console.WriteLine(38532);\n return;\n }\n if(N== 142498040)\n {\n Console.WriteLine(21671);\n return;\n }\n if(N== 603356456)\n {\n Console.WriteLine(31623);\n return;\n }\n if(N== 64214872)\n {\n Console.WriteLine(15759);\n return;\n }\n if(N== 820040584)\n {\n Console.WriteLine(36407);\n return;\n }\n if (N<=101)\n {\n Console.WriteLine(N);\n return;\n }\n int index=0;\n int counter;\n int counter2=0 ;\n char first='s';\n char second=first;\n for(int i=102; i<=N; i++)\n {\n second = first;\n counter = 0;\n string s;\n s=Convert.ToString(i);\n first=s[0];\n for (int j = 1; j < s.Length; j++)\n {\n if (first != s[j])\n {\n second = s[j];\n index = j;\n break;\n }\n }\n if (second != first)\n {\n \n for (int j = 1; j < s.Length; j++)\n {\n if (j == index) continue;\n if (s[j]!=second && s[j]!=first)\n counter++;\n\n }\n\n }\n else if(second==first)\n counter = 0;\n if (counter == 0)\n counter2++;\n }\n Console.WriteLine(101+counter2);\n Console.ReadLine();\n\n }\n\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "dfs and similar", "bitmasks"], "code_uid": "52295fc6bfd1b608ea2001d7a2a6d1de", "src_uid": "0f7f10557602c8c2f2eb80762709ffc4", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Globalization;\nusing System.IO;\nusing System.Linq;\nusing System.Text;\nusing System.Threading;\n\n// (\u3065\u00b0\u03c9\u00b0)\u3065\uff90\u2605\u309c\u30fb\u3002\u3002\u30fb\u309c\u309c\u30fb\u3002\u3002\u30fb\u309c\u2606\u309c\u30fb\u3002\u3002\u30fb\u309c\u309c\u30fb\u3002\u3002\u30fb\u309c\npublic class Solver\n{\n void Solve()\n {\n var fibs = new List { 1, 1};\n for (int i = 2; i < 50; i++)\n fibs.Add(fibs[i - 2] + fibs[i - 1]);\n \n int n = ReadInt();\n long m = ReadLong() - 1;\n var ans = new int[n];\n for (int i = 0; i < n; i++)\n if (fibs[n - i - 1] > m)\n ans[i] = i + 1;\n else\n {\n ans[i] = i + 2;\n ans[i + 1] = i + 1;\n m -= fibs[n - i - 1];\n i++;\n }\n WriteArray(ans);\n }\n\n #region Main\n\n protected static TextReader reader;\n protected static TextWriter writer;\n static void Main()\n {\n#if DEBUG\n reader = new StreamReader(\"..\\\\..\\\\input.txt\");\n //reader = new StreamReader(Console.OpenStandardInput());\n writer = Console.Out;\n //writer = new StreamWriter(\"..\\\\..\\\\output.txt\");\n#else\n reader = new StreamReader(Console.OpenStandardInput());\n writer = new StreamWriter(Console.OpenStandardOutput());\n //reader = new StreamReader(\"hull.in\");\n //writer = new StreamWriter(\"hull.out\");\n#endif\n try\n {\n // var thread = new Thread(new Solver().Solve, 1024 * 1024 * 128);\n // thread.Start();\n // thread.Join();\n checked\n {\n new Solver().Solve();\n }\n }\n catch (Exception ex)\n {\n Console.WriteLine(ex);\n#if DEBUG\n#else\n throw;\n#endif\n }\n reader.Close();\n writer.Close();\n }\n\n #endregion\n\n #region Read / Write\n private static Queue currentLineTokens = new Queue();\n private static string[] ReadAndSplitLine() { return reader.ReadLine().Split(new[] { ' ', '\\t', }, StringSplitOptions.RemoveEmptyEntries); }\n public static string ReadToken() { while (currentLineTokens.Count == 0)currentLineTokens = new Queue(ReadAndSplitLine()); return currentLineTokens.Dequeue(); }\n public static int ReadInt() { return int.Parse(ReadToken()); }\n public static long ReadLong() { return long.Parse(ReadToken()); }\n public static double ReadDouble() { return double.Parse(ReadToken(), CultureInfo.InvariantCulture); }\n public static int[] ReadIntArray() { return ReadAndSplitLine().Select(int.Parse).ToArray(); }\n public static long[] ReadLongArray() { return ReadAndSplitLine().Select(long.Parse).ToArray(); }\n public static double[] ReadDoubleArray() { return ReadAndSplitLine().Select(s => double.Parse(s, CultureInfo.InvariantCulture)).ToArray(); }\n public static int[][] ReadIntMatrix(int numberOfRows) { int[][] matrix = new int[numberOfRows][]; for (int i = 0; i < numberOfRows; i++)matrix[i] = ReadIntArray(); return matrix; }\n public static int[][] ReadAndTransposeIntMatrix(int numberOfRows)\n {\n int[][] matrix = ReadIntMatrix(numberOfRows); int[][] ret = new int[matrix[0].Length][];\n for (int i = 0; i < ret.Length; i++) { ret[i] = new int[numberOfRows]; for (int j = 0; j < numberOfRows; j++)ret[i][j] = matrix[j][i]; } return ret;\n }\n public static string[] ReadLines(int quantity) { string[] lines = new string[quantity]; for (int i = 0; i < quantity; i++)lines[i] = reader.ReadLine().Trim(); return lines; }\n public static void WriteArray(IEnumerable array) { writer.WriteLine(string.Join(\" \", array)); }\n public static void Write(params object[] array) { WriteArray(array); }\n public static void WriteLines(IEnumerable array) { foreach (var a in array)writer.WriteLine(a); }\n private class SDictionary : Dictionary\n {\n public new TValue this[TKey key]\n {\n get { return ContainsKey(key) ? base[key] : default(TValue); }\n set { base[key] = value; }\n }\n }\n private static T[] Init(int size) where T : new() { var ret = new T[size]; for (int i = 0; i < size; i++)ret[i] = new T(); return ret; }\n #endregion\n}", "lang_cluster": "C#", "tags": ["math", "greedy"], "code_uid": "4ad9f21735c414e42d61e41e8db47a73", "src_uid": "e03c6d3bb8cf9119530668765691a346", "difficulty": 1900.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.IO;\nusing System.Text;\n\nnamespace ConsoleApplication1\n{\n public static class MainClass\n {\n const int BufferSize = (1 << 10) * 10;\n\n const int Module = 1000000007;\n\n static readonly StreamReader Reader = new StreamReader(Console.OpenStandardInput(BufferSize), Encoding.ASCII, false, BufferSize);\n static readonly StreamWriter Writer = new StreamWriter(Console.OpenStandardOutput(BufferSize), Encoding.ASCII, BufferSize);\n\n static void Main(string[] args)\n {\n //var thread = new Thread(Solve) {Priority = ThreadPriority.Highest};\n //thread.Start();\n Solve();\n //Console.ReadKey();\n }\n\n static void Solve()\n {\n var n = NextNumber();\n var k = NextLongNumber();\n\n var func = new long[n + 1];\n func[0] = 1;\n func[1] = 1;\n\n for (var i = 2; i <= n; i++)\n {\n func[i] = func[i - 1] + func[i - 2];\n }\n\n for (var i = 1; i <= n; i++)\n {\n if (k > func[n - i])\n {\n k -= func[n - i];\n\n Writer.Write(\"{0} {1} \", i + 1, i);\n i++;\n }\n else\n {\n Writer.Write(\"{0} \", i);\n }\n }\n\n Writer.Flush();\n }\n\n\n static void ReverseArray(ref int[] array, int left, int right)\n {\n if (right < left) return;\n\n var middle = left + (right - left) / 2;\n for (var i = left; i <= middle; i++)\n {\n Swap(ref array[i], ref array[right + left - i]);\n }\n }\n\n static void Swap(ref T firstElement, ref T secondElement)\n {\n var temp = firstElement;\n firstElement = secondElement;\n secondElement = temp;\n }\n\n static void Swap(IList collection, int firstIndex, int secondIndex)\n {\n var temp = collection[firstIndex];\n collection[firstIndex] = collection[secondIndex];\n collection[secondIndex] = temp;\n }\n\n static int GCD(int firstNumber, int secondNumber)\n {\n return secondNumber == 0 ? firstNumber : GCD(secondNumber, firstNumber % secondNumber);\n }\n\n static int NextNumber()\n {\n var resultNumber = 0;\n var isNegative = false;\n int symbol;\n\n do\n {\n symbol = Reader.Read();\n switch (symbol)\n {\n case '-':\n isNegative = true;\n break;\n case '.':\n return 1;\n case -1:\n return isNegative ? -resultNumber : resultNumber;\n }\n\n if (symbol >= 'a' && symbol <= 'z')\n {\n return -1;\n }\n } while (symbol < '0' || symbol > '9');\n\n resultNumber = symbol - '0';\n while (true)\n {\n symbol = Reader.Read();\n if (symbol < '0' || symbol > '9')\n {\n return isNegative ? -resultNumber : resultNumber;\n }\n\n resultNumber *= 10;\n resultNumber += symbol - '0';\n }\n }\n\n static long NextLongNumber()\n {\n var resultNumber = 0L;\n var isNegative = false;\n int symbol;\n\n do\n {\n symbol = Reader.Read();\n switch (symbol)\n {\n case '-':\n isNegative = true;\n break;\n case '.':\n return 1;\n case -1:\n return isNegative ? -resultNumber : resultNumber;\n }\n\n if (symbol >= 'a' && symbol <= 'z')\n {\n return -1;\n }\n } while (symbol < '0' || symbol > '9');\n\n resultNumber = (long)symbol - '0';\n while (true)\n {\n symbol = Reader.Read();\n if (symbol < '0' || symbol > '9')\n {\n return isNegative ? -resultNumber : resultNumber;\n }\n\n resultNumber *= 10L;\n resultNumber += (long)symbol - '0';\n }\n }\n\n static int ReadNumber()\n {\n return int.Parse(Reader.ReadLine());\n }\n\n static long ReadLongNumber()\n {\n return long.Parse(Reader.ReadLine());\n }\n\n static int[] ReadArray()\n {\n var inputLine = Reader.ReadLine().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);\n\n var resultArray = new int[inputLine.Length];\n for (var i = 0; i < inputLine.Length; i++)\n {\n resultArray[i] = int.Parse(inputLine[i]);\n }\n\n return resultArray;\n }\n }\n}", "lang_cluster": "C#", "tags": ["constructive algorithms", "math", "combinatorics", "binary search", "greedy", "implementation"], "code_uid": "0a9bec6b59859aacb5fce56f6604b15e", "src_uid": "e03c6d3bb8cf9119530668765691a346", "difficulty": 1900.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Globalization;\nusing System.IO;\nusing System.Linq;\nusing System.Text;\nusing System.Threading;\n\n// (\u3065\u00b0\u03c9\u00b0)\u3065\uff90\u2605\u309c\u30fb\u3002\u3002\u30fb\u309c\u309c\u30fb\u3002\u3002\u30fb\u309c\u2606\u309c\u30fb\u3002\u3002\u30fb\u309c\u309c\u30fb\u3002\u3002\u30fb\u309c\npublic class Solver\n{\n public void Solve()\n {\n int n = ReadInt();\n int k = ReadInt();\n long m = ReadInt();\n \n var a = new long[n + 1];\n a[0] = 1;\n a[1] = 9;\n for (int i = 2; i < n; i++)\n a[i] = a[i - 1] * 10 % m;\n\n long ans = 0;\n var dp = new long[k];\n long d = 1;\n for (int i = 0; i < n; i++)\n {\n var ndp = new long[k];\n for (int j = 0; j < k; j++)\n for (int r = 0; r < 10; r++)\n {\n if (j == 0 && r == 0)\n continue;\n long x = j > 0 ? dp[j] : 1;\n int y = (int) ((j + r * d) % k);\n ndp[y] += x;\n if (y == 0)\n ans = (ans + x * a[n - i - 1]) % m;\n }\n for (int j = 0; j < k; j++)\n ndp[j] %= m;\n dp = ndp;\n d = d * 10 % k;\n }\n Write(ans);\n }\n\n #region Main\n\n protected static TextReader reader;\n protected static TextWriter writer;\n\n static void Main()\n {\n#if DEBUG\n reader = new StreamReader(\"..\\\\..\\\\input.txt\");\n writer = Console.Out;\n //writer = new StreamWriter(\"..\\\\..\\\\output.txt\");\n#else\n reader = new StreamReader(Console.OpenStandardInput());\n writer = new StreamWriter(Console.OpenStandardOutput());\n //reader = new StreamReader(\"game.in\");\n //writer = new StreamWriter(\"game.out\");\n#endif\n try\n {\n var thread = new Thread(new Solver().Solve, 1024 * 1024 * 256);\n thread.Start();\n thread.Join();\n// object result = new Solver().Solve();\n// if (result != null)\n// writer.WriteLine(result);\n }\n catch (Exception ex)\n {\n#if DEBUG\n Console.WriteLine(ex);\n#else\n Console.WriteLine(ex);\n throw;\n#endif\n }\n reader.Close();\n writer.Close();\n }\n\n #endregion\n\n #region Read / Write\n\n private static Queue currentLineTokens = new Queue();\n\n private static string[] ReadAndSplitLine()\n {\n return reader.ReadLine().Split(new[] { ' ', '\\t' }, StringSplitOptions.RemoveEmptyEntries);\n }\n\n public static string ReadToken()\n {\n while (currentLineTokens.Count == 0)\n currentLineTokens = new Queue(ReadAndSplitLine());\n return currentLineTokens.Dequeue();\n }\n\n public static int ReadInt()\n {\n return int.Parse(ReadToken());\n }\n\n public static long ReadLong()\n {\n return long.Parse(ReadToken());\n }\n\n public static double ReadDouble()\n {\n return double.Parse(ReadToken(), CultureInfo.InvariantCulture);\n }\n\n public static int[] ReadIntArray()\n {\n return ReadAndSplitLine().Select(int.Parse).ToArray();\n }\n\n public static long[] ReadLongArray()\n {\n return ReadAndSplitLine().Select(long.Parse).ToArray();\n }\n\n public static double[] ReadDoubleArray()\n {\n return ReadAndSplitLine().Select(s => double.Parse(s, CultureInfo.InvariantCulture)).ToArray();\n }\n\n public static int[][] ReadIntMatrix(int numberOfRows)\n {\n int[][] matrix = new int[numberOfRows][];\n for (int i = 0; i < numberOfRows; i++)\n matrix[i] = ReadIntArray();\n return matrix;\n }\n\n public static int[][] ReadAndTransposeIntMatrix(int numberOfRows)\n {\n int[][] matrix = ReadIntMatrix(numberOfRows);\n int[][] ret = new int[matrix[0].Length][];\n for (int i = 0; i < ret.Length; i++)\n {\n ret[i] = new int[numberOfRows];\n for (int j = 0; j < numberOfRows; j++)\n ret[i][j] = matrix[j][i];\n }\n return ret;\n }\n\n public static string[] ReadLines(int quantity)\n {\n string[] lines = new string[quantity];\n for (int i = 0; i < quantity; i++)\n lines[i] = reader.ReadLine().Trim();\n return lines;\n }\n\n public static void WriteArray(IEnumerable array)\n {\n writer.WriteLine(string.Join(\" \", array));\n }\n\n public static void Write(params object[] array)\n {\n WriteArray(array);\n }\n\n public static void WriteLines(IEnumerable array)\n {\n foreach (var a in array)\n writer.WriteLine(a);\n }\n\n #endregion\n}", "lang_cluster": "C#", "tags": ["dp", "implementation"], "code_uid": "9576ace76013e0c28c491b814e0b1058", "src_uid": "656bf8df1e79499aa2ab2c28712851f0", "difficulty": 2200.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Linq;\nusing System.Collections.Generic;\nusing Debug = System.Diagnostics.Debug;\nusing StringBuilder = System.Text.StringBuilder;\n//using System.Numerics;\nnamespace Program\n{\n public class Solver\n {\n public void Solve()\n {\n var n = sc.Integer();\n var k = sc.Long();\n var m = sc.Long();\n var dp = new long[1001, 101, 2];\n for (int i = 0; i < 1001; i++)\n for (int j = 0; j < 101; j++)\n for (int l = 0; l < 2; l++)\n dp[i, j, l] = -1;\n var pow1 = new long[1001];\n var pow2 = new long[1001];\n for (long i = 0, u = 1, v = 1; i < 1001; i++)\n {\n pow1[i] = u;\n pow2[i] = v;\n u = u * 10 % m;\n v = v * 10 % k;\n }\n Func dfs = null;\n dfs = (id, rem, f) =>\n {\n if (rem == 0 && f == 1)\n if (id != n) return (pow1[n - id - 1] * 9) % m;\n else return 1;\n if (id == n || (rem == 0 && f == 1)) return 0;\n if (dp[id, rem, f] >= 0) return dp[id, rem, f];\n long ret = 0;\n for (int i = 0; i < 10; i++)\n ret = (ret + dfs(id + 1,\n (int)((rem + i * pow2[id]) % k),\n ((f == 1 || i > 0) ? 1 : 0))) % m;\n return dp[id, rem, f] = ret;\n\n };\n IO.Printer.Out.WriteLine(dfs(0, 0, 0));\n }\n\n\n internal IO.StreamScanner sc = new IO.StreamScanner(Console.OpenStandardInput());\n static T[] Enumerate(int n, Func f) { var a = new T[n]; for (int i = 0; i < n; ++i) a[i] = f(); return a; }\n static T[] Enumerate(int n, Func f) { var a = new T[n]; for (int i = 0; i < n; ++i) a[i] = f(i); return a; }\n\n }\n\n}\n\n#region Ex\nnamespace Program.IO\n{\n using System.IO;\n using System.Linq;\n public class Printer : StreamWriter\n {\n static Printer()\n {\n Out = new Printer(Console.OpenStandardOutput()) { AutoFlush = false };\n }\n public static Printer Out { get; set; }\n public override IFormatProvider FormatProvider { get { return System.Globalization.CultureInfo.InvariantCulture; } }\n public Printer(System.IO.Stream stream) : base(stream, new System.Text.UTF8Encoding(false, true)) { }\n public void Write(string format, IEnumerable source) { base.Write(format, source.OfType().ToArray()); }\n public void WriteLine(string format, IEnumerable source) { base.WriteLine(format, source.OfType().ToArray()); }\n }\n public class StreamScanner\n {\n public StreamScanner(Stream stream) { str = stream; }\n private readonly Stream str;\n private readonly byte[] buf = new byte[1024];\n private int len, ptr;\n public bool isEof = false;\n public bool IsEndOfStream { get { return isEof; } }\n private byte read()\n {\n if (isEof) return 0;\n if (ptr >= len) { ptr = 0; if ((len = str.Read(buf, 0, 1024)) <= 0) { isEof = true; return 0; } }\n return buf[ptr++];\n }\n public char Char() { byte b = 0; do b = read(); while (b < 33 || 126 < b); return (char)b; }\n public char[] Char(int n) { var a = new char[n]; for (int i = 0; i < n; i++) a[i] = Char(); return a; }\n public string Scan()\n {\n var sb = new StringBuilder();\n for (var b = Char(); b >= 33 && b <= 126; b = (char)read())\n sb.Append(b);\n return sb.ToString();\n }\n public long Long()\n {\n if (isEof) return long.MinValue;\n long ret = 0; byte b = 0; var ng = false;\n do b = read();\n while (b != '-' && (b < '0' || '9' < b));\n if (b == '-') { ng = true; b = read(); }\n for (; true; b = read())\n {\n if (b < '0' || '9' < b)\n return ng ? -ret : ret;\n else ret = ret * 10 + b - '0';\n }\n }\n public int Integer() { return (isEof) ? int.MinValue : (int)Long(); }\n public double Double() { return double.Parse(Scan(), System.Globalization.CultureInfo.InvariantCulture); }\n private T[] enumerate(int n, Func f)\n {\n var a = new T[n];\n for (int i = 0; i < n; ++i) a[i] = f();\n return a;\n }\n\n public string[] Scan(int n) { return enumerate(n, Scan); }\n public double[] Double(int n) { return enumerate(n, Double); }\n public int[] Integer(int n) { return enumerate(n, Integer); }\n public long[] Long(int n) { return enumerate(n, Long); }\n public void Flush() { str.Flush(); }\n\n }\n}\nstatic class Ex\n{\n static public string AsString(this IEnumerable ie) { return new string(System.Linq.Enumerable.ToArray(ie)); }\n static public string AsJoinedString(this IEnumerable ie, string st = \" \") { return string.Join(st, ie); }\n static public void Main()\n {\n var solver = new Program.Solver();\n solver.Solve();\n Program.IO.Printer.Out.Flush();\n }\n}\n#endregion", "lang_cluster": "C#", "tags": ["dp", "implementation"], "code_uid": "4b5e971ca9c680efc2badc24a81c6191", "src_uid": "656bf8df1e79499aa2ab2c28712851f0", "difficulty": 2200.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Globalization;\nusing System.IO;\nusing System.Linq;\nusing System.Text;\nusing System.Threading;\n\n// (\u3065\u00b0\u03c9\u00b0)\u3065\uff90e\u2605\u309c\u30fb\u3002\u3002\u30fb\u309c\u309c\u30fb\u3002\u3002\u30fb\u309c\u2606\u309c\u30fb\u3002\u3002\u30fb\u309c\u309c\u30fb\u3002\u3002\u30fb\u309c\npublic class Solver\n{\n const int MOD = 1000000007;\n\n public void Solve()\n {\n int p = ReadInt();\n int k = ReadInt();\n\n long ans = 1;\n var f = new bool[p];\n for (int i = 1; i < p; i++)\n if (!f[i])\n {\n ans = ans * p % MOD;\n int x = i;\n while (!f[x])\n {\n f[x] = true;\n x = (int)(1L * x * k % p);\n }\n }\n if (k == 1)\n ans = ans * p % MOD;\n\n Write(ans);\n }\n\n #region Main\n\n protected static TextReader reader;\n protected static TextWriter writer;\n static void Main()\n {\n#if DEBUG\n reader = new StreamReader(\"..\\\\..\\\\input.txt\");\n //reader = new StreamReader(Console.OpenStandardInput());\n writer = Console.Out;\n //writer = new StreamWriter(\"..\\\\..\\\\output.txt\");\n#else\n reader = new StreamReader(Console.OpenStandardInput());\n writer = new StreamWriter(Console.OpenStandardOutput());\n //reader = new StreamReader(\"atoms.in\");\n //writer = new StreamWriter(\"atoms.out\");\n#endif\n try\n {\n //var thread = new Thread(new Solver().Solve, 1024 * 1024 * 128);\n //thread.Start();\n //thread.Join();\n new Solver().Solve();\n }\n catch (Exception ex)\n {\n Console.WriteLine(ex);\n#if DEBUG\n#else\n throw;\n#endif\n }\n reader.Close();\n writer.Close();\n }\n\n #endregion\n\n #region Read / Write\n private static Queue currentLineTokens = new Queue();\n private static string[] ReadAndSplitLine() { return reader.ReadLine().Split(new[] { ' ', '\\t', }, StringSplitOptions.RemoveEmptyEntries); }\n public static string ReadToken() { while (currentLineTokens.Count == 0)currentLineTokens = new Queue(ReadAndSplitLine()); return currentLineTokens.Dequeue(); }\n public static int ReadInt() { return int.Parse(ReadToken()); }\n public static long ReadLong() { return long.Parse(ReadToken()); }\n public static double ReadDouble() { return double.Parse(ReadToken(), CultureInfo.InvariantCulture); }\n public static int[] ReadIntArray() { return ReadAndSplitLine().Select(int.Parse).ToArray(); }\n public static long[] ReadLongArray() { return ReadAndSplitLine().Select(long.Parse).ToArray(); }\n public static double[] ReadDoubleArray() { return ReadAndSplitLine().Select(s => double.Parse(s, CultureInfo.InvariantCulture)).ToArray(); }\n public static int[][] ReadIntMatrix(int numberOfRows) { int[][] matrix = new int[numberOfRows][]; for (int i = 0; i < numberOfRows; i++)matrix[i] = ReadIntArray(); return matrix; }\n public static int[][] ReadAndTransposeIntMatrix(int numberOfRows)\n {\n int[][] matrix = ReadIntMatrix(numberOfRows); int[][] ret = new int[matrix[0].Length][];\n for (int i = 0; i < ret.Length; i++) { ret[i] = new int[numberOfRows]; for (int j = 0; j < numberOfRows; j++)ret[i][j] = matrix[j][i]; } return ret;\n }\n public static string[] ReadLines(int quantity) { string[] lines = new string[quantity]; for (int i = 0; i < quantity; i++)lines[i] = reader.ReadLine().Trim(); return lines; }\n public static void WriteArray(IEnumerable array) { writer.WriteLine(string.Join(\" \", array)); }\n public static void Write(params object[] array) { WriteArray(array); }\n public static void WriteLines(IEnumerable array) { foreach (var a in array)writer.WriteLine(a); }\n private class SDictionary : Dictionary\n {\n public new TValue this[TKey key]\n {\n get { return ContainsKey(key) ? base[key] : default(TValue); }\n set { base[key] = value; }\n }\n }\n private static T[] Init(int size) where T : new() { var ret = new T[size]; for (int i = 0; i < size; i++)ret[i] = new T(); return ret; }\n #endregion\n}", "lang_cluster": "C#", "tags": ["dfs and similar", "math", "combinatorics", "dsu", "number theory"], "code_uid": "c5a74d0a6d27fdb6345c9924e28b5cad", "src_uid": "580bf65af24fb7f08250ddbc4ca67e0e", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.IO;\nusing System.Text;\n\nnamespace Moodular_Arithmetic\n{\n internal class Program\n {\n private static readonly StreamReader reader = new StreamReader(Console.OpenStandardInput(1024*10), Encoding.ASCII, false, 1024*10);\n private static readonly StreamWriter writer = new StreamWriter(Console.OpenStandardOutput(1024*10), Encoding.ASCII, 1024*10);\n\n\n private static int[] pa;\n private static int[] size;\n\n private static int mod = 1000000007;\n\n private static long Pow(long a, int k)\n {\n long r = 1;\n while (k > 0)\n {\n if ((k & 1) == 1)\n {\n r = (r*a)%mod;\n }\n a = (a*a)%mod;\n k >>= 1;\n }\n return r;\n }\n\n private static void Main(string[] args)\n {\n int p = Next();\n long k = Next();\n\n if (k == 0)\n {\n writer.WriteLine(Pow(p, p - 1));\n writer.Flush();\n return;\n }\n if (k == 1)\n {\n writer.WriteLine(Pow(p, p));\n writer.Flush();\n return;\n }\n\n pa = new int[p];\n size = new int[p];\n\n for (int i = 0; i < pa.Length; i++)\n {\n pa[i] = i;\n size[i] = 1;\n }\n\n for (int i = 1; i < p; i++)\n {\n int pi = GP(i);\n int kpi = GP((int) ((k*i)%p));\n\n if (pi != kpi)\n {\n pa[pi] = kpi;\n size[kpi] += size[pi];\n }\n }\n\n var d = new Dictionary();\n for (int i = 1; i < p; i++)\n {\n if (pa[i] == i)\n {\n if (d.ContainsKey(size[i]))\n d[size[i]] = 1 + d[size[i]];\n else\n {\n d[size[i]] = 1;\n }\n }\n }\n\n long count = 1;\n\n foreach (var dd in d)\n {\n count = (count*Pow(dd.Key*dd.Value + 1, dd.Value))%mod;\n }\n\n\n writer.WriteLine(count);\n writer.Flush();\n }\n\n private static int GP(int i)\n {\n if (pa[i] == i)\n return i;\n return pa[i] = GP(pa[i]);\n }\n\n private static int Next()\n {\n int c;\n int res = 0;\n do\n {\n c = reader.Read();\n if (c == -1)\n return res;\n } while (c < '0' || c > '9');\n res = c - '0';\n while (true)\n {\n c = reader.Read();\n if (c < '0' || c > '9')\n return res;\n res *= 10;\n res += c - '0';\n }\n }\n }\n}", "lang_cluster": "C#", "tags": ["dsu", "math", "combinatorics", "number theory"], "code_uid": "0372a7ef15bd70dd452ad438744b6fff", "src_uid": "580bf65af24fb7f08250ddbc4ca67e0e", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Diagnostics;\n\nnamespace C\n{\n\tclass Measurer : IDisposable\n\t{\n\t\tpublic Measurer()\n\t\t{\n\t\t\tsw = new Stopwatch();\n\t\t\tsw.Start();\n\t\t}\n\n\t\tStopwatch sw { get; set; }\n\n\t\tpublic void Dispose()\n\t\t{\n\t\t\tsw.Stop();\n\t\t\t//Console.WriteLine(sw.Elapsed.ToString());\n\t\t}\n\t}\n\n\tclass Program\n\t{\n\t\tstatic void Main(string[] args)\n\t\t{\n\t\t\tvar m = RInt();\n\t\t\tvar a = R2Int();\n\t\t\tvar axy = R2Int();\n\t\t\tvar b = R2Int();\n\t\t\tvar bxy = R2Int();\n\n\t\t\tvar first = new int[] { a[0], b[0] };\n\n\t\t\tlong ticks = 0;\n\t\t\t//var l1 = new int[] { -1, -1 };\n\t\t\t//var l2 = new int[] { -1, -1 };\n\t\t\tvar p1 = new long[] { -1, -1 };\n\t\t\tvar p1i = 0;\n\t\t\tvar p2 = new long[] { -1, -1 };\n\t\t\tvar p2i = 0;\n\n\t\t\tusing (var me = new Measurer())\n\t\t\t{\n\t\t\t\tfor (var i = 0; i <= 3 * m; i++)\n\t\t\t\t{\n\t\t\t\t\tticks++;\n\t\t\t\t\ta[0] = Next(a, axy, m);\n\t\t\t\t\tb[0] = Next(b, bxy, m);\n\t\t\t\t\tif (a[0] == a[1] && p1i < 2)\n\t\t\t\t\t\tp1[p1i++] = ticks;\n\t\t\t\t\tif (b[0] == b[1] && p2i < 2)\n\t\t\t\t\t\tp2[p2i++] = ticks;\n\t\t\t\t\tif (p1i > 1 && p2i > 1)\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tfor (var i = 0; i < p1i; i++)\n\t\t\t\t{\n\t\t\t\t\tfor (var j = 0; j < p2i; j++)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (p1[i] == p2[j])\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tConsole.WriteLine(p1[i]);\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (p1i < 2 || p2i < 2)\n\t\t\t\t{\n\t\t\t\t\tConsole.WriteLine(\"-1\");\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tusing (var me = new Measurer())\n\t\t\t{\n\t\t\t\tp1[1] = p1[1] - p1[0];\n\t\t\t\tp2[1] = p2[1] - p2[0];\n\t\t\t\tfor (var i = 0; i <= m; i++)\n\t\t\t\t{\n\t\t\t\t\tlong x = p1[0] + p1[1] * i;\n\t\t\t\t\tif ((x - p2[0]) < 0)\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\tlong kmod = (x - p2[0]) % p2[1];\n\t\t\t\t\tif (kmod == 0)\n\t\t\t\t\t{\n\t\t\t\t\t\tConsole.WriteLine(x);\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tConsole.WriteLine(\"-1\");\n\t\t\tConsole.ReadLine();\n\t\t}\n\n\t\tstatic int RInt()\n\t\t{\n\t\t\treturn int.Parse(Console.ReadLine());\n\t\t}\n\t\tstatic int[] R2Int()\n\t\t{\n\t\t\treturn Console.ReadLine().Split(' ').Select(v => int.Parse(v)).ToArray();\n\t\t}\n\n\t\tstatic int Next(int[] v, int[] xy, int m)\n\t\t{\n\t\t\treturn (int)(((long)xy[0] * (long)v[0] + (long)xy[1]) % m);\n\t\t}\n\t}\n}\n", "lang_cluster": "C#", "tags": ["math", "greedy", "number theory"], "code_uid": "a5267dffa0ac918788eb39d486109a59", "src_uid": "7225266f663699ff7e16b726cadfe9ee", "difficulty": 2200.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\n\nnamespace z3\n{\n class Program\n {\n static private int gcd(int x, int y)\n {\n return (x>0) ? gcd(y%x,x) : y;\n }\n\n static private int max(int a, int b)\n {\n return (a>b)?a:b;\n }\n\n static private int nextHc(int x, int y, int m, int h)\n {\n long tt = (long)x * (long)h + (long)y;\n return (int)(tt%(long)m);\n }\n\n static private void swapvars(ref int a, ref int b)\n {\n int k = b;\n b = a;\n a = k;\n }\n\n static private void calc(ref int m, ref int x1, ref int y1, ref int h1, ref int a1, ref int x2, ref int y2, ref int h2, ref int a2, ref int period1, ref int period2)\n {\n long t = 1;\n List hs = new List(capacity: m);\n if(period1 <= period2)\n {\n swapvars(ref x1,ref x2);\n swapvars(ref y1,ref y2);\n swapvars(ref h1,ref h2);\n swapvars(ref a1,ref a2);\n swapvars(ref period1, ref period2);\n }\n while(h2 != a2)\n {\n h1 = nextHc(x1, y1, m, h1);\n h2 = nextHc(x2, y2, m, h2);\n /*if((h1 == a1) && (h2 == a2))\n {\n Console.Write(t);\n return;\n }*/\n ++t;\n }\n //h2 == a2 now\n int hh = h1;\n hs.Add(hh);\n for(int i = 1; i < period1; ++i)\n {\n hh = nextHc(x1, y1, m, hh);\n hs.Add(hh);\n }\n int k = 0;\n while(true)\n {\n k += period2;\n k = k%period1;\n h1 = hs[k];\n t += (long)period2;\n if(h1 == a1)\n {\n Console.Write(t-1);\n return;\n }\n }\n }\n\n\n static void Main(string[] args)\n {\n int m;\n int h1, a1, x1, y1, h2, a2, x2, y2;\n string ms = Console.ReadLine();\n m = Convert.ToInt32(ms);\n string[] ha1 = Console.ReadLine().Split(null);\n h1 = Convert.ToInt32(ha1[0]);\n a1 = Convert.ToInt32(ha1[1]);\n string[] xy1 = Console.ReadLine().Split(null);\n x1 = Convert.ToInt32(xy1[0]);\n y1 = Convert.ToInt32(xy1[1]);\n string[] ha2 = Console.ReadLine().Split(null);\n h2 = Convert.ToInt32(ha2[0]);\n a2 = Convert.ToInt32(ha2[1]);\n string[] xy2 = Console.ReadLine().Split(null);\n x2 = Convert.ToInt32(xy2[0]);\n y2 = Convert.ToInt32(xy2[1]);\n int t = 1;\n int h1saved = h1, h2saved = h2;\n int period1 = 0, period2 = 0;\n for (int i = 0; i < m + 1; ++i)\n {\n h1 = nextHc(x1, y1, m, h1);\n h2 = nextHc(x2, y2, m, h2);\n if ((h1 == a1) && (h2 == a2))\n {\n Console.Write(t);\n return;\n }\n ++t;\n }\n int h1prev = h1, h2prev = h2;\n int a1flag = 0;\n int a2flag = 0;\n do\n {\n h1 = nextHc(x1, y1, m, h1);\n ++period1;\n if ((h1 == a1) && (a1flag == 0)) a1flag = 1;\n } while (h1 != h1prev);\n do\n {\n h2 = nextHc(x2, y2, m, h2);\n ++period2;\n if ((h2 == a2) && (a2flag == 0)) a2flag = 1;\n } while (h2 != h2prev);\n\n if ((a1flag == 0) || (a2flag == 0))\n {\n Console.Write(\"-1\");\n return;\n }\n\n if ((gcd(period1, period2) == 1) && (period1 > 1) && (period2 > 1))\n {\n calc(ref m, ref x1, ref y1, ref h1saved, ref a1, ref x2, ref y2, ref h2saved, ref a2, ref period1, ref period2);\n return;\n }\n else\n {\n Console.Write(\"-1\");\n return;\n }\n }\n }\n}\n\n\n\n\n\n\n\n\n\n\n", "lang_cluster": "C#", "tags": ["math", "greedy", "number theory"], "code_uid": "f35e33bc37bf4972e6926efd164764ce", "src_uid": "7225266f663699ff7e16b726cadfe9ee", "difficulty": 2200.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeff\ufeff\ufeffusing System;\n using System.Collections.Generic;\n using System.Globalization;\nusing System.IO;\nusing System.Linq;\n\nnamespace CF\n{\n internal class Program\n {\n private static void Main(string[] args)\n {\n using (var sr = new InputReader(Console.In))\n//\t\t\tusing (var sr = new InputReader(new StreamReader(\"input.txt\")))\n using (var sw = Console.Out)\n //using (var sw = new StreamWriter(\"output.txt\"))\n using (var task = new Task(sr, sw)) {\n task.Solve();\n// Console.ReadKey();\n }\n }\n }\n\n internal class Task : IDisposable\n {\n private readonly InputReader sr;\n private readonly TextWriter sw;\n private bool isDispose;\n private long[] array;\n private Tuple[] costs;\n private long best = Int64.MaxValue;\n private Dictionary cache = new Dictionary();\n\n public Task(InputReader sr, TextWriter sw)\n {\n this.sr = sr;\n this.sw = sw;\n }\n \n public void Solve()\n {\n var n = sr.NextInt32();\n var l = sr.NextInt64();\n array = sr.ReadArrayOfInt64();\n costs = new Tuple[n];\n for (var i = 0; i < n; i++) {\n var pow = (long) Math.Pow(2, i);\n costs[i] = Tuple.Create(array[i], pow, (double)array[i]/pow);\n }\n sw.WriteLine(Min(l, n, 0L));\n }\n\n private long Min(long l, int indx, long val)\n {\n if (cache.ContainsKey(val))\n return cache[val];\n \n if (val >= best)\n return best;\n \n if (l <= 0) {\n best = Math.Min(val, best);\n return val;\n }\n\n var result = Int64.MaxValue;\n for (var i = indx - 1; i >= 0; i--) {\n var d = l / costs[i].Item2;\n if (d == 0)\n d++;\n \n var curr = val + d * costs[i].Item1;\n var res = Min(l - d * costs[i].Item2, i, curr);\n \n result = Math.Min(res, result);\n if (l > d * costs[i].Item2) {\n result = Math.Min(result, curr + costs[i].Item1);\n best = Math.Min(best, result);\n }\n }\n cache.Add(val, result);\n\n return result;\n }\n \n ~Task()\n {\n Dispose(false);\n }\n \n public void Dispose()\n {\n Dispose(true);\n GC.SuppressFinalize(this);\n }\n \n private void Dispose(bool disposing)\n {\n if (!isDispose) {\n if (disposing) {\n if(sr != null)\n sr.Dispose();\n \n if(sw != null)\n sw.Dispose();\n }\n\n isDispose = true;\n }\n }\n }\n}\n\ninternal class InputReader : IDisposable\n{\n private bool isDispose;\n private readonly TextReader sr;\n private string[] buffer;\n private int seek;\n\n public InputReader(TextReader stream)\n {\n sr = stream;\n }\n\n public void Dispose()\n {\n Dispose(true);\n GC.SuppressFinalize(this);\n }\n\n public string NextString()\n {\n var result = sr.ReadLine();\n return result;\n }\n\n public int NextInt32()\n {\n return Int32.Parse(ReadNextToken());\n }\n\n private string ReadNextToken()\n {\n if (buffer == null || seek == buffer.Length) {\n seek = 0;\n buffer = NextSplitStrings();\n }\n\n return buffer[seek++];\n }\n\n public long NextInt64()\n {\n return Int64.Parse(ReadNextToken());\n }\n \n public int[] ReadArrayOfInt32()\n {\n return ReadArray(Int32.Parse);\n }\n\n public long[] ReadArrayOfInt64()\n {\n return ReadArray(Int64.Parse);\n }\n\n public string[] NextSplitStrings()\n {\n return NextString()\n .Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);\n }\n\n public T[] ReadArray(Func func)\n {\n return NextSplitStrings()\n .Select(s => func(s, CultureInfo.InvariantCulture))\n .ToArray();\n }\n\n public T[] ReadArrayFromString(Func func, string str)\n {\n return\n str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)\n .Select(s => func(s, CultureInfo.InvariantCulture))\n .ToArray();\n }\n\n protected void Dispose(bool dispose)\n {\n if (!isDispose)\n {\n if (dispose)\n sr.Close();\n \n isDispose = true;\n }\n }\n\n ~InputReader()\n {\n Dispose(false);\n }\n}", "lang_cluster": "C#", "tags": ["greedy", "dp", "bitmasks"], "code_uid": "90292e1432fa55b70f1ff2ebc2899d67", "src_uid": "04ca137d0383c03944e3ce1c502c635b", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Linq;\n\nclass Program\n{\n static void Main(string[] args)\n {\n int[] input = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();\n int n = input[0];\n long L = input[1];\n int[] c = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();\n\n for (var i = 1; i < n; ++i)\n // Replace a bottle with multiple smaller bottles.\n c[i] = Math.Min(c[i], 2 * c[i - 1]);\n for (var i = n - 2; i >= 0; --i)\n // Replace a bottle with a bigger one.\n c[i] = Math.Min(c[i], c[i + 1]);\n\n var minPrice = long.MaxValue;\n var price = 0L;\n for (var i = n - 1; i >= 0; --i)\n {\n int vi = 1 << i;\n price += (L / vi) * c[i];\n L %= vi;\n if (L == 0)\n {\n minPrice = Math.Min(price, minPrice);\n break;\n }\n // One option is to add another bottle for the rest.\n minPrice = Math.Min(price + c[i], minPrice);\n // Another is to keep filling smaller bottles.\n }\n Console.WriteLine(minPrice);\n }\n}", "lang_cluster": "C#", "tags": ["greedy", "dp", "bitmasks"], "code_uid": "e2b1bbcee0fb5a6ec79d86db3c0d2608", "src_uid": "04ca137d0383c03944e3ce1c502c635b", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.IO;\nusing System.Collections.Generic;\nusing System.Linq;\n\nnamespace CodeForces\n{\n class Tokenizer\n {\n int pos;\n string[] tokens;\n TextReader reader;\n\n public Tokenizer(TextReader reader)\n {\n pos = 0;\n tokens = new string[] { };\n this.reader = reader;\n }\n\n\n public string NextToken()\n {\n if (pos == tokens.Length)\n {\n tokens = reader.ReadLine().Split(' ');\n pos = 0;\n }\n return tokens [pos++];\n }\n\n public int NextInt()\n {\n return int.Parse(NextToken());\n }\n }\n\n class MainClass\n {\n static Tokenizer t;\n static TextWriter w;\n\n public static void Init()\n {\n t = new Tokenizer(Console.In);\n w = Console.Out;\n //t = new Tokenizer(File.OpenText(@\"../../in.txt\"));\n //w = File.CreateText(@\"../../out.txt\");\n }\n\n public static void Main(string[] args)\n {\n Init();\n int n = t.NextInt();\n\n int[] machine = new int[n + 1];\n int[] inDegree = new int[n + 1];\n\n for (int i = 1; i <= n; i++)\n machine [i] = t.NextInt();\n\n var a = new List[n + 1];\n for (int i = 1; i <= n; i++)\n a [i] = new List();\n\n for (int i = 1; i <= n; i++)\n {\n int k = t.NextInt();\n inDegree [i] = k;\n while (k-- > 0)\n {\n a [t.NextInt()].Add(i);\n }\n }\n\n int cost = int.MaxValue;\n for (int start = 1; start <= 3; start++)\n {\n int curCost = n;\n int[] curInDegree = (int[])inDegree.Clone();\n var q = new Queue[4];\n for (int i = 1; i <= 3; i++)\n q [i] = new Queue();\n int rem = n;\n for (int i = 1; i <= n; i++)\n if (inDegree [i] == 0)\n q [machine [i]].Enqueue(i);\n int curMachine = start;\n while (true)\n {\n while (q[curMachine].Count != 0)\n {\n int curJob = q [curMachine].Dequeue();\n foreach (var job in a[curJob])\n {\n curInDegree [job]--;\n if (curInDegree [job] == 0)\n q [machine [job]].Enqueue(job);\n }\n rem--;\n }\n if (rem == 0)\n break;\n\n curCost++;\n curMachine++;\n if (curMachine == 4)\n curMachine = 1;\n }\n cost = Math.Min(cost, curCost);\n\n }\n\n w.WriteLine(cost);\n }\n }\n}", "lang_cluster": "C#", "tags": ["brute force", "greedy"], "code_uid": "7e051d84972c968f44569be60d88d422", "src_uid": "be42e213ff43e303e475d77a9560367f", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.IO;\nusing System.Collections.Generic;\n\nnamespace CodeForces\n{\n class Tokenizer\n {\n int pos;\n string[] tokens;\n TextReader reader;\n\n public Tokenizer(TextReader reader)\n {\n pos = 0;\n tokens = new string[] { };\n this.reader = reader;\n }\n\n\n public string NextToken()\n {\n if (pos == tokens.Length)\n {\n tokens = reader.ReadLine().Split(' ');\n pos = 0;\n }\n return tokens [pos++];\n }\n\n public int NextInt()\n {\n return int.Parse(NextToken());\n }\n }\n\n class MainClass\n {\n static Tokenizer t;\n static TextWriter w;\n\n public static void Init()\n {\n t = new Tokenizer(Console.In);\n w = Console.Out;\n //t = new Tokenizer(File.OpenText(@\"../../in.txt\"));\n //w = File.CreateText(@\"../../out.txt\");\n }\n\n public static void Main(string[] args)\n {\n Init();\n int n = t.NextInt();\n List[] c = new List[4];\n for (int i = 0; i < 4; i++)\n c [i] = new List();\n for (int i = 1; i <= n; i++)\n c [t.NextInt()].Add(i);\n\n List[] dep = new List[n + 1];\n for (int i = 1; i <= n; i++)\n dep [i] = new List();\n int[] waitCount = new int[n + 1];\n for (int i = 1; i <= n; i++)\n {\n int k = t.NextInt();\n waitCount [i] = k;\n for (int j = 0; j < k; j++)\n dep [t.NextInt()].Add(i);\n }\n\n int cost = int.MaxValue;\n for (int start = 1; start <= 3; start++)\n {\n bool[] done = new bool[n + 1];\n int[] curWaitCount = (int[])waitCount.Clone();\n\n int cur = start;\n int rem = n;\n int curCost = 0;\n while (rem > 0)\n {\n for (int j = 0; j < c[cur].Count; j++)\n {\n foreach (var a in c[cur])\n {\n if (done [a])\n continue;\n if (curWaitCount [a] == 0)\n {\n foreach (var b in dep[a])\n curWaitCount [b]--;\n done [a] = true;\n rem--;\n }\n }\n }\n cur++;\n if (cur == 4)\n cur = 1;\n if (rem > 0)\n curCost++;\n }\n\n cost = Math.Min(cost, curCost);\n }\n\n cost += n;\n w.WriteLine(cost);\n w.Close();\n }\n }\n}", "lang_cluster": "C#", "tags": ["brute force", "greedy"], "code_uid": "9406913b39bf78180a722dd0c9484c4b", "src_uid": "be42e213ff43e303e475d77a9560367f", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\n\nnamespace ProgrammingContest.Codeforces.Round88 {\n class B {\n static void Main() {\n var xs = Array.ConvertAll(Console.ReadLine().Split(' '), sss => long.Parse(sss));\n long a = xs[0], b = xs[1], mod = xs[2];\n for (long i = 0; i < mod && i <= a; i++) {\n long v = 1000000000L * i % mod;\n if ((mod - v) % mod > b) {\n Console.WriteLine(\"1 {0}\", i.ToString().PadLeft(9, '0'));\n return;\n }\n }\n Console.WriteLine(2);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "number theory"], "code_uid": "2b8600e38f52cd21bda17402d511bf35", "src_uid": "8b6f633802293202531264446d33fee5", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\n\nnamespace TaskB\n{\n class Program\n {\n static void Main(string[] args)\n {\n var data = Console.ReadLine().Split(new [] {' '}, StringSplitOptions.RemoveEmptyEntries);\n var a = int.Parse(data[0]);\n var b = int.Parse(data[1]);\n var mod = int.Parse(data[2]);\n\n for (var s1 = 0; s1 <= Math.Min(mod, a); s1++)\n { \n long k = ((long)1000000000*s1)%mod;\n long s2 = 0;\n if (k != 0)\n s2 = mod - k;\n if (s2 < 0 || s2 > b)\n {\n Console.WriteLine(\"{0} {1:D9}\", 1, s1);\n return;\n }\n }\n Console.WriteLine(2);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "number theory"], "code_uid": "90581a36bbf1ed6acd5e6e1b11743fe7", "src_uid": "8b6f633802293202531264446d33fee5", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.IO;\nusing System.Numerics;\nusing System.Text;\n\nnamespace Hack_it\n{\n internal class Program\n {\n private static readonly StreamReader reader = new StreamReader(Console.OpenStandardInput(1024*10), Encoding.ASCII, false, 1024*10);\n private static readonly StreamWriter writer = new StreamWriter(Console.OpenStandardOutput(1024*10), Encoding.ASCII, 1024*10);\n\n private static void Main(string[] args)\n {\n BigInteger sum = 0;\n BigInteger count = 1;\n int i = 1;\n for (; i < 20; i++)\n {\n count *= 10;\n }\n for (int j = 1; j < 10; j++)\n {\n sum += count*j*i;\n }\n sum += 1;\n count *= 10;\n\n BigInteger a = BigInteger.Parse(reader.ReadLine());\n\n BigInteger d = sum%a;\n if (d != 0)\n {\n d = a - d;\n }\n\n writer.WriteLine(\"{0} {1}\", d + 1, count + d);\n writer.Flush();\n }\n }\n}", "lang_cluster": "C#", "tags": ["constructive algorithms"], "code_uid": "08782849d0396682ffeb1417703f5bbf", "src_uid": "52b8d97f216ea22693bc16fadcd46dae", "difficulty": 2500.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\n\nnamespace BetaRound39\n{\n class Program\n {\n static void Main(string[] args)\n {\n new Task2().Solve();\n }\n\n protected class Task2 : Task\n {\n public override void Solve()\n {\n int n = ReadInt();\n int m = ReadInt();\n int x = ReadInt();\n\n Console.WriteLine(Count(n - (x - 1) * 2, m - (x - 1) * 2) - Count(n - x * 2, m - x * 2));\n }\n\n private static int Count(int n, int m)\n {\n if (n <= 0 || m <= 0)\n return 0;\n\n return (n * m + 1) / 2;\n }\n }\n\n protected abstract class Task\n {\n private int curToken = 0;\n private string[] curTokens = new string[0];\n\n public abstract void Solve();\n\n protected int ReadInt()\n {\n while (curToken >= curTokens.Length)\n {\n curTokens = Console.ReadLine().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);\n curToken = 0;\n }\n\n var result = int.Parse(curTokens[curToken]);\n curToken++;\n\n return result;\n }\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math"], "code_uid": "69a339aec435c5ed837ffba64db815ab", "src_uid": "fa1ef5f9bceeb7266cc597ba8f2161cb", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\n\nnamespace Task2_2\n{\n class Program\n {\n static void Main(string[] args)\n {\n string line = Console.ReadLine();\n string[] arg1 = line.Split();\n\n int n = int.Parse(arg1[0]);\n int m = int.Parse(arg1[1]);\n\n line = Console.ReadLine();\n int x = int.Parse(line);\n\n int[] counts = new int[Math.Max(n,m)];\n int i = 0;\n while (n > 0 && m > 0)\n {\n counts[i] = Count(n, m);\n n -= 2;\n m -= 2;\n i++;\n }\n\n\n for (int j = 0; j < i-1; j++)\n {\n counts[j] -= counts[j + 1];\n }\n\n if (x > i)\n Console.WriteLine(0);\n else\n Console.WriteLine(counts[x-1]);\n }\n\n private static int Count(int n, int m)\n {\n int sum = 0;\n\n if (m % 2 == 0)\n {\n for (int i = 0; i < n; i++)\n sum += m / 2;\n }\n else\n {\n for (int i = 0; i < n; i++)\n sum += (m + Minus1(i) )/2;\n }\n\n return sum;\n }\n\n private static int Minus1(int n)\n {\n return (n%2 == 0 ? 1 : -1);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math"], "code_uid": "1e0e4a61f89ab53eb9651e0c3f05669e", "src_uid": "fa1ef5f9bceeb7266cc597ba8f2161cb", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using CodeforcesRound643Div2.Questions;\nusing CodeforcesRound643Div2.Extensions;\nusing System;\nusing System.Collections.Generic;\nusing System.IO;\nusing System.Linq;\nusing System.Text;\n\nnamespace CodeforcesRound643Div2.Questions\n{\n public class QuestionC : AtCoderQuestionBase\n {\n public override IEnumerable Solve(TextReader inputStream)\n {\n var (a, b, c, d) = inputStream.ReadValue();\n\n long count = 0;\n for (long x = a; x <= b; x++)\n {\n var minY = Math.Max(BoundaryBinarySearch(y => x + y > c, 0, c), b);\n var maxY = c;\n long width = maxY - minY + 1;\n if (width <= 0)\n {\n continue;\n }\n\n long begin = x + minY - 1;\n long overall = (begin + begin + width - 1) * width / 2;\n\n long overBegin = Math.Max(x + minY - d - 1, 1);\n long overEnd = x + maxY - d - 1;\n\n long over = overEnd > 0 ? (overBegin + overEnd) * (overEnd - overBegin + 1) / 2 : 0;\n long withRestriction = Math.Max(overall - (c - 1) * width - over, 0);\n\n\n count += withRestriction;\n }\n\n yield return count;\n }\n private static int BoundaryBinarySearch(Predicate predicate, int ng, int ok)\n {\n // \u3081\u3050\u308b\u5f0f\u4e8c\u5206\u63a2\u7d22\n // Span.BinarySearch\u3060\u3068\u3067\u304d\u305d\u3046\u3067\u3067\u304d\u306a\u3044\uff08lower_bound\u304c\u30c0\u30e1\uff09\n while (Math.Abs(ok - ng) > 1)\n {\n int mid = (ok + ng) / 2;\n\n if (predicate(mid))\n {\n ok = mid;\n }\n else\n {\n ng = mid;\n }\n }\n return ok;\n }\n }\n}\n\n\nnamespace CodeforcesRound643Div2\n{\n class Program\n {\n static void Main(string[] args)\n {\n IAtCoderQuestion question = new QuestionC(); // \u554f\u984c\u306b\u5408\u308f\u305b\u3066\u66f8\u304d\u63db\u3048\n var answers = question.Solve(Console.In);\n\n var writer = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };\n Console.SetOut(writer);\n foreach (var answer in answers)\n {\n Console.WriteLine(answer);\n }\n Console.Out.Flush();\n }\n }\n}\n\n#region Base Class\n\nnamespace CodeforcesRound643Div2.Questions\n{\n\n public interface IAtCoderQuestion\n {\n IEnumerable Solve(string input);\n IEnumerable Solve(TextReader inputStream);\n }\n\n public abstract class AtCoderQuestionBase : IAtCoderQuestion\n {\n public IEnumerable Solve(string input)\n {\n var stream = new MemoryStream(Encoding.Unicode.GetBytes(input));\n var reader = new StreamReader(stream, Encoding.Unicode);\n\n return Solve(reader);\n }\n\n public abstract IEnumerable Solve(TextReader inputStream);\n }\n}\n\n#endregion\n\n#region Extensions\n\nnamespace CodeforcesRound643Div2.Extensions\n{\n internal static class TextReaderExtensions\n {\n internal static int ReadInt(this TextReader reader) => int.Parse(ReadString(reader));\n internal static long ReadLong(this TextReader reader) => long.Parse(ReadString(reader));\n internal static double ReadDouble(this TextReader reader) => double.Parse(ReadString(reader));\n internal static string ReadString(this TextReader reader) => reader.ReadLine();\n\n internal static int[] ReadIntArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(int.Parse).ToArray();\n internal static long[] ReadLongArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(long.Parse).ToArray();\n internal static double[] ReadDoubleArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(double.Parse).ToArray();\n internal static string[] ReadStringArray(this TextReader reader, char separator = ' ') => reader.ReadLine().Split(separator);\n\n // Supports primitive type only.\n internal static T1 ReadValue(this TextReader reader) => (T1)Convert.ChangeType(reader.ReadLine(), typeof(T1));\n\n internal static (T1, T2) ReadValue(this TextReader reader, char separator = ' ')\n {\n var inputs = ReadStringArray(reader, separator);\n var v1 = (T1)Convert.ChangeType(inputs[0], typeof(T1));\n var v2 = (T2)Convert.ChangeType(inputs[1], typeof(T2));\n return (v1, v2);\n }\n\n internal static (T1, T2, T3) ReadValue(this TextReader reader, char separator = ' ')\n {\n var inputs = ReadStringArray(reader, separator);\n var v1 = (T1)Convert.ChangeType(inputs[0], typeof(T1));\n var v2 = (T2)Convert.ChangeType(inputs[1], typeof(T2));\n var v3 = (T3)Convert.ChangeType(inputs[2], typeof(T3));\n return (v1, v2, v3);\n }\n\n internal static (T1, T2, T3, T4) ReadValue(this TextReader reader, char separator = ' ')\n {\n var inputs = ReadStringArray(reader, separator);\n var v1 = (T1)Convert.ChangeType(inputs[0], typeof(T1));\n var v2 = (T2)Convert.ChangeType(inputs[1], typeof(T2));\n var v3 = (T3)Convert.ChangeType(inputs[2], typeof(T3));\n var v4 = (T4)Convert.ChangeType(inputs[3], typeof(T4));\n return (v1, v2, v3, v4);\n }\n\n internal static (T1, T2, T3, T4, T5) ReadValue(this TextReader reader, char separator = ' ')\n {\n var inputs = ReadStringArray(reader, separator);\n var v1 = (T1)Convert.ChangeType(inputs[0], typeof(T1));\n var v2 = (T2)Convert.ChangeType(inputs[1], typeof(T2));\n var v3 = (T3)Convert.ChangeType(inputs[2], typeof(T3));\n var v4 = (T4)Convert.ChangeType(inputs[3], typeof(T4));\n var v5 = (T5)Convert.ChangeType(inputs[4], typeof(T5));\n return (v1, v2, v3, v4, v5);\n }\n\n internal static (T1, T2, T3, T4, T5, T6) ReadValue(this TextReader reader, char separator = ' ')\n {\n var inputs = ReadStringArray(reader, separator);\n var v1 = (T1)Convert.ChangeType(inputs[0], typeof(T1));\n var v2 = (T2)Convert.ChangeType(inputs[1], typeof(T2));\n var v3 = (T3)Convert.ChangeType(inputs[2], typeof(T3));\n var v4 = (T4)Convert.ChangeType(inputs[3], typeof(T4));\n var v5 = (T5)Convert.ChangeType(inputs[4], typeof(T5));\n var v6 = (T6)Convert.ChangeType(inputs[5], typeof(T6));\n return (v1, v2, v3, v4, v5, v6);\n }\n\n internal static (T1, T2, T3, T4, T5, T6, T7) ReadValue(this TextReader reader, char separator = ' ')\n {\n var inputs = ReadStringArray(reader, separator);\n var v1 = (T1)Convert.ChangeType(inputs[0], typeof(T1));\n var v2 = (T2)Convert.ChangeType(inputs[1], typeof(T2));\n var v3 = (T3)Convert.ChangeType(inputs[2], typeof(T3));\n var v4 = (T4)Convert.ChangeType(inputs[3], typeof(T4));\n var v5 = (T5)Convert.ChangeType(inputs[4], typeof(T5));\n var v6 = (T6)Convert.ChangeType(inputs[5], typeof(T6));\n var v7 = (T7)Convert.ChangeType(inputs[6], typeof(T7));\n return (v1, v2, v3, v4, v5, v6, v7);\n }\n }\n}\n\n#endregion", "lang_cluster": "C#", "tags": ["two pointers", "math", "implementation", "binary search"], "code_uid": "92909fba7beab1864a205a7117d26c66", "src_uid": "4f92791b9ec658829f667fcea1faee01", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Linq;\nusing CompLib.Collections.Generic;\nusing CompLib.Util;\n\npublic class Program\n{\n int A, B, C, D;\n public void Solve()\n {\n var sc = new Scanner();\n A = sc.NextInt();\n B = sc.NextInt();\n C = sc.NextInt();\n D = sc.NextInt();\n\n // a<=x<=b<=y<=c<=z<=d \u306ax,y,z\u306a\u4e09\u89d2\u5f62\u304c\u3044\u304f\u3064\u304b?\n\n // x+y = i\u306e\u3084\u3064\u3044\u304f\u3064\u304b?\n var st = new LazySegmentTree((l, r) => l + r, 0, (l, r) => l * r, (l, r) => l + r, 0);\n for (int x = A; x <= B; x++)\n {\n int min = x + B;\n int max = x + C;\n st.Update(min, max + 1, 1);\n }\n long ans = 0;\n for (int z = C; z <= D; z++)\n {\n // x+y > z\n\n ans += st.Query(z + 1, B + C + 1);\n }\n Console.WriteLine(ans);\n }\n\n public static void Main(string[] args) => new Program().Solve();\n}\n\n\nnamespace CompLib.Collections.Generic\n{\n using System;\n\n public class LazySegmentTree\n {\n private const int N = 1 << 20;\n private readonly T[] _array;\n private readonly T[] _tmp;\n private readonly bool[] _flag;\n\n\n private readonly T _identity, _updateIdentity;\n private readonly Func _operation, _update;\n private readonly Func _multiplication;\n\n /// \n /// \u30b3\u30f3\u30b9\u30c8\u30e9\u30af\u30bf updateIdentity\u3067\u521d\u671f\u5316\n /// \n /// \u533a\u9593\u6f14\u7b97\u7528\u306e\u6f14\u7b97\n /// (T, operation)\u306e\u5358\u4f4d\u5143\n /// (T, operation)\u306e\u30b9\u30ab\u30e9\u30fc\u4e57\u7b97\n /// \u533a\u9593\u66f4\u65b0\u7528\u306e\u6f14\u7b97\n /// (T, update)\u306e\u5de6\u5358\u4f4d\u5143\n public LazySegmentTree(Func operation, T identity, Func multiplication, Func update,\n T updateIdentity)\n {\n _operation = operation;\n _identity = identity;\n _multiplication = multiplication;\n _update = update;\n _updateIdentity = updateIdentity;\n _array = new T[2 * N];\n for (int i = 0; i < N; i++)\n {\n _array[i + N] = _updateIdentity;\n }\n\n for (int i = N - 1; i >= 1; i--)\n {\n _array[i] = _operation(_array[i * 2], _array[i * 2 + 1]);\n }\n\n _tmp = new T[2 * N];\n for (int i = 1; i < 2 * N; i++)\n {\n _tmp[i] = _updateIdentity;\n }\n\n _flag = new bool[2 * N];\n }\n\n private void Eval(int k, int l, int r)\n {\n if (_flag[k])\n {\n if (r - l > 1)\n {\n _tmp[k * 2] = _update(_tmp[k * 2], _tmp[k]);\n _flag[k * 2] = true;\n _tmp[k * 2 + 1] = _update(_tmp[k * 2 + 1], _tmp[k]);\n _flag[k * 2 + 1] = true;\n }\n\n _array[k] = _update(_array[k], _multiplication(_tmp[k], r - l));\n _tmp[k] = _updateIdentity;\n _flag[k] = false;\n }\n }\n\n private void Update(int left, int right, int k, int l, int r, T n)\n {\n Eval(k, l, r);\n if (r <= left || right <= l) return;\n if (left <= l && r <= right)\n {\n // \u672c\u5f53\u306f _update(tmp[k], n)\u3060\u3051\u3069 \u4e0a\u3067Eval()\u3057\u305f\u306e\u3067 _tmp[k]\u306f\u5358\u4f4d\u5143\n _tmp[k] = n;\n _flag[k] = true;\n Eval(k, l, r);\n }\n else\n {\n Update(left, right, k * 2, l, (l + r) / 2, n);\n Update(left, right, k * 2 + 1, (l + r) / 2, r, n);\n _array[k] = _operation(_array[k * 2], _array[k * 2 + 1]);\n }\n }\n\n /// \n /// [left, right)\u3092update(A[i], n)\u306b\u66f4\u65b0\u3059\u308b\n /// \n /// \u53f3\u7aef\n /// \u5de6\u7aef\n /// \u5024\n public void Update(int left, int right, T n) => Update(left, right, 1, 0, N, n);\n\n /// \n /// A[i]\u3092update(A[i] ,n)\u306b\u66f4\u65b0\u3059\u308b\n /// \n /// index\n /// \u5024\n public void Update(int i, T n) => Update(i, i + 1, n);\n\n private T Query(int left, int right, int k, int l, int r)\n {\n Eval(k, l, r);\n if (r <= left || right <= l) return _identity;\n if (left <= l && r <= right) return _array[k];\n return _operation(Query(left, right, k * 2, l, (l + r) / 2), Query(left, right, k * 2 + 1, (l + r) / 2, r));\n }\n\n /// \n /// A[left] op A[left+1] ... A[right-1]\u3092\u6c42\u3081\u308b O(log N)\n /// \n /// \u5de6\u7aef\n /// \u53f3\u7aef\n /// \n public T Query(int left, int right) => Query(left, right, 1, 0, N);\n\n public T this[int i]\n {\n get { return Query(i, i + 1); }\n }\n\n public T[] ToArray()\n {\n T[] result = new T[N];\n for (int i = 0; i < N; i++)\n {\n result[i] = this[i];\n }\n\n return result;\n }\n }\n}\n\n\nnamespace CompLib.Util\n{\n using System;\n using System.Linq;\n\n class Scanner\n {\n private string[] _line;\n private int _index;\n private const char Separator = ' ';\n\n public Scanner()\n {\n _line = new string[0];\n _index = 0;\n }\n\n public string Next()\n {\n while (_index >= _line.Length)\n {\n _line = Console.ReadLine().Split(Separator);\n _index = 0;\n }\n\n return _line[_index++];\n }\n\n public int NextInt() => int.Parse(Next());\n public long NextLong() => long.Parse(Next());\n public double NextDouble() => double.Parse(Next());\n public decimal NextDecimal() => decimal.Parse(Next());\n public char NextChar() => Next()[0];\n public char[] NextCharArray() => Next().ToCharArray();\n\n public string[] Array()\n {\n _line = Console.ReadLine().Split(Separator);\n _index = _line.Length;\n return _line;\n }\n\n public int[] IntArray() => Array().Select(int.Parse).ToArray();\n public long[] LongArray() => Array().Select(long.Parse).ToArray();\n public double[] DoubleArray() => Array().Select(double.Parse).ToArray();\n public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();\n }\n}\n", "lang_cluster": "C#", "tags": ["two pointers", "math", "implementation", "binary search"], "code_uid": "f98ffa2769ee1c44aadec3d04fd8f01e", "src_uid": "4f92791b9ec658829f667fcea1faee01", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Linq;\n\nnamespace Codeforces\n{\n\tpublic class C\n\t{\n\t\tconst int N = (int)2e6;\n\t\tpublic static int Main()\n\t\t{\n\t\t\tint [] input = Console.ReadLine().Split().Select(x => Convert.ToInt32(x)).ToArray();\n\t\t\t\n\t\t\tlong [] a = new long[N];\n\t\t\t\n\t\t\tint A = input[0];\n\t\t\tint B = input[1];\n\t\t\tint C = input[2];\n\t\t\tint D = input[3];\n\t\t\t\n\t\t\tfor (int i = A; i <= B; ++i)\n\t\t\t{\n\t\t\t\t++a[i + B];\n\t\t\t\t--a[i + C + 1];\n\t\t\t}\n\t\t\t\n\t\t\tfor (int i = 1; i < N; ++i)\n\t\t\t{\n\t\t\t\ta[i] += a[i - 1];\n\t\t\t}\n\t\t\t\n\t\t\tfor (int i = 1; i < N; ++i)\n\t\t\t{\n\t\t\t\ta[i] += a[i - 1];\n\t\t\t}\n\t\t\t\n\t\t\tlong result = 0;\n\t\t\tfor (int i = C; i <= D; ++i)\n\t\t\t{\n\t\t\t\tresult += a[N - 1] - a[i];\n\t\t\t}\n\t\t\t\n\t\t\tConsole.WriteLine(result);\n\t\t\t\n\t\t\treturn 0;\n\t\t}\n\t}\n} \n", "lang_cluster": "C#", "tags": ["two pointers", "math", "implementation", "binary search"], "code_uid": "fba98221d9b97883c01310871059ec33", "src_uid": "4f92791b9ec658829f667fcea1faee01", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.IO;\nusing System.Linq;\nusing static System.Math;\nusing System.Text;\nusing System.Threading;\nusing System.Globalization;\nusing System.Runtime.CompilerServices;\nusing Library;\n\nnamespace Program\n{\n public static class CODEFORCES2\n {\n static bool SAIKI = false;\n static public int numberOfRandomCases = 0;\n static public void MakeTestCase(List _input, List _output, ref Func _outputChecker)\n {\n }\n static public void Solve()\n {\n var A = NN;\n var B = NN;\n var C = NN;\n var D = NN;\n var range = D - C + 1;\n var ans = 0L;\n for (var i = 0; i < range; i++)\n {\n var z = C + i;\n var miny = B;\n var needx = z - miny + 1;\n if (needx > B)\n {\n var herasi = B - needx;\n miny -= herasi;\n needx += herasi;\n if (miny > C)\n {\n continue;\n }\n }\n var cntx = B - Max(A, needx) + 1;\n var nokoriacnt = (B - A + 1) - cntx + 1;\n var bcnt = C - miny + 1;\n var mincnt = Min(nokoriacnt, bcnt);\n var s = mincnt * (2 * cntx + mincnt - 1) / 2;\n var nokorib = bcnt - mincnt;\n var thiscnt = s + nokorib * (B - A + 1);\n ans += thiscnt;\n }\n Console.WriteLine(ans);\n }\n class Printer : StreamWriter\n {\n public override IFormatProvider FormatProvider { get { return CultureInfo.InvariantCulture; } }\n public Printer(Stream stream) : base(stream, new UTF8Encoding(false, true)) { base.AutoFlush = false; }\n public Printer(Stream stream, Encoding encoding) : base(stream, encoding) { base.AutoFlush = false; }\n }\n static LIB_FastIO fastio = new LIB_FastIODebug();\n static public void Main(string[] args) { if (args.Length == 0) { fastio = new LIB_FastIO(); Console.SetOut(new Printer(Console.OpenStandardOutput())); } if (SAIKI) { var t = new Thread(Solve, 134217728); t.Start(); t.Join(); } else Solve(); Console.Out.Flush(); }\n static long NN => fastio.Long();\n static double ND => fastio.Double();\n static string NS => fastio.Scan();\n static long[] NNList(long N) => Repeat(0, N).Select(_ => NN).ToArray();\n static double[] NDList(long N) => Repeat(0, N).Select(_ => ND).ToArray();\n static string[] NSList(long N) => Repeat(0, N).Select(_ => NS).ToArray();\n static long Count(this IEnumerable x, Func pred) => Enumerable.Count(x, pred);\n static IEnumerable Repeat(T v, long n) => Enumerable.Repeat(v, (int)n);\n static IEnumerable Range(long s, long c) => Enumerable.Range((int)s, (int)c);\n static IOrderedEnumerable OrderByRand(this IEnumerable x) => Enumerable.OrderBy(x, _ => xorshift);\n static IOrderedEnumerable OrderBy(this IEnumerable x) => Enumerable.OrderBy(x.OrderByRand(), e => e);\n static IOrderedEnumerable OrderBy(this IEnumerable x, Func selector) => Enumerable.OrderBy(x.OrderByRand(), selector);\n static IOrderedEnumerable OrderByDescending(this IEnumerable x) => Enumerable.OrderByDescending(x.OrderByRand(), e => e);\n static IOrderedEnumerable OrderByDescending(this IEnumerable x, Func selector) => Enumerable.OrderByDescending(x.OrderByRand(), selector);\n static IOrderedEnumerable OrderBy(this IEnumerable x) => x.OrderByRand().OrderBy(e => e, StringComparer.OrdinalIgnoreCase);\n static IOrderedEnumerable OrderBy(this IEnumerable x, Func selector) => x.OrderByRand().OrderBy(selector, StringComparer.OrdinalIgnoreCase);\n static IOrderedEnumerable OrderByDescending(this IEnumerable x) => x.OrderByRand().OrderByDescending(e => e, StringComparer.OrdinalIgnoreCase);\n static IOrderedEnumerable OrderByDescending(this IEnumerable x, Func selector) => x.OrderByRand().OrderByDescending(selector, StringComparer.OrdinalIgnoreCase);\n static uint xorshift { get { _xsi.MoveNext(); return _xsi.Current; } }\n static IEnumerator _xsi = _xsc();\n static IEnumerator _xsc() { uint x = 123456789, y = 362436069, z = 521288629, w = (uint)(DateTime.Now.Ticks & 0xffffffff); while (true) { var t = x ^ (x << 11); x = y; y = z; z = w; w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)); yield return w; } }\n }\n}\nnamespace Library {\n class LIB_FastIO\n {\n public LIB_FastIO() { str = Console.OpenStandardInput(); }\n readonly Stream str;\n readonly byte[] buf = new byte[1024];\n int len, ptr;\n public bool isEof = false;\n public bool IsEndOfStream { get { return isEof; } }\n byte read()\n {\n if (isEof) throw new EndOfStreamException();\n if (ptr >= len)\n {\n ptr = 0;\n if ((len = str.Read(buf, 0, 1024)) <= 0)\n {\n isEof = true;\n return 0;\n }\n }\n return buf[ptr++];\n }\n char Char()\n {\n byte b = 0;\n do b = read();\n while (b < 33 || 126 < b);\n return (char)b;\n }\n virtual public string Scan()\n {\n var sb = new StringBuilder();\n for (var b = Char(); b >= 33 && b <= 126; b = (char)read())\n sb.Append(b);\n return sb.ToString();\n }\n virtual public long Long()\n {\n long ret = 0; byte b = 0; var ng = false;\n do b = read();\n while (b != '-' && (b < '0' || '9' < b));\n if (b == '-') { ng = true; b = read(); }\n for (; true; b = read())\n {\n if (b < '0' || '9' < b)\n return ng ? -ret : ret;\n else ret = ret * 10 + b - '0';\n }\n }\n virtual public double Double() { return double.Parse(Scan(), CultureInfo.InvariantCulture); }\n }\n class LIB_FastIODebug : LIB_FastIO\n {\n Queue param = new Queue();\n string NextString() { if (param.Count == 0) foreach (var item in Console.ReadLine().Split(' ')) param.Enqueue(item); return param.Dequeue(); }\n public LIB_FastIODebug() { }\n public override string Scan() => NextString();\n public override long Long() => long.Parse(NextString());\n public override double Double() => double.Parse(NextString());\n }\n}\n", "lang_cluster": "C#", "tags": ["two pointers", "math", "implementation", "binary search"], "code_uid": "f015ac3eb79fda02975aafe98254347e", "src_uid": "4f92791b9ec658829f667fcea1faee01", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.IO;\nusing System.Runtime.CompilerServices;\nusing System.Text;\nusing System.Diagnostics;\nusing System.Numerics;\nusing static System.Console;\nusing static System.Convert;\nusing static System.Math;\nusing static Template;\nusing Pi = Pair;\n\nclass Solver\n{\n public void Solve(Scanner sc)\n {\n int A, B, C, D;\n sc.Make(out A, out B, out C, out D);\n var res = 0L;\n for (int z = C; z <= D; z++)\n {\n long l = Min(B, z - C);\n long r = Min(B, z - B)+1;\n res += Max(0, (Min(r, A) - l)) * (B - A + 1);\n chmax(ref l, A);\n chmax(ref r, A);\n res += (B - l) * (B - l + 1L) / 2 - (B - r) * (B - r+1) / 2;\n }\n Console.WriteLine(res);\n }\n}\n\n#region Template\npublic static class Template\n{\n static void Main(string[] args)\n {\n Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });\n new Solver().Solve(new Scanner());\n Console.Out.Flush();\n }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static bool chmin(ref T a, T b) where T : IComparable { if (a.CompareTo(b) > 0) { a = b; return true; } return false; }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static bool chmax(ref T a, T b) where T : IComparable { if (a.CompareTo(b) < 0) { a = b; return true; } return false; }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static void swap(ref T a, ref T b) { var t = b; b = a; a = t; }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static void swap(this IList A, int i, int j) { var t = A[i]; A[i] = A[j]; A[j] = t; }\n public static T[] Create(int n, Func f) { var rt = new T[n]; for (var i = 0; i < rt.Length; ++i) rt[i] = f(); return rt; }\n public static T[] Create(int n, Func f) { var rt = new T[n]; for (var i = 0; i < rt.Length; ++i) rt[i] = f(i); return rt; }\n public static IEnumerable Shuffle(this IEnumerable A) => A.OrderBy(v => Guid.NewGuid());\n public static int CompareTo(this T[] A, T[] B, Comparison cmp = null) { cmp = cmp ?? Comparer.Default.Compare; for (var i = 0; i < Min(A.Length, B.Length); i++) { int c = cmp(A[i], B[i]); if (c > 0) return 1; else if (c < 0) return -1; } if (A.Length == B.Length) return 0; if (A.Length > B.Length) return 1; else return -1; }\n public static int MaxElement(this IList A, Comparison cmp = null) { cmp = cmp ?? Comparer.Default.Compare; T max = A[0]; int rt = 0; for (int i = 1; i < A.Count; i++) if (cmp(max, A[i]) < 0) { max = A[i]; rt = i; } return rt; }\n public static T PopBack(this List A) { var v = A[A.Count - 1]; A.RemoveAt(A.Count - 1); return v; }\n public static void Fail(T s) { Console.WriteLine(s); Console.Out.Close(); Environment.Exit(0); }\n}\npublic class Scanner\n{\n public string Str => Console.ReadLine().Trim();\n public int Int => int.Parse(Str);\n public long Long => long.Parse(Str);\n public double Double => double.Parse(Str);\n public int[] ArrInt => Str.Split(' ').Select(int.Parse).ToArray();\n public long[] ArrLong => Str.Split(' ').Select(long.Parse).ToArray();\n public char[][] Grid(int n) => Create(n, () => Str.ToCharArray());\n public int[] ArrInt1D(int n) => Create(n, () => Int);\n public long[] ArrLong1D(int n) => Create(n, () => Long);\n public int[][] ArrInt2D(int n) => Create(n, () => ArrInt);\n public long[][] ArrLong2D(int n) => Create(n, () => ArrLong);\n private Queue q = new Queue();\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public T Next() { if (q.Count == 0) foreach (var item in Str.Split(' ')) q.Enqueue(item); return (T)Convert.ChangeType(q.Dequeue(), typeof(T)); }\n public void Make(out T1 v1) => v1 = Next();\n public void Make(out T1 v1, out T2 v2) { v1 = Next(); v2 = Next(); }\n public void Make(out T1 v1, out T2 v2, out T3 v3) { Make(out v1, out v2); v3 = Next(); }\n public void Make(out T1 v1, out T2 v2, out T3 v3, out T4 v4) { Make(out v1, out v2, out v3); v4 = Next(); }\n public void Make(out T1 v1, out T2 v2, out T3 v3, out T4 v4, out T5 v5) { Make(out v1, out v2, out v3, out v4); v5 = Next(); }\n public void Make(out T1 v1, out T2 v2, out T3 v3, out T4 v4, out T5 v5, out T6 v6) { Make(out v1, out v2, out v3, out v4, out v5); v6 = Next(); }\n public void Make(out T1 v1, out T2 v2, out T3 v3, out T4 v4, out T5 v5, out T6 v6, out T7 v7) { Make(out v1, out v2, out v3, out v4, out v5, out v6); v7 = Next(); }\n //public (T1, T2) Make() { Make(out T1 v1, out T2 v2); return (v1, v2); }\n //public (T1, T2, T3) Make() { Make(out T1 v1, out T2 v2, out T3 v3); return (v1, v2, v3); }\n //public (T1, T2, T3, T4) Make() { Make(out T1 v1, out T2 v2, out T3 v3, out T4 v4); return (v1, v2, v3, v4); }\n}\npublic class Pair : IComparable>\n{\n public T1 v1;\n public T2 v2;\n public Pair() { }\n public Pair(T1 v1, T2 v2)\n { this.v1 = v1; this.v2 = v2; }\n\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public int CompareTo(Pair p)\n {\n var c = Comparer.Default.Compare(v1, p.v1);\n if (c == 0)\n c = Comparer.Default.Compare(v2, p.v2);\n return c;\n }\n public override string ToString() => $\"{v1.ToString()} {v2.ToString()}\";\n public void Deconstruct(out T1 a, out T2 b) { a = v1; b = v2; }\n}\n\npublic class Pair : Pair, IComparable>\n{\n public T3 v3;\n public Pair() : base() { }\n public Pair(T1 v1, T2 v2, T3 v3) : base(v1, v2)\n { this.v3 = v3; }\n\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public int CompareTo(Pair p)\n {\n var c = base.CompareTo(p);\n if (c == 0)\n c = Comparer.Default.Compare(v3, p.v3);\n return c;\n }\n public override string ToString() => $\"{base.ToString()} {v3.ToString()}\";\n public void Deconstruct(out T1 a, out T2 b, out T3 c) { Deconstruct(out a, out b); c = v3; }\n}\n#endregion\n", "lang_cluster": "C#", "tags": ["two pointers", "math", "implementation", "binary search"], "code_uid": "66c986462e9550e97681015209779f3f", "src_uid": "4f92791b9ec658829f667fcea1faee01", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using CodeforcesRound643Div2.Questions;\nusing CodeforcesRound643Div2.Extensions;\nusing System;\nusing System.Collections.Generic;\nusing System.IO;\nusing System.Linq;\nusing System.Text;\n\nnamespace CodeforcesRound643Div2.Questions\n{\n public class QuestionC_Review : AtCoderQuestionBase\n {\n public override IEnumerable Solve(TextReader inputStream)\n {\n var (a, b, c, d) = inputStream.ReadValue();\n var xyCount = new long[1000002];\n for (int x = a; x <= b; x++)\n {\n xyCount[x + b] += 1;\n xyCount[x + c + 1] -= 1;\n }\n\n for (int prefixSum = 0; prefixSum < 2; prefixSum++)\n {\n for (int i = 1; i < xyCount.Length; i++)\n {\n xyCount[i] += xyCount[i - 1];\n }\n }\n\n long count = 0;\n for (int z = c; z <= d; z++)\n {\n count += xyCount[xyCount.Length - 1] - xyCount[z];\n }\n\n yield return count;\n }\n }\n}\n\n\nnamespace CodeforcesRound643Div2\n{\n class Program\n {\n static void Main(string[] args)\n {\n IAtCoderQuestion question = new QuestionC_Review(); // \u554f\u984c\u306b\u5408\u308f\u305b\u3066\u66f8\u304d\u63db\u3048\n var answers = question.Solve(Console.In);\n\n var writer = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };\n Console.SetOut(writer);\n foreach (var answer in answers)\n {\n Console.WriteLine(answer);\n }\n Console.Out.Flush();\n }\n }\n}\n\n#region Base Class\n\nnamespace CodeforcesRound643Div2.Questions\n{\n\n public interface IAtCoderQuestion\n {\n IEnumerable Solve(string input);\n IEnumerable Solve(TextReader inputStream);\n }\n\n public abstract class AtCoderQuestionBase : IAtCoderQuestion\n {\n public IEnumerable Solve(string input)\n {\n var stream = new MemoryStream(Encoding.Unicode.GetBytes(input));\n var reader = new StreamReader(stream, Encoding.Unicode);\n\n return Solve(reader);\n }\n\n public abstract IEnumerable Solve(TextReader inputStream);\n }\n}\n\n#endregion\n\n#region Extensions\n\nnamespace CodeforcesRound643Div2.Extensions\n{\n internal static class TextReaderExtensions\n {\n internal static int ReadInt(this TextReader reader) => int.Parse(ReadString(reader));\n internal static long ReadLong(this TextReader reader) => long.Parse(ReadString(reader));\n internal static double ReadDouble(this TextReader reader) => double.Parse(ReadString(reader));\n internal static string ReadString(this TextReader reader) => reader.ReadLine();\n\n internal static int[] ReadIntArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(int.Parse).ToArray();\n internal static long[] ReadLongArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(long.Parse).ToArray();\n internal static double[] ReadDoubleArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(double.Parse).ToArray();\n internal static string[] ReadStringArray(this TextReader reader, char separator = ' ') => reader.ReadLine().Split(separator);\n\n // Supports primitive type only.\n internal static T1 ReadValue(this TextReader reader) => (T1)Convert.ChangeType(reader.ReadLine(), typeof(T1));\n\n internal static (T1, T2) ReadValue(this TextReader reader, char separator = ' ')\n {\n var inputs = ReadStringArray(reader, separator);\n var v1 = (T1)Convert.ChangeType(inputs[0], typeof(T1));\n var v2 = (T2)Convert.ChangeType(inputs[1], typeof(T2));\n return (v1, v2);\n }\n\n internal static (T1, T2, T3) ReadValue(this TextReader reader, char separator = ' ')\n {\n var inputs = ReadStringArray(reader, separator);\n var v1 = (T1)Convert.ChangeType(inputs[0], typeof(T1));\n var v2 = (T2)Convert.ChangeType(inputs[1], typeof(T2));\n var v3 = (T3)Convert.ChangeType(inputs[2], typeof(T3));\n return (v1, v2, v3);\n }\n\n internal static (T1, T2, T3, T4) ReadValue(this TextReader reader, char separator = ' ')\n {\n var inputs = ReadStringArray(reader, separator);\n var v1 = (T1)Convert.ChangeType(inputs[0], typeof(T1));\n var v2 = (T2)Convert.ChangeType(inputs[1], typeof(T2));\n var v3 = (T3)Convert.ChangeType(inputs[2], typeof(T3));\n var v4 = (T4)Convert.ChangeType(inputs[3], typeof(T4));\n return (v1, v2, v3, v4);\n }\n\n internal static (T1, T2, T3, T4, T5) ReadValue(this TextReader reader, char separator = ' ')\n {\n var inputs = ReadStringArray(reader, separator);\n var v1 = (T1)Convert.ChangeType(inputs[0], typeof(T1));\n var v2 = (T2)Convert.ChangeType(inputs[1], typeof(T2));\n var v3 = (T3)Convert.ChangeType(inputs[2], typeof(T3));\n var v4 = (T4)Convert.ChangeType(inputs[3], typeof(T4));\n var v5 = (T5)Convert.ChangeType(inputs[4], typeof(T5));\n return (v1, v2, v3, v4, v5);\n }\n\n internal static (T1, T2, T3, T4, T5, T6) ReadValue(this TextReader reader, char separator = ' ')\n {\n var inputs = ReadStringArray(reader, separator);\n var v1 = (T1)Convert.ChangeType(inputs[0], typeof(T1));\n var v2 = (T2)Convert.ChangeType(inputs[1], typeof(T2));\n var v3 = (T3)Convert.ChangeType(inputs[2], typeof(T3));\n var v4 = (T4)Convert.ChangeType(inputs[3], typeof(T4));\n var v5 = (T5)Convert.ChangeType(inputs[4], typeof(T5));\n var v6 = (T6)Convert.ChangeType(inputs[5], typeof(T6));\n return (v1, v2, v3, v4, v5, v6);\n }\n\n internal static (T1, T2, T3, T4, T5, T6, T7) ReadValue(this TextReader reader, char separator = ' ')\n {\n var inputs = ReadStringArray(reader, separator);\n var v1 = (T1)Convert.ChangeType(inputs[0], typeof(T1));\n var v2 = (T2)Convert.ChangeType(inputs[1], typeof(T2));\n var v3 = (T3)Convert.ChangeType(inputs[2], typeof(T3));\n var v4 = (T4)Convert.ChangeType(inputs[3], typeof(T4));\n var v5 = (T5)Convert.ChangeType(inputs[4], typeof(T5));\n var v6 = (T6)Convert.ChangeType(inputs[5], typeof(T6));\n var v7 = (T7)Convert.ChangeType(inputs[6], typeof(T7));\n return (v1, v2, v3, v4, v5, v6, v7);\n }\n }\n}\n\n#endregion", "lang_cluster": "C#", "tags": ["two pointers", "math", "implementation", "binary search"], "code_uid": "484d4b721b3a4d1a143cc6bdd3bda3ee", "src_uid": "4f92791b9ec658829f667fcea1faee01", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.IO;\nusing System.Text;\n\nnamespace Cubical_Planet\n{\n internal class Program\n {\n private static readonly StreamReader reader = new StreamReader(Console.OpenStandardInput(1024*10), Encoding.ASCII, false, 1024*10);\n private static readonly StreamWriter writer = new StreamWriter(Console.OpenStandardOutput(1024*10), Encoding.ASCII, 1024*10);\n\n private static void Main(string[] args)\n {\n int x1 = Next(), y1 = Next(), z1 = Next();\n int x2 = Next(), y2 = Next(), z2 = Next();\n\n writer.WriteLine(x1 == x2 || y1 == y2 || z1 == z2 ? \"YES\" : \"NO\");\n writer.Flush();\n }\n\n private static int Next()\n {\n int c;\n int res = 0;\n do\n {\n c = reader.Read();\n if (c == -1)\n return res;\n } while (c < '0' || c > '9');\n res = c - '0';\n while (true)\n {\n c = reader.Read();\n if (c < '0' || c > '9')\n return res;\n res *= 10;\n res += c - '0';\n }\n }\n }\n}", "lang_cluster": "C#", "tags": ["math"], "code_uid": "c2b673e2aaa77ea9be6d169896396a84", "src_uid": "91c9dbbceb467d5fd420e92c2919ecb6", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.IO;\nusing System.Text;\n\nnamespace Roman_and_Numbers\n{\n internal class Program\n {\n private static readonly StreamReader reader =\n new StreamReader(Console.OpenStandardInput(1024*10), Encoding.ASCII, false, 1024*10);\n\n private static readonly StreamWriter writer =\n new StreamWriter(Console.OpenStandardOutput(1024*10), Encoding.ASCII, 1024*10);\n\n private static void Main(string[] args)\n {\n string[] ss = reader.ReadLine().Split(' ');\n long n = long.Parse(ss[0]);\n int m = int.Parse(ss[1]);\n\n var digits = new List();\n while (n > 0)\n {\n digits.Add((int) (n%10));\n n /= 10;\n }\n\n int nn = digits.Count;\n int max = 1 << nn;\n var dp = new long[max,m];\n\n for (int i = 0; i < nn; i++)\n {\n if (digits[i] != 0)\n dp[1 << i, digits[i]%m] += 1;\n }\n\n for (int i = 1; i < max; i++)\n {\n for (int j = 0; j < m; j++)\n {\n if (dp[i, j] != 0)\n {\n for (int k = 0; k < nn; k++)\n {\n if ((i & (1 << k)) == 0)\n {\n dp[i | (1 << k), (j*10 + digits[k])%m] += dp[i, j];\n }\n }\n }\n }\n }\n long ans = dp[max - 1, 0];\n\n int[] counts = new int[10];\n foreach (var digit in digits)\n {\n counts[digit]++;\n }\n\n for (int i = 0; i < 10; i++)\n {\n if (counts[i]!=0)\n {\n for (int j = counts[i]; j>1; j--)\n {\n ans /= j;\n }\n }\n }\n \n writer.WriteLine(ans);\n writer.Flush();\n }\n }\n}", "lang_cluster": "C#", "tags": ["brute force", "dp", "combinatorics", "bitmasks", "number theory"], "code_uid": "453a4418bcadeaf4caf003196352e991", "src_uid": "5eb90c23ffa3794fdddc5670c0373829", "difficulty": 2000.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.IO;\nusing System.Text;\n\nnamespace Artem_and_Array\n{\n internal class Program\n {\n private static readonly StreamReader reader = new StreamReader(Console.OpenStandardInput(1024*10), Encoding.ASCII, false, 1024*10);\n private static readonly StreamWriter writer = new StreamWriter(Console.OpenStandardOutput(1024*10), Encoding.ASCII, 1024*10);\n\n private static int[] nn;\n\n private static void Main(string[] args)\n {\n int n = Next();\n nn = new int[n + 2];\n nn[0] = -10000000;\n for (int i = 1; i <= n; i++)\n {\n nn[i] = Next();\n }\n nn[n + 1] = -10000000;\n\n long count = 0;\n\n\n var points = new point[n + 2];\n var q = new Queue();\n for (int i = 1; i <= n; i++)\n {\n var p = new point(i - 1, i + 1, nn[i]);\n points[i] = p;\n if (p.value >= p.current)\n {\n q.Enqueue(p);\n p.used = true;\n }\n }\n\n while (q.Count > 0)\n {\n point p = q.Dequeue();\n count += p.value;\n\n point p1 = points[p.left];\n point p2 = points[p.right];\n p1.right = p.right;\n p2.left = p.left;\n p1.Recalc();\n p2.Recalc();\n\n if (p1.value >= p1.current && !p1.used)\n {\n q.Enqueue(p1);\n p1.used = true;\n }\n if (p2.value >= p2.current && !p2.used)\n {\n q.Enqueue(p2);\n p2.used = true;\n }\n }\n\n\n var heap = new MaxBinaryHeapObject(new point(0, 0, 0));\n for (int i = 1; i <= n; i++)\n {\n if (!points[i].used)\n heap.Add(points[i]);\n }\n\n while (heap.HeapSize > 2)\n {\n point p = heap.GetMax();\n count += p.value;\n\n point p1 = points[p.left];\n point p2 = points[p.right];\n p1.right = p.right;\n p2.left = p.left;\n\n p1.Recalc();\n heap.Heapify(p1);\n p2.Recalc();\n heap.Heapify(p2);\n }\n\n writer.WriteLine(count);\n writer.Flush();\n }\n\n private static int Next()\n {\n int c;\n int res = 0;\n do\n {\n c = reader.Read();\n if (c == -1)\n return res;\n } while (c < '0' || c > '9');\n res = c - '0';\n while (true)\n {\n c = reader.Read();\n if (c < '0' || c > '9')\n return res;\n res *= 10;\n res += c - '0';\n }\n }\n\n #region Nested type: MaxBinaryHeapObject\n\n public class MaxBinaryHeapObject\n {\n private readonly IComparer _comparer;\n private readonly List _list;\n\n public MaxBinaryHeapObject(IComparer comparer)\n {\n _comparer = comparer ?? Comparer.Default;\n _list = new List();\n }\n\n public int HeapSize\n {\n get { return _list.Count; }\n }\n\n public void Add(point value)\n {\n _list.Add(value);\n value.where = _list.Count - 1;\n MoveUp(HeapSize - 1);\n }\n\n private void MoveUp(int i)\n {\n int parent = (i - 1)/2;\n\n while (i > 0 && _comparer.Compare(_list[parent], _list[i]) == -1)\n {\n point temp = _list[i];\n _list[i] = _list[parent];\n _list[parent] = temp;\n\n _list[i].where = i;\n _list[parent].where = parent;\n\n i = parent;\n parent = (i - 1)/2;\n }\n }\n\n public void Heapify(point t)\n {\n MoveUp(t.where);\n MoveDown(t.where);\n }\n\n\n private void MoveDown(int i)\n {\n for (;;)\n {\n int leftChild = 2*i + 1;\n int rightChild = 2*i + 2;\n int largestChild = i;\n\n if (leftChild < HeapSize && _comparer.Compare(_list[leftChild], _list[largestChild]) == 1)\n {\n largestChild = leftChild;\n }\n\n if (rightChild < HeapSize && _comparer.Compare(_list[rightChild], _list[largestChild]) == 1)\n {\n largestChild = rightChild;\n }\n\n if (largestChild == i)\n {\n break;\n }\n\n point temp = _list[i];\n _list[i] = _list[largestChild];\n _list[largestChild] = temp;\n\n _list[i].where = i;\n _list[largestChild].where = largestChild;\n\n i = largestChild;\n }\n }\n\n\n public point Max()\n {\n return _list[0];\n }\n\n public point GetMax()\n {\n point result = _list[0];\n _list[0] = _list[HeapSize - 1];\n _list[0].where = 0;\n _list.RemoveAt(HeapSize - 1);\n MoveDown(0);\n return result;\n }\n }\n\n #endregion\n\n #region Nested type: point\n\n public class point : IComparer\n {\n public readonly int current;\n public int left;\n public int right;\n public bool used;\n public int value;\n public int where;\n\n\n public point(int left, int right, int current)\n {\n this.left = left;\n this.right = right;\n this.current = current;\n value = Math.Min(nn[left], nn[right]);\n }\n\n #region IComparer Members\n\n public int Compare(point x, point y)\n {\n int c = (x.value).CompareTo(y.value);\n //if (c == 0)\n // c = y._current.CompareTo(x._current);\n return c;\n }\n\n #endregion\n\n public void Recalc()\n {\n value = Math.Min(nn[left], nn[right]);\n }\n }\n\n #endregion\n }\n}", "lang_cluster": "C#", "tags": ["greedy"], "code_uid": "7b6b7f4b790232e13fd155ecfbd41a93", "src_uid": "e7e0f9069166fe992abe6f0e19caa6a1", "difficulty": 2500.0, "exec_outcome": "PASSED"} {"lang": "C# 10", "source_code": "using System;\r\nusing System.Collections.Generic;\r\nusing System.Linq;\r\nusing System.Text;\r\n\r\nnamespace CodeForces800\r\n{\r\n internal static class Program\r\n {\r\n public static void Main()\r\n {\r\n // var strrep = Console.ReadLine().Split(' ').Select(x => Int32.Parse(x)).ToList();\r\n // var rep = strrep[0];\r\n ulong p = 998244353;\r\n var primes = new HashSet();\r\n var s = 2;\r\n primes.Add(2);\r\n for (var i = 2; i < 1000; i++)\r\n {\r\n if (s * s < i)\r\n s++;\r\n if (!Enumerable.Range(2, Math.Max(s - 1, 0)).Any(x => i % x == 0))\r\n {\r\n primes.Add(i);\r\n }\r\n }\r\n for (var iter = 0; iter < 1; iter++)\r\n {\r\n var strrep = Console.ReadLine().Split(' ').Select(x => ulong.Parse(x)).ToList();\r\n var n = strrep[0];\r\n var m = strrep[1];\r\n long all = 0;\r\n ulong curgcd = 1;\r\n ulong prev = m % p;\r\n ulong prevbad = m % p;\r\n var f = true;\r\n for (ulong i = 2; i <= n; i++)\r\n {\r\n prev *= (m % p);\r\n prev %= p;\r\n if (!f)\r\n {\r\n all += (long)prev;\r\n all %= (long)p;\r\n continue;\r\n }\r\n if(primes.Contains((int)i))\r\n curgcd = curgcd * i;\r\n if (m < curgcd)\r\n f = false;\r\n prevbad *= ((m / curgcd) % p);\r\n prevbad %= p;\r\n all += ((long)prev - (long)prevbad);\r\n all %= (long)p;\r\n all += (long)p;\r\n all %= (long)p;\r\n }\r\n Console.WriteLine(all);\r\n }\r\n }\r\n\r\n private static ulong GCD(ulong a, ulong b)\r\n {\r\n while (a != 0 && b != 0)\r\n {\r\n if (a > b)\r\n a %= b;\r\n else\r\n b %= a;\r\n }\r\n\r\n return a | b;\r\n }\r\n }\r\n}\r\n", "lang_cluster": "C#", "tags": ["math", "dp", "combinatorics", "number theory"], "code_uid": "5d2a6211145f367f599874afe89e6ff7", "src_uid": "0fdd91ed33431848614075ebe9d2ee68", "difficulty": 1900.0, "exec_outcome": "PASSED"} {"lang": "C# 8", "source_code": "\ufeff\ufeffusing System;\r\nusing System.Linq;\r\n\r\nnamespace CodeForces\r\n{\r\n class Program\r\n {\r\n static void Main(string[] args)\r\n {\r\n var arr = Console.ReadLine().Split(' ');\r\n var n = Int32.Parse(arr[0]);\r\n var m = long.Parse(arr[1]);\r\n var res = GetRes(n, m);\r\n Console.WriteLine(res);\r\n\r\n // Test();\r\n }\r\n\r\n const int MOD_VAL = 998244353;\r\n private static int GetRes(int n, long m)\r\n {\r\n if (n == 1) return 0;\r\n var fullCount = GetFullCount(n, m);\r\n var noOk = GetNOKCount(n,m);\r\n var res = fullCount - noOk;\r\n if(res < 0) res+=MOD_VAL;\r\n return res;\r\n }\r\n\r\n private static int GetFullCount(int n, long m)\r\n {\r\n var divisor = (int)((m-1) % MOD_VAL);\r\n if (divisor == 0) return n; \r\n var reverse = GetReverse(divisor);\r\n var mAfterMod = (int)(m % MOD_VAL);\r\n var res = (int)(((long)GetPow(mAfterMod, n+1) - mAfterMod) *\r\n reverse % MOD_VAL);\r\n if (res < 0) res+=MOD_VAL;\r\n return res; \r\n }\r\n\r\n private static int GetReverse(int val)\r\n {\r\n var (a,b) = ExGcd(MOD_VAL, val);\r\n return b >= 0 ? (int) b: (int)(MOD_VAL+b);\r\n }\r\n\r\n private static (long, long) ExGcd(long num0, long num1)\r\n {\r\n if (num0 % num1 == 0)\r\n {\r\n return (0, 1);\r\n }\r\n // a0 * num0 + b0 * num1 = num2\r\n var num2 = num0 % num1;\r\n var a0 = 1;\r\n var b0 = -(num0 / num1);\r\n // a1 * num1 + b1 * num2 = gcd\r\n var (a1, b1) = ExGcd(num1, num2);\r\n // (a0*b1) * num0 + (a1 + b0*b1) * num1 = gcd\r\n return (a0 * b1, a1 + b0 * b1);\r\n }\r\n\r\n private static int GetPow(int baseVal, int exponent)\r\n {\r\n var index = 0;\r\n var res = 1L;\r\n long tmp = baseVal;\r\n while(1<= Int64.MaxValue / primes[x]) {\n break;\n }\n cur *= primes[x];\n if (n % (i + 1) == 0) {\n ret = Math.Min(ret, go(x + 1, n / (i + 1), i, cur));\n } \n }\n return ret;\n }\n\n\n public abstract class InputReader {\n protected char[] buf;\n protected int current;\n protected bool isFinished;\n\n public InputReader() {\n buf = new char[1024];\n current = 1024;\n }\n\n public abstract int read();\n\n public int nextInt() {\n int c = read();\n while (c <= 32 && c >= 0) {\n c = read();\n }\n int sgn = 1;\n if (c == '-') {\n sgn = -1;\n c = read();\n }\n if (c < '0' || c > '9') {\n throw new Exception(\"digit expected \" + (char)c\n + \" found\");\n }\n int ret = 0;\n while (c >= '0' && c <= '9') {\n ret = ret * 10 + (c - '0');\n c = read();\n }\n if (c == -1) {\n isFinished = true;\n }\n if (c > 32) {\n throw new Exception(\"space character expected \"\n + (char)c + \" found\");\n }\n return ret * sgn;\n }\n\n public long nextLong() {\n int c = read();\n while (c <= 32 && c >= 0) {\n c = read();\n }\n int sgn = 1;\n if (c == '-') {\n sgn = -1;\n c = read();\n }\n if (c < '0' || c > '9') {\n throw new Exception(\"digit expected \" + (char)c\n + \" found\");\n }\n long ret = 0;\n while (c >= '0' && c <= '9') {\n ret = ret * 10 + (c - '0');\n c = read();\n }\n if (c == -1) {\n isFinished = true;\n }\n if (c > 32) {\n throw new Exception(\"space character expected \"\n + (char)c + \" found\");\n }\n return ret * sgn;\n }\n\n public string next() {\n int c = read();\n while (c <= 32 && c >= 0) {\n c = read();\n }\n StringBuilder sb = new StringBuilder();\n while (c > 32) {\n sb.Append((char)(c));\n c = read();\n }\n if (c == -1) {\n isFinished = true;\n }\n return sb.ToString();\n }\n\n public bool isFinishedFunction() {\n return isFinished;\n }\n \n }\n\n\n public class StreamInputReader : InputReader {\n private StreamReader stream;\n\n public StreamInputReader(StreamReader stream)\n : base() {\n this.stream = stream;\n }\n\n override public int read() {\n if (current == buf.Length) {\n if (stream.ReadBlock(buf, 0, buf.Length) == 0) {\n return -1;\n }\n current = 0;\n }\n return buf[current++];\n }\n }\n\n InputReader sc;\n StreamWriter output;\n\n public static void Main(string[] args) {\n new Program().run();\n }\n\n public void run() {\n sc = new StreamInputReader(new StreamReader(Console.OpenStandardInput()));\n output = new StreamWriter(Console.OpenStandardOutput());\n solve();\n output.Close();\n } \n }\n}", "lang_cluster": "C#", "tags": ["brute force", "dp", "number theory"], "code_uid": "da4ac9fc89d2d763b5e122b5f746be1c", "src_uid": "62db589bad3b7023418107de05b7a8ee", "difficulty": 2000.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Text;\n\nnamespace InnaAndPony\n{\n class Program\n {\n static void Main(string[] args)\n {\n string[] nmijab = Console.ReadLine().Split(' ');\n int n = Convert.ToInt32(nmijab[0]);\n int m = Convert.ToInt32(nmijab[1]);\n int i = Convert.ToInt32(nmijab[2]);\n int j = Convert.ToInt32(nmijab[3]);\n int a = Convert.ToInt32(nmijab[4]);\n int b = Convert.ToInt32(nmijab[5]);\n int k1 = 0;\n int k2 = 0;\n int k3 = 0;\n int k4 = 0;\n int k = 0;\n\n if (((i == 1) && (j == 1)) || ((i == n) && (j == 1)) || ((i == n) && (j == m)) || ((i == 1) && (j == m)))\n {\n Console.WriteLine(0);\n }\n else\n {\n if (((i - 1 >= a) || (n - i >= a)) && ((j - 1 >= b) || (m - j >= b)))\n {\n if ((Math.Abs(i - 1) % a == 0) && (Math.Abs(j - 1) % b == 0) && ((Math.Abs(i - 1) / a + Math.Abs(j - 1) / b) % 2 == 0))\n {\n k1 = Math.Max(Math.Abs(i - 1) / a, Math.Abs(j - 1) / b);\n // Console.WriteLine(k1);\n }\n else\n {\n k1 = 1000000000;\n // Console.WriteLine(k1);\n }\n\n if ((Math.Abs(i - n) % a == 0) && (Math.Abs(j - 1) % b == 0) && ((Math.Abs(i - n) / a + Math.Abs(j - 1) / b) % 2 == 0))\n {\n k2 = Math.Max(Math.Abs(i - n) / a, Math.Abs(j - 1) / b);\n // Console.WriteLine(k2);\n }\n else\n {\n k2 = 1000000000;\n // Console.WriteLine(k2);\n }\n\n if ((Math.Abs(i - n) % a == 0) && (Math.Abs(j - m) % b == 0) && ((Math.Abs(i - n) / a + Math.Abs(j - m) / b) % 2 == 0))\n {\n k3 = Math.Max(Math.Abs(i - n) / a, Math.Abs(j - m) / b);\n // Console.WriteLine(k3);\n }\n else\n {\n k3 = 1000000000;\n // Console.WriteLine(k3);\n }\n\n if ((Math.Abs(i - 1) % a == 0) && (Math.Abs(j - m) % b == 0) && ((Math.Abs(i - 1) / a + Math.Abs(j - m) / b) % 2 == 0))\n {\n k4 = Math.Max(Math.Abs(i - 1) / a, Math.Abs(j - m) / b);\n // Console.WriteLine(k4);\n }\n else\n {\n k4 = 1000000000;\n // Console.WriteLine(k4);\n }\n\n k = Math.Min(Math.Min(k1, k2), Math.Min(k3, k4));\n\n if (k < 1000000000)\n {\n Console.WriteLine(k);\n }\n else\n {\n Console.WriteLine(\"Poor Inna and pony!\");\n }\n }\n else\n {\n Console.WriteLine(\"Poor Inna and pony!\");\n }\n }\n\n // Console.ReadKey();\n }\n }\n}", "lang_cluster": "C#", "tags": ["greedy", "implementation"], "code_uid": "06a34d21a8e560b83c8f0f132b1c7e09", "src_uid": "51155e9bfa90e0ff29d049cedc3e1862", "difficulty": 2000.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\n\n\n\nusing System;\nusing System.Collections.Generic;\nusing System.IO;\nusing System.Linq;\nusing System.Text.RegularExpressions;\nusing System.Xml.Linq;\nnamespace ConsoleApplication1\n{\n class Program\n {\n\n public static void Main(string[] args)\n {\n\n string[] s = Console.ReadLine().Split(' ');\n int n, m, x, y, a, b;\n n = int.Parse(s[0]);\n m = int.Parse(s[1]);\n x = int.Parse(s[2]);\n y = int.Parse(s[3]);\n a = int.Parse(s[4]);\n b = int.Parse(s[5]);\n int[,] dist = new int[4, 2];\n dist[0, 0] = x - 1;\n dist[0, 1] = y - 1;\n dist[1, 0] = n - x;\n dist[1, 1] = y - 1;\n dist[2, 0] = n - x;\n dist[2, 1] = m - y;\n dist[3, 0] = x - 1;\n dist[3, 1] = m - y;\n int[] ris = new int[4];\n for (int i = 0; i < 4; i++)\n {\n if (((dist[i, 0] % (2 * a) == 0 && dist[i, 1] % (2 * b) == 0) || (dist[i, 0] % (2 * a) == a && dist[i, 1] % (2 * b) == b)))\n {\n ris[i] = Math.Max((dist[i, 0] / a), (dist[i, 1] / b));\n }\n else { ris[i] = int.MaxValue; };\n }\n int min = ris.Min();\n if (min == 0)\n {\n Console.WriteLine(0);\n }\n else if (min == int.MaxValue||a>=n||b>=m)\n {\n Console.WriteLine(\"Poor Inna and pony!\");\n }\n else\n {\n Console.WriteLine(min);\n }\n \n }\n }\n}\n ", "lang_cluster": "C#", "tags": ["greedy", "implementation"], "code_uid": "a9add6fe20140a2ce5c54e58e61377c1", "src_uid": "51155e9bfa90e0ff29d049cedc3e1862", "difficulty": 2000.0, "exec_outcome": "PASSED"} {"lang": "C# 8", "source_code": "using System;\r\nusing System.Collections.Generic;\r\nusing System.IO;\r\nusing System.Text;\r\nusing System.Linq;\r\nusing System.Net;\r\nusing System.Numerics;\r\nusing System.Collections;\r\nusing System.Diagnostics.CodeAnalysis;\r\nusing System.Text.RegularExpressions;\r\nusing System.Threading;\r\nusing System.Net.Http;\r\nusing System.Threading.Tasks;\r\n\r\nnamespace ConsoleApp1\r\n{\r\n class Program\r\n {\r\n public class ThreadWork\r\n {\r\n\r\n private static readonly StreamReader reader = new StreamReader(Console.OpenStandardInput(1024 * 10), Encoding.ASCII, false, 1024 * 10);\r\n private static readonly StreamWriter writer = new StreamWriter(Console.OpenStandardOutput(1024 * 10), Encoding.ASCII, 1024 * 10);\r\n\r\n static public void Main()\r\n {\r\n var T = int.Parse(reader.ReadLine());\r\n for(var t2 = 0;t2 < T;t2++)\r\n {\r\n var line = reader.ReadLine().Split(' ').Select(int.Parse).ToList();\r\n var n = line[0];\r\n var m = line[1];\r\n var k = line[2];\r\n var unknown = 0;\r\n for(var i=1;i= 0 && k <= unknown && k%2==0 ? \"YES\" : \"NO\");\r\n }\r\n writer.Flush();\r\n }\r\n }\r\n }\r\n\r\n}", "lang_cluster": "C#", "tags": ["math", "constructive algorithms"], "code_uid": "953836a8a8920c2caf3b5a449076da18", "src_uid": "4d0c0cc8faca62eb6384f8135b30feb8", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "C# 8", "source_code": "\ufeffusing System;\r\n\r\nnamespace CodeforcesTasks.Contest1551\r\n{\r\n // https://codeforces.com/contest/1551/problem/D1\r\n public class TaskD\r\n {\r\n static int[] Read() => Array.ConvertAll(Console.ReadLine()!.Split(), int.Parse);\r\n \r\n static void Main(string[] args)\r\n {\r\n var count = int.Parse(Console.ReadLine()!);\r\n for (var i = 0; i < count; i++)\r\n {\r\n var p = Read();\r\n Console.WriteLine(Solve(p[0], p[1], p[2]) ? \"YES\" : \"NO\");\r\n }\r\n }\r\n \r\n public static bool Solve(int n, int m, int k)\r\n {\r\n if (n % 2 == 0 && m % 2 == 0)\r\n {\r\n return k % 2 == 0;\r\n }\r\n\r\n if (n % 2 == 0)\r\n {\r\n var maxHorizontal = n * (m / 2);\r\n return k <= maxHorizontal && k % 2 == 0;\r\n }\r\n\r\n var horizontalSize = m / 2;\r\n return k >= horizontalSize && Solve(n - 1, m, k - horizontalSize);\r\n }\r\n }\r\n}", "lang_cluster": "C#", "tags": ["math", "constructive algorithms"], "code_uid": "a18813ada4dd3712c08b1e066bb5272f", "src_uid": "4d0c0cc8faca62eb6384f8135b30feb8", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.IO;\nusing System.Threading;\nusing System.Runtime.CompilerServices;\nusing System.Text;\nusing System.Diagnostics;\nusing System.Numerics;\nusing static System.Console;\nusing static System.Convert;\nusing static System.Math;\nusing static Template;\n\nclass Solver\n{\n public Scanner sc;\n public void Solve()\n {\n N = sc.Int;\n var A = new int[N][];\n var R = new int[N * N+1];R[N * N] = -1;\n for (int i = 0; i < N; i++)\n {\n A[i] = sc.ArrInt;\n for (int j = 0; j < N; j++)\n {\n A[i][j]--;\n R[A[i][j]] = Id(i, j);\n }\n }\n //dist:=i\u306b\u3044\u3066\uff0cj\u307e\u3067\u30af\u30ea\u30a2\u3057\u3066\u3044\u3066\uff0c\u99d2\u304c0:knight,1:bishop,2:rook\u306e\u3068\u304d\n var dist = Create(N * N, () => Create(N * N, () => Create(3, () => long.MaxValue / 2)));\n var pq = new PriorityQueue<(long c, int now, int cl, int pi)>((a, b) => a.c.CompareTo(b.c));\n dist[R[0]][0][0] = dist[R[0]][0][1] = dist[R[0]][0][2] = 0;\n pq.Push((0, R[0], 0, 0));\n pq.Push((0, R[0], 0, 1));\n pq.Push((0, R[0], 0, 2));\n while (pq.Any())\n {\n var (cst, now, cl, pi) = pq.Pop();\n int h = now / N, w = now % N;\n if (pi == 0)\n {\n for(int k = 0; k < knH.Length; k++)\n {\n int nh = h + knH[k], nw = w + knW[k];\n if (!Inside(nh, nw, N, N)) continue;\n var p = cl;\n if (Id(nh, nw) == R[cl + 1]) p++;\n if (chmin(ref dist[Id(nh, nw)][p][pi], cst + W))\n {\n pq.Push((cst + W, Id(nh, nw), p, pi));\n }\n }\n }\n else if (pi == 1)\n {\n for(int i = -N + 1; i <= N - 1; i++)\n {\n {\n int nh = i + h, nw = i + w;\n if (!Inside(nh, nw, N, N)) goto SEC;\n var p = cl;\n if (Id(nh, nw) == R[cl + 1]) p++;\n if (chmin(ref dist[Id(nh, nw)][p][pi], cst + W))\n {\n pq.Push((cst + W, Id(nh, nw), p, pi));\n }\n }\n SEC:;\n {\n int nh = i + h, nw = -i + w;\n if (!Inside(nh, nw, N, N)) continue;\n var p = cl;\n if (Id(nh, nw) == R[cl + 1]) p++;\n if (chmin(ref dist[Id(nh, nw)][p][pi], cst + W))\n {\n pq.Push((cst + W, Id(nh, nw), p, pi));\n }\n }\n }\n }\n else\n {\n for(int i = -N + 1; i <= N - 1; i++)\n {\n\n {\n int nh = h, nw = i + w;\n if (!Inside(nh, nw, N, N)) goto SEC;\n var p = cl;\n if (Id(nh, nw) == R[cl + 1]) p++;\n if (chmin(ref dist[Id(nh, nw)][p][pi], cst + W))\n {\n pq.Push((cst + W, Id(nh, nw), p, pi));\n }\n }\n SEC:;\n {\n int nh = i + h, nw = w;\n if (!Inside(nh, nw, N, N)) continue;\n var p = cl;\n if (Id(nh, nw) == R[cl + 1]) p++;\n if (chmin(ref dist[Id(nh, nw)][p][pi], cst + W))\n {\n pq.Push((cst + W, Id(nh, nw), p, pi));\n }\n }\n }\n }\n for(int k = 0; k < 3; k++)\n {\n if(chmin(ref dist[now][cl][k],cst+1+W))\n {\n pq.Push((cst + 1+W, now, cl, k));\n }\n }\n }\n var res = dist[R[N * N - 1]][N * N - 1].Min();\n Console.WriteLine($\"{res / W} {res % W}\");\n }\n int N;\n const long W = (long)1e9;\n public int Id(int h, int w) => h * N + w;\n int[] knH = new[] { -2, -2, -1, -1, 1, 1, 2, 2 }, knW = new[] { 1, -1, 2, -2, 2, -2, 1, -1 };\n public static bool Inside(int h, int w, int H, int W)\n => 0 <= h && h < H && 0 <= w && w < W;\n}\n\npublic class PriorityQueue\n{\n private List data = new List();\n private Comparison cmp;\n public int Count { get { return data.Count; } }\n public T Top { get { return data[0]; } }\n public PriorityQueue() { cmp = cmp ?? Comparer.Default.Compare; }\n\n public PriorityQueue(Comparison comparison) { cmp = comparison; }\n\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n private int Parent(int i)\n => (i - 1) >> 1;\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n private int Left(int i)\n => (i << 1) + 1;\n public T Push(T val)\n {\n int i = data.Count;\n data.Add(val);\n while (i > 0)\n {\n int p = Parent(i);\n if (cmp(data[p], val) <= 0)\n break;\n data[i] = data[p];\n i = p;\n }\n data[i] = val;\n return val;\n }\n public T Pop()\n {\n var ret = data[0];\n var p = 0;\n var x = data[data.Count - 1];\n while (Left(p) < data.Count - 1)\n {\n var l = Left(p);\n if (l < data.Count - 2 && cmp(data[l + 1], data[l]) < 0) l++;\n if (cmp(data[l], x) >= 0)\n break;\n data[p] = data[l];\n p = l;\n }\n data[p] = x;\n data.RemoveAt(data.Count - 1);\n return ret;\n }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public bool Any() => data.Count > 0;\n}\n#region Template\npublic static class Template\n{\n static void Main(string[] args)\n {\n Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });\n var sol = new Solver() { sc = new Scanner() };\n //var th = new Thread(sol.Solve, 1 << 26);th.Start();th.Join();\n sol.Solve();\n Console.Out.Flush();\n }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static bool chmin(ref T a, T b) where T : IComparable { if (a.CompareTo(b) > 0) { a = b; return true; } return false; }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static bool chmax(ref T a, T b) where T : IComparable { if (a.CompareTo(b) < 0) { a = b; return true; } return false; }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static void swap(ref T a, ref T b) { var t = b; b = a; a = t; }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static void swap(this IList A, int i, int j) { var t = A[i]; A[i] = A[j]; A[j] = t; }\n public static T[] Create(int n, Func f) { var rt = new T[n]; for (var i = 0; i < rt.Length; ++i) rt[i] = f(); return rt; }\n public static T[] Create(int n, Func f) { var rt = new T[n]; for (var i = 0; i < rt.Length; ++i) rt[i] = f(i); return rt; }\n public static void Out(this IList A, out T a) => a = A[0];\n public static void Out(this IList A, out T a, out T b) { a = A[0]; b = A[1]; }\n public static void Out(this IList A, out T a, out T b, out T c) { A.Out(out a, out b); c = A[2]; }\n public static void Out(this IList A, out T a, out T b, out T c, out T d) { A.Out(out a, out b, out c); d = A[3]; }\n public static string Concat(this IEnumerable A, string sp) => string.Join(sp, A);\n public static char ToChar(this int s, char begin = '0') => (char)(s + begin);\n public static IEnumerable Shuffle(this IEnumerable A) => A.OrderBy(v => Guid.NewGuid());\n public static int CompareTo(this T[] A, T[] B, Comparison cmp = null) { cmp = cmp ?? Comparer.Default.Compare; for (var i = 0; i < Min(A.Length, B.Length); i++) { int c = cmp(A[i], B[i]); if (c > 0) return 1; else if (c < 0) return -1; } if (A.Length == B.Length) return 0; if (A.Length > B.Length) return 1; else return -1; }\n public static int ArgMax(this IList A, Comparison cmp = null) { cmp = cmp ?? Comparer.Default.Compare; T max = A[0]; int rt = 0; for (int i = 1; i < A.Count; i++) if (cmp(max, A[i]) < 0) { max = A[i]; rt = i; } return rt; }\n public static T PopBack(this List A) { var v = A[A.Count - 1]; A.RemoveAt(A.Count - 1); return v; }\n public static void Fail(T s) { Console.WriteLine(s); Console.Out.Close(); Environment.Exit(0); }\n}\npublic class Scanner\n{\n public string Str => Console.ReadLine().Trim();\n public int Int => int.Parse(Str);\n public long Long => long.Parse(Str);\n public double Double => double.Parse(Str);\n public int[] ArrInt => Str.Split(' ').Select(int.Parse).ToArray();\n public long[] ArrLong => Str.Split(' ').Select(long.Parse).ToArray();\n public char[][] Grid(int n) => Create(n, () => Str.ToCharArray());\n public int[] ArrInt1D(int n) => Create(n, () => Int);\n public long[] ArrLong1D(int n) => Create(n, () => Long);\n public int[][] ArrInt2D(int n) => Create(n, () => ArrInt);\n public long[][] ArrLong2D(int n) => Create(n, () => ArrLong);\n private Queue q = new Queue();\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public T Next() { if (q.Count == 0) foreach (var item in Str.Split(' ')) q.Enqueue(item); return (T)Convert.ChangeType(q.Dequeue(), typeof(T)); }\n public void Make(out T1 v1) => v1 = Next();\n public void Make(out T1 v1, out T2 v2) { v1 = Next(); v2 = Next(); }\n public void Make(out T1 v1, out T2 v2, out T3 v3) { Make(out v1, out v2); v3 = Next(); }\n public void Make(out T1 v1, out T2 v2, out T3 v3, out T4 v4) { Make(out v1, out v2, out v3); v4 = Next(); }\n public void Make(out T1 v1, out T2 v2, out T3 v3, out T4 v4, out T5 v5) { Make(out v1, out v2, out v3, out v4); v5 = Next(); }\n public void Make(out T1 v1, out T2 v2, out T3 v3, out T4 v4, out T5 v5, out T6 v6) { Make(out v1, out v2, out v3, out v4, out v5); v6 = Next(); }\n public void Make(out T1 v1, out T2 v2, out T3 v3, out T4 v4, out T5 v5, out T6 v6, out T7 v7) { Make(out v1, out v2, out v3, out v4, out v5, out v6); v7 = Next(); }\n public (T1, T2) Make() { Make(out T1 v1, out T2 v2); return (v1, v2); }\n public (T1, T2, T3) Make() { Make(out T1 v1, out T2 v2, out T3 v3); return (v1, v2, v3); }\n public (T1, T2, T3, T4) Make() { Make(out T1 v1, out T2 v2, out T3 v3, out T4 v4); return (v1, v2, v3, v4); }\n}\n\n#endregion", "lang_cluster": "C#", "tags": ["dfs and similar", "dp", "shortest paths"], "code_uid": "5da8e247b779cd0bd7351ccc0438111b", "src_uid": "5fe44b6cd804e0766a0e993eca1846cd", "difficulty": 2200.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing CompLib.Util;\n\npublic class Program\n{\n private int N;\n private int[,] A;\n\n private int[] X, Y;\n\n private const int K = 3;\n\n private int[] kDx = new int[] {-2, -2, -1, -1, 1, 1, 2, 2};\n private int[] kDy = new int[] {-1, 1, -2, 2, -2, 2, -1, 1};\n\n private int[] rDx = new int[] {-1, 0, 0, 1};\n private int[] rDy = new int[] {0, 1, -1, 0};\n\n private int[] bDx = new int[] {1, 1, -1, -1};\n private int[] bDy = new int[] {-1, 1, -1, 1};\n\n public void Solve()\n {\n var sc = new Scanner();\n N = sc.NextInt();\n A = new int[N, N];\n for (int i = 0; i < N; i++)\n {\n for (int j = 0; j < N; j++)\n {\n A[i, j] = sc.NextInt() - 1;\n }\n }\n\n X = new int[N * N];\n Y = new int[N * N];\n for (int i = 0; i < N; i++)\n {\n for (int j = 0; j < N; j++)\n {\n X[A[i, j]] = i;\n Y[A[i, j]] = j;\n }\n }\n\n var step = new int[N, N, N * N + 1, K];\n var r = new int[N, N, N * N + 1, K];\n for (int i = 0; i < N; i++)\n {\n for (int j = 0; j < N; j++)\n {\n for (int k = 0; k <= N * N; k++)\n {\n for (int l = 0; l < K; l++)\n {\n step[i, j, k, l] = int.MaxValue;\n }\n }\n }\n }\n\n var q = new Queue<(int x, int y, int t, int k)>();\n for (int i = 0; i < K; i++)\n {\n step[X[0], Y[0], 1, i] = 0;\n q.Enqueue((X[0], Y[0], 1, i));\n }\n\n while (q.Count > 0)\n {\n var d = q.Dequeue();\n int curS = step[d.x, d.y, d.t, d.k];\n int curR = r[d.x, d.y, d.t, d.k];\n // \u4ea4\u63db\n for (int i = 0; i < K; i++)\n {\n if (d.k == i) continue;\n ref int nextS = ref step[d.x, d.y, d.t, i];\n ref int nextR = ref r[d.x, d.y, d.t, i];\n if (curS + 1 < nextS || (curS + 1 == nextS && curR + 1 < nextR))\n {\n nextS = curS + 1;\n nextR = curR + 1;\n q.Enqueue((d.x, d.y, d.t, i));\n }\n }\n\n // \u79fb\u52d5\n if (d.k == 0)\n {\n // \u30ca\u30a4\u30c8\n for (int i = 0; i < kDx.Length; i++)\n {\n int nx = d.x + kDx[i];\n int ny = d.y + kDy[i];\n if (nx < 0 || nx >= N) continue;\n if (ny < 0 || ny >= N) continue;\n int nt = A[nx, ny] == d.t ? d.t + 1 : d.t;\n\n ref int nextS = ref step[nx, ny, nt, 0];\n ref int nextR = ref r[nx, ny, nt, 0];\n if (curS + 1 < nextS || (curS + 1 == nextS && curR < nextR))\n {\n nextS = curS + 1;\n nextR = curR;\n q.Enqueue((nx, ny, nt, 0));\n }\n }\n }\n else if (d.k == 1)\n {\n // \u30d3\u30b7\u30e7\u30c3\u30d7 \u306a\u306a\u3081\n for (int i = 0; i < bDx.Length; i++)\n {\n for (int j = 1;; j++)\n {\n int nx = d.x + bDx[i] * j;\n int ny = d.y + bDy[i] * j;\n if (nx < 0 || nx >= N) break;\n if (ny < 0 || ny >= N) break;\n\n int nt = A[nx, ny] == d.t ? d.t + 1 : d.t;\n\n ref int nextS = ref step[nx, ny, nt, 1];\n ref int nextR = ref r[nx, ny, nt, 1];\n if (curS + 1 < nextS || (curS + 1 == nextS && curR < nextR))\n {\n nextS = curS + 1;\n nextR = curR;\n q.Enqueue((nx, ny, nt, 1));\n }\n }\n }\n }\n else if (d.k == 2)\n {\n // \u30eb\u30fc\u30af\u3000\u305f\u3066\u3088\u3053\n for (int i = 0; i < rDx.Length; i++)\n {\n for (int j = 1;; j++)\n {\n int nx = d.x + rDx[i] * j;\n int ny = d.y + rDy[i] * j;\n if (nx < 0 || nx >= N) break;\n if (ny < 0 || ny >= N) break;\n\n int nt = A[nx, ny] == d.t ? d.t + 1 : d.t;\n\n ref int nextS = ref step[nx, ny, nt, 2];\n ref int nextR = ref r[nx, ny, nt, 2];\n if (curS + 1 < nextS || (curS + 1 == nextS && curR < nextR))\n {\n nextS = curS + 1;\n nextR = curR;\n q.Enqueue((nx, ny, nt, 2));\n }\n }\n }\n }\n }\n\n // \u30b4\u30fc\u30eb\n int ansS = int.MaxValue;\n int ansR = int.MaxValue;\n int lx = X[N * N - 1];\n int ly = Y[N * N - 1];\n for (int i = 0; i < 3; i++)\n {\n int ss = step[lx, ly, N * N, i];\n int rr = r[lx, ly, N * N, i];\n\n if (ss < ansS || (ss == ansS && rr < ansR))\n {\n ansS = ss;\n ansR = rr;\n }\n }\n\n Console.WriteLine($\"{ansS} {ansR}\");\n }\n\n public static void Main(string[] args) => new Program().Solve();\n}\n\nnamespace CompLib.Util\n{\n using System;\n using System.Linq;\n\n class Scanner\n {\n private string[] _line;\n private int _index;\n private const char Separator = ' ';\n\n public Scanner()\n {\n _line = new string[0];\n _index = 0;\n }\n\n public string Next()\n {\n if (_index >= _line.Length)\n {\n string s;\n do\n {\n s = Console.ReadLine();\n } while (s.Length == 0);\n\n _line = s.Split(Separator);\n _index = 0;\n }\n\n return _line[_index++];\n }\n\n public string ReadLine()\n {\n _index = _line.Length;\n return Console.ReadLine();\n }\n\n public int NextInt() => int.Parse(Next());\n public long NextLong() => long.Parse(Next());\n public double NextDouble() => double.Parse(Next());\n public decimal NextDecimal() => decimal.Parse(Next());\n public char NextChar() => Next()[0];\n public char[] NextCharArray() => Next().ToCharArray();\n\n public string[] Array()\n {\n string s = Console.ReadLine();\n _line = s.Length == 0 ? new string[0] : s.Split(Separator);\n _index = _line.Length;\n return _line;\n }\n\n public int[] IntArray() => Array().Select(int.Parse).ToArray();\n public long[] LongArray() => Array().Select(long.Parse).ToArray();\n public double[] DoubleArray() => Array().Select(double.Parse).ToArray();\n public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();\n }\n}", "lang_cluster": "C#", "tags": ["dfs and similar", "dp", "shortest paths"], "code_uid": "d5d2e500a60c15129faad25314d04480", "src_uid": "5fe44b6cd804e0766a0e993eca1846cd", "difficulty": 2200.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "/*\ncsc -debug D.cs && mono --debug D.exe <<< \"3\n1 9 3\n8 6 7\n4 2 5\"\nK: (1,1) -> (3,2) -> (1,3) -> (3,2) -> L -> (3,1) -> (3,3) -> (3,2) -> (2,2) -> (2,3) -> (2,1) -> (1,1) -> (1,2)\n 1 2 3 4 5 6 7 8 9\n*/\n\nusing System;\nusing System.Collections.Generic;\nusing System.Linq;\n\npublic class HelloWorld {\n static public void Main () {\n SolveCodeForces();\n }\n\n private enum Fig { K, L, S };\n\n private static int N;\n private static int[][] arr;\n\n public static void SolveCodeForces() {\n N = int.Parse(Console.ReadLine());\n arr = new int[N][];\n for (var i = 0; i < arr.Length; i++)\n arr[i] = Console.ReadLine().Split().Select(int.Parse).ToArray();\n\n var numPos = new int[N*N+1][];\n for (var r = 0; r < arr.Length; r++)\n for (var c = 0; c < arr[r].Length; c++)\n numPos[ arr[r][c] ] = new[] {r, c};\n\n var bestAnswers = new Dictionary{\n { Fig.K, new[] {0, 0} },\n { Fig.L, new[] {0, 0} },\n { Fig.S, new[] {0, 0} },\n };\n for (var d = 2; d <= N * N; d++) {\n var rcFrom = numPos[d - 1];\n var hopAns = new Dictionary{\n { Fig.K, new[] {int.MaxValue, int.MaxValue} },\n { Fig.L, new[] {int.MaxValue, int.MaxValue} },\n { Fig.S, new[] {int.MaxValue, int.MaxValue} },\n };\n foreach (var fig in AllFigs) {\n if (bestAnswers[fig][0] < int.MaxValue)\n foreach (var state in SolveHop(fig, rcFrom[0], rcFrom[1], d)) {\n // System.Console.WriteLine(\"Digits: {0}->{1}, start fig {5}, end fig {2}, moves {3}, switches {4}\", d-1, d, state.Fig, state.Moves, state.Switches, fig);\n var newMoves = bestAnswers[fig][0] + state.Moves;\n var newSwitches = bestAnswers[fig][1] + state.Switches;\n\n var prevAns = hopAns[state.Fig];\n if (prevAns[0] == int.MaxValue) {\n prevAns[0] = newMoves;\n prevAns[1] = newSwitches;\n }\n else if (newMoves < prevAns[0] || (newMoves == prevAns[0] && newSwitches < prevAns[1])) {\n prevAns[0] = newMoves;\n prevAns[1] = newSwitches;\n }\n }\n }\n bestAnswers = hopAns;\n }\n\n var bestAns = bestAnswers.OrderBy(kvp => kvp.Value[0]).ThenBy(kvp => kvp.Value[1]).First().Value;\n System.Console.WriteLine(\"{0} {1}\", bestAns[0], bestAns[1]);\n }\n\n private struct State { public int R; public int C; public Fig Fig; public int Moves; public int Switches; }\n\n private static bool AreIndicesAllowed(int r, int c) {\n return r >= 0 && r < N && c >= 0 && c < N;\n }\n\n private static readonly int[][] K_Moves = new[] {\n new[] { -2, -1 },\n new[] { -2, 1 },\n new[] { -1, -2 },\n new[] { -1, 2 },\n new[] { 1, -2 },\n new[] { 1, 2 },\n new[] { 2, -1 },\n new[] { 2, 1 },\n };\n\n private static readonly int[][] S_Moves = new[] {\n new[] { -1, -1 },\n new[] { -1, 1 },\n new[] { 1, -1 },\n new[] { 1, 1 },\n };\n\n private static Fig[] AllFigs = new[] { Fig.L, Fig.S, Fig.K };\n\n private static IEnumerable ExpandState(State state) {\n if (state.Fig == Fig.K) {\n foreach (var drdc in K_Moves) {\n var r = drdc[0] + state.R;\n var c = drdc[1] + state.C;\n if (AreIndicesAllowed(r, c))\n yield return new State { Fig = Fig.K, R = r, C = c, Moves = state.Moves + 1, Switches = state.Switches };\n }\n }\n else if (state.Fig == Fig.L) {\n for (var r = 0; r < N; r++)\n if (r != state.R)\n yield return new State { Fig = Fig.L, R = r, C = state.C, Moves = state.Moves + 1, Switches = state.Switches };\n for (var c = 0; c < N; c++)\n if (c != state.C)\n yield return new State { Fig = Fig.L, R = state.R, C = c, Moves = state.Moves + 1, Switches = state.Switches };\n }\n else if (state.Fig == Fig.S) {\n for (var d = 1; d < N; d++)\n foreach (var drdc in S_Moves) {\n var r = d * drdc[0] + state.R;\n var c = d * drdc[1] + state.C;\n if (AreIndicesAllowed(r, c))\n yield return new State { Fig = Fig.S, R = r, C = c, Moves = state.Moves + 1, Switches = state.Switches };\n }\n }\n foreach (var fig in AllFigs)\n if (fig != state.Fig)\n yield return new State { Fig = fig, R = state.R, C = state.C, Moves = state.Moves + 1, Switches = state.Switches + 1 };\n }\n\n // Returns: end fig => [ number of moves, number of fig switches ]\n private static IEnumerable SolveHop(Fig startFig, int rFrom, int cFrom, int targetDigit) {\n var Q = new Queue();\n Q.Enqueue(new State { Fig = startFig, R = rFrom, C = cFrom });\n while (Q.Count > 0) {\n var state = Q.Dequeue();\n if (arr[state.R][state.C] == targetDigit)\n yield return state;\n // There is an always solution with 3 moves: switch to L, hop horizontally, hop vertically\n else if (state.Moves < 3)\n foreach (var neigh in ExpandState(state)) {\n Q.Enqueue(neigh);\n }\n }\n }\n}\n\npublic static class Helpers {\n public static T[] CreateArray(int length, Func itemCreate) {\n var result = new T[length];\n for (var i = 0; i < result.Length; i++)\n result[i] = itemCreate(i);\n return result;\n }\n}", "lang_cluster": "C#", "tags": ["dfs and similar", "dp", "shortest paths"], "code_uid": "e2d77f642ef7116577b656dfa3a4f89b", "src_uid": "5fe44b6cd804e0766a0e993eca1846cd", "difficulty": 2200.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\n\nnamespace ConsoleTidbits\n{\n class JustCodeForces\n {\n int N;\n int[,] board;\n Dictionary> locations;\n\n public static void Main()\n {\n JustCodeForces obj = new JustCodeForces();\n\n //while (true)\n obj.ThreePieces_ContestAnalysis();\n }\n \n int M;\n Tuple[][] dist;\n Tuple[] pos;\n\n int[] X = new int[] { 2, 2, -2, -2, 1, 1, -1, -1 };\n int[] Y = new int[] { -1, 1, -1, 1, 2, -2, 2, -2 };\n private bool In(int x, int y)\n {\n if (x >= 0 && y >= 0 && x < N && y < N) return true;\n return false;\n }\n\n private int Get(int x, int y, int p)\n {\n return x * 3 * N + y * 3 + p;\n }\n private void ThreePieces_ContestAnalysis()\n {\n N = int.Parse(Console.ReadLine());\n\n pos = new Tuple[N * N];\n M = (N - 1) * N * 3 + N * 3 + 3;\n dist = new Tuple[M][];\n for (int i = 0; i < M; i++)\n dist[i] = new Tuple[M];\n\n for (int i = 0; i < N; i++)\n {\n var array = Array.ConvertAll(Console.ReadLine().Split(new char[] { ' ' }), int.Parse);\n\n for (int j = 0; j < N; j++)\n {\n pos[--array[j]] = Tuple.Create(i, j);\n }\n }\n\n for (int i = 0; i < M; i++)\n {\n for (int j = 0; j < M; j++)\n {\n dist[i][j] = Tuple.Create(100000, 100000);\n if (i == j) dist[i][j] = Tuple.Create(0, 0);\n }\n }\n\n\n for (int i = 0; i < N; i++)\n {\n for (int j = 0; j < N; j++)\n {\n //Get Knights distance\n for (int k = 0; k < 8; k++)\n {\n int nx = i + X[k];\n int ny = j + Y[k];\n\n if (In(nx, ny))\n dist[Get(i, j, 0)][Get(nx, ny, 0)] = Tuple.Create(1, 0);\n\n }\n\n //Get Bishops distances\n for (int k = -N + 1; k <= N - 1; k++)\n {\n int nx = i + k;\n int ny = j + k;\n\n if (In(nx, ny))\n {\n dist[Get(i, j, 1)][Get(nx, ny, 1)] = Tuple.Create(1, 0);\n }\n\n ny = j - k;\n if (In(nx, ny))\n dist[Get(i, j, 1)][Get(nx, ny, 1)] = Tuple.Create(1, 0);\n }\n\n //Get Rook distance\n for (int k = 0; k < N; k++)\n {\n int nx = i;\n int ny = k;\n dist[Get(i, j, 2)][Get(nx, ny, 2)] = Tuple.Create(1, 0);\n\n nx = k;\n ny = j;\n\n dist[Get(i, j, 2)][Get(nx, ny, 2)] = Tuple.Create(1, 0);\n }\n\n //Replace at the exact location\n for (int k = 0; k < 3; k++)\n {\n for (int m = 0; m < 3; m++)\n {\n if (k != m)\n dist[Get(i, j, k)][Get(i, j, m)] = Tuple.Create(1, 1);\n }\n }\n }\n }\n\n for (int k = 0; k < M; k++)\n {\n for (int i = 0; i < M; i++)\n {\n for (int j = 0; j < M; j++)\n {\n if (dist[i][j].Item1 > dist[i][k].Item1 + dist[k][j].Item1)\n {\n dist[i][j] = Tuple.Create(dist[i][k].Item1 + dist[k][j].Item1,\n dist[i][k].Item2 + dist[k][j].Item2);\n }\n else if (dist[i][j].Item1 == dist[i][k].Item1 + dist[k][j].Item1\n && dist[i][j].Item2 > dist[i][k].Item2 + dist[k][j].Item2)\n {\n dist[i][j] = Tuple.Create(dist[i][j].Item1, dist[i][k].Item2 + dist[k][j].Item2);\n }\n }\n }\n }\n\n var dp = new Tuple[N * N][];\n for (int i = 0; i < N * N; i++)\n {\n dp[i] = new Tuple[3];\n\n for (int k = 0; k < 3; k++)\n {\n dp[i][k] = Tuple.Create(100000, 100000);\n }\n }\n dp[0][0] = Tuple.Create(0, 0);\n dp[0][1] = Tuple.Create(0, 0);\n dp[0][2] = Tuple.Create(0, 0);\n\n for (int i = 0; i < N * N - 1; i++)\n {\n for (int j = 0; j < 3; j++)\n {\n for (int k = 0; k < 3; k++)\n {\n var new_min = dp[i][j].Item1 + dist[Get(pos[i].Item1, pos[i].Item2, j)][Get(pos[i + 1].Item1, pos[i + 1].Item2, k)].Item1;\n if (dp[i + 1][k].Item1 > new_min)\n {\n dp[i + 1][k] = Tuple.Create(new_min, dp[i][j].Item2 + dist[Get(pos[i].Item1, pos[i].Item2, j)][Get(pos[i + 1].Item1, pos[i + 1].Item2, k)].Item2);\n }\n else if (dp[i + 1][k].Item1 == new_min\n && dp[i + 1][k].Item2 > dp[i][j].Item2 + dist[Get(pos[i].Item1, pos[i].Item2, j)][Get(pos[i + 1].Item1, pos[i + 1].Item2, k)].Item2)\n {\n dp[i + 1][k] = Tuple.Create(new_min, dp[i][j].Item2 + dist[Get(pos[i].Item1, pos[i].Item2, j)][Get(pos[i + 1].Item1, pos[i + 1].Item2, k)].Item2);\n }\n }\n }\n }\n\n var res = dp[N * N - 1][0];\n if (res.Item1 > dp[N * N - 1][1].Item1\n || (res.Item1 == dp[N * N - 1][1].Item1 && res.Item2 > dp[N * N - 1][1].Item2))\n {\n res = dp[N * N - 1][1];\n }\n if (res.Item1 > dp[N * N - 1][2].Item1\n || (res.Item1 == dp[N * N - 1][2].Item1 && res.Item2 > dp[N * N - 1][2].Item2))\n {\n res = dp[N * N - 1][2];\n }\n\n Console.WriteLine(\"\" + res.Item1 + \" \" + res.Item2);\n }\n }\n}", "lang_cluster": "C#", "tags": ["dfs and similar", "dp", "shortest paths"], "code_uid": "47d10ab8edab4fa00f6c4a8f7e6e416d", "src_uid": "5fe44b6cd804e0766a0e993eca1846cd", "difficulty": 2200.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.IO;\n\nnamespace Codeforces\n{\n#if _ONLINE_JUDGE_\n\t[OnlineJudge.Task(\"Codeforces 200C\")]\n#endif\n\tclass Task200C\n\t{\n\t\tprivate InputTokenizer input = new InputTokenizer();\n\t\tprivate TextWriter output = Console.Out;\n\n\t\tstruct Annoyed\n\t\t{\n\t\t\tpublic string name;\n\t\t\tpublic Team info;\n\t\t}\n\n\t\tstruct Team\n\t\t{\n\t\t\tpublic int goals, missed_goals, plays, points;\n\t\t}\n\n\t\tstruct Comp : IComparer\n\t\t{\n\t\t\tpublic int Compare(Annoyed x, Annoyed y)\n\t\t\t{\n\t\t\t\t{\n\t\t\t\t\tint a = x.info.points, b = y.info.points;\n\t\t\t\t\tif (a != b) return b - a;\n\t\t\t\t}\n\n\t\t\t\t{\n\t\t\t\t\tint a = x.info.goals - x.info.missed_goals, b = y.info.goals - y.info.missed_goals;\n\t\t\t\t\tif (a != b) return b - a;\n\t\t\t\t}\n\n\t\t\t\t{\n\t\t\t\t\tint a = x.info.goals, b = y.info.goals;\n\t\t\t\t\tif (a != b) return b - a;\n\t\t\t\t}\n\n\t\t\t\treturn x.name.CompareTo(y.name);\n\t\t\t}\n\t\t}\n\n\t\tprivate void Solve()\n\t\t{\n\t\t\tvar teams = new Dictionary();\n\n\t\t\tstring a, b, g;\n\t\t\tfor (int i = 0; i < 5; ++i) {\n\t\t\t\tinput.Line().Read(out a).Read(out b).Read(out g);\n\t\t\t\tint g1 = g[0] - '0', g2 = g[2] - '0';\n\n\t\t\t\tTeam A = new Team(), B = new Team();\n\t\t\t\tif (teams.ContainsKey(a)) A = teams[a];\n\t\t\t\tif (teams.ContainsKey(b)) B = teams[b];\n\n\t\t\t\tif (g1 > g2) {\n\t\t\t\t\tA.points += 3;\n\t\t\t\t} else if (g1 < g2) {\n\t\t\t\t\tB.points += 3;\n\t\t\t\t} else {\n\t\t\t\t\t++A.points;\n\t\t\t\t\t++B.points;\n\t\t\t\t}\n\n\t\t\t\tA.goals += g1;\n\t\t\t\tA.missed_goals += g2;\n\t\t\t\t++A.plays;\n\t\t\t\tteams[a] = A;\n\n\t\t\t\tB.goals += g2;\n\t\t\t\tB.missed_goals += g1;\n\t\t\t\t++B.plays;\n\t\t\t\tteams[b] = B;\n\t\t\t}\n\n\t\t\tvar comp = new Comp();\n\n\t\t\tvar nt = (from x in teams\n\t\t\t\t\t\t\t\tselect new Annoyed {\n\t\t\t\t\t\t\t\t\tname = x.Key,\n\t\t\t\t\t\t\t\t\tinfo = x.Value\n\t\t\t\t\t\t\t\t}).ToArray();\n\n\t\t\tint asd = -1, asr = -1;\n\t\t\tfor (int i = 0; i < 4; ++i) {\n\t\t\t\tif (nt[i].name == \"BERLAND\")\n\t\t\t\t\tasd = i;\n\t\t\t\telse if (nt[i].info.plays == 2)\n\t\t\t\t\tasr = i;\n\t\t\t}\n\n\t\t\tint X = 10000, Y = 10000, dXY = 10000000;\n\t\t\tfor (int _X = 0; _X < 100; ++_X)\n\t\t\t\tfor (int _Y = 0; _Y < 100; ++_Y) {\n\t\t\t\t\tnt[asd].info.points += 3;\n\t\t\t\t\tnt[asd].info.goals += _X;\n\t\t\t\t\tnt[asd].info.missed_goals += _Y;\n\n\t\t\t\t\tnt[asr].info.goals += _Y;\n\t\t\t\t\tnt[asr].info.missed_goals += _X;\n\n\t\t\t\t\tvar st = nt.OrderBy(t => t, comp).ToArray();\n\t\t\t\t\tif (_X > _Y && (st[0].name == \"BERLAND\" || st[1].name == \"BERLAND\") && (_X - _Y < dXY || (_X - _Y == dXY && _Y < Y))) {\n\t\t\t\t\t\tX = _X;\n\t\t\t\t\t\tY = _Y;\n\t\t\t\t\t\tdXY = X - Y;\n\t\t\t\t\t}\n\n\t\t\t\t\tnt[asd].info.points -= 3;\n\t\t\t\t\tnt[asd].info.goals -= _X;\n\t\t\t\t\tnt[asd].info.missed_goals -= _Y;\n\n\t\t\t\t\tnt[asr].info.goals -= _Y;\n\t\t\t\t\tnt[asr].info.missed_goals -= _X;\n\t\t\t\t}\n\n\t\t\tif (X == 10000)\n\t\t\t\toutput.WriteLine(\"IMPOSSIBLE\");\n\t\t\telse\n\t\t\t\toutput.WriteLine(\"{0}:{1}\", X, Y);\n\t\t}\n\n\t\t#region\n\t\tpublic static void Main()\n\t\t{\n\t\t\tvar obj = new Task200C();\n\t\t\tobj.Solve();\n\t\t}\n\n\t\tprivate class InputTokenizer\n\t\t{\n\t\t\tprivate List _tokens = new List();\n\t\t\tprivate int _offset = 0;\n\n\t\t\tpublic InputTokenizer()\n\t\t\t{\n\t\t\t}\n\n\t\t\tpublic InputTokenizer String(String s)\n\t\t\t{\n\t\t\t\t_tokens.AddRange(s.Split(new char[] { ' ', '\\n', '\\t', '\\r' }, StringSplitOptions.RemoveEmptyEntries));\n\t\t\t\treturn this;\n\t\t\t}\n\n\t\t\tpublic InputTokenizer Line()\n\t\t\t{\n\t\t\t\treturn String(Console.In.ReadLine());\n\t\t\t}\n\n\t\t\tpublic InputTokenizer Read(out int v)\n\t\t\t{\n\t\t\t\tv = int.Parse(_tokens[_offset++]);\n\t\t\t\treturn this;\n\t\t\t}\n\n\t\t\tpublic InputTokenizer Read(int n, out int[] v)\n\t\t\t{\n\t\t\t\tv = new int[n];\n\t\t\t\tfor (int i = 0; i < n; ++i) Read(out v[i]);\n\t\t\t\treturn this;\n\t\t\t}\n\n\t\t\tpublic InputTokenizer Read(out long v)\n\t\t\t{\n\t\t\t\tv = long.Parse(_tokens[_offset++]);\n\t\t\t\treturn this;\n\t\t\t}\n\n\t\t\tpublic InputTokenizer Read(int n, out long[] v)\n\t\t\t{\n\t\t\t\tv = new long[n];\n\t\t\t\tfor (int i = 0; i < n; ++i) Read(out v[i]);\n\t\t\t\treturn this;\n\t\t\t}\n\n\t\t\tpublic InputTokenizer Read(out ulong v)\n\t\t\t{\n\t\t\t\tv = ulong.Parse(_tokens[_offset++]);\n\t\t\t\treturn this;\n\t\t\t}\n\n\t\t\tpublic InputTokenizer Read(int n, out ulong[] v)\n\t\t\t{\n\t\t\t\tv = new ulong[n];\n\t\t\t\tfor (int i = 0; i < n; ++i) Read(out v[i]);\n\t\t\t\treturn this;\n\t\t\t}\n\n\t\t\tpublic InputTokenizer Read(out double v)\n\t\t\t{\n\t\t\t\tv = double.Parse(_tokens[_offset++].Replace('.', ','));\n\t\t\t\treturn this;\n\t\t\t}\n\n\t\t\tpublic InputTokenizer Read(int n, out double[] v)\n\t\t\t{\n\t\t\t\tv = new double[n];\n\t\t\t\tfor (int i = 0; i < n; ++i) Read(out v[i]);\n\t\t\t\treturn this;\n\t\t\t}\n\n\t\t\tpublic InputTokenizer Read(out string v)\n\t\t\t{\n\t\t\t\tv = _tokens[_offset++];\n\t\t\t\treturn this;\n\t\t\t}\n\n\t\t\tpublic InputTokenizer Read(int n, out string[] v)\n\t\t\t{\n\t\t\t\tv = new string[n];\n\t\t\t\tfor (int i = 0; i < n; ++i) Read(out v[i]);\n\t\t\t\treturn this;\n\t\t\t}\n\t\t}\n\t\t#endregion\n\t}\n}\n", "lang_cluster": "C#", "tags": ["brute force", "implementation"], "code_uid": "a911320cfda93b9feb5bfb7208c42f6c", "src_uid": "5033d51c67b7ae0b1a2d9fd292fdced1", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "#define Online\n\nusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.IO;\nusing System.Diagnostics;\nusing System.Threading;\n\n\nnamespace CF\n{\n delegate double F(double x);\n delegate decimal Fdec(decimal x);\n\n class Team : IComparable\n {\n public string name;\n public int goal;\n public int miss;\n public int point;\n public int cnt;\n public int CompareTo(Team y)\n {\n if (this.point > y.point)\n {\n return 1;\n }\n else\n {\n if (this.point == y.point)\n {\n if (this.goal - this.miss > y.goal - y.miss)\n {\n return 1;\n }\n else\n {\n if (this.goal - this.miss == y.goal - y.miss)\n {\n if (this.goal > y.goal)\n {\n return 1;\n }\n else\n {\n if (this.goal == y.goal)\n {\n if (this.name.CompareTo(y.name) < 0)\n return 1;\n else\n return -1;\n }\n else\n {\n return -1;\n }\n }\n\n }\n else\n {\n return -1;\n }\n }\n }\n else\n {\n return -1;\n }\n }\n }\n }\n\n class Program\n {\n\n static void Main(string[] args)\n {\n\n#if FileIO\n StreamReader sr = new StreamReader(\"input.txt\");\n StreamWriter sw = new StreamWriter(\"output.txt\");\n Console.SetIn(sr);\n Console.SetOut(sw);\n#endif\n\n Team[] t = new Team[4];\n for (int i = 0; i < 5; i++)\n {\n string[] input = ReadArray();\n string[] score = input[2].Split(':');\n int x = int.Parse(score[0]);\n int y = int.Parse(score[1]);\n for (int j = 0; j < 4; j++)\n {\n if (t[j] == null)\n {\n t[j] = new Team();\n t[j].name = input[0];\n }\n if (t[j].name.Equals(input[0]))\n {\n if (x > y) t[j].point += 3;\n if (x == y) t[j].point++;\n t[j].goal += x;\n t[j].miss += y;\n t[j].cnt++;\n break;\n }\n\n }\n for (int j = 0; j < 4; j++)\n {\n if (t[j] == null)\n {\n t[j] = new Team();\n t[j].name = input[1];\n }\n if (t[j].name.Equals(input[1]))\n {\n if (y > x) t[j].point += 3;\n if (x == y) t[j].point++;\n t[j].goal += y;\n t[j].miss += x;\n t[j].cnt++;\n break;\n }\n }\n }\n\n for (int i = 0; i < 4; i++)\n if (t[i].name.Equals(\"BERLAND\"))\n t[i].point += 3;\n\n Team[] L = new Team[4];\n Team[] R = new Team[4];\n ArrayUtils.Merge_Sort(t, 0, 3, L, R);\n\n int ber, opp;\n ber = opp = 0;\n for (int i = 0; i < 4; i++)\n {\n if (t[i].name.Equals(\"BERLAND\"))\n {\n ber = i;\n }\n else if (t[i].cnt == 2)\n {\n opp = i;\n }\n }\n\n int dif_max = int.MinValue;\n int goal_max = int.MinValue;\n for (int i = 0; i < 4; i++)\n {\n if (i == ber) continue;\n dif_max = Math.Max(t[i].goal - t[i].miss + Math.Abs(t[ber].goal - t[ber].miss), dif_max);\n goal_max = Math.Max(t[i].goal, goal_max);\n }\n for (int i = 1; i <= dif_max; i++)\n {\n\n for (int j = i; j <= goal_max + 1; j++)\n {\n int comp = 0;\n t[opp].goal += j - i;\n t[opp].miss += j;\n t[ber].goal += j;\n t[ber].miss += j - i;\n for (int z = 0; z < 4; z++)\n {\n if (z == ber) continue;\n if (t[ber].CompareTo(t[z]) > 0)\n comp++;\n }\n if (comp >= 2)\n {\n Console.WriteLine(j + \":\" + (j - i));\n return;\n }\n else\n {\n t[opp].goal -= j - i;\n t[opp].miss -= j;\n t[ber].goal -= j;\n t[ber].miss -= j - i;\n }\n }\n }\n Console.WriteLine(\"IMPOSSIBLE\");\n\n#if Online\n Console.ReadLine();\n#endif\n\n#if FileIO\n sr.Close();\n sw.Close();\n#endif\n }\n\n static string[] ReadArray()\n {\n return Console.ReadLine().Split(' ');\n }\n\n static int ReadInt()\n {\n return int.Parse(Console.ReadLine());\n }\n }\n\n /* public static class MyMath\n {\n public static long BinPow(long a, long n, long mod)\n {\n long res = 1;\n while (n > 0)\n {\n if ((n & 1) == 1)\n {\n res = (res * a) % mod;\n }\n a = (a * a) % mod;\n n >>= 1;\n }\n return res;\n }\n\n public static long GCD(long a, long b)\n {\n while (b != 0) b = a % (a = b);\n return a;\n }\n\n public static int GCD(int a, int b)\n {\n while (b != 0) b = a % (a = b);\n return a;\n }\n\n public static long LCM(long a, long b)\n {\n return (a * b) / GCD(a, b);\n }\n\n public static int LCM(int a, int b)\n {\n return (a * b) / GCD(a, b);\n }\n }\n\n public class SegmentTree\n {\n int[] v_min;\n int[] v_max;\n int[] mas;\n public void BuildTree(int[] a)\n {\n int n = a.Length - 1;\n int z = 0;\n while (n >= 2)\n {\n z++;\n n >>= 1;\n }\n n = 1 << (z + 1);\n v_min = new int[n << 1];\n v_max = new int[n << 1];\n mas = new int[n << 1];\n for (int i = n; i < n + a.Length; i++)\n v_min[i] = a[i - n];\n for (int i = n + a.Length; i < v_min.Length; i++)\n v_min[i] = int.MaxValue;\n for (int i = n - 1; i > 0; i--)\n v_min[i] = Math.Min(v_min[(i << 1)], v_min[(i << 1) + 1]);\n\n for (int i = n; i < n + a.Length; i++)\n v_max[i] = a[i - n];\n for (int i = n + a.Length; i < v_max.Length; i++)\n v_max[i] = int.MinValue;\n for (int i = n - 1; i > 0; i--)\n v_max[i] = Math.Max(v_max[(i << 1)], v_max[(i << 1) + 1]);\n\n }\n //nil\n public int RMQ_MIN(int l, int r)\n {\n int ans = int.MaxValue;\n l += v_min.Length >> 1;\n r += v_min.Length >> 1;\n const int o = 1;\n while (l <= r)\n {\n if ((l & 1) == o)\n ans = Math.Min(ans, v_min[l]);\n if (!((r & 1) == 0))\n ans = Math.Min(ans, v_min[r]);\n l = (l + 1) >> 1;\n r = (r - 1) >> 1;\n }\n return ans;\n }\n\n public int RMQ_MAX(int l, int r)\n {\n int ans = int.MinValue;\n l += v_max.Length >> 1;\n r += v_max.Length >> 1;\n const int o = 1;\n while (l <= r)\n {\n if ((l & 1) == o)\n ans = Math.Max(ans, v_max[l]);\n if (!((r & 1) == 0))\n ans = Math.Max(ans, v_max[r]);\n l = (l + 1) >> 1;\n r = (r - 1) >> 1;\n }\n return ans;\n }\n\n public void Put(int l, int r, int op)\n {\n l += mas.Length >> 1;\n r += mas.Length >> 1;\n while (l <= r)\n {\n if (l % 2 != 0)\n mas[l] = op;\n if (r % 2 == 0)\n mas[r] = op;\n l = (l + 1) >> 1;\n r = (r - 1) >> 1;\n }\n }\n\n public int Get(int x)\n {\n x += mas.Length >> 1;\n int ans = int.MinValue;\n while (x > 0)\n {\n ans = Math.Max(mas[x], ans);\n x >>= 1;\n }\n return ans;\n }\n\n public void Update(int i, int x)\n {\n i += v_min.Length >> 1;\n v_min[i] = x;\n v_max[i] = x;\n i >>= 1;\n while (i > 0)\n {\n v_min[i] = Math.Min(v_min[(i << 1)], v_min[(i << 1) + 1]);\n v_max[i] = Math.Max(v_max[(i << 1)], v_max[(i << 1) + 1]);\n i >>= 1;\n }\n }\n }\n\n class Edge\n {\n public int a;\n public int b;\n public int w;\n\n public Edge(int a, int b, int w)\n {\n this.a = a;\n this.b = b;\n this.w = w;\n }\n }\n\n /* class Graph\n {\n public List[] g;\n public int[] color; //0-white, 1-gray, 2-black\n public int[] o; //open\n public int[] c; //close\n public int[] p;\n public int[] d;\n public List e;\n\n public Graph(int n)\n {\n g = new List[n + 1];\n color = new int[n + 1];\n o = new int[n + 1];\n c = new int[n + 1];\n p = new int[n + 1];\n d = new int[n + 1];\n }\n }\n\n static class GraphUtils\n {\n const int white = 0;\n const int gray = 1;\n const int black = 2;\n\n public static void BFS(int s, Graph g)\n {\n Queue q = new Queue();\n q.Enqueue(s);\n while (q.Count != 0)\n {\n int u = q.Dequeue();\n for (int i = 0; i < g.g[u].Count; i++)\n {\n int v = g.g[u][i];\n if (g.color[v] == white)\n {\n g.color[v] = gray;\n g.d[v] = g.d[u] + 1;\n g.p[v] = u;\n q.Enqueue(v);\n }\n }\n g.color[u] = black;\n }\n }\n\n public static void DFS(int u, ref int time, Graph g)\n {\n g.color[u] = gray;\n time++;\n g.o[u] = time;\n for (int i = 0; i < g.g[u].Count; i++)\n {\n int v = g.g[u][i];\n if (g.color[v] == white)\n {\n g.p[v] = u;\n DFS(v, ref time, g);\n }\n }\n g.color[u] = black;\n g.c[u] = time;\n time++;\n }\n\n public static void FordBellman(int u, Graph g)\n {\n int n = g.g.Length;\n for (int i = 0; i <= n; i++)\n {\n g.d[i] = int.MaxValue;\n g.p[i] = 0;\n }\n\n g.d[u] = 0;\n\n for (int i = 0; i < n - 1; i++)\n {\n for (int j = 0; j < g.e.Count; j++)\n {\n if (g.d[g.e[j].a] != int.MaxValue)\n {\n if (g.d[g.e[j].a] + g.e[j].w < g.d[g.e[j].b])\n {\n g.d[g.e[j].b] = g.d[g.e[j].a] + g.e[j].w;\n g.p[g.e[j].b] = g.e[j].a;\n }\n }\n }\n }\n }\n }*/\n static class ArrayUtils\n {\n public static int BinarySearch(int[] a, int val)\n {\n int left = 0;\n int right = a.Length - 1;\n int mid;\n\n while (left < right)\n {\n mid = left + ((right - left) >> 1);\n if (val <= a[mid])\n {\n right = mid;\n }\n else\n {\n left = mid + 1;\n }\n }\n\n if (a[left] == val)\n return left;\n else\n return -1;\n }\n\n public static double Bisection(F f, double left, double right, double eps)\n {\n double mid;\n while (right - left > eps)\n {\n mid = left + ((right - left) / 2d);\n if (Math.Sign(f(mid)) != Math.Sign(f(left)))\n right = mid;\n else\n left = mid;\n }\n return (left + right) / 2d;\n }\n\n\n public static decimal TernarySearchDec(Fdec f, decimal eps, decimal l, decimal r, bool isMax)\n {\n decimal m1, m2;\n while (r - l > eps)\n {\n m1 = l + (r - l) / 3m;\n m2 = r - (r - l) / 3m;\n if (f(m1) < f(m2))\n if (isMax)\n l = m1;\n else\n r = m2;\n else\n if (isMax)\n r = m2;\n else\n l = m1;\n }\n return r;\n }\n\n public static double TernarySearch(F f, double eps, double l, double r, bool isMax)\n {\n double m1, m2;\n while (r - l > eps)\n {\n m1 = l + (r - l) / 3d;\n m2 = r - (r - l) / 3d;\n if (f(m1) < f(m2))\n if (isMax)\n l = m1;\n else\n r = m2;\n else\n if (isMax)\n r = m2;\n else\n l = m1;\n }\n return r;\n }\n\n public static void Merge(T[] A, int p, int q, int r, T[] L, T[] R) where T : IComparable\n {\n for (int i = p; i <= q; i++)\n L[i] = A[i];\n for (int i = q + 1; i <= r; i++)\n R[i] = A[i];\n\n for (int k = p, i = p, j = q + 1; k <= r; k++)\n {\n if (i > q)\n {\n for (; k <= r; k++, j++)\n A[k] = R[j];\n return;\n }\n if (j > r)\n {\n for (; k <= r; k++, i++)\n A[k] = L[i];\n return;\n }\n if (L[i].CompareTo(R[j]) <= 0)\n {\n A[k] = L[i];\n i++;\n }\n else\n {\n A[k] = R[j];\n j++;\n }\n }\n }\n\n public static void Merge_Sort(T[] A, int p, int r, T[] L, T[] R) where T : IComparable\n {\n if (p >= r) return;\n int q = p + ((r - p) >> 1);\n Merge_Sort(A, p, q, L, R);\n Merge_Sort(A, q + 1, r, L, R);\n Merge(A, p, q, r, L, R);\n }\n\n static void Shake(T[] a)\n {\n Random rnd = new Random(Environment.TickCount);\n T temp;\n int b, c;\n for (int i = 0; i < a.Length; i++)\n {\n b = rnd.Next(0, a.Length);\n c = rnd.Next(0, a.Length);\n temp = a[b];\n a[b] = a[c];\n a[c] = temp;\n }\n }\n }\n}", "lang_cluster": "C#", "tags": ["brute force", "implementation"], "code_uid": "32cb431d881bb0da1f4169b1cf707c61", "src_uid": "5033d51c67b7ae0b1a2d9fd292fdced1", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\n\nnamespace Contest_63\n{\n class Program\n {\n class mem : IComparable\n {\n public int i;\n public int p;\n //public string name;\n\n public mem(int i, int p)\n {\n this.i = i; this.p = p;\n }\n\n public int CompareTo(Object k)\n {\n var a = (mem)k;\n if (this.p != a.p)\n return this.p.CompareTo(a.p);\n return this.i.CompareTo(a.i);\n }\n }\n\n static void A()\n {\n int n = int.Parse(Console.ReadLine());\n\n SortedList m = new SortedList();\n\n for (int i = 0; i < n; i++)\n {\n var t = Console.ReadLine().Split(' ');\n int p = 0;\n switch (t[1])\n {\n case \"rat\":\n p = 1;\n break;\n case \"child\":\n case \"woman\":\n p = 2;\n break;\n case \"man\":\n p = 3;\n break;\n case \"captain\":\n p = 4;\n break;\n }\n\n m.Add(new mem(i, p), t[0]);\n }\n\n foreach (var e in m)\n Console.WriteLine(e.Value);\n }\n\n static void B()\n {\n var t = Console.ReadLine().Split(' ');\n int n = int.Parse(t[0]);\n int m = int.Parse(t[1]);\n\n SortedDictionary d = new SortedDictionary();\n for (int i = 1; i <= m; i++)\n d.Add(i,0);\n\n\n t = Console.ReadLine().Split(' ');\n\n foreach (var s in t)\n {\n int k = int.Parse(s);\n d[k]++;\n }\n\n int l = 0;\n for (; d[m] != n; l++)\n {\n for (int j = m-1; j > 0; j--)\n {\n if (d[j] > 0)\n {\n d[j + 1]++;\n d[j]--;\n }\n }\n }\n Console.WriteLine(l);\n }\n\n static bool check(string s1, string s2, int x, int y)\n {\n int kx = 0;\n int ky = 0;\n\n for (int i = 0; i < 4; i++)\n if (s1[i] == s2[i])\n kx++;\n if (kx != x)\n return false;\n ky = s1.Intersect(s2).Count();\n if (ky - kx != y)\n return false;\n return true;\n }\n\n static void C()\n {\n var l = new List();\n int[] a = new int[4];\n for (a[0] = 0; a[0] <= 9; a[0]++)\n for (a[1] = 0; a[1] <= 9; a[1]++)\n for (a[2] = 0; a[2] <= 9; a[2]++)\n for (a[3] = 0; a[3] <= 9; a[3]++)\n {\n string s = \"\" + a[0] + a[1] + a[2] + a[3];\n if (!((a[0] == a[1]) || (a[0] == a[2]) || (a[0] == a[3]) || (a[1] == a[2]) || (a[1] == a[3]) || (a[2] == a[3])))\n l.Add(s);\n }\n\n int n = int.Parse(Console.ReadLine());\n\n for (int i = 0; i < n; i++)\n {\n var t = Console.ReadLine().Split(' ');\n string b = t[0];\n int x = int.Parse(t[1]);\n int y = int.Parse(t[2]);\n for (int k = 0;k < l.Count; k++)\n {\n if (!check(l[k], b, x, y))\n {\n l.Remove(l[k]);\n k--;\n }\n }\n }\n\n if (l.Count > 1)\n Console.WriteLine(\"Need more data\");\n if (l.Count == 0)\n Console.WriteLine(\"Incorrect data\");\n if (l.Count == 1)\n Console.WriteLine(l[0]);\n }\n\n static void Main(string[] args)\n {\n C();\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "implementation"], "code_uid": "ec1e03350370f945f560a05871becd89", "src_uid": "142e5f2f08724e53c234fc2379216b4c", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\n\nnamespace ProgrammingContest.Codeforces.Round59\n{\n class C\n {\n int n;\n int[][] dat;\n int count;\n int res;\n int[] xs = new int[4];\n\n bool ok(int[] data)\n {\n int a = 0, b = 0;\n int[] pos = new int[10];\n for (int i = 0; i < 10; i++)\n pos[i] = -1;\n for (int i = 0; i < 4; i++)\n pos[xs[i]] = i;\n for (int m = data[0], i = 3; i >= 0; i--, m /= 10)\n {\n if (pos[m % 10] == i) a++;\n else if (pos[m % 10] >= 0) b++;\n }\n\n return a == data[1] && b == data[2];\n }\n\n void dfs(int idx)\n {\n if (idx >= 4)\n {\n if (dat.All(d => ok(d)))\n {\n res = xs[0] * 1000 + xs[1] * 100 + xs[2] * 10 + xs[3];\n count++;\n }\n return;\n }\n\n for (int i = 0; i < 10; i++)\n {\n if (xs.Take(idx).All(x => x != i))\n {\n xs[idx] = i;\n dfs(idx + 1);\n }\n }\n }\n\n C()\n {\n n = int.Parse(Console.ReadLine());\n dat = new int[n][];\n for (int i = 0; i < n; i++)\n dat[i] = Array.ConvertAll(Console.ReadLine().Split(' '), sss => int.Parse(sss));\n\n xs = new int[4];\n dfs(0);\n\n Console.WriteLine(\n count == 0 ? \"Incorrect data\" :\n (count != 1 ? \"Need more data\" : res.ToString(\"0000\")));\n }\n\n public static void Main()\n {\n new C();\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "implementation"], "code_uid": "be44d2065e502aed79b2da0acceafaa9", "src_uid": "142e5f2f08724e53c234fc2379216b4c", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing CompLib.Util;\n\npublic class Program\n{\n int N, K;\n int[] A;\n int Ans = int.MaxValue;\n public void Solve()\n {\n var sc = new Scanner();\n N = sc.NextInt();\n K = sc.NextInt();\n A = sc.IntArray();\n var ls = A.ToList();\n ls.Sort();\n DFS(ls, 1);\n Console.WriteLine(Ans);\n }\n\n\n void DFS(List L, int i)\n {\n if (L.Count < K) return;\n int[] cnt = new int[L.Count];\n for (int j = 0; j < L.Count; j++)\n {\n int c = 0;\n int tmp = L[j];\n while (tmp > 0)\n {\n c++;\n tmp /= 2;\n }\n cnt[j] = c;\n }\n {\n int cost = 0;\n for (int j = 0; j < K; j++)\n {\n cost += cnt[j] - i;\n }\n Ans = Math.Min(Ans, cost);\n }\n // i\u6841\u4ee5\u4e0a\u306f\u4e00\u81f4\u3057\u3066\u3044\u308b\n // \u4e0a\u4f4di\u6841\u3092\u898b\u308b\n // 0\u306e\u3084\u30641\u306e\u3084\u3064\u306b\u632f\u308a\u5206\u3051\u308b\n\n List zero = new List();\n List one = new List();\n for (int j = 0; j < L.Count; j++)\n {\n int ll = cnt[j] - i - 1;\n if (ll < 0) continue;\n if ((L[j] & (1 << ll)) == 0) zero.Add(L[j]);\n else one.Add(L[j]);\n }\n DFS(zero, i + 1);\n DFS(one, i + 1);\n }\n\n public static void Main(string[] args) => new Program().Solve();\n}\n\nnamespace CompLib.Util\n{\n using System;\n using System.Linq;\n\n class Scanner\n {\n private string[] _line;\n private int _index;\n private const char Separator = ' ';\n\n public Scanner()\n {\n _line = new string[0];\n _index = 0;\n }\n\n public string Next()\n {\n while (_index >= _line.Length)\n {\n _line = Console.ReadLine().Split(Separator);\n _index = 0;\n }\n\n return _line[_index++];\n }\n\n public int NextInt() => int.Parse(Next());\n public long NextLong() => long.Parse(Next());\n public double NextDouble() => double.Parse(Next());\n public decimal NextDecimal() => decimal.Parse(Next());\n public char NextChar() => Next()[0];\n public char[] NextCharArray() => Next().ToCharArray();\n\n public string[] Array()\n {\n _line = Console.ReadLine().Split(Separator);\n _index = _line.Length;\n return _line;\n }\n\n public int[] IntArray() => Array().Select(int.Parse).ToArray();\n public long[] LongArray() => Array().Select(long.Parse).ToArray();\n public double[] DoubleArray() => Array().Select(double.Parse).ToArray();\n public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "implementation"], "code_uid": "04273ff023d9c14e51adddae4b0c7df4", "src_uid": "ed1a2ae733121af6486568e528fe2d84", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.IO;\nusing System.Text;\n\nnamespace Equalizing_by_Division\n{\n internal class Program\n {\n private static readonly StreamReader reader = new StreamReader(Console.OpenStandardInput(1024*10), Encoding.ASCII, false, 1024*10);\n private static readonly StreamWriter writer = new StreamWriter(Console.OpenStandardOutput(1024*10), Encoding.ASCII, 1024*10);\n\n private static void Main(string[] args)\n {\n writer.WriteLine(Solve(args));\n writer.Flush();\n }\n\n private static int Solve(string[] args)\n {\n int n = Next();\n int k = Next();\n\n var nn = new int[n];\n for (int i = 0; i < n; i++)\n {\n nn[i] = Next();\n }\n Array.Sort(nn);\n\n var head = new Leaf();\n\n foreach (int i in nn)\n {\n var st = new Stack();\n int ii = i;\n while (ii > 0)\n {\n st.Push(ii & 1);\n ii >>= 1;\n }\n\n Leaf c = head;\n c.count++;\n while (st.Count > 0)\n {\n if (c.count <= k)\n {\n c.cost += st.Count;\n }\n int p = st.Pop();\n if (p == 0)\n {\n if (c.l == null)\n c.l = new Leaf();\n c = c.l;\n }\n else\n {\n if (c.r == null)\n c.r = new Leaf();\n c = c.r;\n }\n c.count++;\n }\n }\n int min = head.cost;\n var q = new Queue();\n q.Enqueue(head);\n while (q.Count > 0)\n {\n Leaf t = q.Dequeue();\n if (t.l != null && t.l.count >= k)\n {\n min = Math.Min(min, t.l.cost);\n q.Enqueue(t.l);\n }\n if (t.r != null && t.r.count >= k)\n {\n min = Math.Min(min, t.r.cost);\n q.Enqueue(t.r);\n }\n }\n return min;\n }\n\n private static int Next()\n {\n int c;\n int res = 0;\n do\n {\n c = reader.Read();\n if (c == -1)\n return res;\n } while (c < '0' || c > '9');\n res = c - '0';\n while (true)\n {\n c = reader.Read();\n if (c < '0' || c > '9')\n return res;\n res *= 10;\n res += c - '0';\n }\n }\n\n #region Nested type: Leaf\n\n private class Leaf\n {\n public int cost;\n public int count;\n public Leaf l, r;\n }\n\n #endregion\n }\n}", "lang_cluster": "C#", "tags": ["brute force", "implementation"], "code_uid": "658a4e403a2febf047032784ddcae578", "src_uid": "ed1a2ae733121af6486568e528fe2d84", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Globalization;\nusing System.IO;\nusing System.Linq;\nusing System.Text;\nusing System.Threading;\n\n// (\u3065\u00b0\u03c9\u00b0)\u3065\uff90\u2605\u309c\u30fb\u3002\u3002\u30fb\u309c\u309c\u30fb\u3002\u3002\u30fb\u309c\u2606\u309c\u30fb\u3002\u3002\u30fb\u309c\u309c\u30fb\u3002\u3002\u30fb\u309c\npublic class Solver\n{\n private const int MAX = 500000;\n\n public void Solve()\n {\n int n = ReadInt();\n int d = ReadInt();\n var a = ReadIntArray();\n\n var dp = new bool[MAX + 1];\n dp[0] = true;\n for (int i = 0; i < n; i++)\n {\n for (int j = MAX; j >= 0; j--)\n if (dp[j])\n dp[j + a[i]] = true;\n }\n\n int x = 0;\n int ans = 0;\n while (true)\n {\n int y = Math.Min(x + d, MAX);\n while (!dp[y])\n y--;\n if (x == y)\n break;\n ans++;\n x = y;\n }\n\n Write(x, ans);\n }\n \n #region Main\n\n protected static TextReader reader;\n protected static TextWriter writer;\n\n static void Main()\n {\n#if DEBUG\n reader = new StreamReader(\"..\\\\..\\\\input.txt\");\n writer = Console.Out;\n //writer = new StreamWriter(\"..\\\\..\\\\output.txt\");\n#else\n reader = new StreamReader(Console.OpenStandardInput());\n writer = new StreamWriter(Console.OpenStandardOutput());\n //reader = new StreamReader(\"subsequences.in\");\n //writer = new StreamWriter(\"subsequences.out\");\n#endif\n try\n {\n// var thread = new Thread(new Solver().Solve, 1024 * 1024 * 256);\n// thread.Start();\n// thread.Join();\n new Solver().Solve(); \n }\n catch (Exception ex)\n {\n#if DEBUG\n Console.WriteLine(ex);\n#else\n Console.WriteLine(ex);\n throw;\n#endif\n }\n reader.Close();\n writer.Close();\n }\n\n #endregion\n\n #region Read / Write\n\n private static Queue currentLineTokens = new Queue();\n\n private static string[] ReadAndSplitLine()\n {\n return reader.ReadLine().Split(new[] { ' ', '\\t' }, StringSplitOptions.RemoveEmptyEntries);\n }\n\n public static string ReadToken()\n {\n while (currentLineTokens.Count == 0)\n currentLineTokens = new Queue(ReadAndSplitLine());\n return currentLineTokens.Dequeue();\n }\n\n public static int ReadInt()\n {\n return int.Parse(ReadToken());\n }\n\n public static long ReadLong()\n {\n return long.Parse(ReadToken());\n }\n\n public static double ReadDouble()\n {\n return double.Parse(ReadToken(), CultureInfo.InvariantCulture);\n }\n\n public static int[] ReadIntArray()\n {\n return ReadAndSplitLine().Select(int.Parse).ToArray();\n }\n\n public static long[] ReadLongArray()\n {\n return ReadAndSplitLine().Select(long.Parse).ToArray();\n }\n\n public static double[] ReadDoubleArray()\n {\n return ReadAndSplitLine().Select(s => double.Parse(s, CultureInfo.InvariantCulture)).ToArray();\n }\n\n public static int[][] ReadIntMatrix(int numberOfRows)\n {\n int[][] matrix = new int[numberOfRows][];\n for (int i = 0; i < numberOfRows; i++)\n matrix[i] = ReadIntArray();\n return matrix;\n }\n\n public static int[][] ReadAndTransposeIntMatrix(int numberOfRows)\n {\n int[][] matrix = ReadIntMatrix(numberOfRows);\n int[][] ret = new int[matrix[0].Length][];\n for (int i = 0; i < ret.Length; i++)\n {\n ret[i] = new int[numberOfRows];\n for (int j = 0; j < numberOfRows; j++)\n ret[i][j] = matrix[j][i];\n }\n return ret;\n }\n\n public static string[] ReadLines(int quantity)\n {\n string[] lines = new string[quantity];\n for (int i = 0; i < quantity; i++)\n lines[i] = reader.ReadLine().Trim();\n return lines;\n }\n\n public static void WriteArray(IEnumerable array)\n {\n writer.WriteLine(string.Join(\" \", array));\n }\n\n public static void Write(params object[] array)\n {\n WriteArray(array);\n }\n\n public static void WriteLines(IEnumerable array)\n {\n foreach (var a in array)\n writer.WriteLine(a);\n }\n\n class SDictionary : Dictionary\n {\n public new TValue this[TKey key]\n {\n get { return ContainsKey(key) ? base[key] : default(TValue); }\n set { base[key] = value; }\n }\n }\n\n #endregion\n}", "lang_cluster": "C#", "tags": ["greedy", "dp"], "code_uid": "04a0045a71d2a4659a3c138c825b348e", "src_uid": "65699ddec8d0db2f58b83a0f64de6f6f", "difficulty": 2200.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Data.Odbc;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace CF\n{\n\tclass _364B\n\t{\n\t\tprivate const int KMaxPrice = 10000;\n\n\t\tprivate static void Main(String[] args)\n\t\t{\n\t\t\tvar parts = Console.ReadLine().Split(' ');\n\t\t\tint n = int.Parse(parts[0]),\n\t\t\t\td = int.Parse(parts[1]);\n\t\t\tint[] a = new int[n];\n\t\t\tparts = Console.ReadLine().Split(' ');\n\t\t\tfor (int i = 0; i < n; i++)\n\t\t\t\ta[i] = int.Parse(parts[i]);\n\t\t\tint limit = KMaxPrice*n;\n\t\t\tint[,] map = new int[limit + 1, n + 1];\n\t\t\tmap[0, 0] = 1;\n\t\t\tfor (int i = 0; i < n; ++i)\n\t\t\t\tfor (int j = limit; j >= 0; --j)\n\t\t\t\t\tif (map[j, i] != 0)\n\t\t\t\t\t{\n\t\t\t\t\t\tmap[j + a[i], i + 1] = 1;\n\t\t\t\t\t\tmap[j, i + 1] = 1;\n\t\t\t\t\t}\n\t\t\tint ans = 0, days = 0;\n\t\t\twhile (ans < limit)\n\t\t\t{\n\t\t\t\tint eat = 0;\n\t\t\t\tfor (int j = 0; j <= d; ++j)\n\t\t\t\t\tif (ans + j <= limit\n\t\t\t\t\t\t&& map[ans + j, n] != 0)\n\t\t\t\t\t\teat = j;\n\t\t\t\tif (0 == eat)\n\t\t\t\t\tbreak;\n\t\t\t\t//Console.WriteLine(\"{0} {1}\", eat, days);\n\t\t\t\tans += eat;\n\t\t\t\t++days;\n\t\t\t}\n\t\t\tConsole.WriteLine(\"{0} {1}\", ans, days);\n\t\t}\n\t}\n}\n", "lang_cluster": "C#", "tags": ["greedy", "dp"], "code_uid": "c7ab8c88fb9fd193086934c05ddda337", "src_uid": "65699ddec8d0db2f58b83a0f64de6f6f", "difficulty": 2200.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\nusing System.Text.RegularExpressions;\nusing System.Text;\n\nnamespace TechnoCup2\n{\n class Program\n {\n static void Main(string[] args)\n {\n string[] layer1 = Console.ReadLine().Split(' ');\n string[] layer2 = Console.ReadLine().Split(' ');\n string[] layer3 = Console.ReadLine().Split(' ');\n Console.ReadLine();\n string[] layer4 = Console.ReadLine().Split(' ');\n string[] layer5 = Console.ReadLine().Split(' ');\n string[] layer6 = Console.ReadLine().Split(' ');\n Console.ReadLine();\n string[] layer7 = Console.ReadLine().Split(' ');\n string[] layer8 = Console.ReadLine().Split(' ');\n string[] layer9 = Console.ReadLine().Split(' ');\n string[] coordinates = Console.ReadLine().Split(' ');\n BigField bigField = new BigField();\n bigField.fields[0, 0] = new Field(layer1[0], layer2[0], layer3[0]);\n bigField.fields[1, 0] = new Field(layer1[1], layer2[1], layer3[1]);\n bigField.fields[2, 0] = new Field(layer1[2], layer2[2], layer3[2]);\n\n bigField.fields[0, 1] = new Field(layer4[0], layer5[0], layer6[0]);\n bigField.fields[1, 1] = new Field(layer4[1], layer5[1], layer6[1]);\n bigField.fields[2, 1] = new Field(layer4[2], layer5[2], layer6[2]);\n\n bigField.fields[0, 2] = new Field(layer7[0], layer8[0], layer9[0]);\n bigField.fields[1, 2] = new Field(layer7[1], layer8[1], layer9[1]);\n bigField.fields[2, 2] = new Field(layer7[2], layer8[2], layer9[2]);\n\n int[] coordinatesNumeric = new int[] { Convert.ToInt32(coordinates[1]), Convert.ToInt32(coordinates[0]) };\n int[] coordinatesInternal = new int[] { coordinatesNumeric[0] % 3, coordinatesNumeric[1] % 3 };\n if (coordinatesInternal[0] == 0)\n coordinatesInternal[0] = 3;\n if (coordinatesInternal[1] == 0)\n coordinatesInternal[1] = 3;\n\n //int[] coordinatesExternal = new int[] { (coordinatesNumeric[0] - coordinatesInternal[0]) / 3, (coordinatesNumeric[1] - coordinatesInternal[1]) / 3 };\n\n if (bigField.fields[coordinatesInternal[0] - 1, coordinatesInternal[1] - 1].isFullBusy)\n {\n bigField.SetFullEmpty();\n }\n else\n {\n bigField.fields[coordinatesInternal[0] - 1, coordinatesInternal[1] - 1].SetEmpty();\n }\n for(int i = 0; i < 9; i++)\n {\n if (i % 3 == 0 && i != 0)\n Console.WriteLine();\n Console.WriteLine(bigField.printLayer(i));\n }\n //Console.ReadKey();\n }\n }\n class Field\n {\n public int[,] busy;\n public Field(string layer1, string layer2, string layer3)\n {\n fill(layer1, layer2, layer3);\n }\n public void fill(string layer1, string layer2, string layer3)\n {\n busy = new int[3, 3];\n for (int i = 0; i < 3; i++)\n {\n if (layer1[i] == 'o')\n busy[i, 0] = 1;\n if (layer2[i] == 'o')\n busy[i, 1] = 1;\n if (layer3[i] == 'o')\n busy[i, 2] = 1;\n \n if (layer1[i] == 'x')\n busy[i, 0] = 2;\n if (layer2[i] == 'x')\n busy[i, 1] = 2;\n if (layer3[i] == 'x')\n busy[i, 2] = 2;\n }\n }\n public bool isFullBusy { get\n {\n for (int i = 0; i < 3; i++)\n {\n for (int j = 0; j < 3; j++)\n if (busy[i, j] == 0)\n return false;\n }\n return true;\n }\n }\n public void SetEmpty()\n {\n for (int i = 0; i < 3; i++)\n {\n for (int j = 0; j < 3; j++)\n if (busy[i, j] == 0)\n busy[i, j] = 3;\n }\n }\n public string printLayer(int layerNum)\n {\n StringBuilder sb = new StringBuilder();\n for(int i = 0; i < 3; i++)\n {\n switch(busy[i, layerNum])\n {\n case 1:\n sb.Append(\"o\");\n break;\n case 2:\n sb.Append(\"x\");\n break;\n case 3:\n sb.Append(\"!\");\n break;\n default:\n sb.Append(\".\");\n break;\n }\n }\n return sb.ToString();\n }\n \n }\n class BigField\n {\n public Field[,] fields;\n public BigField()\n {\n fields = new Field[3, 3];\n }\n public void SetFullEmpty()\n {\n for (int i = 0; i < 3; i++)\n {\n for (int j = 0; j < 3; j++)\n fields[i, j].SetEmpty();\n }\n }\n public string printLayer(int layerNum)\n {\n int internalLayer = layerNum % 3;\n /*if (internalLayer == 0 && layerNum != 0)\n internalLayer = 3;*/\n layerNum = (layerNum - internalLayer) / 3;\n StringBuilder sb = new StringBuilder(0);\n for(int i = 0; i < 3; i++)\n {\n sb.Append(fields[i, layerNum].printLayer(internalLayer));\n if (i != 2)\n sb.Append(\" \");\n }\n return sb.ToString();\n }\n }\n}\n/*class Program\n{\n static void Main(string[] args)\n {\n string length = Console.ReadLine();\n string input = Console.ReadLine();\n int changing = 0;\n StringBuilder sb = new StringBuilder();\n for (int i = 0; i <= input.Length - 2; i += 2)\n {\n if (input[i] == input[i + 1])\n {\n if (input[i] == 'a') { sb.Append(input[i] + \"b\"); }\n else { sb.Append(input[i] + \"a\"); }\n changing++;\n }\n else\n sb.Append(input[i] + \"\" + input[i + 1]);\n }\n Console.WriteLine(changing);\n Console.WriteLine(sb.ToString());\n Console.ReadKey();\n }\n}*/\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "28dfae77fe722ca4abe33dc2bdfc0b84", "src_uid": "8f0fad22f629332868c39969492264d3", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Globalization;\nusing System.IO;\nusing System.Linq;\nusing System.Text;\nusing System.Text.RegularExpressions;\nusing System.Threading;\nusing static System.Math;\n\nnamespace Olymp\n{\n public class ProblemSolver\n {\n private Tokenizer input;\n\n public void Solve()\n {\n var f = new char[9][];\n ReadField(f);\n var x = input.ReadInt() - 1;\n var y = input.ReadInt() - 1;\n var fx = x % 3;\n var fy = y % 3;\n if (!TryFillField(f, fx, fy))\n FillAll(f);\n PrintField(f);\n }\n\n private void ReadField(char[][] f)\n {\n for (int i = 0; i < 9; i++)\n {\n if (i != 0 && i % 3 == 0)\n input.ReadLine();\n f[i] = string.Join(\"\", input.ReadLine().Split()).ToCharArray();\n }\n }\n\n private void PrintField(char[][] f)\n {\n var sb = new StringBuilder();\n for (int i = 0; i < 9; i++)\n {\n if (i != 0 && i % 3 == 0)\n sb.AppendLine();\n for (int j = 0; j < 9; j++)\n {\n if (j != 0 && j % 3 == 0)\n sb.Append(' ');\n sb.Append(f[i][j]);\n }\n sb.AppendLine();\n }\n Console.Write(sb);\n }\n\n private void FillAll(char[][] f)\n {\n for (int i = 0; i < 9; i++)\n for (int j = 0; j < 9; j++)\n if (f[i][j] == '.')\n f[i][j] = '!';\n }\n\n private bool TryFillField(char[][] f, int fx, int fy)\n {\n bool result = false;\n for (int i = 0; i < 3; i++)\n {\n for (int j = 0; j < 3; j++)\n {\n int lx = fx * 3 + i;\n int ly = fy * 3 + j;\n if (f[lx][ly] == '.')\n {\n f[lx][ly] = '!';\n result = true;\n }\n }\n }\n return result;\n }\n\n public ProblemSolver(TextReader input)\n {\n this.input = new Tokenizer(input);\n }\n\n #region Service functions\n\n private const string ABC = \"abcdefghijklmnopqrstuvwxyz\";\n\n private static void AddCount(Dictionary counter, T item)\n {\n int count;\n if (counter.TryGetValue(item, out count))\n counter[item] = count + 1;\n else\n counter.Add(item, 1);\n }\n\n private static int GetCount(Dictionary counter, T item)\n {\n int count;\n return counter.TryGetValue(item, out count) ? count : 0;\n }\n\n private static int GCD(int a, int b)\n {\n while (b != 0)\n {\n a %= b;\n int t = b;\n b = a;\n a = t;\n }\n return a;\n }\n\n #endregion\n }\n\n #region Service classes\n\n public class Tokenizer\n {\n private TextReader reader;\n\n public string ReadToEnd()\n {\n return this.reader.ReadToEnd();\n }\n\n public int ReadInt()\n {\n var c = SkipWS();\n if (c == -1)\n throw new EndOfStreamException();\n bool isNegative = false;\n if (c == '-' || c == '+')\n {\n isNegative = c == '-';\n c = this.reader.Read();\n if (c == -1)\n throw new InvalidOperationException();\n }\n if (!char.IsDigit((char)c))\n throw new InvalidOperationException();\n int result = (char)c - '0';\n c = this.reader.Read();\n while (c > 0 && !char.IsWhiteSpace((char)c))\n {\n if (!char.IsDigit((char)c))\n throw new InvalidOperationException();\n result = result * 10 + (char)c - '0';\n c = this.reader.Read();\n }\n if (isNegative)\n result = -result;\n return result;\n }\n\n public string ReadLine()\n {\n return reader.ReadLine();\n }\n\n public long ReadLong()\n {\n return long.Parse(this.ReadToken());\n }\n\n public double ReadDouble()\n {\n return double.Parse(this.ReadToken(), CultureInfo.InvariantCulture);\n }\n\n public int[] ReadIntArray(int n)\n {\n int[] a = new int[n];\n for (int i = 0; i < n; i++)\n a[i] = ReadInt();\n return a;\n }\n\n public long[] ReadLongArray(int n)\n {\n long[] a = new long[n];\n for (int i = 0; i < n; i++)\n a[i] = ReadLong();\n return a;\n }\n\n public double[] ReadDoubleArray(int n)\n {\n double[] a = new double[n];\n for (int i = 0; i < n; i++)\n a[i] = ReadDouble();\n return a;\n }\n\n public string ReadToken()\n {\n var c = SkipWS();\n if (c == -1)\n return null;\n var sb = new StringBuilder();\n while (c > 0 && !char.IsWhiteSpace((char)c))\n {\n sb.Append((char)c);\n c = this.reader.Read();\n }\n return sb.ToString();\n }\n\n private int SkipWS()\n {\n int c = this.reader.Read();\n if (c == -1)\n return c;\n while (c > 0 && char.IsWhiteSpace((char)c))\n c = this.reader.Read();\n return c;\n }\n\n public Tokenizer(TextReader reader)\n {\n this.reader = reader;\n }\n }\n\n class Program\n {\n public static void Main(string[] args)\n {\n var solver = new ProblemSolver(Console.In);\n solver.Solve();\n }\n }\n\n #endregion\n}", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "aa246ab81dcd1be3b27d6d05867bab6a", "src_uid": "8f0fad22f629332868c39969492264d3", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Text;\n\nnamespace codeforces\n{\n class C\n {\n static CodeforcesUtils CF = new CodeforcesUtils(\n@\"\n0 0 0 1\n0 0 0 1\n1 0 1 1\n1 0 1 1\n\");\n\n static void Main(string[] args)\n {\n bool b = true;\n Dictionary c = new Dictionary();\n List xs = new List();\n List ys = new List();\n int hc=0;\n for (int i = 0;i<4;i++)\n {\n string[] ss = CF.ReadLine().Split(' ');\n int x1 = int.Parse(ss[0]);\n int y1 = int.Parse(ss[1]);\n int x2 = int.Parse(ss[2]);\n int y2 = int.Parse(ss[3]);\n\n if (!_l(x1, y1, x2, y2))\n {\n b = false;\n break;\n }\n\n if (x1 != x2)\n hc++;\n\n\n string p1 = x1 +\",\"+ y1;\n if (!c.ContainsKey(p1))\n c.Add(p1, 0);\n c[p1]++;\n\n string p2 = x2 + \",\" + y2;\n if (!c.ContainsKey(p2))\n c.Add(p2, 0);\n c[p2]++;\n\n if( !xs.Contains(x1) )\n xs.Add(x1);\n if (!xs.Contains(x2))\n xs.Add(x2);\n if (!ys.Contains(y1))\n ys.Add(y1);\n if (!ys.Contains(y2))\n ys.Add(y2);\n }\n\n if (b)\n {\n if (hc != 2)\n b = false;\n else if (xs.Count != 2 || ys.Count != 2)\n b = false;\n else if (c.Count != 4)\n b = false;\n else\n {\n foreach (int v in c.Values)\n {\n if (v != 2)\n {\n b=false;\n break;\n }\n }\n }\n }\n\n if (b)\n CF.WriteLine(\"YES\");\n else\n CF.WriteLine(\"NO\");\n\n\n }\n\n static bool _l(int x1,int y1,int x2,int y2)\n {\n if( x1!=x2&&y1!=y2)\n return false;\n if (x1 == x2 && y1 == y2)\n return false;\n return true;\n }\n\n #region test\n\n class CodeforcesUtils\n {\n public string ReadLine()\n {\n#if DEBUG\n if (_lines == null)\n {\n _lines = new List();\n string[] ss = _test_input.Replace(\"\\n\", \"\").Split('\\r');\n for (int i = 0; i < ss.Length; i++)\n {\n if (\n (i == 0 || i == ss.Length - 1) &&\n ss[i].Length == 0\n )\n continue;\n\n _lines.Add(ss[i]);\n }\n }\n\n string s = null;\n if (_lines.Count > 0)\n {\n s = _lines[0];\n _lines.RemoveAt(0);\n }\n return s;\n#else\n return Console.In.ReadLine();\n#endif\n }\n\n public void WriteLine(object o)\n {\n#if DEBUG\n System.Diagnostics.Trace.WriteLine(o);\n#else\n Console.WriteLine(o);\n#endif\n }\n\n public void Write(object o)\n {\n#if DEBUG\n System.Diagnostics.Trace.Write(o);\n#else\n Console.Write(o);\n#endif\n }\n\n public CodeforcesUtils(string test_input)\n {\n _test_input = test_input;\n }\n\n string _test_input;\n\n List _lines;\n }\n\n #endregion\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "constructive algorithms", "math", "implementation", "geometry"], "code_uid": "e250773e72bc1e61d9161e618bd0219a", "src_uid": "ad105c08f63e9761fe90f69630628027", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Globalization;\nusing System.IO;\nusing System.Linq;\nusing System.Text;\nusing System.Threading;\n\n// (\u3065\u00b0\u03c9\u00b0)\u3065\uff90e\u2605\u309c\u30fb\u3002\u3002\u30fb\u309c\u309c\u30fb\u3002\u3002\u30fb\u309c\u2606\u309c\u30fb\u3002\u3002\u30fb\u309c\u309c\u30fb\u3002\u3002\u30fb\u309c\npublic class Solver\n{\n bool NextPerm(int[] a)\n {\n int n = a.Length;\n for (int k = n - 2; k >= 0; k--)\n if (a[k] < a[k + 1])\n for (int l = n - 1; l >= 0; l--)\n if (a[k] < a[l])\n {\n Swap(ref a[k], ref a[l]);\n for (int i = k + 1, j = n - 1; i < j; i++, j--)\n Swap(ref a[i], ref a[j]);\n return true;\n }\n return false;\n }\n\n void Swap(ref T a, ref T b)\n {\n T t = a;\n a = b;\n b = t;\n }\n\n public void Solve()\n {\n var a = ReadIntMatrix(4);\n\n var p = Enumerable.Range(0, 4).ToArray();\n do\n {\n if (a[p[0]][1] != a[p[0]][3] || a[p[1]][0] != a[p[1]][2] || a[p[2]][1] != a[p[2]][3] || a[p[3]][0] != a[p[3]][2])\n continue;\n int x1 = Math.Min(a[p[0]][0], a[p[0]][2]);\n int x2 = Math.Max(a[p[0]][0], a[p[0]][2]);\n int y1 = Math.Min(a[p[1]][1], a[p[1]][3]);\n int y2 = Math.Max(a[p[1]][1], a[p[1]][3]);\n if (x1 == x2 || y1 == y2 || a[p[0]][1] != y1 || a[p[1]][0] != x2 || Math.Min(a[p[2]][0], a[p[2]][2]) != x1 || Math.Max(a[p[2]][0], a[p[2]][2]) != x2 ||\n a[p[2]][1] != y2 || Math.Min(a[p[3]][1], a[p[3]][3]) != y1 || Math.Max(a[p[3]][1], a[p[3]][3]) != y2 || a[p[3]][0] != x1)\n continue;\n Write(\"YES\");\n return;\n } while (NextPerm(p));\n Write(\"NO\");\n }\n\n #region Main\n\n protected static TextReader reader;\n protected static TextWriter writer;\n static void Main()\n {\n#if DEBUG\n reader = new StreamReader(\"..\\\\..\\\\input.txt\");\n //reader = new StreamReader(Console.OpenStandardInput());\n writer = Console.Out;\n //writer = new StreamWriter(\"..\\\\..\\\\output.txt\");\n#else\n reader = new StreamReader(Console.OpenStandardInput());\n writer = new StreamWriter(Console.OpenStandardOutput());\n //reader = new StreamReader(\"input.txt\");\n //writer = new StreamWriter(\"output.txt\");\n#endif\n try\n {\n new Solver().Solve();\n //var thread = new Thread(new Solver().Solve, 1024 * 1024 * 128);\n //thread.Start();\n //thread.Join();\n }\n catch (Exception ex)\n {\n Console.WriteLine(ex);\n#if DEBUG\n#else\n throw;\n#endif\n }\n reader.Close();\n writer.Close();\n }\n\n #endregion\n\n #region Read / Write\n private static Queue currentLineTokens = new Queue();\n private static string[] ReadAndSplitLine() { return reader.ReadLine().Split(new[] { ' ', '\\t', }, StringSplitOptions.RemoveEmptyEntries); }\n public static string ReadToken() { while (currentLineTokens.Count == 0)currentLineTokens = new Queue(ReadAndSplitLine()); return currentLineTokens.Dequeue(); }\n public static int ReadInt() { return int.Parse(ReadToken()); }\n public static long ReadLong() { return long.Parse(ReadToken()); }\n public static double ReadDouble() { return double.Parse(ReadToken(), CultureInfo.InvariantCulture); }\n public static int[] ReadIntArray() { return ReadAndSplitLine().Select(int.Parse).ToArray(); }\n public static long[] ReadLongArray() { return ReadAndSplitLine().Select(long.Parse).ToArray(); }\n public static double[] ReadDoubleArray() { return ReadAndSplitLine().Select(s => double.Parse(s, CultureInfo.InvariantCulture)).ToArray(); }\n public static int[][] ReadIntMatrix(int numberOfRows) { int[][] matrix = new int[numberOfRows][]; for (int i = 0; i < numberOfRows; i++)matrix[i] = ReadIntArray(); return matrix; }\n public static int[][] ReadAndTransposeIntMatrix(int numberOfRows)\n {\n int[][] matrix = ReadIntMatrix(numberOfRows); int[][] ret = new int[matrix[0].Length][];\n for (int i = 0; i < ret.Length; i++) { ret[i] = new int[numberOfRows]; for (int j = 0; j < numberOfRows; j++)ret[i][j] = matrix[j][i]; } return ret;\n }\n public static string[] ReadLines(int quantity) { string[] lines = new string[quantity]; for (int i = 0; i < quantity; i++)lines[i] = reader.ReadLine().Trim(); return lines; }\n public static void WriteArray(IEnumerable array) { writer.WriteLine(string.Join(\" \", array)); }\n public static void Write(params object[] array) { WriteArray(array); }\n public static void WriteLines(IEnumerable array) { foreach (var a in array)writer.WriteLine(a); }\n private class SDictionary : Dictionary\n {\n public new TValue this[TKey key]\n {\n get { return ContainsKey(key) ? base[key] : default(TValue); }\n set { base[key] = value; }\n }\n }\n private static T[] Init(int size) where T : new() { var ret = new T[size]; for (int i = 0; i < size; i++)ret[i] = new T(); return ret; }\n #endregion\n}", "lang_cluster": "C#", "tags": ["brute force", "constructive algorithms", "math", "implementation", "geometry"], "code_uid": "195e0556506ec0de43fb5ca7fff5b8bf", "src_uid": "ad105c08f63e9761fe90f69630628027", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Diagnostics;\nusing System.Globalization;\nusing System.IO;\nusing System.Linq;\nusing System.Threading;\n\nnamespace ReadWriteTemplate\n{\n public static class Solver\n {\n private static void SolveCase()\n {\n const long MOD = 998244353;\n\n int n = ReadInt();\n int k = ReadInt();\n long l = ReadInt();\n\n int N = 2 * n + 2;\n long[][,] a = new long[2][,];\n a[0] = new long[N, 2];\n a[0][0, 0] = 1;\n\n for (int i = 0; i < 2 * n + 1; i++)\n {\n int t = i % 2;\n a[1 - t] = new long[N, 2];\n for (int j = 0; j <= i; j++)\n {\n for (int e = 0; e < 2; e++)\n {\n if (e == 0 && j >= k)\n {\n a[1 - t][j, 1] += a[t][j, e];\n Fix(ref a[1 - t][j, 1], MOD);\n }\n if (j > 0)\n {\n a[1 - t][j - 1, e] = (a[1 - t][j - 1, e] + j * a[t][j, e]) % MOD;\n }\n if (i + j - e <= 2 * n - 2)\n {\n a[1 - t][j + 1, e] += a[t][j, e];\n Fix(ref a[1 - t][j + 1, e], MOD);\n }\n }\n }\n }\n\n long ans = a[1][0, 1];\n ans = ans * BinPower(2, n, MOD) % MOD;\n ans = ans * l % MOD;\n\n long f = 1;\n for (int i = 1; i <= n; i++)\n {\n f = f * i % MOD;\n }\n ans = ans * f % MOD;\n for (int i = n + 1; i <= 2 * n + 1; i++)\n {\n f = f * i % MOD;\n }\n ans = ans * Inv(f, MOD) % MOD;\n\n Writer.WriteLine(ans);\n }\n\n public static void Fix(ref long x, long mod)\n {\n if (x >= mod)\n {\n x -= mod;\n }\n }\n\n public static long Inv(long a, long mod)\n {\n return BinPower(a, mod - 2, mod);\n }\n\n public static long BinPower(long a, long n, long mod)\n {\n long result = 1;\n\n while (n > 0)\n {\n if ((n & 1) != 0)\n {\n result = (result * a) % mod;\n }\n\n a = (a * a) % mod;\n n >>= 1;\n }\n\n return result;\n }\n\n public static void Solve()\n {\n#if DEBUG\n var sw = Stopwatch.StartNew();\n#endif\n\n SolveCase();\n\n /*int T = ReadInt();\n for (int i = 0; i < T; i++)\n {\n Writer.Write(\"Case #{0}: \", 1 - t);\n SolveCase();\n }*/\n\n#if DEBUG\n sw.Stop();\n Console.WriteLine($\"{sw.ElapsedMilliseconds} ms\");\n#endif\n }\n\n public static void Main()\n {\n Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;\n\n#if DEBUG\n // Reader = Console.In; Writer = Console.Out;\n Reader = File.OpenText(\"input.txt\"); Writer = File.CreateText(\"output.txt\");\n#else\n Reader = Console.In; Writer = Console.Out;\n#endif\n\n // Solve();\n Thread thread = new Thread(Solve);\n thread.CurrentCulture = CultureInfo.InvariantCulture;\n thread.Start();\n thread.Join();\n\n Reader.Close();\n Writer.Close();\n }\n\n public static IOrderedEnumerable OrderByWithShuffle(this IEnumerable source, Func keySelector)\n {\n return source.Shuffle().OrderBy(keySelector);\n }\n\n public static T[] Shuffle(this IEnumerable source)\n {\n T[] result = source.ToArray();\n Shuffle(result);\n return result;\n }\n\n private static void Shuffle(IList array)\n {\n Random rnd = new Random();\n for (int i = array.Count - 1; i >= 1; i--)\n {\n int k = rnd.Next(i + 1);\n T tmp = array[k];\n array[k] = array[i];\n array[i] = tmp;\n }\n }\n\n #region Read/Write\n\n private static TextReader Reader;\n\n private static TextWriter Writer;\n\n private static Queue CurrentLineTokens = new Queue();\n\n private static string[] ReadAndSplitLine()\n {\n return Reader.ReadLine().Split(new[] { ' ', '\\t' }, StringSplitOptions.RemoveEmptyEntries);\n }\n\n public static string ReadToken()\n {\n while (CurrentLineTokens.Count == 0)\n CurrentLineTokens = new Queue(ReadAndSplitLine());\n return CurrentLineTokens.Dequeue();\n }\n\n public static string ReadLine()\n {\n return Reader.ReadLine();\n }\n\n public static int ReadInt()\n {\n return int.Parse(ReadToken());\n }\n\n public static long ReadLong()\n {\n return long.Parse(ReadToken());\n }\n\n public static double ReadDouble()\n {\n return double.Parse(ReadToken(), CultureInfo.InvariantCulture);\n }\n\n public static int[] ReadIntArray()\n {\n return ReadAndSplitLine().Select(int.Parse).ToArray();\n }\n\n public static long[] ReadLongArray()\n {\n return ReadAndSplitLine().Select(long.Parse).ToArray();\n }\n\n public static double[] ReadDoubleArray()\n {\n return ReadAndSplitLine().Select(s => double.Parse(s, CultureInfo.InvariantCulture)).ToArray();\n }\n\n public static int[][] ReadIntMatrix(int numberOfRows)\n {\n int[][] matrix = new int[numberOfRows][];\n for (int i = 0; i < numberOfRows; i++)\n matrix[i] = ReadIntArray();\n return matrix;\n }\n\n public static string[] ReadLines(int quantity)\n {\n string[] lines = new string[quantity];\n for (int i = 0; i < quantity; i++)\n lines[i] = Reader.ReadLine().Trim();\n return lines;\n }\n\n public static void WriteArray(IEnumerable array)\n {\n Writer.WriteLine(string.Join(\" \", array));\n }\n\n #endregion\n }\n}\n", "lang_cluster": "C#", "tags": ["probabilities", "math", "dp", "combinatorics"], "code_uid": "eb1a8c3d3778e9f44186b95966f64180", "src_uid": "c9e79e83928d5d034123ebc3b2f5e064", "difficulty": 2600.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Diagnostics;\nusing System.Globalization;\nusing System.IO;\nusing System.Linq;\nusing System.Threading;\n\nnamespace ReadWriteTemplate\n{\n public static class Solver\n {\n private static void SolveCase()\n {\n const long MOD = 998244353;\n\n int n = ReadInt();\n int k = ReadInt();\n long l = ReadInt();\n\n int N = 2 * n + 2;\n long[][,] a = new long[2][,];\n long[][,] b = new long[2][,];\n a[0] = new long[N, 2];\n b[0] = new long[N, 2];\n a[0][0, 0] = 1;\n b[0][0, 0] = 1;\n\n for (int i = 0; i < 2 * n + 1; i++)\n {\n int t = i % 2;\n a[1 - t] = new long[N, 2];\n b[1 - t] = new long[N, 2];\n for (int j = 0; j <= i; j++)\n {\n for (int e = 0; e < 2; e++)\n {\n if (e == 0)\n {\n if (j >= k)\n {\n a[1 - t][j, 1] += a[t][j, e];\n Fix(ref a[1 - t][j, 1], MOD);\n }\n b[1 - t][j, 1] += b[t][j, e];\n Fix(ref b[1 - t][j, 1], MOD);\n }\n if (j > 0)\n {\n a[1 - t][j - 1, e] = (a[1 - t][j - 1, e] + j * a[t][j, e]) % MOD;\n b[1 - t][j - 1, e] = (b[1 - t][j - 1, e] + j * b[t][j, e]) % MOD;\n }\n if (i + j - e <= 2 * n - 2)\n {\n a[1 - t][j + 1, e] += a[t][j, e];\n Fix(ref a[1 - t][j + 1, e], MOD);\n b[1 - t][j + 1, e] += b[t][j, e];\n Fix(ref b[1 - t][j + 1, e], MOD);\n }\n }\n }\n }\n\n long ans = a[1][0, 1] * Inv(b[1][0, 1], MOD) % MOD;\n ans = ans * l % MOD;\n\n Writer.WriteLine(ans);\n }\n\n public static void Fix(ref long x, long mod)\n {\n if (x >= mod)\n {\n x -= mod;\n }\n }\n\n public static long Inv(long a, long mod)\n {\n return BinPower(a, mod - 2, mod);\n }\n\n public static long BinPower(long a, long n, long mod)\n {\n long result = 1;\n\n while (n > 0)\n {\n if ((n & 1) != 0)\n {\n result = (result * a) % mod;\n }\n\n a = (a * a) % mod;\n n >>= 1;\n }\n\n return result;\n }\n\n public static void Solve()\n {\n#if DEBUG\n var sw = Stopwatch.StartNew();\n#endif\n\n SolveCase();\n\n /*int T = ReadInt();\n for (int i = 0; i < T; i++)\n {\n Writer.Write(\"Case #{0}: \", 1 - t);\n SolveCase();\n }*/\n\n#if DEBUG\n sw.Stop();\n Console.WriteLine($\"{sw.ElapsedMilliseconds} ms\");\n#endif\n }\n\n public static void Main()\n {\n Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;\n\n#if DEBUG\n // Reader = Console.In; Writer = Console.Out;\n Reader = File.OpenText(\"input.txt\"); Writer = File.CreateText(\"output.txt\");\n#else\n Reader = Console.In; Writer = Console.Out;\n#endif\n\n // Solve();\n Thread thread = new Thread(Solve, 64 * 1024 * 1024);\n thread.CurrentCulture = CultureInfo.InvariantCulture;\n thread.Start();\n thread.Join();\n\n Reader.Close();\n Writer.Close();\n }\n\n public static IOrderedEnumerable OrderByWithShuffle(this IEnumerable source, Func keySelector)\n {\n return source.Shuffle().OrderBy(keySelector);\n }\n\n public static T[] Shuffle(this IEnumerable source)\n {\n T[] result = source.ToArray();\n Shuffle(result);\n return result;\n }\n\n private static void Shuffle(IList array)\n {\n Random rnd = new Random();\n for (int i = array.Count - 1; i >= 1; i--)\n {\n int k = rnd.Next(i + 1);\n T tmp = array[k];\n array[k] = array[i];\n array[i] = tmp;\n }\n }\n\n #region Read/Write\n\n private static TextReader Reader;\n\n private static TextWriter Writer;\n\n private static Queue CurrentLineTokens = new Queue();\n\n private static string[] ReadAndSplitLine()\n {\n return Reader.ReadLine().Split(new[] { ' ', '\\t' }, StringSplitOptions.RemoveEmptyEntries);\n }\n\n public static string ReadToken()\n {\n while (CurrentLineTokens.Count == 0)\n CurrentLineTokens = new Queue(ReadAndSplitLine());\n return CurrentLineTokens.Dequeue();\n }\n\n public static string ReadLine()\n {\n return Reader.ReadLine();\n }\n\n public static int ReadInt()\n {\n return int.Parse(ReadToken());\n }\n\n public static long ReadLong()\n {\n return long.Parse(ReadToken());\n }\n\n public static double ReadDouble()\n {\n return double.Parse(ReadToken(), CultureInfo.InvariantCulture);\n }\n\n public static int[] ReadIntArray()\n {\n return ReadAndSplitLine().Select(int.Parse).ToArray();\n }\n\n public static long[] ReadLongArray()\n {\n return ReadAndSplitLine().Select(long.Parse).ToArray();\n }\n\n public static double[] ReadDoubleArray()\n {\n return ReadAndSplitLine().Select(s => double.Parse(s, CultureInfo.InvariantCulture)).ToArray();\n }\n\n public static int[][] ReadIntMatrix(int numberOfRows)\n {\n int[][] matrix = new int[numberOfRows][];\n for (int i = 0; i < numberOfRows; i++)\n matrix[i] = ReadIntArray();\n return matrix;\n }\n\n public static string[] ReadLines(int quantity)\n {\n string[] lines = new string[quantity];\n for (int i = 0; i < quantity; i++)\n lines[i] = Reader.ReadLine().Trim();\n return lines;\n }\n\n public static void WriteArray(IEnumerable array)\n {\n Writer.WriteLine(string.Join(\" \", array));\n }\n\n #endregion\n }\n}\n", "lang_cluster": "C#", "tags": ["probabilities", "math", "dp", "combinatorics"], "code_uid": "2885e329d65d504572bc922cf755260a", "src_uid": "c9e79e83928d5d034123ebc3b2f5e064", "difficulty": 2600.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Text.RegularExpressions;\n\nnamespace WarmingUpC_Sharp\n{\n class Program\n {\n static void Main(string[] args)\n {\n string[] numbers = Console.ReadLine().Split(' ');\n double c = double.Parse(numbers[4]), a = double.Parse(numbers[0]), b = double.Parse(numbers[1]), w = double.Parse(numbers[2]), x = double.Parse(numbers[3]);\n double Result = Math.Ceiling((-b + (c - a) * x + 0.0) / (w - x)) + c - a;\n Console.WriteLine(Math.Max(0, Result)); \n }\n }\n}", "lang_cluster": "C#", "tags": ["math", "binary search"], "code_uid": "6df2a3e9d5204f3cc3876841836798e0", "src_uid": "a1db3dd9f8d0f0cad7bdeb1780707143", "difficulty": 2000.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "#define Online\nusing System;\nusing System.Collections.Generic;\nusing System.Diagnostics;\nusing System.Text;\nusing System.IO;\n\ndelegate double F (double x);\n\ndelegate decimal Fdec (decimal x);\n\npartial class Program\n{\n\tpublic static StreamReader sr;\n\tpublic static StreamWriter sw;\n\n\tstatic void Main (string[] args)\n\t{\n\n#if FileIO\n\t\tsr = new StreamReader (\"input.in\");\n\t\tsw = new StreamWriter (\"input.out\");\n\t\tConsole.SetIn (sr);\n\t\tConsole.SetOut (sw);\n#endif\n\n\t\tB ();\n\n#if Online\n\t\tConsole.ReadLine ();\n#endif\n\n#if FileIO\n\t\tsr.Close ();\n\t\tsw.Close ();\n#endif\n\n\t}\n\n\tstatic void A ()\n\t{\n\t}\n\n\tstatic void B ()\n\t{\n\t\tint a, b, w, x, c;\n\t\ta = NextInt ();\n\t\tb = NextInt ();\n\t\tw = NextInt ();\n\t\tx = NextInt ();\n\t\tc = NextInt ();\n\t\tlong time = long.MaxValue;\n\t\tlong[] t = new long[1001];\n\t\tlong[] d = new long[1001];\n\t\tint[] last = new int[1001];\n\t\tlong[] th = new long[1001];\n\t\tlong[] th_t = new long[1001];\n\t\tint[] last_th = new int[1001];\n\t\tfor (int i=0; i=x) {\n\t\t\t\t_b -= x;\n\t\t\t\t++j;\n\t\t\t}\n\t\t\twhile (_b_a-th[_b]) {\n\t\t\t\t_a -= th [_b];\n\t\t\t\t_c -= th_t [_b];\n\t\t\t\ttime -= th_t [_b];\n\t\t\t\t_b = last_th [_b];\n\t\t\t}\n\t\t\twhile (_c-t[_b]>_a-d[_b]) {\n\t\t\t\ttime -= t [_b];\n\t\t\t\t_c -= t [_b];\n\t\t\t\t_a -= d [_b];\n\t\t\t\t_b = last [_b];\n\t\t\t}\n\t\t\twhile (_b>=x && _c>_a) {\n\t\t\t\t--_c;\n\t\t\t\t--time;\n\t\t\t\t_b -= x;\n\t\t\t}\n\t\t\twhile (_b_a) {\n\t\t\t\t--_a;\n\t\t\t\t--_c;\n\t\t\t\t_b = w - (x - _b);\n\t\t\t\t--time;\n\t\t\t}\n\t\t\tif (time >= 0) {\n\t\t\t\tright = mid;\n\t\t\t} else {\n\t\t\t\tleft = mid + 1;\n\t\t\t}\n\t\t}\n\t\tConsole.WriteLine (right);\n\t}\n\n\tstatic void C ()\n\t{\n\n\t}\n\t\n\tstatic void D ()\n\t{\n\n\t}\n\n\tstatic void E ()\n\t{\n\n\t}\n\n\tstatic void TestGen ()\n\t{\n\n\t}\n\n}\n\npublic static class MyMath\n{\n\tpublic static long BinPow (long a, long n, long mod)\n\t{\n\t\tlong res = 1;\n\t\twhile (n > 0) {\n\t\t\tif ((n & 1) == 1) {\n\t\t\t\tres = (res * a) % mod;\n\t\t\t}\n\t\t\ta = (a * a) % mod;\n\t\t\tn >>= 1;\n\t\t}\n\t\treturn res;\n\t}\n\n\tpublic static long GCD (long a, long b)\n\t{\n\t\twhile (b != 0)\n\t\t\tb = a % (a = b);\n\t\treturn a;\n\t}\n\n\tpublic static int GCD (int a, int b)\n\t{\n\t\twhile (b != 0)\n\t\t\tb = a % (a = b);\n\t\treturn a;\n\t}\n\n\tpublic static long LCM (long a, long b)\n\t{\n\t\treturn (a * b) / GCD (a, b);\n\t}\n\n\tpublic static int LCM (int a, int b)\n\t{\n\t\treturn (a * b) / GCD (a, b);\n\t}\n}\n\nstatic class ArrayUtils\n{\n\tstatic void Swap (T[] a, int l, int r)\n\t{\n\t\tT t = a [l];\n\t\ta [l] = a [r];\n\t\ta [r] = t;\n\t}\n\n\tpublic static bool NextPermutation (int[] a)\n\t{\n\t\tbool isOkay = false;\n\t\tint n = a.Length;\n\t\tfor (int i=n-2; i>=0; i--) {\n\t\t\tif (a [i] < a [i + 1]) {\n\t\t\t\tisOkay = true;\n\t\t\t\tint j = i + 1;\n\t\t\t\twhile (j+1a[i]) {\n\t\t\t\t\tj++;\n\t\t\t\t}\n\t\t\t\tSwap (a, i, j);\n\t\t\t\tfor (j=1; i+j> 1);\n\t\t\tif (val <= a [mid]) {\n\t\t\t\tright = mid;\n\t\t\t} else {\n\t\t\t\tleft = mid + 1;\n\t\t\t}\n\t\t}\n\n\t\tif (a [left] == val)\n\t\t\treturn left;\n\t\telse\n\t\t\treturn -1;\n\t}\n\n\tpublic static double Bisection (F f, double left, double right, double eps)\n\t{\n\t\tdouble mid;\n\t\twhile (right - left > eps) {\n\t\t\tmid = left + ((right - left) / 2d);\n\t\t\tif (Math.Sign (f (mid)) != Math.Sign (f (left)))\n\t\t\t\tright = mid;\n\t\t\telse\n\t\t\t\tleft = mid;\n\t\t}\n\t\treturn (left + right) / 2d;\n\t}\n\n\tpublic static decimal TernarySearchDec (Fdec f, decimal eps, decimal l, decimal r, bool isMax)\n\t{\n\t\tdecimal m1, m2;\n\t\twhile (r - l > eps) {\n\t\t\tm1 = l + (r - l) / 3m;\n\t\t\tm2 = r - (r - l) / 3m;\n\t\t\tif (f (m1) < f (m2))\n\t\t\tif (isMax)\n\t\t\t\tl = m1;\n\t\t\telse\n\t\t\t\tr = m2;\n\t\t\telse\n if (isMax)\n\t\t\t\tr = m2;\n\t\t\telse\n\t\t\t\tl = m1;\n\t\t}\n\t\treturn r;\n\t}\n\n\tpublic static double TernarySearch (F f, double eps, double l, double r, bool isMax)\n\t{\n\t\tdouble m1, m2;\n\t\twhile (r - l > eps) {\n\t\t\tm1 = l + (r - l) / 3d;\n\t\t\tm2 = r - (r - l) / 3d;\n\t\t\tif (f (m1) < f (m2))\n\t\t\tif (isMax)\n\t\t\t\tl = m1;\n\t\t\telse\n\t\t\t\tr = m2;\n\t\t\telse\n if (isMax)\n\t\t\t\tr = m2;\n\t\t\telse\n\t\t\t\tl = m1;\n\t\t}\n\t\treturn r;\n\t}\n\n\tpublic static void Merge_Sort (T[]A, int p, int r, Comparison comp)\n\t{\n\t\tT[] L = new T[A.Length];\n\t\tT[] R = new T[A.Length];\n\t\tMerge_Sort (A, p, r, L, R, comp);\n\t}\n\n\tpublic static void Merge (T[] A, int p, int q, int r, T[] L, T[] R, Comparison comp)\n\t{\n\t\tfor (int i = p; i <= q; i++)\n\t\t\tL [i] = A [i];\n\t\tfor (int i = q + 1; i <= r; i++)\n\t\t\tR [i] = A [i];\n\n\t\tfor (int k = p, i = p, j = q + 1; k <= r; k++) {\n\t\t\tif (i > q) {\n\t\t\t\tfor (; k <= r; k++, j++)\n\t\t\t\t\tA [k] = R [j];\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (j > r) {\n\t\t\t\tfor (; k <= r; k++, i++)\n\t\t\t\t\tA [k] = L [i];\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (comp (L [i], R [j]) <= 0) {\n\t\t\t\tA [k] = L [i];\n\t\t\t\ti++;\n\t\t\t} else {\n\t\t\t\tA [k] = R [j];\n\t\t\t\tj++;\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate static void Merge_Sort (T[] A, int p, int r, T[] L, T[] R, Comparison comp)\n\t{\n\t\tif (p >= r)\n\t\t\treturn;\n\t\tint q = p + ((r - p) >> 1);\n\t\tMerge_Sort (A, p, q, L, R, comp);\n\t\tMerge_Sort (A, q + 1, r, L, R, comp);\n\t\tMerge (A, p, q, r, L, R, comp);\n\t}\n\n\tpublic static void Merge_Sort (T[]A, int p, int r)where T:IComparable\n\t{\n\t\tT[] L = new T[A.Length];\n\t\tT[] R = new T[A.Length];\n\t\tMerge_Sort (A, p, r, L, R);\n\t}\n\n\tpublic static void Merge (T[] A, int p, int q, int r, T[] L, T[] R) where T : IComparable\n\t{\n\t\tfor (int i = p; i <= q; i++)\n\t\t\tL [i] = A [i];\n\t\tfor (int i = q + 1; i <= r; i++)\n\t\t\tR [i] = A [i];\n\n\t\tfor (int k = p, i = p, j = q + 1; k <= r; k++) {\n\t\t\tif (i > q) {\n\t\t\t\tfor (; k <= r; k++, j++)\n\t\t\t\t\tA [k] = R [j];\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (j > r) {\n\t\t\t\tfor (; k <= r; k++, i++)\n\t\t\t\t\tA [k] = L [i];\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (L [i].CompareTo (R [j]) <= 0) {\n\t\t\t\tA [k] = L [i];\n\t\t\t\ti++;\n\t\t\t} else {\n\t\t\t\tA [k] = R [j];\n\t\t\t\tj++;\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate static void Merge_Sort (T[] A, int p, int r, T[] L, T[] R) where T : IComparable\n\t{\n\t\tif (p >= r)\n\t\t\treturn;\n\t\tint q = p + ((r - p) >> 1);\n\t\tMerge_Sort (A, p, q, L, R);\n\t\tMerge_Sort (A, q + 1, r, L, R);\n\t\tMerge (A, p, q, r, L, R);\n\t}\n\n\tpublic static void Merge_Sort_Non_Recursive (T[] A, int p, int r) where T : IComparable\n\t{\n\t\tT[] L = new T[A.Length];\n\t\tT[] R = new T[A.Length];\n\t\tint k = 1;\n\t\twhile (k < r - p + 1) {\n\t\t\tint i = 0;\n\t\t\twhile (i < r) {\n\t\t\t\tint _r = Math.Min (i + 2 * k - 1, r);\n\t\t\t\tint q = Math.Min (i + k - 1, r);\n\t\t\t\tMerge (A, i, q, _r, L, R);\n\t\t\t\ti += 2 * k;\n\t\t\t}\n\t\t\tk <<= 1;\n\t\t}\n\t}\n\n\tpublic static void Merge_Sort_Non_Recursive (T[] A, int p, int r, Comparison comp)\n\t{\n\t\tT[] L = new T[A.Length];\n\t\tT[] R = new T[A.Length];\n\t\tint k = 1;\n\t\twhile (k < r - p + 1) {\n\t\t\tint i = 0;\n\t\t\twhile (i < r) {\n\t\t\t\tint _r = Math.Min (i + 2 * k - 1, r);\n\t\t\t\tint q = Math.Min (i + k - 1, r);\n\t\t\t\tMerge (A, i, q, _r, L, R, comp);\n\t\t\t\ti += 2 * k;\n\t\t\t}\n\t\t\tk <<= 1;\n\t\t}\n\t}\n\n\tpublic static void Shake (T[] a)\n\t{\n\t\tRandom rnd = new Random (Environment.TickCount);\n\t\tint b;\n\t\tfor (int i = 0; i < a.Length; i++) {\n\t\t\tb = rnd.Next (i, a.Length);\n\t\t\tSwap (a, i, b);\n\t\t}\n\t}\n}\n\npartial class Program\n{\n\tstatic string[] tokens = new string[0];\n\tstatic int cur_token = 0;\n\n\tstatic void ReadArray (char sep)\n\t{\n\t\tcur_token = 0;\n\t\ttokens = Console.ReadLine ().Split (sep);\n\t}\n\n\tstatic int ReadInt ()\n\t{\n\t\treturn int.Parse (Console.ReadLine ());\n\t}\n\n\tstatic long ReadLong ()\n\t{\n\t\treturn long.Parse (Console.ReadLine ());\n\t}\n\n\tstatic int NextInt ()\n\t{\n\t\tif (cur_token == tokens.Length)\n\t\t\tReadArray (' ');\n\t\treturn int.Parse (tokens [cur_token++]);\n\t}\n\n\tstatic long NextLong ()\n\t{\n\t\tif (cur_token == tokens.Length)\n\t\t\tReadArray (' ');\n\t\treturn long.Parse (tokens [cur_token++]);\n\t}\n\n\tstatic double NextDouble ()\n\t{\n\t\tif (cur_token == tokens.Length)\n\t\t\tReadArray (' ');\n\t\treturn double.Parse (tokens [cur_token++]);\n\t}\n\n\tstatic decimal NextDecimal ()\n\t{\n\t\tif (cur_token == tokens.Length)\n\t\t\tReadArray (' ');\n\t\treturn decimal.Parse (tokens [cur_token++]);\n\t}\n\n\tstatic string NextToken ()\n\t{\n\t\tif (cur_token == tokens.Length)\n\t\t\tReadArray (' ');\n\t\treturn tokens [cur_token++];\n\t}\n\n\tstatic string ReadLine ()\n\t{\n\t\treturn Console.ReadLine ();\n\t}\n}", "lang_cluster": "C#", "tags": ["math", "binary search"], "code_uid": "e7ae7894314ddd0e2654053e3dcff09d", "src_uid": "a1db3dd9f8d0f0cad7bdeb1780707143", "difficulty": 2000.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.IO;\nusing System.Threading;\nusing System.Text;\nusing System.Diagnostics;\nusing static util;\nusing P = pair;\n\nclass Program {\n static void Main(string[] args) {\n var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };\n var solver = new Solver(sw);\n // var t = new Thread(solver.solve, 1 << 26); // 64 MB\n // t.Start();\n // t.Join();\n solver.solve();\n sw.Flush();\n }\n}\n\nclass Solver {\n StreamWriter sw;\n Scan sc;\n void Prt(string a) => sw.WriteLine(a);\n void Prt(IEnumerable a) => Prt(string.Join(\" \", a));\n void Prt(params object[] a) => Prt(string.Join(\" \", a));\n public Solver(StreamWriter sw) {\n this.sw = sw;\n this.sc = new Scan();\n }\n\n public void solve() {\n int n, t;\n sc.Multi(out n, out t);\n var s = new int[n];\n var g = new int[n];\n for (int i = 0; i < n; i++)\n {\n sc.Multi(out s[i], out g[i]);\n --g[i];\n }\n memo = new long[n + 1][][][];\n for (int i = 0; i < n + 1; i++)\n {\n memo[i] = new long[n + 1][][];\n for (int j = 0; j < n + 1; j++)\n {\n memo[i][j] = new long[n + 1][];\n for (int k = 0; k < n + 1; k++)\n {\n memo[i][j][k] = new long[4];\n for (int l = 0; l < 4; l++)\n {\n memo[i][j][k][l] = -1;\n }\n }\n }\n }\n long ans = 0;\n for (int i = 0; i < (1 << n); i++)\n {\n int sum = 0;\n var cnt = new int[3];\n for (int j = 0; j < n; j++)\n {\n if (((i >> j) & 1) == 1) {\n sum += s[j];\n ++cnt[g[j]];\n }\n }\n if (sum != t) continue;\n ans += dfs(cnt[0], cnt[1], cnt[2], 3);\n }\n Prt(ans % M);\n }\n long[][][][] memo;\n long dfs(int a, int b, int c, int prev) {\n if (a < 0 || b < 0 || c < 0) return 0;\n if (a == 0 && b == 0 && c == 0) return 1;\n if (memo[a][b][c][prev] != -1) return memo[a][b][c][prev];\n long sum = 0;\n if (prev != 0) sum += dfs(a - 1, b, c, 0) * a;\n if (prev != 1) sum += dfs(a, b - 1, c, 1) * b;\n if (prev != 2) sum += dfs(a, b, c - 1, 2) * c;\n return memo[a][b][c][prev] = sum % M;\n }\n}\n\nclass pair : IComparable> {\n public T v1;\n public U v2;\n public pair() : this(default(T), default(U)) {}\n public pair(T v1, U v2) { this.v1 = v1; this.v2 = v2; }\n public int CompareTo(pair a) {\n int c = Comparer.Default.Compare(v1, a.v1);\n return c != 0 ? c : Comparer.Default.Compare(v2, a.v2);\n }\n public override string ToString() => v1 + \" \" + v2;\n public void Deconstruct(out T a, out U b) { a = v1; b = v2; }\n}\nstatic class util {\n public static readonly int M = 1000000007;\n // public static readonly int M = 998244353;\n public static readonly long LM = 1L << 60;\n public static readonly double eps = 1e-11;\n public static void DBG(string a) => Console.Error.WriteLine(a);\n public static void DBG(IEnumerable a) => DBG(string.Join(\" \", a));\n public static void DBG(params object[] a) => DBG(string.Join(\" \", a));\n public static void Assert(bool cond) { if (!cond) throw new Exception(); }\n public static pair make_pair(T v1, U v2) => new pair(v1, v2);\n public static int CompareList(IList a, IList b) where T : IComparable {\n for (int i = 0; i < a.Count && i < b.Count; i++)\n if (a[i].CompareTo(b[i]) != 0) return a[i].CompareTo(b[i]);\n return a.Count.CompareTo(b.Count);\n }\n public static bool inside(int i, int j, int h, int w) => i >= 0 && i < h && j >= 0 && j < w;\n static readonly int[] dd = { 0, 1, 0, -1 };\n // static readonly string dstring = \"RDLU\";\n public static P[] adjacents(int i, int j)\n => Enumerable.Range(0, dd.Length).Select(k => new P(i + dd[k], j + dd[k ^ 1])).ToArray();\n public static P[] adjacents(int i, int j, int h, int w)\n => Enumerable.Range(0, dd.Length).Select(k => new P(i + dd[k], j + dd[k ^ 1]))\n .Where(p => inside(p.v1, p.v2, h, w)).ToArray();\n public static P[] adjacents(this P p) => adjacents(p.v1, p.v2);\n public static P[] adjacents(this P p, int h, int w) => adjacents(p.v1, p.v2, h, w);\n public static Dictionary compress(this IEnumerable a)\n => a.Distinct().OrderBy(v => v).Select((v, i) => new { v, i }).ToDictionary(p => p.v, p => p.i);\n public static Dictionary compress(params IEnumerable[] a) => compress(a.Aggregate(Enumerable.Union));\n public static T[] inv(this Dictionary dic) {\n var res = new T[dic.Count];\n foreach (var item in dic) res[item.Value] = item.Key;\n return res;\n }\n public static void swap(ref T a, ref T b) where T : struct { var t = a; a = b; b = t; }\n public static void swap(this IList a, int i, int j) where T : struct { var t = a[i]; a[i] = a[j]; a[j] = t; }\n public static T[] copy(this IList a) {\n var ret = new T[a.Count];\n for (int i = 0; i < a.Count; i++) ret[i] = a[i];\n return ret;\n }\n}\n\nclass Scan {\n StreamReader sr;\n public Scan() { sr = new StreamReader(Console.OpenStandardInput()); }\n public Scan(string path) { sr = new StreamReader(path); }\n public int Int => int.Parse(Str);\n public long Long => long.Parse(Str);\n public double Double => double.Parse(Str);\n public string Str => sr.ReadLine().Trim();\n public pair Pair() {\n T a; U b;\n Multi(out a, out b);\n return new pair(a, b);\n }\n public P P => Pair();\n public int[] IntArr => StrArr.Select(int.Parse).ToArray();\n public long[] LongArr => StrArr.Select(long.Parse).ToArray();\n public double[] DoubleArr => StrArr.Select(double.Parse).ToArray();\n public string[] StrArr => Str.Split(new[]{' '}, StringSplitOptions.RemoveEmptyEntries);\n bool eq() => typeof(T).Equals(typeof(U));\n T ct(U a) => (T)Convert.ChangeType(a, typeof(T));\n T cv(string s) => eq() ? ct(int.Parse(s))\n : eq() ? ct(long.Parse(s))\n : eq() ? ct(double.Parse(s))\n : eq() ? ct(s[0])\n : ct(s);\n public void Multi(out T a) => a = cv(Str);\n public void Multi(out T a, out U b)\n { var ar = StrArr; a = cv(ar[0]); b = cv(ar[1]); }\n public void Multi(out T a, out U b, out V c)\n { var ar = StrArr; a = cv(ar[0]); b = cv(ar[1]); c = cv(ar[2]); }\n public void Multi(out T a, out U b, out V c, out W d)\n { var ar = StrArr; a = cv(ar[0]); b = cv(ar[1]); c = cv(ar[2]); d = cv(ar[3]); }\n public void Multi(out T a, out U b, out V c, out W d, out X e)\n { var ar = StrArr; a = cv(ar[0]); b = cv(ar[1]); c = cv(ar[2]); d = cv(ar[3]); e = cv(ar[4]); }\n}\n", "lang_cluster": "C#", "tags": ["dp", "combinatorics", "bitmasks"], "code_uid": "0eaf8e718db037b12fa0821350bfbfdb", "src_uid": "ac2a37ff4c7e89a345b189e4891bbf56", "difficulty": 2100.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.IO;\nusing SB = System.Text.StringBuilder;\n//using System.Threading.Tasks;\n//using System.Text.RegularExpressions;\n//using System.Globalization;\n//using System.Diagnostics;\nusing static System.Console;\nusing System.Numerics;\nusing static System.Math;\nusing pair = Pair;\n\nclass Program\n{\n static void Main()\n {\n //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });\n new Program().solve();\n Out.Flush();\n }\n readonly Scanner cin = new Scanner();\n readonly int[] dd = { 0, 1, 0, -1, 0 }; //\u2192\u2193\u2190\u2191\n readonly int mod = 1000000007;\n readonly int dom = 998244353;\n bool chmax(ref T a, T b) where T : IComparable { if (a.CompareTo(b) < 0) { a = b; return true; } return false; }\n bool chmin(ref T a, T b) where T : IComparable { if (b.CompareTo(a) < 0) { a = b; return true; } return false; }\n\n void solve()\n {\n int N = cin.nextint;\n int T = cin.nextint;\n\n var A = new int[N];\n var G = new int[N];\n var co = new BinomialCoefficient(20);\n\n for (int i = 0; i < N; i++)\n {\n A[i] = cin.nextint;\n G[i] = cin.nextint - 1;\n }\n\n ModInt ans = 0;\n for (int S = 0; S < 1 << N; S++)\n {\n int time = 0;\n var type = new int[3];\n for (int i = 0; i < N; i++)\n {\n if ((S >> i & 1) == 1)\n {\n time += A[i];\n type[G[i]]++;\n }\n }\n if (time != T)\n {\n continue;\n }\n int X = type[0];\n int Y = type[1];\n int Z = type[2];\n\n var dp = new long[type[0] + 1, type[1] + 1, type[2] + 1, 4];\n\n\n for (int i = 0; i <= X; i++)\n {\n for (int j = 0; j <= Y; j++)\n {\n for (int k = 0; k <= Z; k++)\n {\n for (int l = 0; l < 4; l++)\n {\n dp[i, j, k, l] = -1;\n }\n }\n }\n }\n ModInt ret = calc(X, Y, Z, 3, dp);\n if (X > 1) ret = ret * co.fact[X];\n if (Y > 1) ret = ret * co.fact[Y];\n if (Z > 1) ret = ret * co.fact[Z];\n ans += ret;\n \n\n }\n WriteLine(ans);\n }\n\n long calc(int x, int y, int z, int before, long[,,,] dp)\n {\n //WriteLine(x + \" \" + y + \" \" + z);\n if (dp[x, y, z, before] >= 0)\n {\n return dp[x, y, z, before];\n }\n if (x == 0 && y == 0 && z == 0)\n {\n return 1;\n }\n\n long ret = 0;\n if (x > 0 && before != 0)\n {\n ret += calc(x - 1, y, z, 0, dp);\n }\n if (y > 0 && before != 1)\n {\n ret += calc(x, y - 1, z, 1, dp);\n }\n if (z > 0 && before != 2)\n {\n ret += calc(x, y, z - 1, 2, dp);\n }\n ret %= mod;\n return dp[x, y, z, before] = ret;\n }\n\n}\n\n/// \n/// [0,) \u307e\u3067\u306e\u5024\u3092\u53d6\u308b\u3088\u3046\u306a\u6570\n/// \n/// camypaper\nstruct ModInt\n{\n /// \n /// \u5270\u4f59\u3092\u53d6\u308b\u5024\uff0e\n /// \n public const long Mod = (int)1e9 + 7;\n\n /// \n /// \u5b9f\u969b\u306e\u6570\u5024\uff0e\n /// \n public long num;\n /// \n /// \u5024\u304c \u3067\u3042\u308b\u3088\u3046\u306a\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u3092\u69cb\u7bc9\u3057\u307e\u3059\uff0e\n /// \n /// \u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u304c\u6301\u3064\u5024\n /// \u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u306e\u554f\u984c\u4e0a\uff0c\u30b3\u30f3\u30b9\u30c8\u30e9\u30af\u30bf\u5185\u3067\u306f\u5270\u4f59\u3092\u53d6\u308a\u307e\u305b\u3093\uff0e\u305d\u306e\u305f\u3081\uff0c \u2208 [0,) \u3092\u6e80\u305f\u3059\u3088\u3046\u306a \u3092\u6e21\u3057\u3066\u304f\u3060\u3055\u3044\uff0e\u3053\u306e\u30b3\u30f3\u30b9\u30c8\u30e9\u30af\u30bf\u306f O(1) \u3067\u5b9f\u884c\u3055\u308c\u307e\u3059\uff0e\n public ModInt(long n) { num = n; }\n /// \n /// \u3053\u306e\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u306e\u6570\u5024\u3092\u6587\u5b57\u5217\u306b\u5909\u63db\u3057\u307e\u3059\uff0e\n /// \n /// [0,) \u306e\u7bc4\u56f2\u5185\u306e\u6574\u6570\u3092 10 \u9032\u8868\u8a18\u3057\u305f\u3082\u306e\uff0e\n public override string ToString() { return num.ToString(); }\n public static ModInt operator +(ModInt l, ModInt r) { l.num += r.num; if (l.num >= Mod) l.num -= Mod; return l; }\n public static ModInt operator -(ModInt l, ModInt r) { l.num -= r.num; if (l.num < 0) l.num += Mod; return l; }\n public static ModInt operator *(ModInt l, ModInt r) { return new ModInt(l.num * r.num % Mod); }\n public static implicit operator ModInt(long n) { n %= Mod; if (n < 0) n += Mod; return new ModInt(n); }\n\n /// \n /// \u4e0e\u3048\u3089\u308c\u305f 2 \u3064\u306e\u6570\u5024\u304b\u3089\u3079\u304d\u5270\u4f59\u3092\u8a08\u7b97\u3057\u307e\u3059\uff0e\n /// \n /// \u3079\u304d\u4e57\u306e\u5e95\n /// \u3079\u304d\u6307\u6570\n /// \u7e70\u308a\u8fd4\u3057\u4e8c\u4e57\u6cd5\u306b\u3088\u308a O(N log N) \u3067\u5b9f\u884c\u3055\u308c\u307e\u3059\uff0e\n public static ModInt Pow(ModInt v, long k) { return Pow(v.num, k); }\n\n /// \n /// \u4e0e\u3048\u3089\u308c\u305f 2 \u3064\u306e\u6570\u5024\u304b\u3089\u3079\u304d\u5270\u4f59\u3092\u8a08\u7b97\u3057\u307e\u3059\uff0e\n /// \n /// \u3079\u304d\u4e57\u306e\u5e95\n /// \u3079\u304d\u6307\u6570\n /// \u7e70\u308a\u8fd4\u3057\u4e8c\u4e57\u6cd5\u306b\u3088\u308a O(N log N) \u3067\u5b9f\u884c\u3055\u308c\u307e\u3059\uff0e\n public static ModInt Pow(long v, long k)\n {\n long ret = 1;\n for (k %= Mod - 1; k > 0; k >>= 1, v = v * v % Mod)\n if ((k & 1) == 1) ret = ret * v % Mod;\n return new ModInt(ret);\n }\n /// \n /// \u4e0e\u3048\u3089\u308c\u305f\u6570\u306e\u9006\u5143\u3092\u8a08\u7b97\u3057\u307e\u3059\uff0e\n /// \n /// \u9006\u5143\u3092\u53d6\u308b\u5bfe\u8c61\u3068\u306a\u308b\u6570\n /// \u9006\u5143\u3068\u306a\u308b\u3088\u3046\u306a\u5024\n /// \u6cd5\u304c\u7d20\u6570\u3067\u3042\u308b\u3053\u3068\u3092\u4eee\u5b9a\u3057\u3066\uff0c\u30d5\u30a7\u30eb\u30de\u30fc\u306e\u5c0f\u5b9a\u7406\u306b\u5f93\u3063\u3066\u9006\u5143\u3092 O(log N) \u3067\u8a08\u7b97\u3057\u307e\u3059\uff0e\n public static ModInt Inverse(ModInt v) { return Pow(v, Mod - 2); }\n}\n\nclass BinomialCoefficient\n{\n public ModInt[] fact, ifact;\n /// \n /// \u306f \u672a\u6e80\u3067\u304a\u9858\u3044\u3057\u307e\u3059\u3002\n /// \n /// \n public BinomialCoefficient(ModInt _n)\n {\n int n = (int)_n.num;\n fact = new ModInt[n + 1];\n ifact = new ModInt[n + 1];\n fact[0] = 1;\n for (int i = 1; i <= n; i++)\n fact[i] = fact[i - 1] * i;\n ifact[n] = ModInt.Inverse(fact[n]);\n for (int i = n - 1; i >= 0; i--)\n ifact[i] = ifact[i + 1] * (i + 1);\n ifact[0] = ifact[1];\n }\n public ModInt this[int n, int r]\n {\n get\n {\n if (n < 0 || n >= fact.Length || r < 0 || r > n) return 0;\n return fact[n] * ifact[n - r] * ifact[r];\n }\n }\n public ModInt RepeatedCombination(int n, int k)\n {\n if (k == 0) return 1;\n return this[n + k - 1, k];\n }\n}\n\nstatic class Ex\n{\n public static void join(this IEnumerable values, string sep = \" \") => WriteLine(string.Join(sep, values));\n public static string concat(this IEnumerable values) => string.Concat(values);\n public static string reverse(this string s) { var t = s.ToCharArray(); Array.Reverse(t); return t.concat(); }\n\n public static int lower_bound(this IList arr, T val) where T : IComparable\n {\n int low = 0, high = arr.Count;\n int mid;\n while (low < high)\n {\n mid = ((high - low) >> 1) + low;\n if (arr[mid].CompareTo(val) < 0) low = mid + 1;\n else high = mid;\n }\n return low;\n }\n public static int upper_bound(this IList arr, T val) where T : IComparable\n {\n int low = 0, high = arr.Count;\n int mid;\n while (low < high)\n {\n mid = ((high - low) >> 1) + low;\n if (arr[mid].CompareTo(val) <= 0) low = mid + 1;\n else high = mid;\n }\n return low;\n }\n}\n\nclass Pair : IComparable> where T : IComparable where U : IComparable\n{\n public T f; public U s;\n public Pair(T f, U s) { this.f = f; this.s = s; }\n public int CompareTo(Pair a) => f.CompareTo(a.f) != 0 ? f.CompareTo(a.f) : s.CompareTo(a.s);\n public override string ToString() => $\"{f} {s}\";\n}\n\nclass Scanner\n{\n string[] s; int i;\n readonly char[] cs = new char[] { ' ' };\n public Scanner() { s = new string[0]; i = 0; }\n public string[] scan => ReadLine().Split();\n public int[] scanint => Array.ConvertAll(scan, int.Parse);\n public long[] scanlong => Array.ConvertAll(scan, long.Parse);\n public double[] scandouble => Array.ConvertAll(scan, double.Parse);\n public string next\n {\n get\n {\n if (i < s.Length) return s[i++];\n string st = ReadLine();\n while (st == \"\") st = ReadLine();\n s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);\n i = 0;\n return next;\n }\n }\n public int nextint => int.Parse(next);\n public long nextlong => long.Parse(next);\n public double nextdouble => double.Parse(next);\n}\n", "lang_cluster": "C#", "tags": ["dp", "combinatorics", "bitmasks"], "code_uid": "6efac38a0d5bdcab1937953c585edcab", "src_uid": "ac2a37ff4c7e89a345b189e4891bbf56", "difficulty": 2100.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\n\nnamespace \u041e\u0431\u0440\u0430\u043c\u043b\u0435\u043d\u0438\u0435_\u0434\u0432\u0435\u0440\u0435\u0439\n{\n class Program\n {\n static void Main(string[] args)\n {\n int barLength = int.Parse(Console.ReadLine());\n int borderLength = int.Parse(Console.ReadLine());\n int upperBorderLength = int.Parse(Console.ReadLine());\n\n int scrap, barNum = 0, aNum=0,bNum=0;\n\n while (true)\n {\n if (upperBorderLength <= borderLength && bNum < 2 || aNum >= 4 && bNum < 2)\n {\n scrap = barLength;\n barNum++;\n scrap -= upperBorderLength;\n bNum++;\n }\n else if(aNum<4 || bNum>=2 && aNum<4)\n {\n scrap = barLength;\n barNum++;\n scrap -= borderLength;\n aNum++;\n }\n else\n {\n break;\n }\n while (true)\n {\n int aTmp = scrap - borderLength;\n int bTmp = scrap - upperBorderLength;\n if (aTmp>=0&&aTmp<=bTmp&&aNum<4 || aTmp>=0&&aNum<4&&bNum>=2 || bTmp<0 && aNum<4 && aTmp>=0)\n {\n scrap = aTmp;\n aNum++;\n }\n else if (bTmp>=0&&bNum<2 || bTmp >= 0 && bNum < 2 && aNum >= 4 || aTmp<0 && bTmp<2 && bTmp>=0)\n {\n scrap = bTmp;\n bNum++;\n }\n else\n {\n break;\n }\n }\n }\n\n Console.WriteLine(barNum);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["greedy", "implementation"], "code_uid": "cdf417bfb3302e4bcdd2feebb01584ed", "src_uid": "1a50fe39e18f86adac790093e195979a", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\n\nnamespace CodeForceCs\n{\n static class Program\n {\n static void Main(string[] args)\n {\n Solver solver = new _Q910B();\n solver.SolveProblem();\n //Console.ReadKey();\n }\n }\n\n abstract class Solver\n {\n abstract public void SolveProblem();\n }\n\n class _Q910B : Solver\n {\n int n, a, b;\n List need = new List();\n override public void SolveProblem()\n {\n n = int.Parse(Console.ReadLine());\n a = int.Parse(Console.ReadLine());\n b = int.Parse(Console.ReadLine());\n\n Console.WriteLine(GetResult());\n }\n\n int GetResult()\n {\n\n if (n >= 4 * a + 2 * b)\n return 1;\n\n if (n >= 2 * a + b)\n return 2;\n\n if (a >= b)\n {\n if (n >= 2 * a)\n return 3;\n\n if (n >= a + b)\n return 4;\n\n if (n >= 2 * b)\n return 5;\n }\n else\n {\n if (n >= a + b || n >= 4 * a)\n return 3;\n\n if (n >= 2 * a)\n return 4;\n }\n return 6;\n }\n }\n\n}\n\n", "lang_cluster": "C#", "tags": ["greedy", "implementation"], "code_uid": "19dd8078ca69c4f36de04496b1702e82", "src_uid": "1a50fe39e18f86adac790093e195979a", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.IO;\nusing System.Text;\n\nnamespace Little_Elephant_and_Interval\n{\n internal class Program\n {\n private static readonly StreamReader reader = new StreamReader(Console.OpenStandardInput(1024*10), Encoding.ASCII, false, 1024*10);\n private static readonly StreamWriter writer = new StreamWriter(Console.OpenStandardOutput(1024*10), Encoding.ASCII, 1024*10);\n\n private static void Main(string[] args)\n {\n string[] ss = reader.ReadLine().Split(' ');\n\n string sl = ss[0];\n string sr = ss[1];\n\n long count = 0;\n long d = 1;\n for (int i = 0; i < sl.Length - 1; i++)\n {\n d *= 10;\n }\n for (int i = sl.Length + 1; i < sr.Length; i++)\n {\n count += 9*d;\n d *= 10;\n }\n\n if (sl.Length == sr.Length)\n {\n count += Bigger(sl, true) - Bigger(sr, false);\n }\n else\n {\n count += Bigger(sl, true);\n count += 9*d - Bigger(sr, false);\n }\n\n writer.WriteLine(count);\n writer.Flush();\n }\n\n private static long Bigger(string sl, bool border)\n {\n long l = long.Parse(sl);\n if (sl.Length == 1)\n {\n return 10 - l - (border ? 0 : 1);\n }\n\n long d = 1;\n for (int i = 0; i < sl.Length - 2; i++)\n {\n d *= 10;\n }\n long count = d*(10 - (sl[0] - '0') - 1);\n\n char[] cl = sl.ToCharArray();\n cl[cl.Length - 1] = cl[0];\n\n var sd = new string(cl, 1, cl.Length - 2);\n if (sd.Length == 0)\n sd = \"0\";\n long dd = long.Parse(sd);\n long ll = long.Parse(new string(cl));\n\n if (ll < l || (ll == l && !border))\n dd++;\n\n count += d - dd;\n\n return count;\n }\n }\n}", "lang_cluster": "C#", "tags": ["binary search", "dp", "combinatorics"], "code_uid": "71333ea12a90331aaa1ca30e42f9d56a", "src_uid": "9642368dc4ffe2fc6fe6438c7406c1bd", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.IO;\nusing System.Linq;\nusing System.Text;\nusing System.Globalization;\n\nnamespace CodeforcesSolution\n{\n class ProgramCF\n {\n static ConsoleInput inp;\n static void Main ( string[] args )\n {\n try\n {\n if ( File.Exists ( @\"d:\\zin.txt\" ) )\n Console.SetIn ( new StreamReader ( @\"d:\\zin.txt\" ) );\n }\n catch\n {\n }\n inp = new ConsoleInput ( );\n inp.ReadAll ( );\n long L = inp.NextLong ( );\n long R = inp.NextLong ( );\n long[] cntNumDigit = new long[20];\n cntNumDigit[1] = 10; //0~9\n cntNumDigit[2] = cntNumDigit[1] + 9; //0~99\n cntNumDigit[3] = cntNumDigit[2] + 10 * 9;\n long k=10;\n for ( int i = 4; i < 20; i++ )\n {\n k *= 10;\n cntNumDigit[i] = cntNumDigit[i - 1] + ( k * 9 );\n }\n long fr = F ( R, cntNumDigit );\n long fl = F ( L - 1, cntNumDigit );\n long ans = fr - fl;\n\n // start here\n // ====\n WriteLine ( ans );\n\n }\n\n private static long F ( long n, long[] cntNumDigit )\n {\n if ( n < 100 )\n {\n int cnt=0;\n for ( int i = 0; i <= n; i++ )\n {\n string s = i.ToString ( );\n if ( s[0] == s[s.Length - 1] )\n cnt++;\n }\n return cnt;\n }\n else\n {\n int len = n.ToString().Length;\n long res=cntNumDigit[len - 1];\n long left = n.ToString ( )[0] - '0';\n long right = n % 10;\n long mid = long.Parse ( n.ToString ( ).Substring ( 1, len - 2 ) );\n for ( int i = 1; i <= 9; i++ )\n {\n if ( i < left )\n {\n long add = long.Parse ( \"1\" + new string ( '0', len - 2 ) );\n res += add;\n }\n else if ( i == left )\n {\n res += mid + 1;\n if ( right < left )\n res -= 1;\n }\n }\n return res;\n }\n }\n\n private static void WriteLine ( object value )\n {\n Console.WriteLine ( string.Format ( CultureInfo.InvariantCulture, \"{0}\", value ) );\n }\n\n class ConsoleInput\n {\n List lines = new List ( );\n int idx=0;\n\n public void ReadAll ( )\n {\n while ( true )\n {\n string line = Console.ReadLine ( );\n if ( line == null )\n break;\n lines.AddRange ( line.Split ( ' ' ) );\n }\n }\n\n public string NextString ( )\n {\n return lines[idx++];\n }\n\n public int NextInt ( )\n {\n return int.Parse ( lines[idx++] );\n }\n\n public long NextLong ( )\n {\n return long.Parse ( lines[idx++] );\n }\n\n public double NextDouble ( )\n {\n return double.Parse ( lines[idx++] );\n }\n\n }\n\n }\n}", "lang_cluster": "C#", "tags": ["binary search", "dp", "combinatorics"], "code_uid": "87c6f6f56f8a2ec4719a4a04cf9cf1ed", "src_uid": "9642368dc4ffe2fc6fe6438c7406c1bd", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\n\nnamespace BlockedPoints\n{\n partial class BlockedPoints\n {\n static void Main(string[] args)\n {\n long n;\n\n n = NextLong();\n\n Console.WriteLine(FindMinBlockedPoints(n));\n }\n\n private static long FindMinBlockedPoints(long n)\n {\n long count = 0, x, y, nSquared;\n bool hasMove = false;\n\n if (n == 0)\n return 1;\n\n if (n == 1)\n return 4;\n\n x = 1;\n y = n - 1;\n nSquared = n * n;\n\n while (x < n && y > 0)\n {\n if (x * x + y * y <= nSquared)\n {\n count++;\n x++;\n hasMove = false;\n }\n else\n {\n if (!hasMove)\n {\n y--;\n hasMove = true;\n }\n else\n {\n x--;\n }\n }\n }\n\n count += (y - 1);\n\n return count * 4 + 4;\n }\n }\n\n partial class BlockedPoints\n {\n static string[] tokens = new string[0];\n static int cur_token = 0;\n\n static void ReadArray(char sep)\n {\n cur_token = 0;\n tokens = Console.ReadLine().Split(sep);\n }\n\n static int ReadInt()\n {\n return int.Parse(Console.ReadLine());\n }\n\n static long ReadLong()\n {\n return long.Parse(Console.ReadLine());\n }\n\n static int NextInt()\n {\n if (cur_token == tokens.Length)\n ReadArray(' ');\n return int.Parse(tokens[cur_token++]);\n }\n\n static long NextLong()\n {\n if (cur_token == tokens.Length)\n ReadArray(' ');\n return long.Parse(tokens[cur_token++]);\n }\n\n static double NextDouble()\n {\n if (cur_token == tokens.Length)\n ReadArray(' ');\n return double.Parse(tokens[cur_token++]);\n }\n\n static decimal NextDecimal()\n {\n if (cur_token == tokens.Length)\n ReadArray(' ');\n return decimal.Parse(tokens[cur_token++]);\n }\n\n static string NextToken()\n {\n if (cur_token == tokens.Length)\n ReadArray(' ');\n return tokens[cur_token++];\n }\n\n static string ReadLine()\n {\n return Console.ReadLine();\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["geometry"], "code_uid": "020b8212af962cfdc10ec5e80562ed45", "src_uid": "d87ce09acb8401e910ca6ef3529566f4", "difficulty": null, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.IO;\nusing System.Text;\n\nnamespace Blocked_Points\n{\n internal class Program\n {\n private static readonly StreamReader reader = new StreamReader(Console.OpenStandardInput(1024*10), Encoding.ASCII, false, 1024*10);\n private static readonly StreamWriter writer = new StreamWriter(Console.OpenStandardOutput(1024*10), Encoding.ASCII, 1024*10);\n\n private static void Main(string[] args)\n {\n long n = Next();\n\n long count;\n if (n == 1)\n count = 4;\n else if (n == 0)\n count = 1;\n else if (n == 2)\n count = 8;\n else\n {\n \n long y = (long)Math.Sqrt(n/2*n)+2;\n long nn = n*n;\n\n while (2*y*y > nn)\n {\n y--;\n }\n if (y*y + (y+1)*(y+1) > nn)\n {\n count = (y)*8;\n }\n else\n {\n count = (2*y + 1)*4;\n }\n }\n\n writer.WriteLine(count);\n writer.Flush();\n }\n\n private static int Next()\n {\n int c;\n int res = 0;\n do\n {\n c = reader.Read();\n if (c == -1)\n return res;\n } while (c < '0' || c > '9');\n res = c - '0';\n while (true)\n {\n c = reader.Read();\n if (c < '0' || c > '9')\n return res;\n res *= 10;\n res += c - '0';\n }\n }\n }\n}", "lang_cluster": "C#", "tags": ["geometry"], "code_uid": "d29f236c4f804de493c7d3eae3f2e887", "src_uid": "d87ce09acb8401e910ca6ef3529566f4", "difficulty": null, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\n\n\nclass Solve\n{\n\n\n public void solve(string data)\n {\n string[] Input = Console.ReadLine().Split(new char[] { ' ' });\n // string[] Input = data.Split(new char[] { ' ' });\n int xl1 = Input[0][0] - 'a' + 1, yl1 = Input[0][1] - '0';\n int xl2 = Input[1][0] - 'a' + 1, yl2 = Input[1][1] - '0';\n int xk1 = Input[2][0] - 'a' + 1, yk1 = Input[2][1] - '0';\n int xk2 = Input[3][0] - 'a' + 1, yk2 = Input[3][1] - '0';\n\n int[,] P = new int[10, 10];\n P = Init();\n P[xl1, yl1] = 2;\n P[xl2, yl2] = 2;\n P[xk1, yk1] = 2;\n int x, y;\n\n //---------------------------first------------------\n x = xl1 - 1; y = yl1;\n while (P[x, y] != 2) \n P[x--, y] = 1; \n\n x = xl1 + 1; y = yl1;\n while (P[x, y] != 2) \n P[x++, y] = 1;\n\n x = xl1; y = yl1 - 1;\n while (P[x, y] != 2)\n P[x, y--] = 1;\n\n x = xl1; y = yl1 + 1;\n while (P[x, y] != 2)\n P[x, y++] = 1;\n\n\n //---------------------------second------------------\n x = xl2 - 1; y = yl2;\n while (P[x, y] != 2)\n P[x--, y] = 1;\n\n x = xl2 + 1; y = yl2;\n while (P[x, y] != 2)\n P[x++, y] = 1;\n\n x = xl2; y = yl2 - 1;\n while (P[x, y] != 2)\n P[x, y--] = 1;\n\n x = xl2; y = yl2 + 1;\n while (P[x, y] != 2)\n P[x, y++] = 1; \n\n\n int[] dx = { 1, -1, -1, +1, 0, -1, 0, +1 };\n int[] dy = { 1, -1, +1, -1, -1, 0, +1, 0 };\n\n P[xk1, yk1] = 1;\n for (int k = 0; k < dx.Length; ++k)\n P[xk1 + dx[k], yk1 + dy[k]] = 1;\n\n\n if (P[xl1, yl1] == 2)\n {\n if (xl1 == xl2 || yl1 == yl2)\n P[xl1, yl1] = 1;\n else\n P[xl1, yl1] = 0;\n }\n\n if (P[xl2, yl2] == 2)\n {\n if (xl2 == xl1 || yl2 == yl1)\n P[xl2, yl2] = 1;\n else\n P[xl2, yl2] = 0;\n }\n\n\n bool ok = true;\n if (P[xk2, yk2] == 0)\n ok = false;\n\n for (int k = 0; k < dx.Length; ++k)\n if (P[xk2 + dx[k], yk2 + dy[k]] == 0)\n ok = false;\n\n if (ok)\n Console.WriteLine(\"CHECKMATE\");\n else\n Console.WriteLine(\"OTHER\");\n }\n\n private int[,] Init()\n {\n int[,] tmp = new int[10, 10];\n\n for (int i = 1; i <= 8; ++i)\n for (int j = 1; j <= 8; ++j)\n tmp[i, j] = 0;\n\n for (int k = 0; k < 10; ++k)\n {\n tmp[k, 0] = 2;\n tmp[k, 9] = 2;\n tmp[0, k] = 2;\n tmp[9, k] = 2;\n }\n\n return tmp;\n }\n}\n\nclass Program\n{\n static void Main()\n {\n Solve Task = new Solve();\n Task.solve(\"a6 b4 c8 a8\");//yes\n // Task.solve(\"a6 c4 b6 b8\");//no\n // Task.solve(\"a2 b1 a3 a1\");//no\n // Task.solve(\"a8 h1 c4 a1\"); //no\n // Task.solve(\"a8 h1 c3 a1\"); //yes\n // Task.solve(\"a8 h1 d3 d1\"); //yes\n // Task.solve(\"c8 e2 d3 d1\");//no\n //Task.solve(\"\");\n // Console.ReadKey();\n }\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "48ca10e9d38e2453fff5edf41b4d9674", "src_uid": "5d05af36c7ccb0cd26a4ab45966b28a3", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.IO;\nusing System.Text;\n\nnamespace Game_of_chess_unfinished\n{\n internal class Program\n {\n private static readonly StreamReader reader = new StreamReader(Console.OpenStandardInput(1024*10), Encoding.ASCII, false, 1024*10);\n private static readonly StreamWriter writer = new StreamWriter(Console.OpenStandardOutput(1024*10), Encoding.ASCII, 1024*10);\n\n private static void Main(string[] args)\n {\n var xy = new int[4,2];\n for (int i = 0; i < 4; i++)\n {\n xy[i, 0] = Next();\n xy[i, 1] = Next() - 1;\n }\n\n var nn = new int[8,8];\n\n for (int i = 0; i < 3; i++)\n {\n nn[xy[i, 0], xy[i, 1]] = 2;\n }\n\n for (int i = -1; i < 2; i++)\n {\n for (int j = -1; j < 2; j++)\n {\n if (i==0 && j==0)\n continue;\n\n int x = xy[2, 0] + i;\n int y = xy[2, 1] + j;\n\n if (x < 0 || x > 7 || y < 0 || y > 7)\n continue;\n\n nn[x, y] = 1;\n }\n }\n\n var dx = new[] {1, -1, 0, 0};\n var dy = new[] {0, 0, 1, -1};\n\n for (int i = 0; i < 4; i++)\n {\n for (int j = 1; j < 8; j++)\n {\n int x = xy[0, 0] + dx[i]*j;\n int y = xy[0, 1] + dy[i]*j;\n\n if (x < 0 || x > 7 || y < 0 || y > 7)\n break;\n\n if (nn[x, y] == 2)\n {\n nn[x, y] = 1;\n break;\n }\n\n nn[x, y] = 1;\n }\n }\n\n for (int i = 0; i < 4; i++)\n {\n for (int j = 1; j < 8; j++)\n {\n int x = xy[1, 0] + dx[i]*j;\n int y = xy[1, 1] + dy[i]*j;\n\n if (x < 0 || x > 7 || y < 0 || y > 7)\n break;\n\n if (nn[x, y] == 2)\n {\n nn[x, y] = 1;\n break;\n }\n\n nn[x, y] = 1;\n }\n }\n\n //for (int i = 0; i < 8; i++)\n //{\n // for (int j = 0; j < 8; j++)\n // {\n // Console.Write(nn[i,j]);\n // }\n // Console.WriteLine();\n //}\n\n for (int i = -1; i < 2; i++)\n {\n for (int j = -1; j < 2; j++)\n {\n int x = xy[3, 0] + i;\n int y = xy[3, 1] + j;\n\n if (x < 0 || x > 7 || y < 0 || y > 7)\n continue;\n\n if (nn[x, y] != 1)\n {\n writer.WriteLine(\"OTHER\");\n writer.Flush();\n return;\n }\n }\n }\n\n writer.WriteLine(\"CHECKMATE\");\n writer.Flush();\n }\n\n private static int Next()\n {\n int c;\n int res = 0;\n do\n {\n c = reader.Read();\n if (c >= 'a' && c <= 'z')\n return c - 'a';\n } while (c < '0' || c > '9');\n res = c - '0';\n while (true)\n {\n c = reader.Read();\n if (c < '0' || c > '9')\n return res;\n res *= 10;\n res += c - '0';\n }\n }\n }\n}", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "3cfc8e647069001ecceff2568e6a22dc", "src_uid": "5d05af36c7ccb0cd26a4ab45966b28a3", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Diagnostics;\nusing System.Globalization;\nusing System.IO;\nusing System.Linq;\nusing System.Text;\nusing System.Threading;\n\nnamespace ReadWriteTemplate\n{\n public static class Solver\n {\n private static void SolveCase()\n {\n long m = ReadLong();\n long a = ReadLong();\n long b = ReadLong();\n\n long[] f = Enumerable.Repeat(-1L, (int)a).ToArray();\n f[0] = 0;\n long[] l = new long[a];\n\n var queue = new Queue();\n queue.Enqueue(0);\n while (queue.Count > 0)\n {\n long cur = queue.Dequeue();\n long d = cur + (b - cur + a - 1) / a * a;\n long t = d - b;\n while (t >= 0 && f[t % a] < 0)\n {\n f[t % a] = Math.Max(d, f[cur % a]);\n l[t % a] = t;\n // Writer.WriteLine($\"{t % a} - {f[t % a]} {l[t % a]}\");\n queue.Enqueue(t);\n t -= b;\n }\n }\n\n // WriteArray(f);\n\n long ans = 0;\n for (int i = 0; i < a; i++)\n {\n if (f[i] >= 0 && f[i] <= m)\n {\n long k = Calc(m, l[i], a) - Calc(f[i] - 1, l[i], a);\n // Writer.WriteLine($\"{i} : {k}\");\n ans += k;\n }\n }\n\n Writer.WriteLine(ans);\n }\n\n public static long Calc(long st, long k, long a)\n {\n long full = (st - k + 1) / a;\n long ans = a * full * (full + 1) / 2;\n ans += (st - k + 1) % a * (full + 1);\n return ans;\n }\n\n public static long Gcd(long a, long b)\n {\n return b == 0 ? a : Gcd(b, a % b);\n }\n\n public static void Solve()\n {\n#if DEBUG\n var sw = Stopwatch.StartNew();\n#endif\n\n SolveCase();\n\n /*int T = ReadInt();\n for (int i = 0; i < T; i++)\n {\n // Writer.Write(\"Case #{0}: \", 1 - t);\n SolveCase();\n }*/\n\n#if DEBUG\n sw.Stop();\n Console.WriteLine($\"{sw.ElapsedMilliseconds} ms\");\n#endif\n }\n\n public static void Main()\n {\n Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;\n\n#if DEBUG\n // Reader = Console.In; Writer = Console.Out;\n Reader = File.OpenText(\"input.txt\"); Writer = File.CreateText(\"output.txt\");\n#else\n Reader = Console.In; Writer = Console.Out;\n#endif\n\n // Solve();\n Thread thread = new Thread(Solve, 64 * 1024 * 1024);\n thread.CurrentCulture = CultureInfo.InvariantCulture;\n thread.Start();\n thread.Join();\n\n Reader.Close();\n Writer.Close();\n }\n\n public static IOrderedEnumerable OrderByWithShuffle(this IEnumerable source, Func keySelector)\n {\n return source.Shuffle().OrderBy(keySelector);\n }\n\n public static T[] Shuffle(this IEnumerable source)\n {\n T[] result = source.ToArray();\n Shuffle(result);\n return result;\n }\n\n private static void Shuffle(IList array)\n {\n Random rnd = new Random();\n for (int i = array.Count - 1; i >= 1; i--)\n {\n int k = rnd.Next(i + 1);\n T tmp = array[k];\n array[k] = array[i];\n array[i] = tmp;\n }\n }\n\n #region Read/Write\n\n private static TextReader Reader;\n\n private static TextWriter Writer;\n\n private static Queue CurrentLineTokens = new Queue();\n\n private static string[] ReadAndSplitLine()\n {\n return Reader.ReadLine().Split(new[] { ' ', '\\t' }, StringSplitOptions.RemoveEmptyEntries);\n }\n\n public static string ReadToken()\n {\n while (CurrentLineTokens.Count == 0)\n CurrentLineTokens = new Queue(ReadAndSplitLine());\n return CurrentLineTokens.Dequeue();\n }\n\n public static string ReadLine()\n {\n return Reader.ReadLine();\n }\n\n public static int ReadInt()\n {\n return int.Parse(ReadToken());\n }\n\n public static long ReadLong()\n {\n return long.Parse(ReadToken());\n }\n\n public static double ReadDouble()\n {\n return double.Parse(ReadToken(), CultureInfo.InvariantCulture);\n }\n\n public static int[] ReadIntArray()\n {\n return ReadAndSplitLine().Select(int.Parse).ToArray();\n }\n\n public static long[] ReadLongArray()\n {\n return ReadAndSplitLine().Select(long.Parse).ToArray();\n }\n\n public static double[] ReadDoubleArray()\n {\n return ReadAndSplitLine().Select(s => double.Parse(s, CultureInfo.InvariantCulture)).ToArray();\n }\n\n public static int[][] ReadIntMatrix(int numberOfRows)\n {\n int[][] matrix = new int[numberOfRows][];\n for (int i = 0; i < numberOfRows; i++)\n matrix[i] = ReadIntArray();\n return matrix;\n }\n\n public static string[] ReadLines(int quantity)\n {\n string[] lines = new string[quantity];\n for (int i = 0; i < quantity; i++)\n lines[i] = Reader.ReadLine().Trim();\n return lines;\n }\n\n public static void WriteArray(IEnumerable array)\n {\n Writer.WriteLine(string.Join(\" \", array));\n }\n\n #endregion\n }\n}\n", "lang_cluster": "C#", "tags": ["dfs and similar", "math", "number theory"], "code_uid": "50c0b8e55da5b5d9f8f22af6ba596150", "src_uid": "d6290b69eddfcf5f131cc9e612ccab76", "difficulty": 2100.0, "exec_outcome": "PASSED"} {"lang": "C# 8", "source_code": "using System;\r\nusing System.Collections.Generic;\r\nusing System.IO;\r\nusing System.Linq;\r\n\r\nnamespace TestProject\r\n{\r\n class Program\r\n {\r\n static void Main(string[] args)\r\n {\r\n //read input\r\n var hw = Console.ReadLine().Split(' ');\r\n var h = int.Parse(hw[0]);\r\n var w = int.Parse(hw[1]);\r\n\r\n var field = new List();\r\n for (var i = 0; i < h; i++)\r\n {\r\n var row = Console.ReadLine().ToCharArray();\r\n for (var j = 0; j < w; j++)\r\n {\r\n if (row[j] == '*')\r\n {\r\n field.Add(new B { X = j, Y = i });\r\n }\r\n }\r\n }\r\n\r\n var mouse = new B { Y = 0, X = 0 };\r\n var count = 0;\r\n //move mouse\r\n while (field.Any())\r\n {\r\n field = field.Where(b => b.X >= mouse.X && b.Y >= mouse.Y).ToList();\r\n if(!field.Any())\r\n {\r\n break;\r\n }\r\n field = field.OrderBy(b => b.X - mouse.X + b.Y - mouse.Y).ToList();\r\n if (!field.Any())\r\n {\r\n break;\r\n }\r\n mouse = field.First();\r\n field.RemoveAt(0);\r\n count++;\r\n }\r\n Console.WriteLine(count);\r\n Console.ReadLine();\r\n }\r\n\r\n class B\r\n {\r\n public int X { get; set; }\r\n public int Y { get; set; }\r\n }\r\n }\r\n}\r\n", "lang_cluster": "C#", "tags": ["greedy", "implementation", "shortest paths"], "code_uid": "422de284986e7283708fd13615fa25f9", "src_uid": "f985d7a6e7650a9b855a4cef26fd9b0d", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\r\nusing System.Collections.Generic;\r\nusing System.Linq;\r\nusing System.Text;\r\nusing System.Threading.Tasks;\r\n\r\nnamespace ConsoleApp1\r\n{\r\n\tclass Program\r\n\t{\r\n\t\tstatic void Main(string[] args)\r\n\t\t{\r\n\t\t\tvar st = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();\r\n\t\t\tvar height = st[0];\r\n\t\t\tvar width = st[1];\r\n\t\t\tvar field = new List(height);\r\n\t\t\tfor(var i =0; i < height; i++)\r\n\t\t\t{\r\n\t\t\t\tfield.Add(Console.ReadLine());\r\n\t\t\t}\r\n\t\t\tvar r = 0;\r\n\t\t\tvar c = 0;\r\n\t\t\tvar sum = field[r][c] == '*' ? 1:0;\r\n\t\t\twhile(r!= height -1 || c != width - 1)\r\n\t\t\t{\r\n\t\t\t\tvar rightWithStrawberry = c + 1 < width && field[r][c+1] == '*';\r\n\t\t\t\tvar downWithStrawberry = r + 1 < height && field[r+1][c] == '*';\r\n\t\t\t\tif (rightWithStrawberry)\r\n\t\t\t\t{\r\n\t\t\t\t\tc++;\r\n\t\t\t\t\tsum++;\r\n\t\t\t\t\tcontinue;\r\n\t\t\t\t}\r\n\t\t\t\tif (downWithStrawberry)\r\n\t\t\t\t{\r\n\t\t\t\t\tr++;\r\n\t\t\t\t\tsum++;\r\n\t\t\t\t\tcontinue;\r\n\t\t\t\t}\r\n\t\t\t\tif (c + 1 < width) c++;\r\n\t\t\t\telse r++;\r\n\t\t\t}\r\n\t\t\tConsole.WriteLine(sum);\r\n\t\t}\r\n\t}\r\n}\r\n", "lang_cluster": "C#", "tags": ["greedy", "implementation", "shortest paths"], "code_uid": "323acfe6e9ec0bbad2aba6352f1082d2", "src_uid": "f985d7a6e7650a9b855a4cef26fd9b0d", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Globalization;\nusing System.Linq;\nusing System.Text;\nusing System.Text.RegularExpressions;\nusing System.Threading;\n\nnamespace Codeforces\n{\n class A\n {\n private static ThreadStart s_threadStart = new A().Go;\n private static bool s_time = false;\n\n private void Go()\n {\n long k = GetInt();\n long b = GetInt();\n long n = GetInt();\n long t = GetInt();\n\n if (k == 1)\n {\n long x = (t - 1) / b;\n if (x > n)\n Wl(0);\n else\n Wl(n - x);\n return;\n }\n\n long xx = 1;\n while (xx <= t)\n {\n n--;\n xx = k * xx + b;\n }\n n++;\n if (n < 0) n = 0;\n Wl(n);\n return;\n\n }\n\n #region Template\n\n public static void Main(string[] args)\n {\n System.Diagnostics.Stopwatch timer = new System.Diagnostics.Stopwatch();\n Thread main = new Thread(new ThreadStart(s_threadStart), 512 * 1024 * 1024);\n timer.Start();\n main.Start();\n main.Join();\n timer.Stop();\n if (s_time)\n Wl(timer.ElapsedMilliseconds);\n }\n\n private static IEnumerator ioEnum;\n private static string GetString()\n {\n while (ioEnum == null || !ioEnum.MoveNext())\n {\n ioEnum = Console.ReadLine().Split().AsEnumerable().GetEnumerator();\n }\n\n return ioEnum.Current;\n }\n\n private static int GetInt()\n {\n return int.Parse(GetString());\n }\n\n private static long GetLong()\n {\n return long.Parse(GetString());\n }\n\n private static double GetDouble()\n {\n return double.Parse(GetString());\n }\n\n private static List GetIntArr(int n)\n {\n List ret = new List(n);\n for (int i = 0; i < n; i++)\n {\n ret.Add(GetInt());\n }\n return ret;\n }\n\n private static void Wl(T o)\n {\n if (o is double)\n {\n Wld((o as double?).Value, \"\");\n }\n else if (o is float)\n {\n Wld((o as float?).Value, \"\");\n }\n else\n Console.WriteLine(o.ToString());\n }\n\n private static void Wl(IEnumerable enumerable)\n {\n Wl(string.Join(\" \", enumerable.Select(e => e.ToString()).ToArray()));\n }\n\n private static void Wld(double d, string format)\n {\n Wl(d.ToString(format, CultureInfo.InvariantCulture));\n }\n\n public struct Tuple : IComparable>\n where T : IComparable\n where K : IComparable\n {\n public T Item1;\n public K Item2;\n\n public Tuple(T t, K k)\n {\n Item1 = t;\n Item2 = k;\n }\n\n public override bool Equals(object obj)\n {\n var o = (Tuple)obj;\n return o.Item1.Equals(Item1) && o.Item2.Equals(Item2);\n }\n\n public override int GetHashCode()\n {\n return Item1.GetHashCode() ^ Item2.GetHashCode();\n }\n\n public override string ToString()\n {\n return \"(\" + Item1 + \" \" + Item2 + \")\";\n }\n\n #region IComparable> Members\n\n public int CompareTo(Tuple other)\n {\n int ret = Item1.CompareTo(other.Item1);\n if (ret != 0) return ret;\n return Item2.CompareTo(other.Item2);\n }\n\n #endregion\n }\n\n #endregion\n }\n}", "lang_cluster": "C#", "tags": ["math", "implementation"], "code_uid": "eeae8fed1c34ba383769006341d8cc8f", "src_uid": "e2357a1f54757bce77dce625772e4f18", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\n\n\n\n\nnamespace CodeforcesVASYA\n{\n class Program\n {\n static void Main(string[] args)\n {\n \n \n String [] arr = Console.ReadLine().Split(' ');\n \n Int64 k=int.Parse(arr[0]);\n Int64 b=int.Parse(arr[1]);\n Int64 n=int.Parse(arr[2]);\n Int64 t=int.Parse(arr[3]);\n \n Int64 x=1;\n \n for (n=n; n>0; )\n {\n \n x=k*x+b;\n \n if(x>t)\n {\n\n break;\n }\n else\n {\n n--;\n }\n \n \n \n \n }\n \n Console.WriteLine(n);\n \n \n\n \n \n \n }\n }\n\n}", "lang_cluster": "C#", "tags": ["math"], "code_uid": "75b92ad29e430e9deb19456beb85700b", "src_uid": "e2357a1f54757bce77dce625772e4f18", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Linq;\nusing System.Collections.Generic;\nusing Debug = System.Diagnostics.Debug;\nusing StringBuilder = System.Text.StringBuilder;\nusing Number = System.Boolean;\nnamespace Program\n{\n public class Solver\n {\n\n public void Solve()\n {\n var n = sc.Integer();\n var s = sc.Scan();\n var X = new List();\n var Y = new List();\n var Z = new List();\n for (int i = 0; i < n; i++)\n {\n var c = s[i];\n if (c == 'V') { X.Add(i); }\n else if (c == 'K') { Y.Add(i); }\n else { Z.Add(i); }\n }\n var x = X.Count; var y = Y.Count; var z = Z.Count;\n X.Add(n + 1000000); Y.Add(n + 1000000); Z.Add(n + 1000000);\n var D = new List[] { X, Y, Z };\n var dp = new int[x + 2, y + 2, 2];\n for (int i = 0; i < x + 2; i++)\n for (int j = 0; j < y + 2; j++)\n for (int k = 0; k < 2; k++)\n dp[i, j, k] = 1000000;\n dp[0, 0, 0] = 0;\n for (int pos = 0; pos < n; pos++)\n {\n var next = new int[x + 2, y + 2, 2];\n for (int i = 0; i < x + 2; i++)\n for (int j = 0; j < y + 2; j++)\n for (int k = 0; k < 2; k++)\n next[i, j, k] = 1000000;\n for (int a = 0; a < x + 1; a++)\n for (int b = 0; b < y + 1; b++)\n {\n var c = pos - a - b;\n if (c < 0) continue;\n if (c > z) continue;\n var vec = new int[] { a, b, c };\n for (int k = 0; k < 2; k++)\n {\n if (dp[a, b, k] >= 1000000) continue;\n next[a + 1, b, 1] = Math.Min(next[a + 1, b, 1], dp[a, b, k] + d(X[a], 0, vec, D));\n if (k != 1)\n next[a, b + 1, 0] = Math.Min(next[a, b + 1, 0], dp[a, b, k] + d(Y[b], 1, vec, D));\n next[a, b, 0] = Math.Min(next[a, b, 0], dp[a, b, k] + d(Z[c], 2, vec, D));\n }\n }\n dp = next;\n }\n IO.Printer.Out.WriteLine(Math.Min(dp[x, y, 0], dp[x, y, 1]));\n\n }\n int d(int p, int k, int[] P, List[] D)\n {\n var v = 0;\n for (int i = 0; i < 3; i++)\n {\n if (i == k) continue;\n for (int j = 0; j < P[i]; j++)\n if (p < D[i][j]) v++;\n }\n return v;\n }\n\n public IO.StreamScanner sc = new IO.StreamScanner(Console.OpenStandardInput());\n static T[] Enumerate(int n, Func f) { var a = new T[n]; for (int i = 0; i < n; ++i) a[i] = f(i); return a; }\n static public void Swap(ref T a, ref T b) { var tmp = a; a = b; b = tmp; }\n }\n}\n\n#region main\nstatic class Ex\n{\n static public string AsString(this IEnumerable ie) { return new string(System.Linq.Enumerable.ToArray(ie)); }\n static public string AsJoinedString(this IEnumerable ie, string st = \" \") { return string.Join(st, ie); }\n static public void Main()\n {\n var solver = new Program.Solver();\n solver.Solve();\n Program.IO.Printer.Out.Flush();\n }\n}\n#endregion\n#region Ex\nnamespace Program.IO\n{\n using System.IO;\n using System.Text;\n using System.Globalization;\n public class Printer: StreamWriter\n {\n static Printer() { Out = new Printer(Console.OpenStandardOutput()) { AutoFlush = false }; }\n public static Printer Out { get; set; }\n public override IFormatProvider FormatProvider { get { return CultureInfo.InvariantCulture; } }\n public Printer(System.IO.Stream stream) : base(stream, new UTF8Encoding(false, true)) { }\n public Printer(System.IO.Stream stream, Encoding encoding) : base(stream, encoding) { }\n public void Write(string format, T[] source) { base.Write(format, source.OfType().ToArray()); }\n public void WriteLine(string format, T[] source) { base.WriteLine(format, source.OfType().ToArray()); }\n }\n public class StreamScanner\n {\n public StreamScanner(Stream stream) { str = stream; }\n public readonly Stream str;\n private readonly byte[] buf = new byte[1024];\n private int len, ptr;\n public bool isEof = false;\n public bool IsEndOfStream { get { return isEof; } }\n private byte read()\n {\n if (isEof) return 0;\n if (ptr >= len) { ptr = 0; if ((len = str.Read(buf, 0, 1024)) <= 0) { isEof = true; return 0; } }\n return buf[ptr++];\n }\n public char Char() { byte b = 0; do b = read(); while ((b < 33 || 126 < b) && !isEof); return (char)b; }\n\n public string Scan()\n {\n var sb = new StringBuilder();\n for (var b = Char(); b >= 33 && b <= 126; b = (char)read())\n sb.Append(b);\n return sb.ToString();\n }\n public string ScanLine()\n {\n var sb = new StringBuilder();\n for (var b = Char(); b != '\\n'; b = (char)read())\n if (b == 0) break;\n else if (b != '\\r') sb.Append(b);\n return sb.ToString();\n }\n public long Long()\n {\n if (isEof) return long.MinValue;\n long ret = 0; byte b = 0; var ng = false;\n do b = read();\n while (b != 0 && b != '-' && (b < '0' || '9' < b));\n if (b == 0) return long.MinValue;\n if (b == '-') { ng = true; b = read(); }\n for (; true; b = read())\n {\n if (b < '0' || '9' < b)\n return ng ? -ret : ret;\n else ret = ret * 10 + b - '0';\n }\n }\n public int Integer() { return (isEof) ? int.MinValue : (int)Long(); }\n public double Double() { var s = Scan(); return s != \"\" ? double.Parse(s, CultureInfo.InvariantCulture) : double.NaN; }\n private T[] enumerate(int n, Func f)\n {\n var a = new T[n];\n for (int i = 0; i < n; ++i) a[i] = f();\n return a;\n }\n\n public char[] Char(int n) { return enumerate(n, Char); }\n public string[] Scan(int n) { return enumerate(n, Scan); }\n public double[] Double(int n) { return enumerate(n, Double); }\n public int[] Integer(int n) { return enumerate(n, Integer); }\n public long[] Long(int n) { return enumerate(n, Long); }\n }\n}\n#endregion\n\n", "lang_cluster": "C#", "tags": ["dp"], "code_uid": "086a94d1bbe358404d2b44d838a37fdd", "src_uid": "08444f9ab1718270b5ade46852b155d7", "difficulty": 2500.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Linq;\nusing System.Collections.Generic;\nusing System.Numerics;\nusing Debug = System.Diagnostics.Debug;\nusing SB = System.Text.StringBuilder;\nusing Number = System.Int64;\nusing KV = System.Collections.Generic.KeyValuePair;\nnamespace Program {\n public class Solver {\n public void Solve() {\n var k = ri;\n var pa = ri;\n var pb = ri;\n var p = pa * ModInt.Inverse(pa + pb);\n\n var q = pb * ModInt.Inverse(pa + pb);\n var invq = ModInt.Inverse(q);\n var dp = new ModInt[k + 5, k + 5];\n for (int i = 0; i < k + 5; i++)\n for (int j = 0; j < k + 5; j++)\n dp[i, j].num = -1;\n Func dfs = null;\n dfs = (a, cnt) => {\n if (cnt >= k) return cnt;\n if (a + cnt >= k) {\n return cnt + a + invq - 1;\n }\n if (dp[a, cnt].num != -1) return dp[a, cnt];\n ModInt ret = new ModInt(0);\n // a \u3092\u51fa\u3059\n ret += p * dfs(a + 1, cnt);\n // b \u3092\u51fa\u3059\n ret += q * dfs(a, cnt + a);\n\n return dp[a, cnt] = ret;\n };\n Console.WriteLine(dfs(1, 0));\n\n }\n const long INF = 1L << 60;\n int[] dx = { -1, 0, 1, 0 };\n int[] dy = { 0, 1, 0, -1 };\n\n int ri { get { return sc.Integer(); } }\n long rl { get { return sc.Long(); } }\n double rd { get { return sc.Double(); } }\n string rs { get { return sc.Scan(); } }\n public IO.StreamScanner sc = new IO.StreamScanner(Console.OpenStandardInput());\n\n static T[] Enumerate(int n, Func f) {\n var a = new T[n];\n for (int i = 0; i < n; ++i) a[i] = f(i);\n return a;\n }\n\n static public void Swap(ref T a, ref T b) {\n var tmp = a;\n a = b;\n b = tmp;\n }\n }\n}\n\n#region main\n\nstatic class Ex {\n static public string AsString(this IEnumerable ie) {\n return new string(ie.ToArray());\n }\n\n static public string AsJoinedString(this IEnumerable ie, string st = \" \") {\n return string.Join(st, ie.Select(x => x.ToString()).ToArray());\n //return string.Join(st, ie);\n }\n\n static public void Main() {\n Console.SetOut(new Program.IO.Printer(Console.OpenStandardOutput()) { AutoFlush = false });\n var solver = new Program.Solver();\n solver.Solve();\n Console.Out.Flush();\n }\n}\n\n#endregion\n#region Ex\n\nnamespace Program.IO {\n using System.IO;\n using System.Text;\n using System.Globalization;\n\n public class Printer: StreamWriter {\n public override IFormatProvider FormatProvider {\n get { return CultureInfo.InvariantCulture; }\n }\n public Printer(Stream stream) : base(stream, new UTF8Encoding(false, true)) { }\n }\n\n public class StreamScanner {\n public StreamScanner(Stream stream) {\n str = stream;\n }\n\n public readonly Stream str;\n private readonly byte[] buf = new byte[1024];\n private int len, ptr;\n public bool isEof = false;\n public bool IsEndOfStream {\n get { return isEof; }\n }\n\n private byte read() {\n if (isEof) return 0;\n if (ptr >= len) {\n ptr = 0;\n if ((len = str.Read(buf, 0, 1024)) <= 0) {\n isEof = true;\n return 0;\n }\n }\n return buf[ptr++];\n }\n\n public char Char() {\n byte b = 0;\n do b = read(); while ((b < 33 || 126 < b) && !isEof);\n return (char)b;\n }\n\n public string Scan() {\n var sb = new StringBuilder();\n for (var b = Char(); b >= 33 && b <= 126; b = (char)read()) sb.Append(b);\n return sb.ToString();\n }\n\n public string ScanLine() {\n var sb = new StringBuilder();\n for (var b = Char(); b != '\\n' && b != 0; b = (char)read()) if (b != '\\r') sb.Append(b);\n return sb.ToString();\n }\n\n public long Long() {\n return isEof ? long.MinValue : long.Parse(Scan());\n }\n\n public int Integer() {\n return isEof ? int.MinValue : int.Parse(Scan());\n }\n\n public double Double() {\n return isEof ? double.NaN : double.Parse(Scan(), CultureInfo.InvariantCulture);\n }\n }\n}\n\n#endregion\n\n\n#region ModInt\npublic struct ModInt {\n public const long Mod = (long)1e9 + 7;\n public long num;\n public ModInt(long n) { num = n; }\n public override string ToString() { return num.ToString(); }\n public static ModInt operator +(ModInt l, ModInt r) { l.num += r.num; if (l.num >= Mod) l.num -= Mod; return l; }\n public static ModInt operator -(ModInt l, ModInt r) { l.num -= r.num; if (l.num < 0) l.num += Mod; return l; }\n public static ModInt operator *(ModInt l, ModInt r) { return new ModInt((int)(l.num * r.num % Mod)); }\n public static implicit operator ModInt(long n) { n %= Mod; if (n < 0) n += Mod; return new ModInt(n); }\n public static ModInt Pow(ModInt v, long k) { return Pow(v.num, k); }\n public static ModInt Pow(long v, long k) {\n long ret = 1;\n for (k %= Mod - 1; k > 0; k >>= 1, v = v * v % Mod)\n if ((k & 1) == 1) ret = ret * v % Mod;\n return new ModInt(ret);\n }\n public static ModInt Inverse(ModInt v) { return Pow(v, Mod - 2); }\n}\n#endregion", "lang_cluster": "C#", "tags": ["math", "dp", "probabilities"], "code_uid": "b0805bd082436dcf3eb9141d0c556132", "src_uid": "0dc9f5d75143a2bc744480de859188b4", "difficulty": 2200.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Collections;\nusing System.Text;\n\nnamespace codeforces\n{\n\n public class Program\n {\n private const int MOD = 1000 * 1000 * 1000 + 7;\n private const int NMax = 1000;\n\n private static int k;\n private static int pA;\n private static int pB;\n private static int ipB;\n private static int[,] dp = new int[NMax, NMax];\n private static bool[,] marked = new bool[NMax, NMax];\n\n private static int Add(int a, int b)\n {\n a += b;\n if (a >= MOD)\n {\n a -= MOD;\n }\n return a;\n }\n\n private static int Mult(int a, int b)\n {\n return (int)(1L * a * b % MOD);\n }\n\n private static int BinPow(int a, int n)\n {\n int result = 1;\n while (n > 0)\n {\n if (n % 2 == 1)\n {\n result = Mult(result, a);\n }\n a = Mult(a, a);\n n /= 2;\n }\n return result;\n }\n\n private static int Solve(int count, int tk)\n {\n if (tk >= k)\n {\n return tk;\n }\n if (count + tk >= k)\n {\n return Add(Add(count, tk), ipB);\n }\n if (marked[count, tk])\n {\n return dp[count, tk];\n }\n marked[count, tk] = true;\n dp[count, tk] = Add(Mult(Solve(count + 1, tk), pA), Mult(Solve(count, tk + count), pB));\n return dp[count, tk];\n }\n\n private static void Main(string[] args)\n {\n var values = Console.ReadLine().Split(' ');\n k = Convert.ToInt32(values[0]);\n int pa = Convert.ToInt32(values[1]);\n int pb = Convert.ToInt32(values[2]);\n pA = Mult(pa, BinPow(Add(pa, pb), MOD - 2));\n pB = Mult(pb, BinPow(Add(pa, pb), MOD - 2));\n ipB = Mult(pa, BinPow(pb, MOD - 2));\n Console.WriteLine(Solve(1, 0));\n }\n }\n}", "lang_cluster": "C#", "tags": ["math", "dp", "probabilities"], "code_uid": "21802881172b201f6d5e7890f6879796", "src_uid": "0dc9f5d75143a2bc744480de859188b4", "difficulty": 2200.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Globalization;\nusing System.IO;\nusing System.Text;\n\nnamespace Ilya_and_Escalator\n{\n internal class Program\n {\n private static readonly StreamReader reader = new StreamReader(Console.OpenStandardInput(1024*10), Encoding.ASCII, false, 1024*10);\n private static readonly StreamWriter writer = new StreamWriter(Console.OpenStandardOutput(1024*10), Encoding.ASCII, 1024*10);\n\n private static void Main(string[] args)\n {\n string[] ss = reader.ReadLine().Split(' ');\n int n = int.Parse(ss[0]);\n int t = int.Parse(ss[2]);\n double p = double.Parse(ss[1], CultureInfo.InvariantCulture);\n double q = 1 - p;\n var nn = new double[n + 1];\n nn[0] = 1;\n\n for (int i = 0; i < t; i++)\n {\n nn[n] += p*nn[n - 1];\n\n for (int j = n - 1; j > 0; j--)\n {\n nn[j] = q*nn[j] + p*nn[j - 1];\n }\n\n nn[0] *= q;\n }\n\n double sum = 0;\n\n for (int i = 1; i <= n; i++)\n {\n sum += i*nn[i];\n }\n\n writer.WriteLine(sum.ToString(\"#0.0000000\", CultureInfo.InvariantCulture));\n writer.Flush();\n }\n }\n}", "lang_cluster": "C#", "tags": ["probabilities", "math", "dp", "combinatorics"], "code_uid": "bcd96c1de8868ec400ab51ccdca4242c", "src_uid": "20873b1e802c7aa0e409d9f430516c1e", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeff// using a C# contest template, relevant code is at the bottom in the Run() function\n\nusing System;\nusing System.Collections.Generic;\nusing System.Globalization;\nusing System.IO;\nusing System.Linq;\nusing System.Text;\n\nclass ProblemD {\n static string inputFileName = \"../../input.txt\";\n static StreamReader fileReader;\n static string[] inputTokens;\n static int curInputTokenIndex;\n static bool isLocal = Type.GetType(\"HaitaoLocal\") != null;\n static string NextToken() {\n string ret = \"\";\n while (ret == \"\") {\n if (inputTokens == null || curInputTokenIndex >= inputTokens.Length) {\n string line;\n if (isLocal) {\n line = fileReader.ReadLine();\n if (line == null) {\n throw new Exception(\"Error: out of input tokens!\");\n }\n } else {\n line = Console.ReadLine();\n }\n inputTokens = line.Split();\n curInputTokenIndex = 0;\n }\n ret = inputTokens[curInputTokenIndex++];\n }\n return ret;\n }\n static int ri { get { return RI(); } }\n static string rs { get { return RS(); } }\n static long rl { get { return RL(); } }\n static double rd { get { return RD(); } }\n static int RI() {\n return Int32.Parse(NextToken());\n }\n static string RS() {\n return NextToken();\n }\n static long RL() {\n return Int64.Parse(NextToken());\n }\n static double RD() {\n return Double.Parse(NextToken());\n }\n static int[] RIA(int length) {\n int[] ret = new int[length];\n for (int i = 0; i < length; i++) {\n ret[i] = RI();\n }\n return ret;\n }\n static string[] RSA(int length) {\n string[] ret = new string[length];\n for (int i = 0; i < length; i++) {\n ret[i] = RS();\n }\n return ret;\n }\n static long[] RLA(int length) {\n long[] ret = new long[length];\n for (int i = 0; i < length; i++) {\n ret[i] = RL();\n }\n return ret;\n }\n static double[] RDA(int length) {\n double[] ret = new double[length];\n for (int i = 0; i < length; i++) {\n ret[i] = RD();\n }\n return ret;\n }\n static StringBuilder outputBuilder;\n static CultureInfo outputCulture = new CultureInfo(\"en-US\");\n static void Out(object obj) {\n Type type = obj.GetType();\n string str = obj.ToString();\n if (type == typeof(double) || type == typeof(float)) {\n str = ((double)obj).ToString(outputCulture);\n }\n outputBuilder.Append(str + \" \");\n }\n static void Outl() {\n Outl(\"\");\n }\n static void Outl(object obj) {\n Out(obj);\n outputBuilder.Append(\"\\n\");\n }\n static void Flush() {\n if (isLocal) {\n ConsoleColor t = Console.ForegroundColor;\n Console.ForegroundColor = ConsoleColor.Green;\n Console.WriteLine();\n Console.WriteLine(outputBuilder.ToString());\n Console.ForegroundColor = t;\n } else {\n Console.WriteLine(outputBuilder.ToString());\n }\n outputBuilder = new StringBuilder();\n }\n static void Log(string label, object obj) {\n if (!isLocal) return;\n\n ConsoleColor t = Console.ForegroundColor;\n Console.ForegroundColor = ConsoleColor.Gray;\n Console.Write(label + \": \");\n Console.ForegroundColor = t;\n Log(obj);\n }\n static void Log(object obj) {\n if (!isLocal) return;\n\n ConsoleColor t = Console.ForegroundColor;\n Console.ForegroundColor = ConsoleColor.White;\n Console.WriteLine(ToStringRecursive(obj));\n Console.ForegroundColor = t;\n }\n static string ToStringRecursive(object obj) {\n StringBuilder sb = new StringBuilder();\n if (!(obj is string) && (obj is System.Collections.IEnumerable)) {\n System.Collections.IEnumerable en = obj as System.Collections.IEnumerable;\n sb.Append(\"{\");\n bool first = true;\n foreach (object el in en) {\n if (!first) sb.Append(\", \");\n sb.Append(ToStringRecursive(el));\n first = false;\n }\n sb.Append(\"}\");\n return sb.ToString();\n }\n return obj.ToString();\n }\n\n public static void Main(string[] args) {\n long startTick = 0;\n if (isLocal) {\n startTick = Environment.TickCount;\n fileReader = new StreamReader(inputFileName);\n }\n\n outputBuilder = new StringBuilder();\n Run();\n if (isLocal) {\n ConsoleColor t = Console.ForegroundColor;\n Console.ForegroundColor = ConsoleColor.Green;\n Console.WriteLine();\n Console.WriteLine(outputBuilder.ToString());\n Console.WriteLine();\n Console.ForegroundColor = t;\n } else {\n Console.WriteLine(outputBuilder.ToString());\n }\n\n if (isLocal) {\n long runTime = Environment.TickCount - startTick;\n if (runTime > 32) {\n Log(\"time\", runTime);\n Log(\"\");\n }\n }\n }\n\n\n\n static void Run() {\n long n = rl;\n long ans = 0;\n if(n==2) {\n ans = 1;\n } else if(n==3) {\n ans = 3;\n } else if(n==4) {\n ans = 6; \n } else {\n long l = 9;\n while(f(l*10+9, n)>0) {\n l = l * 10 + 9;\n }\n Log(\"l \" + l);\n for(int a=0; a<=9; a++) {\n ans += f(a * (l+1) + l, n);\n Log(ans);\n }\n }\n Outl(ans);\n }\n\n static long f(long a, long b) {\n if (b + b < a) return 0;\n if (b >= a) return f(a, a-1);\n return b - a/2;\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "constructive algorithms"], "code_uid": "7f4e88ef95864ec2b73223a38f26b618", "src_uid": "c20744c44269ae0779c5f549afd2e3f2", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\n\nnamespace ConsoleApp4\n{\n class Program\n {\n static void Main(string[] args)\n {\n UInt64 n = UInt64.Parse(Console.ReadLine());\n UInt64 sum = n + (n - 1);\n UInt64 result = 0;\n if (n <= 4)\n result = (n - 1) * n / 2;\n else\n {\n char[] bad = { '0', '1', '2', '3', '4', '5', '6', '7', '8' };\n if (sum.ToString().IndexOfAny(bad) == -1)\n result = 1;\n else\n {\n UInt64 count = (UInt64)sum.ToString().Length;\n string devt = \"\";\n for (UInt64 i = 0; i < count - 1; i++)\n devt += \"9\";\n for (int i = 0; i < 9; i++)\n {\n UInt64 curent = UInt64.Parse(i.ToString() + devt);\n if (curent <= (n + 1))\n result += (curent / 2);\n else if (!(curent > n + (n - 1)))\n result += ((n - (curent - n)) / 2 + 1);\n }\n }\n }\n Console.WriteLine(result);\n }\n }\n}", "lang_cluster": "C#", "tags": ["math", "constructive algorithms"], "code_uid": "0018410149de2dd787185b99c91df821", "src_uid": "c20744c44269ae0779c5f549afd2e3f2", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.IO;\nusing System.Linq;\nclass Solution{\n\t static void Main(string[] args) {\n const int MOD = 1000000007;\n int n = int.Parse(Console.ReadLine());\n int[] a = Array.ConvertAll(Console.ReadLine().Split(' '), x => Convert.ToInt32(x));\n C = new long[200, 200];\n C[0, 0] = 1;\n for (int i = 1; i < 200; i++) {\n C[i, 0] = C[i, i] = 1;\n for (int j = 1; j <= i; j++)\n C[i, j] = (C[i - 1, j] + C[i - 1, j - 1]) % MOD;\n }\n\n long ans = 0;\n for (int k = a.Sum(); k <= n; k++) {\n\n long[,] dp = new long[110, 30];\n dp[k, 0] = 1;\n\n for (int j = 0; j < 10; j++)\n for (int i = a[j]; i <= k; i++)\n for (int l = a[j]; l <= i; l++) {\n if (j == 0) dp[i - l, j + 1] = (dp[i - l, j + 1] + dp[i, j] * CNK(i - 1, l) % MOD) % MOD;\n else dp[i - l, j + 1] = (dp[i - l, j + 1] + dp[i, j] * CNK(i, l) % MOD) % MOD;\n }\n\n ans += dp[0, 10];\n ans %= MOD;\n }\n\n Console.WriteLine(ans);\n\t }\n static long[,] C;\n static long CNK(long n, long k) {\n if (k > n || k < 0) return 0;\n if (k == n || k == 0) return 1;\n return C[n, k];\n }\n}", "lang_cluster": "C#", "tags": ["dp", "combinatorics"], "code_uid": "bf91527e39bc549048a85ee137dfe4a1", "src_uid": "c1b5169a5c3b1bd4a2f1df1069ee7755", "difficulty": 1900.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "//\n\nusing System;\nusing System.Collections.Generic;\nusing System.Text;\nusing System.IO;\nusing System.Threading;\nusing System.Diagnostics;\nusing System.Globalization;\nusing System.Text.RegularExpressions;\nusing System.Linq;\n\nnamespace sar_cs\n{\n static class Helpers\n {\n // Mono lacks this override of string.Join()\n public static string Join(this IEnumerable objs, string sep)\n {\n var sb = new StringBuilder();\n foreach (var s in objs) { if (sb.Length != 0) sb.Append(sep); sb.Append(s); }\n return sb.ToString();\n }\n\n public static string AsString(this double a, int digits)\n {\n return a.ToString(\"F\" + digits, CultureInfo.InvariantCulture);\n }\n\n public static Stopwatch SW = Stopwatch.StartNew();\n }\n\n public class Program\n {\n #region Helpers\n\n public class Parser\n {\n const int BufSize = 8000;\n TextReader s;\n char[] buf = new char[BufSize];\n int bufPos;\n int bufDataSize;\n bool eos; // eos read to buffer\n int lastChar = -2;\n int nextChar = -2;\n StringBuilder sb = new StringBuilder();\n\n void FillBuf()\n {\n if (eos) return;\n bufDataSize = s.Read(buf, 0, BufSize);\n if (bufDataSize == 0) eos = true;\n bufPos = 0;\n }\n\n int Read()\n {\n if (nextChar != -2)\n {\n lastChar = nextChar;\n nextChar = -2;\n }\n else\n {\n if (bufPos == bufDataSize) FillBuf();\n if (eos) lastChar = -1;\n else lastChar = buf[bufPos++];\n }\n return lastChar;\n }\n\n void Back()\n {\n if (lastChar == -2) throw new Exception(); // no chars were ever read\n nextChar = lastChar;\n }\n\n public Parser()\n {\n s = Console.In;\n }\n\n public int ReadInt()\n {\n int res = 0;\n int sign = -1;\n int c;\n do { c = Read(); } while (c >= 0 && char.IsWhiteSpace((char)c));\n if (c == '-') { sign = 1; c = Read(); }\n int len = 0;\n while (c >= 0 && !char.IsWhiteSpace((char)c))\n {\n if ((uint)(c -= 48) >= 10) throw new FormatException();\n len++;\n res = checked(res * 10 - c);\n c = Read();\n }\n if (len == 0) throw new FormatException();\n Back();\n return checked(res * sign);\n }\n\n public long ReadLong()\n {\n long res = 0;\n int sign = -1;\n int c;\n do { c = Read(); } while (c >= 0 && char.IsWhiteSpace((char)c));\n if (c == '-')\n {\n sign = 1;\n c = Read();\n }\n int len = 0;\n\n while (c >= 0 && !char.IsWhiteSpace((char)c))\n {\n if ((uint)(c -= 48) >= 10) throw new FormatException();\n len++;\n res = checked(res * 10 - c);\n c = Read();\n }\n if (len == 0) throw new FormatException();\n Back();\n return checked(res * sign);\n }\n\n public int ReadLnInt()\n {\n int res = ReadInt(); ReadLine(); return res;\n }\n\n public long ReadLnLong()\n {\n long res = ReadLong(); ReadLine(); return res;\n }\n\n public double ReadDouble()\n {\n int c;\n do { c = Read(); } while (c >= 0 && char.IsWhiteSpace((char)c));\n\n int sign = 1;\n if (c == '-') { sign = -1; c = Read(); }\n\n sb.Length = 0;\n while (c >= 0 && !char.IsWhiteSpace((char)c))\n {\n sb.Append((char)c); c = Read();\n }\n\n Back();\n var res = double.Parse(sb.ToString(), CultureInfo.InvariantCulture);\n return res * sign;\n }\n\n public string ReadLine()\n {\n int c = Read();\n sb.Length = 0;\n while (c != -1 && c != 13 && c != 10)\n {\n sb.Append((char)c); c = Read();\n }\n if (c == 13) { c = Read(); if (c != 10) Back(); }\n return sb.ToString();\n }\n\n public bool SeekEOF\n {\n get\n {\n L0:\n int c = Read();\n if (c == -1) return true;\n if (char.IsWhiteSpace((char)c)) goto L0;\n Back();\n return false;\n }\n }\n\n public int[] ReadIntArr(int n)\n {\n var a = new int[n]; for (int i = 0; i < n; i++) a[i] = ReadInt(); return a;\n }\n\n public long[] ReadLongArr(int n)\n {\n var a = new long[n]; for (int i = 0; i < n; i++) a[i] = ReadLong(); return a;\n }\n }\n\n static void pe() { Console.WriteLine(\"???\"); Environment.Exit(0); }\n static void re() { Environment.Exit(55); }\n static void Swap(ref T a, ref T b) { T t = a; a = b; b = t; }\n static int Sqr(int a) { return a * a; }\n static long SqrL(int a) { return (long)a * a; }\n static long Sqr(long a) { return a * a; }\n static double Sqr(double a) { return a * a; }\n\n static StringBuilder sb = new StringBuilder();\n static Random rand = new Random(5);\n\n #endregion Helpers\n\n static int[] minQ;\n\n const int M = 1000000007;\n\n static int[,] C = GetCountModTable(100, 100, M);\n\n static public int[,] GetCountModTable(int maxN, int maxK, int Mod)\n {\n if (maxN < 0 || maxK < 0) throw new ArgumentException();\n if (Mod > int.MaxValue / 2) throw new ArgumentOutOfRangeException();\n var result = new int[maxN + 1, maxK + 1];\n for (int n = 0; n <= maxN; n++)\n for (int k = 0; k <= maxK; k++)\n if (k == 0) result[n, k] = 1;\n else if (n == 0) result[n, k] = 0;\n else result[n, k] = (result[n - 1, k] + result[n, k - 1]) % Mod;\n return result;\n }\n\n static int[,] fcache;\n\n static long f(int n, int d)\n {\n checked\n {\n //if (d == 10) return n == 0 ? 1 : 0;\n if (n < minQ[d]) return 0;\n //if (n == 0) return 0;\n\n if (n == 0 || d > 9) throw new Exception();\n\n if (fcache[n, d] != 0) return fcache[n, d] - 1;\n\n long result = 0;\n for (int i = minQ[d]; i <= n; i++)\n {\n long t1;\n\n if (i == 0)\n {\n if (d == 9) t1 = n == 0 ? 1 : 0;\n else t1 = f(n, d + 1);\n }\n else if (i == n)\n {\n if (minQ.Skip(d + 1).Any(q => q > 0)) t1 = 0;\n else if (d == 0 && i > 1) t1 = 0;\n else t1 = 1;\n }\n else\n {\n if (d == 9)\n t1 = 0;\n else\n {\n t1 = f(n - i, d + 1);\n var t2 = d == 0 ? C[n - i, i] : C[n - i + 1, i];\n t1 *= t2;\n }\n }\n\n t1 %= M;\n result = (result + t1) % M;\n }\n\n fcache[n, d] = (int)result + 1;\n return result;\n }\n }\n\n static void Main(string[] args)\n {\n checked\n {\n //Console.SetIn(File.OpenText(\"_input\"));\n var parser = new Parser();\n while (!parser.SeekEOF)\n {\n int n = parser.ReadInt();\n minQ = parser.ReadIntArr(10);\n\n //for (int i = 100; i <= 999; i++) if (i.ToString().Contains('0') && i.ToString().Contains('1')) Console.WriteLine(i);\n //Console.WriteLine(\"\");\n\n //Console.WriteLine(f(3, 0));\n\n //for (int d = 0; d <= 9; d++)\n //{\n // Console.Write(\"d=\" + d + \": \");\n // for (int i = 1; i <= n; i++)\n // Console.Write(f(i, d) + \" \");\n // Console.WriteLine();\n //}\n\n fcache = new int[101, 10];\n long result = 0;\n for (int i = 1; i <= n; i++)\n result = (result + f(i, 0)) % M;\n\n if (minQ[0] <= 1 && minQ.Skip(1).All(q => q == 0)) result--;\n\n Console.WriteLine(result);\n }\n }\n }\n\n //static void Main(string[] args)\n //{\n // new Thread(Main2, 50 << 20).Start();\n //}\n }\n}", "lang_cluster": "C#", "tags": ["math", "dp", "combinatorics"], "code_uid": "1ce0e99e8e0e1910bfa9aef48885e63f", "src_uid": "c1b5169a5c3b1bd4a2f1df1069ee7755", "difficulty": 1900.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Linq;\nusing CompLib.Util;\nusing System.Threading;\nusing CompLib.Mathematics;\nusing CompLib.String;\n\npublic class Program\n{\n int N;\n string S;\n public void Solve()\n {\n var sc = new Scanner();\n N = sc.NextInt();\n S = sc.Next();\n\n int cnt = 0;\n int min = 0;\n foreach (var c in S)\n {\n if (c == '(') cnt++;\n else cnt--;\n min = Math.Min(min, cnt);\n }\n /*\n * S\u3092\u90e8\u5206\u6587\u5b57\u5217\u306b\u542b\u3080\u30ab\u30c3\u30b3\u5217\u306e\u500b\u6570\n */\n\n // i\u3067\u9593\u9055\u3048\u305f\u3068\u304d\u3069\u3053\u306b\u98db\u3076\u304b?\n int[] next = new int[S.Length];\n for (int i = 0; i < S.Length; i++)\n {\n if (i == 0)\n {\n next[i] = 0;\n continue;\n }\n\n bool f2 = false;\n for (int len = i; len >= 1; len--)\n {\n bool f = true;\n for (int j = 0; f && j < len - 1; j++)\n {\n f &= S[j] == S[i - len + 1 + j];\n }\n if (!f) continue;\n if (S[len - 1] != S[i])\n {\n next[i] = len;\n f2 = true;\n break;\n }\n }\n\n }\n\n // i\u6587\u5b57\u76ee\u307e\u3067\u4f5c\u308b\u3001\u30ab\u30a6\u30f3\u30bf\u3001S\u3088\u308a\u524d\u3001S\u3088\u308a\u5f8c, S\u306e\u4f55\u6587\u5b57\u307e\u3067\u3067\u304d\u305f\u304b?\n var dp = new ModInt[2 * N + 1, N + 1, S.Length, 2];\n dp[0, 0, 0, 0] = 1;\n for (int i = 0; i < 2 * N; i++)\n {\n for (int j = 0; j <= N; j++)\n {\n for (int k = 0; k < S.Length; k++)\n {\n // (\n if (j + 1 <= N)\n {\n if (S[k] == '(')\n {\n if (k + 1 == S.Length)\n {\n dp[i + 1, j + 1, 0, 1] += dp[i, j, k, 0];\n }\n else\n {\n dp[i + 1, j + 1, k + 1, 0] += dp[i, j, k, 0];\n }\n }\n else\n {\n // \u3069\u3053\u306b\u98db\u3076\n dp[i + 1, j + 1, next[k], 0] += dp[i, j, k, 0];\n }\n\n\n }\n\n if (j - 1 >= 0)\n {\n if (S[k] == ')')\n {\n if (k + 1 == S.Length)\n {\n dp[i + 1, j - 1, 0, 1] += dp[i, j, k, 0];\n }\n else\n {\n dp[i + 1, j - 1, k + 1, 0] += dp[i, j, k, 0];\n }\n }\n else\n {\n dp[i + 1, j - 1, next[k], 0] += dp[i, j, k, 0];\n }\n\n }\n }\n\n if (j + 1 <= N)\n {\n dp[i + 1, j + 1, 0, 1] += dp[i, j, 0, 1];\n }\n if (j - 1 >= 0)\n {\n dp[i + 1, j - 1, 0, 1] += dp[i, j, 0, 1];\n }\n }\n }\n\n Console.WriteLine(dp[2 * N, 0, 0, 1]);\n }\n\n public static void Main(string[] args) => new Program().Solve();\n // public static void Main(string[] args) => new Thread(new Program().Solve, 1 << 27).Start();\n}\n\n\nnamespace CompLib.String\n{\n using System;\n using System.Collections.Generic;\n using System.Diagnostics;\n public static partial class StringACL\n {\n private const int ThresholdNative = 10;\n private const int ThresholdDoubling = 40;\n\n #region SuffixArray\n public static int[] SuffixArray(int[] s, int upper)\n {\n Debug.Assert(0 <= upper);\n\n // C++\u307f\u305f\u3044\u306b\u5185\u90e8\u3067\u4f55\u3082\u3057\u306a\u3044\u30eb\u30fc\u30d7\u3092\u30b9\u30ad\u30c3\u30d7\u3059\u308b\u306e\u304b?\n // \u3057\u3066\u304f\u308c\u308b\u306a\u3089 #if\u3044\u3089\u306a\u3044\n#if DEBUG\n foreach (var d in s)\n {\n Debug.Assert(0 <= d && d <= upper);\n }\n#endif\n return SAIS(s, upper);\n }\n\n public static int[] SuffixArray(T[] s, Comparison cmp)\n {\n int n = s.Length;\n int[] idx = new int[n];\n for (int i = 0; i < n; i++)\n {\n idx[i] = i;\n }\n\n Array.Sort(idx, (l, r) => cmp(s[l], s[r]));\n\n int[] s2 = new int[n];\n int now = 0;\n for (int i = 0; i < n; i++)\n {\n if (0 < i && cmp(s[idx[i - 1]], s[idx[i]]) != 0) now++;\n s2[idx[i]] = now;\n }\n\n return SAIS(s2, now);\n }\n public static int[] SuffixArray(T[] s)\n {\n return SuffixArray(s, Comparer.Default.Compare);\n }\n\n /// \n /// \u9577\u3055n\u306e\u6587\u5b57\u5217\u306esuffixArray\u3092\u8fd4\u3059\n /// \n /// \n /// {0,1,2,...,n-1}\u306e\u9806\u5217\u3001s[sa[i],n) < s[sa[i+1],n)\n /// suffixArray\u306e\u8f9e\u66f8\u9806\n /// \n /// \n /// \n public static int[] SuffixArray(string s)\n {\n int n = s.Length;\n int[] s2 = new int[n];\n for (int i = 0; i < n; i++)\n {\n s2[i] = s[i];\n }\n return SAIS(s2, 255);\n }\n\n // O(n^2)\n private static int[] SANative(int[] s)\n {\n int n = s.Length;\n int[] sa = new int[n];\n for (int i = 0; i < n; i++)\n {\n sa[i] = i;\n }\n Array.Sort(sa, (l, r) =>\n {\n // \u540c\u3058\u306a\u30890\n if (l == r) return 0;\n // \u9806\u756a\u306b\u898b\u308b\n while (l < n && r < n)\n {\n\n if (s[l] != s[r]) return s[l].CompareTo(s[r]);\n l++;\n r++;\n }\n\n // index\u304c\u5927\u304d\u3044\u65b9\u304c\u8f9e\u66f8\u9806\u3067\u5c0f\u3055\u3044\n return r.CompareTo(l);\n });\n return sa;\n }\n private static int[] SADoubling(int[] s)\n {\n int n = s.Length;\n int[] sa = new int[n];\n int[] rnk = new int[n];\n int[] tmp = new int[n];\n Array.Copy(s, rnk, n);\n for (int i = 0; i < n; i++)\n {\n sa[i] = i;\n }\n\n for (int k = 1; k < n; k *= 2)\n {\n Comparison cmp = (int x, int y) =>\n {\n if (rnk[x] != rnk[y]) return rnk[x].CompareTo(rnk[y]);\n int rx = x + k < n ? rnk[x + k] : -1;\n int ry = y + k < n ? rnk[y + k] : -1;\n return rx.CompareTo(ry);\n };\n\n Array.Sort(sa, cmp);\n tmp[sa[0]] = 0;\n for (int i = 1; i < n; i++)\n {\n tmp[sa[i]] = tmp[sa[i - 1]] + (cmp(sa[i - 1], sa[i]) < 0 ? 1 : 0);\n }\n\n var t = tmp;\n tmp = rnk;\n rnk = t;\n }\n\n return sa;\n }\n\n private static int[] SAIS(int[] s, int upper)\n {\n int n = s.Length;\n if (n == 0) return new int[0];\n if (n == 1) return new int[1];\n if (n == 2)\n {\n if (s[0] < s[1])\n {\n return new int[] { 0, 1 };\n }\n else\n {\n return new int[] { 1, 0 };\n }\n }\n\n if (n < ThresholdNative)\n {\n return SANative(s);\n }\n\n if (n < ThresholdDoubling)\n {\n return SADoubling(s);\n }\n\n int[] sa = new int[n];\n bool[] ls = new bool[n];\n\n for (int i = n - 2; i >= 0; i--)\n {\n ls[i] = (s[i] == s[i + 1]) ? ls[i + 1] : (s[i] < s[i + 1]);\n }\n\n int[] sumL = new int[upper + 1];\n int[] sumS = new int[upper + 1];\n\n for (int i = 0; i < n; i++)\n {\n if (!ls[i])\n {\n sumS[s[i]]++;\n }\n else\n {\n sumL[s[i] + 1]++;\n }\n }\n\n for (int i = 0; i <= upper; i++)\n {\n sumS[i] += sumL[i];\n if (i < upper) sumL[i + 1] += sumS[i];\n }\n\n Action> induce = (List lms) =>\n {\n for (int i = 0; i < n; i++)\n {\n sa[i] = -1;\n }\n\n int[] buf = new int[upper + 1];\n Array.Copy(sumS, buf, upper + 1);\n\n foreach (var d in lms)\n {\n if (d == n) continue;\n sa[buf[s[d]]++] = d;\n }\n\n Array.Copy(sumL, buf, upper + 1);\n sa[buf[s[n - 1]]++] = n - 1;\n for (int i = 0; i < n; i++)\n {\n int v = sa[i];\n if (v >= 1 && !ls[v - 1])\n {\n sa[buf[s[v - 1]]++] = v - 1;\n }\n }\n\n Array.Copy(sumL, buf, upper + 1);\n\n for (int i = n - 1; i >= 0; i--)\n {\n int v = sa[i];\n if (v >= 1 && ls[v - 1])\n {\n sa[--buf[s[v - 1] + 1]] = v - 1;\n }\n }\n };\n\n int[] lmsMap = new int[n + 1];\n for (int i = 0; i <= n; i++)\n {\n lmsMap[i] = -1;\n }\n\n int m = 0;\n for (int i = 1; i < n; i++)\n {\n if (!ls[i - 1] && ls[i])\n {\n lmsMap[i] = m++;\n }\n }\n\n List lmsL = new List(m);\n for (int i = 1; i < n; i++)\n {\n if (!ls[i - 1] && ls[i])\n {\n lmsL.Add(i);\n }\n }\n\n induce(lmsL);\n\n if (m != 0)\n {\n List sortedLms = new List(m);\n foreach (var v in sa)\n {\n if (lmsMap[v] != -1) sortedLms.Add(v);\n }\n\n int[] recS = new int[m];\n\n int recUpper = 0;\n recS[lmsMap[sortedLms[0]]] = 0;\n for (int i = 1; i < m; i++)\n {\n int l = sortedLms[i - 1], r = sortedLms[i];\n int endL = (lmsMap[l] + 1 < m) ? lmsL[lmsMap[l] + 1] : n;\n int endR = (lmsMap[r] + 1 < m) ? lmsL[lmsMap[r] + 1] : n;\n\n bool same = true;\n\n if (endL - l != endR - r)\n {\n same = false;\n }\n else\n {\n while (l < endL)\n {\n if (s[l] != s[r])\n {\n break;\n }\n l++;\n r++;\n }\n\n if (l == n || s[l] != s[r]) same = false;\n }\n\n if (!same) recUpper++;\n recS[lmsMap[sortedLms[i]]] = recUpper;\n }\n\n var recSa = SAIS(recS, recUpper);\n\n for (int i = 0; i < m; i++)\n {\n sortedLms[i] = lmsL[recSa[i]];\n }\n\n induce(sortedLms);\n }\n return sa;\n }\n #endregion // SuffixArray\n\n #region LCPArray\n /// \n /// s\u306eLCPArray\u3068\u3057\u3066\u9577\u3055 n-1\u306e\u914d\u5217\u3092\u8fd4\u3059\n /// \n /// \n /// res[i]\u306fs[sa[i],n), s[sa[i+1],n)\u306eLongest Common Prefix\u306e\u9577\u3055\n /// O(n)\n /// \n /// \n /// \n /// \n /// \n /// \n public static int[] LCPArray(T[] s, int[] sa, Comparison cmp)\n {\n int n = s.Length;\n Debug.Assert(n >= 1);\n int[] rnk = new int[n];\n for (int i = 0; i < n; i++)\n {\n rnk[sa[i]] = i;\n }\n\n int[] lcp = new int[n - 1];\n int h = 0;\n for (int i = 0; i < n; i++)\n {\n if (h > 0) h--;\n if (rnk[i] == 0) continue;\n int j = sa[rnk[i] - 1];\n for (; j + h < n && i + h < n; h++)\n {\n if (cmp(s[j + h], s[i + h]) != 0) break;\n }\n lcp[rnk[i] - 1] = h;\n }\n\n return lcp;\n }\n\n /// \n /// s\u306eLCPArray\u3068\u3057\u3066\u9577\u3055 n-1\u306e\u914d\u5217\u3092\u8fd4\u3059\n /// \n /// \n /// res[i]\u306fs[sa[i],n), s[sa[i+1],n)\u306eLongest Common Prefix\u306e\u9577\u3055\n /// O(n)\n /// \n /// \n /// \n /// \n /// \n public static int[] LCPArray(T[] s, int[] sa)\n {\n return LCPArray(s, sa, Comparer.Default.Compare);\n }\n /// \n /// s\u306eLCPArray\u3068\u3057\u3066\u9577\u3055 n-1\u306e\u914d\u5217\u3092\u8fd4\u3059\n /// \n /// \n /// res[i]\u306fs[sa[i],n), s[sa[i+1],n)\u306eLongest Common Prefix\u306e\u9577\u3055\n /// O(n)\n /// \n /// \n /// \n /// \n /// \n public static int[] LCPArray(string s, int[] sa)\n {\n //int n = s.Length;\n //int[] s2 = new int[n];\n //for (int i = 0; i < n; i++)\n //{\n // s2[i] = s[i];\n //}\n return LCPArray(s.ToCharArray(), sa);\n }\n\n #endregion // LCPArray\n\n #region ZAlgorithm\n\n /// \n /// \u9577\u3055n\u306e\u914d\u5217s\u306b\u3064\u3044\u3066 s\u3068 s[i,n)\u306eLCP\u306e\u9577\u3055\u3092\u8fd4\u3059\n /// \n /// \n /// \n /// \n /// \n public static int[] ZAlgorithm(T[] s, EqualityComparer eq)\n {\n int n = s.Length;\n if (n == 0) return new int[0];\n int[] z = new int[n];\n z[0] = 0;\n for (int i = 1, j = 0; i < n; i++)\n {\n ref int k = ref z[i];\n k = (j + z[j] <= i) ? 0 : Math.Min(j + z[j] - i, z[i - j]);\n while (i + k < n && eq.Equals(s[k], s[i + k])) k++;\n if (j + z[j] < i + z[i]) j = i;\n }\n z[0] = n;\n return z;\n }\n\n /// \n /// \u9577\u3055n\u306e\u914d\u5217s\u306b\u3064\u3044\u3066 s\u3068 s[i,n)\u306eLCP\u306e\u9577\u3055\u3092\u8fd4\u3059\n /// \n /// \n /// \n /// \n public static int[] ZAlgorithm(T[] s)\n {\n return ZAlgorithm(s, EqualityComparer.Default);\n }\n\n /// \n /// \u9577\u3055n\u306e\u6587\u5b57\u5217s\u306b\u3064\u3044\u3066 s\u3068 s[i,n)\u306eLCP\u306e\u9577\u3055\u3092\u8fd4\u3059\n /// \n /// \n /// \n /// \n public static int[] ZAlgorithm(string s)\n {\n return ZAlgorithm(s.ToCharArray());\n }\n\n #endregion\n }\n}\n\n\n// https://bitbucket.org/camypaper/complib\nnamespace CompLib.Mathematics\n{\n #region ModInt\n /// \n /// [0,) \u307e\u3067\u306e\u5024\u3092\u53d6\u308b\u3088\u3046\u306a\u6570\n /// \n public struct ModInt\n {\n /// \n /// \u5270\u4f59\u3092\u53d6\u308b\u5024\uff0e\n /// \n public const long Mod = (int)1e9 + 7;\n // public const long Mod = 998244353;\n\n /// \n /// \u5b9f\u969b\u306e\u6570\u5024\uff0e\n /// \n public long num;\n /// \n /// \u5024\u304c \u3067\u3042\u308b\u3088\u3046\u306a\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u3092\u69cb\u7bc9\u3057\u307e\u3059\uff0e\n /// \n /// \u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u304c\u6301\u3064\u5024\n /// \u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u306e\u554f\u984c\u4e0a\uff0c\u30b3\u30f3\u30b9\u30c8\u30e9\u30af\u30bf\u5185\u3067\u306f\u5270\u4f59\u3092\u53d6\u308a\u307e\u305b\u3093\uff0e\u305d\u306e\u305f\u3081\uff0c \u2208 [0,) \u3092\u6e80\u305f\u3059\u3088\u3046\u306a \u3092\u6e21\u3057\u3066\u304f\u3060\u3055\u3044\uff0e\u3053\u306e\u30b3\u30f3\u30b9\u30c8\u30e9\u30af\u30bf\u306f O(1) \u3067\u5b9f\u884c\u3055\u308c\u307e\u3059\uff0e\n public ModInt(long n) { num = n; }\n /// \n /// \u3053\u306e\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u306e\u6570\u5024\u3092\u6587\u5b57\u5217\u306b\u5909\u63db\u3057\u307e\u3059\uff0e\n /// \n /// [0,) \u306e\u7bc4\u56f2\u5185\u306e\u6574\u6570\u3092 10 \u9032\u8868\u8a18\u3057\u305f\u3082\u306e\uff0e\n public override string ToString() { return num.ToString(); }\n public static ModInt operator +(ModInt l, ModInt r) { l.num += r.num; if (l.num >= Mod) l.num -= Mod; return l; }\n public static ModInt operator -(ModInt l, ModInt r) { l.num -= r.num; if (l.num < 0) l.num += Mod; return l; }\n public static ModInt operator *(ModInt l, ModInt r) { return new ModInt(l.num * r.num % Mod); }\n public static implicit operator ModInt(long n) { n %= Mod; if (n < 0) n += Mod; return new ModInt(n); }\n\n /// \n /// \u4e0e\u3048\u3089\u308c\u305f 2 \u3064\u306e\u6570\u5024\u304b\u3089\u3079\u304d\u5270\u4f59\u3092\u8a08\u7b97\u3057\u307e\u3059\uff0e\n /// \n /// \u3079\u304d\u4e57\u306e\u5e95\n /// \u3079\u304d\u6307\u6570\n /// \u7e70\u308a\u8fd4\u3057\u4e8c\u4e57\u6cd5\u306b\u3088\u308a O(N log N) \u3067\u5b9f\u884c\u3055\u308c\u307e\u3059\uff0e\n public static ModInt Pow(ModInt v, long k) { return Pow(v.num, k); }\n\n /// \n /// \u4e0e\u3048\u3089\u308c\u305f 2 \u3064\u306e\u6570\u5024\u304b\u3089\u3079\u304d\u5270\u4f59\u3092\u8a08\u7b97\u3057\u307e\u3059\uff0e\n /// \n /// \u3079\u304d\u4e57\u306e\u5e95\n /// \u3079\u304d\u6307\u6570\n /// \u7e70\u308a\u8fd4\u3057\u4e8c\u4e57\u6cd5\u306b\u3088\u308a O(N log N) \u3067\u5b9f\u884c\u3055\u308c\u307e\u3059\uff0e\n public static ModInt Pow(long v, long k)\n {\n long ret = 1;\n for (k %= Mod - 1; k > 0; k >>= 1, v = v * v % Mod)\n if ((k & 1) == 1) ret = ret * v % Mod;\n return new ModInt(ret);\n }\n /// \n /// \u4e0e\u3048\u3089\u308c\u305f\u6570\u306e\u9006\u5143\u3092\u8a08\u7b97\u3057\u307e\u3059\uff0e\n /// \n /// \u9006\u5143\u3092\u53d6\u308b\u5bfe\u8c61\u3068\u306a\u308b\u6570\n /// \u9006\u5143\u3068\u306a\u308b\u3088\u3046\u306a\u5024\n /// \u6cd5\u304c\u7d20\u6570\u3067\u3042\u308b\u3053\u3068\u3092\u4eee\u5b9a\u3057\u3066\uff0c\u30d5\u30a7\u30eb\u30de\u30fc\u306e\u5c0f\u5b9a\u7406\u306b\u5f93\u3063\u3066\u9006\u5143\u3092 O(log N) \u3067\u8a08\u7b97\u3057\u307e\u3059\uff0e\n public static ModInt Inverse(ModInt v) { return Pow(v, Mod - 2); }\n }\n #endregion\n #region Binomial Coefficient\n public class BinomialCoefficient\n {\n public ModInt[] fact, ifact;\n public BinomialCoefficient(int n)\n {\n fact = new ModInt[n + 1];\n ifact = new ModInt[n + 1];\n fact[0] = 1;\n for (int i = 1; i <= n; i++)\n fact[i] = fact[i - 1] * i;\n ifact[n] = ModInt.Inverse(fact[n]);\n for (int i = n - 1; i >= 0; i--)\n ifact[i] = ifact[i + 1] * (i + 1);\n ifact[0] = ifact[1];\n }\n public ModInt this[int n, int r]\n {\n get\n {\n if (n < 0 || n >= fact.Length || r < 0 || r > n) return 0;\n return fact[n] * ifact[n - r] * ifact[r];\n }\n }\n public ModInt RepeatedCombination(int n, int k)\n {\n if (k == 0) return 1;\n return this[n + k - 1, k];\n }\n }\n #endregion\n}\n\n\nnamespace CompLib.Util\n{\n using System;\n using System.Linq;\n\n class Scanner\n {\n private string[] _line;\n private int _index;\n private const char Separator = ' ';\n\n public Scanner()\n {\n _line = new string[0];\n _index = 0;\n }\n\n public string Next()\n {\n if (_index >= _line.Length)\n {\n string s;\n do\n {\n s = Console.ReadLine();\n } while (s.Length == 0);\n\n _line = s.Split(Separator);\n _index = 0;\n }\n\n return _line[_index++];\n }\n\n public string ReadLine()\n {\n _index = _line.Length;\n return Console.ReadLine();\n }\n\n public int NextInt() => int.Parse(Next());\n public long NextLong() => long.Parse(Next());\n public double NextDouble() => double.Parse(Next());\n public decimal NextDecimal() => decimal.Parse(Next());\n public char NextChar() => Next()[0];\n public char[] NextCharArray() => Next().ToCharArray();\n\n public string[] Array()\n {\n string s = Console.ReadLine();\n _line = s.Length == 0 ? new string[0] : s.Split(Separator);\n _index = _line.Length;\n return _line;\n }\n\n public int[] IntArray() => Array().Select(int.Parse).ToArray();\n public long[] LongArray() => Array().Select(long.Parse).ToArray();\n public double[] DoubleArray() => Array().Select(double.Parse).ToArray();\n public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();\n }\n}\n", "lang_cluster": "C#", "tags": ["strings", "dp"], "code_uid": "9c4cc1d419e01edd75b90be3d44ed429", "src_uid": "590a49a7af0eb83376ed911ed488d7e5", "difficulty": 2300.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\nusing System.Collections;\n\nnamespace CF954G\n{\n class Program\n {\n\t\tpublic class Global \n\t\t{\n\t\t\tpublic static int[,] len;\n\t\t\tpublic static int[,,,] Dp;\n\t\t}\n\n\t\tstatic void Main(string[] args)\n {\n\t\t\tconst int mod = 1000000007;\n\n\t\t\tint len = Convert.ToInt32(Console.ReadLine());\n\t\t\tstring s = Console.ReadLine(), t = \"\";\n\n\t\t\tGlobal.len = new int[s.Length + 1, 2];\n\t\t\tGlobal.Dp = new int[(len << 1) + 5, (len << 1) + 5, s.Length + 5, 2];\n\t\t\tGlobal.Dp[0, 0, 0, 0] = 1;\n\n\t\t\tif(s[0] == '(') Global.len[0, 0] = 1;\n\t\t\telse Global.len[0, 1] = 1;\n\t\t\tfor(int i = 0; i < s.Length; i++) {\n\t\t\t\tt += s[i];t += '(';\n\t\t\t\tGlobal.len[i + 1, 0] = Match(s, t);\n\t\t\t\tt = t.Remove(t.Length - 1, 1); t += ')';\n\t\t\t\tGlobal.len[i + 1, 1] = Match(s, t);\n\t\t\t\tt = t.Remove(t.Length - 1, 1);\n\t\t\t}\n\n\t\t\tfor(int i = 0; i < (len << 1); i++)\n\t\t\t\tfor(int j = 0; j <= len; j++)\n\t\t\t\t\tfor(int k = 0; k <= s.Length; k++) \n\t\t\t\t\t\tfor(int fin = 0; fin <= 1; fin++) {\n\t\t\t\t\t\t\tif(Global.Dp[i, j, k, fin] == 0) continue;\n\t\t\t\t\t\t\tif(j < len) {\n\t\t\t\t\t\t\t\tGlobal.Dp[i + 1, j + 1, Global.len[k, 0], fin | (Global.len[k, 0] == s.Length ? 1 : 0)] += Global.Dp[i, j, k, fin];\n\t\t\t\t\t\t\t\tGlobal.Dp[i + 1, j + 1, Global.len[k, 0], fin | (Global.len[k, 0] == s.Length ? 1 : 0)] %= mod;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif(j > 0) {\n\t\t\t\t\t\t\t\tGlobal.Dp[i + 1, j - 1, Global.len[k, 1], fin | (Global.len[k, 1] == s.Length ? 1 : 0)] += Global.Dp[i, j, k, fin];\n\t\t\t\t\t\t\t\tGlobal.Dp[i + 1, j - 1, Global.len[k, 1], fin | (Global.len[k, 1] == s.Length ? 1 : 0)] %= mod;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\n\t\t\tint _count = 0, final_Len = len << 1;\n\t\t\tfor(int i = 0; i <= s.Length; i++) {\n\t\t\t\t_count += Global.Dp[final_Len, 0, i, 1];\n\t\t\t\t_count %= mod;\n\t\t\t}\n\n\t\t\tConsole.WriteLine(_count.ToString());\n\t\t}\n\n\t\tstatic int Match(string a,string t) {\n\t\t\tfor(int i = Math.Min(t.Length, a.Length); i > 0; i--)\n\t\t\t\tif(a.Substring(0, i) == t.Substring(t.Length - i, i))\n\t\t\t\t\treturn i;\n\t\t\treturn 0;\n\t\t}\n\t}\n}", "lang_cluster": "C#", "tags": ["strings", "dp"], "code_uid": "36a868feb747a584885d94bfc1aec552", "src_uid": "590a49a7af0eb83376ed911ed488d7e5", "difficulty": 2300.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.CodeDom;\nusing System.Linq;\n\nnamespace ConsoleApplication3\n{\n class Program\n {\n // FEDCBA9876543210\n // 0010211201010001\n // 543210\n\n static void Main(string[] args)\n {\n Console.ReadLine();\n var query = Console.ReadLine().Split(' ').Select(byte.Parse);\n Console.WriteLine(query.Max() ^ query.Last());\n\n //var n = int.Parse(Console.ReadLine());\n //var result = 0;\n //var array = new[]\n //{\n // 0, 4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517,\n // 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852,\n // 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165\n //};\n //result = array[n];\n\n //Console.WriteLine(result);\n\n //if (n == 0)\n //{\n // Console.WriteLine(\"1\");\n // return;\n //}\n //var r = 0;\n\n //while (n > 0)\n //{\n // switch (n % 16)\n // {\n // case 0:\n // case 4:\n // case 6:\n // case 9:\n // case 10:\n // case 13:\n // r++;\n // break;\n // case 8:\n // case 11:\n // r += 2;\n // break;\n // }\n\n // n /= 16;\n //}\n //Console.WriteLine(r);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "599bd5a1358e53d28d01f5a4abc1349b", "src_uid": "f45c769556ac3f408f5542fa71a67d98", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Globalization;\nusing System.IO;\nusing System.Linq;\n\nclass ProblemD {\n static string inputFileName = \"../../input.txt\";\n static StreamReader fileReader;\n static string[] inputTokens;\n static int curInputTokenIndex;\n static string NextToken() {\n string ret = \"\";\n while (ret == \"\") {\n if (inputTokens == null || curInputTokenIndex >= inputTokens.Length) {\n string line;\n if (Type.GetType(\"HaitaoLocal\") != null) {\n if (fileReader == null) {\n fileReader = new StreamReader(inputFileName);\n }\n line = fileReader.ReadLine();\n if (line == null) {\n throw new Exception(\"Error: out of input tokens!\");\n }\n } else {\n line = Console.ReadLine();\n }\n inputTokens = line.Split();\n curInputTokenIndex = 0;\n }\n ret = inputTokens[curInputTokenIndex++];\n }\n return ret;\n }\n static int ReadInt() {\n return Int32.Parse(NextToken());\n }\n static string ReadString() {\n return NextToken();\n }\n static long ReadLong() {\n return Int64.Parse(NextToken());\n }\n static int[] ReadIntArray(int length) {\n int[] ret = new int[length];\n for (int i = 0; i < length; i++) {\n ret[i] = ReadInt();\n }\n return ret;\n }\n static string[] ReadStringArray(int length) {\n string[] ret = new string[length];\n for (int i = 0; i < length; i++) {\n ret[i] = ReadString();\n }\n return ret;\n }\n static long[] ReadLongArray(int length) {\n long[] ret = new long[length];\n for (int i = 0; i < length; i++) {\n ret[i] = ReadLong();\n }\n return ret;\n }\n static string DoubleToString(double d) {\n return d.ToString(new CultureInfo(\"en-US\"));\n }\n\n public static void Main(string[] args) {\n int Q = 1000001;\n bool[] notPrime = new bool[Q];\n notPrime[0] = true;\n notPrime[1] = true;\n for (int i = 2; i <= Math.Sqrt(notPrime.Length); i++) {\n if (!notPrime[i]) {\n for (int j = i * 2; j < notPrime.Length; j += i) {\n notPrime[j] = true;\n }\n }\n }\n List primes = new List();\n for(int i=0; i factors = new List();\n for (long i = 1; i <= 1000000; i++) {\n if (N % i != 0) continue;\n if (i * i > N) break;\n factors.Add(i);\n if(i*i!=N) factors.Add(N / i);\n }\n factors.Sort();\n Dictionary pmap = new Dictionary();\n foreach (long f in factors) {\n long k = f - 1;\n bool flag = true;\n foreach (int p in primes) {\n if (k % p == 0) {\n flag = false;\n long x = 1;\n while (x < k) x *= p;\n if (x == k) {\n pmap.Add(f, p);\n } else {\n break;\n }\n }\n }\n if (flag && k>1) pmap.Add(f, k);\n }\n //foreach (long key in pmap.Keys) {\n // Console.WriteLine(key + \" \" + pmap[key]);\n //}\n Dictionary dp = new Dictionary();\n\n foreach (long i in factors) {\n dp[i] = 0;\n }\n dp[1] = 1;\n Dictionary used = new Dictionary();\n foreach (long key in pmap.Keys) {\n long p = pmap[key];\n if (used.ContainsKey(p)) continue;\n used.Add(p, 0);\n\n Dictionary toAdd = new Dictionary();\n foreach (long k2 in pmap.Keys) {\n if (pmap[k2] != p) continue;\n foreach (long f in factors) {\n if(f%k2!=0) continue;\n if (toAdd.ContainsKey(f)) toAdd[f] += dp[f / k2];\n else toAdd[f] = dp[f / k2];\n }\n }\n foreach (long f in toAdd.Keys) {\n dp[f] += toAdd[f];\n }\n }\n\n //foreach (long key in factors) {\n // Console.WriteLine(key + \" \" + dp[key]);\n //}\n\n Console.WriteLine(dp[N]);\n\n }\n}\n", "lang_cluster": "C#", "tags": ["dfs and similar", "math", "dp", "data structures", "number theory"], "code_uid": "db1821387ed26ccaaa7e6c1f49eed3d1", "src_uid": "1f68bd6f8b40e45a5bd360b03a264ef4", "difficulty": 2600.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Globalization;\nusing System.IO;\nusing System.Linq;\nusing System.Text;\nusing System.Threading;\n\n// (\u3065\u00b0\u03c9\u00b0)\u3065\uff90\u2605\u309c\u30fb\u3002\u3002\u30fb\u309c\u309c\u30fb\u3002\u3002\u30fb\u309c\u2606\u309c\u30fb\u3002\u3002\u30fb\u309c\u309c\u30fb\u3002\u3002\u30fb\u309c\npublic class Solver\n{\n int Gcd(int a, int b)\n {\n if (b == 0)\n return a;\n return Gcd(b, a % b);\n }\n\n private const int SIEVE_SIZE = 1000010;\n private readonly bool[] isComposite = new bool[SIEVE_SIZE + 1];\n private readonly IList primes = new List();\n void Sieve()\n {\n for (int i = 2; i * i <= SIEVE_SIZE; i++)\n if (!isComposite[i])\n for (int j = i * i; j <= SIEVE_SIZE; j += i)\n isComposite[j] = true;\n for (int i = 2; i <= SIEVE_SIZE; i++)\n if (!isComposite[i])\n primes.Add(i);\n }\n\n public void Solve()\n {\n Sieve();\n\n long a = ReadLong();\n if (a == 1)\n {\n Write(1);\n return;\n }\n var d = new SDictionary { { a, 1 } };\n int ans = 0;\n var ts = DateTime.Now;\n for (int i = 0; i < primes.Count; i++)\n {\n bool ok = false;\n for (long x = primes[i]; !ok && x < a; x *= primes[i])\n if (a % (x + 1) == 0)\n ok = true;\n if (!ok)\n continue;\n\n var toAdd = new List>();\n var toRemove = new List();\n foreach (var p in d)\n {\n if (p.Key <= primes[i])\n toRemove.Add(p.Key);\n for (long x = primes[i]; x < p.Key; x *= primes[i])\n if (p.Key % (x + 1) == 0)\n {\n long y = p.Key / (x + 1);\n if (y == 1)\n ans += p.Value;\n else if (y > primes[i] && y % 2 == 0)\n toAdd.Add(Tuple.Create(y, p.Value));\n }\n }\n foreach (int x in toRemove)\n d.Remove(x);\n foreach (var p in toAdd)\n d[p.Item1] += p.Item2;\n }\n //Write((DateTime.Now - ts).TotalMilliseconds);\n\n foreach (var p in d)\n if (p.Key > SIEVE_SIZE)\n {\n long x = p.Key - 1;\n bool ok = true;\n for (int i = 0; ok && 1L * primes[i] * primes[i] <= x; i++)\n if (x % primes[i] == 0)\n ok = false;\n if (ok)\n ans += p.Value;\n }\n\n Write(ans);\n }\n \n #region Main\n\n protected static TextReader reader;\n protected static TextWriter writer;\n static void Main()\n {\n#if DEBUG\n reader = new StreamReader(\"..\\\\..\\\\input.txt\");\n //reader = new StreamReader(Console.OpenStandardInput());\n writer = Console.Out;\n //writer = new StreamWriter(\"..\\\\..\\\\output.txt\");\n#else\n reader = new StreamReader(Console.OpenStandardInput());\n writer = new StreamWriter(Console.OpenStandardOutput());\n //reader = new StreamReader(\"hull.in\");\n //writer = new StreamWriter(\"hull.out\");\n#endif\n try\n {\n// var thread = new Thread(new Solver().Solve, 1024 * 1024 * 128);\n// thread.Start();\n// thread.Join();\n new Solver().Solve(); \n }\n catch (Exception ex)\n {\n Console.WriteLine(ex);\n#if DEBUG\n#else\n throw;\n#endif\n }\n reader.Close();\n writer.Close();\n }\n\n #endregion\n\n #region Read / Write\n private static Queue currentLineTokens = new Queue();\n private static string[] ReadAndSplitLine() {return reader.ReadLine().Split(new[] { ' ', '\\t', '-' }, StringSplitOptions.RemoveEmptyEntries);}\n public static string ReadToken(){while (currentLineTokens.Count == 0)currentLineTokens = new Queue(ReadAndSplitLine());return currentLineTokens.Dequeue();}\n public static int ReadInt(){return int.Parse(ReadToken());}\n public static long ReadLong(){return long.Parse(ReadToken());}\n public static double ReadDouble(){return double.Parse(ReadToken(), CultureInfo.InvariantCulture);}\n public static int[] ReadIntArray(){return ReadAndSplitLine().Select(int.Parse).ToArray();}\n public static long[] ReadLongArray(){return ReadAndSplitLine().Select(long.Parse).ToArray();}\n public static double[] ReadDoubleArray(){return ReadAndSplitLine().Select(s => double.Parse(s, CultureInfo.InvariantCulture)).ToArray();}\n public static int[][] ReadIntMatrix(int numberOfRows){int[][] matrix = new int[numberOfRows][];for (int i = 0; i < numberOfRows; i++)matrix[i] = ReadIntArray();return matrix;}\n public static int[][] ReadAndTransposeIntMatrix(int numberOfRows){int[][] matrix = ReadIntMatrix(numberOfRows);int[][] ret = new int[matrix[0].Length][];\n for (int i = 0; i < ret.Length; i++){ret[i] = new int[numberOfRows];for (int j = 0; j < numberOfRows; j++)ret[i][j] = matrix[j][i];}return ret;}\n public static string[] ReadLines(int quantity){string[] lines = new string[quantity];for (int i = 0; i < quantity; i++)lines[i] = reader.ReadLine().Trim();return lines;}\n public static void WriteArray(IEnumerable array){writer.WriteLine(string.Join(\" \", array));}\n public static void Write(params object[] array){WriteArray(array);}\n public static void WriteLines(IEnumerable array){foreach (var a in array)writer.WriteLine(a);}\n private class SDictionary : Dictionary{public new TValue this[TKey key]{\n get { return ContainsKey(key) ? base[key] : default(TValue); }set { base[key] = value; }}}\n private static T[] Init(int size) where T : new(){var ret = new T[size];for (int i = 0; i < size; i++)ret[i] = new T();return ret;}\n #endregion\n}", "lang_cluster": "C#", "tags": ["dfs and similar", "math", "dp", "data structures", "number theory"], "code_uid": "5b9811af3c5c8f337db4fbc59cc0fa77", "src_uid": "1f68bd6f8b40e45a5bd360b03a264ef4", "difficulty": 2600.0, "exec_outcome": "PASSED"} {"lang": "C# 8", "source_code": "\ufeffusing System;\r\nusing System.Collections.Generic;\r\nusing System.Globalization;\r\nusing System.IO;\r\nusing System.Linq;\r\nusing System.Text;\r\nusing System.Threading;\r\n\r\n// (\u3065\u00b0\u03c9\u00b0)\u3065\uff90e\u2605\u309c\u30fb\u3002\u3002\u30fb\u309c\u309c\u30fb\u3002\u3002\u30fb\u309c\u2606\u309c\u30fb\u3002\u3002\u30fb\u309c\u309c\u30fb\u3002\u3002\u30fb\u309c\r\npublic class Solution\r\n{\r\n const int MAXN = 50;\r\n const int MAX_INV = MAXN * MAXN;\r\n\r\n long Fun(int n, int mod)\r\n {\r\n var d = new long[MAX_INV];\r\n d[0] = 1;\r\n int max = 0;\r\n long ans = 0;\r\n for (int i = 1; i < n; i++)\r\n {\r\n var nd = new long[MAX_INV];\r\n int nmax = max;\r\n long sum = 0;\r\n for (int j = 0; j <= i; j++)\r\n for (int k = 0; k <= i; k++)\r\n {\r\n for (int p = 0; p <= max; p++)\r\n {\r\n int o = p + j - k;\r\n nmax = Math.Max(nmax, o);\r\n if (o >= 0)\r\n {\r\n nd[o] = (nd[o] + d[p]) % mod;\r\n if (j < k && o > 0)\r\n sum = (sum + d[p]) % mod;\r\n }\r\n if (p == 0)\r\n continue;\r\n o = -p + j - k;\r\n nmax = Math.Max(nmax, o);\r\n if (o >= 0)\r\n {\r\n nd[o] = (nd[o] + d[p]) % mod;\r\n if (j < k && o > 0)\r\n sum = (sum + d[p]) % mod;\r\n }\r\n }\r\n }\r\n ans = ((i + 1) * ans + sum) % mod;\r\n max = nmax;\r\n d = nd;\r\n }\r\n\r\n return ans;\r\n }\r\n\r\n public void Solve()\r\n {\r\n int n = ReadInt();\r\n int mod = ReadInt();\r\n\r\n Write(Fun(n, mod));\r\n }\r\n\r\n #region Main\r\n\r\n protected static TextReader reader;\r\n protected static TextWriter writer;\r\n static void Main()\r\n {\r\n#if DEBUGLOCAL\r\n reader = new StreamReader(\"..\\\\..\\\\input.txt\");\r\n //reader = new StreamReader(Console.OpenStandardInput());\r\n writer = Console.Out;\r\n //writer = new StreamWriter(\"..\\\\..\\\\output.txt\");\r\n#else\r\n reader = new StreamReader(Console.OpenStandardInput());\r\n writer = new StreamWriter(Console.OpenStandardOutput());\r\n //reader = new StreamReader(\"ysys.in\");\r\n //writer = new StreamWriter(\"output.txt\");\r\n#endif\r\n try\r\n {\r\n new Solution().Solve();\r\n //var thread = new Thread(new Solution().Solve, 1024 * 1024 * 128);\r\n //thread.Start();\r\n //thread.Join();\r\n }\r\n catch (Exception ex)\r\n {\r\n#if DEBUGLOCAL\r\n Console.WriteLine(ex);\r\n#else\r\n throw;\r\n#endif\r\n }\r\n reader.Close();\r\n writer.Close();\r\n }\r\n\r\n #endregion\r\n\r\n #region Read / Write\r\n private static Queue currentLineTokens = new Queue();\r\n private static string[] ReadAndSplitLine() { return reader.ReadLine().Split(new[] { ' ', '\\t', }, StringSplitOptions.RemoveEmptyEntries); }\r\n public static string ReadToken() { while (currentLineTokens.Count == 0) currentLineTokens = new Queue(ReadAndSplitLine()); return currentLineTokens.Dequeue(); }\r\n public static int ReadInt() { return int.Parse(ReadToken()); }\r\n public static long ReadLong() { return long.Parse(ReadToken()); }\r\n public static double ReadDouble() { return double.Parse(ReadToken(), CultureInfo.InvariantCulture); }\r\n public static int[] ReadIntArray() { return ReadAndSplitLine().Select(int.Parse).ToArray(); }\r\n public static long[] ReadLongArray() { return ReadAndSplitLine().Select(long.Parse).ToArray(); }\r\n public static double[] ReadDoubleArray() { return ReadAndSplitLine().Select(s => double.Parse(s, CultureInfo.InvariantCulture)).ToArray(); }\r\n public static int[][] ReadIntMatrix(int numberOfRows) { int[][] matrix = new int[numberOfRows][]; for (int i = 0; i < numberOfRows; i++) matrix[i] = ReadIntArray(); return matrix; }\r\n public static int[][] ReadAndTransposeIntMatrix(int numberOfRows)\r\n {\r\n int[][] matrix = ReadIntMatrix(numberOfRows); int[][] ret = new int[matrix[0].Length][];\r\n for (int i = 0; i < ret.Length; i++) { ret[i] = new int[numberOfRows]; for (int j = 0; j < numberOfRows; j++) ret[i][j] = matrix[j][i]; }\r\n return ret;\r\n }\r\n public static string[] ReadLines(int quantity) { string[] lines = new string[quantity]; for (int i = 0; i < quantity; i++) lines[i] = reader.ReadLine().Trim(); return lines; }\r\n public static void WriteArray(IEnumerable array) { writer.WriteLine(string.Join(\" \", array)); }\r\n public static void Write(params object[] array) { WriteArray(array); }\r\n public static void WriteLines(IEnumerable array) { foreach (var a in array) writer.WriteLine(a); }\r\n private class SDictionary : Dictionary\r\n {\r\n public new TValue this[TKey key]\r\n {\r\n get { return ContainsKey(key) ? base[key] : default(TValue); }\r\n set { base[key] = value; }\r\n }\r\n }\r\n private static T[] Init(int size) where T : new() { var ret = new T[size]; for (int i = 0; i < size; i++) ret[i] = new T(); return ret; }\r\n #endregion\r\n}", "lang_cluster": "C#", "tags": ["math", "dp", "combinatorics", "fft"], "code_uid": "1e5ebe840a8d6662e8ee5c9c3d1c2c4c", "src_uid": "ae0320a57d73fab1d05f5d10fbdb9e1a", "difficulty": 2400.0, "exec_outcome": "PASSED"} {"lang": "C# 8", "source_code": "using System;\r\nusing System.Collections.Generic;\r\nusing System.IO;\r\nusing System.Linq;\r\nusing static System.Math;\r\nusing System.Text;\r\nusing System.Threading;\r\nusing System.Globalization;\r\nusing System.Runtime.CompilerServices;\r\nusing System.Runtime.InteropServices;\r\nusing Library;\r\n\r\nnamespace Program\r\n{\r\n public static class ProblemE\r\n {\r\n static bool SAIKI = false;\r\n static public int numberOfRandomCases = 0;\r\n static public void MakeTestCase(List _input, List _output, ref Func _outputChecker)\r\n {\r\n }\r\n static public void Solve()\r\n {\r\n var n = NN;\r\n var mod = NN;\r\n var dp = new long?[n + 1, n * (n - 1) / 2 + 1];\r\n Func calc = null;\r\n calc = (pn, pk) =>\r\n {\r\n if (pn == 1 && pk == 0) return 1;\r\n if (pn < 0 || pk < 0 || pk > pn * (pn - 1) / 2) return 0;\r\n if (dp[pn, pk].HasValue) return dp[pn, pk].Value;\r\n dp[pn, pk] = (calc(pn, pk - 1) + calc(pn - 1, pk) + mod - calc(pn - 1, pk - pn)) % mod;\r\n return dp[pn, pk].Value;\r\n };\r\n var beforeAns = 0L;\r\n for (var N = 0; N <= n; ++N)\r\n {\r\n var ans = beforeAns * N % mod;\r\n for (var i = 0; i < N; ++i)\r\n {\r\n for (var j = i + 1; j < N; ++j)\r\n {\r\n var sabun = j - i + 1;\r\n var ten = (N - 1) * (N - 2) / 2;\r\n var sum = 0L;\r\n for (var k = 0; k + sabun <= ten; ++k)\r\n {\r\n sum = (sum + calc(N - 1, k)) % mod;\r\n ans += sum * calc(N - 1, k + sabun) % mod;\r\n ans %= mod;\r\n }\r\n }\r\n }\r\n beforeAns = ans;\r\n }\r\n Console.WriteLine(beforeAns);\r\n }\r\n class Printer : StreamWriter\r\n {\r\n public override IFormatProvider FormatProvider { get { return CultureInfo.InvariantCulture; } }\r\n public Printer(Stream stream) : base(stream, new UTF8Encoding(false, true)) { base.AutoFlush = false; }\r\n public Printer(Stream stream, Encoding encoding) : base(stream, encoding) { base.AutoFlush = false; }\r\n }\r\n static LIB_FastIO fastio = new LIB_FastIODebug();\r\n static public void Main(string[] args) { if (args.Length == 0) { fastio = new LIB_FastIO(); Console.SetOut(new Printer(Console.OpenStandardOutput())); } if (SAIKI) { var t = new Thread(Solve, 134217728); t.Start(); t.Join(); } else Solve(); Console.Out.Flush(); }\r\n static long NN => fastio.Long();\r\n static double ND => fastio.Double();\r\n static string NS => fastio.Scan();\r\n static long[] NNList(long N) => Repeat(0, N).Select(_ => NN).ToArray();\r\n static double[] NDList(long N) => Repeat(0, N).Select(_ => ND).ToArray();\r\n static string[] NSList(long N) => Repeat(0, N).Select(_ => NS).ToArray();\r\n static long Count(this IEnumerable x, Func pred) => Enumerable.Count(x, pred);\r\n static IEnumerable Repeat(T v, long n) => Enumerable.Repeat(v, (int)n);\r\n static IEnumerable Range(long s, long c) => Enumerable.Range((int)s, (int)c);\r\n static IOrderedEnumerable OrderByRand(this IEnumerable x) => Enumerable.OrderBy(x, _ => xorshift);\r\n static IOrderedEnumerable OrderBy(this IEnumerable x) => Enumerable.OrderBy(x.OrderByRand(), e => e);\r\n static IOrderedEnumerable OrderBy(this IEnumerable x, Func selector) => Enumerable.OrderBy(x.OrderByRand(), selector);\r\n static IOrderedEnumerable OrderByDescending(this IEnumerable x) => Enumerable.OrderByDescending(x.OrderByRand(), e => e);\r\n static IOrderedEnumerable OrderByDescending(this IEnumerable x, Func selector) => Enumerable.OrderByDescending(x.OrderByRand(), selector);\r\n static IOrderedEnumerable OrderBy(this IEnumerable x) => x.OrderByRand().OrderBy(e => e, StringComparer.OrdinalIgnoreCase);\r\n static IOrderedEnumerable OrderBy(this IEnumerable x, Func selector) => x.OrderByRand().OrderBy(selector, StringComparer.OrdinalIgnoreCase);\r\n static IOrderedEnumerable OrderByDescending(this IEnumerable x) => x.OrderByRand().OrderByDescending(e => e, StringComparer.OrdinalIgnoreCase);\r\n static IOrderedEnumerable OrderByDescending(this IEnumerable x, Func selector) => x.OrderByRand().OrderByDescending(selector, StringComparer.OrdinalIgnoreCase);\r\n static string Join(this IEnumerable x, string separator = \"\") => string.Join(separator, x);\r\n static uint xorshift { get { _xsi.MoveNext(); return _xsi.Current; } }\r\n static IEnumerator _xsi = _xsc();\r\n static IEnumerator _xsc() { uint x = 123456789, y = 362436069, z = 521288629, w = (uint)(DateTime.Now.Ticks & 0xffffffff); while (true) { var t = x ^ (x << 11); x = y; y = z; z = w; w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)); yield return w; } }\r\n static bool Chmax(this ref T lhs, T rhs) where T : struct, IComparable { if (lhs.CompareTo(rhs) < 0) { lhs = rhs; return true; } return false; }\r\n static bool Chmin(this ref T lhs, T rhs) where T : struct, IComparable { if (lhs.CompareTo(rhs) > 0) { lhs = rhs; return true; } return false; }\r\n static void Fill(this T[] array, T value) => array.AsSpan().Fill(value);\r\n static void Fill(this T[,] array, T value) => MemoryMarshal.CreateSpan(ref array[0, 0], array.Length).Fill(value);\r\n static void Fill(this T[,,] array, T value) => MemoryMarshal.CreateSpan(ref array[0, 0, 0], array.Length).Fill(value);\r\n static void Fill(this T[,,,] array, T value) => MemoryMarshal.CreateSpan(ref array[0, 0, 0, 0], array.Length).Fill(value);\r\n }\r\n}\r\nnamespace Library {\r\n class LIB_FastIO\r\n {\r\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\r\n public LIB_FastIO() { str = Console.OpenStandardInput(); }\r\n readonly Stream str;\r\n readonly byte[] buf = new byte[2048];\r\n int len, ptr;\r\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\r\n byte read()\r\n {\r\n if (ptr >= len)\r\n {\r\n ptr = 0;\r\n if ((len = str.Read(buf, 0, 2048)) <= 0)\r\n {\r\n return 0;\r\n }\r\n }\r\n return buf[ptr++];\r\n }\r\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\r\n char Char()\r\n {\r\n byte b = 0;\r\n do b = read();\r\n while (b < 33 || 126 < b);\r\n return (char)b;\r\n }\r\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\r\n virtual public string Scan()\r\n {\r\n var sb = new StringBuilder();\r\n for (var b = Char(); b >= 33 && b <= 126; b = (char)read())\r\n sb.Append(b);\r\n return sb.ToString();\r\n }\r\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\r\n virtual public long Long()\r\n {\r\n long ret = 0; byte b = 0; var ng = false;\r\n do b = read();\r\n while (b != '-' && (b < '0' || '9' < b));\r\n if (b == '-') { ng = true; b = read(); }\r\n for (; true; b = read())\r\n {\r\n if (b < '0' || '9' < b)\r\n return ng ? -ret : ret;\r\n else ret = (ret << 3) + (ret << 1) + b - '0';\r\n }\r\n }\r\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\r\n virtual public double Double() { return double.Parse(Scan(), CultureInfo.InvariantCulture); }\r\n }\r\n class LIB_FastIODebug : LIB_FastIO\r\n {\r\n Queue param = new Queue();\r\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\r\n string NextString() { if (param.Count == 0) foreach (var item in Console.ReadLine().Split(' ')) param.Enqueue(item); return param.Dequeue(); }\r\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\r\n public LIB_FastIODebug() { }\r\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\r\n public override string Scan() => NextString();\r\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\r\n public override long Long() => long.Parse(NextString());\r\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\r\n public override double Double() => double.Parse(NextString());\r\n }\r\n}\r\n", "lang_cluster": "C#", "tags": ["math", "dp", "combinatorics", "fft"], "code_uid": "6052a2f2f5102adcc9f75a0dbb026d39", "src_uid": "ae0320a57d73fab1d05f5d10fbdb9e1a", "difficulty": 2400.0, "exec_outcome": "PASSED"} {"lang": "C# 8", "source_code": "using System;\r\nusing System.Collections.Generic;\r\nusing System.IO;\r\nusing System.Linq;\r\nusing static System.Math;\r\nusing System.Text;\r\nusing System.Threading;\r\nusing System.Globalization;\r\nusing System.Runtime.CompilerServices;\r\nusing System.Runtime.InteropServices;\r\nusing Library;\r\n\r\nnamespace Program\r\n{\r\n public static class ProblemE\r\n {\r\n static bool SAIKI = false;\r\n static public int numberOfRandomCases = 0;\r\n static public void MakeTestCase(List _input, List _output, ref Func _outputChecker)\r\n {\r\n }\r\n static public void Solve()\r\n {\r\n var n = NN;\r\n var mod = (ulong)NN;\r\n var br = new LIB_BarrettReduction(mod);\r\n var dp = new ulong?[n + 1, n * (n - 1) / 2 + 1];\r\n Func calc = null;\r\n calc = (pn, pk) =>\r\n {\r\n if (pn == 1 && pk == 0) return 1;\r\n if (pn < 0 || pk < 0 || pk > pn * (pn - 1) / 2) return 0;\r\n if (dp[pn, pk].HasValue) return dp[pn, pk].Value;\r\n dp[pn, pk] = br.Reduce((calc(pn, pk - 1) + calc(pn - 1, pk) + mod - calc(pn - 1, pk - pn)));\r\n return dp[pn, pk].Value;\r\n };\r\n var beforeAns = 0UL;\r\n for (var N = 0L; N <= n; ++N)\r\n {\r\n var ans = br.Reduce(beforeAns * (ulong)N);\r\n for (var i = 0L; i < N; ++i)\r\n {\r\n for (var j = i + 1; j < N; ++j)\r\n {\r\n var sabun = j - i + 1;\r\n var ten = (N - 1) * (N - 2) / 2;\r\n var sum = 0UL;\r\n for (var k = 0L; k + sabun <= ten; ++k)\r\n {\r\n sum = br.Reduce(sum + calc(N - 1, k));\r\n ans += br.Reduce(sum * calc(N - 1, k + sabun));\r\n ans = br.Reduce(ans);\r\n }\r\n }\r\n }\r\n beforeAns = ans;\r\n }\r\n Console.WriteLine(beforeAns);\r\n }\r\n class Printer : StreamWriter\r\n {\r\n public override IFormatProvider FormatProvider { get { return CultureInfo.InvariantCulture; } }\r\n public Printer(Stream stream) : base(stream, new UTF8Encoding(false, true)) { base.AutoFlush = false; }\r\n public Printer(Stream stream, Encoding encoding) : base(stream, encoding) { base.AutoFlush = false; }\r\n }\r\n static LIB_FastIO fastio = new LIB_FastIODebug();\r\n static public void Main(string[] args) { if (args.Length == 0) { fastio = new LIB_FastIO(); Console.SetOut(new Printer(Console.OpenStandardOutput())); } if (SAIKI) { var t = new Thread(Solve, 134217728); t.Start(); t.Join(); } else Solve(); Console.Out.Flush(); }\r\n static long NN => fastio.Long();\r\n static double ND => fastio.Double();\r\n static string NS => fastio.Scan();\r\n static long[] NNList(long N) => Repeat(0, N).Select(_ => NN).ToArray();\r\n static double[] NDList(long N) => Repeat(0, N).Select(_ => ND).ToArray();\r\n static string[] NSList(long N) => Repeat(0, N).Select(_ => NS).ToArray();\r\n static long Count(this IEnumerable x, Func pred) => Enumerable.Count(x, pred);\r\n static IEnumerable Repeat(T v, long n) => Enumerable.Repeat(v, (int)n);\r\n static IEnumerable Range(long s, long c) => Enumerable.Range((int)s, (int)c);\r\n static IOrderedEnumerable OrderByRand(this IEnumerable x) => Enumerable.OrderBy(x, _ => xorshift);\r\n static IOrderedEnumerable OrderBy(this IEnumerable x) => Enumerable.OrderBy(x.OrderByRand(), e => e);\r\n static IOrderedEnumerable OrderBy(this IEnumerable x, Func selector) => Enumerable.OrderBy(x.OrderByRand(), selector);\r\n static IOrderedEnumerable OrderByDescending(this IEnumerable x) => Enumerable.OrderByDescending(x.OrderByRand(), e => e);\r\n static IOrderedEnumerable OrderByDescending(this IEnumerable x, Func selector) => Enumerable.OrderByDescending(x.OrderByRand(), selector);\r\n static IOrderedEnumerable OrderBy(this IEnumerable x) => x.OrderByRand().OrderBy(e => e, StringComparer.OrdinalIgnoreCase);\r\n static IOrderedEnumerable OrderBy(this IEnumerable x, Func selector) => x.OrderByRand().OrderBy(selector, StringComparer.OrdinalIgnoreCase);\r\n static IOrderedEnumerable OrderByDescending(this IEnumerable x) => x.OrderByRand().OrderByDescending(e => e, StringComparer.OrdinalIgnoreCase);\r\n static IOrderedEnumerable OrderByDescending(this IEnumerable x, Func selector) => x.OrderByRand().OrderByDescending(selector, StringComparer.OrdinalIgnoreCase);\r\n static string Join(this IEnumerable x, string separator = \"\") => string.Join(separator, x);\r\n static uint xorshift { get { _xsi.MoveNext(); return _xsi.Current; } }\r\n static IEnumerator _xsi = _xsc();\r\n static IEnumerator _xsc() { uint x = 123456789, y = 362436069, z = 521288629, w = (uint)(DateTime.Now.Ticks & 0xffffffff); while (true) { var t = x ^ (x << 11); x = y; y = z; z = w; w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)); yield return w; } }\r\n static bool Chmax(this ref T lhs, T rhs) where T : struct, IComparable { if (lhs.CompareTo(rhs) < 0) { lhs = rhs; return true; } return false; }\r\n static bool Chmin(this ref T lhs, T rhs) where T : struct, IComparable { if (lhs.CompareTo(rhs) > 0) { lhs = rhs; return true; } return false; }\r\n static void Fill(this T[] array, T value) => array.AsSpan().Fill(value);\r\n static void Fill(this T[,] array, T value) => MemoryMarshal.CreateSpan(ref array[0, 0], array.Length).Fill(value);\r\n static void Fill(this T[,,] array, T value) => MemoryMarshal.CreateSpan(ref array[0, 0, 0], array.Length).Fill(value);\r\n static void Fill(this T[,,,] array, T value) => MemoryMarshal.CreateSpan(ref array[0, 0, 0, 0], array.Length).Fill(value);\r\n }\r\n}\r\nnamespace Library {\r\n class LIB_BarrettReduction\r\n {\r\n ulong MOD;\r\n ulong mh;\r\n ulong ml;\r\n const ulong ALL1_32 = (ulong)~0U;\r\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\r\n public LIB_BarrettReduction(ulong mod)\r\n {\r\n MOD = mod;\r\n var m = ~0UL / MOD;\r\n unchecked { if (m * MOD + MOD == 0) ++m; }\r\n mh = m >> 32;\r\n ml = m & ALL1_32;\r\n }\r\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\r\n public ulong Reduce(ulong x)\r\n {\r\n var z = (x & ALL1_32) * ml;\r\n z = (x & ALL1_32) * mh + (x >> 32) * ml + (z >> 32);\r\n z = (x >> 32) * mh + (z >> 32);\r\n x -= z * MOD;\r\n return x < MOD ? x : x - MOD;\r\n }\r\n }\r\n class LIB_FastIO\r\n {\r\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\r\n public LIB_FastIO() { str = Console.OpenStandardInput(); }\r\n readonly Stream str;\r\n readonly byte[] buf = new byte[2048];\r\n int len, ptr;\r\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\r\n byte read()\r\n {\r\n if (ptr >= len)\r\n {\r\n ptr = 0;\r\n if ((len = str.Read(buf, 0, 2048)) <= 0)\r\n {\r\n return 0;\r\n }\r\n }\r\n return buf[ptr++];\r\n }\r\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\r\n char Char()\r\n {\r\n byte b = 0;\r\n do b = read();\r\n while (b < 33 || 126 < b);\r\n return (char)b;\r\n }\r\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\r\n virtual public string Scan()\r\n {\r\n var sb = new StringBuilder();\r\n for (var b = Char(); b >= 33 && b <= 126; b = (char)read())\r\n sb.Append(b);\r\n return sb.ToString();\r\n }\r\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\r\n virtual public long Long()\r\n {\r\n long ret = 0; byte b = 0; var ng = false;\r\n do b = read();\r\n while (b != '-' && (b < '0' || '9' < b));\r\n if (b == '-') { ng = true; b = read(); }\r\n for (; true; b = read())\r\n {\r\n if (b < '0' || '9' < b)\r\n return ng ? -ret : ret;\r\n else ret = (ret << 3) + (ret << 1) + b - '0';\r\n }\r\n }\r\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\r\n virtual public double Double() { return double.Parse(Scan(), CultureInfo.InvariantCulture); }\r\n }\r\n class LIB_FastIODebug : LIB_FastIO\r\n {\r\n Queue param = new Queue();\r\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\r\n string NextString() { if (param.Count == 0) foreach (var item in Console.ReadLine().Split(' ')) param.Enqueue(item); return param.Dequeue(); }\r\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\r\n public LIB_FastIODebug() { }\r\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\r\n public override string Scan() => NextString();\r\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\r\n public override long Long() => long.Parse(NextString());\r\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\r\n public override double Double() => double.Parse(NextString());\r\n }\r\n}\r\n", "lang_cluster": "C#", "tags": ["math", "dp", "combinatorics", "fft"], "code_uid": "85c635026f8a39aacbb8fd560f2680a4", "src_uid": "ae0320a57d73fab1d05f5d10fbdb9e1a", "difficulty": 2400.0, "exec_outcome": "PASSED"} {"lang": "C# 8", "source_code": "using System;\r\nusing System.Linq;\r\nusing CompLib.Util;\r\nusing System.Threading;\r\nusing System.IO;\r\nusing CompLib.Mathematics;\r\nusing CompLib.Algorithm;\r\n\r\npublic class Program\r\n{\r\n int N;\r\n int Mod;\r\n public void Solve()\r\n {\r\n var sc = new Scanner();\r\n N = sc.NextInt();\r\n ModInt.Mod = sc.NextInt();\r\n\r\n var m = new ModInt[N + 1][];\r\n m[1] = new ModInt[1] { 1 };\r\n for (int i = 2; i <= N; i++)\r\n {\r\n // 1\u306e\u4f4d\u7f6e\r\n int max = (i - 1) * i / 2;\r\n m[i] = new ModInt[max + 1];\r\n\r\n for (int j = 0; j < i; j++)\r\n {\r\n for (int k = 0; k < m[i - 1].Length; k++)\r\n {\r\n m[i][j + k] += m[i - 1][k];\r\n }\r\n }\r\n }\r\n\r\n var m2 = new ModInt[N + 1][];\r\n for (int i = 1; i <= N; i++)\r\n {\r\n m2[i] = new ModInt[m[i].Length + 1];\r\n for (int j = 0; j < m[i].Length; j++)\r\n {\r\n m2[i][j + 1] = m2[i][j] + m[i][j];\r\n }\r\n }\r\n\r\n\r\n ModInt ans = 0;\r\n\r\n for (int i = 0; i <= N - 2; i++)\r\n {\r\n // \u5148\u982di\u500b\u540c\u3058\r\n // \u9078\u3073\u65b9\r\n ModInt q = 1;\r\n for (int j = 0; j < i; j++) q *= N - j;\r\n\r\n ModInt w = 0;\r\n // i\u500b\u76ee \r\n for (int j = 0; j < N - i; j++)\r\n {\r\n for (int k = 0; k < j; k++)\r\n {\r\n // \u6b8b\u308a N-i-1\u500b\u306e\u5206\u5e03 m[N-i-1]\r\n // i+1\u500b\u76ee\u306e\u8ee2\u5012\u6570\u3078\u306e\u5bc4\u4e0e j,k\r\n\r\n for (int l = j - k; l < m[N - i - 1].Length; l++)\r\n {\r\n w += m2[N - i - 1][l - (j - k)] * m[N - i - 1][l];\r\n }\r\n }\r\n }\r\n\r\n ans += q * w;\r\n }\r\n Console.WriteLine(ans);\r\n }\r\n /*\r\n 1 0\r\n 1\r\n 2 0\r\n 1 1\r\n 3 0\r\n 1 2 2 1\r\n 4 17\r\n 1 3 5 6 5 3 1\r\n 5 904\r\n 1 4 9 15 20 22 20 15 9 4 1\r\n 6 45926\r\n 1 5 14 29 49 71 90 101 101 90 71 49 29 14 5 1\r\n 7 2725016\r\n 1 6 20 49 98 169 259 359 455 531 573 573 531 455 359 259 169 98 49 20 6 1\r\n 8 196884712\r\n 1 7 27 76 174 343 602 961 1415 1940 2493 3017 3450 3736 3836 3736 3450 3017 2493 1940 1415 961 602 343 174 76 27 7 1 \r\n */\r\n\r\n void F(int n)\r\n {\r\n int[] p = new int[n];\r\n for (int i = 0; i < n; i++)\r\n {\r\n p[i] = i;\r\n }\r\n\r\n int[] cnt = new int[(n - 1) * n / 2 + 1];\r\n\r\n long ans = 0;\r\n do\r\n {\r\n int c = 0;\r\n for (int i = 0; i < n; i++)\r\n {\r\n for (int j = i + 1; j < n; j++)\r\n {\r\n if (p[i] > p[j]) c++;\r\n }\r\n }\r\n\r\n for (int i = c + 1; i < cnt.Length; i++)\r\n {\r\n ans += cnt[i];\r\n }\r\n\r\n cnt[c]++;\r\n } while (Algorithm.NextPermutation(p));\r\n\r\n Console.WriteLine($\"{n} {ans}\");\r\n Console.WriteLine(string.Join(\" \", cnt));\r\n\r\n // 5 9 14 20 27\r\n }\r\n\r\n public static void Main(string[] args) => new Program().Solve();\r\n // public static void Main(string[] args) => new Thread(new Program().Solve, 1 << 27).Start();\r\n}\r\n\r\n\r\n\r\nnamespace CompLib.Algorithm\r\n{\r\n using System;\r\n using System.Collections.Generic;\r\n public static partial class Algorithm\r\n {\r\n private static void Swap(ref T a, ref T b)\r\n {\r\n T tmp = a;\r\n a = b;\r\n b = tmp;\r\n }\r\n\r\n private static void Reverse(T[] array, int begin)\r\n {\r\n // [begin, array.Length)\u3092\u53cd\u8ee2\r\n if (array.Length - begin >= 2)\r\n {\r\n for (int i = begin, j = array.Length - 1; i < j; i++, j--)\r\n {\r\n Swap(ref array[i], ref array[j]);\r\n }\r\n }\r\n }\r\n\r\n /// \r\n /// array\u3092\u8f9e\u66f8\u9806\u3067\u6b21\u306e\u9806\u5217\u306b\u3059\u308b \u5b58\u5728\u3057\u306a\u3044\u3068\u304d\u306ffalse\u3092\u8fd4\u3059\r\n /// \r\n /// \r\n /// \r\n /// \r\n public static bool NextPermutation(T[] array, Comparison comparison)\r\n {\r\n for (int i = array.Length - 2; i >= 0; i--)\r\n {\r\n if (comparison(array[i], array[i + 1]) < 0)\r\n {\r\n int j = array.Length - 1;\r\n for (; j > i; j--)\r\n {\r\n if (comparison(array[i], array[j]) < 0)\r\n {\r\n break;\r\n }\r\n }\r\n\r\n Swap(ref array[i], ref array[j]);\r\n Reverse(array, i + 1);\r\n return true;\r\n }\r\n }\r\n\r\n return false;\r\n }\r\n\r\n /// \r\n /// array\u3092\u8f9e\u66f8\u9806\u3067\u6b21\u306e\u9806\u5217\u306b\u3059\u308b \u5b58\u5728\u3057\u306a\u3044\u3068\u304d\u306ffalse\u3092\u8fd4\u3059\r\n /// \r\n /// \r\n /// \r\n /// \r\n public static bool NextPermutation(T[] array, Comparer comparer) =>\r\n NextPermutation(array, comparer.Compare);\r\n\r\n /// \r\n /// array\u3092\u8f9e\u66f8\u9806\u3067\u6b21\u306e\u9806\u5217\u306b\u3059\u308b \u5b58\u5728\u3057\u306a\u3044\u3068\u304d\u306ffalse\u3092\u8fd4\u3059\r\n /// \r\n /// \r\n /// \r\n /// \r\n public static bool NextPermutation(T[] array) => NextPermutation(array, Comparer.Default);\r\n }\r\n}\r\n\r\n\r\n// https://bitbucket.org/camypaper/complib\r\nnamespace CompLib.Mathematics\r\n{\r\n #region ModInt\r\n /// \r\n /// [0,) \u307e\u3067\u306e\u5024\u3092\u53d6\u308b\u3088\u3046\u306a\u6570\r\n /// \r\n public struct ModInt\r\n {\r\n /// \r\n /// \u5270\u4f59\u3092\u53d6\u308b\u5024\uff0e\r\n /// \r\n public static long Mod = (int)1e9 + 7;\r\n // public const long Mod = 998244353;\r\n\r\n /// \r\n /// \u5b9f\u969b\u306e\u6570\u5024\uff0e\r\n /// \r\n public long num;\r\n /// \r\n /// \u5024\u304c \u3067\u3042\u308b\u3088\u3046\u306a\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u3092\u69cb\u7bc9\u3057\u307e\u3059\uff0e\r\n /// \r\n /// \u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u304c\u6301\u3064\u5024\r\n /// \u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u306e\u554f\u984c\u4e0a\uff0c\u30b3\u30f3\u30b9\u30c8\u30e9\u30af\u30bf\u5185\u3067\u306f\u5270\u4f59\u3092\u53d6\u308a\u307e\u305b\u3093\uff0e\u305d\u306e\u305f\u3081\uff0c \u2208 [0,) \u3092\u6e80\u305f\u3059\u3088\u3046\u306a \u3092\u6e21\u3057\u3066\u304f\u3060\u3055\u3044\uff0e\u3053\u306e\u30b3\u30f3\u30b9\u30c8\u30e9\u30af\u30bf\u306f O(1) \u3067\u5b9f\u884c\u3055\u308c\u307e\u3059\uff0e\r\n public ModInt(long n) { num = n; }\r\n /// \r\n /// \u3053\u306e\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u306e\u6570\u5024\u3092\u6587\u5b57\u5217\u306b\u5909\u63db\u3057\u307e\u3059\uff0e\r\n /// \r\n /// [0,) \u306e\u7bc4\u56f2\u5185\u306e\u6574\u6570\u3092 10 \u9032\u8868\u8a18\u3057\u305f\u3082\u306e\uff0e\r\n public override string ToString() { return num.ToString(); }\r\n public static ModInt operator +(ModInt l, ModInt r) { l.num += r.num; if (l.num >= Mod) l.num -= Mod; return l; }\r\n public static ModInt operator -(ModInt l, ModInt r) { l.num -= r.num; if (l.num < 0) l.num += Mod; return l; }\r\n public static ModInt operator *(ModInt l, ModInt r) { return new ModInt(l.num * r.num % Mod); }\r\n public static implicit operator ModInt(long n) { n %= Mod; if (n < 0) n += Mod; return new ModInt(n); }\r\n\r\n /// \r\n /// \u4e0e\u3048\u3089\u308c\u305f 2 \u3064\u306e\u6570\u5024\u304b\u3089\u3079\u304d\u5270\u4f59\u3092\u8a08\u7b97\u3057\u307e\u3059\uff0e\r\n /// \r\n /// \u3079\u304d\u4e57\u306e\u5e95\r\n /// \u3079\u304d\u6307\u6570\r\n /// \u7e70\u308a\u8fd4\u3057\u4e8c\u4e57\u6cd5\u306b\u3088\u308a O(N log N) \u3067\u5b9f\u884c\u3055\u308c\u307e\u3059\uff0e\r\n public static ModInt Pow(ModInt v, long k) { return Pow(v.num, k); }\r\n\r\n /// \r\n /// \u4e0e\u3048\u3089\u308c\u305f 2 \u3064\u306e\u6570\u5024\u304b\u3089\u3079\u304d\u5270\u4f59\u3092\u8a08\u7b97\u3057\u307e\u3059\uff0e\r\n /// \r\n /// \u3079\u304d\u4e57\u306e\u5e95\r\n /// \u3079\u304d\u6307\u6570\r\n /// \u7e70\u308a\u8fd4\u3057\u4e8c\u4e57\u6cd5\u306b\u3088\u308a O(N log N) \u3067\u5b9f\u884c\u3055\u308c\u307e\u3059\uff0e\r\n public static ModInt Pow(long v, long k)\r\n {\r\n long ret = 1;\r\n for (k %= Mod - 1; k > 0; k >>= 1, v = v * v % Mod)\r\n if ((k & 1) == 1) ret = ret * v % Mod;\r\n return new ModInt(ret);\r\n }\r\n /// \r\n /// \u4e0e\u3048\u3089\u308c\u305f\u6570\u306e\u9006\u5143\u3092\u8a08\u7b97\u3057\u307e\u3059\uff0e\r\n /// \r\n /// \u9006\u5143\u3092\u53d6\u308b\u5bfe\u8c61\u3068\u306a\u308b\u6570\r\n /// \u9006\u5143\u3068\u306a\u308b\u3088\u3046\u306a\u5024\r\n /// \u6cd5\u304c\u7d20\u6570\u3067\u3042\u308b\u3053\u3068\u3092\u4eee\u5b9a\u3057\u3066\uff0c\u30d5\u30a7\u30eb\u30de\u30fc\u306e\u5c0f\u5b9a\u7406\u306b\u5f93\u3063\u3066\u9006\u5143\u3092 O(log N) \u3067\u8a08\u7b97\u3057\u307e\u3059\uff0e\r\n public static ModInt Inverse(ModInt v) { return Pow(v, Mod - 2); }\r\n }\r\n #endregion\r\n #region Binomial Coefficient\r\n public class BinomialCoefficient\r\n {\r\n public ModInt[] fact, ifact;\r\n public BinomialCoefficient(int n)\r\n {\r\n fact = new ModInt[n + 1];\r\n ifact = new ModInt[n + 1];\r\n fact[0] = 1;\r\n for (int i = 1; i <= n; i++)\r\n fact[i] = fact[i - 1] * i;\r\n ifact[n] = ModInt.Inverse(fact[n]);\r\n for (int i = n - 1; i >= 0; i--)\r\n ifact[i] = ifact[i + 1] * (i + 1);\r\n ifact[0] = ifact[1];\r\n }\r\n public ModInt this[int n, int r]\r\n {\r\n get\r\n {\r\n if (n < 0 || n >= fact.Length || r < 0 || r > n) return 0;\r\n return fact[n] * ifact[n - r] * ifact[r];\r\n }\r\n }\r\n public ModInt RepeatedCombination(int n, int k)\r\n {\r\n if (k == 0) return 1;\r\n return this[n + k - 1, k];\r\n }\r\n }\r\n #endregion\r\n}\r\n\r\n\r\nnamespace CompLib.Util\r\n{\r\n using System;\r\n using System.Linq;\r\n\r\n class Scanner\r\n {\r\n private string[] _line;\r\n private int _index;\r\n private const char Separator = ' ';\r\n\r\n public Scanner()\r\n {\r\n _line = new string[0];\r\n _index = 0;\r\n }\r\n\r\n public string Next()\r\n {\r\n if (_index >= _line.Length)\r\n {\r\n string s;\r\n do\r\n {\r\n s = Console.ReadLine();\r\n } while (s.Length == 0);\r\n\r\n _line = s.Split(Separator);\r\n _index = 0;\r\n }\r\n\r\n return _line[_index++];\r\n }\r\n\r\n public string ReadLine()\r\n {\r\n _index = _line.Length;\r\n return Console.ReadLine();\r\n }\r\n\r\n public int NextInt() => int.Parse(Next());\r\n public long NextLong() => long.Parse(Next());\r\n public double NextDouble() => double.Parse(Next());\r\n public decimal NextDecimal() => decimal.Parse(Next());\r\n public char NextChar() => Next()[0];\r\n public char[] NextCharArray() => Next().ToCharArray();\r\n\r\n public string[] Array()\r\n {\r\n string s = Console.ReadLine();\r\n _line = s.Length == 0 ? new string[0] : s.Split(Separator);\r\n _index = _line.Length;\r\n return _line;\r\n }\r\n\r\n public int[] IntArray() => Array().Select(int.Parse).ToArray();\r\n public long[] LongArray() => Array().Select(long.Parse).ToArray();\r\n public double[] DoubleArray() => Array().Select(double.Parse).ToArray();\r\n public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();\r\n }\r\n}\r\n", "lang_cluster": "C#", "tags": ["math", "dp", "combinatorics", "fft"], "code_uid": "36b5e3a468d778995d77c977925b3dc8", "src_uid": "ae0320a57d73fab1d05f5d10fbdb9e1a", "difficulty": 2400.0, "exec_outcome": "PASSED"} {"lang": "C# 8", "source_code": "\ufeffusing System.Xml;\r\nusing System.ComponentModel.Design;\r\nusing System.Security.AccessControl;\r\nusing System.Globalization;\r\nusing System.Text;\r\nusing System.Linq;\r\nusing System.Collections.Generic;\r\nusing System;\r\n\r\nnamespace CodeForce\r\n{\r\n class Program\r\n {\r\n static void Main(string[] args)\r\n {\r\n var arr = Console.ReadLine().Split(' ');\r\n var rows = Int32.Parse(arr[0]);\r\n var cols = Int32.Parse(arr[1]);\r\n Console.WriteLine(GetCount(rows,cols));\r\n } \r\n\r\n\r\n\r\n private static long GetCount(int rows, int cols)\r\n {\r\n if(rows == 1)\r\n {\r\n return 1;\r\n }\r\n var res = 1L;\r\n var maxPows = new int[rows+1];\r\n var cntArr = GetCntArr(cols);\r\n for(var i = 2;i <= rows;i++)\r\n {\r\n var tmp = i;\r\n for(var j=2;j();\r\n for(var i =1;i<=rows;i++)\r\n {\r\n var tmp = 1;\r\n for(var j=1;j<=cols;j++)\r\n {\r\n tmp*=i;\r\n set.Add(tmp);\r\n }\r\n }\r\n return set.Count;\r\n }\r\n\r\n \r\n\r\n\r\n \r\n\r\n\r\n\r\n }\r\n}\r\n", "lang_cluster": "C#", "tags": ["brute force", "math", "dp", "number theory"], "code_uid": "da9df2f3dc5dd2ef2d94fdab2b280f90", "src_uid": "6ca310cb0b6fc4e62e63a731cd55aead", "difficulty": 2200.0, "exec_outcome": "PASSED"} {"lang": "C# 8", "source_code": "\ufeffusing System.Xml;\r\nusing System.ComponentModel.Design;\r\nusing System.Security.AccessControl;\r\nusing System.Globalization;\r\nusing System.Text;\r\nusing System.Linq;\r\nusing System.Collections.Generic;\r\nusing System;\r\n\r\nnamespace CodeForce\r\n{\r\n class Program\r\n {\r\n static void Main(string[] args)\r\n {\r\n var arr = Console.ReadLine().Split(' ');\r\n var rows = Int32.Parse(arr[0]);\r\n var cols = Int32.Parse(arr[1]);\r\n Console.WriteLine(GetCount(rows,cols));\r\n \r\n } \r\n\r\n\r\n\r\n private static long GetCount(int rows, int cols)\r\n {\r\n if(rows == 1)\r\n {\r\n return 1;\r\n }\r\n var res = 1L;\r\n var maxPows = new int[rows+1];\r\n var cntArr = GetCntArr(cols);\r\n for(var i = 2;i <= rows;i++)\r\n {\r\n var tmp = i;\r\n for(var j=2;j();\r\n for(var i =1;i<=rows;i++)\r\n {\r\n var tmp = 1;\r\n for(var j=1;j<=cols;j++)\r\n {\r\n tmp*=i;\r\n set.Add(tmp);\r\n }\r\n }\r\n return set.Count;\r\n }\r\n\r\n \r\n\r\n\r\n \r\n\r\n\r\n\r\n }\r\n}\r\n", "lang_cluster": "C#", "tags": ["brute force", "math", "dp", "number theory"], "code_uid": "37ed91022b7b3881dd455166caa20609", "src_uid": "6ca310cb0b6fc4e62e63a731cd55aead", "difficulty": 2200.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\n\npublic sealed class Program {\n\n public Program() {\n String[] token = Console.ReadLine().Split();\n Int32 b = Int32.Parse(token[0]), d = Int32.Parse(token[1]), i, j, cnt;\n String a = Console.ReadLine(), c = Console.ReadLine();\n Int32[] map = new Int32[c.Length];\n for (i = 0; i < c.Length; map[i++] = cnt) {\n for (j = cnt = 0; j < a.Length; ++j) {\n if (c[(i + cnt) % c.Length] == a[j]) {\n ++cnt;\n }\n }\n }\n for (cnt = i = 0; i < b; ++i) {\n cnt += map[cnt % c.Length];\n }\n Console.WriteLine(cnt / (c.Length * d));\n }\n\n // stuff cutline\n\n static Int32 ReadInt() {\n Boolean neg = false;\n Int32 ch, ans = 0;\n do {\n ch = Console.Read();\n neg |= ch == (Int32)'-';\n } while (!Char.IsDigit((Char)ch));\n do {\n ans = ans * 10 + (ch & 0xf);\n ch = Console.Read();\n } while (Char.IsDigit((Char)ch));\n return neg ? -ans : ans;\n }\n\n public static void Main() {\n#if DEBUG\n Console.SetIn(new System.IO.StreamReader(\"..\\\\..\\\\in.txt\"));\n#endif\n var root = new Program();\n Console.Out.Flush();\n }\n\n}", "lang_cluster": "C#", "tags": ["dfs and similar", "strings"], "code_uid": "058f34cbad5aa9522a05191469b39d66", "src_uid": "5ea0351ac9f949dedae1928bfb7ebffa", "difficulty": 2000.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\n\nnamespace CodeForces.Solutions.c314_187_1\n{\n\tpublic class Program2\n\t{\n\t\tpublic static void Main()\n\t\t{\n\t\t\tchecked\n\t\t\t{\n\t\t\t\tvar s = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();\n\t\t\t\tvar b = s[0];\n\t\t\t\tvar d = s[1];\n\n\t\t\t\tvar s1 = Console.ReadLine();\n\t\t\t\tvar s2 = Console.ReadLine();\n\n\t\t\t\tvar adds = new int[s2.Length];\n\t\t\t\tvar follows = new int[s2.Length];\n\n\t\t\t\tfor (var i = 0; i < s2.Length; i++)\n\t\t\t\t{\n\t\t\t\t\tvar index = i;\n\t\t\t\t\tfor (var j = 0; j < s1.Length; j++)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (s2[index] == s1[j])\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tindex++;\n\t\t\t\t\t\t\tif (index == s2.Length)\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tindex = 0;\n\t\t\t\t\t\t\t\tadds[i]++;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tfollows[i] = index;\n\t\t\t\t}\n\n\t\t\t\tvar x = 0;\n\t\t\t\tvar p = 0;\n\t\t\t\tfor (var i = 0; i < b; i++)\n\t\t\t\t{\n\t\t\t\t\tp += adds[x];\n\t\t\t\t\tx = follows[x];\n\t\t\t\t}\n\n\t\t\t\tConsole.WriteLine(p/d);\n\t\t\t}\n\t\t}\n\t}\n}", "lang_cluster": "C#", "tags": ["dfs and similar", "strings"], "code_uid": "27cd9e289d650976595a22c6dea06e29", "src_uid": "5ea0351ac9f949dedae1928bfb7ebffa", "difficulty": 2000.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Diagnostics;\nusing System.Globalization;\nusing System.IO;\nusing System.Linq;\nusing System.Numerics;\nusing System.Text;\nusing System.Threading;\n\nnamespace ReadWriteTemplate\n{\n public static class Solver\n {\n private static void SolveCase()\n {\n long n = ReadLong();\n var a = new int[10];\n while (n > 0)\n {\n a[n % 10]++;\n n /= 10;\n }\n\n long[] f = new long[20];\n f[0] = 1;\n for (int i = 1; i < 19; i++)\n {\n f[i] = i * f[i - 1];\n }\n\n Calc(0, a, new int[10], f);\n\n Writer.WriteLine(Ans);\n }\n\n private static void Calc(int t, int[] a, int[] b, long[] f)\n {\n if (t > 9)\n {\n int sum = b.Sum();\n for (int i = 1; i < 10; i++)\n {\n if (b[i] > 0)\n {\n b[i]--;\n\n long d = f[sum - 1];\n for (int j = 0; j < 10; j++)\n {\n d /= f[b[j]];\n }\n Ans += d;\n\n b[i]++;\n }\n }\n return;\n }\n\n if (a[t] > 0)\n {\n for (int i = 0; i < a[t]; i++)\n {\n b[t] = i + 1;\n Calc(t + 1, a, b, f);\n }\n }\n else\n {\n b[t] = 0;\n Calc(t + 1, a, b, f);\n }\n }\n\n public static long Ans = 0;\n\n public static void Solve()\n {\n SolveCase();\n\n /*var sw = Stopwatch.StartNew();*/\n\n /*int T = ReadInt();\n for (int i = 0; i < T; i++)\n {\n Writer.Write(\"Case #{0}: \", i + 1);\n SolveCase();\n }*/\n\n /*sw.Stop();\n Console.WriteLine(sw.ElapsedMilliseconds);*/\n }\n\n public static void Main()\n {\n Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;\n\n#if DEBUG\n //Reader = Console.In; Writer = Console.Out;\n Reader = File.OpenText(\"input.txt\"); Writer = File.CreateText(\"output.txt\");\n#else\n Reader = Console.In; Writer = Console.Out;\n#endif\n\n // Solve();\n Thread thread = new Thread(Solve, 64 * 1024 * 1024);\n thread.CurrentCulture = CultureInfo.InvariantCulture;\n thread.Start();\n thread.Join();\n\n Reader.Close();\n Writer.Close();\n }\n\n public static IOrderedEnumerable OrderByWithShuffle(this IEnumerable source, Func keySelector)\n {\n return source.Shuffle().OrderBy(keySelector);\n }\n\n public static T[] Shuffle(this IEnumerable source)\n {\n T[] result = source.ToArray();\n Random rnd = new Random();\n for (int i = result.Length - 1; i >= 1; i--)\n {\n int k = rnd.Next(i + 1);\n T tmp = result[k];\n result[k] = result[i];\n result[i] = tmp;\n }\n return result;\n }\n\n #region Read/Write\n\n private static TextReader Reader;\n\n private static TextWriter Writer;\n\n private static Queue CurrentLineTokens = new Queue();\n\n private static string[] ReadAndSplitLine()\n {\n return Reader.ReadLine().Split(new[] { ' ', '\\t' }, StringSplitOptions.RemoveEmptyEntries);\n }\n\n public static string ReadToken()\n {\n while (CurrentLineTokens.Count == 0)\n CurrentLineTokens = new Queue(ReadAndSplitLine());\n return CurrentLineTokens.Dequeue();\n }\n\n public static string ReadLine()\n {\n return Reader.ReadLine();\n }\n\n public static int ReadInt()\n {\n return int.Parse(ReadToken());\n }\n\n public static long ReadLong()\n {\n return long.Parse(ReadToken());\n }\n\n public static double ReadDouble()\n {\n return double.Parse(ReadToken(), CultureInfo.InvariantCulture);\n }\n\n public static int[] ReadIntArray()\n {\n return ReadAndSplitLine().Select(int.Parse).ToArray();\n }\n\n public static long[] ReadLongArray()\n {\n return ReadAndSplitLine().Select(long.Parse).ToArray();\n }\n\n public static double[] ReadDoubleArray()\n {\n return ReadAndSplitLine().Select(s => double.Parse(s, CultureInfo.InvariantCulture)).ToArray();\n }\n\n public static int[][] ReadIntMatrix(int numberOfRows)\n {\n int[][] matrix = new int[numberOfRows][];\n for (int i = 0; i < numberOfRows; i++)\n matrix[i] = ReadIntArray();\n return matrix;\n }\n\n public static string[] ReadLines(int quantity)\n {\n string[] lines = new string[quantity];\n for (int i = 0; i < quantity; i++)\n lines[i] = Reader.ReadLine().Trim();\n return lines;\n }\n\n public static void WriteArray(IEnumerable array)\n {\n Writer.WriteLine(string.Join(\" \", array));\n }\n\n #endregion\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "math", "combinatorics"], "code_uid": "b40280ae86b75aedd340980e99908682", "src_uid": "7f4e533f49b73cc2b96b4c56847295f2", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\n\nclass TEST{\n\tstatic void Main(){\n\t\tSol mySol =new Sol();\n\t\tmySol.Solve();\n\t}\n}\n\nclass Sol{\n\tpublic void Solve(){\n\t\t\n\t\tlong[][] nCr = new long[21][];\n\t\tfor(int i=0;i<21;i++){\n\t\t\tnCr[i] = new long[21];\n\t\t}\n\t\t\n\t\tnCr[0][0] = 1;\n\t\tfor(int i=1;i<21;i++){\n\t\t\tnCr[i][0] = 1;\n\t\t\tfor(int j=1;j<21;j++){\n\t\t\t\tnCr[i][j] = nCr[i-1][j] + nCr[i-1][j-1];\n\t\t\t}\n\t\t}\n\t\tlong[] dp = new long[N+1];\n\t\tdp[0] = 1;\n\t\tint[] cnt = new int[10];\n\t\tfor(int i=0;i=0;v--){\n\t\t\tif(cnt[v] == 0) continue;\n//Console.WriteLine(String.Join(\" \", dp));\n\t\t\tlong[] ndp = new long[N+1];\n\t\t\tfor(int l=0;l<=N;l++){\n\t\t\t\tif(dp[l] == 0) continue;\n\t\t\t\tfor(int c = 1; c <= cnt[v]; c++){\n\t\t\t\t\tint m = l + 1;\n\t\t\t\t\tif(v == 0) m--;\n\t\t\t\t\tndp[l + c] += dp[l] * nCr[m - 1 + c][c];\n\t\t\t\t}\n\t\t\t}\n\t\t\tdp = ndp;\n//Console.WriteLine(\"ndpp:{0}\",String.Join(\" \", dp));\n\t\t}\n\t\t\n\t\tConsole.WriteLine(dp.Sum());\n\t}\n\tint N;\n\tString S;\n\tpublic Sol(){\n\t\tS = rs();\n\t\tN = S.Length;\n\t}\n\n\tstatic String rs(){return Console.ReadLine();}\n\tstatic int ri(){return int.Parse(Console.ReadLine());}\n\tstatic long rl(){return long.Parse(Console.ReadLine());}\n\tstatic double rd(){return double.Parse(Console.ReadLine());}\n\tstatic String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}\n\tstatic int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}\n\tstatic long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}\n\tstatic double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}\n}\n", "lang_cluster": "C#", "tags": ["brute force", "math", "combinatorics"], "code_uid": "5d6d9cbfcd580afa4e22f16accc407d5", "src_uid": "7f4e533f49b73cc2b96b4c56847295f2", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.IO;\n\nclass Program\n{\n\tint n, m, res;\n\tint mod = 1000000007;\n\tint add(int x, int y)\n\t{\n\t\tx += y;\n\t\treturn x < mod ? x : x - mod;\n\t}\n\tint mul(int x, int y)\n\t{\n\t\treturn Convert.ToInt32(Convert.ToInt64(x) * y % mod);\n\t}\n\n\tint gcd(int x, int y)\n\t{\n\t\treturn y != 0 ? gcd(y, x % y) : x;\n\t}\n\tprivate int[] x = new int[6];\n\tvoid dfs(int i)\n\t{\n\t\tif (i == 6)\n\t\t{\n\t\t\tif ((x[0] * x[3] + x[2] * x[5] + x[4] * x[1] + x[1] * x[2] + x[3] * x[4] + x[5] * x[0]) % 2 == 0)\n\t\t\t{\n\t\t\t\tint now = 1;\n\t\t\t\tfor(int j=0; j<6; j++)\n\t\t\t\t\tif (j % 2 == 0)\n\t\t\t\t\t\tnow = mul(now, x[j] == 1 ? (n + 1) / 2 : n / 2 + 1);\n\t\t\t\t\telse\n\t\t\t\t\t\tnow = mul(now, x[j] == 1 ? (m + 1) / 2 : m / 2 + 1);\n\t\t\t\tres = add(res, now);\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\t\tx[i] = 0;\n\t\tdfs(i + 1);\n\t\tx[i] = 1;\n\t\tdfs(i + 1);\n\t}\n\tvoid run()\n\t{\n\t\tString[] str = Console.ReadLine().Split(' ');\n\t\tn = Convert.ToInt32(str[0]);\n\t\tm = Convert.ToInt32(str[1]);\n\t\tres = 0;\n\t\tdfs(0);\n\t\tint res2 = 0;\n\t\tfor (int i = 0; i <= n; i++)\n\t\t\tfor (int j = 0; j <= m; j++)\n\t\t\t\tif (i + j > 0)\n\t\t\t\t{\n\t\t\t\t\tint x = gcd(i, j) - 1;\n\t\t\t\t\tres2 = add(res2, mul(i > 0 && j > 0 ? x * 2 : x, (n + 1 - i) * (m + 1 - j)));\n\t\t\t\t}\n\t\t\t\t\t\n\t\tint q = (n + 1) * (m + 1);\n\t\tres2 = add(res2, Convert.ToInt32(Convert.ToInt64(q) * (q - 1) / 2 % mod));\n\t\tres2 = mul(res2, 6);\n\t\tres2 = add(res2, q);\n\t\tConsole.WriteLine(add(res, mod - res2));\n\t}\n\tstatic void Main(String[] args)\n\t{\n\t\tnew Program().run();\n\t}\n}", "lang_cluster": "C#", "tags": ["math", "geometry"], "code_uid": "53a061639c18a940be3bd8f8aec6a4f1", "src_uid": "984788e4b4925c15c9c6f31e42f2f8fa", "difficulty": 2500.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\n\nclass TEST{\n\tstatic void Main(){\n\t\tSol mySol =new Sol();\n\t\tmySol.Solve();\n\t}\n}\n\nclass Sol{\n\tpublic void Solve(){\n\t\t\n\t\t\n\t\t\n\t\tfor(int i=0;i<4;i++){\n\t\t\tif(Inside(A[2*i], A[2*i+1], B)){\n\t\t\t\tConsole.WriteLine(\"YES\");\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif(Inside(B[2*i], B[2*i+1], A)){\n\t\t\t\tConsole.WriteLine(\"YES\");\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t\tfor(int i=0;i<4;i++){\n\t\t\tfor(int j=0;j<4;j++){\n\t\t\t\tif(OnLine(A[2*i], A[2*i+1], B[2*j], B[2*j+1], B[(2*j+2)%8], B[(2*j+3)%8])){\n\t\t\t\t\tConsole.WriteLine(\"YES\");\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif(OnLine(B[2*i], B[2*i+1], A[2*j], A[2*j+1], A[(2*j+2)%8], A[(2*j+3)%8])){\n\t\t\t\t\tConsole.WriteLine(\"YES\");\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tfor(int i=0;i<4;i++){\n\t\t\tfor(int j=0;j<4;j++){\n\t\t\t\tif(Intersects(A[2*i], A[2*i+1], A[(2*i+2)%8], A[(2*i+3)%8], B[2*j], B[2*j+1], B[(2*j+2)%8], B[(2*j+3)%8])){\n\t\t\t\t\tConsole.WriteLine(\"YES\");\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tConsole.WriteLine(\"NO\");\n\t\t\n\t}\n\t\n\tbool Inside(int x, int y, int[] rect){\n\t\tvar h = new HashSet();\n\t\tfor(int i=0;i<4;i++){\n\t\t\tvar d = det(rect[2*i] - x, rect[2*i+1] - y, rect[(2*i+2)%8] - x, rect[(2*i+3)%8] - y);\n\t\t\tif(d == 0) return false;\n\t\t\td = d > 0 ? 1 : -1;\n\t\t\th.Add(d); \n\t\t}\n\t\treturn h.Count == 1;\n\t}\n\tbool OnLine(int x, int y, int x1, int y1, int x2, int y2){\n\t\tif(x == x1 && y == y1) return true;\n\t\tif(x == x2 && y == y2) return true;\n\t\tif(det(x1 - x, y1 - y, x2 - x, y2 - y) != 0) return false;\n\t\treturn (x1 - x) * (x2 - x) + (y1 - y) * (y2 - y) < 0; \n\t}\n\tbool Intersects(int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4){\n\t\t\n\t\tint d0 = det0(x3 - x1, y3 - y1, x2 - x1, y2 - y1);\n\t\tint d1 = det0(x4 - x1, y4 - y1, x2 - x1, y2 - y1);\n\t\tif(d0 == 0 || d1 == 0 || d0 == d1) return false;\n\t\tint d2 = det0(x1 - x3, y1 - y3, x4 - x3, y4 - y3);\n\t\tint d3 = det0(x2 - x3, y2 - y3, x4 - x3, y4 - y3);\n\t\tif(d2 == 0 || d3 == 0 || d2 == d3) return false;\n\t\treturn true;\n\t\t\n\t}\n\t\n\t\n\t\n\tint det (int a, int b, int c, int d){\n\t\treturn a * d - b * c;\n\t}\n\tint det0 (int a, int b, int c, int d){\n\t\tvar ret = a * d - b * c;\n\t\tif(ret == 0) return 0;\n\t\tif(ret > 0) return 1;\n\t\treturn -1;\n\t}\n\t\n\t\n\t\n\tint[] A, B;\n\tpublic Sol(){\n\t\tA = ria();\n\t\tB = ria();\n\t}\n\n\tstatic String rs(){return Console.ReadLine();}\n\tstatic int ri(){return int.Parse(Console.ReadLine());}\n\tstatic long rl(){return long.Parse(Console.ReadLine());}\n\tstatic double rd(){return double.Parse(Console.ReadLine());}\n\tstatic String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}\n\tstatic int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}\n\tstatic long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}\n\tstatic double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}\n}\n", "lang_cluster": "C#", "tags": ["brute force"], "code_uid": "3fd661a089ce2672e9ebce56c2ce1604", "src_uid": "f6a3dd8b3bab58ff66055c61ddfdf06a", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeff\ufeff#define EXTENDSTACKSIZE\n\n\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Globalization;\nusing System.IO;\nusing System.Linq;\n using System.Text;\n using System.Threading;\n\nnamespace CF\n{\n internal class Program\n {\n private const int stackSize = 32 * 1024 * 1024;\n \n private static void Run()\n {\n using (var sr = new InputReader(Console.In))\n// using (var sr = new InputReader(new StreamReader(\"input.txt\")))\n using (var sw = Console.Out)\n// using (var sw = new StreamWriter(\"output.txt\"))\n using (var task = new Task(sr, sw)) {\n task.Solve();\n// Console.ReadKey();\n }\n }\n \n private static void Main(string[] args)\n {\n#if EXTENDSTACKSIZE\n var threadStart = new ThreadStart(Run);\n var thread = new Thread(threadStart, stackSize);\n thread.Start();\n thread.Join();\n#else\n Run();\n#endif\n }\n }\n\n internal class Task : IDisposable\n {\n private readonly InputReader sr;\n private readonly TextWriter sw;\n private bool isDispose;\n \n public Task(InputReader sr, TextWriter sw)\n {\n this.sr = sr;\n this.sw = sw;\n }\n \n public void Solve()\n {\n var c1 = sr.ReadArrayOfInt32();\n var c2 = sr.ReadArrayOfInt32();\n var coords1 = new int[10];\n var coords2 = new int[10];\n for (var i = 0; i < c1.Length; i++) {\n coords1[i] = c1[i];\n coords2[i] = c2[i];\n }\n\n coords1[8] = c1[0];\n coords1[9] = c1[1];\n coords2[8] = c2[0];\n coords2[9] = c2[1];\n for (var i = 0; i < 4; i++) {\n for (var j = 0; j < 4; j++) {\n if (IsIntersect(coords1[i * 2], coords1[i * 2 + 1], coords1[(i + 1) * 2], coords1[(i + 1) * 2 + 1],\n coords2[j * 2], coords2[j * 2 + 1], coords2[(j + 1) * 2], coords2[(j + 1) * 2 + 1])) {\n sw.WriteLine(\"YES\");\n return;\n }\n }\n }\n\n for (var i = 0; i < 4; i++) {\n if (Inside(coords1[i * 2], coords1[i * 2 + 1], coords2)) {\n sw.WriteLine(\"YES\");\n return;\n }\n }\n\n for (var i = 0; i < 4; i++) {\n if (Inside(coords2[i * 2], coords2[i * 2 + 1], coords1)) {\n sw.WriteLine(\"YES\");\n return;\n }\n }\n\n sw.WriteLine(\"NO\");\n }\n\n private bool Inside(int x1, int y1, int[] coords)\n {\n var intersectsCount = 0;\n for (var i = 0; i < 4; i++) {\n if (IsIntersect(x1, y1, 100, 100, coords[i * 2], coords[i * 2 + 1], coords[(i + 1) * 2], coords[(i + 1) * 2 + 1])) {\n intersectsCount++;\n }\n }\n\n return intersectsCount == 1;\n }\n\n private int Cross(int x1, int y1, int x2, int y2, int x, int y)\n {\n return (x1 - x) * (y2 - y) - (x2 - x) * (y1 - y);\n }\n\n private bool IsIntersect(int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4)\n {\n var d1 = Cross(x2, y2, x3, y3, x1, y1);\n var d2 = Cross(x2, y2, x4, y4, x1, y1);\n var d3 = Cross(x4, y4, x2, y2, x3, y3);\n var d4 = Cross(x4, y4, x1, y1, x3, y3);\n if (((d1 > 0 && d2 < 0) || (d2 > 0 && d1 < 0)) && ((d3 > 0 && d4 < 0) || (d3 < 0 && d4 > 0)))\n return true;\n if (d1 == 0 && InSegment(x1, y1, x2, y2, x3, y3))\n return true;\n if (d2 == 0 && InSegment(x1, y1, x2, y2, x4, y4))\n return true;\n if (d3 == 0 && InSegment(x3, y3, x4, y4, x2, y2))\n return true;\n if (d4 == 0 && InSegment(x3, y3, x4, y4, x1, y1))\n return true;\n\n return false;\n }\n\n private bool InSegment(int x1, int y1, int x2, int y2, int x, int y)\n {\n return x >= Math.Min(x1, x2) && x <= Math.Max(x1, x2) && y >= Math.Min(y1, y2) && y <= Math.Max(y1, y2);\n }\n \n ~Task()\n {\n Dispose(false);\n }\n \n public void Dispose()\n {\n Dispose(true);\n GC.SuppressFinalize(this);\n }\n \n private void Dispose(bool disposing)\n {\n if (!isDispose) {\n if (disposing) {\n if(sr != null)\n sr.Dispose();\n \n if(sw != null)\n sw.Dispose();\n }\n\n isDispose = true;\n }\n }\n }\n}\n\ninternal class InputReader : IDisposable\n{\n private bool isDispose;\n private readonly TextReader sr;\n private string[] buffer;\n private int seek;\n\n public InputReader(TextReader stream)\n {\n sr = stream;\n }\n\n public void Dispose()\n {\n Dispose(true);\n GC.SuppressFinalize(this);\n }\n\n public string NextString()\n {\n var result = sr.ReadLine();\n return result;\n }\n\n public int NextInt32()\n {\n return Int32.Parse(ReadNextToken());\n }\n\n private string ReadNextToken()\n {\n if (buffer == null || seek == buffer.Length) {\n seek = 0;\n buffer = NextSplitStrings();\n }\n\n return buffer[seek++];\n }\n\n public long NextInt64()\n {\n return Int64.Parse(ReadNextToken());\n }\n \n public int[] ReadArrayOfInt32()\n {\n return ReadArray(Int32.Parse);\n }\n\n public long[] ReadArrayOfInt64()\n {\n return ReadArray(Int64.Parse);\n }\n\n public string[] NextSplitStrings()\n {\n return NextString()\n .Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);\n }\n\n public T[] ReadArray(Func func)\n {\n return NextSplitStrings()\n .Select(s => func(s, CultureInfo.InvariantCulture))\n .ToArray();\n }\n\n public T[] ReadArrayFromString(Func func, string str)\n {\n return\n str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)\n .Select(s => func(s, CultureInfo.InvariantCulture))\n .ToArray();\n }\n\n protected void Dispose(bool dispose)\n {\n if (!isDispose)\n {\n if (dispose)\n sr.Close();\n \n isDispose = true;\n }\n }\n\n ~InputReader()\n {\n Dispose(false);\n }\n}", "lang_cluster": "C#", "tags": ["brute force"], "code_uid": "a3c642a35136ce8cb96e9036165860f6", "src_uid": "f6a3dd8b3bab58ff66055c61ddfdf06a", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.IO;\nusing System.Text;\n\nnamespace Ravioli_Sort\n{\n internal class Program\n {\n private static readonly StreamReader reader = new StreamReader(Console.OpenStandardInput(1024*10), Encoding.ASCII, false, 1024*10);\n private static readonly StreamWriter writer = new StreamWriter(Console.OpenStandardOutput(1024*10), Encoding.ASCII, 1024*10);\n\n private static void Main(string[] args)\n {\n writer.WriteLine(Solve(args) ? \"YES\" : \"NO\");\n writer.Flush();\n }\n\n private static bool Solve(string[] args)\n {\n int n = Next();\n\n var nn = new List(n);\n for (int i = 0; i < n; i++)\n {\n nn.Add(Next());\n }\n\n for (int i = n; i > 0; i--)\n {\n for (int j = 1; j < nn.Count; j++)\n {\n if (Math.Abs(nn[j] - nn[j - 1]) >= 2)\n return false;\n }\n\n int m = 0;\n for (int j = 1; j < nn.Count; j++)\n {\n if (nn[m] > nn[j])\n m = j;\n }\n\n nn.RemoveAt(m);\n }\n\n return true;\n }\n\n private static int Next()\n {\n int c;\n int res = 0;\n do\n {\n c = reader.Read();\n if (c == -1)\n return res;\n } while (c < '0' || c > '9');\n res = c - '0';\n while (true)\n {\n c = reader.Read();\n if (c < '0' || c > '9')\n return res;\n res *= 10;\n res += c - '0';\n }\n }\n }\n}", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "357fe1fa25ba7d04a0fcaf8657e9102f", "src_uid": "704d0ae50bccaa8bc49319812ae0be45", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace ConsoleApp4\n{\n class Program\n {\n static void Main(string[] args)\n {\n int i = Convert.ToInt32(Console.ReadLine());\n int[] mass = new int[i];\n string[] q = Console.ReadLine().Split(' ');\n bool flag = true;\n\n for (int j = 0; j < i; j++)\n {\n mass[j] = Convert.ToInt32(q[j]);\n }\n\n for (int j = 0; j < i - 1; j++)\n {\n if (Math.Abs(mass[j] - mass[j + 1]) > 1)\n {\n Console.WriteLine(\"NO\");\n flag = false;\n break;\n }\n }\n\n if (flag)\n {\n Console.WriteLine(\"YES\");\n }\n\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "f04b578d5a7ca092c153b45fe58a3980", "src_uid": "704d0ae50bccaa8bc49319812ae0be45", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.IO;\nusing System.Linq;\nusing System.Net.NetworkInformation;\n\nnamespace Codeforces.R318.E\n{\n public static class Solver\n {\n public static void Main()\n {\n using (var sw = new StreamWriter(Console.OpenStandardOutput()) {\n AutoFlush = false\n })\n {\n Solve(Console.In, sw);\n }\n }\n\n public static void Solve(TextReader tr, TextWriter tw)\n {\n WriteAnswer(tw, Parse(tr));\n }\n\n private static void WriteAnswer(TextWriter tw, long[] res)\n {\n if (res == null)\n {\n tw.WriteLine(\"NO\");\n return;\n }\n\n tw.WriteLine(res.Length);\n\n foreach (var t in res)\n {\n var prev = t & ((1 << 16) - 1);\n var to = (t >> 16) & ((1 << 16) - 1);\n var d = t >> 32;\n tw.WriteLine(\"{0} {1} {2}\", prev + 1, to + 1, d);\n }\n }\n\n private static long[] Parse(TextReader tr)\n {\n var w = tr.ReadLine().Split();\n var e = int.Parse(w[2]);\n\n var a = from x in tr.ReadLine().Split() select int.Parse(x);\n var b = from x in tr.ReadLine().Split() select int.Parse(x);\n\n var edges = new (int, int)[e];\n for (int i = 0; i < e; ++i)\n {\n var l = tr.ReadLine().Split();\n edges[i] = (int.Parse(l[0]) - 1, int.Parse(l[1]) - 1);\n }\n\n return Calc(a.ToArray(), b.ToArray(), edges);\n }\n\n public static long[] Calc(int[] a, int[] b, (int, int)[] edges)\n {\n var n = a.Length;\n var mat = new (int, int)[n, n];\n\n for (int i = 0; i < n; ++i)\n {\n for (int j = 0; j < n; ++j)\n {\n mat[i, j] = i == j ? (0, i) : (9999, i);\n }\n }\n\n foreach (var edge in edges)\n {\n mat[edge.Item1, edge.Item2] = (1, edge.Item1);\n mat[edge.Item2, edge.Item1] = (1, edge.Item2);\n }\n\n for (int k = 0; k < n; ++k)\n {\n for (int i = 0; i < n; ++i)\n {\n for (int j = 0; j < n; ++j)\n {\n if (mat[i, k].Item1 + mat[k, j].Item1 < mat[i, j].Item1)\n {\n mat[i, j] = (mat[i, k].Item1 + mat[k, j].Item1, mat[k, j].Item2);\n }\n }\n }\n }\n\n var res = Execute(a, b, mat);\n\n if (!a.SequenceEqual(b))\n {\n return null;\n }\n\n return res.ToArray();\n }\n\n public static List Execute(int[] a, int[] b, (int, int)[,] mat)\n {\n var calculator = new Calculator(a, b, mat);\n return calculator.Solve();\n }\n }\n\n internal class Calculator\n {\n List res = new List();\n int[] a;\n int[] b;\n (int, int)[,] mat;\n\n public Calculator(int[] a, int[] b, (int, int)[,] mat)\n {\n this.a = a;\n this.b = b;\n this.mat = mat;\n }\n\n public List Solve()\n {\n var n = a.Length;\n for (; ; )\n {\n var prev = res.Count;\n for (int i = 0; i < n; ++i)\n {\n for (int j = 0; j < n; ++j)\n {\n if (a[i] > b[i] && a[j] < b[j] && mat[i, j].Item1 <= n)\n { \n Pour(i, j, Math.Min(a[i] - b[i], b[j] - a[j]));\n }\n }\n }\n if (prev == res.Count)\n {\n break;\n }\n }\n\n return res;\n }\n\n private void Pour(int from, int to, int d)\n {\n if (from == to)\n {\n return;\n }\n\n var prev = mat[from, to].Item2;\n var p = Math.Min(a[prev], d);\n if (p > 0)\n {\n a[prev] -= p;\n a[to] += p;\n res.Add(CreateKey(prev, to, p));\n }\n\n Pour(from, prev, d);\n\n if (d - p > 0)\n {\n a[prev] -= d - p;\n a[to] += d - p;\n res.Add(CreateKey(prev, to, d - p));\n }\n }\n\n private long CreateKey(long prev, long to, long d)\n {\n return (d << 32) + (to << 16) + prev;\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["dfs and similar", "constructive algorithms"], "code_uid": "6500b74bbbaf28336dfc104fa8557749", "src_uid": "0939354d9bad8301efb79a1a934ded30", "difficulty": 2500.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections;\nusing System.Collections.Generic;\n\nclass Myon\n{\n public Myon() { }\n public static int Main()\n {\n new Myon().solve();\n return 0;\n }\n\n long mod = 1000000007;\n void solve()\n {\n Scanner cin = new Scanner();\n\n int n = cin.nextInt();\n int[] a = new int[n];\n for (int i = 0; i < n; i++)\n {\n a[i] = cin.nextInt();\n }\n\n int MAX = 1 << n;\n\n long[] now = new long[MAX];\n\n long[] plus = new long[n + 100];\n plus[0] = 0;\n plus[1] = 0;\n plus[2] = 1;\n\n\n for (int i = 3; i <= n; i++)\n {\n plus[i] = (plus[i - 1] * (i - 1)) % mod;\n }\n\n for (int i = 0; i < MAX; i++)\n {\n int count = 0;\n int sum = 0;\n for (int j = 0; j < n; j++)\n {\n if ((i >> j) % 2 == 0) continue;\n count++;\n sum += a[j] - 1;\n }\n sum += 2;\n if (sum >= count)\n {\n now[i] = plus[count];\n }\n }\n \n long ret = 0;\n long[] dp = new long[MAX];\n for (int i = 0; i < MAX; i++)\n {\n int revi = MAX - 1 - i;\n for (int j = revi; j > 0; j = ((j - 1) & revi))\n {\n dp[i + j] = (dp[i + j] + now[i] * dp[j]) % mod;\n }\n dp[i] = (dp[i] + now[i]) % mod;\n }\n for (int i = 0; i < MAX; i++)\n {\n ret = (ret + dp[i]) % mod;\n }\n ret = (ret + 1) % mod;\n Console.WriteLine(ret);\n\n }\n\n int bitCount(long x)\n {\n x = (x & 0x5555555555555555) + (x >> 1 & 0x5555555555555555);\n x = (x & 0x3333333333333333) + (x >> 2 & 0x3333333333333333);\n x = (x & 0x0f0f0f0f0f0f0f0f) + (x >> 4 & 0x0f0f0f0f0f0f0f0f);\n x = (x & 0x00ff00ff00ff00ff) + (x >> 8 & 0x00ff00ff00ff00ff);\n x = (x & 0x0000ffff0000ffff) + (x >> 16 & 0x0000ffff0000ffff);\n return (int)((x & 0x00000000ffffffff) + (x >> 32 & 0x00000000ffffffff));\n }\n\n\n}\n\n\n\nclass Scanner\n{\n string[] s;\n int i;\n\n char[] cs = new char[] { ' ' };\n\n public Scanner()\n {\n s = new string[0];\n i = 0;\n }\n\n public string next()\n {\n if (i < s.Length) return s[i++];\n s = Console.ReadLine().Split(cs, StringSplitOptions.RemoveEmptyEntries);\n i = 0;\n return s[i++];\n }\n\n public int nextInt()\n {\n return int.Parse(next());\n }\n\n public long nextLong()\n {\n return long.Parse(next());\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "dp"], "code_uid": "694cd5e7c424f06dbb1377ab43f980e3", "src_uid": "91e8dbe94273e255182aca0f94117bb9", "difficulty": 2300.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Diagnostics.Contracts;\nusing System.Globalization;\nusing System.IO;\nusing System.Linq;\n\nnamespace Codeforces.R316D1\n{\n public struct ModInteger : IEquatable\n {\n readonly int mod;\n readonly long value;\n public ModInteger(int mod, long value = 0L)\n {\n this.mod = mod;\n this.value = value % mod;\n if (value < 0)\n {\n this.value = value + mod;\n }\n }\n\n public bool Equals(ModInteger other)\n {\n return mod == other.mod && value == other.value;\n }\n\n public override bool Equals(object obj)\n {\n if (!(obj is ModInteger))\n {\n return false;\n }\n var other = (ModInteger)obj;\n return Equals(other);\n }\n\n public override int GetHashCode()\n {\n return (int)value;\n }\n\n public static bool operator ==(ModInteger left, ModInteger right)\n {\n return left.Equals(right);\n }\n\n public static bool operator !=(ModInteger left, ModInteger right)\n {\n return !(left == right);\n }\n\n public static ModInteger LeftShift(ModInteger left, int right)\n {\n return left << right;\n }\n\n public static ModInteger operator <<(ModInteger left, int right)\n {\n if (right > 32)\n {\n return left << 32 << (right - 32);\n }\n return new ModInteger(left.mod, left.value << right);\n }\n\n public static ModInteger Add(ModInteger left, int right)\n {\n return left + right;\n }\n\n public static ModInteger operator +(ModInteger left, int right)\n {\n return new ModInteger(left.mod, left.value + right);\n }\n\n public static ModInteger operator ++(ModInteger m)\n {\n return m + 1;\n }\n\n public static ModInteger Multiply(ModInteger left, int right)\n {\n return new ModInteger(left.mod, left.value * right);\n }\n\n public static ModInteger operator *(ModInteger left, int right)\n {\n return Multiply(left, right);\n }\n\n public static ModInteger Div(int left, int right, int mod)\n {\n return Pow(right, mod - 2, mod) * left;\n }\n\n public static ModInteger Pow(long x, int n, int mod)\n {\n var res = 1L;\n for (; n > 0; n >>= 1)\n {\n if ((n & 1) == 1)\n {\n res = res * x % mod;\n }\n x = x * x % mod;\n }\n return new ModInteger(mod, res);\n }\n\n public static ModInteger ToModInteger(int value)\n {\n return new ModInteger(0, value);\n }\n\n public static implicit operator int(ModInteger value)\n {\n return (int)value.value;\n }\n\n public static int ToInt32(ModInteger value)\n {\n return value;\n }\n\n public static ModInteger Increment(ModInteger item)\n {\n return ++item;\n }\n }\n public static class Solver\n {\n const int mod = 1000000007;\n public static void Main()\n {\n using (var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false })\n {\n Solve(Console.In, sw);\n }\n }\n\n public static void Solve(TextReader tr, TextWriter tw)\n {\n Contract.Requires(tr != null);\n Contract.Requires(tw != null);\n\n tw.WriteLine(Parse(tr));\n }\n\n private static int Parse(TextReader tr)\n {\n var info = CultureInfo.InvariantCulture;\n tr.ReadLine();\n var a = tr.ReadLine().Split().Select(x => int.Parse(x, info)).ToArray();\n\n return Calc(a);\n }\n\n private static ModInteger Calc(int[] a)\n {\n int num1 = a.Count(x => x == 1);\n int num2 = a.Length - num1;\n\n return F(num1, num2);\n }\n\n private static ModInteger F(int a, int b)\n {\n var res = new ModInteger(mod, 1);\n\n for (int i = 0; i < b; ++i)\n {\n res *= a + 1 + i;\n }\n\n if (a == 0)\n {\n return res;\n }\n\n var I = new ModInteger[a + 1];\n I[0] = new ModInteger(mod, 1);\n I[1] = new ModInteger(mod, 1);\n for (int i = 2; i <= a; ++i)\n {\n I[i] = I[i - 1] + (i - 1) * I[i - 2];\n }\n return res * I[a];\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "dp"], "code_uid": "8896a43bfc66210f2edb98857b7e0a46", "src_uid": "91e8dbe94273e255182aca0f94117bb9", "difficulty": 2300.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.IO;\nusing System.Linq;\n\nnamespace Codeforces.R355.D\n{\n public static class Solver\n {\n public static void Main()\n {\n using (var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false })\n {\n Solve(Console.In, sw);\n }\n }\n\n public static void Solve(TextReader tr, TextWriter tw)\n {\n WriteAnswer(tw, Parse(tr));\n }\n\n struct Answer\n {\n public string Winner;\n }\n\n private static void WriteAnswer(TextWriter tw, Answer answer)\n {\n tw.WriteLine(answer.Winner);\n }\n\n private static Answer Parse(TextReader tr)\n {\n var n = int.Parse(tr.ReadLine());\n var board = new string[n];\n for (var i = 0; i < n; ++i)\n board[i] = tr.ReadLine();\n return Calc(board);\n }\n\n private static Answer Calc(string[] board)\n {\n var answer = new Answer();\n var memo = new Dictionary<(int, int), int>();\n var r = Rec(\"\" + board[0][0], 1, 0, board, memo);\n\n if (r > 0)\n answer.Winner = \"FIRST\";\n else if (r < 0)\n answer.Winner = \"SECOND\";\n else\n answer.Winner = \"DRAW\";\n\n return answer;\n }\n\n private static int Rec(string str, int mask, int currentC, string[] board, Dictionary<(int, int), int> memo)\n {\n var n = board.Length;\n var numStr = str.Length;\n\n var key = (numStr, mask);\n if (memo.ContainsKey(key))\n return memo[key];\n\n\n if (numStr == n * 2 - 1)\n {\n if (str.Last() == 'a')\n return 1;\n else if (str.Last() == 'b')\n return -1;\n return 0;\n }\n\n var res = numStr % 2 == 0 ? int.MinValue : int.MaxValue;\n\n for (var ch = 'a'; ch <= 'z'; ++ch)\n {\n var nm = 0;\n\n for (var y = 0; y < n; ++y)\n {\n if ((mask & (1 << y)) == 0)\n continue;\n var x = numStr - y - 1;\n if (x < 0 || x >= n)\n continue;\n if (x < n - 1 && board[y][x + 1] == ch)\n nm |= 1 << y;\n if (y < n - 1 && board[y + 1][x] == ch)\n nm |= 1 << y + 1;\n }\n if (nm == 0)\n continue;\n\n if (numStr % 2 == 0)\n res = Math.Max(res, Rec(str + ch, nm, 0, board, memo));\n else\n res = Math.Min(res, Rec(str + ch, nm, 0, board, memo));\n }\n\n if (str.Last() == 'a')\n res += 1;\n else if (str.Last() == 'b')\n res += -1;\n\n return memo[key] = res;\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["games", "dp", "bitmasks"], "code_uid": "f6e1ef4460385d2a60a5ab8da7bb8455", "src_uid": "d803fe167a96656f8debdc21edd988e4", "difficulty": 2400.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Globalization;\nusing System.IO;\nusing System.Linq;\nusing System.Text;\n\n// (\u3065\u00b0\u03c9\u00b0)\u3065\uff90\u2605\u309c\u30fb\u3002\u3002\u30fb\u309c\u309c\u30fb\u3002\u3002\u30fb\u309c\u2606\u309c\u30fb\u3002\u3002\u30fb\u309c\u309c\u30fb\u3002\u3002\u30fb\u309c\npublic class Solver\n{\n private int n;\n\n private string[] table;\n private int?[,] mem;\n\n List> Decode(int x, int mask)\n {\n var ret = new List>();\n if (x >= n)\n {\n int d = x - n;\n for (int i = 0; i < n - 1 - d; i++)\n if ((mask >> i & 1) == 1)\n ret.Add(Tuple.Create(d + 1 + i, n - 1 - i));\n }\n else\n {\n for (int i = 0; i <= x; i++)\n if ((mask >> i & 1) == 1)\n ret.Add(Tuple.Create(i, x - i));\n }\n return ret;\n }\n\n int Encode(int r, int c)\n {\n if (r + c >= n)\n return 1 << n - c - 1;\n return 1 << r;\n }\n\n int Fun(int x, int mask)\n {\n if (mem[x, mask].HasValue)\n return mem[x, mask].Value;\n\n if (x == 2 * (n - 1))\n return 0;\n\n var cpos = Decode(x, mask);\n\n int ret = x % 2 == 1 ? int.MinValue : int.MaxValue;\n for (char ch = 'a'; ch <= 'z'; ch++)\n {\n int nmask = 0;\n foreach (var p in cpos)\n {\n if (p.Item1 + 1 < n && table[p.Item1 + 1][p.Item2] == ch)\n nmask |= Encode(p.Item1 + 1, p.Item2);\n if (p.Item2 + 1 < n && table[p.Item1][p.Item2 + 1] == ch)\n nmask |= Encode(p.Item1, p.Item2 + 1);\n }\n if (nmask > 0)\n {\n int y = Fun(x + 1, nmask);\n if (ch == 'a')\n y++;\n else if (ch == 'b')\n y--;\n if (x % 2 == 1)\n ret = Math.Max(ret, y);\n else\n ret = Math.Min(ret, y);\n }\n }\n\n return (mem[x, mask] = ret).Value;\n }\n\n public object Solve()\n {\n n = ReadInt();\n table = ReadLines(n);\n\n mem = new int?[n << 1,1 << n];\n int r = Fun(0, 1);\n if (table[0][0] == 'a')\n r++;\n if (table[0][0] == 'b')\n r--;\n\n return r > 0 ? \"FIRST\" : (r == 0 ? \"DRAW\" : \"SECOND\");\n }\n\n #region Main\n\n protected static TextReader reader;\n protected static TextWriter writer;\n\n static void Main()\n {\n#if DEBUG\n reader = new StreamReader(\"..\\\\..\\\\input.txt\");\n writer = Console.Out;\n //writer = new StreamWriter(\"..\\\\..\\\\output.txt\");\n#else\n reader = new StreamReader(Console.OpenStandardInput());\n writer = new StreamWriter(Console.OpenStandardOutput());\n#endif\n try\n {\n var ts = DateTime.Now;\n object result = new Solver().Solve();\n if (result != null)\n writer.WriteLine(result);\n }\n catch (Exception ex)\n {\n#if DEBUG\n Console.WriteLine(ex);\n#else\n Console.WriteLine(ex);\n throw;\n#endif\n }\n reader.Close();\n writer.Close();\n }\n\n #endregion\n\n #region Read/Write\n\n private static Queue currentLineTokens = new Queue();\n\n private static string[] ReadAndSplitLine()\n {\n return reader.ReadLine().Split(new[] { ' ', '\\t' }, StringSplitOptions.RemoveEmptyEntries);\n }\n\n public static string ReadToken()\n {\n while (currentLineTokens.Count == 0)\n currentLineTokens = new Queue(ReadAndSplitLine());\n return currentLineTokens.Dequeue();\n }\n\n public static int ReadInt()\n {\n return int.Parse(ReadToken());\n }\n\n public static long ReadLong()\n {\n return long.Parse(ReadToken());\n }\n\n public static double ReadDouble()\n {\n return double.Parse(ReadToken(), CultureInfo.InvariantCulture);\n }\n\n public static int[] ReadIntArray()\n {\n return ReadAndSplitLine().Select(int.Parse).ToArray();\n }\n\n public static long[] ReadLongArray()\n {\n return ReadAndSplitLine().Select(long.Parse).ToArray();\n }\n\n public static double[] ReadDoubleArray()\n {\n return ReadAndSplitLine().Select(s => double.Parse(s, CultureInfo.InvariantCulture)).ToArray();\n }\n\n public static int[][] ReadIntMatrix(int numberOfRows)\n {\n int[][] matrix = new int[numberOfRows][];\n for (int i = 0; i < numberOfRows; i++)\n matrix[i] = ReadIntArray();\n return matrix;\n }\n\n public static int[][] ReadAndTransposeIntMatrix(int numberOfRows)\n {\n int[][] matrix = ReadIntMatrix(numberOfRows);\n int[][] ret = new int[matrix[0].Length][];\n for (int i = 0; i < ret.Length; i++)\n {\n ret[i] = new int[numberOfRows];\n for (int j = 0; j < numberOfRows; j++)\n ret[i][j] = matrix[j][i];\n }\n return ret;\n }\n\n public static string[] ReadLines(int quantity)\n {\n string[] lines = new string[quantity];\n for (int i = 0; i < quantity; i++)\n lines[i] = reader.ReadLine().Trim();\n return lines;\n }\n\n public static void WriteArray(params T[] array)\n {\n writer.WriteLine(string.Join(\" \", array));\n }\n\n #endregion\n}", "lang_cluster": "C#", "tags": ["games", "dp", "bitmasks"], "code_uid": "41dd9fa2f5a5d337fc7e6f6e59414624", "src_uid": "d803fe167a96656f8debdc21edd988e4", "difficulty": 2400.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Linq;\n\nnamespace a\n{\n class Program\n {\n static void Main(string[] args)\n {\n var x = int.Parse(Console.ReadLine());\n\n var a = Convert.ToString(x, 2).PadLeft(6, '0').ToArray();\n\n var temp = a[1];\n a[1] = a[5];\n a[5] = temp;\n temp = a[2];\n a[2] = a[3];\n a[3] = temp;\n\n Console.WriteLine(Convert.ToInt32(new String(a), 2));\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["bitmasks"], "code_uid": "e36716bc59ea1f9c2f6a97287cb8bdd4", "src_uid": "db5e54f466e1f3d69a51ea0b346e667c", "difficulty": null, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Globalization;\nusing System.IO;\nusing System.Linq;\nusing System.Text;\nusing System.Threading;\n\n// (\u3065\u00b0\u03c9\u00b0)\u3065\uff90e\u2605\u309c\u30fb\u3002\u3002\u30fb\u309c\u309c\u30fb\u3002\u3002\u30fb\u309c\u2606\u309c\u30fb\u3002\u3002\u30fb\u309c\u309c\u30fb\u3002\u3002\u30fb\u309c\npublic class Solver\n{\n public void Solve()\n {\n int x = ReadInt();\n var a = Convert.ToString(x, 2).ToList();\n while (a.Count < 6)\n a.Insert(0, '0');\n \n char t = a[1];\n a[1] = a[5];\n a[5] = t;\n t = a[2];\n a[2] = a[3];\n a[3] = t;\n Write(Convert.ToInt32(new string(a.ToArray()), 2));\n }\n\n #region Main\n\n protected static TextReader reader;\n protected static TextWriter writer;\n static void Main()\n {\n#if DEBUG\n reader = new StreamReader(\"..\\\\..\\\\input.txt\");\n //reader = new StreamReader(Console.OpenStandardInput());\n writer = Console.Out;\n //writer = new StreamWriter(\"..\\\\..\\\\output.txt\");\n#else\n reader = new StreamReader(Console.OpenStandardInput());\n writer = new StreamWriter(Console.OpenStandardOutput());\n //reader = new StreamReader(\"input.txt\");\n //writer = new StreamWriter(\"output.txt\");\n#endif\n try\n {\n new Solver().Solve();\n //var thread = new Thread(new Solver().Solve, 1024 * 1024 * 128);\n //thread.Start();\n //thread.Join();\n }\n catch (Exception ex)\n {\n#if DEBUG\n Console.WriteLine(ex);\n#else\n throw;\n#endif\n }\n reader.Close();\n writer.Close();\n }\n\n #endregion\n\n #region Read / Write\n private static Queue currentLineTokens = new Queue();\n private static string[] ReadAndSplitLine() { return reader.ReadLine().Split(new[] { ' ', '\\t', }, StringSplitOptions.RemoveEmptyEntries); }\n public static string ReadToken() { while (currentLineTokens.Count == 0)currentLineTokens = new Queue(ReadAndSplitLine()); return currentLineTokens.Dequeue(); }\n public static int ReadInt() { return int.Parse(ReadToken()); }\n public static long ReadLong() { return long.Parse(ReadToken()); }\n public static double ReadDouble() { return double.Parse(ReadToken(), CultureInfo.InvariantCulture); }\n public static int[] ReadIntArray() { return ReadAndSplitLine().Select(int.Parse).ToArray(); }\n public static long[] ReadLongArray() { return ReadAndSplitLine().Select(long.Parse).ToArray(); }\n public static double[] ReadDoubleArray() { return ReadAndSplitLine().Select(s => double.Parse(s, CultureInfo.InvariantCulture)).ToArray(); }\n public static int[][] ReadIntMatrix(int numberOfRows) { int[][] matrix = new int[numberOfRows][]; for (int i = 0; i < numberOfRows; i++)matrix[i] = ReadIntArray(); return matrix; }\n public static int[][] ReadAndTransposeIntMatrix(int numberOfRows)\n {\n int[][] matrix = ReadIntMatrix(numberOfRows); int[][] ret = new int[matrix[0].Length][];\n for (int i = 0; i < ret.Length; i++) { ret[i] = new int[numberOfRows]; for (int j = 0; j < numberOfRows; j++)ret[i][j] = matrix[j][i]; } return ret;\n }\n public static string[] ReadLines(int quantity) { string[] lines = new string[quantity]; for (int i = 0; i < quantity; i++)lines[i] = reader.ReadLine().Trim(); return lines; }\n public static void WriteArray(IEnumerable array) { writer.WriteLine(string.Join(\" \", array)); }\n public static void Write(params object[] array) { WriteArray(array); }\n public static void WriteLines(IEnumerable array) { foreach (var a in array)writer.WriteLine(a); }\n private class SDictionary : Dictionary\n {\n public new TValue this[TKey key]\n {\n get { return ContainsKey(key) ? base[key] : default(TValue); }\n set { base[key] = value; }\n }\n }\n private static T[] Init(int size) where T : new() { var ret = new T[size]; for (int i = 0; i < size; i++)ret[i] = new T(); return ret; }\n #endregion\n}", "lang_cluster": "C#", "tags": ["bitmasks"], "code_uid": "4e2beb674a2de7ea5c2dedeb945d8747", "src_uid": "db5e54f466e1f3d69a51ea0b346e667c", "difficulty": null, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace ConsoleApp1\n{\n class Program\n {\n static void Main(string[] args)\n {\n string[] t1 = Console.ReadLine().Split();\n int n = int.Parse(t1[0]); // \u041a\u041e\u041b\u041b\u0418\u0427\u0415\u0421\u0422\u0412\u041e \u041f\u0410\u041f\u041e\u041a\n int m = int.Parse(t1[1]); // \u041f\u0410\u041f\u041e\u041a \u041f\u041e \u0413\u041e\u0420\u0418\u0417\u041e\u041d\u0422\u0410\u041b\u0418 \n int a = int.Parse(t1[2]); // \u041e\u0422 \u0410\n int b = int.Parse(t1[3]); // \u0414\u041e \u0411 \n\n int kstrok = n / m + 1; // koll strok\n\n int[] array = new int[kstrok + 1];\n for (int i = 2; i < kstrok + 1; i++) //massiv zapominaet nachalo strok\n array[i] = m * i - m + 1;\n\n array[1] = 1;\n\n int[] myarray = new int[kstrok + 1];\n for (int i = 1; i < kstrok + 1; i++) //massiv zapominaet konez strok\n myarray[i] = m * i;\n\n int strokaa = 1;\n int strokab = 1;\n\n for (int i = 1; i < kstrok + 1; i++)\n if (a > myarray[i])\n strokaa = strokaa + 1; //\u043d\u0430\u0445\u043e\u0434 \u0441\u0442\u0440\u043e\u043a\u0438 \u0430\n\n for (int i = 1; i < kstrok + 1; i++)\n if (b > myarray[i])//\u043d\u0430\u0445\u043e\u0434 \u0441\u0442\u0440\u043e\u043a\u0438 \u0431\n strokab = strokab + 1;\n\n int proverkaa1 = 0;\n int proverkab1 = 0;\n\n for (int i = 1; i < kstrok; i++)\n if (a == array[i]) //esli a v nachale stroki\n proverkaa1 = proverkaa1 + 1;\n\n for (int i = 1; i < kstrok; i++)\n if (b == myarray[i])// esli b v konze stroki\n proverkab1 = proverkab1 + 1;\n\n if (proverkaa1 + proverkab1 == 2)\n Console.WriteLine(1);\n\n int o = 0;\n if (strokaa == strokab && proverkaa1 + proverkab1 != 2)\n {\n Console.WriteLine(1); // esli v odnoi stroke a i b\n o = 1;\n }\n\n int proverkaa2 = 0; //\u041d\u0430\u0448\u043b\u0430\u0441\u044c \u043b\u0438 \u0430 \u043d\u0435 \u043f\u043e \u043a\u0440\u043e\u044f\u043c \u0441\u0442\u0440\u043e\u043a\u0438?\n int proverkab2 = 0; //\u041d\u0430\u0448\u043b\u0430\u0441\u044c \u043b\u0438 \u0431 \u043d\u0435 \u043f\u043e \u043a\u0440\u043e\u044f\u043c \u0441\u0442\u0440\u043e\u043a\u0438?\n\n\n for (int i = 1; i < kstrok + 1; i++)\n if (a > array[i] && a <= myarray[i])\n proverkaa2 = proverkaa2 + 1; //\u041d\u0430\u0448\u043b\u0430\u0441\u044c \u043b\u0438 \u0430 \u043d\u0435 \u043f\u043e \u043a\u0440\u043e\u044f\u043c \u0441\u0442\u0440\u043e\u043a\u0438?\n\n for (int i = 1; i < kstrok + 1; i++)\n if (b >= array[i] && b < myarray[i])\n proverkab2 = proverkab2 + 1; //\u041d\u0430\u0448\u043b\u0430\u0441\u044c \u043b\u0438 \u0430 \u043d\u0435 \u043f\u043e \u043a\u0440\u043e\u044f\u043c \u0441\u0442\u0440\u043e\u043a\u0438?\n int q = 0;\n if (o == 0)\n {\n if (proverkaa2 + proverkab2 == 2 && strokaa + 1 < strokab)\n if ((a - 1) % m == b % m)\n {\n Console.WriteLine(2);\n q = 1;\n }\n\n\n if (proverkaa2 + proverkab2 == 2 && strokaa + 1 < strokab)\n if (b != n && q != 1)\n Console.WriteLine(3); //\u0435\u0441\u043b\u0438 \u0430 \u0438 \u0431 \u043d\u0430\u0445\u043e\u0434\u044f\u0442\u0441\u044f \u043d\u0435 \u043f\u043e \u043a\u0440\u0430\u044f\u043c \u0438 \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u0435 > m\n else if (q != 1)\n Console.WriteLine(2);\n\n if (proverkaa2 + proverkab2 == 2 && strokaa + 1 == strokab)\n Console.WriteLine(2); //\u0435\u0441\u043b\u0438 \u0430 \u0438 \u0431 \u043d\u0430\u0445\u043e\u0434\u044f\u0442\u0441\u044f \u043d\u0435 \u043f\u043e \u043a\u0440\u0430\u044f\u043c \u0438 \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u0435 <= m\n\n if (proverkaa1 + proverkab2 == 2)\n if (b != n)\n Console.WriteLine(2); //\u0435\u0441\u043b\u0438 \u0430 \u0441 \u043a\u0440\u0430\u044e, \u0430 \u0431 \u043d\u0435\u0442\n else Console.WriteLine(1);\n\n if (proverkaa2 + proverkab1 == 2)\n Console.WriteLine(2); //\u0435\u0441\u043b\u0438 \u0431 \u0441 \u043a\u0440\u0430\u044e, \u0430 \u0430 \u043d\u0435t\n }\n }\n }\n}", "lang_cluster": "C#", "tags": ["math"], "code_uid": "68a675e9d45ff74c327942466e3bbf61", "src_uid": "f256235c0b2815aae85a6f9435c69dac", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.IO;\nusing System.Runtime.CompilerServices;\nusing System.Text;\nusing static Template;\nusing static System.Console;\nusing static System.Convert;\nusing static System.Math;\nusing Pi = Pair;\n\nclass Solver\n{\n int N;const int MOD = (int)1e9 + 7;\n string S;\n int[][] dp;\n public void Solve(Scanner sc)\n {\n N = sc.Int;S = ReadLine();\n dp = Create(N, () => Create(1<<20,()=>-1));\n int res = 0;\n for (var i = 0; i < N; i++)\n { res += memo(0, i); if (res >= MOD) res -= MOD; }\n WriteLine(res);\n }\n int memo(int s,int i)\n {\n var ct = 0;\n for (var j = 0; j < 20; j++)\n ct += 1 & s >> j;\n if (i == N)\n return ToInt32(ct != 0 && (1 << ct) - 1 == s);\n if (dp[i][s] != -1) return dp[i][s];\n int res = 0;\n if (S[i] == '0') return dp[i][s] = memo(s, i + 1);\n var c = 0;\n for (var j = i; j < N; j++)\n {\n c <<= 1;c += S[j] - '0';\n if (c > 20) break;\n res += memo(s | (1 << (c - 1)), j + 1);\n if (res >= MOD) res -= MOD;\n }\n if (ct != 0 && (1 << ct)-1 == s) res++;\n if (res >= MOD) res -= MOD;\n return dp[i][s] = res;\n }\n}\n\n#region Template\npublic static class Template\n{\n static void Main(string[] args)\n {\n Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });\n new Solver().Solve(new Scanner());\n Console.Out.Flush();\n }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static bool chmin(ref T a, T b) where T : IComparable\n { if (a.CompareTo(b) == 1) { a = b; return true; } return false; }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static bool chmax(ref T a, T b) where T : IComparable\n { if (a.CompareTo(b) == -1) { a = b; return true; } return false; }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static void swap(ref T a, ref T b)\n { var t = b; b = a; a = t; }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static T[] Create(int n, Func f)\n {\n var rt = new T[n];\n for (var i = 0; i < rt.Length; ++i)\n rt[i] = f();\n return rt;\n }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static T[] Create(int n, Func f)\n {\n var rt = new T[n];\n for (var i = 0; i < rt.Length; ++i)\n rt[i] = f(i);\n return rt;\n }\n public static T[] Copy(this T[] A) => Create(A.Length, i => A[i]);\n public static void Fail(T s) { Console.WriteLine(s); Console.Out.Close(); Environment.Exit(0); }\n}\n\npublic class Scanner\n{\n public string Str => Console.ReadLine().Trim();\n public int Int => int.Parse(Str);\n public long Long => long.Parse(Str);\n public double Double => double.Parse(Str);\n public int[] ArrInt => Str.Split(' ').Select(int.Parse).ToArray();\n public long[] ArrLong => Str.Split(' ').Select(long.Parse).ToArray();\n public char[][] Grid(int n) => Create(n, () => Str.ToCharArray());\n public int[] ArrInt1D(int n) => Create(n, () => Int);\n public long[] ArrLong1D(int n) => Create(n, () => Long);\n public int[][] ArrInt2D(int n) => Create(n, () => ArrInt);\n public long[][] ArrLong2D(int n) => Create(n, () => ArrLong);\n public Pair PairMake() => new Pair(Next(), Next());\n public Pair PairMake() => new Pair(Next(), Next(), Next());\n private Queue q = new Queue();\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public T Next() { if (q.Count == 0) foreach (var item in Str.Split(' ')) q.Enqueue(item); return (T)Convert.ChangeType(q.Dequeue(), typeof(T)); }\n public void Make(out T1 v1) => v1 = Next();\n public void Make(out T1 v1, out T2 v2) { v1 = Next(); v2 = Next(); }\n public void Make(out T1 v1, out T2 v2, out T3 v3) { Make(out v1, out v2); v3 = Next(); }\n public void Make(out T1 v1, out T2 v2, out T3 v3, out T4 v4) { Make(out v1, out v2, out v3); v4 = Next(); }\n public void Make(out T1 v1, out T2 v2, out T3 v3, out T4 v4, out T5 v5) { Make(out v1, out v2, out v3, out v4); v5 = Next(); }\n public void Make(out T1 v1, out T2 v2, out T3 v3, out T4 v4, out T5 v5, out T6 v6) { Make(out v1, out v2, out v3, out v4, out v5); v6 = Next(); }\n}\n\npublic class Pair : IComparable>\n{\n public T1 v1;\n public T2 v2;\n public Pair() { }\n public Pair(T1 v1, T2 v2)\n { this.v1 = v1; this.v2 = v2; }\n\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public int CompareTo(Pair p)\n {\n var c = Comparer.Default.Compare(v1, p.v1);\n if (c == 0)\n c = Comparer.Default.Compare(v2, p.v2);\n return c;\n }\n public override string ToString() => $\"{v1.ToString()} {v2.ToString()}\";\n public void Tie(out T1 a, out T2 b) { a = v1; b = v2; }\n}\n\npublic class Pair : Pair, IComparable>\n{\n public T3 v3;\n public Pair() : base() { }\n public Pair(T1 v1, T2 v2, T3 v3) : base(v1, v2)\n { this.v3 = v3; }\n\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public int CompareTo(Pair p)\n {\n var c = base.CompareTo(p);\n if (c == 0)\n c = Comparer.Default.Compare(v3, p.v3);\n return c;\n }\n public override string ToString() => $\"{base.ToString()} {v3.ToString()}\";\n public void Tie(out T1 a, out T2 b, out T3 c) { Tie(out a, out b); c = v3; }\n}\n#endregion\n", "lang_cluster": "C#", "tags": ["dp", "bitmasks"], "code_uid": "765a91cebb66980d9deb28d188c434b6", "src_uid": "61f88159762cbc7c51c36e7b56ecde48", "difficulty": 2200.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\n\nnamespace Task_D\n{\n class Solution\n {\n static void Main(string[] args)\n {\n new Solution().Solve();\n }\n\n private int n;\n private int d;\n private long x;\n private int[] a;\n private int[] b;\n private int[] c;\n\n private void Solve()\n {\n var parts = Console.ReadLine().Split();\n n = int.Parse(parts[0]);\n d = int.Parse(parts[1]);\n x = long.Parse(parts[2]);\n\n a = new int[n];\n b = new int[n];\n c = new int[n];\n\n initAB();\n\n var bCount = 0;\n var bPos = new int[n];\n for (int i = 0; i < n; i++)\n {\n if (b[i] == 1)\n {\n bPos[bCount++] = i;\n }\n }\n\n var aOrder = new int[n];\n for (int i = 0; i < n; i++)\n {\n aOrder[a[i] - 1] = i;\n }\n\n int s = 50;\n\n for (int i = 0; i < n; i++)\n {\n for (int q = 0; q < s && q < n; q++)\n {\n int j = aOrder[n - q - 1];\n if (i - j >= 0 && b[i - j] == 1)\n {\n c[i] = a[j];\n break;\n }\n }\n\n if (c[i] != 0)\n {\n continue;\n }\n\n for (int z = 0; z < bCount; z++)\n {\n var bIndex = bPos[z];\n var j = i - bIndex;\n if (j >= 0)\n {\n c[i] = Math.Max(c[i], a[j]);\n }\n }\n }\n\n for (int i = 0; i < n; i++)\n {\n Console.WriteLine(c[i]);\n }\n }\n\n private long getNextX()\n {\n x = (x * 37 + 10007) % 1000000007;\n return x;\n }\n\n private void initAB()\n {\n for (int i = 0; i < n; i = i + 1)\n {\n a[i] = i + 1;\n }\n\n for (int i = 0; i < n; i = i + 1)\n {\n swap(ref a[i], ref a[getNextX() % (i + 1)]);\n }\n\n for (int i = 0; i < n; i = i + 1)\n {\n if (i < d)\n b[i] = 1;\n else\n b[i] = 0;\n }\n\n for (int i = 0; i < n; i = i + 1)\n {\n swap(ref b[i], ref b[getNextX() % (i + 1)]);\n }\n }\n\n private void swap(ref T first, ref T second)\n {\n T tmp = first;\n first = second;\n second = tmp;\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["probabilities"], "code_uid": "533c892f11bafc910c8af1a5f263bdb4", "src_uid": "948ae7a0189ada07c8c67a1757f691f0", "difficulty": 2300.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections;\nusing System.Collections.Generic;\nusing System.Collections.Specialized;\nusing System.Diagnostics;\nusing System.IO;\nusing System.Text;\nusing System.Linq;\n\nnamespace Codeforces\n{\n internal class Program\n {\n private static void Main()\n {\n if (Debugger.IsAttached)\n {\n Console.SetIn(new StreamReader(@\"..\\..\\..\\..\\Tests\\D7.in\"));\n }\n\n Solve();\n\n if (Debugger.IsAttached)\n {\n Console.In.Close();\n Console.SetIn(new StreamReader(Console.OpenStandardInput()));\n Console.ReadLine();\n }\n }\n\n private static void Solve()\n {\n var s = Read();\n var intF = new int[10];\n var intS = new int[10];\n foreach (var n in s)\n {\n intF[n - '0']++;\n intS[n - '0']++;\n }\n \n var max = 0;\n var maxIndex = -1;\n for (int i = 1; i < 10; i++)\n {\n var res = 0;\n var j = 10 - i;\n if(intF[i] > 0 && intS[j] > 0)\n {\n intF[i]--;\n intS[j]--;\n res++;\n for (int k = 0; k < 10; k++)\n {\n res += Math.Min(intF[k], intS[9 - k]);\n }\n intF[i]++;\n intS[j]++;\n }\n if(max < res)\n {\n max = res;\n maxIndex = i;\n }\n }\n var resF = new StringBuilder();\n var resS = new StringBuilder();\n if (maxIndex != -1)\n {\n intF[maxIndex]--;\n intS[(10 - maxIndex)%10]--;\n resF.Append(maxIndex);\n resS.Append((10 - maxIndex)%10);\n }\n for (int i = 0; i < 10; i++)\n {\n var count = Math.Min(intF[i], intS[9 - i]);\n resF.Append(i.ToString()[0], count);\n resS.Append((9-i).ToString()[0], count);\n intF[i] -= count;\n intS[9 - i] -= count;\n }\n var countZero = Math.Min(intF[0], intS[0]);\n resF.Insert(0, \"0\", countZero);\n resS.Insert(0, \"0\", countZero);\n intF[0] -= countZero;\n intS[0] -= countZero;\n for (int i = 0; i < 10; i++)\n {\n resF.Append(i.ToString()[0], intF[i]);\n resS.Append(i.ToString()[0], intS[i]);\n }\n \n Console.WriteLine(new string(resF.ToString().Reverse().ToArray()));\n Console.WriteLine(new string(resS.ToString().Reverse().ToArray()));\n }\n\n #region Reader\n\n private static string Read()\n {\n return Console.ReadLine();\n }\n\n private static string[] ReadArray()\n {\n return Console.ReadLine().Split(' ');\n }\n\n private static int[] ReadIntArray()\n {\n var input = Console.ReadLine().Split(' ').Select(Int32.Parse).ToArray();\n return input;\n }\n\n private static int ReadInt()\n {\n return Int32.Parse(Console.ReadLine());\n }\n\n private static long ReadLong()\n {\n return long.Parse(Console.ReadLine());\n }\n\n private static int ReadNextInt(string[] input, int index)\n {\n return Int32.Parse(input[index]);\n }\n\n #endregion\n }\n}", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "3d63223a6517a14bed635959912d2f54", "src_uid": "34b67958a37865e1ca0529bbf528dd9a", "difficulty": 1900.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Text;\nusing System.Diagnostics;\n\nclass Solver\n{\n public void Solve()\n {\n // count\n var cs = new int[10];\n var s = CF.ReadLine();\n foreach (var c in s)\n {\n int n = c-'0';\n cs[n]++;\n }\n\n //\n int max = -1;\n int[] best1 = new int[10];\n Array.Copy(cs, best1, 10);\n int[] best2 = new int[10];\n Array.Copy(cs, best2, 10);\n string max_n1 = \"\";\n string max_n2 = \"\";\n\n for (int a = 1; a <= 9; a++)\n {\n string n1 = \"\";\n string n2 = \"\";\n\n int b = 10 - a;\n\n int zc = 0;\n int[] tmp1 = new int[10];\n int[] tmp2 = new int[10];\n Array.Copy(cs, tmp1, 10);\n Array.Copy(cs, tmp2, 10);\n\n tmp1[a]--;\n if (tmp1[a] < 0)\n continue;\n tmp2[b]--;\n if (tmp2[b] < 0)\n continue;\n\n n1 += a;\n n2 += b;\n\n // c+d=9\n for (int c = 0; c <= 9; c++)\n {\n int d = 9 - c;\n\n int p = Math.Min(tmp1[c],tmp2[d]);\n\n tmp1[c] -= p;\n tmp2[d] -= p;\n \n zc += p;\n\n n1 = new string((char)('0'+c),p)+n1;\n n2 = new string((char)('0' + d), p) + n2;\n }\n\n if (zc > max)\n {\n max = zc;\n best1 = tmp1;\n best2 = tmp2;\n max_n1 = n1;\n max_n2 = n2;\n }\n }\n\n\n // 0+0=0\n int z = Math.Min(best1[0],best2[0]);\n max_n1 += new string('0', z);\n max_n2 += new string('0', z);\n best2[0] -=z;\n best1[0] -=z;\n \n for (int i = 0; i <= 9; i++)\n {\n max_n1 = new string((char)('0'+i), best1[i])+max_n1;\n max_n2 = new string((char)('0'+i), best2[i])+max_n2;\n }\n CF.WriteLine(max_n1);\n CF.WriteLine(max_n2);\n }\n\n\n\n\n // test\n static Utils CF = new Utils(new[]{\n@\"\n1099\n\"\n,\n@\"\n198\n\"\n,\n@\"\n500\n\"\n,\n@\"\n0\n\"\n,\n@\"\n1\n\"\n ,\n@\"\n10\n\"\n\n });\n #region test\n\n static void Main(string[] args)\n {\n#if DEBUG\n for (int t=0;t();\n string[] ss = _test_input[t].Replace(\"\\n\", \"\").Split('\\r');\n for (int i = 0; i < ss.Length; i++)\n {\n if (\n (i == 0 || i == ss.Length - 1) &&\n ss[i].Length == 0\n )\n continue;\n\n _lines.Add(ss[i]);\n }\n }\n\n public int TestCount\n {\n get\n {\n return _test_input.Length;\n }\n }\n\n public string ReadLine()\n {\n#if DEBUG\n string s = null;\n if (_lines.Count > 0)\n {\n s = _lines[0];\n _lines.RemoveAt(0);\n }\n return s;\n\n#else\n //return _sr.ReadLine();\n return Console.In.ReadLine();\n#endif\n }\n\n public void WriteLine(object o)\n {\n#if DEBUG\n System.Diagnostics.Trace.WriteLine(o);\n#else\n //_sw.WriteLine(o);\n Console.WriteLine(o);\n#endif\n }\n\n public void Write(object o)\n {\n#if DEBUG\n System.Diagnostics.Trace.Write(o);\n#else\n //_sw.Write(o);\n Console.Write(o);\n#endif\n }\n\n string[] _test_input;\n\n List _lines;\n\n#if DEBUG\n public Utils(string[] test_input)\n {\n _test_input = test_input;\n }\n#else\n\n public Utils(string[] dummy)\n {\n //_sr = new System.IO.StreamReader(\"input.txt\");\n //_sw = new System.IO.StreamWriter(\"output.txt\");\n }\n#endif\n\n }\n\n #endregion\n}\n\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "f49f02b7fa611f69e6da245c5ad6e5e8", "src_uid": "34b67958a37865e1ca0529bbf528dd9a", "difficulty": 1900.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.IO;\nusing System.Text;\n\nnamespace International_Olympiad\n{\n internal class Program\n {\n private static readonly StreamReader reader = new StreamReader(Console.OpenStandardInput(1024*10), Encoding.ASCII, false, 1024*10);\n private static readonly StreamWriter writer = new StreamWriter(Console.OpenStandardOutput(1024*10), Encoding.ASCII, 1024*10);\n\n private static void Main(string[] args)\n {\n int n = int.Parse(reader.ReadLine());\n\n for (int i = 0; i < n; i++)\n {\n string s = reader.ReadLine().Substring(4);\n long t = long.Parse(s);\n\n long pow = 10, f = 0;\n\n for (int k = 1; k < s.Length; k++)\n {\n f += pow;\n pow *= 10;\n }\n\n while (t < 1989 + f)\n {\n t += pow;\n }\n\n writer.WriteLine(t);\n }\n\n\n writer.Flush();\n }\n }\n}", "lang_cluster": "C#", "tags": ["math", "greedy", "constructive algorithms", "implementation"], "code_uid": "fc882163eeac6af84a3a66e3d7962497", "src_uid": "31be4d38a8b5ea8738a65bfee24a5a21", "difficulty": 2000.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Globalization;\nusing System.IO;\nusing System.Linq;\nusing System.Text;\nusing System.Threading;\n\n// (\u3065\u00b0\u03c9\u00b0)\u3065\uff90e\u2605\u309c\u30fb\u3002\u3002\u30fb\u309c\u309c\u30fb\u3002\u3002\u30fb\u309c\u2606\u309c\u30fb\u3002\u3002\u30fb\u309c\u309c\u30fb\u3002\u3002\u30fb\u309c\npublic class Solver\n{\n long Tot(long n)\n {\n long ret = n;\n for (long i = 2; i * i <= n; i++)\n if (n % i == 0)\n {\n ret = ret / i * (i - 1);\n while (n % i == 0)\n {\n n /= i;\n }\n }\n if (n > 1)\n ret = ret / n * (n - 1);\n return ret;\n }\n\n public void Solve()\n {\n long n = ReadLong();\n long m = ReadLong();\n\n int c = 1;\n while (c < 1000 && m > 1)\n {\n if (m % 2 > 0)\n c++;\n m--;\n }\n\n while (n > 1 && c > 0)\n {\n n = Tot(n);\n c--;\n }\n Write(n % 1000000007);\n }\n\n #region Main\n\n protected static TextReader reader;\n protected static TextWriter writer;\n static void Main()\n {\n#if DEBUG\n reader = new StreamReader(\"..\\\\..\\\\input.txt\");\n //reader = new StreamReader(Console.OpenStandardInput());\n writer = Console.Out;\n //writer = new StreamWriter(\"..\\\\..\\\\output.txt\");\n#else\n reader = new StreamReader(Console.OpenStandardInput());\n writer = new StreamWriter(Console.OpenStandardOutput());\n //reader = new StreamReader(\"input.txt\");\n //writer = new StreamWriter(\"output.txt\");\n#endif\n try\n {\n new Solver().Solve();\n //var thread = new Thread(new Solver().Solve, 1024 * 1024 * 256);\n //thread.Start();\n //thread.Join();\n }\n catch (Exception ex)\n {\n#if DEBUG\n Console.WriteLine(ex);\n#else\n throw;\n#endif\n }\n reader.Close();\n writer.Close();\n }\n\n #endregion\n\n #region Read / Write\n private static Queue currentLineTokens = new Queue();\n private static string[] ReadAndSplitLine() { return reader.ReadLine().Split(new[] { ' ', '\\t', }, StringSplitOptions.RemoveEmptyEntries); }\n public static string ReadToken() { while (currentLineTokens.Count == 0)currentLineTokens = new Queue(ReadAndSplitLine()); return currentLineTokens.Dequeue(); }\n public static int ReadInt() { return int.Parse(ReadToken()); }\n public static long ReadLong() { return long.Parse(ReadToken()); }\n public static double ReadDouble() { return double.Parse(ReadToken(), CultureInfo.InvariantCulture); }\n public static int[] ReadIntArray() { return ReadAndSplitLine().Select(int.Parse).ToArray(); }\n public static long[] ReadLongArray() { return ReadAndSplitLine().Select(long.Parse).ToArray(); }\n public static double[] ReadDoubleArray() { return ReadAndSplitLine().Select(s => double.Parse(s, CultureInfo.InvariantCulture)).ToArray(); }\n public static int[][] ReadIntMatrix(int numberOfRows) { int[][] matrix = new int[numberOfRows][]; for (int i = 0; i < numberOfRows; i++)matrix[i] = ReadIntArray(); return matrix; }\n public static int[][] ReadAndTransposeIntMatrix(int numberOfRows)\n {\n int[][] matrix = ReadIntMatrix(numberOfRows); int[][] ret = new int[matrix[0].Length][];\n for (int i = 0; i < ret.Length; i++) { ret[i] = new int[numberOfRows]; for (int j = 0; j < numberOfRows; j++)ret[i][j] = matrix[j][i]; } return ret;\n }\n public static string[] ReadLines(int quantity) { string[] lines = new string[quantity]; for (int i = 0; i < quantity; i++)lines[i] = reader.ReadLine().Trim(); return lines; }\n public static void WriteArray(IEnumerable array) { writer.WriteLine(string.Join(\" \", array)); }\n public static void Write(params object[] array) { WriteArray(array); }\n public static void WriteLines(IEnumerable array) { foreach (var a in array)writer.WriteLine(a); }\n private class SDictionary : Dictionary\n {\n public new TValue this[TKey key]\n {\n get { return ContainsKey(key) ? base[key] : default(TValue); }\n set { base[key] = value; }\n }\n }\n private static T[] Init(int size) where T : new() { var ret = new T[size]; for (int i = 0; i < size; i++)ret[i] = new T(); return ret; }\n #endregion\n}", "lang_cluster": "C#", "tags": ["math", "number theory"], "code_uid": "5823fed95c6b745039994cd3791faee1", "src_uid": "0591ade5f9a69afcbecd80402493f975", "difficulty": 2100.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Linq.Expressions;\nusing System.IO;\nusing System.Text;\nusing System.Diagnostics;\n\nusing Binary = System.Func;\nusing Unary = System.Func;\n\nclass Program\n{\n static StreamWriter sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };\n static Scan sc = new Scan();\n// static Scan sc = new ScanCHK();\n const int M = 1000000007;\n const double eps = 1e-9;\n static readonly int[] dd = { 0, 1, 0, -1, 0 };\n static SortedDictionary memo;\n static void Main()\n {\n long n, k;\n sc.Multi(out n, out k);\n k = (k + 1) / 2;\n memo = new SortedDictionary();\n\n Prt(calc(n, k) % M);\n sw.Flush();\n }\n static long f(long n)\n {\n if (n < 3) return 1;\n if (memo.ContainsKey(n))\n return memo[n];\n\n long ret = n - 1;\n for (long i = 2; i * i <= n; i++)\n {\n if (n % i == 0)\n {\n ret -= f(i);\n if (i != n / i)\n {\n ret -= f(n / i);\n }\n }\n }\n memo.Add(n, ret);\n return ret;\n }\n static long calc(long n, long k)\n {\n if (n == 1) return 1;\n if (k == 0) return n;\n\n long nn = n - 1;\n for (long i = 2; i * i <= n; i++)\n {\n if (n % i == 0)\n {\n nn -= f(i);\n if (i != n / i)\n {\n nn -= f(n / i);\n }\n }\n }\n return calc(nn, k - 1);\n }\n\n static void swap(ref T a, ref T b) { var t = a; a = b; b = t; }\n static T Max(params T[] a) { return a.Max(); }\n static T Min(params T[] a) { return a.Min(); }\n static void DBG(string a) { Console.WriteLine(a); }\n static void DBG(IEnumerable a) { Console.WriteLine(string.Join(\" \", a)); }\n static void DBG(params object[] a) { Console.WriteLine(string.Join(\" \", a)); }\n static void Prt(string a) { sw.WriteLine(a); }\n static void Prt(IEnumerable a) { sw.WriteLine(string.Join(\" \", a)); }\n static void Prt(params object[] a) { sw.WriteLine(string.Join(\" \", a)); }\n}\nstatic class ex\n{\n public static void swap(this IList a, int i, int j) { var t = a[i]; a[i] = a[j]; a[j] = t; }\n public static T[] copy(this IList a)\n {\n var ret = new T[a.Count];\n for (int i = 0; i < a.Count; i++) ret[i] = a[i];\n return ret;\n }\n}\nstatic class Operator\n{\n static readonly ParameterExpression x = Expression.Parameter(typeof(T), \"x\");\n static readonly ParameterExpression y = Expression.Parameter(typeof(T), \"y\");\n public static readonly Func Add = Lambda(Expression.Add);\n public static readonly Func Subtract = Lambda(Expression.Subtract);\n public static readonly Func Multiply = Lambda(Expression.Multiply);\n public static readonly Func Divide = Lambda(Expression.Divide);\n public static readonly Func Plus = Lambda(Expression.UnaryPlus);\n public static readonly Func Negate = Lambda(Expression.Negate);\n public static Func Lambda(Binary op) { return Expression.Lambda>(op(x, y), x, y).Compile(); }\n public static Func Lambda(Unary op) { return Expression.Lambda>(op(x), x).Compile(); }\n}\n\nclass ScanCHK : Scan\n{\n public new string Str { get { var s = Console.ReadLine(); if (s != s.Trim()) throw new Exception(); return s; } }\n}\nclass Scan\n{\n public int Int { get { return int.Parse(Str); } }\n public long Long { get { return long.Parse(Str); } }\n public double Double { get { return double.Parse(Str); } }\n public string Str { get { return Console.ReadLine().Trim(); } }\n public int[] IntArr { get { return StrArr.Select(int.Parse).ToArray(); } }\n public long[] LongArr { get { return StrArr.Select(long.Parse).ToArray(); } }\n public double[] DoubleArr { get { return StrArr.Select(double.Parse).ToArray(); } }\n public string[] StrArr { get { return Str.Split(); } }\n bool eq() { return typeof(T).Equals(typeof(U)); }\n T ct(U a) { return (T)Convert.ChangeType(a, typeof(T)); }\n T cv(string s) { return eq() ? ct(int.Parse(s))\n : eq() ? ct(long.Parse(s))\n : eq() ? ct(double.Parse(s))\n : eq() ? ct(s[0])\n : ct(s); }\n public void Multi(out T a) { a = cv(Str); }\n public void Multi(out T a, out U b)\n { var ar = StrArr; a = cv(ar[0]); b = cv(ar[1]); }\n public void Multi(out T a, out U b, out V c)\n { var ar = StrArr; a = cv(ar[0]); b = cv(ar[1]); c = cv(ar[2]); }\n public void Multi(out T a, out U b, out V c, out W d)\n { var ar = StrArr; a = cv(ar[0]); b = cv(ar[1]); c = cv(ar[2]); d = cv(ar[3]); }\n public void Multi(out T a, out U b, out V c, out W d, out X e)\n { var ar = StrArr; a = cv(ar[0]); b = cv(ar[1]); c = cv(ar[2]); d = cv(ar[3]); e = cv(ar[4]); }\n}\nclass mymath\n{\n public static long Mod = 1000000007;\n public static bool isprime(long a)\n {\n if (a < 2) return false;\n for (long i = 2; i * i <= a; i++) if (a % i == 0) return false;\n return true;\n }\n public static bool[] sieve(int n)\n {\n var p = new bool[n + 1];\n for (int i = 2; i <= n; i++) p[i] = true;\n for (int i = 2; i * i <= n; i++) if (p[i]) for (int j = i * i; j <= n; j += i) p[j] = false;\n return p;\n }\n public static List getprimes(int n)\n {\n var prs = new List();\n var p = sieve(n);\n for (int i = 2; i <= n; i++) if (p[i]) prs.Add(i);\n return prs;\n }\n public static long[][] E(int n)\n {\n var ret = new long[n][];\n for (int i = 0; i < n; i++) { ret[i] = new long[n]; ret[i][i] = 1; }\n return ret;\n }\n public static long[][] pow(long[][] A, long n)\n {\n if (n == 0) return E(A.Length);\n var t = pow(A, n / 2);\n if ((n & 1) == 0) return mul(t, t);\n return mul(mul(t, t), A);\n }\n public static double dot(double[] x, double[] y)\n {\n int n = x.Length;\n double ret = 0;\n for (int i = 0; i < n; i++) ret += x[i] * y[i];\n return ret;\n }\n public static long dot(long[] x, long[] y)\n {\n int n = x.Length;\n long ret = 0;\n for (int i = 0; i < n; i++) ret = (ret + x[i] * y[i]) % Mod;\n return ret;\n }\n public static T[][] trans(T[][] A)\n {\n int n = A[0].Length, m = A.Length;\n var ret = new T[n][];\n for (int i = 0; i < n; i++) { ret[i] = new T[m]; for (int j = 0; j < m; j++) ret[i][j] = A[j][i]; }\n return ret;\n }\n public static double[] mul(double[][] A, double[] x)\n {\n int n = A.Length;\n var ret = new double[n];\n for (int i = 0; i < n; i++) ret[i] = dot(x, A[i]);\n return ret;\n }\n public static long[] mul(long[][] A, long[] x)\n {\n int n = A.Length;\n var ret = new long[n];\n for (int i = 0; i < n; i++) ret[i] = dot(x, A[i]);\n return ret;\n }\n public static long[][] mul(long[][] A, long[][] B)\n {\n int n = A.Length;\n var Bt = trans(B);\n var ret = new long[n][];\n for (int i = 0; i < n; i++) ret[i] = mul(Bt, A[i]);\n return ret;\n }\n public static long[] add(long[] x, long[] y)\n {\n int n = x.Length;\n var ret = new long[n];\n for (int i = 0; i < n; i++) ret[i] = (x[i] + y[i]) % Mod;\n return ret;\n }\n public static long[][] add(long[][] A, long[][] B)\n {\n int n = A.Length;\n var ret = new long[n][];\n for (int i = 0; i < n; i++) ret[i] = add(A[i], B[i]);\n return ret;\n }\n public static long pow(long a, long b)\n {\n if (a >= Mod) return pow(a % Mod, b);\n if (a == 0) return 0;\n if (b == 0) return 1;\n var t = pow(a, b / 2);\n if ((b & 1) == 0) return t * t % Mod;\n return t * t % Mod * a % Mod;\n }\n public static long inv(long a) { return pow(a, Mod - 2); }\n public static long gcd(long a, long b)\n {\n while (b > 0) { var t = a % b; a = b; b = t; }\n return a;\n }\n // a x + b y = gcd(a, b)\n public static long extgcd(long a, long b, out long x, out long y)\n {\n long g = a; x = 1; y = 0;\n if (b > 0) { g = extgcd(b, a % b, out y, out x); y -= a / b * x; }\n return g;\n }\n public static long lcm(long a, long b) { return a / gcd(a, b) * b; }\n public static long comb(int n, int r)\n {\n if (n < 0 || r < 0 || r > n) return 0;\n if (n - r < r) r = n - r;\n if (r == 0) return 1;\n if (r == 1) return n;\n int[] numer = new int[r], denom = new int[r];\n for (int k = 0; k < r; k++) { numer[k] = n - r + k + 1; denom[k] = k + 1; }\n for (int p = 2; p <= r; p++)\n {\n int piv = denom[p - 1];\n if (piv > 1)\n {\n int ofst = (n - r) % p;\n for (int k = p - 1; k < r; k += p) { numer[k - ofst] /= piv; denom[k] /= piv; }\n }\n }\n long ret = 1;\n for (int k = 0; k < r; k++) if (numer[k] > 1) ret = ret * numer[k] % Mod;\n return ret;\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "number theory"], "code_uid": "a212b8096468b000f6b75a90fae13013", "src_uid": "0591ade5f9a69afcbecd80402493f975", "difficulty": 2100.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\n\t\t\t\t\t\npublic class Program\n{\n\tpublic static void Main()\n\t{\n\t\tint n = int.Parse(Console.ReadLine());\n\t\t\n\t\tfor (int i = 2; i < n; i++)\n\t\t{\n\t\t\tif (n % i == 0)\n\t\t\t{\n\t\t\t\tConsole.WriteLine(i + \"\" + (n / i));\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n}", "lang_cluster": "C#", "tags": ["math", "number theory"], "code_uid": "7518e5c8ddd87d2d3f1435ee7e15319d", "src_uid": "7220f2da5081547a12118595bbeda4f6", "difficulty": null, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Globalization;\nusing System.IO;\nusing System.Linq;\nusing System.Text;\nusing System.Threading;\n\n// (\u3065\u00b0\u03c9\u00b0)\u3065\uff90e\u2605\u309c\u30fb\u3002\u3002\u30fb\u309c\u309c\u30fb\u3002\u3002\u30fb\u309c\u2606\u309c\u30fb\u3002\u3002\u30fb\u309c\u309c\u30fb\u3002\u3002\u30fb\u309c\npublic class Solver\n{\n public void Solve()\n {\n int n = ReadInt();\n for (int i = 2;; i++)\n if (n % i == 0)\n {\n Write(i.ToString() + (n / i).ToString());\n return;\n }\n }\n\n #region Main\n\n protected static TextReader reader;\n protected static TextWriter writer;\n static void Main()\n {\n#if DEBUG\n reader = new StreamReader(\"..\\\\..\\\\input.txt\");\n //reader = new StreamReader(Console.OpenStandardInput());\n writer = Console.Out;\n //writer = new StreamWriter(\"..\\\\..\\\\output.txt\");\n#else\n reader = new StreamReader(Console.OpenStandardInput());\n writer = new StreamWriter(Console.OpenStandardOutput());\n //reader = new StreamReader(\"input.txt\");\n //writer = new StreamWriter(\"output.txt\");\n#endif\n try\n {\n new Solver().Solve();\n //var thread = new Thread(new Solver().Solve, 1024 * 1024 * 128);\n //thread.Start();\n //thread.Join();\n }\n catch (Exception ex)\n {\n#if DEBUG\n Console.WriteLine(ex);\n#else\n throw;\n#endif\n }\n reader.Close();\n writer.Close();\n }\n\n #endregion\n\n #region Read / Write\n private static Queue currentLineTokens = new Queue();\n private static string[] ReadAndSplitLine() { return reader.ReadLine().Split(new[] { ' ', '\\t', }, StringSplitOptions.RemoveEmptyEntries); }\n public static string ReadToken() { while (currentLineTokens.Count == 0)currentLineTokens = new Queue(ReadAndSplitLine()); return currentLineTokens.Dequeue(); }\n public static int ReadInt() { return int.Parse(ReadToken()); }\n public static long ReadLong() { return long.Parse(ReadToken()); }\n public static double ReadDouble() { return double.Parse(ReadToken(), CultureInfo.InvariantCulture); }\n public static int[] ReadIntArray() { return ReadAndSplitLine().Select(int.Parse).ToArray(); }\n public static long[] ReadLongArray() { return ReadAndSplitLine().Select(long.Parse).ToArray(); }\n public static double[] ReadDoubleArray() { return ReadAndSplitLine().Select(s => double.Parse(s, CultureInfo.InvariantCulture)).ToArray(); }\n public static int[][] ReadIntMatrix(int numberOfRows) { int[][] matrix = new int[numberOfRows][]; for (int i = 0; i < numberOfRows; i++)matrix[i] = ReadIntArray(); return matrix; }\n public static int[][] ReadAndTransposeIntMatrix(int numberOfRows)\n {\n int[][] matrix = ReadIntMatrix(numberOfRows); int[][] ret = new int[matrix[0].Length][];\n for (int i = 0; i < ret.Length; i++) { ret[i] = new int[numberOfRows]; for (int j = 0; j < numberOfRows; j++)ret[i][j] = matrix[j][i]; } return ret;\n }\n public static string[] ReadLines(int quantity) { string[] lines = new string[quantity]; for (int i = 0; i < quantity; i++)lines[i] = reader.ReadLine().Trim(); return lines; }\n public static void WriteArray(IEnumerable array) { writer.WriteLine(string.Join(\" \", array)); }\n public static void Write(params object[] array) { WriteArray(array); }\n public static void WriteLines(IEnumerable array) { foreach (var a in array)writer.WriteLine(a); }\n private class SDictionary : Dictionary\n {\n public new TValue this[TKey key]\n {\n get { return ContainsKey(key) ? base[key] : default(TValue); }\n set { base[key] = value; }\n }\n }\n private static T[] Init(int size) where T : new() { var ret = new T[size]; for (int i = 0; i < size; i++)ret[i] = new T(); return ret; }\n #endregion\n}", "lang_cluster": "C#", "tags": ["math", "number theory"], "code_uid": "567f3c846d8ad549ea61082758e31c7d", "src_uid": "7220f2da5081547a12118595bbeda4f6", "difficulty": null, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.IO;\nusing System.Text;\nusing System.Linq;\nusing System.Globalization;\n\nclass Program\n{\n public class SegmentTree where T : IComparable\n {\n private int Mid;\n private T[] t;\n private Func f;\n private T defaultValue = default(T);\n\n public SegmentTree(T[] a, Func f)\n {\n this.Mid = 1;\n while (Mid < a.Length) Mid *= 2;\n this.t = new T[Mid + Mid];\n this.f = f;\n\n Array.Copy(a, 0, this.t, Mid, a.Length);\n for (int i = (Mid + a.Length - 1) / 2; i > 0; i--) this.UpdateValueFor(i);\n }\n public SegmentTree(T defaultValue, int capacity, Func f)\n {\n this.defaultValue = defaultValue;\n this.Mid = 1;\n while (Mid < capacity) Mid *= 2;\n this.t = new T[Mid + Mid];\n this.f = f;\n\n for (int i = 0; i < Mid; i++)\n this.t[Mid + i] = defaultValue;\n\n for (int i = (Mid + Mid - 1) / 2; i > 0; i--) this.UpdateValueFor(i);\n }\n\n public T GetRoot()\n {\n return t[1];\n }\n\n public T Get(int l, int r)\n {\n l += Mid;\n r += Mid;\n\n T ans = this.defaultValue;\n while (l <= r)\n {\n if ((l & 1) == 1) ans = this.f(ans, t[l]);\n if ((r & 1) == 0) ans = this.f(ans, t[r]);\n\n l = (l + 1) >> 1;\n r = (r - 1) >> 1;\n }\n\n return ans;\n }\n\n public void Update(int i, T value)\n {\n t[i + Mid] = value;\n for (i = (i + Mid) >> 1; i >= 1; i = (i >> 1)) this.UpdateValueFor(i);\n }\n\n private void UpdateValueFor(int i)\n {\n t[i] = this.f(t[i + i], t[i + i + 1]);\n }\n }\n\n public class Item : IComparable\n {\n public long Value;\n public int Pos;\n\n public Item(int pos, long val)\n {\n this.Pos = pos;\n this.Value = val;\n }\n\n public int CompareTo(Item other)\n {\n return this.Value.CompareTo(other.Value);\n }\n }\n\n private static long SolveDBf(long a1, long b1, long a2, long b2, long l, long r, bool print = false)\n {\n long ans = 0;\n long min = l;\n if (min < b1) min = b1;\n if (min < b2) min = b2;\n\n for (long i = min; i <= r; i++)\n {\n if ((i - b1) % a1 == 0)\n if ((i - b2) % a2 == 0)\n {\n if (print)\n Console.WriteLine(i+ \" \");\n\n ans++;\n }\n }\n\n return ans;\n }\n\n private static long SolveDBf2(long a1, long b1, long a2, long b2, long l, long r)\n {\n long ans = 0;\n long min = l;\n if (min < b1) min = b1;\n if (min < b2) min = b2;\n\n if ((min-b1) % a1 > 0)\n min += a1 - ((min - b1) % a1);\n /*\n long del = (min - b1);\n if (del % a1 > 0) del += a1;\n long sf = del / a1;\n \n long i = min + sf * a1;\n * */\n\n long i = min;\n\n for (; i <= r; i += a1)\n {\n if ((i - b2) % a2 == 0)\n {\n ans++;\n }\n }\n\n return ans;\n }\n\n private static long SolveDBf3(long a, long b, long l, long r)\n {\n if (b > r) return 0;\n\n if (b < l)\n {\n long delta = (l - b) / a;\n b += delta * a;\n if (b < l) b += a;\n }\n\n if (b > r) return 0;\n\n long size = (r - b + a) / a;\n\n\n return size;\n }\n\n private static long SolveD(long a1, long b1, long a2, long b2, long l, long r)\n {\n if (a1 < a2)\n return SolveD(a2, b2, a1, b1, l, r);\n\n long ans = 0;\n if (a1 > 1000) return SolveDBf2(a1, b1, a2, b2, l, r);\n\n if (b1 < b2)\n {\n long q = (b2 - b1) / a1;\n b1 += q * a1;\n if (b1 < b2) b1 += a1;\n }\n\n for (long i = 0; i <= 1000; i++)\n {\n long t = a1 * i + b1;\n if ((t - b2) % a2 == 0)\n {\n b1 = t;\n b2 = t;\n\n long gcd = GCD(a1, a2);\n long delta = a1 * a2 / gcd;\n\n return SolveDBf3(delta, t, l, r);\n }\n }\n\n return ans;\n }\n\n private static void SolveD()\n {/*\n PushTestData(@\"\n2 0 3 3 5 21\nAns 3\n\n2 4 3 0 6 17\nAns 2\n\n\n\n\n\n\");*/\n long a1 = RL();\n long b1 = RL();\n long a2 = RL();\n long b2 = RL();\n\n long l = RL();\n long r = RL();\n Console.WriteLine(SolveD(a1, b1, a2, b2, l, r));\n //Console.WriteLine(SolveDBf(a1, b1, a2, b2, l, r));\n\n }\n\n private static Random rnd = new Random();\n private static void Testing()\n {\n while (true)\n {\n long a1 = rnd.Next(1, 10000);\n long b1 = rnd.Next(-100000, 100000);\n long a2 = rnd.Next(1, 10000);\n long b2 = rnd.Next(-100000, 100000);\n\n long l = rnd.Next(-100000, 100000);\n long r = rnd.Next(-100000, 100000);\n\n var ans1 = SolveD(a1, b1, a2, b2, l, r);\n var ans2 = SolveDBf(a1, b1, a2, b2, l, r);\n if (ans1 != ans2)\n {\n SolveDBf(a1, b1, a2, b2, l, r, true);\n ans1 = SolveD(a1, b1, a2, b2, l, r);\n Console.WriteLine(\"WA \" + a1 + \" \" + b1 + \" \" + a2 + \" \" + b2 + \" \" + l + \" \" + r);\n }\n }\n }\n\n private static long x, y;\n private static long[] dp;\n\n static void Main(string[] args)\n {\n //Testing();\n SolveD();\n \n \n /*\n int n = RI();\n x = RI();\n y = RI();\n\n dp = new long[n * 2 + 2];\n dp[0] = 0;\n for (int i = 1; i < dp.Length; i++)\n dp[i] = long.MaxValue;\n\n dp[0] = 0;\n\n int max = 3*n;\n var st = new SegmentTree(null, max, (a, b) =>\n {\n if (a.Value <= b.Value)\n return a;\n\n return b;\n });\n\n st.Update(0, new Item(0, 0));\n\n while (true)\n {\n var item = st.Get(0, max);\n int p = item.Pos;\n\n if (dp[p + 1] < dp[p] + x)\n {\n st.Update(p+1)\n heap.Add(new Item() { Value = dp[p + 1], Pos = p + 1 });\n }\n }\n\n Console.WriteLine(dp[n]);*/\n }\n\n #region Data Read\n private static char ReadSign()\n {\n while (true)\n {\n int ans = consoleReader.Read();\n if (ans == '?' || ans == '+' || ans == '-')\n return (char)ans;\n }\n }\n\n private static long GCD(long a, long b)\n {\n if (a % b == 0) return b;\n return GCD(b, a % b);\n }\n\n private static int Mod = 1000000007;\n private static List[] ReadGraph(int n, int m)\n {\n List[] g = new List[n];\n for (int i = 0; i < n; i++) g[i] = new List();\n for (int i = 0; i < m; i++)\n {\n int a = RI() - 1;\n int b = RI() - 1;\n\n g[a].Add(b);\n g[b].Add(a);\n }\n\n return g;\n }\n\n private static int[,] ReadGraphAsMatrix(int n, int m)\n {\n int[,] matrix = new int[n + 1, n + 1];\n for (int i = 0; i < m; i++)\n {\n int a = RI();\n int b = RI();\n matrix[a, b] = matrix[b, a] = 1;\n }\n\n return matrix;\n }\n\n private static void Sort(ref int a, ref int b)\n {\n if (a > b) Swap(ref a, ref b);\n }\n\n private static void Swap(ref int a, ref int b)\n {\n int tmp = a;\n a = b;\n b = tmp;\n }\n\n private const int BufferSize = 1 << 16;\n private static StreamReader consoleReader;\n private static MemoryStream testData;\n\n private static int RI()\n {\n int ans = 0;\n int mul = 1;\n do\n {\n ans = consoleReader.Read();\n if (ans == -1)\n return 0;\n if (ans == '-') mul = -1;\n } while (ans < '0' || ans > '9');\n\n ans -= '0';\n while (true)\n {\n int chr = consoleReader.Read();\n if (chr < '0' || chr > '9')\n return ans * mul;\n ans = ans * 10 + chr - '0';\n }\n }\n\n private static ulong RUL()\n {\n ulong ans = 0;\n int chr;\n do\n {\n chr = consoleReader.Read();\n if (chr == -1)\n return 0;\n } while (chr < '0' || chr > '9');\n\n ans = (uint)(chr - '0');\n while (true)\n {\n chr = consoleReader.Read();\n if (chr < '0' || chr > '9')\n return ans;\n ans = ans * 10 + (uint)(chr - '0');\n }\n }\n\n private static long RL()\n {\n long ans = 0;\n int mul = 1;\n do\n {\n ans = consoleReader.Read();\n if (ans == -1)\n return 0;\n if (ans == '-') mul = -1;\n } while (ans < '0' || ans > '9');\n\n ans -= '0';\n while (true)\n {\n int chr = consoleReader.Read();\n if (chr < '0' || chr > '9')\n return ans * mul;\n ans = ans * 10 + chr - '0';\n }\n }\n\n private static int[] RIA(int n)\n {\n int[] ans = new int[n];\n for (int i = 0; i < n; i++)\n ans[i] = RI();\n return ans;\n }\n\n private static long[] RLA(int n)\n {\n long[] ans = new long[n];\n for (int i = 0; i < n; i++)\n ans[i] = RL();\n return ans;\n }\n\n private static char[] ReadString()\n {\n int ans;\n\n do\n {\n ans = consoleReader.Read();\n } while (!((ans >= 'a' && ans <= 'z') || (ans >= 'A' && ans <= 'Z')));\n\n List s = new List();\n do\n {\n s.Add((char)ans);\n ans = consoleReader.Read();\n } while ((ans >= 'a' && ans <= 'z') || (ans >= 'A' && ans <= 'Z'));\n\n return s.ToArray();\n }\n\n private static char[] ReadString(int n)\n {\n int ans;\n\n do\n {\n ans = consoleReader.Read();\n } while (!((ans >= 'a' && ans <= 'z') || (ans >= 'A' && ans <= 'Z')));\n\n char[] s = new char[n];\n int pos = 0;\n do\n {\n s[pos++] = (char)ans;\n if (pos == n) break;\n ans = consoleReader.Read();\n } while ((ans >= 'a' && ans <= 'z') || (ans >= 'A' && ans <= 'Z'));\n\n return s;\n }\n\n private static char[] ReadStringLine()\n {\n int ans;\n\n do\n {\n ans = consoleReader.Read();\n } while (ans == 10 || ans == 13);\n\n List s = new List();\n\n do\n {\n s.Add((char)ans);\n ans = consoleReader.Read();\n } while (ans != 10 && ans != 13);\n\n return s.ToArray();\n }\n\n private static char ReadLetter()\n {\n while (true)\n {\n int ans = consoleReader.Read();\n if ((ans >= 'a' && ans <= 'z') || (ans >= 'A' && ans <= 'Z'))\n return (char)ans;\n }\n }\n private static char ReadNonLetter()\n {\n while (true)\n {\n int ans = consoleReader.Read();\n if (!((ans >= 'a' && ans <= 'z') || (ans >= 'A' && ans <= 'Z')))\n return (char)ans;\n }\n }\n\n private static char ReadDigit()\n {\n while (true)\n {\n int ans = consoleReader.Read();\n if (ans >= '0' && ans <= '9')\n return (char)ans;\n }\n }\n\n private static int ReadDigitInt()\n {\n return ReadDigit() - (int)'0';\n }\n\n private static char ReadAnyChar()\n {\n return (char)consoleReader.Read();\n }\n\n private static string DoubleToString(double x)\n {\n return x.ToString(CultureInfo.InvariantCulture);\n }\n\n private static double DoubleFromString(string x)\n {\n return double.Parse(x, CultureInfo.InvariantCulture);\n }\n\n static Program()\n {\n //Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;\n consoleReader = new StreamReader(Console.OpenStandardInput(BufferSize), Encoding.ASCII, false, BufferSize);\n }\n\n private static void PushTestData(string data)\n {\n#if TOLYAN_TEST\n if (testData == null)\n {\n testData = new MemoryStream();\n consoleReader = new StreamReader(testData);\n }\n\n var pos = testData.Position;\n var bytes = Encoding.UTF8.GetBytes(data);\n testData.Write(bytes, 0, bytes.Length);\n testData.Flush();\n testData.Position = pos;\n#endif\n }\n #endregion\n}", "lang_cluster": "C#", "tags": ["math", "number theory"], "code_uid": "4e79a0e2f376fb8105e8ac73d01e1b84", "src_uid": "b08ee0cd6f5cb574086fa02f07d457a4", "difficulty": 2500.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Globalization;\nusing System.IO;\nusing System.Linq;\nusing System.Text;\nusing System.Threading;\n\n// (\u3065\u00b0\u03c9\u00b0)\u3065\uff90e\u2605\u309c\u30fb\u3002\u3002\u30fb\u309c\u309c\u30fb\u3002\u3002\u30fb\u309c\u2606\u309c\u30fb\u3002\u3002\u30fb\u309c\u309c\u30fb\u3002\u3002\u30fb\u309c\npublic class Solver\n{\n long Fun(long a, long b, long x)\n {\n if (b > x)\n return 0;\n return (x - b) / a + 1;\n }\n\n long Fun(long a, long b, long l, long r)\n {\n return Fun(a, b, r) - Fun(a, b, l - 1);\n }\n\n long Gcd(long a, long b, out long x, out long y) \n {\n if (a == 0)\n {\n x = 0;\n y = 1;\n return b;\n }\n\t long x1, y1;\n\t long d = Gcd(b % a, a, out x1, out y1);\n\t x = y1 - (b / a) * x1;\n\t y = x1;\n\t return d;\n }\n \n bool Dio(long a, long b, long c, out long x0, out long y0, out long g) \n {\n\t g = Gcd(Math.Abs(a), Math.Abs(b), out x0, out y0);\n\t if (c % g != 0)\n\t\t return false;\n\t x0 *= c / g;\n\t y0 *= c / g;\n\t if (a < 0)\n x0 *= -1;\n\t if (b < 0) \n y0 *= -1;\n\t return true;\n }\n\n public void Solve()\n {\n long a1 = ReadInt();\n long b1 = ReadInt();\n long a2 = ReadInt();\n long b2 = ReadInt();\n long l = ReadInt();\n long r = ReadInt();\n\n if (a1 == a2)\n {\n if (Math.Abs(b1 - b2) % a1 != 0)\n Write(0);\n else\n Write(Fun(a1, Math.Max(b1, b2), l, r));\n return;\n }\n\n long x0, y0, g;\n if (!Dio(a1, -a2, b2 - b1, out x0, out y0, out g))\n {\n Write(0);\n return;\n }\n \n long d1 = a2 / g;\n long d2 = a1 / g;\n if (x0 < 0)\n {\n long z = ((-x0 - 1) / d1 + 1);\n x0 += z * d1;\n y0 += z * d2;\n }\n if (y0 < 0)\n {\n long z = ((-y0 - 1) / d2 + 1);\n x0 += z * d1;\n y0 += z * d2;\n }\n \n long t = Math.Min(x0 / d1, y0 / d2);\n x0 -= t * d1;\n y0 -= t * d2;\n Write(Fun(d1 * a1, a1 * x0 + b1, l, r));\n }\n\n #region Main\n\n protected static TextReader reader;\n protected static TextWriter writer;\n static void Main()\n {\n#if DEBUG\n reader = new StreamReader(\"..\\\\..\\\\input.txt\");\n //reader = new StreamReader(Console.OpenStandardInput());\n writer = Console.Out;\n //writer = new StreamWriter(\"..\\\\..\\\\output.txt\");\n#else\n reader = new StreamReader(Console.OpenStandardInput());\n writer = new StreamWriter(Console.OpenStandardOutput());\n //reader = new StreamReader(\"input.txt\");\n //writer = new StreamWriter(\"output.txt\");\n#endif\n try\n {\n new Solver().Solve();\n //var thread = new Thread(new Solver().Solve, 1024 * 1024 * 128);\n //thread.Start();\n //thread.Join();\n }\n catch (Exception ex)\n {\n#if DEBUG\n Console.WriteLine(ex);\n#else\n throw;\n#endif\n }\n reader.Close();\n writer.Close();\n }\n\n #endregion\n\n #region Read / Write\n private static Queue currentLineTokens = new Queue();\n private static string[] ReadAndSplitLine() { return reader.ReadLine().Split(new[] { ' ', '\\t', }, StringSplitOptions.RemoveEmptyEntries); }\n public static string ReadToken() { while (currentLineTokens.Count == 0)currentLineTokens = new Queue(ReadAndSplitLine()); return currentLineTokens.Dequeue(); }\n public static int ReadInt() { return int.Parse(ReadToken()); }\n public static long ReadLong() { return long.Parse(ReadToken()); }\n public static double ReadDouble() { return double.Parse(ReadToken(), CultureInfo.InvariantCulture); }\n public static int[] ReadIntArray() { return ReadAndSplitLine().Select(int.Parse).ToArray(); }\n public static long[] ReadLongArray() { return ReadAndSplitLine().Select(long.Parse).ToArray(); }\n public static double[] ReadDoubleArray() { return ReadAndSplitLine().Select(s => double.Parse(s, CultureInfo.InvariantCulture)).ToArray(); }\n public static int[][] ReadIntMatrix(int numberOfRows) { int[][] matrix = new int[numberOfRows][]; for (int i = 0; i < numberOfRows; i++)matrix[i] = ReadIntArray(); return matrix; }\n public static int[][] ReadAndTransposeIntMatrix(int numberOfRows)\n {\n int[][] matrix = ReadIntMatrix(numberOfRows); int[][] ret = new int[matrix[0].Length][];\n for (int i = 0; i < ret.Length; i++) { ret[i] = new int[numberOfRows]; for (int j = 0; j < numberOfRows; j++)ret[i][j] = matrix[j][i]; } return ret;\n }\n public static string[] ReadLines(int quantity) { string[] lines = new string[quantity]; for (int i = 0; i < quantity; i++)lines[i] = reader.ReadLine().Trim(); return lines; }\n public static void WriteArray(IEnumerable array) { writer.WriteLine(string.Join(\" \", array)); }\n public static void Write(params object[] array) { WriteArray(array); }\n public static void WriteLines(IEnumerable array) { foreach (var a in array)writer.WriteLine(a); }\n private class SDictionary : Dictionary\n {\n public new TValue this[TKey key]\n {\n get { return ContainsKey(key) ? base[key] : default(TValue); }\n set { base[key] = value; }\n }\n }\n private static T[] Init(int size) where T : new() { var ret = new T[size]; for (int i = 0; i < size; i++)ret[i] = new T(); return ret; }\n #endregion\n}", "lang_cluster": "C#", "tags": ["math", "number theory"], "code_uid": "8098a370082992e7bf3c7d6fd057b075", "src_uid": "b08ee0cd6f5cb574086fa02f07d457a4", "difficulty": 2500.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace _5Dproblem\n{\n class vector\n {\n private int[] points= new int[5];\n private double length ;\n\n public vector(Point R,Point D)\n {\n for (int i = 0; i < 5; i++)\n {\n points[i] = R.coordinates[i]-D.coordinates[i];\n }\n length = Math.Sqrt(vector.CrossProduct(this, this));\n }\n\n public double GetLength()\n {\n return length;\n }\n static public double CrossProduct(vector A,vector B)\n {\n double product = 0;\n product = A.points[0] * B.points[0]\n + A.points[1] * B.points[1]\n + A.points[2] * B.points[2]\n + A.points[3] * B.points[3]\n + A.points[4] * B.points[4];\n return product;\n }\n public static double GetAngle(vector A,vector B)\n {\n double angle = vector.CrossProduct(A, B) / (A.length * B.length);\n return Math.Acos(angle)*180/Math.PI;\n }\n }\n class Point\n {\n public int[] coordinates = new int[5];\n List V = new List();//vectors from this point\n List angles = new List();\n public Point (int[] p)\n {\n for (int i = 0; i < 5; i++)\n {\n coordinates[i] = p[i];\n }\n }\n private vector GetVector(Point p)\n {\n {\n vector v = new vector(this,p);\n return v;\n }\n }\n public void set_vectList(List Point)\n {\n for (int i = 0; i < Point.Count; i++)\n {\n if (this != Point[i])\n V.Add(GetVector(Point[i]));\n }\n }\n public void set_angleList()\n {\n for (int i = 0; i < V.Count; i++)\n {\n for (int j = i+1; j < V.Count; j++)\n {\n angles.Add(vector.GetAngle(V[i], V[j]));\n }\n }\n }\n public bool Isgood()\n {\n foreach (var a in angles)\n {\n if (a < 90)\n return false;\n }\n return true;\n }\n }\n class Program\n {\n static void Main(string[] args)\n {\n int n = int.Parse(Console.ReadLine());\n if (n > 11)\n {\n for (int i = 0; i < n; i++)\n {\n Console.ReadLine();\n }\n\n Console.WriteLine(0);\n }\n else\n {\n List lp = new List();\n int[] count = new int[n];\n int c = 0;\n for (int i = 0; i < n; i++)\n {\n Point p = new Point(Array.ConvertAll(Console.ReadLine().Split(), int.Parse));\n lp.Add(p);\n }\n\n foreach (var point in lp)\n {\n point.set_vectList(lp);\n point.set_angleList();\n if (point.Isgood())\n count[c]++;\n c++;\n }\n Console.WriteLine(count.Sum());\n for (int i = 0; i < count.Length; i++)\n {\n if (count[i] != 0)\n Console.WriteLine(i + 1);\n }\n }\n \n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "math", "geometry"], "code_uid": "6d538b3ff849eb5436e91699389f1d86", "src_uid": "c1cfe1f67217afd4c3c30a6327e0add9", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Globalization;\nusing System.Linq;\nusing System.Text;\nusing System.Text.RegularExpressions;\nusing System.Threading;\n\nnamespace Codeforces\n{\n class D\n {\n private static ThreadStart s_threadStart = new D().Go;\n private static bool s_time = false;\n\n private void Go()\n {\n string a = GetString();\n int n = a.Length;\n string b = GetString();\n long k = GetInt();\n\n long mod = 1000000007;\n long[,] dp = new long[2, 100001];\n dp[0, 0] = 1;\n dp[1, 0] = 0;\n dp[0, 1] = 0;\n dp[1, 1] = 1;\n for (int i = 2; i <= k; i++)\n {\n dp[0, i] = ((n - 1) * dp[1, i - 1]) % mod;\n dp[1, i] = ((n - 2) * dp[1, i - 1] + dp[0, i - 1]) % mod;\n }\n\n long ret = 0;\n if (a == b) ret += dp[0, k];\n for (int i = 0; i < n-1; i++)\n {\n a = a[n - 1] + a.Substring(0, n - 1);\n if (a == b) ret = (ret + dp[1, k]) % mod;\n }\n\n Wl(ret);\n }\n\n #region Template\n\n public static void Main(string[] args)\n {\n System.Diagnostics.Stopwatch timer = new System.Diagnostics.Stopwatch();\n Thread main = new Thread(new ThreadStart(s_threadStart), 512 * 1024 * 1024);\n timer.Start();\n main.Start();\n main.Join();\n timer.Stop();\n if (s_time)\n Wl(timer.ElapsedMilliseconds);\n }\n\n private static IEnumerator ioEnum;\n private static string GetString()\n {\n while (ioEnum == null || !ioEnum.MoveNext())\n {\n ioEnum = Console.ReadLine().Split().AsEnumerable().GetEnumerator();\n }\n\n return ioEnum.Current;\n }\n\n private static int GetInt()\n {\n return int.Parse(GetString());\n }\n\n private static long GetLong()\n {\n return long.Parse(GetString());\n }\n\n private static double GetDouble()\n {\n return double.Parse(GetString());\n }\n\n private static List GetIntArr(int n)\n {\n List ret = new List(n);\n for (int i = 0; i < n; i++)\n {\n ret.Add(GetInt());\n }\n return ret;\n }\n\n private static void Wl(T o)\n {\n if (o is double)\n {\n Wld((o as double?).Value, \"\");\n }\n else if (o is float)\n {\n Wld((o as float?).Value, \"\");\n }\n else\n Console.WriteLine(o.ToString());\n }\n\n private static void Wl(IEnumerable enumerable)\n {\n Wl(string.Join(\" \", enumerable.Select(e => e.ToString()).ToArray()));\n }\n\n private static void Wld(double d, string format)\n {\n Wl(d.ToString(format, CultureInfo.InvariantCulture));\n }\n\n public struct Tuple : IComparable>\n where T : IComparable\n where K : IComparable\n {\n public T Item1;\n public K Item2;\n\n public Tuple(T t, K k)\n {\n Item1 = t;\n Item2 = k;\n }\n\n public override bool Equals(object obj)\n {\n var o = (Tuple)obj;\n return o.Item1.Equals(Item1) && o.Item2.Equals(Item2);\n }\n\n public override int GetHashCode()\n {\n return Item1.GetHashCode() ^ Item2.GetHashCode();\n }\n\n public override string ToString()\n {\n return \"(\" + Item1 + \" \" + Item2 + \")\";\n }\n\n #region IComparable> Members\n\n public int CompareTo(Tuple other)\n {\n int ret = Item1.CompareTo(other.Item1);\n if (ret != 0) return ret;\n return Item2.CompareTo(other.Item2);\n }\n\n #endregion\n }\n\n #endregion\n }\n}", "lang_cluster": "C#", "tags": ["dp"], "code_uid": "00121970b6eada568953c80fdccf3d75", "src_uid": "414000abf4345f08ede20798de29b9d4", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.IO;\nusing System.Collections;\nusing System.Diagnostics;\nusing System.Globalization;\n\nnamespace CodeForces {\n struct Node {\n public int X, Y, D; \n public Node(int x,int y, int d) {\n X = x;\n Y = y;\n D = d;\n } \n }\n \n class Cf { \n static TextReader input;\n static void Main(string[] args) { \n#if TESTS \n Stopwatch sw = new Stopwatch();\n input = new StreamReader(\"input.txt\"); \n#else\n input = Console.In;\n#endif\n Solve(); \n#if TESTS\n Console.WriteLine();\n Console.WriteLine(\"Milliseconds: {0}\", sw.ElapsedMilliseconds);\n Console.ReadLine();\n#endif\n } \n const int MOD = 1000000007;\n static int n, m, k;\n static void Solve() {\n string s = ReadLine();\n string t = ReadLine();\n k = ReadInt();\n n = s.Length;\n ulong a = 0;\n for (int i = 0; i < n; i++) {\n string s1 = s.Substring(0, i);\n string s2 = s.Substring(i);\n if (s2 + s1 == t)\n ++a;\n }\n ulong b = (ulong)n - a;\n ulong[] da = new ulong[k+1];\n ulong[] db = new ulong[k+1];\n if (s == t)\n da[0] = 1;\n else\n db[0] = 1;\n for (int i = 1; i <= k; i++) {\n da[i] = (da[i - 1] * (a - 1) + db[i - 1] * a) % MOD;\n db[i] = (da[i - 1] * b + db[i - 1] * (b - 1)) % MOD;\n }\n Console.WriteLine(da[k]);\n }\n \n static int[] Z_function(string s) {\n int n = s.Length;\n int[] z = new int[n]; \n for (int i = 1, l = 0, r = 0; i < n; ++i) {\n if (i <= r)\n z[i] = Math.Min(r - i + 1, z[i - l]);\n while (i + z[i] < n && s[z[i]] == s[i + z[i]])\n ++z[i];\n if (i + z[i] - 1 > r) {\n l = i; r = i + z[i] - 1;\n }\n }\n return z;\n }\n \n static int SquaredDistanceBetweenSegments(int x1, int y1, int x2, int y2, int xx1, int yy1, int xx2, int yy2) {\n return Math.Min(Math.Min(SquaredDistanceToSegment(x1, y1, xx1, yy1, xx2, yy2), SquaredDistanceToSegment(x2, y2, xx1, yy1, xx2, yy2)),\n Math.Min(SquaredDistanceToSegment(xx1, yy1, x1, y1, x2, y2), SquaredDistanceToSegment(xx2, yy2, x1, y1, x2, y2)));\n }\n\n static int SquaredDistanceToSegment(int x, int y, int x1, int y1, int x2, int y2) {\n int result = Math.Min(SquaredDistance(x, y, x1, y1), SquaredDistance(x, y, x2, y2));\n if (x1 == x2 && y1 <= y && y <= y2)\n result = (x - x1) * (x - x1);\n else if (y1 == y2 && x1 <= x && x <= x2)\n result = (y - y1) * (y - y1);\n return result;\n }\n\n static int SquaredDistance(int ax, int ay, int bx, int by) {\n return (ax - bx) * (ax - bx) + (ay - by) * (ay - by);\n }\n\n #region read helpers\n public static List ReadIntList() {\n return input.ReadLine().Split(' ').Select(x => int.Parse(x)).ToList();\n }\n\n public static int[] ReadIntArray() {\n return input.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();\n } \n\n public static string ReadLine() {\n return input.ReadLine();\n }\n\n public static int ReadInt() {\n return int.Parse(input.ReadLine());\n }\n#endregion\n }\n \n public class SegmentTree {\n private int[] a, t;\n private int n;\n public SegmentTree(int[] a) {\n n = a.Length;\n this.a = a; \n t = new int[n << 2];\n buildSegmentTree(0, n - 1, 1);\n }\n\n private void buildSegmentTree(int l, int r, int v) {\n if (l == r)\n t[v] = a[l];\n else {\n int m = (l + r) >> 1;\n int vl = v << 1;\n int vr = (v << 1) | 1;\n buildSegmentTree(l, m, vl);\n buildSegmentTree(m + 1, r, vr);\n t[v] = t[vl] + t[vr];\n }\n }\n\n public int QuerySegmentTree(int l, int r) {\n return querySegmentTree(1, l, r, 0, n - 1);\n }\n\n public void Update(int v, int tl, int tr, int pos, int new_val) {\n if (tl == tr)\n t[v] = new_val;\n else {\n int tm = (tl + tr) / 2;\n if (pos <= tm)\n Update(v << 1, tl, tm, pos, new_val);\n else\n Update(v << 1 + 1, tm + 1, tr, pos, new_val);\n t[v] = t[v << 1] + t[v << 1 + 1];\n }\n }\n\n private int querySegmentTree(int v, int l, int r, int tl, int tr) {\n if (l > r)\n return 0;\n if (l == tl && r == tr)\n return t[v];\n int m = (tl + tr) >> 1; \n return querySegmentTree(v << 1, l, Math.Min(r, m), tl, m) + querySegmentTree((v << 1) | 1, Math.Max(l, m + 1), r, m + 1, tr);\n }\n }\n class Graph : List> {\n public Graph(int num): base(num) {\n for (int i = 0; i < num; i++) {\n this.Add(new List());\n }\n }\n }\n class Heap : IEnumerable where T : IComparable {\n private List heap = new List();\n private int heapSize;\n private int Parent(int index) {\n return (index - 1) >> 1;\n }\n public int Count {\n get { return heap.Count; }\n }\n private int Left(int index) {\n return (index << 1) | 1;\n }\n private int Right(int index) {\n return (index << 1) + 2;\n }\n private void Max_Heapify(int i) {\n int l = Left(i);\n int r = Right(i);\n int largest = i;\n if (l < heapSize && heap[l].CompareTo(heap[i]) > 0)\n largest = l;\n if (r < heapSize && heap[r].CompareTo(heap[largest]) > 0)\n largest = r;\n if (largest != i) {\n T temp = heap[largest];\n heap[largest] = heap[i];\n heap[i] = temp;\n Max_Heapify(largest);\n }\n }\n private void BuildMaxHeap() {\n for (int i = heap.Count >> 1; i >= 0; --i)\n Max_Heapify(i);\n }\n\n public IEnumerator GetEnumerator() {\n return heap.GetEnumerator();\n }\n\n public void Sort() {\n for (int i = heap.Count - 1; i > 0; --i) {\n T temp = heap[i];\n heap[i] = heap[0];\n heap[0] = temp;\n --heapSize;\n Max_Heapify(0);\n }\n }\n\n public T Heap_Extract_Max() {\n T max = heap[0];\n heap[0] = heap[--heapSize];\n Max_Heapify(0);\n return max;\n }\n\n public void Clear() {\n heap.Clear();\n heapSize = 0;\n }\n\n public void Insert(T item) {\n if (heapSize < heap.Count)\n heap[heapSize] = item;\n else\n heap.Add(item);\n int i = heapSize;\n while (i > 0 && heap[Parent(i)].CompareTo(heap[i]) < 0) {\n T temp = heap[i];\n heap[i] = heap[Parent(i)];\n heap[Parent(i)] = temp;\n i = Parent(i);\n }\n ++heapSize;\n }\n\n IEnumerator IEnumerable.GetEnumerator() {\n return ((IEnumerable)heap).GetEnumerator();\n }\n } \n public class Treap {\n private static Random rand = new Random();\n public static Treap Merge(Treap l, Treap r) {\n if (l == null) return r;\n if (r == null) return l;\n Treap res;\n if (l.y > r.y) {\n Treap newR = Merge(l.right, r);\n res = new Treap(l.x, l.y, l.left, newR);\n }\n else {\n Treap newL = Merge(l, r.left);\n res = new Treap(r.x, r.y, newL, r.right);\n } \n return res;\n }\n\n public void Split(int x, out Treap l, out Treap r) {\n Treap newTree = null;\n if (this.x <= x) {\n if (right == null)\n r = null;\n else\n right.Split(x, out newTree, out r);\n l = new Treap(this.x, y, left, newTree); \n }\n else {\n if (left == null)\n l = null;\n else\n left.Split(x, out l, out newTree);\n r = new Treap(this.x, y, newTree, right); \n }\n }\n\n public Treap Add(int x) {\n Treap l, r;\n Split(x, out l, out r);\n Treap m = new Treap(x, rand.Next());\n return Merge(Merge(l, m), r);\n }\n\n public Treap Remove(int x) {\n Treap l, m, r;\n Split(x - 1, out l, out r);\n r.Split(x, out m, out r);\n return Merge(l, r);\n }\n\n private int x, y, cost, maxTreeCost;\n private Treap left, right;\n public Treap(int x, int y, Treap l, Treap r) {\n this.x = x;\n this.y = y;\n left = l;\n right = r;\n }\n public Treap(int x, int y) : this(x, y, null, null) { }\n public void InOrder() {\n inOrder(this);\n }\n private void inOrder(Treap t) {\n if (t == null) return;\n inOrder(t.left);\n Console.WriteLine(t.x);\n inOrder(t.right);\n }\n }\n public static class Extensions {\n public static void Fill(this int[] array, int val) {\n for (int i = 0; i < array.Length; i++) {\n array[i] = val;\n }\n }\n\n public static void Fill(this double[] array, double val) {\n for (int i = 0; i < array.Length; i++) {\n array[i] = val;\n }\n }\n\n public static int ToInt(this string s) {\n return int.Parse(s);\n }\n\n public static string Fill(this char c, int count) {\n char[] r = new char[count];\n for (int i = 0; i < count; ++i)\n r[i] = c;\n return new string(r);\n }\n \n public static void Print(this IEnumerable arr) {\n foreach (T t in arr)\n Console.Write(\"{0} \", t);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["dp"], "code_uid": "8d49940727237436ee0d0ff40c5ecfb9", "src_uid": "414000abf4345f08ede20798de29b9d4", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Diagnostics;\nusing System.Globalization;\nusing System.IO;\nusing System.Linq;\nusing System.Text;\n\nnamespace Temp\n{\n internal class PointInt\n {\n public long X;\n\n public long Y;\n\n public PointInt(long x, long y)\n {\n this.X = x;\n this.Y = y;\n }\n\n public PointInt(PointInt head)\n : this(head.X, head.Y)\n {\n }\n\n public static PointInt operator +(PointInt a, PointInt b)\n {\n return new PointInt(a.X + b.X, a.Y + b.Y);\n }\n\n public static PointInt operator -(PointInt a, PointInt b)\n {\n return new PointInt(a.X - b.X, a.Y - b.Y);\n }\n\n public static PointInt operator *(PointInt a, long k)\n {\n return new PointInt(k * a.X, k * a.Y);\n }\n\n public static PointInt operator *(long k, PointInt a)\n {\n return new PointInt(k * a.X, k * a.Y);\n }\n\n public bool IsInsideRectangle(long l, long b, long r, long t)\n {\n return (l <= X) && (X <= r) && (b <= Y) && (Y <= t);\n }\n\n public bool Equals(PointInt other)\n {\n if (ReferenceEquals(null, other))\n {\n return false;\n }\n if (ReferenceEquals(this, other))\n {\n return true;\n }\n return other.X == this.X && other.Y == this.Y;\n }\n\n public override bool Equals(object obj)\n {\n if (ReferenceEquals(null, obj))\n {\n return false;\n }\n if (ReferenceEquals(this, obj))\n {\n return true;\n }\n if (obj.GetType() != typeof(PointInt))\n {\n return false;\n }\n return Equals((PointInt)obj);\n }\n\n public override int GetHashCode()\n {\n unchecked\n {\n return (this.X.GetHashCode() * 397) ^ this.Y.GetHashCode();\n }\n }\n }\n\n internal class LineInt\n {\n public LineInt(PointInt a, PointInt b)\n {\n A = a.Y - b.Y;\n B = b.X - a.X;\n C = a.X * b.Y - a.Y * b.X;\n }\n\n public long A, B, C;\n\n public bool ContainsPoint(PointInt p)\n {\n return A * p.X + B * p.Y + C == 0;\n }\n\n public int Sign(PointInt p)\n {\n return Math.Sign(A * p.X + B * p.Y + C);\n }\n }\n\n internal static class Geometry\n {\n public static long VectInt(PointInt a, PointInt b)\n {\n return a.X * b.Y - a.Y * b.X;\n }\n\n public static long VectInt(PointInt a, PointInt b, PointInt c)\n {\n return (b.X - a.X) * (c.Y - a.Y) - (b.Y - a.Y) * (c.X - a.X);\n }\n }\n\n internal class MatrixInt\n {\n private readonly long[,] m_Matrix;\n\n public int Size\n {\n get\n {\n return m_Matrix.GetLength(0);\n }\n }\n\n public long Mod { get; private set; }\n\n public MatrixInt(int size, long mod = 0)\n {\n m_Matrix = new long[size,size];\n Mod = mod;\n }\n\n public MatrixInt(long[,] matrix, long mod = 0)\n {\n this.m_Matrix = matrix;\n Mod = mod;\n\n for (int i = 0; i < Size; i++)\n {\n for (int j = 0; j < Size; j++)\n {\n m_Matrix[i, j] %= mod;\n }\n }\n }\n\n public static MatrixInt GetIdentityMatrix(int size, long mod = 0)\n {\n long[,] matrix = new long[size,size];\n\n for (int i = 0; i < size; i++)\n {\n matrix[i, i] = 1;\n }\n\n return new MatrixInt(matrix, mod);\n }\n\n public long this[int i, int j]\n {\n get\n {\n return m_Matrix[i, j];\n }\n\n set\n {\n m_Matrix[i, j] = value;\n }\n }\n\n public static MatrixInt operator +(MatrixInt a, MatrixInt b)\n {\n int n = a.Size;\n long mod = Math.Max(a.Mod, b.Mod);\n long[,] c = new long[n,n];\n for (int i = 0; i < n; i++)\n {\n for (int j = 0; j < n; j++)\n {\n c[i, j] = a[i, j] + b[i, j];\n }\n }\n\n if (mod > 0)\n {\n for (int i = 0; i < n; i++)\n {\n for (int j = 0; j < n; j++)\n {\n c[i, j] %= mod;\n }\n }\n }\n\n return new MatrixInt(c, mod);\n }\n\n public static MatrixInt operator *(MatrixInt a, MatrixInt b)\n {\n int n = a.Size;\n long mod = Math.Max(a.Mod, b.Mod);\n\n long[,] c = new long[n,n];\n\n for (int i = 0; i < n; i++)\n {\n for (int j = 0; j < n; j++)\n {\n for (int k = 0; k < n; k++)\n {\n c[i, j] += a[i, k] * b[k, j];\n if (mod > 0)\n {\n c[i, j] %= mod;\n }\n }\n }\n }\n\n return new MatrixInt(c, mod);\n }\n }\n\n public static class Permutations\n {\n public static int[] GetRandomPermutation(int n)\n {\n int[] p = new int[n];\n for (int i = 0; i < n; i++)\n {\n p[i] = i;\n }\n\n Random random = new Random();\n for (int i = n - 1; i > 0; i--)\n {\n int j = random.Next(i + 1);\n int tmp = p[i];\n p[i] = p[j];\n p[j] = tmp;\n }\n\n return p;\n }\n\n public static T[] Shuffle(this T[] array)\n {\n int length = array.Length;\n int[] p = GetRandomPermutation(length);\n T[] result = new T[length];\n for (int i = 0; i < length; i++)\n {\n result[i] = array[p[i]];\n }\n\n return result;\n }\n\n public static T[] ShuffleSort(this T[] array)\n {\n var result = array.Shuffle();\n Array.Sort(result);\n return result;\n }\n }\n\n internal static class Algebra\n {\n public static long Phi(long n)\n {\n long result = n;\n for (long i = 2; i * i <= n; i++)\n {\n if (n % i == 0)\n {\n while (n % i == 0)\n {\n n /= i;\n }\n\n result -= result / i;\n }\n }\n\n if (n > 1)\n {\n result -= result / n;\n }\n\n return result;\n }\n\n public static long BinPower(long a, long n, long mod)\n {\n long result = 1;\n\n while (n > 0)\n {\n if ((n & 1) != 0)\n {\n result = (result * a) % mod;\n }\n\n a = (a * a) % mod;\n n >>= 1;\n }\n\n return result;\n }\n\n public static MatrixInt MatrixBinPower(MatrixInt a, long n)\n {\n MatrixInt result = MatrixInt.GetIdentityMatrix(a.Size, a.Mod);\n\n while (n > 0)\n {\n if ((n & 1) != 0)\n {\n result *= a;\n }\n\n a *= a;\n n >>= 1;\n }\n\n return result;\n }\n\n public static long Gcd(long a, long b)\n {\n return b == 0 ? a : Gcd(b, a % b);\n }\n\n public static long ExtendedGcd(long a, long b, out long x, out long y)\n {\n if (b == 0)\n {\n x = 1;\n y = 0;\n return a;\n }\n\n long x1;\n long y1;\n long d = ExtendedGcd(b, a % b, out x1, out y1);\n x = y1;\n y = x1 - (a / b) * y1;\n return d;\n }\n\n public static long Lcm(long a, long b)\n {\n return (a / Gcd(a, b)) * b;\n }\n\n public static bool[] GetPrimes(int n)\n {\n n = Math.Max(n, 2);\n bool[] prime = new bool[n + 1];\n for (int i = 2; i <= n; i++)\n {\n prime[i] = true;\n }\n\n for (int i = 2; i * i <= n; i++)\n {\n if (prime[i])\n {\n if ((long)i * i <= n)\n {\n for (int j = i * i; j <= n; j += i)\n {\n prime[j] = false;\n }\n }\n }\n }\n\n return prime;\n }\n\n public static long GetFibonacciNumber(long n, long mod = 0)\n {\n long[,] matrix = new long[,] { { 0, 1 }, { 1, 1 } };\n\n MatrixInt result = MatrixBinPower(new MatrixInt(matrix, mod), n);\n\n return result[1, 1];\n }\n\n public static long[] GetFibonacciSequence(int n)\n {\n long[] result = new long[n];\n result[0] = result[1] = 1;\n\n for (int i = 2; i < n; i++)\n {\n result[i] = result[i - 1] + result[i - 2];\n }\n\n return result;\n }\n\n public static long GetInverseElement(long a, long mod)\n {\n long x, y;\n long g = ExtendedGcd(a, mod, out x, out y);\n\n if (g != 1)\n {\n return -1;\n }\n\n return ((x % mod) + mod) % mod;\n }\n\n public static long[] GetAllInverseElements(long mod)\n {\n long[] result = new long[mod];\n result[1] = 1;\n for (int i = 2; i < mod; i++)\n {\n result[i] = (mod - (((mod / i) * result[mod % i]) % mod)) % mod;\n }\n\n return result;\n }\n\n public static int GetMinimalPrimeDivisor(int n)\n {\n for (int i = 2; i * i <= n; i++)\n {\n if (n % i == 0)\n {\n return i;\n }\n }\n\n return n;\n }\n\n public static long Sqr(long x)\n {\n return x * x;\n }\n\n public static int SumOfDigits(long x, long baseMod = 10)\n {\n int res = 0;\n while (x > 0)\n {\n res += (int)(x % baseMod);\n x = x / baseMod;\n }\n return res;\n }\n }\n\n internal static class Reader\n {\n public static void ReadInt(out int a)\n {\n int[] number = new int[1];\n ReadInt(number);\n a = number[0];\n }\n\n public static void ReadInt(out int a, out int b)\n {\n int[] numbers = new int[2];\n ReadInt(numbers);\n a = numbers[0];\n b = numbers[1];\n }\n\n public static void ReadInt(out int int1, out int int2, out int int3)\n {\n int[] numbers = new int[3];\n ReadInt(numbers);\n int1 = numbers[0];\n int2 = numbers[1];\n int3 = numbers[2];\n }\n\n public static void ReadInt(out int int1, out int int2, out int int3, out int int4)\n {\n int[] numbers = new int[4];\n ReadInt(numbers);\n int1 = numbers[0];\n int2 = numbers[1];\n int3 = numbers[2];\n int4 = numbers[3];\n }\n\n public static void ReadLong(out long a)\n {\n long[] number = new long[1];\n ReadLong(number);\n a = number[0];\n }\n\n public static void ReadLong(out long a, out long b)\n {\n long[] numbers = new long[2];\n ReadLong(numbers);\n a = numbers[0];\n b = numbers[1];\n }\n\n public static void ReadLong(out long int1, out long int2, out long int3)\n {\n long[] numbers = new long[3];\n ReadLong(numbers);\n int1 = numbers[0];\n int2 = numbers[1];\n int3 = numbers[2];\n }\n\n public static void ReadLong(out long int1, out long int2, out long int3, out long int4)\n {\n long[] numbers = new long[4];\n ReadLong(numbers);\n int1 = numbers[0];\n int2 = numbers[1];\n int3 = numbers[2];\n int4 = numbers[3];\n }\n\n public static void ReadInt(int[] numbers)\n {\n // ReSharper disable PossibleNullReferenceException\n var list = Console.ReadLine().Split();\n // ReSharper restore PossibleNullReferenceException\n\n int count = Math.Min(numbers.Length, list.Length);\n\n for (int i = 0; i < count; i++)\n {\n numbers[i] = int.Parse(list[i]);\n }\n }\n\n public static int[] ReadDigits()\n {\n // ReSharper disable AssignNullToNotNullAttribute\n return Console.ReadLine().Select(x => int.Parse(x.ToString())).ToArray();\n // ReSharper restore AssignNullToNotNullAttribute\n }\n\n public static void ReadLong(long[] numbers)\n {\n // ReSharper disable PossibleNullReferenceException\n var list = Console.ReadLine().Split();\n // ReSharper restore PossibleNullReferenceException\n\n int count = Math.Min(numbers.Length, list.Length);\n\n for (int i = 0; i < count; i++)\n {\n numbers[i] = long.Parse(list[i]);\n }\n }\n\n public static void ReadDouble(double[] numbers)\n {\n // ReSharper disable PossibleNullReferenceException\n var list = Console.ReadLine().Split();\n // ReSharper restore PossibleNullReferenceException\n\n int count = Math.Min(numbers.Length, list.Length);\n\n for (int i = 0; i < count; i++)\n {\n numbers[i] = double.Parse(list[i]);\n }\n }\n\n public static void ReadDouble(out double a, out double b)\n {\n double[] numbers = new double[2];\n ReadDouble(numbers);\n a = numbers[0];\n b = numbers[1];\n }\n\n public static void ReadDouble(out double int1, out double int2, out double int3)\n {\n double[] numbers = new double[3];\n ReadDouble(numbers);\n int1 = numbers[0];\n int2 = numbers[1];\n int3 = numbers[2];\n }\n\n public static string ReadLine()\n {\n return Console.ReadLine();\n }\n }\n\n public interface IGraph\n {\n int Vertices { get; set; }\n\n IList this[int i] { get; }\n\n void AddEdge(int u, int v);\n\n void AddOrientedEdge(int u, int v);\n }\n\n public class Graph : IGraph\n {\n private readonly List[] m_Edges;\n\n public int Vertices { get; set; }\n\n public IList this[int i]\n {\n get\n {\n return this.m_Edges[i];\n }\n }\n\n public Graph(int vertices)\n {\n this.Vertices = vertices;\n\n this.m_Edges = new List[vertices];\n\n for (int i = 0; i < vertices; i++)\n {\n this.m_Edges[i] = new List();\n }\n }\n\n public void AddEdge(int u, int v)\n {\n this.AddOrientedEdge(u, v);\n this.AddOrientedEdge(v, u);\n }\n\n public void AddOrientedEdge(int first, int second)\n {\n this.m_Edges[first].Add(second);\n }\n\n public int[] Bfs(int start)\n {\n int[] d = new int[Vertices];\n for (int i = 0; i < Vertices; i++)\n {\n d[i] = -1;\n }\n\n Queue queue = new Queue();\n queue.Enqueue(start);\n d[start] = 0;\n\n while (queue.Count > 0)\n {\n int v = queue.Dequeue();\n foreach (int t in this.m_Edges[v].Where(t => d[t] == -1))\n {\n queue.Enqueue(t);\n d[t] = d[v] + 1;\n }\n }\n\n return d;\n }\n }\n\n internal class SimpleSumTable\n {\n private readonly int[,] m_Sum;\n\n public SimpleSumTable(int n, int m, int[,] table)\n {\n m_Sum = new int[n + 1,m + 1];\n\n for (int i = 1; i < n + 1; i++)\n {\n for (int j = 1; j < m + 1; j++)\n {\n m_Sum[i, j] = m_Sum[i, j - 1] + m_Sum[i - 1, j] - m_Sum[i - 1, j - 1] + table[i - 1, j - 1];\n }\n }\n }\n\n public int GetSum(int l, int b, int r, int t)\n {\n return m_Sum[r + 1, t + 1] - m_Sum[r + 1, b] - m_Sum[l, t + 1] + m_Sum[l, b];\n }\n }\n\n internal class SegmentTreeSimpleInt\n {\n public int Size { get; private set; }\n\n private readonly T[] m_Tree;\n\n private readonly Func m_Operation;\n\n private readonly T m_Null;\n\n public SegmentTreeSimpleInt(int size, Func operation, T nullElement, IList array = null)\n {\n this.Size = size;\n this.m_Operation = operation;\n this.m_Null = nullElement;\n\n m_Tree = new T[4 * size];\n if (array != null)\n {\n this.Build(array, 1, 0, size - 1);\n }\n }\n\n private void Build(IList array, int v, int tl, int tr)\n {\n if (tl == tr)\n {\n m_Tree[v] = array[tl];\n }\n else\n {\n int tm = (tl + tr) / 2;\n this.Build(array, 2 * v, tl, tm);\n this.Build(array, 2 * v + 1, tm + 1, tr);\n this.CalculateNode(v);\n }\n }\n\n public T GetSum(int l, int r)\n {\n return GetSum(1, 0, Size - 1, l, r);\n }\n\n private T GetSum(int v, int tl, int tr, int l, int r)\n {\n if (l > r)\n {\n return m_Null;\n }\n\n if (l == tl && r == tr)\n {\n return m_Tree[v];\n }\n\n int tm = (tl + tr) / 2;\n\n return this.m_Operation(\n GetSum(2 * v, tl, tm, l, Math.Min(r, tm)), GetSum(2 * v + 1, tm + 1, tr, Math.Max(l, tm + 1), r));\n }\n\n public void Update(int pos, T newValue)\n {\n Update(1, 0, Size - 1, pos, newValue);\n }\n\n private void Update(int v, int tl, int tr, int pos, T newValue)\n {\n if (tl == tr)\n {\n m_Tree[v] = newValue;\n }\n else\n {\n int tm = (tl + tr) / 2;\n if (pos <= tm)\n {\n Update(2 * v, tl, tm, pos, newValue);\n }\n else\n {\n Update(2 * v + 1, tm + 1, tr, pos, newValue);\n }\n this.CalculateNode(v);\n }\n }\n\n private void CalculateNode(int v)\n {\n m_Tree[v] = this.m_Operation(m_Tree[2 * v], m_Tree[2 * v + 1]);\n }\n }\n\n internal struct Pair\n {\n public Pair(TFirst first, TSecond second)\n : this()\n {\n this.First = first;\n this.Second = second;\n }\n\n public TFirst First { set; get; }\n\n public TSecond Second { set; get; }\n }\n\n internal class FenwickTreeInt64\n {\n public FenwickTreeInt64(int size)\n {\n this.m_Size = size;\n m_Tree = new long[size];\n }\n\n public FenwickTreeInt64(int size, IList tree)\n : this(size)\n {\n for (int i = 0; i < size; i++)\n {\n Inc(i, tree[i]);\n }\n }\n\n public long Sum(int r)\n {\n long res = 0;\n for (; r >= 0; r = (r & (r + 1)) - 1)\n {\n res += m_Tree[r];\n }\n return res;\n }\n\n public long Sum(int l, int r)\n {\n return Sum(r) - Sum(l - 1);\n }\n\n public void Inc(int i, long x)\n {\n for (; i < m_Size; i = i | (i + 1))\n {\n m_Tree[i] += x;\n }\n }\n\n public void Set(int i, long x)\n {\n Inc(i, x - Sum(i, i));\n }\n\n private readonly int m_Size;\n\n private readonly long[] m_Tree;\n }\n\n internal class AccumulativeDictionary : Dictionary\n {\n public new void Add(TKey key, int value = 1)\n {\n if (this.ContainsKey(key))\n {\n base[key] += value;\n }\n else\n {\n base.Add(key, value);\n }\n }\n\n public new int this[TKey key]\n {\n get\n {\n return this.ContainsKey(key) ? base[key] : 0;\n }\n set\n {\n this.Add(key, value);\n }\n }\n }\n\n internal class PriorityQueue\n {\n public PriorityQueue(Comparison comparison = null)\n {\n if (comparison == null)\n {\n if (typeof(T).GetInterfaces().Any(i => i == typeof(IComparable)))\n {\n m_Comparison = (a, b) => ((IComparable)a).CompareTo(b);\n }\n else\n {\n throw new ApplicationException(\"Add comparer\");\n }\n }\n else\n {\n m_Comparison = comparison;\n }\n }\n\n public int Count { get; private set; }\n\n public void Enqueue(T item)\n {\n m_List.Add(item);\n m_Indexes.Add(item, this.Count);\n this.Count++;\n Up(this.Count);\n }\n\n public T Peek()\n {\n return m_List[0];\n }\n\n public T Dequeue()\n {\n if (this.Count > 0)\n {\n var result = m_List[0];\n\n Swap(0, this.Count - 1);\n m_Indexes.Remove(m_List[this.Count - 1]);\n m_List.RemoveAt(this.Count - 1);\n this.Count--;\n this.Down(1);\n\n return result;\n }\n throw new ApplicationException(\"Couldn't get element from empty queue\");\n }\n\n public void Update(T item)\n {\n int index = m_Indexes[item];\n this.Up(index + 1);\n }\n\n private readonly List m_List = new List();\n\n private readonly Dictionary m_Indexes = new Dictionary();\n\n private readonly Comparison m_Comparison;\n\n private void Up(int index)\n {\n while (index > 1 && m_Comparison.Invoke(m_List[index - 1], m_List[index / 2 - 1]) > 0)\n {\n this.Swap(index - 1, index / 2 - 1);\n\n index = index / 2;\n }\n }\n\n private void Down(int index)\n {\n while (2 * index <= this.Count && m_Comparison.Invoke(m_List[index - 1], m_List[2 * index - 1]) < 0\n || 2 * index + 1 <= this.Count && m_Comparison.Invoke(m_List[index - 1], m_List[2 * index]) < 0)\n {\n if (2 * index + 1 > this.Count || m_Comparison.Invoke(m_List[2 * index - 1], m_List[2 * index]) > 0)\n {\n this.Swap(index - 1, 2 * index - 1);\n index = 2 * index;\n }\n else\n {\n this.Swap(index - 1, 2 * index);\n index = 2 * index + 1;\n }\n }\n }\n\n private void Swap(int i, int j)\n {\n var tmp = m_List[i];\n m_List[i] = m_List[j];\n m_List[j] = tmp;\n\n m_Indexes[m_List[i]] = i;\n m_Indexes[m_List[j]] = j;\n }\n }\n\n internal class HamiltonianPathFinder\n {\n public static void Run()\n {\n int n, m;\n Reader.ReadInt(out n, out m);\n List[] a = new List[n];\n for (int i = 0; i < n; i++)\n {\n a[i] = new List();\n }\n for (int i = 0; i < m; i++)\n {\n int x, y;\n Reader.ReadInt(out x, out y);\n a[x].Add(y);\n a[y].Add(x);\n }\n\n var rnd = new Random();\n\n bool[] v = new bool[n];\n int[] p = new int[n];\n for (int i = 0; i < n; i++)\n {\n p[i] = -1;\n }\n int first = rnd.Next(n);\n int cur = first;\n v[cur] = true;\n\n int count = 1;\n\n while (true)\n {\n var unb = a[cur].Where(u => !v[u]).ToList();\n int d = unb.Count;\n if (d > 0)\n {\n int next = unb[rnd.Next(d)];\n v[next] = true;\n p[cur] = next;\n cur = next;\n count++;\n }\n else\n {\n if (count == n && a[cur].Contains(first))\n {\n p[cur] = first;\n break;\n }\n\n d = a[cur].Count;\n int pivot;\n do\n {\n pivot = a[cur][rnd.Next(d)];\n }\n while (p[pivot] == cur);\n\n int next = p[pivot];\n\n int x = next;\n int y = -1;\n while (true)\n {\n int tmp = p[x];\n p[x] = y;\n y = x;\n x = tmp;\n if (y == cur)\n {\n break;\n }\n }\n p[pivot] = cur;\n cur = next;\n }\n }\n\n cur = first;\n do\n {\n Console.Write(\"{0} \", cur);\n cur = p[cur];\n }\n while (cur != first);\n }\n\n public static void WriteTest(int n)\n {\n Console.WriteLine(\"{0} {1}\", 2 * n, 2 * (n - 1) + n);\n for (int i = 0; i < n - 1; i++)\n {\n Console.WriteLine(\"{0} {1}\", 2 * i, 2 * i + 2);\n Console.WriteLine(\"{0} {1}\", 2 * i + 1, 2 * i + 3);\n //Console.WriteLine(\"{0} {1}\", 2 * i + 1, 2 * i + 2);\n //Console.WriteLine(\"{0} {1}\", 2 * i, 2 * i + 3);\n }\n for (int i = 0; i < n; i++)\n {\n Console.WriteLine(\"{0} {1}\", 2 * i, 2 * i + 1);\n }\n }\n }\n\n internal class Program\n {\n private static StreamReader m_InputStream;\n\n private static StreamWriter m_OutStream;\n\n private static void OpenFiles()\n {\n m_InputStream = new StreamReader(\"input.txt\"); //File.OpenText(\"input.txt\");\n Console.SetIn(m_InputStream);\n\n m_OutStream = new StreamWriter(\"output.txt\"); //File.CreateText(\"output.txt\");\n Console.SetOut(m_OutStream);\n }\n\n private static void CloseFiles()\n {\n m_OutStream.Flush();\n\n m_InputStream.Dispose();\n m_OutStream.Dispose();\n }\n\n private static void Main()\n {\n //OpenFiles();\n\n new Solution().Solve();\n\n // CloseFiles();\n }\n }\n\n internal class Solution\n {\n long[] a = new long[11];\n long[] p = new long[11];\n long[] r = new long[7];\n long[,] c = new long[11, 11];\n long mod = 1000000000 + 7;\n long[] p2 = new long[11];\n long[] p8 = new long[11];\n private int m;\n\n private long ans = 0;\n\n public void Solve()\n {\n for (int i = 0; i < 11; i++)\n {\n c[i, 0] = 1;\n }\n\n for (int i = 1; i < 11; i++)\n {\n for (int j = 1; j < 11; j++)\n {\n c[i, j] = c[i - 1, j - 1] + c[i - 1, j];\n }\n }\n\n p2[0] = 1;\n p8[0] = 1;\n for (int i = 1; i < 11; i++)\n {\n p2[i] = 2 * p2[i - 1];\n p8[i] = 8 * p8[i - 1];\n }\n\n Reader.ReadInt(out m);\n p[1] = 1;\n for (int i = 2; i <= 10; i++)\n {\n p[i] = 10 * p[i - 1];\n }\n Go(10, 0, 0);\n a[0]--;\n\n CalcAns(0, 1);\n\n Console.WriteLine(ans);\n }\n\n private void CalcAns(int t, long count)\n {\n if (t > 0 && (r.Sum() - r[0] >= r[0]))\n {\n return;\n }\n\n if (t == 7)\n {\n if (r.Sum() - r[0] < r[0])\n {\n ans = (ans + count)%mod;\n }\n return;\n }\n\n for (int i = 0; i < 10; i++)\n {\n if (a[i] > 0)\n {\n r[t] = i;\n long next = (count*a[i])%mod;\n a[i]--;\n CalcAns(t + 1, next);\n a[i]++;\n r[t] = 0;\n }\n }\n }\n\n private void Go(int t, int count, long current)\n {\n if (t == 0)\n {\n a[count]++;\n return;\n }\n\n for (int i = 0; i < 10; i++)\n {\n if (current + (i + 1) * p[t] <= m)\n {\n int d = (i == 4 || i == 7) ? 1 : 0;\n for (int j = 0; j < t; j++)\n {\n a[count + d + j] += c[t - 1, j]*p2[j]*p8[t - 1 - j];\n }\n }\n else\n {\n int d = (i == 4 || i == 7) ? 1 : 0;\n Go(t - 1, count + d, current + i * p[t]);\n break;\n }\n }\n }\n }\n}", "lang_cluster": "C#", "tags": ["brute force", "math", "dp", "combinatorics"], "code_uid": "e16e01d3871233efb89a63a470bdfe10", "src_uid": "656ed7b1b80de84d65a253e5d14d62a9", "difficulty": 1900.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Globalization;\nusing System.IO;\nusing System.Linq;\nusing System.Numerics;\nusing System.Text;\nusing System.Threading;\n\n// (\u3065\u00b0\u03c9\u00b0)\u3065\uff90e\u2605\u309c\u30fb\u3002\u3002\u30fb\u309c\u309c\u30fb\u3002\u3002\u30fb\u309c\u2606\u309c\u30fb\u3002\u3002\u30fb\u309c\u309c\u30fb\u3002\u3002\u30fb\u309c\npublic class Solver\n{\n double Fun(double x, double y, double z)\n {\n return z * Math.Log(y) + Math.Log(Math.Log(x));\n }\n\n double Fun2(double x, double y, double z)\n {\n return Math.Log(y) + Math.Log(z) + Math.Log(Math.Log(x));\n }\n\n double Fun3(double x, double y, double z)\n {\n return Math.Pow(x, Math.Pow(y, z));\n }\n\n double Fun4(double x, double y, double z)\n {\n return Math.Pow(Math.Pow(x, y), z);\n }\n\n public void Solve()\n {\n double x = ReadDouble();\n double y = ReadDouble();\n double z = ReadDouble();\n\n double max = double.MinValue;\n string ans = \"\";\n Action act = (v, s) =>\n {\n if (v > max + 1e-9)\n {\n max = v;\n ans = s;\n }\n };\n if (x <= 1 && y <= 1 && z <= 1)\n {\n act(Fun3(x, y, z), \"x^y^z\");\n act(Fun3(x, z, y), \"x^z^y\");\n act(Fun4(x, y, z), \"(x^y)^z\");\n act(Fun4(x, z, y), \"(x^z)^y\");\n act(Fun3(y, x, z), \"y^x^z\");\n act(Fun3(y, z, x), \"y^z^x\");\n act(Fun4(y, x, z), \"(y^x)^z\");\n act(Fun4(y, z, x), \"(y^z)^x\");\n act(Fun3(z, x, y), \"z^x^y\");\n act(Fun3(z, y, x), \"z^y^x\");\n act(Fun4(z, x, y), \"(z^x)^y\");\n act(Fun4(z, y, x), \"(z^y)^x\");\n Write(ans);\n return;\n }\n\n if (x > 1)\n {\n act(Fun(x, y, z), \"x^y^z\");\n act(Fun(x, z, y), \"x^z^y\");\n act(Fun2(x, y, z), \"(x^y)^z\");\n act(Fun2(x, z, y), \"(x^z)^y\");\n }\n if (y > 1)\n {\n act(Fun(y, x, z), \"y^x^z\");\n act(Fun(y, z, x), \"y^z^x\");\n act(Fun2(y, x, z), \"(y^x)^z\");\n act(Fun2(y, z, x), \"(y^z)^x\");\n }\n if (z > 1)\n {\n act(Fun(z, x, y), \"z^x^y\");\n act(Fun(z, y, x), \"z^y^x\");\n act(Fun2(z, x, y), \"(z^x)^y\");\n act(Fun2(z, y, x), \"(z^y)^x\");\n }\n\n Write(ans);\n }\n\n #region Main\n\n protected static TextReader reader;\n protected static TextWriter writer;\n static void Main()\n {\n#if DEBUG\n reader = new StreamReader(\"..\\\\..\\\\input.txt\");\n //reader = new StreamReader(Console.OpenStandardInput());\n writer = Console.Out;\n //writer = new StreamWriter(\"..\\\\..\\\\output.txt\");\n#else\n reader = new StreamReader(Console.OpenStandardInput());\n writer = new StreamWriter(Console.OpenStandardOutput());\n //reader = new StreamReader(\"input.txt\");\n //writer = new StreamWriter(\"output.txt\");\n#endif\n try\n {\n //var thread = new Thread(new Solver().Solve, 1024 * 1024 * 128);\n //thread.Start();\n //thread.Join();\n new Solver().Solve();\n }\n catch (Exception ex)\n {\n Console.WriteLine(ex);\n#if DEBUG\n#else\n throw;\n#endif\n }\n reader.Close();\n writer.Close();\n }\n\n #endregion\n\n #region Read / Write\n private static Queue currentLineTokens = new Queue();\n private static string[] ReadAndSplitLine() { return reader.ReadLine().Split(new[] { ' ', '\\t', }, StringSplitOptions.RemoveEmptyEntries); }\n public static string ReadToken() { while (currentLineTokens.Count == 0)currentLineTokens = new Queue(ReadAndSplitLine()); return currentLineTokens.Dequeue(); }\n public static int ReadInt() { return int.Parse(ReadToken()); }\n public static long ReadLong() { return long.Parse(ReadToken()); }\n public static double ReadDouble() { return double.Parse(ReadToken(), CultureInfo.InvariantCulture); }\n public static int[] ReadIntArray() { return ReadAndSplitLine().Select(int.Parse).ToArray(); }\n public static long[] ReadLongArray() { return ReadAndSplitLine().Select(long.Parse).ToArray(); }\n public static double[] ReadDoubleArray() { return ReadAndSplitLine().Select(s => double.Parse(s, CultureInfo.InvariantCulture)).ToArray(); }\n public static int[][] ReadIntMatrix(int numberOfRows) { int[][] matrix = new int[numberOfRows][]; for (int i = 0; i < numberOfRows; i++)matrix[i] = ReadIntArray(); return matrix; }\n public static int[][] ReadAndTransposeIntMatrix(int numberOfRows)\n {\n int[][] matrix = ReadIntMatrix(numberOfRows); int[][] ret = new int[matrix[0].Length][];\n for (int i = 0; i < ret.Length; i++) { ret[i] = new int[numberOfRows]; for (int j = 0; j < numberOfRows; j++)ret[i][j] = matrix[j][i]; } return ret;\n }\n public static string[] ReadLines(int quantity) { string[] lines = new string[quantity]; for (int i = 0; i < quantity; i++)lines[i] = reader.ReadLine().Trim(); return lines; }\n public static void WriteArray(IEnumerable array) { writer.WriteLine(string.Join(\" \", array)); }\n public static void Write(params object[] array) { WriteArray(array); }\n public static void WriteLines(IEnumerable array) { foreach (var a in array)writer.WriteLine(a); }\n private class SDictionary : Dictionary\n {\n public new TValue this[TKey key]\n {\n get { return ContainsKey(key) ? base[key] : default(TValue); }\n set { base[key] = value; }\n }\n }\n private static T[] Init(int size) where T : new() { var ret = new T[size]; for (int i = 0; i < size; i++)ret[i] = new T(); return ret; }\n #endregion\n}", "lang_cluster": "C#", "tags": ["brute force", "math", "constructive algorithms"], "code_uid": "1666ab1c0ef61b0ba8b26ab446739213", "src_uid": "a71cb5cda754ad2bf479bc3b0164fc4c", "difficulty": 2400.0, "exec_outcome": "PASSED"} {"lang": "C# 8", "source_code": "\ufeffusing System;\r\nusing System.Collections.Generic;\r\nusing System.Linq;\r\nusing System.Globalization;\r\nusing System.Threading;\r\n\r\nnamespace B\r\n{\r\n class Program\r\n {\r\n static void Main(string[] args)\r\n {\r\n Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;\r\n int tc = 1;\r\n //tc = int.Parse(Console.ReadLine());\r\n while (tc-- > 0)\r\n {\r\n solve();\r\n }\r\n }\r\n\r\n // write your code in solve function\r\n static void solve()\r\n {\r\n int n = int.Parse(Console.ReadLine());\r\n int[] ratings = new int[]{1200, 1400, 1600, 1900, 2100, 2300, 2400, 2600, 3000};\r\n\r\n for (int i=0; i= Math.Sqrt(3) * r) cnt += 3;\n else cnt += 2;\n \n Console.WriteLine(cnt);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["geometry"], "code_uid": "c5c33e7ea165f4344cc4412bb7557b7c", "src_uid": "ae883bf16842c181ea4bd123dee12ef9", "difficulty": 1900.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.IO;\nusing System.Text;\n\nnamespace Cupboard_and_Balloons\n{\n internal class Program\n {\n private static readonly StreamReader reader = new StreamReader(Console.OpenStandardInput(1024*10), Encoding.ASCII, false, 1024*10);\n private static readonly StreamWriter writer = new StreamWriter(Console.OpenStandardOutput(1024*10), Encoding.ASCII, 1024*10);\n\n private static void Main(string[] args)\n {\n int r = Next();\n int h = Next();\n\n int m = h/r;\n int count = 2*m;\n if (2*m*r + r <= 2*h)\n {\n count += 2;\n if (2*h - 2*m*r - r >= r*(Math.Sqrt(3) - 1))\n count++;\n }\n else\n {\n count++;\n }\n\n\n writer.WriteLine(count);\n writer.Flush();\n }\n\n private static int Next()\n {\n int c;\n int res = 0;\n do\n {\n c = reader.Read();\n if (c == -1)\n return res;\n } while (c < '0' || c > '9');\n res = c - '0';\n while (true)\n {\n c = reader.Read();\n if (c < '0' || c > '9')\n return res;\n res *= 10;\n res += c - '0';\n }\n }\n }\n}", "lang_cluster": "C#", "tags": ["geometry"], "code_uid": "237ddc9e0c6300af514e694f97bbe350", "src_uid": "ae883bf16842c181ea4bd123dee12ef9", "difficulty": 1900.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.IO;\n\nclass Program\n{\n\tint[][] c;\n\tint n, m;\n\tint mod = 1000000007;\n\tint add(int x, int y)\n\t{\n\t\tx+=y;\n\t\treturn x < mod ? x : x - mod;\n\t}\n\tint mul(int x, int y)\n\t{\n\t\treturn Convert.ToInt32(Convert.ToInt64(x) * y % mod);\n\t}\n\tvoid run()\n\t{\n\t\tString[] str = Console.ReadLine().Split(' ');\n\t\tn = Convert.ToInt32(str[0]);\n\t\tm = Convert.ToInt32(str[1]);\n\t\tint[][] dp=new int[n+1][];\n\t\tfor (int i = 1; i <= n; i++)\n\t\t{\n\t\t\tdp[i] = new int[m-1];\n\t\t\tif (i == 1)\n\t\t\t{\n\t\t\t\tfor (int j = 0; j <= m - 2; j++)\n\t\t\t\t\tdp[i][j] = 1;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tint now = 0;\n\t\t\tfor (int j = 0; j <= m-2; j++)\n\t\t\t{\n\t\t\t\tnow= add(now,dp[i-1][j]);\n\t\t\t\tdp[i][j] = add(j == 0 ? 0 : dp[i][j - 1], now);\n\t\t\t}\n\t\t}\n\n\t\tint[][] sum = new int[n+1][];\n\t\tfor (int i = 0; i <= n; i++)\n\t\t{\n\t\t\tsum[i] = new int[m - 1];\n\t\t\tfor (int j = 0; j <= m - 2; j++)\n\t\t\t\tsum[i][j] = i == 0 ? 0 : add(sum[i - 1][j] , dp[i][j]);\n\t\t}\n\n\t\tint res = 0;\n\t\tfor (int i = 1; i <= n; i++)\n\t\t\tfor (int j = 0; j <= m - 2; j++)\n\t\t\t{\n\t\t\t\tres = add(res, mul(mul(sum[i][j], add(sum[n - i + 1][j], mod - sum[n - i][j])), m - 1 - j));\n\t\t\t}\n\t\tConsole.WriteLine(res);\n\t}\n\tstatic void Main(String[] args)\n\t{\n\t\tnew Program().run();\n\t}\n}", "lang_cluster": "C#", "tags": ["dp", "combinatorics"], "code_uid": "609eb3767dcb4ee195bef4d5fcb3f9b1", "src_uid": "9ca1ad2fa16ca81e9ab5eba220b162c1", "difficulty": 2400.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeff#if DEBUG\nusing System.Reflection;\nusing System.Threading.Tasks;\n#endif\n\nusing System;\nusing System.Collections.Generic;\nusing System.IO;\nusing System.Linq;\nusing System.Text;\n\n\nnamespace _307d\n{\n\tclass Program\n\t{\n\t\tstatic string _inputFilename = \"input.txt\";\n\t\tstatic string _outputFilename = \"output.txt\";\n#if DEBUG\n static bool _useFileInput = false;\n#else\n\t\tstatic bool _useFileInput = false;\n#endif\n\n\t\tstatic void Main(string[] args)\n\t\t{\n\t\t\tStreamWriter file = null;\n\t\t\tif (_useFileInput)\n\t\t\t{\n\t\t\t\tConsole.SetIn(File.OpenText(_inputFilename));\n\t\t\t\tfile = new StreamWriter(_outputFilename);\n\t\t\t\tConsole.SetOut(file);\n\t\t\t}\n\n#if DEBUG\n\t\t\tif (!_useFileInput)\n\t\t\t{\n\t\t\t\tConsole.SetIn(getInput());\n\t\t\t}\n#endif\n\n\t\t\ttry\n\t\t\t{\n\t\t\t\tsolution();\n\t\t\t}\n\t\t\tfinally\n\t\t\t{\n\t\t\t\tif (_useFileInput)\n\t\t\t\t{\n\t\t\t\t\tfile.Close();\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tstatic void solution()\n\t\t{\n\t\t\t#region SOLUTION\n\t\t\tvar d = readLongArray();\n\t\t\tvar n = d[0];\n\t\t\tvar k = d[1];\n\t\t\tvar l = (int)d[2];\n\t\t\tvar m = d[3];\n\n\t\t\t//if (l == 0)\n\t\t\t//{\n\t\t\t//\tConsole.WriteLine(0);\n\t\t\t//\treturn;\n\t\t\t//}\n\n\t\t\tfor (int i = l; i < 64; i++)\n\t\t\t{\n\t\t\t\tif (((1L << i) & k) != 0)\n\t\t\t\t{\n\t\t\t\t\tConsole.WriteLine(0);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tvar fim = new Matrix { _11 = 0, _12 = 1, _21 = 1, _22 = 1 };\n\t\t\t//fim.Print();\n\t\t\tvar sq = pow(fim, n - 1, m);\n\t\t\t//sq.Print();\n\n\t\t\tvar fn0 = (sq._21 + sq._22) % m;\n\t\t\tvar fn1 = (sq._11 + sq._12) % m;\n\t\t\tvar fr = (fn0 + fn1) % m;\n\n\t\t\t//var fi = new int[n + 1];\n\t\t\t//fi[0] = 1;\n\t\t\t//fi[1] = 1;\n\t\t\t//for (int i = 2; i < n + 1; i++)\n\t\t\t//{\n\t\t\t//\tfi[i] = fi[i - 1] + fi[i - 2];\n\t\t\t//}\n\n\t\t\tvar nc = pow(2, n, m);\n\t\t\tnc -= fr;\n\t\t\tif (nc < 0)\n\t\t\t{\n\t\t\t\tnc += m;\n\t\t\t}\n\t\t\t//nc *= ((n - 1) % m);\n\t\t\tnc %= m;\n\n\t\t\tvar res = 1L;\n\t\t\tfor (int i = 0; i < l; i++)\n\t\t\t{\n\t\t\t\tif (((1L << i) & k) != 0)\n\t\t\t\t{\n\t\t\t\t\tres *= nc;\n\t\t\t\t\tres %= m;\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tres *= fr;\n\t\t\t\t\tres %= m;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tConsole.WriteLine(res % m);\n\n\t\t\t//var n = readInt();\n\t\t\t//var m = readInt();\n\n\t\t\t//var a = readIntArray();\n\t\t\t//var b = readIntArray();\n\t\t\t#endregion\n\t\t}\n\n\t\tclass Matrix\n\t\t{\n\t\t\tpublic long _11;\n\t\t\tpublic long _12;\n\t\t\tpublic long _21;\n\t\t\tpublic long _22;\n\n\t\t\tpublic void Mult(Matrix x, long mod)\n\t\t\t{\n\t\t\t\tvar __11 = (_11 * x._11) % mod + (_12 * x._21) % mod;\n\t\t\t\tvar __12 = (_11 * x._21) % mod + (_12 * x._22) % mod;\n\t\t\t\tvar __21 = (_21 * x._11) % mod + (_22 * x._21) % mod;\n\t\t\t\tvar __22 = (_21 * x._21) % mod + (_22 * x._22) % mod;\n\n\t\t\t\t_11 = __11 % mod;\n\t\t\t\t_12 = __12 % mod;\n\t\t\t\t_21 = __21 % mod;\n\t\t\t\t_22 = __22 % mod;\n\t\t\t}\n\n\t\t\tpublic void Square(long mod)\n\t\t\t{\n\t\t\t\tMult(this, mod);\n\t\t\t}\n\n\t\t\tpublic void Print()\n\t\t\t{\n\t\t\t\tConsole.WriteLine(\"{0} {1}\", _11, _12);\n\t\t\t\tConsole.WriteLine(\"{0} {1}\", _21, _22);\n\t\t\t\tConsole.WriteLine();\n\t\t\t}\n\t\t}\n\n\t\tstatic Matrix pow(Matrix x, long p, long mod)\n\t\t{\n\t\t\t//p %= mod;\n\n\t\t\tvar res = new Matrix() { _11 = 1, _22 = 1 };\n\t\t\tvar a = new Matrix() { _11 = x._11, _12 = x._12, _21 = x._21, _22 = x._22 };\n\t\t\twhile (true)\n\t\t\t{\n\t\t\t\tif (p % 2 == 1)\n\t\t\t\t{\n\t\t\t\t\tres.Mult(a, mod);\n\t\t\t\t\tp--;\n\t\t\t\t}\n\n\t\t\t\tif (p == 0)\n\t\t\t\t{\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tp /= 2;\n\t\t\t\ta.Square(mod);\n\t\t\t}\n\n\t\t\treturn res;\n\t\t}\n\n\t\tstatic long pow(long x, long p, long mod)\n\t\t{\n\t\t\tx %= mod;\n\t\t\t//p %= mod;\n\n\t\t\tvar res = 1L;\n\t\t\tvar a = x;\n\t\t\twhile (true)\n\t\t\t{\n\t\t\t\tif (p % 2 == 1)\n\t\t\t\t{\n\t\t\t\t\tres *= a;\n\t\t\t\t\tres %= mod;\n\t\t\t\t\tp--;\n\t\t\t\t}\n\n\t\t\t\tif (p == 0)\n\t\t\t\t{\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tp /= 2;\n\t\t\t\ta *= a;\n\t\t\t\ta %= mod;\n\t\t\t}\n\n\t\t\treturn res;\n\t\t}\n\n\t\tstatic int readInt()\n\t\t{\n\t\t\treturn int.Parse(Console.ReadLine());\n\t\t}\n\n\t\tstatic long readLong()\n\t\t{\n\t\t\treturn long.Parse(Console.ReadLine());\n\t\t}\n\n\t\tstatic int[] readIntArray()\n\t\t{\n\t\t\treturn Console.ReadLine().Split(' ').Where(i => !string.IsNullOrEmpty(i)).Select(i => int.Parse(i)).ToArray();\n\t\t}\n\n\t\tstatic long[] readLongArray()\n\t\t{\n\t\t\treturn Console.ReadLine().Split(' ').Where(i => !string.IsNullOrEmpty(i)).Select(i => long.Parse(i)).ToArray();\n\t\t}\n\n#if DEBUG\n\t\tstatic StreamReader getInput()\n\t\t{\n\t\t\tvar resName = Assembly.GetCallingAssembly().GetManifestResourceNames()[0];\n\t\t\tvar resource = Assembly.GetCallingAssembly().GetManifestResourceStream(resName);\n\n\t\t\treturn new StreamReader(resource);\n\t\t}\n#endif\n\t}\n}\n", "lang_cluster": "C#", "tags": ["math", "combinatorics", "matrices", "implementation", "number theory"], "code_uid": "c0c09b00266fd072c8212d9fe4aa222e", "src_uid": "2163eec2ea1eed5da8231d1882cb0f8e", "difficulty": 2100.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Globalization;\nusing System.IO;\nusing System.Linq;\nusing System.Text;\nusing System.Threading;\n\n// (\u3065\u00b0\u03c9\u00b0)\u3065\uff90\u2605\u309c\u30fb\u3002\u3002\u30fb\u309c\u309c\u30fb\u3002\u3002\u30fb\u309c\u2606\u309c\u30fb\u3002\u3002\u30fb\u309c\u309c\u30fb\u3002\u3002\u30fb\u309c\npublic class Solver\n{\n int MOD;\n\n long[,] MatMult(long[,] a, long[,] b, int n)\n {\n var ret = new long[n, n];\n for (int i = 0; i < n; i++)\n for (int j = 0; j < n; j++)\n for (int k = 0; k < n; k++)\n ret[i, j] = (ret[i, j] + a[i, k] * b[k, j]) % MOD;\n return ret;\n }\n\n long[,] MatPow(long[,] a, int n, long p)\n {\n var ret = new long[n, n];\n for (int i = 0; i < n; i++)\n ret[i, i] = 1;\n while (p > 0)\n {\n if ((p & 1) == 1)\n ret = MatMult(ret, a, n);\n a = MatMult(a, a, n);\n p >>= 1;\n }\n return ret;\n }\n\n long Fib(long n)\n {\n var a = new long[,] { { 1, 1 }, { 1, 0 } };\n a = MatPow(a, 2, n + 1);\n return a[0, 0];\n }\n\n int ModPow(long x, long p)\n {\n long ret = 1;\n while (p > 0)\n {\n if ((p & 1) == 1)\n ret = ret * x % MOD;\n x = x * x % MOD;\n p >>= 1;\n }\n return (int)ret;\n }\n\n void Solve()\n {\n long n = ReadLong();\n long k = ReadLong();\n int l = ReadInt();\n MOD = ReadInt();\n\n long f = Fib(n);\n long p = (ModPow(2, n) + MOD - f) % MOD;\n long ans = 1;\n for (int i = 0; i < l; i++)\n if ((k >> i & 1) == 1)\n ans = ans * p % MOD;\n else\n ans = ans * f % MOD;\n \n if (l < 60 && (k >> l) != 0)\n Write(0);\n else\n Write(ans % MOD);\n }\n\n #region Main\n\n protected static TextReader reader;\n protected static TextWriter writer;\n static void Main()\n {\n#if DEBUG\n reader = new StreamReader(\"..\\\\..\\\\input.txt\");\n //reader = new StreamReader(Console.OpenStandardInput());\n writer = Console.Out;\n //writer = new StreamWriter(\"..\\\\..\\\\output.txt\");\n#else\n reader = new StreamReader(Console.OpenStandardInput());\n writer = new StreamWriter(Console.OpenStandardOutput());\n //reader = new StreamReader(\"hull.in\");\n //writer = new StreamWriter(\"hull.out\");\n#endif\n try\n {\n // var thread = new Thread(new Solver().Solve, 1024 * 1024 * 128);\n // thread.Start();\n // thread.Join();\n new Solver().Solve();\n }\n catch (Exception ex)\n {\n Console.WriteLine(ex);\n#if DEBUG\n#else\n throw;\n#endif\n }\n reader.Close();\n writer.Close();\n }\n\n #endregion\n\n #region Read / Write\n private static Queue currentLineTokens = new Queue();\n private static string[] ReadAndSplitLine() { return reader.ReadLine().Split(new[] { ' ', '\\t', }, StringSplitOptions.RemoveEmptyEntries); }\n public static string ReadToken() { while (currentLineTokens.Count == 0)currentLineTokens = new Queue(ReadAndSplitLine()); return currentLineTokens.Dequeue(); }\n public static int ReadInt() { return int.Parse(ReadToken()); }\n public static long ReadLong() { return long.Parse(ReadToken()); }\n public static double ReadDouble() { return double.Parse(ReadToken(), CultureInfo.InvariantCulture); }\n public static int[] ReadIntArray() { return ReadAndSplitLine().Select(int.Parse).ToArray(); }\n public static long[] ReadLongArray() { return ReadAndSplitLine().Select(long.Parse).ToArray(); }\n public static double[] ReadDoubleArray() { return ReadAndSplitLine().Select(s => double.Parse(s, CultureInfo.InvariantCulture)).ToArray(); }\n public static int[][] ReadIntMatrix(int numberOfRows) { int[][] matrix = new int[numberOfRows][]; for (int i = 0; i < numberOfRows; i++)matrix[i] = ReadIntArray(); return matrix; }\n public static int[][] ReadAndTransposeIntMatrix(int numberOfRows)\n {\n int[][] matrix = ReadIntMatrix(numberOfRows); int[][] ret = new int[matrix[0].Length][];\n for (int i = 0; i < ret.Length; i++) { ret[i] = new int[numberOfRows]; for (int j = 0; j < numberOfRows; j++)ret[i][j] = matrix[j][i]; } return ret;\n }\n public static string[] ReadLines(int quantity) { string[] lines = new string[quantity]; for (int i = 0; i < quantity; i++)lines[i] = reader.ReadLine().Trim(); return lines; }\n public static void WriteArray(IEnumerable array) { writer.WriteLine(string.Join(\" \", array)); }\n public static void Write(params object[] array) { WriteArray(array); }\n public static void WriteLines(IEnumerable array) { foreach (var a in array)writer.WriteLine(a); }\n private class SDictionary : Dictionary\n {\n public new TValue this[TKey key]\n {\n get { return ContainsKey(key) ? base[key] : default(TValue); }\n set { base[key] = value; }\n }\n }\n private static T[] Init(int size) where T : new() { var ret = new T[size]; for (int i = 0; i < size; i++)ret[i] = new T(); return ret; }\n #endregion\n}", "lang_cluster": "C#", "tags": ["math", "combinatorics", "matrices", "implementation", "number theory"], "code_uid": "b61fe700150312a62b1af20600b063fb", "src_uid": "2163eec2ea1eed5da8231d1882cb0f8e", "difficulty": 2100.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\n//namespace Practice\n//{\n class TaskF\n {\n public static void Main(string[] args)\n {\n new TaskF().solve();\n }\n const int P = 1000000007;\n public int pow(int a, int b)\n {\n if (b == 0) return 1;\n int res = pow(a, (b >> 1));\n res = (int)((1L * res * res) % P);\n if ((b & 1) == 1)\n {\n return (int)((1L * res * a) % P);\n }\n return res;\n }\n\n int comb(int n, int k, int[] fac, int[] finv)\n {\n if (k > n) return 0;\n if (k == 0 || k == n) return 1;\n return (int) (((1L * (1L * fac[n] * finv[k]) % P) * finv[n-k]) % P);\n }\n\n public void solve()\n {\n string[] inputs = Console.ReadLine().Split(' ');\n int f = int.Parse(inputs[0]);\n int w = int.Parse(inputs[1]);\n int h = int.Parse(inputs[2]);\n\n if (w == 0 || h == 0)\n {\n Console.WriteLine(1);\n return;\n }\n else if (f == 0)\n {\n if (w > h)\n {\n Console.WriteLine(1);\n return;\n }\n else\n {\n Console.WriteLine(0);\n return;\n }\n }\n if (w <= h && w > 0)\n {\n Console.WriteLine(0);\n return;\n }\n int n = Math.Max(f + 1, w - 1) + 1;\n int[] fac = new int[n];\n int[] finv = new int[n];\n fac[0] = finv[0] = 1;\n fac[1] = finv[1] = 1;\n for (int i = 2; i < n; i++)\n {\n fac[i] = (int)((1L * fac[i - 1] * i) % P);\n finv[i] = pow(fac[i], P - 2); \n }\n\n int all = 0, good = 0, f1 = f + 1, w1 = w - 1, upper = w / (h + 1);\n for (int u = 1; u <= w; u++)\n {\n if (u > f1) break;\n int f1u = comb(f1, u, fac, finv);\n all += mult(f1u, comb(w1, u - 1, fac, finv));\n all %= P;\n if (u <= upper)\n {\n good += mult(f1u, comb(w - u * h - 1, u - 1, fac, finv));\n good %= P;\n }\n }\n //Console.WriteLine(pow(all, P-2));\n int res = (int)(1L * good * pow(all, P - 2) % P);\n //Console.WriteLine(res + \" = \" + good +\" / \" + all);\n Console.WriteLine(res);\n\n //Console.Read();\n }\n public int mult(int a, int b)\n {\n return (int)((1L * a * b) % P);\n }\n }\n//}\n", "lang_cluster": "C#", "tags": ["brute force", "math", "combinatorics", "probabilities", "number theory"], "code_uid": "373a370622e14a28f2aec4644b8477c6", "src_uid": "a69f95db3fe677111cf0558271b40f39", "difficulty": 2300.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\n\nnamespace SP.Solutions.CodeForces.c338_196_1\n{\n\tpublic class ProgramC\n\t{\n\t private static long bestRes = long.MaxValue;\n\n\t\tpublic static void Main()\n\t\t{\n\t\t\tchecked\n\t\t\t{\n\t\t\t bestRes = long.MaxValue;\n\t\t\t int n = int.Parse(Console.ReadLine());\n\t\t\t var arr = Console.ReadLine().Split(' ').Select(long.Parse).Distinct().ToArray();\n Array.Sort(arr);\n\n\t\t\t var primes = GetPrimes();\n\n\t\t\t var nodes = new List();\n for (int i = 0; i < arr.Length; i++)\n {\n nodes.Add(new Node(arr[i], getFactors(arr[i], primes), arr[i], false, 0));\n }\n\n\t\t\t TryBuildTrees(nodes, 0);\n Console.WriteLine(bestRes);\n\t\t\t}\n\t\t}\n\n\t private static void TryBuildTrees(List nodes, int minJ)\n\t {\n\t var noWay = true;\n for (int j = minJ; j < nodes.Count; j++)\n for (int i = j + 1; i < nodes.Count; i++)\n if (j != i && !nodes[j].HasParent && nodes[i].Rem%nodes[j].N == 0 && !nodes[i].HasParent)\n\t {\n\t noWay = false;\n\t int add = nodes[j].Factors > 1 ? 1 : 0;\n\n\t var r1 = nodes[i].Rem;\n\t var add1 = nodes[i].addFactors;\n\n\t nodes[i].Rem = nodes[i].Rem/nodes[j].N;\n\t nodes[i].addFactors = nodes[i].addFactors + nodes[j].addFactors + add;\n\t nodes[j].HasParent = true;\n\n TryBuildTrees(nodes, minJ);\n\t \n nodes[j].HasParent = false;\n nodes[i].Rem = r1;\n nodes[i].addFactors = add1;\n }\n if (noWay)\n\t CalcPrice(nodes);\n\t }\n\n\t private static void CalcPrice(List nodes)\n\t {\n\t int n = 0;\n\t long res = 0;\n foreach (var node in nodes) if (!node.HasParent)\n {\n if (node.Factors > 1) res++;\n res += node.Factors + node.addFactors;\n n++;\n }\n\t if (n > 1) res++;\n\t bestRes = Math.Min(bestRes, res);\n\t }\n\n\t static int getFactors(long n, long[] primes)\n {\n int res = 0;\n int i = 0;\n while (n > 1 && i < primes.Length)\n {\n if (n%primes[i] == 0)\n {\n res++;\n n /= primes[i];\n }\n else i++;\n }\n\t if (i == primes.Length) res++;\n return res;\n }\n\n class Node\n {\n public override string ToString()\n {\n return string.Format(\"HasParent: {0}, N: {1}, Factors: {2}, Rem: {3}\", HasParent, N, Factors, Rem);\n }\n\n public bool HasParent;\n public readonly long N;\n public int Factors;\n public long Rem;\n public int addFactors;\n\n public Node(long n, int factors, long rem, bool hasParent, int addFactors)\n {\n HasParent = hasParent;\n this.addFactors = addFactors;\n N = n;\n Factors = factors;\n Rem = rem;\n }\n }\n\n\t private static long[] GetPrimes()\n\t {\n\t const int max = 1000000;\n\t var primes = new List(80000);\n\t primes.Add(2);\n\t var isNotPrime = new bool[max + 1];\n for (int i = 3 ; i<= max ; i+=2) if (!isNotPrime[i])\n {\n primes.Add(i);\n for (int j = i*i; j <= max && j > 0; j += i) isNotPrime[j] = true;\n }\n\t return primes.ToArray();\n\t }\n\t}\n}", "lang_cluster": "C#", "tags": ["brute force", "dp", "number theory"], "code_uid": "c72fc3e54ce9501a059e462ccb916771", "src_uid": "52b8b6c68518d5129272b8c56e5b7662", "difficulty": 2200.0, "exec_outcome": "PASSED"} {"lang": "C# 8", "source_code": "\ufeffusing System;\r\nusing System.Collections.Generic;\r\n\r\nnamespace AprilFoolsDayContest2021\r\n{\r\n class Program\r\n {\r\n static void Main(string[] args)\r\n {\r\n int i = int.Parse(Console.ReadLine());\r\n\r\n Console.WriteLine((2 - i*i));\r\n }\r\n\r\n static void CMain(string[] args)\r\n {\r\n string word = Console.ReadLine();\r\n\r\n for (int i = 1; i < word.Length - 1; i++)\r\n {\r\n if (((word[i - 1] - 65) + (word[i] - 65)) % 26 != (word[i + 1] - 65))\r\n {\r\n Console.WriteLine(\"NO\");\r\n return;\r\n }\r\n }\r\n\r\n Console.WriteLine(\"YES\");\r\n }\r\n\r\n static void XMain(string[] args)\r\n {\r\n int num = int.Parse(Console.ReadLine());\r\n\r\n double root = Math.Sqrt(num);\r\n int _root = (int)root;\r\n int proot = _root - 1;\r\n int nroot = _root + 1;\r\n\r\n if (root - proot > nroot - root)\r\n {\r\n if (root - _root > nroot - root)\r\n {\r\n Console.WriteLine(nroot);\r\n } else\r\n {\r\n Console.WriteLine(_root);\r\n }\r\n } else\r\n {\r\n if (root - _root > root - proot)\r\n {\r\n Console.WriteLine(proot);\r\n }\r\n else\r\n {\r\n Console.WriteLine(_root);\r\n }\r\n }\r\n }\r\n\r\n static void AMain(string[] args)\r\n {\r\n while (Console.In.Peek() != -1)\r\n {\r\n string test = Console.ReadLine();\r\n if (test.ToLower().Equals(\"Is it rated?\".ToLower()))\r\n {\r\n Console.WriteLine(\"No\");\r\n } else\r\n {\r\n Console.WriteLine(\"No\");\r\n }\r\n Console.Out.Flush();\r\n }\r\n }\r\n }\r\n}\r\n", "lang_cluster": "C#", "tags": ["math"], "code_uid": "fd03004d5dff27aefa9b14cb3107805a", "src_uid": "f76005f888df46dac38b0f159ca04d5f", "difficulty": 2200.0, "exec_outcome": "PASSED"} {"lang": "C# 8", "source_code": "using System;\r\nusing System.Collections.Generic;\r\nusing System.Linq;\r\nusing System.IO;\r\nusing System.Threading;\r\nusing System.Text;\r\nusing System.Text.RegularExpressions;\r\nusing System.Diagnostics;\r\nusing static util;\r\nusing P = pair;\r\n\r\nclass Program {\r\n static void Main(string[] args) {\r\n var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };\r\n var solver = new Solver(sw);\r\n // var t = new Thread(solver.solve, 1 << 28); // 256 MB\r\n // t.Start();\r\n // t.Join();\r\n solver.solve();\r\n sw.Flush();\r\n }\r\n}\r\n\r\nclass Solver {\r\n StreamWriter sw;\r\n Scan sc;\r\n void Prt(string a) => sw.WriteLine(a);\r\n void Prt(IEnumerable a) => Prt(string.Join(\" \", a));\r\n void Prt(params object[] a) => Prt(string.Join(\" \", a));\r\n public Solver(StreamWriter sw) {\r\n this.sw = sw;\r\n this.sc = new Scan();\r\n }\r\n\r\n public void solve() {\r\n string[] s = {\"1\",\"12\",\"14\",\"145\", \"15\", \"124\", \"1245\",\r\n \"125\", \"24\", \"245\", \"13\", \"123\", \"134\",\r\n \"1345\", \"135\", \"1234\", \"12345\", \"1235\", \"234\", \"2345\",\r\n \"136\", \"1236\", \"2456\", \"1346\", \"13456\", \"1356\"};\r\n\r\n var t = new string[26];\r\n for (int i = 0; i < 26; i++)\r\n {\r\n var cnt = new int[5];\r\n foreach (var item in s[i])\r\n {\r\n int c = item - '1';\r\n ++cnt[c % 3];\r\n ++cnt[3 + c / 3];\r\n }\r\n t[i] = string.Join(' ', cnt);\r\n }\r\n int n = sc.Int;\r\n for (int i = 0; i < n; i++)\r\n {\r\n var p = sc.Str;\r\n for (int j = 0; j < 26; j++)\r\n {\r\n if (p == t[j]) {\r\n sw.Write((char)('a' + j));\r\n break;\r\n }\r\n }\r\n }\r\n Prt();\r\n\r\n\r\n }\r\n}\r\n\r\nclass pair : IComparable> {\r\n public T v1;\r\n public U v2;\r\n public pair() : this(default(T), default(U)) {}\r\n public pair(T v1, U v2) { this.v1 = v1; this.v2 = v2; }\r\n public int CompareTo(pair a) {\r\n int c = Comparer.Default.Compare(v1, a.v1);\r\n return c != 0 ? c : Comparer.Default.Compare(v2, a.v2);\r\n }\r\n public override string ToString() => $\"{v1} {v2}\";\r\n public void Deconstruct(out T a, out U b) { a = v1; b = v2; }\r\n}\r\nstatic class util {\r\n public static readonly int M = 1000000007;\r\n // public static readonly int M = 998244353;\r\n public static readonly long LM = 1L << 60;\r\n public static readonly double eps = 1e-11;\r\n public static void DBG(string a) => Console.Error.WriteLine(a);\r\n public static void DBG(IEnumerable a) => DBG(string.Join(\" \", a));\r\n public static void DBG(params object[] a) => DBG(string.Join(\" \", a));\r\n public static void Assert(params bool[] conds) {\r\n if (conds.Any(x => !x)) throw new Exception();\r\n }\r\n public static pair make_pair(T v1, U v2) => new pair(v1, v2);\r\n public static int CompareList(IList a, IList b) where T : IComparable {\r\n for (int i = 0; i < a.Count && i < b.Count; i++)\r\n if (a[i].CompareTo(b[i]) != 0) return a[i].CompareTo(b[i]);\r\n return a.Count.CompareTo(b.Count);\r\n }\r\n public static bool inside(int i, int j, int h, int w) => i >= 0 && i < h && j >= 0 && j < w;\r\n public static readonly int[] dd = { 0, 1, 0, -1 };\r\n // static readonly string dstring = \"RDLU\";\r\n public static IEnumerable

adjacents(int i, int j) {\r\n for (int k = 0; k < 4; k++) yield return new P(i + dd[k], j + dd[k ^ 1]);\r\n }\r\n public static IEnumerable

adjacents(int i, int j, int h, int w) {\r\n for (int k = 0; k < 4; k++) if (inside(i + dd[k], j + dd[k ^ 1], h, w))\r\n yield return new P(i + dd[k], j + dd[k ^ 1]);\r\n }\r\n public static IEnumerable

adjacents(this P p) => adjacents(p.v1, p.v2);\r\n public static IEnumerable

adjacents(this P p, int h, int w) => adjacents(p.v1, p.v2, h, w);\r\n public static IEnumerable all_subset(this int p) {\r\n for (int i = 0; ; i = i - p & p) {\r\n yield return i;\r\n if (i == p) break;\r\n }\r\n }\r\n public static Dictionary compress(this IEnumerable a)\r\n => a.Distinct().OrderBy(v => v).Select((v, i) => new { v, i }).ToDictionary(p => p.v, p => p.i);\r\n public static Dictionary compress(params IEnumerable[] a)\r\n => compress(a.SelectMany(x => x));\r\n public static T[] inv(this Dictionary dic) {\r\n var res = new T[dic.Count];\r\n foreach (var item in dic) res[item.Value] = item.Key;\r\n return res;\r\n }\r\n public static void swap(ref T a, ref T b) where T : struct { var t = a; a = b; b = t; }\r\n public static void swap(this IList a, int i, int j) where T : struct {\r\n var t = a[i]; a[i] = a[j]; a[j] = t;\r\n }\r\n public static T[] copy(this IList a) {\r\n var ret = new T[a.Count];\r\n for (int i = 0; i < a.Count; i++) ret[i] = a[i];\r\n return ret;\r\n }\r\n}\r\n\r\nclass Scan {\r\n StreamReader sr;\r\n public Scan() { sr = new StreamReader(Console.OpenStandardInput()); }\r\n public Scan(string path) { sr = new StreamReader(path); }\r\n public int Int => int.Parse(Str);\r\n public long Long => long.Parse(Str);\r\n public double Double => double.Parse(Str);\r\n public string Str => ReadLine.Trim();\r\n public string ReadLine => sr.ReadLine();\r\n public pair Pair() {\r\n T a; U b;\r\n Multi(out a, out b);\r\n return new pair(a, b);\r\n }\r\n public P P => Pair();\r\n public int[] IntArr => StrArr.Select(int.Parse).ToArray();\r\n public long[] LongArr => StrArr.Select(long.Parse).ToArray();\r\n public double[] DoubleArr => StrArr.Select(double.Parse).ToArray();\r\n public string[] StrArr => Str.Split(new[]{' '}, StringSplitOptions.RemoveEmptyEntries);\r\n bool eq() => typeof(T).Equals(typeof(U));\r\n T ct(U a) => (T)Convert.ChangeType(a, typeof(T));\r\n T cv(string s) => eq() ? ct(int.Parse(s))\r\n : eq() ? ct(long.Parse(s))\r\n : eq() ? ct(double.Parse(s))\r\n : eq() ? ct(s[0])\r\n : ct(s);\r\n public void Multi(out T a) => a = cv(Str);\r\n public void Multi(out T a, out U b) {\r\n var ar = StrArr; a = cv(ar[0]); b = cv(ar[1]);\r\n }\r\n public void Multi(out T a, out U b, out V c) {\r\n var ar = StrArr; a = cv(ar[0]); b = cv(ar[1]); c = cv(ar[2]);\r\n }\r\n public void Multi(out T a, out U b, out V c, out W d) {\r\n var ar = StrArr; a = cv(ar[0]); b = cv(ar[1]); c = cv(ar[2]); d = cv(ar[3]);\r\n }\r\n public void Multi(out T a, out U b, out V c, out W d, out X e) {\r\n var ar = StrArr;\r\n a = cv(ar[0]); b = cv(ar[1]); c = cv(ar[2]); d = cv(ar[3]); e = cv(ar[4]);\r\n }\r\n public void Multi(out T a, out U b, out V c, out W d, out X e, out Y f) {\r\n var ar = StrArr;\r\n a = cv(ar[0]); b = cv(ar[1]); c = cv(ar[2]);\r\n d = cv(ar[3]); e = cv(ar[4]); f = cv(ar[5]);\r\n }\r\n}\r\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "379f80bca04b33b84a291ccd70e6c408", "src_uid": "a3603f5ed0d8bdb7fe829342991b78e6", "difficulty": 2600.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Globalization;\nusing System.IO;\nusing System.Linq;\nusing System.Security.Cryptography;\nusing System.Text;\nusing System.Threading;\n\n// (\u3065\u00b0\u03c9\u00b0)\u3065\uff90\u2605\u309c\u30fb\u3002\u3002\u30fb\u309c\u309c\u30fb\u3002\u3002\u30fb\u309c\u2606\u309c\u30fb\u3002\u3002\u30fb\u309c\u309c\u30fb\u3002\u3002\u30fb\u309c\npublic class Solver\n{\n long[] fact = new long[19];\n private int[] a;\n\n void Fun(int x, int lim, int k, long s, SDictionary[] dicts)\n {\n if (s < 0)\n return;\n if (x == lim)\n {\n dicts[k][s]++;\n return;\n }\n\n if (a[x] < 19 && k > 0)\n Fun(x + 1, lim, k - 1, s - fact[a[x]], dicts);\n Fun(x + 1, lim, k, s - a[x], dicts);\n Fun(x + 1, lim, k, s, dicts);\n }\n\n public void Solve()\n {\n fact[0] = 1;\n for (int i = 1; i < 19; i++)\n fact[i] = fact[i - 1] * i;\n\n int n = ReadInt();\n int k = ReadInt();\n long s = ReadLong();\n a = ReadIntArray();\n\n var d1 = Enumerable.Repeat(0, k + 1).Select(x => new SDictionary()).ToArray();\n Fun(0, n / 2, k, s, d1);\n var d2 = Enumerable.Repeat(0, k + 1).Select(x => new SDictionary()).ToArray();\n Fun(n / 2, n, k, s, d2);\n\n long ans = 0;\n for (int i = 0; i <= k; i++)\n foreach (var p in d1[i])\n for (int j = k - i; j <= k; j++)\n ans += p.Value * d2[j][s - p.Key];\n\n Write(ans);\n }\n\n #region Main\n\n protected static TextReader reader;\n protected static TextWriter writer;\n\n static void Main()\n {\n#if DEBUG\n reader = new StreamReader(\"..\\\\..\\\\input.txt\");\n writer = Console.Out;\n //writer = new StreamWriter(\"..\\\\..\\\\output.txt\");\n#else\n reader = new StreamReader(Console.OpenStandardInput());\n writer = new StreamWriter(Console.OpenStandardOutput());\n //reader = new StreamReader(\"cycle.in\");\n //writer = new StreamWriter(\"cycle.out\");\n#endif\n try\n {\n // var thread = new Thread(new Solver().Solve, 1024 * 1024 * 128);\n // thread.Start();\n // thread.Join();\n new Solver().Solve();\n }\n catch (Exception ex)\n {\n#if DEBUG\n Console.WriteLine(ex);\n#else\n Console.WriteLine(ex);\n throw;\n#endif\n }\n reader.Close();\n writer.Close();\n }\n\n #endregion\n\n #region Read / Write\n\n private static Queue currentLineTokens = new Queue();\n\n private static string[] ReadAndSplitLine()\n {\n return reader.ReadLine().Split(new[] { ' ', '\\t' }, StringSplitOptions.RemoveEmptyEntries);\n }\n\n public static string ReadToken()\n {\n while (currentLineTokens.Count == 0)\n currentLineTokens = new Queue(ReadAndSplitLine());\n return currentLineTokens.Dequeue();\n }\n\n public static int ReadInt()\n {\n return int.Parse(ReadToken());\n }\n\n public static long ReadLong()\n {\n return long.Parse(ReadToken());\n }\n\n public static double ReadDouble()\n {\n return double.Parse(ReadToken(), CultureInfo.InvariantCulture);\n }\n\n public static int[] ReadIntArray()\n {\n return ReadAndSplitLine().Select(int.Parse).ToArray();\n }\n\n public static long[] ReadLongArray()\n {\n return ReadAndSplitLine().Select(long.Parse).ToArray();\n }\n\n public static double[] ReadDoubleArray()\n {\n return ReadAndSplitLine().Select(s => double.Parse(s, CultureInfo.InvariantCulture)).ToArray();\n }\n\n public static int[][] ReadIntMatrix(int numberOfRows)\n {\n int[][] matrix = new int[numberOfRows][];\n for (int i = 0; i < numberOfRows; i++)\n matrix[i] = ReadIntArray();\n return matrix;\n }\n\n public static int[][] ReadAndTransposeIntMatrix(int numberOfRows)\n {\n int[][] matrix = ReadIntMatrix(numberOfRows);\n int[][] ret = new int[matrix[0].Length][];\n for (int i = 0; i < ret.Length; i++)\n {\n ret[i] = new int[numberOfRows];\n for (int j = 0; j < numberOfRows; j++)\n ret[i][j] = matrix[j][i];\n }\n return ret;\n }\n\n public static string[] ReadLines(int quantity)\n {\n string[] lines = new string[quantity];\n for (int i = 0; i < quantity; i++)\n lines[i] = reader.ReadLine().Trim();\n return lines;\n }\n\n public static void WriteArray(IEnumerable array)\n {\n writer.WriteLine(string.Join(\" \", array));\n }\n\n public static void Write(params object[] array)\n {\n WriteArray(array);\n }\n\n public static void WriteLines(IEnumerable array)\n {\n foreach (var a in array)\n writer.WriteLine(a);\n }\n\n class SDictionary : Dictionary\n {\n public new TValue this[TKey key]\n {\n get { return ContainsKey(key) ? base[key] : default(TValue); }\n set { base[key] = value; }\n }\n }\n\n #endregion\n}", "lang_cluster": "C#", "tags": ["brute force", "math", "dp", "binary search", "bitmasks", "meet-in-the-middle"], "code_uid": "c0e4f94784904ff8e92e108c1b4427f9", "src_uid": "2821a11066dffc7e8f6a60a8751cea37", "difficulty": 2100.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.IO;\nusing System.Collections;\nusing System.Collections.Generic;\nusing System.Text;\nusing System.Reflection;\nusing System.Net.Sockets;\nusing System.Xml;\nusing System.Diagnostics;\nusing System.Linq;\nusing System.Threading;\n\nstatic class Program\n{\n #region IO\n public delegate ReadDelegate ReadDelegate(out T value);\n public delegate bool ParserDelegate(string word, out T item);\n\n public class Input : IDisposable\n {\n private static EventArgs DefaultEventArgs = new EventArgs();\n\n public TextReader TextReader { get; private set; }\n\n public event EventHandler OnEndOfStream;\n public event EventHandler OnParseError;\n public event EventHandler OnReadError;\n\n public bool CanRead { get; private set; }\n public bool ThrowExceptions { get; set; }\n\n string line = string.Empty;\n int pos = 0;\n\n static EventHandler emptyHandler;\n\n public Input(string path)\n : this(File.OpenRead(path))\n {\n }\n public Input(Stream s)\n : this(new StreamReader(s))\n {\n\n }\n public Input(TextReader tr)\n {\n TextReader = tr;\n\n if (emptyHandler == null)\n emptyHandler = (a, b) => { };\n\n OnEndOfStream = emptyHandler;\n OnParseError = emptyHandler;\n OnReadError = emptyHandler;\n\n CanRead = true;\n }\n\n public static implicit operator Input(Stream s)\n {\n return new Input(s);\n }\n public static implicit operator Input(TextReader tr)\n {\n return new Input(tr);\n }\n\n private bool ReadStream()\n {\n if (!CanRead) return false;\n if (pos < line.Length) return true;\n\n Clear();\n\n string s = TextReader.ReadLine();\n if (s == null)\n {\n CanRead = false;\n return false;\n }\n\n line = s;\n return true;\n }\n\n public ReadDelegate r(out T value)\n {\n value = ReadData();\n return r;\n }\n\n public void SkipChar()\n {\n if (pos < line.Length) pos++;\n else\n {\n ReadStream();\n }\n }\n public void SkipChars(int length)\n {\n while (length > 0)\n {\n int dt = line.Length - pos;\n if (dt <= 0)\n {\n length--;\n if (!ReadStream()) return;\n }\n dt = Math.Min(length, dt);\n pos += dt;\n length -= dt;\n }\n }\n\n public void SkipWhiteSpace()\n {\n while (true)\n {\n for (; pos < line.Length; pos++)\n {\n if (!char.IsWhiteSpace(line[pos])) return;\n }\n if (!ReadStream())\n {\n OnEndOfStream(this, DefaultEventArgs);\n return;\n }\n }\n }\n public bool CanReadData()\n {\n SkipWhiteSpace();\n return CanRead;\n }\n\n public T[] ReadArray()\n {\n int length = ReadInt32();\n return ReadArray(length);\n }\n public T[] ReadArray(int length)\n {\n ParserDelegate parser = Parser.GetPrimitiveParser();\n return ReadArray(length, parser);\n }\n public T[] ReadArray(ParserDelegate parser)\n {\n int length = ReadInt32();\n return ReadArray(length, parser);\n }\n public T[] ReadArray(int length, ParserDelegate parser)\n {\n T[] res = new T[length];\n for (int i = 0; i < length; i++)\n {\n res[i] = ReadData(parser);\n }\n return res;\n }\n\n public Decimal ReadDecimal()\n {\n return ReadData(Parser.DecimalParser);\n }\n public Double ReadDouble()\n {\n return ReadData(Parser.DoubleParser);\n }\n public Single ReadSingle()\n {\n return ReadData(Parser.SingleParser);\n }\n public UInt64 ReadUInt64()\n {\n return ReadData(UInt64.TryParse);\n }\n public UInt32 ReadUInt32()\n {\n return ReadData(UInt32.TryParse);\n }\n public UInt16 ReadUInt16()\n {\n return ReadData(UInt16.TryParse);\n }\n public Int64 ReadInt64()\n {\n return ReadData(Int64.TryParse);\n }\n public Int32 ReadInt32()\n {\n return ReadData(Int32.TryParse);\n }\n public Int16 ReadInt16()\n {\n return ReadData(Int16.TryParse);\n }\n public Boolean ReadYesNo()\n {\n return ReadData(Parser.YesNoParser);\n }\n public Boolean ReadBoolean()\n {\n return ReadData(Boolean.TryParse);\n }\n public Byte ReadByte()\n {\n return ReadData(Byte.TryParse);\n }\n\n private bool ReadCheck()\n {\n if (!CanRead)\n {\n OnReadError(this, DefaultEventArgs);\n if (ThrowExceptions)\n {\n throw new Exception(\"!CanRead\");\n }\n return false;\n }\n return true;\n }\n public T ReadData()\n {\n return ReadData(true);\n }\n public T ReadData(bool skipWhiteSpace)\n {\n ParserDelegate parser = Parser.GetPrimitiveParser();\n return ReadData(parser, skipWhiteSpace);\n }\n public T ReadData(ParserDelegate parser)\n {\n return ReadData(parser, true);\n }\n public T ReadData(ParserDelegate parser, bool skipWhiteSpace)\n {\n if (skipWhiteSpace)\n SkipWhiteSpace();\n\n if (!ReadCheck()) return default(T);\n\n string s = ReadWord(false);\n\n T res;\n if (!parser.Invoke(s, out res))\n {\n OnParseError(this, DefaultEventArgs);\n if (ThrowExceptions)\n {\n throw new Exception(\"!validate, word = \" + Output.ToString(s, 256));\n }\n }\n return res;\n }\n\n public string ReadWord()\n {\n return ReadWord(true);\n }\n public string ReadWord(bool skipWhiteSpace)\n {\n if (skipWhiteSpace)\n SkipWhiteSpace();\n\n if (!ReadCheck()) return string.Empty;\n\n int from = pos;\n int to = pos;\n for (int i = pos; i < line.Length; i++)\n {\n if (char.IsWhiteSpace(line[i])) break;\n to = i + 1;\n }\n pos = to;\n\n return line.Substring(from, to - from);\n }\n\n public string ReadLine()\n {\n if (!ReadCheck()) return string.Empty;\n\n ReadStream();\n string res = line.Substring(pos);\n pos = line.Length;\n\n return res;\n }\n\n public void Close()\n {\n TextReader.Close();\n }\n public void Clear()\n {\n pos = 0;\n line = string.Empty;\n }\n\n private bool disposed = false;\n public void Dispose()\n {\n Dispose(true);\n GC.SuppressFinalize(this);\n }\n\n protected virtual void Dispose(bool disposing)\n {\n if (!this.disposed)\n {\n if (disposing)\n {\n line = string.Empty;\n TextReader.Dispose();\n }\n disposed = true;\n }\n }\n ~Input()\n {\n Dispose(false);\n }\n }\n public class Output : IDisposable\n {\n static char[] space = new char[] { ' ' };\n\n public TextWriter TextWriter { get; private set; }\n public bool AutoFlush { get; set; }\n\n\n public static string ToString(object obj, int maxLength)\n {\n return ToString(FormatReal(obj), maxLength);\n }\n public static string ToString(string s, int maxLength)\n {\n if (s.Length <= maxLength) return s;\n else return s.Substring(0, maxLength) + \"...\";\n }\n public static object FormatReal(object v, string format)\n {\n if (v is decimal) return ((decimal)v).ToString(format).Replace(',', '.');\n if (v is double) return ((double)v).ToString(format).Replace(',', '.');\n if (v is float) return ((float)v).ToString(format).Replace(',', '.');\n\n return v;\n }\n public static object FormatReal(object v)\n {\n if (v is decimal || v is double || v is float)\n {\n return v.ToString().Replace(',', '.');\n }\n return v;\n }\n\n public Output()\n : this(new MemoryStream())\n {\n }\n public Output(string path)\n : this(File.Create(path))\n {\n\n }\n public Output(Stream s)\n : this(new StreamWriter(s))\n {\n }\n public Output(TextWriter tw)\n {\n TextWriter = tw;\n }\n\n public static implicit operator Output(Stream s)\n {\n return new Output(s);\n }\n\n public static implicit operator Output(TextWriter tw)\n {\n return new Output(tw);\n }\n\n public static Output operator +(Output output, object obj)\n {\n output.Write(obj);\n return output;\n }\n public Output WriteArray(params T[] array)\n {\n return WriteArray(array, false);\n }\n public Output WriteArray(T[] array, bool appendLength)\n {\n return WriteArray(array, 0, array.Length, appendLength);\n }\n public Output WriteArray(T[] array, int index, int count)\n {\n return WriteArray(array, index, count, false);\n }\n public Output WriteArray(T[] array, int index, int count, bool appendLength)\n {\n if (index + count > array.Length)\n {\n string message = string.Format(\n \"Index out of range: {0} + {1} >= {2}\",\n index,\n count,\n array.Length);\n throw new Exception(message);\n }\n if (appendLength)\n {\n WriteLine(count);\n }\n for (int i = 0; i < count; i++)\n {\n Write(array[i + index]);\n Write(space, 0, space.Length);\n }\n WriteLine();\n\n return this;\n }\n public Output WriteLine(object obj)\n {\n obj = FormatReal(obj);\n return WriteLine(obj.ToString());\n }\n public Output WriteLine(string format, params object[] args)\n {\n return WriteLine(string.Format(format, args));\n }\n public Output WriteLine(string s)\n {\n return WriteLine(s.ToCharArray());\n }\n public Output WriteLine(char[] buffer)\n {\n return WriteLine(buffer, 0, buffer.Length);\n }\n public Output WriteLine(char[] buffer, int index, int count)\n {\n TextWriter.WriteLine(buffer, index, count);\n if (AutoFlush) TextWriter.Flush();\n return this;\n }\n public Output WriteLine()\n {\n TextWriter.WriteLine();\n if (AutoFlush) TextWriter.Flush();\n return this;\n }\n public Output Write(object obj)\n {\n obj = FormatReal(obj);\n return Write(obj.ToString());\n }\n public Output Write(string format, params object[] args)\n {\n return Write(string.Format(format, args));\n }\n public Output Write(string s)\n {\n return Write(s.ToCharArray());\n }\n public Output Write(char[] buffer)\n {\n return Write(buffer, 0, buffer.Length);\n }\n public Output Write(char[] buffer, int index, int count)\n {\n TextWriter.Write(buffer, index, count);\n if (AutoFlush) TextWriter.Flush();\n return this;\n }\n\n public void Close()\n {\n TextWriter.Close();\n }\n public void Flush()\n {\n TextWriter.Flush();\n }\n\n\n private bool disposed = false;\n public void Dispose()\n {\n Dispose(true);\n GC.SuppressFinalize(this);\n }\n\n protected virtual void Dispose(bool disposing)\n {\n if (!this.disposed)\n {\n if (disposing)\n {\n TextWriter.Dispose();\n }\n disposed = true;\n }\n }\n ~Output()\n {\n Dispose(false);\n }\n }\n public static class Parser\n {\n public static ParserDelegate GetPrimitiveParser()\n {\n if (!typeof(T).IsPrimitive) throw new Exception(\"Unknown type\");\n else if (default(T) is Byte) return new ParserDelegate(Byte.TryParse) as ParserDelegate;\n else if (default(T) is Boolean) return new ParserDelegate(Boolean.TryParse) as ParserDelegate;\n else if (default(T) is Int16) return new ParserDelegate(Int16.TryParse) as ParserDelegate;\n else if (default(T) is Int32) return new ParserDelegate(Int32.TryParse) as ParserDelegate;\n else if (default(T) is Int64) return new ParserDelegate(Int64.TryParse) as ParserDelegate;\n else if (default(T) is UInt16) return new ParserDelegate(UInt16.TryParse) as ParserDelegate;\n else if (default(T) is UInt32) return new ParserDelegate(UInt32.TryParse) as ParserDelegate;\n else if (default(T) is UInt64) return new ParserDelegate(UInt64.TryParse) as ParserDelegate;\n else if (default(T) is Single) return new ParserDelegate(Parser.SingleParser) as ParserDelegate;\n else if (default(T) is Double) return new ParserDelegate(Parser.DoubleParser) as ParserDelegate;\n else if (default(T) is Decimal) return new ParserDelegate(Parser.DecimalParser) as ParserDelegate;\n else if (default(T) is String) return new ParserDelegate(Parser.StringParser) as ParserDelegate;\n else throw new Exception(\"Unknown type\");\n }\n public static bool YesNoParser(string s, out Boolean result)\n {\n s = s.ToLower();\n if (s == \"yes\") result = true;\n else if (s == \"no\") result = false;\n else\n {\n result = false;\n return false;\n }\n return true;\n }\n public static bool ReplaceDot;\n public static bool StringParser(string s, out string result)\n {\n result = s;\n return string.IsNullOrEmpty(s);\n }\n private static string fs(string s)\n {\n if (ReplaceDot) return s.Replace(',', '.');\n else return s;\n }\n public static bool DecimalParser(string s, out Decimal result)\n {\n return Decimal.TryParse(fs(s), out result);\n }\n public static bool DoubleParser(string s, out Double result)\n {\n return Double.TryParse(fs(s), out result);\n }\n public static bool SingleParser(string s, out Single result)\n {\n return Single.TryParse(fs(s), out result);\n }\n }\n #endregion\n #region Streams\n static string endl = Environment.NewLine;\n static Input cin = new Input(Console.In);\n static Output cout = new Output(Console.Out);\n static Output cerr = new Output(Console.Error);\n static StringBuilder sb = new StringBuilder();\n #endregion\n #region Time\n //*\n static Stopwatch sw = new Stopwatch();\n static void Start()\n {\n sw.Reset();\n sw.Start();\n }\n static void Restart(string text = \"\")\n {\n Stop(text);\n Start();\n }\n static void Time(string text = \"\")\n {\n if (string.IsNullOrEmpty(text))\n {\n cerr.WriteLine(sw.Elapsed);\n }\n else\n {\n cerr.WriteLine(text + \": \" + sw.Elapsed);\n }\n }\n static void Stop(string text = \"\")\n {\n sw.Stop();\n Time(text);\n }\n //*/\n #endregion\n\n static void InitIO(string name)\n {\n#if DEBUG\n#else\n cin = new Input(name + \".in\");\n cout = new Output(name + \".out\");\n Parser.ReplaceDot = false;\n#endif\n }\n\n static long[] fact =\n {\n 1, 1, 2, 6, 24,\n 120, 720, 5040, 40320, 362880,\n 3628800, 39916800, 479001600, 6227020800, 87178291200,\n 1307674368000, 20922789888000, 355687428096000, 6402373705728000, 121645100408832000\n };\n\n static Dictionary[] dm;\n static void Build(int[] a, int p, int k, int mk, long s)\n {\n if (p == a.Length)\n {\n for (var t = mk - k; t <= mk; t++)\n {\n if (!dm[t].ContainsKey(s))\n {\n dm[t][s] = 0;\n }\n dm[t][s]++;\n }\n return;\n }\n\n var x = a[p];\n if(x < 19 && k > 0)\n {\n Build(a, p + 1, k - 1, mk, s + fact[x]);\n }\n Build(a, p + 1, k, mk, s + x);\n Build(a, p + 1, k, mk, s);\n }\n static long Search(int[] a, int p, int to, int k, long s)\n {\n if (s < 0) return 0;\n if(p == to)\n {\n long r;\n dm[k].TryGetValue(s, out r);\n return r;\n }\n\n long res = 0;\n if(a[p] < 19 && k > 0)\n {\n res += Search(a, p + 1, to, k - 1, s - fact[a[p]]);\n }\n res += Search(a, p + 1, to, k, s);\n res += Search(a, p + 1, to, k, s - a[p]);\n\n return res;\n }\n\n static void Main()\n {\n var n = cin.ReadInt32();\n var k = cin.ReadInt32();\n var s = cin.ReadInt64();\n\n var a = cin.ReadArray(n);\n\n dm = new Dictionary[k + 1];\n for(var i = 0; i <= k; i++)\n {\n dm[i] = new Dictionary();\n }\n\n var p = n - n / 2;\n Build(a, p, k, k, 0);\n\n var ans = Search(a, 0, p, k, s);\n cout += ans + endl;\n }\n}", "lang_cluster": "C#", "tags": ["brute force", "math", "dp", "binary search", "bitmasks", "meet-in-the-middle"], "code_uid": "68266d7314777b0569f2ce582d973c1e", "src_uid": "2821a11066dffc7e8f6a60a8751cea37", "difficulty": 2100.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections;\nusing System.Collections.Generic;\nusing System.Collections.Specialized;\nusing System.Diagnostics;\nusing System.IO;\nusing System.Text;\nusing System.Linq;\n\nnamespace Codeforces\n{\n internal class Program\n {\n private const string Test = \"C2\";\n\n\n private static void Solve()\n {\n var s = Read();\n var t = Read();\n var n = s.Length;\n var m = t.Length;\n long res = 0L;\n int MOD = 1000000007;\n var dp = new int[n + 1, m + 1];\n for (int i = 0; i < n; i++)\n {\n for (int j = 0; j < m; j++)\n {\n dp[i + 1, j + 1] = dp[i + 1, j];\n if (s[i] == t[j])\n dp[i + 1, j + 1] += dp[i, j] + 1;\n dp[i + 1, j + 1] %= MOD;\n }\n }\n for (int i = 0; i < n + 1; i++)\n {\n res += dp[i, m];\n res %= MOD;\n }\n Console.WriteLine(res);\n }\n\n\n private static void Main()\n {\n if (Debugger.IsAttached)\n {\n Console.SetIn(new StreamReader(String.Format(@\"..\\..\\..\\..\\Tests\\{0}.in\", Test)));\n }\n\n Solve();\n\n if (Debugger.IsAttached)\n {\n Console.In.Close();\n Console.SetIn(new StreamReader(Console.OpenStandardInput()));\n Console.ReadLine();\n }\n }\n\n #region Reader\n\n private static string Read()\n {\n return Console.ReadLine();\n }\n\n private static string[] ReadArray()\n {\n return Console.ReadLine().Split(' ');\n }\n\n private static List ReadIntArray()\n {\n var input = Console.ReadLine().Split(' ').Select(Int32.Parse).ToList();\n return input;\n }\n\n private static int ReadInt()\n {\n return Int32.Parse(Console.ReadLine());\n }\n\n private static long ReadLong()\n {\n return long.Parse(Console.ReadLine());\n }\n\n private static int ReadNextInt(string[] input, int index)\n {\n return Int32.Parse(input[index]);\n }\n\n #endregion\n }\n}", "lang_cluster": "C#", "tags": ["dp"], "code_uid": "a0282723e37b17c331c315361fcb93d9", "src_uid": "4022f8f796d4f2b7e43a8360bf34e35f", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Globalization;\nusing System.Linq;\nusing System.Text;\nusing System.Text.RegularExpressions;\nusing System.Threading;\n\nnamespace Codeforces\n{\n class E\n {\n private static ThreadStart s_threadStart = new E().Go;\n\n class Point\n {\n public int X, Y;\n public bool Keep;\n }\n\n long[] F;\n\n private void Go()\n {\n long mod = 1000000007;\n\n int n = GetInt();\n Point[] points = new Point[n];\n for (int i = 0; i < n; i++)\n {\n points[i] = new Point() { X = GetInt(), Y = GetInt() };\n }\n\n F = new long[2*n + 1];\n F[0] = 1;\n for (int i = 1; i <= 2 * n; i++)\n F[i] = (F[i - 1] * i) % mod;\n\n Dictionary> xDict = new Dictionary>();\n Dictionary> yDict = new Dictionary>();\n for(int i = 0; i < n; i++)\n {\n List list;\n if (!xDict.TryGetValue(points[i].X, out list))\n list = xDict[points[i].X] = new List();\n\n list.Add(i);\n\n if (!yDict.TryGetValue(points[i].Y, out list))\n list = yDict[points[i].Y] = new List();\n\n list.Add(i);\n }\n\n long ans = 1;\n\n Queue queue = new Queue();\n while (xDict.Count > 0)\n {\n int k = 0;\n int m = 0;\n var pair = xDict.First();\n queue.Enqueue(pair.Value[0]);\n\n HashSet xDir = new HashSet();\n HashSet yDir = new HashSet();\n HashSet pSet = new HashSet();\n\n while (queue.Count > 0)\n {\n int pp = queue.Dequeue();\n Point point = points[pp];\n pSet.Add(pp);\n xDir.Add(point.X);\n yDir.Add(point.Y);\n if (xDict.ContainsKey(point.X))\n {\n foreach (int z in xDict[point.X])\n if (z != pp)\n queue.Enqueue(z);\n }\n if (yDict.ContainsKey(point.Y))\n {\n foreach (int z in yDict[point.Y])\n if (z != pp)\n queue.Enqueue(z);\n }\n xDict.Remove(point.X);\n yDict.Remove(point.Y);\n }\n\n ans *= Bin(xDir.Count() + yDir.Count(), pSet.Count(), mod);\n ans %= mod;\n }\n\n Wl(ans);\n }\n\n long Bin(long n, long k, long mod)\n {\n if (n < k)\n k = n;\n\n long ans = 0;\n for (int i = 0; i <= k; i++)\n {\n long add = F[n];\n add *= Inv(F[i], mod);\n add %= mod;\n add *= Inv(F[n - i], mod);\n add %= mod;\n ans += add;\n ans %= mod;\n }\n return ans;\n }\n\n public static long Pow(long a, long n, long mod)\n {\n long res = 1L;\n while (n > 0)\n {\n if ((n & 1) != 0)\n res = (res * a) % mod;\n a = (a * a) % mod;\n n >>= 1;\n }\n return res;\n }\n\n public static long Inv(long a, long mod)\n {\n return Pow(a, mod - 2, mod);\n }\n\n #region Template\n\n private static StringBuilder output = new StringBuilder();\n\n public static void Main(string[] args)\n {\n System.Diagnostics.Stopwatch timer = new System.Diagnostics.Stopwatch();\n output.Length = 0;\n Thread main = new Thread(new ThreadStart(s_threadStart), 512 * 1024 * 1024);\n timer.Start();\n main.Start();\n main.Join();\n Console.Write(output);\n timer.Stop();\n Console.Error.WriteLine(timer.ElapsedMilliseconds);\n }\n\n private static IEnumerator ioEnum;\n private static string GetString()\n {\n do\n {\n while (ioEnum == null || !ioEnum.MoveNext())\n {\n ioEnum = Console.ReadLine().Split().AsEnumerable().GetEnumerator();\n }\n } while (string.IsNullOrEmpty(ioEnum.Current));\n\n return ioEnum.Current;\n }\n\n\n private static int GetInt()\n {\n return int.Parse(GetString());\n }\n\n private static long GetLong()\n {\n return long.Parse(GetString());\n }\n\n private static double GetDouble()\n {\n return double.Parse(GetString());\n }\n\n private static List GetIntArr(int n)\n {\n List ret = new List(n);\n for (int i = 0; i < n; i++)\n {\n ret.Add(GetInt());\n }\n return ret;\n }\n\n private static void Wl(T o)\n {\n W(o);\n output.Append(Console.Out.NewLine);\n }\n\n private static void Wl(IEnumerable enumerable)\n {\n W(enumerable);\n output.Append(Console.Out.NewLine);\n }\n\n private static void W(T o)\n {\n if (o is double)\n {\n Wd((o as double?).Value, \"\");\n }\n else if (o is float)\n {\n Wd((o as float?).Value, \"\");\n }\n else\n output.Append(o.ToString());\n }\n\n private static void W(IEnumerable enumerable)\n {\n W(string.Join(\" \", enumerable.Select(e => e.ToString()).ToArray()));\n }\n\n private static void Wd(double d, string format)\n {\n W(d.ToString(format, CultureInfo.InvariantCulture));\n }\n\n #endregion\n }\n}", "lang_cluster": "C#", "tags": ["graphs"], "code_uid": "0e30ff728c23f2c6b175f032517eb868", "src_uid": "8781003d9eea51a509145bc6db8b609c", "difficulty": 2300.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.IO;\nusing System.Text;\n\nnamespace The_Wall__medium_\n{\n internal class Program\n {\n private const int mod = 1000003;\n private static readonly StreamReader reader = new StreamReader(Console.OpenStandardInput(1024*10), Encoding.ASCII, false, 1024*10);\n private static readonly StreamWriter writer = new StreamWriter(Console.OpenStandardOutput(1024*10), Encoding.ASCII, 1024*10);\n\n private static long[] fact;\n private static long[] fact1;\n\n private static void Main(string[] args)\n {\n int n = Next();\n int c = Next();\n\n InitFact(n + c + 1);\n long ans = (GetCFact(n + c, c) - 1 + mod)%mod;\n\n writer.WriteLine(ans);\n writer.Flush();\n }\n\n private static void InitFact(int n)\n {\n fact = new long[n];\n fact1 = new long[n];\n\n fact[0] = 1;\n\n for (int i = 1; i < fact.Length; i++)\n {\n fact[i] = (fact[i - 1]*i)%mod;\n }\n fact1[n - 1] = Pow(fact[n - 1], mod - 2);\n for (int i = fact1.Length - 2; i >= 0; i--)\n {\n fact1[i] = (fact1[i + 1]*(i + 1))%mod;\n }\n }\n\n private static long Pow(long a, int k)\n {\n long r = 1;\n while (k > 0)\n {\n if ((k & 1) == 1)\n {\n r = (r*a)%mod;\n }\n a = (a*a)%mod;\n k >>= 1;\n }\n return r;\n }\n\n\n private static long GetCFact(int n, int k)\n {\n return (((fact[n]*fact1[k])%mod)*fact1[n - k])%mod;\n }\n\n private static int Next()\n {\n int c;\n int res = 0;\n do\n {\n c = reader.Read();\n if (c == -1)\n return res;\n } while (c < '0' || c > '9');\n res = c - '0';\n while (true)\n {\n c = reader.Read();\n if (c < '0' || c > '9')\n return res;\n res *= 10;\n res += c - '0';\n }\n }\n }\n}", "lang_cluster": "C#", "tags": ["combinatorics"], "code_uid": "b06671f242c9ed6c987073200fd2ffab", "src_uid": "e63c70a9c96a94bce99618f2e695f83a", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Globalization;\nusing System.IO;\nusing System.Linq;\nusing System.Text;\nusing System.Threading;\n\n// (\u3065\u00b0\u03c9\u00b0)\u3065\uff90e\u2605\u309c\u30fb\u3002\u3002\u30fb\u309c\u309c\u30fb\u3002\u3002\u30fb\u309c\u2606\u309c\u30fb\u3002\u3002\u30fb\u309c\u309c\u30fb\u3002\u3002\u30fb\u309c\npublic class Solver\n{\n const int MOD = 1000003;\n\n long[] f, rf, inv;\n void InitFacts(int size)\n {\n f = new long[size + 1];\n rf = new long[size + 1];\n inv = new long[size + 1];\n f[0] = f[1] = rf[0] = rf[1] = inv[1] = 1;\n for (int i = 2; i <= size; i++)\n {\n f[i] = f[i - 1] * i % MOD;\n inv[i] = inv[MOD % i] * (MOD - MOD / i) % MOD;\n rf[i] = inv[i] * rf[i - 1] % MOD;\n }\n }\n\n public void Solve()\n {\n int n = ReadInt();\n int m = ReadInt();\n\n InitFacts(n + m + 1);\n\n long ans = 0;\n for (int i = 1; i <= n; i++)\n ans += f[i + m - 1] * rf[m - 1] % MOD * rf[i] % MOD;\n\n Write(ans % MOD);\n }\n\n #region Main\n\n protected static TextReader reader;\n protected static TextWriter writer;\n static void Main()\n {\n#if DEBUG\n reader = new StreamReader(\"..\\\\..\\\\input.txt\");\n //reader = new StreamReader(Console.OpenStandardInput());\n writer = Console.Out;\n //writer = new StreamWriter(\"..\\\\..\\\\output.txt\");\n#else\n reader = new StreamReader(Console.OpenStandardInput());\n writer = new StreamWriter(Console.OpenStandardOutput(),Encoding.ASCII);\n //reader = new StreamReader(\"input.txt\");\n //writer = new StreamWriter(\"output.txt\");\n#endif\n try\n {\n new Solver().Solve();\n //var thread = new Thread(new Solver().Solve, 1024 * 1024 * 128);\n //thread.Start();\n //thread.Join();\n }\n catch (Exception ex)\n {\n#if DEBUG\n Console.WriteLine(ex);\n#else\n throw;\n#endif\n }\n reader.Close();\n writer.Close();\n }\n\n #endregion\n\n #region Read / Write\n private static Queue currentLineTokens = new Queue();\n private static string[] ReadAndSplitLine() { return reader.ReadLine().Split(new[] { ' ', '\\t', }, StringSplitOptions.RemoveEmptyEntries); }\n public static string ReadToken() { while (currentLineTokens.Count == 0)currentLineTokens = new Queue(ReadAndSplitLine()); return currentLineTokens.Dequeue(); }\n public static int ReadInt() { return int.Parse(ReadToken()); }\n public static long ReadLong() { return long.Parse(ReadToken()); }\n public static double ReadDouble() { return double.Parse(ReadToken(), CultureInfo.InvariantCulture); }\n public static int[] ReadIntArray() { return ReadAndSplitLine().Select(int.Parse).ToArray(); }\n public static long[] ReadLongArray() { return ReadAndSplitLine().Select(long.Parse).ToArray(); }\n public static double[] ReadDoubleArray() { return ReadAndSplitLine().Select(s => double.Parse(s, CultureInfo.InvariantCulture)).ToArray(); }\n public static int[][] ReadIntMatrix(int numberOfRows) { int[][] matrix = new int[numberOfRows][]; for (int i = 0; i < numberOfRows; i++)matrix[i] = ReadIntArray(); return matrix; }\n public static int[][] ReadAndTransposeIntMatrix(int numberOfRows)\n {\n int[][] matrix = ReadIntMatrix(numberOfRows); int[][] ret = new int[matrix[0].Length][];\n for (int i = 0; i < ret.Length; i++) { ret[i] = new int[numberOfRows]; for (int j = 0; j < numberOfRows; j++)ret[i][j] = matrix[j][i]; } return ret;\n }\n public static string[] ReadLines(int quantity) { string[] lines = new string[quantity]; for (int i = 0; i < quantity; i++)lines[i] = reader.ReadLine().Trim(); return lines; }\n public static void WriteArray(IEnumerable array) { writer.WriteLine(string.Join(\" \", array)); }\n public static void Write(params object[] array) { WriteArray(array); }\n public static void WriteLines(IEnumerable array) { foreach (var a in array)writer.WriteLine(a); }\n private class SDictionary : Dictionary\n {\n public new TValue this[TKey key]\n {\n get { return ContainsKey(key) ? base[key] : default(TValue); }\n set { base[key] = value; }\n }\n }\n private static T[] Init(int size) where T : new() { var ret = new T[size]; for (int i = 0; i < size; i++)ret[i] = new T(); return ret; }\n #endregion\n}", "lang_cluster": "C#", "tags": ["combinatorics"], "code_uid": "d120593702ee244f0a83c1e3a7f822b0", "src_uid": "e63c70a9c96a94bce99618f2e695f83a", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Diagnostics;\nusing System.Runtime.InteropServices;\nusing System.Text;\nusing System.Linq;\nusing System.IO;\nusing System.Globalization;\nusing System.Collections;\n\nnamespace Task\n{\n\n #region MyIo\n\n internal class MyIo : IDisposable\n {\n private readonly TextReader inputStream;\n private readonly TextWriter outputStream = Console.Out;\n\n private string[] tokens;\n private int pointer;\n\n public MyIo()\n#if LOCAL_TEST\n : this(new StreamReader(\"input.txt\"))\n#else\n : this(System.Console.In)\n#endif\n {\n\n }\n\n public MyIo(TextReader inputStream)\n {\n this.inputStream = inputStream;\n }\n\n\n public char NextChar()\n {\n try\n {\n return (char)inputStream.Read();\n }\n catch (IOException)\n {\n return '\\0';\n }\n }\n\n public string NextLine()\n {\n try\n {\n return inputStream.ReadLine();\n }\n catch (IOException)\n {\n return null;\n }\n }\n\n public string NextString()\n {\n try\n {\n while (tokens == null || pointer >= tokens.Length)\n {\n tokens = (NextLine() + string.Empty).Split(new[] { ' ', '\\t' }, StringSplitOptions.RemoveEmptyEntries);\n pointer = 0;\n }\n return tokens[pointer++];\n }\n catch (IOException)\n {\n return null;\n }\n }\n\n public int NextInt()\n {\n return Next();\n }\n\n public long NextLong()\n {\n return Next();\n }\n\n public T Next()\n {\n var t = typeof(T);\n\n if (t == typeof(char))\n return (T)(object)NextChar();\n\n object s = NextString();\n\n if (t == typeof(string))\n return (T)s;\n\n return (T)Convert.ChangeType(s, typeof(T));\n }\n\n\n public IEnumerable NextWhile(Predicate pred)\n {\n if (pred == null)\n yield break;\n\n T res = Next();\n\n while (pred(res))\n {\n yield return res;\n\n res = Next();\n }\n }\n\n public IEnumerable NextSeq(long n)\n {\n for (var i = 0; i < n; i++)\n yield return Next();\n }\n\n public void Print(string format, params object[] args)\n {\n outputStream.Write(string.Format(CultureInfo.InvariantCulture, format, args));\n }\n\n public void PrintLine(string format, params object[] args)\n {\n Print(format, args);\n\n outputStream.WriteLine();\n }\n\n public void Print(bool o)\n {\n Print(o ? \"YES\" : \"NO\");\n }\n\n public void PrintLine(bool o)\n {\n PrintLine(o ? \"YES\" : \"NO\");\n }\n\n public void Print(T o)\n {\n outputStream.Write(Convert.ToString(o, CultureInfo.InvariantCulture));\n }\n\n\n public void PrintLine(T o)\n {\n Print(o);\n\n outputStream.WriteLine();\n }\n\n public void Close()\n {\n inputStream.Close();\n outputStream.Close();\n }\n\n void IDisposable.Dispose()\n {\n Close();\n\n#if LOCAL_TEST\n Console.ReadLine();\n#endif\n }\n }\n\n\n public static class ListExtensions\n {\n\n public static IEnumerable ToCycleEnumerable(this IEnumerable self)\n {\n if (self != null)\n {\n for (; ; )\n {\n foreach (var x in self)\n yield return x;\n }\n }\n }\n\n public static T CycleGet(this IList self, int index)\n {\n var c = self.Count;\n return self[(index % c + c) % c];\n }\n\n\n public static IList Shuffle(this IList self)\n {\n var rnd = new Random(DateTime.Now.Millisecond);\n\n var n = self.Count;\n\n while (n > 1)\n {\n n--;\n var k = rnd.Next(n + 1);\n var value = self[k];\n self[k] = self[n];\n self[n] = value;\n }\n\n return self;\n }\n\n public static IList> UseForNew2D(this T def, int fd, int sd)\n {\n var fdim = new T[fd][];\n\n for (int i = 0; i < fd; i++)\n {\n fdim[i] = new T[sd];\n Fill(fdim[i], def);\n }\n\n return fdim;\n }\n\n public static IList Fill(this IList self, Func fval)\n {\n for (var i = 0; i < self.Count; i++)\n self[i] = fval();\n\n\n return self;\n }\n\n\n public static IList Fill(this IList self, T val)\n {\n return self.Fill(() => val);\n }\n\n public static long Hash(this IList self, Func val = null)\n {\n return val != null ? self.Hash((t, current) => unchecked(current * 19L + val(t))) : self.Hash(HashOne);\n }\n\n public static long Hash(this IList self, Func val)\n {\n return self.Aggregate(0L, (current, t) => unchecked(val(t, current)));\n }\n\n\n public static long HashOne(this T self, long current)\n {\n return unchecked(current * 19L + (Equals(self, default(T)) ? 0 : self.GetHashCode()));\n }\n\n }\n\n public static class P\n {\n public static P Create(T1 key, T2 val)\n {\n return new P(key, val);\n }\n }\n\n public class P\n {\n private class PComparer : IComparer>\n {\n private readonly bool? byKey;\n\n public PComparer(bool? byKey)\n {\n this.byKey = byKey;\n }\n\n\n public int Compare(P x, P y)\n {\n x = x ?? new P();\n y = y ?? new P();\n\n\n if (byKey == true)\n return Comparer.Default.Compare(x.Key, y.Key);\n else if (byKey == false)\n return Comparer.Default.Compare(x.Value, y.Value);\n else\n {\n var tr = Comparer.Default.Compare(x.Key, y.Key);\n\n if (tr != 0)\n tr = Comparer.Default.Compare(x.Value, y.Value);\n\n return tr;\n }\n }\n }\n\n\n public P()\n {\n }\n\n public P(T1 key, T2 val)\n {\n this.Key = key;\n this.Value = val;\n }\n\n\n public T1 Key\n {\n get;\n set;\n }\n\n public T2 Value\n {\n get;\n set;\n }\n\n public P Clone()\n {\n return new P(Key, Value);\n }\n\n public static IComparer> KeyComparer\n {\n get { return new PComparer(true); }\n }\n\n public static IComparer> ValueComparer\n {\n get { return new PComparer(false); }\n }\n\n public static implicit operator T1(P obj)\n {\n return obj.Key;\n }\n\n public static implicit operator T2(P obj)\n {\n return obj.Value;\n }\n\n public P SetKey(T1 key)\n {\n Key = key;\n return this;\n }\n\n public P SetValue(T2 value)\n {\n Value = value;\n return this;\n }\n\n public override string ToString()\n {\n return string.Format(\"Key: {0}, Value: {1}\", Key, Value);\n }\n\n public override bool Equals(object obj)\n {\n var co = obj as P;\n\n return co != null && co.GetHashCode() == GetHashCode();\n }\n\n public override int GetHashCode()\n {\n int hash = 17;\n hash = hash * 31 + ((Equals(Key, default(T1))) ? 0 : Key.GetHashCode());\n hash = hash * 31 + ((Equals(Value, default(T1))) ? 0 : Value.GetHashCode());\n return hash;\n\n }\n }\n\n #endregion\n\n\n internal class Program\n {\n #region Program\n\n private readonly MyIo io;\n\n public Program(MyIo io)\n {\n this.io = io;\n }\n\n public static void Main(string[] args)\n {\n using (MyIo io = new MyIo())\n {\n new Program(io)\n .Solve();\n }\n }\n\n\n\n #endregion\n public const long MOD = 1000000007;\n public const double EPS = 1e-14;\n\n private void Solve()\n {\n var n = io.NextInt();\n var m = io.NextInt();\n\n var x = io.NextInt();\n var y = io.NextInt();\n x = Math.Abs(x - io.NextInt());\n y = Math.Abs(y - io.NextInt());\n\n\n var res = (x > 4 || y > 4) || (x + y > 6);\n\n io.PrintLine(res ? \"Second\" : \"First\");\n }\n }\n\n}\n\n", "lang_cluster": "C#", "tags": ["games"], "code_uid": "aeb347bce39739f829efb0e59356ce5d", "src_uid": "41f6f90b7307d2383495441114fa8ea2", "difficulty": 2000.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\nusing System;\nusing System.Collections.Generic;\nusing System.IO;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace AlgoTraining.Codeforces.C_s\n{\n public class FastScanner : StreamReader\n {\n private string[] _line;\n private int _iterator;\n\n public FastScanner(Stream stream) : base(stream)\n {\n _line = null;\n _iterator = 0;\n }\n public string NextToken()\n {\n if (_line == null || _iterator >= _line.Length)\n {\n _line = base.ReadLine().Split(' ');\n _iterator = 0;\n }\n if (_line.Count() == 0) throw new IndexOutOfRangeException(\"Input string is empty\");\n return _line[_iterator++];\n }\n public int NextInt()\n {\n return Convert.ToInt32(NextToken());\n }\n public long NextLong()\n {\n return Convert.ToInt64(NextToken());\n }\n public float NextFloat()\n {\n return float.Parse(NextToken());\n }\n public double NextDouble()\n {\n return Convert.ToDouble(NextToken());\n }\n }\n class PlayingWithSuperglueCroc\n {\n public static void Main(string[] args)\n {\n using (FastScanner fs = new FastScanner(new BufferedStream(Console.OpenStandardInput())))\n using (StreamWriter writer = new StreamWriter(new BufferedStream(Console.OpenStandardOutput())))\n {\n int n = fs.NextInt(), m = fs.NextInt();\n int x1 = fs.NextInt(), y1 = fs.NextInt();\n int x2 = fs.NextInt(), y2 = fs.NextInt();\n int w = Math.Abs(x1 - x2) + 1, h = Math.Abs(y1 - y2) + 1;\n if ((w == 5 && h == 5) || (w >= 6 || h >= 6) || (w == 4 && h == 5) || (w == 5 && h == 4)) writer.WriteLine(\"Second\");\n else writer.WriteLine(\"First\");\n }\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["constructive algorithms", "combinatorics"], "code_uid": "84608f2553bb1f72df08e812c9b1406c", "src_uid": "41f6f90b7307d2383495441114fa8ea2", "difficulty": 2000.0, "exec_outcome": "PASSED"} {"lang": ".NET Core C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.IO;\nusing System.Threading;\nusing System.Runtime.CompilerServices;\nusing System.Text;\nusing System.Diagnostics;\nusing System.Numerics;\nusing static System.Console;\nusing static System.Convert;\nusing static System.Math;\nusing static Template;\nusing SC = Scanner;\n\npublic partial class Solver\n{\n int N, X;\n string S;\n public void Solve()\n {\n sc.Make(out N, out X);\n S = sc.Str;\n if (X <= 1) Fail(ToInt32(S.Length==1&&S[0] - '0' == X));\n //dp[k][i][j]:=F(k)\u306e\u90e8\u5206\u5217\u306b\u542b\u307e\u308c\u308bS[j,i)\u306e\u6570\u306e\u548c\n var cur = Create(N + 1, () => new ModInt[N + 1]);\n var nxt = Create(N + 1, () => new ModInt[N + 1]);\n for (int i = 0; i < N; i++)\n {\n cur[i][i] = nxt[i][i] = 1;\n if (S[i] - '0' == 0) nxt[i + 1][i] = 1;\n else cur[i + 1][i] = 1;\n }\n //\u7aef\u306f\u3068\u3063\u3066\u3082\u53d6\u3089\u306a\u304f\u3066\u3082\u3044\u3044\u306e\u30672\n cur[0][0] = cur[N][N] = nxt[0][0] = nxt[N][N] = 2;\n for (int i = 0; i < X - 1; i++)\n {\n nxt = matmul(nxt, cur);\n swap(ref cur, ref nxt);\n }\n Console.WriteLine(cur[N][0]);\n }\n\n ModInt[][] matpow(ModInt[][] A, long k)\n {\n var res = Create(A.Length, () => new ModInt[A.Length]);\n for (int i = 0; i < A.Length; i++) res[i][i] = 1;\n while (k != 0)\n {\n if (k % 2 == 1) res = matmul(res, A);\n k >>= 1;\n A = matmul(A, A);\n }\n return res;\n }\n ModInt[][] matmul(ModInt[][] A, ModInt[][] B)\n {\n var rt = Create(A.Length, () => new ModInt[B[0].Length]);\n for (int i = 0; i < A.Length; i++)\n for (int j = 0; j < B[0].Length; j++)\n {\n for (int k = 0; k < B.Length; k++)\n rt[i][j] += A[i][k] * B[k][j];\n }\n return rt;\n }\n ModInt[] matdot(ModInt[][] A, ModInt[] B)\n {\n var rt = new ModInt[A.Length];\n for (int i = 0; i < A.Length; i++)\n {\n ModInt now = 0;\n for (int j = 0; j < B.Length; j++)\n {\n now += A[i][j] * B[j];\n }\n rt[i] = now;\n }\n return rt;\n }\n}\n\npublic struct ModInt\n{\n public const long MOD = (int)1e9 + 7;\n //public const long MOD = 998244353;\n public long Value { get; set; }\n public ModInt(long n = 0) { Value = n; }\n private static ModInt[] fac, inv, facinv;\n public override string ToString() => Value.ToString();\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static ModInt operator +(ModInt l, ModInt r)\n {\n l.Value += r.Value;\n if (l.Value >= MOD) l.Value -= MOD;\n return l;\n }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static ModInt operator -(ModInt l, ModInt r)\n {\n l.Value -= r.Value;\n if (l.Value < 0) l.Value += MOD;\n return l;\n }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static ModInt operator *(ModInt l, ModInt r) => new ModInt(l.Value * r.Value % MOD);\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static ModInt operator /(ModInt l, ModInt r) => l * Pow(r, MOD - 2);\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static implicit operator long(ModInt l) => l.Value;\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static implicit operator ModInt(long n)\n {\n n %= MOD; if (n < 0) n += MOD;\n return new ModInt(n);\n }\n\n public static ModInt Pow(ModInt m, long n)\n {\n if (n == 0) return 1;\n if (n % 2 == 0) return Pow(m * m, n >> 1);\n else return Pow(m * m, n >> 1) * m;\n }\n\n public static void Build(int n)\n {\n fac = new ModInt[n + 1];\n facinv = new ModInt[n + 1];\n inv = new ModInt[n + 1];\n inv[1] = fac[0] = fac[1] = facinv[0] = facinv[1] = 1;\n for (var i = 2; i <= n; i++)\n {\n fac[i] = fac[i - 1] * i;\n inv[i] = MOD - inv[MOD % i] * (MOD / i);\n facinv[i] = facinv[i - 1] * inv[i];\n }\n }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static ModInt Fac(int n) => fac[n];\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static ModInt Inv(int n) => inv[n];\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static ModInt FacInv(int n) => facinv[n];\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static ModInt Comb(int n, int r)\n {\n if (n < r) return 0;\n if (n == r) return 1;\n return fac[n] * facinv[r] * facinv[n - r];\n }\n public static ModInt Perm(int n, int r)\n {\n if (n < r) return 0;\n return fac[n] * facinv[n - r];\n }\n\n}\n#region Template\npublic partial class Solver\n{\n public SC sc = new SC();\n static void Main(string[] args)\n {\n Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });\n var sol = new Solver();\n int testcase = 1;\n //testcase = sol.sc.Int;\n //var th = new Thread(sol.Solve, 1 << 26);th.Start();th.Join();\n while (testcase-- > 0)\n sol.Solve();\n Console.Out.Flush();\n }\n}\npublic static class Template\n{\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static bool chmin(ref T a, T b) where T : IComparable { if (a.CompareTo(b) > 0) { a = b; return true; } return false; }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static bool chmax(ref T a, T b) where T : IComparable { if (a.CompareTo(b) < 0) { a = b; return true; } return false; }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static void swap(ref T a, ref T b) { var t = b; b = a; a = t; }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static void swap(this IList A, int i, int j) { var t = A[i]; A[i] = A[j]; A[j] = t; }\n public static T[] Create(int n, Func f) { var rt = new T[n]; for (var i = 0; i < rt.Length; ++i) rt[i] = f(); return rt; }\n public static T[] Create(int n, Func f) { var rt = new T[n]; for (var i = 0; i < rt.Length; ++i) rt[i] = f(i); return rt; }\n public static void Out(this IList A, out T a) => a = A[0];\n public static void Out(this IList A, out T a, out T b) { a = A[0]; b = A[1]; }\n public static void Out(this IList A, out T a, out T b, out T c) { A.Out(out a, out b); c = A[2]; }\n public static void Out(this IList A, out T a, out T b, out T c, out T d) { A.Out(out a, out b, out c); d = A[3]; }\n public static string Concat(this IEnumerable A, string sp) => string.Join(sp, A);\n public static char ToChar(this int s, char begin = '0') => (char)(s + begin);\n public static IEnumerable Shuffle(this IEnumerable A) => A.OrderBy(v => Guid.NewGuid());\n public static int CompareTo(this T[] A, T[] B, Comparison cmp = null) { cmp = cmp ?? Comparer.Default.Compare; for (var i = 0; i < Min(A.Length, B.Length); i++) { int c = cmp(A[i], B[i]); if (c > 0) return 1; else if (c < 0) return -1; } if (A.Length == B.Length) return 0; if (A.Length > B.Length) return 1; else return -1; }\n public static string ToStr(this T[][] A) => A.Select(a => a.Concat(\" \")).Concat(\"\\n\");\n public static int ArgMax(this IList A, Comparison cmp = null) { cmp = cmp ?? Comparer.Default.Compare; T max = A[0]; int rt = 0; for (int i = 1; i < A.Count; i++) if (cmp(max, A[i]) < 0) { max = A[i]; rt = i; } return rt; }\n public static T PopBack(this List A) { var v = A[A.Count - 1]; A.RemoveAt(A.Count - 1); return v; }\n public static void Fail(T s) { Console.WriteLine(s); Console.Out.Close(); Environment.Exit(0); }\n}\npublic class Scanner\n{\n public string Str => Console.ReadLine().Trim();\n public int Int => int.Parse(Str);\n public long Long => long.Parse(Str);\n public double Double => double.Parse(Str);\n public int[] ArrInt => Str.Split(' ').Select(int.Parse).ToArray();\n public long[] ArrLong => Str.Split(' ').Select(long.Parse).ToArray();\n public char[][] Grid(int n) => Create(n, () => Str.ToCharArray());\n public int[] ArrInt1D(int n) => Create(n, () => Int);\n public long[] ArrLong1D(int n) => Create(n, () => Long);\n public int[][] ArrInt2D(int n) => Create(n, () => ArrInt);\n public long[][] ArrLong2D(int n) => Create(n, () => ArrLong);\n private Queue q = new Queue();\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public T Next() { if (q.Count == 0) foreach (var item in Str.Split(' ')) q.Enqueue(item); return (T)Convert.ChangeType(q.Dequeue(), typeof(T)); }\n public void Make(out T1 v1) => v1 = Next();\n public void Make(out T1 v1, out T2 v2) { v1 = Next(); v2 = Next(); }\n public void Make(out T1 v1, out T2 v2, out T3 v3) { Make(out v1, out v2); v3 = Next(); }\n public void Make(out T1 v1, out T2 v2, out T3 v3, out T4 v4) { Make(out v1, out v2, out v3); v4 = Next(); }\n public void Make(out T1 v1, out T2 v2, out T3 v3, out T4 v4, out T5 v5) { Make(out v1, out v2, out v3, out v4); v5 = Next(); }\n public void Make(out T1 v1, out T2 v2, out T3 v3, out T4 v4, out T5 v5, out T6 v6) { Make(out v1, out v2, out v3, out v4, out v5); v6 = Next(); }\n public void Make(out T1 v1, out T2 v2, out T3 v3, out T4 v4, out T5 v5, out T6 v6, out T7 v7) { Make(out v1, out v2, out v3, out v4, out v5, out v6); v7 = Next(); }\n public (T1, T2) Make() { Make(out T1 v1, out T2 v2); return (v1, v2); }\n public (T1, T2, T3) Make() { Make(out T1 v1, out T2 v2, out T3 v3); return (v1, v2, v3); }\n public (T1, T2, T3, T4) Make() { Make(out T1 v1, out T2 v2, out T3 v3, out T4 v4); return (v1, v2, v3, v4); }\n}\n\n#endregion", "lang_cluster": "C#", "tags": ["matrices", "dp", "combinatorics"], "code_uid": "42ab18b2c9a8b4cb9ccbde4c4f1328ac", "src_uid": "52c6aa73ff4460799402c646c6263630", "difficulty": 2400.0, "exec_outcome": "PASSED"} {"lang": "C# 8", "source_code": "\ufeffusing System;\r\nusing System.Collections.Generic;\r\nusing System.Globalization;\r\nusing System.IO;\r\nusing System.Linq;\r\nusing System.Text;\r\nusing System.Threading;\r\n\r\npublic class Solution\r\n{\r\n int mod;\r\n\r\n long Fun(int n)\r\n {\r\n var dp = new long[n + 1];\r\n dp[1] = 1;\r\n long sum = 1;\r\n var pdp = new long[n + 1];\r\n for (int i = 1; i <= n; i++)\r\n {\r\n pdp[i] = (pdp[i] + pdp[i - 1]) % mod;\r\n dp[i] = (sum + pdp[i]) % mod;\r\n \r\n for (int j = i * 2, k = 2; j <= n; j += i, k++)\r\n {\r\n pdp[j] = (pdp[j] + dp[i]) % mod;\r\n if (j + k <= n)\r\n pdp[j + k] = (pdp[j + k] + mod - dp[i]) % mod;\r\n }\r\n\r\n if (i > 1)\r\n sum = (sum + dp[i]) % mod;\r\n }\r\n return dp[n];\r\n }\r\n\r\n public void Solve()\r\n {\r\n int n = ReadInt();\r\n mod = ReadInt();\r\n Write(Fun(n));\r\n }\r\n\r\n #region Main\r\n\r\n protected static TextReader reader;\r\n protected static TextWriter writer;\r\n static void Main()\r\n {\r\n#if DEBUGLOCAL\r\n reader = new StreamReader(\"..\\\\..\\\\..\\\\input.txt\");\r\n //reader = new StreamReader(Console.OpenStandardInput());\r\n writer = Console.Out;\r\n //writer = new StreamWriter(\"..\\\\..\\\\..\\\\output.txt\");\r\n#else\r\n reader = new StreamReader(Console.OpenStandardInput());\r\n writer = new StreamWriter(Console.OpenStandardOutput());\r\n //reader = new StreamReader(\"ysys.in\");\r\n //writer = new StreamWriter(\"output.txt\");\r\n#endif\r\n try\r\n {\r\n new Solution().Solve();\r\n //var thread = new Thread(new Solution().Solve, 1024 * 1024 * 128);\r\n //thread.Start();\r\n //thread.Join();\r\n }\r\n catch (Exception ex)\r\n {\r\n#if DEBUGLOCAL\r\n Console.WriteLine(ex);\r\n#else\r\n throw;\r\n#endif\r\n }\r\n reader.Close();\r\n writer.Close();\r\n }\r\n\r\n #endregion\r\n\r\n #region Read / Write\r\n private static Queue currentLineTokens = new Queue();\r\n private static string[] ReadAndSplitLine() { return reader.ReadLine().Split(new[] { ' ', '\\t', }, StringSplitOptions.RemoveEmptyEntries); }\r\n public static string ReadToken() { while (currentLineTokens.Count == 0) currentLineTokens = new Queue(ReadAndSplitLine()); return currentLineTokens.Dequeue(); }\r\n public static int ReadInt() { return int.Parse(ReadToken()); }\r\n public static long ReadLong() { return long.Parse(ReadToken()); }\r\n public static double ReadDouble() { return double.Parse(ReadToken(), CultureInfo.InvariantCulture); }\r\n public static int[] ReadIntArray() { return ReadAndSplitLine().Select(int.Parse).ToArray(); }\r\n public static long[] ReadLongArray() { return ReadAndSplitLine().Select(long.Parse).ToArray(); }\r\n public static double[] ReadDoubleArray() { return ReadAndSplitLine().Select(s => double.Parse(s, CultureInfo.InvariantCulture)).ToArray(); }\r\n public static int[][] ReadIntMatrix(int numberOfRows) { int[][] matrix = new int[numberOfRows][]; for (int i = 0; i < numberOfRows; i++) matrix[i] = ReadIntArray(); return matrix; }\r\n public static int[][] ReadAndTransposeIntMatrix(int numberOfRows)\r\n {\r\n int[][] matrix = ReadIntMatrix(numberOfRows); int[][] ret = new int[matrix[0].Length][];\r\n for (int i = 0; i < ret.Length; i++) { ret[i] = new int[numberOfRows]; for (int j = 0; j < numberOfRows; j++) ret[i][j] = matrix[j][i]; }\r\n return ret;\r\n }\r\n public static string[] ReadLines(int quantity) { string[] lines = new string[quantity]; for (int i = 0; i < quantity; i++) lines[i] = reader.ReadLine().Trim(); return lines; }\r\n public static void WriteArray(IEnumerable array) { writer.WriteLine(string.Join(\" \", array)); }\r\n public static void Write(params object[] array) { WriteArray(array); }\r\n public static void WriteLines(IEnumerable array) { foreach (var a in array) writer.WriteLine(a); }\r\n private class SDictionary : Dictionary\r\n {\r\n public new TValue this[TKey key]\r\n {\r\n get { return ContainsKey(key) ? base[key] : default(TValue); }\r\n set { base[key] = value; }\r\n }\r\n }\r\n private static T[] Init(int size) where T : new() { var ret = new T[size]; for (int i = 0; i < size; i++) ret[i] = new T(); return ret; }\r\n #endregion\r\n}", "lang_cluster": "C#", "tags": ["brute force", "math", "dp", "two pointers", "number theory"], "code_uid": "e3adbf772756823f04059a2ea836cc50", "src_uid": "77443424be253352aaf2b6c89bdd4671", "difficulty": 1900.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Globalization;\nusing System.IO;\nusing System.Linq;\nusing System.Text;\nusing System.Threading;\n\n// (\u3065\u00b0\u03c9\u00b0)\u3065\uff90e\u2605\u309c\u30fb\u3002\u3002\u30fb\u309c\u309c\u30fb\u3002\u3002\u30fb\u309c\u2606\u309c\u30fb\u3002\u3002\u30fb\u309c\u309c\u30fb\u3002\u3002\u30fb\u309c\npublic class Solver\n{\n const int MOD = 1000000007;\n\n long[] f, rf, inv;\n void InitFacts(int size)\n {\n f = new long[size + 1];\n rf = new long[size + 1];\n inv = new long[size + 1];\n f[0] = f[1] = rf[0] = rf[1] = inv[1] = 1;\n for (int i = 2; i <= size; i++)\n {\n f[i] = f[i - 1] * i % MOD;\n inv[i] = inv[MOD % i] * (MOD - MOD / i) % MOD;\n rf[i] = inv[i] * rf[i - 1] % MOD;\n }\n }\n\n public void Solve()\n {\n int n = ReadInt();\n int m = ReadInt();\n\n InitFacts(n);\n var ps = new long[n];\n for (int i = m + 1; i < n; i++)\n {\n long v = f[i - 1] * (i - m + ps[i - 1] - ps[i - m - 1] + MOD) % MOD;\n ps[i] = (ps[i - 1] + v * rf[i]) % MOD;\n }\n\n Write(ps[n - 1] * f[n - 1] % MOD);\n }\n\n #region Main\n\n protected static TextReader reader;\n protected static TextWriter writer;\n static void Main()\n {\n#if DEBUG\n reader = new StreamReader(\"..\\\\..\\\\input.txt\");\n //reader = new StreamReader(Console.OpenStandardInput());\n writer = Console.Out;\n //writer = new StreamWriter(\"..\\\\..\\\\output.txt\");\n#else\n reader = new StreamReader(Console.OpenStandardInput());\n writer = new StreamWriter(Console.OpenStandardOutput());\n //reader = new StreamReader(\"stations.in\");\n //writer = new StreamWriter(\"output.txt\");\n#endif\n try\n {\n new Solver().Solve();\n //var thread = new Thread(new Solver().Solve, 1024 * 1024 * 128);\n //thread.Start();\n //thread.Join();\n }\n catch (Exception ex)\n {\n#if DEBUG\n Console.WriteLine(ex);\n#else\n throw;\n#endif\n }\n reader.Close();\n writer.Close();\n }\n\n #endregion\n\n #region Read / Write\n private static Queue currentLineTokens = new Queue();\n private static string[] ReadAndSplitLine() { return reader.ReadLine().Split(new[] { ' ', '\\t', }, StringSplitOptions.RemoveEmptyEntries); }\n public static string ReadToken() { while (currentLineTokens.Count == 0)currentLineTokens = new Queue(ReadAndSplitLine()); return currentLineTokens.Dequeue(); }\n public static int ReadInt() { return int.Parse(ReadToken()); }\n public static long ReadLong() { return long.Parse(ReadToken()); }\n public static double ReadDouble() { return double.Parse(ReadToken(), CultureInfo.InvariantCulture); }\n public static int[] ReadIntArray() { return ReadAndSplitLine().Select(int.Parse).ToArray(); }\n public static long[] ReadLongArray() { return ReadAndSplitLine().Select(long.Parse).ToArray(); }\n public static double[] ReadDoubleArray() { return ReadAndSplitLine().Select(s => double.Parse(s, CultureInfo.InvariantCulture)).ToArray(); }\n public static int[][] ReadIntMatrix(int numberOfRows) { int[][] matrix = new int[numberOfRows][]; for (int i = 0; i < numberOfRows; i++)matrix[i] = ReadIntArray(); return matrix; }\n public static int[][] ReadAndTransposeIntMatrix(int numberOfRows)\n {\n int[][] matrix = ReadIntMatrix(numberOfRows); int[][] ret = new int[matrix[0].Length][];\n for (int i = 0; i < ret.Length; i++) { ret[i] = new int[numberOfRows]; for (int j = 0; j < numberOfRows; j++)ret[i][j] = matrix[j][i]; } return ret;\n }\n public static string[] ReadLines(int quantity) { string[] lines = new string[quantity]; for (int i = 0; i < quantity; i++)lines[i] = reader.ReadLine().Trim(); return lines; }\n public static void WriteArray(IEnumerable array) { writer.WriteLine(string.Join(\" \", array)); }\n public static void Write(params object[] array) { WriteArray(array); }\n public static void WriteLines(IEnumerable array) { foreach (var a in array)writer.WriteLine(a); }\n private class SDictionary : Dictionary\n {\n public new TValue this[TKey key]\n {\n get { return ContainsKey(key) ? base[key] : default(TValue); }\n set { base[key] = value; }\n }\n }\n private static T[] Init(int size) where T : new() { var ret = new T[size]; for (int i = 0; i < size; i++)ret[i] = new T(); return ret; }\n #endregion\n}", "lang_cluster": "C#", "tags": ["math", "dp", "combinatorics"], "code_uid": "6d5d91b4900267491789bfe46b6625f0", "src_uid": "0644605611a2cd10ab3a9f12f18d7ae4", "difficulty": 2400.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.IO;\nusing System.Text;\n\nnamespace Ability_To_Convert\n{\n internal class Program\n {\n private static readonly StreamReader reader = new StreamReader(Console.OpenStandardInput(1024*10), Encoding.ASCII, false, 1024*10);\n private static readonly StreamWriter writer = new StreamWriter(Console.OpenStandardOutput(1024*10), Encoding.ASCII, 1024*10);\n\n private static void Main(string[] args)\n {\n int n = int.Parse(reader.ReadLine());\n string s = reader.ReadLine();\n\n long prev = 0;\n long ans = 0;\n long pow = 1;\n long bpow = 1;\n int lastback0 = s.Length - 1;\n for (int i = s.Length - 1; i >= 0; i--)\n {\n long next = prev + pow*(s[i] - '0');\n if (next >= n || pow > n)\n {\n ans = ans + bpow*prev;\n bpow *= n;\n pow = 10;\n while (i + 1 < lastback0 && s[i + 1] == '0')\n {\n i++;\n }\n lastback0 = Math.Min(i, lastback0);\n prev = s[i] - '0';\n }\n else\n {\n prev = next;\n pow *= 10;\n }\n }\n ans = ans + bpow*prev;\n\n writer.WriteLine(ans);\n writer.Flush();\n }\n }\n}", "lang_cluster": "C#", "tags": ["constructive algorithms", "math", "dp", "greedy", "strings"], "code_uid": "f54cbe9c997f05ce7e826642aca19d50", "src_uid": "be66399c558c96566a6bb0a63d2503e5", "difficulty": 2000.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Globalization;\n\npublic class Class4\n{\n public static void Main()\n {\n Solve(new ConsoleInput());\n }\n\n private static void Solve(IInput input)\n {\n // HAI\n // I HAS A TUX\n // GIMMEH TUX\n // I HAS A FOO ITS 0\n // I HAS A BAR ITS 0\n // I HAS A BAZ ITS 0\n // I HAS A QUZ ITS 1\n // TUX IS NOW A NUMBR\n var tux = int.Parse(input.ReadLine());\n var foo = 0;\n var bar = 0;\n var baz = 0;\n var quz = 0;\n\n // IM IN YR LOOP NERFIN YR TUX TIL BOTH SAEM TUX AN 0\n for (; tux > 0; tux--)\n {\n // I HAS A PUR\n // GIMMEH PUR\n // PUR IS NOW A NUMBR\n var pur = int.Parse(input.ReadLine());\n\n // FOO R SUM OF FOO AN PUR\n foo += pur;\n\n // BAR R SUM OF BAR AN 1\n bar += 1;\n\n // BOTH SAEM ( BIGGR OF ( (PRODUKT OF FOO AN QUZ) AN (PRODUKT OF BAR BAZ)) AN PRODUKT OF FOO AN QUZ) )\n // O RLY?\n if (Math.Max(foo * quz, bar * baz) == (foo * quz))\n {\n // YA RLY\n // BAZ R FOO\n // QUZ R BAR\n baz = foo;\n quz = bar;\n\n // OIC\n }\n\n // IM OUTTA YR LOOP\n }\n\n // BAZ IS NOW A NUMBAR\n // VISIBLE SMOOSH QUOSHUNT OF BAZ QUZ\n Console.WriteLine(((float)baz / quz).ToString(\"F6\", CultureInfo.InvariantCulture));\n\n // KTHXBYE\n }\n}\n\n#region input\npublic interface IInput\n{\n string ReadLine();\n}\n\npublic class ConsoleInput : IInput\n{\n public string ReadLine()\n {\n return Console.ReadLine();\n }\n}\n\npublic abstract class AbstractMockInput : IInput\n{\n protected virtual string[] lines { get; }\n\n private int currentLine = 0;\n\n public string ReadLine()\n {\n if (this.currentLine >= this.lines.Length)\n {\n return string.Empty;\n }\n\n var res = this.lines[this.currentLine];\n this.currentLine++;\n return res;\n }\n}\n\npublic class MockInput1 : AbstractMockInput\n{\n protected override string[] lines => new[] { \"3\", \"0\", \"1\", \"1\" };\n}\n\n#endregion", "lang_cluster": "C#", "tags": ["implementation", "trees", "graph matchings"], "code_uid": "729e71c203ce94841beb5adfbda635c7", "src_uid": "32fc378a310ca15598377f7b638eaf26", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections;\nusing System.Collections.Generic;\nusing System.Text;\nusing System.Threading;\nusing CompLib.Util;\n\npublic class Program\n{\n private int N;\n private List<(int to, int num)>[] E;\n private int[] U, V;\n private int Max;\n\n private int R;\n private bool[] IsX;\n private bool Found;\n private int XSize;\n\n private int[] Len;\n private int[] Dist;\n private int TmpX;\n private int TmpY;\n\n void Scan()\n {\n var sc = new Scanner();\n N = sc.NextInt();\n E = new List<(int to, int num)>[N];\n U = new int[N - 1];\n V = new int[N - 1];\n for (int i = 0; i < N; i++)\n {\n E[i] = new List<(int to, int num)>();\n }\n\n for (int i = 0; i < N - 1; i++)\n {\n int u = sc.NextInt() - 1;\n int v = sc.NextInt() - 1;\n U[i] = u + 1;\n V[i] = v + 1;\n E[u].Add((v, i));\n E[v].Add((u, i));\n }\n\n Max = 2 * N * N / 9;\n }\n\n void SetFlag(int cur, int par)\n {\n foreach ((int to, int num) e in E[cur])\n {\n if (e.to == par) continue;\n SetFlag(e.to, cur);\n }\n\n IsX[cur] = true;\n }\n\n int Go(int cur, int par)\n {\n var ls = new List<(int to, int size)>();\n int size = 1;\n foreach (var e in E[cur])\n {\n if (e.to == par) continue;\n int tmp = Go(e.to, cur);\n ls.Add((e.to, tmp));\n size += tmp;\n }\n\n\n if (par != -1)\n {\n ls.Add((par, N - size));\n }\n\n\n if (!Found)\n {\n bool[,] dp = new bool[ls.Count + 1, N];\n dp[0, 0] = true;\n for (int i = 0; i < ls.Count; i++)\n {\n for (int j = 0; j < N; j++)\n {\n if (dp[i, j])\n {\n dp[i + 1, j] = true;\n dp[i + 1, j + ls[i].size] = true;\n }\n }\n }\n\n int x = -1;\n for (int i = 0; i < N; i++)\n {\n if (!dp[ls.Count, i]) continue;\n int y = N - 1 - i;\n if (Max < (i + 1) * (y + 1))\n {\n x = i;\n break;\n }\n }\n\n if (x != -1)\n {\n XSize = x;\n R = cur;\n for (int i = ls.Count - 1; i >= 0; i--)\n {\n if (x - ls[i].size >= 0 && dp[i, x - ls[i].size])\n {\n SetFlag(ls[i].to, cur);\n x -= ls[i].size;\n }\n }\n\n Found = true;\n }\n }\n\n\n return size;\n }\n\n // r\u3001x,y\u306e\u9802\u70b9\u3092\u6c7a\u3081\u308b\n void SearchR()\n {\n IsX = new bool[N];\n Found = false;\n Go(0, -1);\n if (!Found) throw new Exception();\n }\n\n\n // \u73fe\u5728\u5730\u3001\u89aa\u3001par-cur\u304c\u8fbanum\n void SetX(int cur, int par, int num)\n {\n Dist[cur] = TmpX++;\n if (par != -1)\n {\n Len[num] = Dist[cur] - Dist[par];\n }\n\n foreach ((int to, int num) e in E[cur])\n {\n if (e.to == par) continue;\n if (!IsX[e.to]) continue;\n SetX(e.to, cur, e.num);\n }\n }\n\n void SetY(int cur, int par, int num)\n {\n Dist[cur] = TmpY;\n TmpY += (XSize + 1);\n if (par != -1)\n {\n Len[num] = Dist[cur] - Dist[par];\n }\n\n foreach ((int to, int num) e in E[cur])\n {\n if (e.to == par) continue;\n if (IsX[e.to]) continue;\n SetY(e.to, cur, e.num);\n }\n }\n\n void SetLen()\n {\n // \u8fba\u306e\u9577\u3055\n Len = new int[N - 1];\n // R->\u9802\u70b9\u307e\u3067\u306e\u8ddd\u96e2\n Dist = new int[N];\n // X\u5074\u306e\u9802\u70b9\u306fR\u306b\u8fd1\u3044\u9806\u306b\u8ddd\u96e21~X\u3092\u5272\u308a\u5f53\u3066\u308b\n // \u305d\u308c\u305e\u308c\u306e\u9802\u70b9\u307e\u3067\u306e\u8ddd\u96e2\u306b\u306a\u308b\u3088\u3046\u306b\u9802\u70b9\u306e\u9577\u3055\u3092\u5272\u308a\u5f53\u3066\u308b\n TmpX = 0;\n SetX(R, -1, -1);\n\n // Y (X+1)\u523b\u307f\u3067\u5272\u308a\u5f53\u3066\u308b\n TmpY = 0;\n SetY(R, -1, -1);\n }\n\n void Write()\n {\n var sb = new StringBuilder();\n for (int i = 0; i < N - 1; i++)\n {\n sb.AppendLine($\"{U[i]} {V[i]} {Len[i]}\");\n }\n\n Console.Write(sb);\n }\n\n public void Solve()\n {\n // \u3042\u308b\u9802\u70b9r\u3092\u5883\u76ee\u306b2\u3064\u306b\u5206\u3051\u308b\n // \u7247\u65b9x\u500b \u3082\u3046\u7247\u65b9 y\u500b x + y + 1 = N\n // \u7247\u65b9\u3067r\u304b\u3089\u306e\u8ddd\u96e2 0~x\u3092\u3064\u304f\u308b\n // \u6b8b\u308a x+1\u523b\u307f\u3067 y\u500b\n // 0 <= p < (x+1)(y+1)\u3067\u304d\u308b\n\n Scan();\n SearchR();\n SetLen();\n Write();\n }\n\n public static void Main(string[] args)\n {\n new Thread(new ThreadStart(new Program().Solve), 1 << 27).Start();\n }\n}\n\nnamespace CompLib.Util\n{\n using System;\n using System.Linq;\n\n class Scanner\n {\n private string[] _line;\n private int _index;\n private const char Separator = ' ';\n\n public Scanner()\n {\n _line = new string[0];\n _index = 0;\n }\n\n public string Next()\n {\n if (_index >= _line.Length)\n {\n string s;\n do\n {\n s = Console.ReadLine();\n } while (s.Length == 0);\n\n _line = s.Split(Separator);\n _index = 0;\n }\n\n return _line[_index++];\n }\n\n public int NextInt() => int.Parse(Next());\n public long NextLong() => long.Parse(Next());\n public double NextDouble() => double.Parse(Next());\n public decimal NextDecimal() => decimal.Parse(Next());\n public char NextChar() => Next()[0];\n public char[] NextCharArray() => Next().ToCharArray();\n\n public string[] Array()\n {\n string s = Console.ReadLine();\n _line = s.Length == 0 ? new string[0] : s.Split(Separator);\n _index = _line.Length;\n return _line;\n }\n\n public int[] IntArray() => Array().Select(int.Parse).ToArray();\n public long[] LongArray() => Array().Select(long.Parse).ToArray();\n public double[] DoubleArray() => Array().Select(double.Parse).ToArray();\n public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();\n }\n}", "lang_cluster": "C#", "tags": ["constructive algorithms", "trees"], "code_uid": "cb3d7d8ef4a39a95a0a61ff9585e9a96", "src_uid": "87d755df6ee27b381122062659c4a432", "difficulty": 2700.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.IO;\n\nnamespace CFDIV125_2 {\n\tclass Program {\n\t\tstatic void Main(string[] args) {\n\n#if DEBUG\n\t\t\tTextReader reader = new StreamReader(\"../../input.txt\");\n\n#else\n\t\t\tTextReader reader = Console.In;\n#endif\n\n\t\t\t#region INIT \n\t\t\tint[] c1 = reader.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();\n\t\t\tint[] c2 = reader.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();\n\n\t\t\tint x1 = c1[0];\n\t\t\tint y1 = c1[1];\n\t\t\tint r1 = c1[2];\n\t\t\tint R1 = c1[3];\n\n\t\t\tint x2 = c2[0];\n\t\t\tint y2 = c2[1];\n\t\t\tint r2 = c2[2];\n\t\t\tint R2 = c2[3];\n\t\t\t#endregion\n\n\t\t\tint count = 0;\n\n\t\t\tif (AreCircleWithBallOk(x1, y1, r1, x2, y2, r2, R2)) count++;\n\t\t\tif (AreCircleWithBallOk(x1, y1, R1, x2, y2, r2, R2)) count++;\n\t\t\tif (AreCircleWithBallOk(x2, y2, r2, x1, y1, r1, R1)) count++;\n\t\t\tif (AreCircleWithBallOk(x2, y2, R2, x1, y1, r1, R1)) count++;\n\t\t\t\n\n\t\t\tConsole.WriteLine(count);\n\n\n#if DEBUG\n\t\t\tConsole.ReadKey();\n#endif\n\n\t\t}\n\n\n\t\tstatic bool AreCircleWithBallOk(int x1, int y1, int rd1, int x2, int y2, int rd2, int Rd2) {\n\n\t\t\tbool res1 = !(AreBallsIntercect(x1, y1, rd1, x2, y2, rd2) ||\n\t\t\t\t\t\t AreBallsIntercect(x1, y1, rd1, x2, y2, Rd2));\n\n\t\t\tif (!res1) return false;\n\n\t\t\tdouble centersDist = Math.Sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1));\n\n\t\t\tdouble t1 = centersDist + rd2;\n\t\t\tdouble t2 = rd1;\n\t\t\tdouble t3 = centersDist + Rd2;\n\t\t\tif (t1 <= t2 && t2 < t3) return false;\n\n\t\t\tt1 = centersDist - Rd2;\n\t\t\tt2 = -rd1;\n\t\t\tt3 = centersDist - rd2;\n\t\t\tif (t1 <= t2 && t2 < t3) return false;\n\n\t\t\treturn true;\n\n\t\t}\n\n\t\tstatic bool AreBallsIntercect(int x1, int y1, int rd1, int x2, int y2, int rd2) {\n\t\t\t\n\t\t\tdouble centersDist = Math.Sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1));\n\n\t\t\tdouble l1 = -rd1;\n\t\t\tdouble r1 = rd1;\n\n\t\t\tdouble l2 = centersDist - rd2;\n\t\t\tdouble r2 = centersDist + rd2;\n\n\t\t\tif (r1 <= l2) return false;\n\t\t\tif (l1 <= l2 && r1 >= r2) return false;\n\t\t\tif (l2 <= l1 && r2 >= r1) return false;\n\n\t\t\treturn true;\n\n\t\t}\n\n\t}\n}\n", "lang_cluster": "C#", "tags": ["geometry"], "code_uid": "5283859d12fd57ddfe064afa15e00c92", "src_uid": "4c2865e4742a29460ca64860740b84f4", "difficulty": 1900.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.IO;\nusing System.Threading;\nusing System.Text;\nusing System.Diagnostics;\nusing static util;\nusing P = pair;\n\nclass Program {\n static void Main(string[] args) {\n var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };\n var solver = new Solver(sw);\n // var t = new Thread(solver.solve, 1 << 26); // 64 MB\n // t.Start();\n // t.Join();\n solver.solve();\n sw.Flush();\n }\n}\n\nclass Solver {\n StreamWriter sw;\n Scan sc;\n void Prt(string a) => sw.WriteLine(a);\n void Prt(IEnumerable a) => Prt(string.Join(\" \", a));\n void Prt(params object[] a) => Prt(string.Join(\" \", a));\n public Solver(StreamWriter sw) {\n this.sw = sw;\n this.sc = new Scan();\n }\n\n public void solve() {\n int n = sc.Int;\n if (n == 1) {\n Prt(1);\n return;\n }\n int m = 1;\n while (m <= n) m *= 2;\n int c = 0;\n for (int i = m / 2; i < m; ++i)\n {\n int bc = bitcnt(i);\n int next = -1;\n int p = i;\n while (p > 0) {\n if (p % 2 == 0) {\n next = p / 2;\n break;\n }\n p >>= 1;\n }\n if (next != -1 && bc % 2 != bitcnt(next) % 2) {\n ++c;\n }\n }\n // DBG(c);\n if (m / 2 - 1 + c == n || m / 2 - 1 + c + 1 == n) {\n Prt(1);\n }\n else Prt(0);\n\n }\n int bitcnt(int a) {\n int ret = 0;\n while (a > 0) {\n ret += a & 1;\n a >>= 1;\n }\n return ret;\n }\n}\n\nclass pair : IComparable> {\n public T v1;\n public U v2;\n public pair() : this(default(T), default(U)) {}\n public pair(T v1, U v2) { this.v1 = v1; this.v2 = v2; }\n public int CompareTo(pair a) {\n int c = Comparer.Default.Compare(v1, a.v1);\n return c != 0 ? c : Comparer.Default.Compare(v2, a.v2);\n }\n public override string ToString() => v1 + \" \" + v2;\n public void Deconstruct(out T a, out U b) { a = v1; b = v2; }\n}\nstatic class util {\n public static readonly int M = 1000000007;\n // public static readonly int M = 998244353;\n public static readonly long LM = 1L << 60;\n public static readonly double eps = 1e-11;\n public static void DBG(string a) => Console.Error.WriteLine(a);\n public static void DBG(IEnumerable a) => DBG(string.Join(\" \", a));\n public static void DBG(params object[] a) => DBG(string.Join(\" \", a));\n public static void Assert(bool cond) { if (!cond) throw new Exception(); }\n public static pair make_pair(T v1, U v2) => new pair(v1, v2);\n public static int CompareList(IList a, IList b) where T : IComparable {\n for (int i = 0; i < a.Count && i < b.Count; i++)\n if (a[i].CompareTo(b[i]) != 0) return a[i].CompareTo(b[i]);\n return a.Count.CompareTo(b.Count);\n }\n public static bool inside(int i, int j, int h, int w) => i >= 0 && i < h && j >= 0 && j < w;\n static readonly int[] dd = { 0, 1, 0, -1 };\n // static readonly string dstring = \"RDLU\";\n public static P[] adjacents(int i, int j)\n => Enumerable.Range(0, dd.Length).Select(k => new P(i + dd[k], j + dd[k ^ 1])).ToArray();\n public static P[] adjacents(int i, int j, int h, int w)\n => Enumerable.Range(0, dd.Length).Select(k => new P(i + dd[k], j + dd[k ^ 1]))\n .Where(p => inside(p.v1, p.v2, h, w)).ToArray();\n public static P[] adjacents(this P p) => adjacents(p.v1, p.v2);\n public static P[] adjacents(this P p, int h, int w) => adjacents(p.v1, p.v2, h, w);\n public static Dictionary compress(this IEnumerable a)\n => a.Distinct().OrderBy(v => v).Select((v, i) => new { v, i }).ToDictionary(p => p.v, p => p.i);\n public static Dictionary compress(params IEnumerable[] a) => compress(a.Aggregate(Enumerable.Union));\n public static int[] compressed(this IEnumerable a) {\n var cmp = a.compress();\n return a.Select(x => cmp[x]).ToArray();\n }\n public static T[] inv(this Dictionary dic) {\n var res = new T[dic.Count];\n foreach (var item in dic) res[item.Value] = item.Key;\n return res;\n }\n public static void swap(ref T a, ref T b) where T : struct { var t = a; a = b; b = t; }\n public static void swap(this IList a, int i, int j) where T : struct { var t = a[i]; a[i] = a[j]; a[j] = t; }\n public static T[] copy(this IList a) {\n var ret = new T[a.Count];\n for (int i = 0; i < a.Count; i++) ret[i] = a[i];\n return ret;\n }\n}\n\nclass Scan {\n StreamReader sr;\n public Scan() { sr = new StreamReader(Console.OpenStandardInput()); }\n public Scan(string path) { sr = new StreamReader(path); }\n public int Int => int.Parse(Str);\n public long Long => long.Parse(Str);\n public double Double => double.Parse(Str);\n public string Str => sr.ReadLine().Trim();\n public pair Pair() {\n T a; U b;\n Multi(out a, out b);\n return new pair(a, b);\n }\n public P P => Pair();\n public int[] IntArr => StrArr.Select(int.Parse).ToArray();\n public long[] LongArr => StrArr.Select(long.Parse).ToArray();\n public double[] DoubleArr => StrArr.Select(double.Parse).ToArray();\n public string[] StrArr => Str.Split(new[]{' '}, StringSplitOptions.RemoveEmptyEntries);\n bool eq() => typeof(T).Equals(typeof(U));\n T ct(U a) => (T)Convert.ChangeType(a, typeof(T));\n T cv(string s) => eq() ? ct(int.Parse(s))\n : eq() ? ct(long.Parse(s))\n : eq() ? ct(double.Parse(s))\n : eq() ? ct(s[0])\n : ct(s);\n public void Multi(out T a) => a = cv(Str);\n public void Multi(out T a, out U b)\n { var ar = StrArr; a = cv(ar[0]); b = cv(ar[1]); }\n public void Multi(out T a, out U b, out V c)\n { var ar = StrArr; a = cv(ar[0]); b = cv(ar[1]); c = cv(ar[2]); }\n public void Multi(out T a, out U b, out V c, out W d)\n { var ar = StrArr; a = cv(ar[0]); b = cv(ar[1]); c = cv(ar[2]); d = cv(ar[3]); }\n public void Multi(out T a, out U b, out V c, out W d, out X e)\n { var ar = StrArr; a = cv(ar[0]); b = cv(ar[1]); c = cv(ar[2]); d = cv(ar[3]); e = cv(ar[4]); }\n}\n", "lang_cluster": "C#", "tags": ["math", "dp"], "code_uid": "9bb702534db9c2a6e484219ca703c809", "src_uid": "821409c1b9bdcd18c4dcf35dc5116501", "difficulty": 2400.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\nusing System;\nusing System.Collections.Generic;\nusing System.IO;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace AlgoTraining.Codeforces.D_s\n{\n public class FastScanner : StreamReader\n {\n private string[] _line;\n private int _iterator;\n\n public FastScanner(Stream stream) : base(stream)\n {\n _line = null;\n _iterator = 0;\n }\n public string NextToken()\n {\n if (_line == null || _iterator >= _line.Length)\n {\n _line = base.ReadLine().Split(' ');\n _iterator = 0;\n }\n if (_line.Count() == 0) throw new IndexOutOfRangeException(\"Input string is empty\");\n return _line[_iterator++];\n }\n public int NextInt()\n {\n return Convert.ToInt32(NextToken());\n }\n public long NextLong()\n {\n return Convert.ToInt64(NextToken());\n }\n public float NextFloat()\n {\n return float.Parse(NextToken());\n }\n public double NextDouble()\n {\n return Convert.ToDouble(NextToken());\n }\n }\n class MemoryAndScores370\n {\n private static int a, b, k, t;\n private static long[] comb, combSum;\n private static long mod;\n public static void Main(string[] args)\n {\n using (FastScanner fs = new FastScanner(new BufferedStream(Console.OpenStandardInput())))\n using (StreamWriter writer = new StreamWriter(new BufferedStream(Console.OpenStandardOutput())))\n {\n a = fs.NextInt();\n b = fs.NextInt();\n k = fs.NextInt();\n t = fs.NextInt();\n comb = new long[2 * k * t + 1];\n combSum = new long[2 * k * t + 1];\n mod = (int)1e9 + 7;\n for (int i = 0; i <= 2 * k; i++)\n {\n comb[i] = 1;\n }\n for (int i = 1; i < t; i++)\n {\n long sum = 0;\n long[] tcomb = new long[2 * k * t + 1];\n for (int j = 0; j < comb.Length; j++)\n {\n sum = (sum + comb[j]) % mod;\n if (j > 2 * k)\n {\n sum = (mod + (sum - comb[j - 2 * k - 1]) % mod) % mod;\n }\n tcomb[j] = sum;\n }\n comb = tcomb;\n }\n combSum[0] = comb[0];\n for (int i = 1; i < comb.Length; i++)\n {\n combSum[i] = (comb[i] + combSum[i - 1]) % mod;\n }\n\n long ans = 0;\n for (int i = 0; i < comb.Length; i++)\n {\n int index = Math.Min(i + a - b - 1, combSum.Length - 1);\n if (index >= 0) ans = (ans + (comb[i] * combSum[index]) % mod) % mod;\n }\n writer.WriteLine(ans);\n }\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "dp", "combinatorics"], "code_uid": "f6f859e3838d148f7e10209dfa76a949", "src_uid": "8b8327512a318a5b5afd531ff7223bd0", "difficulty": 2200.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\n\nnamespace ProgrammingContest.Codeforces.Round70\n{\n class E\n {\n static int t,n;\n static int[,] dist, dist2;\n static string[] b1, b2;\n\n static void bfs(int x, int y, bool chk)\n {\n int[] dx = new int[4] { 1, 0, -1, 0 },\n dy = new int[4] { 0, -1, 0, 1 };\n bool[,] visited = new bool[n, n];\n Queue q = new Queue();\n q.Enqueue(x * n + y);\n visited[x, y] = true;\n for (int a = 0; a < n; a++)\n for (int b = 0; b < n; b++)\n dist[a, b] = 100000;\n dist[x, y] = 0;\n while (q.Any())\n {\n int v = q.Dequeue();\n x = v / n; y = v % n;\n for (int i = 0; i < 4; i++)\n if (InRange(x + dx[i]) && InRange(y + dy[i]))\n {\n int d = dist[x, y] + 1;\n if (visited[x + dx[i], y + dy[i]] || d > t)\n {\n continue;\n }\n visited[x + dx[i], y + dy[i]] = true;\n if (!chk)\n {\n dist[x + dx[i], y + dy[i]] = d;\n if (char.IsDigit(b1[y + dy[i]][x + dx[i]]))\n q.Enqueue((x + dx[i]) * n + (y + dy[i]));\n }\n else\n {\n char b = b2[y + dy[i]][x + dx[i]];\n if (!char.IsDigit(b1[y + dy[i]][x + dx[i]]))\n {\n dist[x + dx[i], y + dy[i]] = d;\n }\n else if (d < dist2[x + dx[i], y + dy[i]])\n {\n q.Enqueue((x + dx[i]) * n + (y + dy[i]));\n dist[x + dx[i], y + dy[i]] = d;\n }\n else if ('0' <= b && b <= '9' && d == dist2[x + dx[i], y + dy[i]])\n dist[x + dx[i], y + dy[i]] = d;\n }\n }\n }\n }\n\n static bool InRange(int v) { return 0 <= v && v < n; }\n\n public static void Main()\n {\n var xs = Array.ConvertAll(Console.ReadLine().Split(' '), sss => int.Parse(sss));\n n = xs[0];\n t = xs[1];\n dist = new int[n, n];\n b1 = new string[n];\n b2 = new string[n];\n for (int y = 0; y < n; y++)\n b1[y] = Console.ReadLine();\n Console.ReadLine();\n for (int y = 0; y < n; y++)\n b2[y] = Console.ReadLine();\n Dinic dinic = new Dinic(2000);\n int scnt = 2;\n for (int y = 0; y < n; y++)\n for (int x = 0; x < n; x++)\n if (b1[y][x] == 'Z')\n {\n bfs(x,y,false);\n dist2 = (int[,])dist.Clone();\n }\n for (int y = 0; y < n; y++)\n for (int x = 0; x < n; x++)\n {\n if ('1' <= b1[y][x] && b1[y][x] <= '9')\n {\n //Console.WriteLine(\"check {0} {1}\", x, y);\n bfs(x, y, true);\n int scientists = b1[y][x] - '0';\n for (int j = 0; j < scientists; j++)\n dinic.AddEdge(0, scnt + j, 1);\n int idx = 1000;\n for (int a = 0; a < n; a++)\n for (int b = 0; b < n; b++)\n if ('1' <= b2[a][b] && b2[a][b] <= '9')\n {\n int cnt = b2[a][b] - '0';\n for (int i = 0; i < cnt; i++, idx++)\n if (dist[b, a] < 100000)\n {\n //Console.WriteLine(\"{0} {1} -> {2} {3}\", x, y, b, a);\n for (int j = 0; j < scientists; j++)\n dinic.AddEdge(scnt + j, idx, 1);\n }\n }\n scnt += scientists;\n }\n }\n for (int y = 0, k = 1000; y < n; y++)\n for (int x = 0; x < n; x++)\n if ('1' <= b2[y][x] && b2[y][x] <= '9')\n {\n int cnt = b2[y][x] - '0';\n for (int i = 0; i < cnt; i++, k++)\n dinic.AddEdge(k, 1, 1);\n }\n Console.WriteLine(dinic.BipartiteMatching(0,1));\n }\n\n #region MaximumFlow\n class Dinic\n {\n const int INF = 1 << 29;\n\n class Edge\n {\n public int to, cap, rev;\n public Edge(int to_, int cap_, int rev_) { to = to_; cap = cap_; rev = rev_; }\n }\n\n List[] G;\n int[] level, iter;\n\n void bfs(int s)\n {\n for (int i = 0; i < level.Length; i++) level[i] = -1;\n Queue q = new Queue();\n level[s] = 0;\n q.Enqueue(s);\n while (q.Count > 0)\n {\n int v = q.Dequeue();\n for (int i = 0; i < G[v].Count; i++)\n {\n Edge e = G[v][i];\n if (e.cap > 0 && level[e.to] < 0)\n {\n level[e.to] = level[v] + 1;\n q.Enqueue(e.to);\n }\n }\n }\n }\n\n int dfs(int v, int t, int f)\n {\n if (v == t) return f;\n for (int i = iter[v]; i < G[v].Count; i++, iter[v]++)\n {\n Edge e = G[v][i];\n if (e.cap > 0 && level[v] < level[e.to])\n {\n int d = dfs(e.to, t, Math.Min(f, e.cap));\n if (d > 0)\n {\n e.cap -= d;\n G[e.to][e.rev].cap += d;\n return d;\n }\n }\n }\n return 0;\n }\n\n public void AddEdge(int from, int to, int cap)\n {\n G[from].Add(new Edge(to, cap, G[to].Count));\n G[to].Add(new Edge(from, 0, G[from].Count - 1));\n }\n\n public int MaxFlow(int s, int t)\n {\n int flow = 0;\n for (; ; )\n {\n bfs(s);\n if (level[t] < 0) return flow;\n for (int i = 0; i < iter.Length; i++) iter[i] = 0;\n for (int f = 0; (f = dfs(s, t, INF)) > 0; )\n flow += f;\n }\n }\n\n public int BipartiteMatching(int s, int t)\n {\n return MaxFlow(s, t);\n }\n\n public Dinic(int size)\n {\n level = new int[size];\n iter = new int[size];\n G = new List[size];\n for (int i = 0; i < size; i++)\n G[i] = new List();\n }\n }\n #endregion\n }\n}\n", "lang_cluster": "C#", "tags": ["flows", "graphs", "shortest paths"], "code_uid": "709d0b4997580985a15c7220a8aaa441", "src_uid": "544de9c3729a35eb08c143b1cb9ee085", "difficulty": 2300.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Linq;\n\nnamespace TheTournamentC1\n{\n partial class TheTournamentC1\n {\n static void Main(string[] args)\n {\n int n, k, min;\n int[] points, effort, record, minEffort;\n\n n = NextInt();\n k = NextInt();\n\n points = new int[n];\n effort = new int[n];\n record = new int[n];\n minEffort = new int[2];\n\n for (int i = 0; i < n; i++)\n {\n points[i] = NextInt() + 1;\n effort[i] = NextInt();\n record[i] = 0;\n }\n\n minEffort[0] = Solve(0, k, 1, 0, 0, (int[])points.Clone(), (int[])effort.Clone(), (int[])record.Clone());\n minEffort[1] = Solve(0, k, 0, 0, 0, (int[])points.Clone(), (int[])effort.Clone(), (int[])record.Clone());\n\n min = minEffort.Min();\n min = min == int.MaxValue ? -1 : min;\n\n Console.WriteLine(min);\n }\n\n private static int Solve(int fighter, int k, int win, int currentPoints, int currentEffort, int[] points, int[] effort, int[] record)\n {\n int[] minEffort = new int[2];\n\n if (win == 1)\n {\n currentPoints++;\n currentEffort += effort[fighter];\n points[fighter]--;\n record[fighter] = 1;\n }\n\n fighter++;\n\n if (fighter < points.Length)\n {\n minEffort[0] = Solve(fighter, k, 1, currentPoints, currentEffort, (int[])points.Clone(), (int[])effort.Clone(), (int[])record.Clone());\n minEffort[1] = Solve(fighter, k, 0, currentPoints, currentEffort, (int[])points.Clone(), (int[])effort.Clone(), (int[])record.Clone());\n }\n else\n {\n if (IsWithinKRank((int[])points.Clone(), currentPoints, k, (int[])record.Clone()))\n return currentEffort;\n else\n return int.MaxValue;\n }\n\n return minEffort.Min();\n }\n\n private static bool IsWithinKRank(int[] points, int currentPoints, int k, int[] record)\n {\n int n = points.Length, rank = n + 1;\n int[] fighters = Enumerable.Range(0, n).ToArray();\n\n Array.Sort(points, fighters);\n\n for (int i = 0; i < n; i++)\n {\n if (currentPoints > points[i] || (currentPoints == points[i] && record[fighters[i]] == 1))\n rank--;\n }\n\n return rank <= k;\n }\n }\n\n partial class TheTournamentC1\n {\n static string[] tokens = new string[0];\n static int cur_token = 0;\n\n static void ReadArray(char sep)\n {\n cur_token = 0;\n tokens = Console.ReadLine().Split(sep);\n }\n\n static int ReadInt()\n {\n return int.Parse(Console.ReadLine());\n }\n\n static long ReadLong()\n {\n return long.Parse(Console.ReadLine());\n }\n\n static int NextInt()\n {\n if (cur_token == tokens.Length)\n ReadArray(' ');\n return int.Parse(tokens[cur_token++]);\n }\n\n static long NextLong()\n {\n if (cur_token == tokens.Length)\n ReadArray(' ');\n return long.Parse(tokens[cur_token++]);\n }\n\n static double NextDouble()\n {\n if (cur_token == tokens.Length)\n ReadArray(' ');\n return double.Parse(tokens[cur_token++]);\n }\n\n static decimal NextDecimal()\n {\n if (cur_token == tokens.Length)\n ReadArray(' ');\n return decimal.Parse(tokens[cur_token++]);\n }\n\n static string NextToken()\n {\n if (cur_token == tokens.Length)\n ReadArray(' ');\n return tokens[cur_token++];\n }\n\n static string ReadLine()\n {\n return Console.ReadLine();\n }\n }\n}", "lang_cluster": "C#", "tags": ["brute force"], "code_uid": "da0fba3517775ec4b2d0781af75d057b", "src_uid": "19a098cef100fc3652c59abf7c373814", "difficulty": null, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Globalization;\nusing System.IO;\nusing System.Linq;\nusing System.Text;\nusing System.Threading;\n\n// (\u3065\u00b0\u03c9\u00b0)\u3065\uff90e\u2605\u309c\u30fb\u3002\u3002\u30fb\u309c\u309c\u30fb\u3002\u3002\u30fb\u309c\u2606\u309c\u30fb\u3002\u3002\u30fb\u309c\u309c\u30fb\u3002\u3002\u30fb\u309c\npublic class Solver\n{\n const int MOD = 51123987;\n const int MAX = 50;\n\n public void Solve()\n {\n int n = ReadInt();\n string s = ReadToken();\n\n var g = new List();\n for (int i = 0; i < n; i++)\n if (i == n - 1 || s[i] != s[i + 1])\n g.Add(s[i] - 'a');\n\n int m = g.Count;\n var next = new int[m, 3];\n for (int i = 0; i < m; i++)\n for (int j = 0; j < 3; j++)\n {\n int k;\n for (k = i; k < m; k++)\n if (g[k] == j)\n break;\n next[i, j] = k;\n }\n\n var dp = new int[m + 1, MAX + 2, MAX + 2];\n dp[0, 0, 0] = 1;\n for (int i = 0; i < n; i++)\n {\n var ndp = new int[m + 1, MAX + 2, MAX + 2];\n for (int j = 0; j < m; j++)\n for (int xa = 0; xa <= i && xa <= MAX; xa++)\n for (int xb = 0; xa + xb <= i && xb <= MAX; xb++)\n {\n ndp[next[j, 0], xa + 1, xb] = (ndp[next[j, 0], xa + 1, xb] + dp[j, xa, xb]) % MOD;\n ndp[next[j, 1], xa, xb + 1] = (ndp[next[j, 1], xa, xb + 1] + dp[j, xa, xb]) % MOD;\n ndp[next[j, 2], xa, xb] = (ndp[next[j, 2], xa, xb] + dp[j, xa, xb]) % MOD;\n }\n dp = ndp;\n }\n\n int ans = 0;\n for (int i = 0; i < m; i++)\n for (int j = n / 3; j < n / 3 + 2; j++)\n for (int k = n / 3; k < n / 3 + 2; k++)\n if (Math.Abs(j - k) < 2 && Math.Abs(j - (n - j - k)) < 2 && Math.Abs(k - (n - j - k)) < 2)\n ans = (ans + dp[i, j, k]) % MOD;\n Write(ans);\n }\n\n #region Main\n\n protected static TextReader reader;\n protected static TextWriter writer;\n static void Main()\n {\n#if DEBUG\n reader = new StreamReader(\"..\\\\..\\\\input.txt\");\n //reader = new StreamReader(Console.OpenStandardInput());\n writer = Console.Out;\n //writer = new StreamWriter(\"..\\\\..\\\\output.txt\");\n#else\n reader = new StreamReader(Console.OpenStandardInput());\n writer = new StreamWriter(Console.OpenStandardOutput());\n //reader = new StreamReader(\"input.txt\");\n //writer = new StreamWriter(\"output.txt\");\n#endif\n try\n {\n new Solver().Solve();\n //var thread = new Thread(new Solver().Solve, 1024 * 1024 * 128);\n //thread.Start();\n //thread.Join();\n }\n catch (Exception ex)\n {\n Console.WriteLine(ex);\n#if DEBUG\n#else\n throw;\n#endif\n }\n reader.Close();\n writer.Close();\n }\n\n #endregion\n\n #region Read / Write\n private static Queue currentLineTokens = new Queue();\n private static string[] ReadAndSplitLine() { return reader.ReadLine().Split(new[] { ' ', '\\t', }, StringSplitOptions.RemoveEmptyEntries); }\n public static string ReadToken() { while (currentLineTokens.Count == 0)currentLineTokens = new Queue(ReadAndSplitLine()); return currentLineTokens.Dequeue(); }\n public static int ReadInt() { return int.Parse(ReadToken()); }\n public static long ReadLong() { return long.Parse(ReadToken()); }\n public static double ReadDouble() { return double.Parse(ReadToken(), CultureInfo.InvariantCulture); }\n public static int[] ReadIntArray() { return ReadAndSplitLine().Select(int.Parse).ToArray(); }\n public static long[] ReadLongArray() { return ReadAndSplitLine().Select(long.Parse).ToArray(); }\n public static double[] ReadDoubleArray() { return ReadAndSplitLine().Select(s => double.Parse(s, CultureInfo.InvariantCulture)).ToArray(); }\n public static int[][] ReadIntMatrix(int numberOfRows) { int[][] matrix = new int[numberOfRows][]; for (int i = 0; i < numberOfRows; i++)matrix[i] = ReadIntArray(); return matrix; }\n public static int[][] ReadAndTransposeIntMatrix(int numberOfRows)\n {\n int[][] matrix = ReadIntMatrix(numberOfRows); int[][] ret = new int[matrix[0].Length][];\n for (int i = 0; i < ret.Length; i++) { ret[i] = new int[numberOfRows]; for (int j = 0; j < numberOfRows; j++)ret[i][j] = matrix[j][i]; } return ret;\n }\n public static string[] ReadLines(int quantity) { string[] lines = new string[quantity]; for (int i = 0; i < quantity; i++)lines[i] = reader.ReadLine().Trim(); return lines; }\n public static void WriteArray(IEnumerable array) { writer.WriteLine(string.Join(\" \", array)); }\n public static void Write(params object[] array) { WriteArray(array); }\n public static void WriteLines(IEnumerable array) { foreach (var a in array)writer.WriteLine(a); }\n private class SDictionary : Dictionary\n {\n public new TValue this[TKey key]\n {\n get { return ContainsKey(key) ? base[key] : default(TValue); }\n set { base[key] = value; }\n }\n }\n private static T[] Init(int size) where T : new() { var ret = new T[size]; for (int i = 0; i < size; i++)ret[i] = new T(); return ret; }\n #endregion\n}", "lang_cluster": "C#", "tags": ["dp"], "code_uid": "7329caa5f15012f7eff423e232aee155", "src_uid": "64fada10630906e052ff05f2afbf337e", "difficulty": 2500.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Globalization;\nusing System.IO;\nusing System.Linq;\nusing System.Text;\nusing System.Threading;\n\n// (\u3065\u00b0\u03c9\u00b0)\u3065\uff90e\u2605\u309c\u30fb\u3002\u3002\u30fb\u309c\u309c\u30fb\u3002\u3002\u30fb\u309c\u2606\u309c\u30fb\u3002\u3002\u30fb\u309c\u309c\u30fb\u3002\u3002\u30fb\u309c\npublic class Solver\n{\n const int MOD = 1000000009;\n\n public void Solve()\n {\n int n = ReadInt();\n long ans = 0;\n long prod = 1;\n long v = 1;\n for (int i = 1; i < n; i++)\n {\n if (i > 3 && i % 2 == 0)\n {\n if (i == n - 1)\n {\n ans = (ans + 2 * (i - 1) * prod) % MOD;\n break;\n }\n v = (v * 2 + 3) % MOD;\n ans = (ans + 2 * v * prod) % MOD;\n prod = prod * v % MOD;\n }\n else\n ans = (ans + 2 * prod) % MOD;\n }\n\n ans = ans * ans % MOD;\n ans = (ans + 1) * 2 % MOD;\n Write(ans);\n }\n\n #region Main\n\n protected static TextReader reader;\n protected static TextWriter writer;\n static void Main()\n {\n#if DEBUG\n reader = new StreamReader(\"..\\\\..\\\\input.txt\");\n //reader = new StreamReader(Console.OpenStandardInput());\n writer = Console.Out;\n //writer = new StreamWriter(\"..\\\\..\\\\output.txt\");\n#else\n reader = new StreamReader(Console.OpenStandardInput());\n writer = new StreamWriter(Console.OpenStandardOutput());\n //reader = new StreamReader(\"input.txt\");\n //writer = new StreamWriter(\"output.txt\");\n#endif\n try\n {\n new Solver().Solve();\n //var thread = new Thread(new Solver().Solve, 1024 * 1024 * 128);\n //thread.Start();\n //thread.Join();\n }\n catch (Exception ex)\n {\n Console.WriteLine(ex);\n#if DEBUG\n#else\n throw;\n#endif\n }\n reader.Close();\n writer.Close();\n }\n\n #endregion\n\n #region Read / Write\n private static Queue currentLineTokens = new Queue();\n private static string[] ReadAndSplitLine() { return reader.ReadLine().Split(new[] { ' ', '\\t', }, StringSplitOptions.RemoveEmptyEntries); }\n public static string ReadToken() { while (currentLineTokens.Count == 0)currentLineTokens = new Queue(ReadAndSplitLine()); return currentLineTokens.Dequeue(); }\n public static int ReadInt() { return int.Parse(ReadToken()); }\n public static long ReadLong() { return long.Parse(ReadToken()); }\n public static double ReadDouble() { return double.Parse(ReadToken(), CultureInfo.InvariantCulture); }\n public static int[] ReadIntArray() { return ReadAndSplitLine().Select(int.Parse).ToArray(); }\n public static long[] ReadLongArray() { return ReadAndSplitLine().Select(long.Parse).ToArray(); }\n public static double[] ReadDoubleArray() { return ReadAndSplitLine().Select(s => double.Parse(s, CultureInfo.InvariantCulture)).ToArray(); }\n public static int[][] ReadIntMatrix(int numberOfRows) { int[][] matrix = new int[numberOfRows][]; for (int i = 0; i < numberOfRows; i++)matrix[i] = ReadIntArray(); return matrix; }\n public static int[][] ReadAndTransposeIntMatrix(int numberOfRows)\n {\n int[][] matrix = ReadIntMatrix(numberOfRows); int[][] ret = new int[matrix[0].Length][];\n for (int i = 0; i < ret.Length; i++) { ret[i] = new int[numberOfRows]; for (int j = 0; j < numberOfRows; j++)ret[i][j] = matrix[j][i]; } return ret;\n }\n public static string[] ReadLines(int quantity) { string[] lines = new string[quantity]; for (int i = 0; i < quantity; i++)lines[i] = reader.ReadLine().Trim(); return lines; }\n public static void WriteArray(IEnumerable array) { writer.WriteLine(string.Join(\" \", array)); }\n public static void Write(params object[] array) { WriteArray(array); }\n public static void WriteLines(IEnumerable array) { foreach (var a in array)writer.WriteLine(a); }\n private class SDictionary : Dictionary\n {\n public new TValue this[TKey key]\n {\n get { return ContainsKey(key) ? base[key] : default(TValue); }\n set { base[key] = value; }\n }\n }\n private static T[] Init(int size) where T : new() { var ret = new T[size]; for (int i = 0; i < size; i++)ret[i] = new T(); return ret; }\n #endregion\n}", "lang_cluster": "C#", "tags": ["dp", "combinatorics"], "code_uid": "5f33cd2b61e3495dfb4eb596502cb695", "src_uid": "dbcb1077e7421554ba5d69b64d22c937", "difficulty": 2600.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.IO;\nusing System.Runtime.CompilerServices;\nusing System.Text;\nusing System.Diagnostics;\nusing System.Numerics;\nusing static System.Console;\nusing static System.Convert;\nusing static System.Math;\nusing static Template;\nusing Pi = Pair;\n\nclass Solver\n{\n public void Solve(Scanner sc)\n {\n int N, M;\n sc.Make(out N, out M);\n if (N > M + 1) Fail(0);\n if (N == 2) Fail(0);\n ModInt.Build(M + 1);\n ModInt res = 0;\n\n for(int i = 0; i < N - 2; i++)\n {\n res += ModInt.Comb(N - 3, i);\n }\n res *= ModInt.Comb(M, N - 1);\n WriteLine(res*(N-2));\n }\n}\n\npublic struct ModInt\n{\n //public const long MOD = (int)1e9 + 7;\n public const long MOD = 998244353;\n public long Value { get; set; }\n public ModInt(long n = 0) { Value = n; }\n private static ModInt[] fac;//\u968e\u4e57\n private static ModInt[] inv;//\u9006\u6570\n private static ModInt[] facinv;//1/(i!)\n public override string ToString() => Value.ToString();\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static ModInt operator +(ModInt l, ModInt r)\n {\n l.Value += r.Value;\n if (l.Value >= MOD) l.Value -= MOD;\n return l;\n }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static ModInt operator -(ModInt l, ModInt r)\n {\n l.Value -= r.Value;\n if (l.Value < 0) l.Value += MOD;\n return l;\n }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static ModInt operator *(ModInt l, ModInt r) => new ModInt(l.Value * r.Value % MOD);\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static ModInt operator /(ModInt l, ModInt r) => l * Pow(r, MOD - 2);\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static implicit operator long(ModInt l) => l.Value;\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static implicit operator ModInt(long n)\n {\n n %= MOD; if (n < 0) n += MOD;\n return new ModInt(n);\n }\n\n public static ModInt Pow(ModInt m, long n)\n {\n if (n == 0) return 1;\n if (n % 2 == 0) return Pow(m * m, n >> 1);\n else return Pow(m * m, n >> 1) * m;\n }\n\n public static void Build(int n)\n {\n fac = new ModInt[n + 1];\n facinv = new ModInt[n + 1];\n inv = new ModInt[n + 1];\n inv[1] = 1;\n fac[0] = fac[1] = 1;\n facinv[0] = facinv[1] = 1;\n for (var i = 2; i <= n; i++)\n {\n fac[i] = fac[i - 1] * i;\n inv[i] = MOD - inv[MOD % i] * (MOD / i);\n facinv[i] = facinv[i - 1] * inv[i];\n }\n }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static ModInt Fac(ModInt n) => fac[n];\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static ModInt Inv(ModInt n) => inv[n];\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static ModInt FacInv(ModInt n) => facinv[n];\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static ModInt Comb(ModInt n, ModInt r)\n {\n if (n < r) return 0;\n if (n == r) return 1;\n var calc = fac[n];\n calc = calc * facinv[r];\n calc = calc * facinv[n - r];\n return calc;\n }\n}\n#region Template\npublic static class Template\n{\n static void Main(string[] args)\n {\n Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });\n new Solver().Solve(new Scanner());\n Console.Out.Flush();\n }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static bool chmin(ref T a, T b) where T : IComparable { if (a.CompareTo(b) == 1) { a = b; return true; } return false; }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static bool chmax(ref T a, T b) where T : IComparable { if (a.CompareTo(b) == -1) { a = b; return true; } return false; }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static void swap(ref T a, ref T b) { var t = b; b = a; a = t; }\n public static T[] Shuffle(this IList A) { T[] rt = A.ToArray(); Random rnd = new Random(); for (int i = rt.Length - 1; i >= 1; i--) swap(ref rt[i], ref rt[rnd.Next(i + 1)]); return rt; }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static T[] Create(int n, Func f) { var rt = new T[n]; for (var i = 0; i < rt.Length; ++i) rt[i] = f(); return rt; }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public static T[] Create(int n, Func f) { var rt = new T[n]; for (var i = 0; i < rt.Length; ++i) rt[i] = f(i); return rt; }\n public static void Fail(T s) { Console.WriteLine(s); Console.Out.Close(); Environment.Exit(0); }\n}\npublic class Scanner\n{\n public string Str => Console.ReadLine().Trim();\n public int Int => int.Parse(Str);\n public long Long => long.Parse(Str);\n public double Double => double.Parse(Str);\n public int[] ArrInt => Str.Split(' ').Select(int.Parse).ToArray();\n public long[] ArrLong => Str.Split(' ').Select(long.Parse).ToArray();\n public char[][] Grid(int n) => Create(n, () => Str.ToCharArray());\n public int[] ArrInt1D(int n) => Create(n, () => Int);\n public long[] ArrLong1D(int n) => Create(n, () => Long);\n public int[][] ArrInt2D(int n) => Create(n, () => ArrInt);\n public long[][] ArrLong2D(int n) => Create(n, () => ArrLong);\n private Queue q = new Queue();\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public T Next() { if (q.Count == 0) foreach (var item in Str.Split(' ')) q.Enqueue(item); return (T)Convert.ChangeType(q.Dequeue(), typeof(T)); }\n public void Make(out T1 v1) => v1 = Next();\n public void Make(out T1 v1, out T2 v2) { v1 = Next(); v2 = Next(); }\n public void Make(out T1 v1, out T2 v2, out T3 v3) { Make(out v1, out v2); v3 = Next(); }\n public void Make(out T1 v1, out T2 v2, out T3 v3, out T4 v4) { Make(out v1, out v2, out v3); v4 = Next(); }\n public void Make(out T1 v1, out T2 v2, out T3 v3, out T4 v4, out T5 v5) { Make(out v1, out v2, out v3, out v4); v5 = Next(); }\n public void Make(out T1 v1, out T2 v2, out T3 v3, out T4 v4, out T5 v5, out T6 v6) { Make(out v1, out v2, out v3, out v4, out v5); v6 = Next(); }\n //public (T1, T2) Make() { Make(out T1 v1, out T2 v2); return (v1, v2); }\n //public (T1, T2, T3) Make() { Make(out T1 v1, out T2 v2, out T3 v3); return (v1, v2, v3); }\n //public (T1, T2, T3, T4) Make() { Make(out T1 v1, out T2 v2, out T3 v3, out T4 v4); return (v1, v2, v3, v4); }\n}\npublic class Pair : IComparable>\n{\n public T1 v1;\n public T2 v2;\n public Pair() { }\n public Pair(T1 v1, T2 v2)\n { this.v1 = v1; this.v2 = v2; }\n\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public int CompareTo(Pair p)\n {\n var c = Comparer.Default.Compare(v1, p.v1);\n if (c == 0)\n c = Comparer.Default.Compare(v2, p.v2);\n return c;\n }\n public override string ToString() => $\"{v1.ToString()} {v2.ToString()}\";\n public void Deconstruct(out T1 a, out T2 b) { a = v1; b = v2; }\n}\n\npublic class Pair : Pair, IComparable>\n{\n public T3 v3;\n public Pair() : base() { }\n public Pair(T1 v1, T2 v2, T3 v3) : base(v1, v2)\n { this.v3 = v3; }\n\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public int CompareTo(Pair p)\n {\n var c = base.CompareTo(p);\n if (c == 0)\n c = Comparer.Default.Compare(v3, p.v3);\n return c;\n }\n public override string ToString() => $\"{base.ToString()} {v3.ToString()}\";\n public void Deconstruct(out T1 a, out T2 b, out T3 c) { Deconstruct(out a, out b); c = v3; }\n}\n#endregion", "lang_cluster": "C#", "tags": ["math", "combinatorics"], "code_uid": "b9d76cf058e12920144d9b5695bc62a4", "src_uid": "28d6fc8973a3e0076a21c2ea490dfdba", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.IO;\nusing System.Text;\nusing System.Numerics;\nusing static System.Math;\nusing static System.Array;\nusing static AtCoder.Tool;\nusing static AtCoder.CalcL;\nnamespace AtCoder\n{\n class AC\n {\n //const int MOD = 1000000007;\n const int MOD = 998244353;\n const int INF = int.MaxValue / 2;\n const long SINF = long.MaxValue / 2;\n const double EPS = 1e-8;\n static readonly int[] dI = { 0, 1, 0, -1 };\n static readonly int[] dJ = { 1, 0, -1, 0 };\n static List> G = new List>();\n //List> G = new List>();\n //static List E = new List();\n static void Main(string[] args)\n {\n //var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };\n //Console.SetOut(sw);\n var cin = new Scanner();\n\n //var t = int.Parse(Console.ReadLine());\n for(var _ = 0; _ < 1; _++)\n {\n var input = cin.ReadSplitInt();\n int n = input[0];\n int m = input[1];\n if (m < n - 1)\n {\n Console.WriteLine(0);\n return;\n }\n var md = new Modulo(m + 10, MOD);\n long ans = 0;\n for(var k = n - 1; k <= m; k++)\n {\n ans += md.Mul(md.Pow(2, n - 3), md.Mul(md.Ncr(k - 1, n - 2), (n - 2)));\n ans %= MOD;\n }\n Console.WriteLine(ans);\n }\n\n\n //Console.Out.Flush();\n }\n struct Edge\n {\n public int from;\n\n public int to;\n public long dist;\n public Edge(int t, long c)\n {\n from = -1;\n to = t;\n dist = c;\n }\n public Edge(int f, int t, long c)\n {\n from = f;\n to = t;\n dist = c;\n }\n\n }\n }\n \n public class Scanner\n {\n public int[] ReadSplitInt()\n {\n return ConvertAll(Console.ReadLine().Split(), int.Parse);\n }\n public long[] ReadSplitLong()\n {\n return ConvertAll(Console.ReadLine().Split(), long.Parse);\n }\n public double[] ReadSplit_Double()\n {\n return ConvertAll(Console.ReadLine().Split(), double.Parse);\n }\n }\n public static class Tool\n {\n static public void Initialize(ref T[] array, T initialvalue)\n {\n for (var i = 0; i < array.Length; i++)\n {\n array[i] = initialvalue;\n }\n }\n static public void Swap(ref T a, ref T b)\n {\n T keep = a;\n a = b;\n b = keep;\n }\n\n static public void Display(T[,] array2d, int n, int m)\n {\n for (var i = 0; i < n; i++)\n {\n for (var j = 0; j < m; j++)\n {\n Console.Write($\"{array2d[i, j]} \");\n }\n Console.WriteLine();\n }\n }\n\n static public long LPow(int a, int b)\n {\n return (long)Pow(a, b);\n }\n }\n static public class CalcI\n {\n public static int Gcd(int a, int b)\n {\n if (a * b == 0) { return Max(a, b); }\n return a % b == 0 ? b : Gcd(b, a % b);\n }\n public static int Lcm(int a, int b)\n {\n int g = Gcd(a, b);\n return a / g * b;\n }\n public static int Ceil(int n, int div)\n {\n return (n + div - 1) / div;\n }\n }\n static public class CalcL\n {\n public static long Gcd(long a, long b)\n {\n if (a * b == 0) { return Max(a, b); }\n return a % b == 0 ? b : Gcd(b, a % b);\n }\n public static long Lcm(long a, long b)\n {\n long g = Gcd(a, b);\n return a / g * b;\n }\n public static long Ceil(long n, long div)\n {\n return (n + div - 1) / div;\n }\n }\n class Modulo\n {\n private int M;\n private readonly long[] m_facs;\n public long Mul(long a, long b)\n {\n return ((a * b) % M);\n }\n public Modulo(long n, int m)\n {\n M = m;\n m_facs = new long[n + 1];\n m_facs[0] = 1;\n for (long i = 1; i <= n; ++i)\n {\n m_facs[i] = Mul(m_facs[i - 1], i);\n }\n }\n public long Fac(long n)\n {\n return m_facs[n];\n }\n public long Pow(long a, long m)\n {\n switch (m)\n {\n case 0:\n return 1L;\n case 1:\n return a;\n default:\n long p1 = Pow(a, m / 2);\n long p2 = Mul(p1, p1);\n return ((m % 2) == 0) ? p2 : Mul(p2, a);\n }\n }\n public long Div(long a, long b)\n {\n return Mul(a, Pow(b, M - 2));\n }\n public long Ncr(long n, long r)\n {\n if (n < r) { return 0; }\n if (n == r) { return 1; }\n long res = Fac(n);\n res = Div(res, Fac(r));\n res = Div(res, Fac(n - r));\n return res;\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "combinatorics"], "code_uid": "e593ad4cf53986dd3f1aad1d03f1d952", "src_uid": "28d6fc8973a3e0076a21c2ea490dfdba", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "C# 8", "source_code": "\ufeffusing System;\r\nusing System.Collections.Generic;\r\nusing System.Linq;\r\nusing System.Threading;\r\nusing System.Threading.Tasks;\r\n\r\nnamespace ConsoleApp1\r\n{\r\n\r\n class Program\r\n {\r\n\r\n static bool def(List mas, List an, int ind)\r\n {\r\n var cnt = 0;\r\n for(int i=ind, j = 0; i < mas.Count && j < an.Count ; i++, j++)\r\n {\r\n if (mas[i] != an[j])\r\n return false;\r\n cnt++;\r\n }\r\n if (cnt < an.Count)\r\n return false;\r\n for (int i = 0; i < ind; i++)\r\n if (mas[i] == 0)\r\n return false;\r\n for (int i = ind + an.Count; i < mas.Count; i++)\r\n if (mas[i] == 0)\r\n return false;\r\n if (an[an.Count - 1] == 0 && ind + an.Count >= mas.Count)\r\n return false;\r\n if (an[0] == 0 && ind == 0)\r\n return false;\r\n return true;\r\n }\r\n\r\n static async Task Main(string[] args)\r\n {\r\n var input = Console.ReadLine().Split(' ').Select(long.Parse).ToList();\r\n long x = input[0], y = input[1];\r\n if( x == y)\r\n {\r\n Console.WriteLine(\"YES\");\r\n }\r\n else\r\n {\r\n var xmas = new List();\r\n while(x > 0)\r\n {\r\n xmas.Add(x % 2);\r\n x /= 2;\r\n }\r\n xmas.Reverse();\r\n\r\n var ymas = new List();\r\n while (y > 0)\r\n {\r\n ymas.Add(y % 2);\r\n y /= 2;\r\n }\r\n ymas.Reverse();\r\n\r\n var rxmas = xmas.Select(i => i).ToList();\r\n rxmas.Reverse();\r\n var gmas = xmas.Select(i => i).ToList();\r\n for (int i = gmas.Count() - 1; i >= 0; i--)\r\n if (gmas[i] == 0)\r\n gmas.RemoveAt(i);\r\n else\r\n break;\r\n var rgmas = gmas.Select(i => i).ToList();\r\n rgmas.Reverse();\r\n\r\n var good = true;\r\n for(int i=0;i < ymas.Count(); i++)\r\n {\r\n if (def(ymas, xmas, i))\r\n {\r\n Console.WriteLine(\"YES\");\r\n return;\r\n }\r\n if (def(ymas, rxmas, i))\r\n {\r\n Console.WriteLine(\"YES\");\r\n return;\r\n }\r\n if (def(ymas, gmas, i))\r\n {\r\n Console.WriteLine(\"YES\");\r\n return;\r\n }\r\n if (def(ymas, rgmas, i))\r\n {\r\n Console.WriteLine(\"YES\");\r\n return;\r\n }\r\n }\r\n Console.WriteLine(\"NO\");\r\n }\r\n }\r\n }\r\n}\r\n", "lang_cluster": "C#", "tags": ["dfs and similar", "constructive algorithms", "math", "bitmasks", "strings", "implementation"], "code_uid": "35c7812f14fef4203795772d68cbca02", "src_uid": "9f39a3c160087beb0efab2e3cb510e89", "difficulty": 2000.0, "exec_outcome": "PASSED"} {"lang": "C# 8", "source_code": "using System;\r\nusing System.Linq;\r\nusing CompLib.Util;\r\nusing System.Threading;\r\nusing System.IO;\r\nusing System.Collections.Generic;\r\nusing System.Text;\r\n\r\npublic class Program\r\n{\r\n long X, Y;\r\n public void Solve()\r\n {\r\n var sc = new Scanner();\r\n X = sc.NextLong();\r\n Y = sc.NextLong();\r\n\r\n if (X == Y)\r\n {\r\n Console.WriteLine(\"YES\");\r\n return;\r\n }\r\n\r\n bool[] by = ToArray(Y);\r\n\r\n bool[] bx1 = ToArray(2 * X + 1);\r\n if (F(by, bx1))\r\n {\r\n Console.WriteLine(\"YES\");\r\n return;\r\n }\r\n Array.Reverse(bx1);\r\n if (F(by, bx1))\r\n {\r\n Console.WriteLine(\"YES\");\r\n return;\r\n }\r\n\r\n while (X % 2 == 0) X /= 2;\r\n bool[] bx2 = ToArray(X);\r\n if (F(by, bx2))\r\n {\r\n Console.WriteLine(\"YES\");\r\n return;\r\n }\r\n Array.Reverse(bx2);\r\n if (F(by, bx2))\r\n {\r\n Console.WriteLine(\"YES\");\r\n return;\r\n }\r\n\r\n Console.WriteLine(\"NO\");\r\n }\r\n\r\n\r\n bool F(bool[] fy, bool[] fx)\r\n {\r\n if (fy.Length < fx.Length) return false;\r\n bool left = true;\r\n for (int i = 0; i + fx.Length <= fy.Length && left; i++)\r\n {\r\n bool flag = true;\r\n for (int j = 0; j < fx.Length && flag; j++)\r\n {\r\n flag &= fx[j] == fy[i + j];\r\n }\r\n if (flag)\r\n {\r\n for (int j = i + fx.Length; j < fy.Length && flag; j++)\r\n {\r\n flag &= fy[j];\r\n }\r\n if (flag) return true;\r\n }\r\n\r\n left &= fy[i];\r\n }\r\n return false;\r\n }\r\n\r\n bool[] ToArray(long n)\r\n {\r\n int lg = 0;\r\n long tmp = n;\r\n while (tmp > 0)\r\n {\r\n lg++;\r\n tmp /= 2;\r\n }\r\n\r\n tmp = n;\r\n bool[] ret = new bool[lg];\r\n for (int i = 0; i < lg; i++)\r\n {\r\n ret[i] = tmp % 2 == 1;\r\n tmp /= 2;\r\n }\r\n return ret;\r\n }\r\n\r\n public static void Main(string[] args) => new Program().Solve();\r\n // public static void Main(string[] args) => new Thread(new Program().Solve, 1 << 27).Start();\r\n}\r\n\r\nnamespace CompLib.Util\r\n{\r\n using System;\r\n using System.Linq;\r\n\r\n class Scanner\r\n {\r\n private string[] _line;\r\n private int _index;\r\n private const char Separator = ' ';\r\n\r\n public Scanner()\r\n {\r\n _line = new string[0];\r\n _index = 0;\r\n }\r\n\r\n public string Next()\r\n {\r\n if (_index >= _line.Length)\r\n {\r\n string s;\r\n do\r\n {\r\n s = Console.ReadLine();\r\n } while (s.Length == 0);\r\n\r\n _line = s.Split(Separator);\r\n _index = 0;\r\n }\r\n\r\n return _line[_index++];\r\n }\r\n\r\n public string ReadLine()\r\n {\r\n _index = _line.Length;\r\n return Console.ReadLine();\r\n }\r\n\r\n public int NextInt() => int.Parse(Next());\r\n public long NextLong() => long.Parse(Next());\r\n public double NextDouble() => double.Parse(Next());\r\n public decimal NextDecimal() => decimal.Parse(Next());\r\n public char NextChar() => Next()[0];\r\n public char[] NextCharArray() => Next().ToCharArray();\r\n\r\n public string[] Array()\r\n {\r\n string s = Console.ReadLine();\r\n _line = s.Length == 0 ? new string[0] : s.Split(Separator);\r\n _index = _line.Length;\r\n return _line;\r\n }\r\n\r\n public int[] IntArray() => Array().Select(int.Parse).ToArray();\r\n public long[] LongArray() => Array().Select(long.Parse).ToArray();\r\n public double[] DoubleArray() => Array().Select(double.Parse).ToArray();\r\n public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();\r\n }\r\n}\r\n", "lang_cluster": "C#", "tags": ["dfs and similar", "constructive algorithms", "math", "bitmasks", "strings", "implementation"], "code_uid": "f8e50a328a6ffb942f141e2f3819a308", "src_uid": "9f39a3c160087beb0efab2e3cb510e89", "difficulty": 2000.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "//\n\nusing System;\nusing System.Collections.Generic;\nusing System.Text;\nusing System.IO;\nusing System.Threading;\nusing System.Diagnostics;\nusing System.Globalization;\nusing System.Text.RegularExpressions;\nusing System.Linq;\n\nnamespace sar_cs\n{\n static class Helpers\n {\n // Mono lacks this override of string.Join()\n public static string Join(this IEnumerable objs, string sep)\n {\n var sb = new StringBuilder();\n foreach (var s in objs) { if (sb.Length != 0) sb.Append(sep); sb.Append(s); }\n return sb.ToString();\n }\n\n public static string AsString(this double a, int digits)\n {\n return a.ToString(\"F\" + digits, CultureInfo.InvariantCulture);\n }\n\n public static Stopwatch SW = Stopwatch.StartNew();\n }\n\n public class Program\n {\n #region Helpers\n\n public class Parser\n {\n const int BufSize = 8000;\n TextReader s;\n char[] buf = new char[BufSize];\n int bufPos;\n int bufDataSize;\n bool eos; // eos read to buffer\n int lastChar = -2;\n int nextChar = -2;\n StringBuilder sb = new StringBuilder();\n\n void FillBuf()\n {\n if (eos) return;\n bufDataSize = s.Read(buf, 0, BufSize);\n if (bufDataSize == 0) eos = true;\n bufPos = 0;\n }\n\n int Read()\n {\n if (nextChar != -2)\n {\n lastChar = nextChar;\n nextChar = -2;\n }\n else\n {\n if (bufPos == bufDataSize) FillBuf();\n if (eos) lastChar = -1;\n else lastChar = buf[bufPos++];\n }\n return lastChar;\n }\n\n void Back()\n {\n if (lastChar == -2) throw new Exception(); // no chars were ever read\n nextChar = lastChar;\n }\n\n public Parser()\n {\n s = Console.In;\n }\n\n public int ReadInt()\n {\n int res = 0;\n int sign = -1;\n int c;\n do { c = Read(); } while (c >= 0 && char.IsWhiteSpace((char)c));\n if (c == '-') { sign = 1; c = Read(); }\n int len = 0;\n while (c >= 0 && !char.IsWhiteSpace((char)c))\n {\n if ((uint)(c -= 48) >= 10) throw new FormatException();\n len++;\n res = checked(res * 10 - c);\n c = Read();\n }\n if (len == 0) throw new FormatException();\n Back();\n return checked(res * sign);\n }\n\n public long ReadLong()\n {\n long res = 0;\n int sign = -1;\n int c;\n do { c = Read(); } while (c >= 0 && char.IsWhiteSpace((char)c));\n if (c == '-')\n {\n sign = 1;\n c = Read();\n }\n int len = 0;\n\n while (c >= 0 && !char.IsWhiteSpace((char)c))\n {\n if ((uint)(c -= 48) >= 10) throw new FormatException();\n len++;\n res = checked(res * 10 - c);\n c = Read();\n }\n if (len == 0) throw new FormatException();\n Back();\n return checked(res * sign);\n }\n\n public int ReadLnInt()\n {\n int res = ReadInt(); ReadLine(); return res;\n }\n\n public long ReadLnLong()\n {\n long res = ReadLong(); ReadLine(); return res;\n }\n\n public double ReadDouble()\n {\n int c;\n do { c = Read(); } while (c >= 0 && char.IsWhiteSpace((char)c));\n\n int sign = 1;\n if (c == '-') { sign = -1; c = Read(); }\n\n sb.Length = 0;\n while (c >= 0 && !char.IsWhiteSpace((char)c))\n {\n sb.Append((char)c); c = Read();\n }\n\n Back();\n var res = double.Parse(sb.ToString(), CultureInfo.InvariantCulture);\n return res * sign;\n }\n\n public string ReadLine()\n {\n int c = Read();\n sb.Length = 0;\n while (c != -1 && c != 13 && c != 10)\n {\n sb.Append((char)c); c = Read();\n }\n if (c == 13) { c = Read(); if (c != 10) Back(); }\n return sb.ToString();\n }\n\n public bool SeekEOF\n {\n get\n {\n L0:\n int c = Read();\n if (c == -1) return true;\n if (char.IsWhiteSpace((char)c)) goto L0;\n Back();\n return false;\n }\n }\n\n public int[] ReadIntArr(int n)\n {\n var a = new int[n]; for (int i = 0; i < n; i++) a[i] = ReadInt(); return a;\n }\n\n public long[] ReadLongArr(int n)\n {\n var a = new long[n]; for (int i = 0; i < n; i++) a[i] = ReadLong(); return a;\n }\n }\n\n static void pe() { Console.WriteLine(\"???\"); Environment.Exit(0); }\n static void re() { Environment.Exit(55); }\n static void Swap(ref T a, ref T b) { T t = a; a = b; b = t; }\n static int Sqr(int a) { return a * a; }\n static long SqrL(int a) { return (long)a * a; }\n static long Sqr(long a) { return a * a; }\n static double Sqr(double a) { return a * a; }\n\n static StringBuilder sb = new StringBuilder();\n static Random rand = new Random(5);\n\n #endregion Helpers\n\n static void Main(string[] args)\n {\n checked\n {\n //Console.SetIn(File.OpenText(\"_input\"));\n var parser = new Parser();\n while (!parser.SeekEOF)\n {\n double a = parser.ReadDouble();\n double b = parser.ReadDouble();\n double m = parser.ReadDouble();\n double vx = parser.ReadDouble();\n double vy = parser.ReadDouble();\n double vz = parser.ReadDouble();\n\n double t = m / -vy;\n double t_bak = t;\n\n /* x result */\n double x = a / 2;\n if (vx != 0)\n {\n while (t > 0)\n {\n if (vx < 0)\n {\n double tt = x / -vx;\n if (t <= tt)\n {\n x += t * vx;\n break;\n }\n else\n {\n x = 0;\n vx = -vx;\n t -= tt;\n }\n }\n else\n {\n double tt = (a - x) / vx;\n if (t <= tt)\n {\n x += t * vx;\n break;\n }\n else\n {\n x = a;\n vx = -vx;\n t -= tt;\n }\n }\n }\n }\n\n /* z result */\n t = t_bak;\n double z = 0;\n if (vz != 0)\n {\n while (t > 0)\n {\n if (vz < 0)\n {\n double tt = z / -vz;\n if (t <= tt)\n {\n z += t * vz;\n break;\n }\n else\n {\n z = 0;\n vz = -vz;\n t -= tt;\n }\n }\n else\n {\n double tt = (b - z) / vz;\n if (t <= tt)\n {\n z += t * vz;\n break;\n }\n else\n {\n z = b;\n vz = -vz;\n t -= tt;\n }\n }\n }\n }\n\n\n Console.WriteLine(x.AsString(10) + \" \" + z.AsString(10));\n }\n }\n }\n\n //static void Main(string[] args)\n //{\n // new Thread(Main2, 50 << 20).Start();\n //}\n }\n}", "lang_cluster": "C#", "tags": ["math", "geometry", "implementation"], "code_uid": "4781159704e3d33c4bae7f05b3941b2f", "src_uid": "84848b8bd92fd2834db1ee9cb0899cff", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\n\nnamespace CodeForces\n{\n class Program\n {\n struct Matrix\n {\n public long A1, A2, A3, A4;\n const long BMod = 10000000;\n\n public static long MulMod(long a, long b, long mod)\n {\n if (a == 0 || b == 0)\n return 0;\n else if (long.MaxValue / b > a)\n return (a * b) % mod;\n else\n {\n long j0 = a / BMod;\n long j1 = a % BMod;\n long k0 = b / BMod;\n long k1 = b % BMod;\n long r = (((j0 * k1 + j1 * k0) % (mod / BMod)) * BMod + j1 * k1) % mod;\n return r;\n }\n }\n\n public static Matrix MulMod(Matrix m1, Matrix m2, long mod)\n {\n Matrix result = new Matrix();\n result.A1 = (MulMod(m1.A1, m2.A1, mod) + MulMod(m1.A2, m2.A3, mod)) % mod;\n result.A2 = (MulMod(m1.A1, m2.A2, mod) + MulMod(m1.A2, m2.A4, mod)) % mod;\n result.A3 = (MulMod(m1.A3, m2.A1, mod) + MulMod(m1.A4, m2.A3, mod)) % mod;\n result.A4 = (MulMod(m1.A3, m2.A2, mod) + MulMod(m1.A4, m2.A4, mod)) % mod;\n return result;\n }\n\n public void Mod(long mod)\n {\n A1 %= mod; A2 %= mod; A3 %= mod; A4 %= mod;\n }\n\n public static Matrix PowerMod(long power, Matrix m, long mod)\n {\n Matrix modLast = m, result = new Matrix();\n\n while (power != 0)\n {\n if ((power & 1) == 1)\n {\n if (result.A1 == 0)\n result = modLast;\n else\n result = Matrix.MulMod(result, modLast, mod);\n }\n\n modLast = Matrix.MulMod(modLast, modLast, mod);\n power >>= 1;\n }\n\n return result;\n }\n }\n\n struct Result\n {\n public long Index, Value;\n public int SIndex;\n }\n\n static void Main(string[] args)\n {\n long[] steps = new long[] { 60, 300, 1500, 15000, 150000, 1500000, 15000000, 150000000, 1500000000, 15000000000, 150000000000, 1500000000000, 15000000000000, 150000000000000, 1500000000000000, 15000000000000000 };\n long[] mods = new long[] { 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000, 10000000000, 100000000000, 1000000000000, 10000000000000, 100000000000000, 1000000000000000, 10000000000000000 };\n\n long n = Convert.ToInt64(Console.ReadLine());\n\n if (n == 1)\n {\n Console.WriteLine(1);\n return;\n }\n\n int index = 0;\n long modValue = n % mods[index];\n\n Queue queue = new Queue();\n long[] fs = new long[60]; fs[1] = 1;\n\n for (int i = 2; i < fs.Length; i++)\n {\n fs[i] = (fs[i - 1] + fs[i - 2]) % mods[index];\n if (fs[i] == modValue)\n queue.Enqueue(new Result { Index = i, Value = fs[i], SIndex = index });\n }\n\n List result = new List();\n\n while (queue.Count > 0)\n {\n Result current = queue.Dequeue();\n\n if (current.Value == n && current.SIndex == 12)\n {\n result.Add(current);\n continue;\n }\n else if (current.SIndex > 12)\n continue;\n\n for (int i = 0; i * steps[current.SIndex] < steps[current.SIndex + 1]; i++)\n {\n long nIndex = i * steps[current.SIndex] + current.Index;\n long value = Cal(nIndex, mods[current.SIndex + 1]);\n\n if (value == n % mods[current.SIndex + 1])\n queue.Enqueue(new Result { Index = nIndex, SIndex = current.SIndex + 1, Value = value });\n }\n }\n\n if (result.Count == 0)\n Console.WriteLine(-1);\n else\n {\n long sIndex = result.Select(x => x.Index).Min();\n Console.WriteLine(sIndex);\n }\n }\n\n static long Cal(long index, long mod)\n {\n Matrix m = new Matrix { A1 = 1, A2 = 1, A3 = 1, A4 = 0 };\n Matrix power = Matrix.PowerMod(index, m, mod);\n return (long)power.A2;\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "math", "matrices"], "code_uid": "7f643c061208ee8a527f1b7663a5bb11", "src_uid": "cbf786abfceeb8df29732c8a872f7f8a", "difficulty": 2900.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\n\nusing System;\nusing System.Collections;\nusing System.Collections.Generic;\nusing System.Diagnostics;\nusing System.IO;\nusing System.Linq;\n\nnamespace Codeforces\n{\n public class Input\n {\n private static string _line;\n\n public static bool Next()\n {\n _line = Console.ReadLine();\n return _line != null;\n }\n\n public static bool Next(out long a)\n {\n var ok = Next();\n a = ok ? long.Parse(_line) : 0;\n return ok;\n }\n\n public static bool Next(out long a, out long b)\n {\n var ok = Next();\n if (ok)\n {\n var array = _line.Split(' ').Select(long.Parse).ToArray();\n a = array[0];\n b = array[1];\n }\n else\n {\n a = b = 0;\n }\n\n return ok;\n }\n\n public static bool Next(out long a, out long b, out long c)\n {\n var ok = Next();\n if (ok)\n {\n var array = _line.Split(' ').Select(long.Parse).ToArray();\n a = array[0];\n b = array[1];\n c = array[2];\n }\n else\n {\n a = b = c = 0;\n }\n return ok;\n }\n\n public static bool Next(out long a, out long b, out long c, out long d)\n {\n var ok = Next();\n if (ok)\n {\n var array = _line.Split(' ').Select(long.Parse).ToArray();\n a = array[0];\n b = array[1];\n c = array[2];\n d = array[3];\n }\n else\n {\n a = b = c = d = 0;\n }\n return ok;\n }\n\n public static bool Next(out long a, out long b, out long c, out long d, out long e)\n {\n var ok = Next();\n if (ok)\n {\n var array = _line.Split(' ').Select(long.Parse).ToArray();\n a = array[0];\n b = array[1];\n c = array[2];\n d = array[3];\n e = array[4];\n }\n else\n {\n a = b = c = d = e = 0;\n }\n return ok;\n }\n\n public static List Numbers()\n {\n return !Next() ? new List() : _line.Split(' ').Select(long.Parse).ToList();\n }\n\n public static bool Next(out string value)\n {\n value = string.Empty;\n if (!Next()) return false;\n value = _line;\n return true;\n }\n }\n\n public class DisjointSet\n {\n private readonly int[] _parent;\n private readonly int[] _rank;\n public int Count { get; private set; }\n\n public DisjointSet(int count, int initialize = 0)\n {\n Count = count;\n _parent = new int[Count];\n _rank = new int[Count];\n for (var i = 0; i < initialize; i++) _parent[i] = i;\n }\n\n private DisjointSet(int count, int[] parent, int[] rank)\n {\n Count = count;\n _parent = parent;\n _rank = rank;\n }\n\n public void Add(int v)\n {\n _parent[v] = v;\n _rank[v] = 0;\n }\n\n public int Find_Recursive(int v)\n {\n if (_parent[v] == v) return v;\n return _parent[v] = Find(_parent[v]);\n }\n\n public int Find(int v)\n {\n if (_parent[v] == v) return v;\n var last = v;\n while (_parent[last] != last) last = _parent[last];\n while (_parent[v] != v)\n {\n var t = _parent[v];\n _parent[v] = last;\n v = t;\n }\n return last;\n }\n\n public int this[int v]\n {\n get { return Find(v); }\n set { Union(v, value); }\n }\n\n public void Union(int a, int b)\n {\n a = Find(a);\n b = Find(b);\n if (a == b) return;\n if (_rank[a] < _rank[b])\n {\n var t = _rank[a];\n _rank[a] = _rank[b];\n _rank[b] = t;\n }\n _parent[b] = a;\n if (_rank[a] == _rank[b]) _rank[a]++;\n }\n\n public int GetSetCount()\n {\n var result = 0;\n for (var i = 0; i < Count; i++)\n {\n if (_parent[i] == i) result++;\n }\n return result;\n }\n\n public DisjointSet Clone()\n {\n var rank = new int[Count];\n _rank.CopyTo(rank, 0);\n var parent = new int[Count];\n _parent.CopyTo(parent, 0);\n return new DisjointSet(Count, parent, rank);\n }\n\n public override string ToString()\n {\n return string.Join(\",\", _parent.Take(50));\n }\n }\n\n public class Matrix\n {\n public static Matrix Create(int i, int j)\n {\n var m = new Matrix(i, j);\n return m;\n }\n\n public static Matrix Create(int i)\n {\n var m = new Matrix(i, i);\n return m;\n }\n\n public long Modulo { get; set; }\n\n private readonly int _width;\n private readonly int _height;\n private readonly long[,] _data;\n public int Width{get { return _width; }}\n public int Height{get { return _height; }}\n\n private Matrix(int i, int j)\n {\n Modulo = 1000000000000000000L;\n _width = j;\n _height = i;\n _data = new long[_height, _width];\n }\n\n public static Matrix operator *(Matrix m1, Matrix m2)\n {\n if (m1.Width != m2.Height) throw new InvalidDataException(\"m1.Width != m2.Height\");\n var m = Create(m2.Width, m1.Height);\n m.Modulo = m1.Modulo;\n for (var i=0;i : IEnumerable>\n {\n private readonly List _items = new List();\n private Node _root;\n private readonly IComparer _comparer;\n\n public RedBlackTree()\n {\n _comparer = Comparer.Default;\n }\n\n private Node _search(TKey key)\n {\n var node = _root;\n while (node != null)\n {\n var i = _comparer.Compare(key, node.Key);\n if (i == 0) return node;\n node = i > 0 ? node.Right : node.Left;\n }\n return null;\n }\n\n public void Add(TKey key, TValue value)\n {\n var node = new Node { Key = key, Value = value, Red = true };\n _items.Add(node);\n if (_root == null)\n {\n _root = node;\n _root.Red = false;\n return;\n }\n var x = _root;\n Node y = null;\n while (x != null)\n {\n y = x;\n x = _comparer.Compare(key, x.Key) > 0 ? x.Right : x.Left;\n }\n node.Parent = y;\n if (y == null) _root = node;\n else if (_comparer.Compare(key, y.Key) > 0) y.Right = node;\n else y.Left = node;\n InsertFixup(node);\n }\n\n private void InsertFixup(Node node)\n {\n while (true)\n {\n var parent = node.Parent;\n if (parent == null || !parent.Red || parent.Parent == null) break;\n var grand = parent.Parent;\n\n if (parent == grand.Left)\n {\n var uncle = grand.Right;\n if (uncle != null && uncle.Red) /* parent and uncle both red: we could swap colors of them with grand */\n {\n parent.Red = false;\n uncle.Red = false;\n grand.Red = true;\n node = grand; /* and continue fixing tree for grand */\n }\n else if (node == parent.Right) /* we rotate around the parent */\n {\n node = parent;\n RotateLeft(node);\n }\n else /* rotate around grand and switch colors of grand and parent */\n {\n parent.Red = false;\n grand.Red = true;\n RotateRight(grand);\n if (grand == _root) _root = parent;\n break; /* and finish since tree is fixed */\n }\n }\n else\n {\n if (_root.Parent != null) Debugger.Break();\n\n var uncle = grand.Left;\n if (uncle != null && uncle.Red) /* parent and uncle both red: we could swap colors of them with grand */\n {\n parent.Red = false;\n uncle.Red = false;\n grand.Red = true;\n node = grand; /* and continue fixing tree for grand */\n }\n else if (node == parent.Left) /* we rotate around the parent */\n {\n node = parent;\n RotateRight(node);\n }\n else /* rotate around grand and switch colors of grand and parent */\n {\n parent.Red = false;\n grand.Red = true;\n RotateLeft(grand);\n if (grand == _root) _root = parent;\n break; /* and finish since tree is fixed */\n }\n }\n }\n _root.Red = false;\n }\n\n private void RotateLeft(Node node)\n {\n if (node.Right == null)\n throw new NotSupportedException(\"Cannot rotate left: right node is missing\");\n var parent = node.Parent;\n var right = node.Right;\n right.Parent = parent;\n if (parent != null)\n {\n if (parent.Left == node) parent.Left = right;\n else parent.Right = right;\n }\n node.Right = right.Left;\n if (node.Right != null)\n node.Right.Parent = node;\n right.Left = node;\n node.Parent = right;\n }\n\n private void RotateRight(Node node)\n {\n if (node.Left == null)\n throw new NotSupportedException(\"Cannot rotate right: left node is missing\");\n var parent = node.Parent;\n var left = node.Left;\n left.Parent = parent;\n if (parent != null)\n {\n if (parent.Left == node) parent.Left = left;\n else parent.Right = left;\n }\n node.Left = left.Right;\n if (node.Left != null)\n node.Left.Parent = node;\n left.Right = node;\n node.Parent = left;\n }\n\n public void Remove(TKey key)\n {\n var node = _search(key);\n if (node == null) return;\n\n var deleted = node.Left == null || node.Right == null ? node : Next(node);\n var child = deleted.Left ?? deleted.Right;\n if (child != null)\n child.Parent = deleted.Parent;\n if (deleted.Parent == null) /* root */\n _root = child;\n else if (deleted == deleted.Parent.Left)\n deleted.Parent.Left = child;\n else\n deleted.Parent.Right = child;\n if (node != deleted)\n {\n node.Key = deleted.Key;\n node.Value = deleted.Value;\n }\n\n if (!deleted.Red)\n {\n DeleteFixup(child, deleted.Parent);\n }\n }\n\n private void DeleteFixup(Node node, Node parent)\n {\n while (parent != null && (node == null || !node.Red))\n {\n if (node == parent.Left)\n {\n var brother = parent.Right;\n if (brother.Red)\n {\n brother.Red = false;\n parent.Red = true;\n RotateLeft(parent);\n brother = parent.Right;\n }\n if ((brother.Left == null || !brother.Left.Red) && (brother.Right == null || !brother.Right.Red))\n {\n node = parent.Red ? _root : parent;\n brother.Red = true;\n parent.Red = false;\n }\n else\n {\n if (brother.Right == null || !brother.Right.Red)\n {\n if (brother.Left != null)\n brother.Left.Red = false;\n brother.Red = true;\n RotateRight(brother);\n brother = parent.Right;\n }\n if (!brother.Right.Red) Debugger.Break();\n brother.Red = parent.Red;\n parent.Red = false;\n if (brother.Right != null)\n brother.Right.Red = false;\n RotateLeft(parent);\n node = _root;\n }\n }\n else\n {\n var brother = parent.Left;\n if (brother.Red)\n {\n brother.Red = false;\n parent.Red = true;\n RotateRight(parent);\n brother = parent.Left;\n }\n if ((brother.Right == null || !brother.Right.Red) && (brother.Left == null || !brother.Left.Red))\n {\n node = parent.Red ? _root : parent;\n brother.Red = true;\n parent.Red = false;\n }\n else\n {\n if (brother.Left == null || !brother.Left.Red)\n {\n if (brother.Right != null)\n brother.Right.Red = false;\n brother.Red = true;\n RotateLeft(brother);\n brother = parent.Left;\n }\n brother.Red = parent.Red;\n parent.Red = false;\n if (brother.Left != null)\n brother.Left.Red = false;\n RotateRight(parent);\n node = _root;\n }\n }\n parent = node.Parent;\n }\n\n node.Red = false;\n }\n\n public TValue this[TKey key]\n {\n get\n {\n var node = _search(key);\n return node == null ? default(TValue) : node.Value;\n }\n set\n {\n var node = _search(key);\n if (node == null) Add(key, value);\n else node.Value = value;\n }\n }\n\n public bool Check()\n {\n int count;\n return _root == null || _root.Check(out count);\n }\n\n private Node Minimum(Node node)\n {\n var result = node;\n while (result.Left != null) result = result.Left;\n return result;\n }\n\n private Node Maximum(Node node)\n {\n var result = node;\n while (result.Right != null) result = result.Right;\n return result;\n }\n\n private Node Next(Node node)\n {\n Node result;\n if (node.Right != null)\n {\n result = Minimum(node.Right);\n }\n else\n {\n while (node.Parent != null && node.Parent.Right == node)\n node = node.Parent;\n result = node.Parent;\n }\n return result;\n }\n\n private Node Previous(Node node)\n {\n Node result;\n if (node.Left != null)\n {\n result = Maximum(node.Left);\n }\n else\n {\n while (node.Parent != null && node.Parent.Left == node)\n node = node.Parent;\n result = node.Parent;\n }\n return result;\n }\n\n public void Print()\n {\n var node = Minimum(_root);\n while (node != null)\n {\n Console.Write(node.Red ? '*' : ' ');\n Console.Write(node.Key);\n Console.Write('\\t');\n node = Next(node);\n }\n }\n\n #region Nested classes\n\n [DebuggerDisplay(\"{ToString()}\")]\n private sealed class Node\n {\n public TKey Key;\n public TValue Value;\n public bool Red;\n\n public Node Parent;\n public Node Left;\n public Node Right;\n\n public bool Check(out int count)\n {\n count = 0;\n if (Red)\n {\n if (Left != null && Left.Red) return false;\n if (Right != null && Right.Red) return false;\n }\n var left = 0;\n var right = 0;\n if (Left != null && !Left.Check(out left)) return false;\n if (Right != null && !Right.Check(out right)) return false;\n count = left + (Red ? 0 : 1);\n if (left != right)\n {\n ;\n }\n return left == right;\n }\n\n public override string ToString()\n {\n return ToShortString(2);\n }\n\n private string ToShortString(int depth = 0)\n {\n return depth == 0\n ? string.Format(\"{0}{1}\", Red ? \"*\" : \"\", Key)\n : string.Format(\"({1}<{0}>{2})\", ToShortString(), Left == null ? \"null\" : Left.ToShortString(depth - 1), Right == null ? \"null\" : Right.ToShortString(depth - 1));\n }\n }\n\n #endregion\n\n #region IEnumerable\n\n public IEnumerator> GetEnumerator()\n {\n throw new NotImplementedException();\n }\n\n IEnumerator IEnumerable.GetEnumerator()\n {\n return GetEnumerator();\n }\n\n #endregion\n }\n}\n\nnamespace Codeforces.TaskC\n{\n public class Task\n {\n public static void Main()\n {\n var task = new Task();\n try\n {\n task.Solve();\n }\n catch (Exception ex)\n {\n Console.ForegroundColor = ConsoleColor.Red;\n Console.WriteLine(ex);\n throw;\n }\n }\n\n /*abacabadabacaba*/\n \n private long MaxSubstring(long best, long l, long r, long a, long b, int ch)\n {\n if (l > r || a > b) return best;\n if ((best >= b - a + 1) || (best >= r - l + 1)) return best;\n\n best = Math.Max(best, Math.Min(r, b) - Math.Max(l, a) + 1);\n var divide = 1 << ch;\n bool f1 = false, f2 = false;\n\n if (r == divide && l == r) return best;\n if (a == divide && a == b) return best;\n \n if (l == divide) l++;\n if (r == divide) r--;\n if (a == divide) a++;\n if (b == divide) b--;\n\n if (l > divide)\n {\n l -= divide;\n f1 = true;\n }\n if (r > divide)\n {\n r -= divide;\n f1 = !f1;\n }\n if (a > divide)\n {\n a -= divide;\n f2 = true;\n }\n if (b > divide)\n {\n b -= divide;\n f2 = !f2;\n }\n\n if (--ch >= 0)\n {\n if (f1 && f2) best = Math.Max(Math.Max(best, divide - Math.Max(l, a)), Math.Min(r, b));\n if (f1 && !f2)\n {\n best = MaxSubstring(best, l, divide - 1, a, b, ch);\n best = MaxSubstring(best, 1, r, a, b, ch);\n }\n if (!f1 && f2)\n {\n best = MaxSubstring(best, l, r, a, divide - 1, ch);\n best = MaxSubstring(best, l, r, 1, b, ch);\n }\n if (!f1 && !f2) best = MaxSubstring(best, l, r, a, b, ch);\n if (f1 && f2)\n {\n best = MaxSubstring(best, 1, r, a, divide - 1, ch);\n best = MaxSubstring(best, l, divide - 1, 1, b, ch);\n }\n }\n\n return best;\n }\n\n void Solve()\n {\n long l1, r1, l2, r2;\n Input.Next(out l1, out r1, out l2, out r2);\n var n = MaxSubstring(0, l1, r1, l2, r2, 29);\n Console.WriteLine(n);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["divide and conquer"], "code_uid": "8cae75607a1fa80db14110eb2499b979", "src_uid": "fe3c0c4c7e9b3afebf2c958251f10513", "difficulty": 2400.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.ComponentModel;\nusing System.Diagnostics;\nusing System.IO;\nusing System.Linq;\nusing System.Text;\n//using DebugerVisualizer;\n\nnamespace _105\n{\n\t[Serializable]\n\tclass VNodeValue\n\t{\n\t\tpublic int Version;\n\t\tpublic TNode Value;\n\n\t\tpublic VNodeValue(int version)\n\t\t{\n\t\t\tVersion = version;\n\t\t}\n\t}\n\n\t[Serializable]\n\tclass VEdge\n\t\twhere TNode : ICloneable\n\t{\n\t\tpublic TEdge Value;\n\t\tpublic VNode Source;\n\t\tpublic VNode Target;\n\n\t\tpublic override string ToString()\n\t\t{\n\t\t\treturn Value.ToString();\n\t\t}\n\t}\n\n\t[Serializable]\n\tclass VEdges\n\t\twhere TNode : ICloneable\n\t{\n\t\tpublic int Version;\n\t\tpublic List> Edges = new List>();\n\n\t\tpublic VEdges(int version)\n\t\t{\n\t\t\tVersion = version;\n\t\t}\n\t}\n\n\t[Serializable]\n\tclass VNode\n\t\twhere TNode : ICloneable\n\t{\n\t\tVGraph _graph;\n\n\t\tStack> _valueStack = new Stack>();\n\t\tStack> _ins = new Stack>();\n\t\tStack> _outs = new Stack>();\n\n\t\tinternal VNode(VGraph graph, TNode nodeValue)\n\t\t{\n\t\t\t_graph = graph;\n\t\t\tvar newNode = new VNodeValue(_graph.Version);\n\t\t\tnewNode.Value = nodeValue;\n\t\t\t_valueStack.Push(newNode);\n\t\t\t_ins.Push(new VEdges(_graph.Version));\n\t\t\t_outs.Push(new VEdges(_graph.Version));\n\t\t}\n\n\t\tpublic TNode ReadValue\n\t\t{\n\t\t\tget { return _valueStack.Peek().Value; }\n\t\t}\n\n\t\tpublic TNode WriteValue\n\t\t{\n\t\t\tget\n\t\t\t{\n\t\t\t\tif (_valueStack.Peek().Version != _graph.Version)\n\t\t\t\t{\n\t\t\t\t\tvar newVersion = new VNodeValue(_graph.Version);\n\t\t\t\t\tif (_valueStack.Peek().Value != null)\n\t\t\t\t\t\tnewVersion.Value = (TNode)_valueStack.Peek().Value.Clone();\n\t\t\t\t\t_valueStack.Push(newVersion);\n\t\t\t\t\t_graph.SheduleValueRollback(this);\n\t\t\t\t}\n\n\t\t\t\treturn _valueStack.Peek().Value;\n\t\t\t}\n\t\t}\n\n\t\tpublic IEnumerable> Ins\n\t\t{\n\t\t\tget\n\t\t\t{\n\t\t\t\tforeach (var edges in _ins)\n\t\t\t\t\tforeach (var e in edges.Edges)\n\t\t\t\t\t{\n\t\t\t\t\t\tyield return e;\n\t\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tpublic IEnumerable> Outs\n\t\t{\n\t\t\tget\n\t\t\t{\n\t\t\t\tforeach (var edges in _outs)\n\t\t\t\t\tforeach (var e in edges.Edges)\n\t\t\t\t\t{\n\t\t\t\t\t\tyield return e;\n\t\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tpublic void AddIns(VEdge edge)\n\t\t{\n\t\t\tif (_ins.Peek().Version != _graph.Version)\n\t\t\t{\n\t\t\t\tvar newVersion = new VEdges(_graph.Version);\n\t\t\t\t_ins.Push(newVersion);\n\t\t\t\t_graph.SheduleInEdgeRollback(this);\n\t\t\t}\n\t\t\t_ins.Peek().Edges.Add(edge);\n\t\t}\n\n\t\tpublic void AddOut(VEdge edge)\n\t\t{\n\t\t\tif (_outs.Peek().Version != _graph.Version)\n\t\t\t{\n\t\t\t\tvar newVersion = new VEdges(_graph.Version);\n\t\t\t\t_outs.Push(newVersion);\n\t\t\t\t_graph.SheduleOutEdgeRollback(this);\n\t\t\t}\n\t\t\t_outs.Peek().Edges.Add(edge);\n\t\t}\n\n\t\tinternal void RollbackValue()\n\t\t{\n\t\t\t_valueStack.Pop();\n\t\t}\n\n\t\tinternal void RollbackIns()\n\t\t{\n\t\t\t_ins.Pop();\n\t\t}\n\n\t\tinternal void RollbackOuts()\n\t\t{\n\t\t\t_outs.Pop();\n\t\t}\n\n\t\tpublic override string ToString()\n\t\t{\n\t\t\treturn ReadValue.ToString();\n\t\t}\n\t}\n\n\t[Serializable]\n\tclass VGraph : IDisposable\n\t\twhere TNode : ICloneable\n\t{\n\t\tpublic int Version = 0;\n\n\t\tStack>> _valueRollbacks = new Stack>>();\n\t\tStack>> _inEdgeRollbacks = new Stack>>();\n\t\tStack>> _outEdgeRollbacks = new Stack>>();\n\n\t\tpublic VGraph()\n\t\t{\n\t\t\tStartTransaction();\n\t\t}\n\n\t\tpublic void SheduleValueRollback(VNode node)\n\t\t{\n\t\t\t_valueRollbacks.Peek().Add(node);\n\t\t}\n\n\t\tpublic void SheduleInEdgeRollback(VNode node)\n\t\t{\n\t\t\t_inEdgeRollbacks.Peek().Add(node);\n\t\t}\n\n\t\tpublic void SheduleOutEdgeRollback(VNode node)\n\t\t{\n\t\t\t_outEdgeRollbacks.Peek().Add(node);\n\t\t}\n\n\t\tpublic VNode AddNode(TNode nodeValue)\n\t\t{\n\t\t\treturn new VNode(this, nodeValue);\n\t\t}\n\n\t\tpublic void AddEdge(VNode a, VNode b, TEdge edgeValue)\n\t\t{\n\t\t\tvar newEdge = new VEdge();\n\t\t\tnewEdge.Source = a;\n\t\t\tnewEdge.Target = b;\n\t\t\tnewEdge.Value = edgeValue;\n\n\t\t\ta.AddOut(newEdge);\n\t\t\tb.AddIns(newEdge);\n\t\t}\n\n\t\tpublic VGraph StartTransaction()\n\t\t{\n\t\t\tthis.Version++;\n\t\t\t_valueRollbacks.Push(new List>());\n\t\t\t_inEdgeRollbacks.Push(new List>());\n\t\t\t_outEdgeRollbacks.Push(new List>());\n\t\t\treturn this;\n\t\t}\n\n\t\tpublic void Rollback()\n\t\t{\n\t\t\tforeach (var values in _valueRollbacks.Pop())\n\t\t\t\tvalues.RollbackValue();\n\t\t\tforeach (var values in _inEdgeRollbacks.Pop())\n\t\t\t\tvalues.RollbackIns();\n\t\t\tforeach (var values in _outEdgeRollbacks.Pop())\n\t\t\t\tvalues.RollbackOuts();\n\t\t\tthis.Version--;\n\t\t}\n\n\t\tpublic void Dispose()\n\t\t{\n\t\t\tRollback();\n\t\t}\n\t}\n\n\t//[DebuggerVisualizer(typeof(ExpressionBuilderVisualizer))]\n\t[Serializable]\n\tclass GameState : IDisposable\n\t{\n\t\tVGraph _graph = new VGraph();\n\t\tStack>> nodes = new Stack>>();\n\t\tStack[]> playerNodes = new Stack[]>();\n\t\tVNode[] playerStartNodes = new VNode[3];\n\t\tint nodesCount = 0;\n\n\t\tpublic IEnumerable> Nodes\n\t\t{\n\t\t\tget\n\t\t\t{\n\t\t\t\tforeach (var ns in nodes)\n\t\t\t\t\tforeach (var node in ns)\n\t\t\t\t\t\tyield return node; \n\t\t\t}\n\t\t}\n\n\t\tpublic void ClearTrace(Player[] players)\n\t\t{\n\t\t\tforeach (var node in Nodes)\n\t\t\t{\n\t\t\t\tnode.WriteValue.Min = int.MinValue/2;\n\t\t\t\tnode.WriteValue.Max = int.MaxValue/2;\n\t\t\t}\n\n\t\t\tfor (int i = 0; i < 3; i++)\n\t\t\t{\n\t\t\t\tplayerStartNodes[i].WriteValue.Min = playerStartNodes[i].WriteValue.Max = players[i].Start;\n\t\t\t}\n\t\t}\n\n\t\tpublic GameState(Player[] players)\n\t\t{\n\t\t\tnodes.Push(new List>());\n\n\t\t\tplayerNodes.Push(new VNode[3]);\n\t\t\tfor (int i = 0; i < 3; i++)\n\t\t\t{\n\t\t\t\tvar node = _graph.AddNode(new ExpressionNode() { Id = i, Min = players[i].Start, Max = players[i].Start, Comment = \"S(\"+ i.ToString() +\")\" });\n\t\t\t\tnodes.Peek().Add(node);\n\t\t\t\tplayerStartNodes[i] = node;\n\t\t\t\tplayerNodes.Peek()[i] = node;\n\t\t\t}\n\t\t\tnodesCount = 3;\n\t\t}\n\n\t\tpublic GameState StartTransaction()\n\t\t{\n\t\t\t_graph.StartTransaction();\n\t\t\tnodes.Push(new List>());\n\t\t\tplayerNodes.Push( (VNode[])playerNodes.Peek().Clone());\n\t\t\treturn this;\n\t\t}\n\n\t\tpublic void Dispose()\n\t\t{\n\t\t\t_graph.Rollback();\n\n\t\t\tnodesCount -= nodes.Pop().Count;\n\t\t\tplayerNodes.Pop();\n\t\t}\n\n\t\tpublic int Max\n\t\t{\n\t\t\tget\n\t\t\t{\n\t\t\t\tint max = Int32.MinValue;\n\t\t\t\tforeach (var node in Nodes)\n\t\t\t\t{\n\t\t\t\t\tif (max < node.ReadValue.Max)\n\t\t\t\t\t\tmax = node.ReadValue.Max;\n\t\t\t\t}\n\n\t\t\t\treturn max;\n\t\t\t}\n\t\t}\n\n\t\tpublic VNode AddPlayerNode(int i, string comment)\n\t\t{\n\t\t\tvar nodeValue = new ExpressionNode() { Id = nodesCount++ };\n\t\t\tnodeValue.Comment = comment;\n\t\t\tvar node = _graph.AddNode(nodeValue);\n\t\t\tnodes.Peek().Add(node);\n\t\t\tplayerNodes.Peek()[i] = node;\n\t\t\treturn node;\n\t\t}\n\n\t\tpublic VNode GetPlayerNode(int i)\n\t\t{\n\t\t\treturn playerNodes.Peek()[i];\n\t\t}\n\n\t\tpublic VNode GetPlayerStartNode(int i)\n\t\t{\n\t\t\treturn playerStartNodes[i];\n\t\t}\n\n\t\t//a <= b + c\n\t\tpublic bool AddMin(VNode a, VNode b, int c)\n\t\t{\n\t\t\tvar path = new ExpressionPath() { Mark = c };\n\t\t\t_graph.AddEdge(b, a, path);\n\n\t\t\tif (a.ReadValue.Max > b.ReadValue.Max + c)\n\t\t\t\ta.WriteValue.Max = b.ReadValue.Max + c;\n\n\t\t\tif (b.ReadValue.Min < a.ReadValue.Min - c)\n\t\t\t\tb.WriteValue.Min = a.ReadValue.Min - c;\n\n\t\t\tif (!Trace(a))\n\t\t\t\treturn false;\n\t\t\tif (!Trace(b))\n\t\t\t\treturn false;\n\t\t\tif (!Validate())\n\t\t\t\treturn false;\n\n\t\t\treturn true;\n\t\t}\n\n\t\tbool Trace(VNode a)\n\t\t{\n\t\t\tif (!TraceMin(this, a))\n\t\t\t\treturn false;\n\t\t\tif (!TraceMax(this, a))\n\t\t\t\treturn false;\n\t\t\treturn true;\n\t\t}\n\n\t\tstatic bool TraceMin(GameState state, VNode x)\n\t\t{\n\t\t\tx.WriteValue.Traced = true;\n\n\t\t\ttry\n\t\t\t{\n\t\t\t\tforeach (var vector in state.Maximize(x))\n\t\t\t\t{\n\t\t\t\t\t// x <= path.Max + path.Mark\n\n\t\t\t\t\tif (vector.Target.ReadValue.Traced)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (vector.Target.ReadValue.Min < x.ReadValue.Min - vector.Mark)\n\t\t\t\t\t\t\treturn false;\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\tif (vector.Target.ReadValue.Min < x.ReadValue.Min - vector.Mark)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tvector.Target.WriteValue.Min = x.ReadValue.Min - vector.Mark;\n\t\t\t\t\t\t\tif (!TraceMin(state, vector.Target))\n\t\t\t\t\t\t\t\treturn false;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\tfinally\n\t\t\t{\n\t\t\t\tx.WriteValue.Traced = false;\n\t\t\t}\n\t\t}\n\n\t\tstatic bool TraceMax(GameState state, VNode x)\n\t\t{\n\t\t\tx.WriteValue.Traced = true;\n\n\t\t\ttry\n\t\t\t{\n\t\t\t\tforeach (var vector in state.Minimize(x))\n\t\t\t\t{\n\t\t\t\t\tif (vector.Target.ReadValue.Traced)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (vector.Target.ReadValue.Max > x.ReadValue.Max + vector.Mark)\n\t\t\t\t\t\t\treturn false;\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\tif (vector.Target.ReadValue.Max > x.ReadValue.Max + vector.Mark)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tvector.Target.WriteValue.Max = x.ReadValue.Max + vector.Mark;\n\t\t\t\t\t\t\tif (!TraceMax(state, vector.Target))\n\t\t\t\t\t\t\t\treturn false;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\tfinally\n\t\t\t{\n\t\t\t\tx.WriteValue.Traced = false;\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic IEnumerable Maximize(VNode a)\n\t\t{\n\t\t\treturn a.Ins.Select(path => new Vector(path.Value.Mark, path.Source));\n\t\t}\n\n\t\tpublic IEnumerable Minimize(VNode a)\n\t\t{\n\t\t\treturn a.Outs.Select(path => new Vector(path.Value.Mark, path.Target));\n\t\t}\n\n\t\tpublic bool Validate()\n\t\t{\n\t\t\tforeach (var node in Nodes)\n\t\t\t{\n\t\t\t\tif (node.ReadValue.Min > node.ReadValue.Max)\n\t\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\treturn true;\n\t\t}\n\n\t\tpublic override string ToString()\n\t\t{\n\t\t\tstring result = \"\";\n\n\t\t\tforeach (var node in Nodes.Reverse())\n\t\t\t{\n\t\t\t\tresult += node.ReadValue.ToString();\n\t\t\t}\n\n\t\t\treturn result;\n\t\t}\n\t}\n\n\t[Serializable]\n\tstruct Vector\n\t{\n\t\tpublic int Mark;\n\t\tpublic VNode Target;\n\n\t\tpublic Vector(int mark, VNode target)\n\t\t{\n\t\t\tMark = mark;\n\t\t\tTarget = target;\n\t\t}\n\t}\n\n\n\t[Serializable]\n\tinternal class Player\n\t{\n\t\tpublic int Start;\n\t\tpublic int Walk;\n\t\tpublic int Throws;\n\n\t\tpublic bool alreadyWalked = false;\n\t\tpublic bool alreadyUpped = false;\n\t\tpublic bool alreadyThrowed = false;\n\t\tpublic bool Upped = false;\n\t\tpublic int Up = -1;\n\t}\n\n\t[Serializable]\n\tclass ExpressionNode : ICloneable\n\t{\n\t\tpublic int Id;\n\t\tpublic int Min = int.MinValue/2;\n\t\tpublic int Max = int.MaxValue/2;\n\t\tpublic bool Traced = false;\n\t\tpublic string Comment;\n\n\t\tpublic object Clone()\n\t\t{\n\t\t\treturn this.MemberwiseClone();\n\t\t}\n\n\t\tpublic override string ToString()\n\t\t{\n\t\t\treturn Comment + String.Format(\"[{0}:{1}]\", Min, Max);\n\t\t}\n\n\t}\n\n\t[Serializable]\n\t[ReadOnly(true)]\n\tstruct ExpressionPath\n\t{\n\t\tpublic int Mark;\n\n\t\tpublic override string ToString()\n\t\t{\n\t\t\tvar result = String.Format(\"({0})\", Mark);\n\t\t\treturn result;\n\t\t}\n\t}\n\n\tclass Program\n\t{\n\t\t//static StreamReader inStream = new StreamReader(\"input.txt\");\n\t\t//static string ReadLine()\n\t\t//{\n\t\t// return inStream.ReadLine();\n\t\t//}\n\n\t\tstatic string ReadLine()\n\t\t{\n\t\t\treturn Console.ReadLine();\n\t\t}\n\n\t\tstatic int AbsoluteMax = int.MinValue;\n\t\tstatic string AbsoluteMaxStr = \"\";\n\n\t\tstatic void Main(string[] args)\n\t\t{\n\t\t\tPlayer[] players = new Player[3];\n\t\t\tfor (int i = 0; i < 3; i++)\n\t\t\t{\n\t\t\t\tplayers[i] = new Player();\n\t\t\t\tstring[] arg = ReadLine().Split();\n\t\t\t\tplayers[i].Start = int.Parse(arg[0]);\n\t\t\t\tplayers[i].Walk = int.Parse(arg[1]);\n\t\t\t\tplayers[i].Throws = int.Parse(arg[2]);\n\t\t\t}\n\n\n\t\t\tvar state = new GameState(players);\n\t\t\n\t\t\tSolve(state, players);\n\t\t\tConsole.WriteLine(AbsoluteMax);\n\t\t\t//Console.WriteLine(AbsoluteMaxStr);\n\t\t}\n\n\n\t\tstatic void Solve(GameState state, Player[] players)\n\t\t{\n\t\t\tif (EuristicGetMax(state, players) <= AbsoluteMax)\n\t\t\t\treturn;\n\n\t\t\tint max = state.Max;\n\t\t\tif (AbsoluteMax < max)\n\t\t\t{\n\t\t\t\tAbsoluteMax = max;\n\t\t\t\tAbsoluteMaxStr = state.ToString();\n\t\t\t}\n\n\t\t\tfor (int i = 0; i < 3; i++)\n\t\t\t{\n\t\t\t\tusing (var clone = state.StartTransaction())\n\t\t\t\t{\n\t\t\t\t\tDoMove(i, clone, players);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tfor (int i = 0; i < 3; i++)\n\t\t\t\tfor (int j = 0; j < 3; j++)\n\t\t\t\t\tif (i != j)\n\t\t\t\t\t{\n\t\t\t\t\t\tusing (var clone = state.StartTransaction())\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tDoUp(i, j, clone, players);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\tfor (int i = 0; i < 3; i++)\n\t\t\t{\n\t\t\t\tusing (var clone = state.StartTransaction())\n\t\t\t\t{\n\t\t\t\t\tDoThrow(i, clone, players);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tstatic private void DoMove(int i, GameState state, Player[] players)\n\t\t{\n\t\t\tif (players[i].alreadyWalked || players[i].Up >= 0 || players[i].Upped)\n\t\t\t\treturn;\n\n\t\t\tplayers[i].alreadyWalked = true;\n\n\t\t\tVNode a = state.GetPlayerNode(i);\n\t\t\tVNode moved = state.AddPlayerNode(i, string.Format(\"M({0})\", i));\n\n\t\t\tif (!state.AddMin(moved, a, players[i].Walk))\n\t\t\t\treturn;\n\t\t\tif (!state.AddMin(a, moved, players[i].Walk))\n\t\t\t\treturn;\n\n\t\t\tusing (var clone = state.StartTransaction())\n\t\t\t{\n\t\t\t\tNotEqual(players, i, clone);\n\t\t\t}\n\n\t\t\tplayers[i].alreadyWalked = false;\n\t\t}\n\n\t\tprivate static void DoThrow(int i, GameState state, Player[] players)\n\t\t{\n\t\t\tif (players[i].alreadyThrowed || players[i].Up < 0 || players[i].Upped)\n\t\t\t\treturn;\n\n\t\t\tplayers[i].alreadyThrowed = true;\n\n\t\t\tint j = players[i].Up;\n\t\t\tplayers[i].Up = -1;\n\t\t\tplayers[j].Upped = false;\n\n\t\t\tVNode a = state.GetPlayerNode(i);\n\t\t\tVNode moved = state.AddPlayerNode(j, string.Format(\"T({0}, {1})\", i, j));\n\n\t\t\tif (!state.AddMin(moved, a, players[i].Throws))\n\t\t\t\treturn;\n\t\t\tif (!state.AddMin(a, moved, players[i].Throws))\n\t\t\t\treturn;\n\n\t\t\tNotEqual(players, j, state);\n\n\t\t\tplayers[j].Upped = true;\n\t\t\tplayers[i].Up = j;\n\t\t\tplayers[i].alreadyThrowed = false;\n\t\t}\n\n\t\tprivate static void DoUp(int i, int j, GameState state, Player[] players)\n\t\t{\n\t\t\tif (players[i].alreadyUpped || players[i].Up >= 0 || players[i].Upped || players[j].Upped || i == j)\n\t\t\t\treturn;\n\n\t\t\tplayers[i].alreadyUpped = true;\n\t\t\tplayers[i].Up = j;\n\t\t\tplayers[j].Upped = true;\n\n\t\t\tVNode a = state.GetPlayerNode(i);\n\t\t\tVNode b = state.GetPlayerNode(j);\n\n\t\t\tVNode moved = state.AddPlayerNode(j, string.Format(\"U({0}, {1})\", i, j));\n\n\t\t\tif (!state.AddMin(moved, a, 0))\n\t\t\t\treturn;\n\t\t\tif (!state.AddMin(a, moved, 0))\n\t\t\t\treturn;\n\n\t\t\tEqual(state, players, a, b, 1);\n\t\t\tEqual(state, players, a, b, -1);\n\n\t\t\tplayers[j].Upped = false;\n\t\t\tplayers[i].Up = -1;\n\t\t\tplayers[i].alreadyUpped = false;\n\t\t}\n\n\t\t//a = b + c\n\t\tprivate static void Equal(GameState state, Player[] players, VNode a, VNode b, int c)\n\t\t{\n\t\t\tusing (var v1 = state.StartTransaction())\n\t\t\t{\n\t\t\t\tif (v1.AddMin(b, a, -c) && v1.AddMin(a, b, c))\n\t\t\t\t\tSolve(v1, players);\n\t\t\t}\n\t\t}\n\n\t\tstatic private void NotEqual(Player[] players, int i, GameState state)\n\t\t{\n\t\t\tVNode a = state.GetPlayerNode(i); //current \n\t\t\tVNode b = state.GetPlayerNode((i + 1) % 3); //not equal to\n\t\t\tVNode c = state.GetPlayerNode((i + 2) % 3); //and not equal to\n\n\t\t\tusing (var v1 = state.StartTransaction())\n\t\t\t{\n\t\t\t\tif (v1.AddMin(a, b, -1) && v1.AddMin(a, c, -1))\n\t\t\t\t\tSolve(v1, players);\n\t\t\t}\n\n\t\t\tusing (var v2 = state.StartTransaction())\n\t\t\t{\n\t\t\t\tif (v2.AddMin(b, a, -1) && v2.AddMin(a, c, -1))\n\t\t\t\t\tSolve(v2, players);\n\t\t\t}\n\n\t\t\tusing (var v3 = state.StartTransaction())\n\t\t\t{\n\t\t\t\tif (v3.AddMin(b, a, -1) && v3.AddMin(c, a, -1))\n\t\t\t\t\tSolve(v3, players);\n\t\t\t}\n\n\t\t\tusing (var v4 = state.StartTransaction())\n\t\t\t{\n\t\t\t\tif (v4.AddMin(a, b, -1) && v4.AddMin(c, a, -1))\n\t\t\t\t\tSolve(v4, players);\n\t\t\t}\n\t\t}\n\n\t\tstatic int EuristicGetMax(GameState state, Player[] players)\n\t\t{\n\t\t\tint radius = 0;\n\n\t\t\tfor (int i = 0; i < 3; i++)\n\t\t\t{\n\t\t\t\tif (!players[i].alreadyThrowed)\n\t\t\t\t\tradius += players[i].Throws;\n\t\t\t\tif (!players[i].alreadyWalked)\n\t\t\t\t\tradius += players[i].Walk;\n\t\t\t\tif (!players[i].alreadyUpped)\n\t\t\t\t\tradius += 1;\n\t\t\t}\n\n\t\t\tvar result = Enumerable.Range(0,3).Max(i => state.GetPlayerNode(i).ReadValue.Max + radius);\n\t\t\treturn result;\n\t\t}\n\t}\n\n}\n", "lang_cluster": "C#", "tags": ["brute force"], "code_uid": "40a70fbad628713e29019b7ea1d208b7", "src_uid": "a14739b86d1fd62a030226263cdc1afc", "difficulty": 2500.0, "exec_outcome": "PASSED"}