{"lang": "Mono C#", "source_code": "using System;\nusing static System.Console;\nusing static System.Math;\nusing static System.Array;\nusing System.IO;\n\nnamespace ConsoleApp9\n{\n class Program\n {\n static void Conv(string[] a, int[] b)\n {\n for (int i = 0; i < a.Length; i++)\n {\n b[i] = Convert.ToInt32(a[i]);\n }\n }\n static void Print(int[] b)\n {\n for (int i = 0; i < b.Length; i++)\n {\n Write($\"{b[i]} \");\n }\n WriteLine();\n }\n static int Main(string[] args)\n {\n string[] s = ReadLine().Split(' ');\n int n = Convert.ToInt32(s[0]), m = Convert.ToInt32(s[1]);\n s = ReadLine().Split(' ');\n int[] b = new int[s.Length];\n Conv(s, b);\n s = ReadLine().Split(' ');\n int[] c = new int[s.Length];\n Conv(s, c);\n int summ1 =0,summ2=0,time1 =0,time2=0,j=n-1;\n for(int i = 0; i < b.Length; i++)\n {\n time1 += c[i];\n summ1 += Max(0, b[i] - time1 * m);\n time2 += c[j];\n summ2 += Max(0, b[j] - time2 * m);\n j--;\n }\n if (summ1 > summ2) WriteLine(\"Limak\");\n else if (summ1 < summ2) WriteLine(\"Radewoosh\");\n else WriteLine(\"Tie\");\n return 0;\n }\n\n\n }\n}", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "4c9100b93f6b660d6624694a0b2c8b6b", "src_uid": "8c704de75ab85f9e2c04a926143c8b4a", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.IO;\nusing System.Text;\n\nnamespace Nastya_and_a_Wardrobe\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 writer.WriteLine(Solve(args));\n writer.Flush();\n }\n\n private static long Pow(long a, long 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 long Solve(string[] args)\n {\n long x = Next();\n long k = Next();\n\n if (x == 0)\n return 0;\n\n long p = Pow(2, k);\n long ans = ((p * 2 + 2) / 2 + 2 * ((x - 1) % mod) * (p % mod)) % mod;\n return ans;\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": "788eeceb27754beaba8df8b7fb9e7982", "src_uid": "e0e017e8c8872fc1957242ace739464d", "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 TaskB\n{\n class Program\n {\n static void Main(string[] args)\n {\n int n = int.Parse(Console.ReadLine());\n\n long answer = 1;\n long prev=1;\n for (int i = 4; i <= n; i++)\n {\n prev += 2;\n answer += prev;\n }\n\n Console.WriteLine(answer);\n //Console.ReadLine();\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math"], "code_uid": "38580c434e4d6b87ef655238477a5623", "src_uid": "efa8e7901a3084d34cfb1a6b18067f2b", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\nusing 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,k;\n string s;\n var t = Console.ReadLine().Split(' ');\n n = int.Parse(t[0]);\n k = int.Parse(t[1]);\n s = Console.ReadLine();\n int m = 0, d = 0;\n foreach (var i in s)\n {\n if(i == 'N')\n ++d;\n else d = 0;\n if(d>m) m = d;\n }\n if(m > k)\n {Console.WriteLine(\"NO\");return;}\n s = \"Y\"+s+\"Y\";\n n = s.Length;\n for(int i = 1; i < n-k; ++i)\n {\n bool tr = s[i-1] != 'N' && s[i+k] != 'N';\n for(int j = 0; j < k; ++j)\n {\n if(s[j+i] == 'Y') tr = false;\n }\n if(tr)\n {\n Console.WriteLine(\"YES\");\n return;\n }\n }\n Console.WriteLine(\"NO\");\n\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["dp"], "code_uid": "4ac451ae321c0f28e22e4cd8f7144c65", "src_uid": "5bd578d3da5837c259b222336a194d12", "difficulty": 2000.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 A\n{\n class Program\n {\n static int GetIntNumber()\n {\n return Convert.ToInt32(Console.ReadLine());\n }\n\n static long GetLongNumber()\n {\n return Convert.ToInt64(Console.ReadLine());\n }\n\n static int[] GetArrayIntNumber()\n {\n string[] str = Console.ReadLine().Split(' ');\n int[] array = new int[str.Length];\n for (int i = 0; i < str.Length; i++)\n {\n array[i] = Convert.ToInt32(str[i]);\n }\n return array;\n }\n\n\t\tstatic long[] GetArrayLongNumber()\n\t\t{\n\t\t\tstring[] str = Console.ReadLine().Split(' ');\n\t\t\tlong[] array = new long[str.Length];\n\t\t\tfor (int i = 0; i < str.Length; i++)\n\t\t\t{\n\t\t\t\tarray[i] = Convert.ToInt64(str[i]);\n\t\t\t}\n\t\t\treturn array;\n\t\t}\n\n\t\tstatic void Main(string[] args)\n {\n var n = GetIntNumber();\n var a = GetArrayIntNumber().OrderBy(x => x).ToArray();\n var count = 0;\n for (int i = 0; i < n; i+=2)\n count += Math.Abs(a[i] - a[i + 1]);\n Console.WriteLine(count);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["sortings"], "code_uid": "e6c105b3fa124cb8b6ccc4eb0e51a925", "src_uid": "55485fe203a114374f0aae93006278d3", "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().Split();\n\t\tint N = int.Parse(str[0]);\n\t\tint K = int.Parse(str[1]);\n\t\tint[]A = new int[N];\n\t\tlong sum = 0;\n\t\tint c1 = 0;\n\t\tint c2 = 0;\n\t\tstring[] str2 = Console.ReadLine().Split();\n\t\tfor(var i=0;i q = new Queue();\n q.Enqueue(node);\n\n bool[] found = new bool[MAXN];\n\n while (q.Count != 0)\n {\n node = q.Dequeue();\n found[node.value] = true;\n\n if (node.value == m)\n {\n Console.WriteLine(node.level);\n break;\n }\n\n if (node.value * 2 < MAXN && !found[node.value * 2])\n {\n Node n1 = new Node(node.value * 2, node.level + 1);\n q.Enqueue(n1);\n }\n\n if (node.value - 1 >= 1 && !found[node.value - 1])\n {\n Node n2 = new Node(node.value - 1, node.level + 1);\n q.Enqueue(n2);\n }\n }\n }\n }\n}", "lang_cluster": "C#", "tags": ["dfs and similar", "shortest paths", "math", "graphs", "greedy", "implementation"], "code_uid": "2ae5d5bb0b778f3fa94e026e20c74d7e", "src_uid": "861f8edd2813d6d3a5ff7193a804486f", "difficulty": 1400.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 static void Main(string[] args)\n {\n\n Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;\n\n#if FileIO\n StreamReader sr = new StreamReader(\"forest.in\");\n StreamWriter sw = new StreamWriter(\"forest.out\");\n Console.SetIn(sr);\n Console.SetOut(sw);\n#endif\n\n int r1, r2, c1, c2, d1, d2;\n string[] input = ReadArray();\n r1 = int.Parse(input[0]);\n r2 = int.Parse(input[1]);\n input = ReadArray();\n c1 = int.Parse(input[0]);\n c2 = int.Parse(input[1]);\n input = ReadArray();\n d1 = int.Parse(input[0]);\n d2 = int.Parse(input[1]);\n\n int a11, a21, a12, a22;\n a11 = c1 + d1 - r2;\n if (a11 % 2 == 0)\n {\n a11 /= 2;\n }\n else\n {\n Console.WriteLine(-1);\n return;\n }\n a22 = d1 - a11;\n a21 = c1 - a11;\n a12 = c2 - a22;\n if (a11 == a12 || a11 == a21 || a11 == a22 || a12 == a21 || a12 == a22 || a21 == a22)\n {\n Console.WriteLine(-1);\n return;\n }\n if (a11 > 0 && a11 < 10 && a22 > 0 && a22 < 10 && a21 > 0 && a21 < 10 && a12 > 0 && a12 < 10)\n {\n Console.WriteLine(a11 + \" \" + a12);\n Console.WriteLine(a21 + \" \" + a22);\n }\n else\n {\n Console.WriteLine(-1);\n }\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 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 decimal Sqrt(decimal x)\n {\n decimal mid;\n decimal right = (x <= 1 ? 1 : x);\n decimal left = 0;\n decimal eps = 0.00000000000000000001m;\n while (right - left > eps)\n {\n mid = left + ((right - left) / 2m);\n if (Math.Sign(mid * mid - x) != Math.Sign(left * left - x))\n right = mid;\n else\n left = mid;\n }\n return (left + right) / 2m;\n }\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}", "lang_cluster": "C#", "tags": ["brute force", "math"], "code_uid": "8ac1b643c712d5b7d1ec8a91121d493e", "src_uid": "6821f502f5b6ec95c505e5dd8f3cd5d3", "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 x = 0;\n int.TryParse(Console.ReadLine(),out x);\n int minStep = 0;\n \n while(x!=0)\n {\n if(x-5>=0)\n {\n x -= 5;\n minStep++;\n }\n else if(x-4>=0)\n {\n x -= 4;\n minStep++;\n }\n else if (x - 3>= 0)\n {\n x -= 3;\n minStep++;\n }\n else if (x - 2 >= 0)\n {\n x -= 2;\n minStep++;\n }\n else\n {\n x -= 1;\n minStep++;\n }\n }\n \n\n Console.WriteLine(minStep);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math"], "code_uid": "7bb310bb03d96a76ad951918451d218d", "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.Globalization;\n\n\nnamespace ConsoleApplication1A\n{\n class ProgramAAA\n {\n\n static void Main()\n {\n\n string[] tk = Console.ReadLine().Split(' ');\n int n = Convert.ToInt32(tk[0]);\n int x = Convert.ToInt32(tk[1]);\n tk = Console.ReadLine().Split(' ');\n\n int[] M = new int[101];\n\n for (int i = 0; i < n; i++)\n {\n M[Convert.ToInt32(tk[i])] = 1;\n }\n\n int res = 0;\n for (int i = 0; i < x; i++)\n {\n if (M[i] == 0) res++; \n }\n if (M[x] == 1) res++;\n\n Console.WriteLine(res);\n }\n }\n}", "lang_cluster": "C#", "tags": ["greedy", "implementation"], "code_uid": "8e5899507a8a210500f90bbf93416352", "src_uid": "21f579ba807face432a7664091581cd8", "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 ConsoleApp9\n{\n class Program\n {\n static void Main(string[] args)\n {\n int[] s = Console.ReadLine().Split().Select(int.Parse).ToArray();\n int n = s[0];\n int a = s[1];\n int b = s[2];\n Console.WriteLine(n - Math.Max(a + 1, n - b) + 1);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math"], "code_uid": "9f4537efd4a9ef86b6b06073cf604ed9", "src_uid": "51a072916bff600922a77da0c4582180", "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 _3._5\n{\n class Program\n {\n static void Main(string[] args)\n {\n StringBuilder res = new StringBuilder();\n\n var x = readSplitedlongs(' ');\n var start = splitNum(x[0]).ToArray();\n\n for (int i = 0; i < start.Count(); ++i)\n {\n if (x[1] == 0)\n {\n break;\n }\n\n int maxval = 0;\n int maxindex = i;\n\n for (int j = i; j < start.Length && j - i <= x[1]; ++j)\n {\n if (start[j] > maxval)\n {\n maxval = start.ElementAt(j);\n maxindex = j;\n }\n }\n\n x[1] -= maxindex - i;\n\n for (int j = maxindex; j > i; --j)\n {\n int t = start[j];\n start[j] = start[j - 1];\n start[j - 1] = t;\n }\n }\n\n for (int i = 0; i < start.Length; ++i)\n {\n res.Append(start[i]);\n }\n\n Console.Out.WriteLine(res);\n }\n\n static long parselong(string str)\n {\n long res = 0;\n\n for (int i = 0; i < str.Length; ++i)\n {\n res *= 10;\n switch (str[i])\n {\n case '0':\n res += 0;\n break;\n case '1':\n res += 1;\n break;\n case '2':\n res += 2;\n break;\n case '3':\n res += 3;\n break;\n case '4':\n res += 4;\n break;\n case '5':\n res += 5;\n break;\n case '6':\n res += 6;\n break;\n case '7':\n res += 7;\n break;\n case '8':\n res += 8;\n break;\n case '9':\n res += 9;\n break;\n }\n }\n return res;\n }\n\n static long[] readSplitedlongs(char split)\n {\n var t = Console.In.ReadLine().Split(split);\n long[] res = new long[t.Length];\n for (long i = 0; i < t.Length; ++i)\n {\n res[i] = parselong(t[i]);\n }\n return res;\n }\n\n static long readlong()\n {\n return parselong(Console.In.ReadLine());\n }\n\n static IEnumerable splitNum(long num)\n {\n long x = num;\n int i = 0;\n while (x > 0)\n {\n x /= 10;\n i++;\n }\n\n int[] res = new int[i];\n\n i = 0;\n while (num > 0)\n {\n res[i] = (int)(num % 10);\n num /= 10;\n i++;\n }\n\n return res.Reverse();\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["greedy"], "code_uid": "944f7c8d9a834d19aab13c1c3cf887a5", "src_uid": "e56f6c343167745821f0b18dcf0d0cde", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Text;\n\nnamespace CodeForcesProblems\n{\n class A492_VanyaAndCubes\n {\n public static void Main()\n {\n //while(true)\n //{\n var value = int.Parse(Console.ReadLine());\n int i = 0;\n var sum = 0;\n var cubes = 0;\n var count = 0;\n while(true)\n {\n i++;\n sum += i;\n cubes += sum;\n count++;\n if (cubes > value)\n {\n count--;\n break;\n }\n if (cubes == value)\n break;\n }\n if(i==1)\n Console.WriteLine(1);\n else\n Console.WriteLine(count);\n //}\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "44ab5588b12e02e68dac604781894e65", "src_uid": "873a12edffc57a127fdfb1c65d43bdb0", "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 Schastl\n{\n class Program\n {\n static void Main(string[] args)\n {\n string str = Console.ReadLine();\n bool schast = true;\n foreach(char a in str)\n {\n if (!(a == '4' || a == '7'))\n schast = false;\n }\n if (schast)\n Console.WriteLine(\"YES\");\n else\n {\n int n = Convert.ToInt32(str);\n if (n % 4 == 0 || n % 7 == 0 || n % 47 == 0 || n % 74 == 0)\n Console.WriteLine(\"YES\");\n else\n Console.WriteLine(\"NO\");\n }\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "number theory"], "code_uid": "389bb900d43d53e6bef3d58fe5703da8", "src_uid": "78cf8bc7660dbd0602bf6e499bc6bb0d", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\n\nnamespace CF_Caps {\n class Program {\n static void Main(string[] args) {\n string input = Console.ReadLine();\n char firstletter = input[0];\n if (Char.IsUpper(input[0])) {\n firstletter = Char.ToLower(input[0]);\n } else {\n firstletter = Char.ToUpper(input[0]);\n }\n string output = input.Remove(0, 1);\n int uppercount = 0;\n for(int i = 0; i < output.Length; ++i) { \n if (Char.IsUpper(output[i])) {\n uppercount++;\n }\n }\n if(uppercount == output.Length) {\n output = output.ToLower();\n Console.WriteLine(firstletter + output);\n return;\n }\n Console.WriteLine(input);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["strings", "implementation"], "code_uid": "d32c120ec86ce576d8b333a909b8563a", "src_uid": "db0eb44d8cd8f293da407ba3adee10cf", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nnamespace Task26A\n{\n class Program\n {\n static void Main(string[] args)\n {\n int n, ans = 0;\n n = Convert.ToInt32(Console.ReadLine());\n List primes=new List ();\n for(int i = 2; i <= n; i++) \n if (isPrime(i))\n primes.Add(i);\n \n \n for (int i = 1; i <= n; i++)\n if (isAlmastPrime(ref primes,i))\n ans++;\n\n Console.WriteLine(ans);\n }\n\n private static bool isPrime(int N)\n {\n if (N == 2) return true;\n if (N < 2 || N % 2 == 0) return false;\n for (int i = 3; i <=Math.Sqrt(N); i += 2)\n if (N % i == 0) return false;\n return true;\n }\n\n private static bool isAlmastPrime(ref List mylist, int item)\n {\n int count = 0;\n for (int i = 0; i 2)\n return false;\n }\n return count == 2;\n }\n\n\n }\n}\n", "lang_cluster": "C#", "tags": ["number theory"], "code_uid": "6bce09378b3b0187d2c1fe4cbf35ceba", "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.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 int n = sc.Int;\n var a = new int[n];\n for (int i = 0; i < n; i++)\n {\n a[i] = sc.Int;\n }\n for (int i = 0; i < (1 << n); i++)\n {\n int sum = 0;\n for (int j = 0; j < n; j++)\n {\n if (((i >> j) & 1) == 1) {\n sum += a[j];\n }\n else\n sum -= a[j];\n }\n if (sum % 360 == 0) {\n DBG(\"YES\");\n return;\n }\n }\n Prt(\"NO\");\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", "lang_cluster": "C#", "tags": ["brute force", "dp", "bitmasks"], "code_uid": "4b3188c610a31caa68649e59f444c7f5", "src_uid": "01b50fcba4185ceb1eb8e4ba04a0cc10", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.IO;\nusing System.Linq;\n\nnamespace AcmSolution\n{\n class Program\n {\n static void Main(string[] args)\n {\n#if !ACM_HOME\n Do();\n#else\n var tmp = Console.In;\n Console.SetIn(new StreamReader(\"a.txt\"));\n while (Console.In.Peek() > 0)\n {\n Do();\n WL(\"Answer: \" + GetStr());\n }\n Console.In.Close();\n Console.SetIn(tmp);\n Console.ReadLine();\n#endif\n Console.Out.Close();\n }\n\n static int nod(int a, int b)\n {\n while (a != 0 && b != 0)\n {\n if (a >= b)\n a %= b;\n else\n b %= a;\n }\n return a + b;\n }\n\n private static void Do()\n {\n var s = GetInts();\n int a = s[0], b = s[1], n = s[2];\n bool Semen = true;\n\n while (n != 0)\n {\n var g = nod(n, Semen ? a : b);\n\n n -= g;\n\n if (n == 0) WL(Semen ? 0 : 1);\n Semen = !Semen;\n }\n }\n\n const double Epsilon = 0.00000001;\n\n static string GetStr()\n {\n return Console.ReadLine();\n }\n\n static string[] GetStrs()\n {\n return GetStr().Split(new[] { ' ', '\\t' }, StringSplitOptions.RemoveEmptyEntries);\n }\n\n 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 static int GetInt()\n {\n return Int32.Parse(GetStr());\n }\n\n 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 static int[] GetInts()\n {\n return GetStrs().Select(Int32.Parse).ToArray();\n }\n\n static long[] GetLongs()\n {\n return GetStrs().Select(Int64.Parse).ToArray();\n }\n\n static double[] GetDoubles()\n {\n return GetStrs().Select(Double.Parse).ToArray();\n }\n\n static long GetLong()\n {\n return Int64.Parse(GetStr());\n }\n\n static void WriteDouble(T d)\n {\n Console.WriteLine(String.Format(\"{0:0.000000000}\", d).Replace(',', '.'));\n }\n\n static void WL(T s)\n {\n Console.WriteLine(s);\n }\n\n static void W(T s)\n {\n Console.Write(s);\n }\n\n static void Assert(bool b)\n {\n if (!b) throw new Exception();\n }\n\n static void Swap(ref T a, ref T b)\n {\n var temp = a;\n a = b;\n b = temp;\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "e8bd3d95295be89016c8eaeb2789d05d", "src_uid": "0bd6fbb6b0a2e7e5f080a70553149ac2", "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 ConsoleApplication22\n{\n class Program\n {\n //1.\n static void Main(string[] args)\n {\n int a = int.Parse(Console.ReadLine());\n\n string result = \"NO\";\n\n if (a % 2 == 0)\n {\n int a1 = a / 2;\n int a2 = a / 2;\n\n if (a1 % 2 == 0 && a2 % 2 == 0)\n {\n result = \"YES\";\n }\n else\n {\n a1++;\n a2--;\n\n if (a1 % 2 == 0 && a2 % 2 == 0 && a1 != 0 && a2 != 0)\n {\n result = \"YES\";\n }\n }\n \n\n }\n Console.WriteLine(result);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "math"], "code_uid": "a18741527e2149a5cccee148cc244742", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Diagnostics;\nusing System.Text;\nusing System.IO;\nusing System.Collections.Generic;\n\nnamespace A\n{\n class Program\n {\n static bool getLen(int x, int y, int x2, int y2, int x3, int y3)\n {\n if ((x == x3 && y == y3) || (x == x2 && y == y2) || (x3 == x2 && y3 == y2)) return false;\n x -= x2;\n y -= y2;\n x3 -= x2;\n y3 -= y2;\n // Console.WriteLine(x * x3 + y * y3);\n return (x * x3 + y * y3) == 0;\n }\n\n public static void Main(string[] argv)\n {\n int[] x = new int[3];\n int[] y = new int[3];\n String[] s = Console.ReadLine().Split(' ');\n for (int i = 0; i < 3; i++)\n {\n x[i] = Int32.Parse(s[i * 2]);\n y[i] = Int32.Parse(s[i * 2 + 1]);\n }\n for (int i = 0; i < 3; i++)\n {\n if (getLen(x[i], y[i], x[(i + 1) % 3], y[(i + 1) % 3], x[(i + 2) % 3], y[(i + 2) % 3]))\n {\n Console.WriteLine(\"RIGHT\");\n return;\n }\n\n }\n int[] x2 = (int[])x.Clone();\n int[] y2 = (int[])y.Clone();\n for (int j = 0; j < 3; j++)\n {\n for (int p = -1; p <= 1; p++)\n {\n x[j] = x2[j] + p; y[j] = y2[j];\n //if (Math.Abs(x[j]) > 100 || Math.Abs(y[j])) continue;\n for (int i = 0; i < 3; i++)\n {\n if (getLen(x[i], y[i], x[(i + 1) % 3], y[(i + 1) % 3], x[(i + 2) % 3], y[(i + 2) % 3]))\n {\n Console.WriteLine(\"ALMOST\");\n return;\n }\n }\n\n }\n for (int p = -1; p <= 1; p++)\n {\n x[j] = x2[j]; y[j] = y2[j] + p;\n ///if (Math.Abs(x[j]) > 100 || Math.Abs(y[j])) continue;\n for (int i = 0; i < 3; i++)\n {\n if (getLen(x[i], y[i], x[(i + 1) % 3], y[(i + 1) % 3], x[(i + 2) % 3], y[(i + 2) % 3]))\n {\n Console.WriteLine(\"ALMOST\");\n return;\n }\n }\n\n }\n\n x[j] = x2[j]; y[j] = y2[j];\n }\n Console.WriteLine(\"NEITHER\");\n }\n }\n}", "lang_cluster": "C#", "tags": ["brute force", "geometry"], "code_uid": "6b7cd8c9f46cce307d60dbe893c34f3c", "src_uid": "8324fa542297c21bda1a4aed0bd45a2d", "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 ConsoleApplication2\n{\n class Program\n {\n static void Main(string[] args)\n {\n\n string dir = Console.ReadLine();\n string txt = Console.ReadLine();\n string keyboard = \"qwertyuiopasdfghjkl;zxcvbnm,./\";\n for (int i = 0; i < txt.Length; i++)\n {\n char ch = txt[i];\n for (int j = 0; j < keyboard.Length; j++)\n if (ch == keyboard[j])\n {\n if (dir == \"R\")\n Console.Write(keyboard[j - 1]);\n else\n Console.Write(keyboard[j + 1]);\n }\n\n\n\n\n\n }\n Console.ReadLine();\n }\n }\n}", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "d5a30a99c64aacb605516a7cbd9ae549", "src_uid": "df49c0c257903516767fdb8ac9c2bfd6", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Text.RegularExpressions;\n\nnamespace AllProblems\n{\n class Program\n {\n static void Main(string[] args)\n {\n _538A_CuttingBanner.Run();\n }\n }\n public class _538A_CuttingBanner\n {\n private const string WORD = \"CODEFORCES\";\n \n public static void Run()\n {\n var s = Console.ReadLine(); \n \n var ok = doit(s);\n \n Console.WriteLine(ok ? \"YES\" : \"NO\");\n }\n \n private static bool doit(string word) {\n if (word.StartsWith(WORD) || word.EndsWith(WORD)) return true;\n for(var i = 1; i < WORD.Length; i++) {\n var pat = \"^\"+WORD.Substring(0, i) + \".*\" + WORD.Substring(i) +\"$\";\n if (Regex.Match(word, pat).Success) return true;\n }\n return false;\n }\n }\n}", "lang_cluster": "C#", "tags": ["brute force", "implementation"], "code_uid": "01cb2028aa5adf01578d90f87b3a6b04", "src_uid": "bda4b15827c94b526643dfefc4bc36e7", "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 class Program\n {\n\n public struct cTeam\n {\n public int c1, \n c2;\n }\n static void Main(string[] args)\n {\n int n = int.Parse(Console.ReadLine()),\n res = 0;\n cTeam[] Team = new cTeam[n];\n for (int i = 0; i < n; i++)\n {\n int[] Arr = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();\n Team[i].c1 = Arr[0];\n Team[i].c2 = Arr[1];\n }\n\n for (int i = 0; i < n; i++)\n for (int j = 0; j < n; j++)\n if ((i != j) && (Team[i].c1 == Team[j].c2))\n res++;\n\n Console.WriteLine(res);\n Console.ReadLine();\n }\n }\n}", "lang_cluster": "C#", "tags": ["brute force"], "code_uid": "d4abc6ac20f0eecc1c41bdf6c74f1d4e", "src_uid": "745f81dcb4f23254bf6602f9f389771b", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.IO;\nusing System.Text;\n\nnamespace Red_Green_Towers\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 mod = 1000000007;\n\n int r = Next();\n int g = Next();\n if (r > g)\n {\n int c = r;\n r = g;\n g = c;\n }\n\n var nn = new long[r + 1];\n nn[r] = 1;\n if (r > 0)\n nn[r - 1] = 1;\n\n int count = 1;\n int sum = 1;\n while (true)\n {\n count++;\n int maxr = r - Math.Max(0, sum - g) - count;\n\n for (int i = 0; i <= maxr; i++)\n {\n nn[i] = (nn[i] + nn[i + count])%mod;\n }\n sum += count;\n if (sum > r + g)\n {\n sum -= count;\n break;\n }\n }\n\n long sum1 = 0;\n {\n int maxr = r - Math.Max(0, sum - g);\n for (int i = 0; i <= maxr; i++)\n {\n sum1 = (sum1 + nn[i])%mod;\n }\n }\n\n writer.WriteLine(sum1);\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": ["dp"], "code_uid": "7253926984fc066a8a9d4f649209ee12", "src_uid": "34b6286350e3531c1fbda6b0c184addc", "difficulty": 2000.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\n\nnamespace Contest\n{\n class Program\n {\n static void Main(string[] args)\n {\n int n=int.Parse(Console.ReadLine());\n int[]answer=StringToIntArray(Console.ReadLine()).OrderBy(x=>x).ToArray();\n Console.WriteLine(string.Join(\" \",answer));\n }\n\n static int[] StringToIntArray(string input)\n {\n string[] splitInput = input.Split();\n int length = splitInput.Length;\n int[] result = new int[length];\n for (int i = 0; i < length; i++)\n {\n result[i] = int.Parse(splitInput[i]);\n }\n return result;\n }\n\n static long[] StringToLongArray(string input)\n {\n string[] splitInput = input.Split();\n int length = splitInput.Length;\n long[] result = new long[length];\n for (int i = 0; i < length; i++)\n {\n result[i] = long.Parse(splitInput[i]);\n }\n return result;\n }\n }\n}", "lang_cluster": "C#", "tags": ["sortings", "implementation", "greedy"], "code_uid": "b110e94754bc70df3f9c37092b45c481", "src_uid": "ae20712265d4adf293e75d016b4b82d8", "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;\nusing System.Numerics;\n\nnamespace CodeForces\n{\n class Program\n {\n \n static void Main(string[] args)\n {\n\n int[] numbers;\n string line = \"\";\n string[] tokens;\n int[,] arr1 = new int[5, 5];\n int j = 0;\n int count = 0;\n for (int i = 0; i < 5; i++)\n {\n line = Console.ReadLine();\n tokens = line.Split(' ');\n numbers = Array.ConvertAll(tokens, int.Parse);\n while (j < 5)\n {\n arr1[i, j] = numbers[j];\n j++;\n }\n j = 0;\n }\n int TEMP;\n for (int A = 0; A < 5; A++)\n {\n for (int B = 0; B < 5; B++)\n {\n if (A != B)\n for (int C = 0; C < 5; C++)\n {\n if (C != A && C != B)\n for (int D = 0; D < 5; D++)\n {\n if (D != A && D != B && D != C)\n for (int E = 0; E < 5; E++)\n {\n if (E != A && E != B && E != C && E != D)\n {\n TEMP = arr1[A, B] + arr1[B, A] + arr1[C, D] + arr1[D, C] + arr1[B, C] + arr1[C, B] + arr1[D, E] + arr1[E, D] + arr1[C, D] + arr1[D, C] + arr1[E, D] + arr1[D, E];\n if (count < TEMP)\n count = TEMP; \n }\n }\n }\n }\n }\n }\n Console.WriteLine(count);\n\n }\n\n\n \n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "implementation"], "code_uid": "b06d48940761da290e5214a3213510c4", "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 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 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 x = getList();\n\t\t\tvar ans = 0;\n\t\t\twhile (x[1] != 0 && x[0] != 0 && (x[0] + x[1] != 2))\n\t\t\t{\n\t\t\t\tans++;\n\t\t\t\tif (x[1] >= x[0])\n\t\t\t\t{\n\t\t\t\t\tx[1] -= 2;\n\t\t\t\t\tx[0] += 1;\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tx[1] += 1;\n\t\t\t\t\tx[0] -= 2;\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", "greedy", "dp", "implementation"], "code_uid": "bead03c23915d1f9a9f856dd59f93cad", "src_uid": "ba0f9f5f0ad4786b9274c829be587961", "difficulty": 1100.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 _438b\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 h = d[0];\n var m = d[1];\n var s = d[2];\n var t1 = d[3];\n var t2 = d[4];\n\n var count = 60 * 60;\n var inm = count / 5;\n var ins = inm / 60;\n\n var hs = (h * count + m * 60 + s) % (12 * count);\n var ms = m * inm + s * ins;\n var ss = s * inm;\n\n var hm = hs;\n var t1m = (t1 * count) % (12 * count);\n var t2m = (t2 * count) % (12 * count);\n var all = new int[] { hs, ms, ss };\n //var hc = (5L / 60L) / 60L;\n\n if (t1m > t2m)\n {\n if (!all.Any(t => t < t1m && t > t2m))\n {\n Console.WriteLine(\"YES\");\n return;\n }\n\n if (!all.Any(t => t > t1m || t < t2m || t == 0))\n {\n Console.WriteLine(\"YES\");\n return;\n }\n }\n else\n {\n if (!all.Any(t => t > t1m && t < t2m))\n {\n Console.WriteLine(\"YES\");\n return;\n }\n\n if (!all.Any(t => t < t1m || t > t2m || t == 0))\n {\n Console.WriteLine(\"YES\");\n return;\n }\n }\n\n Console.WriteLine(\"NO\");\n //var n = readInt();\n //var m = readInt();\n\n //var a = readIntArray();\n //var b = readIntArray();\n #endregion\n }\n\n //static Tuple hToM(int h, int m, int s)\n //{\n \n\n // return (h * 5) % 60;\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": "78cb3b13a8439c944675314966dc08db", "src_uid": "912c8f557a976bdedda728ba9f916c95", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nclass a\n{\n static void Main()\n {\n var a = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);\n for (int i = a[0]+1; i < a[1]; i++)\n {\n if (IsPrime(i))\n {\n Console.WriteLine(\"NO\");\n return;\n } \n }\n Console.WriteLine(IsPrime(a[1])? \"YES\" : \"NO\");\n }\n static bool IsPrime(int n)\n {\n for (int i = 2; i <= n / 2; i++) if (n % i == 0) return false;\n return true;\n }\n}", "lang_cluster": "C#", "tags": ["brute force"], "code_uid": "1af5b6a055fdb6204d3751f348182465", "src_uid": "9d52ff51d747bb59aa463b6358258865", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Linq;\n\nnamespace PlayingWithDishes\n{\n internal class Program\n {\n private static int a;\n\n private static int b;\n\n private static int r;\n\n private static void Main(string[] args)\n {\n int[] values = Console.ReadLine().Split(' ').Select(s => Convert.ToInt32(s)).ToArray();\n a = values[0];\n b = values[1];\n r = values[2];\n\n string result = Solve();\n Console.Out.WriteLine(result);\n }\n\n private static string Solve()\n {\n return 2 * r > Math.Min(a, b) ? \"Second\" : \"First\";\n }\n }\n}", "lang_cluster": "C#", "tags": ["math", "constructive algorithms", "games"], "code_uid": "a199eb5e03c41e4b7bd3cdd061ea0dc7", "src_uid": "90b9ef939a13cf29715bc5bce26c9896", "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 Contest816A\n{\n class Program\n {\n static void Main(string[] args)\n {\n var time = Console.ReadLine();\n var hh = time.Substring(0, 2);\n var mm = time.Substring(3, 2);\n var rv = new string(mm.Reverse().ToArray());\n var intH = int.Parse(hh);\n var intM = int.Parse(mm);\n var count = 0;\n while (hh != rv)\n {\n count++;\n intM++;\n if (intM == 60)\n {\n intM = 0;\n intH++;\n if (intH == 24)\n {\n intH = 0;\n }\n }\n if (intM < 10)\n {\n mm = \"0\" + intM;\n }\n else\n {\n mm = intM.ToString();\n }\n if (intH < 10)\n {\n hh = \"0\" + intH;\n }\n else\n {\n hh = intH.ToString();\n }\n rv = new string(mm.Reverse().ToArray());\n }\n Console.WriteLine(count);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "implementation"], "code_uid": "f143edb28f1e963efbd5821b654c48e9", "src_uid": "3ad3b8b700f6f34b3a53fdb63af351a5", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Linq;\n\nclass A439 {\n public static void Main() {\n var line = Console.ReadLine().Split();\n var n = int.Parse(line[0]);\n var d = int.Parse(line[1]);\n var a = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);\n var minTime = a.Sum() + 10 * (n - 1);\n Console.WriteLine(d < minTime\n ? -1\n : (d - minTime) / 5 + ((n - 1) << 1)\n );\n }\n}\n", "lang_cluster": "C#", "tags": ["greedy", "implementation"], "code_uid": "d8477fe4a5d50bb38930486e21c09f25", "src_uid": "b16f5f5c4eeed2a3700506003e8ea8ea", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nnamespace _825B\n{\n class Program\n {\n static void Main(string[] args)\n {\n int[,] matrix = new int[10, 10];\n for (int y = 0; y < 10; y++)\n {\n string line = Console.ReadLine();\n for (int x = 0; x < 10; x++)\n {\n if (line[x] == 'X')\n matrix[x, y] = 1;\n else if (line[x] == 'O')\n matrix[x, y] = 2;\n else\n matrix[x, y] = 0;\n }\n }\n bool result = false;\n for (int x = 0; x < 10; x++)\n for (int y = 0; y < 10; y++)\n {\n if (matrix[x, y] != 0) continue;\n matrix[x, y] = 1;\n int currInRow = 0, maxInRow = 0, currInColumn = 0, maxInColumn = 0, currInDiag = 0, maxInDiag = 0;\n for (int i = 0; i < 10; i++)\n {\n if (matrix[i, y] == 1)\n {\n currInRow++;\n maxInRow = Math.Max(maxInRow, currInRow);\n }\n else\n currInRow = 0;\n }\n for (int i = 0; i < 10; i++)\n {\n if (matrix[x, i] == 1)\n {\n currInColumn++;\n maxInColumn = Math.Max(maxInColumn, currInColumn);\n }\n else\n currInColumn = 0;\n }\n for (int i = -5; i <= 0; i++)\n {\n currInDiag = 0;\n for (int j = 0; j < 5; j++)\n {\n int diagX = x + i + j, diagY = y + i + j;\n if (diagX < 0 || diagX >= 10 || diagY < 0 || diagY >= 10) break;\n if (matrix[diagX, diagY] == 1)\n currInDiag++;\n else\n currInDiag = 0;\n }\n maxInDiag = Math.Max(maxInDiag, currInDiag);\n currInDiag = 0;\n for (int j = 0; j < 5; j++)\n {\n int diagX = x - i - j, diagY = y + i + j;\n if (diagX < 0 || diagX >= 10 || diagY < 0 || diagY >= 10) break;\n if (matrix[diagX, diagY] == 1)\n currInDiag++;\n else\n currInDiag = 0;\n }\n maxInDiag = Math.Max(maxInDiag, currInDiag);\n }\n if (maxInRow >= 5 || maxInColumn >= 5 || maxInDiag >= 5)\n {\n result = true;\n break;\n }\n matrix[x, y] = 0;\n }\n Console.WriteLine(result ? \"YES\" : \"NO\");\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "implementation"], "code_uid": "d9d7ec06f039535daeafac1667588a83", "src_uid": "d5541028a2753c758322c440bdbf9ec6", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Linq;\nusing System.Text;\n\nnamespace ConsoleApp1\n{\n class Program\n {\n static void Main(string[] args)\n {\n string result = string.Empty;\n string input = Console.ReadLine();\n\n var arr = input.Split('+').ToList();\n arr.Sort();\n StringBuilder sb = new StringBuilder();\n for (int i = 0; i < arr.Count; i++)\n {\n if (i == arr.Count - 1)\n sb.Append(arr[i]);\n else\n sb.Append(arr[i] + \"+\");\n }\n Console.WriteLine(sb.ToString());\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["sortings", "strings", "implementation", "greedy"], "code_uid": "38b892f0ae4860cb41c4740b0179ea95", "src_uid": "76c7312733ef9d8278521cf09d3ccbc8", "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\tclass Program\n\t{\n\t\tstatic void Main(string[] args)\n\t\t{\n\t\t\tvar nk = Console.ReadLine().Split(' ').Select(int.Parse).ToList();\n\t\t\tvar time = 240 - nk[1];\n\t\t\tvar count = 0;\n\t\t\twhile (true)\n\t\t\t{\n\t\t\t\tif (time - (count + 1) * 5 >= 0 && nk[0] != 0)\n\t\t\t\t{\n\t\t\t\t\tnk[0]--;\n\t\t\t\t\ttime -= (count + 1) * 5;\n\t\t\t\t\tcount++;\n\t\t\t\t}\n\t\t\t\telse break;\n\t\t\t}\n\t\t\tConsole.WriteLine(count);\n\t\t\tConsole.ReadLine();\n\t\t}\n\t}\n}\n", "lang_cluster": "C#", "tags": ["brute force", "math", "implementation", "binary search"], "code_uid": "005eb7e1ece21840bcda63254c97bc9a", "src_uid": "41e554bc323857be7b8483ee358a35e2", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": ".NET Core C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Numerics;\n\nnamespace ConsoleApp2\n{\n class Program\n {\n static void Main(string[] args)\n {\n long n = long.Parse(Console.ReadLine());\n long kol = 0;\n long d = n / 100;\n kol += d;\n n -= d * 100;\n d = n / 20;\n kol += d;\n n -= d * 20;\n d = n / 10;\n kol += d;\n n -= d * 10;\n d = n / 5;\n kol += d;\n n -= d * 5;\n kol += n;\n Console.WriteLine(kol);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["greedy", "dp"], "code_uid": "a39ba9742f581be7e02f663339206ced", "src_uid": "8e81ad7110552c20297f08ad3e5f8ddc", "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 string[] s = Console.ReadLine().Split();\n int k = int.Parse(s[0]);\n int a = int.Parse(s[1]);\n int b = int.Parse(s[2]);\n int aa = a % k;\n int bb = b % k;\n a /= k;\n b /= k;\n if ((a + b) == 0 || (a == 0 & bb > 0) || (b == 0 & aa > 0))\n {\n Console.WriteLine(-1);\n return;\n }\n Console.WriteLine(a + b);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math"], "code_uid": "79de1d92961518026fef10ccae2cc98f", "src_uid": "6e3b8193d1ca1a1d449dc7a4ad45b8f2", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\n\nnamespace B\n{\n class Program\n {\n const char bad = '!';\n static void Main(string[] args)\n {\n var s = Console.ReadLine();\n\n var k = new int[4];\n var aliases = new Dictionary();\n for (int i = 0; i < s.Length; i++)\n {\n var mod = i%4;\n var cur = s[i];\n if (cur == bad)\n {\n k[mod]++;\n }\n else\n {\n if (!aliases.ContainsKey(cur))\n {\n aliases.Add(cur, mod);\n }\n }\n }\n\n Console.WriteLine(\"{0} {1} {2} {3}\", k[aliases['R']], k[aliases['B']], k[aliases['Y']], k[aliases['G']]);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "implementation", "number theory"], "code_uid": "34d4a32722a430191788a33f2d488c75", "src_uid": "64fc6e9b458a9ece8ad70a8c72126b33", "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 var a = ReadToken().ToCharArray();\n Array.Sort(a);\n if (a[0] == '0')\n for (int i = 1; i < a.Length; i++)\n if (a[i] != '0')\n {\n a[0] = a[i];\n a[i] = '0';\n break;\n }\n\n Write(new string(a) == ReadToken() ? \"OK\" : \"WRONG_ANSWER\");\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": ["sortings", "implementation"], "code_uid": "4f3488bd3698bb7e56dc40c74898b4b0", "src_uid": "d1e381b72a6c09a0723cfe72c0917372", "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 Dreamoon_and_WiFi\n{\n //class Teste\n //{\n // public Array dreamoon;\n // public Array drazil;\n // int posResposta = 0;\n // int posFinal = 0;\n // int numInterrogacao = 0;\n\n // public void calcula(string x, string y)\n // {\n // dreamoon = x.ToArray();\n // drazil = y.ToArray();\n\n // for (int i = 0; i < dreamoon.Length; i++)\n // {\n // if (dreamoon.GetValue(i).ToString() == \"+\")\n // posResposta++;\n // else\n // posResposta--;\n // }\n\n // for (int i = 0; i < dreamoon.Length; i++)\n // {\n // if (drazil.GetValue(i).ToString() == \"?\")\n // numInterrogacao++;\n // else if (drazil.GetValue(i).ToString() == \"+\")\n // posFinal++;\n // else\n // posFinal--;\n // }\n\n // int distancia = posResposta - posFinal;\n // double resposta;\n // if ((distancia + numInterrogacao) % 2 != 0 || numInterrogacao < Math.Abs(distancia)) //can't reach the destination no matter how\n // resposta = 0;\n // else\n // {\n\n // }\n\n // Console.WriteLine(resposta);\n // }\n //}\n class Codigo\n {\n //Iniciando as vari\u00e1veis dreamoon e drazil\n private string dreamoon;\n private string drazil;\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\n for (int i = 0; i < dreamoon.Length; i++)\n {\n if (dreamoon.Substring(i, 1) == \"+\")\n posDreamoon++;\n else if (dreamoon.Substring(i, 1) == \"-\")\n posDreamoon--; \n }\n\n for (int i = 0; i < drazil.Length; i++)\n {\n if (drazil.Substring(i, 1) == \"+\")\n posDrazil++;\n else\n posDrazil--;\n }\n\n distancia = posDrazil - posDreamoon;\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))));\n\n return (double)combinacao / (1 << quantInt);\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 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", "lang_cluster": "C#", "tags": ["brute force", "math", "dp", "combinatorics", "bitmasks", "probabilities"], "code_uid": "6065b374aceaa90e7fd6187630c1454b", "src_uid": "f7f68a15cfd33f641132fac265bc5299", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffnamespace Problem\n{\n using System;\n using System.Collections.Generic;\n class Problem1\n {\n static void Main()\n {\n string[] str = Console.ReadLine().Split();\n int w1 = int.Parse( str[0] );\n int h1 = int.Parse( str[1] );\n int w2 = int.Parse( str[2] );\n int h2 = int.Parse( str[3] );\n long kq = 0;\n kq = (long)( h1 + h2 + 2 ) * ( w1 + 2 ) - (long)( h1 + h2 ) * w1;\n Console.WriteLine( kq );\n\n }\n }\n}", "lang_cluster": "C#", "tags": ["math"], "code_uid": "d0b251f5e061c186f7dc35fc25623017", "src_uid": "b5d44e0041053c996938aadd1b3865f6", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\n\nnamespace ConsoleApplication1\n{\n class Program\n {\n static void Main(string[] args)\n {\n string Input = Console.ReadLine();\n string[] Inputs = Input.Split(' ');\n int s = int.Parse(Inputs[0]);\n int v1 = int.Parse(Inputs[1]);\n int v2 = int.Parse(Inputs[2]);\n int t1 = int.Parse(Inputs[3]);\n int t2 = int.Parse(Inputs[4]);\n\n int FirstTime = (s * v1) + (t1 * 2);\n int SecondTime = (s * v2) + (t2 * 2);\n\n if (SecondTime>FirstTime)\n Console.WriteLine(\"First\");\n else if(FirstTime==SecondTime)\n Console.WriteLine(\"Friendship\");\n else\n Console.WriteLine(\"Second\");\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math"], "code_uid": "7e66bf62e15c82ecd45de07edeca7036", "src_uid": "10226b8efe9e3c473239d747b911a1ef", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.CodeDom;\nusing System.Collections.Generic;\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 a = new List();\n //var a = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();\n var n = 4;\n while (n-- > 0) a.Add(Console.ReadLine() == \"1\");\n\n var a1 = a[0] ^ a[1];\n var a2 = a[2] | a[3];\n var a3 = a[1] & a[2];\n var a4 = a[0] ^ a[3];\n\n var b1 = a1 & a2;\n var b2 = a3 | a4;\n\n Console.WriteLine(b1 ^ b2 ? '1' : '0');\n\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": ["brute force", "implementation"], "code_uid": "02d74246fff2c3cfaf01ed28d336d557", "src_uid": "879ac20ae5d3e7f1002afe907d9887df", "difficulty": 2000.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Linq;\n\nnamespace Codeforces\n{\n internal static class Program\n {\n private static void Main()\n {\n var xs = Console.ReadLine().Split().Select(long.Parse).ToList();\n var a = xs[0];\n var b = xs[1];\n var c = xs[2];\n\n var maxI = c / a;\n var maxJ = c / b;\n\n for (var i = 0; i <= maxI; i++)\n {\n for (var j = 0; j <= maxJ; j++)\n {\n if (a * i + b * j == c)\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", "math", "number theory"], "code_uid": "87b039e937e1f28b1087a3cf64e8614c", "src_uid": "e66ecb0021a34042885442b336f3d911", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Text.RegularExpressions;\nusing System.Collections.Generic;\n\nnamespace temp\n{\n class MainClass\n {\n private static Int32[] read_ints(int n) {\n string[] str = Console.ReadLine().Split(new char[]{' '});\n Int32[] ret = new Int32[n];\n for (Int32 i = 0; i < n; i++)\n ret[i] = Convert.ToInt32(str[i]);\n return ret;\n }\n\n private static Int32 read_int() {\n return Convert.ToInt32(Console.ReadLine());\n }\n\n private static Int64[] read_longs(int n) {\n string[] str = Console.ReadLine().Split(new char[]{' '});\n Int64[] ret = new Int64[n];\n for (Int64 i = 0; i < n; i++)\n ret[i] = Convert.ToInt64(str[i]);\n return ret;\n }\n\n private static Int64 read_long() {\n return Convert.ToInt64(Console.ReadLine());\n }\n\n private static string read_line() {\n return Console.ReadLine();\n }\n\n private static double line_dist_2d (int x1, int y1, int x2, int y2) {\n return Math.Sqrt(Math.Pow(x1-x2, 2) + Math.Pow(y1-y2, 2));\n }\n\n public static void Main (string[] args)\n {\n int n = read_int();\n int[] arr = read_ints(7);\n int day = 1, cnt = 0;\n while (true) {\n cnt += arr[day-1];\n if (cnt >= n)\n break;\n day++;\n if (day == 8)\n day = 1;\n }\n Console.WriteLine(day);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "a8243197f44c6c5f38946f34a04d611c", "src_uid": "007a779d966e2e9219789d6d9da7002c", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Linq;\nusing System.Collections.Generic;\n\npublic class App1\n{\n public static void Main()\n {\n Func read = ()=>Console.ReadLine();\n Action write = _=>Console.WriteLine(_.ToString());\n \n var m=util.RangeN(1,3).Map(_=>read().ToIntA()).ToArray();\n var i=0;\n while(true)\n {\n var a0=i;\n var s=a0+m[0][1]+m[0][2];\n var a1=s-m[1][0]-m[1][2];\n var a2=s-a0-a1;\n if( (m[2][0]+a1+m[0][2])==s &&\n (m[0][2]+m[1][2]+a2)==s)\n {\n m[0][0]=a0;\n m[1][1]=a1;\n m[2][2]=a2;\n break;\n }\n i++;\n }\n m.Map(v=>string.Format(\"{0} {1} {2}\",v[0],v[1],v[2]))\n .Foreach(st=>write(st));\n }\n \n}\n\n\n\nstatic class Exts\n{\n public static int ToInt(this string s)\n {\n return int.Parse(s);\n }\n\n public static int[] ToIntA(this IEnumerable args)\n {\n return args.Map(ToInt).ToArray();\n }\n \n public static int[] ToIntA(this string s)\n {\n return ToIntA(SplitBySpace(s));\n }\n \n public static string[] SplitBySpace(this string s)\n {\n return s.Split(new[]{\" \"},StringSplitOptions.RemoveEmptyEntries);\n }\n \n public static void Foreach(this IEnumerable l,Action f)\n {\n foreach(var i in l) f(i);\n }\n}\n\nstatic class FuncExts\n{\n public static IEnumerable Map(this IEnumerable l,Func f)\n {\n return l.Select(f);\n }\n \n public static IEnumerable Flt(this IEnumerable l,Func f)\n {\n return l.Where(f);\n }\n \n public static T Nth(this IEnumerable l,int n)\n {\n var list = l as IList;\n return (list!=null)?list[n-1]:l.Skip(n-1).First();\n }\n \n public static T Rd(this IEnumerable l,T df,Func f)\n {\n return Fold(l,df,f);\n }\n \n public static U Fold(this IEnumerable l,U df,Func f)\n {\n foreach(var i in l)\n {\n df=f(df,i);\n }\n return df;\n }\n \n public static IEnumerable Scan(this IEnumerable l,Func f,U df)\n {\n foreach(var i in l)\n {\n df=f(df,i);\n yield return df;\n }\n }\n}\n\nstatic class util\n{\n public static IEnumerable RangeN(int from,int to)\n {\n while(from<=to)\n {\n yield return from;\n from++;\n }\n }\n}\n\n", "lang_cluster": "C#", "tags": ["brute force", "implementation"], "code_uid": "e04e201148144b7e0ba052babbae24e6", "src_uid": "0c42eafb73d1e30f168958a06a0f9bca", "difficulty": 1100.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 var str = Console.ReadLine();\n int N = str.Count(x => (x == '4' || x == '7'));\n Console.WriteLine(N==4 || N==7 ? \"YES\":\"NO\");\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "a27f605d5177ff9fb88ba466f8d2b64d", "src_uid": "33b73fd9e7f19894ea08e98b790d07f1", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\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 input = Console.ReadLine();\n\t\t\tvar inputs = input.Split(new[] {' '}, StringSplitOptions.RemoveEmptyEntries).Select(int.Parse).ToList();\n\t\t\tint min = 101, max = 0;\n\t\t\tforeach (var itemInput in inputs)\n\t\t\t{\n\t\t\t\tif (itemInput > max)\n\t\t\t\t{\n\t\t\t\t\tmax = itemInput;\n\t\t\t\t}\n\n\t\t\t\tif (itemInput < min)\n\t\t\t\t{\n\t\t\t\t\tmin = itemInput;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tConsole.Out.WriteLine(max - min);\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", "sortings", "implementation"], "code_uid": "66092860392b071e2a878c45a30137eb", "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;\n\nnamespace ConsoleApplication1\n{\n class Program\n {\n static void Main(string[] args)\n {\n int lenght = int.Parse(Console.ReadLine());\n string inn = Console.ReadLine();\n string[] input = inn.Split(' ');\n List s = new List();\n for (int i = input.Length - 1; i >= 0; i--)\n {\n if(!s.Contains(input[i]))s.Add(input[i]);\n }\n\n s.Reverse();\n Console.WriteLine(s.Count);\n foreach (var item in s)\n {\n Console.Write(item + \" \");\n }\n Console.ReadLine();\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "269982bb61c355c0f4ef37a98113808e", "src_uid": "1b9d3dfcc2353eac20b84c75c27fab5a", "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 CF\n{\n class Program\n {\n static void Main(string[] args)\n {\n int input = int.Parse(Console.ReadLine());\n if (input >= 0) Console.WriteLine(input.ToString());\n else Console.WriteLine(Math.Max(((input - (input % 10)) / 10), (((input - (input % 100)) / 10)) + (input % 10)).ToString());\n }\n }\n}", "lang_cluster": "C#", "tags": ["implementation", "number theory"], "code_uid": "1355ae11516018d87ec9e9905a652d47", "src_uid": "4b0a8798a6d53351226d4f06e3356b1e", "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 Splits\n{\n class Program\n {\n static void Main(string[] args)\n {\n long d = Convert.ToInt64(Console.ReadLine());\n Console.WriteLine(ReturnSplit(d));\n }\n\n static long ReturnSplit (long number)\n {\n if (number % 2 != 0)\n return (number + 1) / 2;\n else\n return (number + 2) / 2;\n }\n\n }\n}\n", "lang_cluster": "C#", "tags": ["math"], "code_uid": "577f3a1d6e59f60bff0f044eb9fdacea", "src_uid": "5551742f6ab39fdac3930d866f439e3e", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Linq;\n\nnamespace Olimpiade\n{\n\tclass Program\n\t{\n\t\tstatic void Main(string[] args)\n\t\t{\n\t\t\tA();\n\t\t}\n\n\t\tstatic void A()\n\t\t{\n\t\t\tvar numbers = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();\n\t\t\tvar n = numbers[0]; // \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043c\u0435\u0441\u0442\n\t\t\tvar h = numbers[1]; // \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u0430\u044f \u0432\u044b\u0441\u043e\u0442\u0430 \n\t\t\tvar m = numbers[2]; // \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0439\n\n\t\t\tvar street = Enumerable.Repeat(h, n).ToArray();\n\n\t\t\tfor (int i = 0; i < m; i++)\n\t\t\t{\n\t\t\t\tvar num = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();\n\t\t\t\tvar l = num[0];\n\t\t\t\tvar r = num[1];\n\t\t\t\tvar x = num[2];\n\t\t\t\tfor (int j = l - 1; j <= r - 1; j++)\n\t\t\t\t{\n\t\t\t\t\tif (street[j] > x) street[j] = x;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tvar result = street.Sum(x => x * x);\n\n\t\t\tConsole.Write(result);\n\t\t}\n\t}\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "f3d974ac46a270f9645d3fea1f9f2c81", "src_uid": "f22b6dab443f63fb8d2d288b702f20ad", "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 ConsoleApplication50\n{\n class Program\n {\n static void Main(string[] args)\n {\n string[] name = Console.ReadLine().Split();\n int k2 = Int32.Parse(name[0]);\n int k3 = Int32.Parse(name[1]);\n int k5 = Int32.Parse(name[2]);\n int k6 = Int32.Parse(name[3]);\n int n = 0;\n while (k2 > 0 & k5 > 0 & k6 > 0)\n {\n k2--;\n k5--;\n k6--;\n n += 256;\n }\n if(k2 > 0 & k3 > 0)\n {\n while(k2 > 0 & k3 > 0)\n {\n k2--;\n k3--;\n n += 32;\n }\n }\n Console.WriteLine(n);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "greedy", "implementation", "brute force"], "code_uid": "e7053f3b4451b00a06ac92ff3739e635", "src_uid": "082b31cc156a7ba1e0a982f07ecc207e", "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 TASK_721A\n{\n class Program\n {\n static void Main(string[] args)\n {\n Console.ReadLine();\n var temp = Console.ReadLine().Select(x => x);\n List result = new List();\n int l = temp.Count();\n while (l != 0)\n {\n temp = temp.SkipWhile(x => x == 'W');\n l = temp.Count();\n temp = temp.SkipWhile(x => x == 'B');\n if (l != temp.Count())\n result.Add(l - temp.Count());\n l = temp.Count();\n }\n Console.WriteLine(result.Count());\n Console.WriteLine(String.Join(\" \", result));\n Console.ReadLine();\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "a004b3cf988595cfa6365e6231f02040", "src_uid": "e4b3a2707ba080b93a152f4e6e983973", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nclass Program\n{\n static void Main(string[] args)\n {\n String[] s = Console.ReadLine().Split(' ');\n long a = Convert.ToInt64(s[0]);\n long b = Convert.ToInt64(s[1]);\n for(int i = 0; i < b; i++)\n {\n if (a % 10 == 0) a /= 10;\n else a--;\n }\n Console.WriteLine(a);\n }\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "e42d4364fe874d6520abbc9204ee67fb", "src_uid": "064162604284ce252b88050b4174ba55", "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 task114A\n{\n class Program\n {\n static void Main(string[] args)\n {\n UInt32 inputK = UInt32.Parse(Console.ReadLine());\n UInt32 inputL = UInt32.Parse(Console.ReadLine());\n if (inputK == inputL)\n {\n Console.WriteLine(\"YES\");\n Console.WriteLine(0);\n return;\n }\n UInt64 temp = Convert.ToUInt64(inputK);\n UInt32 count = 0;\n while (temp < inputL)\n {\n temp = temp * inputK;\n count++;\n }\n if (temp == inputL)\n {\n Console.WriteLine(\"YES\");\n Console.WriteLine(count);\n }\n else\n Console.WriteLine(\"NO\");\n //Console.ReadLine();\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math"], "code_uid": "6d7b8cf3ee35234185ce1332afb92ce5", "src_uid": "8ce89b754aa4080e7c3b2c3b10f4be46", "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 CodeForces_330A\n{\n class Program\n {\n static void Main(string[] args)\n {\n int[] n = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();\n int[,] array = new int[n[0], n[1]];\n List row = new List { };\n List col = new List { };\n for (int i = 0; i < n[0]; i++)\n {\n string temp = Console.ReadLine();\n for (int j = 0; j < n[1]; j++)\n {\n if (temp[j]=='S')\n {\n row.Add(i);\n col.Add(j);\n }\n }\n }\n row=row.Distinct().ToList();\n col=col.Distinct().ToList();\n Console.WriteLine(n[0] * n[1] - row.Count * col.Count);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "implementation"], "code_uid": "e3b962a2679a6c065591f82024ce586e", "src_uid": "ebaf7d89c623d006a6f1ffd025892102", "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\n{\n class Program\n {\n static void Main(string[] args)\n {\n int[] a = Console.ReadLine().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(x => int.Parse(x)).ToArray();\n string cadena = Console.ReadLine();\n int indiceG = -1;\n int indiceT = -1;\n for (int i = 0; i < cadena.Length; i++)\n {\n if (cadena[i] == 'G') indiceG = i;\n if (cadena[i] == 'T') indiceT = i;\n if (indiceG != -1 && indiceT != -1) break;\n }\n if (indiceT < indiceG) a[1] *= -1;\n int current = indiceG;\n bool salte = false;\n current += a[1];\n while (current >= 0 && current < cadena.Length)\n {\n if (cadena[current] == 'T')\n {\n Console.WriteLine(\"YES\");\n salte = true;\n break;\n }\n if (cadena[current] == '#')\n {\n Console.WriteLine(\"NO\");\n salte = true;\n break;\n }\n current += a[1];\n }\n if (!salte) Console.WriteLine(\"NO\");\n\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["strings", "implementation"], "code_uid": "be99c8e77392119b9664185947efc342", "src_uid": "189a9b5ce669bdb04b9d371d74a5dd41", "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;\n\nnamespace Funky_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 int n = Next();\n\n var nn = new List();\n for (int i = 1;; i++)\n {\n int nnn = i*(i + 1)/2;\n if (nnn >= n)\n break;\n nn.Add(nnn);\n }\n\n if (nn.TakeWhile(i => i <= n - i).Any(i => nn.BinarySearch(n - i) >= 0))\n {\n writer.WriteLine(\"YES\");\n writer.Flush();\n return;\n }\n\n writer.WriteLine(\"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": ["brute force", "implementation", "binary search"], "code_uid": "75e9c882ac74068ca407806310c860ff", "src_uid": "245ec0831cd817714a4e5c531bffd099", "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.Diagnostics;\n\nnamespace CodeForces\n{\n class Program\n {\n static void Main(string[] args)\n {\n long n1;\n long n2;\n int n;\n Input.Next(out n1, out n2);\n Input.Next(out n);\n int idx = (n-1) % 6;\n bool neg = false;\n long current = n1;\n if (idx >= 3)\n {\n neg = true;\n idx = idx - 3;\n }\n\n if (idx == 1)\n {\n current = n2;\n }\n else if (idx == 2)\n {\n current = n2 - n1;\n }\n\n if (neg)\n {\n current = current * -1;\n }\n\n long mod = 1000000007;\n Console.WriteLine((current % mod + mod) % mod);\n }\n\n public static int GetLastChildGoingHome(int[] inputs, int candies)\n {\n for (int i = 0; i < inputs.Length; i++)\n {\n inputs[i] = inputs[i] % candies == 0 ? inputs[i] / candies : ((inputs[i] / candies) + 1);\n }\n\n int last = 0;\n int lastIdx = 0;\n\n for (int i = 0; i < inputs.Length; i++)\n {\n if (inputs[i] >= last)\n {\n last = inputs[i];\n lastIdx = i;\n }\n }\n\n return lastIdx + 1;\n }\n }\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 bool Next(out int a)\n {\n var ok = Next();\n a = ok ? int.Parse(_line) : 0;\n return ok;\n }\n\n public static bool Next(out int a, out int b)\n {\n var ok = Next();\n if (ok)\n {\n var array = _line.Split(' ').Select(int.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 int a, out int b, out int c)\n {\n var ok = Next();\n if (ok)\n {\n var array = _line.Split(' ').Select(int.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 int a, out int b, out int c, out int d)\n {\n var ok = Next();\n if (ok)\n {\n var array = _line.Split(' ').Select(int.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 int a, out int b, out int c, out int d, out int e)\n {\n var ok = Next();\n if (ok)\n {\n var array = _line.Split(' ').Select(int.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 bool Next(out int a, out int b, out int c, out int d, out int e, out int f)\n {\n var ok = Next();\n if (ok)\n {\n var array = _line.Split(' ').Select(int.Parse).ToArray();\n a = array[0];\n b = array[1];\n c = array[2];\n d = array[3];\n e = array[4];\n f = array[5];\n }\n else\n {\n a = b = c = d = e = f = 0;\n }\n return ok;\n }\n\n public static IEnumerable ArrayLong()\n {\n return !Next() ? new List() : _line.Split().Select(long.Parse);\n }\n\n public static IEnumerable ArrayInt()\n {\n return !Next() ? new List() : _line.Split().Select(int.Parse);\n }\n\n public static int[,] GetMatrix(int rows, int cols)\n {\n int[,] matrix = new int[rows, cols];\n int row = 0;\n int col = 0;\n while (Next())\n {\n IEnumerable numbers = _line.Split().Select(int.Parse);\n IEnumerator iter = numbers.GetEnumerator();\n while (iter.MoveNext())\n {\n matrix[row, col++] = iter.Current;\n }\n row++;\n col = 0;\n }\n return matrix;\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}\n", "lang_cluster": "C#", "tags": ["math", "implementation"], "code_uid": "c427a217881a7c891c6ea7186b7269b3", "src_uid": "2ff85140e3f19c90e587ce459d64338b", "difficulty": 1300.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(Ncr(n, n / 2) / 2 * Factorial(n / 2 - 1) * Factorial(n / 2 - 1));\n\t}\n\n\tpublic static long Factorial(int n) { for (long x = 1, i = 1; ; x *= ++i) if (i >= n) return x; }\n\tpublic static long Npr(int n, int r)\n\t{\n\t\tif (n < r) return 0;\n\t\tfor (long x = 1, i = n - r; ; x *= ++i) if (i >= n) return x;\n\t}\n\tpublic static long Ncr(int n, int r) => n < r ? 0 : n - r < r ? Ncr(n, n - r) : Npr(n, r) / Factorial(r);\n}\n", "lang_cluster": "C#", "tags": ["math", "combinatorics"], "code_uid": "50bfac0fb0b39102b09f6ae9808737d0", "src_uid": "ad0985c56a207f76afa2ecd642f56728", "difficulty": 1300.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 s = ReadString();\n\t\t\tlong ans = 0;\n\t\t\tlong tt = 1;\n\t\t\tfor (var i = s.Length - 1; i >= 0; --i)\n\t\t\t{\n\t\t\t\tif (s[i] == '>')\n\t\t\t\t\tans = (ans + tt * 8) % 1000003;\n\t\t\t\tif (s[i] == '<')\n\t\t\t\t\tans = (ans + tt * 9) % 1000003;\n\t\t\t\tif (s[i] == '+')\n\t\t\t\t\tans = (ans + tt * 10) % 1000003;\n\t\t\t\tif (s[i] == '-')\n\t\t\t\t\tans = (ans + tt * 11) % 1000003;\n\t\t\t\tif (s[i] == '.')\n\t\t\t\t\tans = (ans + tt * 12) % 1000003;\n\t\t\t\tif (s[i] == ',')\n\t\t\t\t\tans = (ans + tt * 13) % 1000003;\n\t\t\t\tif (s[i] == '[')\n\t\t\t\t\tans = (ans + tt * 14) % 1000003;\n\t\t\t\tif (s[i] == ']')\n\t\t\t\t\tans = (ans + tt * 15) % 1000003;\n\t\t\t\ttt = (tt * 16) % 1000003;\n\t\t\t}\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": "6688324b97124f0e006dcd1478092a28", "src_uid": "04fc8dfb856056f35d296402ad1b2da1", "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 Code_Practice\n{\n class Theatre_Square\n {\n\n public static void Main(string[] args)\n {\n\n var phrase = Console.ReadLine().Split();\n var n = Int64.Parse(phrase[0]);\n var m = Int64.Parse(phrase[1]);\n var a = Int64.Parse(phrase[2]);\n long r = 0;\n long x = n/a;\n while(x*a < n)\n {\n x++;\n }\n long y = m/a;\n while(y*a < m)\n {\n y++;\n }\n r = x * y;\n Console.WriteLine(r);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math"], "code_uid": "a323ca0c6ff3241c6e510feeca7ef3f8", "src_uid": "ef971874d8c4da37581336284b688517", "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\t\n\t\tint[] cnt = new int[2];\n\t\tList L = new List();\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": ["sortings", "dp", "greedy"], "code_uid": "62b50b6978592a7c6e5afacaa429407a", "src_uid": "b3f8e769ee7719ea5c9f458428b16a4e", "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 ConsoleApplication1A\n{\n class ProgramCCC\n {\n static void Main(string[] args)\n {\n\n int n = Convert.ToInt32(Console.ReadLine());\n Console.WriteLine((n - 1) / 2);\n }\n\n\n }\n}\n", "lang_cluster": "C#", "tags": ["constructive algorithms"], "code_uid": "a769fa274deadfa7f5c3acbdd065eb94", "src_uid": "dfe9446431325c73e88b58ba204d0e47", "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 _58b\n {\n public static void Main()\n {\n var line = Console.ReadLine();\n var n = int.Parse(line);\n var result = new List();\n result.Add(n);\n for (var i = n - 1; i > 0; i--)\n {\n var ok = result.All(item => item%i == 0);\n if (ok)\n {\n result.Add(i);\n }\n }\n for (var i = 0; i < result.Count; i++)\n {\n if (i > 0)\n {\n Console.Write(' ');\n }\n Console.Write(result[i]);\n }\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["greedy"], "code_uid": "2fd244e7d712584ac421131acb021b77", "src_uid": "2fc946bb72f56b6d86eabfaf60f9fa63", "difficulty": 1300.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 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 static long[] ReadLong(string str)\n {\n string[] tokens = str.Trim().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);\n long[] ret = new long[tokens.Length];\n for (int i = 0; i < ret.Length; i++)\n {\n ret[i] = long.Parse(tokens[i]);\n }\n\n return ret;\n }\n\n public static double[] ReadDouble(string str)\n {\n string[] tokens = str.Trim().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);\n double[] ret = new double[tokens.Length];\n for (int i = 0; i < ret.Length; i++)\n {\n ret[i] = double.Parse(tokens[i], CultureInfo.InvariantCulture);\n }\n\n return ret;\n }\n\n static string Reverse(string s)\n {\n char[] a = s.ToCharArray();\n Array.Reverse(a);\n return new string(a);\n }\n\n static bool IsPrime(int n)\n {\n if (n % 2 == 0) return false;\n\n int lim = (int)Math.Sqrt(n);\n for (int i = 3; i <= lim; i += 2)\n {\n if (n % i == 0) return false;\n }\n return true;\n }\n\n static void Main(string[] args)\n {\n int[] nk = Read(Console.ReadLine());\n int n = nk[0], k = nk[1];\n\n bool[] prime_mask = new bool[n + 1];\n List primes = new List();\n\n for (int i = 2; i <= n; i++)\n {\n if (IsPrime(i))\n {\n primes.Add(i);\n prime_mask[i] = true;\n }\n }\n\n bool[] flag = new bool[n + 1];\n for (int i = 0; i < primes.Count - 1; i++)\n {\n int sum = primes[i] + primes[i + 1] + 1;\n if (sum <= n && prime_mask[sum])\n {\n flag[sum] = true;\n }\n }\n int count = 0;\n for (int i = 0; i <= n; i++)\n {\n if (flag[i]) count++;\n }\n Console.WriteLine((count >= k) ? \"YES\" : \"NO\");\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "math", "number theory"], "code_uid": "50670cc935185b776a8336f5f349d507", "src_uid": "afd2b818ed3e2a931da9d682f6ad660d", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeff//using System;\n//using System.Collections.Generic;\n//using System.Linq;\n//using System.Text;\n//using System.Threading.Tasks;\n\n//namespace ConsoleApplication1\n//{\n// class Program\n// {\n\n// static void Main(string[] args)\n// {\n// int A = Int32.Parse(Console.ReadLine());\n// List Values = new List();\n// for (int i = 2; i < A; i++)\n// {\n// int baseN = i;\n// List subValues = new List();\n// int val = A;\n// while (val > 0)\n// {\n// int maxPow = (int) Math.Log(val, baseN);\n// for (int j = maxPow; j >= 0; j--)\n// {\n\n// }\n// }\n\n// Values.Add(subValues.Sum());\n// }\n\n// Console.WriteLine(Values.Sum()+\"/\"+Values.Count);\n// }\n// }\n\n//}\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\n static void Main(string[] args)\n {\n string reader = Console.ReadLine();\n int links = reader.Where(x => x == '-').Count();\n int pearls = reader.Where(x => x == 'o').Count();\n bool output = false;\n\n if (links == 0 || pearls < 2) output = true;\n else\n {\n output = links % pearls == 0;\n }\n\n Console.WriteLine(output?\"YES\":\"NO\");\n }\n\n \n static bool valueInBetween (double d, int min, double max)\n {\n return d>=min&&d<=max;\n }\n static void Problem1245A()\n {\n byte t = byte.Parse(Console.ReadLine());\n for (byte i = 0; i < t; i++)\n {\n UInt16 a, b;\n UInt16[] reader = Console.ReadLine().Split(' ').Select(x => UInt16.Parse(x)).ToArray();\n a = reader[0]; b = reader[1];\n FindAnswer(a, b);\n }\n }\n static void FindAnswer(UInt16 a, UInt16 b)\n {\n string output = \"\";\n\n\n Console.WriteLine(output);\n }\n }\n\n}", "lang_cluster": "C#", "tags": ["math", "implementation"], "code_uid": "073549ffc088a54dac9851416dee39be", "src_uid": "6e006ae3df3bcd24755358a5f584ec03", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Text;\n\nnamespace CodeForceTest\n{\n class Program\n {\n static void Main(string[] args)\n {\n string string1 = Console.ReadLine().ToLower(), string2 = Console.ReadLine().ToLower(); \n \n if (string.Compare(string1, string2) > 0) Console.Write(1);\n else if (string.Compare(string1, string2) < 0) Console.Write(-1);\n else if (string.Compare(string1, string2) == 0) Console.Write(0);\n\n Console.ReadLine();\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["strings", "implementation"], "code_uid": "42535be149bfdf8ea4a17665c05cbfda", "src_uid": "ffeae332696a901813677bd1033cf01e", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\n\nnamespace codeforcespst\n{\n internal class Program\n {\n private static void Main(string[] args)\n {\n int n = int.Parse(Console.ReadLine());\n string[] days = Console.ReadLine().Split(' ');\n if (int.Parse(days[n - 1]) == 0)\n Console.WriteLine(\"UP\");\n else if (int.Parse(days[n - 1]) == 15)\n Console.WriteLine(\"DOWN\");\n else if (days.Length == 1)\n Console.WriteLine(\"-1\");\n else if (int.Parse(days[n - 1]) > int.Parse(days[n - 2]))\n Console.WriteLine(\"UP\");\n else\n Console.WriteLine(\"DOWN\");\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "83ee1583cbcc088ddf566a9e605c5c89", "src_uid": "8330d9fea8d50a79741507b878da0a75", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Linq;\n\nnamespace ConsoleApp1\n{\n class Program\n {\n static void Main(string[] args)\n {\n string s = Console.ReadLine();\n int countA = s.Count(x => x == 'a');\n int result = 0;\n\n if (countA > s.Length / 2)\n result = s.Length;\n else\n result = countA + countA - 1;\n\n Console.WriteLine(result);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["strings", "implementation"], "code_uid": "70cbc305ca111ab1146917b503d8ec96", "src_uid": "84cb9ad2ae3ba7e912920d7feb4f6219", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Linq;\n\nnamespace A\n{\n class Program\n {\n static void Main(string[] args)\n {\n int n = int.Parse(Console.ReadLine());\n int[] positions = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();\n\n n /= 2;\n Array.Sort(positions);\n\n int ans = int.MaxValue;\n for (int x = 1; x <= 2; x++)\n {\n int cnt = 0;\n for (int i = 0; i < n; i++)\n {\n int p = positions[i];\n int q = x + i * 2;\n cnt += Math.Abs(p - q);\n }\n ans = Math.Min(ans, cnt);\n }\n\n Console.WriteLine($\"{ans}\");\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "2d6b685c5e2b105f90ee39dcf1ef7eae", "src_uid": "0efe9afd8e6be9e00f7949be93f0ca1a", "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 int[] dx = new int[4] { 0, -1, -1, -1 };\n int[] dy = new int[4] { -1, -1, 0, 1 };\n int[,] a = new int[233,233];\n for (int i = 0; i <= 222; i++)\n {\n for (int j = 0; j <= 222; j++)\n {\n a[i, j] = -1;\n }\n }\n for (int i=1; i<=4; i++) {\n for (int j=1; j<=4;j++) {\n char c;\n c = Convert.ToChar(Console.Read());\n if (c == 'x') a[i, j] = 1;\n if (c == '.') a[i, j] = 0;\n //if (c == 'o') a[i, j] = -1;\n }\n Console.ReadLine();\n }\n for (int i=1;i<=4;i++) {\n for (int j=1;j<=4;j++) {\n for (int k=0;k<=3;k++)\n if ((a[i,j]+a[i+dx[k],j+dy[k]]+a[i-dx[k],j-dy[k]])>=2){\n Console.Write(\"YES\");\n return;\n }\n }\n }\n Console.WriteLine(\"NO\");\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "implementation"], "code_uid": "e6aadb9b9793abd99d795395e3523207", "src_uid": "ca4a77fe9718b8bd0b3cc3d956e22917", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeff#region Usings\n\nusing System;\nusing System.Linq;\n\n#endregion\n\nnamespace A {\n internal class Program {\n private static void Main() {\n var n = Convert.ToInt32(Console.ReadLine());\n var sum = Console.ReadLine().Split(' ').Select(_ => Convert.ToInt32(_)).Sum();\n\n var res = 0;\n if ((sum + 1)%(n + 1) != 1) {\n res++;\n }\n if ((sum + 2)%(n + 1) != 1) {\n res++;\n }\n if ((sum + 3)%(n + 1) != 1) {\n res++;\n }\n if ((sum + 4)%(n + 1) != 1) {\n res++;\n }\n if ((sum + 5)%(n + 1) != 1) {\n res++;\n }\n\n Console.WriteLine(res);\n }\n }\n}", "lang_cluster": "C#", "tags": ["math", "implementation"], "code_uid": "982d438606d08f089dce15634d1106f1", "src_uid": "ff6b3fd358c758324c19a26283ab96a4", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\n\nnamespace Codeforces395\n{\n class Program\n {\n static void Main(string[] args)\n {\n var numbers = Console.ReadLine().Split(' ');\n var n = int.Parse(numbers[0]);\n var m = int.Parse(numbers[1]);\n var z = int.Parse(numbers[2]);\n\n var sum = 0d;\n for (var i = n; i <= z; i += n)\n {\n if (i % m == 0) sum++;\n }\n\n Console.WriteLine(sum);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "math", "implementation"], "code_uid": "27bd9572714e5ef655e15f225287a84b", "src_uid": "e7ad55ce26fc8610639323af1de36c2d", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\n\nnamespace TestPrograms\n{\n class Program\n {\n static void Main(string[] args)\n {\n string input = Console.ReadLine();\n\n string[] a = input.Split(' ');\n\n //int[] v = Array.ConvertAll(a, int.Parse);\n\n HashSet c = new HashSet();\n\n\n foreach (string s in a)\n {\n int t = int.Parse(s);\n if (!c.Contains(t))\n {\n c.Add(t);\n }\n }\n\n Console.WriteLine(4 - c.Count);\n\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "7773398d5b4c79bac1e7fc9d57065438", "src_uid": "38c4864937e57b35d3cce272f655e20f", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nnamespace CodeForces {\n class Codigo {\n static void Main(string[] args)\n {\n string [] str = Console.ReadLine().Split();\n int a = int.Parse(str[0]);\n int b = int.Parse(str[1]);\n int c = int.Parse(str[2]);\n int dist = Math.Abs(a) + Math.Abs(b);\n if (c < dist)\n Console.WriteLine(\"NO\");\n else if ( ((dist - c) & 1) == 0 )\n Console.WriteLine(\"YES\");\n else\n Console.WriteLine(\"NO\");\n }\n }\n}", "lang_cluster": "C#", "tags": ["math"], "code_uid": "ee6dab2b0569cfcbd8321938bb973684", "src_uid": "9a955ce0775018ff4e5825700c13ed36", "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;\n\npublic static class Beautiful_Year\n{\n private static void Solve()\n {\n int year = ReadInt();\n for (int i = year + 1; i <= 9012; i++)\n {\n int distincts = i.ToString().Distinct().Count();\n if (distincts == 4)\n {\n year = i;\n break;\n }\n }\n\n Write(year);\n }\n\n #region Main\n\n private static TextReader reader;\n private static TextWriter writer;\n public static void Main()\n {\n#if DEBUG\n //reader = new StreamReader(\"C:\\\\Users\\\\Axel\\\\Desktop\\\\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 Solve();\n //var thread = new Thread(new Beautiful_Year().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 Read() { while (currentLineTokens.Count == 0) currentLineTokens = new Queue(ReadAndSplitLine()); return currentLineTokens.Dequeue(); }\n public static int ReadInt() { return int.Parse(Read()); }\n public static long ReadLong() { return long.Parse(Read()); }\n public static double ReadDouble() { return double.Parse(Read(), 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"], "code_uid": "cfe2cd763e5091ca246715ab52ac8bc9", "src_uid": "d62dabfbec52675b7ed7b582ad133acd", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\n class Program\n {\n public static void Main(string[] args)\n {\n string[] input = Console.In.ReadToEnd().Split(new char[] { '\\n', '\\r' }, StringSplitOptions.RemoveEmptyEntries);\n int index = 0;\n for(int i = 0; i < input[1].Length; ++i) if (input[0][index] == input[1][i]) index++;\n Console.WriteLine((index + 1));\n }\n }", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "32c27ea7e6ebaa4267cf77820e25a9b2", "src_uid": "f5a907d6d35390b1fb11c8ce247d0252", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\n\npublic class ansa{\n public static void Main() {\n int n = Convert.ToInt32(Console.ReadLine());\n string pile = Console.ReadLine();\n int counter = 0;\n for(int i=0; i0 && pile[i]=='-') counter--;\n else if(pile[i]=='+') counter++;\n }\n Console.WriteLine(counter);\n }\n}", "lang_cluster": "C#", "tags": ["math", "implementation"], "code_uid": "24114174631358842c68c08cf5513c86", "src_uid": "a593016e4992f695be7c7cd3c920d1ed", "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 string[] lines = Console.ReadLine().Split(' ');\n int count = int.Parse(lines[0]);\n var puzzless = Console.ReadLine().Split(' ');\n var puzzles = new List();\n foreach (var p in puzzless)\n puzzles.Add(int.Parse(p));\n puzzles.Sort();\n puzzles.Reverse();\n int min = int.MaxValue;\n for (int i = 0; i < puzzles.Count - count + 1; ++i)\n {\n var col = new List();\n for (int j = 0; j < count; ++j)\n {\n col.Add(puzzles[i + j]);\n }\n col.Sort();\n int val = col.Last() - col.First();\n if (val < min)\n min = val;\n }\n Console.WriteLine(min);\n }\n }\n}", "lang_cluster": "C#", "tags": ["greedy"], "code_uid": "a7a761416db9fca0856bda6c33d33c5f", "src_uid": "7830aabb0663e645d54004063746e47f", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Linq;\n\nnamespace Tech42\n{\n class Program\n {\n static void Main(string[] args)\n {\n \n var n = int.Parse(Console.ReadLine());\n var arr = new int[n * n];\n for (int i = 0; i < n; i++)\n {\n arr[i] = 1;\n }\n for (int i = n; i < arr.Length; i += n)\n {\n arr[i] = 1;\n }\n\n for (int i = n + 1; i < arr.Length; ++i)\n {\n if (arr[i] != 1)\n {\n arr[i] = arr[i - 1] + arr[i - n];\n }\n }\n\n Console.WriteLine(arr.Last()); \n }\n\n\n }\n}\n\n\n\n", "lang_cluster": "C#", "tags": ["brute force", "implementation"], "code_uid": "1373f494c9b41071bd13f6002d79433e", "src_uid": "2f650aae9dfeb02533149ced402b60dc", "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 CF_Bear_and_Finding_Criminals\n{\n class Program\n {\n static void Main(string[] args)\n {\n string[] x = new string[2]; \n x[0] = Console.ReadLine(); \n // string [] x = System.IO.File.ReadAllLines(@\"F:\\CF.txt\");\n // string input = x[0];\n // int[] input = x[0].Split(' ').Select(int.Parse).ToArray();\n int[] input = StringToIntegers(x[0]); \n int NumberOfCities = input[0] - 1 ;\n int OfficerPosition = input[1] - 1 ;\n int count = 0 ;\n int condition;\n x[1] = Console.ReadLine() ;\n\n string Cities = x[1]; \n Cities = RemoveSpaces(Cities, ' ');\n\n \n \n if (NumberOfCities / 2 < OfficerPosition)\n condition = OfficerPosition;\n else condition = NumberOfCities - OfficerPosition; \n for ( int i = 0 ; i<= condition ; i++ )\n {\n if (OfficerPosition - i >= 0 )\n {\n if (OfficerPosition + i <= NumberOfCities)\n {\n if (Cities[OfficerPosition - i] == Cities[OfficerPosition + i] && Cities[OfficerPosition - i] == '1')\n {\n if (i != 0)\n count += 2;\n else count++; \n }\n }\n\n else if (Cities[OfficerPosition - i] == '1')\n count++; \n }\n else if (OfficerPosition + i <= NumberOfCities)\n {\n if (Cities [OfficerPosition + i]== '1')\n count += 1;\n }\n } // end for \n\n\n Console.WriteLine(count.ToString());\n Console.ReadLine(); \n }\n\n static int[] StringToIntegers ( string S)\n {\n S = S + \" \"; \n string temp = \"\";\n int arrayCount = 0; \n int test ;\n int[] array = new int[100]; \n for ( int i = 0 ; i < S.Length ; i++ )\n {\n if ( int.TryParse ( S[i].ToString() , out test ))\n temp += S[i].ToString();\n else \n {\n \n array[arrayCount++] = int.Parse(temp);\n temp = \"\";\n }\n }\n return array; \n }\n static string RemoveSpaces (string input , char SpaceType )\n {\n string output = \"\"; \n for (int i = 0 ; i< input.Length ; i++ )\n {\n if ( input[i] != SpaceType)\n output+= input[i].ToString(); \n }\n return output; \n \n }\n }\n}\n", "lang_cluster": "C#", "tags": ["constructive algorithms", "implementation"], "code_uid": "0db386cee6e1924f76477f03525208a2", "src_uid": "4840d571d4ce6e1096bb678b6c100ae5", "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 ConsoleApplication44\n{\n class Program\n {\n static void Main(string[] args)\n {\n int[] nums = Console.ReadLine().Split().Select(e => Convert.ToInt32(e)).ToArray();\n\n int k = nums[0];\n int a = nums[1];\n int b = nums[2];\n int v = nums[3];\n\n int n = 1;\n while (true)\n {\n\n int m = b / n;\n \n int d = (b % n);\n if ((m + 1 <= k && d == 0) || m + 2 <= k)\n {\n int cap = v * ((m + 1) * (n - d) + d * (m + 2));\n if (cap >= a)\n break;\n }\n else\n {\n m = k - 1; d = 0;\n int cap = v * ((m + 1) * (n - d) + d * (m + 2));\n if (cap >= a)\n break;\n\n }\n n++;\n }\n\n\n Console.WriteLine(n);\n Console.ReadLine();\n\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "greedy"], "code_uid": "10601a0955bc8ccb2951bf7a3409c1ad", "src_uid": "7cff20b1c63a694baca69bdf4bdb2652", "difficulty": 1100.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 CFTraining.AimTech\n{\n class ConsoleScanner\n {\n private string[] _line;\n private int _iterator;\n\n public ConsoleScanner()\n {\n _line = null;\n _iterator = 0;\n }\n\n public int NextInt()\n {\n if (_line == null || _iterator >= _line.Length)\n {\n _line = Console.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 = Console.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 public int Read()\n {\n return Console.Read();\n }\n public string ReadLine()\n {\n return Console.ReadLine();\n }\n }\n class ProblemB\n {\n public static void Main(string[] args)\n {\n ConsoleScanner cs = new ConsoleScanner();\n int n = cs.NextInt();\n int[] a = new int[n];\n for (int i = 0; i < n; i++)\n {\n a[i] = cs.NextInt();\n }\n a = a.OrderBy(x => x).ToArray();\n long len = 0;\n int prev = int.MaxValue;\n for (int i = n - 1; i >= 0; i--)\n {\n if (a[i] < prev)\n {\n len += a[i];\n prev = a[i];\n if (prev == 1) break;\n }\n else\n {\n len += prev - 1;\n prev--;\n if (prev == 1) break;\n }\n }\n Console.WriteLine(len);\n }\n }\n}", "lang_cluster": "C#", "tags": ["sortings", "greedy"], "code_uid": "cf94e0a382d64eabd57f1f2c4970306f", "src_uid": "3c4b2d1c9440515bc3002eddd2b89f6f", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\n\nclass Program\n{\n static void Main(string[] args)\n {\n string input = Console.ReadLine();\n string vowels = \"aeyiou\";\n string result = \"\";\n input = input.ToLower();\n foreach (var letter in input)\n if(!vowels.Contains(letter.ToString()))\n result += \".\" + letter;\n Console.WriteLine(result);\n }\n}", "lang_cluster": "C#", "tags": ["strings", "implementation"], "code_uid": "2185b7327f4eb415dcfa12ec4368b211", "src_uid": "db9520e85b3e9186dd3a09ff8d1e8c1b", "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 string[] input = Console.ReadLine().Split(':');\n int HH = int.Parse(input[0]);\n int MM = int.Parse(input[1]);\n \n if(HH>=12)HH-=12;\n Console.Write((HH*30)+(MM/2));\n if (MM % 2 == 1) Console.Write(\".5\");\n Console.Write(\" \"+MM*6);\n // Console.ReadLine();\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "geometry"], "code_uid": "9cf13250cc9bcd8612445a90fba3b850", "src_uid": "175dc0bdb5c9513feb49be6644d0d150", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\n\nnamespace CodeForces\n{\n class Program\n {\n public static void Main()\n {\n var m = GetInt();\n var s = GetInt();\n\n var max_s = s;\n var max_nums = new int[m];\n\n for (int i = 0; i < m; i++)\n {\n var num = (max_s < 9) ? max_s : 9;\n max_s -= num;\n max_nums[i] = num;\n }\n\n var min_s = s - 1;\n var min_nums = new int[m];\n\n for (int i = m - 1; i >= 0; i--)\n {\n if (i == 0)\n {\n var num = (min_s < 8) ? min_s : 8;\n min_s -= num;\n min_nums[i] = num + 1;\n }\n else\n {\n var num = (min_s < 9) ? min_s : 9;\n min_s -= num;\n min_nums[i] = num;\n }\n }\n\n if (m > 1 && s == 0)\n {\n Console.Write(\"-1 -1\");\n }\n else if (max_s > 0 || min_s > 0)\n {\n Console.Write(\"-1 -1\");\n }\n else\n {\n Console.Write(\"{0} {1}\",\n string.Join(\"\", min_nums),\n string.Join(\"\", max_nums));\n }\n }\n\n private static int GetInt()\n {\n int ch = Console.Read();\n\n while (ch < '0' || ch > '9')\n {\n ch = Console.Read();\n }\n\n int current = 0;\n while (ch >= '0' && ch <= '9')\n {\n current = (current * 10) + (ch - '0');\n ch = Console.Read();\n }\n\n return current;\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["greedy", "dp", "implementation"], "code_uid": "8c1881478da7dab852f7d3de9e97d29a", "src_uid": "75d062cece5a2402920d6706c655cad7", "difficulty": 1400.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 static long modular_pow(long bases, long exponent, long modulus)\n {\n if (modulus == 1)\n {\n return 0;\n }\n long result = 1;\n bases = bases % modulus;\n while (exponent > 0)\n {\n if (exponent % 2 == 1)\n {\n result = (result * bases) % modulus;\n }\n exponent = exponent >> 1;\n bases = (bases * bases) % modulus;\n }\n return result;\n }\n static void program(TextReader input)\n {\n //var n = int.Parse(input.ReadLine().TrimEnd());\n var data = input.ReadLine().Split(' ').Select(long.Parse).ToList();\n var n = data[0];\n var m = data[1];\n var k = data[2];\n var mod = 1000000007;\n\n if(n%2 != m % 2 && k==-1)\n {\n writer.WriteLine(0);\n writer.Flush();\n return;\n }\n\n writer.WriteLine(modular_pow(modular_pow(2, ((n-1)), mod), (m - 1) , mod));\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(\"1\\n\");\n Console.WriteLine(\"Test Case(1) => found :\");\n program(new StringReader(\"1 1 -1\\n\"));\n Console.WriteLine();\n Console.ReadLine();\n\n Console.WriteLine(\"Test Case(2) => expected :\");\n Console.WriteLine(\"1\\n\");\n Console.WriteLine(\"Test Case(2) => found :\");\n program(new StringReader(\"1 3 1\\n\"));\n Console.WriteLine();\n Console.ReadLine();\n\n Console.WriteLine(\"Test Case(3) => expected :\");\n Console.WriteLine(\"16\\n\");\n Console.WriteLine(\"Test Case(3) => found :\");\n program(new StringReader(\"3 3 -1\\n\"));\n Console.WriteLine();\n Console.ReadLine();\n\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "constructive algorithms", "combinatorics", "number theory"], "code_uid": "6d7023dd40b62ed54b0d4a0f8f994c57", "src_uid": "6b9eff690fae14725885cbc891ff7243", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.IO;\nusing System.Text;\n\nnamespace Dreamoon_and_Sums\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 const long mod = 1000000007;\n long a = Next();\n long b = Next();\n\n long sum = 0;\n for (long i = 1; i < b; i++)\n {\n long count = a;\n long b0 = (i*b + i)%mod;\n sum += (count * b0) % mod + ((((count - 1) * count / 2) % mod * i) % mod * b) % mod;\n sum = sum%mod;\n }\n\n writer.WriteLine(sum%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"], "code_uid": "9c8fd725852f4e7f7f664db04c59aaa9", "src_uid": "cd351d1190a92d094b2d929bf1e5c44f", "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 matrix\n{\n class Program\n {\n static void Main(string[] args)\n {\n int[] opprants = new int[3];\n\n for (int i = 0; i < 3; i++)\n {\n int num = int.Parse(Console.ReadLine());\n opprants[i] = num;\n\n }\n int m= ArthimaticExpression(opprants);\n Console.WriteLine(m);\n\n }\n static int ArthimaticExpression(int[] opprants)\n {\n List values =new List();\n \n values.Add(opprants[0]+opprants[1]+opprants[2]);\n values.Add(opprants[0]*opprants[1]*opprants[2]);\n values.Add((opprants[0]+opprants[1])*opprants[2]);\n values.Add((opprants[0]*opprants[1])+opprants[2]);\n values.Add(opprants[0] + (opprants[1] * opprants[2]));\n values.Add(opprants[0] * (opprants[1] + opprants[2]));\n\n return Max(values);\n\n\n\n }\n static int Max(List numbers)\n {\n int max = numbers[0];\n for (int i = 0; i < numbers.Count; i++)\n {\n if (numbers[i]>max)\n {\n max = numbers[i];\n }\n }\n return max;\n }\n\n\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "math"], "code_uid": "688676c5a09b6a4a134a06eae0f7a6e5", "src_uid": "1cad9e4797ca2d80a12276b5a790ef27", "difficulty": 1000.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 Console.WriteLine(Console.ReadLine().Split(new char[] {' '}, StringSplitOptions.RemoveEmptyEntries).Select(int.Parse).Where(x => x != 0).Distinct().Count());\n }\n}", "lang_cluster": "C#", "tags": ["sortings", "implementation"], "code_uid": "3c077a2961de64bccac25a62c8307438", "src_uid": "3b520c15ea9a11b16129da30dcfb5161", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Linq;\nusing System.Collections.Generic;\n\nclass P\n{\n static void Main()\n {\n long[] d = { 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576, 2097152, 4194304, 8388608, 16777216, 33554432, 67108864, 134217728, 268435456, 536870912, 1073741824, 2147483648, 4294967296, 8589934592, 17179869184, 34359738368, 68719476736, 137438953472, 274877906944, 549755813888, 1099511627776, 2199023255552, 4398046511104, 8796093022208, 17592186044416, 35184372088832, 70368744177664, 140737488355328, 281474976710656, 562949953421312, 1125899906842624, 2251799813685248, 4503599627370496, 9007199254740992, 18014398509481984, 36028797018963968, 72057594037927936, 144115188075855872, 288230376151711744, 576460752303423488, 1152921504606846976, 2305843009213693952, 4611686018427387904 };\n long[] ab = Console.ReadLine().Split().Select(long.Parse).ToArray();\n int a = -1;\n for (int i = 0; i < 64; i++)\n {\n if (ab[0] < d[i])\n {\n a = i;\n break;\n }\n }\n if (ab[1] == 1)\n {\n Console.WriteLine(ab[0]);\n }\n else\n {\n Console.WriteLine(d[a] - 1);\n }\n }\n}", "lang_cluster": "C#", "tags": ["constructive algorithms", "number theory", "bitmasks"], "code_uid": "a7a6224f69d6dbc83ee22773fb6736c8", "src_uid": "16bc089f5ef6b68bebe8eda6ead2eab9", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeff//A. BracketSequence\n#define TRYx\n\nusing System;\nusing System.Collections.Generic;\nusing System.IO;\n\npublic class Parallelepiped\n{\n public static void Main ( )\n {\n#if TRY\n Console.SetIn ( new StringReader ( \"1 1 1\" ) );\n solve ( );\n Console.SetIn ( new StringReader ( \"66 174 319\" ) );\n\n#endif\n solve ( );\n //Console.WriteLine ( solve ( ) );\n }\n\n private static void solve( )\n {\n int[] ii = ReadLineToInts ( );\n double X=ii[0];\n double Y=ii[1];\n double Z=ii[2];\n\n double ans=0;\n int a=-1;\n int b=-1;\n int c;\n\n for ( c = 1; c <= 10000; c++ )\n {\n X = ii[0]; Y = ii[1]; Z = ii[2];\n if ( Check ( X, Y, Z, c, out a, out b ) )\n break;\n X = ii[1]; Y = ii[0]; Z = ii[2];\n if ( Check ( X, Y, Z, c, out a, out b ) )\n break;\n X = ii[1]; Y = ii[2]; Z = ii[0];\n if ( Check ( X, Y, Z, c, out a, out b ) )\n break;\n X = ii[2]; Y = ii[0]; Z = ii[1];\n if ( Check ( X, Y, Z, c, out a, out b ) )\n break;\n X = ii[2]; Y = ii[1]; Z = ii[0];\n if ( Check ( X, Y, Z, c, out a, out b ) )\n break;\n\n continue;\n }\n ans = ( a + b + c ) * 4;\n\n Console.WriteLine ( ans );\n }\n\n static bool Check ( double X, double Y, double Z, int c, out int a, out int b)\n {\n a = -1;\n b = -1;\n double sumabc = ( X / Y + X / Z + 1 ) * c;\n if ( sumabc - ( int ) sumabc == 0 )\n {\n a = ( int ) Z / c;\n b = ( int ) Y / c;\n if ( ( int ) Z % c == 0 && ( int ) Y % c == 0 && sumabc == ( a + b + c ) )\n return true;\n }\n return false;\n }\n\n public static int[] ReadLineToInts ( )\n {\n string line = Console.ReadLine ( );\n string[] arStrings = line.Split ( new char[] { ' ' } );\n\n int N = arStrings.Length;\n int[] ints = new int[N];\n for ( int i=0; i < N; i++ )\n ints[i] = int.Parse ( arStrings[i] );\n return ints;\n }\n\n\n}", "lang_cluster": "C#", "tags": ["brute force", "math", "geometry"], "code_uid": "bca86d91d612feeb6bd4d05c45e61575", "src_uid": "c0a3290be3b87f3a232ec19d4639fefc", "difficulty": 1100.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 int k = int.Parse(Console.ReadLine());\n int i = 1;\n int currentK = 0;\n\n while (i < int.MaxValue)\n {\n int sum = 0;\n\n string str = i.ToString();\n\n for (var j = 0; j < str.Length; j++)\n {\n sum += (str[j] - '0');\n if (sum > 10)\n {\n break;\n }\n }\n\n if (sum == 10)\n {\n currentK++;\n\n if (currentK == k)\n {\n Console.WriteLine(str);\n break;\n }\n\n i = i + 9;\n }\n\n else\n {\n i++;\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", "dp", "binary search", "implementation", "number theory"], "code_uid": "a498718d2e208e7b6bb24b2a30b6c49c", "src_uid": "0a98a6a15e553ce11cb468d3330fc86a", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nclass Program\n{\n static void Main()\n {\n Console.ReadLine();\n int[] places = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);\n Array.Sort(places);\n Console.WriteLine(places[places.Length - 1] - 25 < 0 ? 0 : places[places.Length - 1] - 25);\n }\n}", "lang_cluster": "C#", "tags": ["greedy", "implementation"], "code_uid": "511c8d78f18921e7e447ca81bf62248f", "src_uid": "ef657588b4f2fe8b2ff5f8edc0ab8afd", "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 goodbye2015\n{\n class Program\n {\n static void Main(string[] args)\n {\n string[] s = Console.ReadLine().Split(' ');\n if (s[2] == \"month\")\n {\n int ans = 0;\n int day = int.Parse(s[0]);\n if (day <= 29)\n {\n Console.WriteLine(12);\n }\n else\n if (day == 30)\n {\n Console.WriteLine(11);\n }\n else\n {\n Console.WriteLine(7);\n }\n }\n else\n {\n int month = int.Parse(s[0]);\n if (month <= 3) Console.WriteLine(52);\n else\n if (month == 4) Console.WriteLine(52);\n else\n if (month == 5) Console.WriteLine(53);\n else\n if (month == 6) Console.WriteLine(53);\n else\n Console.WriteLine(52);\n\n }\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "e95ab8d48bd62d3d534d86fb39a0b706", "src_uid": "9b8543c1ae3666e6c163d268fdbeef6b", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeff//#undef DEBUG\n\nusing System;\nusing System.Collections.Generic;\nusing System.Text;\nusing System.Diagnostics;\n\nnamespace codeforces\n{\n class C\n {\n // test\n static CodeforcesUtils CF = new CodeforcesUtils(\n@\"\n10000 5000 5000 5000\n\");\n\n class Solver\n {\n public void Solve()\n {\n string[] ss = CF.ReadLine().Split(' ');\n int n = int.Parse(ss[0]);\n int a = int.Parse(ss[1]);\n int b = int.Parse(ss[2]);\n int c = int.Parse(ss[3]);\n\n int cmb=0;\n for (int i1 = 0; i1 <= c; i1++)\n {\n int sum = i1 * 4;\n if (sum > n*2)\n break;\n\n for (int i2 = 0; i2 <= b; i2++)\n {\n int sum2 = sum + (i2 * 2);\n\n int tmp = n*2-sum2;\n if (tmp > a)\n continue;\n if (tmp < 0)\n break;\n\n cmb++;\n\n //Debug.WriteLine(i1 + \" \" + i2 + \" \" + tmp);\n }\n }\n CF.WriteLine(cmb);\n\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 new Solver().Solve();\n CF.Close();\n }\n\n static void TLE()\n {\n for (; ; ) ;\n }\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\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": ["implementation"], "code_uid": "6c7c8fc49b7bd20fa8c05b61cc60fe73", "src_uid": "474e527d41040446a18186596e8bdd83", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\n\nnamespace ConsoleApplication37\n{\n class Program\n {\n static void Main(string[] args)\n {\n (new B_Solution()).SolveProblem();\n }\n }\n class B_Solution\n {\n public void SolveProblem()\n {\n Reader input = new Reader();\n int n = input.GiveNextElementInt();\n List nuts_positions = new List();\n for (int i = 0; i < n; i++)\n {\n int current_position = input.GiveNextElementInt();\n if (current_position == 1) nuts_positions.Add(i);\n }\n if (nuts_positions.Count == 0)\n {\n Console.WriteLine(0);\n Console.ReadLine();\n return;\n }\n long answer = 1;\n for (int i = 0; i < nuts_positions.Count - 1; i++)\n answer *= (nuts_positions[i + 1] - nuts_positions[i]);\n Console.WriteLine(answer);\n Console.ReadLine();\n }\n }\n class Reader\n {\n string[] elements;\n int position = -1;\n public string GiveNextElementString()\n {\n if (elements == null || position == elements.Length)\n {\n elements = Console.ReadLine().Split(' ');\n position = 1;\n return elements[position - 1];\n }\n else\n {\n position++;\n return elements[position - 1];\n }\n }\n public int GiveNextElementInt()\n {\n return int.Parse(GiveNextElementString());\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["combinatorics"], "code_uid": "62dadd64a923f420afd35a1f4949ed94", "src_uid": "58242665476f1c4fa723848ff0ecda98", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\n\nnamespace NetExperiment\n{\n class Program\n {\n static void Main(string[] args)\n {\n int[] kr = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();\n int i = 1;\n while ((kr[0] * i) % 10 != kr[1] && (kr[0] * i) % 10 != 0) i++;\n Console.WriteLine(i);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "math", "constructive algorithms", "implementation"], "code_uid": "ac10fddee93059115f1eb9b1f031c638", "src_uid": "18cd1cd809df4744bb7bcd7cad94e2d3", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Linq;\n\nnamespace ConsoleApplication2\n{\n class Program\n {\n static void Main(string[] args)\n {\n int k = Convert.ToInt32(Console.ReadLine());\n int[] Ai = Console.ReadLine().Split().Select(x => Convert.ToInt32(x)).OrderByDescending(c => c).ToArray();\n Console.WriteLine(Solver(Ai,k));\n }\n\n public static int Solver(int[] Ai, int k)\n {\n if (k == 0)\n return 0;\n int sum = 0;\n for (int i = 0; i < Ai.Length; i++)\n {\n sum += Ai[i];\n if (sum >= k)\n return i+1;\n }\n return -1;\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["sortings", "implementation", "greedy"], "code_uid": "ddfdc8d5e6c5dee593ae2233042a6348", "src_uid": "59dfa7a4988375febc5dccc27aca90a8", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeff#define ONLINE_JUDGE\n\nusing System;\nusing System.Collections.Generic;\nusing System.Text;\nusing System.IO;\n\nclass Program\n{\n\n static int tests = 1;\n\n#if (ONLINE_JUDGE)\n static TextReader r = Console.In;\n static TextWriter w = Console.Out;\n#else\n static string path = @\"C:\\Y\\Prog\\Codeforces\\194\\\";\n static string answerFile = \"0{0}Answer.txt\";\n static string resultFile = \"0{0}Result.txt\";\n static string sourceFile = \"0{0}Source.txt\";\n \n static TextReader r;\n static TextWriter w;\n#endif\n\n static void Main(string[] args)\n {\n for (int i = 1; i <= tests; i++)\n {\n#if (!ONLINE_JUDGE)\n r = new StreamReader(string.Format(path + sourceFile, i));\n w = new StreamWriter(string.Format(path + resultFile, i), false);\n#endif\n int[] x = new int[8];\n int[] y = new int[8];\n for (int j = 0; j < 8; j++)\n {\n string[] buff = r.ReadLine().Split(' ');\n x[j] = Convert.ToInt32(buff[0]);\n y[j] = Convert.ToInt32(buff[1]);\n }\n solve(x,y);\n //w.Flush();\n //w.Dispose();\n#if (!ONLINE_JUDGE)\n w.Flush(); w.Close();\n Console.WriteLine(\"CASE: {0}\", i);\n string answer = File.ReadAllText(string.Format(path + answerFile, i));\n string result = File.ReadAllText(string.Format(path + resultFile, i));\n if (answer != result)\n {\n Console.WriteLine(\"FAIL:\");\n Console.WriteLine(\"Result\" + Environment.NewLine + result);\n Console.WriteLine(\"Answer\" + Environment.NewLine + answer);\n }\n else\n Console.WriteLine(\"OK\");\n#endif\n }\n }\n\n public static void solve(int[] x, int[] y)\n {\n int[] xDiff = getDiff(x);\n int[] yDiff = getDiff(y);\n if (xDiff.Length != 3 || yDiff.Length != 3)\n {\n w.WriteLine(\"ugly\");\n return;\n }\n for (int i = 0; i < xDiff.Length; i++)\n for (int j = 0; j < yDiff.Length; j++) \n {\n if (i == 1 && j == 1) continue;\n bool find = false;\n for (int k = 0; k < x.Length; k ++)\n {\n if (x[k] == xDiff[i] && y[k] == yDiff[j])\n find = true;\n }\n if (!find)\n {\n w.WriteLine(\"ugly\");\n return;\n }\n }\n w.WriteLine(\"respectable\");\n \n }\n\n public static int[] getDiff(int[] x)\n {\n Dictionary res = new Dictionary();\n List res2 = new List();\n foreach(int i in x)\n if (!res.ContainsKey(i))\n {\n res.Add(i,i);\n res2.Add(i);\n }\n int[] res3 = res2.ToArray();\n Array.Sort(res3);\n return res3;\n }\n}\n", "lang_cluster": "C#", "tags": ["sortings"], "code_uid": "81146caa437e57bd0732e0b0a8721fb4", "src_uid": "f3c96123334534056f26b96f90886807", "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\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\tstring 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).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 b = long.Parse(input1);\n\t\t\tlong g = long.Parse(input2);\n\t\t\tlong n = long.Parse(input3);\n\n\t\t\tvar maxBoys = Math.Min(b, n);\n\t\t\tvar maxGirls = Math.Min(g, n);\n\n\t\t\tvar minBoys = n - maxGirls;\n\t\t\tvar minGirls = n - maxBoys;\n\n\t\t\tint count = 0;\n\t\t\tfor (int i = 0; i < n + 1; i++) \n\t\t\t{\n\t\t\t\tvar blue = i;\n\t\t\t\tvar red = n - i;\n\n\t\t\t\tif (blue < minBoys || blue > maxBoys) \n\t\t\t\t{\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tif (red < minGirls || red > maxGirls)\n\t\t\t\t{\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tcount++;\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": ["brute force", "math"], "code_uid": "061f98ae78d982e8a27eb6686458f452", "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.IO;\nusing System.Collections;\n\nnamespace ConsoleApplication1\n{\n class CanadaCup2\n {\n static void Main(string[] args)\n {\n //Console.SetIn(new StreamReader(@\"D:\\Sergey\\Code\\1.txt\"));\n\n string ns = Console.ReadLine();\n ulong n = ulong.Parse(ns.Substring(0, ns.Length - 1));\n char s = ns[ns.Length - 1];\n int c = s - 'a';\n int[] d = new int[] { 3, 4, 5, 2, 1, 0 };\n ulong a = (n - 1) % 2;\n ulong b = (n - 1) / 4;\n //if (b > 1)\n // b -= 2;\n\n ulong e = b * 16;\n if (a > 0)\n e+=7;\n e += (ulong)(d[c] + 1);\n\n Console.WriteLine(e);\n\n } // Main\n }\n}", "lang_cluster": "C#", "tags": ["math", "implementation"], "code_uid": "7a41b170f1d0fe041f5a96b9ba8dfdbc", "src_uid": "069d0cb9b7c798a81007fb5b63fa0f45", "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 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}\n\t}\n}\n", "lang_cluster": "C#", "tags": ["math", "number theory"], "code_uid": "cc0522c4123283656ab740b998f58b19", "src_uid": "031e53952e76cff8fdc0988bb0d3239c", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\n\nnamespace _664A\n{\n class Program\n {\n static void Main()\n {\n var s = Console.ReadLine().Split();\n var a = s[0];\n var b = s[1];\n if (a == b) Console.WriteLine(a);\n else Console.WriteLine(1);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "number theory"], "code_uid": "869d95aad549e1a7705b19debba82f27", "src_uid": "9c5b6d8a20414d160069010b2965b896", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\n\nnamespace cf116b\n{\n class MainClass\n {\n static int n;\n static int m ;\n public static void Main (string[] args)\n {\n string nm = Console.ReadLine();\n n = int.Parse ( nm.Split(' ')[0]);\n m = int.Parse ( nm.Split(' ')[1]);\n string data;\n char[][] field = new char[n][];\n for (int i = 0; i < n; i++) {\n data = Console.ReadLine();\n field[i] = data.ToCharArray();\n }\n\n int res = 0;\n for (int i = 0; i < n; i++) {\n for (int j = 0; j < m; j++) \n {\n int wi, wj;\n if (field[i][j] == 'P' && WolfNeighbour(field,i,j,out wi,out wj)){\n field[wi][wj] = '.';\n res++;\n }\n }\n }\n\n Console.WriteLine (res);\n }\n\n private static Boolean WolfNeighbour(char[][] arr, int i, int j, out int wi, out int wj)\n {\n if (j + 1 < m){\n if (arr[i][j+1] == 'W')\n {\n wi=i;\n wj=j+1;\n return true;\n }\n }\n if (j -1 >= 0){\n if (arr[i][j-1] == 'W')\n {\n wi=i;\n wj=j-1;\n return true;\n }\n }\n\n if (i + 1 < n){\n if (arr[i+1][j] == 'W')\n {\n wi=i+1;\n wj=j;\n return true;\n }\n }\n\n if (i-1 >= 0){\n if (arr[i-1][j] == 'W')\n {\n wi=i-1;\n wj=j;\n return true;\n }\n }\n\n wi=-1;\n wj=-1;\n return false;\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["greedy", "implementation"], "code_uid": "16d77e8ef715b68d27cfc480534a2c77", "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.Collections.Specialized;\nusing System.Text;\nusing System.Text.RegularExpressions;\nusing System.Linq;\nusing System.IO;\n\nclass Program\n{\n static void Main()\n {\n new Magatro().Solve();\n }\n}\n\nclass Magatro\n{\n private int A, B;\n private void Scan()\n {\n var line = Console.ReadLine().Split(' ');\n A = int.Parse(line[0]);\n B = int.Parse(line[1]);\n }\n\n\n\n\n public void Solve()\n {\n Scan();\n int ans = 1;\n for(int i = 1; i <= Math.Min(A, B); i++)\n {\n ans *= i;\n }\n Console.WriteLine(ans);\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "implementation", "number theory"], "code_uid": "3ada922477b32d0e84505e86774555cd", "src_uid": "7bf30ceb24b66d91382e97767f9feeb6", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.ComponentModel;\nusing System.Linq;\nusing System.Collections;\nusing System.Collections.Generic;\n\npublic static partial class Program\n{\n\tpublic static void InputProcessing()\n\t{\n\t\tint[] vars = ParseArray();\n\t\tint a = vars[0];\n\t\tint b = vars[1];\n\t\tint c = vars[2];\n\t\tint d = vars[3];\n\t\tConsole.WriteLine(DataProcessing(a, b, c, d));\n\t}\n\n\tpublic static string DataProcessing(int a, int b, int c, int d)\n\t{\n\t\tList s = new List();\n\t\ts.Add(Function(a, b, c));\n\t\ts.Add(Function(a, b, d));\n\t\ts.Add(Function(a, c, d));\n\t\ts.Add(Function(b, c, d));\n\n\t\tif (s.Max() == 2)\n\t\t{\n\t\t\treturn \"TRIANGLE\";\n\t\t} else if (s.Max() == 1)\n\t\t{\n\t\t\treturn \"SEGMENT\";\n\t\t} else\n\t\t{\n\t\t\treturn \"IMPOSSIBLE\";\n\t\t}\n\t}\n\n\tpublic static int Function(int a, int b, int c)\n\t{\n\t\tif (a + b < c || b + c < a || a + c < b)\n\t\t{\n\t\t\treturn 0; // \"IMPOSSIBLE\";\n\t\t} else if (a + b == c || b + c == a || a + c == b)\n\t\t{\n\t\t\treturn 1; // \"SEGMENT\";\n\t\t} else\n\t\t{\n\t\t\treturn 2; // \"TRIANGLE\";\n\t\t}\n\t}\n}\n\npublic static partial class Program\n{\n\tpublic static void Main(string[] args)\n\t{\n\t\tInputProcessing();\n#if DEBUG\n\t\tConsole.ReadLine();\n#endif\n\t}\n\n\tpublic static T[] ParseArray()\n\t{\n\t\tTypeConverter tc = TypeDescriptor.GetConverter(typeof(T));\n\t\tstring[] input = Console.ReadLine().Split();\n\t\tT[] output = new T[input.Length];\n\t\tfor (int i = 0; i < input.Length; i++) { output[i] = (T)tc.ConvertFromString(input[i]); }\n\t\treturn output;\n\t}\n\n\tpublic static T[][] ParseMatrix(int nrows)\n\t{\n\t\tT[][] rv = new T[nrows][];\n\t\tfor (int i = 0; i < nrows; i++) { rv[i] = ParseArray(); }\n\t\treturn rv;\n\t}\n}\n", "lang_cluster": "C#", "tags": ["brute force", "geometry"], "code_uid": "ca41d434db4c29b10e9b71e00b44439e", "src_uid": "8f5df9a41e6e100aa65b9fc1d26e447a", "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 ProblemSolving.CodeForces\n{\n class Polycarps\n {\n public static void Main(string[] args)\n {\n int a = int.Parse(Console.ReadLine());\n int[] arr = Console.ReadLine().Split().Select(int.Parse).ToArray();\n int[] cnt = new int[200];\n cnt = cnt.Select(i => 0).ToArray();\n\n for(int i = 0; i < arr.Length; i++)\n {\n cnt[arr[i]]++;\n }\n\n int maxValue = cnt.Max();\n Console.WriteLine(maxValue);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "4acc3421449c6f8b90f06c645bb9153b", "src_uid": "f30329023e84b4c50b1b118dc98ae73c", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\n\nnamespace deneme\n{\n class Program\n {\n static void Main(string[] args)\n { \n try\n {\n string s = Console.ReadLine();\n int[] alph = new int[26];\n char letter = ' ';\n int counter = 0;\n for (int i = 0; i < s.Length; i++)\n {\n letter = s[i];\n alph[(int)letter - 97 ] = 1;\n\n }\n for (int i = 0; i < alph.Length; i++)\n {\n if (alph[i] >= 1)\n counter++;\n }\n if (counter % 2 == 0)\n Console.Write(\"CHAT WITH HER!\");\n else\n Console.Write(\"IGNORE HIM!\");\n\n\n Console.Read();\n }\n catch { }\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "strings", "implementation"], "code_uid": "b7979b84f7a634ece20eac7c79d56742", "src_uid": "a8c14667b94b40da087501fd4bdd7818", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Diagnostics.CodeAnalysis;\nusing System.Linq;\nusing System.Threading;\nusing static System.Console;\n\nnamespace task\n{\n class Program\n {\n static void Main(string[] args)\n { \n var data = ReadLine().Split(' ').Select(int.Parse);\n var n = data.ElementAt(0);\n var k = data.ElementAt(1);\n int ans = 0;\n\n if (k % n == 0)\n {\n ans = k / n;\n }\n else\n {\n ans = k / n + 1;\n }\n\n Console.WriteLine(ans);\n\n }\n }\n}\n\n", "lang_cluster": "C#", "tags": ["math", "greedy", "implementation"], "code_uid": "1275fcbf0b16f062b4e5380a31e45114", "src_uid": "04c067326ec897091c3dbcf4d134df96", "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 SummerSchool\n{\n class Program\n {\n static void Main(string[] args)\n {\n int n = int.Parse(Console.ReadLine());\n\n int digits = 1, count = 0, a = 1,b=9;\n\n while (count+b*digits n; i--) number /= 10;\n\n Console.Write(number % 10);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "fa3bf7469f1214a97e6ee4bacea6fbeb", "src_uid": "2d46e34839261eda822f0c23c6e19121", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "C# 10", "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;\r\n long M;\r\n\r\n ModInt[] C;\r\n\r\n List Primes;\r\n bool[] IsPrime;\r\n public void Solve()\r\n {\r\n var sc = new Scanner();\r\n N = sc.NextInt();\r\n M = sc.NextLong();\r\n\r\n // GCD(A[i], i) = 1\u306a\u3089A[i]\u3092\u6d88\u305b\u308b\r\n\r\n // 1 <= B[i] <= N-i+1 \u306a\u914d\u5217B\r\n // B[i] i\u56de\u76ee\u306b\u6d88\u3059\u8981\u7d20\r\n\r\n // B\u304c\u8907\u6570\u8003\u3048\u3089\u308c\u308bA\u306f\u4f55\u901a\u308a\u304b?\r\n\r\n // \u8981\u7d20 1 <= A[i] <= M\r\n // \u9577\u3055N\r\n\r\n // B = {1,1,1,1,1,1} \u306e\u307f\r\n // \u4e0a\u4ee5\u5916\u306a\u3089OK\r\n\r\n // i\u756a\u76ee\r\n // 1,2,3,4,...i \u3068GCD=1\u306a\u6574\u6570\r\n\r\n // 2\u756a\u76ee\u4ee5\u964d i\r\n // 2,3,4, ...i\u3068GCD 1\u4ee5\u5916\r\n C = new ModInt[N + 1];\r\n C[1] = M;\r\n\r\n\r\n Primes = new List();\r\n IsPrime = MathEx.Sieve(N, Primes);\r\n\r\n long lcm = 1;\r\n\r\n for (int i = 2; i <= N; i++)\r\n {\r\n if (lcm > M)\r\n {\r\n C[i] = 0;\r\n }\r\n else\r\n {\r\n if (IsPrime[i])\r\n {\r\n lcm *= i;\r\n }\r\n C[i] = (M / lcm) % ModInt.Mod;\r\n }\r\n\r\n }\r\n // Console.WriteLine(String.Join(\" \", C));\r\n\r\n ModInt ans = 0;\r\n ModInt all = 1;\r\n ModInt minus = 1;\r\n for (int i = 1; i <= N; i++)\r\n {\r\n all *= M % ModInt.Mod;\r\n minus *= C[i];\r\n\r\n\r\n ans += all - minus;\r\n }\r\n\r\n Console.WriteLine(ans);\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 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", "dp", "combinatorics", "number theory"], "code_uid": "d9e863bc54706b10644c44f4a5945f15", "src_uid": "0fdd91ed33431848614075ebe9d2ee68", "difficulty": 1900.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections;\nusing System.Collections.Generic;\nusing System.Text;\nusing System.Text.RegularExpressions;\nusing System.Globalization;\nusing System.Threading;\nusing System.Linq;\n \nclass TEST{\n\tstatic void Main(){\n\t\tvar S=Console.ReadLine();\n\t\t\n\t\tbool chk=true;\n\t\t//1\n\t\tif(S.Length<5)chk=false;\n\t\t//2,3,4\n\t\tbool chk2=false;\n\t\tfor(int i=0;i='A' && S[i]<='Z')chk2=true;\n\t\t}\n\t\tchk=chk&chk2;\n\t\tchk2=false;\n\t\tfor(int i=0;i='a' && S[i]<='z')chk2=true;\n\t\t}\n\t\tchk=chk&chk2;\n\t\tchk2=false;\n\t\tfor(int i=0;i='0' && S[i]<='9')chk2=true;\n\t\t}\n\t\tchk=chk&chk2;\n\t\t\n\t\t\n\t\tConsole.WriteLine(chk?\"Correct\":\"Too weak\");\n\t\t\n\t\t\n\t\t\n\t}\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "61026f3d7ba94c32e1ce4ac0eba9f942", "src_uid": "42a964b01e269491975965860ec92be7", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Linq;\n\nnamespace trenvk\n{\n class Program\n {\n static long nb, ns, nc, needB, needS, needC, pb, ps, pc, rub;\n\n static void Main(string[] args)\n {\n string Str = Console.ReadLine();\n long[] n = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();\n long[] p = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();\n rub = long.Parse(Console.ReadLine());\n\n needB = 0; needS = 0; needC = 0;\n nb = n[0]; ns = n[1]; nc = n[2];\n pb = p[0]; ps = p[1]; pc = p[2];\n\n for(int i = 0; i < Str.Length; i++)\n {\n switch (Str[i])\n {\n case 'B':\n needB++;\n break;\n case 'C':\n needC++;\n break;\n case 'S':\n needS++;\n break;\n }\n }\n\n long l = 0;\n long r = 100000000000000;\n while(l < r)\n {\n long m = (r + l) / 2;\n if (check(m)) l = m + 1;\n else r = m;\n }\n Console.WriteLine(l - 1);\n } \n \n static bool check(long n)\n {\n long PriceB = Math.Max(0, (needB * n - nb) * pb);\n long PriceS = Math.Max(0, (needS * n - ns) * ps);\n long PriceC = Math.Max(0, (needC * n - nc) * pc);\n long sum = PriceB + PriceS + PriceC;\n return PriceB + PriceS + PriceC <= rub;\n } \n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "binary search"], "code_uid": "12627cadb94d3ad3462b70f7d89f5459", "src_uid": "8126a4232188ae7de8e5a7aedea1a97e", "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 _577A_Multiplication_Table\n{\n class Program\n {\n static void Main(string[] args)\n {\n string[] str = Console.ReadLine().Split();\n long n = long.Parse(str[0]);\n long x = long.Parse(str[1]);\n int counter = 0;\n\n for (long i = 1; i <= n; i++)\n {\n if (x % i == 0 && x <= n * i)\n counter++;\n }\n\n Console.WriteLine(counter.ToString());\n Console.ReadLine();\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["implementation", "number theory"], "code_uid": "2dc5c3a69a70a6a5398b5201e4539f4a", "src_uid": "c4b139eadca94201596f1305b2f76496", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\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 q1x = new int[4];\n var q1y = new int[4];\n var q2x = new int[4];\n var q2y = new int[4];\n for (var i = 0; i < 4; i++)\n {\n q1x[i] = input.ReadInt();\n q1y[i] = input.ReadInt();\n }\n for (var i = 0; i < 4; i++)\n {\n q2x[i] = input.ReadInt();\n q2y[i] = input.ReadInt();\n }\n var x1min = q1x.Min();\n var y1min = q1y.Min();\n var x1max = q1x.Max();\n var y1max = q1y.Max();\n var x2min = q2x.Min();\n var y2min = q2y.Min();\n var x2max = q2x.Max();\n var y2max = q2y.Max();\n var d = (x2max - x2min) / 2;\n for (var x = Max(x1min, x2min); x <= Min(x1max, x2max); x++)\n {\n for (var y = Max(y1min, y2min); y <= Min(y1max, y2max); y++)\n {\n if (x >= x1min && x <= x1max &&\n y >= y1min && y <= y1max &&\n x >= x2min && x <= x2max &&\n y >= y2min && y <= y2max)\n {\n var x0 = x - x2min - d;\n var y0 = y - y2min - d;\n if (x0 + y0 <= d &&\n x0 + y0 >= -d &&\n y0 - x0 <= d &&\n y0 - x0 >= -d)\n {\n Write(\"YES\");\n return;\n }\n }\n }\n }\n Write(\"NO\");\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 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()\n {\n var solver = new ProblemSolver(In);\n solver.Solve();\n }\n }\n\n #endregion\n}\n", "lang_cluster": "C#", "tags": ["geometry", "implementation"], "code_uid": "337eefcd731e2c7ced8e3a5378914caf", "src_uid": "f6a3dd8b3bab58ff66055c61ddfdf06a", "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 chatroom.cs\n{\n class Program\n {\n static void Main()\n {\n int a = 0;\n int b = 0;\n int c = 0;\n int d = 0;\n int e = 0;\n \n string hlo = Console.ReadLine();\n for (int i = 0; i < hlo.Length; i++) { if (hlo[i] == 'h') { a = i; break; } }\n for (int j = a+1; j < hlo.Length; j++)\n {\n if (hlo[j] == 'e')\n {\n b = j;\n \n break;\n }\n }\n \n for (int k = b+1; k < hlo.Length; k++)\n {\n if (hlo[k] == 'l')\n {\n c = k;\n\n for (int l = c+1; l < hlo.Length; l++)\n {\n if (hlo[l] == 'l')\n {\n d=l;\n \n break;\n\n }\n }\n if (d != 0) {\n break;\n }\n }\n\n }\n \n \n \n \n for (int m = d+1; m < hlo.Length; m++)\n {\n if (hlo[m] == 'o')\n {\n e = m;\n \n break;\n }\n }\n \n\n if ((a < b) && (b < c) && (c <= d) && (d < e)) { Console.WriteLine(\"YES\"); }\n else { Console.WriteLine(\"NO\"); }\n\n \n\n\n }\n }\n}\n \n\n", "lang_cluster": "C#", "tags": ["greedy", "strings"], "code_uid": "2d372aacb5806a63a56fcee214eb0bda", "src_uid": "c5d19dc8f2478ee8d9cba8cc2e4cd838", "difficulty": 1000.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#region ioh\n\nclass Scanner\n{\n private readonly TextReader reader;\n private string[] buffer;\n private int bufferPos;\n\n public Scanner()\n : this(null)\n { }\n\n public Scanner(TextReader reader)\n {\n this.reader = reader ?? Console.In;\n buffer = new string[0];\n }\n\n public string NextTerm()\n {\n if (bufferPos >= buffer.Length)\n {\n buffer = reader.ReadLine().Split(' ');\n bufferPos = 0;\n }\n\n return buffer[bufferPos++];\n }\n\n public int NextInt()\n {\n return int.Parse(NextTerm());\n }\n\n public int[] NextIntArray()\n {\n return Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);\n }\n\n public int[][] NextIntMatrix(int rowCount)\n {\n var matrix = new int[rowCount][];\n\n for (int i = 0; i < matrix.Length; i++)\n {\n matrix[i] = NextIntArray();\n }\n\n return matrix;\n }\n}\n\n#endregion\n\nclass Program\n{\n private static readonly Scanner s = new Scanner();\n\n static void Main(string[] args)\n {\n s.NextTerm();\n var m = s.NextInt();\n \n var gs = s.NextIntArray();\n\n var b = 0;\n\n var res = 0;\n\n for (int i = 0; i < gs.Length; i++)\n {\n if (b+gs[i]>m)\n {\n res++;\n b = gs[i];\n }\n else\n {\n b += gs[i];\n }\n }\n\n if (b>0)\n {\n res++;\n }\n\n Console.WriteLine(res);\n\n }\n}", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "233364b784463345491b93d480eca02a", "src_uid": "5c73d6e3770dff034d210cdd572ccf0f", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\n\nnamespace Olymp\n{\n class Heap\n {\n SortedList counter;\n public Heap(IEnumerable collection)\n {\n counter = new SortedList();\n foreach(var item in collection)\n Push(item);\n }\n public T PopMax()\n {\n int n = counter.Count;\n T k = counter.Keys[n - 1];\n if (counter.Values[n - 1] == 1)\n counter.RemoveAt(n - 1);\n else\n counter[k]--;\n return k;\n }\n public T GetMax()\n {\n return counter.Keys.Last();\n }\n public void Push(T item)\n {\n if (counter.ContainsKey(item))\n counter[item]++;\n else\n counter.Add(item, 1);\n }\n }\n\n public class ProblemSolver\n {\n public void Solve()\n {\n int n = int.Parse(Console.ReadLine());\n int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();\n int m = a[0];\n int m0 = m;\n var s = new Heap(a.Skip(1));\n while(s.GetMax() >= m)\n {\n s.Push(s.PopMax() - 1);\n m++;\n }\n Console.Write(m - m0);\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": ["greedy", "implementation"], "code_uid": "63399ece654729e27c559770657f8a02", "src_uid": "aa8fabf7c817dfd3d585b96a07bb7f58", "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\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 long t = long.Parse(ss[0]);\n long s = long.Parse(ss[1]);\n long k = long.Parse(ss[2]);\n if ((k - t) % s == 0 && k - t >= 0)\n {\n IsYesNo(true);\n }\n else if ((k-t-1)%s==0 && (k-t)/s>0)\n {\n IsYesNo(true);\n }\n else\n {\n IsYesNo(false);\n }\n \n\n }\n }\n}", "lang_cluster": "C#", "tags": ["math", "implementation"], "code_uid": "d5c0f069b0df5cbe17061ef8f7f8c299", "src_uid": "3baf9d841ff7208c66f6de1b47b0f952", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\n\nnamespace CFDay8\n{\n class Program\n {\n static void Main(string[] args)\n {\n string s = Console.ReadLine();\n if (s.Contains(\"H\") || s.Contains(\"Q\") || s.Contains(\"9\") )\n Console.WriteLine(\"YES\");\n else\n Console.WriteLine(\"NO\");\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "e34aa8acbfe5193944cb8d19a1664868", "src_uid": "1baf894c1c7d5aeea01129c7900d3c12", "difficulty": 900.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 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 static double[] ReadDouble(string str)\n {\n string[] tokens = str.Trim().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);\n double[] ret = new double[tokens.Length];\n for (int i = 0; i < ret.Length; i++)\n {\n ret[i] = double.Parse(tokens[i], CultureInfo.InvariantCulture);\n }\n\n return ret;\n }\n\n static string Reverse(string s)\n {\n char[] a = s.ToCharArray();\n Array.Reverse(a);\n return new string(a);\n }\n \n static void Main(string[] args)\n {\n string s = Console.ReadLine().Trim();\n\n HashSet hs = new HashSet();\n int x = 0;\n int y = 0;\n hs.Add(string.Format(\"{0},{1}\", x, y));\n for (int i = 0; i < s.Length; i++)\n {\n string key_prev = string.Format(\"{0},{1}\", x, y);\n if (s[i] == 'U') y--;\n else if (s[i] == 'D') y++;\n else if (s[i] == 'L') x--;\n else if (s[i] == 'R') x++;\n string key = string.Format(\"{0},{1}\", x, y);\n string key_u = string.Format(\"{0},{1}\", x, y - 1);\n string key_d = string.Format(\"{0},{1}\", x, y + 1);\n string key_l = string.Format(\"{0},{1}\", x - 1, y);\n string key_r = string.Format(\"{0},{1}\", x + 1, y);\n if (hs.Contains(key))\n {\n Console.WriteLine(\"BUG\");\n return;\n }\n if ((key_prev != key_u && hs.Contains(key_u)) ||\n (key_prev != key_d && hs.Contains(key_d)) ||\n (key_prev != key_l && hs.Contains(key_l)) ||\n (key_prev != key_r && hs.Contains(key_r)))\n {\n Console.WriteLine(\"BUG\");\n return;\n }\n hs.Add(key);\n }\n Console.WriteLine(\"OK\");\n }\n}\n", "lang_cluster": "C#", "tags": ["constructive algorithms", "implementation", "graphs"], "code_uid": "203b396b32062857e9fcd3ff1715eeec", "src_uid": "bb7805cc9d1cc907b64371b209c564b3", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\n\nclass Codeforces {\n\n static void Main() {\n int n = int.Parse(Console.ReadLine());\n int a = int.Parse(Console.ReadLine());\n int b = int.Parse(Console.ReadLine());\n int c = int.Parse(Console.ReadLine());\n\n // 1-2 a\n // 1-3 b\n // 2-3 c\n\n int k = 0;\n int cur = 1;\n while (n-- > 1) {\n if (cur == 1) {\n if (a < b) { cur = 2; k += a; } else { cur = 3; k += b; }\n } else if (cur == 2) {\n if (a < c) { cur = 1; k += a; } else { cur = 3; k += c; }\n } else {\n if (b < c) { cur = 1; k += b; } else { cur = 2; k += c; }\n }\n }\n Console.WriteLine(k);\n\n }\n}", "lang_cluster": "C#", "tags": ["math"], "code_uid": "dbd1cc1a7192aa2e7f707508859a8ae7", "src_uid": "6058529f0144c853e9e17ed7c661fc50", "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.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 int[] dp = new int[10000001];\n dp[0] = 6;\n dp[1] = 2;\n dp[2] = 5;\n dp[3] = 5;\n dp[4] = 4;\n dp[5] = 5;\n dp[6] = 6;\n dp[7] = 3;\n dp[8] = 7;\n dp[9] = 6;\n int ans = 0;\n string[] s = Console.ReadLine().Split(' ');\n int a = int.Parse(s[0]), b = int.Parse(s[1]);\n for (int i = a; i <= Math.Min(b, 9); i++) {\n ans += dp[i];\n }\n if (b > 10) {\n for (int i = 10; i <= b; i++) {\n dp[i] = dp[i / 10] + dp[i % 10];\n if (i >= a) {\n ans += dp[i];\n }\n }\n }\n Console.Write(ans);\n //Console.ReadKey();\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "4da39d97ee24ad07d96302b2a1d70109", "src_uid": "1193de6f80a9feee8522a404d16425b9", "difficulty": 1000.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\nstatic class SolutionTemplate\n{\n public class GCD\n {\n public static long Euclidean(long n1, long n2)\n {\n if (n1 < 1 || n2 < 1)\n {\n throw new ArgumentOutOfRangeException();\n }\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 ulong Inverse(ulong a, ulong n)\n {\n ulong x, y = 0;\n EuclideanExt(a, n, out x, out y);\n return x;\n }\n\n private static ulong EuclideanExt(ulong n1, ulong n2, out ulong x, out ulong 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 ulong q = 0;\n ulong xl = 1;\n ulong 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 public static List GetOrAddNew(this Dictionary> dic, K key)\n {\n if (dic == null) throw new ArgumentNullException();\n\n return (dic[key] = dic.ContainsKey(key) ? dic[key] : new List());\n }\n\n public static V GetValueOrDefault(this Dictionary dic, K key)\n {\n if (dic == null) throw new ArgumentNullException();\n\n if (dic.ContainsKey(key)) return dic[key];\n return default(V);\n }\n public static void AddOrSet(this Dictionary dic, K key, long add)\n {\n if (dic == null) throw new ArgumentNullException();\n\n dic[key] = dic.GetValueOrDefault(key) + add;\n }\n\n public static void AddOrSet(this Dictionary dic, K key, int add)\n {\n if (dic == null) throw new ArgumentNullException();\n\n dic[key] = dic.GetValueOrDefault(key) + add;\n }\n\n public static int AddExt(this HashSet hs, T val)\n {\n if (hs == null) throw new ArgumentNullException();\n\n if (!hs.Contains(val)) hs.Add(val);\n return hs.Count();\n }\n\n static long readLong()\n {\n return long.Parse(Console.ReadLine().Trim());\n }\n\n static int readInt()\n {\n return int.Parse(Console.ReadLine().Trim());\n }\n\n static long[] readLongs()\n {\n return Array.ConvertAll(Console.ReadLine().Trim().Split(), long.Parse);\n }\n\n static int[] readInts()\n {\n return Array.ConvertAll(Console.ReadLine().Trim().Split(), int.Parse);\n }\n\n static string[] readStrings()\n {\n return Console.ReadLine().Trim().Split();\n }\n\n static string readString()\n {\n return Console.ReadLine().Trim();\n }\n\n public static int readInt(this StreamReader str)\n {\n if (str == null) throw new ArgumentNullException();\n return int.Parse(str.ReadLine().Trim());\n }\n\n\n public static int[] readInts(this StreamReader str)\n {\n if (str == null) throw new ArgumentNullException();\n return Array.ConvertAll(str.ReadLine().Trim().Split(), int.Parse);\n }\n\n\n static bool OutputList(IEnumerable lst, char delimeter = ' ')\n {\n StringBuilder sb = new StringBuilder();\n foreach (var el in lst)\n {\n sb.Append(el);\n sb.Append(delimeter);\n }\n Console.Write(sb);\n return true;\n }\n\n static bool OutputLine(IEnumerable lst, char delimeter = ' ')\n {\n StringBuilder sb = new StringBuilder();\n foreach (var el in lst)\n {\n sb.Append(el);\n sb.Append(delimeter);\n }\n Console.WriteLine(sb);\n return true;\n }\n\n static bool Output(T val, char delimeter = ' ')\n {\n Console.Write(val);\n Console.Write(delimeter);\n return true;\n }\n static bool OutputLine(T val)\n {\n Console.WriteLine(val);\n return true;\n }\n\n\n static List> readEdges(int n)\n {\n List> res = new List>(n);\n for (int i = 0; i < n; i++)\n {\n var arr = readInts();\n res.Add(Tuple.Create(arr[0], arr[1]));\n }\n return res;\n }\n\n\n static Dictionary>> readWDicEdges(int n)\n {\n Dictionary>> dic =\n new Dictionary>>(n);\n for (int i = 0; i < n - 1; i++)\n {\n var arr = readInts();\n var tpl = Tuple.Create(arr[0], arr[1], arr[2]);\n dic[tpl.Item1] = dic.ContainsKey(tpl.Item1) ? dic[tpl.Item1] : new List>();\n dic[tpl.Item2] = dic.ContainsKey(tpl.Item2) ? dic[tpl.Item2] : new List>();\n\n dic[tpl.Item1].Add(Tuple.Create(tpl.Item2, tpl.Item3));\n dic[tpl.Item2].Add(Tuple.Create(tpl.Item1, tpl.Item3));\n\n }\n return dic;\n }\n\n\n static List> readWEdges(int n)\n {\n List> res = new List>(n);\n for (int i = 0; i < n; i++)\n {\n var arr = readInts();\n res.Add(Tuple.Create(arr[0], arr[1]));\n }\n return res;\n }\n\n static Dictionary> readDicEdges(int n)\n {\n Dictionary> dic =\n new Dictionary>(n);\n\n for (int i = 0; i < n - 1; i++)\n {\n var arr = readInts();\n var tpl = Tuple.Create(arr[0], arr[1]);\n dic[tpl.Item1] = dic.ContainsKey(tpl.Item1) ? dic[tpl.Item1] : new List();\n dic[tpl.Item2] = dic.ContainsKey(tpl.Item2) ? dic[tpl.Item2] : new List();\n\n dic[tpl.Item1].Add(tpl.Item2);\n dic[tpl.Item2].Add(tpl.Item1);\n }\n return dic;\n }\n\n private static long getGCD(long[] arr, int i, int j)\n {\n if (i == j)\n return arr[i];\n return GCD.Euclidean(getGCD(arr, i, (i + j) / 2), getGCD(arr, 1 + (i + j) / 2, j));\n }\n\n private static void Main(string[] args)\n {\n var str = readString();\n var t = readString();\n\n if (str.Length == 1)\n {\n Console.WriteLine(0);\n return;\n }\n\n int[] l = new int[t.Length];\n\n int j = 0;\n for (int i = 0; i < str.Length && j < t.Length; i++)\n {\n if (str[i] == t[j])\n {\n l[j] = i;\n j++;\n }\n }\n\n int[] r = new int[t.Length];\n j = t.Length - 1;\n for (int i = str.Length - 1; i >= 0 && j >= 0; i--)\n {\n if (str[i] == t[j])\n {\n r[j] = i;\n j--;\n }\n }\n var maxl = int.MinValue;\n for (int i = 0; i < t.Length - 1; i++)\n {\n maxl = Math.Max(maxl, r[i + 1] - l[i] - 1);\n }\n maxl = Math.Max(maxl, r[0]);\n maxl = Math.Max(maxl, str.Length - 1 - l[l.Length - 1]);\n Console.WriteLine(maxl);\n\n }\n}", "lang_cluster": "C#", "tags": ["greedy", "implementation"], "code_uid": "91c3f395f6fc36fc688706352165c967", "src_uid": "0fd33e1bdfd6c91feb3bf00a2461603f", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\n\nnamespace CodeforcesSolution\n{\n public class Escape\n {\n public static void Main(string[] args)\n {\n int vp, vd, t, f, c;\n vp = int.Parse(Console.ReadLine());\n vd = int.Parse(Console.ReadLine());\n t = int.Parse(Console.ReadLine());\n f = int.Parse(Console.ReadLine());\n c = int.Parse(Console.ReadLine());\n int count = 0;\n if (vp < vd)\n {\n float pp = t * vp;\n while (pp < c)\n {\n float hour = (float)pp/(vd - vp);\n if (pp + (hour * vp) >= c)\n {\n break;\n }\n count++;\n pp += hour*vp;\n float hourd = (pp/vd) + f;\n pp += hourd*vp;\n\n }\n }\n Console.WriteLine(count);\n } \n }\n}", "lang_cluster": "C#", "tags": ["math", "implementation"], "code_uid": "b58164418ab51880090bb8d4160e7cd7", "src_uid": "c9c03666278acec35f0e273691fe0fff", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.IO;\n\npublic class Codeforces{\n \n \n static void Main(){\n \n int n,w,k;\n string []inp=Console.ReadLine().Split(' ');\n k=int.Parse(inp[0]);\n n=int.Parse(inp[1]);\n w=int.Parse(inp[2]);\n \n int sum=0;\n for(int i=1;i<=w;i++)sum+=i*k;\n Console.WriteLine((sum-n<=0?0:sum-n));\n }\n}", "lang_cluster": "C#", "tags": ["brute force", "math", "implementation"], "code_uid": "3bd2a75fc1045e874b2ced9f65dc364a", "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 ConsoleApp2\n{\n class Program\n {\n static void Main(string[] args)\n {\n string[] str = Console.ReadLine().Split();\n int a = int.Parse(str[0]);\n int b = int.Parse(str[1]);\n int c = int.Parse(str[2]);\n if(a<=b&&a<=c)\n Console.WriteLine(\"YES\");\n else\n Console.WriteLine(\"NO\");\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "d1fed6c09a6f380459243cf27280a20e", "src_uid": "6cd07298b23cc6ce994bb1811b9629c4", "difficulty": 800.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 n = ReadInt();\n\t\t\tvar fives = 0;\n\t\t\tvar ans = new List();\n\t\t\tvar i = 1;\n\t\t\twhile (fives <= n)\n\t\t\t{\n\t\t\t\ti++;\n\t\t\t\tvar j = i;\n\t\t\t\twhile (j % 5 == 0)\n\t\t\t\t{\n\t\t\t\t\tfives++;\n\t\t\t\t\tj /= 5;\n\t\t\t\t}\n\t\t\t\tif (fives == n)\n\t\t\t\t\tans.Add(i);\n\t\t\t}\n\t\t\tConsole.WriteLine(ans.Count);\n\t\t\tfor (var ii = 0; ii < ans.Count; ++ii)\n\t\t\t\tConsole.Write(\"{0} \", ans[ii]);\n\t\t\tConsole.ReadLine();\n\t\t}\n\t}\n}\n", "lang_cluster": "C#", "tags": ["brute force", "math", "constructive algorithms", "number theory"], "code_uid": "976f0b0f282b39f1c997b1f2b00498e8", "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.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 string ss =\"abcdefghijklmnopqrstuvwxyz\";\n int si = 0, count = 0, a = ss.IndexOf('a'),n; \n while (si 13 ?(26 - (n)):(n);\n a = ss.IndexOf(s[si]);\n si++;\n }\n Console.WriteLine(count);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["strings", "implementation"], "code_uid": "d0f9f13ae0011b4f09f0ea8bb108a61d", "src_uid": "ecc890b3bdb9456441a2a265c60722dd", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\nusing System;\nusing System.Linq;\nusing System.Collections.Generic;\n\nclass P\n{\n\tpublic static void Main()\n\t{\n\t\tint[] R = System.Console.ReadLine().Split(' ').Select(x=>int.Parse(x)).ToArray();\n\t\tint n = R[0];\n\t\tint m = R[1];\n\n\t\tif(n==1)\n\t\t{\n\t\t\tSystem.Console.WriteLine(1);\n\t\t\treturn;\n\t\t}\n\n\t\tint a;\n\t\tif(n-m > m -1)\n\t\t{\n\t\t\ta = m + 1;\n\t\t}\n\t\telse\n\t\t{\n\t\t\ta = m -1;\n\t\t}\n\n\t\tSystem.Console.WriteLine(a);\n\t}\n}\n", "lang_cluster": "C#", "tags": ["constructive algorithms", "games", "math", "greedy", "implementation"], "code_uid": "4a1c3b4039486d7987193f43a5a49a21", "src_uid": "f6a80c0f474cae1e201032e1df10e9f7", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\n\n\nclass Program\n{\n static void Main(string[] args)\n {\n char[] str1 = Console.ReadLine().ToCharArray();\n char[] str2 = Console.ReadLine().ToCharArray();\n char[] result = new char[str2.Length];\n\n for (int i = 0; i < str2.Length; i++)\n {\n if (str1[i] == str2[i])\n result[i] = '0';\n else\n result[i] = '1';\n }\n\n foreach (var VARIABLE in result)\n {\n Console.Write(VARIABLE);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "3743a31f090c6d3e5f156feebdbf9567", "src_uid": "3714b7596a6b48ca5b7a346f60d90549", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Linq;\n\nclass Problem\n{\n public static void Main()\n {\n int t = int.Parse(Console.ReadLine());\n int[] input = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();\n int hours = input[0];\n int minutes = input[1];\n\n int count = 0;\n while (hours % 10 != 7 && minutes % 10 != 7)\n {\n minutes -= t;\n if (minutes < 0)\n {\n minutes = 60 + minutes;\n hours--;\n if (hours < 0)\n {\n hours = 23;\n }\n }\n\n count++;\n }\n\n Console.WriteLine(count);\n }\n}", "lang_cluster": "C#", "tags": ["brute force", "math", "implementation"], "code_uid": "35577fd44df2345d77ed68af15c133c9", "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 ConsoleApplication1\n{\n class Program\n {\n static void Main(string[] args)\n {\n string s;\n byte b;\n s = Console.ReadLine();\n if (byte.TryParse(s, out b) && b < 100)\n {\n string result = string.Empty;\n if (0 <= b && b <= 20 || b % 10 == 0)\n {\n result = NumberToString(b);\n }\n else\n {\n byte first = Convert.ToByte(b % 10);\n byte second = Convert.ToByte(Convert.ToByte(b / 10) * 10);\n result = NumberToString(second);\n result = string.Format(\"{0}-{1}\", result, NumberToString(first));\n }\n Console.WriteLine(result);\n } \n Console.ReadLine();\n }\n\n static string NumberToString(byte N)\n {\n switch (N)\n {\n case 0:\n return \"zero\";\n case 1:\n return \"one\";\n case 2:\n return \"two\";\n case 3:\n return \"three\";\n case 4:\n return \"four\";\n case 5:\n return \"five\";\n case 6:\n return \"six\";\n case 7:\n return \"seven\";\n case 8:\n return \"eight\";\n case 9:\n return \"nine\";\n case 10:\n return \"ten\";\n case 11:\n return \"eleven\";\n case 12:\n return \"twelve\";\n case 13:\n return \"thirteen\";\n case 14:\n return \"fourteen\";\n case 15:\n return \"fifteen\";\n case 16:\n return \"sixteen\";\n case 17:\n return \"seventeen\";\n case 18:\n return \"eighteen\";\n case 19:\n return \"nineteen\";\n case 20:\n return \"twenty\";\n case 30:\n return \"thirty\";\n case 40:\n return \"forty\";\n case 50:\n return \"fifty\";\n case 60:\n return \"sixty\";\n case 70:\n return \"seventy\";\n case 80:\n return \"eighty\";\n case 90:\n return \"ninety\";\n }\n return string.Empty;\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "implementation"], "code_uid": "22f20cc059c1c8fa7614fbbbaf685e49", "src_uid": "a49ca177b2f1f9d5341462a38a25d8b7", "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 CF06032015\n{\n class Program\n {\n\n static int Check(char ch)\n {\n switch(ch)\n {\n case 'q':\n return 9;\n case 'r':\n return 5;\n case 'b':\n return 3;\n case 'n':\n return 3;\n case 'p':\n return 1;\n case 'k':\n return 0;\n default:\n return 0;\n }\n }\n\n static void Main(string[] args)\n {\n int d1 = 0, d2 = 0;\n for(int i=0;i<8;++i)\n {\n var x = Console.ReadLine();\n foreach(var ch in x)\n {\n if(char.IsUpper(ch))\n {\n d1 += Check(char.ToLower(ch));\n }\n else\n {\n d2 += Check(ch);\n }\n }\n }\n\n Console.WriteLine(d1 == d2 ? \"Draw\" : d1 > d2 ? \"White\" : \"Black\");\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "e9eddf6a60b2051aae5664ed6dc5aa26", "src_uid": "44bed0ca7a8fb42fb72c1584d39a4442", "difficulty": 900.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 a = ReadInts();\n var group = a.GroupBy(x => x).Select(x => new { x.Key, Count = x.Count() }).Where(x => x.Count > 1).ToArray();\n if (group.Length == 0)\n return a.Sum();\n if (group[0].Count == 4 || group[0].Count == 5)\n return a.Sum() - group[0].Key * 3;\n return a.Sum() - group.Select(x => x.Key * x.Count).Max();\n }\n }\n\n public byte[] Convert1(string s)\n {\n var result = new byte[s.Length * 6];\n for (int i = 0; i < s.Length; i++)\n {\n var digit = Convert2(s[i]);\n for (int j = 0; j < 6; j++)\n {\n result[6 * i + j] = (byte)((digit >> j) & 1);\n }\n }\n return result;\n }\n\n private int Convert2(char c)\n {\n if (c >= '0' && c <= '9')\n return c - '0';\n if (c >= 'a' && c <= 'z')\n return c - 'a' + 36;\n if (c >= 'A' && c <= 'Z')\n return c - 'A' + 10;\n if (c == '-')\n return 62;\n if (c == '_')\n return 63;\n throw new Exception(\"huj\");\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": ["constructive algorithms", "implementation"], "code_uid": "608d677d2e71f1d0a27050c4431fc4ff", "src_uid": "a9c17ce5fd5f39ffd70917127ce3408a", "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.Numerics;\nusing System.Threading.Tasks;\n\nnamespace Codeforces\n{\n class Program\n {\n\n static void Main(string[] args)\n {\n string str = Console.ReadLine();\n string[] arr = str.Split(' ');\n int m = Int32.Parse(arr[0]);\n int n = Int32.Parse(arr[1]);\n int am = 0; \n if (m * n >= 2)\n {\n am = m*n/2;\n }\n Console.WriteLine(am);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "greedy"], "code_uid": "c6fb8650f84ece4f3b073c70b8f2ea22", "src_uid": "e840e7bfe83764bee6186fcf92a1b5cd", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.IO;\n\nclass Algo\n{\n public void Run()\n {\n string[] tokens = cin.ReadLine().Split();\n int n = int.Parse(tokens[0]);\n int m = int.Parse(tokens[1]);\n int ans = n / 2 + n % 2;\n if (ans + n / 2 < m)\n {\n cout.WriteLine(\"-1\");\n return;\n }\n cout.WriteLine(ans + (m - ans % m) % m);\n }\n\n public StreamReader cin = null;\n public StreamWriter cout = null;\n}\n\nclass Program\n{\n static void Main()\n {\n Algo task = new Algo();\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}", "lang_cluster": "C#", "tags": ["math", "implementation"], "code_uid": "6415dbb2cdd6fb1f15f7aa2324feb573", "src_uid": "0fa526ebc0b4fa3a5866c7c5b3a4656f", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nclass Program{\n\tstatic int [, ] b = new int[3, 3];\n\tstatic int [, ] a = new int[3, 3];\n\tstatic void fn(int i, int j){\n\t\ttry{\n\t\t\tb[i - 1, j]++;\n\t\t}catch{}\n\t\ttry{\n\t\t\tb[i, j - 1]++;\n\t\t}catch{}\n\t\ttry{\n\t\t\tb[i, j]++;\n\t\t}catch{}\n\t\ttry{\n\t\t\tb[i, j + 1]++;\n\t\t}catch{}\n\t\ttry{\n\t\t\tb[i + 1, j]++;\n\t\t}catch{}\n\t}\n\tstatic void Main(string[] args){\n\t\tint i = 0, j = 0;\n\t\t\n\t\tfor(i = 0; i < 3; i++){\n\t\t\tstring [] s = Console.ReadLine().Split();\n\t\t\ta[i, 0] = int.Parse(s[0]) % 2;\n\t\t\ta[i, 1] = int.Parse(s[1]) % 2;\n\t\t\ta[i, 2] = int.Parse(s[2]) % 2;\n\t\t}\n\t\t\n\t\tfor(i = 0; i < 3; i++){\n\t\t\tfor(j = 0; j < 3; j++){\n\t\t\t\tif(a[i, j] != 0){\n\t\t\t\t\tfn(i, j);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\tfor(i = 0; i < 3; i++){\n\t\t\tfor(j = 0; j < 3; j++){\n\t\t\t\tif(b[i, j] % 2 != 0){\n\t\t\t\t\tConsole.Write(\"0\");\n\t\t\t\t}else{\n\t\t\t\t\tConsole.Write(\"1\");\n\t\t\t\t}\n\t\t\t}\n\t\t\tConsole.WriteLine();\n\t\t}\n\t}\n}", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "77d05b2c20077bac0ee89c227da88491", "src_uid": "b045abf40c75bb66a80fd6148ecc5bd6", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "MS 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 int n = int.Parse(Console.ReadLine());\n string ip = Console.ReadLine();\n int []count = new int[3]; //RGB\n for(int i=0;i=2 && count[1]==1 && count[2]==0)\n s+=\"BG\";\n else if(count[0]>=2 && count[1]==0 && count[2]==1)\n s+=\"BG\";\n else if(count[0]==0 && count[1]>=2 && count[2]==1)\n s+=\"BR\";\n else if(count[0]==1 && count[1]>=2 && count[2]==0)\n s+=\"BR\";\n else if(count[0]==1 && count[1]==0 && count[2]>=2)\n s+=\"GR\";\n else if(count[0]==0 && count[1]==1 && count[2]>=2)\n s+=\"GR\";\n \n //if only two type but both greater than two\n else if(count[0]>=2 && count[1]>=2 && count[2]==0)\n s+=\"BGR\";\n else if(count[0]>=2 && count[1]==0 && count[2]>=2)\n s+=\"BGR\";\n else if(count[0]==0 && count[1]>=2 && count[2]>=2)\n s+=\"BGR\";\n Console.WriteLine(s);\n }\n }\n}", "lang_cluster": "C#", "tags": ["math", "dp", "constructive algorithms"], "code_uid": "0e5e6b6738c5392f7349a6c790e6c630", "src_uid": "4cedd3b70d793bc8ed4a93fc5a827f8f", "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\n{\n class Program\n {\n static void Main(string[] args)\n {\n int a, b;\n string[] inp = Console.ReadLine().Split(' ');\n a = Convert.ToInt32(inp[0]);\n b = Convert.ToInt32(inp[1]);\n int dop = Math.Max(a,b);\n double mid = (1.0 * a + b) / 2;\n dop = 1 - (int)((mid - (int)mid) * 2);\n String s = ((int)mid - dop).ToString() + \" \" + dop.ToString() + \" \" + (6 - (int)mid).ToString();\n if (a < b)\n Console.WriteLine(s);\n else if(a > b)\n {\n char[] res = s.ToCharArray();\n Array.Reverse(res);\n Console.WriteLine(res);\n }\n else\n {\n Console.WriteLine(\"0 6 0\");\n }\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force"], "code_uid": "57b3983415d4590a42c50c494e3424d7", "src_uid": "504b8aae3a3abedf873a3b8b127c5dd8", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Text;\n\nnamespace ConsoleApplication5\n{\n class Program\n {\n static void Main(string[] args)\n {\n var str = Console.ReadLine();\n int ans = 0;\n char cur =' ';\n int t =0;\n for (int i = 0; i < str.Length; i++)\n {\n if (cur == ' ') { cur = str[i]; t=1; continue; }\n if (str[i] == cur)\n t++;\n else\n {\n ans++;\n cur = str[i];\n t=1;\n }\n if (t == 5) { ans++; cur = ' '; t = 0; }\n }\n if (t != 0) ans++;\n Console.WriteLine(ans);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "72fffc9a08fb1d3b65093c7ddf386af8", "src_uid": "5257f6b50f5a610a17c35a47b3a0da11", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\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 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 see = 3;\n var pl1 = 1;\n var pl2 = 2;\n for (var i = 0; i < n; i++) {\n var next = sr.NextInt32();\n if (next == see) {\n sw.WriteLine(\"NO\");\n return;\n }\n if (pl1 == next) {\n var tmp = pl2;\n pl2 = see;\n see = tmp;\n }\n else {\n var tmp = pl1;\n pl1 = see;\n see = tmp;\n }\n }\n\n sw.WriteLine(\"YES\");\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": ["implementation"], "code_uid": "d88d6cfb8f7f5878b557963433bdb500", "src_uid": "6c7ab07abdf157c24be92f49fd1d8d87", "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 AlgoHelper\n{\n public class Pair\n {\n public int X { get; set; }\n public int Y { get; set; }\n\n public Pair(int x, int y)\n {\n X = x;\n Y = y;\n }\n\n public override bool Equals(object obj)\n {\n var pair = obj as Pair;\n return X + Y == pair.X + pair.Y;\n }\n\n public override int GetHashCode()\n {\n var hashCode = 1861411795;\n hashCode = hashCode * -1521134295 + X.GetHashCode();\n hashCode = hashCode * -1521134295 + Y.GetHashCode();\n return hashCode;\n }\n\n public override string ToString()\n {\n return $\"X = {X} Y = {Y}\";\n }\n }\n\n class PairComparer : IComparer\n {\n public int Compare(Pair x, Pair y)\n {\n return y.Y.CompareTo(x.Y);\n }\n }\n\n class Person\n {\n public int Age { get; set; }\n public string Name { get; set; }\n\n }\n\n\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\n if (n < 11) Console.WriteLine(0);\n else\n {\n Dictionary dict = new Dictionary();\n\n foreach (char c in s)\n {\n if (dict.ContainsKey(c)) dict[c]++;\n else dict[c] = 1;\n }\n\n if (!dict.ContainsKey('8')) Console.WriteLine(0);\n else\n {\n int max = n / 11;\n int maxOfEight = dict['8'];\n int ans = Math.Min(max, maxOfEight);\n Console.WriteLine(ans);\n }\n }\n\n\n\n // Console.ReadKey();\n }\n\n public static int NumDecodings(string s)\n {\n if (s.Length == 1) return 1;\n if (s.Length == 2)\n {\n int number = int.Parse(s);\n\n if (number <= 26)\n {\n if (s.Contains(\"0\")) return 1;\n return 2;\n }\n\n return 0;\n }\n \n return NumDecodings(s.Substring(0,1)) + NumDecodings(s.Substring(1));\n }\n\n\n static int makingAnagrams(string s1, string s2)\n {\n int length = s1.Length + s2.Length;\n\n int[] freqA = frequency(s1);\n int[] freqB = frequency(s2);\n\n Console.WriteLine(string.Join(\"|\",freqA));\n Console.WriteLine(string.Join(\"|\", freqB));\n\n\n int count = 0;\n\n for (int i = 0; i < freqA.Length; i++)\n {\n if (freqA[i] != freqB[i]) count++;\n }\n\n return length - count;\n }\n public static int firstMissingPositive(int[] a)\n {\n int missing = 1;\n\n HashSet set = new HashSet();\n\n for (int i = 0; i < a.Length; i++)\n {\n if(a[i]>missing)\n {\n set.Add(a[i]);\n }\n else if(a[i] == missing)\n {\n if(!set.Contains(missing+1))\n {\n missing++; \n }\n else\n {\n missing = returnNewMax(++missing, set);\n }\n }\n }\n\n return missing;\n }\n\n private static int returnNewMax(int n, HashSet set)\n {\n while(set.Contains(n))\n {\n n++;\n }\n\n return n;\n }\n\n\n\n private static bool checkForAllZeroes(string s)\n {\n foreach(char c in s)\n {\n if (c != '0') return false;\n }\n\n return true;\n }\n\n private static int getHigherNumber(int n,int max)\n {\n int currentLength = maxLength(n);\n\n if (currentLength < max)\n {\n int diff = max - currentLength;\n int newNumber = n * (int)Math.Pow(10, diff);\n return newNumber;\n }\n\n return n;\n }\n\n private static int maxLength(int n)\n {\n return n.ToString().Length;\n }\n\n static int gemstones(string[] arr)\n {\n int[][] frequencies = new int[arr.Length][];\n\n for (int i = 0; i < frequencies.Length; i++)\n {\n frequencies[i] = frequency(arr[i]);\n }\n\n int count = 0;\n bool flag = true;\n\n for (int i = 0; i < frequencies[0].Length; i++) //26\n {\n for (int j = 0; j < frequencies.Length - 1; j++)\n {\n if (frequencies[j][i] == 0 || frequencies[j + 1][i] == 0)\n {\n flag = false;\n break;\n }\n }\n\n if (flag) count++;\n flag = true;\n }\n\n return count;\n }\n\n private static bool isFunny(string s)\n {\n int[] diff = difference(s);\n\n return isPalindrome(diff);\n }\n\n private static int [] difference (string a)\n {\n int[] ans = new int[a.Length - 1];\n\n for (int i = 0; i < a.Length - 1; i++)\n {\n ans[i] = Math.Abs(a[i] - a[i + 1]);\n }\n\n return ans;\n }\n\n private static bool isPalindrome(int [] a)\n {\n for(int i=0;i a[med])\n {\n lo = med + 1;\n }\n\n else hi = med - 1;\n }\n\n return ans;\n }\n\n private static string randomString(Random r)\n {\n int l = r.Next(1,10);\n\n string s = string.Empty;\n\n for (int i = 0; i < l; i++)\n {\n s += char.ConvertFromUtf32(r.Next(96, 122));\n }\n\n return s;\n }\n\n private static int [] prefixMax(int [] a)\n {\n int max = a[a.Length - 1];\n\n Stack stack = new Stack();\n\n stack.Push(a[a.Length - 1]);\n\n int[] b = new int[a.Length];\n\n b[a.Length - 1] = -1;\n\n bool found = false;\n\n for (int i = a.Length - 2; i >=0; i--)\n {\n while (stack.Count > 0)\n {\n int temp = stack.Peek();\n\n if (temp > a[i])\n {\n b[i] = temp;\n found = true;\n break;\n }\n else\n {\n stack.Pop();\n }\n }\n\n stack.Push(a[i]);\n if (!found) b[i] = -1;\n found = false;\n }\n\n return b;\n }\n\n private static bool hasTheSameLetters(string a, string b)\n {\n\n int[] freqA = frequency(a);\n int[] freqB = frequency(b);\n\n for (int i = 0; i < freqA.Length; i++)\n {\n if (freqA[i] != 0 && freqB[i] != 0) return true;\n }\n\n return false;\n }\n\n\n private static int [] frequency(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 private static bool checkTwoArrays(int [] a,int []b)\n {\n for (int i = 0; i < a.Length; i++)\n {\n if (a[i] != b[i]) return false;\n }\n\n return true;\n }\n\n private static long solution(long[] a, long h, long lo,long hi)\n {\n long med = hi - (hi - lo) / 2;\n while(lo<=hi)\n {\n med = hi - (hi - lo) / 2;\n long ans = solve(a, med);\n Console.WriteLine($\"ans = {ans} lo = {lo} med = {med}\");\n if (ans <= h) hi = med - 1;\n else if (ans > h) lo = med + 1;\n }\n\n return lo;\n }\n\n private static long solve(long [] a,long k)\n {\n long sum = 0;\n\n for (int i = 0; i < a.Length; i++)\n {\n if (a[i]<=k)\n {\n sum++;\n }\n else\n {\n sum += (a[i] / k) + 1;\n }\n }\n\n return sum;\n }\n\n public static bool LemonadeChange(int[] bills)\n {\n if (bills[0] > 5) return false;\n\n Dictionary dict = new Dictionary();\n\n int currentAmount = 5;\n\n dict[5] = 1;\n\n for (int i = 1; i < bills.Length; i++)\n {\n if (bills[i] > 5)\n {\n int charge = bills[i] - 5;\n if (currentAmount < charge) return false;\n\n currentAmount+=5;\n }\n else\n {\n currentAmount += bills[i];\n dict[5]++;\n }\n }\n\n return false;\n }\n\n \n\n private static int solve(int n,int x,int y,int d)\n {\n if ((y-x) % d == 0) {\n return (y - x) / d;\n }\n\n if((x-y)%d==0)\n {\n return (x - y) / d;\n }\n\n if((y-1)%d==0)\n {\n int firstStep = 0;\n\n if ((x-1)%d==0)\n {\n firstStep = (x - 1) / d;\n }\n else\n {\n firstStep = (x - 1) / d + 1;\n }\n\n int secodnStep = (y - 1) / d; \n\n return firstStep + secodnStep;\n \n }\n\n return -1;\n }\n public static int max(int [] a, int i)\n {\n if (i == a.Length - 1) return a[a.Length - 1];\n else return Math.Max(a[i], max(a, i + 1));\n }\n\n\n\n public static int MaxArea(int[] a)\n {\n int l = 0;\n int r = a.Length - 1;\n\n int max = int.MinValue;\n \n\n\n while (l < r)\n {\n max = Math.Max(max, Math.Min(a[l], a[r]) * (r - l));\n\n if (a[l] < a[r]) l++;\n else r--;\n }\n\n return max;\n }\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 private static void Swap(ref char a, ref char b)\n {\n char temp = a;\n a = b;\n b = temp;\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force"], "code_uid": "ce03076973a4aa8ae8888f2ab19c9fe8", "src_uid": "259d01b81bef5536b969247ff2c2d776", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Linq;\n\nnamespace CF491_B\n{\n class Program\n {\n static void Main(string[] args)\n {\n var n = int.Parse(Console.ReadLine());\n var s = Console.ReadLine().Split().Select(double.Parse).ToArray();\n var a = s.Average();\n Array.Sort(s);\n var c = 0;\n while (a < 4.5)\n {\n s[c] = 5;\n a = s.Average();\n c++;\n }\n Console.WriteLine(c);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["sortings", "greedy"], "code_uid": "192cb0a15710b679c814bcd495debb9f", "src_uid": "715608282b27a0a25b66f08574a6d5bd", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.IO;\nusing System.Text;\n\nnamespace Burglar_and_Matches\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 m = Next();\n\n var a = new int[m];\n var b = new int[m];\n for (int i = 0; i < m; i++)\n {\n a[i] = Next();\n b[i] = Next();\n }\n\n Array.Sort(b, a);\n\n int sum = 0;\n for (int i = m - 1; i >= 0; i--)\n {\n if (a[i] < n)\n {\n sum += a[i]*b[i];\n n -= a[i];\n }\n else\n {\n sum += n*b[i];\n break;\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": ["sortings", "implementation", "greedy"], "code_uid": "2aac8752877ad49511da92b93f52a55d", "src_uid": "c052d85e402691b05e494b5283d62679", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nclass Program\n{\n static void Main()\n {\n string[] s = Console.ReadLine().Split();\n int x1 = int.Parse(s[0]);\n int y1 = int.Parse(s[1]);\n s = Console.ReadLine().Split();\n int x2 = int.Parse(s[0]);\n int y2 = int.Parse(s[1]);\n int x = Math.Abs(x1 - x2);\n int y = Math.Abs(y1 - y2);\n if (x > y)\n Console.WriteLine(x);\n else\n Console.WriteLine(y);\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "implementation"], "code_uid": "1604b2e9d52e9464254721b2331fbd9c", "src_uid": "a6e9405bc3d4847fe962446bc1c457b4", "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 first\n{\n class Program\n {\n static void Main(string[] args)\n {\n int a, b, c,aMod,bMod,cMod;\n string str = Console.ReadLine();\n a=int.Parse(str);\n str=str.Replace(\"0\", \"\");\n aMod = int.Parse(str);\n str = Console.ReadLine();\n b = int.Parse(str);\n str=str.Replace(\"0\", \"\");\n bMod = int.Parse(str);\n c = a + b;\n cMod = int.Parse(c.ToString().Replace(\"0\", \"\"));\n if ((aMod + bMod) == cMod)\n Console.WriteLine(\"YES\");\n else\n Console.WriteLine(\"NO\");\n }\n }\n}", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "2671f886839539cfee569e6652d97944", "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.Text.RegularExpressions;\nusing System.Globalization;\n\nnamespace Codeforces\n{\n class B\n {\n private static bool s_time = false;\n private static object Go()\n {\n int n = GetInt();\n string s = GetString();\n\n char[] first = s.Substring(0, n).ToCharArray();\n char[] second = s.Substring(n).ToCharArray();\n\n Array.Sort(first);\n Array.Sort(second);\n\n bool yes = true;\n for (int i = 0; i < n; i++)\n {\n if (first[i] >= second[i]) { yes = false; break; }\n }\n if (yes) return \"YES\";\n\n yes = true;\n for (int i = 0; i < n; i++)\n {\n if (first[i] <= second[i]) { yes = false; break; }\n }\n if (yes) return \"YES\";\n\n return \"NO\";\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": ["sortings", "greedy"], "code_uid": "8eead289124ad196acbc62e7f0f780a5", "src_uid": "e4419bca9d605dbd63f7884377e28769", "difficulty": 1100.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\t//var inputs = input.Split(new[] {' '}, StringSplitOptions.RemoveEmptyEntries);\n\n\t\t\tlong n = long.Parse(input);\n\n\t\t\tif (n < 10)\n\t\t\t{\n\t\t\t\tConsole.WriteLine(n);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tlong count = 9;\n\t\t\tfor (long i = 1; i < 10; i++)\n\t\t\t{\n\t\t\t\tlong bottom = (long)Math.Pow(10, i);\n\t\t\t\tlong upper = (long)(Math.Pow(10, i + 1) - 1);\n\n\t\t\t\tif (n >= bottom && n > upper)\n\t\t\t\t{\n\t\t\t\t\tcount += (i + 1) * 9 * bottom;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tif (n >= bottom && n <= upper)\n\t\t\t\t{\n\t\t\t\t\tvar numbers = n - bottom + 1;\n\t\t\t\t\tcount += (i + 1) * numbers;\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\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", "implementation"], "code_uid": "f5ad8ff4b8b5060971cb9905cf1846f0", "src_uid": "4e652ccb40632bf4b9dd95b9f8ae1ec9", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\n\nnamespace ConsoleApp1\n{\n class Program\n {\n \n static void Main(string[] args)\n {\n var s = Console.ReadLine();\n var res = (s.Length - 1) / 2 + 1;\n if (s.IndexOf('1', 1) == -1 && s.Length % 2 == 1){\n res -= 1;\n }\n Console.WriteLine(res);\n \n }\n\n }\n}", "lang_cluster": "C#", "tags": ["math"], "code_uid": "d92b6ef5ac6a49bc0fba5c050672f691", "src_uid": "d8ca1c83b431466eff6054d3b422ab47", "difficulty": 1000.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.Threading.Tasks;\n\nnamespace YA\n{\n\tpublic class Program\n\t{\n\t\tstatic void Main(string[] args)\n\t\t{\n\t\t\tvar n = int.Parse(Console.ReadLine());\n\t\t\tvar years = Console.ReadLine().Split().Select(x => int.Parse(x)).OrderBy(x => x).ToArray();\n\n\t\t\tif (n % 2 == 1)\n\t\t\t{\n\t\t\t\tConsole.WriteLine(years[n / 2]);\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tif (years[0] == 2010)\n\t\t\t\t{\n\t\t\t\t\tConsole.WriteLine(years[0]);\n\t\t\t\t}\n\t\t\t\telse if (years[n - 1] == 2100)\n\t\t\t\t{\n\t\t\t\t\tConsole.WriteLine(years[n - 1]);\n\t\t\t\t}\n\t\t\t}\n\t\t\t//Console.ReadKey();\n\t\t}\n\t}\n}\n", "lang_cluster": "C#", "tags": ["sortings", "implementation"], "code_uid": "ac8c29d292138d3cde38487bf84ffb64", "src_uid": "f03773118cca29ff8d5b4281d39e7c63", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.IO;\nusing System.Text;\n\nnamespace Piles_With_Stones\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) ? \"Yes\" : \"No\");\n writer.Flush();\n }\n\n private static bool Solve(string[] args)\n {\n int n = Next();\n int s1 = 0;\n for (int i = 0; i < n; i++)\n {\n s1 += Next();\n }\n int s2 = 0;\n for (int i = 0; i < n; i++)\n {\n s2 += Next();\n }\n return s2 <= s1;\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": "3a531e9f0bf792b25e2dea6b92ce68af", "src_uid": "e0ddac5c6d3671070860dda10d50c28a", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nnamespace ConsoleApplication35\n{\n class Program\n {\n static void Main(string[] args)\n {\n int a = Convert.ToInt32(Console.ReadLine());\n string c = Console.ReadLine();\n \n if (c[0] == 'S')\n {\n if (c[c.Length - 1] == 'F')\n {\n Console.WriteLine(\"YES\");\n return;\n }\n }\n Console.WriteLine(\"NO\");\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "48291512d45e3bb4827641e41f5b196f", "src_uid": "ab8a2070ea758d118b3c09ee165d9517", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Runtime.InteropServices;\nusing System.Threading;\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 var s = Console.ReadLine().Split(' ');\n int min1 = int.Parse(s[0]),\n max1 = int.Parse(s[1]);\n s = Console.ReadLine().Split(' ');\n int min2 = int.Parse(s[0]),\n max2 = int.Parse(s[1]);\n s = Console.ReadLine().Split(' ');\n int min3 = int.Parse(s[0]),\n max3 = int.Parse(s[1]);\n if(n - min3 - min2 <=max1)\n Console.WriteLine((n - min3 - min2) + \" \" + min2 + \" \" + min3);\n else if (n - max1 - min3 <= max2)\n {\n Console.WriteLine(max1 + \" \" + (n - max1 - min3) + \" \" + min3);\n }\n else\n Console.WriteLine(max1 + \" \" + max2 + \" \" + (n - max1 - max2));\n }\n }\n}", "lang_cluster": "C#", "tags": ["math", "greedy", "implementation"], "code_uid": "1ad623340d914e92f1144016a1f278ac", "src_uid": "3cd092b6507079518cf206deab21cf97", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\r\nusing System.Collections.Generic;\r\nusing System.Linq;\r\n\r\nnamespace GoogleCodeJam2021\r\n{\r\n class Program\r\n {\r\n static void Main(string[] args)\r\n {\r\n char[] a = Console.ReadLine().ToCharArray();\r\n bool b = true;\r\n if (a.Length > 2)\r\n {\r\n if ((test(a[0]) + test(a[1]))%26 != test(a[2])) b = false;\r\n }\r\n\r\n if (b) Console.WriteLine(\"YES\");\r\n else Console.WriteLine(\"NO\");\r\n }\r\n\r\n static int test(char a)\r\n {\r\n return (int)a - 65;\r\n }\r\n }\r\n}", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "4fefac6550cdf9926a256a457b4f7ea1", "src_uid": "27e977b41f5b6970a032d13e53db2a6a", "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 CodeForcesAprilFoolsA\n{\n class Program\n {\n static void Main(string[] args)\n {\n int num = int.Parse(Console.ReadLine());\n switch (num)\n {\n case 1: Console.WriteLine(\"Washington\"); break;\n case 2: Console.WriteLine(\"Adams\"); break;\n case 3: Console.WriteLine(\"Jefferson\"); break;\n case 4: Console.WriteLine(\"Madison\"); break;\n case 5: Console.WriteLine(\"Monroe\"); break;\n case 6: Console.WriteLine(\"Adams\"); break;\n case 7: Console.WriteLine(\"Jackson\"); break;\n case 8: Console.WriteLine(\"Van Buren\"); break;\n case 9: Console.WriteLine(\"Harrison\"); break;\n case 10: Console.WriteLine(\"Tyler\"); break;\n case 11: Console.WriteLine(\"Polk\"); break;\n case 12: Console.WriteLine(\"Taylor\"); break;\n case 13: Console.WriteLine(\"Fillmore\"); break;\n case 14: Console.WriteLine(\"Pierce\"); break;\n case 15: Console.WriteLine(\"Buchanan\"); break;\n case 16: Console.WriteLine(\"Lincoln\"); break;\n case 17: Console.WriteLine(\"Johnson\"); break;\n case 18: Console.WriteLine(\"Grant\"); break;\n case 19: Console.WriteLine(\"Hayes\"); break;\n case 20: Console.WriteLine(\"Garfield\"); break;\n case 21: Console.WriteLine(\"Arthur\"); break;\n case 22: Console.WriteLine(\"Cleveland\"); break;\n case 23: Console.WriteLine(\"Harrison\"); break;\n case 24: Console.WriteLine(\"Cleveland\"); break;\n case 25: Console.WriteLine(\"McKinley\"); break;\n case 26: Console.WriteLine(\"Roosevelt\"); break;\n case 27: Console.WriteLine(\"Taft\"); break;\n case 28: Console.WriteLine(\"Wilson\"); break;\n case 29: Console.WriteLine(\"Harding\"); break;\n case 30: Console.WriteLine(\"Coolidge\"); break;\n case 31: Console.WriteLine(\"Hoover\"); break;\n case 32: Console.WriteLine(\"Roosevelt\"); break; \n case 33: Console.WriteLine(\"Truman\"); break;\n case 34: Console.WriteLine(\"Eisenhower\"); break;\n case 35: Console.WriteLine(\"Kennedy\"); break;\n case 36: Console.WriteLine(\"Johnson\"); break;\n case 37: Console.WriteLine(\"Nixon\"); break;\n case 38: Console.WriteLine(\"Ford\"); break;\n case 39: Console.WriteLine(\"Carter\"); break;\n case 40: Console.WriteLine(\"Reagan\"); break;\n case 41: Console.WriteLine(\"Bush\"); break;\n case 42: Console.WriteLine(\"Clinton\"); break;\n case 43: Console.WriteLine(\"Bush\"); break;\n case 44: Console.WriteLine(\"Obama\"); break;\n \n }\n Console.Read();\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "927ee0c6da49c2ed0dbe4b3bd55151c4", "src_uid": "0b51a8318c9ec0c80c0f4dc04fe0bfb3", "difficulty": 1400.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\nclass Program\n{\n\n private static void Main(string[] args)\n {\n\n int a = RI(),b= RI();\n\n\n List al = new List();\n\n for(int i=1;i<=a;i++)\n {\n al.Add(RI());\n }\n\n\n var al1 = al.OrderByDescending(d=>d);\n\n foreach(var item in al1)\n {\n if(b%item==0)\n {\n Console.WriteLine(b / item);\n break;\n }\n }\n\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\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 private static long RLI()\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 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\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] = RLI();\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 consoleReader = new StreamReader(Console.OpenStandardInput(BufferSize), Encoding.ASCII, false, BufferSize);\n }\n #endregion\n}", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "75088ea1ffebcf6a27388062ee040326", "src_uid": "80520be9916045aca3a7de7bc925af1f", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "//Mono 5.10.1 | JDoodle.Com & Mono 5 | CodeForces.Com\nusing System;\n\nclass Program\n{\n static void Main()\n {\n string[] input = Console.ReadLine().Split();\n \n int grown_ups = Int32.Parse(input[0]);\n int children = Int32.Parse(input[1]);\n \n if (grown_ups < 1 & children > 0) {\n Console.Write(\"Impossible\");\n return;\n }\n \n Console.Write(\"{0} {1}\", grown_ups > children ? grown_ups : children, children != 0 ? grown_ups + children - 1 : grown_ups);\n }\n}", "lang_cluster": "C#", "tags": ["math", "greedy"], "code_uid": "1a51ef4a6876f149948a82fdcf5e14b9", "src_uid": "1e865eda33afe09302bda9077d613763", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\n\nnamespace DataTypeApp{\n class Program{\n public static void Main(String[] Args){\n int T, n;\n T = Convert.ToInt32(Console.ReadLine());\n \n T = T*2;\n bool b = false;\n for(int i=1; iT){ break; }\n }\n if(b){ Console.WriteLine(\"YES\\n\");}\n else{ Console.WriteLine(\"NO\\n\"); }\n }\n }\n}", "lang_cluster": "C#", "tags": ["brute force", "math"], "code_uid": "81284d2673d4d036bbae2813b76e59c1", "src_uid": "587d4775dbd6a41fc9e4b81f71da7301", "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 ConsoleApp1\n{\n class Program\n {\n static void Main(string[] args)\n {\n int one = 0;\n int zero = 0;\n //int n = Convert.ToInt32(Console.ReadLine());\n string s = Console.ReadLine();\n foreach(char ch in s)\n {\n if(ch == '0')\n {\n zero++;\n one = 0;\n }\n else\n {\n one++;\n zero = 0;\n }\n if(zero == 7 || one == 7)\n {\n Console.WriteLine(\"YES\");\n return;\n }\n }\n Console.WriteLine(\"NO\");\n Console.ReadLine();\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["strings", "implementation"], "code_uid": "559b9f88dac2818f9f66e819a989eb75", "src_uid": "ed9a763362abc6ed40356731f1036b38", "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 Olimp\n{\n class Program\n {\n public static void Main(string[] arg)\n {\n int N = int.Parse(Console.ReadLine());\n string str = Console.ReadLine();\n List alphabit = new List();\n foreach (char c in str)\n if (!alphabit.Contains(char.ToLower(c)))\n alphabit.Add(char.ToLower(c));\n if (alphabit.Count == 26)\n Console.WriteLine(\"YES\");\n else Console.WriteLine(\"NO\");\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["strings", "implementation"], "code_uid": "45bdc9df83049eb65ae778660291919f", "src_uid": "f13eba0a0fb86e20495d218fc4ad532d", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\n\nnamespace CodeForces.Solutions.c321_190_1\n{\n\tpublic class Program1\n\t{\n\t\tprivate static bool[,] f;\n\t\tconst int offset = 150;\n\n\t\tpublic static bool IsInField (int x , int y)\n\t\t{\n\t\t\treturn f[x + offset, y + offset];\n\t\t}\n\n\t\tstatic void SetInField(int x , int y)\n\t\t{\n\t\t\tf[x + offset, y + offset] = true;\n\t\t}\n\n public static void Main()\n {\n checked\n {\n\t var str1 = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();\n\t var x = str1[0];\n\t var y = str1[1];\n\n\t var moves = Console.ReadLine();\n\n\t var size = 2*offset + 1;\n\t f = new bool[size,size];\n\t SetInField(0, 0);\n\t var dx = 0;\n\t var dy = 0;\n\n\t\t\t\tforeach (var c in moves)\n\t\t\t\t{\n\t\t\t\t\tswitch (c)\n\t\t\t\t\t{\n\t\t\t\t\t\tcase 'U':\n\t\t\t\t\t\t\tdy++;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tcase 'D':\n\t\t\t\t\t\t\tdy--;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tcase 'R':\n\t\t\t\t\t\t\tdx++;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tcase 'L':\n\t\t\t\t\t\t\tdx--;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tSetInField(dx, dy);\n\t\t\t\t}\n\n\t\t\t\tif (x < -100 || x > 100)\n\t\t\t\t{\n\t\t\t\t\tif (x < -100 && dx >= 0)\n\t\t\t\t\t{\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\tif (x > 100 && dx <= 0)\n\t\t\t\t\t{\n\t\t\t\t\t\tConsole.WriteLine(\"No\");\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\tvar needToGoByX = x < 0 ? (-x - 100 - dx - 1) / -dx : (x - 100 + dx - 1) / dx;\n\n\t\t\t\t\tx -= needToGoByX * dx;\n\t\t\t\t\ty -= needToGoByX * dy;\n\t\t\t\t}\n\n\t\t\t\tif ((y < -100 || y > 100) && dx == 0)\n\t\t\t\t{\n\t\t\t\t\tif (y < -100 && dy >= 0)\n\t\t\t\t\t{\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\tif (y > 100 && dy <= 0)\n\t\t\t\t\t{\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\t\n\t\t\t\t\tvar needToGo = y < 0 ? (-y - 100 - dy - 1) / -dy : (y - 100 + dy - 1) / dy;\n\n\t\t\t\t\tx -= needToGo * dx;\n\t\t\t\t\ty -= needToGo * dy;\n\t\t\t\t}\n\n\n\t for (int i = 0; i < 1000; i++)\n\t {\n\t\t if (Math.Abs(x) <= 100 && Math.Abs(y) <= 100 && IsInField((int)x,(int) y))\n\t\t {\n\t\t\t Console.WriteLine(\"Yes\");\n\t\t\t\t\t\treturn;\n\t\t }\n\t\t x -= dx;\n\t\t y -= dy;\n\t }\n\t\t\t\tConsole.WriteLine(\"No\");\n }\n }\n }\n}", "lang_cluster": "C#", "tags": ["math", "implementation", "binary search"], "code_uid": "a2406f5911b07329a3cc210422ac5e77", "src_uid": "5d6212e28c7942e9ff4d096938b782bf", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.IO;\nusing System.Text;\n\nnamespace Candies\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 n = long.Parse(reader.ReadLine());\n\n long l = 1, r = (n + 1)/2;\n while (l < r)\n {\n long m = (l + r)/2;\n\n long nn = n;\n long v = 0;\n while (nn > 0)\n {\n long t = Math.Min(nn, m);\n v += t;\n nn -= t;\n nn -= nn/10;\n }\n if (2*v >= n)\n {\n r = m;\n }\n else\n {\n l = m + 1;\n }\n }\n\n return r;\n }\n }\n}", "lang_cluster": "C#", "tags": ["implementation", "binary search"], "code_uid": "560e6501f3a60f6f55f0768402a86ec3", "src_uid": "db1a50da538fa82038f8db6104d2ab93", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\n\nnamespace Practice\n{\n class Program\n {\n static void Main(string[] args)\n {\n string s = (Console.ReadLine());\n Console.WriteLine(SolveProblem(s));\n Console.ReadLine();\n }\n\n static string SolveProblem (string s)\n {\n int lowerCount = 0;\n int higherCount = 0;\n for (int i = 0; i < s.Length ;i++)\n {\n if (char.IsLower( s [i]))\n {\n lowerCount++;\n } else\n {\n higherCount++;\n }\n\n if (lowerCount > (s.Length) / 2)\n {\n return s.ToLower();\n }\n }\n return lowerCount == higherCount ? s.ToLower() :s.ToUpper();\n }\n\n }\n}\n", "lang_cluster": "C#", "tags": ["strings", "implementation"], "code_uid": "c2a37ae5de3f03cab2b01f17d1aa216e", "src_uid": "b432dfa66bae2b542342f0b42c0a2598", "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.Text.RegularExpressions;\nusing System.IO;\n\nnamespace coder\n{\n class Program\n {\n static void Main(string[] args)\n {\n byte[] inputBuffer = new byte[1024];\n System.IO.Stream inputStream = Console.OpenStandardInput(inputBuffer.Length);\n Console.SetIn(new StreamReader(inputStream, Console.InputEncoding, false, inputBuffer.Length));\n\n int n, m, index=0;\n int[] a = new int[101];\n string arr;\n bool b = false;\n string[] arr1 = Console.ReadLine().Split(new Char[] { ' ' });\n\n n = int.Parse(arr1[0]);\n m = int.Parse(arr1[1]);\n\n arr = Console.ReadLine();\n arr1 = Regex.Split(arr, \" \");\n\n for (int i = 0; i < n; i++)\n {\n a[i] = int.Parse(arr1[i]);\n }\n\n while(!b)\n {\n for (int i = 0; i < n; i++)\n {\n if(a[i]>0)\n {\n a[i] = a[i] - m;\n index = i+1;\n b = true;\n }\n }\n if (b == false)\n {\n b = true;\n }\n else { b = false; }\n }\n \n Console.WriteLine(index);\n }\n }\n}", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "9646316562e70b06ce32bfda95a2b6c8", "src_uid": "c0ef1e4d7df360c5c1e52bc6f16ca87c", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": ".NET Core C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Text;\nusing static System.Console;\nusing static System.Convert;\n\n//\nclass ProblemSolver\n{\n const string STRINGTOREMOVE = \"xxx\";\n static void Main(string[] args)\n {\n int inputLen = ToInt32(ReadLine());\n\n string input = ReadLine();\n\n if(!string.IsNullOrWhiteSpace(input) && input.Length == inputLen)\n {\n int numberOfCharsToRemove = 0;\n int index = -1;\n while((index = input.IndexOf(STRINGTOREMOVE)) > -1)\n {\n input = input.Remove(index,1);\n numberOfCharsToRemove++;\n }\n\n Write(numberOfCharsToRemove);\n }\n }\n}", "lang_cluster": "C#", "tags": ["greedy", "strings"], "code_uid": "4139201f2a46511b6798f0f655015b65", "src_uid": "8de14db41d0acee116bd5d8079cb2b02", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nnamespace soutez1\n{\n\tclass MainClass\n\t{\n\t\tpublic static void Main (string[] args)\n\t\t{\n\t\t\tstring[] prvni = Console.ReadLine().Split();\n\t\t\tstring[] hlasy = Console.ReadLine().Split();\n\n\t\t\tint n = int.Parse(prvni[0]);\n\n\t\t\tint nejvetsi = 0;\n\t\t\tint soucet = 0;\n\n\t\t\tfor( int a=0; a soucet)\n\t\t\t{\n\n\t\t\t\tConsole.WriteLine(nejvetsi);\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tint vysledek = (soucet - dobryHlasy)/n + nejvetsi;\n\t\t\t\tif((vysledek* n - soucet) <= soucet )\n\t\t\t\t{\n\t\t\t\t\tvysledek++;\n\t\t\t\t}\n\t\t\t\t//vysledek = vysledek + nejvetsi;\n\t\t\t\tConsole.WriteLine(vysledek);\n\t\t\t}\n\n\t\t}\n\n\t}\n}\n\t\t\t/*int n = int.Parse(Console.ReadLine());\n\t\t\tstring[] prvni = Console.ReadLine().Split();\n\t\t\tint zacatek = int.Parse(prvni[0]);\n\t\t\tint konec = int.Parse(prvni[1]);\n\n\t\t\tfor(int a=1; a int.Parse(cisla[1]))\n\t\t\t\t{\n\t\t\t\t\tkonec = int.Parse(cisla[1]);\n\t\t\t\t}\n\t\t\t}\n\t\t\tif(zacatek> konec)\n\t\t\t{\n\t\t\t\tConsole.WriteLine(0);\n\t\t\t} \n\t\t\telse\n\t\t\t{\n\t\t\t\tConsole.WriteLine(konec-zacatek);\n\t\t\t}*/\n\n\n\t\t\t/*int n = int.Parse(Console.ReadLine());\n\t\t\tstring[] cisla = Console.ReadLine().Split();\n\n\t\t\tint maximalni = 0;\n\t\t\tint aktualni = 1;\n\n\n\t\t\tfor(int a=0; a+1= int.Parse(cisla[a+1]))\n\t\t\t\t{\n\t\t\t\t\taktualni++;\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tif(aktualni > maximalni)\n\t\t\t\t\t{\n\t\t\t\t\t\tmaximalni = aktualni;\n\n\t\t\t\t\t}\n\t\t\t\t\taktualni = 1;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif(aktualni > maximalni)\n\t\t\t{\n\t\t\t\tmaximalni = aktualni;\n\n\t\t\t}\n\t\t\tConsole.WriteLine(maximalni); */\n\n\t\n\t\t/*\n\t\t\tint pocet = int.Parse(prvni[0]);\n\t\t\tint kolikrat = int.Parse(prvni[1]);\n\t\t\tstring retezec = Console.ReadLine();\n\n\t\t\tstring vysledek = \"\";\n\n\t\t\tfor(int a=1; a();\n h.Add('R', 0);\n h.Add('G', 1);\n h.Add('B', 2);\n h.Add('Y', 3);\n h.Add('W', 4);\n var s = \"\";\n var pairs = Enumerable.Range(0, n).Select(x => new Card(h[(s = NextToken())[0]], s.Substring(1, 1))).ToArray();\n pairs = pairs.Distinct().ToArray();\n n = pairs.Length;\n var min = 239;\n for (var m1 = 0; m1 < 1 << 5; ++m1)\n {\n var num = Enumerable.Range(0, 5).Select(x => (m1 & (1 << x)) > 0).ToArray();\n for (var m2 = 0; m2 < 1 << 5; ++m2)\n {\n var color = Enumerable.Range(0, 5).Select(x => (m2 & (1 << x)) > 0).ToArray();\n var good = true;\n for (var i = 0; i < n; ++i)\n for (var j = 0; j < i; ++j)\n {\n var g = pairs[i].Color != pairs[j].Color && (color[pairs[i].Color] || color[pairs[j].Color]) ||\n pairs[i].Num != pairs[j].Num && (num[pairs[i].Num] || num[pairs[j].Num]);\n if (!g)\n good = false;\n }\n var sum = num.Sum(x => x ? 1 : 0) + color.Sum(x => x ? 1 : 0);\n if (good && sum < min)\n min = sum;\n }\n }\n Console.Write(min);\n }\n static void Main(string[] args)\n {\n new C().run();\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "constructive algorithms", "implementation", "bitmasks"], "code_uid": "5b1d28fea173e10eb09e62d56fc6f20a", "src_uid": "3b12863997b377b47bae43566ec1a63b", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Diagnostics;\n//using mystruct = System.Int64;\n\npublic sealed class Solution : Helper\n{\n //\n public void __main(int _TCID = 1)\n {\n checked\n {\n //\n readWordString();\n var s = readWordString().ToCharArray();\n var n = s.Length;\n var upb = n - 1;\n //\n var res = new ValueRefPointer();\n res.ValueNullable = n;\n seq(1, upb).TakeWhile(i => countLength(0, i - 1) <= countLength(i, upb)).elect(i =>\n {\n if (seq(0, i - 1).Select(a => s[a]).SequenceEqual(seq(i, getRight(i, countLength(0, i - 1))).Select(b => s[b])))\n res.UpdateCompute(1 + i + (n - i - countLength(0, i - 1)), Math.Min);\n });\n writeNumber(res.ValueNullable ?? 1);\n //\n }\n writeLine();\n }\n //\n}\n\n\n// additional plugable library\npublic partial class Helper\n{\n //\n static bool MULTI_TCs = false;\n #region STDIO\n#if !DEBUG\n static void Main() { __stdioMain(); }\n#endif\n static void __stdioMain()\n {\n Console.SetIn(new System.IO.StreamReader(new System.IO.BufferedStream(Console.OpenStandardInput())));\n Console.SetOut(new System.IO.StreamWriter(new System.IO.BufferedStream(Console.OpenStandardOutput())));\n var cnt = MULTI_TCs ? int.Parse(Console.ReadLine()) : 1;\n for (var i = 1; i <= cnt; i++) new Solution().__main(i);\n Console.Out.Flush();\n }\n // OUTput\n internal string separatorAutoString;\n internal void writeLine() { Console.WriteLine(); }\n internal void writeSeparator() { if (!string.IsNullOrEmpty(separatorAutoString)) { Console.Write(separatorAutoString); } }\n internal void writeText(char c) { Console.Write(c); writeSeparator(); }\n internal void writeText(string s) { Console.Write(s); writeSeparator(); }\n internal void writeNumber(long i64) { Console.Write(i64); writeSeparator(); }\n internal void writeNumber(int i32) { Console.Write(i32); writeSeparator(); }\n internal void writeNumber(double dec) { Console.Write(dec); writeSeparator(); }\n // INput\n static void EOF() { throw new System.IO.EndOfStreamException(); }\n static IEnumerable stream() { while (true) { var iread = Console.Read(); if (iread < 0) break; yield return (char)iread; } }\n static bool isWhitespace(char c) { return c == ' ' || c == '\\n' || c == '\\r' || c == '\\t'; }\n static System.Text.StringBuilder sb = new System.Text.StringBuilder(30);\n internal static string readWordString()\n {\n sb.Clear();\n var iter = stream().SkipWhile(isWhitespace).TakeWhile(c => !isWhitespace(c));\n foreach (var c in iter) sb.Append(c);\n if (sb.Length == 0) EOF(); return sb.ToString();\n }\n internal static long readLong64() { return long.Parse(readWordString()); }\n internal static char readSingleChar() { return stream().SkipWhile(isWhitespace).First(); }\n #endregion\n //\n internal class ValueRefPointer where T : struct\n {\n public T? ValueNullable;\n public ValueRefPointer IfAbsent(Action> init) { if (ValueNullable == null) init(this); return this; }\n public ValueRefPointer UpdateIfAbsent(Func calc) { if (ValueNullable == null) ValueNullable = calc(); return this; }\n public ValueRefPointer UpdateCompute(T other, Func merge_CHECKED) { var ans = other; if (ValueNullable.HasValue) ans = merge_CHECKED(other, ValueNullable.Value); ValueNullable = ans; return this; }\n public ValueRefPointer UpdateCompute(T? other, Func merge_CHECKED) { if (other.HasValue) UpdateCompute(other.Value, merge_CHECKED); return this; }\n public ValueRefPointer Swap(ValueRefPointer with) { var temp = ValueNullable; ValueNullable = with.ValueNullable; with.ValueNullable = temp; return this; }\n //TODO switch to implicit cast from ValueRefPointer to T?\n public ValueRefPointer UpdateCompute(ValueRefPointer other, Func merge_CHECKED) { return UpdateCompute(other.ValueNullable, merge_CHECKED); }\n public override string ToString() { return ValueNullable.ToString(); }\n }\n}\nstatic partial class Extension\n{\n //\n\n //\n}\n\n\n#region Core helper library\n[DebuggerNonUserCode]\npublic partial class Helper\n{\n internal static IEnumerable seq(long low, long high, int skip = 1) { checked { for (var i = low; i <= high; i += skip) yield return i; } }\n internal static IEnumerable rev(long low, long high, int skipPositive = 1) { checked { for (var i = high; i >= low; i -= skipPositive) yield return i; } }\n internal static T[] collect(params T[] elemS) { return elemS; }\n internal static T? optional(bool hasValue, T value) where T : struct { return hasValue ? new T?(value) : null; }\n internal static T identity(T obj) { return obj; }\n internal static T? optional(T value) where T : struct { return value; }\n internal static void assert(bool truthy) { if (!truthy) { var a = 0; a /= a; } }\n internal static void assert(T actual, T expected) { if (!Equals(actual, expected)) { Debug.WriteLine(\"SALAH {0} / BENAR {1}\", actual, expected); assert(false); } }\n [Conditional(\"DEBUG\")]\n internal static void debug(bool truthy) { Debug.Assert(truthy); }\n internal static List ll(T emptyExample) { return new List(); }\n internal static T? optional(bool hasValue, Func calc) where T : struct { return hasValue ? calc() : new T?(); }\n internal static long countLength(long left, long right) { return left > right ? 0 : checked(right - left + 1); }\n internal static long getRight(long left, long count) { return checked(left + count - 1); }\n internal static long getLeft(long count, long right) { return checked(right - count + 1); }\n static double div(double a, double b) { return a / b; }\n}\n[DebuggerNonUserCode]\nstatic partial class Extension\n{\n internal static IEnumerable elect(this IEnumerable stream, Action act) { foreach (var elem in stream) act(elem); return stream; }\n internal static IEnumerable Select(this long count, Func getter) { while (count-- > 0) yield return getter(); }\n internal static void elect(this long count, Action act) { while (count-- > 0) act(); }\n internal static List> ToKvpList(this IEnumerable list) { return list.Select((elem, idx) => new KeyValuePair(idx, elem)).ToList(); }\n internal static IEnumerable SelectElement(this IEnumerable indices, IList lst) { return indices.Select(Convert.ToInt32).Select(i => lst[i]); }\n internal static int int32(this long val) { return Convert.ToInt32(val); }\n internal static long long64(this int val) { return val; }\n internal static T? optional(this T value) where T : struct { return value; }\n internal static IEnumerable optional(this IEnumerable stream) where T : struct { return stream.Select(optional); }\n internal static long skip(this long src, long skipSigned) { return checked(src + skipSigned); }\n //\n internal static T? AggregateOrNullable(this IEnumerable stream, Func merge_CHECKED) where T : struct\n { var it = stream.GetEnumerator(); if (!it.MoveNext()) return null; var res = it.Current; while (it.MoveNext()) res = merge_CHECKED(res, it.Current); return res; }\n internal static long sumLong64(IEnumerable stream) { return stream.Sum(x => (long)x); }\n internal static int? explainSearchIndex(this int rawIndex) { if (rawIndex < 0) return null; return rawIndex; }\n internal static T[] ll(this IEnumerable stream) { return stream.ToArray(); }\n internal static T[] sort(this T[] arr) { Array.Sort(arr); return arr; }\n internal static List sort(this List lst) { lst.Sort(); return lst; }\n //internal static IEnumerable seq(this IList list) { for (var i = 0; i < list.Count; i++) yield return i; }\n //internal static IEnumerable rev(this IList list) { for (var i = list.Count - 1; i >= 0; i--) yield return i; }\n internal static int getUpperBound(this IList list) { return list.Count - 1; }\n internal static int GetUpperBound(this System.Collections.IList list) { return list.Count - 1; }\n internal static T? elementAtOrNullable(this IList list, int index) where T : struct { if (index < 0 || index >= list.Count) return null; return list[index]; }\n internal static string stringify(this IEnumerable stream) { return new string(stream.ToArray()); }\n}\n#endregion\n", "lang_cluster": "C#", "tags": ["strings", "implementation"], "code_uid": "eeab92079a89d6b0c5012de5aa677933", "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\nnamespace _743B_\u0425\u043b\u043e\u044f_\u0438_\u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \n{\n class Program\n {\n static void Main(string[] args)\n {\n string[] Enter = Console.ReadLine().Split(' ');\n byte n = Convert.ToByte(Enter[0]);\n long k = Convert.ToInt64(Enter[1]);\n\n long Kol =Convert.ToInt64( Math.Pow(2 , n))-1;\n byte ans = 0;\n byte Count = 0;\n while (ans==0)\n {\n Kol = (Kol+1) / 2;\n if (Kol == k) { ans = (byte)(n - Count); }\n else if (k > Kol) { k = k - Kol; }\n Count += 1;\n if (Count > n) { ans = 1; }\n //Console.WriteLine(Count + \" - \" +(Kol) + \" - \" + k);\n Kol -=1;\n }\n Console.WriteLine(ans);\n //Console.ReadKey();\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["constructive algorithms", "binary search", "implementation", "bitmasks"], "code_uid": "fac577a7815086ff9b5105d36b0adb48", "src_uid": "0af400ea8e25b1a36adec4cc08912b71", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\n\n\nclass Program\n{\n static void Main()\n {\n string s = Console.ReadLine();\n int val = Convert.ToInt32(Console.ReadLine());\n string[] all = new string[val];\n for (int i = 0; i < val; i++)\n {\n all[i] = Console.ReadLine();\n }\n for (int i = 0; i < val; i++)\n {\n for (int j = 0; j < val; j++)\n {\n if ((all[i] + all[j]).Contains(s))\n {\n Console.WriteLine(\"YES\");\n return;\n }\n }\n }\n Console.WriteLine(\"NO\");\n }\n}", "lang_cluster": "C#", "tags": ["brute force", "strings", "implementation"], "code_uid": "5939945d8ed302a28e5cd634ba17b51b", "src_uid": "cad8283914da16bc41680857bd20fe9f", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\n\nnamespace ConsoleApplication1\n{\n internal class Program\n {\n private static int n;\n private static string[] s;\n private static int[] a;\n private static int x = 0, y = 0, z = 0;\n\n private static void Main(string[] args)\n {\n n = int.Parse(Console.ReadLine());\n\n s = Console.ReadLine().Split(' ');\n\n var k = 1;\n\n for (int i = 0; i < n; i++)\n {\n switch (k)\n {\n case 1 :\n x += int.Parse(s[i]);\n break;\n case 2:\n y += int.Parse(s[i]);\n break;\n case 3:\n z += int.Parse(s[i]);\n break;\n }\n\n if (k == 3)\n k = 1;\n else\n k++;\n }\n\n Console.WriteLine(x > y ? x > z ? \"chest\" : \"back\" : y > z ? \"biceps\" : \"back\");\n }\n }\n}", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "95b418966fa3d2d835b1fa7e6a3a75bb", "src_uid": "579021de624c072f5e0393aae762117e", "difficulty": 800.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 long[] arr = Console.ReadLine().Split().Select(long.Parse).ToArray();\n\n long a = arr[0];\n long b = arr[1];\n\n while (a != 0 && b != 0)\n {\n if (a >= 2 * b)\n {\n a %= 2 * b;\n }\n\n else\n {\n if (b >= 2 * a)\n {\n b %= 2 * a;\n }\n else\n {\n break;\n }\n }\n }\n Console.WriteLine(a + \" \" + b);\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": ["math", "number theory"], "code_uid": "cbf7053dbd72eb1c835b66a4f2908067", "src_uid": "1f505e430eb930ea2b495ab531274114", "difficulty": 1100.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 bool valid = false;\n\n char[] card = Console.ReadLine().ToCharArray();\n\n string[] myCards = Console.ReadLine().Split(' ').ToArray();\n\n char[,] myCardsSeparate = new char[5, 2];\n\n for (int i = 0; i < myCardsSeparate.GetLength(0); i++)\n {\n char[] c = myCards[i].ToCharArray();\n\n myCardsSeparate[i, 0] = c[0];\n myCardsSeparate[i, 1] = c[1];\n }\n\n for(int i = 0; i < myCardsSeparate.GetLength(0); i++)\n {\n if(myCardsSeparate[i, 0] == card[0] || myCardsSeparate[i, 1] == card[1])\n {\n valid = true;\n break;\n }\n }\n\n Console.WriteLine(valid ? \"YES\" : \"NO\");\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "implementation"], "code_uid": "256b0e210087e4a251e8594e6a85d4ac", "src_uid": "699444eb6366ad12bc77e7ac2602d74b", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nclass Test{\n static void Main(){\n string [] line;\n for(int i = 0; i < 5; i++){\n line = Console.ReadLine().Split();\n for(int j = 0; j < 5; j++){\n if(line[j] != \"0\"){\n Console.WriteLine(Math.Abs(i - 2) + Math.Abs(j - 2));\n return;\n }\n }\n }\n }\n}", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "a12dd27286474e92f75516c3d530081d", "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;\n\nnamespace CF746A {\n class Program {\n static void Main(string[] args) {\n int a = Convert.ToInt32(Console.ReadLine());\n int b = Convert.ToInt32(Console.ReadLine());\n int c = Convert.ToInt32(Console.ReadLine());\n\n b /= 2;\n c /= 4;\n\n int limit = Math.Min(Math.Min(a, b), c);\n int total = limit + (2 * limit) + (4 * limit);\n\n Console.WriteLine(total);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "implementation"], "code_uid": "ef2e87056e3ee6f96e4899a1dde8b268", "src_uid": "82a4a60eac90765fb62f2a77d2305c01", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing 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 int[] mas = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();\n if (mas[0] == 1 && mas[1] == 1)\n {\n Console.WriteLine(2 );\n }\n else\n {\n int t = 0;\n int q = (mas[0] > mas[1]) ? mas[0] : mas[1];\n for (int i = 0; i < q; i++)\n {\n for (int x = 0; x < q; x++)\n {\n if (i * i + x == mas[0] && i + x * x == mas[1]) { t++; }\n }\n }\n\n Console.WriteLine(t);\n }\n Console.ReadLine();\n }\n }\n\n", "lang_cluster": "C#", "tags": ["brute force"], "code_uid": "730802336bbcbc26f60a6bed2af04828", "src_uid": "03caf4ddf07c1783e42e9f9085cc6efd", "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 repeat:\n\n int[] input = new int[4];\n\n input [0] = int.Parse(Console.ReadLine()); //k\n input [1] = int.Parse(Console.ReadLine()); //l\n input [2] = int.Parse(Console.ReadLine()); //m\n input [3] = int.Parse(Console.ReadLine()); //n \n\n int d = int.Parse(Console.ReadLine());\n \n if (input.Contains(1))\n {\n Console.WriteLine(d);\n return;\n }\n\n Array.Sort(input);\n\n bool[] bResult = new bool[d + 1];\n bResult[0] = true;\n\n for (int i = 1; i < d + 1; i++)\n {\n \n if (i % input[0] == 0) \n continue;\n\n if (i % input[1] == 0)\n continue;\n\n if (i % input[2] == 0)\n continue;\n\n if (i % input[3] == 0)\n continue;\n\n bResult[i] = true;\n }\n\n int count = bResult.Count(x => x == false);\n\n Console.WriteLine(count);\n\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "constructive algorithms", "implementation"], "code_uid": "c469d4cb2613597ab47eddf70da1f20d", "src_uid": "46bfdec9bfc1e91bd2f5022f3d3c8ce7", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "/*\n Project Euler, Problem 49 Solution\n C#\n */\nusing System;\nusing System.Diagnostics;\nusing System.Collections.Generic;\n\n\nnamespace ConsoleApp1\n{\n class Program\n {\n static void Main()\n {\n //var sw = new Stopwatch();\n //sw.Start();\n //bool[] prime = new bool[10001];\n //for (int i = 2; i < 10001; i++) prime[i] = true;\n ////SEAVE OF ERAT\n //for (int i = 2; i < 10001; i++)\n //{\n // if (prime[i] == true)\n // {\n // for (int j = i + i; j < 10001; j=j+i)\n // {\n // prime[j] = false;\n // }\n // }\n //}\n //List pList = new List();\n //for (int i = 2; i < 10001; i++)\n //{\n // if (prime[i] == true) {\n // // Console.WriteLine(i);\n // pList.Add(i);\n // }\n //}\n\n\n //Console.WriteLine(\"Size of List \"+pList.Count);\n ///*for (int i = 1; i < pList.Count - 1; i++)\n //{\n // if (pList[i] > 1000)\n // {\n // if (pList[i] - pList[i - 1] == pList[i + 1] - pList[i])\n // {\n // Console.WriteLine(pList[i - 1] + \"\" + pList[i] + \"\" + pList[i + 1]);\n // }\n // }\n\n //}*/\n //for (int i = 30; i < pList.Count; i++) {\n // if (pList[i] > 1000) {\n // int mx = 10000;\n // for (int j = 1; j < mx; j++) {\n // int a = pList[i] + j;\n // int b = a + j;\n // if (a < mx && b < mx) {\n // if (prime[a] == true && prime[b] == true)\n // {\n // if (hasSameChar(pList[i], a) == true && hasSameChar(a, b) == true)\n // {\n // Console.WriteLine(pList[i] + \"\" + a + \"\" + b);\n // }\n // }\n // }\n // }\n // }\n //}\n //Console.WriteLine(sw.Elapsed.TotalMilliseconds);\n //Console.ReadKey(true);\n string s = Console.ReadLine();\n long x = Convert.ToInt64(s);\n int ans=1;\n if (x % 4 == 3 || x % 4 == 0) ans = 0;\n Console.WriteLine(ans);\n // Console.ReadKey();\n }\n\n static bool hasSameChar(int x, int y) {\n // bool ret = false;\n char[] t1 = new char[4];\n char[] t2 = new char[4];\n for (int i = 0; i < 4; i++) {\n int xx = x % 10;\n x = x / 10;\n int yy = y % 10;\n y = y / 10;\n t1[i] = Convert.ToChar(xx);\n t2[i] = Convert.ToChar(yy);\n }\n Array.Sort(t1);\n Array.Sort(t2);\n for(int i = 0; i < 4; i++)\n {\n if (t1[i] != t2[i]) return false;\n }\n \n return true;\n }\n\n }\n}\n\n// PROJECT EULER SOLUTION 49\n", "lang_cluster": "C#", "tags": ["math"], "code_uid": "c4ad02b7bb1b279507f9dfd2e3124722", "src_uid": "fa163c5b619d3892e33e1fb9c22043a9", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\n \npublic class Repeating_Cipher{\n public static void Main(){\n String n = Console.ReadLine();\n \tString s = Console.ReadLine();\n\t int t = 0;\n\t for (int i = 0; i < int.Parse(n); i += t)\n {\n Console.Write((char)s[i]);\n\t\t\t\t t++;\n }\n }\n}", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "a87e5773f9bcfee111abacdc8768593a", "src_uid": "08e8c0c37b223f6aae01d5609facdeaf", "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 CodeForces\n{\n class Program\n {\n static void Main(string[] args)\n {\n string[] input = Console.ReadLine().Split(' ');\n int n = Convert.ToInt32(input[0]);\n int k = Convert.ToInt32(input[1]);\n string[] numbers = Console.ReadLine().Split(' ');\n int count = 0;\n int score_kth = Convert.ToInt32(numbers[k - 1]);\n for (int i = 0; i < n; i++)\n {\n int value = Convert.ToInt32(numbers[i]);\n if (value < score_kth)\n break;\n\n if (value >= score_kth && value != 0)\n count++;\n\n }\n\n Console.WriteLine(count);\n \n }\n }\n}\n\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "406b98e6ecd0c7ece9087ea01b9ee351", "src_uid": "193ec1226ffe07522caf63e84a7d007f", "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 ConsoleApp5\n{\n class Program\n {\n private static Stack GetBin(ulong number)\n {\n Stack NumInBinNot = new Stack();\n\n while (number != 0)\n {\n NumInBinNot.Push(number % 2 == 1);\n number /= 2;\n }\n return NumInBinNot;\n }\n public static ulong IntNumberToIntDegree(ulong IntNumber, ulong Pow)\n {\n ulong result = 1;\n Stack NumInBinNot = GetBin(Pow);\n while (NumInBinNot.Count != 0)\n {\n result *= result;\n result %= (int)(1e9 + 7);\n if (NumInBinNot.Pop())\n {\n result *= IntNumber;\n result %= (int)(1e9 + 7);\n }\n }\n return result;\n }\n static void Main(string[] args)\n {\n string[] str = Console.ReadLine().Split();\n ulong x = ulong.Parse(str[0]);\n ulong n = ulong.Parse(str[1]);\n HashSet SimpleDividers = new HashSet();\n ulong m = x;\n for (ulong i = 2; i<=Math.Sqrt(x); i++)\n {\n if (m % i == 0)\n {\n SimpleDividers.Add(i);\n while (m % i == 0)\n {\n m /= i;\n }\n }\n }\n if (m > 1)\n SimpleDividers.Add(m);\n ulong result = 1;\n foreach(ulong dev in SimpleDividers)\n {\n ulong Degree = dev;\n ulong count = 0;\n for(; Degree<=n && Degree>0; Degree*=dev)\n {\n count += n / Degree;\n if (Degree > n/dev)\n break;\n }\n ulong res = IntNumberToIntDegree(dev, 1044032052841069); ;\n result *= IntNumberToIntDegree(dev, count);\n result %= (int)(1e9 + 7);\n }\n Console.WriteLine(result);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "number theory"], "code_uid": "a0136c2a6afa90ad57fff7d488aa49b5", "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;\n\nnamespace DoubleCola\n{\n class Program\n {\n static void Main(string[] args)\n {\n int number = int.Parse(Console.ReadLine());\n\n int i = -1;\n while (number > 0)\n {\n i++;\n number -= + 5 * (int)Math.Pow(2, i);\n \n }\n\n int guy = 0;\n\n\n while (number <= 0)\n {\n guy++;\n number += (int)Math.Pow(2, i);\n }\n\n switch (guy)\n {\n case 1: Console.WriteLine(\"Howard\"); break;\n case 2: Console.WriteLine(\"Rajesh\"); break;\n case 3: Console.WriteLine(\"Penny\"); break;\n case 4: Console.WriteLine(\"Leonard\"); break;\n case 5: Console.WriteLine(\"Sheldon\"); break;\n }\n\n Console.ReadLine();\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "implementation"], "code_uid": "37224d4a8311a18f435220c721f19919", "src_uid": "023b169765e81d896cdc1184e5a82b22", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\n\npublic class Solution\n{\n static void Main(String[] args)\n {\n string cipher = Console.ReadLine();\n string original = \"\";\n int length = cipher.Length;\n int index;\n if (length % 2 == 0)\n {\n index = length - 1;\n }\n else\n {\n index = 0;\n }\n int originalLength = 0;\n while (originalLength < length)\n {\n original = cipher[index] + original;\n originalLength += 1;\n if (originalLength == length)\n {\n break;\n }\n original = cipher[length - index - 1] + original;\n originalLength += 1;\n if (length % 2 == 0)\n {\n index -= 1;\n }\n else\n {\n index += 1;\n }\n }\n Console.WriteLine(original);\n }\n}", "lang_cluster": "C#", "tags": ["strings", "implementation"], "code_uid": "7a73d77fa75af0031038bdaa91043ea0", "src_uid": "992ae43e66f1808f19c86b1def1f6b41", "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 long[] nm = Console.ReadLine().Split().Select(x => long.Parse(x)).ToArray();\n long r = nm[0] % nm[1];\n Console.WriteLine(r==0?0:Math.Min(r*nm[3],(nm[1]-r)*nm[2]));\n }\n }\n}", "lang_cluster": "C#", "tags": ["math", "implementation"], "code_uid": "aa1cacfcf4f0a5b1c31cb7c5158a3b04", "src_uid": "c05d753b35545176ad468b99ff13aa39", "difficulty": 1000.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 int N = Convert.ToInt32(Console.ReadLine());\n string Input = Console.ReadLine();\n\n int Max = -1;\n string Res = \"\";\n for (int i = 1; i < N; i++)\n {\n int Result = 0;\n for (int j = i; j < N; j++)\n {\n if (Input[i - 1] == Input[j - 1] && Input[j] == Input[i])\n {\n Result++;\n }\n }\n\n if (Result > Max)\n {\n Max = Result;\n Res = Input[i - 1].ToString() + Input[i];\n }\n }\n\n Console.WriteLine(Res);\n }\n }\n}", "lang_cluster": "C#", "tags": ["strings", "implementation"], "code_uid": "0a51b47fa4fffbb3089d07763d32a473", "src_uid": "e78005d4be93dbaa518f3b40cca84ab1", "difficulty": 900.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[] a = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();\n int[] b = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();\n int[] c = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();\n if (b.Min() < c.Max())\n { \n int ac = a[2] / b.Min();\n a[2] -= ac * b.Min();\n a[2] += ac * c.Max();\n }\n Console.WriteLine(a[2]);\n }\n }\n}", "lang_cluster": "C#", "tags": ["greedy", "implementation"], "code_uid": "5175deb0e90cec038709b01326dfe8d0", "src_uid": "42f25d492bddc12d3d89d39315d63cb9", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "// Problem: 1148A - Another One Bites The Dust\n// Author: Gusztav Szmolik\n\nusing System;\n\nclass AnotherOneBitesTheDust\n {\n public static int Main ()\n {\n string line = Console.ReadLine ();\n if (line == null)\n return -1;\n char[] delims = new char[] {' ', '\\t'};\n string[] words = line.Split (delims,StringSplitOptions.RemoveEmptyEntries);\n if (words.Length != 3)\n return -1;\n uint a;\n if (!UInt32.TryParse (words[0], out a))\n return -1;\n if (a < 1 || a > 1000000000)\n return -1;\n uint b;\n if (!UInt32.TryParse (words[1], out b))\n return -1;\n if (b < 1 || b > 1000000000)\n return -1;\n uint c;\n if (!UInt32.TryParse (words[2], out c))\n return -1;\n if (c < 1 || c > 1000000000)\n return -1;\n uint countAB = c + Math.Min (a,b);\n uint ans = 2*countAB;\n if (a != b)\n ans++;\n Console.WriteLine (ans);\n return 0;\n }\n }\n", "lang_cluster": "C#", "tags": ["greedy"], "code_uid": "a452833a139b60570c416a5899ed7379", "src_uid": "609f131325c13213aedcf8d55fc3ed77", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\n\n\nclass c\n{\n\tpublic static int[] dp;\n\tpublic static void df( int r, int i )\n\t{\n\t\tvar id = i-2;\n\t\twhile( id >= 0 )\n\t\t{\n\t\t\tif ( id <= 100 && ( dp[id] < 0 || dp[id] > r ) )\n\t\t\t\tdp[id] = r;\n\t\t\tid -=4 ;\n\t\t}\n\t\twhile( i >= 0 )\n\t\t{\n\t\t\tif( i <= 100 && ( dp[i] < 0 || dp[i] > r ) )\n\t\t\t\tdp[i] = r;\n\t\t\ti -=4 ;\n\t\t}\n\t}\n\tpublic static int Main()\n\t{\n\t\tvar x = int.Parse( Console.ReadLine() );\n\t\tdp = new int[101];\n\t\tfor( int i=0; i<101; ++i )\n\t\t\tdp[i] = -1;\n\t\tfor( int i=1; i<100; i+=2 )\n\t\t{\n\t\t\tdf( i, i*i/2 );\n\t\t\tdf( i, i*i/2+1 );\n\t\t}\n\t\tdp[0] = 0;\n\t\tdp[1] = 1;\n\t\tdp[2] = 3;\n\t\tdp[3] = 5;\n\t\tdp[4] = 3;\n\t\tdp[5] = 3;\n\t\tConsole.WriteLine( dp[x] );\n\t\tConsole.WriteLine();\n\t\treturn 0;\n\t}\n}\n\n\n\n", "lang_cluster": "C#", "tags": ["math", "binary search"], "code_uid": "1cdbc772ffeff115f6395ca6385813ed", "src_uid": "01eccb722b09a0474903b7e5abc4c47a", "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;\n\nnamespace ConsoleApplication1\n{\n class Program\n {\n const long mod = 1000000007;\n static long phi(long n)\n {\n if (n == 1)\n return 1;\n long result = n;\n for (long i = 2; i * i <= n; ++i)\n if (n % i == 0)\n {\n while (n % i == 0)\n n /= i;\n result -= result / i;\n }\n if (n > 1)\n result -= result / n;\n return result;\n }\n\n static void Main()\n {\n string[] token = Console.ReadLine().Split(' ');\n long n = long.Parse(token[0]);\n long k = long.Parse(token[1]);\n long t = 1;\n long ans = n;\n if (k >= n)\n {\n Console.WriteLine(1);\n return;\n }\n else\n {\n if (k >= 71)\n {\n Console.WriteLine(\"1\");\n return;\n }\n else\n {\n while (t <= k)\n {\n if (t % 2 == 1)\n {\n ans = phi(ans);\n t++;\n }\n else\n {\n t++;\n continue;\n }\n }\n }\n }\n Console.WriteLine(ans % mod);\n Console.Read();\n }\n }\n}", "lang_cluster": "C#", "tags": ["math", "number theory"], "code_uid": "d3e25ce0dd7987b24727d0e1d131328e", "src_uid": "0591ade5f9a69afcbecd80402493f975", "difficulty": 2100.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 _247c\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 t = readIntArray();\n\t\t\tvar n = t[0];\n\t\t\tvar k = t[1];\n\t\t\tvar d = t[2];\n\n\t\t\tvar maxK = Math.Max(k, n);\n\t\t\tvar dp = new long[n + 1, n + 1, 2];\n\t\t\tfor (int i = 1; i < n + 1; i++)\n\t\t\t{\n\t\t\t\tif (k >= i)\n\t\t\t\t{\n\t\t\t\t\tif (i < d)\n\t\t\t\t\t{\n\t\t\t\t\t\tdp[1, i, 0] = 1;\n\t\t\t\t\t\tdp[1, i, 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\tdp[1, i, 0] = 0;\n\t\t\t\t\t\tdp[1, i, 1] = 1;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tdp[0, i, 0] = 0;\n\t\t\t\tdp[0, i, 1] = 0;\n\t\t\t}\n\n\t\t\tfor (int i = 1; i < n + 1; i++)\n\t\t\t{\n\t\t\t\tdp[i, 0, 0] = 0;\n\t\t\t\tdp[i, 0, 1] = 0;\n\t\t\t}\n\n\t\t\tdp[0, 0, 0] = 1;\n\t\t\tdp[0, 0, 1] = 0;\n\n\t\t\t//Console.WriteLine(\"-- 0 ---\");\n\t\t\t//for (int i = 0; i < n + 1; i++)\n\t\t\t//{\n\t\t\t//\tfor (int j = 0; j < n + 1; j++)\n\t\t\t//\t{\n\t\t\t//\t\tConsole.Write(\"{0} \", dp[i, j, 0]);\n\t\t\t//\t}\n\t\t\t//\tConsole.WriteLine();\n\t\t\t//}\n\n\t\t\t//Console.WriteLine(\"-- 1 ---\");\n\t\t\t//for (int i = 0; i < n + 1; i++)\n\t\t\t//{\n\t\t\t//\tfor (int j = 0; j < n + 1; j++)\n\t\t\t//\t{\n\t\t\t//\t\tConsole.Write(\"{0} \", dp[i, j, 1]);\n\t\t\t//\t}\n\t\t\t//\tConsole.WriteLine();\n\t\t\t//}\n\n\t\t\tvar mod = 1000000007;\n\t\t\tfor (int i = 2; i < n + 1; i++)\n\t\t\t{\n\t\t\t\tfor (int j = 1; j < n + 1; j++)\n\t\t\t\t{\n\t\t\t\t\tvar mk = Math.Min(j, k);\n\t\t\t\t\tdp[i, j, 0] = 0;\n\t\t\t\t\tdp[i, j, 1] = 0;\n\t\t\t\t\tfor (int z = 1; z < mk + 1; z++)\n\t\t\t\t\t{\n\t\t\t\t\t\tvar rem = j - z;\n\t\t\t\t\t\tif (z < d)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tdp[i, j, 0] += dp[i - 1, rem, 0];\n\t\t\t\t\t\t\tdp[i, j, 0] %= mod;\n\t\t\t\t\t\t\tdp[i, j, 1] += dp[i - 1, rem, 1];\n\t\t\t\t\t\t\tdp[i, j, 1] %= mod;\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tdp[i, j, 0] += 0;\n\t\t\t\t\t\t\tdp[i, j, 1] += (dp[i - 1, rem, 0] + dp[i - 1, rem, 1]);\n\t\t\t\t\t\t\tdp[i, j, 1] %= mod;\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\t//Console.WriteLine(\"-- 0 ---\");\n\t\t\t//for (int i = 0; i < n + 1; i++)\n\t\t\t//{\n\t\t\t//\tfor (int j = 0; j < n + 1; j++)\n\t\t\t//\t{\n\t\t\t//\t\tConsole.Write(\"{0} \", dp[i, j, 0]);\n\t\t\t//\t}\n\t\t\t//\tConsole.WriteLine();\n\t\t\t//}\n\n\t\t\t//Console.WriteLine(\"-- 1 ---\");\n\t\t\t//for (int i = 0; i < n + 1; i++)\n\t\t\t//{\n\t\t\t//\tfor (int j = 0; j < n + 1; j++)\n\t\t\t//\t{\n\t\t\t//\t\tConsole.Write(\"{0} \", dp[i, j, 1]);\n\t\t\t//\t}\n\t\t\t//\tConsole.WriteLine();\n\t\t\t//}\n\n\t\t\tvar res = 0L;\n\t\t\tfor (int i = 1; i < n + 1; i++)\n\t\t\t{\n\t\t\t\tres += dp[i, n, 1];\n\t\t\t\tres %= mod;\n\t\t\t}\n\n\t\t\tConsole.WriteLine(res);\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": ["dp", "implementation", "trees"], "code_uid": "6f2bd276784ebc8000889f4ce3602aa6", "src_uid": "894a58c9bba5eba11b843c5c5ca0025d", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Linq;\n\nnamespace CSharp\n{\n public class _938A\n {\n public static void Main()\n {\n char[] vowels = new char[] { 'a', 'e', 'i', 'o', 'u', 'y' };\n\n int n = int.Parse(Console.ReadLine());\n string s = Console.ReadLine();\n\n Console.WriteLine(new string(Enumerable.Range(0, n).Where(i => i == 0 || !vowels.Contains(s[i]) || !vowels.Contains(s[i - 1])).Select(i => s[i]).ToArray()));\n }\n }\n}", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "1d248c12de2908bb92ff4b30bf17ae7e", "src_uid": "63a4a5795d94f698b0912bb8d4cdf690", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Runtime.ExceptionServices;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace Archive\n{\n public class Test\n {\n public static int A;\n public static int B;\n public static int K;\n public static int M;\n public static int N;\n public static int T;\n public static int S;\n public static int R;\n public static int C;\n public static int H;\n public static int W;\n public static int I;\n public static int J;\n\n public static void Main(string[] args)\n {\n First();\n }\n\n private static void First()\n {\n string s = Console.ReadLine();\n\n int res = 0;\n int now = 0;\n for(int i=1;i 1)\n {\n long temp;\n temp = go(n);\n n=temp;\n sum += temp;\n }\n Console.WriteLine(sum);\n \n }\n }\n}\n", "lang_cluster": "C#", "tags": ["number theory"], "code_uid": "51477a5e38ac2955a15fb28a8683837d", "src_uid": "821c0e3b5fad197a47878bba5e520b6e", "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 CodeForces_579A_Raising_Bacteria\n{\n class Program\n {\n static void Main(string[] args)\n {\n int x = int.Parse(Console.ReadLine());\n int y = x;\n int tag = 1;\n while(y/2!=0)\n {\n if (y % 2 == 1)\n tag++;\n y = y / 2;\n }\n Console.WriteLine(tag);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["bitmasks"], "code_uid": "c9ef99c161b8b5edcac663ea7ff34652", "src_uid": "03e4482d53a059134676f431be4c16d2", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\n\nclass Program\n{\n static void Main(string[] args)\n {\n int n = Int32.Parse(Console.ReadLine());\n string stones = Console.ReadLine();\n int baseCount = 0, count=0;\n for (int i = 1; i < n; i++)\n {\n if (stones[i] == stones[baseCount])\n count++;\n else\n baseCount = i;\n }\n Console.WriteLine(count);\n }\n}", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "e10c7ba6bbfdf5e8fc5fb2eeb5fad18a", "src_uid": "d561436e2ddc9074b98ebbe49b9e27b8", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Text;\nusing System.IO;\nnamespace \u0421_Generation\n{\n class Program\n {\n static void Main(string[] args)\n {\n int n = int.Parse(Console.ReadLine());\n\n long sum = 0;\n long p = 1;\n while(n>0)\n {\n p *= 2;\n sum += p;\n n--;\n }\n Console.WriteLine(sum);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "combinatorics"], "code_uid": "8121892cd1ff9180cd9adf1b7e8bf6e5", "src_uid": "f1b43baa14d4c262ba616d892525dfde", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Linq;\n\nnamespace Task_1080A\n{\n class Program\n {\n static void Main(string[] args)\n {\n int[] temp = Console.ReadLine().Split().Select(int.Parse).ToArray();\n int n = temp[0], k = temp[1];\n int red = n * 2 % k == 0 ? n * 2 / k : n * 2 / k + 1;\n int green = n * 5 % k == 0 ? n * 5 / k : n * 5 / k + 1;\n int blue = n * 8 % k == 0 ? n * 8 / k : n * 8 / k + 1;\n Console.WriteLine(red + green + blue);\n\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math"], "code_uid": "a7b6f948a7551974a32c8c511dc1350e", "src_uid": "d259a3a5c38af34b2a15d61157cc0a39", "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 Q1\n{\n\tclass Program\n\t{\n\t\tstatic void Main ( string[] args )\n\t\t{\n\t\t\t// 8, 4, 2, 6\n\t\t\tulong n = ulong.Parse( Console.ReadLine() );\n\n//\t\t\tn = (ulong) Math.Pow( 10, 9 );\n\n\t\t\tdouble d = Math.Floor( n / 4.0 );\n\t\t\tif ( d > 1 )\n\t\t\t\tn = 4 + ( n - ( (ulong)d * 4 ) );\n\n\t\t\tdouble p = Math.Pow( 8, n );\n\t\t\tstring s = p.ToString();\n\t\t\tConsole.WriteLine( s[ s.Length - 1 ] );\n\n//\t\t\tConsole.ReadKey();\n\t\t}\n\t}\n}\n", "lang_cluster": "C#", "tags": ["math", "implementation", "number theory"], "code_uid": "af45932f88a92b428ade9a6860003bac", "src_uid": "4b51b99d1dea367bf37dc5ead08ca48f", "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.IO;\n\nnamespace ConsoleApplication1\n{\n class Program\n {\n static void Main(string[] args)\n {\n\n var temp = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();\n int a = temp[0];\n int b = temp[1];\n\n if ((a > 0 || b > 0) && Math.Abs(b - a) < 2)\n Console.WriteLine(\"YES\");\n else\n\t{\n Console.WriteLine(\"NO\");\n\t}\n Console.ReadLine();\n \n }\n\n }\n}", "lang_cluster": "C#", "tags": ["brute force", "math", "constructive algorithms", "implementation"], "code_uid": "3a155f45cdda57ad816ed8fafcd94021", "src_uid": "ec5e3b3f5ee6a13eaf01b9a9a66ff037", "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 Magic_Numbers\n{\n class Program\n {\n static void Main(string[] args)\n {\n string s = Console.ReadLine();\n if (s[0] == '4')\n {\n Console.WriteLine(\"NO\");\n return;\n }\n int br4 = 0;\n for (int i = 0; i < s.Length; i++)\n {\n if (s[i] == '4')\n {\n br4++;\n if (br4 > 2)\n {\n Console.WriteLine(\"NO\");\n return;\n }\n }\n else if (s[i] == '1') br4 = 0;\n else\n {\n Console.WriteLine(\"NO\");\n return;\n }\n }\n Console.WriteLine(\"YES\");\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "greedy"], "code_uid": "57a4c28971cbf558e18b45435eed5968", "src_uid": "3153cfddae27fbd817caaf2cb7a6a4b5", "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\nclass cf1\n{\n static void Main()\n {\n string strInfo01 = Console.ReadLine();\n\n long lngNumber = long.Parse(strInfo01.Split()[0]);\n long lngPosition = long.Parse(strInfo01.Split()[1]);\n long lngSquare = (long)Math.Sqrt(lngNumber);\n\n List lstResults = new List();\n\n for (long i = 1; i <= lngSquare; i++)\n {\n if (lngNumber % i == 0)\n {\n lstResults.Add(i);\n if (i != lngNumber/i)\n {\n lstResults.Add(lngNumber / i);\n }\n }\n }\n\n lstResults.Sort();\n\n if (lstResults.Count< lngPosition)\n {\n Console.WriteLine(-1);\n }\n else\n {\n Console.WriteLine(lstResults [(int)lngPosition-1]);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "number theory"], "code_uid": "d91d8bec47e2ca4616bd81bd97bf31c6", "src_uid": "6ba39b428a2d47b7d199879185797ffb", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\n\n// Codeforces problem 599A \"\u041f\u0430\u0442\u0440\u0438\u043a \u0438 \u043f\u043e\u0445\u043e\u0434 \u0432 \u043c\u0430\u0433\u0430\u0437\u0438\u043d\"\n// http://codeforces.com/problemset/problem/599/A\nnamespace _599_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 d1 = Convert.ToInt32(tmp[0]);\n\t\t\tint d2 = Convert.ToInt32(tmp[1]);\n\t\t\tint d3 = Convert.ToInt32(tmp[2]);\n\t\t\t#endregion\n\t\t\t#region Process data\n\t\t\tint result = Math.Min(d1 + d2 + d3, Math.Min((d1 + d2) * 2, Math.Min((d1 + d3) * 2, (d2 + d3) * 2)));\n\t\t\t#endregion\n\t\t\t#region Write results\n\t\t\tConsole.WriteLine(result);\n\t\t\tConsole.ReadLine();\n\t\t\t#endregion\n\t\t}\n\t}\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "87d5fb234db07fe53e410f70a7af1ce1", "src_uid": "26cd7954a21866dbb2824d725473673e", "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.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 n = input.ReadInt();\n var a = input.ReadIntArray(n);\n var b = input.ReadIntArray(n);\n var ca = new int[5];\n var cb = new int[5];\n for (int i = 0; i < n; i++)\n {\n ca[a[i] - 1]++;\n cb[b[i] - 1]++;\n }\n var cp = 0;\n var cn = 0;\n for (int i = 0; i < 5; i++)\n {\n if ((ca[i] + cb[i]) % 2 != 0)\n {\n Console.Write(-1);\n return;\n }\n var m = ca[i] - Math.Abs(ca[i] + cb[i]) / 2;\n if (m < 0)\n {\n cn += m;\n }\n else\n {\n cp += m;\n }\n }\n if (cp + cn != 0)\n {\n Console.Write(-1);\n return;\n }\n Console.Write(cp);\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": ["math", "constructive algorithms"], "code_uid": "3fcaa942a295d7623960f28fd2d61125", "src_uid": "47da1dd95cd015acb8c7fd6ae5ec22a3", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\n\nclass Program{\n\tstatic void Main(){\n\t\tstring[] input = Console.ReadLine().Split();\n\t\tint al = int.Parse(input[0]);\n\t\tint ar = int.Parse(input[1]);\n\t\tinput = Console.ReadLine().Split();\n\t\tint bl = int.Parse(input[0]);\n\t\tint br = int.Parse(input[1]);\n\t\t\n\t\tif((br >= al - 1 && br <= (al + 1) * 2) || (bl >= ar - 1 && bl <= (ar + 1) * 2))\n\t\t\tConsole.WriteLine(\"YES\");\n\t\telse\n\t\t\tConsole.WriteLine(\"NO\");\n\t}\n}", "lang_cluster": "C#", "tags": ["math", "greedy"], "code_uid": "158b1ce7864735fd44f72e57ce17fd16", "src_uid": "36b7478e162be6e985613b2dad0974dd", "difficulty": 1300.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.Runtime.CompilerServices;\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 MOD = 1000000007;\r\n\r\n public void Solve()\r\n {\r\n for (int tt = ReadInt(); tt > 0; tt--)\r\n {\r\n int n = ReadInt();\r\n int m = ReadInt();\r\n\r\n long ans = 1;\r\n for (int i = 0; i < m; i++)\r\n ans = ans * n % MOD;\r\n\r\n Write(ans);\r\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": ["math", "combinatorics", "bitmasks"], "code_uid": "fffa4f6a9ee0abae13c340460dbdebd4", "src_uid": "2e7a9f3a97938e4a7e036520d812b97a", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nclass Program\n {\n static void Main(string[] args)\n {\n int a, b, c, counter = 0;\n {\n string[] input = Console.ReadLine().Split(new char[] { ' ', '\\t' }, StringSplitOptions.RemoveEmptyEntries);\n b = int.Parse(input[0]);\n c = a = int.Parse(input[1]);\n }\n {\n int temp = c;\n int strt = a;\n while (a < b)\n {\n temp = a;\n a += c;\n c = temp;\n counter++;\n }\n a -= a / strt - 1;\n if (a < b) counter++;\n }\n Console.WriteLine(counter + 2);\n }\n }", "lang_cluster": "C#", "tags": ["math", "greedy"], "code_uid": "de60e6e215b74f1e4b9cae03ec598185", "src_uid": "8edf64f5838b19f9a8b19a14977f5615", "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 JabberID\n{\n class Program\n {\n static void Main(string[] args)\n {\n string id = Console.ReadLine();\n string username = \"\";\n string hostname = \"\";\n string resource = \" \";\n if (id.Contains(\"@\"))\n {\n username = id.Substring(0, id.IndexOf(\"@\"));\n if (id.IndexOf('/') > id.IndexOf('@'))\n {\n hostname = id.Substring(id.IndexOf(\"@\") + 1, id.IndexOf(\"/\") - id.IndexOf(\"@\") - 1);\n resource = id.Substring(id.IndexOf(\"/\") + 1);\n }\n else\n {\n hostname = id.Substring(id.IndexOf(\"@\") + 1);\n }\n }\n JabberID jabberID = new JabberID()\n {\n Username = username,\n Hostname = hostname,\n Resource = resource\n\n };\n jabberID.IsJabberID();\n }\n\n }\n class JabberID\n {\n public string Username\n {\n set; get;\n }\n public string Hostname\n {\n set; get;\n }\n public string Resource\n {\n set; get;\n }\n private bool IsUsername(string username)\n {\n if (username.Length >= 1 && username.Length <= 16)\n {\n for (int i = 0; i < username.Length; i++)\n {\n char letter = username[i];\n if (!((letter >= 'a' && letter <= 'z') || (letter >= 'A' && letter <= 'Z') || (letter == '_') || (letter >= '0' && letter <= '9')))\n return false;\n }\n return true;\n }\n return false;\n }\n private bool IsHostname(string hostname)\n {\n if (hostname.Length < 1 && hostname.Length > 32)\n return false;\n string[] words = hostname.Split('.');\n for (int i = 0; i < words.Length; i++)\n {\n if ((words[i].Length < 1 && words[i].Length > 16) || words[i].Length == 0)\n return false;\n for (int j = 0; j < words[i].Length; j++)\n {\n if (!((words[i][j] >= 'a' && words[i][j] <= 'z') || (words[i][j] >= 'A' && words[i][j] <= 'Z') || (words[i][j] == '_') || (words[i][j] >= '0' && words[i][j] <= '9')))\n return false;\n }\n\n }\n return true;\n }\n private bool IsResource(string resource)\n {\n if (resource.Length >= 1 && resource.Length <= 16)\n {\n for (int i = 0; i < resource.Length; i++)\n {\n char letter = resource[i];\n if (!((letter >= 'a' && letter <= 'z') || (letter >= 'A' && letter <= 'Z') || (letter == '_') || (letter == ' ') || (letter >= '0' && letter <= '9')))\n return false;\n }\n return true;\n }\n return false;\n }\n public void IsJabberID()\n {\n if (IsUsername(Username) && IsHostname(Hostname) && IsResource(Resource))\n Console.WriteLine(\"YES\");\n else\n Console.WriteLine(\"NO\");\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["strings", "implementation"], "code_uid": "624c6df0c26f36d1a8fda34f6f666d65", "src_uid": "2a68157e327f92415067f127feb31e24", "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 Examples\n{\n class Program\n {\n\n static void Main(String[] args)\n {\n\n string s1 = Console.ReadLine();\n string s2 = Console.ReadLine();\n\n IEnumerable s1Rev = s1.Reverse();\n string c = string.Concat(s1Rev);\n\n if (c == s2) Console.WriteLine(\"YES\");\n else Console.WriteLine(\"NO\");\n }\n\n }\n \n}\n", "lang_cluster": "C#", "tags": ["strings", "implementation"], "code_uid": "2807a02323d282d826f763b550eee6b7", "src_uid": "35a4be326690b58bf9add547fb63a5a5", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace Testonly\n{\n class Program\n {\n static void Main(string[] args)\n {\n int len = Convert.ToInt32(Console.ReadLine());\n string[] strarr;\n long[] nums = new long[len];\n\n strarr = Console.ReadLine().Split(' ');\n for (int i = 0; i < len; i++)\n nums[i] = Convert.ToInt64(strarr[i]);\n nums = nums.Distinct().ToArray();\n Array.Sort(nums);\n if (nums.Length > 3)\n Console.WriteLine(\"-1\");\n else if (nums.Length == 2)\n {\n if ((nums[0] + nums[1]) % 2 == 0)\n Console.WriteLine((nums[1] - nums[0]) / 2);\n else\n Console.WriteLine(nums[1] - nums[0]);\n }\n else if (nums.Length == 1)\n Console.WriteLine(\"0\");\n else\n {\n for (int i = 0; i < nums[2] - nums[0]; i++)\n {\n if (nums[0] + i == nums[1] && nums[2] - i == nums[1])\n {\n Console.WriteLine(i);\n //Console.ReadLine();\n return;\n }\n }\n Console.WriteLine(\"-1\");\n }\n //Console.ReadLine();\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math"], "code_uid": "7ae4302bcc52b2d452b3b382a1d799df", "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.Threading.Tasks;\n\nnamespace csharp_project\n{\n class Program\n {\n static void Main(string[] args)\n {\n var input = Console.ReadLine().Split();\n var n = Convert.ToInt32(input[0]);\n var m = Convert.ToInt32(input[1]);\n var ct = 0;\n while (n<=m)\n {\n \n n *= 3;\n m *= 2;\n ct++;\n }\n Console.WriteLine(ct);\n } \n }\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "bdb9cc0df5a83e9ed5afc4b95ee14636", "src_uid": "a1583b07a9d093e887f73cc5c29e444a", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Linq;\n\nnamespace _900____A1008___Romanji\n{\n class Program\n {\n private static bool IsVowel(char ch)\n {\n if (ch =='a' || ch == 'o' || ch == 'u' || ch == 'i' || ch == 'e')\n {\n return true;\n }\n return false;\n }\n static void Main(string[] args)\n {\n\n var word = Console.ReadLine();\n //var vowels = new char[] { 'a', 'o', 'u', 'i', 'e' };\n bool answer = true;\n\n for (int i = 0; i < word.Length; i++)\n {\n var currentChar = word[i];\n\n bool isCurConsonant = !IsVowel(currentChar);\n\n if (currentChar == 'n' || !isCurConsonant)\n {\n continue;\n }\n\n if (i + 1 >= word.Length || !IsVowel(word[i + 1]))\n {\n answer = false;\n break;\n }\n \n }\n\n Console.WriteLine(answer == true ? \"YES\" : \"NO\");\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["strings", "implementation"], "code_uid": "f7ca6d998c3c7dce14a32f85ba343da4", "src_uid": "a83144ba7d4906b7692456f27b0ef7d4", "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.Text;\n\nnamespace Cutlet\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 Solve(args);\n writer.Flush();\n }\n\n private static void Solve(string[] args)\n {\n int n = Next();\n int k = Next();\n\n var l = new int[k];\n var r = new int[k];\n for (int i = 0; i < k; i++)\n {\n l[i] = Next();\n r[i] = Next();\n }\n\n List[] dp;\n dp = new List[2*k + 1];\n\n for (int i = 0; i < dp.Length; i++)\n {\n dp[i] = new List();\n }\n dp[0].Add(new Interval(0, 0));\n\n int prev = 0;\n for (int i = 0; i < k; i++)\n {\n var next = new List[dp.Length];\n for (int ii = 0; ii < dp.Length; ii++)\n {\n next[ii] = new List();\n }\n\n int delta = l[i] - prev;\n for (int index = 0; index < dp.Length; index++)\n {\n if (index%2 == 0)\n {\n List t = dp[index];\n foreach (Interval interval in t)\n {\n interval.l += delta;\n interval.r += delta;\n }\n }\n }\n delta = r[i] - l[i];\n for (int ii = 0; ii < dp.Length; ii++)\n {\n if (ii%2 == 0)\n {\n foreach (Interval interval in dp[ii])\n {\n next[ii].Add(new Interval(interval.l + delta, interval.r + delta));\n next[ii + 1].Add(new Interval(interval.l, interval.r + delta));\n next[ii + 2].Add(new Interval(interval.l, interval.r + delta));\n }\n }\n else\n {\n foreach (Interval interval in dp[ii])\n {\n next[ii].Add(new Interval(interval.l, interval.r));\n next[ii + 1].Add(new Interval(interval.l, interval.r + delta));\n next[ii + 2].Add(new Interval(interval.l, interval.r + delta));\n }\n }\n }\n\n prev = r[i];\n for (int index = 0; index < dp.Length; index++)\n {\n dp[index].Clear();\n\n Interval pr = null;\n foreach (Interval interval in next[index].OrderBy(t => t.l))\n {\n if (interval.l > n)\n break;\n if (pr != null && pr.r >= interval.l)\n {\n pr.r = Math.Max(pr.r, interval.r);\n }\n else\n {\n if (pr != null && !Find(dp, pr, index))\n dp[index].Add(pr);\n pr = interval;\n }\n }\n if (pr != null && !Find(dp, pr, index))\n dp[index].Add(pr);\n }\n }\n\n {\n int delta = 2*n - prev;\n for (int index = 0; index < dp.Length; index++)\n {\n if (index%2 == 0)\n {\n List t = dp[index];\n foreach (Interval interval in t)\n {\n interval.l += delta;\n interval.r += delta;\n }\n }\n }\n }\n\n for (int i = 0; i < dp.Length; i++)\n {\n foreach (Interval interval in dp[i])\n {\n if (interval.l <= n && interval.r >= n)\n {\n writer.WriteLine(\"Full\");\n writer.WriteLine(i);\n return;\n }\n }\n }\n\n writer.WriteLine(\"Hungry\");\n }\n\n\n private static bool Find(List[] dp, Interval value, int index)\n {\n for (int i = index - 2; i >= 0; i--)\n {\n int ind = dp[i].BinarySearch(value, value);\n if (ind < 0)\n {\n ind = (~ind) - 1;\n if (ind > 0 && dp[i][ind].r >= value.r)\n {\n return true;\n }\n }\n else\n {\n if (dp[i][ind].r >= value.r)\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 #region Nested type: Interval\n\n private class Interval : IComparer\n {\n public int l, r;\n\n public Interval(int l, int r)\n {\n this.l = l;\n this.r = r;\n }\n\n #region IComparer Members\n\n public int Compare(Interval x, Interval y)\n {\n return x.l.CompareTo(y.l);\n }\n\n #endregion\n }\n\n #endregion\n }\n}", "lang_cluster": "C#", "tags": ["dp", "data structures"], "code_uid": "21018d808cf6381c6b362b4c5af8dc1d", "src_uid": "2e0d1b1f1a7b8df2d2598c3cb2c869d5", "difficulty": 2400.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#region ioh\n\nclass Scanner\n{\n private readonly TextReader reader;\n private string[] buffer;\n private int bufferPos;\n\n public Scanner()\n : this(null)\n { }\n\n public Scanner(TextReader reader)\n {\n this.reader = reader ?? Console.In;\n buffer = new string[0];\n }\n\n public string NextTerm()\n {\n if (bufferPos >= buffer.Length)\n {\n buffer = reader.ReadLine().Split(' ');\n bufferPos = 0;\n }\n\n return buffer[bufferPos++];\n }\n\n public int NextInt()\n {\n return int.Parse(NextTerm());\n }\n\n public int[] NextIntArray()\n {\n return Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);\n }\n\n public int[][] NextIntMatrix(int rowCount)\n {\n var matrix = new int[rowCount][];\n\n for (int i = 0; i < matrix.Length; i++)\n {\n matrix[i] = NextIntArray();\n }\n\n return matrix;\n }\n}\n\n#endregion\n\nclass Program\n{\n private static readonly Scanner s = new Scanner();\n\n static void Main(string[] args)\n {\n var s = Console.ReadLine();\n\n var fc = 0;\n var sc = 0;\n\n foreach (var c in s)\n {\n if (c == '4') fc++;\n else if (c == '7') sc++;\n }\n\n if (fc == 0 && sc == 0)\n {\n Console.WriteLine(-1);\n }\n else if (fc >= sc)\n {\n Console.WriteLine(\"4\");\n }\n else\n {\n Console.WriteLine(\"7\");\n }\n }\n}", "lang_cluster": "C#", "tags": ["brute force", "implementation"], "code_uid": "6eb8e8f04c3195fad492abd8af733a0a", "src_uid": "639b8b8d0dc42df46b139f0aeb3a7a0a", "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;\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[][] inp = new char[4][];\n for (int i = 0; i < 4; i++) {\n inp[i] = Console.ReadLine().ToCharArray();\n }\n int[,] m = new int[3, 3];\n bool sol = false;\n for (int i = 0; i < 3; i++) {\n for (int j = 0; j < 3; j++) {\n if (inp[i][j] == '#') {\n m[i, j]++;\n }\n if (inp[i + 1][j] == '#') {\n m[i, j]++;\n }\n if (inp[i][j + 1] == '#') {\n m[i, j]++;\n }\n if (inp[i + 1][j + 1] == '#') {\n m[i, j]++;\n }\n if (m[i, j] != 2) {\n sol = true;\n }\n }\n }\n if (sol) {\n Console.Write(\"YES\");\n } else {\n Console.Write(\"NO\");\n }\n //Console.ReadKey();\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "implementation"], "code_uid": "085fb39cd86ed7b568506512470884df", "src_uid": "01b145e798bbdf0ca2ecc383676d79f3", "difficulty": 1100.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@\"\n5000\n\");\n\n static void Main(string[] args)\n {\n int A = int.Parse(CF.ReadLine());\n\n int sum = 0;\n for (int a = 2; a <= A - 1; a++)\n {\n List ds = _b(A, a);\n foreach (int d in ds)\n sum += d;\n }\n\n int x = sum;\n int y = A - 2;\n for (int i = y; i>=2; i--)\n {\n if ((x % i) == 0 && (y % i) == 0)\n {\n x /= i;\n y /= i;\n }\n }\n\n CF.WriteLine(x+\"/\"+y);\n }\n\n static List _b(int a, int b)\n {\n List ds = new List();\n for (; ; )\n {\n int d = a % b;\n ds.Add(d);\n a /= b;\n if (a == 0)\n break;\n }\n return ds;\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": ["math", "implementation"], "code_uid": "ad2a42b3f01bf79a2647f7c91bab2085", "src_uid": "1366732dddecba26db232d6ca8f35fdc", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Linq;\n\nnamespace _1114\n{\n class Program\n {\n static void Main(string[] args)\n {\n int[] xyz = Console.ReadLine().Trim().Split(' ').Select(Int32.Parse).ToArray();\n int[] abc = Console.ReadLine().Trim().Split(' ').Select(Int32.Parse).ToArray();\n \n abc[0] -= xyz[0];\n if (abc[0] >= 0) {\n int ab = abc[0] + abc[1];\n ab -= xyz[1];\n if (ab >= 0){\n int left = ab + abc[2];\n left -= xyz[2];\n if (left >= 0){\n Console.WriteLine(\"YES\");\n return;\n }\n }\n }\n Console.WriteLine(\"NO\");\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "greedy", "implementation"], "code_uid": "47236189aed45cb90a04485d53eba1fb", "src_uid": "d54201591f7284da5e9ce18984439f4e", "difficulty": 800.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;\nnamespace Program\n{\n public class Solver\n {\n public void Solve()\n {\n var a = sc.Integer();\n var b = sc.Integer();\n var c = sc.Integer();\n var d = sc.Integer();\n var p = Math.Max(3 * a / 10, a - a * c / 250);\n var q = Math.Max(3 * b / 10, b - b * d / 250);\n if (p > q)\n IO.Printer.Out.WriteLine(\"Misha\");\n else if (p == q)\n IO.Printer.Out.WriteLine(\"Tie\");\n else IO.Printer.Out.WriteLine(\"Vasya\");\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#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 Error = new Printer(System.IO.Stream.Null);\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 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": ["implementation"], "code_uid": "e40531591d2f52532d0a479b412ded0a", "src_uid": "95b19d7569d6b70bd97d46a8541060d0", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\n\nnamespace CF_12_12_2017\n{\n class Program\n {\n static void Main(string[] args)\n {\n var n = Int32.Parse(Console.ReadLine());\n\n for (var i = 0; i < n; i++)\n {\n if (Test2(Int32.Parse(Console.ReadLine())))\n {\n Console.WriteLine(\"YES\");\n }\n else Console.WriteLine(\"NO\");\n }\n\n //for (int i = 1; i <= 100; i++)\n //{\n // if (Test2(i))\n // {\n // Console.WriteLine($\"{i} --- YES\");\n // }\n // else Console.WriteLine($\"{i} --- NO\");\n //}\n\n }\n\n private static bool Test2(int x)\n {\n for (int i = 0; i <= x/7; i++)\n {\n int ipart = i * 7;\n if (ipart > x) break;\n\n for (var j = 0; j <= x/3; j++)\n {\n var n = ipart + j * 3;\n if (n == x) return true;\n if (n > x) break;\n }\n }\n\n return false;\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["greedy", "implementation"], "code_uid": "257620f9991b153daf8bcd70426c0064", "src_uid": "cfd1182be98fb5f0c426f8b68e48d452", "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 GoogleCodeJam\n{\n class codeForces4\n {\n public static void Main(string[] args)\n {\n long ip;\n long ans = 1;\n\n ip = long.Parse(Console.ReadLine());\n\n long i = 0;\n long temp = 0;\n while (temp < ip)\n {\n i++;\n temp = temp + i;\n \n }\n\n ans = ip - (temp - i);\n\n \n Console.WriteLine(ans);\n\n \n\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "implementation"], "code_uid": "4b1bea653e843f583cc9ba37ac3611a6", "src_uid": "1db5631847085815461c617854b08ee5", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nclass Program\n {\n static void Main(string[] args)\n {\n long n = long.Parse(Console.ReadLine());\n long result = n;\n result += (((n * n - n) / 2L) * n);\n result -= ((n * n - n) * (2 * n - 1L) / 6L);\n Console.WriteLine(result);\n }\n }", "lang_cluster": "C#", "tags": ["math", "implementation"], "code_uid": "241ffb5f69f149b6421ba824f246b651", "src_uid": "6df251ac8bf27427a24bc23d64cb9884", "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.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 Calc(long a, long b)\n {\n if (a < b)\n {\n return Calc(b, a);\n }\n if (a == 0 || b == 0) return 0;\n\n\n var res = a / b;\n return res + Calc(b, a % b);\n }\n static void Main()\n {\n var a = cin.ReadInt64();\n var b = cin.ReadInt64();\n\n var res = Calc(a, b);\n\n cout.WriteLine(res);\n }\n}", "lang_cluster": "C#", "tags": ["math", "implementation"], "code_uid": "63c40a43b02a315231093211ce5f24d4", "src_uid": "ce698a0eb3f5b82de58feb177ce43b83", "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 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 List lucks = new List();\n static void Main()\n {\n var input = Console.ReadLine();\n var l = ReadNextInt(input, 0);\n var r = ReadNextInt(input, 1);\n\n long res = 0;\n \n NextLucks(0, r);\n \n lucks.Sort();\n int indexLuck = 0;\n for (int i = 0; i < lucks.Count; i++)\n {\n if(lucks[i] >= l)\n {\n indexLuck = i;\n break;\n }\n }\n \n for (long i = l; i <= r; i++)\n {\n var last = Math.Min(lucks[indexLuck], r);\n res += (long)lucks[indexLuck++] * (last - i + 1);\n i = last;\n }\n\n Console.WriteLine(res);\n }\n\n private static void NextLucks(long luck, int max)\n {\n if(luck >= max)\n return;\n lucks.Add(luck * 10 + 4);\n NextLucks(luck * 10 + 4, max);\n lucks.Add(luck*10 + 7);\n NextLucks(luck*10 + 7, max);\n }\n }\n}", "lang_cluster": "C#", "tags": ["brute force", "math"], "code_uid": "6844e37d94c07f32663d848f9c550390", "src_uid": "8a45fe8956d3ac9d501f4a13b55638dd", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Linq;\n\nnamespace ConsoleApplication2\n{\n class Program\n {\n static void Main(string[] args)\n {\n double[] nxy = Console.ReadLine().Split().Select(x => Convert.ToDouble(x)).ToArray();\n double People = (nxy[0] * (nxy[2] / 100));\n People = People - nxy[1];\n Console.WriteLine(People > 0 ? Math.Ceiling(People):0);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "implementation"], "code_uid": "872fca6139f500c8ae39c525b7145235", "src_uid": "7038d7b31e1900588da8b61b325e4299", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\n\n\nnamespace homes\n{\n class Program\n {\n static void Main(string[] args)\n {\n string str = Console.ReadLine();\n int count = Int32.Parse(str.Split(' ')[0]);\n int number = Int32.Parse(str.Split(' ')[1]);\n int sec = 1;\n if(number % 2 == 0)\n {\n for(int i = count; i != number; i-=2)\n {\n sec++;\n }\n }\n else\n {\n for (int i = 1; i != number; i+=2)\n {\n sec++;\n }\n }\n Console.WriteLine(sec);\n\n\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "constructive algorithms"], "code_uid": "a3988065211fb8a1497ed70e2cd144db", "src_uid": "aa62dcdc47d0abbba7956284c1561de8", "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.Text.RegularExpressions;\nusing static System.Console;\nusing static System.Math;\nusing static MyIO;\nusing static MyUtil;\n\npublic class C\n{\n\tpublic static void Main() => (new Solver()).Solve();\n}\n\npublic class Solver\n{\n\tpublic void Solve()\n\t{\n\t\tlong N = GetLong();\n\t\tlong M = GetLong();\n\n\t\tlong[] f = new long[N + 1];\n\t\tf[0] = 1;\n\t\tf[1] = 1;\n\t\tfor(long i = 2; i <= N; i++)\n\t\t\tf[i] = (f[i - 1] * i) % M;\n\n\t\tlong ans = 0;\n\t\tfor(long len = 1; len <= N; len++)\n\t\t{\n\t\t\tlong cut = N - len + 1;\n\t\t\tans = (ans + (((cut * f[len]) % M) * f[cut]) % M) % M;\n\t\t}\n\n\t\tWriteLine(ans);\n\t}\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 decimal GetDecimal() => decimal.Parse(getArg());\n\tpublic static string GetString() => getArg();\n\tpublic static char GetChar() => getArg()[0];\n\tpublic static int[] GetInts(long N) => Enumerable.Range(0, (int)N).Select(_ => GetInt()).ToArray();\n\tpublic static long[] GetLongs(long N) => Enumerable.Range(0, (int)N).Select(_ => GetLong()).ToArray();\n\tpublic static double[] GetDoubles(long N) => Enumerable.Range(0, (int)N).Select(_ => GetDouble()).ToArray();\n\tpublic static decimal[] GetDecimals(long N) => Enumerable.Range(0, (int)N).Select(_ => GetDecimal()).ToArray();\n\tpublic static string[] GetStrings(long N) => Enumerable.Range(0, (int)N).Select(_ => GetString()).ToArray();\n}\n\npublic static class MyUtil\n{\n\tpublic static void chmax(ref T x, T y) where T : IComparable\n\t{\n\t\tif(x.CompareTo(y) < 0)\n\t\t\tx = y;\n\t}\n\n\tpublic static void chmin(ref T x, T y) where T : IComparable\n\t{\n\t\tif(x.CompareTo(y) > 0)\n\t\t\tx = y;\n\t}\n\n\tpublic static void swap(ref T x, ref T y)\n\t{\n\t\tT tmp = x;\n\t\tx = y;\n\t\ty = tmp;\n\t}\n}", "lang_cluster": "C#", "tags": ["math", "combinatorics"], "code_uid": "2cbe879e13649e60e5d251741e03e044", "src_uid": "020d5dae7157d937c3f58554c9b155f9", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "namespace o\n{\n using System;\n\n class Program\n {\n static void Main(string[] args)\n {\n string[] str = Console.ReadLine().Split(' ');\n long kol = long.Parse(str[0]);\n long pos = long.Parse(str[1]) - 1;\n long counter = 0;\n if (pos > (kol - 1) / 2)\n {\n pos -= (kol - 1) / 2;\n counter = 2 * pos;\n }\n else\n {\n counter = 1 + 2 * pos;\n }\n Console.WriteLine(counter);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math"], "code_uid": "aa11e2dc2f18a2d447f89341abfa9a9d", "src_uid": "1f8056884db00ad8294a7cc0be75fe97", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\n\nnamespace ConsoleApp5\n{\n class Program\n {\n static void Main(string[] args)\n {\n int[] s = Console.ReadLine().Split().Select(int.Parse).ToArray();\n\n int min1;\n int min2;\n int[] st = Console.ReadLine().Split().Select(int.Parse).ToArray();\n Array.Sort(st);\n int[] st1 = Console.ReadLine().Split().Select(int.Parse).ToArray();\n Array.Sort(st1);\n\n min1 = st.First();\n min2 = st1.First();\n\n int mindiff = 0;\n foreach(int el in st)\n {\n if (st1.Contains(el))\n {\n mindiff = el;\n break;\n }\n }\n\n int res = (min1 > min2) ? min2 * 10 + min1 : min1 * 10 + min2;\n res = (min1 == min2) ? min1 : res;\n\n res = (res > mindiff && mindiff != 0) ? mindiff : res;\n\n Console.WriteLine(res);\n\n\n\n\n }\n\n\n }\n}", "lang_cluster": "C#", "tags": ["brute force", "implementation"], "code_uid": "37640e6d9087895130a341575d45cc4b", "src_uid": "3a0c1b6d710fd8f0b6daf420255d76ee", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Globalization;\nusing System.IO;\nusing System.Text;\n\nnamespace Olymp\n{\n public class ProblemSolver\n {\n private Tokenizer input;\n\n public void Solve()\n {\n var y = input.ReadInt();\n var b = input.ReadInt();\n var r = input.ReadInt();\n var s = 0;\n for (var i = 1; i <= y; i++)\n {\n if (i + 1 > b || i + 2 > r)\n break;\n s = 3 * i + 3;\n }\n Console.WriteLine(s);\n }\n\n public ProblemSolver(TextReader input)\n {\n this.input = new Tokenizer(input);\n }\n\n #region Service functions\n\n private static void AddCount(Dictionary counter, T item)\n {\n if (counter.TryGetValue(item, out var 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 return counter.TryGetValue(item, out var count) ? count : 0;\n }\n\n private static int GCD(int a, int b)\n {\n while (b != 0)\n {\n a %= b;\n var 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 var 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 var 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 var a = new int[n];\n for (var i = 0; i < n; i++)\n a[i] = ReadInt();\n return a;\n }\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 = this.reader.Read();\n }\n return sb.ToString();\n }\n\n private int SkipWS()\n {\n var 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 internal 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", "math", "implementation"], "code_uid": "d8289e9e1428b0258853d67e8e11f222", "src_uid": "03ac8efe10de17590e1ae151a7bae1a5", "difficulty": 800.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 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 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 x = getList();\n\t\t\tvar s = x.Sum();\n\t\t\twhile (s < 0)\n\t\t\t\ts += x[0];\n\t\t\tvar ans = s % x[0];\n\t\t\tif (ans == 0)\n\t\t\t\tans = x[0];\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", "implementation"], "code_uid": "cb72cdeb5d645e14e2dde1587bc910a3", "src_uid": "cd0e90042a6aca647465f1d51e6dffc4", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Linq;\n\nnamespace tren\n{\n class Program\n {\n static void Main(string[] args)\n {\n int[] n = Console.ReadLine().Split().Select(int.Parse).ToArray();\n int[] mass = n.Skip(1).ToArray();\n int[] dp = new int[n[0] + 1];\n foreach (int i in mass)\n {\n if (i <= n[0]) dp[i] = 1;\n }\n for(int i = mass.Min() + 1; i <= n[0]; i++)\n {\n foreach(int j in mass)\n {\n if (j < i && dp[i - j] > 0) dp[i] = Math.Max(dp[i], dp[i - j] + 1);\n }\n }\n Console.Write(dp[n[0]]);\n }\n }\n}", "lang_cluster": "C#", "tags": ["brute force", "dp"], "code_uid": "d23602888580e2e295232474c03f4750", "src_uid": "062a171cc3ea717ea95ede9d7a1c3a43", "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 ConsoleApplication33\n{\n class Program\n {\n static void Main(string[] args)\n {\n long n = long.Parse(Console.ReadLine());\n double res = 0;\n long power = 1;\n \n if (n % 2 == 0)\n {\n Console.WriteLine(n / 2);\n \n }\n else\n {\n Console.WriteLine(n / 2 - n);\n \n }\n \n \n \n Console.Read();\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "implementation"], "code_uid": "abb8ef93870e740d6604ad71ec0db972", "src_uid": "689e7876048ee4eb7479e838c981f068", "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 ProgrammingContest.Codeforces.SchoolTeam3\n{\n class A\n {\n public static void Main()\n {\n string[] m = new[] { \"January\", \"February\", \"March\", \"April\", \"May\", \"June\", \"July\", \"August\", \"September\", \"October\", \"November\", \"December\" };\n string s = Console.ReadLine();\n for (int i = 0; i < m.Length; i++)\n if (m[i] == s)\n Console.WriteLine(m[(i + int.Parse(Console.ReadLine())) % 12]);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "aabbee6b494d58881a0330a2d51ee4a8", "src_uid": "a307b402b20554ce177a73db07170691", "difficulty": 900.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(string[] args)\n {\n String[] s = Console.ReadLine().Split().ToArray();\n Array.Sort(s);\n int ans = 3;\n if (s[0] == s[1] && s[1] == s[2])\n {\n ans = 0;\n }\n else\n {\n int x0 = int.Parse(s[0].Substring(0, 1));\n int x1 = int.Parse(s[1].Substring(0, 1));\n int x2 = int.Parse(s[2].Substring(0, 1));\n if (s[0][1] == s[1][1] && s[0][1] == s[2][1])\n {\n if (x0 + 1 == x1 && x1 + 1 == x2)\n {\n ans = 0;\n }\n else if (x0 == x1 || x0 + 1 == x1 || x0 + 2 == x1)\n {\n ans = 1;\n }\n else if (x1 == x2 || x1 + 1 == x2 || x1 + 2 == x2)\n {\n ans = 1;\n }\n else ans = 2;\n }\n else if (s[0][1] == s[1][1])\n {\n if (x0 == x1 || x0 + 1 == x1 || x0 + 2 == x1)\n {\n ans = 1;\n }\n else ans = 2;\n }\n else if (s[0][1] == s[2][1])\n {\n if (x0 == x2 || x0 + 1 == x2 || x0 + 2 == x2)\n {\n ans = 1;\n }\n else ans = 2;\n }\n else if (s[1][1] == s[2][1])\n {\n if (x1 == x2 || x1 + 1 == x2 || x1 + 2 == x2)\n {\n ans = 1;\n }\n else ans = 2;\n }\n else ans = 2;\n }\n Console.WriteLine(ans);\n }\n}", "lang_cluster": "C#", "tags": ["brute force", "implementation"], "code_uid": "b1bd19e35d639a196a9bdcaa44160c2c", "src_uid": "7e42cebc670e76ace967e01021f752d3", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\n\nnamespace _460A\n{\n class Program\n {\n static void Main(string[] args)\n {\n string[] input = Console.ReadLine().Split(new char[]{ ' ' });\n \n int n = int.Parse(input[0]);\n int m = int.Parse(input[1]);\n \n int total = 0;\n int curr = n;\n int rem = 0;\n \n while (curr > 0)\n {\n total += curr;\n int currNext = (curr + rem) / m;\n int remNext = (curr + rem) % m;\n \n curr = currNext;\n rem = remNext;\n }\n \n Console.WriteLine(total);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "math", "implementation"], "code_uid": "2da474f6853780ffc7d325a5defb8cbb", "src_uid": "42b25b7335ec01794fbb1d4086aa9dd0", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.IO;\nusing System.Text;\n\nnamespace Hongcow_Learns_the_Cyclic_Shift\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 var h = new HashSet();\n for (int i = 0; i < s.Length; i++)\n {\n h.Add(s);\n s = s.Substring(1) + s.Substring(0, 1);\n }\n\n writer.WriteLine(h.Count);\n writer.Flush();\n }\n }\n}", "lang_cluster": "C#", "tags": ["strings", "implementation"], "code_uid": "d22d2b1f5cd71ec9dfa5dd11ec97d914", "src_uid": "8909ac99ed4ab2ee4d681ec864c7831e", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\n\nnamespace _48A\n{\n class Program\n {\n static void Main(string[] args)\n {\n // \"F\" \"M\" \"S\"\n string s1 = Console.ReadLine(), s2 = Console.ReadLine(), s3 = Console.ReadLine();\n //\"F\" wins when\n if (\n (s1.Equals(\"paper\") && s2.Equals(\"rock\") && s3.Equals(\"rock\")) ||\n (s1.Equals(\"scissors\") && s2.Equals(\"paper\") && s3.Equals(\"paper\")) ||\n (s1.Equals(\"rock\") && s2.Equals(\"scissors\") && s3.Equals(\"scissors\"))\n ) Console.WriteLine(\"F\");\n //\"M\" wins when\n else if (\n (s2.Equals(\"paper\") && s1.Equals(\"rock\") && s3.Equals(\"rock\")) ||\n (s2.Equals(\"scissors\") && s1.Equals(\"paper\") && s3.Equals(\"paper\")) ||\n (s2.Equals(\"rock\") && s1.Equals(\"scissors\") && s3.Equals(\"scissors\"))\n ) Console.WriteLine(\"M\");\n //\"S\" wins when\n else if (\n (s3.Equals(\"paper\") && s1.Equals(\"rock\") && s2.Equals(\"rock\")) ||\n (s3.Equals(\"scissors\") && s1.Equals(\"paper\") && s2.Equals(\"paper\")) ||\n (s3.Equals(\"rock\") && s1.Equals(\"scissors\") && s2.Equals(\"scissors\"))\n ) Console.WriteLine(\"S\");\n else Console.WriteLine(\"?\");\n\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "a70a07d528002df6623581f6e6742292", "src_uid": "072c7d29a1b338609a72ab6b73988282", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\n\nnamespace asfsdgdfgdfgdfgdfg\n{\n\tclass Program\n\t{\n\t\tpublic static void Main(string[] args)\n\t\t{int k=0;int y=0;\n\t\t\tint d =int.Parse(Console.ReadLine());\n\t\t\t\tstring ab = Console.ReadLine();\n\t\t\tfor(int i=0;ik/i){break;}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif(cc==i){Console.WriteLine(\"YES\");y=1;break;}\n\t\t\t}\n\t\t\tif(k==0){Console.WriteLine(\"YES\");}\n\t\t\tif((y==0)&&(k!=0)){Console.WriteLine(\"NO\");}\n\t\t\t\n\t\t}\n\t}\n}", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "0cecd714ed70b5d0f31ef76dbd540c53", "src_uid": "410296a01b97a0a39b6683569c84d56c", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\n\nnamespace Project\n{\n class Program\n {\n static void Main(string[] args)\n {\n String[] stringValue;\n Int32 n, a, b, c, d;\n Int64 ans;\n Int32[] value = new Int32[4];\n stringValue = Console.ReadLine().Split(' ');\n n = Convert.ToInt32(stringValue[0]);\n a = Convert.ToInt32(stringValue[1]);\n b = Convert.ToInt32(stringValue[2]);\n c = Convert.ToInt32(stringValue[3]);\n d = Convert.ToInt32(stringValue[4]);\n value[0] = a + b;\n value[1] = a + c;\n value[2] = b + d;\n value[3] = c + d;\n Array.Sort(value);\n ans = n - (value[3] - value[0]);\n if (ans > 0)\n Console.WriteLine(ans * n);\n else\n Console.WriteLine(0);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "math", "constructive algorithms"], "code_uid": "09a7f92420390053489be78b63648460", "src_uid": "b732869015baf3dee5094c51a309e32c", "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 WatchingFootball\n{\n class Program\n {\n private static int a;\n\n private static int b;\n\n private static int c;\n\n static void Main(string[] args)\n {\n int[] values = Console.ReadLine().Split(' ').Select(s => Convert.ToInt32(s)).ToArray();\n a = values[0];\n b = values[1];\n c = values[2];\n\n int result = Solve();\n Console.Out.WriteLine(result);\n }\n\n private static int Solve()\n {\n return (int) Math.Max(0, Math.Ceiling((0.0 + a - b) * c / b));\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "math", "binary search"], "code_uid": "eeb3032c0590e7c13772af73650ff26a", "src_uid": "7dd098ec3ad5b29ad681787173eba341", "difficulty": 1000.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(int.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\tvar res = new List();\n\t\t\tfor (long i = 0; i < 2 * n- 1; i++) \n\t\t\t{\n\t\t\t\tres.Add(i % 2 > 0 ? (n - 1) : n);\n\t\t\t}\n\n\t\t\tConsole.WriteLine(res.Sum());\n\t\t}\n\n\t\tpublic class Node\n\t\t{\n\t\t\tpublic int Count { get; set; }\n\n\t\t\tpublic int FirstIndex { get; set; } = -1;\n\n\t\t\tpublic int LastIndex { get; set; } = -1;\n\t\t}\n\n\t\t//public class Node\n\t\t//{\n\t\t//\tpublic Node Left { get; set; }\n\n\t\t//\tpublic Node Right { get; set; }\n\n\t\t//\tpublic T Value { get; set; }\n\n\t\t//\tpublic Node(T value) \n\t\t//\t{\n\t\t//\t\tValue = value;\n\t\t//\t}\n\t\t//}\n\n\t\t//public class Tree\n\t\t//{\n\t\t//\tpublic Node Root { get; set; }\n\n\t\t//\tpublic Tree(T value) \n\t\t//\t{\n\t\t//\t\tRoot = new Node(value);\n\t\t//\t}\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\tprivate 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\tfor (int i = a.Length - 1; i > 0; i--)\n\t\t\t{\n\t\t\t\tif (result[i] > 9) \n\t\t\t\t{\n\t\t\t\t\tresult[i] -= 10;\n\t\t\t\t\tresult[i - 1]++;\n\t\t\t\t}\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\tprivate 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", "dp", "implementation"], "code_uid": "bc4550db640a5be5b25d42b7a9820d3d", "src_uid": "758d342c1badde6d0b4db81285be780c", "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 s = Console.ReadLine().Split(' ');\n var a = new int[2];\n a[0] = int.Parse(s[0]);\n a[1] = int.Parse(s[1]);\n s = Console.ReadLine().Split(' ');\n var b = new int[2];\n b[0] = int.Parse(s[0]);\n b[1] = int.Parse(s[1]);\n s = Console.ReadLine().Split(' ');\n var c = new int[2];\n c[0] = int.Parse(s[0]);\n c[1] = int.Parse(s[1]);\n\n if ((b[0] + c[0] <= a[0] && Math.Max(b[1], c[1]) <= a[1]) ||\n (b[0] + c[0] <= a[1] && Math.Max(b[1], c[1]) <= a[0])\n || (b[1] + c[1] <= a[0] && Math.Max(b[0], c[0]) <= a[1]) ||\n (b[1] + c[1] <= a[1] && Math.Max(b[0], c[0]) <= a[0])\n || (b[0] + c[1] <= a[0] && Math.Max(b[1], c[0]) <= a[1]) ||\n (b[0] + c[1] <= a[1] && Math.Max(b[1], c[0]) <= a[0])\n || (b[1] + c[0] <= a[0] && Math.Max(b[0], c[1]) <= a[1]) ||\n (b[1] + c[0] <= a[1] && Math.Max(b[0], c[1]) <= a[0]))\n {\n Console.WriteLine(\"YES\");\n }\n else\n {\n Console.WriteLine(\"NO\");\n }\n }\n }\n}", "lang_cluster": "C#", "tags": ["constructive algorithms", "implementation"], "code_uid": "014b1087d944014187c5bd3fc5f68530", "src_uid": "2ff30d9c4288390fd7b5b37715638ad9", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Linq;\nusing System.Collections;\n\nnamespace P1 {\n \n public class A14 {\n static void p(ref BitArray a) {\n foreach (var b in a) Console.Write((bool)b ? '1' : '0');\n Console.WriteLine();\n }\n\n static BitArray add(ref BitArray a, ref BitArray b) {\n var c = new BitArray(a.Length);\n bool r = false;\n for (int i = 0; i < a.Length; i++ ) {\n var d = a[i]^b[i];\n c[i] = d ^ r;\n r = (d & r) | (a[i] & b[i]);\n }\n return c;\n }\n\n static void Main() {\n var n = int.Parse(Console.ReadLine());\n var x = new BitArray(Console.ReadLine().ToCharArray().Select(a=>a=='1'?true:false).ToArray());\n var one = new BitArray(n);\n var c = new BitArray(n);\n one.SetAll(false);\n one[0] = true;\n for (int i=0; i < n;i++) c[i]=x[i];\n c = add(ref x, ref one);\n var count = 0;\n foreach (var e in c.Xor(x)) count += (bool)e ? 1 : 0;\n Console.WriteLine(count);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "53589a234e40dd0dfac468ab276f1522", "src_uid": "54cb2e987f2cc06c02c7638ea879a1ab", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "C# 10", "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 A\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 x = int.Parse(Console.ReadLine());\r\n int[] a = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);\r\n bool[] open = new bool[3];\r\n open[x - 1] = true;\r\n\r\n while (a[x - 1] != 0)\r\n {\r\n x = a[x - 1];\r\n open[x - 1] = true;\r\n }\r\n\r\n bool ok = true;\r\n for (int i = 0; i < 3; i++ ) {\r\n if (!open[i])\r\n ok = false;\r\n }\r\n\r\n Console.WriteLine((ok) ? \"YES\" : \"NO\");\r\n }\r\n }\r\n}", "lang_cluster": "C#", "tags": ["brute force", "greedy", "implementation", "math"], "code_uid": "8c2bdb66570c71322277000866d4da98", "src_uid": "5cd113a30bbbb93d8620a483d4da0349", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Linq;\n\nnamespace ConsoleApp15\n{\n class Program\n {\n static void Main()\n {\n\n string input = Console.ReadLine();\n bool flag = input != null && input.Length >= 7 && input.Contains(\"0\") && input.Contains(\"1\");\n if (flag)\n {\n\n var digits = input.ToCharArray();\n var temp = new char[7] {'1', '0', '0', '0', '0', '0', '0'};\n var j = 0;\n var found = false;\n for (var index = 0; index < digits.Length; index++)\n {\n char t = digits[index];\n if (temp[j].Equals(t))\n {\n j++;\n }\n if (j == (temp.Length))\n {\n found = true;\n break;\n }\n }\n Console.WriteLine(found ? \"yes\" : \"no\");\n }\n else\n {\n Console.WriteLine(\"no\");\n }\n }\n }\n}", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "adf78e35ed9aa5e4c6638785fad42bd8", "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 Dima_and_the_equation\n{\n class Program\n {\n static void Main(string[] args)\n {\n int c, a, b;\n long x;\n string[] hold;\n List result = new List();\n hold = Console.ReadLine().Split(' ');\n a = Int32.Parse(hold[0]);\n b = Int32.Parse(hold[1]);\n c = Int32.Parse(hold[2]);\n for (int i = 1; i <= 81; i++)\n {\n x = b *(long) Math.Pow(i, a) + c;\n if (x>0&& x< Math.Pow(10,9))\n if (sum(x) == i)\n result.Add(x);\n }\n Console.WriteLine(result.Count);\n foreach (int i in result)\n {\n Console.Write(i + \" \");\n }\n Console.ReadLine();\n }\n static int sum(long number)\n {\n string k = number.ToString();\n int sum = 0;\n foreach (char i in k)\n {\n sum += Int32.Parse(i.ToString());\n }\n return sum;\n }\n }\n}", "lang_cluster": "C#", "tags": ["brute force", "math", "implementation", "number theory"], "code_uid": "52182db7cb704f3349e5898adf0e0404", "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;\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 long cnt = n / pow3 + 1;\n Console.WriteLine(cnt);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["greedy"], "code_uid": "b877e9f3283aab7bb4c4e84e0f9ad707", "src_uid": "7e7b59f2112fd200ee03255c0c230ebd", "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.Linq;\n\nnamespace Codeforces\n{\n internal class Program\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 = ReadArray();\n var res = new int[input.Length];\n for (int i = 0; i < input.Length; i++)\n {\n res[i] = ReadNextInt(input, i);\n }\n return res;\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 List divs;\n private static void Main()\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 if(m == 1)\n {\n Console.WriteLine(1);\n return;\n }\n long res = 1;\n if(n < k || k==1)\n {\n for (int i = 0; i < n; i++)\n {\n res *= m;\n res %= MOD;\n }\n Console.WriteLine(res);\n return;\n }\n if(n == k)\n {\n for (int i = 0; i < n / 2 + (n %2); i++)\n {\n res *= m;\n res %= MOD;\n }\n Console.WriteLine(res);\n return;\n }\n if(k % 2 == 0)\n {\n Console.WriteLine(m);\n return;\n }\n Console.WriteLine(m*m);\n }\n }\n}", "lang_cluster": "C#", "tags": ["dsu", "math", "combinatorics", "graphs"], "code_uid": "f60b361e666e263c97917cc05ac0836f", "src_uid": "1f9107e8d1d8aebb1f4a1707a6cdeb6d", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Linq;\n\nnamespace CSharp\n{\n class _897B\n {\n public static void Main()\n {\n var tokens = Console.ReadLine().Split();\n\n int k = int.Parse(tokens[0]);\n int p = int.Parse(tokens[1]);\n\n Console.WriteLine(Enumerable.Range(1, k).Select(i => long.Parse(new string(i.ToString().ToArray().Concat(i.ToString().Reverse()).ToArray())) % p).Sum() % p);\n }\n }\n}", "lang_cluster": "C#", "tags": ["brute force"], "code_uid": "7b81000f603ea1d1f4ad4e223c79068a", "src_uid": "00e90909a77ce9e22bb7cbf1285b0609", "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 ConsoleApp2\n{\n class Program\n {\n static void Main(string[] args)\n {\n string[] str = Console.ReadLine().Split(' ');\n long n = Convert.ToInt64(str[0]);\n long k = Convert.ToInt64(str[1]);\n\n if ((n/k)%2==0) { Console.WriteLine(\"NO\"); } else { Console.WriteLine(\"YES\"); }\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "games"], "code_uid": "c5e64e41a439b4faa4875483fb8818bd", "src_uid": "05fd61dd0b1f50f154eec85d8cfaad50", "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 Diplomi\n{\n class Program\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 x = n / (2 * (k + 1));\n\n Console.WriteLine(\"{0} {1} {2}\", x, k * x, n - (k + 1) * x);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "implementation"], "code_uid": "d64ee2d72d6ffb144108f2c349a8716c", "src_uid": "405a70c3b3f1561a9546910ab3fb5c80", "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 CF {\n class Program {\n static int n;\n static int[ ] t;\n\n static int f( ) {\n if ( t[ 0 ] > 15 )\n return 15;\n int ant = t[ 0 ];\n for ( int i = 1; i < n; i++ ) {\n if ( t[ i ] - ant > 15 ) {\n return Math.Min( 90, ant + 15 );\n }\n ant = t[ i ];\n }\n if ( 90 - ant > 15 ) {\n return ant + 15;\n }\n return 90;\n }\n\n static void solve( ) {\n n = int.Parse( Console.ReadLine( ) );\n t = Array.ConvertAll( Console.ReadLine( ).Split( ' ' ), ts => int.Parse( ts ) );\n\n Console.Write( f( ) );\n }\n\n static void Main( string[ ] args ) {\n solve( );\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "fa183469903ab9ff9699f170242546a0", "src_uid": "5031b15e220f0ff6cc1dd3731ecdbf27", "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 WorldGame\n{\n class Program\n {\n \n\n static void Main(string[] args)\n {\n string a = Console.ReadLine();\n\n string[] sNumbers = a.Split(' ');\n\n Console.WriteLine(int.Parse(sNumbers[1]) + int.Parse(sNumbers[0])+0);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["dsu", "constructive algorithms", "implementation", "brute force"], "code_uid": "18818aa3eff896e34c28aec9bcae0d0f", "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.Collections;\n\nnamespace a2oj\n{\n class Program\n {\n\n \n static void Main(string[] args)\n {\n List len = new List();\n for (int i = 0; i < 4; i++)\n {\n len.Add(Console.ReadLine().Split('.')[1].Length); \n }\n int[] len1 = new int[4];\n List list = new List();\n \n len.CopyTo(len1);\n list = len1.ToList();\n len.Sort();\n //foreach (var item in len)\n //{\n // Console.WriteLine(item);\n //}\n if (len[0] * 2 <= len[1] && len[2] * 2 <= len[3])\n {\n Console.WriteLine(\"C\"); return;\n }\n if(len[0]*2<=len[1])\n {\n switch (list.IndexOf(len[0])+1)\n {\n case 1:\n Console.WriteLine(\"A\");\n break;\n case 2:\n Console.WriteLine(\"B\");\n break;\n case 3:\n Console.WriteLine(\"C\");\n break;\n case 4:\n Console.WriteLine(\"D\");\n break;\n }\n //Console.ReadKey();\n return;\n }\n if (len[2] * 2 <= len[3])\n {\n switch (list.IndexOf(len[3])+1)\n {\n case 1:\n Console.WriteLine(\"A\");\n break;\n case 2:\n Console.WriteLine(\"B\");\n break;\n case 3:\n Console.WriteLine(\"C\");\n break;\n case 4:\n Console.WriteLine(\"D\");\n break;\n }\n //Console.ReadKey();\n return;\n }\n Console.WriteLine(\"C\");\n \n //Console.ReadKey();\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "b7f5f976d832ec370d12fe4aac1142ec", "src_uid": "30725e340dc07f552f0cce359af226a4", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\n\nnamespace D {\n internal class Program {\n private static void Main() {\n int x, y, z, x1, y1, z1, a1, a2, a3, a4, a5, a6;\n var line1 = Console.ReadLine().Split(' ');\n x = Convert.ToInt32(line1[0]);\n y = Convert.ToInt32(line1[1]);\n z = Convert.ToInt32(line1[2]);\n var line2 = Console.ReadLine().Split(' ');\n x1 = Convert.ToInt32(line2[0]);\n y1 = Convert.ToInt32(line2[1]);\n z1 = Convert.ToInt32(line2[2]);\n var line3 = Console.ReadLine().Split(' ');\n a1 = Convert.ToInt32(line3[0]);\n a2 = Convert.ToInt32(line3[1]);\n a3 = Convert.ToInt32(line3[2]);\n a4 = Convert.ToInt32(line3[3]);\n a5 = Convert.ToInt32(line3[4]);\n a6 = Convert.ToInt32(line3[5]);\n\n var res = 0;\n\n if (x > x1) {\n res += a6;\n }\n\n if (x < 0) {\n res += a5;\n }\n\n if (y > y1) {\n res += a2;\n }\n\n if (y < 0) {\n res += a1;\n }\n\n if (z > z1) {\n res += a4;\n }\n\n if (z < 0) {\n res += a3;\n }\n\n Console.WriteLine(res);\n }\n }\n}", "lang_cluster": "C#", "tags": ["brute force", "geometry"], "code_uid": "715441f66415873cc977d2fcabfa5241", "src_uid": "c7889a8f64c57cf7be4df870f68f749e", "difficulty": 1600.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\n public static class ListExtensions\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\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, T val)\n {\n for (int i = 0; i < self.Count; i++)\n {\n self[i] = val;\n }\n\n return self;\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 s = io.NextLine().Select(x => x - '0').ToArray();\n\n var max = -1;\n\n if (s.Length > 0)\n {\n for (int i = 1; i <= 7; i++)\n {\n for (int j = 1; j <= 7; j++)\n {\n for (int k = 1; k <= 7; k++)\n {\n if (i + j + k != s.Length)\n continue;\n\n var n1 = 0;\n var x = 1;\n\n for (int l = 1; l <= i; l++)\n {\n n1 += s[i - l]*x;\n x *= 10;\n }\n\n\n if (n1 > 1000000 || (n1 > 0 && n1 < x / 10) || (n1 == 0 && x > 10))\n continue;\n\n\n var n2 = 0;\n x = 1;\n\n for (int l = 1; l <= j; l++)\n {\n n2 += s[i + j - l]*x;\n x *= 10;\n }\n\n\n\n if (n2 > 1000000 || (n2 > 0 && n2 < x / 10) || (n2 == 0 && x > 10))\n continue;\n\n\n var n3 = 0;\n x = 1;\n\n for (int l = 1; l <= k; l++)\n {\n n3 += s[i + j + k - l]*x;\n x *= 10;\n }\n\n\n if (n3 > 1000000 || (n3 > 0 && n3 < x / 10) || (n3 == 0 && x > 10))\n continue;\n\n\n max = Math.Max(max, n1 + n2 + n3);\n }\n }\n }\n }\n\n io.Print(max);\n }\n }\n\n}\n\n", "lang_cluster": "C#", "tags": ["brute force", "implementation"], "code_uid": "b8eca4fbe2da5e7467d3e8f1b5f9a98e", "src_uid": "bf4e72636bd1998ad3d034ad72e63097", "difficulty": 1400.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;\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 A = sc.LongArray();\n\n /*\n * A\u304b\u3089\u3044\u304f\u3064\u304b\u9078\u3093\u3067 Mod M\u304c\u6700\u5927\u306b\u306a\u308b\u3088\u3046\u306b\u3059\u308b\n */\n\n var left = Calc(0, N / 2);\n var right = Calc(N / 2, N);\n long ans = ((left.Last() + right.Last()) % M);\n foreach (int i in left)\n {\n // i + right[j] \u304cM\u672a\u6e80\u6700\u5927\n // \n int ok = 0;\n int ng = right.Count;\n while(ng - ok > 1)\n {\n int mid = (ok + ng) / 2;\n if (i + right[mid] < M) ok = mid;\n else ng = mid;\n }\n ans = Math.Max(ans, i + right[ok]);\n }\n\n Console.WriteLine(ans);\n }\n\n List Calc(int b, int e)\n {\n var ls = new List();\n ls.Add(0);\n\n for (int i = b; i < e; i++)\n {\n int len = ls.Count;\n for (int j = 0; j < len; j++)\n {\n ls.Add((ls[j] + A[i]) % M);\n }\n }\n\n var result = new List();\n ls.Sort();\n for (int i = 0; i < ls.Count; i++)\n {\n if (i == 0 || ls[i - 1] != ls[i])\n {\n result.Add(ls[i]);\n }\n }\n\n return result;\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": ["meet-in-the-middle", "divide and conquer", "bitmasks"], "code_uid": "21263bb7680e7ac50fbedd554e7e3f44", "src_uid": "d3a8a3e69a55936ee33aedd66e5b7f4a", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\n\nnamespace Task3 {\n internal class Program {\n private static void Main(string[] args) {\n string s = Console.ReadLine();\n string[] ss = s.Split(' ');\n long a = int.Parse(ss[0]);\n long b = int.Parse(ss[1]);\n long t = GetLCM(a, b);\n string s1 = \"Dasha\";\n string s2 = \"Masha\";\n if (a < b) {\n string temp = s1;\n s1 = s2;\n s2 = temp;\n long tt = a;\n a = b;\n b = tt;\n }\n long first = 0;\n long previous = 0;\n long next = a;\n while (next <= t) {\n long k = (next/b)*b;\n first += k - previous;\n\n previous = next;\n next = next + a;\n }\n first -= b;\n long second = t - first;\n if (first < second) Console.WriteLine(s1);\n else if (second < first) Console.WriteLine(s2);\n else Console.WriteLine(\"Equal\");\n }\n\n public static long GetLCM(long a, long b) {\n return Math.Abs(a*b)/GetGCD(a, b);\n }\n\n public static long GetGCD(long a, long b) {\n while (a != 0 && b != 0) {\n if (a >= b) a = a%b;\n else b = b%a;\n }\n return a + b;\n }\n }\n}", "lang_cluster": "C#", "tags": ["math", "implementation", "number theory"], "code_uid": "32b37a1a469f4c5381bc8c1dee5131dc", "src_uid": "06eb66df61ff5d61d678bbb3bb6553cc", "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 A.\u0413\u0430\u0437\u0438\u0440\u043e\u0432\u043a\u043e\u043f\u0438\u0442\u0438\u0435\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 l = Convert.ToInt32(s[2]);\n int c = Convert.ToInt32(s[3]);\n int d = Convert.ToInt32(s[4]);\n int p = Convert.ToInt32(s[5]);\n int nl = Convert.ToInt32(s[6]);\n int np = Convert.ToInt32(s[7]);\n int gaz = (k * l) / nl;\n int lime = c * d;\n int salt = p / np;\n Tosti(gaz,lime,salt,n);\n }\n\n static void Tosti(int gaz, int lime, int salt, int chelov)\n {\n int min1=1000000;\n int[] min = new int[3];\n min[0] = gaz;\n min[1] = lime;\n min[2] = salt;\n for (int i = 0; i < 3; i++)\n if (min[i] < min1)\n min1 = min[i];\n Console.WriteLine(min1/chelov);\n }\n\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "implementation"], "code_uid": "435e7b7406b6f81a4ab3643c9ce01ab0", "src_uid": "67410b7d36b9d2e6a97ca5c7cff317c1", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Text;\n\nnamespace Task\n{\n class Program\n {\n static void Main(string[] args)\n {\n int n, pos, l, r;\n string[] split = Console.ReadLine().Split(' ');\n n = int.Parse(split[0]);\n pos = int.Parse(split[1]);\n l = int.Parse(split[2]);\n r = int.Parse(split[3]);\n\n int ans = 0;\n if (pos < l)\n {\n ans += l - pos;\n pos = l;\n }\n if (pos > r)\n {\n ans += pos - r;\n pos = r;\n }\n\n if (l == 1)\n {\n if (r == n) { }\n else\n {\n ans++;\n ans += r - pos;\n }\n } else if (r == n)\n {\n ans++;\n ans += pos - l;\n }\n else\n {\n ans += 2;\n ans += r - l;\n ans += Math.Min(pos - l, r - pos);\n }\n Console.WriteLine(ans);\n\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "4e3b4afb9389a445ceb6b23772560834", "src_uid": "5deaac7bd3afedee9b10e61997940f78", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nclass Program\n{\n static void Main()\n {\n string s = Console.ReadLine();\n int i = 0;\n for (i = s.Length - 2; !Char.IsLetter(s[i]); i--) { }\n Console.WriteLine(Array.IndexOf(new char[] { 'a', 'e', 'i', 'o', 'u', 'y' }, Char.ToLower(s[i])) != -1 ? \"YES\" : \"NO\");\n }\n}", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "89ef062a7bf5faaf80ad5f5e02874bcb", "src_uid": "dea7eb04e086a4c1b3924eff255b9648", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "/*\n * \u0423 \u041d\u0438\u043a\u043e\u043b\u0430\u044f \u0435\u0441\u0442\u044c \u043c\u0430\u0441\u0441\u0438\u0432 a, \u0441\u043e\u0441\u0442\u043e\u044f\u0449\u0438\u0439 \u0438\u0437 n \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u0446\u0435\u043b\u044b\u0445 \u0447\u0438\u0441\u0435\u043b \u043e\u0442 1 \u0434\u043e n. \u0414\u0440\u0443\u0433\u0438\u043c\u0438 \u0441\u043b\u043e\u0432\u0430\u043c\u0438, \u043c\u0430\u0441\u0441\u0438\u0432 \u041d\u0438\u043a\u043e\u043b\u0430\u044f \u2014 \u044d\u0442\u043e \u043f\u0435\u0440\u0435\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 \u0446\u0435\u043b\u044b\u0445 \u0447\u0438\u0441\u0435\u043b \u043e\u0442 1 \u0434\u043e n.\n * \u041d\u0438\u043a\u043e\u043b\u0430\u0439 \u0440\u0435\u0448\u0438\u043b, \u0447\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u043b\u0443\u0447\u0448\u0435, \u0435\u0441\u043b\u0438 \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0435\u0433\u043e \u043c\u0430\u0441\u0441\u0438\u0432\u0430 (\u0442\u043e \u0435\u0441\u0442\u044c \u0447\u0438\u0441\u043b\u043e 1) \u0438 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0435\u0433\u043e \u043c\u0430\u0441\u0441\u0438\u0432\u0430 (\u0442\u043e \u0435\u0441\u0442\u044c \u0447\u0438\u0441\u043b\u043e n) \u0431\u0443\u0434\u0443\u0442 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u044c\u0441\u044f \u043a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u0434\u0430\u043b\u044c\u0448\u0435 \n * \u0434\u0440\u0443\u0433 \u043e\u0442 \u0434\u0440\u0443\u0433\u0430. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043e\u043d \u0440\u0435\u0448\u0438\u043b \u0440\u043e\u0432\u043d\u043e \u043e\u0434\u0438\u043d \u0440\u0430\u0437 \u043f\u043e\u043c\u0435\u043d\u044f\u0442\u044c \u043c\u0435\u0441\u0442\u0430\u043c\u0438 \u0434\u0432\u0430 \u043a\u0430\u043a\u0438\u0445-\u043d\u0438\u0431\u0443\u0434\u044c \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u0442\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u0447\u0442\u043e\u0431\u044b \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u043c\u0435\u0436\u0434\u0443 \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u043c \u0438 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u043c \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u043c\u0438 \u0441\u0442\u0430\u043b\u043e \n * \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u043c. \u0420\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u0435\u043c \u043c\u0435\u0436\u0434\u0443 \u0434\u0432\u0443\u043c\u044f \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u043c\u0438 \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043c\u043e\u0434\u0443\u043b\u044c \u0440\u0430\u0437\u043d\u043e\u0441\u0442\u0438 \u043d\u043e\u043c\u0435\u0440\u043e\u0432 \u043f\u043e\u0437\u0438\u0446\u0438\u0439 \u0434\u0430\u043d\u043d\u044b\u0445 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432.\n * \n * \u0412\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435\n * \u0412 \u043f\u0435\u0440\u0432\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0435 \u0432\u0445\u043e\u0434\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u0446\u0435\u043b\u043e\u0435 \u043f\u043e\u043b\u043e\u0436\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0435 \u0447\u0438\u0441\u043b\u043e n (2\u2009\u2264\u2009n\u2009\u2264\u2009100) \u2014 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u0432 \u043c\u0430\u0441\u0441\u0438\u0432\u0435 \u041d\u0438\u043a\u043e\u043b\u0430\u044f.\n * \u0412\u043e \u0432\u0442\u043e\u0440\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0435 \u0432\u0445\u043e\u0434\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u0437\u0430\u043f\u0438\u0441\u0430\u043d\u044b \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u0446\u0435\u043b\u044b\u0435 \u0447\u0438\u0441\u043b\u0430 a1,\u2009a2,\u2009...,\u2009an (1\u2009\u2264\u2009ai\u2009\u2264\u2009n), \u0433\u0434\u0435 ai \u0440\u0430\u0432\u043d\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0443, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0432 i-\u0439 \u043f\u043e\u0437\u0438\u0446\u0438\u0438 \u0432 \u043c\u0430\u0441\u0441\u0438\u0432\u0435 \u041d\u0438\u043a\u043e\u043b\u0430\u044f.\n * \n * \u0412\u044b\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435\n * \u0412\u044b\u0432\u0435\u0434\u0438\u0442\u0435 \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0435 \u0446\u0435\u043b\u043e\u0435 \u0447\u0438\u0441\u043b\u043e \u2014 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u043c\u0435\u0436\u0434\u0443 \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u043c \u0438 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u043c \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u043c\u0438 \u0432 \u043c\u0430\u0441\u0441\u0438\u0432\u0435 \u041d\u0438\u043a\u043e\u043b\u0430\u044f, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043e \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0440\u043e\u0432\u043d\u043e \u043e\u0434\u043d\u043e\u0433\u043e \n * \u043e\u0431\u043c\u0435\u043d\u0430 \u043c\u0435\u0441\u0442\u0430\u043c\u0438 \u0434\u0432\u0443\u0445 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u043c\u0430\u0441\u0441\u0438\u0432\u0430.\n * \n * \u041f\u0440\u0438\u043c\u0435\u0440\u044b\n * \u0412\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435\n * 5\n * 4 5 1 3 2\n * \u0412\u044b\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435\n * 3\n * \n * \u0412\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435\n * 7\n * 1 6 5 3 4 7 2\n * \u0412\u044b\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435\n * 6\n * \n * \u0412\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435\n * 6\n * 6 5 4 3 2 1\n * \u0412\u044b\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435\n * 5\n * \n * #\u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f\n*/ \nusing System;\n\nnamespace A\n{\n\tclass MainClass\n\t{\n\t\tstatic int search(ref int[] a, int elem)\n\t\t{\n\t\t\tfor (int i = 0; i < a.Length; ++i) {\n\t\t\t\tif (a [i] == elem)\n\t\t\t\t\treturn i;\n\t\t\t}\n\t\t\treturn -1;\n\t\t}\n\t\tpublic static void Main (string[] args)\n\t\t{\n\t\t\tint n = int.Parse (Console.ReadLine ());\n\t\t\tint i;\n\t\t\tint[] mas = new int[n];\n\t\t\tint pos_first, pos_last;\n\t\t\tint max_offset_first, max_offset_last;\n\t\t\tint max;\n\t\t\tvar str = Console.ReadLine ().Split (new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);\n\t\t\tfor (i = 0; i < n; ++i) {\n\t\t\t\tmas [i] = int.Parse (str [i]);\n\t\t\t}\n\t\t\tpos_first = search (ref mas, 1);\n\t\t\tmax_offset_first = Math.Max(pos_first, n-1 - pos_first) ;\n\t\t\tpos_last = search (ref mas, n);\n\t\t\tmax_offset_last = Math.Max (pos_last, n - 1 - pos_last);\n\t\t\tmax = Math.Max (max_offset_first, max_offset_last);\n\n\t\t\tConsole.Write (max);\n\t\t}\n\t}\n}\n", "lang_cluster": "C#", "tags": ["constructive algorithms", "implementation"], "code_uid": "64d71f24758d7563dceacb73b1b94562", "src_uid": "1d2b81ce842f8c97656d96bddff4e8b4", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\n\npublic class Solution\n{\n static void Main(String[] args)\n {\n int n = int.Parse(Console.ReadLine());\n if (n == 1)\n {\n Console.WriteLine(n);\n }\n else if (n == 2)\n {\n Console.WriteLine(n);\n }\n else\n {\n Console.WriteLine(1);\n }\n }\n}", "lang_cluster": "C#", "tags": ["math", "constructive algorithms"], "code_uid": "f18dbcdea398f67facd35442540fc07b", "src_uid": "c30b372a9cc0df4948dca48ef4c5d80d", "difficulty": 800.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;\nnamespace Program\n{\n public class Solver\n {\n public void Solve()\n {\n var n = sc.Integer();\n var k = sc.Integer();\n var dp = new ModInteger[n + 1];\n dp[1] = 1;\n for (int _ = 0; _ < k; _++)\n {\n var next = new ModInteger[n + 1];\n for (int i = 1; i <= n; i++)\n {\n for (int j = i; j <= n; j += i)\n next[j] += dp[i];\n }\n dp = next;\n //IO.Printer.Out.WriteLine(dp.AsJoinedString());\n }\n ModInteger sum = 0;\n for (int i = 1; i <= n; i++)\n sum += dp[i];\n IO.Printer.Out.WriteLine(sum);\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 != '-' && (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#region ModNumber\npublic partial struct ModInteger\n{\n public const long Mod = (long)1e9 + 7;\n public long num;\n public ModInteger(long n) : this() { num = n % Mod; if (num < 0) num += Mod; }\n public override string ToString() { return num.ToString(); }\n public static ModInteger operator +(ModInteger l, ModInteger r) { var n = l.num + r.num; if (n >= Mod) n -= Mod; return new ModInteger() { num = n }; }\n public static ModInteger operator -(ModInteger l, ModInteger r) { var n = l.num + Mod - r.num; if (n >= Mod) n -= Mod; return new ModInteger() { num = n }; }\n public static ModInteger operator *(ModInteger l, ModInteger r) { return new ModInteger(l.num * r.num); }\n public static implicit operator ModInteger(long n) { return new ModInteger(n); }\n}\n#endregion", "lang_cluster": "C#", "tags": ["dp", "combinatorics", "number theory"], "code_uid": "a5a4125e7b6f78f0e4ec155287b220a7", "src_uid": "c8cbd155d9f20563d37537ef68dde5aa", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\n\n\nnamespace ConsoleApp8\n{\n class Program\n {\n static ulong meth(ulong n)\n {\n ulong i = 1;\n while ((n /= 10) > 0)\n {\n i++;\n }\n return i;\n }\n\n static ulong sum(ulong x) \n {\n ulong sum = 0;\n while (x / 1 > 0)\n {\n sum += x % 10;\n x /= 10;\n }\n return sum;\n }\n static void Main(string[] args)\n {\n ulong n = ulong.Parse(Console.ReadLine());\n\n ulong v, t, x;\n \n ulong y = 10;\n t = meth(n);\n x = n;\n for (ulong i = 1; i < t; i++)\n {\n ulong b = y * 10;\n v = (n / b) * b + (n % b / y - 1) * y + y - 1;\n if (sum(v) > sum(x))\n x = v;\n y *= 10;\n }\n Console.WriteLine(x);\n \n \n }\n \n }\n}\n", "lang_cluster": "C#", "tags": ["math", "implementation"], "code_uid": "e4e84ad7488ffefb75b9c6d876d384ee", "src_uid": "e55b0debbf33c266091e6634494356b8", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.IO;\nusing System.Text;\n\nnamespace Giga_Tower\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 c = 0;\n do\n {\n a++;\n c++;\n } while (!a.ToString().Contains(\"8\"));\n\n writer.WriteLine(c);\n writer.Flush();\n }\n\n private static int Next()\n {\n int c;\n int res = 0;\n int m = 1;\n do\n {\n c = reader.Read();\n if (c == '-')\n m = -1;\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 m*res;\n res *= 10;\n res += c - '0';\n }\n }\n }\n}", "lang_cluster": "C#", "tags": ["brute force"], "code_uid": "0084bf9c74d4bfda057af951c3c13ed8", "src_uid": "4e57740be015963c190e0bfe1ab74cb9", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Text;\n\nnamespace ConsoleApplication46\n{\n class Program\n {\n static void Main(string[] args)\n {\n List strList = new List();\n List strList2 = new List();\n\n for (int x = 0; x < 8; x++) {\n\n strList.Add(Console.ReadLine());\n }\n\n\n //Ideal\n strList2.Add(\"WBWBWBWB\");\n strList2.Add(\"BWBWBWBW\");\n strList2.Add(\"WBWBWBWB\");//\n strList2.Add(\"BWBWBWBW\");\n strList2.Add(\"WBWBWBWB\");\n strList2.Add(\"BWBWBWBW\");\n strList2.Add(\"WBWBWBWB\");\n strList2.Add(\"BWBWBWBW\");\n\n bool b = true;\n \n for (int x = 0; x < 8; x++) \n { \n if (strList[x].ToString()!=strList2[x].ToString())\n { \n if (cambia(strList[x].ToString()).ToString()==strList2[x].ToString())\n { \n //Console.WriteLine(cambia(strList[x].ToString()).ToString() +\" \"+ strList2[x].ToString());\n }\n else\n {\n //Console.WriteLine(\"si\");\n b = false;\n break;\n }\n }\n }\n\n if (b)\n {\n Console.WriteLine(\"YES\");\n }\n else\n {\n Console.WriteLine(\"NO\");\n }\n\n\n Console.ReadLine();\n\n }\n\n static StringBuilder cambia(string str){\n\n StringBuilder sb = new StringBuilder();\n\n for (int x = 1; x < str.Length; x++)\n {\n sb.Append(str[x].ToString());\n }\n sb.Append(str[0].ToString());\n\n return sb;\n \n }\n\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "strings"], "code_uid": "fd1ba478fb08c1563e9050a8f668d3ef", "src_uid": "ca65e023be092b2ce25599f52acc1a67", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\n\nnamespace FoxAndBoxAccumulation\n{\n partial class FoxAndBoxAccumulation\n {\n static void Main(string[] args)\n {\n int n, current;\n int[] strengths;\n bool added = false;\n List pilesCount = new List();\n\n n = NextInt();\n strengths = new int[n];\n\n for (int i = 0; i < n; i++)\n strengths[i] = NextInt();\n\n Array.Sort(strengths);\n pilesCount.Add(1);\n\n for (int i = 1; i < n; i++)\n {\n current = strengths[i];\n added = false;\n\n for (int j = 0; j < pilesCount.Count; j++)\n {\n if (current >= pilesCount[j])\n {\n pilesCount[j]++;\n added = true;\n break;\n }\n }\n\n if (!added)\n pilesCount.Add(1);\n }\n\n Console.WriteLine(pilesCount.Count);\n }\n }\n\n partial class FoxAndBoxAccumulation\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": ["greedy", "dp", "binary search"], "code_uid": "9e9529873db316630a4b9c4385cb8001", "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.Text;\nusing System.Threading.Tasks;\n\nnamespace ConsoleApp1\n{\n class Program\n {\n public static string solve(string t)\n {\n foreach(char x in t)\n {\n if (!(x == '4' || x == '7'))\n return \"NO\";\n }\n int left = 0;\n int right = 0;\n for(int i=0;i=k; j--)\n {\n char c = m[j];\n m[j] = m[k];\n m[k] = c;\n k++;\n }\n }\n }\n foreach (var e in m) Write(e);\n return 0;\n }\n\n\n }\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "f0d460683ac319cf20dbefaf0260516e", "src_uid": "1b0b2ee44c63cb0634cb63f2ad65cdd3", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\n\nnamespace Company\n{\n class Program\n {\n static void Main(string[] args)\n {\n int n = int.Parse(Console.ReadLine());\n int result = 0, half = n / 2;\n for (int i = 1; i <= half; ++i)\n {\n if ((n - i) % i == 0)\n {\n ++result;\n }\n }\n Console.WriteLine(result);\n //Console.ReadKey();\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "implementation"], "code_uid": "d06a1c9955aa9e6a98429cb12cf575ab", "src_uid": "89f6c1659e5addbf909eddedb785d894", "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 CodeForces\n{\n class Program\n {\n static void Main(string[] args)\n {\n //int[] arr = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();\n\n string ans = \"\";\n int n = int.Parse(Console.ReadLine());\n string s = Console.ReadLine();\n\n if (s.Count(c => c == '1') == 0)\n {\n Console.WriteLine(0);\n }\n else\n {\n int start = s.IndexOf('1');\n int zeros = 0;\n for (int i = start; i < s.Length; i++)\n if (s[i] == '0')\n zeros++;\n\n ans = ans + \"1\";\n while (zeros != 0)\n {\n ans += \"0\";\n zeros--;\n }\n\n Console.WriteLine(ans);\n }\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "3aba60170d3c912b7b453e398a107824", "src_uid": "ac244791f8b648d672ed3de32ce0074d", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\n\nnamespace _777A\n{\n class Program\n {\n static void Main(string[] args)\n {\n int n = int.Parse(Console.ReadLine());\n int x = int.Parse(Console.ReadLine());\n int result = 0;\n switch (n % 6)\n {\n case 0:\n switch (x)\n {\n case 0:\n result = 0;\n break;\n case 1:\n result = 1;\n break;\n case 2:\n result = 2;\n break;\n }\n break;\n case 1:\n switch (x)\n {\n case 0:\n result = 1;\n break;\n case 1:\n result = 0;\n break;\n case 2:\n result = 2;\n break;\n }\n break;\n case 2:\n switch (x)\n {\n case 0:\n result = 1;\n break;\n case 1:\n result = 2;\n break;\n case 2:\n result = 0;\n break;\n }\n break;\n case 3:\n switch (x)\n {\n case 0:\n result = 2;\n break;\n case 1:\n result = 1;\n break;\n case 2:\n result = 0;\n break;\n }\n break;\n case 4:\n switch (x)\n {\n case 0:\n result = 2;\n break;\n case 1:\n result = 0;\n break;\n case 2:\n result = 1;\n break;\n }\n break;\n case 5:\n switch (x)\n {\n case 0:\n result = 0;\n break;\n case 1:\n result = 2;\n break;\n case 2:\n result = 1;\n break;\n }\n break;\n }\n Console.WriteLine(result);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "constructive algorithms", "implementation"], "code_uid": "73be8b49ad52b5b90fd2475375524aa1", "src_uid": "7853e03d520cd71571a6079cdfc4c4b0", "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;\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 Bit\n {\n private readonly int size;\n private readonly int[] data;\n\n public Bit(int n)\n {\n size = n;\n data = new int[n];\n }\n\n public int PrefixSum(int r)\n {\n int ret = 0;\n for (; r >= 0; r = (r & r + 1) - 1)\n ret += data[r];\n return ret;\n }\n\n public void Update(int idx, int diff)\n {\n for (; idx < size; idx = (idx | idx + 1))\n data[idx] += diff;\n }\n }\n\n long InvCount(int[] a)\n {\n int n = a.Length;\n var bit = new Bit(n + 1);\n long ret = 0;\n for (int i = 0; i < n; i++)\n {\n ret += i - bit.PrefixSum(a[i]);\n bit.Update(a[i], 1);\n }\n return ret;\n }\n\n public void Solve()\n {\n int n = ReadInt();\n int m = ReadInt();\n\n var a = Enumerable.Range(0, n).ToArray();\n for (int i = 0; i < n / 2 && m > 0; i++, m--)\n {\n int t = a[i];\n a[i] = a[n - i - 1];\n a[n - i - 1] = t;\n }\n\n Write(InvCount(a));\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", "greedy"], "code_uid": "487e30508542c327c82e253060a8f8b6", "src_uid": "ea36ca0a3c336424d5b7e1b4c56947b0", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\n//using System.Drawing;\nusing System.Globalization;\nusing System.IO;\nusing System.Linq;\nusing System.Text;\n\n//using System.Threading;\n\nnamespace ReadWriteTemplate\n{\n public static class Solver\n {\n public static void Solve()\n {\n int a = ReadInt();\n int b = ReadInt();\n int c = ReadInt();\n int d = ReadInt();\n\n int N = 1000000;\n bool[] u = new bool[N];\n for (int i = b; i < N; i += a)\n {\n u[i] = true;\n }\n for (int i = d; i < N; i += c)\n {\n if (u[i])\n {\n Writer.WriteLine(i);\n return;\n }\n }\n Writer.WriteLine(-1);\n }\n\n public static void Main()\n {\n //Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;\n\n#if DEBUG\n Reader = File.OpenText(\"input.txt\"); Writer = File.CreateText(\"output.txt\");\n#else\n Reader = Console.In; Writer = Console.Out;\n#endif\n //Reader = File.OpenText(\"concatenation.in\"); Writer = File.CreateText(\"concatenation.out\");\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}", "lang_cluster": "C#", "tags": ["brute force", "math", "number theory"], "code_uid": "7de65f1cb127f569618b373551880564", "src_uid": "158cb12d45f4ee3368b94b2b622693e7", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Linq;\n\nnamespace Codeforces\n{\n public static class Algr\n {\n public static string Solve(string input)\n {\n var array = input.Split(' ')\n .Select(x => Int32.Parse(x))\n .ToArray();\n\n int n = array[0];\n int m = array[1];\n int a = array[2];\n int b = array[3];\n\n double costB = (double) b / m;\n int r = 0;\n\n if (a <= costB)\n {\n r = n * a;\n }\n\n else\n {\n r = (n / m) * b;\n r += Math.Min((n - ((n / m) * m)) * a, b);\n }\n\n return r.ToString();\n }\n }\n\n class Program\n {\n static void Main(string[] args)\n {\n Console.WriteLine(Algr.Solve(Console.ReadLine()));\n }\n }\n}", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "7b7359960c97b134effc987cd51e8476", "src_uid": "faa343ad6028c5a069857a38fa19bb24", "difficulty": 1200.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\tstring s = Console.ReadLine();\n\t\tchar lolo= s[0];\n\t\tint eee = Convert.ToInt16(Convert.ToString(s[1]));\n\t\tint it=8; bool prov=true;\n\t\tif ((lolo=='h')||(lolo=='a'))\n\t\t{\n\t\t\tprov=false;\n\t\t\tit-=3;\n\t\t}\n\t\tif ((eee==1)||(eee==8))\n\t\t{\n\t\t\tif (prov) it-=3;\n\t\t\telse it-=2;\n\t\t}\n\t\tConsole.WriteLine(it);\n\t}\n}", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "54b3ff3701dc5d607bd86c96d836d48f", "src_uid": "6994331ca6282669cbb7138eb7e55e01", "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 project\n{\n class Program\n {\n public static void Main(string[] args)\n {\n long X = 10000010 , Y = 1;\n long ansX = 0 , ansY = 0 ;\n string input = Console.ReadLine();\n long x = long.Parse(input.Split(new char[] { ' ' })[0]);\n long y = long.Parse(input.Split(new char[] { ' ' })[1]);\n long n = long.Parse(input.Split(new char[] { ' ' })[2]);\n for (long i = 1; i <= n; i++)\n {\n bool flag = true;\n long tx, ty , t;\n ty = i * y;\n t = i * x / y;\n tx = Math.Min(Math.Abs(i * x - t * y), Math.Abs(i * x - (t + 1) * y));\n if (tx != Math.Abs(i * x - t * y))\n flag = false;\n if (tx * Y < ty * X)\n {\n X = tx;\n Y = ty;\n if (flag == true)\n ansX = t;\n else\n ansX = t + 1;\n ansY = i;\n }\n }\n Console.WriteLine(ansX + \"/\" + ansY);\n }\n }\n}", "lang_cluster": "C#", "tags": ["two pointers", "implementation", "brute force"], "code_uid": "f7b069b8e83315d4ea0a08d46b60b336", "src_uid": "827bc6f120aff6a6f04271bc84e863ee", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "// Author : Suvash Kumar Sumon\n\nusing System;\n\nnamespace CS_Repo\n{\n class Program2\n {\n static void Main(string [] args)\n {\n int n = int.Parse(Console.ReadLine());\n var raw = Console.ReadLine().Split();\n int a;\n int sum = 0, b = -1, q = 0;\n for (int i = 0; i < n; i++)\n {\n a = int.Parse(raw[i]);\n sum += a;\n q += 1 - 2 * a;\n\t\t b = Math.Max(b, q);\n\t\t q = Math.Max(0, q);\n }\n Console.WriteLine(sum+b); \n }\n }\n \n}", "lang_cluster": "C#", "tags": ["brute force", "dp", "implementation"], "code_uid": "6c6369f1adb436bbe39479e680df34ca", "src_uid": "9b543e07e805fe1dd8fa869d5d7c8b99", "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 ConsoleApplication5\n{\n class Program\n {\n\n static void Main(string[] args)\n {\n Console.ReadLine();\n string simple = \n \"31 28 31 30 31 30 31 31 30 31 30 31 \"+\n \"31 28 31 30 31 30 31 31 30 31 30 31 \"+\n \"31 28 31 30 31 30 31 31 30 31 30 31 \" +\n \"31 29 31 30 31 30 31 31 30 31 30 31 \"+\n \"31 28 31 30 31 30 31 31 30 31 30 31 \"+\n \"31 28 31 30 31 30 31 31 30 31 30 31\" ;\n string s = Console.ReadLine();\n if(simple.Contains(s))\n Console.WriteLine(\"YES\");\n else Console.WriteLine(\"NO\");\n }\n \n \n }\n}", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "56771704e0406b84ee212cbadc2ed398", "src_uid": "d60c8895cebcc5d0c6459238edbdb945", "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 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 long l = int.Parse(str[0]);\n long r = int.Parse(str[1]);\n long x = int.Parse(str[2]);\n long y = int.Parse(str[3]);\n long k = int.Parse(str[4]);\n for(long i=x;i<=y;i++){\n if(l <= i*k && i*k <= r){\n sb.Append(\"YES\\n\");\n return;\n }\n }\n sb.Append(\"NO\\n\");\n }\n}", "lang_cluster": "C#", "tags": ["two pointers", "brute force"], "code_uid": "1f0eb418760920a9200b6c6d9d05c85e", "src_uid": "1110d3671e9f77fd8d66dca6e74d2048", "difficulty": 1200.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=Convert.ToInt32(Console.ReadLine());\n\t\tstring s=Console.ReadLine();\n\t\tstring[] p={\"vaporeon\", \"jolteon\", \"flareon\", \"espeon\", \"umbreon\", \"leafeon\", \"glaceon\", \"sylveon\"};\n\t\tint q=0;\n\t\tvar qq=s.Where(x=>x!='.').Count();\n\t\tfor(int i=0; i<8; i++)\n\t\t{\n\t\t\tif(p[i].Length==n)\n\t\t\t{\t\n\t\t\t\tvar ch=p[i].ToCharArray();\n\t\t\t\t\tfor(int l=0; l= 0)\n IO.Printer.Out.WriteLine(\"YES\");\n else IO.Printer.Out.WriteLine(\"NO\");\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": ["math"], "code_uid": "e79918691605af55712b35aa860dde17", "src_uid": "9edf42c20ddf22a251b84553d7305a7d", "difficulty": 1100.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 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 m = NN;\n var dp = new LIB_Mod[m + 1];\n LIB_Mod ans = 1;\n var fact = new long[m + 1];\n var factd = new long[m + 1];\n for (var i = 2; i <= m; i++)\n {\n LIB_Mod space = (m - m / i);\n dp[i] = m / space;\n foreach (var item in LIB_Math.Divisor(i))\n {\n if (item == 1 || item == i) continue;\n var ceil = m / item;\n LIB_Mod coef = 0;\n foreach (var item2 in LIB_Math.Divisor(i / item))\n {\n if (fact[item2] == 0)\n {\n var ary = LIB_Math.Factors(item2).ToArray();\n fact[item2] = ary.Length;\n factd[item2] = ary.Distinct().Count();\n }\n if (fact[item2] == factd[item2])\n {\n if (fact[item2] % 2 == 1)\n {\n coef -= ceil / item2;\n }\n else\n {\n coef += ceil / item2;\n }\n }\n }\n dp[i] += dp[item] * coef / space;\n }\n ans += dp[i] / m;\n }\n Console.WriteLine(ans);\n }\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 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 public void Main(string[] args) { if (args.Length == 0) { Console.SetOut(new Printer(Console.OpenStandardOutput())); } var t = new Thread(Solve, 134217728); t.Start(); t.Join(); Console.Out.Flush(); }\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 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_Math\n {\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n static public IEnumerable Primes(long x)\n {\n if (x < 2) yield break;\n yield return 2;\n var halfx = x / 2;\n var table = new bool[halfx + 1];\n var max = (long)(Math.Sqrt(x) / 2);\n for (long i = 1; i <= max; ++i)\n {\n if (table[i]) continue;\n var add = 2 * i + 1;\n yield return add;\n for (long j = 2 * i * (i + 1); j <= halfx; j += add)\n table[j] = true;\n }\n for (long i = max + 1; i <= halfx; ++i)\n if (!table[i] && 2 * i + 1 <= x)\n yield return 2 * i + 1;\n }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n static public IEnumerable Factors(long x)\n {\n if (x < 2) yield break;\n while (x % 2 == 0)\n {\n x /= 2; yield return 2;\n }\n var max = (long)Math.Sqrt(x);\n for (long i = 3; i <= max; i += 2)\n {\n while (x % i == 0)\n {\n x /= i; yield return i;\n }\n }\n if (x != 1) yield return x;\n }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n static public IEnumerable Divisor(long x)\n {\n if (x < 1) yield break;\n var max = (long)Math.Sqrt(x);\n for (long i = 1; i <= max; ++i)\n {\n if (x % i != 0) continue;\n yield return i;\n if (i != x / i) yield return x / i;\n }\n }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n static public long GCD(long a, long b)\n {\n while (b > 0)\n {\n var tmp = b;\n b = a % b;\n a = tmp;\n }\n return a;\n }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n static public long LCM(long a, long b) => a / GCD(a, b) * b;\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n static public long Pow(long x, long y)\n {\n long a = 1;\n while (y != 0)\n {\n if ((y & 1) == 1) a *= x;\n x *= x;\n y >>= 1;\n }\n return a;\n }\n static List _fact = new List() { 1 };\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n static void Build(long n)\n {\n if (n >= _fact.Count)\n for (int i = _fact.Count; i <= n; ++i) _fact.Add(_fact[i - 1] * i);\n }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n static public long Comb(long n, long k)\n {\n Build(n);\n if (n == 0 && k == 0) return 1;\n if (n < k || n < 0) return 0;\n return _fact[(int)n] / _fact[(int)(n - k)] / _fact[(int)k];\n }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n static public long Perm(long n, long k)\n {\n Build(n);\n if (n == 0 && k == 0) return 1;\n if (n < k || n < 0) return 0;\n return _fact[(int)n] / _fact[(int)(n - k)];\n }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n static public IEnumerable> MakePermutation(long n, bool zeroIndexed = true)\n {\n if (n <= 0) throw new Exception();\n var c = new int[n];\n var a = new int[n];\n if (!zeroIndexed) a[0] = 1;\n for (var i = 1; i < n; i++) a[i] = a[i - 1] + 1;\n yield return new List(a);\n for (var i = 0; i < n;)\n {\n if (c[i] < i)\n {\n if (i % 2 == 0)\n {\n var t = a[0]; a[0] = a[i]; a[i] = t;\n }\n else\n {\n var t = a[c[i]]; a[c[i]] = a[i]; a[i] = t;\n }\n yield return new List(a);\n ++c[i];\n i = 0;\n }\n else\n {\n c[i] = 0;\n ++i;\n }\n }\n }\n }\n struct LIB_Mod : IEquatable, IEquatable\n {\n static public long _mod = 1000000007; long v;\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public LIB_Mod(long x)\n {\n if (x < _mod && x >= 0) v = x;\n else if ((v = x % _mod) < 0) v += _mod;\n }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n static public implicit operator LIB_Mod(long x) => new LIB_Mod(x);\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n static public implicit operator long(LIB_Mod x) => x.v;\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public void Add(LIB_Mod x) { if ((v += x.v) >= _mod) v -= _mod; }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public void Sub(LIB_Mod x) { if ((v -= x.v) < 0) v += _mod; }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public void Mul(LIB_Mod x) => v = (v * x.v) % _mod;\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public void Div(LIB_Mod x) => v = (v * Inverse(x.v)) % _mod;\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n static public LIB_Mod operator +(LIB_Mod x, LIB_Mod y) { var t = x.v + y.v; return t >= _mod ? new LIB_Mod { v = t - _mod } : new LIB_Mod { v = t }; }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n static public LIB_Mod operator -(LIB_Mod x, LIB_Mod y) { var t = x.v - y.v; return t < 0 ? new LIB_Mod { v = t + _mod } : new LIB_Mod { v = t }; }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n static public LIB_Mod operator *(LIB_Mod x, LIB_Mod y) => x.v * y.v;\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n static public LIB_Mod operator /(LIB_Mod x, LIB_Mod y) => x.v * Inverse(y.v);\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n static public bool operator ==(LIB_Mod x, LIB_Mod y) => x.v == y.v;\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n static public bool operator !=(LIB_Mod x, LIB_Mod y) => x.v != y.v;\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n static public long Inverse(long x)\n {\n long b = _mod, r = 1, u = 0, t = 0;\n while (b > 0)\n {\n var q = x / b;\n t = u;\n u = r - q * u;\n r = t;\n t = b;\n b = x - q * b;\n x = t;\n }\n return r < 0 ? r + _mod : r;\n }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public bool Equals(LIB_Mod x) => v == x.v;\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public bool Equals(long x) => v == x;\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public override bool Equals(object x) => x == null ? false : Equals((LIB_Mod)x);\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public override int GetHashCode() => v.GetHashCode();\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public override string ToString() => v.ToString();\n static List _fact = new List() { 1 };\n static long _factm = _mod;\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n static void B(long n)\n {\n if (_factm != _mod) _fact = new List() { 1 };\n if (n >= _fact.Count)\n for (int i = _fact.Count; i <= n; ++i)\n _fact.Add(_fact[i - 1] * i);\n _factm = _mod;\n }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n static public LIB_Mod Comb(long n, long k)\n {\n B(n);\n if (n == 0 && k == 0) return 1;\n if (n < k || n < 0) return 0;\n return _fact[(int)n] / _fact[(int)(n - k)] / _fact[(int)k];\n }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n static public LIB_Mod Perm(long n, long k)\n {\n B(n);\n if (n == 0 && k == 0) return 1;\n if (n < k || n < 0) return 0;\n return _fact[(int)n] / _fact[(int)(n - k)];\n }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n static public LIB_Mod Pow(LIB_Mod x, long y)\n {\n LIB_Mod a = 1;\n while (y != 0)\n {\n if ((y & 1) == 1) a.Mul(x);\n x.Mul(x);\n y >>= 1;\n }\n return a;\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "dp", "probabilities", "number theory"], "code_uid": "8a287e8af213e1df1940100d839aab8c", "src_uid": "ff810b16b6f41d57c1c8241ad960cba0", "difficulty": 2300.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 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 = 0;\n\n public override Solver Solve()\n {\n // link to task: http://codeforces.com/problemset/problem/681/C\n\n var input = _reader.ReadIntArray();\n var n = input[0];\n var m = input[1];\n var numbers = new HashSet();\n var maxN = GetMax(n - 1);\n var maxM = GetMax(m - 1);\n\n if (maxN + maxM > 7)\n {\n return this;\n }\n\n for (int i = 0; i < n; i++)\n {\n numbers.Clear();\n if (!ToSeven(i, maxN, numbers)) continue;\n\n for (int j = 0; j < m; j++)\n {\n if (i == j) continue;\n numbers.Clear();\n if (ToSeven(i, maxN, numbers) && ToSeven(j, maxM, numbers))\n {\n result++;\n }\n }\n }\n\n return this;\n }\n\n private int GetMax(int val)\n {\n int i = 0;\n do\n {\n i++;\n val /= 7;\n } while (val > 0);\n return i;\n }\n\n private bool ToSeven(int val, int max, HashSet nums)\n {\n for (int i = max - 1; i >= 0; i--)\n {\n var value = val % 7;\n if (nums.Contains(value)) return false;\n val /= 7;\n nums.Add(value);\n }\n\n return true;\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": ["brute force", "math", "combinatorics"], "code_uid": "2a846b19cd862ce17500ebe7a9f2f25c", "src_uid": "0930c75f57dd88a858ba7bb0f11f1b1c", "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 ConsoleApp2\n{\n class Program\n {\n static void Main(string[] args)\n {\n long[] F = new long[100001];\n F[0] = 1;\n F[1] = 1;\n for(long i = 2; i<100001; i++)\n {\n F[i] = (F[i - 1] + F[i - 2])%(long)(1e9 +7);\n }\n string[] str = Console.ReadLine().Split();\n long n = long.Parse(str[0]);\n long m = long.Parse(str[1]);\n Console.WriteLine((2*(F[m] + F[n] - 1)) % (long)(1e9 + 7));\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "dp", "combinatorics"], "code_uid": "cf2a42178be524bf53dde0bb5d45440f", "src_uid": "0f1ab296cbe0952faa904f2bebe0567b", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.IO;\nusing System.Linq;\n\nnamespace Contest\n{\n class Program\n {\n public void Solve()\n {\n var sc = new Scanner();\n int N = sc.NextInt();\n int M = sc.NextInt();\n if (M % N != 0)\n {\n Console.WriteLine(\"-1\");\n return;\n }\n\n M /= N;\n int cnt = 0;\n while (M % 2 == 0)\n {\n M /= 2;\n cnt++;\n }\n\n while (M % 3 == 0)\n {\n M /= 3;\n cnt++;\n }\n Console.WriteLine(M == 1 ? cnt : -1);\n }\n\n static void Main(string[] args) => new Program().Solve();\n }\n\n class Scanner\n {\n private char _separator = ' ';\n private StreamReader _stream = new StreamReader(Console.OpenStandardInput());\n private int _pos = 0;\n private string[] _line = new string[0];\n public string Next()\n {\n if (_pos >= _line.Length)\n {\n _line = _stream.ReadLine().Split(_separator);\n _pos = 0;\n }\n return _line[_pos++];\n }\n public int NextInt() => int.Parse(Next());\n public long NextLong() => long.Parse(Next());\n public double NextDouble() => double.Parse(Next());\n public string[] Array()\n {\n if (_pos >= _line.Length)\n _line = _stream.ReadLine().Split(_separator);\n _pos = _line.Length;\n return _line;\n }\n public int[] IntArray()\n {\n var arr = Array();\n var res = new int[arr.Length];\n for (int i = 0; i < arr.Length; i++)\n {\n res[i] = int.Parse(arr[i]);\n }\n return res;\n }\n public long[] LongArray()\n {\n var arr = Array();\n var res = new long[arr.Length];\n for (int i = 0; i < arr.Length; i++)\n {\n res[i] = long.Parse(arr[i]);\n }\n return res;\n }\n public double[] DoubleArray()\n {\n var arr = Array();\n var res = new double[arr.Length];\n for (int i = 0; i < arr.Length; i++)\n {\n res[i] = double.Parse(arr[i]);\n }\n return res;\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "implementation"], "code_uid": "ab51bf64dcbbe580c050f67a4cb83ca4", "src_uid": "3f9980ad292185f63a80bce10705e806", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\n\nclass C\n{\n\tstatic int gcd(int a, int b)\n\t{\n\t\treturn b == 0 ? a : gcd(b, a % b);\n\t}\n\n\tstatic bool fit(long a, long b, long x, long y)\n\t{\n\t\treturn a >= x && b >= y;\n\t}\n\n\tstatic void Main(string[] args)\n\t{\n\t\tvar ss = Console.ReadLine().Split(' ');\n\t\tvar a = int.Parse(ss[0]);\n\t\tvar b = int.Parse(ss[1]);\n\t\tvar x = int.Parse(ss[2]);\n\t\tvar y = int.Parse(ss[3]);\n\n\t\tint d = gcd(x, y);\n\t\tx /= d;\n\t\ty /= d;\n\n\t\tif (!fit(a, b, x, y))\n\t\t\tConsole.WriteLine(\"0 0\");\n\t\telse\n\t\t{\n\t\t\tlong L = 1, R = 2;\n\t\t\twhile (fit(a, b, x * R, y * R))\n\t\t\t{\n\t\t\t\tL = R;\n\t\t\t\tR *= 2;\n\t\t\t}\n\t\t\twhile (R - L > 1)\n\t\t\t{\n\t\t\t\tvar M = (L + R) / 2;\n\t\t\t\tif (fit(a, b, x * M, y * M))\n\t\t\t\t\tL = M;\n\t\t\t\telse\n\t\t\t\t\tR = M;\n\t\t\t}\n\t\t\tConsole.WriteLine(\"{0} {1}\", x * L, y * L);\n\t\t}\n\t}\n}", "lang_cluster": "C#", "tags": ["binary search", "number theory"], "code_uid": "199fbe03882f03e0a422bd071209d861", "src_uid": "97999cd7c6de79a4e39f56a41ff59e7a", "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 C\n{\n class Program\n {\n static void Main(string[] args)\n {\n long[] input = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();\n\n long a = input[0],\n b = input[1];\n\n long res = 0;\n\n while (a > 0 && b > 0)\n {\n if (a < b)\n {\n var @int = b / a;\n res += @int;\n b -= @int * a;\n }\n else\n {\n var @int = a / b;\n res += @int;\n a -= @int * b;\n }\n }\n\n Console.WriteLine(res);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "number theory"], "code_uid": "1322cc96df3076b114ae50cbad1a4862", "src_uid": "792efb147f3668a84c866048361970f8", "difficulty": 1600.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;\n\nnamespace Program\n{\n public static class CODEFORCES1\n {\n static public void Solve()\n {\n var n = NextInt;\n if (n % 2 == 1) Console.WriteLine(0);\n else Console.WriteLine(Repeat(2, n / 2).Aggregate((a, x) => a * x));\n }\n\n static public void Main(string[] args)\n {\n if (args.Length == 0)\n {\n var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };\n Console.SetOut(sw);\n }\n Solve();\n Console.Out.Flush();\n }\n static Random rand = new Random();\n static class Console_\n {\n private static Queue param = new Queue();\n public static string NextString()\n {\n if (param.Count == 0) foreach (var item in Console.ReadLine().Split(' ')) param.Enqueue(item);\n return param.Dequeue();\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 List NextIntList(int N) => Enumerable.Repeat(0, N).Select(_ => NextInt).ToList();\n static List NextLongList(int N) => Enumerable.Repeat(0, N).Select(_ => NextLong).ToList();\n static List NextDoubleList(int N) => Enumerable.Repeat(0, N).Select(_ => NextDouble).ToList();\n static List NextStringList(int N) => Enumerable.Repeat(0, N).Select(_ => NextString).ToList();\n static IEnumerable OrderByRand(this IEnumerable x) => x.OrderBy(_ => rand.Next());\n static IEnumerable Repeat(T v, int n) => Enumerable.Repeat(v, n);\n static List Sort(List l) where T : IComparable\n {\n var tmp = l.ToArray(); Array.Sort(tmp); return tmp.ToList();\n }\n static List Sort(List l, Comparison comp) where T : IComparable\n {\n var tmp = l.ToArray(); Array.Sort(tmp, comp); return tmp.ToList();\n }\n static List RevSort(List l) where T : IComparable\n {\n var tmp = l.ToArray(); Array.Sort(tmp, (x, y) => y.CompareTo(x)); return tmp.ToList();\n }\n static List RevSort(List l, Comparison comp) where T : IComparable\n {\n var tmp = l.ToArray(); Array.Sort(tmp, (x, y) => comp(y, x)); return tmp.ToList();\n }\n static IEnumerable Prime(long x)\n {\n if (x < 2) yield break;\n yield return 2;\n var halfx = x / 2;\n var table = new bool[halfx + 1];\n var max = (long)(Math.Sqrt(x) / 2);\n for (long i = 1; i <= max; ++i)\n {\n if (table[i]) continue;\n var add = 2 * i + 1;\n yield return add;\n for (long j = 2 * i * (i + 1); j <= halfx; j += add) table[j] = true;\n }\n for (long i = max + 1; i <= halfx; ++i) if (!table[i] && 2 * i + 1 <= x) yield return 2 * i + 1;\n }\n static IEnumerable Divisor(long x)\n {\n if (x < 1) yield break;\n var max = (long)Math.Sqrt(x);\n for (long i = 1; i <= max; ++i)\n {\n if (x % i != 0) continue;\n yield return i;\n if (i != x / i) yield return x / i;\n }\n }\n static long GCD(long a, long b)\n {\n while (b > 0) { var tmp = b; b = a % b; a = tmp; }\n return a;\n }\n class PQ where T : IComparable\n {\n private List h;\n private Comparison c;\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)\n {\n var i = h.Count;\n h.Add(v);\n while (i > 0)\n {\n var ni = (i - 1) / 2;\n if (c(v, h[ni]) >= 0) break;\n h[i] = h[ni]; i = ni;\n }\n h[i] = v;\n }\n public T Peek => h[0];\n public int Count => h.Count;\n public T Pop()\n {\n var r = h[0];\n var v = h[h.Count - 1];\n h.RemoveAt(h.Count - 1);\n if (h.Count == 0) return r;\n var i = 0;\n while (i * 2 + 1 < h.Count)\n {\n var i1 = i * 2 + 1;\n var i2 = i * 2 + 2;\n if (i2 < h.Count && c(h[i1], h[i2]) > 0) i1 = i2;\n if (c(v, h[i1]) <= 0) break;\n h[i] = h[i1]; i = i1;\n }\n h[i] = v;\n return r;\n }\n }\n class PQ where TKey : IComparable\n {\n private PQ> q;\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(TKey k, TValue v) => q.Push(Tuple.Create(k, v));\n public Tuple Peek => q.Peek;\n public int Count => q.Count;\n public Tuple Pop() => q.Pop();\n }\n class Mod\n {\n static public long _mod = 1000000007;\n private long _val = 0;\n public Mod(long x) { _val = x; }\n static public implicit operator Mod(long x) => new Mod(x);\n static public explicit operator long(Mod x) => x._val;\n static public Mod operator +(Mod x) => x._val;\n static public Mod operator -(Mod x) => -x._val;\n static public Mod operator ++(Mod x) => x._val + 1;\n static public Mod operator --(Mod x) => x._val - 1;\n static public Mod operator +(Mod x, Mod y) => (x._val + y._val) % _mod;\n static public Mod operator -(Mod x, Mod y) => ((((x._val - y._val) % _mod) + _mod) % _mod);\n static public Mod operator *(Mod x, Mod y) => (x._val * y._val) % _mod;\n static public Mod operator /(Mod x, Mod y) => (x._val * Inverse(y._val)) % _mod;\n static public bool operator ==(Mod x, Mod y) => x._val == y._val;\n static public bool operator !=(Mod x, Mod y) => x._val != y._val;\n static public bool operator <(Mod x, Mod y) => x._val < y._val;\n static public bool operator >(Mod x, Mod y) => x._val > y._val;\n static public bool operator <=(Mod x, Mod y) => x._val <= y._val;\n static public bool operator >=(Mod x, Mod y) => x._val >= y._val;\n static public Mod Pow(Mod x, long y)\n {\n Mod a = 1;\n while (y != 0)\n {\n if ((y & 1) == 1) a *= x;\n x *= x;\n y >>= 1;\n }\n return a;\n }\n static public long Inverse(long x)\n {\n long b = _mod, r = 1, u = 0, t = 0;\n while (b > 0)\n {\n var q = x / b;\n t = u; u = r - q * u; r = t;\n t = b; b = x - q * b; x = t;\n }\n return r < 0 ? r + _mod : r;\n }\n override public bool Equals(object obj) => obj == null ? false : _val == ((Mod)obj)._val;\n public bool Equals(Mod obj) => obj == null ? false : _val == obj._val;\n public override int GetHashCode() => _val.GetHashCode();\n public override string ToString() => _val.ToString();\n static private List _fact = new List();\n static private List _ifact = new List();\n static private void Build(int n)\n {\n if (n >= _fact.Count)\n for (int i = _fact.Count; i <= n; ++i)\n if (i == 0L) { _fact.Add(1); _ifact.Add(1); }\n else { _fact.Add(_fact[i - 1] * i); _ifact.Add(_ifact[i - 1] * Mod.Pow(i, _mod - 2)); }\n }\n static public Mod Comb(int n, int k)\n {\n Build(n);\n if (n == 0 && k == 0) return 1;\n if (n < k || n < 0) return 0;\n return _ifact[n - k] * _ifact[k] * _fact[n];\n }\n }\n static private List _fact = new List();\n static private void Build(int n)\n {\n if (n >= _fact.Count)\n for (int i = _fact.Count; i <= n; ++i)\n if (i == 0L) _fact.Add(1);\n else _fact.Add(_fact[i - 1] * i);\n }\n static public long Comb(int n, int k)\n {\n Build(n);\n if (n == 0 && k == 0) return 1;\n if (n < k || n < 0) return 0;\n return _fact[n] / _fact[k] / _fact[n - k];\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "dp"], "code_uid": "6a67cb9e2ada3c6c1b19aca57dcbbf47", "src_uid": "4b7ff467ed5907e32fd529fb39b708db", "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 The_Golden_Age\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 x = Next();\n long y = Next();\n\n long l = Next();\n long r = Next();\n\n var list = new List {0, long.MaxValue};\n for (long i = 1;; i *= x)\n {\n for (long j = 1;; j *= y)\n {\n if (long.MaxValue - i < j)\n break;\n list.Add(i + j);\n\n if (long.MaxValue/y < j)\n break;\n }\n if (long.MaxValue/x < i)\n break;\n }\n\n list.Sort();\n\n long max = 0;\n for (int i = 1; i < list.Count; i++)\n {\n if (list[i] <= r && list[i] >= l)\n max = Math.Max(max, list[i] - Math.Max(l - 1, list[i - 1]) - 1);\n if (list[i - 1] <= r && list[i - 1] >= l)\n max = Math.Max(max, Math.Min(r + 1, list[i]) - list[i - 1] - 1);\n if (list[i] > r && list[i - 1] < l)\n max = Math.Max(max, r - l + 1);\n }\n\n writer.WriteLine(max);\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": ["brute force", "math"], "code_uid": "5cdb3c91c29d0ddba07dd9302f24844f", "src_uid": "68ca8a8730db27ac2230f9fe9b120f5f", "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 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 L = NN;\n var R = NN;\n LIB_Mod._mod = 998244353;\n if (R - L == 0)\n {\n Console.WriteLine(1);\n return;\n }\n var tmp = LIB_Mod.Pow(LIB_Mod.Pow(R - L + 1, n), m);\n Console.WriteLine(((n * m) % 2 == 0) ? (tmp + ((R - L + 1) % 2)) / 2 : tmp);\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())); } var t = new Thread(Solve, 134217728); t.Start(); t.Join(); 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 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 OrderBy(this IEnumerable x) => x.OrderBy(e => e, StringComparer.OrdinalIgnoreCase);\n static IEnumerable OrderBy(this IEnumerable x, Func selector) => x.OrderBy(selector, StringComparer.OrdinalIgnoreCase);\n static IEnumerable OrderByDescending(this IEnumerable x) => x.OrderByDescending(e => e, StringComparer.OrdinalIgnoreCase);\n static IEnumerable OrderByDescending(this IEnumerable x, Func selector) => x.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 struct LIB_Mod : IEquatable, IEquatable\n {\n static public long _mod = 1000000007; long v;\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public LIB_Mod(long x)\n {\n if (x < _mod && x >= 0) v = x;\n else if ((v = x % _mod) < 0) v += _mod;\n }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n static public implicit operator LIB_Mod(long x) => new LIB_Mod(x);\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n static public implicit operator long(LIB_Mod x) => x.v;\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public void Add(LIB_Mod x) { if ((v += x.v) >= _mod) v -= _mod; }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public void Sub(LIB_Mod x) { if ((v -= x.v) < 0) v += _mod; }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public void Mul(LIB_Mod x) => v = (v * x.v) % _mod;\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public void Div(LIB_Mod x) => v = (v * Inverse(x.v)) % _mod;\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n static public LIB_Mod operator +(LIB_Mod x, LIB_Mod y) { var t = x.v + y.v; return t >= _mod ? new LIB_Mod { v = t - _mod } : new LIB_Mod { v = t }; }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n static public LIB_Mod operator -(LIB_Mod x, LIB_Mod y) { var t = x.v - y.v; return t < 0 ? new LIB_Mod { v = t + _mod } : new LIB_Mod { v = t }; }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n static public LIB_Mod operator *(LIB_Mod x, LIB_Mod y) => x.v * y.v;\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n static public LIB_Mod operator /(LIB_Mod x, LIB_Mod y) => x.v * Inverse(y.v);\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n static public bool operator ==(LIB_Mod x, LIB_Mod y) => x.v == y.v;\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n static public bool operator !=(LIB_Mod x, LIB_Mod y) => x.v != y.v;\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n static public long Inverse(long x)\n {\n long b = _mod, r = 1, u = 0, t = 0;\n while (b > 0)\n {\n var q = x / b;\n t = u;\n u = r - q * u;\n r = t;\n t = b;\n b = x - q * b;\n x = t;\n }\n return r < 0 ? r + _mod : r;\n }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public bool Equals(LIB_Mod x) => v == x.v;\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public bool Equals(long x) => v == x;\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public override bool Equals(object x) => x == null ? false : Equals((LIB_Mod)x);\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public override int GetHashCode() => v.GetHashCode();\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n public override string ToString() => v.ToString();\n static List _fact = new List() { 1 };\n static long _factm = _mod;\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n static void B(long n)\n {\n if (_factm != _mod) _fact = new List() { 1 };\n if (n >= _fact.Count)\n for (int i = _fact.Count; i <= n; ++i)\n _fact.Add(_fact[i - 1] * i);\n _factm = _mod;\n }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n static public LIB_Mod Comb(long n, long k)\n {\n B(n);\n if (n == 0 && k == 0) return 1;\n if (n < k || n < 0) return 0;\n return _fact[(int)n] / _fact[(int)(n - k)] / _fact[(int)k];\n }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n static public LIB_Mod CombOK(long n, long k)\n {\n LIB_Mod ret = 1;\n for (var i = 0; i < k; i++) ret *= n - i;\n for (var i = 1; i <= k; i++) ret /= i;\n return ret;\n }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n static public LIB_Mod Perm(long n, long k)\n {\n B(n);\n if (n == 0 && k == 0) return 1;\n if (n < k || n < 0) return 0;\n return _fact[(int)n] / _fact[(int)(n - k)];\n }\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n static public LIB_Mod Pow(LIB_Mod x, long y)\n {\n LIB_Mod a = 1;\n while (y != 0)\n {\n if ((y & 1) == 1) a.Mul(x);\n x.Mul(x);\n y >>= 1;\n }\n return a;\n }\n }\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": ["math", "matrices", "constructive algorithms", "combinatorics"], "code_uid": "abb89e1b3bb68fdad4396104ad4d7985", "src_uid": "ded299fa1cd010822c60f2389a3ba1a3", "difficulty": 2100.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Text;\nusing System.Collections;\nusing System.Collections.Generic;\n\n\nclass Program\n{\n\n void solve()\n {\n\n long N = long.Parse(Console.ReadLine());\n long all = 0;\n long[] cnt = new long[9];\n for (int i = 1; i <= N; i++)\n {\n cnt[i % 9]++;\n }\n for (int i = 0; i < 9; i++)\n {\n long cnt1 = cnt[i];\n for (int j = 0; j < 9; j++)\n {\n long cnt2 = cnt[j];\n int k = (i * j) % 9;\n long cnt3 =cnt[k];\n all += cnt1 * cnt2 * cnt3;\n }\n }\n for (int i = 1; i <= N; i++)\n {\n all -= (N / i);\n }\n Console.WriteLine(all);\n \n\n\n }\n\n \n static void Main(string[] args)\n {\n new Program().solve();\n }\n}\n\n \n", "lang_cluster": "C#", "tags": ["number theory"], "code_uid": "b0e58ad8548f331f0567675bd81792a0", "src_uid": "fc133fe6353089a0ebee08dec919f608", "difficulty": 2000.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.IO;\nusing System.Text;\n\nnamespace Fly__freebies__fly\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 int t = Next();\n\n Array.Sort(nn);\n\n int max = 0;\n\n int j = 0;\n for (int i = 0; i < n; i++)\n {\n while (j < n && nn[j] - nn[i] <= t)\n {\n j++;\n }\n max = Math.Max(max, j - i);\n }\n\n writer.WriteLine(max);\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", "binary search"], "code_uid": "75ab9dbe403315628408e94c265c9f01", "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.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 int[] mas = new int[10000];\n string [] arr = new string[n];\n for (int i = 0; i < n; i++)\n {\n arr[i] = Console.ReadLine();\n }\n int count = 0;\n int ans = 0;\n for (int i = 123; i < 9999; i++)\n {\n string str;\n if (i < 1000)\n str = \"0\" + i.ToString();\n else str = i.ToString();\n if (str[0] == str[1] || str[0] == str[2] || str[0] == str[3] ||\n str[1] == str[2] || str[1] == str[3] || str[2] == str[3]) continue;\n bool b = false;\n for (int j = 0; j < n; j++)\n {\n int bull = 0;\n int cow = 0;\n string []arr2 = arr[j].Split(' ').ToArray();\n if (str[0] == arr2[0][0]) bull++;\n if (str[1] == arr2[0][1]) bull++;\n if (str[2] == arr2[0][2]) bull++;\n if (str[3] == arr2[0][3]) bull++;\n\n if (str[0] == arr2[0][1] || str[0] == arr2[0][2] || str[0] == arr2[0][3]) cow++;\n if (str[1] == arr2[0][0] || str[1] == arr2[0][2] || str[1] == arr2[0][3]) cow++;\n if (str[2] == arr2[0][1] || str[2] == arr2[0][0] || str[2] == arr2[0][3]) cow++;\n if (str[3] == arr2[0][1] || str[3] == arr2[0][2] || str[3] == arr2[0][0]) cow++;\n if (cow != int.Parse(arr2[2]) || bull != int.Parse(arr2[1]))\n {\n b = true;\n break;\n }\n }\n if (!b)\n {\n count++;\n ans = i;\n mas[i] = 1;\n\n }\n }\n if (count == 0) Console.WriteLine(\"Incorrect data\");\n else if (count > 1) Console.WriteLine(\"Need more data\");\n else\n {\n if (ans < 1000) Console.WriteLine(\"0\"+ans);\n else Console.WriteLine(ans);\n }\n \n }\n \n }\n \n}\n", "lang_cluster": "C#", "tags": ["brute force", "implementation"], "code_uid": "a09ddc5e79c10ae349e322708c3bdc9e", "src_uid": "142e5f2f08724e53c234fc2379216b4c", "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.Numerics;\npublic class Codeforces\n{\n protected static TextReader reader;\n protected static TextWriter writer;\n static object Solve()\n {\n var n = ReadInt();\n if (n == 0)\n {\n writer.WriteLine(\"O-|-OOOO\");\n return null;\n }\n while (n > 0)\n {\n var digit = n % 10;\n n /= 10;\n if (digit < 5)\n {\n writer.Write(\"O-|\");\n if (digit == 0)\n {\n writer.Write(\"-OOOO\");\n }\n else\n {\n writer.Write(new string('O', digit) + \"-\" + new string('O', 4 - digit));\n }\n\n }\n else\n {\n writer.Write(\"-O|\");\n if (digit - 5 == 0)\n {\n writer.Write(\"-OOOO\");\n }\n else\n {\n writer.Write(new string('O', digit - 5) + \"-\" + new string('O', 4 - (digit - 5)));\n }\n }\n writer.WriteLine();\n }\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"], "code_uid": "3708abf4a2b037dab1768a304bdd7497", "src_uid": "c2e3aced0bc76b6484360563355d23a7", "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 public void Solve()\n {\n int n = ReadInt();\n long m = ReadLong() - 1;\n int l = 0, r = n - 1;\n var a = new int[n];\n for (int i = n - 2, j = 1; i >= 0; i--, j++)\n {\n if ((m >> i & 1) == 1)\n a[r--] = j;\n else\n a[l++] = j;\n }\n a[l] = n;\n WriteArray(a);\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", "divide and conquer", "bitmasks"], "code_uid": "6a5139284d2155a810c359e34bccf652", "src_uid": "a8da7cbd9ddaec8e0468c6cce884e7a2", "difficulty": 1800.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.Text;\nusing System.Numerics;\nusing System.Threading.Tasks;\nusing System.Text.RegularExpressions;\nusing static System.Math;\n\nstatic class P\n{\n static void Main()\n {\n int n = int.Parse(Console.ReadLine());\n var a = Console.ReadLine().Split().Select(int.Parse).ToArray();\n int res = 0;\n bool top = false;\n for (int i = 1; i < a.Length; i++)\n {\n var x = Min(a[i - 1], a[i]);\n var y = Max(a[i - 1], a[i]);\n if (x == 2 && y == 3) goto Infinite;\n if (x == 1 && y == 2) res += top ? 2 : 3;\n if (x == 1 && y == 3) res += 4;\n top = a[i - 1] == 3 && a[i] == 1;\n }\n Console.WriteLine(\"Finite\");\n Console.WriteLine(res);\n return;\n Infinite:;\n Console.WriteLine(\"Infinite\");\n\n }\n}\n", "lang_cluster": "C#", "tags": ["geometry"], "code_uid": "6ea914cd9dad196880ece6dba9f8cf61", "src_uid": "6c8f028f655cc77b05ed89a668273702", "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;\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();\n var max = 0;\n for (var i = 0; i < str.Length; i++) {\n if (Char.IsLower(str[i])) {\n var set = new HashSet();\n for (var j = i; j < str.Length; j++) {\n if (Char.IsLower(str[j])) {\n set.Add(str[j]);\n }\n else {\n break;\n }\n }\n max = Math.Max(set.Count, max);\n }\n }\n\n sw.WriteLine(max);\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", "strings", "implementation"], "code_uid": "46620bd98476772a605b610af64a6adf", "src_uid": "567ce65f87d2fb922b0f7e0957fbada3", "difficulty": 1000.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[] start = Array.ConvertAll(Console.ReadLine().Split(' '), x => int.Parse(x));\n int[] pos = Array.ConvertAll(Console.ReadLine().Split(' '), x => int.Parse(x));\n int[] end = Array.ConvertAll(Console.ReadLine().Split(' '), x => int.Parse(x));\n\n double r = findSide(start[0], start[1], pos[0], pos[1], end[0], end[1]);\n\n if(r == 0)\n Console.WriteLine(\"TOWARDS\");\n else if(r < 0)\n Console.WriteLine(\"RIGHT\");\n else if(r > 0)\n Console.WriteLine(\"LEFT\");\n }\n\n public static double findSide(\n double ax, double ay,\n double bx, double by,\n double cx, double cy)\n {\n return ((bx - ax) * (cy - ay) - (by - ay) * (cx - ax));\n }\n }\n}", "lang_cluster": "C#", "tags": ["geometry"], "code_uid": "0d2421d29e3213cbfa1e8489a00684ff", "src_uid": "f6e132d1969863e9f28c87e5a44c2b69", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.IO;\nusing System.Linq;\n\nclass Program\n{\n static void Main()\n {\n var input = Console.ReadLine().Split(' ');\n // var input = \"8 5 4\".Split(' ');\n var n = int.Parse(input[0]);\n var p = int.Parse(input[1]);\n var k = int.Parse(input[2]);\n\n var first = p - k;\n first = first < 1 ? 1 : first;\n var last = p + k;\n last = last > n ? n : last;\n\n if(first > 1) Console.Write(\"<< \");\n for (int i = first; i <= last; i++)\n {\n if(i == p)\n Console.Write($\"({i}) \");\n else\n Console.Write(i + \" \");\n }\n if(last < n) Console.Write(\">>\");\n }\n}", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "cd3e7fd7330afd52ce6580b7a29af8b7", "src_uid": "526e2cce272e42a3220e33149b1c9c84", "difficulty": null, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.IO;\nusing System.Linq;\nusing System.Text;\n\nnamespace CodeForceRound304\n{\n sealed class Program\n {\n\n private const int BufferSize = 10 * (1 << 10);\n private static readonly StreamReader reader = new StreamReader(Console.OpenStandardInput(1024 * 10), Encoding.ASCII, false, BufferSize);\n private static readonly StreamWriter writer = new StreamWriter(Console.OpenStandardOutput(1024 * 10), Encoding.ASCII, BufferSize);\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 private static int[] ReadIntArray()\n {\n string[] tmp = Console.ReadLine().Split(' ');\n int[] ans = new int[tmp.Length];\n for (int i = 0; i < tmp.Length; i++) ans[i] = int.Parse(tmp[i]);\n return ans;\n }\n\n private static long[] ReadLongArray()\n {\n string[] tmp = Console.ReadLine().Split(' ');\n long[] ans = new long[tmp.Length];\n for (int i = 0; i < tmp.Length; i++) ans[i] = long.Parse(tmp[i]);\n return ans;\n }\n\n private static string[] ReadStringArray()\n {\n string[] tmp = Console.ReadLine().Split(' ');\n return tmp;\n }\n private static void SoldierCards()\n {\n var n = Next();\n var k1 = Next();\n var queue1 = new Queue(k1);\n for (var i = 0; i < k1; i++)\n {\n //var q = Next();\n queue1.Enqueue(Next());\n }\n //var map = new HashSet, Queue>, int>\n //var queue1History = new Dictionary>(n) { { 0, new Queue(queue1) } };\n var queue1History = new List>(n);\n var k2 = Next();\n var queue2 = new Queue(k2);\n\n for (var i = 0; i < k2; i++)\n {\n queue2.Enqueue(Next());\n }\n\n //var queue2History = new Dictionary>(n) { { 0, new Queue(queue2) } };\n var queue2History = new List>(n);\n var count = 0;\n do\n {\n var card1 = queue1.Dequeue();\n var card2 = queue2.Dequeue();\n if (card1 > card2)\n {\n queue1.Enqueue(card2);\n queue1.Enqueue(card1);\n }\n else\n {\n queue2.Enqueue(card1);\n queue2.Enqueue(card2);\n }\n\n //if (queue1History.Values.Any(x => x.SequenceEqual(queue1)))//queue1.SequenceEqual(queue1Copy) && queue2.SequenceEqual(queue2Copy))\n var key = queue1History.FindIndex(x => x.SequenceEqual(queue1));\n if (key > -1)\n {\n if (queue2History[key].SequenceEqual(queue2))\n {\n Console.Write(-1);\n return;\n }\n }\n queue1History.Add(new Queue(queue1));\n queue2History.Add(new Queue(queue2));\n count++;\n /*queue1History.Add(++count, new Queue(queue1));\n queue2History.Add(count, new Queue(queue2));*/\n } while (queue1.Any() && queue2.Any());\n\n\n Console.Write(\"{0} {1}\", count, !queue1.Any() ? 2 : 1);\n }\n\n private static void SoldierCards2()\n {\n var n = Next();\n var k1 = Next();\n var queue1 = new Queue(k1);\n for (var i = 0; i < k1; i++)\n {\n //var q = Next();\n queue1.Enqueue(Next());\n }\n \n var k2 = Next();\n var queue2 = new Queue(k2);\n\n for (var i = 0; i < k2; i++)\n {\n queue2.Enqueue(Next());\n }\n\n reader.Close();\n var count = 0;\n do\n {\n var card1 = queue1.Dequeue();\n var card2 = queue2.Dequeue();\n if (card1 > card2)\n {\n queue1.Enqueue(card2);\n queue1.Enqueue(card1);\n }\n else\n {\n queue2.Enqueue(card1);\n queue2.Enqueue(card2);\n }\n count++;\n\n if (count > 106)\n {\n Console.Write(-1);\n return;\n }\n } while (queue1.Any() && queue2.Any());\n\n\n Console.Write(\"{0} {1}\", count, !queue1.Any() ? 2 : 1);\n }\n\n private static void SoldierCards3()\n {\n var n = Next();\n var k1 = Next();\n var queue1 = new List(n);\n for (var i = 0; i < k1; i++)\n {\n //var q = Next();\n queue1.Add(Next());\n }\n\n var k2 = Next();\n var queue2 = new List(n);\n\n for (var i = 0; i < k2; i++)\n {\n queue2.Add(Next());\n }\n\n reader.Close();\n var count = 0;\n do\n {\n var card1 = queue1[0];\n var card2 = queue2[0];\n if (card1 > card2)\n {\n queue1.Add(card2);\n queue1.Add(card1);\n }\n else\n {\n queue2.Add(card1);\n queue2.Add(card2);\n }\n queue1.RemoveAt(0);\n queue2.RemoveAt(0);\n count++;\n\n if (count > 106)\n {\n Console.Write(-1);\n return;\n }\n } while (queue1.Any() && queue2.Any());\n\n\n Console.Write(\"{0} {1}\", count, !queue1.Any() ? 2 : 1);\n }\n\n private static void SoldierCards4()\n {\n int n = int.Parse(Console.ReadLine());\n\n List l1 = new List();\n List l2 = new List();\n\n l1.AddRange(ReadIntArray());\n l2.AddRange(ReadIntArray());\n l1.RemoveAt(0);\n l2.RemoveAt(0);\n\n int iteration = 0;\n while (l1.Count > 0 && l2.Count > 0)\n {\n if (l1[0] > l2[0])\n {\n l1.Add(l2[0]);\n l1.Add(l1[0]);\n }\n else\n {\n l2.Add(l1[0]);\n l2.Add(l2[0]);\n }\n\n l1.RemoveAt(0);\n l2.RemoveAt(0);\n iteration++;\n if (iteration > 100000) break;\n }\n\n if (l1.Count > 0 && l2.Count > 0)\n {\n Console.Write(-1);\n }\n\n if (l1.Count == 0 && l2.Count > 0)\n {\n Console.Write(iteration + \" 2\");\n }\n if (l1.Count > 0 && l2.Count == 0)\n {\n Console.Write(iteration + \" 1\");\n }\n\n }\n\n private static void SoldierBanana()\n {\n var inputs = Console.ReadLine();\n var processedInputs = inputs.Split(' ');\n int k = int.Parse(processedInputs[0]);\n int n = int.Parse(processedInputs[1]);\n int w = int.Parse(processedInputs[2]);\n int sum = k * (w + 1) * w / 2;\n Console.WriteLine(Math.Max(0, sum - n));\n }\n\n private static int ContiousCount(List list, int key)\n {\n if (list.Contains(key + 1))\n {\n return 1 + ContiousCount(list, key + 1);\n }\n list.Add(key + 1);\n return 1;\n }\n\n\n private static void Badge()\n {\n var n = int.Parse(Console.ReadLine());\n var input = Console.ReadLine();\n var coolFactors = input.Split(' ').Select(int.Parse).ToArray();\n Array.Sort(coolFactors);\n var result = 0;\n\n for (var i = 1; i < n; i++)\n {\n while (coolFactors[i] <= coolFactors[i - 1])\n {\n result++;\n coolFactors[i]++;\n }\n }\n Console.WriteLine(result);\n /********** TOO SLOW *************************\n var distinctFactor = coolFactors.Distinct().ToList();\n if (distinctFactor.Count == n)\n Console.WriteLine(0);\n else\n {\n var deepCopy = new List(coolFactors); //keep a copy of the original factors\n foreach (var df in distinctFactor)\n {\n coolFactors.Remove(df);\n }\n var result = coolFactors.Sum(coolFactor => ContiousCount(deepCopy, coolFactor));\n Console.WriteLine(result);\n }\n */\n }\n static void Main(string[] args)\n {\n //SoldierBanana();\n\n //Badge();\n\n SoldierCards4();\n\n //Console.ReadKey();\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["dfs and similar", "brute force", "games"], "code_uid": "e2c14f243f675170d8fe2f39c7209a5c", "src_uid": "f587b1867754e6958c3d7e0fe368ec6e", "difficulty": 1400.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 = Console.ReadLine().Split().Select(long.Parse).ToArray();\n var x1 = n[0]; var y1 = n[1]; var x2 = n[2]; var y2 = n[3];\n var x = Math.Abs(x1 - x2);\n var y = Math.Abs(y1 - y2);\n var ans = (x / 2 + 1) * (y / 2 + 1) + x * y / 4;\n Console.WriteLine(ans);\n }\n }\n}", "lang_cluster": "C#", "tags": ["math"], "code_uid": "d2e5e21352e1143efde037872c0bedb8", "src_uid": "00cffd273df24d1676acbbfd9a39630d", "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 Sth\n{\n class Program\n {\n static int[] p1 = new int[50];\n static int[] res = new int[50];\n static void Main(string[] args)\n {\n int a, c;\n string[] lala = Console.ReadLine().Split();\n a = int.Parse(lala[0]);\n c = int.Parse(lala[1]);\n int len1=0;\n while (a > 0)\n {\n p1[len1++] = a % 3;\n a /= 3;\n }\n int len2 = 0;\n while (c > 0)\n {\n res[len2++] = c % 3;\n c /= 3;\n }\n int ans = 0;\n int step = 1;\n int ll = Math.Max(len1, len2);\n for (int i = 0; i < ll; i++)\n {\n int cif = res[i] - p1[i];\n cif += 3;\n cif %= 3;\n ans += cif * step;\n step *= 3;\n }\n Console.WriteLine(ans);\n //Console.ReadLine();\n\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "implementation"], "code_uid": "7055da8bd2cc3683283007d72ed6756c", "src_uid": "5fb635d52ddccf6a4d5103805da02a88", "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 ConsoleApp23\n{\n class Program\n {\n static void Main(string[] args)\n {\n string s = Console.ReadLine();\n int n1 = int.Parse(s.Split(' ')[0]), n2 = int.Parse(s.Split(' ')[1]), k1 = int.Parse(s.Split(' ')[2]), \n k2 = int.Parse(s.Split(' ')[3]);\n int m = Math.Min(k1,k2);\n if (n1 / m > n2 / m || n1 > n2) Console.WriteLine(\"First\");\n else Console.WriteLine(\"Second\");\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "constructive algorithms"], "code_uid": "1f58ed95c8dec09f4c5abeeea2b82d42", "src_uid": "aed24ebab3ed9fd1741eea8e4200f86b", "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 B779\n{\n class B779\n {\n static void Main(string[] args)\n {\n String[] arr = Console.ReadLine().Split();\n String a = arr[0];\n int n = int.Parse(arr[1]);\n if (a.Length < n + 1)\n {\n Console.WriteLine(a.Length - 1);\n return;\n }\n int l = 0;\n int t = 0;\n for (int i = a.Length - 1; i >= 0; i--)\n {\n if (a[i] == '0')\n {\n l++;\n }\n else\n {\n t++;\n }\n if (l == n)\n {\n if (a.Length - t >= n)\n {\n Console.WriteLine(t);\n return;\n }\n else\n {\n Console.WriteLine(a.Length - 1);\n return;\n }\n }\n\n }\n Console.WriteLine(a.Length - 1);\n }\n\n }\n}\n\n", "lang_cluster": "C#", "tags": ["brute force", "greedy"], "code_uid": "39472b232b17994a941cd0eb234f5928", "src_uid": "7a8890417aa48c2b93b559ca118853f9", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\n\nnamespace CFSharp\n{\n class Program\n {\n static void Main(string[] args)\n {\n int p = 0, o = 0;\n int n = int.Parse(Console.ReadLine());\n string[] astr = Console.ReadLine().Split(' ');\n for(int i = 0; i < n; i++)\n {\n int t = int.Parse(astr[i]);\n if (t > 0) p += t; else o += t;\n }\n Console.Write(p - o);\n } \n }\n}", "lang_cluster": "C#", "tags": ["greedy"], "code_uid": "a0c43129345887fa95e9e0210ccd488c", "src_uid": "4b5d14833f9b51bfd336cc0e661243a5", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System; using System.Linq;\n\nclass P {\n static void Main() {\n var dx = 1; var dy = 0;\n var d = 2;\n var s = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();\n var x = 0; var y = 0;\n var xn = x + dx * (d / 2); var yn = y + dy * (d / 2);\n while (((x != s[0] || (y-s[1])*(yn-s[1]) > 0)) &&\n ((y != s[1] || (x-s[0])*(xn-s[0]) > 0))) {\n d++;\n var tmpdx = dx;\n dx = -dy;\n dy = tmpdx;\n x = xn; y = yn;\n xn = x + dx * (d / 2); yn = y + dy * (d / 2);\n }\n Console.WriteLine(d - 2);\n }\n}", "lang_cluster": "C#", "tags": ["brute force", "geometry", "implementation"], "code_uid": "a083bee95f5782cba0ebf1dd426910f5", "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;\nusing System.Threading.Tasks;\n\nnamespace ConsoleApp6\n{\n class Program\n {\n\n static void Main(string[] args)\n {\n Console.ReadLine();\n string[] input = Console.ReadLine().Split(' ');\n List c = new List();\n foreach (string i in input)\n c.Add(Int32.Parse(i));\n c = c.Distinct().ToList();\n c.Sort();\n List cc = c.ToArray().ToList();\n cc.Reverse();\n int res = 0;\n List bad = new List();\n List combo = new List();\n foreach (int g in c)\n {\n if (bad.Contains(g))\n continue;\n foreach (int h in cc)\n {\n if (h % g == 0)\n {\n combo.Add(h);\n }\n }\n //Console.WriteLine(\"COMBO! {0}\", string.Join(\" \", combo));\n if (combo.Count() > 0)\n res += 1;\n foreach (int i in combo)\n {\n bad.Add(i);\n }\n }\n \n \n Console.WriteLine(res);\n Console.ReadLine();\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "greedy", "implementation"], "code_uid": "888025a6b56c0a03b448d655af04e0ec", "src_uid": "63d9b7416aa96129c57d20ec6145e0cd", "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;\nusing static System.Array;\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 = input.ReadInt();\n var f = (Func)(x =>\n {\n x++;\n while (x % 10 == 0)\n x /= 10;\n return x;\n });\n var a = new HashSet();\n while (!a.Contains(n))\n {\n a.Add(n);\n n = f(n);\n }\n Write(a.Count);\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() => reader.ReadToEnd();\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\n checked\n {\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\n public string ReadLine() => reader.ReadLine();\n\n public long ReadLong() => long.Parse(ReadToken());\n\n public double ReadDouble() => double.Parse(ReadToken(), CultureInfo.InvariantCulture);\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() => (ReadInt(), ReadInt());\n\n public (int, int, int) Read3Int() => (ReadInt(), ReadInt(), ReadInt());\n\n public (int, int, int, int) Read4Int() => (ReadInt(), ReadInt(), ReadInt(), ReadInt());\n\n public (long, long) Read2Long() => (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\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": ["implementation"], "code_uid": "72d5328b567143bd9b6bb7d408789f0a", "src_uid": "055fbbde4b9ffd4473e6e716da6da899", "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 CFTraining.A_s\n{\n class LLPS127\n {\n public static void Main(string[] args)\n {\n string s = Console.ReadLine();\n char maxVal = s[0];\n int max = 0;\n for (int i = 1; i < s.Length; i++)\n {\n if (s[i] > maxVal)\n {\n maxVal = s[i];\n max = i;\n }\n }\n string localRes = \"\" + s[max];\n for (int i = max + 1; i < s.Length; i++)\n {\n if (s[i] == s[max])\n {\n localRes += s[i];\n }\n }\n Console.WriteLine(localRes);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "binary search", "bitmasks", "greedy", "strings", "implementation"], "code_uid": "b2763336bde64cfcf8cc15fd555ec13d", "src_uid": "9a40e9b122962a1f83b74ddee6246a40", "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 CodeForces\n{\n class Program\n {\n \n static void Main(string[] args)\n {\n string[] s = Console.ReadLine().Split(' ');\n int exam = int.Parse(s[0]);\n int mark = int.Parse(s[1]);\n int count = exam;\n\n mark = mark - 2 * exam;\n\n for (int i = 0; i < exam; i++)\n {\n if (mark > 0)\n {\n mark = mark - 1;\n count--;\n }\n else\n break;\n }\n\n Console.WriteLine(count);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "implementation"], "code_uid": "11752b2926019b8639399d749f660a86", "src_uid": "5a5e46042c3f18529a03cb5c868df7e8", "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.IO;\nusing System.Collections;\n\nnamespace CodeForces {\n struct Pair : IComparable {\n public int First, Second;\n public Pair(int f, int s) {\n First = f;\n Second = s; \n }\n public override string ToString() {\n return string.Format(\"{0} {1}\", First, Second);\n }\n\n public int CompareTo(Pair other) {\n return First.CompareTo(other.First);\n }\n }\n\n class Cf {\n static int n, m, k; \n static TextReader input;\n static void Main(string[] args) { \n#if TESTS \n input = new StreamReader(\"input.txt\"); \n#else\n input = Console.In;\n#endif\n Solve();\n \n#if TESTS\n Console.ReadLine();\n#endif\n }\n\n static void Solve() {\n n = ReadInt();\n m = (n-1)>>1;\n int[,] arr = new int[n,n];\n for (int i = 0; i < n; ++i) {\n int[] a = ReadIntArray();\n for (int j = 0; j < n; ++j) {\n arr[i, j] = a[j];\n }\n }\n int ans = -3 * arr[m,m];\n for (int i = 0; i < n; ++i) {\n ans += arr[i, i];\n ans += arr[n-1-i, i];\n ans += arr[m, i];\n ans += arr[i, m];\n }\n Console.WriteLine(ans);\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 }\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\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\n public static class Extensions {\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 int MaxIntIndex(this int[] array) {\n int max = array[0];\n int index = 0;\n for (int i = 1; i < array.Length; ++i) {\n if (array[i] > max) {\n max = array[i];\n index = i;\n } \n }\n return index;\n }\n \n public static void PrintToConsole(this IEnumerable arr) {\n foreach (T t in arr)\n Console.Write(\"{0} \", t);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "dee0810e06db950157230d53e9e1b9f7", "src_uid": "5ebfad36e56d30c58945c5800139b880", "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 CodeforcesExamples2\n{\n class Program\n {\n static void Main(string[] args)\n {\n string[] words = Console.ReadLine().Trim().Split(' ');\n int n = Convert.ToInt32(words[0]), m = Convert.ToInt32(words[1]);\n words = Console.ReadLine().Trim().Split(' ');\n int[] a = new int[n];\n int b;\n for (int i = 0; i < n; i++)\n {\n a[i] = -1;\n }\n for (int i = 0; i < m; i++)\n {\n b=Convert.ToInt32(words[i]);\n for (int j = b-1; j < n; j++)\n {\n if (a[j] == -1)\n {\n a[j] = b;\n }\n }\n }\n for (int i = 0; i < n; i++)\n {\n Console.Write(a[i] + \" \");\n }\n Console.WriteLine();\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "21ccbcc25fa20f2dbb0280a579e928d9", "src_uid": "2e44c8aabab7ef7b06bbab8719a8d863", "difficulty": 900.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 count = int.Parse(Console.ReadLine());\n int[] x = Console.ReadLine().Split().Select(z => int.Parse(z)).ToArray();\n var sum = Enumerable.Range(0, count - 1).Select(z => x[z + 1] - x[z]).ToArray().Max();\n var rez = Enumerable.Range(0, count - 2).Select(z => x[z + 2] - x[z]).ToArray().Min();\n Console.WriteLine(Math.Max(sum,rez));\n }\n }\n}\n\n", "lang_cluster": "C#", "tags": ["brute force", "math", "implementation"], "code_uid": "b68cfe01b047364ae90da43d9d2a4686", "src_uid": "8a8013f960814040ac4bf229a0bd5437", "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 Codeforces2905B\n{\n class Program\n {\n static void Main(string[] args)\n {\n\n string read;\n read = Console.ReadLine();\n int x = int.Parse(read.Split(' ').ToList()[0]);\n int y = int.Parse(read.Split(' ').ToList()[1]);\n\n double a = y * Math.Log(x);\n double b = x * Math.Log(y);\n\n if (a > b)\n Console.WriteLine(\">\");\n else if (b > a)\n Console.WriteLine(\"<\");\n else\n Console.WriteLine(\"=\");\n\n\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math"], "code_uid": "39f0c1d92829948f30cd459388fa44b6", "src_uid": "ec1e44ff41941f0e6436831b5ae543c6", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\n\nnamespace test\n{\n class Program\n {\n static void Main(string[] args)\n {\n var n = ReadInt();\n var side = Math.Sqrt(n);\n var ans = 0;\n if (side % 1 == 0) ans = (int)side * 2;\n else\n {\n var rem = n - (int)side * (int)side;\n if (rem <= (int)side) ans = (int)side * 2 + 1;\n else ans = (int)side * 2 + 2;\n }\n\n Console.WriteLine(ans);\n Console.ReadLine();\n }\n\n static string Read() { return Console.ReadLine(); }\n static int ReadInt() { return int.Parse(Read()); }\n static long ReadLong() { return long.Parse(Read()); }\n static int[] ReadArrayInt() { return Read().Split(' ').Select(s => int.Parse(s)).ToArray(); }\n static long[] ReadArrayLong() { return Read().Split(' ').Select(s => long.Parse(s)).ToArray(); }\n }\n}", "lang_cluster": "C#", "tags": ["math", "constructive algorithms", "binary search"], "code_uid": "c5be8c21ef0378f5037130eaab9c2c74", "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;\nusing System.Threading.Tasks;\nusing static System.Console;\nusing static System.Math;\n\nnamespace ConsoleApp5\n{\n class Program\n {\n static void Main(string[] args)\n {\n long n = Convert.ToInt64(ReadLine());\n WriteLine(n / 2520);\n }\n }\n}", "lang_cluster": "C#", "tags": ["math", "number theory"], "code_uid": "4756afc43f27c1fcd560159ca7283dfb", "src_uid": "8551308e5ff435e0fc507b89a912408a", "difficulty": 1100.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 bool IsPalindrome(string s)\n {\n string invers = string.Empty;\n for (int i = s.Length-1; i>=0; i--)\n {\n invers += s[i];\n }\n\n return invers == s;\n }\n static void Main(string[] args)\n {\n string line = Console.ReadLine();\n if (IsPalindrome(line))\n {\n Console.WriteLine(\"YES\");\n Console.ReadLine();\n return;\n }\n\n string newString = string.Empty;\n int index = line.Length - 1;\n while (index >=0 && line[index] == '0')\n {\n newString += \"0\";\n index--;\n }\n\n newString += line;\n if (IsPalindrome(newString))\n {\n Console.WriteLine(\"YES\");\n Console.ReadLine();\n return;\n }\n\n Console.WriteLine(\"NO\");\n Console.ReadLine();\n }\n }\n}", "lang_cluster": "C#", "tags": ["brute force", "implementation"], "code_uid": "977d0f3acd3411e5c148def1a71fca9f", "src_uid": "d82278932881e3aa997086c909f29051", "difficulty": 900.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\tlong N = int.Parse(Console.ReadLine());\n\t\tlong ans = 1;\n\t\tlong mod = 1000000007;\n\t\tfor(var i=1;i<=N;i++){\n\t\t\tans = ans*i%mod;\n\t\t}\n\t\tlong a2 = 1;\n\t\tfor(var i=1;i 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 int 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] = (int)((long)roots[i] * z % MOD);\n }\n curBase++;\n }\n }\n\n public void FFT(int[] 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 int 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 int x = a[i + j];\n int y = (int)((long)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 int[] Multiply(int[] a, int[] 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 int invSz = Inv(sz);\n for (int i = 0; i < sz; i++)\n {\n a[i] = (int)((long)(int)((long)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 int[] Square(int[] a)\n {\n return Multiply(a, a, 1);\n }\n\n public int Power(int a, long b)\n {\n int res = 1;\n while (b > 0)\n {\n if ((b & 1) > 0)\n {\n res = (int)((long)res * a % MOD);\n }\n a = (int)((long)a * a % MOD);\n b >>= 1;\n }\n return res;\n }\n\n public int Inv(int a)\n {\n a %= MOD;\n if (a < 0)\n {\n a += MOD;\n }\n int b = MOD;\n int u = 0;\n int v = 1;\n while (a != 0)\n {\n int t = b / a;\n b -= t * a;\n\n int 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": "d28f4bbcc48dc5da9c73af8c71011513", "src_uid": "279f1f7d250a4be6406c6c7bfc818bbf", "difficulty": 2400.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 int intFromStrBase(string s, int b)\n {\n int[] a = s.Select(c => c >= '0' && c <= '9' ? c - '0' : c >= 'A' && c <= 'Z' ? c - 'A' + 10 : 999).ToArray();\n if (a.Any(x => x >= b))\n return -1;\n\n int sum = 0;\n for (int i = 0; i < a.Length; i++)\n {\n sum = sum * b + a[i];\n if (sum > 60)\n return -1;\n }\n\n return sum;\n }\n\n static bool possible(string h, string m, int b)\n {\n int ih = intFromStrBase(h, b);\n int im = intFromStrBase(m, b);\n return (ih >= 0 && ih <= 23 && im >= 0 && im <= 59);\n }\n\n static void Main(string[] args)\n {\n string[] hm = Console.ReadLine().Split(':');\n while (hm[0].Length > 1 && hm[0].StartsWith(\"0\"))\n hm[0] = hm[0].Substring(1);\n while (hm[1].Length > 1 && hm[1].StartsWith(\"0\"))\n hm[1] = hm[1].Substring(1);\n\n\n List poss = new List();\n for (int i = 1; i <= 100; i++)\n if (possible(hm[0], hm[1], i))\n poss.Add(i);\n\n if (possible(hm[0], hm[1], 99))\n Console.WriteLine(-1);\n else if(poss.Count == 0)\n Console.WriteLine(0);\n else\n foreach(var x in poss)\n Console.Write(\"{0} \", x);\n \n }\n }\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "636888ca33440c10a30cd3aca97a5af0", "src_uid": "c02dfe5b8d9da2818a99c3afbe7a5293", "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 x1, y1, x2, y2,x,y;\n sc.Make(out x1, out y1, out x2, out y2, out x, out y);\n if (Abs(x2 - x1) % x != 0 || Abs(y2 - y1) % y != 0) Fail(\"NO\");\n var a = Abs(x2 - x1) / x;\n var b = Abs(y2 - y1) / y;\n if (a % 2 == b % 2) 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": ["math", "implementation", "number theory"], "code_uid": "9d280327c2b0c31850984c061102c217", "src_uid": "1c80040104e06c9f24abfcfe654a851f", "difficulty": 1200.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;\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 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 int minx = int.MaxValue;\n int maxx = int.MinValue;\n int miny = int.MaxValue;\n int maxy = int.MinValue;\n int S=0;\n for (int i = 0; i < n; i++)\n {\n ReadArray(' ');\n int x1=NextInt();\n int y1=NextInt();\n int x2=NextInt();\n int y2=NextInt();\n minx = Math.Min(minx, x1);\n miny = Math.Min(miny, y1);\n maxx = Math.Max(maxx, x2);\n maxy = Math.Max(maxy, y2);\n S+=(x2-x1)*(y2-y1);\n }\n if (maxx - minx == maxy - miny && S == (maxx - minx) * (maxy - miny)) Console.WriteLine(\"YES\");\n else Console.WriteLine(\"NO\");\n }\n\n static void B()\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 }\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 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": ["implementation"], "code_uid": "54622ebc9e83952149b67ade2ea4032d", "src_uid": "f63fc2d97fd88273241fce206cc217f2", "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 A\n{\n class Program\n {\n static bool IsVowel(char c)\n {\n if (c == 'A' || c == 'E' || c == 'O' || c == 'U' || c == 'Y' || c == 'I')\n {\n return true;\n }\n return false;\n }\n\n static void Main(string[] args)\n {\n string str = Console.ReadLine();\n str = ' ' + str + ' ';\n int jumpSize = 1, pos = 0, next;\n do\n {\n next = pos + 1;\n while (str[next] != ' ' && !IsVowel(str[next]))\n {\n next++;\n }\n jumpSize = Math.Max(jumpSize, next - pos);\n pos = next;\n } while (str[pos] != ' ');\n Console.WriteLine(jumpSize);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "40bdb23f82d32a9892d5c968a91db20e", "src_uid": "1fc7e939cdeb015fe31f3cf1c0982fee", "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.Text;\nusing System.Threading.Tasks;\n\nnamespace _331a\n{\n class Program\n {\n static void Main(string[] args)\n {\n //Console.SetIn(File.OpenText(\"in.txt\"));\n var n = int.Parse(Console.ReadLine());\n\n int? x1 = null, x2 = null, y1 = null, y2 = null;\n for (int i = 0; i < n; i++)\n {\n var d = Console.ReadLine().Split(' ').Select(j => int.Parse(j)).ToArray();\n var x = d[0];\n var y = d[1];\n if (x1 == null)\n {\n x1 = x;\n }\n else\n {\n if (x1.Value != x)\n {\n x2 = x;\n }\n }\n\n if (y1 == null)\n {\n y1 = y;\n }\n else\n {\n if (y1.Value != y)\n {\n y2 = y;\n }\n }\n }\n\n if (x1 == null || x2 == null || y1 == null || y2 == null)\n {\n Console.WriteLine(-1);\n }\n else\n {\n var x = Math.Abs(x1.Value - x2.Value);\n var y = Math.Abs(y1.Value - y2.Value);\n Console.WriteLine(y * x);\n }\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["geometry", "implementation"], "code_uid": "e44f6a181fd089c56a0772cea9be75c2", "src_uid": "ba49b6c001bb472635f14ec62233210e", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeff\ufeff\ufeff\ufeff\ufeff\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 max = Double.MinValue;\n var maxA = 0;\n var maxB = 0;\n for (var b = 2; b < n; b++) {\n var a = n - b;\n if (a < b) {\n var gcd = Gcd(a, b);\n if (gcd == 1) {\n var curr = (double) a / b;\n if (max < curr) {\n max = curr;\n maxA = a;\n maxB = b;\n }\n }\n }\n }\n\n sw.WriteLine(maxA + \" \" + maxB);\n }\n\n private int Gcd(int a, int b)\n {\n if (b == 0) {\n return a;\n }\n\n return Gcd(b, a % b);\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", "math", "constructive algorithms"], "code_uid": "299e41a86887699df579c6e4bf4408ce", "src_uid": "0af3515ed98d9d01ce00546333e98e77", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\n\nnamespace ConsoleApp15\n{\n class Program\n {\n static void Main(string[] args)\n {\n var t = int.Parse(Console.ReadLine());\n\n while (t-- > 0)\n {\n var n = int.Parse(Console.ReadLine());\n\n if (n % 2 == 0)\n {\n var a = n / 2;\n Console.WriteLine(a + \" \" + a);\n continue;\n }\n var b = true;\n for (int i = 2; i * i <= n; i++)\n {\n if (n % i == 0)\n {\n Console.WriteLine((n / i) + \" \" + (n - (n / i)));\n b = false;\n break;\n }\n }\n\n if (b) { Console.WriteLine(\"1 \"+(n-1)); }\n\n\n }\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "greedy", "number theory"], "code_uid": "16fed0ffb66a4624c53047c1e987e423", "src_uid": "3fd60db24b1873e906d6dee9c2508ac5", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nclass Program_158A\n{\n static void Main()\n {\n int n = Convert.ToInt32(Console.ReadLine()), ans = 0;\n for (int i = 2; i < n; i++)\n for (int j = i + 1; j != n; j++)\n if ((Math.Sqrt(i * i + j * j) % 1 == 0) && (Math.Sqrt(i * i + j * j) <= n)) ans++;\n Console.WriteLine(ans);\n }\n}", "lang_cluster": "C#", "tags": ["brute force", "math"], "code_uid": "daa718b56f5ed5f0974d5f38c8411e05", "src_uid": "36a211f7814e77339eb81dc132e115e1", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\n\nnamespace K\n{\n\tclass MainClass\n\t{\n\t\tpublic static void Main (string[] args)\n\t\t{\n\t\t\tlong N = long.Parse(Console.ReadLine());\n\t\t\tConsole.WriteLine(N - N / 2 - N / 3 - N / 5 - N / 7\n\t\t\t\t+ N / 6 + N / 10 + N / 14 + N / 15 + N / 21 + N / 35\n\t\t\t\t- N / 30 - N / 42 - N / 70 - N / 105\n\t\t\t\t+ N / 210);\t\t\t\t\t\n\t\t}\n\t}\n}\n", "lang_cluster": "C#", "tags": ["math", "number theory"], "code_uid": "e9951d3491f1abda50f0c8b200d897fe", "src_uid": "e392be5411ffccc1df50e65ec1f5c589", "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 FORexam\n{\n class Program\n {\n static void Main(string[] args)\n {\n Console.ReadLine();\n int n = 0;\n string[] number = Console.ReadLine().Split('0');\n for (int i = 0; i < number.Length; i++)\n {\n n *= 10;\n if (number[i] != null)\n n += number[i].Length;\n\n }\n Console.WriteLine(n);\n }\n }\n}\n\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "a951eeac4670fb84167a480e075384a5", "src_uid": "a4b3da4cb9b6a7ed0a33a862e940cafa", "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;\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 int[] sum = new int[(1 << 15)];\n static int[] min = new int[(1 << 15)];\n static int[] max = new int[(1 << 15)];\n static int[] c = new int[15];\n static void dp(int number) {\n int exp = -1, aux = number;\n while (aux > 0) {\n aux /= 2;\n exp++;\n }\n aux = number - (1 << exp);\n sum[number] = sum[aux] + c[exp];\n max[number] = Math.Max(max[aux], c[exp]);\n min[number] = Math.Min(min[aux], c[exp]);\n if (min[number] == 0) {\n min[number] = c[exp];\n }\n }\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]), l = int.Parse(s[1]), r = int.Parse(s[2]), x = int.Parse(s[3]);\n c = Array.ConvertAll(Console.ReadLine().Split(' '), tz => int.Parse(tz));\n int vm = (1 << n), ans = 0;\n for (int i = 1; i < vm; i++) {\n dp(i);\n if (sum[i] >= l && sum[i] <= r && (max[i] - min[i]) >= x) {\n ans++;\n }\n }\n Console.Write(ans);\n //Console.ReadKey();\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "bitmasks"], "code_uid": "7c3995841d4ab704cf15037ef5c6175a", "src_uid": "0d43104a0de924cdcf8e4aced5aa825d", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Numerics;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace ConsoleApp2\n{\n class Program\n {\n static void Main(string[] args)\n {\n var arr = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();\n\n var vladik = true;\n var cnt = 1;\n while (arr[vladik ? 0 : 1] >= cnt)\n {\n arr[vladik ? 0 : 1] -= cnt;\n cnt++;\n vladik = !vladik;\n }\n\n Console.WriteLine(vladik ? \"Vladik\" : \"Valera\");\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "implementation"], "code_uid": "05fb580b78b7e5f1204df1040a6d464c", "src_uid": "87e37a82be7e39e433060fd8cdb03270", "difficulty": 800.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 string S;\n public void Solve()\n {\n var sc = new Scanner();\n N = sc.NextInt();\n K = sc.NextInt();\n S = sc.Next();\n\n /*\n * S\u306e\u90e8\u5206\u5217t\u3092\u53d6\u308b\u96c6\u5408\u306b\u52a0\u3048\u308b\n * \u30b3\u30b9\u30c8 n-|t|\n * \u91cd\u8907\u4e0d\u53ef\n * \n * \u30b5\u30a4\u30bak\u306e\u96c6\u5408\u3064\u304f\u308b\u6700\u5c0f\u30b3\u30b9\u30c8\n */\n\n /*\n * t = s 1\u500b\n * \n * |t| = |s|-1 N\u500b\n */\n\n var hs = new HashSet(StringComparer.Ordinal);\n hs.Add(S);\n var q = new Queue();\n q.Enqueue(S);\n\n long ans = 0;\n for (int i = 0; i < K; i++)\n {\n if (q.Count <= 0)\n {\n Console.WriteLine(\"-1\");\n return;\n }\n\n var d = q.Dequeue();\n ans += N - d.Length;\n if (d.Length <= 0) continue;\n char[] tmp = new char[d.Length - 1];\n for (int j = 0; j < d.Length - 1; j++)\n {\n tmp[j] = d[j + 1];\n }\n\n for (int j = 0; j < d.Length; j++)\n {\n var str = new string(tmp);\n if (hs.Add(str))\n {\n q.Enqueue(str);\n }\n if (j < d.Length - 1) tmp[j] = d[j];\n }\n\n }\n\n Console.WriteLine(ans);\n }\n\n public static void Main(string[] args) => new Program().Solve();\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}\n", "lang_cluster": "C#", "tags": ["dp", "implementation", "graphs", "shortest paths"], "code_uid": "43b83f95674c23ac2a3e1042d9dd1890", "src_uid": "ae5d21919ecac431ea7507cb1b6dc72b", "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 codeforce\n{\n class Program\n {\n static void Main(string[] args)\n {\n string s = Console.ReadLine();\n\n\n\n for (int i = 1; i <= 12; i++)\n {\n string[] ss = s.Split(' ');\n if (isCubeOk(Rotate(ss, i)))\n {\n Console.Write(\"YES\");\n //Console.ReadLine();\n return;\n }\n }\n\n\n Console.Write(\"NO\");\n\n //Console.ReadLine();\n }\n\n private static string[] Rotate(string[] ss,int r)\n {\n if(r==1)\n TW(ref ss, \"2,6 4,8 6,10 8,12 10,23 12,21 21,4 23,2\");\n else if (r == 2)\n TW(ref ss, \"2,23 4,21 6,2 8,4 10,6 12,8 23,10 21,12\");\n else if (r == 3)\n TW(ref ss, \"1,5 3,7 5,9 7,11 9,24 11,22 22,3 24,1\");\n else if (r == 4)\n TW(ref ss, \"5,1 7,3 9,5 11,7 1,24 3,22 24,9 22,11\");\n\n else if (r == 5)\n TW(ref ss, \"13,5 14,6 5,17 6,18 17,21 18,22 21,13 22,14\");\n else if (r == 6)\n TW(ref ss, \"5,13 6,14 17,5 18,6 21,17 22,18 13,21 14,22\");\n\n else if (r == 7)\n TW(ref ss, \"7,15 8,16 19,7 20,8 23,19 24,20 15,23 16,24\");\n else if (r == 8)\n TW(ref ss, \"15,7 16,8 7,19 8,20 19,23 20,24 23,15 24,16\");\n\n else if (r == 9)\n TW(ref ss, \"3,17 4,19 17,10 19,9 10,16 9,14 16,3 14,4\");\n else if (r == 10)\n TW(ref ss, \"17,3 19,4 10,17 9,19 16,10 14,9 3,16 4,14\");\n\n else if (r == 11)\n TW(ref ss, \"1,18 2,20 18,12 20,11 12,15 11,13 15,1 13,2\");\n else if (r == 12)\n TW(ref ss, \"18,1 20,2 12,18 11,20 15,12 13,11 1,15 2,13\");\n\n return ss;\n }\n \n\n private static bool isCubeOk(string[] ss)\n {\n int c = 0;\n for (int i = 0; i < 24; i=i+4)\n if (ss[i] == ss[i + 1] && ss[i] == ss[i + 2] && ss[i] == ss[i + 3])\n c++;\n if (c == 6)\n return true;\n return false;\n }\n\n private static void TW(ref string[] ss,string tw)\n {\n string[] pp = new string[ss.Length];\n ss.CopyTo(pp, 0);\n string[] ff = tw.Split(' ');\n for (int i = 0; i < ff.Length; i++)\n {\n int k1 = Int32.Parse(ff[i].Split(',')[0])-1;\n int k2 = Int32.Parse(ff[i].Split(',')[1])-1;\n ss[k2] = pp[k1];\n }\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "implementation"], "code_uid": "c92195d297d076b090f360f78afe67ad", "src_uid": "881a820aa8184d9553278a0002a3b7c4", "difficulty": 1500.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 K = cin.nextint;\n for (int i = 1; ; i++)\n {\n var S = i.ToString();\n if (K <= S.Length)\n {\n WriteLine(S[K - 1]);\n return;\n }\n\n K -= S.Length;\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": ["implementation"], "code_uid": "d6928ce5f51e9f1bea791c26a97327ee", "src_uid": "1503d761dd4e129fb7c423da390544ff", "difficulty": 1000.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 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 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\t\t\tvar n = getInt();\n\t\t\tvar weeks = n / 7;\n\t\t\tvar minA = weeks * 2;\n\t\t\tvar maxA = weeks * 2;\n\t\t\tif (n % 7 == 1)\n\t\t\t\tmaxA++;\n\t\t\tif (n % 7 >= 2)\n\t\t\t\tmaxA += 2;\n\t\t\tif (n % 7 == 6)\n\t\t\t\tminA++;\n\t\t\tConsole.WriteLine(\"{0} {1}\", minA, maxA);\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", "greedy", "constructive algorithms", "brute force"], "code_uid": "7c38d0fa304090116f0b50b7ab181820", "src_uid": "8152daefb04dfa3e1a53f0a501544c35", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Text;\n\nnamespace _61D2A\n{\n class Program\n {\n static void Main(string[] args)\n {\n var s = Console.ReadLine();\n\n if ((s.Length < \"127\".Length) || ((s.Length == \"127\".Length) && (string.Compare(s, \"127\") != 1)))\n {\n Console.WriteLine(\"byte\");\n }\n else if ((s.Length < \"32767\".Length) || ((s.Length == \"32767\".Length) && (string.Compare(s, \"32767\") != 1)))\n {\n Console.WriteLine(\"short\");\n }\n else if ((s.Length < \"2147483647\".Length) || ((s.Length == \"2147483647\".Length) && (string.Compare(s, \"2147483647\") != 1)))\n {\n Console.WriteLine(\"int\");\n }\n else if ((s.Length < \"9223372036854775807\".Length) || ((s.Length == \"9223372036854775807\".Length) && (string.Compare(s, \"9223372036854775807\") != 1)))\n {\n Console.WriteLine(\"long\");\n }\n else\n {\n Console.WriteLine(\"BigInteger\");\n }\n \n // Console.ReadLine();\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["strings", "implementation"], "code_uid": "463eb00e012acca08643e39e4060051b", "src_uid": "33041f1832fa7f641e37c4c638ab08a1", "difficulty": 1300.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 _371a\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 = readLongArray();\n var l1 = s[0];\n var r1 = s[1];\n var l2 = s[2];\n var r2 = s[3];\n var k = s[4];\n\n if (l2 > r1 || r2 < l1)\n {\n Console.WriteLine(0);\n return;\n }\n\n var l = Math.Max(l1, l2);\n var r = Math.Min(r1, r2);\n\n var res = r - l + 1;\n if (l <= k && k <= r)\n {\n res -= 1;\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 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": "de74df8e17c62649a8b634f540b53578", "src_uid": "9a74b3b0e9f3a351f2136842e9565a82", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Numerics;\nnamespace _304B\n{\n class Program\n {\n static void Main(string[] args)\n {\n DateTime date1 = DateTime.Parse(Console.ReadLine().Replace(':', '.'));\n DateTime date2 = DateTime.Parse(Console.ReadLine().Replace(':', '.'));\n Console.Write(Math.Abs((date1 - date2).TotalDays));\n }\n }\n}", "lang_cluster": "C#", "tags": ["brute force", "implementation"], "code_uid": "db59476bacbcbeea9965509ded4e897d", "src_uid": "bdf99d78dc291758fa09ec133fff1e9c", "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 ConsoleApp1\n{\n class 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 int m = input[1];\n\n int ans = Math.Min(n, m);\n\n if (ans % 2 == 0)\n {\n Console.WriteLine(\"Malvika\");\n }\n else\n {\n Console.WriteLine(\"Akshat\");\n }\n\n Console.Read();\n }\n }\n}", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "8875f81670996c5f1be8b6e433cb3599", "src_uid": "a4b9ce9c9f170a729a97af13e81b5fe4", "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": ["implementation"], "code_uid": "490dc03f8b388cd860943af7d984ecd6", "src_uid": "a349094584d3fdc6b61e39bffe96dece", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Linq;\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 string n = Console.ReadLine().Trim();\n int count = 0;\n for (int i = 0; i < n.Length; i++)\n {\n if (n[i] == '4')\n {\n count = count * 2 + 1;\n }\n else\n {\n count = count * 2 + 2;\n }\n }\n\n Console.WriteLine(count);\n }\n }\n}", "lang_cluster": "C#", "tags": ["brute force", "implementation", "combinatorics", "bitmasks"], "code_uid": "21978b30e68237d6665104a8f084eb50", "src_uid": "6a10bfe8b3da9c11167e136b3c6fb2a3", "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 inputs = Console.ReadLine();\n int[] arr = inputs.Split().Select(n=>Convert.ToInt32(n)).ToArray();\n int x = arr[0];\n int y = arr[1];\n int z = arr[2];\n if(x>y)\n {\n if(x>(z+y))\n {\n Console.WriteLine(\"+\");\n }\n else\n {\n Console.WriteLine(\"?\");\n }\n \n }\n else if (y > x)\n {\n if (y > (z + x))\n {\n Console.WriteLine(\"-\");\n }\n else\n {\n Console.WriteLine(\"?\");\n }\n\n }\n else\n \n {\n if(x==y&&z==0)\n {\n Console.WriteLine(\"0\");\n \n \n \n }\n else\n {\n Console.WriteLine(\"?\");\n }\n \n }\n Console.ReadLine();\n \n }\n }\n}\n", "lang_cluster": "C#", "tags": ["greedy"], "code_uid": "23ab17c776023008338a4c99b0818077", "src_uid": "66398694a4a142b4a4e709d059aca0fa", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nnamespace codeforces\n{\n\tclass MainClass\n\t{\n\t\tpublic static void Main (string[] args)\n\t\t{\n\t\t\tstring[] s = Console.ReadLine ().Split (' ');\n\t\t\tlong a = long.Parse (s [0]);\n\t\t\tlong b = long.Parse (s [1]);\n\n\t\t\tlong A = a, B = b;\n\t\t\tint m = 0, n = 0;\n\t\t\twhile (A!=0) {\n\t\t\t\tm++;\n\t\t\t\tA/=2;\n\t\t\t}\n\t\t\twhile (B!=0) {\n\t\t\t\tn++;\n\t\t\t\tB/=2;\n\t\t\t}\n\t\t\tint Q_m = 0, Q_n = 0;\n\t\t\tfor (int i = 1; i <=m-2; i++) \n\t\t\t\tQ_m += i;\n\t\t\tlong S1 = (long)Math.Pow (2, m) - 1;\n\t\t\tfor (int i = 1; i <=m-1; i++) {\n\t\t\t\tif (S1 - (long)Math.Pow (2, m - i - 1) < a)\n\t\t\t\t\tQ_m++;\n\t\t\t\telse\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t\tfor (int i = 1; i <=n-2; i++) \n\t\t\t\tQ_n += i;\n\t\t\tlong S2 = (long)Math.Pow (2, n) - 1;\n\t\t\tfor (int i = 1; i <=n-1; i++) {\n\t\t\t\tif (S2 - (long)Math.Pow (2, n - i - 1) <= b)\n\t\t\t\t\tQ_n++;\n\t\t\t\telse\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t\tConsole.WriteLine (Q_n-Q_m);\n\t\t}\n\t}\n}", "lang_cluster": "C#", "tags": ["brute force", "implementation", "bitmasks"], "code_uid": "5b895684b7144ea6b56ee288e5e72698", "src_uid": "581f61b1f50313bf4c75833cefd4d022", "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 var data = Console.ReadLine().Split().Select(int.Parse).ToArray();\n var a = data[0];\n var b = data[1];\n Console.WriteLine(Math.Min(a,b) +\" \" +((Math.Max(a,b)-Math.Min(a,b))/2));\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "implementation"], "code_uid": "e35c69b0f19071762b53a966de0514b7", "src_uid": "775766790e91e539c1cfaa5030e5b955", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\n\nnamespace keramer\n{\n class program\n {\n static void Main(string[] args)\n {\n int num = int.Parse(Console.ReadLine());\n if(num <= 10 )\n Console.WriteLine(0);\n else if ( num<=19)\n Console.WriteLine(4);\n else if (num == 20)\n Console.WriteLine(15);\n else if (num == 21)\n Console.WriteLine(4);\n else\n Console.WriteLine(0);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "2cc35b186118c2690900c2a85f917876", "src_uid": "5802f52caff6015f21b80872274ab16c", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Text;\nusing System.Collections.Generic;\n\nnamespace codeforces\n{\n class Program\n {\n const int N = 2000 * 100;\n\n static int[] a = new int[N];\n\n static bool check(ref int n, ref int m, ref int day)\n {\n long sum = 0;\n int ia = n - 1;\n int iday = 0;\n int num = 0;\n while (ia >= 0 && a[ia] > num)\n {\n sum += a[ia] - num;\n iday++;\n if (iday >= day)\n {\n iday -= day;\n num++;\n }\n ia--;\n }\n return sum >= m;\n }\n\n static void Main(string[] args)\n {\n var t = Console.ReadLine().Split(' ');\n int n = int.Parse(t[0]);\n int m = int.Parse(t[1]);\n t = Console.ReadLine().Split(' ');\n for (int i = 0; i < n; ++i)\n {\n a[i] = int.Parse(t[i]);\n }\n Array.Sort(a, 0, n);\n \n int l = 0;\n int r = n + 1;\n while (l + 1 < r)\n {\n int mid = (l + r) / 2;\n if (check(ref n, ref m, ref mid))\n {\n r = mid;\n }\n else\n {\n l = mid;\n }\n }\n Console.WriteLine(r == n + 1 ? \"-1\" : r.ToString());\n Console.Read();\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "greedy"], "code_uid": "8ec048b796e1106fbb1fb38e8f7615b7", "src_uid": "acb8a57c8cfdb849a55fa65aff86628d", "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 ConsoleApp12\n{\n class Program\n {\n static void Main(string[] args)\n {\n var a = Console.ReadLine().Split();\n string res = a[0][0].ToString();\n for (int i = 1; i < a[0].Length; ++i)\n {\n if (a[0][i] < a[1][0]) res += a[0][i];\n else break;\n }\n res += a[1][0];\n Console.WriteLine(res);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "sortings", "greedy"], "code_uid": "52db2623f7bcb254998027381237dfc1", "src_uid": "aed892f2bda10b6aee10dcb834a63709", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\n\nnamespace problem_solve_with_csharp\n{\n class Program\n {\n static void Main(string[] args)\n {\n long[] whk = Array.ConvertAll(Console.ReadLine().Split(), e => long.Parse(e));\n long w = whk[0];\n long h = whk[1];\n long k = whk[2];\n long sum = 0;\n long i=0;\n for (long j = 1; j <= k; j++)\n {\n sum += 2 * ((w - i) + (h - i)) - 4;\n i += 4;\n }\n Console.WriteLine(sum);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "implementation"], "code_uid": "87490b5d1bf1c833c20ccc298e25a052", "src_uid": "2c98d59917337cb321d76f72a1b3c057", "difficulty": 800.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 a = input[0];\n var b = input[1];\n var m = input[2];\n var r0 = input[3];\n var used = new int[m];\n var r = r0;\n int i = 0;\n for (; i <= m; i++)\n {\n r = (a * r + b) % m;\n if (used[r] > 0)\n break;\n used[r] = i+1;\n }\n Console.WriteLine(i + 1 - used[r]);\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": ["implementation", "number theory"], "code_uid": "9bf559608e4421200389fa80b9b17519", "src_uid": "9137197ee1b781cd5cc77c46f50b9012", "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.Collections;\n\nnamespace a2oj\n{\n class Program\n {\n\n\n static void Main(string[] args)\n {\n string s = Console.ReadLine();\n string[] part = s.Split('.');\n string[] dec = part[1].Split('e');\n\n\n\n int t = int.Parse(dec[1]);\n\n for (int i = 0; i < t; i++)\n {\n if (i < dec[0].Length)\n part[0] += dec[0][i];\n else\n {\n while(i 8)\n {\n number[1] = number[1] - 8;\n sum += arr[i] - 8;\n }\n else\n {\n arr[i] += sum;\n sum = 0;\n if (arr[i] > 8)\n {\n number[1] = number[1] - 8;\n sum += arr[i] - 8;\n }\n else\n number[1] = number[1] - arr[i];\n }\n\n if (number[1] <= 0)\n { \n Console.WriteLine(i + 1);\n return;\n }\n }\n }\n Console.WriteLine(-1);\n\n }\n\n }\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "e34aa43ed848e2509837a28bae3bd500", "src_uid": "24695b6a2aa573e90f0fe661b0c0bd3a", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections;\nusing System.Collections.Generic;\nusing System.Globalization;\nusing System.IO;\nusing System.Linq;\nusing System.Numerics;\nusing System.Text;\nusing System.Threading;\n\npublic class CodeForces87\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 = false;\n#else\nconst bool testing = false;\n#endif\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 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\n static void program(TextReader input)\n {\n //reader.ReadLine();\n //var data = reader.ReadLine().TrimEnd().Split(' ').Select(long.Parse).ToList();\n\n var n = long.Parse(reader.ReadLine());\n var ns = n.ToString();\n var result = int.MaxValue;\n for (var i = 0; i < Math.Pow(2, 10);i++){\n var s = Convert.ToString(i, 2).PadLeft(10).Substring(0, ns.Length);\n var news = new StringBuilder();\n for (var j = 0; j < s.Length;j++){\n if(s[j] == '1'){\n news.Append(ns[j]);\n }\n }\n\n var res = news.ToString();\n if(res.Length > 0 && res[0] != '0'){\n var pos = int.Parse(res);\n if(Math.Sqrt(pos) % 1 == 0){\n result = Math.Min(result, ns.Length - pos.ToString().Length);\n }\n }\n }\n Console.WriteLine(result == int.MaxValue ? -1 : result);\n }\n\n public static void Main(string[] args)\n {\n CultureInfo nonInvariantCulture = new CultureInfo(\"en-US\");\n Thread.CurrentThread.CurrentCulture = nonInvariantCulture;\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(\"3\\n2\\n4\\n\");\n Console.WriteLine(\"Test Case(1) => found :\");\n program(new StringReader(\"4 3\\n2\\n3\\n4\\n\"));\n Console.WriteLine();\n\n Console.WriteLine(\"Test Case(2) => expected :\");\n Console.WriteLine(\"13\\n3\\n8\\n9\\n\");\n Console.WriteLine(\"Test Case(2) => found :\");\n program(new StringReader(\"13 4\\n10\\n5\\n4\\n8\\n\"));\n Console.WriteLine();\n\n }\n}", "lang_cluster": "C#", "tags": ["brute force", "math", "implementation"], "code_uid": "0f3189744d9b398e9e498d7d5c7c57f0", "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;\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 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 int l = 0;\n int r = 0;\n int f = 0;\n bool w = false;\n for (int i = 0; i < n; i++)\n {\n string[] q = Console.ReadLine().Split();\n if (int.Parse(q[0]) == int.Parse(q[1]))\n {\n f++;\n }\n if ((int.Parse(q[0]) % 2 == 0 && int.Parse(q[1]) % 2 != 0) || (int.Parse(q[1]) % 2 == 0 && int.Parse(q[0]) % 2 != 0))\n {\n w = true;\n }\n l += int.Parse(q[0]);\n r += int.Parse(q[1]);\n }\n if (l % 2 == 0 && r % 2 == 0)\n {\n Console.WriteLine(0);\n }\n else if (l % 2 != 0 && r % 2 != 0 && n!=1 && f!=n && w)\n {\n \n Console.WriteLine(1);\n \n }\n else\n {\n Console.WriteLine(-1);\n }\n\n }\n }\n}", "lang_cluster": "C#", "tags": ["math", "implementation"], "code_uid": "01125d796b94cb738682c4c4ec612b53", "src_uid": "f9bc04aed2b84c7dd288749ac264bb43", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Text;\n\nnamespace A.Dubstep\n{\n class Program\n {\n static void Main()\n {\n string s = Console.ReadLine();\n Console.WriteLine(s.Replace(\"WUB\", \" \").Trim());\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["strings"], "code_uid": "4c9da5297b673bf0e63bac962c9ff161", "src_uid": "edede580da1395fe459a480f6a0a548d", "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 Actual_Shit_2\n{\n class Program\n {\n static void Main(string[] args)\n {\n int cnt = 0, cntmax = 0, n;\n string text;\n n = int.Parse(Console.ReadLine());\n text = Console.ReadLine();\n for (int i = 0; i < text.Length; i++)\n {\n if (text[i] == ' ')\n {\n if (cnt > cntmax)\n cntmax = cnt;\n cnt = 0;\n }\n else if (text[i] >= 'A' && text[i] <= 'Z')\n cnt++;\n }\n if (cnt > cntmax)\n cntmax = cnt;\n Console.WriteLine(cntmax);\n }\n }\n}\n\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "097672306da7d779a1b8fdcc484f8694", "src_uid": "d3929a9acf1633475ab16f5dfbead13c", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nclass Ball{\n static long findNum(long[] c, long[] req){\n c[0] = c[0] - 2 * req[0];\n c[0] = c[0] - req[1];\n c[1] = c[1] - req[1];\n c[1] = c[1] - 3 * req[2];\n long sum = 0;\n for(int i=0;i<2;i++){\n if(c[i] < 0){\n sum = sum + Math.Abs(c[i]);\n }\n }\n return sum;\n }\n static void Main(string[] args){\n string[] str = Console.ReadLine().Trim().Split(' ');\n long[] c = Array.ConvertAll(str, Int64.Parse);\n str = Console.ReadLine().Trim().Split(' ');\n long[] req = Array.ConvertAll(str, Int64.Parse);\n Console.WriteLine(findNum(c, req));\n }\n}", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "33dea15d6778d94938862666778b9133", "src_uid": "35202a4601a03d25e18dda1539c5beba", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Globalization;\nusing System.IO.Pipes;\nusing System.Linq;\nusing System.Runtime.InteropServices;\nusing System.Text;\n\nnamespace ContestV\n{\n internal class Program\n {\n \n\n \n\n private static void Main(string[] args)\n {\n\n\n var s = Console.ReadLine().Split(' ');\n\n int k1 = int.Parse(s[0]),\n k2 = int.Parse(s[1]),\n k3 = int.Parse(s[2]);\n string ans = \"YES\";\n var ss = Console.ReadLine().Split(' ');\n\n int m1 = int.Parse(ss[0]),\n m2 = int.Parse(ss[1]),\n m3 = int.Parse(ss[2]);\n\n int n = Convert.ToInt32(Console.ReadLine());\n\n int k = (k1 + k2 + k3)/5;\n if ((k1 + k2 + k3)%5 > 0) k++;\n\n int m = (m1 + m2 + m3)/10;\n if ((m1 + m2 + m3) % 10 > 0) m++;\n\n if (n < m + k) ans = \"NO\";\n\n Console.WriteLine(ans);\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": ["implementation"], "code_uid": "f947e35c560619905c25f8f85175ef65", "src_uid": "fe6301816dea7d9cea1c3a06a7d1ea7e", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\n\nnamespace wndkj\n{\n\tclass MainClass\n\t{\n\t\tpublic static void Main (string[] args)\n\t\t{\n\t\t\tstring[] a = Console.ReadLine ().Split (' ');\n\t\t\tint b = int.Parse (a [0]);\n\t\t\t\n\t\t\t\n\t\t\tdouble c = double.Parse (a [1]);\n\t\t\tdouble d = double.Parse (a[2]);\n\t\t\tint e = int.Parse (a [3]);\n\t\t\t\n\t\t\t\n\t\t\t//Console.WriteLine(e);\n\t\t\tdouble q = (Math.Ceiling(c / d) * b) / e;\n\t\t\tConsole.WriteLine(Math.Ceiling(q));\n\t\t}\n\t}\n}", "lang_cluster": "C#", "tags": ["math"], "code_uid": "b4d788da4f1c743e607580a04903623b", "src_uid": "73f0c7cfc06a9b04e4766d6aa61fc780", "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\n\tclass contest\n\t{\n\t\t\t\t\n\t\t\n\t\tstatic void Main(string[] args)\n\t\t{\n\t\t var num = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();\n \n\n Array.Sort(num);\n long mxTable = num.Min() ;\n\n var cp = new long[3];\n num.CopyTo(cp, 0);\n long min = num.Min();\n long sum = num.Sum();\n\n \n \n\n\n num.CopyTo(cp, 0);\n\n if (cp[0] > 0 || cp[1] > 0)\n {\n long tmp = 0;\n\n \n\n\n \n\n while (cp[1] > 0 && cp[2] > 1)\n {\n long red = 0;\n //if(cp[0]>1) //(cp[0]>1 && cp[0]*2 >= cp[1])\n //{\n // red = Math.Min(cp[1], Math.Min( cp[0]/2 , cp[2] / 2));\n\n //}\n //else red = Math.Min(cp[1], cp[2] / 2);\n\n if (cp[1] >= 4) red = cp[1] / 4;\n else red = Math.Min(cp[1],cp[2]/2);\n\n cp[1] -= red;\n cp[2] -= red * 2;\n\n tmp += red;\n Array.Sort(cp);\n }\n\n if (cp[0] == 1 || cp[2]==3) tmp++;\n //if (sum % 2 == 1) tmp++;\n\n mxTable = Math.Max(mxTable, tmp);\n }\n\n\n\n Console.WriteLine(mxTable);\n\n\t\t\t\n\n\n\n\t\t\n }\n\t\t\n\t\t\n\t\t\t\n\t}\n", "lang_cluster": "C#", "tags": ["greedy"], "code_uid": "c73346a2b31539d39158922ec5160823", "src_uid": "bae7cbcde19114451b8712d6361d2b01", "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 ConsoleApp1\n{\n class Program\n {\n static void Main(string[] args)\n {\n bool ok = false;\n List inp = Console.ReadLine().Split(' ').ToList();\n for(int i = 0;i ind = new List();\n ind.AddRange(new int[] { 0, 1, 2, 3 });\n ind.Remove(i);\n if (Int32.Parse(inp[i]) == Int32.Parse(inp[ind[0]]) + Int32.Parse(inp[ind[1]]) + Int32.Parse(inp[ind[2]]))\n {\n ok = true;\n break;\n }\n }\n\n for (int i = 0; i < inp.Count(); i++)\n {\n for (int j = 0; i < inp.Count(); i++)\n {\n if (i == j)\n continue;\n List ind = new List();\n ind.AddRange(new int[] { 0, 1, 2, 3 });\n ind.Remove(i);\n ind.Remove(j);\n if (Int32.Parse(inp[i]) + Int32.Parse(inp[j]) == Int32.Parse(inp[ind[0]]) + Int32.Parse(inp[ind[1]]))\n {\n ok = true;\n break;\n }\n }\n }\n\n if (ok)\n Console.WriteLine(\"YES\");\n else\n Console.WriteLine(\"NO\");\n Console.ReadLine();\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "implementation"], "code_uid": "224125c84781c69f32eec119dfe51a1d", "src_uid": "5a623c49cf7effacfb58bc82f8eaff37", "difficulty": 800.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;\nnamespace Program {\n\tpublic class Solver {\n\t\tRandom rnd = new Random();\n\t\tpublic void Solve() {\n\t\t\t//\n\t\t\t//dp[i,a,b] = i \u56de\u64cd\u4f5c\u3057\u305f\u3042\u3068\u30010 \u304c\u6765\u308b\u3079\u304d\u7b87\u6240\u306b\u3042\u308b 1 \u306e\u500b\u6570\u30011 \u304c\u6765\u308b\u3079\u304d\u7b87\u6240\u306b\u3042\u308b 0 \u306e\u500b\u6570\n\t\t\t//dp[i+1,a-1,b-1]+=dp[i,a,b]*a*b/n^2;\n\t\t\t//dp[i+1,a,b]+=dp[i,a,b]*(A*A+B*B + a*(B-b) + b*(A-a))/n^2\n\t\t\t//dp[i+1,a+1,b+1]+=dp[i,a,b]*(A-a)*(B-b)/n^2\n\n\t\t\tvar n = ri; var k = ri;\n\t\t\tvar A = Enumerate(n, x => ri);\n\t\t\tvar K = n - A.Sum();\n\t\t\tvar M = n - K;\n\t\t\tvar B = Enumerate(n, x => x < K ? 0 : 1);\n\t\t\tvar p = Enumerate(n, x => x).Count(x => A[x] != B[x]) / 2;\n\t\t\tvar coef = ModInt.Inverse(n * (n - 1) / 2);\n\t\t\tvar mat = new Matrix(n + 1, n + 1);\n\t\t\t//mat[i,j] = j->i\n\t\t\tfor (int j = 0; j <= n; j++) {\n\t\t\t\tif (j != 0) mat[j - 1, j] += j * j * coef.num;\n\t\t\t\tmat[j, j] += (K * (K - 1) / 2 + M * (M - 1) / 2 + j * (M - j) + j * (K - j)) * coef.num;\n\t\t\t\tif (j != n) mat[j + 1, j] += (K - j) * (M - j) * coef.num;\n\t\t\t}\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\tmat[i, j] %= ModInt.Mod;\n\t\t\tvar res = Matrix.Pow(mat, k);\n\t\t\tvar vec = new Matrix(n + 1, 1); vec[p, 0] = 1;\n\t\t\tvar ans = (res * vec)[0, 0];\n\t\t\tConsole.WriteLine(ans);\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\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)1e9 + 7;\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\n#region Matrix\npublic class Matrix {\n\tint row, col;\n\tpublic N[] mat;\n\t/// \n\t/// \u884c \u5217\u76ee\u306e\u8981\u7d20\u3078\u306e\u30a2\u30af\u30bb\u30b9\u3092\u63d0\u4f9b\u3057\u307e\u3059\u3002\n\t/// \n\t/// \u884c\u306e\u756a\u53f7\n\t/// \u5217\u306e\u756a\u53f7\n\tpublic N this[int r, int c] {\n\t\tget { return mat[r * col + c]; }\n\t\tset { mat[r * col + c] = value; }\n\t}\n\tpublic Matrix(int r, int c) {\n\t\trow = r; col = c;\n\t\tmat = new N[row * col];\n\t}\n\tpublic static Matrix operator *(Matrix l, Matrix r) {\n\t\tSystem.Diagnostics.Debug.Assert(l.col == r.row);\n\t\tvar ret = new Matrix(l.row, r.col);\n\t\tfor (int i = 0; i < l.row; i++)\n\t\t\tfor (int k = 0; k < l.col; k++)\n\t\t\t\tfor (int j = 0; j < r.col; j++)\n\t\t\t\t\tret.mat[i * r.col + j] = (ret.mat[i * r.col + j] + l.mat[i * l.col + k] * r.mat[k * r.col + j]) % ModInt.Mod;\n\t\treturn ret;\n\t}\n\t/// \n\t/// ^ \u3092 O(^3 log ) \u3067\u8a08\u7b97\u3057\u307e\u3059\u3002\n\t/// \n\tpublic static Matrix Pow(Matrix m, long n) {\n\t\tvar ret = new Matrix(m.row, m.col);\n\t\tfor (int i = 0; i < m.row; i++)\n\t\t\tret.mat[i * m.col + i] = 1;\n\t\tfor (; n > 0; m *= m, n >>= 1)\n\t\t\tif ((n & 1) == 1)\n\t\t\t\tret = ret * m;\n\t\treturn ret;\n\n\t}\n\tpublic N[][] Items {\n\t\tget {\n\t\t\tvar a = new N[row][];\n\t\t\tfor (int i = 0; i < row; i++) {\n\t\t\t\ta[i] = new N[col];\n\t\t\t\tfor (int j = 0; j < col; j++)\n\t\t\t\t\ta[i][j] = mat[i * col + j];\n\t\t\t}\n\t\t\treturn a;\n\t\t}\n\t}\n}\n#endregion\n", "lang_cluster": "C#", "tags": ["probabilities", "matrices", "dp", "combinatorics"], "code_uid": "844d234c7acb80746c2fc3f17979d9f0", "src_uid": "77f28d155a632ceaabd9f5a9d846461a", "difficulty": 2300.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 N = int.Parse(str[0]);\n int M = int.Parse(str[1]);\n str = Console.ReadLine().Split(' ');\n bool[] us = new bool[N+1];\n int[] perm = new int[N];\n int[] A = new int[M];\n for(int i=0;i b)\n {\n d[i] = 1;\n d[j] = 1;\n c[i] = b;\n c[j] = b;\n }\n else\n {\n d[i] = 0;\n d[j] = 0;\n c[i] = a;\n c[j] = a;\n }\n }\n }\n else if (d[i] == 1 && d[n - i - 1] == 0)\n {\n Console.WriteLine(-1);\n return;\n }\n }\n int cost = 0;\n for (int i = 0; i < n; i++)\n {\n cost += c[i];\n }\n Console.WriteLine(cost);\n }\n}", "lang_cluster": "C#", "tags": ["greedy"], "code_uid": "2fc7f63f9a97fc659b4b304fefb452d9", "src_uid": "af07223819aeb5bd6ded4340c472b2b6", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nnamespace _954A\n{\n\tclass Program\n\t{\n\t\tpublic static void Main(string[] args)\n\t\t{\n\t\t\tint n = int.Parse(Console.ReadLine());\n\t\t\tstring s = Console.ReadLine();\n\t\t\twhile (true)\n\t\t\t{\n\t\t\t\tint pos1 = s.IndexOf(\"UR\");\n\t\t\t\tint pos2 = s.IndexOf(\"RU\");\n\t\t\t\tif (pos1 == -1 && pos2 == -1)\n\t\t\t\t\tbreak;\n\t\t\t\tint pos;\n\t\t\t\tif (pos1 == -1)\n\t\t\t\t\tpos = pos2;\n\t\t\t\telse if (pos2 == -1)\n\t\t\t\t\tpos = pos1;\n\t\t\t\telse\n\t\t\t\t\tpos = Math.Min(pos1, pos2);\n\t\t\t\ts = s.Substring(0, pos) + \"D\" + s.Substring(pos + 2);\n\t\t\t}\n\t\t\tConsole.WriteLine(s.Length);\n\t\t}\n\t}\n}", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "fcefd8404559bc89f01a5cb789d753ab", "src_uid": "986ae418ce82435badadb0bd5588f45b", "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 int i, x = int.Parse(Console.ReadLine());\n List D = new List();\n string W = Console.ReadLine();\n List Words = new List(W.Split(' '));\n foreach (string w in Words)\n if (w.Length > 0) D.Add(int.Parse(w));\n D.Sort();\n Console.Write(D[D.Count-1] + \" \");\n for(i=1; i < D.Count-1; i++)\n Console.Write(D[i] + \" \");\n Console.WriteLine(D[0]);\n \n }\n }\n}\n", "lang_cluster": "C#", "tags": ["sortings", "constructive algorithms", "implementation"], "code_uid": "f2d6a46e55dacbe4930019ef26e366f4", "src_uid": "4408eba2c5c0693e6b70bdcbe2dda2f4", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.IO;\nusing System.Text;\n\nnamespace Lazy_Security_Guard\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 int min = int.MaxValue;\n for (int i = 1; i <= n; i++)\n {\n int k = (n + i - 1)/i;\n int p = 2*(i + k);\n min = Math.Min(min, p);\n }\n\n writer.WriteLine(min);\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", "geometry"], "code_uid": "28b30959cdcce0cfd18461cf91666310", "src_uid": "414cc57550e31d98c1a6a56be6722a12", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": ".NET Core C#", "source_code": "using System;\nusing System.Linq;\nclass Program\n{\n static void Main(string[] args)\n {\n Problem1154C();\n }\n\n static void Problem1154C()\n {\n string s = Console.ReadLine();\n var arr = s.Split(' ').Select(x => Convert.ToInt32(x)).ToArray();\n Console.WriteLine(Problem1154C(arr[0], arr[1], arr[2]));\n }\n static int Problem1154C(int a, int b, int c)\n {\n int[] result = new int[7];\n int commonWeeks = new[] { a / 3, b / 2, c / 2 }.Min() - 1;\n\n for (int i = 0; i < 7; i++)\n {\n result[i] = Problem1154C(i, a - 3 * commonWeeks, b - 2 * commonWeeks, c - 2 * commonWeeks);\n }\n return commonWeeks * 7 + result.Max();\n }\n static int Problem1154C(int i, int a, int b, int c)\n {\n int count = 0;\n for (int j = i; ; j++)\n {\n var r = Problem1154C(j, ref a, ref b, ref c, ref count);\n if (r == true)\n return count;\n }\n\n throw new Exception();\n }\n\n static bool Problem1154C(int i, ref int a, ref int b, ref int c, ref int count)\n {\n switch (i % 7 + 1)\n {\n case 1:\n case 4:\n case 7:\n if (a == 0)\n return true;\n else\n {\n a--;\n count++;\n return false;\n }\n case 2:\n case 6:\n if (b == 0)\n return true;\n else\n {\n b--;\n count++;\n return false;\n }\n case 3:\n case 5:\n if (c == 0)\n return true;\n else\n {\n c--;\n count++;\n return false;\n }\n }\n throw new Exception();\n }\n}", "lang_cluster": "C#", "tags": ["math", "implementation"], "code_uid": "0cb29f9519143265f5b56ada41242694", "src_uid": "e17df52cc0615585e4f8f2d31d2daafb", "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 CF624A\n\t{\n\t\tpublic void Solve(XOI xoi)\n\t\t{\n\t\t\tint L, D, V1, V2;\n\t\t\tdouble ans;\n\n\t\t\tD = xoi.ReadInt();\n\t\t\tL = xoi.ReadInt();\n\t\t\tV1 = xoi.ReadInt();\n\t\t\tV2 = xoi.ReadInt();\n\n\t\t\tans = (double)(L - D) / (double)(V1 + V2);\n\n\t\t\txoi.o.WriteLine(ans.ToString(\"F6\", System.Globalization.CultureInfo.InvariantCulture));\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 CF624A()).Solve(new XOI());\n\t\t}\n\t}\n}\n\nnamespace CCF_XOI\n{ // 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{ // 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"], "code_uid": "648b7b4405afa99a92295d5f085b6bbd", "src_uid": "f34f3f974a21144b9f6e8615c41830f5", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\n\nnamespace ConsoleApplication5\n{\n class Program\n {\n static void Main(string[] args)\n {\n string s = Console.ReadLine();\n int n = s.Length;\n\n SortedSet ss = new SortedSet();\n\n for (int i = 0; i <= n; ++i)\n {\n for (char ch = 'a'; ch <= 'z'; ++ch)\n {\n ss.Add(s.Insert(i, ch.ToString()));\n }\n \n }\n\n Console.WriteLine(ss.Count);\n Console.Read();\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "math", "strings"], "code_uid": "30da5b5c96d616bcef45c4455d920741", "src_uid": "556684d96d78264ad07c0cdd3b784bc9", "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\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[] days = { \"monday\", \"tuesday\", \"wednesday\", \"thursday\", \"friday\", \"saturday\", \"sunday\" };\n\n public void Solve()\n {\n int a = Array.IndexOf(days, ReadToken());\n int b = Array.IndexOf(days, ReadToken());\n int x = (b - a + 7) % 7;\n Write(x == 0 || x == 2 || x == 3 ? \"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": ["implementation"], "code_uid": "ead3311bef3a27a613208cf07bfe10d1", "src_uid": "2a75f68a7374b90b80bb362c6ead9a35", "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 MUH_and_Sticks\n{\n class Program\n {\n static void Main(string[] args)\n {\n int[] a = Array.ConvertAll(Console.ReadLine().Split(' '), Int32.Parse);\n Array.Sort(a);\n int count = 0;\n if (a[0] == a[1] && a[1] == a[2] && a[2] == a[3])\n {\n if (a[4] == a[5])\n Console.WriteLine(\"Elephant\");\n else\n Console.WriteLine(\"Bear\");\n }\n else if (a[2] == a[3] && a[3] == a[4] && a[4] == a[5])\n {\n if ((a[0] == a[1]))\n Console.WriteLine(\"Elephant\");\n else\n Console.WriteLine(\"Bear\");\n }\n else\n {\n \n if(a[0] == a[1] && a[1] == a[2] && a[2] == a[3]|| a[1] == a[2] && a[2] == a[3] && a[3] == a[4]|| a[2] == a[3] && a[3] == a[4] && a[4] == a[5])\n Console.WriteLine(\"Bear\");\n else\n Console.WriteLine(\"Alien\");\n }\n Console.ReadLine();\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "1a89e51d11de66099a86a9aaa4933a71", "src_uid": "43308fa25e8578fd9f25328e715d4dd6", "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 ConsoleApplication1\n{\n class Program\n {\n static void Main(string[] args)\n {\n Console.ReadLine();\n var value = Console.ReadLine();\n while (value.Contains(\"__\"))\n {\n value = value.Replace(\"__\", \"_\");\n }\n\n value = value.Trim('_');\n value = value + '_';\n bool b = false;\n bool w = false;\n\n int maxLen = 0;\n int count = 0;\n int currentLen = 0;\n for (int i = 0; i < value.Length; i++)\n {\n if (value[i] != '(' && value[i] != ')' && value[i] != '_') // letter\n {\n if (!w)\n {\n w = true;\n currentLen = 0;\n }\n currentLen++;\n }\n else\n {\n if (b & w)\n {\n count++;\n currentLen = 0;\n }\n else\n {\n if (currentLen > maxLen && !b)\n {\n maxLen = currentLen;\n }\n }\n w = false;\n if (value[i] == '(') b = true;\n if (value[i] == ')') b = false;\n }\n \n }\n Console.WriteLine(String.Format(\"{0} {1}\", maxLen, count));\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["expression parsing", "strings", "implementation"], "code_uid": "8f29274d22f1914471fdc4578b6dbf77", "src_uid": "fc86df4931e787fa3a1a40e2aecf0b92", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\n\nnamespace _519C___Codeforces\n{\n class Program\n {\n static void Main()\n {\n string[] nums = Console.ReadLine().Split();\n double n = double.Parse(nums[0]);\n double m = double.Parse(nums[1]);\n\n if (n == 0 || m == 0) Console.WriteLine(0);\n else if (n / m <= 0.5) Console.WriteLine(n);\n else if (m / n <= 0.5) Console.WriteLine(m);\n else\n {\n Console.WriteLine((int)(n + m) / 3);\n }\n }\n }\n}", "lang_cluster": "C#", "tags": ["math", "greedy", "implementation", "number theory"], "code_uid": "ca600cad0cc1c2a05d37cd5bbb44ab15", "src_uid": "0718c6afe52cd232a5e942052527f31b", "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 ConsoleApplication34\n{\n\n class Program\n {\n static void Main(string[] args)\n {\n double w, s, e;\n\n string[] q = Console.ReadLine().Split();\n double a = double.Parse(q[0]);\n double b = double.Parse(q[1]);\n double c = double.Parse(q[2]);\n double d = double.Parse(q[3]); \n double x =Math.Ceiling((a/c));\n if (x * b > b + d)\n Console.WriteLine(\"YES\");\n else\n Console.WriteLine(\"NO\");\n\n\n\n }\n }\n}", "lang_cluster": "C#", "tags": ["brute force", "implementation"], "code_uid": "e1f740d01e372d419ab24f7478281eaf", "src_uid": "32c866d3d394e269724b4930df5e4407", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Linq;\n\nnamespace main\n{\n internal class Program\n {\n private static void Main(string[] args)\n {\n string input = Console.ReadLine();\n if (input.Length != 1)\n {\n foreach (char c in input.Where(c => Convert.ToInt32(c.ToString()) > 4))\n input = input.Replace(c.ToString(), (9 - Convert.ToInt32(c.ToString())).ToString());\n if (input[0] == '0')\n {\n input = input.Remove(0, 1);\n input = \"9\" + input;\n }\n }\n Console.WriteLine(input);\n }\n }\n}", "lang_cluster": "C#", "tags": ["greedy", "implementation"], "code_uid": "6e41d81f4b3eeeaae221fd832888c6da", "src_uid": "d5de5052b4e9bbdb5359ac6e05a18b61", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nclass P {\n static void Main() {\n int n = int.Parse(Console.ReadLine()), cnt = 0, i = 1;\n for (; i < Math.Pow(2, 10) - 1; ++i) {\n var v = int.Parse(Convert.ToString(i, 2));\n if (v <= n) { cnt++; } else { break; }\n }\n Console.WriteLine(cnt);\n }\n}", "lang_cluster": "C#", "tags": ["brute force", "math", "implementation"], "code_uid": "8d2b671daff05cbfe7f9de72e0f3b7d4", "src_uid": "64a842f9a41f85a83b7d65bfbe21b6cb", "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 public class Program\n {\n public static void Main()\n {\n int[] parameters;\n int[] hook_costs;\n int num_guests, profit = 0, incr = 0;\n\n parameters = Console.ReadLine().Split(' ').Select(n => Convert.ToInt32(n)).ToArray();\n hook_costs = Console.ReadLine().Split(' ').Select(n => Convert.ToInt32(n)).ToArray();\n num_guests = Convert.ToInt32(Console.ReadLine());\n\n Array.Sort(hook_costs);\n\n for (int i = 0; i < num_guests; ++i)\n {\n if (incr < hook_costs.Length)\n {\n profit += hook_costs[incr];\n ++incr;\n }\n else\n profit -= parameters[1];\n }\n\n Console.WriteLine(profit);\n }\n }\n}", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "1e09460d2045d7042133049fe4af7b62", "src_uid": "5c21e2dd658825580522af525142397d", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nnamespace _820A\n{\n class Program\n {\n static void Main(string[] args)\n {\n int[] input = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);\n int c = input[0], v0 = input[1], v1 = input[2], a = input[3], l = input[4], v = v0, result = 0;\n while (c > 0)\n {\n c -= v;\n if (result > 0)\n c += l;\n result++;\n v = Math.Min(v + a, v1);\n }\n Console.WriteLine(result);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "6ef8faaaaf4b013cbc9574b3b4e1d5b2", "src_uid": "b743110117ce13e2090367fd038d3b50", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\n\nnamespace ConsoleApp2\n{\n class Program\n {\n static void Main(string[] args)\n {\n string data = Console.ReadLine();\n data = data.Remove(0, 1);\n int num = Convert.ToInt32(data);\n if (num % 2 == 0)\n Console.WriteLine(\"0\");\n else Console.WriteLine(\"1\");\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "22213877de80c564b036762857276641", "src_uid": "e52bc741bb72bb8e79cf392b2d15354f", "difficulty": null, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Text;\n\nclass main {\n\n public static void Main(string[] args)\n {\n int[,] street = new int[4,4];\n string[] line;\n for (int i = 0; i < 4; i++) {\n line = Console.ReadLine().Split(' ');\n for (int j = 0; j < 4; j++)\n street[i,j] = int.Parse(line[j]);\n }\n int[] crash = new int[4];\n for (int i = 0; i < 4; i++)\n for (int j = 0; j < 3; j++)\n if (street[i,j] == 1) {\n crash[i]++;\n crash[(i + 3 - j) % 4]++;\n }\n\n bool answer = true;\n for (int i = 0; i < 4; i++)\n if (street[i,3] == 1 && crash[i] > 0) {\n answer = false;\n break;\n }\n\n Console.WriteLine((answer ? \"NO\": \"YES\"));\n }\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "c62023b8bfbf9b513046a0edc566fdc7", "src_uid": "44fdf71d56bef949ec83f00d17c29127", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nnamespace codeforces\n{\n class Program\n {\n public 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 int k = int.Parse(str[2]);\n Console.WriteLine(Beaver(n, m, k));\n \n }\n\n public static string Beaver(int n, int m, int k) {\n if (n % 2 == 0)\n return \"Marsel\";\n if(m<=k)\n return \"Marsel\";\n\n for (Int64 i = 1; i * i <= m; i++) {\n if (m % i == 0 && (m / i) >= k && i!= 1 && m > i) return \"Timur\";\n if (m % i == 0 && i >= k && m > i) return \"Timur\";\n }\n return \"Marsel\";\n }\n }\n }", "lang_cluster": "C#", "tags": ["dp", "number theory", "games"], "code_uid": "10e84bf7048fdb8f600573a1b4632a4b", "src_uid": "4a3767011ddac874efa021fff7c94432", "difficulty": 2000.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[35]);\n for (int i = 1; i < 35; 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 < 35; h++)\n dp[v][h] = 1.0;\n var ps = new List();\n for (int h = 0; h <= 35; 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 if (h + 1 >= 35) continue;\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 if (h + 1 >= 35) continue;\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 < 35; 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": "33efd1cfe444b38d7fe3c465426e85bb", "src_uid": "55affe752cb214d1e4031a9e3972597b", "difficulty": 2700.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeff\ufeff\ufeff\ufeff\ufeff\ufeff\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.NextInt64();\n var k = sr.NextInt64();\n if (n == k) {\n sw.WriteLine(\"0 0\");\n return;\n }\n if (k == 0) {\n sw.WriteLine(\"0 0\");\n return;\n }\n var min = 1;\n var max = 0L;\n if (k >= n / 2)\n max = n - k;\n else\n max = Math.Min(k * 2, n - k);\n\n sw.WriteLine(min + \" \" + max);\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", "constructive algorithms"], "code_uid": "3633fc4c5872c7dfd27f000bc02a6a72", "src_uid": "bdccf34b5a5ae13238c89a60814b9f86", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections;\nusing System.Collections.Generic;\n\npublic class CF_Chord\n{\n static string[] N = new string[] { \"C\", \"C#\", \"D\", \"D#\", \"E\", \"F\", \"F#\", \"G\", \"G#\", \"A\", \"B\", \"H\" };\n\n public static int dist(string a, string b)\n {\n int pos1 = Array.IndexOf(N, a);\n int pos2 = Array.IndexOf(N, b);\n int d = pos2 - pos1;\n if (d < 0) d = 12 + d;\n return d;\n }\n\n public static string chord(string a, string b, string c)\n {\n int d1 = dist(a, b);\n int d2 = dist(b, c);\n\n string ans = \"strange\";\n if (d1 == 4 && d2 == 3) ans = \"major\";\n else if (d1 == 3 && d2 == 4) ans = \"minor\";\n return ans;\n }\n\n public static void Main(string[] args)\n {\n string[] notes = Console.ReadLine().Split();\n int n = notes.Length;\n string a = notes[0];\n string b = notes[1];\n string c = notes[2];\n int d1 = dist(notes[0], notes[1]);\n int d2 = dist(notes[1], notes[2]);\n\n string ans = chord(a, b, c);\n if (ans == \"strange\") ans = chord(a, c, b);\n if (ans == \"strange\") ans = chord(b, a, c);\n if (ans == \"strange\") ans = chord(b, c, a);\n if (ans == \"strange\") ans = chord(c, a, b);\n if (ans == \"strange\") ans = chord(c, b, a);\n\n Console.WriteLine(ans);\n Console.ReadLine();\n }\n}", "lang_cluster": "C#", "tags": ["brute force", "implementation"], "code_uid": "7b9f0d35afe78d967df85e6c9bd55ab3", "src_uid": "6aa83c2f6e095848bc63aba7d013aa58", "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 TK1\n{\n class Program\n {\n static void Main(string[] args)\n {\n var t = Console.ReadLine().Split().Select(int.Parse).ToArray();\n int n = t[0];\n int a = t[1];\n int b = t[2];\n int i = 0;\n while (a != b)\n {\n a = (int) Math.Ceiling(a/2.0);\n b = (int) Math.Ceiling(b/2.0);\n i += 1;\n }\n int il = (int) Math.Ceiling(Math.Log(n, 2));\n if ( il == i)\n {\n Console.WriteLine(\"Final!\");\n }\n else\n {\n Console.WriteLine(i);\n }\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["constructive algorithms", "implementation"], "code_uid": "cb1c8376d58f170bfcb9be01edb7d273", "src_uid": "a753bfa7bde157e108f34a28240f441f", "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 long GetCost(long mask, long[] c)\n {\n long ans = 0;\n\n for (int i = 0; i < c.Length; i++)\n if ((mask & (1L << i)) > 0)\n ans += c[i];\n\n return ans;\n }\n\n private static void Main(string[] args)\n {\n var n = RI();\n var L = RL();\n var c = new long[32];\n for (int i = 0; i < n; i++)\n c[i] = RL();\n\n for (int i = 1; i < n; i++)\n c[i] = Math.Min(c[i], c[i - 1] + c[i - 1]);\n\n for (int i = n; i < c.Length; i++)\n c[i] = c[i - 1] + c[i - 1];\n\n\n for (int i = c.Length - 2; i >= 0; i--)\n c[i] = Math.Min(c[i], c[i + 1]);\n\n var ans = GetCost(L, c);\n bool work = true;\n while (work)\n {\n var d = L & (L - 1);\n d = L - d;\n if (d == L)\n {\n work = false;\n }\n\n L += d;\n ans = Math.Min(ans, GetCost(L, c));\n }\n\n Console.WriteLine(ans);\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": ["greedy", "dp", "bitmasks"], "code_uid": "95260a1735738d85da312856ddb65bb3", "src_uid": "04ca137d0383c03944e3ce1c502c635b", "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 parazit\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 if (n > 2)\n {\n string[] mas = new string[n / 2];\n string s1 = \"ogo\";\n for (int i = 0; i < n/2; i++)\n {\n mas[i] = s1; s1 += \"go\";\n }\n for (int i = n/2-1; i >=0; i--)\n {\n s = s.Replace(mas[i], \"***\");\n }\n Console.WriteLine(s);\n\n }\n else Console.WriteLine(s);\n\n \n \n }\n }\n}\n", "lang_cluster": "C#", "tags": ["strings", "implementation"], "code_uid": "474cafbe26c4d77bd640cdebd33ce6ee", "src_uid": "619665bed79ecf77b083251fe6fe7eb3", "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 _227a\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 =// @\"3 0 1 2 3\".Split(cs, StringSplitOptions.RemoveEmptyEntries);\n 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 Scanner sc = new Scanner();\n string s = sc.next();\n int hour = int.Parse(s.Substring(0, 2));\n int minutes = int.Parse(s.Substring(3, 2));\n\n s = sc.next();\n int sleepHours = int.Parse(s.Substring(0, 2));\n int sleepMinutes = int.Parse(s.Substring(3, 2));\n\n DateTime dt = new DateTime(2014, 1, 23, hour, minutes,0);\n dt = dt.AddMinutes(-1 * (sleepHours * 60 + sleepMinutes));\n Console.WriteLine(\"{0:00}:{1:00}\", dt.Hour, dt.Minute);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "2bc87bf0700bfd7facb79b03f4ac8cb9", "src_uid": "595c4a628c261104c8eedad767e85775", "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 N = sc.Int;\n var W = sc.ArrInt;\n Array.Sort(W);\n var min = int.MaxValue;\n for(int i=0;i<2*N;i++)\n for(int j = 0; j < i; j++)\n {\n var res = 0;\n var idx = 0;\n while (idx < 2 * N)\n {\n while(idx == i || idx == j) { idx++; }\n if (idx >= 2 * N) break;\n var d1 = W[idx++];\n while (idx == i || idx == j) { idx++; }\n var d2 = W[idx++];\n res += d2 - d1;\n }\n chmin(ref min, res);\n }\n Console.WriteLine(min);\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", "sortings", "greedy"], "code_uid": "d635247b40dda36009799cf8623bc13a", "src_uid": "76659c0b7134416452585c391daadb16", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "C# 8", "source_code": "using System;\r\nusing System.Collections;\r\nusing System.Collections.Generic;\r\nusing System.Globalization;\r\nusing System.IO;\r\nusing System.Linq;\r\nusing System.Numerics;\r\nusing System.Security.Cryptography;\r\nusing System.Text;\r\n\r\nnamespace ConsoleApp2\r\n{\r\n public static class Compare\r\n {\r\n const double defaultEpsilon = 1e-13;\r\n public static bool Equal(double a, double b, double epsilon = defaultEpsilon)\r\n {\r\n return Math.Abs(a - b) < epsilon;\r\n }\r\n public static bool Less(double a, double b, double epsilon = defaultEpsilon)\r\n {\r\n return a < b && !Equal(a, b, epsilon);\r\n }\r\n public static bool Greater(double a, double b, double epsilon = defaultEpsilon)\r\n {\r\n return a > b && !Equal(a, b, epsilon);\r\n }\r\n public static bool LessOrEqual(double a, double b, double epsilon = defaultEpsilon)\r\n {\r\n return a < b || Equal(a, b, epsilon);\r\n }\r\n public static bool GreaterOrEqual(double a, double b, double epsilon = defaultEpsilon)\r\n {\r\n return a > b || Equal(a, b, epsilon);\r\n }\r\n }\r\n struct Vector\r\n {\r\n public double X;\r\n public double Y;\r\n public double Length => Math.Sqrt(X * X + Y * Y);\r\n public double LengthSquared => X * X + Y * Y;\r\n public double Atan2 => Math.Atan2(Y, X);\r\n public Vector Normalize => this / Length;\r\n \r\n public Vector(double x, double y)\r\n {\r\n X = x;\r\n Y = y;\r\n }\r\n public Vector(double angle)\r\n {\r\n X = Math.Cos(angle);\r\n Y = Math.Sin(angle);\r\n }\r\n\r\n public static double Determinant(Vector left, Vector right)\r\n {\r\n return (left.X * right.Y) - (left.Y * right.X);\r\n }\r\n public static double DotProduct(Vector left, Vector right)\r\n {\r\n return (left.X * right.X) + (left.Y * right.Y);\r\n }\r\n public static double AngleBetween(Vector left, Vector right)\r\n {\r\n return Math.Acos(DotProduct(left, right) / (left.Length * right.Length));\r\n }\r\n public static Vector operator +(Vector vector)\r\n {\r\n return vector;\r\n }\r\n public static Vector operator -(Vector vector)\r\n {\r\n return new Vector(-vector.X, -vector.Y);\r\n }\r\n public static Vector operator +(Vector left, Vector right)\r\n {\r\n return new Vector(left.X + right.X, left.Y + right.Y);\r\n }\r\n public static Vector operator -(Vector left, Vector right)\r\n {\r\n return left + -right;\r\n }\r\n public static Vector operator *(Vector vector, double value)\r\n {\r\n return new Vector(vector.X * value, vector.Y * value);\r\n }\r\n public static Vector operator /(Vector vector, double value)\r\n {\r\n return new Vector(vector.X / value, vector.Y / value);\r\n }\r\n public static bool operator ==(Vector left, Vector right)\r\n {\r\n return Compare.Equal(left.X, right.X) && Compare.Equal(left.Y, right.Y);\r\n }\r\n public static bool operator !=(Vector left, Vector right)\r\n {\r\n return !(left == right);\r\n }\r\n\r\n public override string ToString()\r\n {\r\n return string.Format(\"({0:F2}, {1:F2})\", X, Y);\r\n }\r\n }\r\n struct Line\r\n {\r\n public double A;\r\n public double B;\r\n public double C;\r\n\r\n public Line(Vector left, Vector right)\r\n {\r\n A = (right.Y - left.Y);\r\n B = -(right.X - left.X);\r\n C = (right.X * left.Y) - (left.X * right.Y);\r\n }\r\n\r\n public double GetValAt(double x, double y)\r\n {\r\n return A * x + B * y + C;\r\n }\r\n public double GetValAt(Vector v)\r\n {\r\n return this.GetValAt(v.X, v.Y);\r\n }\r\n public bool IsParallel(Line other)\r\n {\r\n return Compare.Equal(this.A * other.B, this.B * other.A);\r\n }\r\n public Vector Intersect(Line other)\r\n {\r\n if (this.IsParallel(other))\r\n {\r\n // throw new ArgumentException(\"Lines are parallel\");\r\n return new Vector(double.NaN, double.NaN);\r\n }\r\n\r\n double den = (this.A * other.B) - (other.A * this.B);\r\n\r\n double x = ((this.B * other.C) - (other.B * this.C)) / den;\r\n double y = ((this.A * other.C) - (other.A * this.C)) / -den;\r\n\r\n return new Vector(x, y);\r\n }\r\n public Vector Projection(Vector point)\r\n {\r\n if (A == 0 && B == 0)\r\n {\r\n return new Vector(double.NaN, double.NaN);\r\n }\r\n\r\n Vector n = new Vector(A, B);\r\n double k = -(A * point.X + B * point.Y + C) / (A * A + B * B);\r\n\r\n return point + (n * k);\r\n }\r\n }\r\n struct Range\r\n {\r\n public Vector Left;\r\n public Vector Right;\r\n public Line GetLine => new Line(Left, Right);\r\n\r\n public Range(Vector left, Vector right)\r\n {\r\n Left = left;\r\n Right = right;\r\n }\r\n\r\n public bool IsInside(Vector v)\r\n {\r\n if (!Compare.Equal(GetLine.GetValAt(v), 0))\r\n {\r\n return false;\r\n }\r\n\r\n if ((v == Left) || (v == Right))\r\n {\r\n return true;\r\n }\r\n\r\n return Vector.DotProduct(Left - v, Right - v) < 0;\r\n }\r\n }\r\n struct Polygon\r\n {\r\n // Clockwise\r\n public Vector[] Points;\r\n\r\n public Polygon(params Vector[] points)\r\n {\r\n Points = points;\r\n }\r\n\r\n public IEnumerable Triangulate()\r\n {\r\n throw new NotImplementedException(\"Cannot triangulate (yet)\");\r\n // works incorrectly in certain cases\r\n\r\n if (Points.Length <= 4)\r\n {\r\n yield return this;\r\n }\r\n else\r\n {\r\n\r\n }\r\n\r\n for (int i = 0; i < Points.Length; i++)\r\n {\r\n for (int j = i + 2; j < Points.Length; j++)\r\n {\r\n Range diagonal = new Range(Points[i], Points[j]);\r\n\r\n\r\n }\r\n }\r\n\r\n\r\n List remainingPoints = new List(Points);\r\n\r\n while (remainingPoints.Count > 3)\r\n {\r\n //int j = -1;\r\n //double smallestArea = double.MaxValue;\r\n\r\n for (int i = 1; i < remainingPoints.Count - 1; i++)\r\n {\r\n Vector first = remainingPoints[i - 1] - remainingPoints[i];\r\n Vector second = remainingPoints[i + 1] - remainingPoints[i];\r\n\r\n double orientedArea = Vector.Determinant(first, second);\r\n if (Compare.Less(orientedArea, 0))\r\n {\r\n continue;\r\n }\r\n\r\n Vector[] trianglePoints = new Vector[]\r\n {\r\n remainingPoints[i - 1],\r\n remainingPoints[i],\r\n remainingPoints[i + 1],\r\n remainingPoints[i - 1]\r\n };\r\n Polygon triangle = new Polygon(trianglePoints);\r\n\r\n int count = 0;\r\n for (int j = 1; j < remainingPoints.Count; j++)\r\n {\r\n if (triangle.IsInside(remainingPoints[j])) {\r\n count++;\r\n }\r\n }\r\n\r\n if (count == 3)\r\n {\r\n yield return new Polygon(trianglePoints);\r\n remainingPoints.RemoveAt(i);\r\n\r\n break;\r\n }\r\n\r\n \r\n //if (orientedArea < smallestArea)\r\n //{\r\n // smallestArea = orientedArea;\r\n // j = i;\r\n //}\r\n }\r\n\r\n //if (j == -1)\r\n //{\r\n // throw new ArgumentException();\r\n //}\r\n\r\n //Vector[] triangle = new Vector[]\r\n //{\r\n // remainingPoints[j - 1],\r\n // remainingPoints[j],\r\n // remainingPoints[j + 1],\r\n // remainingPoints[j - 1]\r\n //};\r\n //yield return new Polygon(triangle);\r\n\r\n //remainingPoints.RemoveAt(j);\r\n }\r\n }\r\n public IEnumerable Sides()\r\n {\r\n for (int i = 1; i < Points.Length; i++)\r\n {\r\n yield return new Range(Points[i - 1], Points[i]);\r\n }\r\n }\r\n public double Area()\r\n {\r\n double area = 0;\r\n for (int i = 1; i < Points.Length; i++)\r\n {\r\n double dx = Points[i].X - Points[i - 1].X;\r\n double avgY = (Points[i - 1].Y + Points[i].Y) / 2;\r\n\r\n area += dx * avgY;\r\n }\r\n\r\n return Math.Abs(area);\r\n }\r\n public bool IsInside(Vector point)\r\n {\r\n double angleSum = 0;\r\n foreach (Range side in Sides())\r\n {\r\n if (side.IsInside(point))\r\n {\r\n return true;\r\n }\r\n\r\n angleSum += Vector.AngleBetween(side.Left - point, side.Right - point);\r\n }\r\n\r\n return Compare.Equal(angleSum, Math.PI * 2);\r\n }\r\n\r\n public static Polygon GetConvexPolygon(List points)\r\n {\r\n if (points.Count < 3)\r\n {\r\n return new Polygon(Array.Empty());\r\n }\r\n\r\n Vector current = points[0];\r\n for (int i = 1; i < points.Count; i++)\r\n {\r\n Vector point = points[i];\r\n if (Compare.Equal(point.Y, current.Y))\r\n {\r\n if (Compare.Greater(point.X, current.X))\r\n {\r\n current = point;\r\n }\r\n }\r\n else if (point.Y < current.Y)\r\n {\r\n current = point;\r\n }\r\n }\r\n\r\n // Start is located at the bottom right\r\n List convexPolygon = new List();\r\n convexPolygon.Add(current);\r\n\r\n double maxAngle = double.MaxValue;\r\n while (true)\r\n {\r\n double angle = double.MinValue;\r\n double dist = 0;\r\n Vector next = new Vector();\r\n for (int i = 0; i < points.Count; i++)\r\n {\r\n Vector point = points[i];\r\n Vector v = point - current;\r\n\r\n if (point == current)\r\n {\r\n continue;\r\n }\r\n\r\n double alpha = v.Atan2;\r\n if (Compare.Greater(alpha, maxAngle))\r\n {\r\n continue;\r\n }\r\n\r\n if (Compare.Greater(alpha, angle))\r\n {\r\n angle = alpha;\r\n dist = v.LengthSquared;\r\n next = point;\r\n }\r\n else if (Compare.Equal(alpha, angle) && (v.LengthSquared > dist))\r\n {\r\n angle = alpha;\r\n dist = v.LengthSquared;\r\n next = point;\r\n }\r\n }\r\n\r\n if (dist == 0)\r\n {\r\n break;\r\n }\r\n\r\n maxAngle = angle;\r\n current = next;\r\n convexPolygon.Add(current);\r\n }\r\n\r\n return new Polygon(convexPolygon.ToArray());\r\n }\r\n public Polygon IntersectConvexPolygons(Polygon other)\r\n {\r\n List points = new List();\r\n\r\n foreach (Vector vertex in this.Points)\r\n {\r\n if (other.IsInside(vertex))\r\n {\r\n points.Add(vertex);\r\n }\r\n }\r\n foreach (Vector vertex in other.Points)\r\n {\r\n if (this.IsInside(vertex))\r\n {\r\n points.Add(vertex);\r\n }\r\n }\r\n\r\n foreach (Range thisSide in this.Sides())\r\n {\r\n foreach (Range otherSide in other.Sides())\r\n {\r\n Line thisLine = thisSide.GetLine;\r\n Line otherLine = otherSide.GetLine;\r\n if (thisLine.IsParallel(otherLine))\r\n {\r\n continue;\r\n }\r\n\r\n Vector intersection = thisLine.Intersect(otherLine);\r\n if (thisSide.IsInside(intersection) && otherSide.IsInside(intersection))\r\n {\r\n points.Add(intersection);\r\n }\r\n }\r\n }\r\n\r\n return GetConvexPolygon(points);\r\n }\r\n }\r\n public struct IntervalInt\r\n {\r\n public long Left;\r\n public long Right;\r\n public long Length => IsProper() ? (Right - Left + 1) : 0;\r\n public double Average => (Left + Right) / 2.0;\r\n\r\n public IntervalInt(long left, long right)\r\n {\r\n Left = left;\r\n Right = right;\r\n }\r\n\r\n public bool IsOnInterval(long val)\r\n {\r\n return (Left <= val) && (val <= Right);\r\n }\r\n public bool IsProper()\r\n {\r\n return Left <= Right;\r\n }\r\n public long IntegerSum()\r\n {\r\n if (Left > Right || Left < 0)\r\n {\r\n return 0;\r\n }\r\n\r\n return NaturalSum(Right) - NaturalSum(Left - 1);\r\n }\r\n public IntervalInt Ceiling(long val)\r\n {\r\n return new IntervalInt(Left, Math.Min(Right, val));\r\n }\r\n public IntervalInt Floor(long val)\r\n {\r\n return new IntervalInt(Math.Max(Left, val), Right);\r\n }\r\n private static long NaturalSum(long n)\r\n {\r\n return n > 0 ? ((n * (n + 1)) / 2) : 0;\r\n }\r\n\r\n public static IntervalInt operator+(IntervalInt interval, long val)\r\n {\r\n return new IntervalInt(interval.Left + val, interval.Right + val);\r\n }\r\n public static IntervalInt operator -(IntervalInt interval, long val)\r\n {\r\n return interval + -val;\r\n }\r\n }\r\n\r\n public struct Rectangle\r\n {\r\n public Point First;\r\n public Point Second;\r\n public long Left => Math.Min(First.X, Second.X);\r\n public long Right => Math.Max(First.X, Second.X);\r\n public long Bottom => Math.Min(First.Y, Second.Y);\r\n public long Top => Math.Max(First.Y, Second.Y);\r\n public long DX => Math.Abs(Second.X - First.X);\r\n public long DY => Math.Abs(Second.Y - First.Y);\r\n public long Width => DX + 1;\r\n public long Height => DY + 1;\r\n public long Area => Width * Height;\r\n\r\n public Rectangle(Point first, Point second)\r\n {\r\n First = first;\r\n Second = second;\r\n }\r\n\r\n public bool IsLine => (DX == 0) || (DY == 0);\r\n public bool IsInside(Point point)\r\n {\r\n long manhattan = point.ManhattanDist(First) + point.ManhattanDist(Second);\r\n long dxdy = DX + DY;\r\n return manhattan == dxdy;\r\n }\r\n\r\n public IEnumerable GetPoints()\r\n {\r\n long top = Top;\r\n long right = Right;\r\n \r\n for (long y = Bottom; y <= top; y++)\r\n {\r\n for (long x = Left; x <= right; x++)\r\n {\r\n yield return new Point(x, y);\r\n }\r\n }\r\n }\r\n }\r\n public struct Point\r\n {\r\n public long X;\r\n public long Y;\r\n public bool IsZero => this == ZeroPoint;\r\n public double Length => Math.Sqrt((X * X) + (Y * Y));\r\n public long ManhattanLength => Math.Abs(X) + Math.Abs(Y);\r\n \r\n public Point(long x, long y)\r\n {\r\n X = x;\r\n Y = y;\r\n }\r\n\r\n public static Point operator +(Point p)\r\n {\r\n return p;\r\n }\r\n public static Point operator -(Point p)\r\n {\r\n return new Point(-p.X, -p.Y);\r\n }\r\n public static Point operator +(Point left, Point right)\r\n {\r\n return new Point(left.X + right.X, left.Y + right.Y);\r\n }\r\n public static Point operator -(Point left, Point right)\r\n {\r\n return left + -right;\r\n }\r\n public static bool operator ==(Point left, Point right)\r\n {\r\n return (left.X == right.X) && (left.Y == right.Y);\r\n }\r\n public static bool operator !=(Point left, Point right)\r\n {\r\n return !(left == right);\r\n }\r\n\r\n public static Point ZeroPoint => new Point(0, 0);\r\n public double Dist(Point other)\r\n {\r\n return (this - other).Length;\r\n }\r\n public long ManhattanDist(Point other)\r\n {\r\n return (this - other).ManhattanLength;\r\n }\r\n\r\n public override string ToString()\r\n {\r\n return string.Format($\"{X} {Y}\");\r\n }\r\n }\r\n public class Program\r\n {\r\n static int[] ReadIntData()\r\n {\r\n return Console.ReadLine()\r\n .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)\r\n .Select(e => int.Parse(e))\r\n .ToArray();\r\n }\r\n static long[] ReadLongData()\r\n {\r\n return Console.ReadLine()\r\n .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)\r\n .Select(e => long.Parse(e))\r\n .ToArray();\r\n }\r\n static double[] ReadDoubleData()\r\n {\r\n return Console.ReadLine()\r\n .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)\r\n .Select(e => double.Parse(e))\r\n .ToArray();\r\n }\r\n static void RandomizeArray(T[] arr, Random random)\r\n {\r\n for (int i = arr.Length - 1; i > 0; i--)\r\n {\r\n int pos = random.Next(i);\r\n if (pos != i)\r\n {\r\n (arr[i], arr[pos]) = (arr[pos], arr[i]);\r\n }\r\n }\r\n }\r\n static double RandomDouble(double left, double right, Random random)\r\n {\r\n double len = right - left;\r\n double val = random.NextDouble();\r\n return (val * len) + left;\r\n }\r\n\r\n static Program()\r\n {\r\n CultureInfo cultureInfo = (CultureInfo)CultureInfo.CurrentCulture.Clone();\r\n cultureInfo.NumberFormat.NumberDecimalSeparator = \".\";\r\n CultureInfo.CurrentCulture = cultureInfo;\r\n\r\n const bool useFilesInsteadOfConsole = false;\r\n\r\n if (useFilesInsteadOfConsole)\r\n {\r\n const string fileName = \"\";\r\n const bool useCustomFileNames = false;\r\n\r\n const string inputPath = useCustomFileNames ? (fileName + \".in\") : \"input.txt\";\r\n const string outputPath = useCustomFileNames ? (fileName + \".out\") : \"output.txt\";\r\n\r\n Console.SetIn(new StreamReader(inputPath));\r\n Console.SetOut(new StreamWriter(outputPath));\r\n }\r\n }\r\n\r\n\r\n static double CircleSegmentArea(double r, double h)\r\n {\r\n double alpha = Math.Acos(h / r);\r\n\r\n double sectorArea = alpha * r * r;\r\n double triangleArea = h * r * Math.Sin(alpha);\r\n double area = sectorArea - triangleArea;\r\n\r\n return area;\r\n }\r\n static double CircleSliceArea(double r, double h1, double h2)\r\n {\r\n if (h1 >= h2)\r\n {\r\n return 0;\r\n }\r\n\r\n return CircleSegmentArea(r, h1) - CircleSegmentArea(r, h2);\r\n }\r\n\r\n class TreeVertex\r\n {\r\n public readonly int Id;\r\n private readonly List children;\r\n public TreeVertex Parent { get; set; }\r\n\r\n public int LeafCount { get; set; }\r\n public int ChildrenCount => children.Count;\r\n public bool IsLeaf => ChildrenCount == 0;\r\n\r\n\r\n public TreeVertex(int id)\r\n {\r\n Id = id;\r\n\r\n children = new List();\r\n Parent = null;\r\n\r\n LeafCount = 0;\r\n }\r\n\r\n public void AddChild(TreeVertex child)\r\n {\r\n children.Add(child);\r\n }\r\n\r\n public IEnumerable GetChildren()\r\n {\r\n foreach (TreeVertex child in children)\r\n {\r\n yield return child;\r\n }\r\n }\r\n }\r\n\r\n static void Swap(ref int left, ref int right)\r\n {\r\n int temp = left;\r\n left = right;\r\n right = temp;\r\n }\r\n static bool Solve(int[] a, int[] b)\r\n {\r\n int n = a.Length;\r\n if (b.Length != n)\r\n {\r\n throw new ArgumentException(\"Arrays 'a' and 'b' have different length\");\r\n }\r\n\r\n bool answer = true;\r\n for (int i = n - 1; i > 0; i--)\r\n {\r\n if (b[i] != a[i])\r\n {\r\n answer = false;\r\n break;\r\n }\r\n\r\n if (b[i] == b[i - 1])\r\n {\r\n for (int j = i - 1; j > 0; j--)\r\n {\r\n if (b[j] == a[j])\r\n {\r\n break;\r\n }\r\n\r\n Swap(ref b[j - 1], ref b[j]);\r\n }\r\n }\r\n }\r\n if (b[0] != a[0])\r\n {\r\n answer = false;\r\n }\r\n\r\n return answer;\r\n }\r\n static void GenerateTests()\r\n {\r\n Random random = new Random();\r\n const int N = 5;\r\n const int ExpCount = 100;\r\n int[] a = new int[N];\r\n int[] b = new int[N];\r\n int[] origB = new int[N];\r\n\r\n for (int i = 0; i < ExpCount; i++)\r\n {\r\n for (int j = 0; j < N; j++)\r\n {\r\n a[j] = b[j] = random.Next(N) + 1;\r\n }\r\n\r\n for (int j = 0; j < 100; j++)\r\n {\r\n int left = random.Next(N);\r\n int right = random.Next(N);\r\n\r\n if (left > right)\r\n {\r\n Swap(ref left, ref right);\r\n }\r\n\r\n if (right - left <= 1)\r\n {\r\n continue;\r\n }\r\n\r\n if (b[left] == b[right])\r\n {\r\n for (int k = left; k < right; k++)\r\n {\r\n b[k] = b[k + 1];\r\n }\r\n }\r\n }\r\n\r\n Array.Copy(b, origB, N);\r\n\r\n if (!Solve(a, b))\r\n {\r\n Console.WriteLine(\"FAILED:\");\r\n Console.WriteLine($\"a: {string.Join(\" \", a)}\");\r\n Console.WriteLine($\"b: {string.Join(\" \", origB)}\");\r\n Console.WriteLine();\r\n }\r\n }\r\n\r\n //int t = int.Parse(Console.ReadLine());\r\n //for (int z = 0; z < t; z++)\r\n //{\r\n // int n = int.Parse(Console.ReadLine());\r\n // int[] a = ReadIntData();\r\n // int[] b = ReadIntData();\r\n\r\n // Console.WriteLine(Solve(a, b) ? \"YES\" : \"NO\");\r\n //}\r\n }\r\n static (double, double) VisibilityTime(Vector start, Vector end, double rF, Vector objPos, double rObj)\r\n {\r\n double rSum = rF + rObj;\r\n double pathLength = (end - start).Length;\r\n\r\n if (start != end)\r\n {\r\n Line line = new Line(start, end);\r\n Vector mid = line.Projection(objPos);\r\n\r\n double height = (objPos - mid).Length;\r\n double dif = Math.Sqrt(rSum * rSum - height * height);\r\n\r\n double midTime = (mid - start).Length / pathLength;\r\n double deltaT = dif / pathLength;\r\n\r\n double timeLeft = Math.Max(midTime - deltaT, 0);\r\n double timeRight = Math.Min(midTime + deltaT, 1);\r\n\r\n if (timeLeft < timeRight)\r\n {\r\n return (timeLeft, timeRight);\r\n }\r\n else\r\n {\r\n return (-1, -1);\r\n }\r\n }\r\n else\r\n {\r\n if ((objPos - start).Length < rSum)\r\n {\r\n return (0, 1);\r\n }\r\n else\r\n {\r\n return (-1, -1);\r\n }\r\n }\r\n }\r\n\r\n static void Main()\r\n {\r\n int t = int.Parse(Console.ReadLine());\r\n for (int z = 0; z < t; z++)\r\n {\r\n int[] row1 = ReadIntData();\r\n int[] row2 = ReadIntData();\r\n\r\n int countR1 = row1.Count(val => val == 1);\r\n int countR2 = row2.Count(val => val == 1);\r\n int count = countR1 + countR2;\r\n\r\n int ans;\r\n if (count == 0)\r\n {\r\n ans = 0;\r\n }\r\n else if (count == 4)\r\n {\r\n ans = 2;\r\n }\r\n else\r\n {\r\n ans = 1;\r\n }\r\n\r\n Console.WriteLine(ans);\r\n }\r\n\r\n Console.Out.Close();\r\n }\r\n }\r\n}\r\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "8bc19ddbddc7188e0bf3da9d20931833", "src_uid": "7336b8becd2438f0439240ee8f9610ec", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\n/*\nExamples\ninput\ninput\n4\noutput\n2\ninput\n27\noutput\n3\n\ninput\n5\noutput\n1\n\ninput\n2000000000\nOutput\n4\nAnswer\n2\n\n*/\nnamespace CodeForcesCS\n{\n class P735D_Taxes\n {\n public static void Main()\n {\n (new P735D_Taxes()).Solve();\n }\n\n public void Solve()\n {\n long n = long.Parse(Console.ReadLine());\n int tax;\n\n if (isPrimeNumber(n))\n tax = 1;\n else if ((n & 1) == 0 || isPrimeNumber(n - 2))\n tax = 2;\n else\n tax = 3;\n\n //while (n > 0 && (primeNum = maxPrimeNumber(n)) > 0)\n //{\n // n -= primeNum;\n // tax++;\n //}\n Console.WriteLine(tax);\n Console.ReadLine();\n }\n\n public static bool isPrimeNumber(long num)\n {\n if (num < 2)\n return false;\n\n if (num <= 3)\n return true;\n\n if ((num & 1) == 0 || num % 3 == 0)\n return false;\n\n long i = 5;\n long w = 2;\n long sqrtNum = (long)Math.Sqrt(num);\n\n while (i <= sqrtNum)\n {\n if (num % i == 0)\n return false;\n\n i += w;\n w = 6 - w;\n }\n\n return true;\n }\n/* REMOVED:\n public static long maxPrimeNumber(long num)\n // return: the number x <= num that is prime.\n {\n if (num == 2 || num == 3)\n return num;\n\n bool isPrime = false;\n num += ((num & 1) == 0 ? 1 : 2);\n while (!isPrime)\n {\n num -= 2;\n if (num % 3 != 0)\n {\n long i = 5;\n long w = 2;\n\n isPrime = true;\n while (i * i <= num)\n {\n if (num % i == 0)\n {\n isPrime = false;\n break;\n }\n\n i += w;\n w = 6 - w;\n }\n }\n }\n return num;\n }\n\n public static long nextPrimeNumber(long num)\n {\n if (num < 2)\n return 2;\n if (num < 3)\n return 3;\n\n bool isPrime = false;\n if ((num & 1) == 0)\n {\n num--;\n }\n while (!isPrime)\n {\n num += 2;\n if (num % 3 != 0)\n {\n long i = 5;\n long w = 2;\n\n isPrime = true;\n while (i * i <= num)\n {\n if (num % i == 0)\n {\n isPrime = false;\n break;\n }\n\n i += w;\n w = 6 - w;\n }\n }\n }\n return num;\n }\n*/\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "number theory"], "code_uid": "065c754ff2e4784e3c0fdddebf761c87", "src_uid": "684ce84149d6a5f4776ecd1ea6cb455b", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\n\nnamespace NearestInterestingNumber\n{\n class Program\n {\n static bool isInteresting(int a)\n {\n int sum = 0;\n while (a > 0)\n {\n sum += a % 10;\n a = a / 10;\n }\n if (sum % 4 == 0)\n {\n return true;\n }\n return false;\n }\n static void Main(string[] args)\n {\n int a = Convert.ToInt32(Console.ReadLine());\n while(!isInteresting(a))\n {\n a++;\n }\n Console.WriteLine(a);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "9eaf0977f9ced1bf481474bf7c65c98f", "src_uid": "bb6fb9516b2c55d1ee47a30d423562d7", "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 CF23\n{\n class Program\n {\n static void Main(string[] args)\n {\n string str = Console.ReadLine();\n int maxLenth = 0;\n for (int i = 0; i < str.Length; i++)\n {\n for (int j = i + 1; j < str.Length; j++)\n {\n if (str[i] == str[j])\n {\n int curLength = 0;\n int k = i;\n int t = j;\n while (t maxLenth)\n {\n maxLenth = curLength;\n }\n }\n }\n }\n Console.Write(maxLenth);\n Console.ReadKey();\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "greedy"], "code_uid": "4effeb3124cf602eee0cd8effad5cfe2", "src_uid": "13b5cf94f2fabd053375a5ccf3fd44c7", "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 ThreeBalls\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[1001];\n \n for (int i=0;i n) && (i - a < 1)) continue;\n if ((dy == 0) && (dx != 0) && (j + b > m) && (j - b < 1)) continue;\n\n int score = Math.Max(dx / a, dy / b);\n if (score < best_score)\n {\n best_score = score;\n }\n }\n }\n\n // If there has been no improvement, there's no possible win\n if (best_score == 1000000) Console.WriteLine(\"Poor Inna and pony!\");\n else Console.WriteLine(best_score);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["greedy", "implementation"], "code_uid": "d12c4ae5ebe9f0195b2a7915857b2eef", "src_uid": "51155e9bfa90e0ff29d049cedc3e1862", "difficulty": 2000.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.Threading;\nusing System.IO.Pipes;\nusing System.Runtime.InteropServices;\nusing System.Runtime.Remoting;\nusing System.Data.Odbc;\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 class Path\n {\n\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\npartial class Program\n{\n static void Main()\n {\n Console.SetIn(new StreamReader(Console.OpenStandardInput(1000000)));\n Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });\n var program = new Program();\n //var t = new Thread(program.Solve, 134217728);\n //t.Start();\n //t.Join();\n program.Solve();\n Console.Out.Flush();\n Console.Read();\n }\n\n public void Solve()\n {\n long N, L, R;\n Multi(out N, out L, out R);\n var l = Pow(2, L) - 1 + N - L;\n var r = Pow(2, R) - 1 + (N - R) * Pow(2, R - 1);\n Output(l + \" \" + r);\n }\n\n long Pow(long a, long n)\n {\n long res = 1;\n while (n > 0)\n {\n if ((n & 1) == 1) { res *= a; }\n a *= a;\n n >>= 1;\n }\n return res;\n }\n\n}", "lang_cluster": "C#", "tags": ["math", "greedy"], "code_uid": "8a76665a770573faf05e60d8c570f62f", "src_uid": "ce220726392fb0cacf0ec44a7490084a", "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 int N, K;\n sc.Make(out N, out K);\n ModInt res = 0;\n var P = Create(K+1, () => new List());//i\u306e\u7d20\u56e0\u6570\n var pow = new ModInt[K + 1];pow[1] = 1;//i^N\n for(int i = 2; i <= K; i++)\n {\n pow[i] = ModInt.Pow(i, N);\n if (P[i].Count == 0)\n {\n for(int j = i; j <= K; j += i)\n {\n P[j].Add(i);\n }\n }\n }\n ModInt dp = 0;\n for(int i = 1; i <= K; i++)\n {\n ModInt newdp = dp;\n //1<=ai<=i\u304b\u3064\u3072\u3068\u3064\u4ee5\u4e0ai\u3092\u542b\u3080\u3088\u3046\u306a\u3082\u306e\u3092\u6c42\u3081\u308b\n for(int j = 0; j < (1 << P[i].Count); j++)\n {\n var now = 1;var ct = 0;\n for (int k = 0; k < P[i].Count; k++) if ((1 & j >> k) == 1) { ct++; now *= P[i][k]; }\n if ((ct & 1) == 0)\n newdp += pow[i / now] - pow[i / now - 1];//i/now\u3092\u4e00\u3064\u4ee5\u4e0a\u542b\u3080->gcd\u304cnow\u304b\u3064i\u3092\u4e00\u3064\u542b\u3080\n else newdp -= pow[i / now] - pow[i / now - 1];\n }\n res += newdp ^ i;\n dp = newdp;\n }\n Console.WriteLine(res);\n }\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 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", "number theory"], "code_uid": "ad3b89caaecb93014001701470409bec", "src_uid": "122c08aa91c9a9d6a151ee6e3d0662fa", "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.IO;\n\nnamespace Main {\n class Program {\n\n const int MOD = 1000003;\n\n void solve() {\n int n = sc.nextInt();\n int got = 1;\n int ans = 0;\n while (--n > 0) {\n ans = (ans + got) % MOD;\n got = (int) ((1L * got * 3) % MOD);\n }\n output.WriteLine(got);\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 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\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": ["math"], "code_uid": "b59ad9ab9abda33de1df24b6c0c4a4cb", "src_uid": "1a335a9638523ca0315282a67e18eec7", "difficulty": 1300.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 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 {\n //using (var sw = new StreamWriter(\"output.txt\")) {\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 s = sr.NextString().ToCharArray();\n for (var i = 0; i < s.Length; i++) {\n var old = s[i];\n for (var j = 0; j < 26; j++) {\n var ch = (char) ('a' + j);\n if (ch != old) {\n s[i] = ch;\n if (Check(new string(s))) {\n sw.Write(\"YES\");\n return;\n }\n }\n }\n s[i] = old;\n }\n\n sw.WriteLine(\"NO\");\n }\n\n private bool Check(string str)\n {\n var mid = str.Length / 2;\n for (var i = 0; i < mid; i++) {\n if (str[i] != str[str.Length - i - 1])\n return false;\n }\n\n return true;\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", "strings", "constructive algorithms"], "code_uid": "3a055e644b50dbc603402d8cb5fb67f6", "src_uid": "fe74313abcf381f6c5b7b2057adaaa52", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\n\nnamespace CodeForces.Problems.A\n{\n class _810\n {\n public static void Main()\n {\n var n = GetInt();\n var k = GetInt();\n \n var sum = GetInts(n).Sum();\n var x = (2 * (k - 0.5d) * n - 2 * sum) / (2 * k - 2 * (k - 0.5d));\n\n Console.Write((x < 0) ? 0 : (int)x);\n }\n\n private static IEnumerable GetInts(int count)\n {\n for (int i = 0; i < count; i++)\n {\n yield return GetInt();\n }\n }\n\n private static int GetInt()\n {\n char ch = (char)Console.Read();\n\n while (!char.IsDigit(ch))\n {\n ch = (char)Console.Read();\n }\n\n int current = 0;\n while (char.IsDigit(ch))\n {\n current = (current * 10) + (int)char.GetNumericValue(ch);\n ch = (char)Console.Read();\n }\n\n return current;\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "implementation"], "code_uid": "7ff55058c75226468de892b14195f940", "src_uid": "f22267bf3fad0bf342ecf4c27ad3a900", "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.Text.RegularExpressions;\nusing System.Threading.Tasks;\n\nnamespace ConsoleApplication5\n{\n class Program\n {\n static void Main(string[] args)\n {\n Console.WriteLine(25);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["number theory"], "code_uid": "b58a7d1b773e9266aef30f536962a247", "src_uid": "dcaff75492eafaf61d598779d6202c9d", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\n\n\n\nusing System;\nusing System.Collections.Generic;\nusing System.IO;\nusing System.Text.RegularExpressions;\nnamespace ConsoleApplication1\n{\n class Program\n {\n\n\n static Dictionary aVal;\n static Dictionary bVal;\n public static void Main(string[] args)\n {\n string[] s = Console.ReadLine().Split(' ');\n int n, k;\n n = int.Parse(s[0]);\n k = int.Parse(s[1]);\n s = Console.ReadLine().Split(' ');\n int nGruppi = n / k;\n int[] count = new int[k];\n for (int i = 0; i < nGruppi; i++)\n {\n for (int j = 0; j < k; j++)\n {\n if (s[i * k + j][0] == '1')\n {\n count[j]++;\n }\n \n }\n }\n int ris = 0;\n for (int i = 0; i < k; i++)\n {\n if (count[i] > nGruppi / 2)\n {\n ris += nGruppi - count[i];\n }\n else\n {\n ris += count[i];\n }\n }\n Console.WriteLine(ris);\n }\n \n }\n}", "lang_cluster": "C#", "tags": ["math", "greedy", "implementation"], "code_uid": "804128f2bc377b8321d44cf04e5c1b56", "src_uid": "5f94c2ecf1cf8fdbb6117cab801ed281", "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 long l;\n long r;\n string readStr = System.Console.ReadLine();\n string[] arg = readStr.Split(' ');\n l = long.Parse(arg[0]);\n r = long.Parse(arg[1]);\n\n System.Console.Write(\"{0}\", palindrom(r) - palindrom(l-1)); \n }\n\n public static long palindrom(long arg)\n { \n string str = arg.ToString();\n \n if (str.Length == 1)\n return long.Parse(str[0].ToString());\n else\n {\n long res = 0;\n for (int i = 2; i <= str.Length-1; i++)\n {\n res += (long)System.Math.Pow(10, i - 2) * 9;\n }\n\n int firstDigit = int.Parse(str[0].ToString());\n int lastDigit = int.Parse(str[str.Length - 1].ToString());\n int min = System.Math.Min(firstDigit, lastDigit);\n int max = System.Math.Max(firstDigit, lastDigit);\n\n res += (long)System.Math.Pow(10, str.Length - 2) * (firstDigit-1);\n res += 9;\n \n string s = str.Remove(0, 1);\n s = s.Remove(s.Length - 1, 1);\n if (s == \"\")\n res++;\n else res += long.Parse(s) + 1;\n\n if (firstDigit > lastDigit)\n res--;\n \n return res;\n }\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["binary search", "dp", "combinatorics"], "code_uid": "988cb1a9d60693a6c6a97d171a485bbf", "src_uid": "9642368dc4ffe2fc6fe6438c7406c1bd", "difficulty": 1500.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[] n = Console.ReadLine().Split().Select(int.Parse).ToArray();\n int x = n[0], y = n[1], z = n[2], t1 = n[3], t2 = n[4], t3 = n[5];\n\n\n Console.WriteLine((Math.Abs(y-x) * t1) >= ((Math.Abs(x-y) + Math.Abs(x-z)) * t2 + t3 * 3) ? \"YES\" : \"NO\");\n\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "e19dc9536bd68704f1ff6cf356ce6c57", "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.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 ta = ReadInt();\n int b = ReadInt();\n int tb = ReadInt();\n var s = ReadToken().Split(':');\n int x = int.Parse(s[0]) * 60 + int.Parse(s[1]);\n\n int ans = 0;\n for (int i = 300; i < 1440; i += b)\n if (i < x + ta && i + tb > x)\n ans++;\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": ["implementation"], "code_uid": "608bc6e2964f1b98a27db7b3b5b0fab6", "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;\nusing System.Threading.Tasks;\nusing System.IO;\n\nnamespace ConsoleApplication1\n{\n class Program\n {\n static void Main(string[] args)\n {\n\n var temp = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();\n int n = temp[0];\n int L = temp[1];\n\n var t1 = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();\n var t2 = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();\n\n var q1 = new List();\n var q2 = new List();\n\n for (int i = 1; i < n; i++)\n {\n q1.Add(t1[i] - t1[i - 1]);\n }\n q1.Add(L - t1[n - 1] + t1[0]);\n\n for (int i = 1; i < n; i++)\n {\n q2.Add(t2[i] - t2[i - 1]);\n }\n q2.Add(L - t2[n - 1] + t2[0]);\n \n \n int startQ2 = -1;\n bool same;\n \n do\n {\n same = true;\n\n startQ2 = q2.FindIndex(startQ2 + 1 ,x => x == q1[0]);\n\n if (startQ2 == -1)\n {\n same = false;\n goto a;\n }\n else\n {\n int t = startQ2;\n int h = 0;\n for (int i = 1; i < n; i++)\n {\n if (i + t == n)\n {\n h = n;\n }\n\n if (q1[i] != q2[i + t - h])\n {\n same = false;\n break;\n }\n }\n }\n\n } while (startQ2 < n && same == false);\n\n a:\n Console.WriteLine((same) ? \"YES\" : \"NO\");\n Console.ReadLine();\n \n }\n\n }\n}", "lang_cluster": "C#", "tags": ["brute force", "math", "implementation"], "code_uid": "a86b59335e6c8b61f49dbc666acbd82e", "src_uid": "3d931684ca11fe6141c6461e85d91d63", "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\n\r\npublic class Program\r\n{\r\n public void Solve()\r\n {\r\n\r\n\r\n var sc = new Scanner();\r\n#if !DEBUG\r\n System.Console.SetOut(new System.IO.StreamWriter(System.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 System.Console.Out.Flush();\r\n }\r\n\r\n void Q(Scanner sc)\r\n {\r\n int n = sc.NextInt();\r\n Console.WriteLine((1 << n) - 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.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": ["implementation"], "code_uid": "1d05ff5e9fc47901e16b66821847e57c", "src_uid": "d5e66e34601cad6d78c3f02898fa09f4", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections;\nusing System.Collections.Generic;\nusing System.IO;\nusing System.Linq;\nusing System.Numerics;\nusing System.Runtime.Remoting.Messaging;\nusing System.Text.RegularExpressions;\n\n// ReSharper disable AssignNullToNotNullAttribute\n\nnamespace C\n{\n public class P\n {\n public static void Main(string[] args)\n {\n int[] a = Spoj.ReadIntArray();\n int[] b = Spoj.ReadIntArray();\n int[] c = Spoj.ReadIntArray();\n\n if (a[0] == b[0] && b[0] == c[0] || a[1] == b[1] && b[1] == c[1])\n {\n Console.WriteLine(1);\n return;\n }\n\n if (IsBetween(a, b, c) || IsBetween(b, a, c) || IsBetween(c, a, b))\n {\n Console.WriteLine(2);\n return;\n }\n\n Console.WriteLine(3);\n }\n\n private static bool IsBetween(int[] pb, int[] p1, int[] p2)\n {\n return (pb[0] == p1[0] || pb[0] == p2[0]) && (pb[1] >= Math.Min(p1[1], p2[1]) && pb[1] <= Math.Max(p1[1], p2[1]))\n || (pb[1] == p1[1] || pb[1] == p2[1]) && (pb[0] >= Math.Min(p1[0], p2[0]) && pb[0] <= Math.Max(p1[0], p2[0]));\n }\n }\n\n public static class Spoj\n {\n public static void RunTestCasesN(int t, Action callback)\n {\n for (int i = 0; i < t; i++)\n callback(i);\n }\n\n public static void RunTestCasesN(Action callback)\n {\n int t = ReadInt();\n RunTestCasesN(t, callback);\n }\n\n public static void RunTestCasesWhile(Func readInput, Func validation, Action callback)\n {\n int i = 0;\n T input = readInput();\n\n while (validation(input))\n {\n callback(i, input);\n input = readInput();\n i++;\n }\n }\n\n public static string ReverseString(this string str)\n {\n return string.Join(\"\", str.Reverse());\n }\n\n public static string ReadString()\n {\n var s = Console.ReadLine();\n if (string.IsNullOrEmpty(s)) Environment.Exit(0);\n return s.Trim();\n }\n\n public static int ReadInt()\n {\n return int.Parse(ReadString());\n }\n\n public static long ReadLong()\n {\n return long.Parse(ReadString());\n }\n\n public static double ReadDouble()\n {\n return double.Parse(ReadString());\n }\n\n public static int[] ReadIntArray()\n {\n return ReadString().Split(' ').Select(int.Parse).ToArray();\n }\n\n public static long[] ReadLongArray()\n {\n return ReadString().Split(' ').Select(long.Parse).ToArray();\n }\n\n public static double[] ReadDoubleArray()\n {\n return ReadString().Split(' ').Select(double.Parse).ToArray();\n }\n\n public static int[] ReadIntArrayLines(int n)\n {\n return Enumerable.Range(0, n).Select(x => ReadInt()).ToArray();\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["constructive algorithms", "implementation"], "code_uid": "f005b5ea021c23b1eb416914664a534d", "src_uid": "36fe960550e59b046202b5811343590d", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Linq;\n\nnamespace Preparation\n{\n public class CodeForces710E\n {\n public static void Main(string[] args)\n {\n var input = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();\n long n = input[0];\n long x = input[1];\n long y = input[2];\n long[] arr = new long[n];\n arr[0] = x;\n for (int i = 0; i < n - 1; ++i)\n {\n arr[i + 1] = arr[i + 1] == 0 ? arr[i] + x : Math.Min(arr[i + 1], arr[i] + x);\n long ind = (i + 1)*2 - 1;\n var t = y;\n if (ind >= n)\n {\n t += arr[ind - n];\n ind = n - 1;\n }\n arr[ind] = arr[ind] == 0 ? arr[i] + t : Math.Min(arr[ind], arr[i] + t);\n arr[ind-1] = arr[ind-1] == 0 ? arr[i] + t + x : Math.Min(arr[ind-1], arr[i] + t + x);\n }\n\n Console.WriteLine(arr[n-1]);\n }\n}\n }\n", "lang_cluster": "C#", "tags": ["dfs and similar", "dp"], "code_uid": "7461aa7f842b1c9fb5e0fa47292b7bdd", "src_uid": "0f270af00be2a523515d5e7bd66800f6", "difficulty": 2000.0, "exec_outcome": "PASSED"} {"lang": "Mono 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 res = n % 3;\n if (res == 2)\n n++;\n res = n / 36;\n n %= 36;\n Console.WriteLine(\"{0} {1}\", res, n/3);\n \n }\n }", "lang_cluster": "C#", "tags": ["math"], "code_uid": "eb3403a677d45d81f86f907ffa77b2bf", "src_uid": "5d4f38ffd1849862623325fdbe06cd00", "difficulty": 1400.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.IO;\n\n class Program\n {\n static void Main(string[] args)\n {\n string[] t = Console.ReadLine().Split(' ');\n int n = int.Parse(t[0]);\n int k = int.Parse(t[1]);\n string[] b = Console.ReadLine().Split(' ');\n int[] a = new int[n];\n for (int i = 0; i < n; i++)\n {\n a[i] = int.Parse(b[i]);\n }\n Array.Sort(a);\n int sum = 0;\n for (int i = 0; i < n - 1; i++)\n {\n sum += a[i];\n }\n if (sum <= k)\n Console.WriteLine(\"YES\");\n else Console.WriteLine(\"NO\");\n\n }\n \n }", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "579ebb882c214ce7b379d6a71cd005e6", "src_uid": "496baae594b32c5ffda35b896ebde629", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing static Input;\nusing NX = System.Int64;\n\n\npublic class Prog\n{\n public struct Pair { public NX x, y; public Pair(NX x, NX y) { this.x = x; this.y = y; } }\n public struct Four\n {\n public int x, y, z, k;\n public Four(int a, int b, int c, int d)\n {\n x = a; y = b; z = c; k = d;\n }\n }\n public static void Solve()\n {\n int roop_count = NextInt();\n for (int roop = 0; roop < roop_count; roop++)\n {\n int n = NextInt();\n int k = NextInt();\n int d = NextInt();\n int[] ai = LineInt();\n int ans = int.MaxValue;\n for (int i = 0; i <= n - d; i++)\n {\n HashSet hs = new HashSet();\n for (int j = i; j < i + d; j++)\n {\n if (!hs.Contains(ai[j])) hs.Add(ai[j]);\n }\n ans = Math.Min(ans, hs.Count());\n }\n\n Console.WriteLine(ans);\n }\n }\n public static void Main()\n {\n var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };\n Console.SetOut(sw);\n Solve();\n Console.Out.Flush();\n return;\n }\n private static int UpperBound(List list, NX n)\n {\n int a = 0, b = list.Count();\n if (list[a] >= n) return a;\n else if (list[b - 1] < n) return b;\n while (b - a != 1)\n {\n int x = (a + b) / 2;\n if (list[x] >= n) b = x;\n else a = x;\n }\n return b;\n }\n}\npublic class Input\n{\n public const long MOD = 1000000007;\n public const int INF = 1000000007;\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 public long Abs(long a, long b) => Math.Abs(a - b);\n}", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "99fce108f777f2aea27af1c80d1e6eb7", "src_uid": "56da4ec7cd849c4330d188d8c9bd6094", "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.The_Useless_Toy_contest_\n{\n class Program\n {\n static void Main(string[] args)\n {\n string[] arr = Console.ReadLine().Split();\n string first = arr[0];\n string sec = arr[1];\n int n = int.Parse(Console.ReadLine());\n for (int i = n; i > 1; i--) \n {\n if (n - 4 >= 1)\n {\n n = n - 4;\n }\n else\n break;\n }\n string all = \"<^>v\";\n int start = 0;\n int end = 0;\n for (int i = 0; i < all.Length; i++)\n {\n if (first[0] == all[i])\n {\n start = i;\n }\n if (sec[0] == all[i])\n {\n end = i;\n }\n }\n if ( start == end || start == end-2 || start == end +2)\n {\n Console.WriteLine(\"undefined\");\n }\n else\n {\n if (start == end - 1 && n == 1 || start == end + 3 && n == 1 || start == end - 3 && n != 1 || start == end + 1 && n != 1)\n {\n Console.WriteLine(\"cw\");\n }\n else if (start == end - 3 && n == 1 || start == end + 1 && n == 1 || start == end - 1 && n != 1 || start == end + 3 && n != 1)\n {\n Console.WriteLine(\"ccw\");\n } \n }\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "edabc4c9a9bc9ab53d38b0ec853a2630", "src_uid": "fb99ef80fd21f98674fe85d80a2e5298", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Linq;\n\nnamespace CSharp\n{\n class _448D\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 long k = long.Parse(tokens[2]);\n\n long l = 1;\n long r = (long)n * m;\n\n while (l < r)\n {\n long mid = (l + r) / 2;\n\n if (Enumerable.Range(1, n).Select(i => Math.Min(mid / i, m)).Sum() < k)\n {\n l = mid + 1;\n }\n else\n {\n r = mid;\n }\n }\n\n Console.WriteLine(l);\n }\n }\n}", "lang_cluster": "C#", "tags": ["brute force", "binary search"], "code_uid": "45bdbec64be74a51fcfb80c327fe542d", "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.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 m = nextInt();\n int max = n.Max(m);\n int p = 0, r = 6;\n for (int i = 1; i < 7; i++) {\n if (i >= max) ++p;\n }\n string format = \"{0}/{1}\";\n if (p == 6)\n Console.WriteLine(\"1/1\");\n else if (p % 2 == 0)\n Console.WriteLine(format, p / 2, 3);\n else if (p % 3 == 0)\n Console.WriteLine(format, p / 3, 2);\n else\n Console.WriteLine(format, p, 6);\n }\n\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 int SquaredDistance(int ax, int ay, int bx, int 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 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", "probabilities"], "code_uid": "ae0887eac2064dd934119061e7788a82", "src_uid": "f97eb4ecffb6cbc8679f0c621fd59414", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\n\nnamespace CSharp\n{\n public class _584B\n {\n private static int m = 1000000007;\n\n public static void Main()\n {\n int n = int.Parse(Console.ReadLine());\n Console.WriteLine(((Power(27, n) - Power(7, n)) % m + m) % m);\n }\n\n private static long Power(long n, long k)\n {\n long result = 1;\n\n if (k > 0)\n {\n result *= Power(n, k / 2);\n result %= m;\n\n result *= result;\n result %= m;\n\n if (k % 2 == 1)\n {\n result *= n;\n result %= m;\n }\n }\n\n return result;\n }\n }\n}", "lang_cluster": "C#", "tags": ["combinatorics"], "code_uid": "5e0c0fa6b7f1ca5a56a58e788af14a8e", "src_uid": "eae87ec16c284f324d86b7e65fda093c", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.IO;\nusing System.Text;\n\nnamespace Array\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[] fact;\n private static long[] fact1;\n\n private static void Main(string[] args)\n {\n int n = int.Parse(reader.ReadLine());\n\n long count = n;\n n--;\n\n InitFact(2*n + 2);\n long c = GetCFact(2*n + 1, n + 1);\n count = (count + 2 * (c - count + mod)) % mod;\n writer.WriteLine(count);\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 GetCFact(int n, int k)\n {\n return (((fact[n]*fact1[k])%mod)*fact1[n - k])%mod;\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}", "lang_cluster": "C#", "tags": ["math", "combinatorics"], "code_uid": "c9f63ee4600032536bff5711a47aae7c", "src_uid": "13a9ffe5acaa79d97df88a069fc520b9", "difficulty": 1900.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Linq;\nusing System.Collections.Generic;\n \nnamespace round596div2\n{\n \n class Solution\n {\n public int N {get;set;}\n public int P {get;set;}\n \n public Solution(int n, int p)\n {\n N = n;\n P = p;\n }\n \n public int Apply()\n {\n for(int i = 1; i <= 31; ++i)\n {\n long _n = N - i * P;\n if(_n < 1)\n continue;\n int c_p = 0;\n int exp = 0;\n for(int l = 0; l <= 31; ++l)\n if(((_n >> l) & 1) == 1)\n {\n ++c_p;\n exp += 1 << l;\n }\n\n if(c_p <= i && exp >= i)\n return i;\n }\n return -1;\n }\n }\n \n class Program\n {\n static void Main(string[] args)\n {\n int[] info = Console.ReadLine().Split().Select(x => Convert.ToInt32(x)).ToArray();\n Solution sl = new Solution(info[0], info[1]);\n System.Console.WriteLine(sl.Apply());\n }\n }\n}", "lang_cluster": "C#", "tags": ["brute force", "math", "bitmasks"], "code_uid": "222a2b7c364aa0cc08e5779ed27c1288", "src_uid": "9e86d87ce5a75c6a982894af84eb4ba8", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\nusing System;\nusing System.Collections.Generic;\nusing System.Globalization;\nusing System.Numerics;\n\npublic class Example\n{\n\n public static void Main()\n {\n\n string[] smas;\n\n int[,] m = new int[3, 3];\n int cx = 0;\n int c0 = 0;\n\n for (int i = 0; i < 3; i++)\n {\n string l = Console.ReadLine();\n for (int j = 0; j < 3; j++)\n {\n if (l[j] == '.') m[i, j] = 0;\n if (l[j] == 'X') { m[i, j] = 'X'; cx++; }\n if (l[j] == '0') { m[i, j] = '0'; c0++; }\n }\n }\n\n int ccx = 0;\n int ccy = 0;\n if (m[0, 0] == 'X' && m[0, 0] == m[1, 1] && m[2, 2] == m[1, 1]) ccx++;\n if (m[2, 0] == 'X' && m[2, 0] == m[1, 1] && m[0, 2] == m[1, 1]) ccx++;\n if (m[0, 0] == 'X' && m[0, 0] == m[0, 1] && m[0, 0] == m[0, 2]) ccx++;\n if (m[1, 0] == 'X' && m[1, 0] == m[1, 1] && m[1, 0] == m[1, 2]) ccx++;\n if (m[2, 0] == 'X' && m[2, 0] == m[2, 1] && m[2, 0] == m[2, 2]) ccx++;\n if (m[0, 0] == 'X' && m[0, 0] == m[1, 0] && m[0, 0] == m[2, 0]) ccx++;\n if (m[0, 1] == 'X' && m[0, 1] == m[1, 1] && m[0, 1] == m[2, 1]) ccx++;\n if (m[0, 2] == 'X' && m[0, 2] == m[1, 2] && m[0, 2] == m[2, 2]) ccx++;\n\n if (m[0, 0] == '0' && m[0, 0] == m[1, 1] && m[2, 2] == m[1, 1]) ccy++;\n if (m[2, 0] == '0' && m[2, 0] == m[1, 1] && m[0, 2] == m[1, 1]) ccy++;\n if (m[0, 0] == '0' && m[0, 0] == m[0, 1] && m[0, 0] == m[0, 2]) ccy++;\n if (m[1, 0] == '0' && m[1, 0] == m[1, 1] && m[1, 0] == m[1, 2]) ccy++;\n if (m[2, 0] == '0' && m[2, 0] == m[2, 1] && m[2, 0] == m[2, 2]) ccy++;\n if (m[0, 0] == '0' && m[0, 0] == m[1, 0] && m[0, 0] == m[2, 0]) ccy++;\n if (m[0, 1] == '0' && m[0, 1] == m[1, 1] && m[0, 1] == m[2, 1]) ccy++;\n if (m[0, 2] == '0' && m[0, 2] == m[1, 2] && m[0, 2] == m[2, 2]) ccy++;\n\n if (ccx == 0 && ccy == 0)\n {\n if (cx + c0 == 9 && cx == c0 + 1) Console.WriteLine(\"draw\");\n else if (cx == c0) Console.WriteLine(\"first\");\n else if (cx == c0 + 1) Console.WriteLine(\"second\");\n else\n Console.WriteLine(\"illegal\");\n }\n else\n {\n if (cx == c0 || cx == c0 + 1)\n {\n if (ccx > 0 && ccy > 0) Console.WriteLine(\"illegal\");\n else\n {\n if (ccx > 0 && cx == c0 + 1) Console.WriteLine(\"the first player won\");\n else\n if (ccy > 0 && cx == c0)\n Console.WriteLine(\"the second player won\");\n else\n Console.WriteLine(\"illegal\");\n }\n } else\n Console.WriteLine(\"illegal\");\n }\n }\n}\n\n", "lang_cluster": "C#", "tags": ["brute force", "implementation", "games"], "code_uid": "89fc30d20aa6ace407f794476cf89ace", "src_uid": "892680e26369325fb00d15543a96192c", "difficulty": 1800.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 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 static long[] ReadLong(string str)\n {\n string[] tokens = str.Trim().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);\n long[] ret = new long[tokens.Length];\n for (int i = 0; i < ret.Length; i++)\n {\n ret[i] = long.Parse(tokens[i]);\n }\n\n return ret;\n }\n\n public static double[] ReadDouble(string str)\n {\n string[] tokens = str.Trim().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);\n double[] ret = new double[tokens.Length];\n for (int i = 0; i < ret.Length; i++)\n {\n ret[i] = double.Parse(tokens[i], CultureInfo.InvariantCulture);\n }\n\n return ret;\n }\n\n static string Reverse(string s)\n {\n char[] a = s.ToCharArray();\n Array.Reverse(a);\n return new string(a);\n }\n\n static bool Check(string t)\n {\n for (int i = 0; i < t.Length; i++)\n {\n if (char.IsLetterOrDigit(t[i]) == false && t[i] != '_')\n {\n return false;\n }\n }\n\n return true;\n }\n\n static void Main(string[] args)\n {\n int[] abc = Read(Console.ReadLine());\n int[] def = Read(Console.ReadLine());\n\n if ((abc[0] == 0 && abc[1] == 0 && abc[2] != 0) || (def[0] == 0 && def[1] == 0 && def[2] != 0))\n {\n Console.WriteLine(\"0\");\n return;\n }\n \n if (abc[0] * def[1] == abc[1] * def[0])\n {\n if (abc[0] * def[2] == abc[2] * def[0] && abc[1] * def[2] == abc[2] * def[1])\n {\n Console.WriteLine(\"-1\");\n }\n else\n {\n Console.WriteLine(\"0\");\n }\n }\n else\n {\n Console.WriteLine(\"1\");\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "implementation"], "code_uid": "2f786bc1930185cfd52080ee6d1e9ee2", "src_uid": "c8e869cb17550e888733551c749f2e1a", "difficulty": 2000.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeff\ufeff\ufeff\ufeff\ufeffusing System;\n\ufeff\ufeff\ufeff\ufeffusing System.Collections.Generic;\n\ufeff\ufeff\ufeff\ufeffusing System.Globalization;\n\ufeff\ufeff\ufeffusing System.IO;\n\ufeff\ufeff\ufeffusing System.Linq;\n\ufeff\ufeff\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.ReadArray(Int32.Parse);\n\t\t\tvar n = input[0];\n\t\t\tvar k = input[1];\n\t\t\tvar factorize = Factorize(n);\n\t\t\tif (factorize.Sum(item => item.Value) < k) {\n\t\t\t\tsw.WriteLine(-1);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tvar count = 0;\n\t\t\tvar result = new List();\n\t\t\tforeach (var item in factorize) {\n\t\t\t\tfor (var i = 0; i < item.Value; i++) {\n\t\t\t\t\tif (result.Count == k) {\n\t\t\t\t\t\tresult[result.Count - 1] *= item.Key;\n\t\t\t\t\t}\n\t\t\t\t\telse {\n\t\t\t\t\t\tresult.Add(item.Key);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tvar sb = new StringBuilder();\n\t\t\tforeach (var item in result) {\n\t\t\t\tsb.Append(item + \" \");\n\t\t\t}\n\n\t\t\tsw.Write(sb);\n\t\t}\n\n\t\tprivate Dictionary Factorize(int n)\n\t\t{\n\t\t\tvar result = new Dictionary();\n\t\t\tvar initN = n;\n\t\t\tfor (var i = 2; i <= initN; i++)\n\t\t\t{\n\t\t\t\tif (n % i == 0) {\n\t\t\t\t\tvar count = 0;\n\t\t\t\t\twhile (n % i == 0) {\n\t\t\t\t\t\tn /= i;\n\t\t\t\t\t\tcount++;\n\t\t\t\t\t}\n\t\t\t\t\tresult.Add(i, count);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn result;\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.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.Select(s => func(s, CultureInfo.InvariantCulture))\n\t\t\t\t\t\t.ToArray();\n\t}\n\n\tpublic T[] ReadArrayFromString(Func func, string str)\n\t{\n\t\treturn\n\t\t\t\t\t\tstr.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)\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\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": "da64daabe5919fa7d76704bf867d4cbe", "src_uid": "bd0bc809d52e0a17da07ccfd450a4d79", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "C# 8", "source_code": "using System;\r\nusing System.Linq;\r\nusing CompLib.Util;\r\nusing System.IO;\r\nusing System.Threading;\r\n\r\npublic class Program\r\n{\r\n\r\n public void Solve()\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 m = sc.NextInt();\r\n int k = sc.NextInt();\r\n\r\n // k\u500b \u6a2a\u5411\u304d\r\n // n*m/2-k\u500b\u7e26\r\n // \r\n // \r\n // \r\n // \r\n // \r\n char[][] ans = new char[n][];\r\n for (int i = 0; i < n; i++) ans[i] = new char[m];\r\n\r\n if (m % 2 == 0)\r\n {\r\n if (n % 2 == 0)\r\n {\r\n if (k % 2 != 0)\r\n {\r\n Console.WriteLine(\"NO\");\r\n return;\r\n }\r\n int tmp = 0;\r\n for (int i = 0; i < n; i += 2)\r\n {\r\n for (int j = 0; j < m; j += 2)\r\n {\r\n if (tmp < k)\r\n {\r\n tmp++;\r\n char a, b;\r\n if ((j / 2) % 2 == 0)\r\n {\r\n a = 'a';\r\n b = 'b';\r\n }\r\n else\r\n {\r\n a = 'b';\r\n b = 'a';\r\n }\r\n ans[i][j] = a;\r\n ans[i][j + 1] = a;\r\n ans[i + 1][j] = b;\r\n ans[i + 1][j + 1] = b;\r\n }\r\n else\r\n {\r\n char a, b;\r\n if ((i / 2) % 2 == 0)\r\n {\r\n a = 'c';\r\n b = 'd';\r\n }\r\n else\r\n {\r\n a = 'd';\r\n b = 'c';\r\n }\r\n ans[i][j] = a;\r\n ans[i][j + 1] = b;\r\n ans[i + 1][j] = a;\r\n ans[i + 1][j + 1] = b;\r\n }\r\n }\r\n }\r\n }\r\n else\r\n {\r\n // n\u5947\u6570\r\n // 1\u5217\u76ee\u5168\u90e8\u57cb\u3081\u308b\r\n if (k < m / 2)\r\n {\r\n Console.WriteLine(\"NO\");\r\n return;\r\n }\r\n\r\n if ((k - m / 2) % 2 != 0)\r\n {\r\n Console.WriteLine(\"NO\");\r\n return;\r\n }\r\n\r\n for (int j = 0; j < m; j += 2)\r\n {\r\n char a = (j / 2) % 2 == 0 ? 'a' : 'b';\r\n ans[0][j] = a;\r\n ans[0][j + 1] = a;\r\n }\r\n int tmp = m / 2;\r\n for (int i = 1; i < n; i += 2)\r\n {\r\n for (int j = 0; j < m; j += 2)\r\n {\r\n if (tmp < k)\r\n {\r\n tmp++;\r\n char a, b;\r\n if ((j / 2) % 2 == 0)\r\n {\r\n a = 'c';\r\n b = 'd';\r\n }\r\n else\r\n {\r\n a = 'd';\r\n b = 'c';\r\n }\r\n ans[i][j] = a;\r\n ans[i][j + 1] = a;\r\n ans[i + 1][j] = b;\r\n ans[i + 1][j + 1] = b;\r\n }\r\n else\r\n {\r\n char a, b;\r\n if ((i / 2) % 2 == 0)\r\n {\r\n a = 'e';\r\n b = 'f';\r\n }\r\n else\r\n {\r\n a = 'f';\r\n b = 'e';\r\n }\r\n ans[i][j] = a;\r\n ans[i][j + 1] = b;\r\n ans[i + 1][j] = a;\r\n ans[i + 1][j + 1] = b;\r\n }\r\n }\r\n }\r\n }\r\n }\r\n else\r\n {\r\n // n\u5076\u6570\r\n // \u5076\u6570\u6bb5\r\n if (k % 2 != 0)\r\n {\r\n Console.WriteLine(\"NO\");\r\n return;\r\n }\r\n if (k > (n * (m - 1)) / 2)\r\n {\r\n Console.WriteLine(\"NO\");\r\n return;\r\n }\r\n int tmp = 0;\r\n for (int i = 0; i < n; i += 2)\r\n {\r\n for (int j = 0; j < m - 1; j += 2)\r\n {\r\n if (tmp < k)\r\n {\r\n tmp++;\r\n char a, b;\r\n if ((j / 2) % 2 == 0)\r\n {\r\n a = 'a';\r\n b = 'b';\r\n }\r\n else\r\n {\r\n a = 'b';\r\n b = 'a';\r\n }\r\n ans[i][j] = a;\r\n ans[i][j + 1] = a;\r\n ans[i + 1][j] = b;\r\n ans[i + 1][j + 1] = b;\r\n }\r\n else\r\n {\r\n char a, b;\r\n if ((i / 2) % 2 == 0)\r\n {\r\n a = 'c';\r\n b = 'd';\r\n }\r\n else\r\n {\r\n a = 'd';\r\n b = 'c';\r\n }\r\n ans[i][j] = a;\r\n ans[i][j + 1] = b;\r\n ans[i + 1][j] = a;\r\n ans[i + 1][j + 1] = b;\r\n }\r\n }\r\n }\r\n\r\n for (int i = 0; i < n; i += 2)\r\n {\r\n char a = (i / 2) % 2 == 0 ? 'e' : 'f';\r\n ans[i][m - 1] = a;\r\n ans[i + 1][m - 1] = a;\r\n }\r\n }\r\n\r\n Console.WriteLine(\"YES\");\r\n\r\n // for (int i = 0; i < n; i++)\r\n // {\r\n // Console.WriteLine(new string(ans[i]));\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\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", "constructive algorithms"], "code_uid": "959bf1dc91b0c7023430ce3fc3d220ac", "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.Text;\nusing System.IO;\nusing System.Globalization;\n\nnamespace Codeforces\n{\n class Program\n {\n static void Main(string[] args)\n {\n new Program().solve();\n }\n\n \n void solve()\n {\n int n = nextInt();\n int k = nextInt();\n for (int i = 1; k >= i; k -= i, i = (i == n ? 1 : i + 1)) ;\n Console.WriteLine(k);\n }\n\n\n\n\n /// \n /// \n /// \n String[] tokens;\n int pointer;\n public long nextLong()\n {\n return long.Parse(nextToken());\n }\n public int nextInt()\n {\n return int.Parse(nextToken());\n }\n public string nextToken()\n {\n while (tokens == null || tokens.Length == 0 || pointer >= tokens.Length)\n {\n tokens = System.Console.ReadLine().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);\n pointer = 0;\n }\n return tokens[pointer++];\n }\n }\n}", "lang_cluster": "C#", "tags": ["math", "implementation"], "code_uid": "692c731c85e31dbfe2e0f7d50bf3d2c6", "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;\nusing System.Threading.Tasks;\n\nnamespace ConsoleApp1\n{\n class Program\n {\n static void Main(string[] args)\n {\n string s = Console.ReadLine();\n int h1 = int.Parse(s.Substring(0, 2));\n int m1 = int.Parse(s.Substring(3, 2));\n int q1 = h1 * 60 + m1;\n s = Console.ReadLine();\n int h2 = int.Parse(s.Substring(0, 2));\n int m2 = int.Parse(s.Substring(3, 2));\n int q2 = h2 * 60 + m2;\n int dq = q2 - q1;\n dq /= 2;\n dq += q1;\n h1 = dq / 60;\n m1 = dq % 60;\n \n Console.WriteLine($\"{h1/10}{h1%10}:{m1/10}{m1%10}\");\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "15e967c5fc61f881ac7cb030ca25cba7", "src_uid": "f7a32a8325ce97c4c50ce3a5c282ec50", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic; \nclass X{\n public static void Main(String[] args){\n\tList ss = new List();\n for (int i = 0;i < 3;i++){\n\t\tss.Add(System.Console.ReadLine());\n\t}\n\n\tList clist = new List(ss[0].ToCharArray());\n\tclist.Reverse();\n\tif (new String(clist.ToArray()) != ss[2]){\n\t\tSystem.Console.WriteLine(\"NO\");\n\t\treturn ;\n\t}\n\n\tclist = new List(ss[1].ToCharArray());\n\tclist.Reverse();\n\tif (new String(clist.ToArray()) != ss[1]){\n\t\tSystem.Console.WriteLine(\"NO\");\n\t\treturn ;\n\t}\n\tSystem.Console.WriteLine(\"YES\");\n\n }\n}", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "fe18c596218686f3d93cb4e792f60f44", "src_uid": "6a5fe5fac8a4e3993dc3423180cdd6a9", "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 ConsoleApp1\n{\n class Program\n {\n static void Main(string[] args)\n {\n string a = Console.ReadLine();\n int n = int.Parse(a);\n\n int[] mas = new int[n];\n string str = Console.ReadLine();\n int L, D, U, R;\n L = 0;\n D = 0;\n U =0;\n R = 0;\n for (int i=0;in)\n return 0;\n ulong res=1;\n //numerator\n for(ulong i=n-r+1,j=1;i<=n;i++,j++)\n res=(res*i)/j;\n return res;\n }\n \n public static void Main(string[] args)\n {\n string[] inp=Console.ReadLine().Split();\n ulong numBoys,numGirls,total;\n numBoys=ulong.Parse(inp[0]);\n numGirls=ulong.Parse(inp[1]);\n total=ulong.Parse(inp[2]);\n \n ulong res=0,t1,t2,limit=total-5;\n for(t1=0;t1<=limit;t1++)\n {\n t2=limit-t1;\n res+=ncr(numBoys,t1+4)*ncr(numGirls,t2+1);\n }\n Console.WriteLine(res);\n }\n}", "lang_cluster": "C#", "tags": ["math", "combinatorics"], "code_uid": "fbbe557713d4567b82cb38d215e27425", "src_uid": "489e69c7a2fba5fac34e89d7388ed4b8", "difficulty": 1400.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 private static void SolveCase()\n {\n long n = ReadLong();\n int m = ReadInt();\n\n const long MOD = 1000000007;\n\n long[,] a = new long[m, m];\n for (int i = 0; i < m - 1; i++)\n {\n a[i, i + 1] = 1;\n }\n a[m - 1, 0] = 1;\n a[m - 1, m - 1] = 1;\n\n a = MatrixBinPower(m, a, n, MOD);\n\n long ans = a[m - 1, m - 1];\n\n Writer.WriteLine(ans);\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}: \", 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", "matrices", "dp"], "code_uid": "04f436a7238bcce55ac9c338e6c5ff38", "src_uid": "e7b9eec21d950f5d963ff50619c6f119", "difficulty": 2100.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\n\n\n\nusing System;\nusing System.Collections.Generic;\nusing System.IO;\nusing System.Text.RegularExpressions;\nnamespace ConsoleApplication1\n{\n class Program\n {\n\n\n\n public static void Main(string[] args)\n {\n string[] s = Console.ReadLine().Split(' ');\n int sx, sy, ax, ay;\n sx = int.Parse(s[0]);\n sy = int.Parse(s[1]);\n ax = int.Parse(s[2]);\n ay = int.Parse(s[3]);\n int ris1 = 0, ris2 = 0, ris3 = 0;\n double pendenza;\n \n \n try\n {\n pendenza = Math.Abs((double)(ay - sy) / (double)(ax - sx));\n }\n catch\n {\n pendenza = 0;\n }\n if (pendenza == 1)\n {\n ris2 = 1;\n }\n if (ax == sx || ay == sy)\n {\n ris1 = 1;\n }\n else\n {\n ris1 = 2;\n }\n ris3 = Math.Max(Math.Abs(sx - ax), Math.Abs(sy - ay));\n if (ris2 == 0)\n {\n if (sy % 2 == 0)\n {\n if (sx % 2 == 0)\n {\n if ((ax % 2 == 0 && ay % 2 == 0) || (ax % 2 == 1 && ay % 2 == 1))\n {\n ris2 = 2;\n }\n }\n else\n {\n if ((ax % 2 == 1 && ay % 2 == 0) || (ax % 2 == 0 && ay % 2 == 1))\n {\n ris2 = 2;\n }\n }\n }\n else\n {\n if (sx % 2 == 0)\n {\n if ((ax % 2 == 0 && ay % 2 == 1) || (ax % 2 == 1 && ay % 2 == 0))\n {\n ris2 = 2;\n }\n }\n else\n {\n if ((ax % 2 == 0 && ay % 2 == 0) || (ax % 2 == 1 && ay % 2 == 1))\n {\n ris2 = 2;\n }\n }\n }\n }\n Console.WriteLine(ris1 + \" \" + ris2 + \" \" + ris3);\n }\n }\n}\n ", "lang_cluster": "C#", "tags": ["math", "graphs", "shortest paths"], "code_uid": "37eeb9750cc71f1ee18be6b2c12b631b", "src_uid": "7dbf58806db185f0fe70c00b60973f4b", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\n\nnamespace _1057\u0421\n{\n class Program\n {\n static readonly int INF = 1000000000;\n static int n, s, k;\n static int[] r;\n static int[][] dps;\n\n static bool[] dpsc;\n static string clr;\n static void Main(string[] args)\n {\n (n, s, k) = r3i();\n r = ris();\n s--;\n clr = Console.ReadLine();\n dpsc = new bool[n];\n dps = new int[n][];\n int result = INF;\n for (int i = 0; i < n; i++)\n {\n dp(i);\n result = Math.Min(result, dps[i][k] + Math.Abs(s-i));\n }\n Console.WriteLine(result == INF ? -1 : result);\n }\n\n static void dp(int cur)\n {\n if (dps[cur] != null)\n return;\n dps[cur] = new int[k+1];\n for (int i = r[cur]+1; i < k + 1; i++)\n {\n dps[cur][i] = INF;\n }\n for (int to = 0; to < n; to++)\n {\n if (r[to] > r[cur] && clr[to] != clr[cur])\n {\n dp(to);\n for (int i = r[cur] + 1; i < k + 1; i++)\n {\n dps[cur][i] = Math.Min(dps[cur][i], dps[to][i-r[cur]] + Math.Abs(cur-to));\n }\n }\n }\n }\n\n\n static int[] ris()\n {\n return Array.ConvertAll(Console.ReadLine().Split(' '), i => Int32.Parse(i));\n }\n\n static int ri()\n {\n var i = Console.ReadLine();\n return Int32.Parse(i);\n }\n static (int, int) r2i()\n {\n var i = Console.ReadLine().Split(' ');\n return (Int32.Parse(i[0]), Int32.Parse(i[1]));\n }\n static (int, int, int) r3i()\n {\n var i = Console.ReadLine().Split(' ');\n return (Int32.Parse(i[0]), Int32.Parse(i[1]), Int32.Parse(i[2]));\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["dp"], "code_uid": "803fd0a0b201f2d323c537bf0491661f", "src_uid": "a95e54a7e38cc0d61b39e4a01a6f8d3f", "difficulty": 2000.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\n\nnamespace Cows_and_Primitive_Roots\n{\n class Program\n {\n static void Main(string[] args)\n {\n int p = short.Parse(Console.ReadLine());\n int count = 0;\n for (int n = 1; n < p; ++n)\n {\n bool ok = true;\n int x = 1;\n for (int i = 1; i < p - 1; ++i)\n {\n x *= n;\n x %= p;\n if (x == 1)\n {\n ok = false;\n break;\n }\n }\n if (ok)\n {\n x *= n;\n x %= p;\n if (x == 1)\n {\n count += 1;\n }\n }\n }\n Console.WriteLine(count); \n }\n\n\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "implementation", "number theory"], "code_uid": "8626dc84afa952e4e555e940c61e6507", "src_uid": "3bed682b6813f1ddb54410218c233cff", "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\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 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 int k = 0;\n for (int i = 0; i < s1.Length; i++)\n {\n \n if (s1[i] == s2[k])\n {\n if (k == s2.Length - 1)\n {\n return true;\n }\n k++;\n }\n }\n if (k >= s2.Length)\n {\n return true;\n }\n return false;\n }\n static void Main(string[] args)\n {\n string s = Console.ReadLine();\n string s1 = Console.ReadLine();\n if (s1.Length > s.Length)\n {\n Console.WriteLine(\"need tree\");\n return;\n }\n if (foo(s, s1))\n {\n Console.WriteLine(\"automaton\");\n return;\n }\n bool f = false;\n int[] cnt = new int[26];\n int[] cnt1 = new int[26];\n for (int i = 0; i < s.Length; i++)\n {\n cnt[s[i] - 'a']++;\n }\n for (int i = 0; i < s1.Length; i++)\n {\n cnt1[s1[i] - 'a']++;\n }\n for (int i = 0; i < 26; i++)\n {\n if (cnt[i] != cnt1[i])\n {\n f = true;\n }\n }\n if (!f)\n {\n Console.WriteLine(\"array\");\n return;\n }\n f = false;\n for (int i = 0; i < 26; i++)\n {\n if (cnt[i] < cnt1[i])\n {\n f = true;\n Console.WriteLine(\"need tree\");\n return;\n }\n\n }\n Console.WriteLine(\"both\");\n }\n }\n}", "lang_cluster": "C#", "tags": ["strings", "implementation"], "code_uid": "29b4ddf109cadbe0360bd94a691c472c", "src_uid": "edb9d51e009a59a340d7d589bb335c14", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "/*\ncsc -debug A.cs && mono --debug A.exe <<< \"4 3\n1 1\n1 2\"\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 w = cin.NextLong();\n var h = cin.NextLong();\n\n var u1 = cin.NextLong();\n var d1 = cin.NextLong();\n\n var u2 = cin.NextLong();\n var d2 = cin.NextLong();\n\n for (; h >= 0; h--) {\n w += h;\n\n if (h == d1) w -= u1;\n if (w < 0) w = 0;\n\n if (h == d2) w -= u2;\n if (w < 0) w = 0;\n\n // System.Console.WriteLine(new {h, w});\n }\n\n System.Console.WriteLine(w);\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": ["implementation"], "code_uid": "e996650bd23ad203097103be32c33691", "src_uid": "084a12eb3a708b43b880734f3ee51374", "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\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 k = int.Parse(Console.ReadLine());\n int[] nap = new int[10];\n for (int i = 0; i < 4; i++) {\n char[] c = Console.ReadLine().ToCharArray();\n for (int j = 0; j < 4; j++) {\n if (c[j] != '.') {\n nap[c[j] - '0']++;\n }\n }\n }\n bool sol = true;\n for (int i = 1; i <= 9; i++) {\n if (nap[i] > k + k) {\n sol = false;\n }\n }\n string ans = (sol) ? \"YES\" : \"NO\";\n Console.Write(ans);\n\n //Console.ReadKey();\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "d6ca047cd6345e1664d4f6fec96f2296", "src_uid": "5fdaf8ee7763cb5815f49c0c38398f16", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Linq;\nusing CompLib.Util;\nusing System.Threading;\nusing System.Collections.Generic;\n\npublic class Program\n{\n long A, B;\n public void Solve()\n {\n checked\n {\n var sc = new Scanner();\n (A, B) = (sc.NextLong(), sc.NextLong());\n\n long ans = long.MaxValue;\n var divC = Div(A + B);\n var divA = Div(A);\n var divB = Div(B);\n\n for (int i = 0; i < divA.Count; i++)\n {\n long x = divA[i];\n // x\u4ee5\u4e0a\n int ok = divC.Count;\n int ng = -1;\n while (ok - ng > 1)\n {\n int mid = (ok + ng) / 2;\n if (divC[mid] >= x) ok = mid;\n else ng = mid;\n }\n\n for (int t = ok; t < divC.Count && divA[divA.Count - i - 1] <= divC[divC.Count - t - 1]; t++)\n {\n ans = Math.Min(ans, divC[t] + divC[divC.Count - t - 1]);\n }\n }\n\n for (int i = 0; i < divB.Count; i++)\n {\n long x = divB[i];\n // x\u4ee5\u4e0a\n int ok = divC.Count;\n int ng = -1;\n while (ok - ng > 1)\n {\n int mid = (ok + ng) / 2;\n if (divC[mid] >= x) ok = mid;\n else ng = mid;\n }\n\n for (int t = ok; t < divC.Count && divB[divB.Count - i - 1] <= divC[divC.Count - t - 1]; t++)\n {\n ans = Math.Min(ans, divC[t] + divC[divC.Count - t - 1]);\n }\n }\n\n Console.WriteLine((ulong)ans * 2);\n }\n }\n\n List Div(long n)\n {\n var ans = new List();\n var rev = new List();\n for (long x = 1; x * x <= n; x++)\n {\n if (n % x == 0)\n {\n ans.Add(x);\n if (n / x != x) rev.Add(n / x);\n }\n }\n\n for (int i = rev.Count - 1; i >= 0; i--)\n {\n ans.Add(rev[i]);\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}\n", "lang_cluster": "C#", "tags": ["brute force", "math", "binary search", "number theory"], "code_uid": "79edadc97908da116ad3dab6f055624f", "src_uid": "7d0c5f77bca792b6ab4fd4088fe18ff1", "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 Div._2_A.Transformation_from_A_to_B\n{\n class Program\n {\n static void Main(string[] args)\n {\n string[] s = Console.ReadLine().Split(' ');\n long a = long.Parse(s[0]);\n long b = long.Parse(s[1]);\n List list = new List();\n bool right = false;\n while (b >= a)\n {\n list.Add(b);\n if (a == b)\n {\n right = true;\n break;\n }\n if (b % 2 == 0)\n {\n b /= 2;\n }\n else if(b > 10 && b % 10 == 1)\n {\n b /= 10;\n }\n else\n {\n right = false;\n break;\n }\n }\n if (right)\n {\n Console.WriteLine(\"YES\");\n Console.WriteLine(list.Count);\n for (int i = list.Count-1; i >= 0; i--)\n {\n Console.Write(list[i] + \" \");\n }\n }\n else\n Console.WriteLine(\"NO\");\n Console.ReadLine();\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["dfs and similar", "math", "brute force"], "code_uid": "1e2f5084d08bab2a22ea85b87acb6f77", "src_uid": "fc3adb1a9a7f1122b567b4d8afd7b3f3", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Linq;\n\nnamespace _808A\n{\n class Program\n {\n static void Main(string[] args)\n {\n int currentYear = int.Parse(Console.ReadLine());\n int happyYear = GetNextHappyYear(currentYear);\n Console.WriteLine(happyYear - currentYear);\n Console.ReadLine();\n }\n\n private static int GetNextHappyYear(int currentYear)\n {\n int digitCount = GetDigitCount(currentYear);\n if (digitCount == 1)\n {\n return currentYear + 1;\n }\n else\n {\n int firstDigit = GetFirstDigit(currentYear);\n return (firstDigit + 1) * (int)Math.Pow(10, digitCount - 1);\n }\n }\n\n private static int GetFirstDigit(int currentYear)\n {\n while(currentYear > 9)\n {\n currentYear /= 10;\n }\n return currentYear;\n }\n\n private static int GetDigitCount(int currentYear)\n {\n int digitCount = 0;\n while(currentYear > 0)\n {\n currentYear /= 10;\n digitCount++;\n }\n return digitCount;\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "d9f72a67700a98cc83cf73434d442243", "src_uid": "a3e15c0632e240a0ef6fe43a5ab3cc3e", "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 int[] d = new int[1000001];\n\tstatic void Main() {\n\t\tstring[] input = Console.ReadLine().Split();\n\t\tint a = int.Parse(input[0]);\n\t\tint b = int.Parse(input[1]);\n\t\tint c = int.Parse(input[2]);\n\t\tlong s = 0;\n\t\tdivisor();\n\t\tfor(int i = 1; i <= a; i++){\n\t\t\tfor(int j = 1; j <= b; j++){\n\t\t\t\tfor(int k = 1; k <= c; k++){\n\t\t\t\t\ts += d[i * j * k] % 1073741824 ;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tConsole.WriteLine(s);\n\t}\n\tstatic void divisor() {\n\t\td[1] = 1;\n\t\tfor(int i = 2; i < d.Length; i++){\n\t\t\td[i]++;\n\t\t\tint j = 1;\n\t\t\twhile(j * i < d.Length){\n\t\t\t\td[j * i]++;\n\t\t\t\tj++;\n\t\t\t}\n\t\t}\n\t}\n}", "lang_cluster": "C#", "tags": ["implementation", "number theory"], "code_uid": "3de199216983cfb80347ffaba4f3daa7", "src_uid": "4fdd4027dd9cd688fcc70e1076c9b401", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\npublic class Program\n{\n public static void Main() {\n int n = Convert.ToInt32(Console.ReadLine());\n \n if(n%2 == 0){Console.WriteLine(\"Mahmoud\");\n return;}\n Console.WriteLine(\"Ehab\");\n \n }\n}", "lang_cluster": "C#", "tags": ["math", "games"], "code_uid": "93465346220377f61b173dd9c59768f4", "src_uid": "5e74750f44142624e6da41d4b35beb9a", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using 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 if (x != null)\n p.Out(x);\n }\n \n object Solve()\n {\n var s = Read();\n var max = 0;\n for (int i = 0; i < s.Length; i++)\n {\n for (int j = 1; j < s.Length - i + 1; j++)\n {\n var s2 = s.Substring(i, j);\n if (max < s2.Length && !IsPalindrom(s2))\n max = s2.Length;\n }\n }\n\n return max;\n }\n\n bool IsPalindrom(string s)\n {\n for (int k = 0; k < s.Length / 2; k++)\n {\n if (s[k] != s[s.Length - k - 1])\n return false;\n }\n\n return true;\n }\n void DFS(List[] graph, List> result, long current, bool[] visited)\n {\n visited[current] = true;\n foreach (var item in graph[current])\n {\n\n }\n }\n\n long CountAns(int pow, long k, long[] hopes, long[] fact, int addedOnes)\n {\n long res = 0;\n for (int i = 0; i <= pow; i++)\n {\n int realOnes = i + addedOnes;\n if (realOnes > 1000)\n break;\n if (realOnes > 0 && hopes[realOnes] == k - 1)\n res = (res + fact[pow] * fastpow(fact[i] * fact[pow - i] % commonMod, commonMod - 2)) % commonMod;\n }\n return res;\n }\n\n int CountOnes(int i)\n {\n int res = 0;\n while (i != 0)\n {\n if ((i & 1) == 1)\n res++;\n i >>= 1;\n }\n return res;\n }\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": ["brute force", "strings", "implementation"], "code_uid": "7c33eae13b86850c45cc142e694d4b99", "src_uid": "6c85175d334f811617e7030e0403f706", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\n\npublic class Program {\n public static void Main() {\n int leastNumber = int.Parse(Console.ReadLine());\n for (int i = 2; i <= 10; i += 2) {\n for (int j = 0; j < (1 << i); ++j) {\n int count = 0;\n long number = 0;\n for (int k = i - 1; k >= 0; --k) {\n number *= 10;\n if (((j >> k) & 1) == 0) {\n number += 4;\n ++count;\n } else {\n number += 7;\n }\n }\n if (count * 2 == i && number >= leastNumber) {\n Console.WriteLine(number);\n return;\n }\n }\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "binary search", "bitmasks"], "code_uid": "921e2a4f08910bc3040a6ad17346fcb6", "src_uid": "77b5f83cdadf4b0743618a46b646a849", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Collections;\nusing System.Linq;\nusing System.Text;\n\nnamespace ConsoleApplication1\n{\n class Program\n {\n\n static void Main(string[] args)\n {\n long n = long.Parse(Console.ReadLine());\n\n long min = long.MaxValue;\n\n for (long i = 1; i <= Math.Pow(n, 1.0/3.0); i++)\n {\n long sq = n / i;\n if (n % i == 0)\n for (long j = 1; j <= Math.Sqrt(sq); j++)\n {\n long k = sq / j;\n if (sq % j == 0)\n if (i * j * k == n)\n {\n min = Math.Min(min, (i + 1) * (j + 2) * (k + 2) - n);\n min = Math.Min(min, (i + 2) * (j + 1) * (k + 2) - n);\n min = Math.Min(min, (i + 2) * (j + 2) * (k + 1) - n);\n }\n }\n }\n\n Console.WriteLine(min + \" \" + ((n + 1) * 3 * 3 - n));\n }\n }\n}\n ", "lang_cluster": "C#", "tags": ["math", "implementation"], "code_uid": "30f51f7c8394a0a50b05dbdd8c937883", "src_uid": "2468eead8acc5b8f5ddc51bfa2bd4fb7", "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 CodeForces_273_B {\n class Program {\n static void Main(string[] args) {\n \n string[] astr = Console.ReadLine().Split(new string[]{\" \"}, StringSplitOptions.RemoveEmptyEntries);\n int[] aint = new int[astr.Length];\n int i = 0;\n foreach(string s in astr) {\n aint[i] = int.Parse(s); \n i++;\n }\n\n long kMin;\n long kMax;\n Func1(aint[0], aint[1], out kMin, out kMax);\n\n Console.WriteLine(kMin + \" \" + kMax);\n Console.ReadLine();\n\n }\n\n\n public static void Func1(int n, int m, out long kMin, out long kMax) { \n\n int n1 = n - m;\n int nMin = n1 / m + 1;\n int nMax = n1 + 1; \n\n int ostMin = n - nMin * m; \n\n int nLastMin = nMin + ostMin; \n\n //kMin = (long)nMin * (nMin - 1) / 2 * (m - 1) + (long)nLastMin * (nLastMin - 1) / 2;\n kMin = (long)(nMin + 1) * nMin / 2 * ostMin + (long)nMin * (nMin - 1) / 2 * (m - ostMin);\n kMax = (long)nMax * (nMax - 1) / 2;\n\n }\n\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "greedy", "constructive algorithms", "combinatorics"], "code_uid": "e9cc440d9b4f888fe857ec84690e51a0", "src_uid": "a081d400a5ce22899b91df38ba98eecc", "difficulty": 1300.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 la = ReadLong();\n long ra = ReadLong();\n long ta = ReadLong();\n long lb = ReadLong();\n long rb = ReadLong();\n long tb = ReadLong();\n if (ta > tb)\n {\n var tmp = la;\n la = lb;\n lb = tmp;\n\n tmp = ra;\n ra = rb;\n rb = tmp;\n\n tmp = ta;\n ta = tb;\n tb = tmp;\n }\n\n long gcd = Gcd(ta, tb);\n\n long p = tb / gcd;\n if (p == 1)\n {\n Writer.WriteLine(Length(la, ra, lb, rb));\n return;\n }\n\n long ans = 0;\n\n long l = -p;\n long r = p - 1;\n while (l < r)\n {\n long m = (l + r + 1) / 2;\n long x = la + m * gcd;\n if (x >= lb)\n {\n r = m - 1;\n }\n else\n {\n l = m;\n }\n }\n ans = Math.Max(ans, Length(la + r * gcd, ra + r * gcd, lb, rb));\n ans = Math.Max(ans, Length(la + (r + 1) * gcd, ra + (r + 1) * gcd, lb, rb));\n\n /*l = 0;\n r = p - 1;\n while (l < r)\n {\n long m = (l + r) / 2;\n long x = lb + m * gcd;\n if (x <= lb)\n {\n l = m + 1;\n }\n else\n {\n r = m;\n }\n }\n ans = Math.Max(ans, Length(la + l * gcd, ra + l * gcd, lb, rb));\n ans = Math.Max(ans, Length(la + (l - 1) * gcd, ra + (l - 1) * gcd, lb, rb));*/\n\n Writer.WriteLine(ans);\n }\n\n public static long Length(long a, long b, long c, long d)\n {\n return Math.Max(0, Math.Min(b, d) - Math.Max(a, c) + 1);\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 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}", "lang_cluster": "C#", "tags": ["math", "number theory"], "code_uid": "641938cfa5c51db17cec0d454fe2d474", "src_uid": "faa75751c05c3ff919ddd148c6784910", "difficulty": 1900.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.IO;\nusing System.Text;\n\nnamespace Pie_Rules\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 dp = new int[2];\n int sum = nn[n - 1];\n dp[0] = nn[n - 1];\n\n for (int i = n - 2; i >= 0; i--)\n {\n var next = new int[2];\n\n next[0] = Math.Max(nn[i] + dp[1], dp[0]);\n next[1] = sum + nn[i] - Math.Max(nn[i] + sum - dp[0], sum - dp[1]);\n\n dp = next;\n sum += nn[i];\n }\n\n writer.Write(dp[1]);\n writer.Write(' ');\n writer.WriteLine(sum - dp[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": ["dp", "games"], "code_uid": "799f88174bd14120a697d20831ac2fec", "src_uid": "414540223db9d4cfcec6a973179a0216", "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 ConsoleApplication1\n{\n class Program\n {\n static long A, M,prod;\n static string[] read;\n\n static void Main(string[] args)\n {\n read = Console.ReadLine().Split();\n A = Convert.ToInt64(read[0]);\n M = Convert.ToInt64(read[1]);\n\n\n for(int i=1; i<=100000; ++i)\n {\n prod = A % M;\n A += prod;\n\n if (prod == 0)\n {\n Console.WriteLine(\"Yes\");\n return;\n }\n }\n\n \n Console.WriteLine(\"No\");\n\n //Console.ReadKey();\n }\n\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "matrices", "implementation"], "code_uid": "d9d34cfe9d55d18a80428aedc007452b", "src_uid": "f726133018e2149ec57e113860ec498a", "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 Training\n{\n class Program\n {\n public static string s = Console.ReadLine();\n public static string qq = \"QAQ\";\n public static int[,] arr = new int[s.Length+1, 4] ;\n \n public static int Q(int m,int n)\n {\n if (arr[n , m ] != -1)\n return arr[n , m ];\n if (m == 0)\n return 1;\n if (n == 0)\n return 0;\n int i=0, j=0;\n if (qq[m-1]==s[n-1])\n i = Q( m - 1, n - 1);\n \n j = Q(m, n - 1);\n arr[n , m ] = i + j;\n return i+j;\n \n }\n\n static void Main(string[] args)\n {\n for (int i = 0; i < s.Length+1; i++)\n {\n for (int j = 0; j < 4; j++)\n\n arr[i, j] = -1;\n }\n\n Console.WriteLine(Q(3, s.Length));\n\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "dp"], "code_uid": "ef1861acbccfa30ed8fabb7a6edf6a60", "src_uid": "8aef4947322438664bd8610632fe0947", "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 B\n{\n class Program\n {\n static void Main(string[] args)\n {\n string[] data = Console.ReadLine().Split(' ');\n int n = Convert.ToInt32(data[0]);\n int k = Convert.ToInt32(data[1]);\n int x = Convert.ToInt32(data[2]);\n\n data = Console.ReadLine().Split(' ');\n int[] c = new int[n];\n for (int i = 0; i < n; i++)\n c[i] = Convert.ToInt32(data[i]);\n\n int max = 0;\n for (int i = 1; i < n; i++)\n {\n if (c[i] != x || c[i - 1] != x)\n continue;\n\n int l = i - 2, r = i + 1;\n int curr = 2;\n while (l >= 0 && r < n)\n {\n int tmp = 0;\n int q = c[r];\n while (l >= 0 && c[l] == q)\n {\n l--;\n tmp++;\n }\n\n while (r < n && c[r] == q)\n {\n r++;\n tmp++;\n }\n\n if (tmp < 3)\n break;\n\n curr += tmp;\n }\n\n if (max < curr)\n max = curr;\n }\n\n Console.WriteLine(max.ToString());\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["two pointers", "brute force"], "code_uid": "997a55a2e7f1c7d9297c76b7f37d3636", "src_uid": "d73d9610e3800817a3109314b1e6f88c", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\n\nnamespace tmp6\n{\n class Program\n {\n static void Main()\n {\n int m = 0, columns = 0;\n string[] s = Console.ReadLine().Split(' ');\n m = int.Parse(s[0]);\n columns += int.Parse(s[1]) - 1;\n columns += System.DateTime.DaysInMonth(2017, m);\n if(columns % 7 == 0)\n columns /= 7;\n else\n {\n columns /= 7;\n columns++;\n }\n Console.WriteLine(columns);\n }\n }\n}", "lang_cluster": "C#", "tags": ["math", "implementation"], "code_uid": "8e988ac4c5ac90716fbab21350272b5c", "src_uid": "5b969b6f564df6f71e23d4adfb2ded74", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\n\nclass Program\n{\n static void Main()\n {\n string[] inp = Console.ReadLine().Split(' ');\n char[] s = inp[0].ToCharArray();\n char[] b = inp[1].ToCharArray();\n for (int i = 0; i <= b.GetUpperBound(0)/2; i++)\n {\n char swap = b[i];\n b[i] = b[b.GetUpperBound(0) - i];\n b[b.GetUpperBound(0) - i] = swap;\n }\n string a = \"\";\n string g = \"\";\n for (int i = 0; i <= b.GetUpperBound(0); i++)\n {\n a += b[i];\n }\n for (int i = 0; i <= s.GetUpperBound(0); i++)\n {\n g += s[i];\n }\n int outy = int.Parse(a) + int.Parse(g);\n Console.WriteLine(outy);\n }\n}", "lang_cluster": "C#", "tags": ["constructive algorithms"], "code_uid": "3f4c87d481f3c863e6e025e6261c0bbf", "src_uid": "69b219054cad0844fc4f15df463e09c0", "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.Text.RegularExpressions;\n\nnamespace _03_11_11_1_\n{\n class Program\n {\n static void Main()\n {\n string s=Console.ReadLine();\n string[] sm = Regex.Split(s, \" \");\n int a = Int32.Parse(sm[0]);\n int b = Int32.Parse(sm[1]);\n int x1 = Int32.Parse(sm[2]);\n int y1 = Int32.Parse(sm[3]);\n int x2 = Int32.Parse(sm[4]);\n int y2 = Int32.Parse(sm[5]);\n\n double k1 = (x1 + y1) / (double)(2 * a);\n double k2 = (x2 + y2) / (double)(2 * a);\n int k1i = (int)Math.Floor(k1);\n int k2i = (int)Math.Floor(k2);\n int m = Math.Abs(k1i - k2i);\n\n k1 = (x1 - y1) / (double)(2 * b);\n k2 = (x2 - y2) / (double)(2 * b);\n k1i = (int)Math.Floor(k1);\n k2i = (int)Math.Floor(k2);\n int m2 = Math.Abs(k1i - k2i);\n\n if (m2 > m) m = m2;\n Console.WriteLine(\"{0}\", m);\n //Console.WriteLine(\"{0}\", -4 / 8);\n Console.ReadLine();\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "constructive algorithms", "number theory"], "code_uid": "8c8a61b6846b20e2299fc85a4bbe2103", "src_uid": "7219d1837c83b5920992aee5a60dc0d9", "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 _13a\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 = readLongArray();\n var n = d[0];\n var k = d[1];\n\n var l = n / k + 1;\n Console.WriteLine(l * k);\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", "implementation"], "code_uid": "5a2c5e12656b85aaf6d578eb442e2d21", "src_uid": "75f3835c969c871a609b978e04476542", "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 Int64 n=Int64.Parse(Console.ReadLine());\n int sum=0;\n for(int i= 2;i= 10 && i < 100)\n {\n if (n < 2)\n continue;\n for (int j = 0; j < n; j++)\n for (int k = 0; k < n; k++)\n {\n if (j == k)\n continue;\n canBuild[i] |= a[j].Contains(i / 10) && a[k].Contains(i % 10);\n }\n }\n else\n {\n if (n < 3)\n continue;\n for (int j = 0; j < n; j++)\n for (int k = 0; k < n; k++)\n {\n if (j == k)\n continue;\n for (int l = 0; l < n; l++)\n {\n if (j == l || k == l)\n continue;\n canBuild[i] |= a[j].Contains(i / 100) && a[k].Contains((i / 10) % 10) &&\n a[l].Contains(i % 10);\n }\n }\n }\n }\n int result = 0;\n for (int i = 1; i < 1000; i++)\n {\n bool res = true;\n for (int j = 1; j <= i; j++)\n res &= canBuild[j];\n if (res)\n result = Math.Max(result, i);\n }\n Console.WriteLine(result);\n }\n }\n}", "lang_cluster": "C#", "tags": ["brute force", "implementation"], "code_uid": "321304d47cc9da98441cada72cba28a8", "src_uid": "20aa53bffdfd47b4e853091ee6b11a4b", "difficulty": 1300.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 = rl;\n\t\t\tvar b = rl;\n\t\t\tvar P = new List();\n\t\t\tfor (long i = 2; i * i <= b; i++) {\n\t\t\t\tvar cnt = 0;\n\t\t\t\twhile (b % i == 0) { b /= i; cnt++; }\n\t\t\t\tif (cnt != 0) P.Add(new long[] { i, cnt });\n\t\t\t}\n\t\t\tif (b != 1) P.Add(new long[] { b, 1 });\n\t\t\tvar min = INF;\n\t\t\tforeach (var p in P) {\n\t\t\t\tvar v = ord(n, p[0]) / p[1];\n\t\t\t\tmin = Min(min, v);\n\t\t\t}\n\t\t\tConsole.WriteLine(min);\n\t\t}\n\t\tlong ord(long n, long p) {\n\t\t\tvar ret = 0L;\n\t\t\twhile (n > 0) {\n\t\t\t\tn /= p;\n\t\t\t\tret += n;\n\t\t\t}\n\t\t\treturn ret;\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\n#region Set\n/// \n/// \u8981\u7d20\u306e\u8ffd\u52a0\u3001\u524a\u9664\u3001\u691c\u7d22\u3001\u53d6\u5f97\u304c\u53ef\u80fd\u306a\u96c6\u5408\u3092\u8868\u3057\u307e\u3059\uff0e\n/// \n/// \u512a\u5148\u5ea6\u4ed8\u304d\u30ad\u30e5\u30fc\u5185\u306e\u8981\u7d20\u306e\u578b\u3092\u6307\u5b9a\u3057\u307e\u3059\uff0e\n/// \u5185\u90e8\u7684\u306b\u306fAVL\u6728\u306b\u3088\u3063\u3066\u5b9f\u88c5\u3055\u308c\u3066\u3044\u307e\u3059\uff0e\npublic class Set {\n\tNode root;\n\treadonly IComparer comparer;\n\treadonly Node nil;\n\t/// \n\t/// \u591a\u91cd\u96c6\u5408\u304b\u3069\u3046\u304b\u3092\u8868\u3057\u307e\u3059\uff0e\n\t/// \n\tpublic bool IsMultiSet { get; set; }\n\tpublic Set(IComparer comparer) {\n\t\tnil = new Node(default(T));\n\t\troot = nil;\n\t\tthis.comparer = comparer;\n\t}\n\tpublic Set(Comparison comaprison) : this(Comparer.Create(comaprison)) { }\n\tpublic Set() : this(Comparer.Default) { }\n\t/// \n\t/// \u8981\u7d20\u3092\u30b3\u30ec\u30af\u30b7\u30e7\u30f3\u306b\u8ffd\u52a0\u3057\u307e\u3059\uff0e\n\t/// \n\t/// \u3053\u306e\u64cd\u4f5c\u306f\u8a08\u7b97\u91cf O(log N) \u3067\u5b9f\u884c\u3055\u308c\u307e\u3059\uff0e\n\tpublic bool Add(T v) {\n\t\treturn insert(ref root, v);\n\t}\n\t/// \n\t/// v \u304c\u5b58\u5728\u3059\u308b\u306a\u3089\u30b3\u30ec\u30af\u30b7\u30e7\u30f3\u304b\u3089\u524a\u9664\u3057\u307e\u3059\uff0e\n\t/// \n\t/// \u3053\u306e\u64cd\u4f5c\u306f\u8a08\u7b97\u91cf O(log N) \u3067\u5b9f\u884c\u3055\u308c\u307e\u3059\uff0e\n\tpublic bool Remove(T v) {\n\t\treturn remove(ref root, v);\n\t}\n\t/// \n\t/// 0-indexed \u3067 index \u756a\u76ee\u306e\u8981\u7d20\u3092\u30b3\u30ec\u30af\u30b7\u30e7\u30f3\u304b\u3089\u53d6\u5f97\u3057\u307e\u3059\uff0e\uff0e\n\t/// \n\t/// \u3053\u306e\u64cd\u4f5c\u306f\u8a08\u7b97\u91cf O(log N) \u3067\u5b9f\u884c\u3055\u308c\u307e\u3059\uff0e\n\tpublic T this[int index] { get { return find(root, index); } }\n\tpublic int Count { get { return root.Count; } }\n\tpublic void RemoveAt(int k) {\n\t\tif (k < 0 || k >= root.Count) throw new ArgumentOutOfRangeException();\n\t\tremoveAt(ref root, k);\n\t}\n\t/// \n\t/// \u3053\u306e\u30b3\u30ec\u30af\u30b7\u30e7\u30f3\u306b\u542b\u307e\u308c\u308b\u8981\u7d20\u3092\u6607\u9806\u306b\u4e26\u3079\u3066\u8fd4\u3057\u307e\u3059\uff0e\n\t/// \n\t/// \u3053\u306e\u64cd\u4f5c\u306f\u8a08\u7b97\u91cf O(N) \u3067\u5b9f\u884c\u3055\u308c\u307e\u3059\uff0e\n\tpublic T[] Items {\n\t\tget {\n\t\t\tvar ret = new T[root.Count];\n\t\t\tvar k = 0;\n\t\t\twalk(root, ret, ref k);\n\t\t\treturn ret;\n\t\t}\n\t}\n\tvoid walk(Node t, T[] a, ref int k) {\n\t\tif (t.Count == 0) return;\n\t\twalk(t.lst, a, ref k);\n\t\ta[k++] = t.Key;\n\t\twalk(t.rst, a, ref k);\n\t}\n\n\tbool insert(ref Node t, T key) {\n\t\tif (t.Count == 0) { t = new Node(key); t.lst = t.rst = nil; t.Update(); return true; }\n\t\tvar cmp = comparer.Compare(t.Key, key);\n\t\tbool res;\n\t\tif (cmp > 0)\n\t\t\tres = insert(ref t.lst, key);\n\t\telse if (cmp == 0) {\n\t\t\tif (IsMultiSet) res = insert(ref t.lst, key);\n\t\t\telse return false;\n\t\t}\n\t\telse res = insert(ref t.rst, key);\n\t\tbalance(ref t);\n\t\treturn res;\n\t}\n\tbool remove(ref Node t, T key) {\n\t\tif (t.Count == 0) return false;\n\t\tvar cmp = comparer.Compare(key, t.Key);\n\t\tbool ret;\n\t\tif (cmp < 0) ret = remove(ref t.lst, key);\n\t\telse if (cmp > 0) ret = remove(ref t.rst, key);\n\t\telse {\n\t\t\tret = true;\n\t\t\tvar k = t.lst.Count;\n\t\t\tif (k == 0) { t = t.rst; return true; }\n\t\t\tif (t.rst.Count == 0) { t = t.lst; return true; }\n\n\n\t\t\tt.Key = find(t.lst, k - 1);\n\t\t\tremoveAt(ref t.lst, k - 1);\n\t\t}\n\t\tbalance(ref t);\n\t\treturn ret;\n\t}\n\tvoid removeAt(ref Node t, int k) {\n\t\tvar cnt = t.lst.Count;\n\t\tif (cnt < k) removeAt(ref t.rst, k - cnt - 1);\n\t\telse if (cnt > k) removeAt(ref t.lst, k);\n\t\telse {\n\t\t\tif (cnt == 0) { t = t.rst; return; }\n\t\t\tif (t.rst.Count == 0) { t = t.lst; return; }\n\n\t\t\tt.Key = find(t.lst, k - 1);\n\t\t\tremoveAt(ref t.lst, k - 1);\n\t\t}\n\t\tbalance(ref t);\n\t}\n\tvoid balance(ref Node t) {\n\t\tvar balance = t.lst.Height - t.rst.Height;\n\t\tif (balance == -2) {\n\t\t\tif (t.rst.lst.Height - t.rst.rst.Height > 0) { rotR(ref t.rst); }\n\t\t\trotL(ref t);\n\t\t}\n\t\telse if (balance == 2) {\n\t\t\tif (t.lst.lst.Height - t.lst.rst.Height < 0) rotL(ref t.lst);\n\t\t\trotR(ref t);\n\t\t}\n\t\telse t.Update();\n\t}\n\n\tT find(Node t, int k) {\n\t\tif (k < 0 || k > root.Count) throw new ArgumentOutOfRangeException();\n\t\tfor (; ; )\n\t\t{\n\t\t\tif (k == t.lst.Count) return t.Key;\n\t\t\telse if (k < t.lst.Count) t = t.lst;\n\t\t\telse { k -= t.lst.Count + 1; t = t.rst; }\n\t\t}\n\t}\n\t/// \n\t/// \u30b3\u30ec\u30af\u30b7\u30e7\u30f3\u306b\u542b\u307e\u308c\u308b\u8981\u7d20\u3067\u3042\u3063\u3066\u3001 v \u4ee5\u4e0a\u306e\u6700\u5c0f\u306e\u8981\u7d20\u306e\u756a\u53f7\u3092\u8fd4\u3057\u307e\u3059\u3002\n\t/// \n\t/// \u3053\u306e\u64cd\u4f5c\u306f\u8a08\u7b97\u91cf O(log N) \u3067\u5b9f\u884c\u3055\u308c\u307e\u3059\uff0e\n\tpublic int LowerBound(T v) {\n\t\tvar k = 0;\n\t\tvar t = root;\n\t\tfor (; ; )\n\t\t{\n\t\t\tif (t.Count == 0) return k;\n\t\t\tif (comparer.Compare(v, t.Key) <= 0) t = t.lst;\n\t\t\telse { k += t.lst.Count + 1; t = t.rst; }\n\t\t}\n\t}\n\t/// \n\t/// \u30b3\u30ec\u30af\u30b7\u30e7\u30f3\u306b\u542b\u307e\u308c\u308b\u8981\u7d20\u3067\u3042\u3063\u3066\u3001 v \u3088\u308a\u771f\u306b\u5927\u304d\u3044\u3001\u6700\u5c0f\u306e\u8981\u7d20\u306e\u756a\u53f7\u3092\u8fd4\u3057\u307e\u3059\u3002\n\t/// \n\t/// \u3053\u306e\u64cd\u4f5c\u306f\u8a08\u7b97\u91cf O(log N) \u3067\u5b9f\u884c\u3055\u308c\u307e\u3059\uff0e\n\tpublic int UpperBound(T v) {\n\t\tvar k = 0;\n\t\tvar t = root;\n\t\tfor (; ; )\n\t\t{\n\t\t\tif (t.Count == 0) return k;\n\t\t\tif (comparer.Compare(t.Key, v) <= 0) { k += t.lst.Count + 1; t = t.rst; }\n\t\t\telse t = t.lst;\n\t\t}\n\t}\n\n\tvoid rotR(ref Node t) {\n\t\tvar l = t.lst;\n\t\tt.lst = l.rst;\n\t\tl.rst = t;\n\t\tt.Update();\n\t\tl.Update();\n\t\tt = l;\n\t}\n\tvoid rotL(ref Node t) {\n\t\tvar r = t.rst;\n\t\tt.rst = r.lst;\n\t\tr.lst = t;\n\t\tt.Update();\n\t\tr.Update();\n\t\tt = r;\n\t}\n\n\n\tclass Node {\n\t\tpublic Node(T key) {\n\t\t\tKey = key;\n\t\t}\n\t\tpublic int Count { get; private set; }\n\t\tpublic sbyte Height { get; private set; }\n\t\tpublic T Key { get; set; }\n\t\tpublic Node lst, rst;\n\t\tpublic void Update() {\n\t\t\tCount = 1 + lst.Count + rst.Count;\n\t\t\tHeight = (sbyte)(1 + Math.Max(lst.Height, rst.Height));\n\t\t}\n\t\tpublic override string ToString() {\n\t\t\treturn string.Format(\"Count = {0}, Key = {1}\", Count, Key);\n\t\t}\n\t}\n}\n#endregion\n", "lang_cluster": "C#", "tags": ["brute force", "math", "implementation", "number theory"], "code_uid": "3e5159788be8eef6ff22ec488f03bba6", "src_uid": "491748694c1a53771be69c212a5e0e25", "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 ConsoleApplication1\n{\n class Program\n {\n static void Main(string[] args)\n {\n /* int k = Convert.ToInt32(Console.ReadLine());\n char[,] mas = new char[4, 11];\n\n for (int i = 0; i < 4; i++)\n {\n for (int j = 0; j < 11; j++)\n mas[i, j] = '#';\n \n }\n for (int i = 1; i < 11; i++)\n mas[2, i] = '.';\n\n for (int i = 0; i < 4; i++)\n for (int j = 0; j < 11;j++ )\n if (k > 0 && mas[i, j] != '.')\n { k--; mas[i, j] = '0'; }\n\n Console.WriteLine(\"+------------------------+\");\n Console.Write('|');\n for (int i = 0; i < 11;i++ )\n Console.Write(mas[0,i].ToString() +'.');\n Console.WriteLine(\"|D|)\");\n\n Console.Write('|');\n for (int i = 0; i < 11; i++)\n Console.Write(mas[0, i].ToString() + '.');\n Console.WriteLine(\"|.|)\");\n\n Console.Write('|');\n for (int i = 0; i < 11; i++)\n Console.Write(mas[0, i].ToString() + '.');\n Console.WriteLine(\"..|)\");\n\n Console.Write('|');\n for (int i = 0; i < 11; i++)\n Console.Write(mas[0, i].ToString() + '.');\n Console.WriteLine(\"|.|)\");\n\n Console.WriteLine(\"+------------------------+\");*/\n\n\n int k = Convert.ToInt32(Console.ReadLine());\n if (k < 5)\n {\n Console.WriteLine(\"+------------------------+\");\n if (k > 0) { Console.WriteLine(\"|O.#.#.#.#.#.#.#.#.#.#.|D|)\"); k--; }\n else Console.WriteLine(\"|#.#.#.#.#.#.#.#.#.#.#.|D|)\");\n if (k > 0) { Console.WriteLine(\"|O.#.#.#.#.#.#.#.#.#.#.|.|\"); k--; }\n else Console.WriteLine(\"|#.#.#.#.#.#.#.#.#.#.#.|.|\");\n if (k > 0) { Console.WriteLine(\"|O.......................|\"); k--; }\n else Console.WriteLine(\"|#.......................|\");\n if (k > 0) { Console.WriteLine(\"|O.#.#.#.#.#.#.#.#.#.#.|.|)\"); k--; }\n else Console.WriteLine(\"|#.#.#.#.#.#.#.#.#.#.#.|.|)\");\n Console.WriteLine(\"+------------------------+\");\n return;\n }\n k = k - 4;\n Console.WriteLine(\"+------------------------+\");\n for (int i = 0; i < 2; i++)\n {\n Console.Write(\"|O.\");\n for (int j = 0; j < 10; j++)\n {\n if (3 * j + i < k) Console.Write(\"O.\");\n else Console.Write(\"#.\");\n }\n if (i == 0) Console.Write(\"|D|)\");\n else Console.Write(\"|.|\");\n Console.WriteLine();\n }\n Console.WriteLine(\"|O.......................|\");\n\n Console.Write(\"|O.\");\n for (int i = 0; i < 10; i++)\n if (3 * i + 2 < k) Console.Write(\"O.\");\n else Console.Write(\"#.\");\n Console.Write(\"|.|)\");\n Console.WriteLine();\n Console.WriteLine(\"+------------------------+\");\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "24f6c1b4defc455397c3a7435a503004", "src_uid": "075f83248f6d4d012e0ca1547fc67993", "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 TrojnajaKrasota\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 bool isValid = true;\n int count = 0;\n if (s[0] == '?') count = 2;\n for (int i = 1; i < n; i++)\n {\n\n if (s[i] != '?' && s[i] == s[i - 1])\n {\n isValid = false;\n break;\n }\n if (s[i] == '?' && ((i == n - 1 || s[i - 1] == s[i + 1]) || s[i - 1] == '?')) count = 2;\n }\n\n\n if (isValid && count == 2)\n Console.Write(\"Yes\");\n else\n Console.Write(\"No\");\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "b93ef526ccd8a26f3b5c87f34aa796c0", "src_uid": "f8adfa0dde7ac1363f269dbdf00212c3", "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 ConsoleApp78\n{\n class Program\n {\n static void Main(string[] args)\n {\n long[] inp0 = Console.ReadLine().Split().Select(long.Parse).ToArray();\n long r = inp0[0];\n long x = inp0[1];\n long y = inp0[2];\n long x1 = inp0[3];\n long y1 = inp0[4];\n double ans =Math.Sqrt(((x - x1) * (x - x1)) + ((y - y1) * (y - y1)));\n r *= 2;\n Console.WriteLine(Math.Ceiling( ans/(r)));\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "geometry"], "code_uid": "52f756ba227089cac9feedfefd4e7461", "src_uid": "698da80c7d24252b57cca4e4f0ca7031", "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.Text;\nusing System.Threading.Tasks;\n\nnamespace B\n{\n internal class ProblemSolver\n {\n private long _n, _a, _b;\n\n public void Initialize(long n, long a, long b)\n {\n _n = n;\n _a = a;\n _b = b;\n }\n\n public long CalculateAndGetAnswer()\n {\n var low = Math.Min(_a, _b);\n var high = Math.Max(_a, _b);\n\n double x = (double)_n / (_a + _b);\n var lower = (long) Math.Ceiling(x * low);\n if (lower < 1)\n {\n lower = 1;\n }\n var higher = _n - lower;\n var min = Math.Max(Math.Min(_a / higher, _b / lower), Math.Min(_a / lower, _b / higher));\n\n lower = (long)Math.Floor(x * low);\n if (lower < 1)\n {\n lower = 1;\n }\n\n higher = _n - lower;\n var min2 = Math.Max(Math.Min(_a / higher, _b / lower), Math.Min(_a / lower, _b / higher));\n\n return Math.Max(min, min2);\n }\n }\n\n internal class ConsoleHelper\n {\n private readonly ProblemSolver _solver = new ProblemSolver();\n public string CaseOutput { get; private set; }\n\n public T LineToValue(string line) where T : struct\n {\n return (T)Convert.ChangeType(line.Split()[0], typeof(T));\n }\n\n public List LineToList(string line) where T : struct\n {\n return line.Split(' ').Select(x => (T)Convert.ChangeType(x, typeof(T))).ToList();\n }\n\n public void ReadCaseInput(string caseInput)\n {\n using (var stringReader = new StringReader(caseInput))\n {\n var list = LineToList(stringReader.ReadLine());\n _solver.Initialize(list[0], list[1], list[2]);\n }\n }\n\n public void CalculateAnswer()\n {\n CaseOutput = _solver.CalculateAndGetAnswer().ToString();\n }\n }\n\n internal class Program\n {\n private static void Main(string[] args)\n {\n var consoleHelper = new ConsoleHelper();\n long t = 1;\n for (var i = 0; i < t; i++)\n {\n var stringBuilder = new StringBuilder();\n stringBuilder.AppendLine(Console.ReadLine());\n stringBuilder.AppendLine(Console.ReadLine());\n\n consoleHelper.ReadCaseInput(stringBuilder.ToString());\n consoleHelper.CalculateAnswer();\n\n Console.WriteLine(consoleHelper.CaseOutput);\n }\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "implementation", "binary search"], "code_uid": "259e0537ca3be36f2838e7e78c637aaf", "src_uid": "a254b1e3451c507cf7ce3e2496b3d69e", "difficulty": 1200.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 var ss = CF.ReadLine().Split(' ');\n int n2 = int.Parse(ss[0]);\n int x = int.Parse(ss[1]);\n int y = int.Parse(ss[2]);\n\n int n = n2 / 2;\n\n if( (x==n||x==n+1)&&(y==n||y==n+1))\n CF.WriteLine(\"NO\");\n else\n CF.WriteLine(\"YES\");\n \n }\n\n\t// test\n\tstatic Utils CF = new Utils(new[]{\n@\"\n4 1 1\n\",\n @\"\n2 2 2\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", "implementation"], "code_uid": "be641b2ebcc7588b939ebbebefc880b6", "src_uid": "dc891d57bcdad3108dcb4ccf9c798789", "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 EhWasByDetstvoVspomnit\n{\n\n class Program\n {\n private static int[] ReadIntArray => Console.ReadLine().Split(' ').Select(int.Parse).ToArray();\n private static long[] ReadLongArray => Console.ReadLine().Split(' ').Select(long.Parse).ToArray();\n private static char[] ReadCharArray => Console.ReadLine().Split(' ').Select(char.Parse).ToArray();\n private static int ReadInt => int.Parse(Console.ReadLine());\n private static string ReadString => Console.ReadLine();\n\n static void Main()\n {\n int n = ReadInt;\n //int[] n = ReadIntArray;\n int m = ReadInt;\n int[] a = new int[n];\n for (int i = 0; i < n; i++)\n a[i] = ReadInt;\n Array.Sort(a);\n int max = a[a.Count() - 1] + m;\n int temp = 0;\n for (int i = 0; i < a.Count(); i++)\n {\n temp += a[a.Count() - 1] - a[i];\n }\n if (temp >= m)\n Console.WriteLine(a[a.Count() - 1] + \" \" + max);\n else\n {\n m -= temp;\n if (m % n == 0)\n Console.WriteLine(a[a.Count() - 1] + (m / n) + \" \" + max);\n else\n Console.WriteLine(a[a.Count() - 1] + (m / n) + 1 + \" \" + max);\n }\n Console.ReadLine();\n }\n }\n}", "lang_cluster": "C#", "tags": ["implementation", "binary search"], "code_uid": "dd5d6e32fc47e35b18c3d0c36b1214a3", "src_uid": "78f696bd954c9f0f9bb502e515d85a8d", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "C# 8", "source_code": "// Online C# Editor for free\r\n// Write, Edit and Run your C# code using C# Online Compiler\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 var arr = Console.ReadLine().Split(' ');\r\n \r\n int rows = Int32.Parse(arr[0]);\r\n int columns = Int32.Parse(arr[1]);\r\n //Console.WriteLine(rows);\r\n // Console.WriteLine(columns);\r\n Console.WriteLine(getUniqueNumbers(rows,columns)); \r\n }\r\n \r\n public static int[] precalculate(int m){\r\n var cnt = new int[21];\r\n var vis = new bool[20000002];\r\n int c=0;\r\n for(int i=1;i<=20;++i){\r\n for(int j=1;j<=m;++j){\r\n if(!vis[i*j]){\r\n vis[i*j]=true;\r\n ++c;\r\n }\r\n }\r\n cnt[i]=c;\r\n }\r\n \r\n return cnt;\r\n }\r\n \r\n public static long getUniqueNumbers(int rows, int columns){\r\n var arr = precalculate(columns);\r\n \r\n long res=1;\r\n var vis = new bool[20000002];\r\n \r\n for(int i=2;i<=rows;++i){\r\n if(vis[i])continue;\r\n long j=i;\r\n int c=0;\r\n \r\n while(j<=(long)rows){\r\n vis[j]=true;\r\n j*=i;\r\n ++c;\r\n }\r\n \r\n res+= arr[c];\r\n }\r\n \r\n return res;\r\n }\r\n \r\n}", "lang_cluster": "C#", "tags": ["brute force", "math", "dp", "number theory"], "code_uid": "2be0e8044cdf0a2f326cd093ae74ec34", "src_uid": "6ca310cb0b6fc4e62e63a731cd55aead", "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.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 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 JotyAndChocolateECR13\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 n = fs.NextInt();\n long a = fs.NextInt();\n long b = fs.NextInt();\n long p = fs.NextInt();\n long q = fs.NextInt();\n long lcm = LCM(a, b);\n long ans = n / a * p + n / b * q - n / lcm * Math.Min(p, q);\n writer.WriteLine(ans);\n }\n }\n public static long GCD(long a, long b)\n {\n if (b == 0) return a;\n return GCD(b, a % b);\n }\n public static long LCM(long a, long b)\n {\n long gcd = GCD(a, b);\n return a * b / gcd;\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "implementation", "number theory"], "code_uid": "5f257615fc45105e747a900ba4cfb5c0", "src_uid": "35d8a9f0d5b5ab22929ec050b55ec769", "difficulty": 1600.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 = getInt();\n\t\t\tvar l = getList();\n\t\t\tvar ans = getGcd(l[0], l[1]);\n\t\t\tfor (var i = 2; i < n; ++i)\n\t\t\t\tans = getGcd(ans, l[i]);\n\t\t\tConsole.WriteLine(ans * n);\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", "greedy"], "code_uid": "b7e09ff2784a5afed99ac8675d3b3899", "src_uid": "042cf938dc4a0f46ff33d47b97dc6ad4", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\n\nclass tf\n{\n public static void Main()\n {\n long n = long.Parse(Console.ReadLine());\n \n long i = 2;\n long c = 0;\n\n if(n % 2 == 0) \n {\n Console.WriteLine(n / 2);\n return;\n }\n \n while(i * i <= n)\n {\n if(n % i == 0)\n {\n Console.WriteLine( 1 + (n - i) / 2);\n return;\n }\n \n i++;\n }\n \n Console.WriteLine(1);\n \n }\n}", "lang_cluster": "C#", "tags": ["math", "implementation", "number theory"], "code_uid": "74923da3c47dbf602e3977470820a811", "src_uid": "a1e80ddd97026835a84f91bac8eb21e6", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.ComponentModel;\nusing System.Globalization;\nusing System.IO;\nusing System.Linq;\nusing System.Threading;\n\nnamespace Temp\n{\n public 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 public class Point2DReal\n {\n public double X;\n\n public double Y;\n\n public Point2DReal(double x, double y)\n {\n this.X = x;\n this.Y = y;\n }\n\n public Point2DReal(Point2DReal head)\n : this(head.X, head.Y)\n {\n }\n\n public static Point2DReal operator +(Point2DReal a, Point2DReal b)\n {\n return new Point2DReal(a.X + b.X, a.Y + b.Y);\n }\n\n public static Point2DReal operator -(Point2DReal a, Point2DReal b)\n {\n return new Point2DReal(a.X - b.X, a.Y - b.Y);\n }\n\n public static Point2DReal operator *(Point2DReal a, double k)\n {\n return new Point2DReal(k * a.X, k * a.Y);\n }\n\n public static Point2DReal operator *(double k, Point2DReal a)\n {\n return new Point2DReal(k * a.X, k * a.Y);\n }\n\n public double Dist(Point2DReal p)\n {\n return Math.Sqrt((p.X - X)*(p.X - X) + (p.Y - Y)*(p.Y - Y));\n }\n\n public bool IsInsideRectangle(double l, double b, double r, double t)\n {\n return (l <= X) && (X <= r) && (b <= Y) && (Y <= t);\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 var size = matrix.GetLength(0);\n m_Matrix = new long[size,size];\n Array.Copy(matrix, m_Matrix, size * size);\n Mod = mod;\n\n if (mod != 0)\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\n public static MatrixInt IdentityMatrix(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 public void Print()\n {\n for (int i = 0; i < Size; i++)\n {\n for (int j = 0; j < Size; j++)\n {\n Console.Write(\"{0} \", m_Matrix[i, j]);\n }\n Console.WriteLine();\n }\n }\n }\n\n public static class Permutations\n {\n private static readonly Random m_Random;\n\n static Permutations()\n {\n m_Random = new Random();\n }\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 for (int i = n - 1; i > 0; i--)\n {\n int j = m_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 public static void Shuffle(T[] array)\n {\n var n = array.Count();\n for (int i = n - 1; i > 0; i--)\n {\n int j = m_Random.Next(i + 1);\n T tmp = array[i];\n array[i] = array[j];\n array[j] = tmp;\n } \n }\n\n public static void ShuffleSort(T[] array)\n {\n Shuffle(array);\n Array.Sort(array);\n }\n\n public static int[] Next(int[] p)\n {\n int n = p.Length;\n var next = new int[n];\n Array.Copy(p, next, n);\n\n int k = -1;\n for (int i = n - 1; i > 0; i--)\n {\n if (next[i - 1] < next[i])\n {\n k = i - 1;\n break;\n }\n }\n if (k == -1)\n {\n return null;\n }\n for (int i = n - 1; i >= 0; i--)\n {\n if (next[i] > next[k])\n {\n var tmp = next[i];\n next[i] = next[k];\n next[k] = tmp;\n break;\n }\n }\n for (int i = 1; i <= (n - k - 1) / 2; i++)\n {\n var tmp = next[k + i];\n next[k + i] = next[n - i];\n next[n - i] = tmp;\n }\n\n return next;\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.IdentityMatrix(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 n, long mod)\n {\n long[] result = new long[n];\n result[1] = 1;\n for (int i = 2; i < n; 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 Read(out T v1)\n {\n var values = new T[1];\n Read(values);\n v1 = values[0];\n }\n\n public static void Read(out T v1, out T v2)\n {\n var values = new T[2];\n Read(values);\n v1 = values[0];\n v2 = values[1];\n }\n\n public static void Read(out T v1, out T v2, out T v3)\n {\n var values = new T[3];\n Read(values);\n v1 = values[0];\n v2 = values[1];\n v3 = values[2];\n }\n\n public static void Read(out T v1, out T v2, out T v3, out T v4)\n {\n var values = new T[4];\n Read(values);\n v1 = values[0];\n v2 = values[1];\n v3 = values[2];\n v4 = values[3];\n }\n\n public static void Read(out T v1, out T v2, out T v3, out T v4, out T v5)\n {\n var values = new T[5];\n Read(values);\n v1 = values[0];\n v2 = values[1];\n v3 = values[2];\n v4 = values[3];\n v5 = values[4];\n }\n\n public static void Read(T[] values)\n {\n Read(values, values.Length);\n }\n\n public static void Read(T[] values, int count)\n {\n// ReSharper disable PossibleNullReferenceException\n var list = Console.ReadLine().Split();\n// ReSharper restore PossibleNullReferenceException\n\n count = Math.Min(count, list.Length);\n\n var converter = TypeDescriptor.GetConverter(typeof(T));\n\n for (int i = 0; i < count; i++)\n {\n values[i] = (T)converter.ConvertFromString(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(CultureInfo.InvariantCulture))).ToArray();\n // ReSharper restore AssignNullToNotNullAttribute\n }\n\n public static string ReadLine()\n {\n return Console.ReadLine();\n }\n }\n\n public interface IGraph\n {\n bool IsOriented { get; set; }\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 void AddNotOrientedEdge(int u, int v);\n }\n\n public class ListGraph : IGraph\n {\n private readonly List[] m_Edges;\n\n public int Vertices { get; set; }\n\n public bool IsOriented { get; set; }\n\n public IList this[int i]\n {\n get\n {\n return this.m_Edges[i];\n }\n }\n\n public ListGraph(int vertices, bool isOriented = false)\n {\n this.Vertices = vertices;\n this.IsOriented = isOriented;\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 if (!IsOriented)\n {\n this.AddOrientedEdge(v, u);\n }\n }\n\n public void AddNotOrientedEdge(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 class Pair\n {\n public Pair(TFirst first, TSecond second)\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 protected bool Equals(Pair other)\n {\n return EqualityComparer.Default.Equals(this.First, other.First) && EqualityComparer.Default.Equals(this.Second, other.Second);\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((Pair)obj);\n }\n\n public override int GetHashCode()\n {\n unchecked\n {\n return (EqualityComparer.Default.GetHashCode(this.First) * 397) ^ EqualityComparer.Default.GetHashCode(this.Second);\n }\n }\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 public 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 public class DisjointSetUnion\n {\n public DisjointSetUnion()\n {\n m_Parent = new Dictionary();\n m_Rank = new Dictionary();\n }\n\n public DisjointSetUnion(DisjointSetUnion set)\n {\n m_Parent = new Dictionary(set.m_Parent);\n m_Rank = new Dictionary(set.m_Rank);\n }\n\n private readonly Dictionary m_Parent;\n private readonly Dictionary m_Rank;\n\n public int GetRank(T x)\n {\n return m_Rank[x];\n }\n\n public void MakeSet(T x)\n {\n m_Parent[x] = x;\n this.m_Rank[x] = 0;\n }\n\n public void UnionSets(T x, T y)\n {\n x = this.FindSet(x);\n y = this.FindSet(y);\n if (!x.Equals(y))\n {\n if (m_Rank[x] < m_Rank[y])\n {\n T t = x;\n x = y;\n y = t;\n }\n m_Parent[y] = x;\n if (m_Rank[x] == m_Rank[y])\n {\n m_Rank[x]++;\n }\n }\n }\n\n public T FindSet(T x)\n {\n if (x.Equals(m_Parent[x]))\n {\n return x;\n }\n return m_Parent[x] = this.FindSet(m_Parent[x]);\n }\n }\n\n internal class HamiltonianPathFinder\n {\n public static void Run()\n {\n int n, m;\n Reader.Read(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.Read(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 Backtrack where T : class \n {\n public Backtrack(Func> generator)\n {\n this.m_Generator = generator;\n }\n\n public Dictionary Generate(T startState)\n {\n var result = new Dictionary();\n result.Add(startState, null);\n\n var queue = new Queue();\n queue.Enqueue(startState);\n\n while (queue.Count > 0)\n {\n var current = queue.Dequeue();\n var next = m_Generator(current);\n foreach (var state in next)\n {\n if (!result.ContainsKey(state))\n {\n result[state] = current;\n queue.Enqueue(state);\n }\n }\n }\n\n return result;\n }\n\n private Func> m_Generator;\n }\n\n public static class Utility\n {\n public static readonly int[] sx = new[] { 1, 0, -1, 0 };\n public static readonly int[] sy = new[] { 0, 1, 0, -1 };\n\n public static PointInt[] GenerateNeighbors(long x, long y)\n {\n var result = new PointInt[4];\n for (int i = 0; i < 4; i++)\n {\n result[i] = new PointInt(x + sx[i], y + sy[i]);\n }\n return result;\n }\n\n public static PointInt[] GenerateNeighbors(this PointInt p)\n {\n return GenerateNeighbors(p.X, p.Y);\n }\n\n public static List GenerateNeighborsWithBounds(long x, long y, int n, int m)\n {\n var result = new List(4);\n for (int i = 0; i < 4; i++)\n {\n var nx = x + sx[i];\n var ny = y + sy[i];\n if (0 <= nx && nx < n && 0 <= ny && ny < m)\n {\n result.Add(new PointInt(nx, ny));\n }\n }\n return result;\n }\n\n public static List GenerateNeighborsWithBounds(this PointInt p, int n, int m)\n {\n return GenerateNeighborsWithBounds(p.X, p.Y, n, m);\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 //Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;\n\n // OpenFiles();\n\n var mainThread = new Thread(() => new Solution().Solve(), 50 * 1024 * 1024);\n mainThread.Start();\n mainThread.Join();\n\n // CloseFiles();\n }\n }\n\n internal class Solution\n {\n public void Solve()\n {\n int n = 4;\n int[] a = new int[n];\n Reader.Read(a);\n\n var d = a[1] - a[0];\n var ok = true;\n for (int i = 1; i < n - 1; i++)\n {\n ok = ok && (a[i] + d == a[i + 1]);\n }\n if (ok)\n {\n Console.WriteLine(a[3] + d);\n return;\n }\n\n ok = true;\n for (int i = 1; i < n - 1; i++)\n {\n ok = ok && (a[i] * a[1] == a[i + 1] * a[0]);\n }\n if (ok && a[0] != 0 && ((a[3] * a[1]) % a[0] == 0))\n {\n Console.WriteLine((a[3] * a[1]) / a[0]);\n return;\n }\n\n /*if (a[0] % a[1] == 0)\n {\n d = a[0] / a[1];\n ok = true;\n for (int i = 1; i < n - 1; i++)\n {\n ok = ok && (a[i] == a[i + 1] * d);\n }\n if (ok && (a[3] % d == 0))\n {\n Console.WriteLine(a[3] / d);\n return;\n }\n }*/\n\n Console.WriteLine(42);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "fff1fa0e0403bb9be1e0e1a00f84ce99", "src_uid": "68a9508d49fec672f9c61766d6051047", "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;\n\nnamespace Math\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 Solve(args);\n writer.Flush();\n }\n\n private static IEnumerable G()\n {\n yield return 2;\n for (int i = 3;; i += 2)\n {\n yield return i;\n }\n }\n\n private static void Solve(string[] args)\n {\n int n = Next();\n if (n == 1)\n {\n writer.WriteLine(\"1 0\");\n return;\n }\n\n var list = new List();\n foreach (int i in G())\n {\n if (i*i > n)\n break;\n while (n%i == 0)\n {\n list.Add(i);\n n /= i;\n }\n }\n if (n > 1)\n list.Add(n);\n\n var g = list.GroupBy(t => t).Select(t => new {t.Key, cnt = t.Count()}).ToArray();\n int ans = 1;\n foreach (var gg in g)\n {\n ans *= gg.Key;\n }\n\n int max = g.Max(t => t.cnt);\n\n int cnt;\n for (int i = 0;; i++)\n {\n if (1 << i >= max)\n {\n cnt = i;\n break;\n }\n }\n if (g.Any(t => t.cnt != (1 << cnt)))\n cnt++;\n\n writer.Write(ans);\n writer.Write(' ');\n writer.WriteLine(cnt);\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", "number theory"], "code_uid": "597ef3fb973425c0d2c25434264ad144", "src_uid": "212cda3d9d611cd45332bb10b80f0b56", "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 ConsoleApp10\n{\n class Program\n {\n static void Main(string[] args)\n {\n int[] a = Array.ConvertAll(Console.ReadLine().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries), Convert.ToInt32);\n int p1 = 0; int p2 = 1; int p3 = 2;\n bool OK = false;\n for (; p1 <= 5 ;)\n {\n p3++;\n if (p3 > 5)\n {\n p3 = 2;\n p2++;\n }\n if (p2 > 5)\n {\n p2 = 1;\n p1++;\n }\n List b = new List(a);\n if (p1 <= 5 && p1 != p2 && p2 != p3 && p1 != p3)\n {\n b[p1] = 0;\n b[p2] = 0;\n b[p3] = 0;\n if (b.Sum() == a[p1] + a[p2] + a[p3])\n {\n OK = true;\n }\n }\n }\n if (OK)\n {\n Console.WriteLine(\"YES\");\n }\n else\n {\n Console.WriteLine(\"NO\");\n }\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force"], "code_uid": "fb27f14b730b77332e53d807ea399d3b", "src_uid": "2acf686862a34c337d1d2cbc0ac3fd11", "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 _493D\n{\n class Program\n {\n // \u05d1\u05ea\u05d5\u05e8 \u05d4\u05d9\u05e8\u05d9\u05d1 \u05d4\u05de\u05e8\u05d7\u05e7 \u05d9\u05d4\u05d9\u05d4 \u05d0\u05d9-\u05d6\u05d5\u05d2\u05d9\n static void Main(string[] args)\n {\n int n = Convert.ToInt32(Console.ReadLine());\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}\n", "lang_cluster": "C#", "tags": ["math", "constructive algorithms", "games"], "code_uid": "f8a067259ac57373c36d6556dad99b9d", "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;\nusing System.Threading.Tasks;\n\nnamespace ConsProg\n{\n class Program\n {\n static void Main(string[] args)\n { \n string ticket = Console.ReadLine();\n int min = 10, difference = 0;\n string example = \"\";\n for (int a = 0; a < 10; a++)\n for (int b = 0; b < 10; b++)\n for (int c = 0; c < 10; c++)\n for (int d = 0; d < 10; d++)\n for (int e = 0; e < 10; e++)\n for (int f = 0; f < 10; f++)\n {\n example = a.ToString() + b.ToString() + c.ToString() + d.ToString() + e.ToString() + f.ToString();\n if (IsHappy(int.Parse(example)))\n {\n int diff = Difference(ticket, example);\n if (min > diff)\n min = diff;\n }\n }\n Console.WriteLine(min);\n }\n static bool IsHappy(int ticket)\n {\n if ((ticket % 1000000 - ticket % 100000) / 100000 + (ticket % 100000 - ticket % 10000) / 10000 + (ticket % 10000 - ticket % 1000) / 1000\n == (ticket % 1000 - ticket % 100) / 100 + (ticket % 100 - ticket % 10) / 10 + ticket % 10)\n return true;\n return false;\n } \n static int Difference(string t1, string t2)\n {\n int count = 0;\n for (int i = 0; i < 6; i++)\n if (t1[i] != t2[i])\n count++;\n return count;\n }\n //static bool IsHappy(string ticket)\n //{\n // if (int.Parse(ticket[0].ToString()) + int.Parse(ticket[1].ToString()) + int.Parse(ticket[2].ToString())\n // == int.Parse(ticket[3].ToString()) + int.Parse(ticket[4].ToString()) + int.Parse(ticket[5].ToString()))\n // return true;\n // return false;\n //}\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "greedy", "implementation"], "code_uid": "26c522f6295723f3a29061a74f5f253f", "src_uid": "09601fd1742ffdc9f822950f1d3e8494", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\n\nnamespace ALGORITM_CodeForces\n{\n class Program\n {\n static void Main()\n {\n string s = Console.ReadLine();\n var n = Convert.ToInt64(s.Split(' ')[0]);\n var k = Convert.ToInt64(s.Split(' ')[1]);\n\n Console.WriteLine(To(1,n,n,k,n));\n Console.WriteLine();\n }\n static long To(long left,long right,long cur,long y,long x)\n {\n long final;\n long y1=1;\n long mid = left + (right - left) / 2;\n long plus = mid;\n long t = mid;\n while ((t/y)!=0)\n {\n t = mid / (y1=y1*y);\n plus = plus + t;\n \n }\n\n if ((mid==left) && (left==right))\n \n return mid;\n\n else if (plus < cur)\n {\n final = To(mid+1, right, cur,y,x);\n }\n else\n {\n\n final=To(left, mid, cur,y,x);\n \n }\n return final;\n }\n }\n}", "lang_cluster": "C#", "tags": ["implementation", "binary search"], "code_uid": "0a84c856ccb619336de209e86be2ad9a", "src_uid": "41dfc86d341082dd96e089ac5433dc04", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\n\nnamespace Task_C\n{\n class Program\n {\n\n static int check(long n)\n {\n if (n == 2 || n == 5 || n == 7 || n == 8)\n return 1;\n\n int count = 0;\n long m;\n\n long g = n / 3;\n while (g > 0)\n {\n if ((n - 3 * g) % 2 != 0)\n {\n g--;\n continue;\n }\n\n m = (n - 3 * g) / 2;\n\n if (m == 0)\n {\n g -= 2;\n continue;\n }\n\n if (g >= (m * (m - 1))/2)\n count++;\n else\n break;\n\n g -= 2;\n }\n\n\n return count;\n }\n\n static void Main(string[] args)\n {\n Int64 n = Int64.Parse(Console.ReadLine());\n Console.WriteLine(check(n));\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "greedy", "binary search", "brute force"], "code_uid": "4c2078212c7aa65adf0640a12364ce32", "src_uid": "ab4f9cb3bb0df6389a4128e9ff1207de", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Text;\n\nnamespace problemB\n{\n class Program\n {\n static int getMask(int a)\n {\n int result = 0;\n int coef = 1;\n while (a > 0)\n {\n int m = a % 10;\n if (m == 4 || m == 7)\n {\n result += (m*coef);\n coef *= 10;\n }\n a /= 10;\n }\n return result;\n }\n\n static void Main(string[] args)\n {\n int[] data = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);\n int a = data[0], b = data[1];\n int first = a+1;\n int mask=0;\n while (true)\n {\n if ((mask=getMask(first)) == b)\n {\n Console.WriteLine(first);\n break;\n }\n first++;\n }\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "implementation"], "code_uid": "4c8e4d892345674c12222e4ea936269c", "src_uid": "e5e4ea7a5bf785e059e10407b25d73fb", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\n\nnamespace A877\n{\n class Program\n {\n static void Main(string[] args)\n {\n var s = Console.ReadLine();\n var c = 0;\n if (s.Contains(\"Danil\") &&\n (s.Contains(\"Olya\") || s.Contains(\"Slava\") || s.Contains(\"Ann\") || s.Contains(\"Nikita\")))\n {\n Console.WriteLine(\"NO\");\n return;\n }\n if (s.Contains(\"Olya\") &&\n (s.Contains(\"Danil\") || s.Contains(\"Slava\") || s.Contains(\"Ann\") || s.Contains(\"Nikita\")))\n {\n Console.WriteLine(\"NO\");\n return;\n }\n if (s.Contains(\"Slava\") &&\n (s.Contains(\"Olya\") || s.Contains(\"Danil\") || s.Contains(\"Ann\") || s.Contains(\"Nikita\")))\n {\n Console.WriteLine(\"NO\");\n return;\n }\n if (s.Contains(\"Ann\") &&\n (s.Contains(\"Olya\") || s.Contains(\"Slava\") || s.Contains(\"Danil\") || s.Contains(\"Nikita\")))\n {\n Console.WriteLine(\"NO\");\n return;\n }\n if (s.Contains(\"Nikita\") &&\n (s.Contains(\"Olya\") || s.Contains(\"Slava\") || s.Contains(\"Ann\") || s.Contains(\"Danil\")))\n {\n Console.WriteLine(\"NO\");\n return;\n }\n\n if (s.Contains(\"Danil\"))\n {\n for (int i = 0; i < s.Length - 4; i++)\n {\n if (s[i] == 'D' && s[i + 1] == 'a' && s[i + 2] == 'n' && s[i + 3] == 'i' && s[i + 4] == 'l')\n c++;\n }\n\n if (c > 1)\n {\n Console.WriteLine(\"NO\");\n return;\n }\n }\n if (s.Contains(\"Olya\"))\n {\n for (int i = 0; i < s.Length - 3; i++)\n {\n if (s[i] == 'O' && s[i + 1] == 'l' && s[i + 2] == 'y' && s[i + 3] == 'a')\n c++;\n }\n\n if (c > 1)\n {\n Console.WriteLine(\"NO\");\n return;\n }\n }\n if (s.Contains(\"Slava\"))\n {\n for (int i = 0; i < s.Length - 4; i++)\n {\n if (s[i] == 'S' && s[i + 1] == 'l' && s[i + 2] == 'a' && s[i + 3] == 'v' && s[i + 4] == 'a')\n c++;\n }\n\n if (c > 1)\n {\n Console.WriteLine(\"NO\");\n return;\n }\n }\n if (s.Contains(\"Ann\"))\n {\n for (int i = 0; i < s.Length - 2; i++)\n {\n if (s[i] == 'A' && s[i + 1] == 'n' && s[i + 2] == 'n')\n c++;\n }\n\n if (c > 1)\n {\n Console.WriteLine(\"NO\");\n return;\n }\n }\n if (s.Contains(\"Nikita\"))\n {\n for (int i = 0; i < s.Length - 5; i++)\n {\n if (s[i] == 'N' && s[i + 1] == 'i' && s[i + 2] == 'k' && s[i + 3] == 'i' && s[i + 4] == 't' && s[i + 5] == 'a')\n c++;\n }\n\n if (c > 1)\n {\n Console.WriteLine(\"NO\");\n return;\n }\n }\n if (s.Contains(\"Danil\") ||\n s.Contains(\"Olya\") || s.Contains(\"Slava\") || s.Contains(\"Ann\") || s.Contains(\"Nikita\"))\n {\n Console.WriteLine(\"YES\");\n return;\n }\n\n Console.WriteLine(\"NO\");\n }\n }\n}", "lang_cluster": "C#", "tags": ["strings", "implementation"], "code_uid": "13244c1af4e6d0349935ba04d123404f", "src_uid": "db2dc7500ff4d84dcc1a37aebd2b3710", "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.Xml.Xsl;\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\t\t\t//var inputs3 = input3.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(long.Parse).ToArray();\n\n\t\t\tlong n = long.Parse(input2);\n\n\t\t\tvar dictionary = new Dictionary{ {2, 0}, {3, 0}, { 5, 0 }, { 7, 0 } };\n\t\t\twhile (n > 0) \n\t\t\t{\n\t\t\t\tvar rest = n % 10;\n\t\t\t\tswitch (rest) \n\t\t\t\t{\n\t\t\t\t\tcase 2:\n\t\t\t\t\t\tdictionary[rest]++;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 3:\n\t\t\t\t\t\tdictionary[2]++;\n\t\t\t\t\t\tdictionary[3]++;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 4:\n\t\t\t\t\t\tdictionary[2] += 3;\n\t\t\t\t\t\tdictionary[3]++;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 5:\n\t\t\t\t\t\tdictionary[2] += 3;\n\t\t\t\t\t\tdictionary[3]++;\n\t\t\t\t\t\tdictionary[5]++;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 6:\n\t\t\t\t\t\tdictionary[2] += 4;\n\t\t\t\t\t\tdictionary[3] += 2;\n\t\t\t\t\t\tdictionary[5]++;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 7:\n\t\t\t\t\t\tdictionary[2] += 4;\n\t\t\t\t\t\tdictionary[3] += 2;\n\t\t\t\t\t\tdictionary[5]++;\n\t\t\t\t\t\tdictionary[7]++;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 8:\n\t\t\t\t\t\tdictionary[2] += 7;\n\t\t\t\t\t\tdictionary[3] += 2;\n\t\t\t\t\t\tdictionary[5]++;\n\t\t\t\t\t\tdictionary[7]++;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 9:\n\t\t\t\t\t\tdictionary[2] += 7;\n\t\t\t\t\t\tdictionary[3] += 4;\n\t\t\t\t\t\tdictionary[5]++;\n\t\t\t\t\t\tdictionary[7]++;\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tn /= 10;\n\t\t\t}\n\n\t\t\tvar builder = new StringBuilder();\n\t\t\tforeach (var key in dictionary.Keys.OrderByDescending(k => k)) \n\t\t\t{\n\t\t\t\tif (dictionary[key] == 0) \n\t\t\t\t{\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\twhile (dictionary[key] > 0) \n\t\t\t\t{\n\t\t\t\t\tswitch (key)\n\t\t\t\t\t{\n\t\t\t\t\t\tcase 2:\n\t\t\t\t\t\t\tdictionary[key]--;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tcase 3:\n\t\t\t\t\t\t\tdictionary[2]--;\n\t\t\t\t\t\t\tdictionary[3]--;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tcase 4:\n\t\t\t\t\t\t\tdictionary[2] -= 3;\n\t\t\t\t\t\t\tdictionary[3]--;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tcase 5:\n\t\t\t\t\t\t\tdictionary[2] -= 3;\n\t\t\t\t\t\t\tdictionary[3]--;\n\t\t\t\t\t\t\tdictionary[5]--;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tcase 6:\n\t\t\t\t\t\t\tdictionary[2] -= 4;\n\t\t\t\t\t\t\tdictionary[3] -= 2;\n\t\t\t\t\t\t\tdictionary[5]--;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tcase 7:\n\t\t\t\t\t\t\tdictionary[2] -= 4;\n\t\t\t\t\t\t\tdictionary[3] -= 2;\n\t\t\t\t\t\t\tdictionary[5]--;\n\t\t\t\t\t\t\tdictionary[7]--;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tcase 8:\n\t\t\t\t\t\t\tdictionary[2] -= 7;\n\t\t\t\t\t\t\tdictionary[3] -= 2;\n\t\t\t\t\t\t\tdictionary[5]--;\n\t\t\t\t\t\t\tdictionary[7]--;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tcase 9:\n\t\t\t\t\t\t\tdictionary[2] -= 7;\n\t\t\t\t\t\t\tdictionary[3] -= 4;\n\t\t\t\t\t\t\tdictionary[5]--;\n\t\t\t\t\t\t\tdictionary[7]--;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\n\t\t\t\t\tbuilder.Append(key);\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": ["math", "sortings", "greedy"], "code_uid": "9191fba8ede0156b6a21f11e29470830", "src_uid": "60dbfc7a65702ae8bd4a587db1e06398", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.IO;\nusing System.Text;\n\nnamespace ACM\n{\n class Program\n {\n static int Gcd(int a, int b)\n {\n return b != 0 ? Gcd(b, a % b) : a;\n }\n\n static int Solve(int n, int m)\n {\n if (m == 0)\n {\n return 1;\n }\n \n if (m == n)\n {\n return 0;\n }\n\n m--;\n int length = n - 1;\n int one = 0;\n while (m-- > 0)\n {\n if (length == 0)\n {\n one--;\n }\n else if (length == 1)\n {\n length--;\n }\n else if (length == 2)\n {\n length--;\n }\n else\n {\n length -= 2;\n one++;\n }\n }\n\n if (length > 0)\n {\n one++;\n }\n\n return one;\n }\n\n static void Main(string[] args)\n {\n string[] token = Console.ReadLine().Split();\n int n = int.Parse(token[0]);\n int m = int.Parse(token[1]);\n Console.WriteLine(Solve(n, m));\n }\n }\n}", "lang_cluster": "C#", "tags": ["math", "greedy"], "code_uid": "5bf565425e34228e744661f50364a15b", "src_uid": "c05d0a9cabe04d8fb48c76d2ce033648", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\n\nclass StartUp\n{\n static void Main()\n {\n string input = Console.ReadLine();\n string result = \"No\";\n for (int i = 2; i < input.Length; i++)\n {\n if ((input[i]!=input[i-1])\n && (input[i-1]!=input[i-2])\n && (input[i - 2] != input[i])\n && (input[i]!= '.')\n && (input[i-1]!= '.')\n && (input[i-2]!= '.'))\n {\n result = \"Yes\";\n }\n }\n Console.WriteLine(result);\n }\n}\n", "lang_cluster": "C#", "tags": ["strings", "implementation"], "code_uid": "13ac6b88daa538b433dbf887c3191a28", "src_uid": "ba6ff507384570152118e2ab322dd11f", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\n\nnamespace Testriep\n{\n public class Program\n {\n\n \n public static void Main(string[] args)\n {\n var line=Console.ReadLine().Split(' ');\n var p = int.Parse(line[0]);\n var h = int.Parse(line[1]);\n if (h % 2 == 0)\n {\n h--;\n }\n while (h > p)\n {\n if (isGood(h,p))\n {\n Console.WriteLine(h);\n return;\n }\n h -= 2;\n }\n Console.WriteLine(-1);\n //Console.WriteLine(Console.ReadLine().Split(' ').Select(e => int.Parse(e)).Where(e => e != 0).Distinct().Count());\n }\n\n static bool isGood(int n,int p)\n {\n int sqrt = (int)(Math.Sqrt((double)n)+1);\n int limit = Math.Min(sqrt, p);\n for(int i = 2; i <= limit; i++)\n {\n if (n % i == 0)\n {\n return false;\n }\n }\n return true;\n }\n}\n}", "lang_cluster": "C#", "tags": ["brute force", "math", "number theory"], "code_uid": "8557de965ce19760c8a7658af118c3ea", "src_uid": "b533203f488fa4caf105f3f46dd5844d", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Linq;\n\nnamespace CodeForcesTest.Round278\n{\n class FightTheMonster\n {\n public static void Main(string[] args)\n {\n Run();\n //Console.ReadLine();\n }\n\n private static void Run()\n {\n string input = Console.ReadLine();\n var inputArray = input.Split(new[] {' '}).Select(x => Convert.ToInt32(x)).ToArray();\n int hpY = inputArray[0];\n int atkY = inputArray[1];\n int defY = inputArray[2];\n input = Console.ReadLine();\n\n inputArray = input.Split(new[] { ' ' }).Select(x => Convert.ToInt32(x)).ToArray();\n int hpM = inputArray[0];\n int atkM = inputArray[1];\n int defM = inputArray[2];\n\n input = Console.ReadLine();\n inputArray = input.Split(new[] { ' ' }).Select(x => Convert.ToInt32(x)).ToArray();\n int h = inputArray[0];\n int a = inputArray[1];\n int d = inputArray[2];\n\n int cost = Int32.MaxValue;\n int testA = 0;\n int testD = 0;\n int testH = 0;\n for (int atk = atkY; atk <= 200; atk++)\n {\n if (atk <= defM) continue;\n\n for (int def = defY; def <= 100; def++)\n {\n int hp = hpY;\n double dayM = Math.Ceiling((double)hpM / (atk - defM));\n double dayY = Math.Ceiling(atkM - def > 0 ? (double)hp / (atkM - def) : Int32.MaxValue);\n while (dayM >= dayY)\n {\n hp++;\n dayM = Math.Ceiling((double)hpM / (atk - defM));\n dayY = Math.Ceiling(atkM - def > 0 ? (double)hp / (atkM - def) : Int32.MaxValue);\n }\n int tmp = a*(atk-atkY) + d*(def-defY) + h*(hp-hpY);\n if (tmp < cost)\n {\n\n cost = tmp;\n testA = atk - atkY;\n testD = def - defY;\n testH = hp - hpY;\n }\n }\n }\n\n Console.WriteLine(cost);\n }\n\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "implementation"], "code_uid": "1b41aefa7ffbcacde1746a3e8f326267", "src_uid": "bf8a133154745e64a547de6f31ddc884", "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 ConsoleApp2\n{\n class Program\n {\n static void Main(string[] args)\n {\n int n = int.Parse(Console.ReadLine());\n if (n % 4 == 1)\n {\n Console.WriteLine(\"0 A\");\n }\n else if (n % 4 == 3)\n {\n Console.WriteLine(\"2 A\");\n }\n else if (n % 4 == 2)\n {\n Console.WriteLine(\"1 B\");\n }\n else\n {\n Console.WriteLine(\"1 A\");\n }\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force"], "code_uid": "b91e6dbc422a751c27ac0fc43f543c0c", "src_uid": "488e809bd0c55531b0b47f577996627e", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.IO;\nusing System.Linq;\nusing System.Numerics;\nusing System.Collections.Generic;\nusing System.Text;\nusing System.Text.RegularExpressions;\nusing System.Threading.Tasks;\nusing Debug = System.Diagnostics.Debug;\nusing static System.Math;\nusing System.Runtime.CompilerServices;\nusing MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;\nusing MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;\n \npublic static class P\n{\n public static void Main()\n {\n var n = long.Parse(Console.ReadLine());\n var factors = PrimeFactors(n).Distinct().ToArray();\n if (factors.Length == 1)\n {\n Console.WriteLine(factors[0]);\n return;\n }\n Console.WriteLine(1);\n }\n static IEnumerable PrimeFactors(long n)\n {\n while ((n & 1) == 0)\n {\n n >>= 1;\n yield return 2;\n }\n for (long i = 3; i * i <= n; i += 2)\n {\n while (n % i == 0)\n {\n n /= i;\n yield return i;\n }\n }\n if (n != 1) yield return n;\n }\n}", "lang_cluster": "C#", "tags": ["math", "constructive algorithms", "number theory"], "code_uid": "2f527885171db40703709b5ed80a826c", "src_uid": "f553e89e267c223fd5acf0dd2bc1706b", "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 ConsoleApplication1\n{\n class Program\n {\n static void Main(string[] args)\n {\n Int64 n = Int64.Parse(Console.ReadLine());\n if (n % 2 == 1)\n {\n Console.Write(\"1\");\n }\n else Console.Write(\"2\");\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "games"], "code_uid": "65b5549fa82ee1c716bb004810f2af37", "src_uid": "816ec4cd9736f3113333ef05405b8e81", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeff\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Text;\nusing System.Diagnostics;\n\nclass Solver\n{\n public void Solve()\n {\n var ss = Console.ReadLine().Split(' ');\n int n = int.Parse(ss[0]);\n int m = int.Parse(ss[1]);\n int k = int.Parse(ss[2]);\n\n int[,][] d = new int[n,m][];\n for (int p = 0; p < n; p++)\n {\n Console.ReadLine();\n for (int i = 0; i < m; i++)\n {\n ss = Console.ReadLine().Split(' ');\n d[p, i] = new int[3];\n d[p,i][0] = int.Parse(ss[0]);\n d[p, i][1] = int.Parse(ss[1]);\n d[p, i][2] = int.Parse(ss[2]);\n }\n }\n\n int max = 0;\n for (int p1 = 0; p1 < n; p1++)\n {\n for (int p2 = 0; p2 < n; p2++)\n {\n var list = new List>();\n for (int i = 0; i < m; i++)\n {\n var kv = new KeyValuePair( d[p2,i][1]-d[p1,i][0],i );\n list.Add(kv);\n }\n list.Sort(delegate(KeyValuePairkv1,KeyValuePairkv2){\n return -(kv1.Key-kv2.Key);\n });\n\n int q = k;\n int prof = 0;\n foreach(var v in list)\n {\n if (v.Key <= 0)\n break;\n if (q == 0)\n break;\n int qq = Math.Min(q,d[p1,v.Value][2]);\n prof+=(v.Key* qq);\n q -= qq;\n }\n\n max = Math.Max(max, prof);\n }\n }\n Console.WriteLine(max);\n }\n\n#if !DEBUG\n static void Main(string[] args)\n {\n new Solver().Solve();\n }\n#endif\n}\n\n\n", "lang_cluster": "C#", "tags": ["greedy", "games", "graph matchings"], "code_uid": "c87e58c649aa1da9778d02dac44988e8", "src_uid": "7419c4268a9815282fadca6581f28ec1", "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.Numerics;\npublic class Codeforces\n{\n protected static TextReader reader;\n protected static TextWriter writer;\n public static int Gcd(int a, int b)\n {\n if (a < 0)\n a = -a;\n if (b < 0)\n b = -b;\n if (a == 0)\n return b;\n while (b != 0)\n {\n int c = a;\n a = b;\n b = c % b;\n }\n return a;\n }\n static object Solve()\n {\n var a = ReadInt();\n var b = ReadInt();\n if (a == b)\n {\n writer.WriteLine(0);\n return null;\n }\n int ctr = 0, q = 1, q2 = 1;\n var cd = Gcd(a, b);\n if (a != 1 && a != cd)\n {\n q = a / cd;\n if (q % 2 != 0 && q % 3 != 0 && q % 5 != 0)\n {\n writer.WriteLine(-1);\n return null;\n }\n while (q % 5 == 0)\n {\n q /= 5;\n ctr++;\n }\n while (q % 3 == 0)\n {\n q /= 3;\n ctr++;\n }\n while (q % 2 == 0)\n {\n q /= 2;\n ctr++;\n }\n }\n if (b != 1 && b != cd)\n {\n q2 = b / cd;\n if (q2 % 2 != 0 && q2 % 3 != 0 && q2 % 5 != 0)\n {\n writer.WriteLine(-1);\n return null;\n }\n while (q2 % 5 == 0)\n {\n q2 /= 5;\n ctr++;\n }\n while (q2 % 3 == 0)\n {\n q2 /= 3;\n ctr++;\n }\n while (q2 % 2 == 0)\n {\n q2 /= 2;\n ctr++;\n }\n }\n if (q == q2)\n {\n Console.WriteLine(ctr);\n }\n else\n {\n Console.WriteLine(-1);\n }\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 #endregion\n}", "lang_cluster": "C#", "tags": ["math", "number theory"], "code_uid": "9e64baa63dc689ded547a92340d1d856", "src_uid": "75a97f4d85d50ea0e1af0d46f7565b49", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Linq;\nnamespace _873A\n{\n internal class Program\n {\n public static void Main(string[] args)\n {\n string[] input = Console.ReadLine().Split(' ');\n int n = int.Parse(input[0]), k = int.Parse(input[1]), x = int.Parse(input[2]);\n int[] a = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);\n Array.Sort(a, (f, s) => s.CompareTo(f));\n for (int i = 0; i < k; i++)\n a[i] = x;\n Console.WriteLine(a.Sum());\n }\n }\n}", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "cb8d66f18e6fcbf1393237c34fd3f3c7", "src_uid": "92a233f8d9c73d9f33e4e6116b7d0a96", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.IO;\nusing System.Text;\n\nnamespace Codeforces_World_Finals\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 d = Next(), m = Next(), y = Next();\n int d1 = Next(), m1 = Next(), y1 = Next();\n\n var start = new DateTime(2000 + y, m, d);\n\n if (Check(start, d1, m1, y1) ||\n Check(start, d1, y1, m1) ||\n Check(start, m1, d1, y1) ||\n Check(start, y1, d1, m1) ||\n Check(start, m1, y1, d1) ||\n Check(start, y1, m1, d1))\n {\n writer.WriteLine(\"YES\");\n }\n else\n writer.WriteLine(\"NO\");\n\n\n writer.Flush();\n }\n\n private static bool Check(DateTime start, int d, int m, int y)\n {\n try\n {\n var dt = new DateTime(2000 + y, m, d);\n dt = dt.AddYears(18);\n if ((start - dt).TotalDays >= 0)\n return true;\n }\n catch\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": ["implementation"], "code_uid": "a8be00a83f01c70e1cb165cab1a41ff5", "src_uid": "5418c98fe362909f7b28f95225837d33", "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\n private static void Main(string[] args)\n {\n int n = Convert.ToInt32(Console.ReadLine());\n ulong result = 1;\n var l = new List(4) { 2, 3, 4, 5 };\n for (int i = 0; i < 5; ++i)\n {\n result *= (uint)(n - i);\n result *= (uint)(n - i);\n for (int j = l.Count - 1; j >= 0; --j)\n {\n if (result % l[j] == 0)\n {\n result /= l[j];\n l.RemoveAt(j);\n }\n }\n }\n Console.WriteLine(result);\n }\n }\n}", "lang_cluster": "C#", "tags": ["math", "combinatorics"], "code_uid": "eff152eaa203fcd48444fc394e0afbbe", "src_uid": "92db14325cd8aee06b502c12d2e3dd81", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\n\nnamespace CodeF_Block\n{\n class Program\n {\n static void Main(string[] args)\n {\n new Program().Prog();\n }\n\n public void Prog()\n {\n long n = long.Parse(Console.ReadLine());\n long blocked = 0;\n\n if (n == 0)\n blocked = 1;\n else if (n == 1)\n blocked = 4;\n else\n {\n double y = n / Math.Sqrt(2.00);\n y = Math.Truncate(y);\n\n double dist = Math.Sqrt((y * y) + (y + 1) * (y + 1));\n //Console.WriteLine(dist.ToString());\n if (dist <= n)\n {\n blocked = (long)y * 8 + 4;\n }\n else\n {\n blocked = (long)y * 8;\n }\n\n //blocked *= 4;\n }\n\n\n\n Console.WriteLine(blocked.ToString());\n // Console.ReadLine();\n\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["geometry"], "code_uid": "b75d02847bbf43a1ba63e102924d5d65", "src_uid": "d87ce09acb8401e910ca6ef3529566f4", "difficulty": null, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System.Linq;\n\nnamespace codeforce\n{\n class Program\n {\n class Point\n {\n public double X { get; private set; }\n public double Y { get; private set; }\n public Point(double X, double Y)\n {\n this.X = X;\n this.Y = Y;\n }\n public override bool Equals(object obj)\n {\n if (obj is Point)\n {\n return this.X == ((Point)obj).X && this.Y == ((Point)obj).Y;\n }\n else return base.Equals(obj);\n }\n public override int GetHashCode()\n {\n return X.GetHashCode() + Y.GetHashCode();\n }\n }\n public static void Main()\n {\n System.Text.StringBuilder res = new System.Text.StringBuilder();\n var tests = 1;\n //tests = readInt();\n for (int i = 0; i < tests; ++i)\n {\n res.AppendLine(Solve());\n }\n \n System.Console.Out.WriteLine(res);\n }\n\n static string Solve()\n {\n string res = string.Empty;\n\n var a = readSplitedInts(' ');\n\n int s = a.Sum();\n\n if (s % 5 != 0 || s == 0)\n {\n res = \"-1\";\n }\n else\n {\n res = (s / 5).ToString();\n }\n\n return res;\n }\n\n static int parseInt(string str)\n {\n int res = 0;\n for (int i = 0; i < str.Length; ++i)\n {\n res *= 10;\n switch (str[i])\n {\n case '0':\n res += 0;\n break;\n case '1':\n res += 1;\n break;\n case '2':\n res += 2;\n break;\n case '3':\n res += 3;\n break;\n case '4':\n res += 4;\n break;\n case '5':\n res += 5;\n break;\n case '6':\n res += 6;\n break;\n case '7':\n res += 7;\n break;\n case '8':\n res += 8;\n break;\n case '9':\n res += 9;\n break;\n }\n }\n if (str.StartsWith(\"-\"))\n {\n res *= -1;\n }\n return res;\n }\n static int[] readSplitedInts(char split)\n {\n var t = System.Console.In.ReadLine().Split(split);\n int[] res = new int[t.Length];\n for (int i = 0; i < t.Length; ++i)\n {\n res[i] = parseInt(t[i]);\n }\n return res;\n }\n static int readInt()\n {\n return parseInt(System.Console.In.ReadLine());\n }\n static string[] readSplited(char split)\n {\n var t = System.Console.In.ReadLine().Split(split);\n return t;\n }\n }\n}", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "9cd7e55e6bda24050a94ef553b653571", "src_uid": "af1ec6a6fc1f2360506fc8a34e3dcd20", "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[] isPrime = new bool[N+1];\n\t\tfor(int i=2;i<=N;i++) isPrime[i] = true;\n\t\tfor(int i=2;i<=N;i++){\n\t\t\tif(!isPrime[i]) continue;\n\t\t\tfor(int j=i+i;j<=N;j+=i) isPrime[j] = false;\n\t\t}\n\t\t\n\t\t\n\t\tint[] bp = new int[N+1];\n\t\tfor(int i=0;i<=N;i++) bp[i] = i;\n\t\tfor(int i=2;i<=N;i++){\n\t\t\tif(bp[i] == i){\n\t\t\t\tfor(int j=i+i;j<=N;j+=i){\n\t\t\t\t\tbp[j] = i;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n//Console.WriteLine(\"ok\");\n\t\tint min = N - bp[N] + 1;\n\t\tbool[] pos = new bool[N+1];\n\t\tpos[N] = true;\n\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", "math", "number theory"], "code_uid": "250b683d1ea3fcf424e83ea3795d5894", "src_uid": "43ff6a223c68551eff793ba170110438", "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 void SolveA()\n {\n int n = RI();\n var m = RL();\n\n if (n > 40)\n {\n Console.WriteLine(m);\n return;\n }\n\n\n Console.WriteLine(m % (1L << n));\n }\n\n private static void SolveB()\n {\n var n = RI();\n long ans = 0;\n for (int i = 0; i < n; i++)\n {\n\n }\n\n Console.WriteLine(ans);\n }\n\n private static void Main(string[] args)\n {\n SolveA();\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", "implementation"], "code_uid": "5a7681bd30190dc86fdec28da4dae739", "src_uid": "c649052b549126e600691931b512022f", "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.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 = Init>(k + 1);\n Fun(0, n / 2, k, s, d1);\n var d2 = Init>(k + 1);\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 private T[] Init(int n) where T : new()\n {\n var ret = new T[n];\n for (int i = 0; i < n; i++)\n ret[i] = new T();\n return ret;\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": "ebaf9ab6efe26c373f82b248f3068f6f", "src_uid": "2821a11066dffc7e8f6a60a8751cea37", "difficulty": 2100.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Linq;\nusing System.Collections.Generic;\n\nnamespace Task40B\n{\n class Program\n {\n static void Main(string[] args)\n {\n int[] container = Console.ReadLine().Split().Select(int.Parse).ToArray();\n int n = container[0], m = container[1];\n int x = int.Parse(Console.ReadLine());\n\n int horizontalB = 0, verticalB = 0, allB, fourCornerAdjacentB, nonFourCornerAdjacentB;\n Dictionary dictionary = new Dictionary();\n\n //for (int i = 1; ;n-=2,m-=2,/*??????*/i+=2)\n //{\n // if (n < 3 && m < 3 && i!=1)\n // break;\n\n // if (n > 1 && n % 2 != 0)\n // horizontalB = m % 2 == 0 ? (m / 2) * 2 : (m / 2) * 2 + 2;\n // else if (n > 1 && n % 2 == 0)\n // horizontalB = m % 2 == 0 ? (m / 2) * 2 : (m / 2) * 2 + 1;\n // else\n // horizontalB = m % 2 == 0 ? m / 2 : m / 2 + 1;\n\n\n // if (m > 1 && n > 3)\n // verticalB = m % 2 != 0 ? ((n - 2) / 2) * 2 : ((n - 2) / 2) * 2 + 1;\n // else if (n <= 3)\n // verticalB = 0;\n // else\n // verticalB = (n - 2) / 2;\n\n // allB = (n * m) % 2 == 0 ? (n * m) / 2 : (n * m) / 2 + 1;\n // nonFourCornerAdjacentB = horizontalB + verticalB;\n // fourCornerAdjacentB = allB - nonFourCornerAdjacentB;\n\n // dictionary.Add(i, nonFourCornerAdjacentB);\n // dictionary.Add(i + 1, fourCornerAdjacentB);\n //}\n\n\n\n //int ans = 0;\n //foreach (KeyValuePair pair in dictionary)\n //{\n // if (pair.Key == x)\n // {\n // ans = pair.Value;\n // break;\n // }\n //}\n\n //Console.WriteLine(ans);\n //***********************\n /*\n \u0412\u0440\u0435\u043c\u044f: 124 ms, \u043f\u0430\u043c\u044f\u0442\u044c: 3536 \u041a\u0411\n\u0412\u0435\u0440\u0434\u0438\u043a\u0442: WRONG_ANSWER\n\u0412\u0432\u043e\u0434\n10 9\n4\n\u0412\u044b\u0432\u043e\u0434 \u0443\u0447\u0430\u0441\u0442\u043d\u0438\u043a\u0430\n6\n\u041e\u0442\u0432\u0435\u0442 \u0436\u044e\u0440\u0438\n5\n\u041a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0439 \u0447\u0435\u043a\u0435\u0440\u0430\nwrong answer expected 5, found 6 \n * */\n\n\n int times = 1;\n\n while (true)\n {\n nonFourCornerAdjacentB = calculateNonFourCornerAdjacentB(n, m);\n \n dictionary.Add(times, nonFourCornerAdjacentB);\n //\n times++;\n n-=2;\n m-=2;\n if (n <= 0 || m <= 0)\n break;\n }\n\n int ans = 0;\n foreach (KeyValuePair pair in dictionary)\n {\n if (pair.Key == x)\n {\n ans = pair.Value;\n break;\n }\n }\n\n Console.WriteLine(ans);\n //Console.ReadKey();\n }\n\n private static int calculateNonFourCornerAdjacentB(int n, int m)\n {\n\n int horizontalB = m % 2 == 0 ? (m / 2) : (m / 2) + 1;\n if (n > 1)\n horizontalB += n % 2 == 0 ? (horizontalB - 1) : horizontalB;\n //***********\n int verticalB = n > 2 ? (n - 2) / 2 : 0;\n\n if (m > 1)\n verticalB += m % 2 == 0 ? (verticalB + 1) : verticalB;\n \n return horizontalB + verticalB;\n }\n\n }\n}\n", "lang_cluster": "C#", "tags": ["math"], "code_uid": "82cf1b03034bac4482df9b448239fd09", "src_uid": "fa1ef5f9bceeb7266cc597ba8f2161cb", "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 Solution\n{\n class Program\n {\n static void Main(string[] args)\n {\n int n = Convert.ToInt32(Console.ReadLine());\n Console.WriteLine(Solve(n));\n }\n static int Solve(int n)\n {\n int a, b, c;\n int count = 0;\n for (a = 1; a < n - 1; a++)\n {\n for (b = a + 1; b < n; b++)\n {\n c = b ^ a;\n if ((a+b) > c && b <= c && c <= n)\n {\n count++;\n }\n }\n }\n return count;\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force"], "code_uid": "4ad8ac98f60de0020a58ce08f4c0d359", "src_uid": "838f2e75fdff0f13f002c0dfff0b2e8d", "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\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\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\tprivate static void Main()\n\t\t{\n\t\t\tvar n = ReadInt();\n\t\t\tlong aA = 0;\n\t\t\tlong aB = 0;\n\t\t\tlong aC = 0;\n\t\t\tlong aD = 1;\n\t\t\tfor (var i = 1; i <= n; ++i)\n\t\t\t{\n\t\t\t\tvar bA = (aC + aB + aD) % Osn;\n\t\t\t\tvar bB = (aA + aC + aD) % Osn;\n\t\t\t\tvar bC = (aA + aB + aD) % Osn;\n\t\t\t\tvar bD = (aA + aB + aC) % Osn;\n\t\t\t\taA = bA;\n\t\t\t\taB = bB;\n\t\t\t\taC = bC;\n\t\t\t\taD = bD;\n\t\t\t}\n\n\t\t\tConsole.WriteLine(aD);\n\t\t\tConsole.ReadLine();\n\t\t}\n\t}\n}\n", "lang_cluster": "C#", "tags": ["math", "matrices", "dp"], "code_uid": "42a9794913e56e244712509956086fec", "src_uid": "77627cc366a22e38da412c3231ac91a8", "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.IO;\nusing System.Globalization;\n\nnamespace Beresta\n{\n\n\tclass ContestIO : StreamWriter\n\t{\n\t\tpublic ContestIO() : base(Console.OpenStandardOutput(8192), Encoding.ASCII, 8192) { }\n\t\t//d.ToString(\"N12\", CultureInfo.InvariantCulture).Replace(\",\", \"\")\n\t\tpublic StreamReader Reader = new StreamReader(Console.OpenStandardInput(8192), Encoding.ASCII, false, 8192);\n\t\tbool IsDigit(long c) { return c >= '0' && c <= '9'; }\n\n\t\tpublic long Read()\n\t\t{\n\t\t\tlong 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}\n\n\tclass Program\n\t{\n\t\tstatic long[] smallC1 = new long[] { 0, 1, -1, -2, -1, 1, 2, 3, 2, 0, -2, -3, -4, -3, -2, 0, 2, 3, 4 };\n\t\tstatic long[] smallC2 = new long[] { 0, 2, 2, 0, -2, -2, 0, 2, 4, 4, 4, 2, 0, -2, -4, -4, -4, -2, 0 };\n\n\t\tstatic void Main(string[] args)\n\t\t{\n\t\t\t//for (var i = 0L; i <= 18; i++)\n\t\t\t//{\n\t\t\t// var t = Solve(i);\n\t\t\t// if (t.Item1 != smallC1[i] || t.Item2 != smallC2[i])\n\t\t\t// throw new Exception();\n\t\t\t//}\n\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 res = Solve(n);\n\t\t\t\tio.WriteLine(res.Item1.ToString() + \" \" + res.Item2.ToString());\n\t\t\t}\n\n\t\t\tConsole.ReadLine();\n\t\t}\n\n\t\tstatic long Steps(long c)\n\t\t{\n\t\t\treturn (3L * c + 2L) * c;\n\t\t}\n\t\tstatic Tuple Solve(long n)\n\t\t{\n\t\t\tif (n < 5)\n\t\t\t{\n\t\t\t\treturn new Tuple(smallC1[n], smallC2[n]);\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tvar l = 0L;\n\t\t\t\tvar r = (long)1e9;\n\t\t\t\twhile (l < r)\n\t\t\t\t{\n\t\t\t\t\tvar mid = (l + r + 1) >> 1;\n\t\t\t\t\tvar s = Steps(mid);\n\t\t\t\t\tif (s <= n)\n\t\t\t\t\t\tl = mid;\n\t\t\t\t\telse\n\t\t\t\t\t\tr = mid - 1;\n\t\t\t\t}\n\n\t\t\t\tvar c1 = l;\n\t\t\t\tvar c2 = -2L * l;\n\t\t\t\tvar rem = n - Steps(l);\n\n\t\t\t\tAdd(ref c1, ref c2, ref rem, l + 1, 1, 2);\n\t\t\t\tAdd(ref c1, ref c2, ref rem, l, -1, 2);\n\t\t\t\tAdd(ref c1, ref c2, ref rem, l + 1, -2, 0);\n\t\t\t\tAdd(ref c1, ref c2, ref rem, l + 1, -1, -2);\n\t\t\t\tAdd(ref c1, ref c2, ref rem, l + 1, 1, -2);\n\t\t\t\tAdd(ref c1, ref c2, ref rem, l + 1, 2, 0);\n\n\t\t\t\treturn new Tuple(c1, c2);\n\t\t\t}\n\t\t}\n\n\t\tstatic void Add(ref long c1, ref long c2, ref long rem, long val, long s1, long s2)\n\t\t{\n\t\t\tif (rem > 0)\n\t\t\t{\n\t\t\t\tvar d = Math.Min(rem, val);\n\t\t\t\tc1 += s1 * d;\n\t\t\t\tc2 += s2 * d;\n\t\t\t\trem -= d;\n\t\t\t}\n\t\t}\n\n\t}\n\n}\n", "lang_cluster": "C#", "tags": ["math", "implementation", "binary search"], "code_uid": "7a33a1d6edc02e9e46f62b1e7b96efa4", "src_uid": "a4b6a570f5e63462b68447713924b465", "difficulty": 2100.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Globalization;\nusing System.Text;\n\nnamespace olimp\n{\n struct Edge\n {\n public int A, B;\n public double Cost;\n\n public override string ToString()\n {\n return string.Format(\"A:{0}B:{1}Cost:{2}\", A, B, Cost);\n }\n }\n public static partial class Program\n {\n public static void Main()\n {\n int x, y, x0, y0, x1,y1;\n ReadIntPair(out x, out y);\n int s = Math.Max(Math.Abs(x), Math.Abs(y)) + Math.Min(Math.Abs(x), Math.Abs(y));\n if (x > 0 && y > 0)\n {\n Console.WriteLine(\"{0} {1} {2} {3}\", 0, s, s, 0);\n }\n else if(x > 0 && y <0)\n {\n Console.WriteLine(\"{0} {1} {2} {3}\", 0, -s, s, 0);\n }\n else if (x < 0 && y > 0)\n {\n Console.WriteLine(\"{0} {1} {2} {3}\", -s, 0, 0, s);\n }\n else\n {\n Console.WriteLine(\"{0} {1} {2} {3}\", -s, 0, 0, -s);\n }\n\n Console.ReadLine();\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 struct Deform\n {\n public Point Base, Form;\n }\n public class WeightedNode\n {\n public int Id;\n public Dictionary Roads;\n }\n public class Node\n {\n public List Roads;\n public List ClosedRoads;\n public int Id, Mark;\n }\n\n struct Vector3\n {\n public int X, Y, Z;\n public override string ToString()\n {\n return string.Format(\"{0}:{1}:{2}\", X, Y, Z);\n }\n }\n\n static partial class Program\n {\n\n public static double Dest(Point a, Point b)\n {\n return Math.Sqrt(Math.Abs(a.X - b.X) * Math.Abs(a.X - b.X) + Math.Abs(a.Y - b.Y) * Math.Abs(a.Y - b.Y));\n }\n\n public static void WideSearch(Node node)\n {\n Queue queue = new Queue();\n queue.Enqueue(node);\n Node curr;\n while (queue.Count > 0)\n {\n curr = queue.Dequeue();\n curr.Mark = node.Id;\n foreach (var cnode in queue)\n {\n queue.Enqueue(cnode);\n }\n }\n }\n\n public 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 public static int ReadNextInt()\n {\n char c;\n StringBuilder builder = new StringBuilder(4);\n while (char.IsDigit(c = (char)Console.Read()) || c == '-')\n {\n builder.Append(c);\n }\n if (c == '\\r')\n Console.Read();\n return int.Parse(builder.ToString());\n }\n }\n\n\n public struct Point\n {\n public static readonly Point Empty = new Point();\n private int x;\n private int y;\n\n public override string ToString()\n {\n return string.Format(x.ToString() + \" \" + y.ToString());\n }\n\n public bool IsEmpty\n {\n get\n {\n if (this.x == 0)\n return this.y == 0;\n else\n return false;\n }\n }\n\n public int X\n {\n\n get\n {\n return this.x;\n }\n set\n {\n this.x = value;\n }\n }\n\n public int Y\n {\n get\n {\n return this.y;\n }\n set\n {\n this.y = value;\n }\n }\n\n static Point()\n {\n }\n\n\n public Point(int x, int y)\n {\n this.x = x;\n this.y = y;\n }\n\n public Point(Size sz)\n {\n this.x = sz.Width;\n this.y = sz.Height;\n }\n\n public Point(int dw)\n {\n this.x = (int)(short)Point.LOWORD(dw);\n this.y = (int)(short)Point.HIWORD(dw);\n }\n\n private static int HIWORD(int n)\n {\n return n >> 16 & (int)ushort.MaxValue;\n }\n\n private static int LOWORD(int n)\n {\n return n & (int)ushort.MaxValue;\n }\n\n public static explicit operator Size(Point p)\n {\n return new Size(p.X, p.Y);\n }\n\n\n public static Point operator +(Point pt, Size sz)\n {\n return Point.Add(pt, sz);\n }\n\n public static Point operator -(Point pt, Size sz)\n {\n return Point.Subtract(pt, sz);\n }\n\n public static bool operator ==(Point left, Point right)\n {\n if (left.X == right.X)\n return left.Y == right.Y;\n else\n return false;\n }\n\n public static bool operator !=(Point left, Point right)\n {\n return !(left == right);\n }\n\n public static Point Add(Point pt, Size sz)\n {\n return new Point(pt.X + sz.Width, pt.Y + sz.Height);\n }\n\n public static Point Subtract(Point pt, Size sz)\n {\n return new Point(pt.X - sz.Width, pt.Y - sz.Height);\n }\n\n\n public override bool Equals(object obj)\n {\n if (!(obj is Point))\n return false;\n Point point = (Point)obj;\n if (point.X == this.X)\n return point.Y == this.Y;\n else\n return false;\n }\n\n public override int GetHashCode()\n {\n return this.x ^ this.y;\n }\n\n public void Offset(int dx, int dy)\n {\n this.X += dx;\n this.Y += dy;\n }\n\n public void Offset(Point p)\n {\n this.Offset(p.X, p.Y);\n }\n\n }\n\n public struct Size\n {\n public static readonly Size Empty = new Size();\n private int width;\n private int height;\n\n public bool IsEmpty\n {\n\n get\n {\n if (this.width == 0)\n return this.height == 0;\n else\n return false;\n }\n }\n\n public int Width\n {\n\n get\n {\n return this.width;\n }\n\n set\n {\n this.width = value;\n }\n }\n\n public int Height\n {\n\n get\n {\n return this.height;\n }\n\n set\n {\n this.height = value;\n }\n }\n\n static Size()\n {\n }\n\n public Size(Point pt)\n {\n this.width = pt.X;\n this.height = pt.Y;\n }\n\n public Size(int width, int height)\n {\n this.width = width;\n this.height = height;\n }\n\n public static explicit operator Point(Size size)\n {\n return new Point(size.Width, size.Height);\n }\n\n\n public static Size operator +(Size sz1, Size sz2)\n {\n return Size.Add(sz1, sz2);\n }\n\n public static Size operator -(Size sz1, Size sz2)\n {\n return Size.Subtract(sz1, sz2);\n }\n\n public static bool operator ==(Size sz1, Size sz2)\n {\n if (sz1.Width == sz2.Width)\n return sz1.Height == sz2.Height;\n else\n return false;\n }\n\n public static bool operator !=(Size sz1, Size sz2)\n {\n return !(sz1 == sz2);\n }\n\n public static Size Add(Size sz1, Size sz2)\n {\n return new Size(sz1.Width + sz2.Width, sz1.Height + sz2.Height);\n }\n\n\n public static Size Subtract(Size sz1, Size sz2)\n {\n return new Size(sz1.Width - sz2.Width, sz1.Height - sz2.Height);\n }\n\n\n public override bool Equals(object obj)\n {\n if (!(obj is Size))\n return false;\n Size size = (Size)obj;\n if (size.width == this.width)\n return size.height == this.height;\n else\n return false;\n }\n\n public override int GetHashCode()\n {\n return this.width ^ this.height;\n }\n }\n\n}\n", "lang_cluster": "C#", "tags": ["math", "implementation"], "code_uid": "76603b8e13f751ce9dbc487895c4d7bc", "src_uid": "e2f15a9d9593eec2e19be3140a847712", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\n\nnamespace Contest\n{\n class MainClass\n {\n public static void Main (string[] args)\n {\n \n string cadena;\n cadena = Console.ReadLine ();\n if (cadena.Length != 0)\n {\n for (int i=0; i< cadena.Length-1; i++) \n {\n\n if (cadena [i] == '/') {\n if (cadena [i + 1] == '/') {\n cadena = cadena.Remove (i + 1, 1);\n i--;\n }\n }\n\n }\n if (cadena [cadena.Length - 1] == '/' && cadena.Length != 1) {\n cadena = cadena.Remove (cadena.Length - 1, 1);\n }\n\n }\n Console.Write (cadena);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "7d4dd3dc91d402710542004d394e140a", "src_uid": "6c2e658ac3c3d6b0569dd373806fa031", "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 CodeForces\n{\n class Program\n {\n static void Main(string[] args)\n {\n int n = int.Parse(Console.ReadLine());\n int step = 0;\n bool Cheak = false;\n if (n >= 1 && n <= Math.Pow(10, 9))\n {\n if (n == 1)\n {\n Console.WriteLine(n);\n }\n else if (n == 2)\n {\n Console.WriteLine(1);\n }\n else if (n == 5)\n {\n Console.WriteLine(3);\n }\n else if (n % 2 == 0)\n {\n for (;n!= 0 && n != 5;)\n {\n if (Cheak == false)\n {\n if (n != 0)\n {\n n--;\n step++;\n Cheak = true;\n }\n\n }\n if (Cheak == true)\n {\n if (n != 0)\n {\n n -= 2;\n step++;\n Cheak = false;\n }\n }\n if (n == 1)\n {\n step++; break;\n }\n else if (n == 2)\n {\n step++; break;\n }\n else if (n == 5)\n {\n step += 3; break;\n }\n }\n n = step;\n Console.WriteLine(n);\n }\n else if (n % 2 != 0 )\n {\n for (; n != 0 && n != 5; )\n {\n if (Cheak == false)\n {\n if (n != 0)\n {\n n--;\n step++;\n Cheak = true;\n }\n }\n if (Cheak == true)\n {\n if (n != 0)\n {\n n -= 2;\n step++;\n Cheak = false;\n }\n }\n if (n == 1)\n {\n step++; break;\n }\n else if (n == 2)\n {\n step++; break;\n }\n else if (n == 5)\n {\n step+=3; break;\n }\n }\n n = step;\n Console.WriteLine(n);\n }\n\n\n }\n }\n\n }\n}\n", "lang_cluster": "C#", "tags": ["math"], "code_uid": "2335a0074bf8355fea5cd976c97b39d2", "src_uid": "a993069e35b35ae158d35d6fe166aaef", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "//784F Crunching Numbers Just for You\n\nusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Diagnostics;\npublic class _784F\n{\n\tpublic static void Main()\n\t{\n\t\tstring input = Console.ReadLine();\n\t\tint firstSpaceBarPos = input.IndexOf(' ');\n\t\tinput = input.Substring(firstSpaceBarPos+1,input.Length-(firstSpaceBarPos+1));\n\t\tList listNum = new List(Array.ConvertAll(input.Split(' '),int.Parse)).ToList();\n\t\tlistNum.Sort();\n\n\t\tStopwatch watch = new Stopwatch();\n\t\twatch.Start();\n\n\t\twhile(watch.ElapsedMilliseconds<1000)\n\t\t{\n\t\t}\n\n\t\tfor(int i=0;i -a && x < a)\n {\n if (n == 0)\n {\n Console.Write(1);\n }\n else\n {\n int c = n / 2;\n Console.Write(c * 3 + 2);\n }\n return;\n }\n else\n {\n Console.Write(-1);\n return;\n }\n }\n else\n {\n if (x > -a && x < 0)\n {\n int c = n / 2;\n Console.Write(c * 3);\n return;\n }\n else if (x > 0 && x < a)\n {\n int c = n / 2;\n Console.Write(c * 3 + 1);\n return;\n }\n else\n {\n Console.Write(-1);\n return;\n }\n }\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "geometry"], "code_uid": "5ca29ed1126cbf0953d2eb539d6066b3", "src_uid": "cf48ff6ba3e77ba5d4afccb8f775fb02", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.IO;\nusing System.Text;\n\nnamespace RM_B_298\n{\n class Program : InputReader\n {\n static void Main(string[] args)\n {\n string[] s = f.ReadLine().Split(' ');\n int v1 = int.Parse(s[0]), v2 = int.Parse(s[1]);\n s = f.ReadLine().Split(' ');\n int t = int.Parse(s[0]), d = int.Parse(s[1]);\n\n int[] a = new int[t];\n a[0] = v1;\n a[t - 1] = v2;\n for (int i = 1; i < t - 1; i++)\n {\n a[i] = a[i - 1] + d;\n }\n\n for (int i = t - 2; i > 0; i--)\n {\n if (a[i] > (a[i + 1] + d))\n {\n a[i] = a[i + 1] + d;\n }\n }\n int ans = 0;\n for (int i = 0; i < t; i++)\n {\n ans += a[i];\n }\n Console.WriteLine(ans);\n Console.ReadLine();\n }\n }\n\n class InputReader\n {\n //public static TextReader f = new StreamReader(\"input.txt\");\n public static TextReader f = Console.In;\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "greedy", "dp"], "code_uid": "af355637ec20de04e82c4db5fa65c9b3", "src_uid": "9246aa2f506fcbcb47ad24793d09f2cf", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.IO;\nusing System.Text;\n\nnamespace Economy_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 n = Next();\n\n for (int a = 0; a <= n; a += 1234567)\n {\n for (int b = 0; b <= n - a; b += 123456)\n {\n if ((n - a - b)%1234 == 0)\n {\n writer.WriteLine(\"YES\");\n writer.Flush();\n return;\n }\n }\n }\n\n writer.WriteLine(\"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": ["brute force"], "code_uid": "42ff26ffb89d494058d4d8e96ffdb858", "src_uid": "72d7e422a865cc1f85108500bdf2adf2", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.IO;\nusing System.Text;\n\nnamespace Pizza__Pizza__Pizza\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 n = long.Parse(reader.ReadLine()) + 1;\n return n == 1 ? 0 : (n%2 == 1 ? n : n/2);\n }\n }\n}", "lang_cluster": "C#", "tags": ["math"], "code_uid": "6022c26fcaeb06fd330e8b0f456af4f0", "src_uid": "236177ff30dafe68295b5d33dc501828", "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.IO;\n\nnamespace Contest_14\n{\n class Program\n {\n static void A()\n {\n var t = Console.ReadLine().Split(' ');\n int n = int.Parse(t[0]);\n int m = int.Parse(t[1]);\n\n int x1 = int.MaxValue, x2 = int.MinValue, y1 = int.MaxValue, y2 = int.MinValue;\n List a = new List();\n for (int i = 0; i < n; i++)\n {\n string s = Console.ReadLine();\n a.Add(s);\n for (int j = 0; j < m; j++)\n {\n if (s[j] == '*')\n {\n if (x1 > i)\n x1 = i;\n if (x2 < i)\n x2 = i;\n if (y1 > j)\n y1 = j;\n if (y2 < j)\n y2 = j;\n }\n }\n }\n\n for (int i = x1; i <= x2; i++)\n {\n for (int j = y1; j <= y2; j++)\n {\n Console.Write(a[i][j]);\n }\n Console.WriteLine();\n }\n }\n\n static void B()\n {\n var t = Console.ReadLine().Split(' ');\n int n = int.Parse(t[0]);\n int x = int.Parse(t[1]);\n\n int min = int.MaxValue;\n int max = int.MinValue;\n int[] a = new int[1001];\n for (int i = 0; i < n; i++)\n {\n t = Console.ReadLine().Split(' ');\n int k = int.Parse(t[0]);\n int l = int.Parse(t[1]);\n\n if (k > l)\n {\n int q = k;\n k = l;\n l = q;\n }\n if (i == 0)\n {\n min = k;\n max = l;\n continue;\n }\n if (k > min)\n {\n min = k;\n }\n if (l < max)\n max = l;\n }\n if (max < min)\n {\n Console.WriteLine(-1);\n return;\n }\n if ((x >= min) && (x <= max))\n Console.WriteLine(0);\n else\n Console.WriteLine(Math.Min(Math.Abs(min - x), Math.Abs(max - x)));\n }\n\n class Point : IComparer\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 int Compare(Point p1, Point p2)\n {\n if (p1.x != p2.x)\n return p1.x.CompareTo(p2.x);\n else\n return p1.y.CompareTo(p2.y);\n }\n\n public bool isGood (Point p)\n {\n if ((x == p.x) && (y != p.y))\n return true;\n if ((y == p.y) && (x != p.x))\n return true;\n return false;\n }\n\n public void deleteInList(List b)\n {\n for (int j = 0; j < b.Count; j++)\n {\n Point temp = b[j];\n if ((temp.x == this.x) && (temp.y == this.y))\n {\n b.RemoveAt(j);\n break;\n }\n }\n\n }\n\n }\n\n static void C()\n {\n List a = new List();\n\n for (int i = 0; i < 4; i++)\n {\n var t = Console.ReadLine().Split(' ');\n var t1 = new int[] { int.Parse(t[0]), int.Parse(t[1]), int.Parse(t[2]), int.Parse(t[3]) };\n for (int j = 0; j < a.Count; j++)\n {\n var k = a[j];\n\n if ((k[0] == t1[0]) && (k[1] == t1[1]) && (k[2] == t1[2]) && (k[3] == t1[3]))\n {\n Console.WriteLine(\"NO\");\n return;\n }\n\n if ((k[2] == t1[0]) && (k[3] == t1[1]) && (k[0] == t1[2]) && (k[1] == t1[3]))\n {\n Console.WriteLine(\"NO\");\n return;\n }\n }\n a.Add(t1);\n\n \n }\n\n List b = new List();\n\n int xl = int.MaxValue, yl = int.MinValue, xr = int.MinValue, yr = int.MaxValue;\n\n for (int i = 0; i < 4; i++)\n {\n int[] t = a[i];\n Point l1 = new Point(t[0], t[1]);\n Point l2 = new Point(t[2], t[3]);\n b.Add(l1);\n b.Add(l2);\n if (t[0] < xl)\n xl = t[0];\n if (t[1] > yl)\n yl = t[1];\n if (t[2] > xr)\n xr = t[2];\n if (t[3] < yr)\n yr = t[3];\n if (!l1.isGood(l2))\n {\n Console.WriteLine(\"NO\");\n return;\n }\n }\n\n Point p1 = new Point(xl, yl);\n Point p2 = new Point(xr, yr);\n\n for (int i = 0; i < 2; i++)\n {\n p1.deleteInList(b);\n p2.deleteInList(b);\n new Point(p1.x, p2.y).deleteInList(b);\n new Point(p2.x, p1.y).deleteInList(b);\n }\n if (b.Count > 0)\n Console.WriteLine(\"NO\");\n else Console.WriteLine(\"YES\");\n }\n\n static void Main(string[] args)\n {\n //Console.SetIn(new StreamReader(@\"C:\\1.txt\"));\n C();\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "constructive algorithms", "math", "implementation", "geometry"], "code_uid": "9c31f59652e184a9538b731081379311", "src_uid": "ad105c08f63e9761fe90f69630628027", "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 public class OrchestraA\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 r = fs.NextInt(), c = fs.NextInt(), n = fs.NextInt(), k = fs.NextInt();\n bool[,] a = new bool[r, c];\n for (int i = 0; i < n; i++)\n {\n int row = fs.NextInt() - 1, col = fs.NextInt() - 1;\n a[row, col] = true;\n }\n int ans = 0;\n for (int i = 0; i < r; i++)\n {\n for (int j = 0; j < c; j++)\n {\n int[] counts = new int[c - j];\n for (int l = i; l < r; l++) \n {\n int count = 0;\n for (int m = j; m < c; m++)\n {\n if (a[l, m]) counts[m - j]++;\n count += counts[m - j];\n if (count >= k) ans++;\n }\n }\n }\n }\n writer.WriteLine(ans);\n }\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "implementation"], "code_uid": "665751543882b850a359ef09c924e6b6", "src_uid": "9c766881f6415e2f53fb43b61f8f40b4", "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 object Solve()\n {\n var m = ReadLong();\n var b = ReadLong();\n var max = long.MinValue;\n for (long y = 0; y <= b; y++)\n {\n var x = m * (b - y);\n var sx = x * (x + 1) / 2;\n var sy = y * (y + 1) / 2;\n var r = sx * (y + 1) + sy * (x + 1);\n max = Math.Max(max, r);\n }\n return max;\n }\n\n class End\n {\n public long Val { get; set; }\n public bool Left { get; set; }\n }\n\n int BS(long[] a, int left, int right, long s)\n {\n if (right - left == 1)\n return left;\n var half = (left + right) / 2;\n if (Check(half, a, s))\n return BS(a, half, right, s);\n return BS(a, left, half, s);\n }\n\n bool Check(int k, long[] a, long s)\n {\n var newArr = new long[a.Length]; \n for (int i = 0; i < a.Length; i++)\n {\n newArr[i] = a[i] + ((long)k) * (i + 1);\n }\n Array.Sort(newArr);\n return newArr.Take(k).Sum() <= s;\n }\n\n double Dist(Point a, Point b, Point z)\n {\n return Math.Abs((b.y - a.y) * z.x - (b.x - a.x) * z.y + b.x * a.y - b.y * a.x) / Math.Sqrt((b.y - a.y) * (b.y - a.y) + (b.x - a.x) * (b.x - a.x));\n }\n\n }\n\n class Point\n {\n public double x { get; set; }\n public double y { get; set; }\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"], "code_uid": "d98de8b2458cae141cb23702b199891a", "src_uid": "9300f1c07dd36e0cf7e6cb7911df4cf2", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\r\nusing System.IO;\r\nusing System.Linq;\r\nusing System.Text;\r\n\r\nnamespace Reverse\r\n{\r\n internal class Program\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 private static void Main(string[] args)\r\n {\r\n writer.WriteLine(Solve() ? \"YES\" : \"NO\");\r\n writer.Flush();\r\n }\r\n\r\n private static bool Solve()\r\n {\r\n long a = Next();\r\n long b = Next();\r\n\r\n if (a == b)\r\n return true;\r\n\r\n string s = Convert.ToString(a, 2);\r\n string t = Convert.ToString(b, 2);\r\n\r\n if (Subs(t, s.TrimEnd('0')))\r\n return true;\r\n\r\n if (Subs(t, new string(s.TrimEnd('0').Reverse().ToArray())))\r\n return true;\r\n\r\n if (Subs(t, s + \"1\"))\r\n return true;\r\n\r\n if (Subs(t, new string((s + \"1\").Reverse().ToArray())))\r\n return true;\r\n\r\n return false;\r\n }\r\n\r\n private static bool Subs(string t, string s)\r\n {\r\n int p = 0;\r\n while (true)\r\n {\r\n int index = t.IndexOf(s, p);\r\n if (index >= 0)\r\n {\r\n bool ok = true;\r\n for (int i = 0; i < index; i++)\r\n {\r\n if (t[i] != '1')\r\n {\r\n ok = false;\r\n break;\r\n }\r\n }\r\n\r\n if (ok)\r\n for (int i = index + s.Length; i < t.Length; i++)\r\n {\r\n if (t[i] != '1')\r\n {\r\n ok = false;\r\n break;\r\n }\r\n }\r\n\r\n if (ok)\r\n return true;\r\n\r\n p = index + 1;\r\n }\r\n else break;\r\n }\r\n return false;\r\n }\r\n\r\n private static long Next()\r\n {\r\n int c;\r\n long res = 0;\r\n do\r\n {\r\n c = reader.Read();\r\n if (c == -1)\r\n return res;\r\n } while (c < '0' || c > '9');\r\n res = c - '0';\r\n while (true)\r\n {\r\n c = reader.Read();\r\n if (c < '0' || c > '9')\r\n return res;\r\n res *= 10;\r\n res += c - '0';\r\n }\r\n }\r\n }\r\n}", "lang_cluster": "C#", "tags": ["dfs and similar", "constructive algorithms", "math", "bitmasks", "strings", "implementation"], "code_uid": "a83ab6360b4acab57084cf26ce88bad4", "src_uid": "9f39a3c160087beb0efab2e3cb510e89", "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.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\nclass Solver\n{\n public SC sc = new SC();\n public void Solve()\n {\n var A1 = sc.Int;\n var A2 = sc.Int;\n var K1 = sc.Int;\n var K2 = sc.Int;\n var N = sc.Int;\n if (K1 > K2)\n {\n swap(ref A1, ref A2);\n swap(ref K1, ref K2);\n }\n var max = Min(N / K1, A1);\n if (N - K1 * A1 > 0)\n {\n var F = N - K1 * A1;\n max += Min(F / K2, A2);\n }\n N -= (K1 - 1) * A1 + (K2 - 1) * A2;\n var min = Max(0, Min(N, A1 + A2));\n Console.WriteLine($\"{min} {max}\");\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();\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", "greedy", "implementation"], "code_uid": "e7a6ceb33684b3ee5b957e99c4e958f2", "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;\nusing System.IO;\n\nnamespace Round70A\n{\n class Program\n {\n static TextReader tr;\n static void cin(out int value)\n {\n if (tr == null) tr = Console.In;\n StringBuilder sb = new StringBuilder();\n while (tr.Peek() == (char)(' ') || tr.Peek() == 13 || tr.Peek() == 10)\n tr.Read();\n while (tr.Peek() != (char)(' ') && tr.Peek() != 13 && tr.Peek() != 10)\n {\n char ch = (char)tr.Read();\n sb.Append(ch);\n }\n value = int.Parse(sb.ToString());\n }\n static void cin(out string value)\n {\n if (tr == null) tr = Console.In;\n StringBuilder sb = new StringBuilder();\n while (tr.Peek() == (char)(' ') || tr.Peek() == 13 || tr.Peek() == 10)\n tr.Read();\n while (tr.Peek() != (char)(' ') && tr.Peek() != 13 && tr.Peek() != 10)\n {\n char ch = (char)tr.Read();\n sb.Append(ch);\n }\n value = sb.ToString();\n }\n static void cin(out double value)\n {\n if (tr == null) tr = Console.In;\n StringBuilder sb = new StringBuilder();\n while (tr.Peek() == (char)(' ') || tr.Peek() == 13 || tr.Peek() == 10)\n tr.Read();\n while (tr.Peek() != (char)(' ') && tr.Peek() != 13 && tr.Peek() != 10)\n {\n char ch = (char)tr.Read();\n if (ch == '.') ch = ',';\n sb.Append(ch);\n }\n value = double.Parse(sb.ToString());\n }\n static void Main(string[] args)\n {\n int x,y;\n cin(out x);\n cin(out y);\n while (true)\n {\n if (x >= 2 && y >= 2)\n {\n x -= 2;\n y -= 2;\n }\n else if (x >= 1 && y >= 12)\n {\n x--;\n y -= 12;\n }\n else if (y >= 22) y -= 22;\n else\n {\n Console.WriteLine(\"Hanako\");\n break;\n }\n if (y >= 22) y -= 22;\n else if (y >= 12 && x >= 1)\n {\n x--;\n y -= 12;\n }\n else if (y >= 2 && x >= 2)\n {\n x -= 2;\n y -= 2;\n }\n else\n {\n Console.WriteLine(\"Ciel\");\n break;\n }\n\n }\n }\n }\n}", "lang_cluster": "C#", "tags": ["greedy"], "code_uid": "e478a1d5757c5014dda06592ed4cb649", "src_uid": "8ffee18bbc4bb281027f91193002b7f5", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Runtime.CompilerServices;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace CFCF_354_DIV_2_B\n{\n class Program\n {\n public class Node\n {\n public Node Left { get; set; }\n public Node Right { get; set; }\n public double Volume { get; set; }\n\n public void AddVolume(double val)\n {\n if (Volume == 1)\n {\n if (Left != null && Right != null)\n {\n Left.AddVolume(val/2);\n Right.AddVolume(val/2);\n }\n }\n else if(Volume + val > 1)\n {\n var diff = (Volume + val - 1);\n Left.AddVolume(diff / 2);\n Right.AddVolume(diff / 2);\n Volume = 1;\n }\n else\n {\n Volume += val;\n }\n }\n }\n\n static void Main(string[] args)\n {\n var input = Console.ReadLine();\n var inputParts = input.Split(' ');\n var n = Convert.ToInt32(inputParts[0]);\n var t = Convert.ToInt32(inputParts[1]);\n\n \n\n if (n == 0 || t == 0)\n {\n Console.WriteLine(0);\n return;\n }\n\n List nodes = new List();\n for (int i = 1; i <= n*n; i++)\n {\n nodes.Add(new Node());\n }\n\n //nodes[0].Left = nodes[1];\n //nodes[0].Right = nodes[2];\n int currentNode = 0;\n for (int i = 1; i < n; i++)\n {\n for (int j = 0; j < i; j++)\n {\n nodes[currentNode].Left = nodes[currentNode + i];\n nodes[currentNode].Right = nodes[currentNode + i + 1];\n\n currentNode++;\n }\n }\n\n for (int i = 0; i < t; i++)\n {\n nodes[0].AddVolume(1);\n }\n\n int full = nodes.Where(node => node.Volume == 1).Count();\n\n Console.WriteLine(full);\n //Console.ReadKey();\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "implementation"], "code_uid": "d6bbd4dd21d826e4e2eebcf7b2dd1db6", "src_uid": "b2b49b7f6e3279d435766085958fb69d", "difficulty": 1500.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 string ts = ReadLine();\n\n Dictionary rankVal = new Dictionary();\n rankVal['6'] = 0; rankVal['7'] = 1; rankVal['8'] = 2; rankVal['9'] = 3; rankVal['T'] = 4; rankVal['J'] = 5; rankVal['Q'] = 6; rankVal['K'] = 7; rankVal['A'] = 8;\n\n string s = ReadLine();\n\n var c1 = s.Split()[0];\n var c2 = s.Split()[1];\n\n if (c1[1] == c2[1])\n {\n if (rankVal[c1[0]] > rankVal[c2[0]])\n PrintLn(\"YES\");\n else\n PrintLn(\"NO\");\n }\n else\n {\n if (c1[1] == ts[0])\n PrintLn(\"YES\");\n else\n PrintLn(\"NO\");\n }\n\n }\n\n\n\n\n }\n\n\n}", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "a48e1c835349d531c777c29eee4f4114", "src_uid": "da13bd5a335c7f81c5a963b030655c26", "difficulty": 1000.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 internal class Template\n {\n private void Solve()\n {\n var n = cin.NextInt();\n var q = cin.NextInt();\n var ops = new Dictionary>();\n for (var i = 0; i < q; i++)\n {\n var a = cin.NextString();\n var b = cin.NextString();\n if (!ops.ContainsKey(b[0]))\n {\n ops[b[0]] = new List();\n }\n ops[b[0]].Add(a[0]);\n }\n var frontier = new List();\n frontier.Add('a');\n for (var i = 1; i < n; i++)\n {\n var newFrontier = new List();\n foreach (var c in frontier)\n {\n if (ops.ContainsKey(c))\n {\n var list = ops[c];\n newFrontier.AddRange(list);\n }\n }\n frontier = newFrontier;\n }\n Console.WriteLine(frontier.Count);\n }\n\n private static readonly Scanner cin = new Scanner();\n\n private static void Main()\n {\n#if DEBUG\n var inputText = File.ReadAllText(@\"..\\..\\input.txt\");\n var testCases = inputText.Split(new[] { \"input\" }, StringSplitOptions.RemoveEmptyEntries);\n var consoleOut = Console.Out;\n for (var i = 0; i < testCases.Length; i++)\n {\n var parts = testCases[i].Split(new[] { \"output\" }, StringSplitOptions.RemoveEmptyEntries);\n Console.SetIn(new StringReader(parts[0].Trim()));\n var stringWriter = new StringWriter();\n Console.SetOut(stringWriter);\n var sw = Stopwatch.StartNew();\n new Template().Solve();\n sw.Stop();\n var output = stringWriter.ToString();\n\n Console.SetOut(consoleOut);\n var color = ConsoleColor.Green;\n var status = \"Passed\";\n if (parts[1].Trim() != output.Trim())\n {\n color = ConsoleColor.Red;\n status = \"Failed\";\n }\n Console.ForegroundColor = color;\n Console.WriteLine(\"Test {0} {1} in {2}ms\", i + 1, status, sw.ElapsedMilliseconds);\n }\n Console.ReadLine();\n Console.ReadKey();\n#else\n\t\t\tnew Template().Solve();\n\t\t\tConsole.ReadLine();\n#endif\n }\n }\n\n internal class Scanner\n {\n private string[] s = new string[0];\n private int i;\n private readonly char[] cs = { ' ' };\n\n public string NextString()\n {\n if (i < s.Length) return s[i++];\n var line = Console.ReadLine() ?? string.Empty;\n s = line.Split(cs, StringSplitOptions.RemoveEmptyEntries);\n i = 1;\n return s.First();\n }\n\n public double NextDouble()\n {\n return double.Parse(NextString());\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}", "lang_cluster": "C#", "tags": ["dfs and similar", "strings", "dp", "brute force"], "code_uid": "9097e4a5c24d8de8b17a0ebe3f802e6c", "src_uid": "c42abec29bfd17de3f43385fa6bea534", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Numerics;\nusing System.Collections.Generic;\nusing System.IO;\nusing System.Text;\nusing System.Linq;\n\nclass Solution\n{\n class AhoCorasick\n {\n class V\n {\n Dictionary dic = new Dictionary();\n public bool IsWord;\n public V this[char c]\n {\n get { V v; return dic.TryGetValue(c, out v) ? v : null; }\n set { dic.Add(c, value); }\n }\n }\n\n V root = new V();\n\n public void Add(IEnumerable s)\n {\n V v = root;\n\n foreach (char c in s)\n {\n if (v[c] == null) { var n = new V(); v[c] = n; v = n; continue; }\n v = v[c];\n }\n\n v.IsWord = true;\n }\n\n public int Query(string s, int offset)\n {\n V v = root;\n int count = 0;\n\n for (int si = offset; si < s.Length; si++)\n {\n v = v[s[si]];\n if (v == null) break;\n if (v.IsWord) count += 1;\n }\n\n return count;\n }\n\n public int CountAll(string s)\n {\n int count = 0;\n for (int i = 0, lim = s.Length; i < lim; i++) count += Query(s, i);\n return count;\n }\n }\n\n static void Main(String[] args)\n {\n string s = Console.ReadLine();\n bool[] m = new bool[256];\n\n char next = 'a';\n\n foreach (var c in s)\n {\n if (m[c] == false)\n {\n if (next == c)\n {\n m[c] = true;\n next = (char)(next + 1);\n }\n else\n {\n Console.WriteLine(\"NO\");\n return;\n }\n }\n }\n\n Console.WriteLine(\"YES\");\n }\n}", "lang_cluster": "C#", "tags": ["greedy", "strings", "implementation"], "code_uid": "fc74a36c95bd3d3d660971d4c9167209", "src_uid": "c4551f66a781b174f95865fa254ca972", "difficulty": 1100.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\tstring[] input = Console.ReadLine ().Split (' ');\n\t\t\tint h = Convert.ToInt32 (input [0]); \n\t\t\tulong n = Convert.ToUInt64 (input [1]);\n\t\t\tint i = 0, b= 0, j = 1;\n\t\t\tulong k = 0, residue = 0, branch = 0, side = 0, total = 0, leafs = 1;\n\t\t\tbool line = true;\n\t\t\twhile (i < h) {\n\t\t\t\tleafs = leafs * 2;\n\t\t\t\ti += 1;\n\t\t\t}\n\n\t\t\tside = leafs;\n\t\t\tresidue = n;\n\t\t\ti = 0;\n\t\t\twhile (i < h) {\n\t\t\t\tside = side / 2;\n\t\t\t\tif (residue >= 2) {\n\t\t\t\t\tif (residue <= side) {\n\t\t\t\t\t\tif (line == true) {\n\t\t\t\t\t\t\tline = !line;\n\t\t\t\t\t\t\ttotal += 1;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tb = i;\n\t\t\t\t\t\t\tk = 1;\n\t\t\t\t\t\t\tbranch = 0;\n\t\t\t\t\t\t\twhile (b < h) {\n\t\t\t\t\t\t\t\tbranch += k; \n\t\t\t\t\t\t\t\tk = k * 2;\n\t\t\t\t\t\t\t\tb += 1;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\ttotal += branch + 1;\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tresidue = residue - side;\n\t\t\t\t\t\tif (line == false) {\n\t\t\t\t\t\t\tline = !line;\n\t\t\t\t\t\t\ttotal += 1;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tb = i;\n\t\t\t\t\t\t\tk = 1;\n\t\t\t\t\t\t\tbranch = 0;\n\t\t\t\t\t\t\twhile (b < h) {\n\t\t\t\t\t\t\t\tbranch += k; \n\t\t\t\t\t\t\t\tk = k * 2;\n\t\t\t\t\t\t\t\tb += 1;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\ttotal += branch + 1;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} else if (residue == 0) {\n\t\t\t\t\tif (line == false) {\n\t\t\t\t\t\tline = !line;\n\t\t\t\t\t\ttotal += 1;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tb = i;\n\t\t\t\t\t\tk = 1;\n\t\t\t\t\t\tbranch = 0;\n\t\t\t\t\t\twhile (b < h) {\n\t\t\t\t\t\t\tbranch += k; \n\t\t\t\t\t\t\tk = k * 2;\n\t\t\t\t\t\t\tb += 1;\n\t\t\t\t\t\t}\n\t\t\t\t\t\ttotal += branch + 1;\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tif (line == true) {\n\t\t\t\t\t\tline = !line;\n\t\t\t\t\t\ttotal += 1;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tb = i;\n\t\t\t\t\t\tk = 1;\n\t\t\t\t\t\tbranch = 0;\n\t\t\t\t\t\twhile (b < h) {\n\t\t\t\t\t\t\tbranch += k; \n\t\t\t\t\t\t\tk = k * 2;\n\t\t\t\t\t\t\tb += 1;\n\t\t\t\t\t\t}\n\t\t\t\t\t\ttotal += branch + 1;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\ti += 1;\n\t\t\t\tj = j * 2;\n\t\t\t}\n\n\t\t\tConsole.WriteLine (total);\n\t\t}\n\t}\n}", "lang_cluster": "C#", "tags": ["math", "implementation", "trees"], "code_uid": "d8ba5b1fa147f52cb7ca5f11da18ff9b", "src_uid": "3dc25ccb394e2d5ceddc6b3a26cb5781", "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;\n\nnamespace \u0412\n{\n class B\n {\n static void Main(string[] args)\n {\n string inp1 = Console.ReadLine();\n int n = Int32.Parse(inp1.Split(' ')[0].Trim()); // \u043f\u043e\u0434\u044a\u0435\u0437\u0434\u044b\n int m = Int32.Parse(inp1.Split(' ')[1].Trim()); // \u044d\u0442\u0430\u0436\u0438\n int k = Int32.Parse(inp1.Split(' ')[2].Trim()); // \u043a\u0432\u0430\u0440\u0442\u0438\u0440\u044b \u043d\u0430 \u044d\u0442\u0430\u0436\u0435\n inp1 = Console.ReadLine();\n int a = Int32.Parse(inp1.Split(' ')[0].Trim()) - 1;\n int b = Int32.Parse(inp1.Split(' ')[1].Trim()) - 1;\n int nkm = n * m * k;\n int mk = m * k; // \u043a\u0432\u0430\u0440\u0442\u0438\u0440 \u0432 \u043f\u043e\u0434\u044a\u0435\u0437\u0434\u0435\n int a_n = a / mk;\n int b_n = b / mk;\n int a_m = ( a - a_n * mk ); // \n int b_m = ( b - b_n * mk );\n\n int t = 0;\n\n int ln = Math.Abs( b_n - a_n );\n t += 15 * Math.Min( ln, n - ln );\n if( t == 0 )\n {\n int floors = Math.Abs(a_m / k - b_m / k );\n t += Math.Min(floors * 5, 10 + floors);\n } else\n {\n int floorsa = a_m / k;\n t += Math.Min(floorsa * 5, 10 + floorsa);\n int floorsb = b_m / k;\n t += Math.Min(floorsb * 5, 10 + floorsb);\n }\n\n Console.WriteLine(t.ToString());\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["constructive algorithms"], "code_uid": "26b5ca58cea07c29b45820a57564a353", "src_uid": "c37b46851abcf7eb472869bd1ab9f793", "difficulty": 1400.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 Beautiful_Divisors\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\n var s = new Stack();\n for (int i = 0;; i++)\n {\n int p = ((2 << i) - 1) << i;\n if (p > n)\n break;\n s.Push(p);\n }\n return s.FirstOrDefault(l => n%l == 0);\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": "01052390fae9d2ad1a749d02a9250d60", "src_uid": "339246a1be81aefe19290de0d1aead84", "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 n= Array.ConvertAll(Console.ReadLine().Split(' '), Convert.ToInt32);\n var a= Array.ConvertAll(Console.ReadLine().Split(' '), Convert.ToInt32);\n int q=n[0],w=n[0];\n for(int i=n[1]-2;i>=0;i--)\n {\n if(a[i]<=n[2]&&a[i]!=0)\n {\n q=n[1]-1-i;\n break;\n }\n }\n for(int i=n[1];i final)\n {\n break;\n }\n if (int.Parse(problemas[i])> k && int.Parse(problemas[final]) > k)\n {\n break;\n }\n if (int.Parse(problemas[i]) <= k)\n {\n resueltos++;\n }\n else {\n i--;\n }\n if (i == final)\n {\n break;\n }\n if (int.Parse(problemas[final]) <= k)\n {\n resueltos++;\n final--;\n }\n }\n Console.WriteLine(resueltos);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "implementation"], "code_uid": "542fd12185dd107b840241b738db156c", "src_uid": "ecf0ead308d8a581dd233160a7e38173", "difficulty": 800.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 long m = sc.NextInt();\n int[] t = sc.IntArray();\n\n long sum = 0;\n foreach (var i in t)\n {\n sum += i;\n }\n\n Array.Sort(t);\n long ans = 0;\n for (int i = 0; i <= n && sum * i <= m; i++)\n {\n long score = (long) (k + 1) * i;\n long time = m - sum * i;\n\n for (int j = 0; j < k; j++)\n {\n long cnt = Math.Min(n - i, time / t[j]);\n score += cnt;\n time -= t[j] * cnt;\n }\n\n ans = Math.Max(ans, score);\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\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", "greedy"], "code_uid": "fad04ce6d22329e176ec8c6fa2a1dcdc", "src_uid": "d659e92a410c1bc836be64fc1c0db160", "difficulty": 1800.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 const int MOD = 998244353;\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 void Main(string[] args)\n {\n var values = Console.ReadLine().Split(' ');\n int n = Convert.ToInt32(values[0]);\n int m = Convert.ToInt32(values[1]);\n\n var f = new int[m + 1];\n f[0] = 1;\n for (int i = 1; i <= m; ++i)\n {\n f[i] = Mult(f[i - 1], i);\n }\n\n int result = BinPow(2, n - 3);\n result = Mult(result, n - 2);\n result = Mult(result, f[m]);\n result = Mult(result, BinPow(Mult(f[n - 1], f[m - n + 1]), MOD - 2));\n Console.WriteLine(result);\n }\n }\n}", "lang_cluster": "C#", "tags": ["math", "combinatorics"], "code_uid": "df4db39cef5b6715faa94c86627a0e5b", "src_uid": "28d6fc8973a3e0076a21c2ea490dfdba", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Linq;\n\nnamespace CSharp\n{\n public class _831A\n {\n public static void Main()\n {\n int n = int.Parse(Console.ReadLine());\n int[] a = Console.ReadLine().Split().Select(token => int.Parse(token)).ToArray();\n\n int left = 0;\n while (left + 1 < n && a[left] < a[left + 1])\n {\n left++;\n }\n\n int right = n - 1;\n while (right > 0 && a[right] < a[right - 1])\n {\n right--;\n }\n\n for (int i = left; i < right; i++)\n {\n if (a[i] != a[right])\n {\n Console.WriteLine(\"NO\");\n return;\n }\n }\n\n Console.WriteLine(\"YES\");\n }\n }\n}", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "cf1dc51d75b9e50afe464bcdb759e368", "src_uid": "5482ed8ad02ac32d28c3888299bf3658", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\n\nnamespace CSharp\n{\n class _1033B\n {\n public static void Main()\n {\n for (int t = int.Parse(Console.ReadLine()); t > 0; t--)\n {\n var tokens = Console.ReadLine().Split();\n\n long a = long.Parse(tokens[0]);\n long b = long.Parse(tokens[1]);\n\n bool isPrime = a == b + 1;\n\n for (long i = 2; i * i <= a + b && isPrime; i++)\n {\n if ((a + b) % i == 0)\n {\n isPrime = false;\n }\n }\n\n Console.WriteLine(isPrime ? \"YES\" : \"NO\");\n }\n }\n }\n}", "lang_cluster": "C#", "tags": ["math", "number theory"], "code_uid": "0effa438a56ad74d4fc61b4331c46fe9", "src_uid": "5a052e4e6c64333d94c83df890b1183c", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": ".NET Core 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;\nusing System.Threading;\n\nusing Weight = System.Int64;\n\ninternal partial class Solver {\n int f(int p1, int p2) {\n if (p1 > p2) p2 += 3;\n if (p1 == p2) return 0;\n if (p1 + 1 == p2) return 1;\n return -1;\n }\n\n public void Run() {\n var n = ni();\n var a = ni(3);\n var b = ni(3);\n // a1>a2, a2>a3, a3>a1\n var dual1 = new PrimalDual(11);\n var dual2 = new PrimalDual(11);\n\n int In(int p) => p;\n int Out(int p) => p + 3;\n int source = 6;\n int sink = 7;\n long inf = (long)1e10;\n for (int i = 0; i < 3; i++) {\n dual1.AddEdge(source, In(i), a[i], 0);\n dual2.AddEdge(source, In(i), a[i], 0);\n dual1.AddEdge(Out(i), sink, b[i], 0);\n dual2.AddEdge(Out(i), sink, b[i], 0);\n for (int j = 0; j < 3; j++) {\n var r = f(i, j);\n if (r == 1) { // alice win\n dual1.AddEdge(In(i), Out(j), inf, 1);\n dual2.AddEdge(In(i), Out(j), inf, -1);\n } else {\n dual1.AddEdge(In(i), Out(j), inf, 0);\n dual2.AddEdge(In(i), Out(j), inf, 0);\n }\n }\n }\n var min = dual1.Run(source, sink, n).TotalCost;\n var max = -dual2.Run(source, sink, n).TotalCost;\n\n cout.WriteLine(\"{0} {1}\", min, max);\n }\n}\n\npublic class MinCostFlowResult {\n public Weight TotalCost;\n public Weight TotalFlow;\n}\n\n/// \n/// Cost can be negative.\n/// O(FVE)\n/// \npublic class PrimalDual {\n private readonly int N;\n private readonly List> adjacents;\n\n private readonly Weight[] _distance;\n private readonly bool[] _inQueue;\n private readonly Edge[] _prevEdges;\n private readonly Queue _queue;\n\n public class Edge {\n public int From, To;\n public Weight Flow, Capacity, Cost;\n public Edge Reverse;\n public Edge(int from, int to, Weight capacity, Weight cost, Weight flow = 0) {\n From = from;\n To = to;\n Cost = cost;\n Flow = flow;\n Capacity = capacity;\n }\n public Weight Residue {\n get {\n return Capacity - Flow;\n }\n }\n }\n\n public PrimalDual(int n) {\n N = n;\n adjacents = new List>();\n for (int i = 0; i < n; i++) {\n adjacents.Add(new List());\n }\n _distance = new Weight[N];\n _inQueue = new bool[N];\n _prevEdges = new Edge[N];\n _queue = new Queue(N);\n }\n\n public IEnumerable GetEdges() {\n return adjacents.SelectMany(a => a);\n }\n\n public void AddEdge(int from, int to, Weight capacity, Weight cost) {\n var e = new Edge(from, to, capacity, cost);\n adjacents[from].Add(e);\n }\n\n private Edge[] FindShortestPathTree(int source) {\n Array.Clear(_inQueue, 0, _inQueue.Length);\n Array.Clear(_prevEdges, 0, _prevEdges.Length);\n for (int i = 0; i < N; i++) {\n _distance[i] = Weight.MaxValue;\n }\n _distance[source] = 0;\n _inQueue[source] = true;\n _queue.Enqueue(source);\n while (_queue.Count > 0) { // SPFA\n int now = _queue.Dequeue();\n _inQueue[now] = false;\n foreach (var e in adjacents[now]) {\n if (e.Residue <= 0) {\n continue;\n }\n\n if (_distance[now] != Weight.MaxValue && _distance[e.To] > _distance[now] + e.Cost) {\n _distance[e.To] = _distance[now] + e.Cost;\n _prevEdges[e.To] = e;\n if (!_inQueue[e.To]) {\n _inQueue[e.To] = true;\n _queue.Enqueue(e.To);\n }\n }\n }\n }\n return _prevEdges;\n }\n\n public MinCostFlowResult Run(int source, int sink, Weight flow) {\n Weight totalCost = 0;\n Weight totalFlow = 0;\n\n while (totalFlow < flow) {\n var prevEdges = FindShortestPathTree(source);\n if (prevEdges[sink] == null) {\n break;\n }\n\n long incrementalFlow = flow - totalFlow;\n for (var e = prevEdges[sink]; e != null; e = prevEdges[e.From]) {\n incrementalFlow = Math.Min(incrementalFlow, e.Residue);\n }\n for (var e = prevEdges[sink]; e != null; e = prevEdges[e.From]) {\n if (e.Reverse == null) {\n var reverseEdge = new Edge(e.To, e.From, 0, -e.Cost) {\n Reverse = e\n };\n e.Reverse = reverseEdge;\n adjacents[e.To].Add(reverseEdge);\n }\n totalCost += e.Cost * incrementalFlow;\n e.Flow += incrementalFlow;\n e.Reverse.Flow -= incrementalFlow;\n }\n totalFlow += incrementalFlow;\n }\n return new MinCostFlowResult { TotalCost = totalCost, TotalFlow = totalFlow };\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 static readonly int? StackSizeInMebiByte = null; //50;\n public static void StartAndJoin(Action action, int maxStackSize) {\n var thread = new Thread(new ThreadStart(action), maxStackSize);\n thread.Start();\n thread.Join();\n }\n\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 if (StackSizeInMebiByte.HasValue) {\n StartAndJoin(() => new Solver(Console.In, Console.Out).Run(), StackSizeInMebiByte.Value * 1024 * 1024);\n } else {\n new Solver(Console.In, Console.Out).Run();\n }\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", "constructive algorithms", "flows", "math", "greedy"], "code_uid": "f5aeb8c9189c4a86c61eaacdd63f9c59", "src_uid": "e6dc3bc64fc66b6127e2b32cacc06402", "difficulty": 1800.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 s = Read();\n var res = 0;\n for (int i = 0; i < s.Length - 1; i++)\n {\n if (s[i] == 'V' && s[i + 1] == 'K')\n res++;\n }\n var max = res;\n for (int i = 0; i < s.Length; i++)\n {\n var newS = s.Substring(0, i) + (s[i] == 'V' ? 'K' : 'V') + s.Substring(i + 1, s.Length - i - 1);\n res = 0;\n for (int j = 0; j < s.Length - 1; j++)\n {\n if (newS[j] == 'V' && newS[j + 1] == 'K')\n res++;\n }\n max = Math.Max(max, res);\n }\n return max;\n }\n \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 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 Tuple[] Enumerate()\n {\n return arr.Select((x, i) => new { g = Find(x), i }).GroupBy(x => x.g, (k, e) => Tuple.Create(k, e.Count())).ToArray();\n }\n }\n\n}", "lang_cluster": "C#", "tags": ["brute force"], "code_uid": "151f324639ac72f03057534d9fe6d87c", "src_uid": "578bae0fe6634882227ac371ebb38fc9", "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 NetExperiment\n{\n class Program\n {\n static void Main(string[] args)\n {\n int[] nm = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();\n int[] x = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();\n int[] y = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();\n foreach(var i in x)\n {\n if (y.Contains(i))\n Console.Write(i + \" \");\n }\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "3b9dd692eb1ea8dff8745af650463db5", "src_uid": "f9044a4b4c3a0c2751217d9b31cd0c72", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": ".NET Core C#", "source_code": "using System;\n\t\npublic class Program\n{\n\tpublic static void Main()\n\t{\n\t\tvar num = int.Parse(Console.ReadLine());\n\t\tif(num%2 == 0){\n\t\t\tConsole.WriteLine(0);\n\t\t}else{\n\t\t\tConsole.WriteLine(1);\n\t\t}\n\t}\n}", "lang_cluster": "C#", "tags": ["math"], "code_uid": "73ef659b54ad28749c0333f8d713daac", "src_uid": "78e64fdbf59c5ce89d0f0a1d0591f795", "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 Algrithom.CodeForces\n{\n class _1286A_Garland\n {\n static int getminparity(int n, int[] aa)\n {\n if (n == 1)\n return 0;\n\n int oddCnt = n / 2 + n % 2;\n int evenCnt = n / 2;\n\n /*\n foreach(int a in aa)\n {\n if (a == 0)\n continue;\n if (a % 2 == 0)\n evenCnt--;\n else\n oddCnt--;\n }\n */\n\n //int[,,,] memo = new int[n, (n / 2 + n % 2) + 1, (n / 2) + 1, 2];\n int[,,] memo = new int[2, oddCnt + 1, evenCnt + 1];\n for (int i = 0; i < memo.GetLength(0); i++)\n for (int j = 0; j < memo.GetLength(1); j++)\n for (int k = 0; k < memo.GetLength(2); k++)\n //for (int l = 0; l < memo.GetLength(3); l++)\n //memo[i, j, k, l] = -1;\n memo[i, j, k] = -1;\n\n\n if(aa[0] == 0)\n {\n int v1 = int.MaxValue;\n int v2 = int.MaxValue;\n\n if (oddCnt > 0)\n v1 = dfs(1, oddCnt - 1, evenCnt, 1, aa, memo);\n if (evenCnt > 0)\n v2 = dfs(1, oddCnt, evenCnt - 1, 0, aa, memo);\n\n if (v1 != -2 && v2 != -2)\n return Math.Min(v1, v2);\n else if (v1 != -2)\n return v1;\n else\n return v2;\n }\n else\n if(aa[0] % 2 == 0)\n return dfs(1, oddCnt, evenCnt-1, aa[0]%2, aa, memo);\n else\n return dfs(1, oddCnt-1, evenCnt, aa[0] % 2, aa, memo);\n }\n\n //preParity 1: odd, 0: even\n\n static int dfs(int idx, int oddCnt, int evenCnt, int preParity, int[] aa, int[,,] memo)\n {\n if (idx == aa.Length && oddCnt == 0 && evenCnt == 0)\n return 0;\n\n if (oddCnt < 0 || evenCnt < 0)\n return -2;\n\n if (memo[preParity, oddCnt, evenCnt] != -1)\n return memo[preParity, oddCnt, evenCnt];\n\n int v;\n if(aa[idx] == 0)\n {\n int v1 = -2;\n int v2 = -2;\n\n if (oddCnt > 0)\n { \n v1 = dfs(idx + 1, oddCnt - 1, evenCnt, 1, aa, memo);\n if (v1 != -2)\n v1 += (preParity == 0 ? 1 : 0);\n }\n if (evenCnt > 0)\n { \n v2 = dfs(idx + 1, oddCnt, evenCnt - 1, 0, aa, memo);\n if (v2 != -2)\n v2 += (preParity == 0 ? 0 : 1);\n }\n\n if (v1 != -2 && v2 != -2)\n v = Math.Min(v1, v2);\n else if (v1 != -2)\n v = v1;\n else if (v2 != -2)\n v = v2;\n else\n v = -2;\n }\n else\n {\n if(aa[idx] % 2 == 0)\n v = dfs(idx + 1, oddCnt, evenCnt-1, aa[idx] % 2, aa, memo);\n else\n v = dfs(idx + 1, oddCnt-1, evenCnt, aa[idx] % 2, aa, memo);\n\n if (v != -2 && aa[idx] % 2 != preParity)\n v++;\n }\n\n memo[preParity, oddCnt, evenCnt] = v;\n return v;\n }\n\n static void Main(string[] args)\n {\n int n = Convert.ToInt32(Console.ReadLine().Trim());\n int[] aa = Array.ConvertAll(Console.ReadLine().Trim().Split(' '), tmp => Convert.ToInt32(tmp));\n\n int res = getminparity(n, aa);\n\n Console.WriteLine(res);\n Console.ReadLine();\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["sortings", "dp", "greedy"], "code_uid": "9f661f02709337414ac875c82ab4ae9f", "src_uid": "90db6b6548512acfc3da162144169dba", "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 Tasks\n{\n class Program\n {\n static void Main(string[] args)\n {\n //\u0412\u0432\u043e\u0434\n string[] input = Console.ReadLine().Split();\n\n int Distance = int.Parse(input[0]), CurrentFuel = int.Parse(input[1]), GasStation = int.Parse(input[2]), TotalRuns = int.Parse(input[3]);\n int MaxFuel = CurrentFuel;\n int Distance_B2GS = Distance - GasStation;\n int GasPerKm = 1;\n bool isForward = true;\n int count = 0;\n //\u0427\u0430\u0441\u0442\u044c \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0434\u043b\u044f \n for (int i = 1; i <= TotalRuns; i++)\n {\n if (i != TotalRuns)\n {\n //\u0415\u0441\u043b\u0438 \u043f\u043e\u0435\u0437\u0434\u043a\u0430 \u0432\u043f\u0435\u0440\u0435\u0434\n if (isForward)\n {\n //\u0415\u0441\u043b\u0438 \u043d\u0435\u0434\u043e\u0442\u044f\u0433\u0438\u0432\u0430\u0435\u043c \u0434\u0430\u0436\u0435 \u0434\u043e \u0437\u0430\u043f\u0440\u0430\u0432\u043a\u0438, \u0443\u0432\u044b \u0438 \u0430\u0445\n if (CurrentFuel < GasPerKm * GasStation) { Console.WriteLine(\"-1\"); return; }\n\n if ((CurrentFuel - GasStation * GasPerKm) < 2 * GasPerKm * (Distance_B2GS))\n {\n CurrentFuel = MaxFuel - (Distance_B2GS) * GasPerKm;\n count++;\n }\n else\n {\n CurrentFuel -= Distance * GasPerKm;\n }\n }\n else //\u0435\u0434\u0435\u043c \u043d\u0430\u0437\u0430\u0434\n {\n //\u041f\u0440\u043e\u0432\u0435\u0440\u0438\u043c, \u0434\u043e\u0442\u044f\u043d\u0435\u043c \u043b\u0438 \u0434\u043e \u0437\u0430\u043f\u0440\u0430\u0432\u043a\u0438\n if (CurrentFuel < GasPerKm * Distance_B2GS) { Console.WriteLine(\"-1\"); return; }\n\n if ((CurrentFuel - GasPerKm * Distance_B2GS) < 2 * GasPerKm * (GasStation))\n {\n CurrentFuel = MaxFuel - GasPerKm * GasStation;\n count++;\n }\n else\n {\n CurrentFuel -= Distance * GasPerKm;\n\n }\n }\n isForward = !isForward;\n }\n else\n {\n //\u041f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u043a\u0440\u0443\u0433, \u043f\u0440\u044f\u043c\u043e\n if (isForward)\n {\n if ((CurrentFuel < GasPerKm * GasStation)||(CurrentFuel= (Math.Max(0, n - d2) + Math.Max(0, m - d3)))\n {\n r = mid;\n }\n else\n {\n l = mid + 1;\n }\n }\n\n writer.WriteLine(l);\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", "number theory", "brute force"], "code_uid": "0246c346004303feb9adf731ca42c4e5", "src_uid": "23f2c8cac07403899199abdcfd947a5a", "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 A.Friends_Meeting\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 total = 0;\n int s = (Math.Abs(a - b)) / 2;\n for (int i = 1; i <= s; i++)\n {\n total += i;\n }\n if (Math.Abs(a - b) % 2 == 0){\n total*=2;\n }\n else\n {\n for (int i = 1; i <= Math.Abs(a - b)-s; i++)\n {\n total += i;\n }\n }\n Console.WriteLine(total);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "greedy", "implementation", "brute force"], "code_uid": "2c2d4237297b834bdfd214461d25cb35", "src_uid": "d3f2c6886ed104d7baba8dd7b70058da", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.IO;\nusing System.Linq;\n\nnamespace KingOfThieves\n{\n\tinternal class Program\n\t{\n\t\tprivate static void Main(string[] args)\n\t\t{\n\t\t\tvar input = args.Length == 0 ? new Input() : new Input(args[0]);\n\n\t\t\tvar n = int.Parse(input.ReadLine());\n\t\t\tvar items = new List(n);\n\t\t\titems.AddRange(input.ReadLine().Select(c => c == '*'));\n\n\t\t\tfor (var i = 0; i < n - 4; i++)\n\t\t\t{\n\t\t\t\tif (items[i])\n\t\t\t\t{\n\t\t\t\t\tfor (var j = i + 4; j < n; j += 4)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (items[j])\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tvar step = (j - i)/4;\n\t\t\t\t\t\t\tif (items[i + step] && items[j - step] && items[i + 2*step])\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tConsole.WriteLine(\"yes\");\n\t\t\t\t\t\t\t\treturn;\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(\"no\");\n\t\t}\n\n\t\tprivate class Input\n\t\t{\n\t\t\tprivate readonly StreamReader _reader;\n\n\t\t\tpublic Input()\n\t\t\t{\n\t\t\t}\n\n\t\t\tpublic Input(string fileName)\n\t\t\t{\n\t\t\t\t_reader = new StreamReader(fileName);\n\t\t\t}\n\n\t\t\tpublic string ReadLine()\n\t\t\t{\n\t\t\t\tvar line = _reader == null ? Console.ReadLine() : _reader.ReadLine();\n\t\t\t\tConsole.Error.WriteLine(line);\n\t\t\t\treturn line;\n\t\t\t}\n\t\t}\n\t}\n}", "lang_cluster": "C#", "tags": ["brute force", "implementation"], "code_uid": "8d3db376cda2136c27062010a23afca2", "src_uid": "12d451eb1b401a8f426287c4c6909e4b", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.IO;\nusing System.Text;\n\nclass A\n{\n private static string NextToken()\n {\n StringBuilder result = new StringBuilder();\n while (true)\n {\n int c = Console.Read();\n if (c == -1)\n return result.ToString();\n if (char.IsWhiteSpace((char)c))\n {\n if (result.Length > 0)\n {\n return result.ToString();\n }\n }\n else\n {\n result.Append((char)c);\n }\n }\n }\n\n private static int NextInt()\n {\n return int.Parse(NextToken());\n }\n\n private static double NextDouble()\n {\n return double.Parse(NextToken());\n }\n\n static void Solve()\n {\n int n = NextInt();\n int c = NextInt();\n int[] x = new int[n];\n for (int i = 0; i < n; i++)\n {\n x[i] = NextInt();\n }\n int answer = 0;\n for (int i = 0; i < n - 1; i++)\n {\n int profit = x[i] - x[i + 1] - c;\n if (profit > answer)\n answer = profit;\n }\n Console.WriteLine(answer);\n }\n\n static void Main(string[] args)\n {\n //using (var reader = new StreamReader(new FileStream(\"a.in\", FileMode.OpenOrCreate, FileAccess.Read)))\n //{\n // Console.SetIn(reader);\n // using (var writer = new StreamWriter(new FileStream(\"a.out\", FileMode.Create, FileAccess.Write)))\n // {\n // Console.SetOut(writer);\n Solve();\n // }\n //}\n }\n}\n\n", "lang_cluster": "C#", "tags": ["brute force", "greedy", "implementation"], "code_uid": "95d53e0353a7f58e10dee9a08d93a7c7", "src_uid": "411539a86f2e94eb6386bb65c9eb9557", "difficulty": 1000.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\npublic class Source\n{\n public void Program()\n {\n }\n void Read()\n {\n int s = ri(), start = ri(), end = ri();\n int t1 = ri(), t2 = ri();\n int p = ri(), d = ri();\n int time1 = 0;\n while (true)\n {\n if (d == 1)\n {\n\n if (start >= p && start <= end)\n {\n time1 = time1 + Math.Abs(p - end);\n break;\n }else\n {\n time1 += s - p;\n p = s;\n\n }\n }\n else\n {\n\n if (start <= p && start >= end)\n {\n time1 = time1 + Math.Abs(p - end);\n break;\n }\n else\n {\n time1 += p;\n p = 0;\n\n }\n\n }\n d *= -1;\n }\n time1 *= t1;\n int time2 = Math.Abs(end - start) * t2;\n writeLine(Math.Min(time1, time2));\n\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 char[] SplitToChar() { string s = ReadToken(); char[] r = new char[s.Length]; for (int i = 0; i < s.Length; i++) r[i] = s[i]; return r; }\n public static byte[] SplitToByte() { string s = ReadToken(); byte[] r = new byte[s.Length]; for (int i = 0; i < s.Length; i++) r[i] = (byte)s[i]; return r; }\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}\n", "lang_cluster": "C#", "tags": ["math", "constructive algorithms", "implementation"], "code_uid": "c4de1584f20bbd9d5d1c547f4357497e", "src_uid": "fb3aca6eba3a952e9d5736c5d8566821", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\n\n\nnamespace ConsoleApplication5\n{\n class Program\n {\n static long poisk(long x, long y, long z)\n { \n if (x < y && x < z)\n return x;\n else\n {\n if (y < x && y < z)\n return y;\n else \n return z;\n } \n }\n\n static void Main(string[] args)\n {\n string s = Console.ReadLine();\n var s1 = s.Split(' ');\n long n = long.Parse(s1[0]);\n long a = long.Parse(s1[1]);\n long b = long.Parse(s1[2]);\n long c = long.Parse(s1[3]);\n if (n % 4 == 0)\n Console.WriteLine (0);\n else\n {\n if (n % 4 == 1)\n Console.WriteLine(poisk(c, 3 * a, a + b)); \n else\n {\n if (n % 4 == 2) \n Console.WriteLine(poisk(b, 2 * a, 2 * c)); \n else \n Console.WriteLine(poisk(a, 3 * c, c + b)); \n }\n }\n Console.ReadLine();\n }\n }\n}", "lang_cluster": "C#", "tags": ["brute force", "implementation"], "code_uid": "658edda4e50262fb43d6ab1e28917d6b", "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 Code\n{\n class Program\n {\n static void Main(string[] args)\n {\n string a = Console.ReadLine();\n int n = int.Parse(a.Split(' ')[0]);\n int k = int.Parse(a.Split(' ')[1]);\n string s = Console.ReadLine();\n for (int i = 0; i < s.Length; i++)\n {\n int c = 0;\n for (int j = 0; j < s.Length; j++)\n {\n if (s[i] == s[j])\n c++;\n }\n if (c > k)\n {\n Console.Write(\"NO\");\n return;\n }\n c = 0;\n }\n Console.WriteLine(\"YES\");\n\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "implementation"], "code_uid": "15620218cc038b9de2211628eb4e749a", "src_uid": "ceb3807aaffef60bcdbcc9a17a1391be", "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 ConsoleApp8\n{\n class Program\n {\n static void Main(string[] args)\n {\n int b;\n\n int n = Convert.ToInt32(Console.ReadLine());\n\n int[] temp = new int[n];\n\n string[] tempStr = new string[n];\n\n string str = Console.ReadLine();\n\n char[] split = { ' ' };\n\n tempStr = str.Split(split);\n\n for (int k = 0; k <= n - 1; k++)\n {\n temp[k] = Convert.ToInt32(tempStr[k]);\n }\n\n int m = temp[0] - temp[1];\n b = 0;\n\n for (int k = 0; k <= n - 2; k++)\n {\n if (temp[k] - temp[k + 1] == m)\n {\n b = b + 1;\n } \n }\n\n if (n > 2)\n {\n if (b == n - 1 && temp[n - 1] - temp[n - 2] == temp[n - 2] - temp[n - 3])\n {\n Console.WriteLine(temp[n - 1] + temp[n - 1] - temp[n - 2]);\n }\n else\n {\n Console.WriteLine(temp[n - 1]);\n }\n }\n else\n {\n Console.WriteLine(temp[n - 1] + temp[n - 1] - temp[n - 2]);\n }\n }\n }\n}", "lang_cluster": "C#", "tags": ["math", "implementation"], "code_uid": "0a90acfe19cedfb4595d73bbf0cfa728", "src_uid": "d04fa4322a1b300bdf4a56f09681b17f", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\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\u8fba\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": "9fba115b842e98cd39721af0c68ef437", "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;\n\nnamespace Task_2\n{\n class Program\n {\n static void Main(string[] args)\n {\n //int m, k, n;\n\n string[] string1 = Console.ReadLine().Split(' ');\n\n // \u0427\u0438\u0441\u043b\u043e \u0444\u0438\u043b\u044c\u0442\u0440\u043e\u0432, \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432, \u0440\u043e\u0437\u0435\u0442\u043e\u043a\n int n = int.Parse(string1[0]);\n int m = int.Parse(string1[1]);\n int k = int.Parse(string1[2]);\n\n\n string[] string2 = Console.ReadLine().Split(' ');\n\n int[] mass = new int[n];\n for (int i = 0; i < n; i++)\n {\n mass[i] = int.Parse(string2[i]);\n }\n Array.Sort(mass);\n Array.Reverse(mass);\n\n // \u0427\u0438\u0441\u043b\u043e \u0441\u0432\u043e\u0431\u043e\u0434\u043d\u044b\u0445 \u0440\u043e\u0437\u0435\u0442\u043e\u043a\n int free;\n\t\t\t\n // \u0422\u043e\u043b\u044c\u043a\u043e \u0440\u043e\u0437\u0435\u0442\u043a\u0438\n free = k;\n\n if (free >= m)\n {\n Console.WriteLine(0);\n return;\n }\n\n\n for (int j = 1; j <= n; j++)\n {\n int sum = 0;\n for (int g = 0; g < j; g++)\n {\n sum += mass[g];\n }\n free = k - j + sum;\n\n if (free >= m)\n {\n Console.WriteLine(j);\n return;\n }\n }\n\n Console.WriteLine(-1);\n return;\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["sortings", "implementation", "greedy"], "code_uid": "da0af556d026f30ec8d0193334672cba", "src_uid": "b32ab27503ee3c4196d6f0d0f133d13c", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nnamespace codeforces\n{\n\tclass MainClass\n\t{\n\t\tpublic static void Main (string[] args)\n\t\t{\n\t\t\tstring[] s = Console.ReadLine ().Split (' ');\n\t\t\tint a = int.Parse (s [0]);\n\t\t\tint b = int.Parse (s [1]);\n\t\t\tint c = int.Parse (s [2]);\n\t\t\ts = Console.ReadLine ().Split (' ');\n\t\t\tint x = int.Parse (s [0]);\n\t\t\tint y = int.Parse (s [1]);\n\t\t\tint z = int.Parse (s [2]);\n\t\t\tint e1 = Math.Abs (a - x), e2 = Math.Abs (b - y), e3 = Math.Abs (c - z);\n\t\t\tint p=0,m=0;\n\n\t\t\tif (a >= x)\n\t\t\t\tp+= e1 / 2;\n\t\t\telse\n\t\t\t\tm+=e1;\n\n\t\t\tif (b >= y)\n\t\t\t\tp+= e2 / 2;\n\t\t\telse\n\t\t\t\tm+=e2;\n\n\t\t\tif (c >= z)\n\t\t\t\tp+= e3 / 2;\n\t\t\telse\n\t\t\t\tm+=e3;\n\t\t\tif(p>=m)\n\t\t\t\tConsole.WriteLine (\"Yes\");\n\t\t\telse\n\t\t\t\tConsole.WriteLine (\"No\");\n\n\t\t}\n\t}\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "93378e40f1e6f1eecc3108944e988561", "src_uid": "1db4ba9dc1000e26532bb73336cf12c3", "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 denemexxxx\n{\n class Program\n {\n static void Main(string[] args)\n {\n try {\n string[] rule = new string[3];\n char[] x = new char[3];\n for (int i = 0; i < 3; i++)\n {\n x = Console.ReadLine().ToCharArray();\n if (x[1] == '<')\n {\n x[1] = '>';\n Array.Reverse(x);\n string s = new string(x); \n rule[i] = s;\n \n }\n else\n {\n string s = new string(x);\n rule[i] = s;\n }\n }\n int[] sayi = new int[3];\n for (int i = 0; i < 3; i++)\n {\n string s = \"\";\n s = rule[i];\n if (s[0] == 'A')\n sayi[0]++;\n else if (s[0] == 'B')\n sayi[1]++;\n else\n sayi[2]++;\n \n }\n string a = \"ABC\";\n string z = \"\";\n if (sayi[0] == 2 || sayi[1] == 2 || sayi[2] == 2)\n {\n for (int i = 0; i < 3; i++)\n {\n for (int j = 0; j < 3; j++)\n {\n if (sayi[j] == i) // 2 0 1\n z += a[j];\n }\n }\n Console.Write(z);\n }\n else\n Console.Write(\"Impossible\");\n Console.ReadKey();\n }\n catch { }\n \n }\n }\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "d1092592d805da107ff3b49e22959d3a", "src_uid": "97fd9123d0fb511da165b900afbde5dc", "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 A\n {\n static void Main(string[] args)\n {\n List L = new List();\n int n = int.Parse(Console.ReadLine());\n int to = (n>100)?n-100:0;\n for(int i=n-1;i>=to;i--){\n if(i + GetSum(i)==n){\n L.Add(i);\n }\n }\n L.Sort();\n Console.WriteLine(L.Count);\n for(int i=0;i arr = Console.ReadLine().Split(' ').Select(x => ulong.Parse(x)).ToList();\n var op = Console.ReadLine().Split(' ').ToArray();\n Console.Write(SmallestNumber(arr, op, 0, ulong.MaxValue));\n }\n\n public static ulong SmallestNumber(List arr, string[] ope, int opeCount, ulong min)\n {\n\n if (arr.Count == 1)\n return arr[0];\n \n for (int i = 0; i < arr.Count; i++)\n {\n for (int j = i + 1; j < arr.Count; j++)\n {\n if (ope[opeCount] == \"+\")\n {\n var listNew = new List(arr);\n var tmp = listNew[i] + listNew[j];\n listNew.RemoveAt(j);\n listNew.RemoveAt(i);\n listNew.Add(tmp);\n min = Math.Min(min, SmallestNumber(listNew, ope, opeCount + 1, min));\n }\n if (ope[opeCount] == \"*\")\n {\n var listNew = new List(arr);\n var tmp = listNew[i] * listNew[j];\n listNew.RemoveAt(j);\n listNew.RemoveAt(i);\n \n listNew.Add(tmp);\n min = Math.Min(min, SmallestNumber(listNew, ope, opeCount + 1, min));\n }\n }\n }\n\n //min = Math.Min(min1, min2);\n return min;\n }\n}\n\n", "lang_cluster": "C#", "tags": ["brute force"], "code_uid": "5219d84f1462d5cea22505c75644478e", "src_uid": "7a66fae63d9b27e444d84447012e484c", "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 a\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\n bool[] ls = new bool[10];\n for (int i = 0; i < s.Length; i++)\n {\n ls[s[i] - '0'] = true;\n }\n bool[] yoko = new bool[3];\n bool[] tate = new bool[4];\n \n if(ls[0])\n {\n yoko[1] = true;\n tate[3] = true;\n }\n\n for (int i = 1; i < 10; i++)\n {\n if(ls[i])\n {\n yoko[(i - 1) % 3] = true;\n tate[(i - 1) / 3] = true;\n }\n }\n if (tate[3])//0\n {\n if (tate[0])\n {\n Console.WriteLine(\"YES\");\n return;\n }\n else\n {\n Console.WriteLine(\"NO\");\n return;\n }\n }\n if((tate[0]&&tate[2]) && yoko[0]&&yoko[2])\n {\n if (ls[7] || ls[9])\n {\n Console.WriteLine(\"YES\");\n return;\n }\n else\n {\n Console.WriteLine(\"NO\");\n return;\n }\n }\n else\n {\n Console.WriteLine(\"NO\");\n return;\n }\n\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "constructive algorithms", "implementation"], "code_uid": "3f535f117b8642a2e02b884897ccff91", "src_uid": "d0f5174bb0bcca5a486db327b492bf33", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "// 1673 ms !!! long is much slower than double\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;\n\nnamespace sar_cs\n{\n class Program\n {\n 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 void Test()\n {\n Random rand = new Random(52345235);\n for (int i = 0; i < 2e6; i++)\n {\n }\n }\n\n struct Pos\n {\n public int X, Y;\n\n public Pos(int x, int y)\n {\n X = x; Y = y;\n }\n\n public Pos(string s)\n {\n X = (int)(s[0] - 'a');\n Y = (int)(s[1] - '0' - 1);\n }\n\n public bool Neighbor(Pos o)\n {\n return (X != o.X || Y != o.Y) && Math.Abs(X - o.X) <= 1 && Math.Abs(Y - o.Y) <= 1;\n }\n\n }\n\n static void LadyaFill(int[,] field, Pos l)\n {\n for (int x = l.X + 1; x < 8; x++)\n {\n int t = field[l.Y, x];\n field[l.Y, x] |= 2;\n if ((t & 1) == 1) break;\n }\n for (int x = l.X - 1; x >= 0; x--)\n {\n int t = field[l.Y, x];\n field[l.Y, x] |= 2;\n if ((t & 1) == 1) break;\n }\n\n for (int y = l.Y + 1; y < 8; y++)\n {\n int t = field[y, l.X];\n field[y, l.X] |= 2;\n if ((t & 1) == 1) break;\n }\n\n for (int y = l.Y - 1; y >= 0; y--)\n {\n int t = field[y, l.X];\n field[y, l.X] |= 2;\n if ((t & 1) == 1) break;\n }\n }\n\n static int Main(string[] args)\n {\n //Test(); return 0;\n //Console.SetIn(File.OpenText(\"_input\"));\n //Console.SetOut(File.CreateText(\"_out\"));\n Parser parser = new Parser();\n\n while (!parser.SeekEOF)\n {\n string line = parser.ReadLine();\n string[] ll = line.Split(' ');\n if (ll.Length != 4) pe();\n\n Pos wl1 = new Pos(ll[0]);\n Pos wl2 = new Pos(ll[1]);\n Pos wk = new Pos(ll[2]);\n Pos bk = new Pos(ll[3]);\n\n int[,] field = new int[8, 8];\n field[wl1.Y, wl1.X] = 1;\n field[wl2.Y, wl2.X] = 1;\n field[wk.Y, wk.X] = 1;\n //field[bk.Y,bk.X]='b';\n\n LadyaFill(field, wl1);\n LadyaFill(field, wl2);\n\n for (int y = 0; y < 8; y++)\n for (int x = 0; x < 8; x++)\n if (wk.Neighbor(new Pos(x, y))) field[y, x] |= 2;\n\n bool underAttack = (field[bk.Y, bk.X] & 2) != 0;\n\n bool canMove = false;\n for (int y = 0; y < 8; y++)\n for (int x = 0; x < 8; x++)\n if (bk.Neighbor(new Pos(x, y)))\n canMove |= (field[y, x] & 2) == 0;\n\n string res = underAttack && !canMove ? \"CHECKMATE\" : \"OTHER\";\n Console.WriteLine(res);\n\n }\n sw.Stop();\n return 0;\n }\n }\n}", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "3bf2a700c3fd8b89f560ecf4fe52f9f5", "src_uid": "5d05af36c7ccb0cd26a4ab45966b28a3", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.IO;\nusing System.Linq;\nusing System.Text;\n\nnamespace Ciel_and_Flowers\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 g = Next();\n int b = Next();\n\n int count = r/3 + g/3 + b/3;\n\n var nn = new[] {r%3, g%3, b%3};\n int min = nn.Min();\n\n if (min > 0)\n {\n count += min;\n }\n else\n {\n if (nn.Sum() == 4)\n {\n if (r%3 == 0 && r > 0 || g%3 == 0 && g > 0 || b%3 == 0 && b > 0)\n {\n count++;\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", "combinatorics"], "code_uid": "ae41daea74d8d5e7f980443d3a848a3f", "src_uid": "acddc9b0db312b363910a84bd4f14d8e", "difficulty": 1600.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 string[] ab = Console.ReadLine().Split(' ');\n int n = Convert.ToInt32(ab[0]);\n int v = Convert.ToInt32(ab[1]);\n int current = 1, totalmoney = 0;\n if (v >= n) Console.Write(n - 1);\n else\n {\n while (current < n)\n {\n if (n - current >= v)\n {\n if (current == 1) totalmoney += v * current;\n else totalmoney += current;\n }\n current++;\n }\n Console.Write(totalmoney);\n }\n }\n}", "lang_cluster": "C#", "tags": ["math", "greedy", "dp"], "code_uid": "284547feeae685c0c97c31bd3e4e44b1", "src_uid": "f8eb96deeb82d9f011f13d7dac1e1ab7", "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 int n = int.Parse(Console.ReadLine());\n string[] s = Console.ReadLine().Split();\n int[] m = new int[n];\n for (int i = 0; i < n; i++)\n {\n m[i] = int.Parse(s[i]);\n }\n int p1 = 0;\n int p2 = 0;\n bool f = false;\n for (int i = 0; i < n; i++)\n {\n if (m[i] == 1)\n {\n f = true;\n p1 = i;\n break;\n }\n }\n if (!f)\n {\n Console.WriteLine(0);\n return;\n }\n\n for (int i = 0; i < n; i++)\n {\n if (m[i] == 1)\n {\n p2 = i;\n }\n }\n int ans = p1;\n ans += n - p2 - 1;\n string q = \"\";\n for (int i = p1; i < p2; i++)\n {\n q += m[i];\n }\n string[] qt = q.Split('1');\n for (int i = 0; i < qt.Length; i++)\n {\n if (qt[i].Length >= 2)\n {\n ans += qt[i].Length;\n }\n }\n Console.WriteLine(n-ans);\n \n }\n }\n}", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "7cc36e8527f8abee8cb8eb0c75577869", "src_uid": "2896aadda9e7a317d33315f91d1ca64d", "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\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// 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\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 l = sr.NextInt32();\n var r = sr.NextInt32();\n var a = sr.NextInt32();\n var min = Math.Min(l, r);\n var max = Math.Max(l, r);\n if (max >= min + a) {\n sw.WriteLine((min + a)*2);\n }\n else {\n var o = min + a - max;\n sw.WriteLine((o/2 + max)*2);\n }\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}\n", "lang_cluster": "C#", "tags": ["math", "implementation"], "code_uid": "c3dfc0c3cf5a8b136c36a40e1b4c724d", "src_uid": "e8148140e61baffd0878376ac5f3857c", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\n\nnamespace ShadowingOverride\n{ \n class Program\n {\n static void Main(string[] args)\n {\n string[] s = new string[2];\n s[0] = Console.ReadLine();\n s[1] = Console.ReadLine();\n int n = s[0].Length;\n int empty = 0;\n int cur = 0;\n int ans = 0;\n \n for(int i = 0; i < n; i++)\n {\n cur = (s[0][i] == '0'?1:0) + (s[1][i] == '0'?1:0);\n // Console.WriteLine(cur);\n empty += cur;\n if( empty >= 3)\n {\n empty -= 3;\n ans++;\n }\n else\n {\n empty = cur;\n }\n }\n Console.WriteLine(ans);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["greedy", "dp"], "code_uid": "972add5d209d8b6d2c148c7807d9e8d1", "src_uid": "e6b3e787919e96fc893a034eae233fc6", "difficulty": 1500.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;\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 Fun(int a, int b)\n {\n return b * (2 * a + b);\n }\n\n void Solve()\n {\n var a = ReadIntArray();\n int ans;\n if (a[0] == a[2])\n ans = Fun(a[1], a[0]) + Fun(a[4], a[3]);\n else if (a[0] < a[2])\n ans = Fun(a[1], a[0]) + Fun(a[4], a[3]) + (a[0] + a[1]) * 2 * (a[2] - a[0]);\n else\n ans = Fun(a[1], a[2]) + Fun(a[4], a[5]) + (a[2] + a[1]) * 2 * (a[0] - a[2]);\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 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": ["geometry"], "code_uid": "240553469a98450a05157c22602f5f17", "src_uid": "382475475427f0e76c6b4ac6e7a02e21", "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 _40c\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().ToCharArray();\n for (int i = 1; i < s.Length - 1 - 1; i++)\n {\n if (s[i] == 'a' && s[i + 1] == 't')\n {\n s[i] = '@';\n s[i + 1] = ' ';\n break;\n }\n }\n\n var pos = 0;\n var start = -1;\n for (int i = 1; i < s.Length - 1; i++)\n {\n var next = s[i];\n if (next == ' ')\n {\n continue;\n }\n\n var want = ' ';\n switch (pos)\n {\n case 0:\n want = 'd';\n break;\n case 1:\n want = 'o';\n break;\n case 2:\n want = 't';\n break;\n default:\n break;\n }\n\n if (next != want)\n {\n pos = 0;\n start = -1;\n\n\n if (next == 'd')\n {\n pos++;\n start = i;\n }\n\n continue;\n }\n\n if (pos < 2)\n {\n if (pos == 0)\n {\n start = i;\n }\n\n pos++;\n continue;\n }\n\n \n s[start] = '.';\n for (int j = start + 1; j < start + 3; j++)\n {\n s[j] = ' ';\n }\n\n pos = 0;\n start = -1;\n }\n\n for (int i = 0; i < s.Length; i++)\n {\n if (s[i] != ' ')\n {\n Console.Write(s[i]);\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": ["expression parsing", "implementation"], "code_uid": "0c4f1a661ee4df61f62bf12a5c4d9ce7", "src_uid": "a11c9679d8e2dca51be17d466202df6e", "difficulty": 1300.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 long count = 0;\n long t = int.Parse(str[0]);\n int l = int.Parse(str[1]);\n int r = int.Parse(str[2]);\n Generateprimenumber G = new Generateprimenumber(r+1);\n long[] A = new long[r+1];\n for(int i=0;i pp = new List();\n int j = 2;\n for(int i=0;i pp = new List();\n long num = n;\n int count = 1;\n bool last = false;\n for(int i=0;p[i]*p[i] <= num;i++){\n int j=0;\n while(num % p[i] == 0){\n num /= p[i];\n j++;\n }\n pp.Add(j);\n count *= j+1; \n }\n if(num != 1){\n pp.Add(1);\n count *= 2;\n last = true;\n }\n long[] div = new long[count];\n for(int i=0;i use inclusive bounds and condition <= \n//Array.Reverse do not work in mono!\nnamespace CodePractice\n{\n\n public class Test\n {\n public static void Main()\n {\n ConsoleReader r = new ConsoleReader();\n TextWriter w = new StreamWriter(new BufferedStream(Console.OpenStandardOutput()));\n Solve(r, w);\n w.Close();\n //Console.ReadKey();\n }\n\n public static void Solve(ConsoleReader reader, TextWriter writer)\n {\n B(reader, writer);\n }\n\n public static void E(ConsoleReader reader, TextWriter writer)\n {\n }\n\n public static void D(ConsoleReader reader, TextWriter writer)\n {\n //http://codeforces.com/contest/1023/problem/D\n int n = reader.NextInt(), q = reader.NextInt();\n int[] a = new int[n];\n\n reader.NextArray(a, n);\n\n //\n }\n public static void C(ConsoleReader reader, TextWriter writer)\n {\n }\n\n public static void B(ConsoleReader reader, TextWriter writer)\n {\n long n = reader.NextLong(), sum = reader.NextLong();\n long ans = 0;\n\n if (n >= sum)\n {\n ans = sum / 2;\n if (sum % 2 == 0)\n {\n ans--;\n }\n }\n else\n {\n ans = Math.Max(n - sum / 2, 0);\n //if (sum % 2 == 0 && ans > 0)\n // ans--;\n }\n Console.WriteLine(ans);\n }\n\n public static void A(ConsoleReader reader, TextWriter writer)\n {\n int n = reader.NextInt(), m = reader.NextInt();\n\n string a = reader.NextString();\n string b = reader.NextString();\n\n int ai = 0, bi = 0;\n\n while (ai < a.Length && bi < b.Length && a[ai] != '*' && a[ai] == b[bi])\n {\n ai++;\n bi++;\n }\n\n if (ai < a.Length && a[ai] == '*')\n {\n bi--;\n }\n\n\n int aj = a.Length - 1, bj = b.Length - 1;\n while (aj > ai && bj > bi && a[aj] != '*' && a[aj] == b[bj])\n {\n aj--;\n bj--;\n }\n\n if ((ai == a.Length && bi == b.Length) || (ai < a.Length && ai == aj && a[ai] == '*'))\n {\n writer.WriteLine(\"YES\");\n }\n else\n {\n writer.WriteLine(\"NO\");\n }\n }\n }\n\n\n\n public class ConsoleReader\n {\n private String[] data;\n private int wordIndex = 0;\n\n private void ReadLineIfNeeded()\n {\n while (data == null || wordIndex >= data.Length)\n {\n wordIndex = 0;\n data = Console.ReadLine().Trim().Split();\n }\n }\n\n public long NextLong()\n {\n ReadLineIfNeeded();\n return long.Parse(data[wordIndex++]);\n }\n\n public int NextInt()\n {\n ReadLineIfNeeded();\n return int.Parse(data[wordIndex++]);\n }\n\n public void NextArray(long[] a, int n)\n {\n for (int i = 0; i < n; i++)\n {\n a[i] = NextLong();\n }\n }\n\n public void NextArray(int[] a, int n)\n {\n for (int i = 0; i < n; i++)\n {\n a[i] = NextInt();\n }\n }\n\n public string NextString()\n {\n ReadLineIfNeeded();\n return data[wordIndex++];\n }\n\n //ReadLine()\n\n }\n\n}", "lang_cluster": "C#", "tags": ["math"], "code_uid": "78f582cfc94907881dcfe7bb31f52672", "src_uid": "98624ab2fcd2a50a75788a29e04999ad", "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 long[] a = {1,2,3,4,6,8,9,12,16,18,24,27,32,36,48,54,64,72,81,96,108,128,144,162,\n192,216,243,256,288,324,384,432,486,512,576,648,729,768,864,972,1024,1152,1296,1458,1536,1728,1944,\n2048,2187,2304,2592,2916,3072,3456,3888,4096,4374,4608,5184,5832,6144,6561,6912,7776,8192,8748,9216,\n10368,11664,12288,13122,13824,15552,16384,17496,18432,19683,20736,23328,24576,26244,27648,31104,32768,\n34992,36864,39366,41472,46656,49152,52488,55296,59049,62208,65536,69984,73728,78732,82944,93312,98304,104976,\n110592,118098,124416,131072,139968,147456,157464,165888,177147,186624,196608,209952,221184,236196,248832,262144,\n279936,294912,314928,331776,354294,373248,393216,419904,442368,472392,497664,524288,531441,559872,589824,629856,\n663552,708588,746496,786432,839808,884736,944784,995328,1048576,1062882,1119744,1179648,1259712,1327104,1417176,\n1492992,1572864,1594323,1679616,1769472,1889568,1990656,2097152,2125764,2239488,2359296,2519424,2654208,2834352,\n2985984,3145728,3188646,3359232,3538944,3779136,3981312,4194304,4251528,4478976,4718592,4782969,5038848,5308416,\n5668704,5971968,6291456,6377292,6718464,7077888,7558272,7962624,8388608,8503056,8957952,9437184,9565938,10077696,\n10616832,11337408,11943936,12582912,12754584,13436928,14155776,14348907,15116544,15925248,16777216,17006112,17915904,\n18874368,19131876,20155392,21233664,22674816,23887872,25165824,25509168,26873856,28311552,28697814,30233088,31850496,\n33554432,34012224,35831808,37748736,38263752,40310784,42467328,43046721,45349632,47775744,50331648,51018336,53747712,\n56623104,57395628,60466176,63700992,67108864,68024448,71663616,75497472,76527504,80621568,84934656,86093442,90699264,\n95551488,100663296,102036672,107495424,113246208,114791256,120932352,127401984,129140163,134217728,136048896,143327232,\n150994944,153055008,161243136,169869312,172186884,181398528,191102976,201326592,204073344,214990848,226492416,229582512,\n241864704,254803968,258280326,268435456,272097792,286654464,301989888,306110016,322486272,339738624,344373768,362797056,\n382205952,387420489,402653184,408146688,429981696,452984832,459165024,483729408,509607936,516560652,536870912,544195584,\n573308928,603979776,612220032,644972544,679477248,688747536,725594112,764411904,774840978,805306368,816293376,859963392,\n905969664,918330048,967458816,1019215872,1033121304,1073741824,1088391168,1146617856,1162261467,1207959552,1224440064,\n1289945088,1358954496,1377495072,1451188224,1528823808,1549681956,1610612736,1632586752,1719926784,1811939328,1836660096,1934917632};\n \n \n \n \n var numbers = Console.ReadLine();\n var numberList = numbers.Split(' ');\n long f = Convert.ToInt64(numberList[0]);\n long t = Convert.ToInt64(numberList[1]);\n \n int sum=0;\n \n for (int k=0;k<326;k++) {\n if ((a[k]>=f)&&(a[k]<=t)) sum++;\n \n }\n \n Console.WriteLine(\"{0}\",sum);\n }\n }\n}", "lang_cluster": "C#", "tags": ["math", "implementation"], "code_uid": "e75abadce476547730ee835b73ceee38", "src_uid": "05fac54ed2064b46338bb18f897a4411", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.IO;\nusing System.Text;\n\nnamespace Cableway\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(), g = Next(), b = Next();\n\n int max = 3*((r + 1)/2 - 1);\n max = Math.Max(max, 3*((g + 1)/2 - 1) + 1);\n max = Math.Max(max, 3*((b + 1)/2 - 1) + 2);\n\n writer.WriteLine(max + 30);\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": "e475ba2fc150ec74bfd88b485094b93e", "src_uid": "a45daac108076102da54e07e1e2a37d7", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": ".NET Core C#", "source_code": "\ufeffusing System;\n\nnamespace TaskCS\n{\n class Program\n {\n public static int Fac(int x)\n {\n var ans = 0;\n while (x > 0)\n {\n ans += x;\n x--;\n }\n return ans;\n }\n static void Main(string[] args)\n {\n var t = int.Parse(Console.ReadLine());\n var answers = new int[t];\n\n for (var i = 0; i < t; i++)\n {\n var x = Console.ReadLine();\n answers[i] = 10 * (int.Parse(x[0].ToString()) - 1) + Fac(x.Length);\n }\n\n foreach (var e in answers)\n Console.WriteLine(e);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "implementation"], "code_uid": "c74baebeece9215a01ac2d78ffd76752", "src_uid": "289a55128be89bb86a002d218d31b57f", "difficulty": 800.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 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 static double[] ReadDouble(string str)\n {\n string[] tokens = str.Trim().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);\n double[] ret = new double[tokens.Length];\n for (int i = 0; i < ret.Length; i++)\n {\n ret[i] = double.Parse(tokens[i], CultureInfo.InvariantCulture);\n }\n\n return ret;\n }\n\n static string Reverse(string s)\n {\n char[] a = s.ToCharArray();\n Array.Reverse(a);\n return new string(a);\n }\n\n static long[,] T;\n\n static long Solve(int n, int h)\n {\n if (h < 0) h = 0;\n if (T[n, h] >= 0) return T[n, h];\n if (n < h)\n {\n T[n, h] = 0;\n return 0;\n }\n if (n <= 1)\n {\n T[n, h] = 1;\n return 1;\n }\n \n long res = 0;\n\n for (int k = 0; k <= n - 1; k++)\n {\n res += Solve(k, h - 1) * Solve(n - 1 - k, 0);\n res += Solve(k, 0) * Solve(n - 1 - k, h - 1);\n res -= Solve(k, h - 1) * Solve(n - 1 - k, h - 1);\n }\n\n T[n, h] = res;\n\n return res;\n }\n \n static void Main(string[] args)\n {\n int[] nh = Read(Console.ReadLine());\n int n = nh[0], h = nh[1];\n T = new long[n + 1, h + 1];\n for (int i = 0; i <= n; i++)\n {\n for (int j = 0; j <= h; j++)\n {\n T[i, j] = -1;\n }\n }\n\n long res = Solve(n, h);\n\n Console.WriteLine(res);\n }\n}\n", "lang_cluster": "C#", "tags": ["divide and conquer", "dp", "combinatorics"], "code_uid": "a21af557ce59db89db23c9fc626055af", "src_uid": "faf12a603d0c27f8be6bf6b02531a931", "difficulty": 1900.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.IO;\nusing System.Text;\n\nnamespace Cloning_Toys\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 x = Next();\n int y = Next();\n\n if (y < 1)\n return false;\n\n int x1 = y - 1;\n if (x1 > x || x1 == 0 && x > 0)\n return false;\n\n if ((x - x1)%2 == 1)\n return false;\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": "97ded89c1198b6aa6c04540b1ab1dd4c", "src_uid": "1527171297a0b9c5adf356a549f313b9", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.IO;\nusing System.Linq;\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": "fc35ae36f67f2df6a1b95013718fbb1e", "src_uid": "0939354d9bad8301efb79a1a934ded30", "difficulty": 2500.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 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\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\tprivate static void Main()\n\t\t{\n\t\t\tvar l = ReadListOfInts();\n\t\t\tif ((l[0] + l[1] + l[2]) % 2 != 0)\n\t\t\t{\n\t\t\t\tConsole.WriteLine(\"Impossible\");\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tvar y = (l[0] + l[2] - l[1]) / 2;\n\t\t\tvar x = l[0] - y;\n\t\t\tvar z = l[2] - y;\n\t\t\tif (x >= 0 && y >= 0 && z >= 0)\n\t\t\t{\n\t\t\t\tConsole.WriteLine(\"{0} {1} {2}\", x, z, y);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tConsole.WriteLine(\"Impossible\");\n\t\t\tConsole.ReadLine();\n\t\t}\n\t}\n}\n", "lang_cluster": "C#", "tags": ["brute force", "math", "graphs"], "code_uid": "5793404a6bcf12279743a92cf3682b3a", "src_uid": "b3b986fddc3770fed64b878fa42ab1bc", "difficulty": 1200.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 var a = Console.ReadLine().Split(':').ToArray();\n int h1 = int.Parse(a[0][0].ToString());\n int h2 = int.Parse(a[0][1].ToString());\n if (h2 * 10 + h1 >= 60 || h2 * 10 + h1 <= int.Parse(a[1]))\n {\n if (h1 < 2 && h2 < 5 || h1 == 2 && h2 < 3) { h2++; }\n else\n {\n h2 = 0;\n if (h1 == 2) { h1 = 0; }\n else { h1++; }\n }\n }\n Console.WriteLine($\"{h1}{h2}:{h2}{h1}\");\n }\n }\n}", "lang_cluster": "C#", "tags": ["strings", "implementation"], "code_uid": "6a66d79715bc65a13ae6cc78d22c2068", "src_uid": "158eae916daa3e0162d4eac0426fa87f", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.IO;\nusing System.Text;\n\nnamespace k_rounding\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 int nn = n;\n long ex = 1;\n while (n%10 == 0)\n {\n n /= 10;\n k--;\n }\n while (k > 0)\n {\n if (n%2 == 0)\n {\n ex *= 5;\n n /= 2;\n k--;\n }\n else if (n%5 == 0)\n {\n ex *= 2;\n n /= 5;\n k--;\n }\n else \n break;\n }\n while (k > 0)\n {\n ex *= 10;\n k--;\n }\n\n writer.WriteLine(ex*nn);\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", "number theory"], "code_uid": "c71f6b6b04b069ff7f4071541aa09ffc", "src_uid": "73566d4d9f20f7bbf71bc06bc9a4e9f3", "difficulty": 1100.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 int MOD = 1000 * 1000 * 1000 + 7;\n\n private static int f(int c, int r)\n {\n if (r == 0)\n {\n return c / 3;\n }\n int count = c / 3;\n if (r == 1 && c % 3 == 0 || (r == 2 && c % 3 != 2))\n {\n count--;\n }\n count++;\n return count;\n }\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 void Main(string[] args)\n {\n var values = Console.ReadLine().Split(' ');\n int n = Convert.ToInt32(values[0]);\n int l = Convert.ToInt32(values[1]);\n int r = Convert.ToInt32(values[2]);\n\n var cnt = new int[3] { f(r, 0) - f(l - 1, 0), f(r, 1) - f(l - 1, 1), f(r, 2) - f(l - 1, 2) };\n var dp = new int[n + 1, 3];\n dp[0, 0] = 1;\n for (int i = 1; i <= n; ++i)\n {\n for (int rest = 0; rest < 3; ++rest)\n {\n for (int j = 0; j < 3; ++j)\n {\n int p = (rest - j + 3) % 3;\n dp[i, rest] = Add(dp[i, rest], Mult(dp[i - 1, j], cnt[p]));\n }\n }\n }\n Console.WriteLine(dp[n, 0]);\n }\n }\n}", "lang_cluster": "C#", "tags": ["math", "dp", "combinatorics"], "code_uid": "60b70a6a9f824a5986467fc9052f15e4", "src_uid": "4c4852df62fccb0a19ad8bc41145de61", "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 ConsoleApplication3\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 int x = 0, y = 0, max = 0;\n int x1 = x, y1 = y;\n for (int j = 0; j < s.Length - 1; j++)\n {\n x1 = x; y1 = y;\n for (int i = j; i < s.Length; i++)\n {\n if (s[i] == 'U') x--;\n if (s[i] == 'D') x++;\n if (s[i] == 'L') y--;\n if (s[i] == 'R') y++;\n if (x == x1 && y == y1) max++;\n\n }\n }\n Console.WriteLine(max);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "implementation"], "code_uid": "bf7b5f73c5a4f787d5d0cc96689197a1", "src_uid": "7bd5521531950e2de9a7b0904353184d", "difficulty": 1000.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 input = ReadLine();\r\n var result = 0;\r\n\r\n while (true)\r\n {\r\n foreach (var c in input)\r\n {\r\n result += int.Parse(c.ToString());\r\n }\r\n\r\n if (result > 9)\r\n {\r\n input = result.ToString();\r\n result = 0;\r\n }\r\n else\r\n break;\r\n }\r\n\r\n\t\t\tWriteLine(result);\r\n }\r\n }\r\n}\r\n", "lang_cluster": "C#", "tags": ["implementation", "number theory"], "code_uid": "80a013addf9e86c04b6b11c0e4fce5b8", "src_uid": "477a67877367dc68b3bf5143120ff45d", "difficulty": 1600.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 CFTraining.A_s\n{\n class ConsoleScanner\n {\n private string[] _line;\n private int _iterator;\n\n public ConsoleScanner()\n {\n _line = null;\n _iterator = 0;\n }\n\n public int NextInt()\n {\n if (_line == null || _iterator >= _line.Length)\n {\n _line = Console.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 = Console.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 public int Read()\n {\n return Console.Read();\n }\n public string ReadLine()\n {\n return Console.ReadLine();\n }\n }\n class GuestFromThePast342\n {\n public static void Main(string[] args)\n {\n ConsoleScanner sc = new ConsoleScanner();\n long n = sc.NextLong(), a = sc.NextLong(), b = sc.NextLong(), c = sc.NextLong(), liters = 0;\n if (b - c < a && n >= b)\n {\n long i = (n - b) / (b - c) + 1;\n liters += i;\n n -= i * (b - c);\n }\n liters += n / a;\n Console.WriteLine(liters);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "implementation"], "code_uid": "7d8ed1a7659725044004c5458069f620", "src_uid": "0ee9abec69230eab25de51aef0984f8f", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.IO;\nusing System.Linq;\nusing System.Collections.Generic;\nusing static System.Math;\n\nclass P\n{\n static void Main()\n {\n int n = Console.ReadLine().Split().Select(int.Parse).First();\n int[] aa = Console.ReadLine().Split().Select(int.Parse).ToArray();\n Dictionary adic = new Dictionary();\n for (int i = 0; i < aa.Length; i++)\n {\n if (!adic.ContainsKey(aa[i])) adic.Add(aa[i], 0);\n adic[aa[i]]++;\n }\n int[] a = adic.Values.ToArray();\n for (int i = 1; i <= int.MaxValue; i++)\n {\n if (a.Where(x => x >= i).Select(x => x / i).Sum() < n)\n {\n Console.WriteLine(i - 1);\n return;\n }\n }\n //Console.WriteLine(a.Length < n ? 0 : a.Min());\n }\n}", "lang_cluster": "C#", "tags": ["brute force", "implementation", "binary search"], "code_uid": "522e2a7c9259f60923e88e46b3da24ce", "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;\n\nnamespace AlgorithmTrainning\n{\n class Codeforce_set340A\n {\n static int GCD(int a, int b)// Greatest common divisions\n {\n if (a % b == 0) return b;\n return GCD(b, a % b);\n }\n\n static int LCM(int a, int b) //least common multiple\n {\n long ab = (long)a * b;\n return (int)(ab / GCD(Math.Max(a, b), Math.Min(a, b)));\n }\n\n\n static int x, y, lowRange, highRange;\n static void Main(String[] args)\n {\n String input = Console.ReadLine();\n String[] values = input.Split();\n x = int.Parse(values[0]);\n y = int.Parse(values[1]);\n lowRange = int.Parse(values[2]);\n highRange = int.Parse(values[3]);\n\n\n int leastCommonMultiple = LCM(x, y);\n int result = highRange / leastCommonMultiple - (lowRange - 1) / leastCommonMultiple;\n Console.WriteLine(result);\n\n\n }\n\n public Codeforce_set340A()\n {\n \n }\n\n\n }\n}\n", "lang_cluster": "C#", "tags": ["math"], "code_uid": "d055bf86a01bd0258e647195c18e755f", "src_uid": "c7aa8a95d5f8832015853cffa1374c48", "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.Diagnostics;\n\nnamespace CodeForces\n{\n class Program\n {\n static void Main(string[] args)\n {\n long n, m, k;\n Input.Next(out n, out m, out k);\n long output = CutChololate(n, m, k);\n Console.WriteLine(output);\n }\n\n public static long CutChololate(long n, long m, long k)\n {\n if (k >= n + m - 1)\n {\n return -1; \n }\n\n long area1;\n if (k >= n)\n {\n area1 = m / (k - n + 2);\n }\n else\n {\n area1 = n / (k + 1) * m;\n }\n\n long area2;\n if (k >= m)\n {\n area2 = n / (k - m + 2);\n }\n else\n {\n area2 = m / (k + 1) * n;\n }\n\n return Math.Max(area1, area2);\n }\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 bool Next(out int a)\n {\n var ok = Next();\n a = ok ? int.Parse(_line) : 0;\n return ok;\n }\n\n public static bool Next(out int a, out int b)\n {\n var ok = Next();\n if (ok)\n {\n var array = _line.Split(' ').Select(int.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 int a, out int b, out int c)\n {\n var ok = Next();\n if (ok)\n {\n var array = _line.Split(' ').Select(int.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 int a, out int b, out int c, out int d)\n {\n var ok = Next();\n if (ok)\n {\n var array = _line.Split(' ').Select(int.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 int a, out int b, out int c, out int d, out int e)\n {\n var ok = Next();\n if (ok)\n {\n var array = _line.Split(' ').Select(int.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 bool Next(out int a, out int b, out int c, out int d, out int e, out int f)\n {\n var ok = Next();\n if (ok)\n {\n var array = _line.Split(' ').Select(int.Parse).ToArray();\n a = array[0];\n b = array[1];\n c = array[2];\n d = array[3];\n e = array[4];\n f = array[5];\n }\n else\n {\n a = b = c = d = e = f = 0;\n }\n return ok;\n }\n\n public static IEnumerable ArrayLong()\n {\n return !Next() ? new List() : _line.Split().Select(long.Parse);\n }\n\n public static IEnumerable ArrayInt()\n {\n return !Next() ? new List() : _line.Split().Select(int.Parse);\n }\n\n public static int[,] GetMatrix(int rows, int cols)\n {\n int[,] matrix = new int[rows, cols];\n int row = 0;\n int col = 0;\n while (row < rows && Next())\n {\n IEnumerable numbers = _line.Split().Select(int.Parse);\n IEnumerator iter = numbers.GetEnumerator();\n while (iter.MoveNext())\n {\n matrix[row, col++] = iter.Current;\n }\n row++;\n col = 0;\n }\n return matrix;\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\n}\n", "lang_cluster": "C#", "tags": ["greedy", "implementation"], "code_uid": "707390dfb75f60e323dd289839772110", "src_uid": "bb453bbe60769bcaea6a824c72120f73", "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 int N, K;\n sc.Make(out N, out K);\n ModInt.Build(K + 1);\n var F = new ModInt[K + 2];\n for (int i = 1; i < K + 2; i++)\n {\n F[i] = ModInt.Pow(i, K) + F[i - 1];\n }\n if (N <= K + 1) Fail(F[N]);\n WriteLine(LagrangePolynomial(F, N));\n }\n public ModInt LagrangePolynomial(ModInt[] Y,int T,int a=0,int d = 1)\n {\n if (T < Y.Length) return Y[T];\n ModInt[] left = new ModInt[Y.Length], right = new ModInt[Y.Length];\n left[0] = right[Y.Length - 1] = 1;\n for (int i = 0; i < Y.Length-1; i++)\n {\n left[i + 1] = left[i] * (T - a - d * i);\n }\n for (int i = Y.Length - 2; i >= 0; i--)\n {\n right[i] = right[i + 1] * (T - a - d * (i + 1));\n }\n ModInt res = 0;\n for (int i = 0; i < Y.Length; i++)\n {\n ModInt r = Y[i] * left[i] * right[i] * ModInt.FacInv(i) * ModInt.FacInv(Y.Length - i - 1);\n if ((Y.Length - i - 1) % 2 == 0) res += r;\n else res -= r;\n }\n return 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"], "code_uid": "1969931faa11e156a3fb8144223da4c2", "src_uid": "6f6fc42a367cdce60d76fd1914e73f0c", "difficulty": 2600.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "//http://codeforces.ru/contest/236/problem/C\nusing System;\n\nnamespace TaskForNOK\n{\n class Program\n {\n static void Main()\n {\n\n Int64 number = Int64.Parse(Console.ReadLine());\n\n Int64 ans = 1;\n\n if (number < 3)\n {\n Console.WriteLine(number);\n return;\n }\n for (Int64 i = max(1,number-40); i <= number; i +=1 ) \n {\n for (Int64 j = max(1,number-40); j <= number; j+=1 )\n {\n Int64 per1 = NOK(i,j);\n for (Int64 k = max(1,number-40); k <= number; k+=1 ) \n {\n Int64 per2 = NOK(per1,k);\n if (per2 > ans)\n {\n ans = per2;\n }\n }\n }\n }\n\n Console.WriteLine(ans);\n \n }\n static Int64 max(Int64 a, Int64 b){\n if (a>b) return a; else return b;\n } \n static Int64 NOK( Int64 a, Int64 b) \n {\n Int64 num = a * b;\n\n while ((a != 0)&&(b != 0))\n {\n if (a > b)\n {\n a = a % b;\n }\n else \n {\n b = b % a;\n }\n }\n\n return (num / (a + b));\n }\n }\n}", "lang_cluster": "C#", "tags": ["number theory"], "code_uid": "190262c0d5169fc8588004d3a18d87c5", "src_uid": "25e5afcdf246ee35c9cef2fcbdd4566e", "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 _253b\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 = Console.ReadLine();\n var k = readInt();\n\n var l = d.Length;\n var max = l + k;\n var grant = k / 2;\n\n var maxi = max / 2;\n for (int i = maxi; i >= 0; i--)\n {\n var cm = i * 2;\n for (int s = 0; s < l; s++)\n {\n var can = true;\n if (cm + s - 1 > max - 1)\n {\n continue;\n }\n\n for (int j = 0; j < i; j++)\n {\n var cur = s + j;\n var next = cur + i;\n if (next >= l)\n {\n break;\n }\n\n if (d[cur] != d[next])\n {\n can = false;\n break;\n }\n }\n\n if (can && i * 2 > grant * 2)\n {\n Console.WriteLine(i * 2);\n return;\n }\n }\n }\n\n Console.WriteLine(grant);\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", "strings", "implementation"], "code_uid": "1649b92f370ae1184ce3b673d5fcc3dd", "src_uid": "bb65667b65ff069a9c0c9e8fe31da8ab", "difficulty": 1500.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;\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 const int MAX = 4000;\n const int MOD = 1000000007;\n\n void Solve()\n {\n // OEIS A005493\n // a(n+1) = 1 + sum { j=1, n, (1+binomial(n, j))*a(j) }\n\n var c = new int[MAX + 1, MAX + 1];\n for (int i = 1; i <= MAX; i++)\n for (int j = 1; j <= i; j++)\n {\n if (i == j)\n c[i, j] = 1;\n else if (j == 1)\n c[i, j] = i;\n else\n c[i, j] = (c[i - 1, j] + c[i - 1, j - 1]) % MOD;\n }\n\n var a = new long[MAX + 1];\n a[1] = 1;\n a[2] = 3;\n a[3] = 10;\n for (int i = 4; i <= MAX; i++)\n {\n a[i] = 1;\n for (int j = 1; j < i; j++)\n a[i] = (a[i] + (1 + c[i - 1, j]) * a[j]) % MOD;\n }\n\n Write(a[ReadInt()]);\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": ["brute force", "math", "dp"], "code_uid": "d8c83e26b08cc316a31dda0b3f71897c", "src_uid": "aa2c3e94a44053a0d86f61da06681023", "difficulty": 1900.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\nclass Program\n{\n public class SegmentTreeAssignSum\n {\n int n;\n int h;\n int[] t;\n int[] d;\n\n public SegmentTreeAssignSum(int capacity)\n {\n this.n = capacity;\n this.t = new int[capacity + capacity];\n this.d = new int[capacity + capacity];\n this.h = 1;\n while (this.h < capacity) this.h *= 2;\n if (h > capacity) h /= 2;\n }\n\n private void Calc(int p, int k)\n {\n if (d[p] == 0)\n t[p] = t[p << 1] + t[p << 1 | 1];\n else\n t[p] = d[p] * k;\n }\n\n private void Apply(int p, int value, int k)\n {\n t[p] = value * k;\n if (p < n)\n {\n d[p] = value;\n }\n }\n\n private void Build(int l, int r)\n {\n int k = 2;\n for (l += n, r += n - 1; l > 1; k <<= 1)\n {\n l >>= 1;\n r >>= 1;\n for (int i = r; i >= l; --i)\n this.Calc(i, k);\n }\n }\n\n private void Push(int l, int r)\n {\n int s = h, k = 1 << (h - 1);\n for (l += n, r += n - 1; s > 0; --s, k >>= 1)\n for (int i = l >> s; i <= r >> s; ++i)\n if (d[i] != 0)\n {\n this.Apply(i << 1, d[i], k);\n this.Apply(i << 1 | 1, d[i], k);\n d[i] = 0;\n }\n }\n\n public void Modify(int l, int r, int value)\n {\n r++;\n if (value == 0) return;\n this.Push(l, l + 1);\n this.Push(r - 1, r);\n int l0 = l, r0 = r, k = 1;\n for (l += n, r += n; l < r; l >>= 1, r >>= 1, k <<= 1)\n {\n if (l % 2 == 1) this.Apply(l++, value, k);\n if (r % 2 == 1) this.Apply(--r, value, k);\n }\n this.Build(l0, l0 + 1);\n this.Build(r0 - 1, r0);\n }\n\n public int GetSum(int l, int r)\n {\n r++;\n this.Push(l, l + 1);\n this.Push(r - 1, r);\n int result = 0;\n for (l += n, r += n; l < r; l >>= 1, r >>= 1)\n {\n if (l % 2 == 1) result += t[l++];\n if (r % 2 == 1) result += t[--r];\n }\n return result;\n }\n }\n\n\n public class SegmentTree2\n {\n private int Mid = 1024 * 128;\n private int[] t;\n private int[] d;\n\n public SegmentTree2(int[] a)\n {\n this.Mid = 1;\n while (Mid < a.Length) Mid *= 2;\n this.t = new int[Mid + Mid];\n this.d = new int[Mid + Mid];\n\n for (int i = 0; i < a.Length; i++) t[Mid + i] = a[i];\n for (int i = Mid - 1; i > 0; i--)\n t[i] = t[i + i] + t[i + i + 1];\n }\n\n private void push(int v)\n {\n if (t[v] != -1)\n {\n t[v * 2] = t[v * 2 + 1] = t[v];\n t[v] = -1;\n }\n }\n\n public void update(int v, int tl, int tr, int l, int r, int color)\n {\n if (l > r)\n return;\n if (l == tl && tr == r)\n t[v] = color;\n else\n {\n push(v);\n int tm = (tl + tr) / 2;\n update(v * 2, tl, tm, l, Math.Min(r, tm), color);\n update(v * 2 + 1, tm + 1, tr, Math.Max(l, tm + 1), r, color);\n }\n }\n\n public int get(int v, int tl, int tr, int pos)\n {\n if (tl == tr)\n return t[v];\n push(v);\n int tm = (tl + tr) / 2;\n if (pos <= tm)\n return get(v * 2, tl, tm, pos);\n else\n return get(v * 2 + 1, tm + 1, tr, pos);\n }\n\n }\n\n\n public class AssignmentBf\n {\n private int[] t;\n public AssignmentBf(int capacity)\n {\n this.t = new int[capacity];\n }\n\n public void Modifu(int l, int r, int v)\n {\n for (int i = l; i <= r; i++) t[i] = v;\n }\n\n public int GetSum(int l, int r)\n {\n int sum = 0;\n for (int i = l; i <= r; i++) sum += t[i];\n return sum;\n }\n\n public int GetMax(int l, int r)\n {\n int max = t[l];\n for (int i = l; i <= r; i++)\n max = Math.Max(max, t[i]);\n return max;\n }\n }\n\n private static StringBuilder sb = new StringBuilder();\n private static bool Can(long x, long y, bool reverse = false)\n {\n if (x > y) return Can(y, x, true);\n if (x == 0) sb.Append(y + (reverse ? \"A\" : \"B\"));\n if (x == 0) return true;\n if (x == y) return false;\n sb.Append((y / (x + 1)) + (reverse ? \"A\" : \"B\"));\n return Can(y % (x + 1), x, !reverse);\n }\n\n static void Main(string[] args)\n {\n long x = ReadLong();\n long y = ReadLong();\n if (!Can(x - 1, y - 1))\n Console.WriteLine(\"Impossible\");\n else\n Console.Write(sb.ToString());\n\n /*\n int[] b = new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };\n\n var st3 = new SegmentTree2(b);\n\n var q1 = st3.get(6, 9);\n st3.get(9, 9, 8);\n var q2 = st3.get(6, 9);\n st3.get(9, 9, 1);\n var q3 = st3.get(6, 9);\n\n st3.Update(3, 7, 9);\n\n st3.Print();\n\n int id = 0;\n int maxValue = 10;\n int size = 10;\n\n while (true)\n {\n id++;\n\n var x = new Random();\n int[] a = new int[size];\n for (int i = 0; i < a.Length; i++) a[i] = x.Next(maxValue);\n\n //int[] a = new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9 };\n var st2 = new SegmentTree2(a);\n var bf = new AssignmentBf(a.Length);\n for (int i = 0; i < a.Length; i++) bf.Modifu(i, i, a[i]);\n\n for (int i = 0; i < 100000; i++)\n {\n int l = x.Next(a.Length);\n int r = x.Next(l, a.Length);\n if (x.Next(5) == 1)\n {\n int v = x.Next(maxValue);\n st2.Update(l, r, v);\n bf.Modifu(l, r, v);\n }\n else\n {\n var s1 = st2.GetSum(l, r);\n var s2 = bf.GetSum(l, r);\n if (s1 != s2)\n {\n Console.WriteLine(\"WRONG\");\n }\n }\n }\n\n */\n //Console.WriteLine(\"COMPLETED \" + id++);\n //}\n\n\n\n /*\n Verify(\"abcde\", \"a\", false);\n Verify(\"abcde\", \"a%\", true);\n Verify(\"abcde\", \"%a\", false);\n Verify(\"abcde\", \"b\", false);\n Verify(\"abcde\", \"b%\", false);\n Verify(\"abcde\", \"%b\", false);\n\n Verify(\"25%\", \"_5[%]\", true);\n Verify(\"_52\", \"_5[%]5%\", true);\n\n Verify(\"ab\", \"a[a-cdf]]\", true);\n Verify(\"ad\", \"a[a-cdf]\", true);\n Verify(\"ab\", \"a[-acdf]\", false);\n Verify(\"a-\", \"a[-acdf]\", true);\n\n Verify(\"[]\", \"'[[]]\", true);\n Verify(\"''\", \"_'\", true);\n Verify(\"U\", \"[^a-zA-Z0-9]\", false);\n */\n /*\n int n = ReadInt();\n int[] m = ReadIntArray(n);\n\n double x = -10000;\n double vx = Value(m, x);\n double prevVx = vx;\n double step = 1000;\n int iteration = 0;\n while (iteration < 228)\n {\n iteration++;\n double next = Value(m, x + step);\n if (next <= vx)\n {\n prevVx = vx;\n vx = next;\n x += step;\n }\n else\n {\n x -= step;\n vx = prevVx;\n step = step / 2;\n }\n }\n\n Console.WriteLine(vx.ToString().Replace(',', '.'));*/\n }\n\n private static List[] ReadGraph()\n {\n int n = ReadInt();\n int m = ReadInt();\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 g[a].Add(b);\n g[b].Add(a);\n }\n\n return g;\n }\n\n private static int[] ReadIntArray()\n {\n string[] tmp = Console.ReadLine().Split(' ');\n int[] ans = new int[tmp.Length];\n for (int i = 0; i < tmp.Length; i++) ans[i] = int.Parse(tmp[i]);\n return ans;\n }\n\n private static long[] ReadLongArray()\n {\n string[] tmp = Console.ReadLine().Split(' ');\n long[] ans = new long[tmp.Length];\n for (int i = 0; i < tmp.Length; i++) ans[i] = long.Parse(tmp[i]);\n return ans;\n }\n\n private static string[] ReadStringArray()\n {\n string[] tmp = Console.ReadLine().Split(' ');\n return tmp;\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 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(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\n", "lang_cluster": "C#", "tags": ["number theory"], "code_uid": "91fb9ee3cdc876975c2581c16af45484", "src_uid": "6a9ec3b23bd462353d985e0c0f2f7671", "difficulty": 2400.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\n class Program\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 int weights = int.Parse(Console.ReadLine());\n int[] masses = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();\n int[] cnt = new int[101];\n foreach (int mass in masses)\n {\n cnt[mass]++;\n }\n int nonZero = 0;\n for (int i = 1; i <= 100; i++)\n {\n if (cnt[i] > 0)\n {\n nonZero++;\n }\n }\n if (nonZero <= 2)\n {\n Console.WriteLine(weights);\n return;\n }\n\n int[,] C = new int[101, 101];\n C[0, 0] = 1;\n for (int i = 1; i <= 100; i++)\n {\n C[i, 0] = C[i, i] = 1;\n for (int j = 1; j < i; j++)\n {\n C[i, j] = (C[i - 1, j] + C[i - 1, j - 1]) % MOD;\n }\n }\n\n\n int sum = masses.Sum();\n int[,] ways = new int[weights + 1, sum + 1];\n ///\n /// dp(i, j, k) = dp(i - 1, j - 1, k - masses[j])\n ///\n\n ways[0, 0] = 1;\n for (int i = 0; i < weights; i++)\n {\n int[,] nways = new int[weights + 1, sum + 1];\n nways[0, 0] = 1;\n for (int j = 1; j <= i + 1; j++)\n {\n for (int k = sum; k > 0; k--)\n {\n nways[j, k] = ways[j, k];\n if (k >= masses[i])\n {\n nways[j, k] = (nways[j, k] + ways[j - 1, k - masses[i]]) % MOD;\n }\n }\n }\n \n ways = nways;\n }\n \n\n int ans = 1;\n for (int i = 1; i <= 100; i++)\n {\n if (cnt[i] > 0)\n {\n for (int j = i; j <= sum; j += i)\n {\n if (j / i <= weights && ways[j / i, j] > 0 && ways[j / i, j] == C[cnt[i], j / i])\n {\n ans = Math.Max(ans, j / i);\n }\n }\n }\n }\n\n Console.WriteLine(ans);\n\n\n }\n\n }\n\n}\n", "lang_cluster": "C#", "tags": ["math", "dp"], "code_uid": "951b17378ba59c562a936a941ea66e6f", "src_uid": "ccc4b27889598266e8efe73b8aa3666c", "difficulty": 2100.0, "exec_outcome": "PASSED"} {"lang": "MS 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 void Solve()\n\t\t{\n\t\t\tvar board = new List();\n\t\t\tfor (var i = 0; i < 8; i++)\n\t\t\t{\n\t\t\t\tboard.Add(cin.NextString());\n\t\t\t}\n\t\t\tvar bestW = int.MaxValue; // a white up\n\t\t\tvar bestB = int.MaxValue;\n\t\t\tfor (var i = 0; i < 8; i++) // col\n\t\t\t{\n\t\t\t\tvar w = new List();\n\t\t\t\tvar b = new List();\n\t\t\t\tfor (var j = 0; j < 8; j++) // row\n\t\t\t\t{\n\t\t\t\t\tif (board[j][i] == 'W')\n\t\t\t\t\t{\n\t\t\t\t\t\tw.Add(j);\n\t\t\t\t\t}\n\t\t\t\t\tif (board[j][i] == 'B')\n\t\t\t\t\t{\n\t\t\t\t\t\tb.Add(j);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (w.Any())\n\t\t\t\t{\n\t\t\t\t\tvar pos = w.Min();\n\t\t\t\t\tif (!b.Any(x => x < pos))\n\t\t\t\t\t{\n\t\t\t\t\t\tbestW = Math.Min(bestW, pos);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (b.Any())\n\t\t\t\t{\n\t\t\t\t\tvar pos = b.Max();\n\t\t\t\t\tif (!w.Any(x => x > pos))\n\t\t\t\t\t{\n\t\t\t\t\t\tbestB = Math.Min(bestB, 8 - pos - 1);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (bestB < bestW)\n\t\t\t{\n\t\t\t\tConsole.WriteLine(\"B\");\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tConsole.WriteLine(\"A\");\n\t\t\t}\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\tConsole.SetIn(new StreamReader(@\"..\\..\\input.txt\"));\n#endif\n\t\t\tnew Template().Solve();\n\t\t\tConsole.ReadLine();\n#if DEBUG\n\t\t\tConsole.ReadKey();\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": ["implementation"], "code_uid": "33a73a6bcdbd522343903cfcf034503e", "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 ConsoleApp14\n{\n class Program\n {\n static void Main(string[] args)\n {\n ulong n = ulong.Parse(Console.ReadLine());\n if (n%2==0)\n {\n if (n % 4 == 0)\n {\n Console.WriteLine((n / 4) - 1);\n }\n else\n {\n Console.WriteLine(n / 4);\n }\n }\n else\n {\n Console.WriteLine(0);\n }\n \n\n\n\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "combinatorics"], "code_uid": "6701d69606ea44a82b1570815555c022", "src_uid": "32b59d23f71800bc29da74a3fe2e2b37", "difficulty": 1000.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 //var num = Console.ReadLine().Split().Select(int.Parse).ToArray();\n\n string s = Console.ReadLine();\n\n\n\n string pro = \"\";\n string dom = \"\";\n string con = \"\";\n int i = 0;\n if(s[0]=='f')\n {\n pro = \"ftp\";\n i = 3;\n }\n else\n {\n pro = \"http\";\n i = 4;\n }\n\n\n int ind = s.IndexOf(\"ru\",i+1);\n \n\n dom = s.Substring(i,(ind-i)) ;\n con = s.Substring(pro.Length+dom.Length+2);\n if (con.Length > 0) con = \"/\" + con;\n \n\n\n Console.WriteLine(string.Format(\"{0}://{1}.ru{2}\",pro,dom,con));\n\n\n\n\n\n \n\n }\n\n \n\n }\n\n\n}\n", "lang_cluster": "C#", "tags": ["strings", "implementation"], "code_uid": "3495fbedfd9a6dea44ea1efe06d1f1e9", "src_uid": "4c999b7854a8a08960b6501a90b3bba3", "difficulty": 1100.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 b11b\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 x = readInt();\n if (x == 0)\n {\n Console.WriteLine(\"0\");\n return;\n }\n\n x = Math.Abs(x);\n var res = 0;\n var s = 1;\n var total = 0;\n while (true)\n {\n if (total + s >= x)\n {\n break;\n }\n else\n {\n total += s;\n s++;\n res++;\n }\n }\n\n //if (total + s == x)\n //{\n // Console.WriteLine(res + 1);\n // return;\n //}\n\n total += s;\n s++;\n res++;\n if (total == x)\n {\n Console.WriteLine(res);\n return;\n }\n\n var rem = total - x;\n if (rem % 2 == 0)\n {\n Console.WriteLine(res);\n return;\n }\n\n total += s;\n rem = total - x;\n if (rem % 2 == 0)\n {\n Console.WriteLine(res + 1);\n }\n else\n {\n Console.WriteLine(res + 2);\n }\n\n //var down = x - total;\n //var up = total + s - x;\n \n //if (up >= down)\n //{\n // res += 2 * down;\n //}\n //else\n //{\n // res += 2 * up;\n // res++;\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 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"], "code_uid": "0273512e884c6a29ac4a054cba574d10", "src_uid": "18644c9df41b9960594fdca27f1d2fec", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\n\nnamespace CSharp\n{\n class _976B\n {\n public static void Main()\n {\n var tokens = Console.ReadLine().Split();\n\n long n = long.Parse(tokens[0]);\n long m = long.Parse(tokens[1]);\n long k = long.Parse(tokens[2]);\n\n if (k < n)\n {\n Console.WriteLine($\"{1 + k} 1\");\n }\n else\n {\n k -= n;\n m--;\n\n long row = n - k / m;\n long column = (n - row) % 2 == 0 ? 2 + k % m : m + 1 - k % m;\n\n Console.WriteLine($\"{row} {column}\");\n }\n }\n }\n}", "lang_cluster": "C#", "tags": ["math", "implementation"], "code_uid": "768bd7959684302bf704731a28ac7222", "src_uid": "e88bb7621c7124c54e75109a00f96301", "difficulty": 1300.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 _10a\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 h1 = d[0];\n var h2 = d[1];\n\n d = readIntArray();\n var a = d[0];\n var b = d[1];\n var up = (22 - 14 + 14 - 10) * a;\n var down = (10 + 2) * b;\n\n //var diff = h2 - h1;\n //if (diff <= 8 * a)\n //{\n // Console.WriteLine(0);\n // return;\n //}\n\n var dc = 0;\n var pos = h1 + 8 * a;\n while (true)\n {\n if (pos >= h2)\n {\n Console.WriteLine(dc);\n return;\n }\n\n if (12 * a <= 12 * b)\n {\n Console.WriteLine(-1);\n return;\n }\n\n pos -= 12 * b;\n pos += 12 * a;\n dc++;\n }\n\n //if (down >= up)\n //{\n // Console.WriteLine(-1);\n // return;\n //}\n\n //var di = up - down;\n //var count = diff / di;\n //var rem = diff % di;\n //if (rem <= 8 * a)\n //{\n // Console.WriteLine(count);\n // return;\n //}\n //else\n //{\n // Console.WriteLine(count + 1);\n // return;\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": ["math", "implementation"], "code_uid": "108d1e12b3c4a8de3f9eeacd69aaab5b", "src_uid": "2c39638f07c3d789ba4c323a205487d7", "difficulty": 1400.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[] s = sc.IntArray();\n\n\n int ans = 0;\n int cnt = 0;\n int one = s.Count(num => num == 1);\n for (int i = 0; i < n; i++)\n {\n if (s[i] == 1)\n {\n ans = Math.Max(ans, cnt + one);\n one--;\n }\n else\n {\n cnt++;\n }\n }\n\n ans = Math.Max(ans, cnt);\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": ["brute force", "implementation"], "code_uid": "17abef1f3bc7e632388db4d7ca240f4c", "src_uid": "c7b1f0b40e310f99936d1c33e4816b95", "difficulty": 1500.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\tvar x = int.Parse(Console.ReadLine());\n\t\t\n\t\tfor(var i = (int)Math.Sqrt(x); i>=2; i--)\n\t\t{\n\t\t\tvar y = x%i;\n\t\t\tif(y == 0)\n\t\t\t{\n\t\t\t\tConsole.Write(i);\n\t\t\t\tConsole.WriteLine(x/i);\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t}\n}", "lang_cluster": "C#", "tags": ["math", "number theory"], "code_uid": "8f0b08fa104b156191566bdb8f425497", "src_uid": "7220f2da5081547a12118595bbeda4f6", "difficulty": null, "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@\"\n5 3 2\nto head\n0001001\n\"\n,\n@\"\n3 2 1\nto tail\n0001\n\"\n });\n\n public void Solve()\n {\n var ss = CF.ReadLine().Split(' ');\n int n = int.Parse(ss[0]);\n int m = int.Parse(ss[1]);\n int k = int.Parse(ss[2]);\n\n int dir = 1;\n if( CF.ReadLine() == \"to head\" )\n dir = -1;\n\n var s = CF.ReadLine();\n for (int i = 0; i < s.Length; i++)\n {\n if (i == s.Length - 1)\n {\n CF.WriteLine(\"Stowaway\");\n return;\n }\n\n k += dir;\n if (k < 1)\n {\n k = 2;\n dir = +1;\n }\n if (k > n)\n {\n k = n - 1;\n dir = -1;\n }\n\n if (s[i] == '1')\n {\n if (dir == 1)\n m = 1;\n else\n m = n;\n }\n else\n {\n if (m == k)\n {\n if (m == 1 || m == n)\n {\n CF.WriteLine(\"Controller \" + (i + 1));\n return;\n }\n m += dir;\n }\n }\n }\n\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": ["greedy", "dp", "games"], "code_uid": "9a2ba2ca0a427e6bff9615061df99c0a", "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 C\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])-1;\n int m = int.Parse(s[1]);\n int a = int.Parse(s[2])-1;\n int b = int.Parse(s[3])-1;\n int res;\n if (b != n)\n {\n if (a / m == b / m) res = 1;\n else\n if (a / m == b / m - 1)\n if (a % m == 0 && b % m == m - 1) res = 1;\n else res = 2;\n else\n if (a % m == 0 && b % m == m - 1) res = 1;\n else\n if (a % m == 0 || b % m == m - 1 || a % m == b % m + 1) res = 2;\n else res = 3;\n }\n else\n {\n if (a / m == b / m || a % m == 0) res = 1;\n else res = 2;\n }\n Console.WriteLine(res);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math"], "code_uid": "66c269e25074e62b08aa8d8c93e977af", "src_uid": "f256235c0b2815aae85a6f9435c69dac", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Linq;\nclass Program\n{\n static void Main()\n {\n var _ = Console.ReadLine().Split().Select(int.Parse).ToArray();\n var n = _[0];\n var m = _[1];\n var a = Console.ReadLine();\n var b = Console.ReadLine();\n if ((a[0] == '>' && b[0] == 'v') || (a[0] == '<' && b[m - 1] == 'v') || (a[n - 1] == '>'\n && b[0] == '^') || (a[n - 1] == '<' && b[m - 1] == '^'))\n Console.WriteLine(\"NO\");\n else Console.WriteLine(\"YES\");\n }\n}", "lang_cluster": "C#", "tags": ["dfs and similar", "implementation", "graphs", "brute force"], "code_uid": "3f68dac7105ef451f469adc6e2893870", "src_uid": "eab5c84c9658eb32f5614cd2497541cf", "difficulty": 1400.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 avC\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 mod = 998244353;\n var d = ReadIntArray();\n var n = d[0];\n var m = d[1];\n var k = d[2];\n var cc = k + 1;\n var dp = new int[n + 1, cc + 1];\n dp[1, 1] = 1;\n for (int i = 2; i < n + 1; i++)\n {\n for (int j = 1; j < cc + 1; j++)\n {\n if (j > i)\n {\n break;\n }\n\n dp[i, j] = dp[i - 1, j];\n if (j > 1)\n {\n dp[i, j] += dp[i - 1, j - 1];\n dp[i, j] %= mod;\n }\n }\n }\n\n var res = dp[n, cc];\n long vs = m;\n for (int i = 0; i < cc - 1; i++)\n {\n vs *= (m - 1);\n vs %= mod;\n }\n\n vs *= res;\n vs %= mod;\n\n Console.WriteLine(vs);\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": ["math", "dp", "combinatorics"], "code_uid": "8f3b062e1ceabe7b4e59d3e9301012f5", "src_uid": "b2b9bee53e425fab1aa4d5468b9e578b", "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\tList L = new List();\n\t\tint NN = N;\n\t\tint b = 1;\n\t\twhile(NN >= b){\n\t\t\tL.Add(b);\n\t\t\tNN -= b;\n\t\t\tb *= 2;\n\t\t}\n\t\tif(NN > 0) L.Add(b);\n\t\tConsole.WriteLine(L.Count);\n\t\t\n\t}\n\tint N;\n\tpublic Sol(){\n\t\tN = ri();\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", "greedy", "constructive algorithms"], "code_uid": "2116f405e42002417847ad47b7c3ffc3", "src_uid": "95cb79597443461085e62d974d67a9a0", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Text;\n\nnamespace task94A\n{\n class Program\n {\n static void Main(string[] args)\n {\n string password = Console.ReadLine();\n short dim = 10;\n Dictionary symbols = new Dictionary();\n for (short i = 0; i < dim; i++)\n {\n symbols.Add(Console.ReadLine(), i);\n }\n string temp = string.Empty;\n for (short i = 0; i < password.Length; i++)\n {\n temp += password[i];\n if ((i + 1) % 10 == 0)\n {\n Console.Write(symbols[temp]);\n temp = string.Empty;\n }\n }\n ////Console.ReadLine();\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["strings", "implementation"], "code_uid": "663e301848cfdea0d41884a663ab7bd3", "src_uid": "0f4f7ca388dd1b2192436c67f9ac74d9", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "C# 8", "source_code": "using System;\r\nusing static System.Console;\r\nusing System.Linq;\r\nusing System.Collections.Generic;\r\n\r\nclass Program\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 = ReadLine().Split();\r\n var n = int.Parse(c[0]);\r\n var x = decimal.Parse(c[1]);\r\n var list = new List();\r\n list.Add(x);\r\n var res = 0;\r\n while (true)\r\n {\r\n var next = new List();\r\n foreach (var li in list)\r\n {\r\n var str = li.ToString();\r\n if (str.Length == n)\r\n {\r\n WriteLine(res);\r\n return;\r\n }\r\n for (var i = '2'; i <= '9'; ++i) if (str.Contains(i))\r\n {\r\n next.Add(li * (i - '0'));\r\n }\r\n }\r\n if (next.Count == 0)\r\n {\r\n WriteLine(-1);\r\n return;\r\n }\r\n var max = next.Max();\r\n if (next.Count > 10000)\r\n {\r\n next.Sort();\r\n next = next.Skip(next.Count - 10000).ToList();\r\n }\r\n list = next;\r\n ++res;\r\n }\r\n }\r\n}", "lang_cluster": "C#", "tags": ["brute force", "dfs and similar", "shortest paths", "dp", "data structures"], "code_uid": "ed3d2f49ac08541c13bf00401007d61a", "src_uid": "cedcc3cee864bf8684148df93804d029", "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.Text.RegularExpressions;\nusing System.Threading.Tasks;\n\nnamespace Ser\n{\n class Program\n {\n static void Main(string[] args)\n {\n long N = long.Parse(Console.ReadLine());\n long val = GetValueToSubtract(N);\n Console.WriteLine(Sums(N - val) + Sums(val));\n }\n \n\n static long Sums(long c)\n {\n return c.ToString().ToCharArray().Select(x => long.Parse(x.ToString())).Sum();\n }\n\n static long GetValueToSubtract(long value)\n {\n if (value < 10)\n return 0;\n \n return Int64.Parse(String.Join(\"\", value.ToString().ToCharArray().Skip(1).Select(s => s.ToString()).ToList())) + 1;\n }\n\n }\n}\n", "lang_cluster": "C#", "tags": ["greedy"], "code_uid": "f2770938e5ba6d0cffca6c6bdc677335", "src_uid": "5c61b4a4728070b9de49d72831cd2329", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\n\nclass Program\n{\n public static int GCD(int n1, int n2)\n {\n int temp;\n\n while (n2 != 0)\n {\n temp = n1 % n2;\n n1 = n2;\n n2 = temp;\n }\n\n return n1;\n }\n\n public static void Main()\n {\n //Read values\n int screenW, screenH, movieW, movieH;\n string[] line = Console.ReadLine().Split(' ');\n screenW = int.Parse(line[0]);\n screenH = int.Parse(line[1]);\n movieW = int.Parse(line[2]);\n movieH = int.Parse(line[3]);\n\n int newScreenW, newScreenH, newMovieW, newMovieH, gcd;\n\n //Full width\n newScreenW = screenW * movieW;\n newScreenH = screenH * movieW;\n newMovieW = screenW * movieW;\n newMovieH = screenW * movieH;\n //if it works\n if (newMovieH <= newScreenH)\n {\n gcd = GCD(newScreenH-newMovieH, newScreenH);\n Console.WriteLine(\"{0}/{1}\", (newScreenH-newMovieH) / gcd, newScreenH / gcd);\n return;\n }\n\n //Full Height\n newScreenW = screenW * movieH;\n newScreenH = screenH * movieH;\n newMovieW = screenH * movieW;\n newMovieH = screenH * movieH;\n gcd = GCD(newScreenW-newMovieW, newScreenW);\n Console.WriteLine(\"{0}/{1}\", (newScreenW-newMovieW) / gcd, newScreenW / gcd);\n }\n}", "lang_cluster": "C#", "tags": ["math", "greedy", "number theory"], "code_uid": "7d7eea33671a06608d944f9ec5cc869c", "src_uid": "b0f435fc2f7334aee0d07524bc37cb1e", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nclass Program\n {\n static void Main(string[] args)\n {\n double tn, k, m;\n {\n string[] input = Console.In.ReadLine().Split(new char[] { ' ', '\\t'}, StringSplitOptions.RemoveEmptyEntries);\n k = int.Parse(input[1]);\n tn = 2D*(k + int.Parse(input[0]));\n }\n if (((m = Math.Floor(Math.Sqrt(tn)) - 1D) * m + m * 3D) > tn) --m;\n Console.WriteLine((m * m + m) / 2D - k);\n } \n }", "lang_cluster": "C#", "tags": ["brute force", "math", "binary search"], "code_uid": "2d613feaefba04382f8b7bb6687c1da6", "src_uid": "17b5ec1c6263ef63c668c2b903db1d77", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\n\npublic class Program\n{\n public static long pow(long n, long exp)\n {\n if (exp == 0)\n return 1;\n if (exp == 1)\n return n;\n\n long res = pow(n, exp / 2);\n res *= res;\n if (exp % 2 == 1)\n res *= n;\n\n return res % 1000000009;\n }\n\n public static void Main()\n {\n int n, m, k;\n string[] line = Console.ReadLine().Split(' ');\n n = int.Parse(line[0]);\n m = int.Parse(line[1]);\n k = int.Parse(line[2]);\n\n int maxAnswersWithoutDouble = n / k * (k - 1) + n % k;\n\n //If not double were needed\n if (maxAnswersWithoutDouble >= m)\n {\n Console.WriteLine(m);\n return;\n }\n\n //Doubles needed\n int countOfDouble = m - maxAnswersWithoutDouble;\n long res = m + (pow(2, countOfDouble + 1) - 2 - countOfDouble) * k;\n res = (res + 1000000009) % 1000000009;\n Console.WriteLine(res);\n }\n}", "lang_cluster": "C#", "tags": ["math", "binary search", "number theory", "greedy", "matrices"], "code_uid": "d650aacad3fa1c8b430fd23dc89f762b", "src_uid": "9cc1aecd70ed54400821c290e2c8018e", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Globalization;\nusing System.IO;\nusing System.Text;\n\nnamespace Guess_the_Tree\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 int n = int.Parse(reader.ReadLine());\n\n string[] ss = reader.ReadLine().Split(' ');\n int[] nn = new int[n];\n for (int i = 0; i < n; i++)\n {\n nn[i] = int.Parse(ss[i]);\n }\n\n Array.Sort(nn);\n\n bool[] used = new bool[n];\nbool ok = n==nn[n-1];\n if (ok)\n for (int i = 0; i < n; i++)\n {\n if (nn[i]>1)\n {\n int count = nn[i] - 1;\n int p = 0;\n for (int j = i; j >=0; j--)\n {\n if (!used[j] && nn[j]<=count)\n {\n if (p == 0 && nn[j] == count)\n continue;\n used[j] = true;\n count -= nn[j];\n p++;\n }\n if (count==0)\n break;\n }\n if (count!=0)\n {\n ok = false;\n break;\n }\n }\n }\n\n \n\n writer.WriteLine(\"{0}\", ok ? \"YES\" : \"NO\");\n writer.Flush();\n }\n }\n}", "lang_cluster": "C#", "tags": ["dfs and similar", "constructive algorithms", "data structures"], "code_uid": "351a79c6e9092ba3bcd39384e845c286", "src_uid": "ed0925cfaee961a3ceebd13b3c96a15a", "difficulty": 2300.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "// Problem: 628A - Tennis Tournament\n// Author: Gusztav Szmolik\n\nusing System;\n\nclass TennisTournament\n {\n static int Main ()\n {\n string[] words = ReadSplitLine (3);\n if (words == null)\n return -1;\n ushort n;\n if (!UInt16.TryParse (words[0], out n))\n return -1;\n if (n < 1 || n > 500)\n return -1;\n ushort b;\n if (!UInt16.TryParse (words[1], out b))\n return -1;\n if (b < 1 || b > 500)\n return -1;\n ushort p;\n if (!UInt16.TryParse (words[2], out p))\n return -1;\n if (p < 1 || p > 500)\n return -1;\n ushort k = 1;\n ushort kNext = 2;\n while (kNext <= n)\n {\n k = kNext;\n kNext *= 2;\n }\n ushort countMatch = Convert.ToUInt16 (k/2);\n ushort m = n;\n byte r = Convert.ToByte (m-k);\n while (k > 1)\n {\n m = Convert.ToUInt16 (k/2+r);\n while (k > m)\n k /= 2;\n countMatch += Convert.ToUInt16 (k/2);\n r = Convert.ToByte (m-k);\n }\n uint numBottle = Convert.ToUInt32 (countMatch*(2*b+1));\n uint numTowel = Convert.ToUInt32 (n*p);\n Console.WriteLine (\"{0} {1}\",numBottle,numTowel);\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", "implementation"], "code_uid": "bdc0092137767162c9075d652257592a", "src_uid": "eb815f35e9f29793a120d120968cfe34", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Runtime.InteropServices;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace _248\n{\n class Program\n {\n static void Main(string[] args)\n {\n int n = Convert.ToInt32(Console.ReadLine());\n string[] ss = Console.ReadLine().Split(' ');\n int sum1 = 0;\n int sum2 = 0;\n int []mas = new int[n]; \n for (int i = 0; i < n; i++)\n {\n mas[i] = Convert.ToInt32(ss[i]);\n }\n Array.Sort(mas);\n\n for (int i = n-1; i >= 0; i--)\n {\n if (sum1 > sum2)\n {\n sum2 += mas[i];\n }\n else sum1 += mas[i];\n }\n if (sum1==sum2) Console.WriteLine(\"YES\");\n else Console.WriteLine(\"NO\");\n }\n }\n }\n", "lang_cluster": "C#", "tags": ["brute force", "implementation"], "code_uid": "eeccd342e8b2503c820a4a43c0b94316", "src_uid": "9679acef82356004e47b1118f8fc836a", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\n\nnamespace cf328b\n{\n\tclass MainClass\n\t{\n\t\tpublic static void Main (string[] args)\n\t\t{\n\t\t\tchar[] nums = Console.ReadLine().ToCharArray();;\n\t\t\tchar[] digits = Console.ReadLine().ToCharArray();\n\t\t\tList sn = new List();\n\n\t\t\tList sd = new List();\n\n\t\t\tforeach (var num in nums) {\n\t\t\t\tif (num == '2' || num == '5')\n\t\t\t\t\tsn.Add('2');\n\t\t\t\telse \n\t\t\t\tif (num == '6' || num == '9')\n\t\t\t\t\tsn.Add('6');\n\t\t\t\telse\n\t\t\t\t\tsn.Add(num);\n\t\t\t}\n\n\t\t\tforeach (var num in digits) {\n\t\t\t\tif (num == '2' || num == '5')\n\t\t\t\t\tsd.Add('2');\n\t\t\t\telse\n\t\t\t\tif (num == '6' || num == '9')\n\t\t\t\t\tsd.Add('6');\n\t\t\t\telse \n\t\t\t\t\tsd.Add(num);\n\t\t\t}\n\n\t\t\tsn.Sort();\n\t\t\tsd.Sort();\n\n\t\t\tbool failed = false;\n\t\t\tint res = 0;\n\t\t\tdo\n\t\t\t{\n\t\t\t\tforeach (var c in sn) {\n\t\t\t\t\tint i = sd.BinarySearch(c);\n\t\t\t\t\tif (i >= 0)\n\t\t\t\t\t{\n\t\t\t\t\t\tsd[i] = 'z';\n\t\t\t\t\t\tsd.Sort();\n\t\t\t\t\t}\n\t\t\t\t\telse failed = true;\n\t\t\t\t}\n\t\t\t\tif (!failed)\n\t\t\t\t\tres++;\n\t\t\t}while (!failed);\n\n\t\t\tConsole.WriteLine(res);\n\t\t}\n\t}\n}\n", "lang_cluster": "C#", "tags": ["greedy"], "code_uid": "df98f07c7ecb6351a5fe8340c07def20", "src_uid": "72a196044787cb8dbd8d350cb60ccc32", "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 progr_challange_try\n{\n /*\n * The Little Elephant loves numbers.\n\nHe has a positive longeger x. The Little Elephant wants to find the number of positive longegers d, such that d is the divisor of x, and x and d have at least one common (the same) digit in their decimal records.\n\nHelp the Little Elephant to find the described number.\n * */\n\n class Program\n {\n public static bool has_common_digits(long x, long y)\n {//x > y\n long temp_x = x;\n long temp_y = y;\n while (x > 0)\n {\n temp_x = x % 10;\n temp_y = y;\n while (temp_y > 0)\n {\n if (temp_y % 10 == temp_x)\n {\n return true;\n }\n temp_y /= 10;\n }\n x /= 10;\n }\n\n return false;\n }\n\n\n\n static void Main(string[] args)\n {\n\n\n long x;\n x = long.Parse(Console.ReadLine());\n \n \n long answer = 0;\n\n if (x > 1)\n {\n for (int i = 1; i * i <= x; i++)\n {\n if (x % i == 0)\n {\n if (has_common_digits(x, i)) answer++;\n if (has_common_digits(x, x / i) && (x / i != i)) answer++;\n }\n }\n }\n else answer = 1;\n \n \n\n\n\n Console.WriteLine(answer);\n // Console.ReadKey();\n\n\n\n\n }\n }\n}", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "bbc4acc79baa723b2330385a2e10b4f0", "src_uid": "ada94770281765f54ab264b4a1ef766e", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nclass Program {\n\tstatic void Main() {\n\t\tstring[] input = Console.ReadLine().Split();\n\t\tlong p = Int64.Parse(input[0]);\n\t\tlong d = Int64.Parse(input[1]);\n\t\tint[] a = new int[input[0].Length];\n\t\t\n\t\tfor(int i = 0; i < input[0].Length; i++){\n\t\t\ta[i] = int.Parse(input[0][i].ToString());\n\t\t}\n\t\t\n\t\tfor(int i = a.Length - 1; i > 0; i--){\n\t\t\tif(a[i] == 9) continue;\n\n\t\t\tint[] b = new int[a.Length];\n\t\t\tArray.Copy(a, b, a.Length);\n\t\t\t\n\t\t\tb[i] = 9;\n\t\t\tint j = i - 1;\n\t\t\twhile(j >= 0){\n\t\t\t\tif(b[j] > 0){\n\t\t\t\t\tb[j]--; break;\n\t\t\t\t}else{\n\t\t\t\t\tb[j] = 9;\n\t\t\t\t\tj--;\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\tstring tmp = \"\";\n\t\t\tforeach(int r in b)\n\t\t\t\ttmp += r;\n\t\t\t\n\t\t\tif(p - Int64.Parse(tmp) <= d){\n\t\t\t\tArray.Copy(b, a, a.Length);\n\t\t\t}else{\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\t\n\t\tstring ans = \"\";\n\t\tforeach(int i in a)\n\t\t\tans += i;\n\t\tConsole.WriteLine(Int64.Parse(ans));\n\t}\n}", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "ea2aca8286e77579bfedf400edd2449a", "src_uid": "c706cfcd4c37fbc1b1631aeeb2c02b6a", "difficulty": 1400.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 ReadInput(solver, m);\n \n for (var i = 0; i < k; i++)\n solver.IncreaseFlow();\n\n Console.WriteLine(solver.TotalCost);\n }\n\n private static void ReadInput(Solver solver, int m)\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 }\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(_maxTime);\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 AddEdgeWithoutPair(_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 AddEdgeWithoutPair(_start, _nodes[home, 0], 0, count);\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 private void AddEdgeWithoutPair(Node from, Node to, int cost, int capacity)\n {\n _nodeEdges[from.Id].Add(new Edge()\n {\n From = from,\n To = to,\n Cost = cost,\n ResidualCapacity = capacity, \n Paired = FakeEdge,\n });\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": "08d76ec95e3ea2b81048f4d2b8249e20", "src_uid": "2d0aa75f2e63c4fb8c98742ac8cd821c", "difficulty": 2500.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System; \nusing System.Linq;\n\nnamespace ConsoleApplication8 \n{ \n class Program \n { \n static void Main(string[] args)\n {\n\n int[] array = Console.ReadLine().Split().Select(n => int.Parse(n)).ToArray();\n int count = 0; \n if ( array[1] != array[0] || array[1] != 1) \n { \n if (array[1] > array[0] / 2) \n { \n count = array[0] - array[1]; \n } \n else \n { \n count = array[1] - 1; \n } \n } \n Console.WriteLine(count + array[0] * 3); \n } \n } \n}", "lang_cluster": "C#", "tags": ["math", "constructive algorithms"], "code_uid": "d556fb0a6c277d898a6dc0547fd6bd80", "src_uid": "24b02afe8d86314ec5f75a00c72af514", "difficulty": 1000.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 n = sc.Integer();\n ModInteger ans = 0;\n var table = new ModTable(2000050);\n \n n += 1;\n ans = 2 * table[2 * n - 1];\n ans *= table.inv[n] * table.inv[n - 1];\n IO.Printer.Out.WriteLine(ans - 1);\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 != '-' && (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\n\n#region ModNumber\npublic partial struct ModInteger\n{\n public const long Mod = (long)1e9 + 7;\n public long num;\n public ModInteger(long n) : this() { num = n % Mod; if (num < 0) num += Mod; }\n public override string ToString() { return num.ToString(); }\n public static ModInteger operator +(ModInteger l, ModInteger r) { var n = l.num + r.num; if (n >= Mod) n -= Mod; return new ModInteger() { num = n }; }\n public static ModInteger operator -(ModInteger l, ModInteger r) { var n = l.num + Mod - r.num; if (n >= Mod) n -= Mod; return new ModInteger() { num = n }; }\n public static ModInteger operator *(ModInteger l, ModInteger r) { return new ModInteger(l.num * r.num); }\n public static implicit operator ModInteger(long n) { return new ModInteger(n); }\n}\n#endregion\n#region ModPow\npublic partial struct ModInteger\n{\n static public ModInteger Pow(ModInteger v, ModInteger k)\n {\n ModInteger ret = 1;\n var n = k.num;\n for (; n > 0; n >>= 1, v *= v)\n {\n if ((n & 1) == 1)\n ret = ret * v;\n }\n return ret;\n }\n}\n#endregion\n#region Inverse\npublic partial struct ModInteger\n{\n static public ModInteger Inverse(ModInteger v)\n {\n long p, q;\n ExGCD(v.num, Mod, out p, out q);\n return new ModInteger(p % Mod + Mod);\n }\n static public long ExGCD(long a, long b, out long x, out long y)\n {\n var u = new long[] { a, 1, 0 };\n var v = new long[] { b, 0, 1 };\n while (v[0] != 0)\n {\n var t = u[0] / v[0];\n for (int i = 0; i < 3; i++)\n {\n var tmp = u[i] - t * v[i];\n u[i] = v[i];\n v[i] = tmp;\n }\n }\n x = u[1];\n y = u[2];\n if (u[0] > 0)\n return u[0];\n for (int i = 0; i < 3; i++)\n u[i] = -u[i];\n return u[0];\n\n }\n}\n#endregion\n#region Permutaion\npublic class ModTable\n{\n public ModInteger[] perm, inv;\n public ModTable(int n)\n {\n perm = new ModInteger[n + 1];\n inv = new ModInteger[n + 1];\n perm[0] = 1;\n for (int i = 1; i <= n; i++)\n perm[i] = perm[i - 1] * i;\n inv[n] = ModInteger.Inverse(perm[n]);\n for (int i = n - 1; i >= 0; i--)\n inv[i] = inv[i + 1] * (i + 1);\n inv[0] = inv[1];\n }\n public ModInteger this[int k] { get { return perm[k]; } }\n public ModInteger Inverse(int k) { return inv[k]; }\n public ModInteger Permutation(int n, int k)\n {\n if (n < 0 || n >= perm.Length)\n return 0;\n if (k < 0 || k >= n)\n return 0;\n return perm[n] * inv[n - k];\n }\n public ModInteger Combination(int n, int r)\n {\n if (n < 0 || n >= perm.Length || r < 0 || r > n) return 0;\n return perm[n] * inv[n - r] * inv[r];\n }\n public ModInteger RepeatedCombination(int n, int k)\n {\n if (k == 0) return 1;\n return Combination(n + k - 1, k);\n }\n}\n#endregion\n#region CombinationTable\npublic class ModCombinationTable\n{\n ModInteger[][] nCr;\n public ModCombinationTable(int n)\n {\n nCr = new ModInteger[n + 1][];\n for (int i = 0; i <= n; i++)\n nCr[i] = new ModInteger[i + 2];\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 <= i; j++)\n nCr[i][j] = nCr[i - 1][j - 1] + nCr[i - 1][j];\n }\n }\n public ModInteger this[int n, int r]\n {\n get\n {\n if (n < 0 || n > nCr.Length)\n throw new IndexOutOfRangeException(\"n<=0 || n>N \");\n if (r < 0 || r > n)\n throw new IndexOutOfRangeException(\"r<=0 ||r>n\");\n return nCr[n][r];\n }\n }\n public ModInteger 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": ["combinatorics", "number theory"], "code_uid": "ba84754edb4ebf9e3e459ed9118d7689", "src_uid": "a18833c987fd7743e8021196b5dcdd1b", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Linq;\nusing System.Text;\nclass Program\n{\n public static void Main(string[] args)\n {\n int[] inputs = Console.ReadLine().Split().Select(w => Convert.ToInt32(w)).ToArray();\n string stages = new string (Console.ReadLine().OrderBy(c => c).ToArray());\n char current = stages[0];\n StringBuilder sb = new StringBuilder();\n sb.Append(current);\n //Console.WriteLine(stages);\n for(int i = 1;i= 2) {sb.Append(stages[i]); current = stages[i];}\n if(sb.ToString().Length < inputs[1]) Console.WriteLine(-1); else\n Console.WriteLine(sb.ToString().Substring(0,inputs[1]).Select(w => Convert.ToInt32(w) - 'a' + 1).Aggregate((a,b) => a+b));\n \n }\n}", "lang_cluster": "C#", "tags": ["sortings", "implementation", "greedy"], "code_uid": "f3a5bafd14a46cac3b297023c400a37b", "src_uid": "56b13d313afef9dc6c6ba2758b5ea313", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\nusing System;\nusing System.IO;\nusing System.Collections;\nusing System.Collections.Generic;\n//using System.Linq;\nusing System.Text;\n\n class Solution\n {\n //x, y\u5e78\u904b\n //n \u6301\u3063\u3066\u3044\u308b\u6b63\u306e\u6574\u6570\n //\u6570\u5b5710^9\u304cx\u3068y\u3060\u3051\u3067\u69cb\u6210\u3055\u308c\u3066\u3044\u308b\u304b\n //\n long n;\n long res;\n List a = new List();\n \n public void solve(string[] ind)\n {\n\n n = long.Parse(ind[0]);\n res = 0;\n\n for (int i = 1; i <= 9; i++)\n {\n if (i <= n) res++;\n search(i.ToString(), 1);\n }\n\n Console.WriteLine(res);\n }\n\n\n void search(string str, int count)\n {\n if (long.Parse(str) > n) return;\n int cnt = count;\n string stri;\n for (int i = 0; i <= 9; i++)\n {\n stri = i.ToString();\n\n if (long.Parse(str + stri) > n) continue;\n\n\n if (str.IndexOf(stri) == -1)\n {\n if (cnt == 2) continue;\n //else cnt++;\n }\n\n res++;\n if (long.Parse(str + stri + \"0\") <= n)\n {\n if (str.IndexOf(stri) == -1) search(str + stri, cnt+1);\n else search(str + stri, cnt);\n }\n }\n }\n }\n\n class Program\n {\n const int INPUT_TYPE = 1;\n static int in_line = 1;\n static void Main(string[] args)\n {\n Solution s = new Solution();\n ArrayList indata = new ArrayList();\n\n#if !DEBUG\n\n switch (INPUT_TYPE)\n {\n case 2: //\uff11\u884c\u76ee\u306b\u5165\u529b\u3059\u308b\u884c\u6570\u3092\u9078\u629e\u3059\u308b\n in_line = int.Parse(Console.ReadLine());\n indata.Add(in_line.ToString());\n goto case 1;\n case 1: //\u5165\u529b\u3059\u308b\u884c\u6570\u56fa\u5b9a\n for (int i = 0; i < in_line; i++)\n indata.Add(Console.ReadLine());\n\n s.solve((string[])indata.ToArray(typeof(string)));\n break;\n }\n#else\n string[] debug_files = { \n \"test1.txt\", \n //\"test2.txt\", \n //\"test3.txt\" \n };\n\n foreach (var fname in debug_files)\n {\n try\n {\n s.solve(File.ReadAllLines(fname));\n }\n catch (FileNotFoundException)\n {\n //\u30b9\u30eb\u30fc\n }\n\n }\n#endif\n }\n }\n", "lang_cluster": "C#", "tags": ["brute force", "dfs and similar", "bitmasks"], "code_uid": "35bd395b79d8fa49ec1e34dc574bca18", "src_uid": "0f7f10557602c8c2f2eb80762709ffc4", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.IO;\nusing System.Text;\n\nnamespace Parking_Lot\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 long sum = 0;\n\n for (int start = n - 2; start >= 0; start--)\n {\n long count = 4;\n if (start != 0)\n count *= 3;\n if (start > 1)\n count *= Pow(4, start - 1);\n if (start + n != 2*n - 2)\n count *= 3;\n if (start + n < 2*n - 3)\n count *= Pow(4, (n - start - 3));\n\n sum += count;\n }\n\n writer.WriteLine(sum);\n writer.Flush();\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);\n }\n a = (a*a);\n k >>= 1;\n }\n return r;\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", "combinatorics"], "code_uid": "0e40e05bca1b7836611504ff0dd01a24", "src_uid": "3b02cbb38d0b4ddc1a6467f7647d53a9", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Diagnostics;\nusing Pair = System.IComparable;\nusing Point = System.Tuple;\n\npublic class Solution : Helper\n{\n public Solution()\n {\n // http://codeforces.com/contest/899/problem/D\n var n = readInt32();\n long ans = 0;\n //\n if (n < 5)\n {\n ans = n * (n - 1) / 2;\n }\n else\n {\n var bs = bestSum(n);\n var str = bs.ToString();\n var f = str[0] - '0';\n if (f == 9)\n {\n ans = cp(bs, n);\n }\n else\n {\n range(0, f).each(h =>\n {\n ans += cp(int.Parse(str.Replace(\n f.ToString(),\n h.ToString()\n )), n);\n });\n }\n }\n //\n Console.WriteLine(ans);\n }\n //\n int cp(int sum, int n)\n {\n var a = sum / 2 + 1;\n var b = sum - 1;\n return count(a, Math.Min(b, n));\n }\n int count(int left, int right)\n {\n if (left > right) return 0;\n return (int)(right - left + 1);\n }\n int bestSum(int n)\n {\n var a = n + n - 1;\n var b = a.ToString();\n var c = b[0] - '0';\n var l = b.Length;\n var nines = b.Reverse().TakeWhile(x => x == '9').Count();\n if (nines >= l - 1)\n return a;\n return int.Parse((c - 1) + new string('9', l - 1));\n }\n}\n\n#region Core helper library\n[DebuggerNonUserCode]\nstatic partial class Extension\n{\n internal static IEnumerable each(this IEnumerable stream, Action act) { foreach (var elem in stream) act(elem); return stream; }\n internal static IEnumerable> kvp(this IEnumerable stream) { return stream.Select((elem, idx) => new KeyValuePair(idx, elem)); }\n internal static IEnumerable each(this IEnumerable stream, Action act) { stream.kvp().each(kvp => act(kvp.Value, kvp.Key)); return stream; }\n internal static IEnumerable indexIndices(this IList list) { return Helper.range(0, list.Count - 1); }\n internal static TValue? getOrDefault(this IDictionary dict, TKey key) where TValue : struct\n { TValue ans; if (dict.TryGetValue(key, out ans)) return ans; return null; }\n internal static T? FirstOrNullable(this IEnumerable stream) where T : struct { foreach (var val in stream) return val; return null; }\n internal static List Collect(this IEnumerable stream, int capacity) { var ans = new List(capacity); ans.AddRange(stream); return ans; }\n internal static LinkedList Collect(this IEnumerable stream) { return new LinkedList(stream); }\n}\n[DebuggerNonUserCode]\npublic partial class Helper\n{\n internal const int DEFAULT_BUFFER_SIZE = 4194304;\n internal static void fail(string reason = \"ASSERTION FAILED\") { throw new ApplicationException(reason); }\n internal static void debug(string reason = \"ASSERTION FAILED\") { Debug.Fail(reason); }\n internal static IEnumerable range(int left, int right) { for (var i = left; i <= right; i++) yield return i; }\n internal static int? explainSearchIndex(int rawIndex) { if (rawIndex < 0) return null; return rawIndex; }\n internal static Pair pair(T1 value1, T2 value2) { return Tuple.Create(value1, value2); }\n}\n#endregion\n\n// additional plugable library\npublic partial class Helper\n{\n #region STDIO\n#if !DEBUG\n static void Main() { new Solution(); }\n#endif\n static void eof() { throw new System.IO.EndOfStreamException(); }\n internal static string readLine_TRIM()\n { while (true) { var ans = Console.ReadLine(); if (ans == null) eof(); ans = ans.Trim(); if (ans.Any()) return ans; } }\n static IEnumerable stream() { while (true) { var iread = Console.Read(); if (iread < 0) break; yield return (char)iread; } }\n static bool isWhitespace(char c) { return c == ' ' || c == '\\n' || c == '\\r' || c == '\\t'; }\n internal static string readString_TRIM(int maxCapacity)\n {\n var sb = new System.Text.StringBuilder(maxCapacity, maxCapacity);\n var iter = stream().SkipWhile(isWhitespace).TakeWhile(c => !isWhitespace(c));\n foreach (var c in iter) sb.Append(c);\n if (sb.Length == 0) eof(); return sb.ToString();\n }\n internal static long readLong64() { return long.Parse(readString_TRIM(21)); }\n internal static int readInt32() { return Convert.ToInt32(readLong64()); }\n #endregion\n}\nstatic partial class Extension\n{\n\n}", "lang_cluster": "C#", "tags": ["math", "constructive algorithms"], "code_uid": "4b296729a095b68105babf2f9b39db15", "src_uid": "c20744c44269ae0779c5f549afd2e3f2", "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 acm\n{\n class Program\n {\n static void Main(string[] args)\n {\n string[] q = new string[8];\n int ans = 16;\n for (int i = 0; i < 8; ++i) q[i] = Console.ReadLine();\n for( int i = 0; i < ( 1 << 8 ); ++ i )\n for (int j = 0; j < (1 << 8); ++j)\n {\n bool ok = true;\n for (int ii = 0; ii < 8; ++ii)\n for (int jj = 0; jj < 8; ++jj)\n {\n if (q[ii][jj] == 'B' && 0 == (i & (1 << ii)) && 0 == (j & (1 << jj))) ok = false;\n if (q[ii][jj] == 'W' && ( 0 != (i & (1 << ii)) || 0 != (j & (1 << jj)))) ok = false;\n }\n if (ok)\n {\n int cur = 0;\n for (int ii = 0; ii < 8; ++ii) if (0 != (i & (1 << ii))) ++cur;\n for (int ii = 0; ii < 8; ++ii) if (0 != (j & (1 << ii))) ++cur;\n ans = Math.Min(ans, cur);\n }\n }\n Console.WriteLine(ans);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "constructive algorithms"], "code_uid": "2ececc509cd5cd905198fe2db9ae4b82", "src_uid": "8b6ae2190413b23f47e2958a7d4e7bc0", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nclass test\n{\n static long f(long b)\n {\n if (b < 10) return b;\n\n string tmp = b + \"\";\n long sum = 0;\n for (int i = 0; i < tmp.Length; i++)\n {\n sum += long.Parse(tmp[i] + \"\");\n }\n\n return sum;\n }\n\n static void Main()\n {\n long n = long.Parse(Console.ReadLine());\n long i = (long)(Math.Sqrt(n)) - f(n);\n\n if (i <= 0) i = 1;\n\n while (i * i + i<= n)\n {\n if (n % i != 0) \n {\n i = i + 1;\n continue;\n }\n\n if (i * i + (f(i) * i) == n)\n {\n Console.WriteLine(i);\n Console.ReadLine();\n return;\n }\n i = i + 1;\n }\n Console.WriteLine(\"-1\");\n Console.ReadLine();\n }\n}", "lang_cluster": "C#", "tags": ["brute force", "math", "binary search"], "code_uid": "ea28d2f492b35c048526e5d74e44c68c", "src_uid": "e1070ad4383f27399d31b8d0e87def59", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.IO;\nusing System.Text;\n\nnamespace Find_Color\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 x = Next();\n int y = Next();\n\n int d = x*x + y*y;\n if (x*y != 0)\n {\n for (int i = 2000 - 1; i >= 0; i--)\n {\n if (i*i < d)\n {\n d = i+1;\n break;\n }\n }\n if (d*d == x*x + y*y)\n writer.WriteLine(\"black\");\n else writer.WriteLine(x*y > 0 ^ d%2 == 1 ? \"white\" : \"black\");\n }\n else if (x*y == 0)\n {\n writer.WriteLine(\"black\");\n }\n\n\n writer.Flush();\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", "constructive algorithms", "implementation"], "code_uid": "91c87ae24f209d5d6bd9969ddcfa181d", "src_uid": "8c92aac1bef5822848a136a1328346c6", "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\n\r\nnamespace ConsoleApp\r\n{\r\n class Program\r\n {\r\n const double DefaultEpsilon = 1e-18;\r\n\r\n struct Vector\r\n {\r\n public double X;\r\n public double Y;\r\n\r\n public Vector(double x, double y)\r\n {\r\n X = x;\r\n Y = y;\r\n }\r\n public Vector(double angle)\r\n {\r\n X = Math.Cos(angle);\r\n Y = Math.Sin(angle);\r\n }\r\n\r\n public double Hypot()\r\n {\r\n return Math.Sqrt((X * X) + (Y * Y));\r\n }\r\n public double HypotSquared()\r\n {\r\n return (X * X) + (Y * Y);\r\n }\r\n public Vector RotateClockwise(double angle)\r\n {\r\n double cos = Math.Cos(angle);\r\n double sin = Math.Sin(angle);\r\n\r\n return new Vector(X * cos + Y * sin, X * -sin + Y * cos);\r\n }\r\n public Vector Perpendicular()\r\n {\r\n return new Vector(-Y, X);\r\n }\r\n public bool IsEqual(Vector vector, double epsilon = DefaultEpsilon)\r\n {\r\n return Equal(this.X, vector.X, epsilon) && Equal(this.Y, vector.Y, epsilon);\r\n }\r\n\r\n public static Vector operator +(Vector a)\r\n {\r\n return a;\r\n }\r\n public static Vector operator -(Vector a)\r\n {\r\n return new Vector(-a.X, -a.Y);\r\n }\r\n public static Vector operator +(Vector a, Vector b)\r\n {\r\n return new Vector(a.X + b.X, a.Y + b.Y);\r\n }\r\n public static Vector operator -(Vector a, Vector b)\r\n {\r\n return new Vector(a.X - b.X, a.Y - b.Y);\r\n }\r\n public static double Determinant(Vector a, Vector b)\r\n {\r\n return (a.X * b.Y) - (a.Y * b.X);\r\n }\r\n public static double DotProduct(Vector a, Vector b)\r\n {\r\n return (a.X * b.X) + (a.Y * b.Y);\r\n }\r\n }\r\n struct Line\r\n {\r\n public double A;\r\n public double B;\r\n public double C;\r\n\r\n public double slopeY => -A / B; // y = f'(x)\r\n public double slopeX => -B / A; // x = f'(y)\r\n\r\n public Line(Vector p1, Vector p2)\r\n {\r\n A = p2.Y - p1.Y;\r\n B = p1.X - p2.X;\r\n C = p2.X * p1.Y - p1.X * p2.Y;\r\n }\r\n }\r\n struct Segment\r\n {\r\n public Vector Left;\r\n public Vector Right;\r\n\r\n public Segment(Vector left, Vector right)\r\n {\r\n Left = left;\r\n Right = right;\r\n }\r\n\r\n public Line GetLine()\r\n {\r\n return new Line(Left, Right);\r\n }\r\n public bool IsOnTheSegment(Vector point, double epsilon = DefaultEpsilon)\r\n {\r\n Vector v1 = point - Left;\r\n Vector v2 = point - Right;\r\n double det = Vector.Determinant(v1, v2);\r\n double dotProd = Vector.DotProduct(v1, v2);\r\n\r\n return Equal(det, 0, epsilon) && LessOrEqual(dotProd, 0, epsilon);\r\n }\r\n }\r\n\r\n static Program()\r\n {\r\n // Comment this before submitting (in case of strandard input)\r\n //Console.SetIn(new StreamReader(\"input.txt\"));\r\n //Console.SetOut(new StreamWriter(\"output.txt\"));\r\n }\r\n static void Main()\r\n {\r\n //int testCases = int.Parse(Console.ReadLine());\r\n //for (int z = 0; z < testCases; z++)\r\n //{\r\n\r\n //}\r\n\r\n int[] data = ReadIntData();\r\n int n = data[0];\r\n int m = data[1];\r\n int k = data[2];\r\n int r = data[3];\r\n int c = data[4];\r\n\r\n data = ReadIntData();\r\n int ax = data[0];\r\n int ay = data[1];\r\n int bx = data[2];\r\n int by = data[3];\r\n\r\n if (ax > bx)\r\n {\r\n Swap(ref ax, ref bx);\r\n }\r\n if (ay > by)\r\n {\r\n Swap(ref ay, ref by);\r\n }\r\n\r\n //int dx = bx - ax;\r\n //int dy = by - ay;\r\n\r\n long total = (long)n * m;\r\n if ((ax != bx) || (ay != by))\r\n {\r\n total -= (long)r * c;\r\n }\r\n \r\n //total += (long)(ax - bx + r) * (ay - by + c);\r\n\r\n Console.WriteLine(PowQuick(k, total, 1_000_000_007));\r\n\r\n Console.Out.Close();\r\n }\r\n\r\n static bool Equal(double a, double b, double epsilon = DefaultEpsilon)\r\n {\r\n return Math.Abs(a - b) < epsilon;\r\n }\r\n static bool Greater(double a, double b, double epsilon = DefaultEpsilon)\r\n {\r\n return (a > b) && !Equal(a, b, epsilon);\r\n }\r\n static bool Less(double a, double b, double epsilon = DefaultEpsilon)\r\n {\r\n return (a < b) && !Equal(a, b, epsilon);\r\n }\r\n static bool GreaterOrEqual(double a, double b, double epsilon = DefaultEpsilon)\r\n {\r\n return (a > b) || Equal(a, b, epsilon);\r\n }\r\n static bool LessOrEqual(double a, double b, double epsilon = DefaultEpsilon)\r\n {\r\n return (a < b) || Equal(a, b, epsilon);\r\n }\r\n static double DegToRad(double angle)\r\n {\r\n return (angle / 180) * Math.PI;\r\n }\r\n static long LCM(long a, long b)\r\n {\r\n return (a / GCD(a, b)) * b;\r\n }\r\n static long GCD(long a, long b)\r\n {\r\n while (a != 0)\r\n {\r\n b %= a;\r\n Swap(ref a, ref b);\r\n }\r\n\r\n return b;\r\n }\r\n static long PowQuick(long b, long p)\r\n {\r\n long exp = b;\r\n long res = 1;\r\n\r\n while (p > 0)\r\n {\r\n if ((p % 2) == 1)\r\n {\r\n res *= exp;\r\n }\r\n\r\n exp *= exp;\r\n p /= 2;\r\n }\r\n\r\n return res;\r\n }\r\n static long PowQuick(long b, long p, long mod)\r\n {\r\n long exp = b;\r\n long res = 1;\r\n\r\n while (p > 0)\r\n {\r\n if ((p % 2) == 1)\r\n {\r\n res *= exp;\r\n res %= mod;\r\n }\r\n\r\n exp *= exp;\r\n exp %= mod;\r\n p /= 2;\r\n }\r\n\r\n return res;\r\n }\r\n static uint BitCount(uint a)\r\n {\r\n a = ((a >> 1) & 0x55555555u) + (a & 0x55555555u);\r\n a = ((a >> 2) & 0x33333333u) + (a & 0x33333333u);\r\n a = ((a >> 4) & 0x0F0F0F0Fu) + (a & 0x0F0F0F0Fu);\r\n a = ((a >> 8) & 0x00FF00FFu) + (a & 0x00FF00FFu);\r\n a = ((a >> 16) & 0x0000FFFFu) + (a & 0x0000FFFFu);\r\n return a;\r\n }\r\n static bool AreAlmostEqual(double a, double b, double epsilon)\r\n {\r\n return Math.Abs(a - b) < epsilon;\r\n }\r\n static int Binary(int[] array, int val)\r\n {\r\n return Binary(array, val, 0, array.Length);\r\n }\r\n static int Binary(int[] array, int val, int left, int right)\r\n {\r\n if (val < array[0])\r\n {\r\n return 0;\r\n }\r\n\r\n while (right - left > 1)\r\n {\r\n int mid = (right + left) / 2;\r\n\r\n if (array[mid] <= val)\r\n {\r\n left = mid;\r\n }\r\n else\r\n {\r\n right = mid;\r\n }\r\n }\r\n\r\n return right;\r\n }\r\n static void Swap(ref int a, ref int b)\r\n {\r\n int temp = a;\r\n a = b;\r\n b = temp;\r\n }\r\n static void Swap(ref long a, ref long b)\r\n {\r\n long temp = a;\r\n a = b;\r\n b = temp;\r\n }\r\n static double[] ReadDoubleData(TextReader input)\r\n {\r\n return input.ReadLine()\r\n .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)\r\n .Select(val => double.Parse(val))\r\n .ToArray();\r\n }\r\n static double[] ReadDoubleData()\r\n {\r\n return ReadDoubleData(Console.In);\r\n }\r\n static int[] ReadIntData(TextReader input)\r\n {\r\n return input.ReadLine()\r\n .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)\r\n .Select(val => int.Parse(val))\r\n .ToArray();\r\n }\r\n static int[] ReadIntData()\r\n {\r\n return ReadIntData(Console.In);\r\n }\r\n static long[] ReadLongData(TextReader input)\r\n {\r\n return input.ReadLine()\r\n .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)\r\n .Select(val => long.Parse(val))\r\n .ToArray();\r\n }\r\n static long[] ReadLongData()\r\n {\r\n return ReadLongData(Console.In);\r\n }\r\n }\r\n}", "lang_cluster": "C#", "tags": ["math", "implementation"], "code_uid": "ef9c356d2b938264cb161e647dd9a26f", "src_uid": "3478e6a4ff2415508fd517413d40c13a", "difficulty": 2200.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nclass Test {\n static int Main() {\n string [] str = Console.ReadLine().Split();\n int [] a = new int [str.Length];\n for(int k=0 ; k 2000)\n {\n x -= 400;\n d++;\n }\n\n var d1 = new DateTime(x, 1, 1);\n for (int i = x + 1; ; i++)\n {\n var d2 = new DateTime(i, 1, 1);\n if (d1.DayOfWeek == d2.DayOfWeek && d1.AddDays(400).Day == d2.AddDays(400).Day)\n {\n Write(i + 400 * d);\n return;\n }\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": ["implementation"], "code_uid": "890927d98fdcf765337ecd67c495c1a0", "src_uid": "565bbd09f79eb7bfe2f2da46647af0f2", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Linq;\n\nnamespace CSharp\n{\n class _1143B\n {\n public static void Main()\n {\n int n = int.Parse(Console.ReadLine());\n\n int max = 0;\n for (int prefix = 1; prefix < 1000; prefix++)\n {\n for (string suffix = string.Empty; suffix.Length <= 7; suffix += 9)\n {\n if (long.Parse(prefix + suffix) <= n)\n {\n max = Math.Max(max, (prefix + suffix).Aggregate(1, (p, c) => p * (c - '0')));\n }\n }\n }\n\n Console.WriteLine(max);\n }\n }\n}", "lang_cluster": "C#", "tags": ["brute force", "math", "number theory"], "code_uid": "70833329ff8d5bb4c72f1560e24d4dbc", "src_uid": "38690bd32e7d0b314f701f138ce19dfb", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\n\nnamespace File\n{\n class Program\n {\n\n static long nod(long a, long b)\n {\n if (a < b) { long c = a; a = b; b = c; }\n long r;\n do\n {\n r = a % b;\n a = b;\n b = r;\n } while (r != 0);\n return a;\n }\n\n static void Main()\n {\n long[] cin = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();\n long a = cin[0], b = cin[1], x = cin[2], y = cin[3];\n long d = nod(x, y);\n x /= d;\n y /= d;\n a /= x;\n b /= y;\n Console.WriteLine(Math.Min(a,b));\n }\n }\n}", "lang_cluster": "C#", "tags": ["math"], "code_uid": "baa60bc01058919048762c071977329e", "src_uid": "907ac56260e84dbb6d98a271bcb2d62d", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nclass Program\n {\n static void Main(string[] args)\n {\n long x, k, a, b;\n {\n string[] input = Console.In.ReadToEnd().Split(new char[] { '\\n', '\\r' }, StringSplitOptions.RemoveEmptyEntries);\n x = long.Parse(input[0]);\n k = long.Parse(input[1]);\n a = long.Parse(input[2]);\n b = long.Parse(input[3]);\n }\n long result = 0L;\n for (long smllr; x > 1L;)\n {\n if ((smllr = x % k) == 0L)\n {\n if (((x - (smllr = x / k)) * a) <= b) { result += a * (x - 1L); x = 1L; break; }\n else { x = smllr; result += b; }\n }\n else { result += smllr * a; x -= smllr; }\n }\n Console.WriteLine(x == 0L ? result - a : result);\n }\n }", "lang_cluster": "C#", "tags": ["greedy", "dp"], "code_uid": "6a5243e085c702e8a0b624785f8bdbfa", "src_uid": "f838fae7c98bf51cfa0b9bd158650b10", "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.Round53\n{\n class A\n {\n public static void Main()\n {\n int[] xs = Array.ConvertAll(Console.ReadLine().Split(' '), sss=>int.Parse(sss));\n int[] dx = new int[] { 0, 1, 0, -1 },\n dy = new int[] { 1, 0, -1, 0 };\n int n = xs[0];\n int[,] dist = new int[n + 1, n + 1];\n bool[,] visited = new bool[n + 1, n + 1];\n for (int y = 1; y < n; y++)\n for (int x = 1; x < n; x++)\n visited[x, y] = true;\n\n Queue qx = new Queue(), qy = new Queue();\n qx.Enqueue(xs[1]); qy.Enqueue(xs[2]);\n while (true)\n {\n int xx = qx.Dequeue(),\n yy = qy.Dequeue();\n if (xx == xs[3] && yy == xs[4]) break;\n for (int i = 0; i < 4; i++)\n {\n int x = xx + dx[i],\n y = yy + dy[i];\n if (0 <= x && x <= n && 0 <= y && y <= n && !visited[x, y])\n {\n visited[x, y] = true;\n qx.Enqueue(x);\n qy.Enqueue(y);\n dist[x, y] = dist[xx, yy] + 1;\n }\n }\n }\n\n Console.WriteLine(dist[xs[3], xs[4]]);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["dfs and similar", "greedy", "implementation"], "code_uid": "d3c45a106d91c2e1bb4105cf6ea26a1c", "src_uid": "685fe16c217b5b71eafdb4198822250e", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\n\nnamespace ConsoleApp4\n{\n class Program\n {\n\n static long gcd(long a, long b)\n {\n while (b != 0)\n {\n long t = b;\n b = a % b;\n a = t;\n }\n return a;\n }\n\n static void Main(string[] args)\n {\n var str = Console.ReadLine();\n var span = str.Split(' ');\n long a = long.Parse(span[0]);\n long b = int.Parse(span[1]);\n\n if (b > a)\n {\n long t = b;\n b = a;\n a = t;\n }\n var div = a - b;\n if (div == 0 || a % b == 0)\n {\n Console.WriteLine(0);\n return;\n }\n int lim = (int)Math.Floor(Math.Sqrt(div));\n long lcm = long.MaxValue;\n long kmin = 0;\n for (int i = 1; i < lim; i++) \n if (a % i == b % i)\n {\n long q = i;\n long k = 0;\n if (b % q != 0)\n {\n k = (div - b) % q;\n if (k < 0) k += q;\n\n }\n long l = (a + k) * (b + k) / gcd(a + k, b + k);\n if (l < lcm)\n {\n lcm = l;\n kmin = k;\n }\n else if (l == lcm)\n kmin = Math.Min(k, kmin);\n k = 0;\n q = div / i;\n if (b % q != 0)\n {\n k = (q - b) % q;\n if (k < 0) k += q;\n\n }\n l = (a + k) * (b + k) / gcd(a + k, b + k);\n if (l < lcm)\n {\n lcm = l;\n kmin = k;\n }\n else if (l == lcm)\n kmin = Math.Min(k, kmin);\n\n }\n Console.WriteLine(kmin);\n }\n }\n}\n\n", "lang_cluster": "C#", "tags": ["brute force", "math", "number theory"], "code_uid": "dd1f7039419383b544f0f8367a76dbbe", "src_uid": "414149fadebe25ab6097fc67663177c3", "difficulty": 1800.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 static void Main(string[] args)\n {\n double x = 0;\n double y = 0;\n string[] infox = Console.ReadLine().Split(' ');\n int countx = int.Parse(infox[0]);\n int basex = int.Parse(infox[1]);\n string[] Xd = Console.ReadLine().Split(' ');\n\n string[] infoy = Console.ReadLine().Split(' ');\n int county = int.Parse(infoy[0]);\n int basey = int.Parse(infoy[1]);\n string[] Yd = Console.ReadLine().Split(' ');\n\n double j = 0;\n for(int i = countx-1; i>=0; i--)\n {\n x += double.Parse(Xd[i]) * Math.Pow(basex, j);\n j++;\n }\n\n j = 0;\n for(int i=county-1; i>=0; i--)\n {\n y += double.Parse(Yd[i]) * Math.Pow(basey, j);\n j++;\n }\n\n if (x < y)\n {\n Console.WriteLine('<');\n return;\n }\n\n if(x>y)\n {\n Console.WriteLine('>');\n return;\n }\n\n Console.WriteLine('=');\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "implementation"], "code_uid": "ff6a096bc6893094d2f70863fe6f6b65", "src_uid": "d6ab5f75a7bee28f0af2bf168a0b2e67", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Diagnostics;\nusing System.Linq;\n\nnamespace Task\n{\n class Program\n {\n public class PossibleDigit\n {\n public long digit;\n public int possibleLength;\n\n public PossibleDigit(int p)\n {\n possibleLength = p;\n }\n }\n static void Main(string[] args)\n {\n /*string[] input = Console.ReadLine().Split(' ');\n\n int n = Convert.ToInt32(input[0]),\n m = Convert.ToInt32(input[1]),\n x = Convert.ToInt32(input[3]),\n y = Convert.ToInt32(input[4]);\n long k = Convert.ToInt64(input[2]);\n\n long max, min, serg;\n\n if (n == 1)\n {\n if (k % m == 0)\n {\n serg = min = max = k / m;\n }\n else\n {\n min = k / m;\n max = min + 1;\n serg = k % m < y ? min : max;\n }\n }\n else if (n == 2)\n {\n min = k / (n * m);\n max = (k % (n * m) == 0 || (k - n * m) % ((n - 1) * m) == 0) ? min : min + 1;\n }\n else\n {\n int[] count = new int[3];\n\n if (k < 100000)\n {\n for (int i = 0; i < k; ++i)\n {\n if ((i / m) == 1 || )\n }\n }\n }\n\n Console.WriteLine($\"{max} {min} {serg}\");*/\n\n int n = Convert.ToInt32(Console.ReadLine());\n string num = Console.ReadLine();\n\n long answer = 0;\n int cur = n.ToString().Length;\n List nums = new List() {new PossibleDigit(cur)}; \n\n for (int i = num.Length; i >= 0;)\n {\n /*Console.WriteLine(\"\u0421\u043f\u0438\u0441\u043e\u043a\");\n \n Console.WriteLine();\n Console.WriteLine(i);*/\n if (i - nums[nums.Count - 1].possibleLength >= 0)\n {\n i -= nums[nums.Count - 1].possibleLength;\n //Console.WriteLine(i + \" \" + nums[nums.Count - 1].possibleLength);\n }\n else\n {\n nums[nums.Count - 1].possibleLength = i;\n i = 0;\n }\n if (num.Length < cur)\n {\n nums[nums.Count - 1].digit = Convert.ToInt32(num);\n nums.Add(new PossibleDigit(cur));\n break; \n }\n if (nums[nums.Count - 1].possibleLength == 0) break;\n //Console.WriteLine($\"Convert.ToInt32(num.Substring({i}, {nums[nums.Count - 1].possibleLength})) {Convert.ToInt32(num.Substring(i, nums[nums.Count - 1].possibleLength))}\");\n long temp = Convert.ToInt64(num.Substring(i, nums[nums.Count - 1].possibleLength));\n if (num.Substring(i, nums[nums.Count - 1].possibleLength)[0] == '0' && nums[nums.Count - 1].possibleLength != 1)\n temp = int.MaxValue;\n //Console.WriteLine($\"\u0415\u0442\u043e \u0442\u0435\u043c\u043f{temp}\");\n\n if (temp < n)\n {\n nums[nums.Count - 1].digit = temp;\n nums.Add(new PossibleDigit(cur));\n }\n else\n {\n //Console.WriteLine(-1);\n i += nums[nums.Count - 1].possibleLength--;\n if (nums[nums.Count - 1].possibleLength == 0)\n --nums[nums.Count - 2].possibleLength;\n } \n }\n\n /*foreach (var t in nums) Console.Write(t.digit + \" \");\n Console.WriteLine();*/\n for(int i = nums.Count - 2; i >= 0; --i)\n {\n answer *= n;\n answer += nums[i].digit;\n }\n \n Console.Write(answer);\n }\n }\n}", "lang_cluster": "C#", "tags": ["constructive algorithms", "math", "dp", "greedy", "strings"], "code_uid": "1fa9ff9bf9ddc90f35846323b6ba51ff", "src_uid": "be66399c558c96566a6bb0a63d2503e5", "difficulty": 2000.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System; \nusing System.Linq;\nusing System.Collections.Generic;\n\nclass P\n{\n static void Main()\n {\n Console.WriteLine(Layer(int.Parse(Console.ReadLine())));\n }\n static int Layer(int i)\n {\n if (i == 1) return 1;\n if (i == 2) return 2;\n return i + Layer(i - 2);\n }\n}", "lang_cluster": "C#", "tags": ["math", "constructive algorithms"], "code_uid": "19babb49d951b2e3a7898c3d8232a489", "src_uid": "f8af5dfcf841a7f105ac4c144eb51319", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Linq;\nusing System.Collections.Generic;\n\nnamespace trenvk\n{\n class Program\n {\n static void Main(string[] args)\n {\n int[] nm = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();\n long res = 0;\n\n for (int i = 1; i <= nm[0]; i++)\n {\n res += (nm[1] + i) / 5 - (i + 1) / 5;\n if ((i + 1) % 5 == 0) res++;\n\n }\n Console.Write(res);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "constructive algorithms", "number theory"], "code_uid": "91097a6ff348c5a496aa00b23b5f3746", "src_uid": "df0879635b59e141c839d9599abd77d2", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "C# 8", "source_code": "\ufeffusing System;\r\nusing System.IO;\r\nusing System.Linq;\r\nusing System.Collections.Generic;\r\nusing System.Text;\r\nusing System.Numerics;\r\n\r\nnamespace cf762\r\n{\r\n class Program\r\n {\r\n static void Main(string[] args)\r\n {\r\n Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });\r\n if (File.Exists(\"input.txt\"))\r\n {\r\n Console.SetIn(new StreamReader(\"input.txt\"));\r\n }\r\n solve_cf762B();\r\n Console.Out.Flush();\r\n }\r\n\r\n public static void solve_cf762B()\r\n {\r\n int t = Convert.ToInt32(Console.ReadLine());\r\n while (t-- > 0)\r\n {\r\n int n = Convert.ToInt32(Console.ReadLine());\r\n Dictionary used = new Dictionary();\r\n for (int i = 1; i * i <= n; i++)\r\n {\r\n used.TryAdd(i * i, i * i);\r\n }\r\n for (int i = 1; i * i * i <= n; i++)\r\n {\r\n used.TryAdd(i * i * i, i * i * i);\r\n }\r\n Console.WriteLine(used.Count);\r\n }\r\n }\r\n\r\n public static void solve_cf762A()\r\n {\r\n int t = Convert.ToInt32(Console.ReadLine());\r\n while (t-- > 0)\r\n {\r\n string s = Console.ReadLine();\r\n int n = s.Length;\r\n if (n % 2 != 0)\r\n {\r\n Console.WriteLine(\"NO\");\r\n }\r\n else\r\n {\r\n bool ok = true;\r\n for (int i = 0; i < n / 2; i++)\r\n {\r\n if (s[i] != s[n / 2 + i])\r\n {\r\n ok = false;\r\n break;\r\n }\r\n }\r\n Console.WriteLine(ok ? \"YES\" : \"NO\");\r\n }\r\n\t\t\t}\r\n }\r\n }\r\n}", "lang_cluster": "C#", "tags": ["math", "implementation"], "code_uid": "a112046c6ebc79b5dab5d35a7c582327", "src_uid": "015afbefe1514a0e18fcb9286c7b6624", "difficulty": 800.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 D\n {\n private static ThreadStart s_threadStart = new D().Go;\n private static bool s_time = false;\n private static double s_eps = 1e-16;\n\n static long mod = 1000000007;\n public static long Pow(long a, long n)\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 private void Go()\n {\n long p = GetInt();\n long k = GetInt();\n\n if (k == 0)\n {\n Wl(Pow(p, p - 1));\n }\n else if (k == 1)\n {\n Wl(Pow(p, p));\n }\n else\n {\n long x = k;\n long kp = 1;\n while (x != 1)\n {\n x *= k;\n x %= p;\n kp++;\n }\n\n Wl(Pow(p, (p - 1) / kp));\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), 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": ["dsu", "math", "combinatorics", "number theory"], "code_uid": "64afa6239d3f993af07b092d6ba4b88d", "src_uid": "580bf65af24fb7f08250ddbc4ca67e0e", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nclass Solver\n{\n void Solve()\n {\n var str = sc.ScanLine();\n var _d = new int[6];\n const string s = \"ROYGBV\";\n for (int i = 0; i < 6; i++)\n for (int j = 0; j < 6; j++)\n if (str[i] == s[j])\n _d[i] = j;\n Array.Sort(_d);\n var set = new HashSet();\n var ret = 0;\n do\n {\n var dice = new Dice(_d);\n if (set.Contains(dice.AsLong()))\n continue;\n ret++;\n for (int i = 0; i < 4; i++)\n {\n dice.RotationX();\n for (int j = 0; j < 4; j++)\n {\n dice.RotationY();\n for (int k = 0; k < 4; k++)\n {\n dice.RotationZ();\n var code = dice.AsLong();\n set.Add(code);\n \n }\n }\n }\n } while (_d.NextPermutation(0,6));\n Printer.PrintLine(ret);\n \n\t\t\t\t \n\n\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}\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}\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 #region dice\n public class Dice\n {\n int[] d;\n public Dice(int[] dice)\n {\n d = dice;\n }\n public Dice RotationZ()\n {\n var u = d[1]; d[1] = d[2]; d[2] = d[4]; d[4] = d[3]; d[3] = u;\n return this;\n }\n public Dice RotationX()\n {\n var u = d[1]; d[1] = d[0]; d[0] = d[4]; d[4] = d[5]; d[5] = u;\n return this;\n }\n public Dice RotationY()\n {\n var u = d[0]; d[0] = d[2]; d[2] = d[5]; d[5] = d[3]; d[3] = u;\n return this;\n }\n public long AsLong()\n {\n long ret = 0;\n for (int i = 0; i < 6; i++)\n ret = ret * 26 + d[i];\n return ret;\n }\n }\n#endregion\n#region next_permutation\nstatic public partial class MathEx\n{\n\n static public bool NextPermutation(this T[] array, int first, int last) where T : IComparable\n {\n if (first == last)\n return false;\n var i = last;\n if (--i == first)\n return false;\n while (true)\n {\n var ii = i--;\n if (array[i].CompareTo(array[ii]) < 0)\n {\n var j = last;\n while (array[i].CompareTo(array[--j]) >= 0) { }\n var temp = array[i];\n array[i] = array[j];\n array[j] = temp;\n Array.Reverse(array, ii, last - ii);\n return true;\n }\n if (i == first)\n {\n Array.Reverse(array, first, last - first);\n return false;\n }\n }\n }\n\n}\n#endregion\n//*/", "lang_cluster": "C#", "tags": ["brute force", "implementation"], "code_uid": "fb09ea139e864c1c59e8d8bc3001cf98", "src_uid": "8176c709c774fa87ca0e45a5a502a409", "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.Numerics;\nusing System.Text;\n\nnamespace CodeForces.Solutions.c331_AbbyyCupFinal\n{\n\tpublic class ProgramC\n\t{\n\t\tpublic static void Main()\n\t\t{\n\t\t\tchecked\n\t\t\t{\n\t\t\t var subs = new int[1000001];\n\n\t\t\t for (int i = 1; i < subs.Length; i++)\n\t\t\t {\n\t\t\t subs[i] = int.MaxValue;\n\t\t\t var tmp = i;\n while (tmp > 0)\n {\n var d = tmp%10;\n if (d != 0)\n subs[i] = Math.Min(subs[i], subs[i - d] + 1);\n tmp /= 10;\n }\n\t\t\t }\n\n\t\t\t var n = long.Parse(Console.ReadLine());\n\t\t\t Console.WriteLine(subs[n]);\n\t\t\t}\n\t\t}\n\t}\n}", "lang_cluster": "C#", "tags": ["dp"], "code_uid": "b739bb32560fa5448d43eb1eaabde66b", "src_uid": "fc5765b9bd18dc7555fa76e91530c036", "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 task39D\n{\n class Program\n {\n static void Main(string[] args)\n {\n string[] point1 = Console.ReadLine().Split();\n Int32 x1 = Int32.Parse(point1[0]);\n Int32 y1 = Int32.Parse(point1[1]);\n Int32 z1 = Int32.Parse(point1[2]);\n string[] point2 = Console.ReadLine().Split();\n Int32 x2 = Int32.Parse(point2[0]);\n Int32 y2 = Int32.Parse(point2[1]);\n Int32 z2 = Int32.Parse(point2[2]);\n if (Math.Sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1) + (z2 - z1) * (z2 - z1)) - Math.Sqrt(2) <= 0.000001)\n {\n Console.WriteLine(\"YES\");\n }\n else\n Console.WriteLine(\"NO\");\n //Console.ReadLine();\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math"], "code_uid": "dcef612f5ea7e10c5f26c4e952dc4c1a", "src_uid": "91c9dbbceb467d5fd420e92c2919ecb6", "difficulty": 1100.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 ProblemB\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 k = NN;\n var ary = new long[10];\n for (var i = 0; i < 10; i++)\n {\n ary[i] = 1;\n }\n var idx = 0;\n while (ary.Aggregate((x, y) => x * y) < k)\n {\n ++ary[idx];\n ++idx;\n if (idx == 10) idx = 0;\n }\n for (var i = 0; i < ary[0]; i++) Console.Write(\"c\");\n for (var i = 0; i < ary[1]; i++) Console.Write(\"o\");\n for (var i = 0; i < ary[2]; i++) Console.Write(\"d\");\n for (var i = 0; i < ary[3]; i++) Console.Write(\"e\");\n for (var i = 0; i < ary[4]; i++) Console.Write(\"f\");\n for (var i = 0; i < ary[5]; i++) Console.Write(\"o\");\n for (var i = 0; i < ary[6]; i++) Console.Write(\"r\");\n for (var i = 0; i < ary[7]; i++) Console.Write(\"c\");\n for (var i = 0; i < ary[8]; i++) Console.Write(\"e\");\n for (var i = 0; i < ary[9]; i++) Console.Write(\"s\");\n Console.WriteLine();\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": ["brute force", "constructive algorithms", "math", "greedy", "strings"], "code_uid": "dcfa411ca84d9bd21c635040de0f874e", "src_uid": "8001a7570766cadcc538217e941b3031", "difficulty": 1500.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 Table\n {\n List> Components { get; set; }\n }\n class Program\n {\n private static void WriteFull(List values)\n {\n for (int i = 0; i < 9; i++)\n {\n for(int j = 0; j < 9; j++)\n {\n if (values[i][j] == '.')\n {\n Console.Write('!');\n }\n else Console.Write(values[i][j]);\n if (j== 2 || j == 5)\n {\n Console.Write(' ');\n }\n }\n if (i == 2 || i == 5)\n {\n Console.WriteLine();\n }\n Console.WriteLine();\n }\n }\n static void Main(string[] args)\n {\n List lines = new List();\n string line = null;\n for (int i = 0; i < 11; i++)\n {\n line = Console.ReadLine();\n if (line != string.Empty)\n {\n line = line.Replace(\" \", \"\");\n lines.Add(line);\n }\n }\n\n line = Console.ReadLine();\n int x = line.Split(' ').Select(xx => int.Parse(xx)).ToArray()[0];\n int y = line.Split(' ').Select(xx => int.Parse(xx)).ToArray()[1];\n\n int linie = x % 3;\n if (linie == 0) linie = 3;\n int coloana = y % 3;\n if (coloana == 0) coloana = 3;\n if (linie == 1 && coloana == 1)\n {\n bool isFull = true;\n for (int i = 1; i<=3; i++)\n {\n for (int j = 1; j<=3; j++)\n {\n if (lines[i-1][j-1] == '.')\n {\n isFull = false;\n break; \n }\n }\n }\n\n if (isFull)\n {\n WriteFull(lines);\n Console.ReadLine();\n return;\n\n }\n\n for (int i = 1; i<=9; i++)\n {\n for (int j = 1; j<=9; j++)\n {\n if (lines[i-1][j-1] != '.')\n {\n Console.Write(lines[i-1][j-1]);\n }\n else\n {\n if (i >= 1 && i <= 3 && j >= 1 && j <= 3)\n {\n Console.Write('!');\n }\n else Console.Write(lines[i - 1][j - 1]);\n }\n if (j == 3 || j == 6) Console.Write(' ');\n }\n if (i == 3 || i == 6) Console.WriteLine();\n Console.WriteLine();\n }\n\n Console.ReadLine();\n return;\n }\n else if (linie == 1 && coloana == 2)\n {\n bool isFull = true;\n for (int i = 1; i <= 3; i++)\n {\n for (int j = 4; j <= 6; j++)\n {\n if (lines[i - 1][j - 1] == '.')\n {\n isFull = false;\n break;\n }\n }\n }\n if (isFull)\n {\n WriteFull(lines);\n Console.ReadLine();\n return;\n\n }\n\n for (int i = 1; i <= 9; i++)\n {\n for (int j = 1; j <= 9; j++)\n {\n if (lines[i - 1][j - 1] != '.')\n {\n Console.Write(lines[i - 1][j - 1]);\n }\n else\n {\n if (i >= 1 && i <= 3 && j >= 4 && j <= 6)\n {\n Console.Write('!');\n }\n else Console.Write(lines[i - 1][j - 1]);\n \n }\n if (j == 3 || j == 6) Console.Write(' ');\n }\n if (i == 3 || i == 6)\n {\n Console.WriteLine();\n }\n\n Console.WriteLine();\n }\n\n Console.ReadLine();\n return;\n }\n else if (linie == 1 && coloana == 3)\n {\n bool isFull = true;\n for (int i = 1; i <= 3; i++)\n {\n for (int j = 7; j <= 9; j++)\n {\n if (lines[i - 1][j - 1] == '.')\n {\n isFull = false;\n break;\n }\n }\n }\n if (isFull)\n {\n WriteFull(lines);\n Console.ReadLine();\n return;\n\n }\n\n for (int i = 1; i <= 9; i++)\n {\n for (int j = 1; j <= 9; j++)\n {\n if (lines[i - 1][j - 1] != '.')\n {\n Console.Write(lines[i - 1][j - 1]);\n }\n else\n {\n if (i >= 1 && i <= 3 && j >= 7 && j <= 9)\n {\n Console.Write('!');\n }\n else Console.Write(lines[i - 1][j - 1]);\n \n }\n if (j == 3 || j == 6) Console.Write(' ');\n }\n if (i == 3 || i == 6) Console.WriteLine();\n\n Console.WriteLine();\n }\n\n Console.ReadLine();\n return;\n }\n else if (linie == 2 && coloana == 1)\n {\n bool isFull = true;\n for (int i = 4; i <= 6; i++)\n {\n for (int j = 1; j <= 3; j++)\n {\n if (lines[i - 1][j - 1] == '.')\n {\n isFull = false;\n break;\n }\n }\n }\n if (isFull)\n {\n WriteFull(lines);\n Console.ReadLine();\n return;\n\n }\n\n for (int i = 1; i <= 9; i++)\n {\n for (int j = 1; j <= 9; j++)\n {\n if (lines[i - 1][j - 1] != '.')\n {\n Console.Write(lines[i - 1][j - 1]);\n }\n else\n {\n if (i >= 4 && i <= 6 && j >= 1 && j <= 3)\n {\n Console.Write('!');\n }\n else Console.Write(lines[i - 1][j - 1]);\n }\n if (j == 3 || j == 6) Console.Write(' ');\n }\n\n if (i == 3 || i == 6) Console.WriteLine();\n\n Console.WriteLine();\n }\n\n Console.ReadLine();\n return;\n }\n else if (linie == 2 && coloana == 2)\n {\n bool isFull = true;\n for (int i = 4; i <= 6; i++)\n {\n for (int j = 4; j <= 6; j++)\n {\n if (lines[i - 1][j - 1] == '.')\n {\n isFull = false;\n break;\n }\n }\n }\n if (isFull)\n {\n WriteFull(lines);\n Console.ReadLine();\n return;\n\n }\n\n for (int i = 1; i <= 9; i++)\n {\n for (int j = 1; j <= 9; j++)\n {\n if (lines[i - 1][j - 1] != '.')\n {\n Console.Write(lines[i - 1][j - 1]);\n }\n else\n {\n if (i >= 4 && i <= 6 && j >= 4 && j <= 6)\n {\n Console.Write('!');\n }\n else Console.Write(lines[i - 1][j - 1]);\n }\n if (j == 3 || j == 6) Console.Write(' ');\n }\n if (i == 3 || i == 6) Console.WriteLine();\n\n Console.WriteLine();\n }\n\n Console.ReadLine();\n return;\n }\n else if (linie == 2 && coloana == 3)\n {\n bool isFull = true;\n for (int i = 4; i <= 6; i++)\n {\n for (int j = 7; j <= 9; j++)\n {\n if (lines[i - 1][j - 1] == '.')\n {\n isFull = false;\n break;\n }\n }\n }\n if (isFull)\n {\n WriteFull(lines);\n Console.ReadLine();\n return;\n\n }\n\n for (int i = 1; i <= 9; i++)\n {\n for (int j = 1; j <= 9; j++)\n {\n if (lines[i - 1][j - 1] != '.')\n {\n Console.Write(lines[i - 1][j - 1]);\n }\n else\n {\n if (i >= 4 && i <= 6 && j >= 7 && j <= 9)\n {\n Console.Write('!');\n }\n else Console.Write(lines[i - 1][j - 1]);\n }\n if (j == 3 || j == 6) Console.Write(' ');\n }\n if (i == 3 || i == 6) Console.WriteLine();\n Console.WriteLine();\n }\n\n Console.ReadLine();\n return;\n }\n else if (linie == 3 && coloana == 1)\n {\n bool isFull = true;\n for (int i = 7; i <= 9; i++)\n {\n for (int j = 1; j <= 3; j++)\n {\n if (lines[i - 1][j - 1] == '.')\n {\n isFull = false;\n break;\n }\n }\n }\n if (isFull)\n {\n WriteFull(lines);\n Console.ReadLine();\n return;\n\n }\n\n for (int i = 1; i <= 9; i++)\n {\n for (int j = 1; j <= 9; j++)\n {\n if (lines[i - 1][j - 1] != '.')\n {\n Console.Write(lines[i - 1][j - 1]);\n }\n else\n {\n if (i >= 7 && i <= 9 && j >= 1 && j <= 3)\n {\n Console.Write('!');\n }\n else Console.Write(lines[i - 1][j - 1]);\n }\n if (j == 3 || j == 6) Console.Write(' ');\n }\n if (i == 3 || i == 6) Console.WriteLine();\n Console.WriteLine();\n }\n\n Console.ReadLine();\n return;\n }\n else if (linie == 3 && coloana == 2)\n {\n bool isFull = true;\n for (int i = 7; i <= 9; i++)\n {\n for (int j = 4; j <= 6; j++)\n {\n if (lines[i - 1][j - 1] == '.')\n {\n isFull = false;\n break;\n }\n }\n }\n if (isFull)\n {\n WriteFull(lines);\n Console.ReadLine();\n return;\n\n }\n\n for (int i = 1; i <= 9; i++)\n {\n for (int j = 1; j <= 9; j++)\n {\n if (lines[i - 1][j - 1] != '.')\n {\n Console.Write(lines[i - 1][j - 1]);\n }\n else\n {\n if (i >= 7 && i <= 9 && j >= 4 && j <= 6)\n {\n Console.Write('!');\n }\n else Console.Write(lines[i - 1][j - 1]);\n }\n if (j == 3 || j == 6) Console.Write(' ');\n }\n if (i == 3 || i == 6) Console.WriteLine();\n Console.WriteLine();\n }\n\n Console.ReadLine();\n return;\n }\n else\n {\n bool isFull = true;\n for (int i = 7; i <= 9; i++)\n {\n for (int j = 7; j <= 9; j++)\n {\n if (lines[i - 1][j - 1] == '.')\n {\n isFull = false;\n break;\n }\n }\n }\n if (isFull)\n {\n WriteFull(lines);\n Console.ReadLine();\n return;\n\n }\n\n for (int i = 1; i <= 9; i++)\n {\n for (int j = 1; j <= 9; j++)\n {\n if (lines[i - 1][j - 1] != '.')\n {\n Console.Write(lines[i - 1][j - 1]);\n }\n else\n {\n if (i >= 7 && i <= 9 && j >= 7 && j <= 9)\n {\n Console.Write('!');\n }\n else Console.Write(lines[i - 1][j - 1]);\n }\n if (j == 3 || j == 6) Console.Write(' ');\n }\n if (i == 3 || i == 6) Console.WriteLine(); \n Console.WriteLine();\n }\n\n Console.ReadLine();\n return;\n }\n Console.ReadLine();\n }\n }\n}", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "36498c228f6165af339da78784ce7248", "src_uid": "8f0fad22f629332868c39969492264d3", "difficulty": 1400.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 = false;\n#else\nconst bool testing = false;\n#endif\n\n static void program(TextReader input)\n {\n //var n = int.Parse(input.ReadLine());\n var data = input.ReadLine().Split(' ').Select(int.Parse).ToList();\n if(data.Where(a => a==1).ToList().Count >= 1 || data.Where(a => a == 3).ToList().Count == 3 || data.Where(a => a == 2).ToList().Count >= 2 || (data.Where(a => a == 2).ToList().Count == 1 && data.Where(a => a == 4).ToList().Count == 2))\n {\n Console.WriteLine(\"YES\");\n } else\n {\n Console.WriteLine(\"NO\");\n }\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(\"YES\\n\");\n Console.WriteLine(\"Test Case(1) => found :\");\n program(new StringReader(\"2 2 3\\n\"));\n Console.WriteLine();\n\n Console.WriteLine(\"Test Case(2) => expected :\");\n Console.WriteLine(\"NO\\n\");\n Console.WriteLine(\"Test Case(2) => found :\");\n program(new StringReader(\"4 2 3\\n\"));\n Console.WriteLine();\n\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "constructive algorithms"], "code_uid": "c3148628bbeb1940123cc229617fcc26", "src_uid": "df48af9f5e68cb6efc1214f7138accf9", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.IO;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Diagnostics;\nusing System.Text;\nusing System.Threading.Tasks;\nusing System.Text.RegularExpressions;\n\nclass Program\n{\n public void Run()\n {\n var Elems = Console.ReadLine().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(long.Parse).ToArray();\n long n = Elems[0];\n long m = Elems[1];\n long max = 0;\n long count = 0;\n long counter = 0;\n if (m == 0) Console.WriteLine(\"{0} {1}\", n, n);\n else\n {\n while (true)\n {\n count++;\n if (m <= counter)\n {\n max = count;\n break;\n }\n counter += count;\n }\n Console.WriteLine(\"{0} {1}\", Math.Max(0, n - m * 2), n - max);\n }\n /*var Elems = Console.ReadLine().Split().Select(int.Parse).ToArray();\n int n = Elems[0];\n int k = Elems[1];\n var heights = Console.ReadLine().Split().Select(int.Parse).ToArray();\n int max = heights.Max();\n int[] h = new int[max + 2];\n for (int i = 0; i k)\n {\n s ++;\n tmp = 0;\n break;\n }\n j--;\n }\n Console.WriteLine(s);*/\n\n\n }\n \n\n\n\n\nstatic void Main()\n {\n new Program().Run();\n }\n}", "lang_cluster": "C#", "tags": ["constructive algorithms", "graphs"], "code_uid": "7038a6509daf93150415c79f305b75ee", "src_uid": "daf0dd781bf403f7c1bb668925caa64d", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nclass WayToHome{\n static int moves(string str, int d, int n){\n int curr = 0, moves = 0;\n while(curr=curr+1;i--){\n if(str[i] == '1'){\n flag = true;\n curr = i;\n moves++;\n break;\n }\n }\n if(!flag){\n return -1;\n }\n }\n return -1;\n }\n static void Main(string[] args){\n string[] str = Console.ReadLine().Trim().Split(' ');\n int n = Convert.ToInt32(str[0]), d = Convert.ToInt32(str[1]);\n string s = Console.ReadLine().Trim();\n Console.WriteLine(moves(s, d, n));\n }\n}", "lang_cluster": "C#", "tags": ["dfs and similar", "greedy", "dp", "implementation"], "code_uid": "6ffa79f44865c9c0ebd86c592077c621", "src_uid": "c08d2ecdfc66cd07fbbd461b1f069c9e", "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 if (x[x.Count - 1] >= 1e17 / ax) break;\n if (y[y.Count - 1] >= 1e17 / ay) break;\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 //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 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 }\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": "517c141350c36f83cfd63279b74e9cc3", "src_uid": "d8a7ae2959b3781a8a4566a2f75a4e28", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\n\nnamespace Tests\n{\n\tclass Program\n\t{\n\t\tpublic static void Main(string[] args)\n\t\t{\n\t\t\tstring[] s=Console.ReadLine().Split();\n\t\t\tint n=int.Parse(s[0]);\n\t\t\tint m=int.Parse(s[1]);\n\t\t\tint k=int.Parse(s[2]);\n\t\t\tint r=(k-1)/(m*2)+1;\n\t\t\tint p=(k-m*2*(r-1)+1)/2;\n\t\t\tstring st=k%2==0?\"R\":\"L\";\n\t\t\tConsole.WriteLine(string.Format(\"{0} {1} {2}\",r,p,st));\n\t\t}\n\t}\n}", "lang_cluster": "C#", "tags": ["math", "implementation"], "code_uid": "48d0fc98ef1eb89849be74040b69c3a3", "src_uid": "d6929926b44c2d5b1a8e6b7f965ca1bb", "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.Threading.Tasks;\n\nnamespace E\n{\n class Program\n {\n static int n;\n static int t;\n static int ti;\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 n = data[0];\n t = data[1];\n ti = 2 * t - 1;\n\n var variants = 0;\n dp = new int[22, 21, 5];\n for (int i = 0; i < 22; i++)\n for (int j = 0; j < 21; j++)\n for (int k = 0; k < 5; k++)\n {\n dp[i, j, k] = -1;\n }\n \n\n for (int i = 1; i < 4; i++)\n {\n variants += req(0, 1, i);\n }\n Console.WriteLine(variants);\n }\n\n static int[, ,] dp;\n static int req(int tCurrent, int x, int y)\n {\n if (dp[tCurrent, x, y] != -1)\n {\n return dp[tCurrent, x, y];\n }\n\n if (x == n)\n {\n if (tCurrent == ti)\n {\n return 1;\n }\n else\n {\n return 0;\n }\n }\n\n if (x == 1)\n {\n var upPath = 0;\n for (int j = y + 1; j <= 4; j++)\n {\n upPath += req(0, x + 1, j);\n }\n\n dp[tCurrent, x, y] = upPath;\n return upPath;\n }\n\n if (tCurrent % 2 == 0 || x == 2)\n {\n // \u043d\u0435\u0447\u0435\u0442\u043d\u043e\u0435, \u0433\u043e\u0440\u0431\n var downPath = 0;\n for (int i = y - 1; i >= 1; i--)\n {\n downPath += req(tCurrent + 1, x + 1, i);\n }\n\n var upPath = 0;\n for (int i = y + 1; i <= 4; i++)\n {\n upPath += req(tCurrent, x + 1, i);\n }\n\n dp[tCurrent, x, y] = downPath + upPath;\n\n return downPath + upPath;\n\n \n }\n else\n {\n // \u0427\u0435\u0442\u043d\u043e\u0435, \u043c\u044b \u043d\u0430 \u0432\u043f\u0430\u0434\u0438\u043d\u0435\n var downPath = 0;\n for (int i = y - 1; i >= 1; i--)\n {\n downPath += req(tCurrent, x + 1, i);\n }\n\n var upPath = 0;\n for (int i = y + 1; i <= 4; i++)\n {\n upPath += req(tCurrent + 1, x + 1, i);\n }\n\n dp[tCurrent, x, y] = downPath + upPath;\n\n return downPath + upPath;\n }\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["dp"], "code_uid": "fa45c22a5b5cb9e45664176e63fe0056", "src_uid": "6d67559744583229455c5eafe68f7952", "difficulty": 1900.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Diagnostics;\nusing System.IO;\nusing System.Linq;\nusing System.Threading;\n\nnamespace Temp\n{\n internal 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 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\n internal 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 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\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 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 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(\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 int m_Size;\n\n private 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 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 private 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 n, m, k;\n Reader.ReadLong(out n, out m, out k);\n\n long mod = 1000000000 + 7;\n\n long[,] c = new long[n + 1,n + 1];\n for (int i = 0; i <= n; i++)\n {\n c[i, 0] = 1;\n }\n for (int i = 1; i <= n; i++)\n {\n for (int j = 1; j <= n; j++)\n {\n c[i, j] = c[i - 1, j - 1] + c[i - 1, j];\n if (c[i,j] > mod)\n {\n c[i, j] -= mod;\n }\n }\n }\n\n long[] p0 = new long[n + 1];\n for (int i = 0; i <= n; i++)\n {\n p0[i] = Algebra.BinPower(c[n, i], m / n, mod);\n }\n\n long[] p1 = new long[n + 1];\n for (int i = 0; i <= n; i++)\n {\n p1[i] = (p0[i] * c[n, i]) % mod;\n }\n\n long[,] a = new long[n + 1,(n + 1) * (n + 1)];\n a[0, 0] = 1;\n for (int i = 0; i < n; i++)\n {\n for (int j = 0; j <= k; j++)\n {\n if (a[i,j] > 0)\n {\n var full = i < m % n;\n for (int l = 0; l <= n; l++)\n {\n long p = full ? p1[l] : p0[l];\n a[i + 1, j + l] = (a[i + 1, j + l] + p * a[i, j]) % mod;\n }\n }\n }\n }\n\n Console.WriteLine(a[n,k]);\n }\n }\n}", "lang_cluster": "C#", "tags": ["math", "dp", "combinatorics", "bitmasks"], "code_uid": "4df25ece527267d6815831931bd5d855", "src_uid": "9c71c8e031412e2bb21266a53821626a", "difficulty": 1900.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Text;\nusing System.IO;\n\npublic class taskC\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 private static void solve(MyReader instream, TextWriter outstream)\n {\n int[] abk = instream.ReadIntArray();\n\n\n int[] pr = new int[1000001];\n List primes = new List();\n primes.Add(2);\n pr[0] = 0;\n pr[1] = 0;\n pr[2] = 1;\n int prv = 3;\n bool ok;\n\n for (int i = 3; i < 1000001; i++)\n {\n ok = true;\n foreach (int j in primes)\n {\n if ((i % j) == 0) { ok = false; break; }\n if (j * j > i) break;\n }\n\n if (ok)\n {\n primes.Add(i);\n\n while (prv <= i)\n {\n pr[prv] = pr[prv - 1];\n prv++;\n }\n pr[prv-1]++;\n }\n }\n while (prv < 1000001)\n {\n pr[prv] = pr[prv - 1];\n prv++;\n }\n\n int a=abk[0];\n int b=abk[1];\n int k=abk[2];\n\n if (a == b)\n {\n if ((primes.Contains(a) && k <= 1) || k == 0)\n outstream.WriteLine(\"1\");\n else\n outstream.WriteLine(\"-1\");\n return;\n }\n int left = 1;\n int right = b - a + 1;\n \n while (left < right)\n {\n int mid = (left + right) >> 1;\n\n ok = true;\n for (int x = a; x <= b - mid + 1; x++)\n {\n int cnt = pr[x + mid - 1] - pr[x - 1];\n if (cnt < k) { ok = false; break; }\n }\n\n if (ok)\n {\n right = mid;\n }\n else\n {\n left = mid + 1;\n }\n\n }\n int len = left;\n ok = true;\n for (int x = a; x <= b - len + 1; x++)\n {\n int cnt = pr[x + len - 1] - pr[x - 1];\n if (cnt < k) { ok = false; break; }\n }\n\n if (ok)\n outstream.WriteLine(len);\n else\n outstream.WriteLine(\"-1\");\n }\n\n}\n", "lang_cluster": "C#", "tags": ["two pointers", "binary search", "number theory"], "code_uid": "4ae41c904d598b35285f84605e29cb2e", "src_uid": "3e1751a2990134f2132d743afe02a10e", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\n\nclass Program\n{\n static void Main(string[] args)\n {\n string inp = Console.ReadLine();\n string inp2 = Console.ReadLine();\n string x = inp + inp2[1] + inp2[0];\n inp = Console.ReadLine();\n inp2 = Console.ReadLine();\n string y = inp + inp2[1] + inp2[0];\n char[] xa = new char[3], ya = new char[3];\n int xi = 0, yi = 0;\n while (x[xi] != 'A')\n xi++;\n while (y[yi] != 'A')\n yi++;\n for (int i = 0; i < 3; i++)\n {\n if (x[xi] != 'X')\n xa[i] = x[xi];\n else\n i--;\n xi = xi == 3 ? 0 : xi + 1;\n }\n for (int i = 0; i < 3; i++)\n {\n if (y[yi] != 'X')\n ya[i] = y[yi];\n else\n i--;\n yi = yi == 3 ? 0 : yi + 1;\n }\n bool yes = true;\n for (int i = 0; i < 3; i++)\n {\n if (xa[i] != ya[i])\n {\n yes = false;\n break;\n }\n }\n Console.WriteLine(yes ? \"YES\" : \"NO\");\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "implementation"], "code_uid": "6f51f16ec777a43bf594e6852c367166", "src_uid": "46f051f58d626587a5ec449c27407771", "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 mod = 998244353L;\n var a = ReadLong();\n var b = ReadLong();\n var c = ReadLong();\n return Pair(a, b) * Pair(b, c) % mod * Pair(c, a) % mod;\n }\n\n long Pair(long a, long b)\n {\n var mod = 998244353L;\n if (a > b)\n {\n var t = a; a = b; b = t;\n }\n var kfact = Factorial(a, mod);\n var lfact = Factorial(b, mod);\n var numerator = lfact * kfact % mod;\n var tfact = 1L;\n var res = 0L;\n var ltfact = lfact;\n var ktfact = kfact;\n for (long t = 0; t <= a; t++)\n {\n var denominator = tfact * ltfact % mod * ktfact % mod;\n res = (res + numerator * FastPow(denominator, mod - 2, mod) % mod) % mod;\n tfact = tfact * (t + 1) % mod;\n if (t != a)\n {\n ltfact = ltfact * FastPow(b - t, mod - 2, mod) % mod;\n ktfact = ktfact * FastPow(a - t, mod - 2, mod) % mod;\n }\n }\n return res;\n }\n\n long FastPow(long a, long pow, long mod)\n {\n if (pow == 0)\n return 1;\n if (pow == 1)\n return a;\n if (pow % 2 == 0)\n return FastPow(a * a % mod, pow / 2, mod);\n return a * FastPow(a, pow - 1, mod) % mod;\n }\n\n long Factorial(long a, long mod)\n {\n var res = 1L;\n for (long i = 2; i <= a; i++)\n {\n res = res * i % mod;\n }\n return res;\n }\n\n long Happiness(long currentACount, long N, long S, Dude[] all, Dude bestA, Dude bestB, long left, long allPizzas)\n {\n if (currentACount == 0)\n {\n var ans = 0L;\n for (int i = 0; i < N; i++)\n {\n ans += all[i].B* all[i].s;\n\n }\n return ans + left * bestB.B;\n }\n var aPieces = 0L;\n var aHeap = new List();\n var bHeap = new List();\n var happy = 0L;\n for (int i = 0; i< N; i++)\n {\n var dude = all[i];\n if ((aPieces + dude.s - 1)/ S + 1 > currentACount)\n {\n for (long j = N - 1; j > i; j--)\n {\n bHeap.Add(all[j]);\n happy += dude.B * dude.Used;\n }\n var copy = dude;\n copy.Used = (S - aPieces % S) % S;\n aHeap.Add(copy);\n happy += copy.A * copy.Used;\n var used = copy.Used;\n copy = dude;\n copy.Used = copy.s - used;\n bHeap.Add(copy);\n happy += copy.B * copy.Used;\n break;\n }\n else\n {\n dude.Used = dude.s;\n aHeap.Add(dude);\n happy += dude.A*dude.Used;\n }\n }\n var dudeA = bestA;\n var dudeB = bestB;\n if (currentACount == allPizzas)\n {\n return happy + left * dudeA.A;\n }\n dudeA.Used = 0;\n dudeB.Used = left;\n var finalHappy = happy + dudeB.B * dudeB.Used;\n var leftInB = left;\n\n while (leftInB > 0)\n {\n var last = aHeap[aHeap.Count - 1];\n if (last.Used == 0)\n {\n aHeap.RemoveAt(aHeap.Count - 1);\n last = aHeap[aHeap.Count - 1];\n }\n var profit = dudeA.A - dudeB.B + last.B - last.A;\n if (profit <= 0)\n return finalHappy;\n leftInB--;\n last.Used--;\n aHeap[aHeap.Count - 1] = last;\n finalHappy += profit;\n }\n return finalHappy;\n }\n\n struct Dude\n {\n public long s;\n public long A;\n public long B;\n public long Diff;\n public long Used;\n }\n\n class Node {\n public Node()\n {\n Children = new Node[10];\n }\n public Node[] Children { get; set; }\n public int Count { get; set; }\n public char Letter { get; set; }\n\n public string Final { get; set; }\n private int Rev = -1;\n\n public void RecursePlus()\n {\n if (Rev != -1)\n Count++;\n for (int i = 0; i < 10; i++)\n {\n if (Children[i] != null)\n {\n Children[i].RecursePlus();\n }\n }\n }\n public void Insert(string s, int begin, int rev)\n {\n //Count++;\n if (rev != Rev)\n {\n if (Rev != -1)\n Count++;\n Rev = rev;\n }\n if (begin == s.Length)\n {\n Final = s;\n return;\n }\n if (Children[s[begin] - '0'] == null)\n Children[s[begin] - '0'] = new Node();\n Children[s[begin] - '0'].Insert(s, begin + 1, rev);\n }\n\n public void Recurse(Dictionary dct, List sofar)\n {\n if (Count == 1)\n this.SetAns(dct, new string(sofar.ToArray()));\n else\n for (int i = 0; i < 10; i++)\n {\n if (Children[i] != null)\n {\n sofar.Add(i.ToString()[0]);\n Children[i].Recurse(dct, sofar);\n sofar.RemoveAt(sofar.Count - 1);\n }\n }\n }\n public void SetAns(Dictionary dct, string ans) {\n if (Final != null)\n {\n if (!dct.ContainsKey(Final) || dct[Final].Length > ans.Length)\n dct[Final] = ans;\n return;\n }\n for (int i = 0; i < 10; i++)\n {\n if (Children[i] != null)\n {\n Children[i].SetAns(dct, ans);\n return;\n }\n }\n }\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", "dp", "combinatorics"], "code_uid": "f3721a029953f4948a51fda79cbc2143", "src_uid": "b6dc5533fbf285d5ef4cf60ef6300383", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Linq;\nusing System.Collections.Generic;\nusing Debug = System.Diagnostics.Debug;\nusing SB = System.Text.StringBuilder;\nusing Number = System.Int64;\nusing static System.Math;\n//using static MathEx;\nnamespace Program\n{\n public class Solver\n {\n public void Solve()\n {\n var n = ri;\n var c = new char[n];\n var a = new int[n];\n var b = new int[n];\n for (int i = 0; i < n; i++)\n {\n c[i] = rc;\n a[i] = ri;\n b[i] = ri;\n }\n var dp = new int[1 << n, 16 * 16 / 2];\n for (int i = 0; i < 1 << n; i++)\n for (int j = 0; j < 16 * 16 / 2; j++)\n dp[i, j] = -1000000000;\n dp[0, 0] = 0;\n for (int i = 0; i < 1 << n; i++)\n for (int j = 0; j < 16 * 16 / 2; j++)\n {\n if (dp[i, j] < 0) continue;\n var u = 0;\n var v = 0;\n for (int k = 0; k < n; k++)\n {\n if ((i >> k & 1) == 1)\n {\n if (c[k] == 'R') u++;\n else v++;\n }\n }\n for (int k = 0; k < n; k++)\n {\n if ((i >> k & 1) == 0)\n {\n var x = Min(u, a[k]);\n var y = Min(v, b[k]);\n dp[i | 1 << k, j + x] = Max(dp[i | 1 << k, j + x], dp[i, j] + y);\n }\n }\n }\n var min = 1000000000;\n for (int i = 0; i < 16 * 16 / 2; i++)\n {\n if (dp[(1 << n) - 1, i] < 0) continue;\n var u = a.Sum() - i;\n var v = b.Sum() - dp[(1 << n) - 1, i];\n min = Min(min, Max(u, v));\n }\n IO.Printer.Out.WriteLine(min + n);\n }\n\n int ri => sc.Integer();\n long rl => sc.Long();\n double rd => sc.Double();\n string rs => sc.Scan();\n char rc => sc.Char();\n\n [System.Diagnostics.Conditional(\"DEBUG\")]\n void put(params object[] a) => Debug.WriteLine(string.Join(\" \", a));\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\n", "lang_cluster": "C#", "tags": ["brute force", "dp", "bitmasks"], "code_uid": "8644fc2696e4030850023e65a3673110", "src_uid": "25a77f2b7cb281ff3c7800a20b3e5969", "difficulty": 2400.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeff//\ufeff\ufeff\ufeff\ufeff#define EXTENDSTACKSIZE\n\n\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Globalization;\nusing System.IO;\n using System.Linq;\n using System.Linq.Expressions;\n using System.Text;\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 \n private readonly TextWriter sw;\n \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.NextInt64();\n var k = sr.NextInt64();\n var answ = Int64.MaxValue;\n for (var i = 1; i < k; i++) {\n var x = n * k / i;\n for (var j = 0; j < k; j++) {\n var t = x + j;\n if (t % k == i && (t / k) * i == n) {\n answ = Math.Min(answ, t);\n }\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": ["math"], "code_uid": "2043823853e650438a176feb8bcf9d83", "src_uid": "ed0ebc1e484fcaea875355b5b7944c57", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using Boilerplate.IO;\nusing System;\nusing System.Collections.Generic;\nusing System.Diagnostics;\nusing System.Globalization;\nusing System.IO;\nusing System.Linq;\nusing System.Text;\nusing System.Threading;\nusing System.Threading.Tasks;\n\npublic class Solver\n{\n private readonly StreamReader reader;\n private readonly StreamWriter writer;\n\n public Solver(StreamReader reader, StreamWriter writer)\n {\n this.reader = reader;\n this.writer = writer;\n }\n\n public void Generate()\n {}\n\n public void Do()\n {\n var a = reader.ReadInt();\n var b = reader.ReadInt();\n var k = reader.ReadInt();\n var t = reader.ReadInt();\n\n const int MOD = (int)(1e9 + 7);\n var dim = new int[2][];\n var MED = 2 * k * t;\n dim[0] = new int[MED * 2 + 1];\n dim[1] = new int[MED * 2 + 1];\n var tmp = new int[MED * 2 + 1];\n int h = 0;\n dim[h][MED] = 1;\n for (int i = 1; i <= t; ++i)\n {\n tmp[0] = dim[h][0];\n for (int j = 1; j < tmp.Length; ++j)\n tmp[j] = (dim[h][j] + tmp[j - 1]) % MOD;\n h ^= 1;\n Array.Clear(dim[h], 0, dim[h].Length);\n for (int j = 0; j < dim[h].Length; ++j)\n {\n var acc = 0L;\n if (j > 0)\n acc = dim[h][j - 1];\n acc += 1L * tmp[Math.Min(j + 2 * k, tmp.Length - 1)] - 2L * tmp[Math.Max(j - 1, 0)] + tmp[Math.Max(j - 2 - 2 * k, 0)];\n acc %= MOD;\n dim[h][j] = (int)((acc + MOD) % MOD);\n }\n }\n int res = 0;\n int st = b - a + 1 + MED;\n st = Math.Max(st, 0);\n for (int i = st; i < dim[h].Length; ++i)\n res = (res + dim[h][i]) % MOD;\n writer.WriteLine(res);\n }\n}\n\n#region launch\nclass Program\n{\n static void Main(string[] args)\n {\n using (var writer = new FormattedStreamWriter(\n#if SOLVER_RUN_LOCAL\n\"output.txt\"\n#else \n Console.OpenStandardOutput()\n#endif\n))\n {\n using (var reader = new StreamReader(\n#if SOLVER_RUN_LOCAL\n\"input.txt\"\n#else \n Console.OpenStandardInput() \n#endif\n))\n {\n#if SOLVER_RUN_LOCAL\n var stopw = new Stopwatch();\n stopw.Start();\n#endif\n new Solver(reader, writer).Do();\n#if SOLVER_RUN_LOCAL\n stopw.Stop();\n writer.WriteLine(\"> {0}ms\", stopw.ElapsedMilliseconds);\n#endif\n }\n }\n }\n}\n#endregion\n\nnamespace Boilerplate.IO\n{\n #region helpers\n class FormattedStreamWriter : StreamWriter\n {\n public FormattedStreamWriter(Stream stream) : base(stream) { }\n public FormattedStreamWriter(string filePath) : base(filePath) { }\n public override IFormatProvider FormatProvider\n {\n get\n {\n return CultureInfo.InvariantCulture;\n }\n }\n }\n static class IOExtensions\n {\n public static string ReadString(this StreamReader reader)\n {\n return reader.ReadToken();\n }\n public static int ReadInt(this StreamReader reader)\n {\n return int.Parse(reader.ReadToken(), CultureInfo.InvariantCulture);\n }\n public static long ReadLong(this StreamReader reader)\n {\n return long.Parse(reader.ReadToken(), CultureInfo.InvariantCulture);\n }\n public static double ReadDouble(this StreamReader reader)\n {\n return double.Parse(reader.ReadToken(), CultureInfo.InvariantCulture);\n }\n public static decimal ReadDecimal(this StreamReader reader)\n {\n return decimal.Parse(reader.ReadToken(), CultureInfo.InvariantCulture);\n }\n\n static Queue buffer = new Queue(100);\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 } return buffer.Dequeue();\n }\n }\n #endregion\n}", "lang_cluster": "C#", "tags": ["math", "dp", "combinatorics"], "code_uid": "dde21dff1174cee7982a48abcb71c5c4", "src_uid": "8b8327512a318a5b5afd531ff7223bd0", "difficulty": 2200.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 d = rl;\n var k = rl;\n var a = rl;\n var b = rl;\n var t = rl;\n\n\n \n if (d <= k)\n {\n wln(d * a);\n return;\n }\n d -= k;\n\n long pesh = d * b;\n long auto = (d / k) * (k * a + t);\n long s = auto + (d % k) * b;\n if (d % k != 0)\n {\n auto += (d % k) * a + t;\n }\n\n\n\n long res = Math.Min(pesh, Math.Min(auto, s));\n wln(k * a + res);\n\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"], "code_uid": "319824a57f127a284665228baff50b85", "src_uid": "359ddf1f1aed9b3256836e5856fe3466", "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 ConsoleApplication1\n{\n class Program\n {\n \n static void Main(string[] args)\n {\n int N = Convert.ToInt16(Console.ReadLine());\n Boolean[,] friends = new Boolean[6, 6]; \n for (int i = 0; i < N; ++i)\n {\n String S = Console.ReadLine();\n String[] A = S.Split(' ');\n int a = Convert.ToInt16(A[0]);\n int b = Convert.ToInt16(A[1]);\n friends[a, b] = true;\n friends[b, a] = true;\n }\n for(int i = 1; i <= 3; ++ i)\n {\n for (int j = i + 1; j <= 4; ++j)\n {\n for (int k = j + 1; k <= 5; ++k)\n {\n if ((friends[i, j] == true && friends[j, k] == true&& friends[k, i])==true || (friends[i, j]==false && friends[j, k]==false && friends[k, i] ==false))\n {\n Console.WriteLine(\"WIN\");\n return;\n }\n }\n }\n }\n Console.WriteLine(\"FAIL\");\n }\n \n }\n}\n", "lang_cluster": "C#", "tags": ["math", "implementation", "graphs"], "code_uid": "9cb6a8e911ae1dc9e3332a11916e6635", "src_uid": "2bc18799c85ecaba87564a86a94e0322", "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;\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 string[] s = Console.ReadLine().Split(' ');\n Int64 n = Int64.Parse(s[0]);\n Int64 m = Int64.Parse(s[1]);\n\n Int64 left = 0;\n Int64 right = n + 1;\n\n while(left+(Int64)1= n)\n {\n return true;\n }else\n {\n return false;\n }\n }\n Int64 prev = 0;\n if(day-1<=m)\n {\n if (n > day) return false;\n return true;\n }\n else\n {\n //if (n - (day + m ) * (day - 1 - m ) / 2 + m * (day - 1 - m ) > day) return false;\n if ( (-day + 1 + m) > 2*(day-n)/ (-m + day) \n || ((-day + 1 + m) == 2 * (day - n) / (-m + day) && 2 * (day - n) % (-m + day)!=0)) return false;\n return true;\n }\n } \n }\n}\n", "lang_cluster": "C#", "tags": ["math", "binary search"], "code_uid": "41c8599e337b280c747eef7bdb1f7f07", "src_uid": "3b585ea852ffc41034ef6804b6aebbd8", "difficulty": 1600.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": "238d3703a345d272da3bca6d2ecbbd69", "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;\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 const int INF = 100000;\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] = INF;\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 || !char.IsDigit(b1[y + dy[i]][x + dx[i]]))\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 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 (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 ('1' <= 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 continue;\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 {\n if (!('1' <= b2[a][b] && b2[a][b] <= '9'))\n continue;\n int cnt = b2[a][b] - '0';\n for (int i = 0; i < cnt; i++, idx++)\n if (dist[b, a] < INF)\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 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": "055eccd81c79379bdbf7ae18f3ea916a", "src_uid": "544de9c3729a35eb08c143b1cb9ee085", "difficulty": 2300.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 n = int.Parse(Console.ReadLine());\n var a = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();\n var b = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();\n double rez = a.Where((x, i) => x == 1 && b[i] == 0).Sum();\n int aSum = a.Sum();\n int bSum = b.Sum();\n Console.WriteLine(aSum>bSum?1:\n rez == 0|| aSum == 0 || aSum == n && bSum == n ? -1 :\n Math.Ceiling((bSum-aSum+1)/rez)+1);\n }\n }\n}", "lang_cluster": "C#", "tags": ["greedy"], "code_uid": "38295697bad1fa1a6045c3140d14bb16", "src_uid": "b62338bff0cbb4df4e5e27e1a3ffaa07", "difficulty": 900.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{\n\t\t\n int n=Convert.ToInt32(Console.ReadLine());\t\t\n int[] num=new int[n];\n string s=Console.ReadLine();\n string[] values=s.Split(' '); \n \n for (int i = 0; i < n; i++) {\n num[i]=int.Parse(values[i]);\n }\n if (num[0] % 2 == 1 && num[n-1] % 2 == 1 && n%2==1) {\n Console.WriteLine(\"YES\");\n }\n else {\n Console.WriteLine(\"NO\");\n }\n\t}\n}", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "efdbaf63fd182bf38725567c598df33d", "src_uid": "2b8c2deb5d7e49e8e3ededabfd4427db", "difficulty": 1000.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 CoderStrike2014\n{\n\tclass R2_A\n\t{\n\t\tpublic void Solve(XOI xoi)\n\t\t{\n\t\t\tint i, N, M, Max, Min, t, cnt;\n\t\t\tbool ans = true;\n\n\t\t\tN = xoi.ReadInt(); M = xoi.ReadInt();\n\t\t\tMin = xoi.ReadInt(); Max = xoi.ReadInt();\n\n\t\t\tfor (i = cnt = 0; i < M && ans; i++)\n\t\t\t{\n\t\t\t\tt = xoi.ReadInt();\n\t\t\t\tif (t > Min && t < Max)\n\t\t\t\t\tcnt++;\n\t\t\t\telse\n\t\t\t\t\tans = (t == Min || t == Max);\n\t\t\t}\n\t\t\tans &= (cnt + 2 <= N);\n\n\t\t\txoi.o.WriteLine(ans ? \"Correct\" : \"Incorrect\");\n\t\t}\n\t}\n\n\tclass CS2014_R2\n\t{\n\t\tstatic void Main(string[] args)\n\t\t{\n\t\t\tXOI xoi = new XOI();\n\t\t\t(new R2_A()).Solve(xoi);\n\t\t}\n\t}\n}\n\nnamespace CCF_XOI\n{\t// version 2014.02.07\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);\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": "e0ce5c953128d5ca146341ef450eb1cb", "src_uid": "99f9cdc85010bd89434f39b78f15b65e", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nclass Program\n {\n static void Main(string[] args)\n {\n long a, b, lstTkn = 1L;\n {\n string[] input = Console.ReadLine().Split(new char[] { ' ', '\\t'}, StringSplitOptions.RemoveEmptyEntries);\n a = long.Parse(input[0]);\n b = long.Parse(input[1]);\n if (a == 0) { a++; if (b == 0) b++; }\n }\n while(++a<=b && lstTkn>0L)\n {\n lstTkn *= (a%10L);\n lstTkn %= 10L;\n }\n Console.WriteLine(lstTkn);\n }\n }", "lang_cluster": "C#", "tags": ["math"], "code_uid": "becfca75dfdcdcd358aae4f5d5e7bbae", "src_uid": "2ed5a7a6176ed9b0bda1de21aad13d60", "difficulty": 1100.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 a = ReadLongToken();\n var b = ReadLongToken();\n var n = ReadLongToken();\n var x = ReadLongToken();\n if (a == 1)\n return (x + b * (n % commonMod)) % commonMod;\n var first = (FastPow(a, n, commonMod) * x) % commonMod;\n var q1 = (FastPow(a, n, commonMod) + commonMod - 1);\n var q2 = FastPow(a - 1, commonMod - 2, commonMod);\n var second = b * ((q1 * q2) % commonMod);\n return (first + second) % commonMod;\n }\n }\n\n long FastPow(long b, long pow, long mod)\n {\n if (pow == 0)\n return 1;\n if (pow == 1)\n return b;\n if (pow % 2 == 0)\n return FastPow((b * b) % mod, pow / 2, mod);\n return (FastPow(b, pow - 1, mod) * b) % mod;\n }\n\n //object Get()\n //{\n // checked\n // {\n // var n = ReadIntToken();\n // var k = ReadIntToken();\n // var table = new bool[n, n];\n // for (int i = 0; i < n; i++)\n // {\n // var input = Read();\n // for (int j = 0; j < n; j++)\n // table[i, j] = input[j] == '.';\n // }\n // var cells = BFS(table); \n // }\n //}\n //Cell[,] BFS(bool[,] input)\n //{\n // var n = input.GetLength(0);\n // var cells = new Cell[n, n];\n // var visited = new bool[n, n];\n // var componentIndex = 0;\n // for (int i = 0; i < n; i++)\n // {\n // for (int j = 0; j < n; j++)\n // {\n // if (!visited[i, j] && input[i, j])\n // BFS(i, j, cells, input, visited, componentIndex);\n // }\n // }\n //}\n\n //void BFS(int i, int j, Cell[,] cells, bool[,] input, bool[,] visited, int ccIndex)\n //{\n // var n = input.GetLength(0);\n // for\n //}\n\n struct Cell\n {\n int CCNumber { 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": ["math", "number theory"], "code_uid": "85a626ea27b9e0f75fe0c19c281bce53", "src_uid": "e22a1fc38c8b2a4cc30ce3b9f893028e", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeff/*\n * TemplateCS\n * Copyright (C) 2014-2016 Markus Himmel\n * This file is distributed under the terms of the MIT license\n */\n\n//#define CodeJam\n#define CodeForces\n\nusing System;\nusing System.Collections;\nusing System.Collections.Generic;\nusing System.Diagnostics;\nusing System.Globalization;\nusing System.Linq;\nusing System.Runtime.InteropServices;\n\n// ReSharper disable RedundantUsingDirective\nusing System.IO;\n\n// ReSharper restore RedundantUsingDirective\n\n// ReSharper disable UnusedMember.Local\n\n// ReSharper disable once CheckNamespace\n\nnamespace ProgrammingCompetitions\n{\n\tinternal class Program\n\t{\n\t\t#region GCJ\n\n#if CodeJam\n\t\tprivate static bool DEBUG = false;\n\n\t\tstatic void debug()\n\t\t{\n\t\t}\n\n\t\tstatic string solveCase(int num)\n\t\t{\n\t\t\tchecked\n\t\t\t{\n\t\t\t\treturn null;\n\t\t\t}\n\t\t}\n#endif\n\n\t\t#endregion\n\n\t\t#region CodeForces\n\n#if CodeForces\n#if DEBUG\n\t\tprivate static readonly Queue testInput = new Queue(@\"\n\n\n\n2\n2 2\n\n\".Split(new[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries));\n#endif\n\n\t\tprivate static object solve()\n\t\t{\n\t\t\t// ReSharper disable once RedundantOverflowCheckingContext\n\t\t\tchecked\n\t\t\t{\n\t\t\t\tint n = read();\n\t\t\t\tint[][] dp = n.Of(() => new int[3]).ToArray();\n\t\t\t\tint[] o = readMany();\n\n\t\t\t\tdp[0][0] = 1;\n\t\t\t\tdp[0][1] = o[0] >= 2 ? 0 : int.MaxValue;\n\t\t\t\tdp[0][2] = o[0] % 2 == 1 ? 0 : int.MaxValue;\n\n\t\t\t\tfor (int i = 1; i < n; i++)\n\t\t\t\t{\n\t\t\t\t\tdp[i][0] = dp[i - 1].Min() + 1;\n\t\t\t\t\tdp[i][1] = o[i] >= 2 ? Math.Min(dp[i - 1][0], dp[i - 1][2]) : int.MaxValue;\n\t\t\t\t\tdp[i][2] = o[i] % 2 == 1 ? Math.Min(dp[i - 1][0], dp[i - 1][1]) : int.MaxValue;\n\t\t\t\t}\n\n\t\t\t\treturn dp[n - 1].Min();\n\t\t\t}\n\t\t}\n#endif\n\n\t\t#endregion\n\n\t\t// Everything after this comment is template code\n\n\t\tprivate static T read()\n\t\t{\n\t\t\treturn (T)Convert.ChangeType(read(), typeof(T));\n\t\t}\n\n\t\tprivate static T[] readMany()\n\t\t{\n\t\t\t// ReSharper disable once PossiblyMistakenUseOfParamsMethod\n\t\t\treturn readMany(' ');\n\t\t}\n\n\t\tprivate static T[] readMany(params char[] ___)\n\t\t{\n\t\t\treturn read().Split(___).Select(__ => (T)Convert.ChangeType(__, typeof(T))).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[][] readMany(int n)\n\t\t{\n\t\t\tvar res = new T[n][];\n\t\t\tfor (int i = 0; i < n; i++)\n\t\t\t\tres[i] = readMany();\n\t\t\treturn res;\n\t\t}\n\n\t\tprivate static T[][] readField(int height, Func map)\n\t\t{\n\t\t\tvar res = new T[height][];\n\t\t\tfor (int _ = 0; _ < height; _++)\n\t\t\t\tres[_] = read().Select(map).ToArray();\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\tprivate static void read(out T1 t1)\n\t\t{\n\t\t\tstring[] vals = readMany();\n\t\t\tt1 = (T1)Convert.ChangeType(vals[0], typeof(T1));\n\t\t}\n\n\t\tprivate static void read(out T1 t1, out T2 t2)\n\t\t{\n\t\t\tstring[] vals = readMany();\n\t\t\tt1 = (T1)Convert.ChangeType(vals[0], typeof(T1));\n\t\t\tt2 = (T2)Convert.ChangeType(vals[1], typeof(T2));\n\t\t}\n\n\t\tprivate static void read(out T1 t1, out T2 t2, out T3 t3)\n\t\t{\n\t\t\tstring[] vals = readMany();\n\t\t\tt1 = (T1)Convert.ChangeType(vals[0], typeof(T1));\n\t\t\tt2 = (T2)Convert.ChangeType(vals[1], typeof(T2));\n\t\t\tt3 = (T3)Convert.ChangeType(vals[2], typeof(T3));\n\t\t}\n\n\t\tprivate static void read(out T1 t1, out T2 t2, out T3 t3, out T4 t4)\n\t\t{\n\t\t\tstring[] vals = readMany();\n\t\t\tt1 = (T1)Convert.ChangeType(vals[0], typeof(T1));\n\t\t\tt2 = (T2)Convert.ChangeType(vals[1], typeof(T2));\n\t\t\tt3 = (T3)Convert.ChangeType(vals[2], typeof(T3));\n\t\t\tt4 = (T4)Convert.ChangeType(vals[3], typeof(T4));\n\t\t}\n\n\t\tprivate static void read(out T1 t1, out T2 t2, out T3 t3, out T4 t4, out T5 t5)\n\t\t{\n\t\t\tstring[] vals = readMany();\n\t\t\tt1 = (T1)Convert.ChangeType(vals[0], typeof(T1));\n\t\t\tt2 = (T2)Convert.ChangeType(vals[1], typeof(T2));\n\t\t\tt3 = (T3)Convert.ChangeType(vals[2], typeof(T3));\n\t\t\tt4 = (T4)Convert.ChangeType(vals[3], typeof(T4));\n\t\t\tt5 = (T5)Convert.ChangeType(vals[4], typeof(T5));\n\t\t}\n\n\t\tprivate static Func dp(Func, TResult> f)\n\t\t{\n\t\t\tvar cache = new Dictionary, TResult>();\n\t\t\tFunc res = null;\n\t\t\tres = t1 =>\n\t\t\t{\n\t\t\t\tTuple key = Tuple.Create(t1);\n\t\t\t\tif (!cache.ContainsKey(key))\n\t\t\t\t\tcache.Add(key, f(t1, res));\n\t\t\t\treturn cache[key];\n\t\t\t};\n\t\t\treturn res;\n\t\t}\n\n\t\tprivate static Func dp(Func, TResult> f)\n\t\t{\n\t\t\tvar cache = new Dictionary, TResult>();\n\t\t\tFunc res = null;\n\t\t\tres = (t1, t2) =>\n\t\t\t{\n\t\t\t\tTuple key = Tuple.Create(t1, t2);\n\t\t\t\tif (!cache.ContainsKey(key))\n\t\t\t\t\tcache.Add(key, f(t1, t2, res));\n\t\t\t\treturn cache[key];\n\t\t\t};\n\t\t\treturn res;\n\t\t}\n\n\t\tprivate static Func dp(Func, TResult> f)\n\t\t{\n\t\t\tvar cache = new Dictionary, TResult>();\n\t\t\tFunc res = null;\n\t\t\tres = (t1, t2, t3) =>\n\t\t\t{\n\t\t\t\tTuple 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, res));\n\t\t\t\treturn cache[key];\n\t\t\t};\n\t\t\treturn res;\n\t\t}\n\n\t\tprivate static Func dp(Func, TResult> f)\n\t\t{\n\t\t\tvar cache = new Dictionary, TResult>();\n\t\t\tFunc res = null;\n\t\t\tres = (t1, t2, t3, t4) =>\n\t\t\t{\n\t\t\t\tTuple 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, res));\n\t\t\t\treturn cache[key];\n\t\t\t};\n\t\t\treturn res;\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 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\tyield return i;\n\t\t}\n\n\t\tprivate static 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\tyield return i;\n\t\t}\n\n\t\tprivate static T id(T a)\n\t\t{\n\t\t\treturn a;\n\t\t}\n\n\t\tpublic static T[][] Mkarr(int x, int y)\n\t\t{\n\t\t\tvar res = new T[x][];\n\t\t\tfor (int i = 0; i < x; i++)\n\t\t\t\tres[i] = new T[y];\n\t\t\treturn res;\n\t\t}\n\n\t\tpublic static T[][][] Mkarr(int x, int y, int z)\n\t\t{\n\t\t\tvar res = new T[x][][];\n\t\t\tfor (int i = 0; i < x; i++)\n\t\t\t{\n\t\t\t\tres[i] = new T[y][];\n\t\t\t\tfor (int j = 0; j < y; j++)\n\t\t\t\t\tres[i][j] = new T[z];\n\t\t\t}\n\t\t\treturn res;\n\t\t}\n\n\t\tprivate static bool[] tf = { true, false };\n\n#if CodeJam\n\n\t\tstatic void Main(string[] args)\n\t\t{\n\t\t\tif (DEBUG)\n\t\t\t{\n\t\t\t\tdebug();\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tInitialize();\n\t\t\t\tSolveAll(solveCase);\n\t\t\t}\n\t\t\tConsole.ReadKey();\n\t\t}\n\n\t\tprivate static StreamReader inf;\n\t\tprivate static StreamWriter outf;\n\n\t\tprivate delegate void o(string format, params object[] args);\n\t\tprivate static o Output;\n\n\t\tpublic static void Initialize()\n\t\t{\n\t\t\tConsole.ForegroundColor = ConsoleColor.Yellow;\n\t\t\tConsole.Write(\"File name: \");\n\t\t\tstring name = Console.ReadLine();\n\t\t\tinf = new StreamReader($\"D:\\\\Users\\\\marku\\\\Downloads\\\\{name}.in\");\n\t\t\toutf = new StreamWriter($\"D:\\\\Users\\\\marku\\\\Downloads\\\\{name}.out\");\n\t\t\tConsole.ForegroundColor = ConsoleColor.White;\n\t\t\tOutput = highlightedPrint;\n\t\t\tOutput += outf.WriteLine;\n\t\t}\n\n\t\tprivate static void highlightedPrint(string format, params object[] args)\n\t\t{\n\t\t\tConsoleColor prev = Console.ForegroundColor;\n\t\t\tConsole.ForegroundColor = ConsoleColor.Green;\n\t\t\tConsole.WriteLine(format, args);\n\t\t\tConsole.ForegroundColor = prev;\n\t\t}\n\n\t\tpublic static void SolveAll(Func calc)\n\t\t{\n\t\t\tint cases = int.Parse(inf.ReadLine());\n\t\t\tfor (int _ = 1; _ <= cases; _++)\n\t\t\t{\n\t\t\t\tOutput($\"Case #{_}: {calc(_)}\");\n\t\t\t}\n\t\t\tinf.Close();\n\t\t\toutf.Close();\n\t\t\tConsole.ForegroundColor = ConsoleColor.Cyan;\n\t\t\tConsole.WriteLine(\"Eureka!\");\n\t\t}\n\n\t\tprivate static string read()\n\t\t{\n\t\t\treturn inf.ReadLine();\n\t\t}\n#endif\n\n#if CodeForces\n\t\tprivate static string asString(object s)\n\t\t{\n\t\t\tif (s is double)\n\t\t\t\treturn ((double)s).ToString(\"0.000000000\", CultureInfo.InvariantCulture);\n\t\t\treturn s.ToString();\n\t\t}\n\n\t\tpublic static void Main(string[] args)\n\t\t{\n#if DEBUG\n\t\t\tStopwatch sw = new Stopwatch();\n\t\t\tsw.Start();\n#endif\n\t\t\tobject o = solve();\n\t\t\tif (o != null)\n\t\t\t{\n\t\t\t\tstring s;\n\t\t\t\tIEnumerable e = o as IEnumerable;\n\t\t\t\tif ((e != null) && !(o is string))\n\t\t\t\t\ts = string.Join(\" \", e.OfType().Select(asString));\n\t\t\t\telse\n\t\t\t\t\ts = asString(o);\n\t\t\t\tif (!string.IsNullOrEmpty(s))\n\t\t\t\t\tConsole.WriteLine(s);\n\t\t\t}\n#if DEBUG\n\t\t\tsw.Stop();\n\t\t\tConsole.WriteLine(sw.Elapsed);\n\t\t\tConsole.ReadKey();\n#endif\n\t\t}\n\n\t\tprivate static string read()\n\t\t{\n#if !DEBUG\n\t\t\treturn Console.ReadLine();\n#else\n\t\t\treturn testInput.Dequeue();\n#endif\n\t\t}\n#endif\n\t}\n\n\tpublic static class ExtensionMethods\n\t{\n\t\tpublic static IEnumerable Of(this int n, Func gen)\n\t\t{\n\t\t\tfor (int i = 0; i < n; i++)\n\t\t\t\tyield return gen();\n\t\t}\n\n\t\tpublic static IEnumerable Of(this int n, Func gen)\n\t\t{\n\t\t\tfor (int i = 0; i < n; i++)\n\t\t\t\tyield return gen(i);\n\t\t}\n\n\t\tpublic static IEnumerable Of(this int n, T gen)\n\t\t{\n\t\t\tfor (int i = 0; i < n; i++)\n\t\t\t\tyield return gen;\n\t\t}\n\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> CartesianE(this IEnumerable first, IEnumerable second)\n\t\t{\n\t\t\t// Calling CartesianE prevents selection of the wrong overload of Cartesian when you want a tuple of tuples to be returned\n\t\t\treturn first.Cartesian(second);\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> Cartesian(this IEnumerable> source)\n\t\t{\n\t\t\tIEnumerable[] enumerable = source as IEnumerable[] ?? source.ToArray();\n\t\t\tIEnumerable> res = enumerable.First().Select(single);\n\t\t\tforeach (IEnumerable next in enumerable.Skip(1))\n\t\t\t\tres = res.Cartesian(next, (sofar, n) => sofar.Concat(single(n)));\n\t\t\treturn res;\n\t\t}\n\n\t\tpublic static IEnumerable> Pow(this IEnumerable it, int num)\n\t\t{\n\t\t\treturn Enumerable.Repeat(it, num).Cartesian();\n\t\t}\n\n\t\tpublic static IEnumerable Demask(this IEnumerable> inp)\n\t\t{\n\t\t\tforeach (Tuple pair in inp)\n\t\t\t\tif (pair.Item2)\n\t\t\t\t\tyield return pair.Item1;\n\t\t}\n\n\t\tpublic static IEnumerable>> Partition(this IEnumerable source, int groups)\n\t\t{\n\t\t\tT[] src = source as T[] ?? source.ToArray();\n\t\t\tforeach (int[] part in Enumerable.Range(0, groups).Pow(src.Length).Select(x => x.ToArray()))\n\t\t\t\tyield return Enumerable.Range(0, groups).Select(x => src.Where((item, idx) => part[idx] == x));\n\t\t}\n\n\t\tpublic static IEnumerable> Combinations(this IEnumerable it)\n\t\t{\n\t\t\tT[] itt = it as T[] ?? it.ToArray();\n\t\t\tforeach (IEnumerable conf in new[] { true, false }.Pow(itt.Length))\n\t\t\t\tyield return itt.Zip(conf, Tuple.Create).Demask();\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\tif (!seen && comp.Equals(a, it))\n\t\t\t\t\tseen = true;\n\t\t\t\telse\n\t\t\t\t\tyield return a;\n\t\t}\n\n\t\tpublic static IEnumerable> Permutations(this IEnumerable it)\n\t\t{\n\t\t\tT[] src = it as T[] ?? it.ToArray();\n\t\t\tif (src.Length < 2)\n\t\t\t{\n\t\t\t\tyield return src;\n\t\t\t\tyield break;\n\t\t\t}\n\n\t\t\tforeach (T first in src)\n\t\t\t\tforeach (IEnumerable part in Permutations(src.exceptSingle(first)))\n\t\t\t\t\tyield return single(first).Concat(part);\n\t\t}\n\n\t\tpublic static T[][] Rho(this IEnumerable source, int x, int y)\n\t\t{\n\t\t\tT[][] res = Program.Mkarr(x, y);\n\n\t\t\tint i = 0, j = 0;\n\n\t\t\tT[] src = source as T[] ?? source.ToArray();\n\t\t\twhile (true)\n\t\t\t{\n\t\t\t\tforeach (T item in src)\n\t\t\t\t{\n\t\t\t\t\tres[i][j] = item;\n\t\t\t\t\tj++;\n\t\t\t\t\tif (j == y)\n\t\t\t\t\t{\n\t\t\t\t\t\tj = 0;\n\t\t\t\t\t\ti++;\n\t\t\t\t\t\tif (i == x)\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (i == x)\n\t\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\treturn res;\n\t\t}\n\n\t\tpublic static T[][][] Rho(this IEnumerable source, int x, int y, int z)\n\t\t{\n\t\t\tT[][][] res = Program.Mkarr(x, y, z);\n\n\t\t\tint i = 0, j = 0, k = 0;\n\t\t\tT[] src = source as T[] ?? source.ToArray();\n\t\t\twhile (true)\n\t\t\t{\n\t\t\t\tforeach (T item in src)\n\t\t\t\t{\n\t\t\t\t\tres[i][j][k] = item;\n\t\t\t\t\tk++;\n\t\t\t\t\tif (k == z)\n\t\t\t\t\t{\n\t\t\t\t\t\tk = 0;\n\t\t\t\t\t\tj++;\n\t\t\t\t\t\tif (j == y)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tj = 0;\n\t\t\t\t\t\t\ti++;\n\t\t\t\t\t\t\tif (i == x)\n\t\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\tif (i == x)\n\t\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\treturn res;\n\t\t}\n\t}\n}\n", "lang_cluster": "C#", "tags": ["brute force", "dp"], "code_uid": "0f9913e97b3843b0848bc25421485674", "src_uid": "08f1ba79ced688958695a7cfcfdda035", "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 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 }\n step = 1;\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": "ca90998433e8e56888ce00cab03f9c6c", "src_uid": "858b5e75e21c4cba6d08f3f66be0c198", "difficulty": 1300.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\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 void Dfs(int u, int color)\n\t\t{\n\t\t\tGraph[u].Was = color;\n\t\t\tforeach (var t in Graph[u].Edges.Where(t => Graph[t].Was == 0))\n\t\t\t{\n\t\t\t\tDfs(t, 3 - color);\n\t\t\t}\n\t\t}\n\n\t\tprivate static void Main()\n\t\t{\n\t\t\tvar s = ReadString().Split(':');\n\t\t\tvar h = int.Parse(s[0]);\n\t\t\tvar m = int.Parse(s[1]);\n\t\t\tvar t = ReadInt();\n\t\t\tm += t;\n\t\t\th += m / 60;\n\t\t\tm = m % 60;\n\t\t\th = h % 24;\n\t\t\tif (h < 10)\n\t\t\t\tConsole.Write(\"0{0}\", h);\n\t\t\telse\n\t\t\t\tConsole.Write(h);\n\t\t\tConsole.Write(\":\");\n\t\t\tif (m < 10)\n\t\t\t\tConsole.Write(\"0{0}\", m);\n\t\t\telse\n\t\t\t\tConsole.Write(m);\n\t\t\tConsole.ReadLine();\n\t\t}\n\t}\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "17d82e4965849b4c4036177dfc99c25f", "src_uid": "20c2d9da12d6b88f300977d74287a15d", "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 CodeForce159\n{\n class Program\n {\n static void Main(string[] args)\n {\n string[] input = Console.ReadLine().Split();\n int n = Convert.ToInt32(input[0]);\n int m = Convert.ToInt32(input[1]);\n int min, max;\n if (n == m)\n Console.WriteLine(n - 1 + \" \" + m);\n else\n {\n if (n > m)\n {\n min = m;\n max = n;\n }\n else\n {\n min = n;\n max = m;\n }\n Console.WriteLine(max-1 + \" \"+min);\n }\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["greedy", "implementation", "games"], "code_uid": "5d91afcba371f7985e92149b0fb71f12", "src_uid": "c8378e6fcaab30d15469a55419f38b39", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\n\nnamespace CountDiamonds\n{\n internal class Program\n {\n private static int w;\n\n private static int h;\n\n private static int[] cache;\n\n private static void Main(string[] args)\n {\n IList values = Console.ReadLine().Split(' ').Select(s => Convert.ToInt32(s)).ToList();\n w = values[0];\n h = values[1];\n\n long result = Solve2();\n Console.Out.WriteLine(result);\n }\n\n private static long Solve()\n {\n long result = 0;\n int z = Math.Min(w, h);\n\n for (int i = 1; i <= z / 2; i++)\n {\n int x = w - 2 * i;\n int y = h - 2 * i;\n\n int points;\n if (x == 0 || y == 0)\n {\n points = Math.Max(x, y) + 1;\n }\n else\n {\n points = 2 * x + 2 * y;\n }\n\n result += i * points;\n }\n\n return result;\n }\n\n private static long Solve2()\n {\n long result = 0;\n\n for (int i = 1; i <= w; i++)\n {\n for (int j = 1; j <= h; j++)\n {\n int x = Math.Min(i, w - i);\n int y = Math.Min(j, h - j);\n\n result += x * y;\n }\n }\n\n return result;\n }\n }\n}", "lang_cluster": "C#", "tags": ["brute force", "math"], "code_uid": "8819b1c1737a77300ac738ed35cd1b3d", "src_uid": "42454dcf7d073bf12030367eb094eb8c", "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 CF_SlimeCombining\n{\n class Program\n {\n static void Main(string[] args)\n {\n int n = int.Parse(Console.ReadLine());\n List A = new List();\n for(int i=0;i=0)\n {\n if(A[j] == A[j-1])\n {\n A[j - 1] = A[j - 1] + 1;\n A.RemoveAt(j);\n }\n j--;\n }\n }\n foreach(int i in A)\n {\n Console.Write(i + \" \");\n }\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "4d993adaf874c3caa923480896312c80", "src_uid": "757cd804aba01dc4bc108cb0722f68dc", "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 public void Solve(Scanner sc)\n {\n var n = sc.Int;var res = long.MaxValue;long a = 0, b = 0;\n for(var i=1L;i*i<=n;i++)\n if (n % i == 0)\n {\n var v = n / i;\n if(chmin(ref res, v - i))\n { a = i;b = v; }\n \n }\n WriteLine($\"{a} {b}\");\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": ["brute force", "math"], "code_uid": "9141243f0ecb1c7693b16a670b01b7ae", "src_uid": "f52af273954798a4ae38a1378bfbf77a", "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;\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 ca=new char[5];\n\t\tca[0]=S[0];\n\t\tca[1]=S[2];\n\t\tca[2]=S[4];\n\t\tca[3]=S[3];\n\t\tca[4]=S[1];\n\t\tlong x=long.Parse(new String(ca));\n\t\tlong y=1;\n\t\tfor(int i=0;i<5;i++){\n\t\t\ty*=x;\n\t\t\ty%=100000;\n\t\t}\n\t\tConsole.WriteLine(\"{0:D05}\",y);\n\t\t\n\t\t\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": ["math", "implementation"], "code_uid": "401a5cf07bf6ad2f436ab76282f25fa8", "src_uid": "51b1c216948663fff721c28d131bf18f", "difficulty": 1400.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 // +1\u304ci\u500b -1\u304cj\u500b \u5168\u30d1\u30bf\u30fc\u30f3\n var dp0 = new ModInt[N + 1, M + 1];\n dp0[0, 0] = 1;\n for (int i = 0; i <= N; i++)\n {\n for (int j = 0; j <= M; j++)\n {\n if (i - 1 >= 0) dp0[i, j] += dp0[i - 1, j];\n if (j - 1 >= 0) dp0[i, j] += dp0[i, j - 1];\n }\n }\n\n // \u7d2f\u7a4d\u548c\u6700\u5927\u304c0\u306b\u306a\u308b\u30d1\u30bf\u30fc\u30f3\n var dp1 = new ModInt[N + 1, M + 1];\n for (int i = 0; i <= N; i++)\n {\n for (int j = 0; j <= M; j++)\n {\n if (i == 0)\n {\n dp1[i, j] = 1;\n }\n else if (i > j)\n {\n dp1[i, j] = 0;\n }\n else\n {\n if (i - 1 >= 0) dp1[i, j] += dp1[i - 1, j];\n if (j - 1 >= 0) dp1[i, j] += dp1[i, j - 1];\n }\n }\n }\n\n // \u7b54\u3048\n var dp2 = new ModInt[N + 1, M + 1];\n for (int i = 0; i <= N; i++)\n {\n for (int j = 0; j <= M; j++)\n {\n if (i == 0)\n {\n dp2[i, j] = 0;\n }\n else if (j == 0)\n {\n dp2[i, j] = i;\n }\n else\n {\n // \u5148\u982d\u306b+1\u3092\u7f6e\u304f\n if (i - 1 >= 0)\n {\n // \u6700\u59271\u5897\u3048\u308b\n // 1\u3064\u524d + \u30d1\u30bf\u30fc\u30f3\u6570\n dp2[i, j] += dp2[i - 1, j] + dp0[i - 1, j];\n }\n\n // \u5148\u982d-1\n if (j - 1 >= 0)\n {\n // \u6700\u5927\n // 1\u3064\u524d 0\u306a\u3089 0\u306e\u307e\u307e\n // \u6b63\u306a\u30891\u3064\u6e1b\u308b\n // 1\u3064\u524d - \u4e26\u3079\u65b9 + 0\u306b\u306a\u308b\u30d1\u30bf\u30fc\u30f3\n dp2[i, j] += dp2[i, j - 1] - dp0[i, j - 1] + dp1[i, j - 1];\n }\n }\n }\n }\n Console.WriteLine(dp2[N, M]);\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 = 998244853;\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", "number theory"], "code_uid": "6aa57c164f7071b33338d2cd13015b48", "src_uid": "a2fcad987e9b2bb3e6395654cd4fcfbb", "difficulty": 2300.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 MakotoAndABlackboard\n {\n public class ModMath\n {\n private int mod;\n\n public ModMath(int mod)\n {\n this.mod = mod;\n }\n\n public long Pow(long x, int n)\n {\n long res = 1;\n for (; n > 0; n >>= 1)\n {\n if ((n & 1) > 0)\n {\n res = res * x % mod;\n }\n x = x * x % mod;\n }\n return res;\n }\n\n public long Div(long l, long r)\n {\n return l * Pow(r, mod - 2) % mod;\n }\n\n internal long Add(long v1, long v2)\n {\n return (v1 + v2) % mod;\n }\n\n internal long Mul(long v1, long v2)\n {\n return v1 * v2 % mod;\n }\n }\n\n const int MOD = 1000000000 + 7;\n\n ModMath math = new ModMath(MOD);\n\n public static void Main()\n {\n StreamWriter sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };\n new MakotoAndABlackboard().Solve(Console.In, sw);\n sw.Flush();\n }\n\n public void Solve(TextReader tr, TextWriter tw)\n {\n var a = tr.ReadLine().Split();\n tw.WriteLine(Solve(long.Parse(a[0]), int.Parse(a[1])));\n }\n\n public int Solve(long n, int k)\n {\n var res = 1L;\n for (long a = 2; a * a <= n; a++)\n {\n var np = GetNumPrime(a, n);\n var numPrime = np.Item1;\n n = np.Item2;\n if (numPrime == 0)\n {\n continue;\n }\n\n res = math.Mul(res, Calculate(k, a, numPrime));\n }\n if (n != 1)\n {\n res = math.Mul(res, Calculate(k, n, 1));\n }\n return (int)(res);\n }\n\n private long Calculate(int k, long a, long numPrime)\n {\n var current = 0;\n var next = 1;\n var dp = new long[2, numPrime + 1];\n dp[current, numPrime] = 1;\n\n var div = new long[numPrime + 2];\n for (int j = 1; j <= numPrime + 1; j++)\n {\n div[j] = math.Div(1, j);\n }\n\n for (int i = 1; i <= k; i++)\n {\n for (int j = 0; j <= numPrime; j++)\n {\n dp[next, j] = 0;\n for (int l = j; l <= numPrime; l++)\n {\n dp[next, j] = math.Add(dp[next, j], math.Mul(dp[current, l], div[l + 1]));\n }\n }\n current ^= 1;\n next ^= 1;\n }\n\n var t = 0L;\n for (int j = 0; j <= numPrime; j++)\n {\n t = math.Add(t, math.Mul(dp[current, j], math.Pow(a, j)));\n }\n return t;\n }\n\n Tuple GetNumPrime(long a, long n)\n {\n var numPrime = 0L;\n while (n % a == 0)\n {\n numPrime++;\n n /= a;\n }\n return Tuple.Create(numPrime, n);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "dp", "probabilities", "number theory"], "code_uid": "c28888233b9b765b0e6ff6785a941962", "src_uid": "dc466d9c24b7dcb37c0e99337b4124d2", "difficulty": 2200.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 a = ReadInt();\n var res = 1;\n if (a == 1)\n res = 2;\n else if (a == 2)\n res = 3;\n else if (a == 3)\n res = 1;\n else if (a == 4)\n res = 2;\n else if (a == 5)\n res = 1;\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": ["brute force"], "code_uid": "b71b94493c5068382872fad763011bd7", "src_uid": "c702e07fed684b7741d8337aafa005fb", "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.IO;\n\nnamespace Codeforces\n{\n#if _ONLINE_JUDGE_\n\t[OnlineJudge.Task(\"Codeforces 171F\")]\n#endif\n\tclass Task171F\n\t{\n\t\t/*\n\t\t * AN EMIRP IS A PRIME NUMBER WHOSE REVERSE IS A DIFFERENT PRIME NUMBER. YOUR TASK IS TO FIND THE NTH EMIRP.\n\t\t * THE INPUT CONSISTS OF A SINGLE INTEGER - THE ONE-BASED INDEX OF THE EMIRP TO FIT.\n\t\t * OUTPUT A SINGLE NUMBER\n\t\t */\n\n\t\tprivate InputTokenizer input = new InputTokenizer();\n\t\tprivate TextWriter output = Console.Out;\n\n\t\tprivate void Solve()\n\t\t{\n\t\t\tbool[] nprime = new bool[1000001];\n\t\t\tfor (int p = 2; p <= 1000; ++p)\n\t\t\t\tfor (int q = 2 * p; q <= 1000000; q += p)\n\t\t\t\t\tnprime[q] = true;\n\n\t\t\tList emirps = new List();\n\t\t\tfor (int p = 2; p <= 1000000; ++p)\n\t\t\t\tif (nprime[p] == false) {\n\t\t\t\t\tint q = int.Parse(new String(p.ToString().Reverse().ToArray()));\n\t\t\t\t\tif (p != q && nprime[q] == false)\n\t\t\t\t\t\temirps.Add(p);\n\t\t\t\t}\n\n\t\t\tint n;\n\t\t\tinput.Line().Read(out n);\n\t\t\toutput.WriteLine(emirps[n - 1]);\n\t\t}\n\n\t\tpublic static void Main()\n\t\t{\n\t\t\tvar obj = new Task171F();\n\t\t\tobj.Solve();\n\t\t}\n\n\t\t#region\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", "number theory"], "code_uid": "e2635e7dc60fa4fcdb4cd223f265e54c", "src_uid": "53879e79cccbacfa6586d40cf3436657", "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;\n using System.Collections.Generic;\n using System.Globalization;\nusing System.IO;\nusing System.Linq;\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 str = sr.NextString();\n var answ = int.MaxValue;\n var gen = \"ACTG\";\n for (var i = 0; i <= n - 4; i++)\n {\n var currMin = 0;\n for (var j = 0; j < 4; j++)\n {\n var ch = 'A' - str[i + j];\n var needed = 'A' - gen[j];\n var first = 0;\n var second = 0;\n if (ch >= needed)\n {\n first = ch - needed;\n second = 26 - ch + needed;\n }\n else\n {\n first = needed - ch;\n second = ch + (26 - needed);\n }\n\n var min = Math.Min(first, second);\n currMin += min;\n }\n\n answ = Math.Min(answ, currMin);\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", "strings"], "code_uid": "71068fcd94d476dab9697176f3233ca1", "src_uid": "ee4f88abe4c9fa776abd15c5f3a94543", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nclass Solution\n{\n static bool[] is_prime;\n private static void MakeSieve(int max)\n {\n // Make an array indicating whether numbers are prime.\n is_prime = new bool[max + 1];\n for (int i = 2; i <= max; i++) is_prime[i] = true;\n\n // Cross out multiples.\n for (int i = 2; i <= max; i++)\n {\n // See if i is prime.\n if (is_prime[i])\n {\n // Knock out multiples of i.\n for (int j = i * 2; j <= max; j += i)\n is_prime[j] = false;\n }\n }\n }\n public static string ToHexspeak(string num)\n {\n long number = long.Parse(num);\n string hexString = number.ToString(\"X\");\n hexString = hexString.Replace('0', 'O').Replace('1', 'I');\n bool valid = true;\n for (int i = 0; i < hexString.Length; i++)\n {\n if (hexString[i] > '1' && hexString[i] <= '9')\n {\n valid = false;\n break;\n }\n }\n if (valid)\n return hexString;\n else\n return \"ERROR\";\n }\n public static IList> RemoveInterval(int[][] intervals, int[] toBeRemoved)\n {\n IList> returnedIntervals = new List>();\n if (toBeRemoved[0] <= intervals[0][0])\n {\n if (toBeRemoved[1] >= intervals[intervals.Length - 1][1])\n return returnedIntervals;\n for (int i = 0; i < intervals.Length; i++)\n {\n if (toBeRemoved[1] <= intervals[i][1])\n {\n List injectedInterval = new List();\n injectedInterval.Add(toBeRemoved[1]);\n injectedInterval.Add(intervals[i][1]);\n returnedIntervals.Add(injectedInterval);\n for (int j = i + 1; j < intervals.Length; j++)\n {\n injectedInterval = new List();\n injectedInterval.Add(intervals[j][0]); injectedInterval.Add(intervals[j][1]);\n returnedIntervals.Add(injectedInterval);\n }\n return returnedIntervals;\n }\n }\n }\n else if (toBeRemoved[1] >= intervals[intervals.Length - 1][1])\n {\n for (int i = 0; i < intervals.Length; i++)\n {\n List injectedInterval = new List();\n if (toBeRemoved[0] >= intervals[i][0] && toBeRemoved[0] <= intervals[i][1])\n {\n injectedInterval.Add(intervals[i][0]);\n injectedInterval.Add(toBeRemoved[0]);\n returnedIntervals.Add(injectedInterval);\n return returnedIntervals;\n }\n injectedInterval = new List();\n injectedInterval.Add(intervals[i][0]); injectedInterval.Add(intervals[i][1]);\n returnedIntervals.Add(injectedInterval);\n }\n }\n else\n {\n for (int i = 0; i < intervals.Length; i++)\n {\n List injectedInterval = new List();\n if (toBeRemoved[0] > intervals[i][1] || toBeRemoved[1] < intervals[i][0])\n {\n injectedInterval = new List();\n injectedInterval.Add(intervals[i][0]); injectedInterval.Add(intervals[i][1]);\n returnedIntervals.Add(injectedInterval);\n }\n else if (toBeRemoved[0] >= intervals[i][0] && toBeRemoved[0] <= intervals[i][1])\n {\n injectedInterval = new List();\n injectedInterval.Add(intervals[i][0]);\n injectedInterval.Add(toBeRemoved[0]);\n returnedIntervals.Add(injectedInterval);\n if (toBeRemoved[1] < intervals[i][1])\n {\n injectedInterval = new List();\n injectedInterval.Add(toBeRemoved[1]);\n injectedInterval.Add(intervals[i][1]);\n returnedIntervals.Add(injectedInterval);\n\n }\n }\n else if (toBeRemoved[1] >= intervals[i][0] && toBeRemoved[1] <= intervals[i][1])\n {\n injectedInterval = new List();\n injectedInterval.Add(toBeRemoved[1]);\n injectedInterval.Add(intervals[i][1]);\n returnedIntervals.Add(injectedInterval);\n }\n }\n }\n return returnedIntervals;\n }\n public class treeNodeWithValue\n {\n public int value;\n public List childern;\n public int NodeNumber;\n public int childsCount;\n public treeNodeWithValue(int val, int nodeVal)\n {\n value = val;\n NodeNumber = nodeVal;\n childern = new List();\n childsCount = 0;\n }\n }\n public class treeWithValues\n {\n public treeNodeWithValue root;\n public void createTree(int[] arrNodesParents, int[] arrValues)\n {\n root = new treeNodeWithValue(arrValues[0], 0);\n for (int i = 1; i < arrNodesParents.Length; i++)\n {\n treeNodeWithValue temp = new treeNodeWithValue(arrValues[i], i);\n traverseTheTree(root, temp, arrNodesParents[i]);\n }\n }\n public void traverseTheTree(treeNodeWithValue rooted, treeNodeWithValue newNode, int parentNumber)\n {\n if (rooted.NodeNumber == parentNumber)\n {\n rooted.childern.Add(newNode);\n }\n else if (rooted.childern.Count > 0)\n {\n for (int i = 0; i < rooted.childern.Count; i++)\n {\n traverseTheTree(rooted.childern[i], newNode, parentNumber);\n }\n }\n }\n public int deleteCountZeroPaths(treeNodeWithValue rooted)\n {\n if (rooted.childern.Count > 0)\n {\n for (int i = 0; i < rooted.childern.Count; i++)\n {\n int tempCount = deleteCountZeroPaths(rooted.childern[i]);\n if (tempCount == 0)\n {\n rooted.childern.RemoveAt(i);\n }\n else\n rooted.childsCount += tempCount;\n }\n }\n else\n {\n return rooted.value;\n }\n int temp = rooted.value + rooted.childsCount;\n return temp;\n }\n public int countThetree(treeNodeWithValue rooted)\n {\n int tempCount = 1;\n if (rooted.childern.Count > 0)\n {\n for (int i = 0; i < rooted.childern.Count; i++)\n {\n tempCount += countThetree(rooted.childern[i]);\n }\n }\n return tempCount;\n }\n\n }\n public static int DeleteTreeNodes(int nodes, int[] parent, int[] value)\n {\n treeWithValues tree = new treeWithValues();\n tree.createTree(parent, value);\n tree.deleteCountZeroPaths(tree.root);\n return tree.countThetree(tree.root);\n //return 0;\n }\n //static void Main(string[] args)\n //{\n // int testcases = int.Parse(Console.ReadLine());\n // for (int t = 0; t < testcases; t++)\n // {\n // string[] words = Console.ReadLine().Split(' ');\n // string a = words[0];\n // string b = words[1];\n // string result = \"\";\n // char minC = 'Z';\n // int minIndexI = -1;\n // int minIndexJ = -1;\n // for (int i = 0; i < a.Length - 1; i++)\n // {\n // bool found = false;\n // for (int j = i + 1; j < a.Length; j++)\n // {\n // if (a[i] > a[j] && a[j] < minC)\n // {\n // minIndexI = i;\n // minIndexJ = j;\n // minC = a[j];\n // found = true;\n // }\n // }\n // if (found)\n // break;\n // }\n // if (minIndexI > -1)\n // {\n // for (int i = 0; i < a.Length; i++)\n // {\n // if (minIndexI == i)\n // {\n // result += a[minIndexJ];\n // }\n // else if (minIndexJ == i)\n // {\n // result += a[minIndexI];\n // }\n // else\n // result += a[i];\n // }\n // a = result;\n // }\n // if (a.Length > b.Length)\n // {\n // bool canBeDone = false;\n // for (int i = 0; i < b.Length; i++)\n // {\n // if (a[i] < b[i])\n // {\n // canBeDone = true;\n // break;\n // }\n // else if (a[i] > b[i])\n // {\n // break;\n // }\n // }\n // if (canBeDone)\n // Console.WriteLine(a);\n // else\n // Console.WriteLine(\"---\");\n // }\n // else if (a.Length < b.Length)\n // {\n // bool canBeDone = false;\n // bool aGreater = false;\n // for (int i = 0; i < a.Length; i++)\n // {\n // if (a[i] < b[i])\n // {\n // canBeDone = true;\n // break;\n // }\n // else if (a[i] > b[i])\n // {\n // aGreater = true;\n // break;\n // }\n // }\n // if (canBeDone || aGreater == false)\n // Console.WriteLine(a);\n // else\n // Console.WriteLine(\"---\");\n // }\n // else {\n // bool canBeDone = false;\n // for (int i = 0; i < a.Length; i++)\n // {\n // if (a[i] < b[i])\n // {\n // canBeDone = true;\n // break;\n // }\n // else if (a[i] > b[i])\n // {\n // break;\n // }\n // }\n // if (canBeDone)\n // Console.WriteLine(a);\n // else\n // Console.WriteLine(\"---\");\n // }\n // }\n //}\n static void Main(string[] args)\n {\n int t, s, v, j, c1, c2;\n t = int.Parse(Console.ReadLine());\n s = int.Parse(Console.ReadLine());\n v = int.Parse(Console.ReadLine());\n j = int.Parse(Console.ReadLine());\n c1 = int.Parse(Console.ReadLine());\n c2 = int.Parse(Console.ReadLine());\n int cost = 0;\n if (c1 > c2)\n {\n int min = Math.Min(j, t);\n j -= min;\n cost += (c1 * min);\n if (j > 0)\n {\n int cost2 = Math.Min(j, Math.Min(v, s));\n cost += (cost2 * c2);\n }\n }\n else\n {\n int cost2 = Math.Min(j, Math.Min(v, s));\n cost += (cost2 * c2);\n j = j - cost2;\n if (j > 0)\n {\n int min = Math.Min(j, t);\n cost += (c1 * min);\n }\n }\n Console.WriteLine(cost);\n }\n}", "lang_cluster": "C#", "tags": ["math", "greedy", "brute force"], "code_uid": "a1baf6a8311801f0b2769f607696f6a9", "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 CodeForces\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], m = arr[1];\n List[] g = new List[n];\n for (int i = 0; i < n; i++)\n {\n g[i] = new List();\n }\n for (int i = 0; i < m; i++)\n {\n var uv = Console.ReadLine().Split().Select(int.Parse).ToArray();\n int u = uv[0], v = uv[1];\n u--;\n v--;\n g[u].Add(v);\n g[v].Add(u);\n }\n\n int max = 0;\n if(n<7)\n {\n max = m;\n }\n for(int i=0;i max) max = temp;\n }\n }\n Console.WriteLine(max);\n Console.Read(); \n }\n }\n}\n// 1 7 11 5\n", "lang_cluster": "C#", "tags": ["brute force", "graphs"], "code_uid": "e4a1f2410d99cbd29dae94e8b909e070", "src_uid": "11e6559cfb71b8f6ca88242094b17a2b", "difficulty": 1700.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 w = sc.Long();\n var m = sc.Long();\n \n if (w <= 3 || m == 1 || ok(m, w))\n IO.Printer.Out.WriteLine(\"YES\");\n else IO.Printer.Out.WriteLine(\"NO\");\n\n }\n public bool ok(long m, long w)\n {\n if (m == 0) return true;\n long sum = 0;\n for (long i = 1; true; i *= w)\n {\n var min = i - sum;\n var max = i + sum;\n if (m < min) return false;\n else if (min <= m && m <= max)\n return ok(Math.Abs(m - i), w);\n sum += i;\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 != '-' && (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", "lang_cluster": "C#", "tags": ["brute force", "math", "dp", "meet-in-the-middle", "greedy", "number theory"], "code_uid": "71fdfcd83e7d65c0b1589ebc58dc42c7", "src_uid": "a74adcf0314692f8ac95f54d165d9582", "difficulty": 1900.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.IO;\nusing System.Text;\n\nnamespace Statues\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[8,8];\n for (int i = 0; i < 8; i++)\n {\n string s = reader.ReadLine();\n for (int j = 0; j < 8; j++)\n {\n if (s[j] == 'S')\n nn[i, j] = -1;\n }\n }\n nn[7, 0] = 2;\n int move = 2;\n bool ok = false;\n for (int i = 0; i < 8; i++)\n {\n for (int j = 0; j < 8; j++)\n {\n for (int k = 0; k < 8; k++)\n {\n if (nn[j, k] == move)\n {\n for (int l = -1; l < 2; l++)\n {\n for (int m = -1; m < 2; m++)\n {\n int x = j + l;\n int y = k + m;\n if (x < 0 || x > 7 || y < 0 || y > 7)\n continue;\n if (nn[x, y] == -1)\n continue;\n if (nn[x, y] == move)\n {\n if (l == 0 && m == 0)\n nn[x, y] = 1 ^ move;\n }\n else\n {\n nn[x, y] = 1 ^ move;\n }\n }\n }\n }\n }\n }\n\n for (int j = 7; j >= 1; j--)\n {\n for (int k = 0; k < 8; k++)\n {\n if (nn[j - 1, k] == -1)\n {\n nn[j, k] = -1;\n nn[j - 1, k] = 0;\n }\n }\n }\n\n move ^= 1;\n\n\n ok = false;\n for (int j = 0; !ok && j < 8; j++)\n {\n for (int k = 0; k < 8; k++)\n {\n if (nn[j, k] == move)\n {\n ok = true;\n break;\n }\n }\n }\n if (!ok)\n break;\n }\n\n writer.WriteLine(ok ? \"WIN\" : \"LOSE\");\n writer.Flush();\n }\n }\n}", "lang_cluster": "C#", "tags": ["dfs and similar"], "code_uid": "a9af7b2f5c73def663183fb5d7a5aa20", "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;\n\nnamespace ConsoleApplication1\n{\n class Program\n {\n static void Main(string[] args)\n {\n Solution solution = new Solution();\n\n bool inFromFile = false;\n bool outFromFile = false;\n\n\n System.IO.TextReader input = null;\n System.IO.TextWriter output = null; \n try\n {\n input = inFromFile ? File.OpenText(\"a.in\") : System.Console.In;\n output = outFromFile ? File.CreateText(\"a.out\") : System.Console.Out;\n\n solution.solve(input, output);\n \n input.Dispose();\n }\n finally\n {\n if (input != null)\n input.Dispose();\n if (output != null)\n output.Dispose();\n } \n }\n }\n\n public class MyStreamReader\n {\n private TextReader myTextReader;\n private string[] words;\n private int tkPos = 0;\n\n public MyStreamReader()\n {\n myTextReader = System.Console.In;\n }\n\n public MyStreamReader(TextReader txtReader)\n {\n myTextReader = txtReader;\n }\n\n public string NextWord()\n {\n\n if (words != null && tkPos < words.Length)\n return words[tkPos++];\n\n words = null;\n tkPos = 0;\n\n while (words == null || words.Length <= 0)\n {\n try\n {\n words = myTextReader.ReadLine().Split(new char[0], StringSplitOptions.RemoveEmptyEntries);\n }\n catch (Exception ex)\n {\n return null;\n }\n }\n\n return words[tkPos++];\n }\n\n public int NextInt()\n {\n return Convert.ToInt32(NextWord());\n }\n\n public long NextLong()\n {\n return Convert.ToInt64(NextWord());\n }\n\n public double NextDouble()\n {\n return Convert.ToDouble(NextWord());\n }\n\n }\n \n class Solution\n {\n public void solve(TextReader input, TextWriter output)\n {\n MyStreamReader reader = new MyStreamReader(input);\n\n long n = reader.NextLong();\n var fat = Fatora(n);\n\n long resp = 1;\n fat.ForEach(t => resp = resp * t.Item1);\n \n output.WriteLine(resp);\n\n }\n\n public List> Fatora(long n)\n {\n var ret = new List>();\n if (n <= 1)\n {\n ret.Add(new Tuple(n, 0));\n return ret;\n }\n\n int lim = 10000000; //10^7\n int jump = 1;\n for (long p = 2; p * p <= n && p <= lim; p += jump)\n {\n int exp = 0;\n while (n % p == 0)\n {\n n = n / p;\n exp++;\n }\n\n if (exp != 0)\n ret.Add(new Tuple(p, exp));\n\n if(p > 2)\n jump = 2;\n }\n\n if (n != 1)\n ret.Add(new Tuple(n, 1));\n\n return ret;\n }\n\n }\n}\n", "lang_cluster": "C#", "tags": ["math"], "code_uid": "92cc19a46eaee003077c16f127f65384", "src_uid": "6d0da975fa0961acfdbe75f2f29aeb92", "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.Text;\n\nnamespace A.Music\n{\n\tclass TextReaderHelper\n\t{\n\t\tprotected TextReader baseReader;\n\t\tprotected LinkedList buffer;\n\n\t\tpublic TextReaderHelper(TextReader baseReader)\n\t\t{\n\t\t\tthis.baseReader = baseReader;\n\t\t\tbuffer = new LinkedList();\n\t\t}\n\n\t\tprotected void readIfEmpty()\n\t\t{\n\t\t\tif (buffer.Count > 0) return;\n\t\t\tstring line;\n\t\t\tdo\n\t\t\t{\n\t\t\t\tline = baseReader.ReadLine();\n\t\t\t\tif (line == null) return;\n\t\t\t}\n\t\t\twhile (line.Trim() == string.Empty);\n\t\t\tforeach (var item in line.Split(' ', '\\n', '\\t'))\n\t\t\t\tif (item != string.Empty)\n\t\t\t\t\tbuffer.AddLast(item);\n\t\t}\n\n\t\tprivate object readChar()\n\t\t{\n\t\t\tvar node = buffer.First;\n\t\t\tvar ret = node.Value[0];\n\t\t\tif (node.Value.Length > 1) node.Value = node.Value.Substring(1);\n\t\t\telse buffer.RemoveFirst();\n\t\t\treturn ret;\n\t\t}\n\n\t\tpublic T NextElement()\n\t\t{\n\t\t\treadIfEmpty();\n\t\t\tif (typeof(T) == typeof(char)) return (T)readChar();\n\t\t\tvar ret = (T)Convert.ChangeType(buffer.First.Value, typeof(T));\n\t\t\tbuffer.RemoveFirst();\n\t\t\treturn ret;\n\t\t}\n\n\t\tpublic int NextInt() { return NextElement(); }\n\n\t\tpublic string NextString() { return NextElement(); }\n\t}\n\n\tclass Program\n\t{\n\t\t[Conditional(\"DEBUG\")]\n\t\tprivate static void Pause()\n\t\t{\n\t\t\tConsole.ReadKey();\n\t\t}\n\n\t\tstatic void Main(string[] args)\n\t\t{\n\t\t\tvar reader = new TextReaderHelper(new StreamReader(Console.OpenStandardInput(), Encoding.ASCII, false, 1048576));\n\t\t\tvar writer = new StreamWriter(Console.OpenStandardOutput(), Encoding.ASCII, 1048576);\n\t\t\twriter.WriteLine(Math.Ceiling(Math.Log((double)reader.NextInt()/reader.NextInt(), reader.NextInt())));\n\t\t\twriter.Flush();\n\t\t\tPause();\n\t\t}\n\t}\n}\n", "lang_cluster": "C#", "tags": ["math", "implementation"], "code_uid": "7f7332ccd1f31a0a0fbce7561b339bec", "src_uid": "0d01bf286fb2c7950ce5d5fa59a17dd9", "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.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 int solve()\n {\n string s = GetString();\n int n = GetInt();\n int[][][] dp1 = new int[101][][];\n for (int i = 0; i < 101; ++i)\n {\n dp1[i] = new int[2][];\n for (int j = 0; j < 2; ++j)\n {\n dp1[i][j] = new int[51];\n }\n }\n for (int i = 0; i < 101; ++i)\n for (int j = 0; j < 51; ++j)\n {\n dp1[i][0][j] = dp1[i][1][j] = -INF;\n }\n dp1[0][0][0] = dp1[0][1][0] = 0;\n for (int i = 1; i <= s.Length; ++i)\n {\n for (int j = 0; j <= n; ++j)\n {\n for (int k = 0; k <= j; ++k)\n {\n if (s[i - 1] == 'T')\n {\n if (k % 2 == 0)\n {\n dp1[i][0][j] = Math.Max(dp1[i - 1][1][j - k], dp1[i][0][j]);\n dp1[i][1][j] = Math.Max(dp1[i - 1][0][j - k], dp1[i][1][j]);\n }\n else\n {\n dp1[i][0][j] = Math.Max(dp1[i][0][j], dp1[i - 1][0][j - k] + 1);\n dp1[i][1][j] = Math.Max(dp1[i][1][j], dp1[i - 1][1][j - k] - 1);\n }\n }\n if (s[i - 1] == 'F')\n {\n if (k % 2 == 0)\n {\n dp1[i][0][j] = Math.Max(dp1[i][0][j], dp1[i - 1][0][j - k] + 1);\n dp1[i][1][j] = Math.Max(dp1[i][1][j], dp1[i - 1][1][j - k] - 1);\n }\n else\n {\n dp1[i][0][j] = Math.Max(dp1[i][0][j], dp1[i - 1][1][j - k]);\n dp1[i][1][j] = Math.Max(dp1[i][1][j], dp1[i - 1][0][j - k]);\n }\n }\n }\n }\n }\n int ans = Math.Max(dp1[s.Length][0][n], dp1[s.Length ][1][n]);\n return ans;\n }\n public static void Main()\n {\n Console.WriteLine(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": ["dp", "implementation"], "code_uid": "054814b763da6ed96cb5880ab5c79ebf", "src_uid": "4a54971eb22e62b1d9e6b72f05ae361d", "difficulty": 1800.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\n{\n class Program\n {\n static void Main(string[] args)\n {\n string[] num = Console.ReadLine().Split(' ');\n int n = int.Parse(num[0]);\n int m = int.Parse(num[1]);\n int k = int.Parse(num[2]);\n int free = m - n;\n int frodo=1;\n int left = k - 1;\n int right = n - k;\n int hob_left = 0;\n int hob_right = 0;\n if (n==1)\n {\n Console.WriteLine(m);\n return;\n }\n if(free==0)\n {\n Console.WriteLine(frodo);\n }\n else if(free==1)\n {\n frodo++;\n Console.WriteLine(frodo);\n return;\n }\n else\n {\n frodo++;\n free--;\n if (free == 0)\n {\n Console.WriteLine(frodo);\n return;\n }\n while (true)\n {\n frodo++;\n if (hob_left != left) hob_left++;\n if (hob_right != right) hob_right++;\n free -= (hob_right + hob_left + 1);\n if (free == 0)\n {\n Console.WriteLine(frodo);\n return;\n }\n if (free < 0)\n {\n frodo--;\n Console.WriteLine(frodo);\n return;\n }\n \n }\n }\n\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["greedy", "binary search"], "code_uid": "14c0acf8f0d9bcb73071d2466b76ddce", "src_uid": "da9ddd00f46021e8ee9db4a8deed017c", "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\n\nnamespace \u041a\u043e\u043d\u0442\u0435\u0441\u0442\u041f\u0440\u043e\u0431\u0430\n{\n class Program\n {\n\n static void Main(string[] args)\n {\n long n;\n long rez = 0;\n n = Convert.ToInt64(Console.ReadLine());\n rez = (n * (n + 1)) / 2;\n rez = 1 + 6 * rez;\n\n Console.WriteLine(rez);\n }\n }\n}", "lang_cluster": "C#", "tags": ["math"], "code_uid": "514c072f0ba2600ca1620d84c139fba9", "src_uid": "c046895a90f2e1381a7c1867020453bd", "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 c = int.Parse(s.Split()[0]);\n int d = int.Parse(s.Split()[1]);\n\n s = Console.ReadLine();\n int n = int.Parse(s.Split()[0]);\n int m = int.Parse(s.Split()[1]);\n\n int k = int.Parse(Console.ReadLine());\n\n int answer = 0;\n int num = n * m - k;\n\n if (num <= 0)\n {\n Console.WriteLine(answer);\n return;\n }\n\n if (d * n < c)\n {\n answer += num * d;\n Console.WriteLine(answer);\n return;\n }\n\n int x = num / n;\n answer += x * c;\n num -= x * n;\n\n if (d * num < c)\n answer += num * d;\n else\n answer += c;\n\n Console.WriteLine(answer); \n \n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "dp", "implementation"], "code_uid": "d0f5895949efa858ae2fa4ac3284ce52", "src_uid": "c6ec932b852e0e8c30c822a226ef7bcb", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System;\nusing System.Collections;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\npublic class Program\n{\n\tpublic static void Main(string[] args)\n\t{\n\t\tstring num = Console.ReadLine();\n\t\tstring[] numArray = num.Split(null);\n\n\t\tlong s = long.Parse(numArray[0]);\n\t\tlong x = long.Parse(numArray[1]);\n\n\t\tstring sum = Convert.ToString(s, 2);\n\t\tstring xor = Convert.ToString(x, 2);\n\n\t\tint sumdiff = 0, xordiff = 0;\n\t\tif (sum.Length > xor.Length)\n\t\t{\n\t\t\tsumdiff = sum.Length - xor.Length;\n\t\t}\n\t\t{\n\t\t\txordiff = xor.Length - sum.Length;\n\t\t}\n\n\t\tif (sumdiff > 0)\n\t\t{\n\t\t\tfor (int i = 0; i < sumdiff; i++)\n\t\t\t\txor = \"0\" + xor;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tfor (int i = 0; i < xordiff; i++)\n\t\t\t\tsum = \"0\" + sum;\n\t\t}\n\n\t\tsum = \"1\" + sum;\n\t\txor = \"1\" + xor;\n\n\t\tchar[] sumChar = sum.ToCharArray();\n\t\tchar[] xorChar = xor.ToCharArray();\n\n\t\tint carry = 0;\n\n\t\tint[] possibilities = new int[xor.Length];\n\n\t\tfor (int i = xor.Length - 1; i >= 0; i--)\n\t\t{\n\t\t\tif (xor[i] == '1')\n\t\t\t{\n\t\t\t\tif (sum[i] == '1')\n\t\t\t\t{\n\t\t\t\t\tpossibilities[i] = 2;\n\n\t\t\t\t\tif (carry == 1)\n\t\t\t\t\t{\n\t\t\t\t\t\tConsole.Write(\"0\");\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (carry == -1)\n\t\t\t\t\t{\n\t\t\t\t\t\tpossibilities[i + 1] = possibilities[i + 1] - 1;\n\t\t\t\t\t}\n\n\t\t\t\t\tcarry = 0;\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tpossibilities[i] = 2;\n\n\t\t\t\t\tif (carry == 0)\n\t\t\t\t\t{\n\t\t\t\t\t\tConsole.Write(\"0\");\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (carry == -1)\n\t\t\t\t\t{\n\t\t\t\t\t\tpossibilities[i + 1] = possibilities[i + 1] - 1;\n\t\t\t\t\t}\n\n\t\t\t\t\tcarry = 1;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tif (sum[i] == '1')\n\t\t\t\t{\n\t\t\t\t\tpossibilities[i] = 2;\n\n\t\t\t\t\tif (carry == -1)\n\t\t\t\t\t{\n\t\t\t\t\t\tpossibilities[i + 1] = possibilities[i + 1] - 1;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (carry == 0)\n\t\t\t\t\t{\n\t\t\t\t\t\tConsole.Write(\"0\");\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\tcarry = -1;\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tpossibilities[i] = 2;\n\n\t\t\t\t\tif (carry == 1)\n\t\t\t\t\t{\n\t\t\t\t\t\tConsole.Write(\"0\");\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (carry == -1)\n\t\t\t\t\t{\n\t\t\t\t\t\tpossibilities[i + 1] = possibilities[i + 1] - 1;\n\t\t\t\t\t}\n\n\t\t\t\t\tcarry = -1;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tlong answer = 1;\n\t\tfor (int i = 1; i < possibilities.Length; i++)\n\t\t{\n\t\t\tanswer = answer * possibilities[i];\n\t\t}\n\n\t\tif(s==x)\n\t\t{\n\t\t\tanswer = answer - 2;\n\t\t}\n\n\t\t\tConsole.Write(answer);\n\t\t}\n\n\n}", "lang_cluster": "C#", "tags": ["math", "dp", "constructive algorithms", "implementation"], "code_uid": "ac5c15df5a7db4bafdca1a623a598338", "src_uid": "18410980789b14c128dd6adfa501aea5", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Diagnostics.Contracts;\nusing System.Globalization;\nusing System.IO;\n\nnamespace Codeforces.R285.D\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 var n = int.Parse(tr.ReadLine(), CultureInfo.InvariantCulture);\n\n tw.WriteLine(Calc(n));\n }\n\n private static int Calc(int n)\n {\n if (n % 2 == 0)\n return 0;\n\n if (n == 15)\n return 150347555;\n\n return (int)(Calc(0, new bool[n], new bool[n]) * Factorial(n) % mod);\n }\n\n private static long Factorial(int n)\n {\n var res = 1L;\n for (int i = 2; i <= n; ++i)\n {\n res = res * i % mod;\n }\n return res;\n }\n\n private static long Calc(int c, bool[] usedB, bool[] usedC)\n {\n var n = usedC.Length;\n\n if (c == n)\n return 1L;\n\n var res = 0L;\n for (int i = 0; i < n; ++i)\n {\n if (!usedB[i])\n {\n usedB[i] = true;\n var next = (c + i) % n;\n if (!usedC[next])\n {\n usedC[next] = true;\n res = (res + Calc(c + 1, usedB, usedC)) % mod;\n usedC[next] = false;\n }\n usedB[i] = false;\n }\n }\n return res;\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["dp", "combinatorics", "bitmasks", "meet-in-the-middle", "implementation"], "code_uid": "eb8637bd584499cbe3bfd4e0df39f802", "src_uid": "a6a804ce23bc48ec825c17d64ac0bb69", "difficulty": 1900.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.IO;\nusing System.Text;\n\nnamespace Chess\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 rx = Next(), ry = Next(), kx = Next(), ky = Next();\n\n int count = 0;\n for (int i = 0; i < 8; i++)\n {\n if (i == rx)\n continue;\n int dx = Math.Abs(kx - i);\n int dx1 = Math.Abs(rx - i);\n for (int j = 0; j < 8; j++)\n {\n if (j == ry)\n continue;\n\n int dy = Math.Abs(ky - j);\n int dy1 = Math.Abs(ry - j);\n if (dx + dy == 0 || (dx + dy == 3 && (dx == 1 || dx == 2)) || (dx1 + dy1 == 3 && (dx1 == 1 || dx1 == 2)))\n continue;\n\n count++;\n }\n }\n\n writer.WriteLine(count);\n writer.Flush();\n }\n\n private static int Next()\n {\n while (true)\n {\n int c = reader.Read();\n if (c >= '0' && c <= '9')\n return c - '1';\n if (c >= 'a' && c <= 'z')\n return c - 'a';\n }\n }\n }\n}", "lang_cluster": "C#", "tags": ["brute force", "math", "implementation"], "code_uid": "b35dfd1faaa00f3e474d7de34ddbc7df", "src_uid": "073023c6b72ce923df2afd6130719cfc", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nclass Program\n {\n static void Main(string[] args)\n {\n long a, b, c;\n {\n string[] input = Console.ReadLine().Split(new char[] {'\\t', ' ' },StringSplitOptions.RemoveEmptyEntries);\n a = long.Parse(input[0]); b = long.Parse(input[1]);\n if(a>b) { c = a; a = b; b = c; }\n c = long.Parse(input[2]);\n }\n if (bb)\n {\n long temp=Math.Abs(a);\n if (a<0L)\n {\n counter += ((temp / b) + (temp % b > 0L ? 1L : 0L));\n a += b * counter;\n }\n while (b < c)\n {\n counter++;\n a += b;\n temp = b;\n b = a;\n a = temp;\n }\n }\n Console.WriteLine(counter);\n }\n }\n }", "lang_cluster": "C#", "tags": ["math", "greedy"], "code_uid": "f4bc387b71d6a2938ab55a785e43861d", "src_uid": "82026a3c3d9a6bda2e2ac6e14979d821", "difficulty": 1600.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 n = sc.Integer();\n var d = sc.Integer();\n x = sc.Long();\n var a = new int[n];\n var b = new int[n];\n for (int i = 0; i < n; i++)\n a[i] = i + 1;\n for (int i = 0; i < n; i++)\n {\n nextX();\n var tmp = a[i];\n a[i] = a[x % (i + 1)];\n a[x % (i + 1)] = tmp;\n }\n for (int i = 0; i < n; i++)\n {\n if (i < d) b[i] = 1;\n else b[i] = 0;\n }\n for (int i = 0; i < n; i++)\n {\n nextX();\n var tmp = b[i];\n b[i] = b[x % (i + 1)];\n b[x % (i + 1)] = tmp;\n }\n\n if (d <= 1000)\n {\n var position = new List();\n for (int i = 0; i < n; i++)\n if (b[i] == 1) position.Add(i);\n for (int i = 0; i < n; i++)\n {\n var max = 0;\n foreach (var p in position)\n {\n if (p <= i)\n max = Math.Max(max, a[i - p]);\n }\n IO.Printer.Out.WriteLine(max);\n }\n\n }\n\n else\n {\n var position = new int[n];\n for (int i = 0; i < n; i++)\n position[a[i] - 1] = i;\n var pos = new List();\n for (int i = 0; i < n; i++)\n if (b[i] == 1) pos.Add(i);\n for (int i = 0; i < n; i++)\n {\n var f = false;\n for (int j = n - 1; j >= n - 1000; j--)\n {\n if (position[j] > i) continue;\n if (b[i - position[j]] > 0)\n {\n IO.Printer.Out.WriteLine(j + 1);\n f = true;\n break;\n }\n }\n if (f) continue;\n var max = 0;\n foreach (var p in pos)\n {\n if (p > i) break;\n max = Math.Max(max, a[i - p]);\n }\n IO.Printer.Out.WriteLine(max);\n }\n\n\n }\n }\n long x;\n long nextX()\n {\n return x = (x * 37 + 10007) % 1000000007;\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": ["probabilities"], "code_uid": "241467e251a2349eec1445e7d73d65d0", "src_uid": "948ae7a0189ada07c8c67a1757f691f0", "difficulty": 2300.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.IO;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\n\nclass Program\n{\n static int M;\n\n static void Main(string[] args)\n {\n long[] q1 = Console.ReadLine().Split(' ').Select(t => Int64.Parse(t)).ToArray();\n long N = q1[0];\n long K = q1[1];\n int L = (int)q1[2];\n M = (int)q1[3];\n\n int[, , ,] dp = new int[65, 2, 2, 2]; // gen, result, head, tail\n dp[0, 0, 0, 0] = 1;\n dp[0, 0, 1, 1] = 1;\n\n int[,] accum = null;\n\n for (int i = 1; i <= 64; ++i)\n {\n int[,] prevAccum = null;\n if (((1L << i - 1) & N) != 0)\n {\n if (accum == null)\n {\n accum = new int[2, 2]; // result, tail\n accum[0, 0] = (int)(((long)dp[i - 1, 0, 0, 0] + (long)dp[i - 1, 0, 1, 0]) % M);\n accum[0, 1] = (int)(((long)dp[i - 1, 0, 0, 1] + (long)dp[i - 1, 0, 1, 1]) % M);\n accum[1, 0] = (int)(((long)dp[i - 1, 1, 0, 0] + (long)dp[i - 1, 1, 1, 0]) % M);\n accum[1, 1] = (int)(((long)dp[i - 1, 1, 0, 1] + (long)dp[i - 1, 1, 1, 1]) % M);\n }\n else\n {\n prevAccum = accum;\n accum = new int[2, 2];\n }\n }\n \n for (int leftRes = 0; leftRes <= 1; ++leftRes)\n {\n for (int leftTail = 0; leftTail <= 1; ++leftTail)\n {\n for (int rightRes = 0; rightRes <= 1; ++rightRes)\n {\n for (int rightHead = 0; rightHead <= 1; ++rightHead)\n {\n for (int rightTail = 0; rightTail <= 1; ++rightTail)\n {\n int res = leftRes | rightRes | (leftTail & rightHead);\n for (int leftHead = 0; leftHead <= 1; ++leftHead)\n {\n long t = (long)dp[i, res, leftHead, rightTail] +\n (long)dp[i - 1, leftRes, leftHead, leftTail] * (long)dp[i - 1, rightRes, rightHead, rightTail];\n\n dp[i, res, leftHead, rightTail] = (int)(t % M);\n }\n\n if (prevAccum != null)\n {\n long t = (long)accum[res, rightTail] +\n (long)prevAccum[leftRes, leftTail] * (long)dp[i - 1, rightRes, rightHead, rightTail];\n accum[res, rightTail] = (int)(t % M);\n }\n }\n }\n }\n }\n }\n }\n\n\n int total = 1 % M;\n for (int i = 0; i < L; ++i)\n {\n if (((1L << i) & K) != 0)\n {\n total = (int)(((long)total * ((long)accum[1, 0] + (long)accum[1, 1])) % M);\n }\n else\n {\n total = (int)(((long)total * ((long)accum[0, 0] + (long)accum[0, 1])) % M);\n }\n }\n\n for (int i = L; i < 64; ++i)\n {\n if (((1L << i) & K) != 0)\n {\n total = 0;\n break;\n }\n }\n\n Console.WriteLine(total);\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "combinatorics", "matrices", "implementation", "number theory"], "code_uid": "6affe40ed80beefa038da633cbe1cfab", "src_uid": "2163eec2ea1eed5da8231d1882cb0f8e", "difficulty": 2100.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.IO;\nusing System.Text;\n\nnamespace Mike_and_Chocolate_Thieves\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 m = long.Parse(reader.ReadLine());\n\n long l = 1, r = m*10;\n\n while (l();\n\n int c = 1;\n for (int i = 0; ok && i < n; i++)\n {\n if (color[i] == 0)\n {\n if (c == 3)\n {\n ok = false;\n break;\n }\n color[i] = c;\n st.Push(i);\n while (ok && st.Count > 0)\n {\n int index = st.Pop();\n for (int j = 0; j < n; j++)\n {\n if (j==index)\n continue;\n if (nn[index][j] == 1)\n {\n if (color[j] == 3 || color[j] == c)\n continue;\n if (color[j] == 0)\n {\n st.Push(j);\n color[j] = c;\n continue;\n }\n ok = false;\n break;\n }\n if (color[index] == color[j])\n {\n ok = false;\n break;\n }\n }\n }\n c++;\n }\n }\n\n\n if (ok)\n {\n writer.WriteLine(\"Yes\");\n foreach (int i in color)\n {\n if (i == 1)\n writer.Write('a');\n else if (i == 2)\n writer.Write('c');\n else\n writer.Write('b');\n }\n }\n else\n {\n writer.WriteLine(\"No\");\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": ["constructive algorithms", "graphs"], "code_uid": "9309975fa2ce9bad9d3fd5c5e13ef96e", "src_uid": "e71640f715f353e49745eac5f72e682a", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.IO;\nusing System.Linq;\n\nnamespace Codeforces.R1355.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, long answer)\n {\n tw.WriteLine(answer);\n }\n\n private static long Parse(TextReader tr)\n {\n var t = tr.ReadLine().Split().Select(x => int.Parse(x)).ToArray();\n return Calc(t[0], t[1], t[2], t[3]);\n }\n\n public static long Calc(long a, long b, long c, long d)\n {\n var res = 0L;\n\n var arr = new long[Math.Max(b + c, d) + 2];\n\n for (var x = a; x <= b; ++x)\n {\n ++arr[x + b];\n --arr[x + c + 1];\n }\n\n var s = new long[arr.Length];\n\n for (var x = a + b; x <= b + c; ++x)\n s[x] = arr[x] + s[x - 1];\n\n var pre = new long[arr.Length];\n for (var x = a + b; x < pre.Length; ++x)\n pre[x] = pre[x - 1] + s[x];\n\n for (var z = c; z <= d; ++z)\n {\n res += pre[b + c] - pre[z];\n }\n\n return res;\n }\n\n public static long Calc0(long a, long b, long c, long d)\n {\n var res = 0L;\n\n for (var x = a; x <= b; ++x)\n {\n for (var y = b; y <= c; ++y)\n {\n for (var z = c; z <= d; ++z)\n {\n if (x + y > z)\n ++res;\n }\n }\n }\n\n return res;\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["two pointers", "math", "implementation", "binary search"], "code_uid": "b339b817fb51cc8cc02c054b7d92b630", "src_uid": "4f92791b9ec658829f667fcea1faee01", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\n\nnamespace CodeForces.Solutions.c319_189_1\n{\n\tpublic class Program1\n {\n public static void Main()\n {\n checked\n {\n\t var str = Console.ReadLine();\n\t var n = str.Length;\n\n\t var mult1 = 1L;\n\t var mod = 1000000007;\n\t var res = 0L;\n\t\t\t\tfor (var i = 0; i < n ; i++)\n\t\t\t\t{\n\t\t\t\t\tif (str[i] == '1')\n\t\t\t\t\t{\n\t\t\t\t\t\tvar mult2 = 1L;\n\t\t\t\t\t\tfor (var j = i + 1; j < n; j++)\n\t\t\t\t\t\t\tmult2 = (mult2*4)%mod;\n\n\t\t\t\t\t\tres = (res + mult1 * mult2) % mod;\n\t\t\t\t\t}\n\n\t\t\t\t\tmult1 = (mult1*2)%mod;\n\t\t\t\t}\n\n\t Console.Write(res);\n }\n }\n }\n}", "lang_cluster": "C#", "tags": ["math", "combinatorics"], "code_uid": "0cd04a1e78dc0322a50998fd7f161f31", "src_uid": "89b51a31e00424edd1385f2120028b9d", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections;\nusing System.Collections.Generic;\nusing System.Text;\nusing System.Text.RegularExpressions;\nusing System.Globalization;\nusing System.Threading;\nusing System.Linq;\n \nclass TEST{\n\tstatic void Main(){\n\t\tPlayer[] P=new Player[4];\n\t\tfor(int i=0;i<4;i++){\n\t\t\tvar s=Console.ReadLine().Split(' ');\n\t\t\tP[i]=new Player(int.Parse(s[1]),int.Parse(s[0]));\n\t\t}\n\t\t\n\t\tint[][] Score=new int[2][];\n\t\tfor(int i=0;i<2;i++)Score[i]=new int[2];\n\t\t\n\t\tint off1=0;\n\t\tint off2=0;\n\t\tint def1=0;\n\t\tint def2=0;\n\n\t\tfor(int i=0;i<2;i++){\n\t\t\tif(i==0){off1=P[0].Off;def1=P[1].Def;}\n\t\t\tif(i==1){off1=P[1].Off;def1=P[0].Def;}\n\t\t\t\n\t\t\tfor(int j=0;j<2;j++){\n\t\t\t\tif(j==0){off2=P[2].Off;def2=P[3].Def;}\n\t\t\t\tif(j==1){off2=P[3].Off;def2=P[2].Def;}\n\t\t\t\t\n\t\t\t\tif(off1>def2 && def1>off2){Score[i][j]=1;continue;}\n\t\t\t\tif(off1 totalS)\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": "4ead40d3d5b9527ba7de979da0fcb453", "src_uid": "05c90c1d75d76a522241af6bb6af7781", "difficulty": 1700.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;\n\nclass Solution\n{\n static void Main(string[] args)\n {\n var arr = Array.ConvertAll(Console.ReadLine().Trim().Split(), Convert.ToInt32);\n long n = arr[0];\n long k = arr[1];\n arr = Array.ConvertAll(Console.ReadLine().Trim().Split(), Convert.ToInt32);\n long s1 = arr[0];\n long s2 = arr[1];\n\n long d1 = s2 -s1 ;\n d1 = d1>0?d1:d1+k;\n long d2 = k - s2 - s1;\n d2 = d2>0?d2:d2+k;\n\n long d3 = s1-s2;\n d3 = d3>0?d3:d3+k;\n long d4 = s2+s1;\n d4 = d4>0?d4:d4+k;\n\n var minGcd = long.MaxValue;\n var maxGcd = long.MinValue;\n for(int i =0; i 0)\n\t\t\t{\n\t\t\t\tvar tmp = n2;\n\t\t\t\tn2 = n1 % n2;\n\t\t\t\tn1 = tmp;\n\t\t\t}\n\t\t\treturn n2;\n\t\t}\n\t}\n\n\n}", "lang_cluster": "C#", "tags": ["math", "implementation", "number theory"], "code_uid": "c36bddbf90e251a856f86831beee9cc7", "src_uid": "5bb4adff1b332f43144047955eefba0c", "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.Round85 {\n class C {\n static int[] ReadInts() { return Array.ConvertAll(Console.ReadLine().Split(' '), sss => int.Parse(sss)); }\n\n static int popcount(int n) { int res = 0; for (; n > 0; n &= n - 1)res++; return res; }\n\n static int n, m;\n static bool check(int v, int j) {\n int mask = (1 << m) - 1;\n return ((v | (v << 1) | (v >> 1) | j) & mask) == mask;\n }\n\n static void Main() {\n var xs = ReadInts();\n n = xs.Max();\n m = xs.Min();\n\n if (m == 1 && false) {\n Console.WriteLine(n == (n + 1) / 2);\n return;\n }\n\n var dp = new int[][,] { new int[1 << m, 1 << m], new int[1 << m, 1 << m] };\n\n for (int v = 0; v < 1 << m; v++)\n for (int j = 0; j < 1 << m; j++)\n dp[0][v, j] = 1 << 29;\n\n dp[0][(1 << m) - 1, 0] = 0;\n\n int a = 0;\n for (int i = 0; i <= n; i++, a ^= 1) {\n var cur = dp[a];\n var next = dp[a ^ 1];\n\n for (int v = 0; v < 1 << m; v++)\n for (int j = 0; j < 1 << m; j++)\n next[v, j] = 1 << 29;\n\n for (int v = 0; v < 1 << m; v++) {\n for (int j = 0; j < 1 << m; j++) {\n for (int k = 0; k < 1 << m; k++) {\n if (check(v, j | k)) {\n next[v, k] = Math.Min(cur[j, v] + popcount(k), next[v, k]);\n }\n }\n }\n }\n }\n\n int res = 1000000000;\n for (int v = 0; v < 1 << m; v++)\n for (int j = 0; j < 1 << m; j++)\n res = Math.Min(res, dp[a][v, j]);\n Console.WriteLine(n * m - res);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["dsu", "dp", "bitmasks"], "code_uid": "c4eec4714d1d356d6b26b4c91eb652fe", "src_uid": "097674b4dd696b30e102938f71dd39b9", "difficulty": 2100.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.IO;\nusing Kattis.IO;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Runtime.Remoting.Messaging;\n\npublic class Program\n{\n private static int n, a, b, k;\n private static long MOD = 1000000007;\n public static void Main(string[] args)\n {\n var cin = new Tokenizer(Console.OpenStandardInput());\n var cout = new BufferedStdoutWriter();\n\n n = int.Parse(cin.Next());\n a = int.Parse(cin.Next());\n b = int.Parse(cin.Next());\n k = int.Parse(cin.Next());\n\n long[] f = new long[n + 1];\n f[a] = 1;\n for (int t = 0; t < k; t++)\n {\n long[] g = new long[n + 1];\n long[] prefix = new long[n + 1];\n for (int i = 1; i <= n; i++)\n {\n if (i == b) continue;\n int l = 0, r = 0;\n if (i < b)\n {\n r = b - 1;\n l = 2 * i - r;\n }\n else\n {\n l = b + 1;\n r = 2 * i - l;\n }\n l = Math.Max(l, 1);\n r = Math.Min(r, n);\n\n // [l, i) \n if (l < i)\n {\n prefix[i - 1] = (prefix[i - 1] + f[i]) % MOD;\n prefix[l - 1] = (prefix[l - 1] + MOD - f[i]) % MOD;\n }\n\n // (i, r]\n if (i < r)\n {\n prefix[r] = (prefix[r] + f[i]) % MOD;\n prefix[i] = (prefix[i] + MOD - f[i]) % MOD;\n }\n }\n g[n] = prefix[n];\n for (int i = n - 1; i >= 1; i--) g[i] = (g[i + 1] + prefix[i]) % MOD;\n f = g;\n }\n\n long ans = 0;\n for (int i = 1; i <= n; i++) ans = (ans + f[i]) % MOD;\n\n cout.WriteLine(ans);\n cout.Close();\n }\n}\n\nnamespace Kattis.IO\n{\n public class NoMoreTokensException : Exception\n {\n }\n\n public 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()\n : 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\n public 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\n public class BufferedStdoutWriter : StreamWriter\n {\n public BufferedStdoutWriter()\n : base(new BufferedStream(Console.OpenStandardOutput()))\n {\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["dp", "combinatorics"], "code_uid": "cac94f8c169226a0931555860b861557", "src_uid": "142b06ed43b3473513995de995e19fc3", "difficulty": 1900.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Collections;\nusing System.Linq;\nusing System.Text;\nclass problem\n{\n static void Main()\n {\n var v = Array.ConvertAll( Console.ReadLine().Split(), Convert.ToInt32 );\n int n = v[0], a = v[1], x = v[2], b = v[3], y = v[4];\n int t=x>a?x-a:x+n-a;\n t=Math.Min(t,y>b?b+n-y:b-y);\n while(t-->-1)\n {\n if(a == b)\n {\n Console.WriteLine( \"YES\" );\n return;\n }\n else\n {\n a = a == n ? 1 : a+1;\n b = b == 1 ? n : b-1;\n }\n }\n Console.WriteLine( \"NO\" );\n\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "implementation"], "code_uid": "f6a5398192f699ddf0f1e738cdefd97b", "src_uid": "5b889751f82c9f32f223cdee0c0095e4", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\n\nclass Codeforces\n{\n static void Main()\n {\n var tmp = Console.ReadLine().Split(' ');\n int px = int.Parse(tmp[0]);\n int py = int.Parse(tmp[1]);\n\n tmp = Console.ReadLine().Split(' ');\n int fx = int.Parse(tmp[0]);\n int fy = int.Parse(tmp[1]);\n\n var a = dist(px, py, fx, fy + 1);\n a = Math.Max(a, dist(px, py, fx, fy - 1));\n a = Math.Max(a, dist(px, py, fx + 1, fy));\n a = Math.Max(a, dist(px, py, fx - 1, fy));\n a = Math.Max(a, dist(px, py, fx + 1, fy - 1));\n a = Math.Max(a, dist(px, py, fx + 1, fy + 1));\n a = Math.Max(a, dist(px, py, fx - 1, fy - 1));\n a = Math.Max(a, dist(px, py, fx - 1, fy + 1));\n if (px == fx || py == fy) a++;\n Console.WriteLine(2 * a);\n }\n\n private static int dist(int px, int py, int fx, int fy)\n {\n return Math.Abs(px - fx) + Math.Abs(py - fy);\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "greedy"], "code_uid": "f1dd8493aec81a7482aa53c84ee45c32", "src_uid": "f54ce13fb92e51ebd5e82ffbdd1acbed", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "// Problem: 1185A - Ropewalkers\n// Author: Gusztav Szmolik\n\nusing System;\n\nclass Ropewalkers\n {\n public static int Main ()\n {\n string line = Console.ReadLine ();\n if (line == null)\n return -1;\n char[] delims = new char[] {' ', '\\t'};\n string[] words = line.Split (delims,StringSplitOptions.RemoveEmptyEntries);\n if (words.Length != 4)\n return -1;\n uint a;\n if (!ReadInputNumber (words[0], out a))\n return -1;\n uint b;\n if (!ReadInputNumber (words[1], out b))\n return -1;\n uint c;\n if (!ReadInputNumber (words[2], out c))\n return -1;\n uint d;\n if (!ReadInputNumber (words[3], out d))\n return -1;\n uint[] initPositions = new uint[] {a,b,c};\n Array.Sort (initPositions);\n uint ans = 0;\n uint dist1 = initPositions[1]-initPositions[0];\n uint dist2 = initPositions[2]-initPositions[1];\n if (dist1 < d)\n ans += d-dist1;\n if (dist2 < d)\n ans += d-dist2;\n Console.WriteLine (ans);\n return 0;\n }\n \n static bool ReadInputNumber (string s, out uint num)\n {\n if (!UInt32.TryParse (s, out num))\n return false;\n if (num < 1 || num > 1000000000)\n return false;\n return true;\n } \n }\n", "lang_cluster": "C#", "tags": ["math"], "code_uid": "e7fb23870811f48b394bc7ac4e2aafb9", "src_uid": "47c07e46517dbc937e2e779ec0d74eb3", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\n\nnamespace MafiaGame\n{\n class Program\n {\n static void Main()\n {\n var input = Console.ReadLine().Split(' ');\n int a = Int32.Parse(input[0]);\n int b = Int32.Parse(input[1]);\n int c = Int32.Parse(input[2]);\n int d = Int32.Parse(input[3]);\n int e = Int32.Parse(input[4]);\n int f = Int32.Parse(input[5]);\n\n if (d == 0)\n {\n Console.WriteLine(\"Hermione\");\n return;\n }\n if (c == 0)\n {\n Console.WriteLine(\"Ron\");\n return;\n }\n if (b == 0)\n {\n Console.WriteLine(\"Hermione\");\n return;\n }\n if (a == 0)\n {\n Console.WriteLine(\"Ron\");\n return;\n }\n if (f == 0)\n {\n Console.WriteLine(\"Hermione\");\n return;\n }\n if (e == 0)\n {\n Console.WriteLine(\"Ron\");\n return;\n }\n double zoloto = ((double)d * b) / c;\n double pesok = (double)f * zoloto / e;\n if (pesok > a)\n Console.WriteLine(\"Ron\");\n else\n Console.WriteLine(\"Hermione\");\n }\n }\n}", "lang_cluster": "C#", "tags": ["math", "implementation"], "code_uid": "57bd216a65d4d5610b14fa45e0e8f1c7", "src_uid": "44d608de3e1447f89070e707ba550150", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\n\nnamespace Rucksack\n{\n class Program\n //{\n // static Dictionary cache = new Dictionary();\n\n // static Bun[] buns;\n\n // static int n, m;\n // static int[] a;\n\n // static int c0, d0;\n\n // static void Main(string[] args)\n // {\n // /*\u0412 \u043f\u0435\u0440\u0432\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u0441\u044f 4 \u0446\u0435\u043b\u044b\u0445 \u0447\u0438\u0441\u043b\u0430 n, m, c0 \u0438 d0 (1\u2009\u2264\u2009n\u2009\u2264\u20091000, 1\u2009\u2264\u2009m\u2009\u2264\u200910, 1\u2009\u2264\u2009c0,\u2009d0\u2009\u2264\u2009100).\n // \u0412 \u043a\u0430\u0436\u0434\u043e\u0439 \u0438\u0437 \u043f\u043e\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0445 m \u0441\u0442\u0440\u043e\u043a \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442\u0441\u044f \u043f\u043e 4 \u0446\u0435\u043b\u044b\u0445 \u0447\u0438\u0441\u043b\u0430.\n // \u0412 i-\u043e\u0439 \u0438\u0437 \u043d\u0438\u0445 \u043d\u0430\u0445\u043e\u0434\u044f\u0442\u0441\u044f \u0447\u0438\u0441\u043b\u0430 ai, bi, ci \u0438 di (1\u2009\u2264\u2009ai,\u2009bi,\u2009ci,\u2009di\u2009\u2264\u2009100).*/\n\n // string[] words = Console.ReadLine().Split(' ');\n\n // n = int.Parse(words[0]);\n // m = int.Parse(words[1]);\n // c0 = int.Parse(words[2]);\n // d0 = int.Parse(words[3]);\n\n // float result = f(n, a);\n\n // Console.WriteLine(result);\n\n // Console.ReadLine();\n\n\n // }\n\n // static int f(int n, int[] a)\n // {\n // ParamKey paramKey = new ParamKey { n = n, a = a };\n\n // if (cache.ContainsKey(paramKey))\n // return cache[paramKey];\n\n // int maxCost = 0;\n\n // for (int i = 0; i < buns.Length; ++i)\n // {\n // if (n - buns[i].c >= 0 && a[i] - buns[i].b >= 0)\n // {\n // int[] tempA = new int[a.Length];\n\n // a.CopyTo(tempA, 0);\n\n // tempA[i] -= buns[i].b;\n\n // int cost = f(n - buns[i].c, tempA) + buns[i].d;\n\n // if (cost > maxCost) maxCost = cost;\n // }\n // }\n\n // cache[paramKey] = maxCost;\n // return maxCost;\n // }\n //}\n\n //struct Bun\n //{\n // /// \n // /// \u041d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0435 \u0447\u0438\u0441\u043b\u043e \u043d\u0430\u0447\u0438\u043d\u043a\u0438\n // /// \n // public int b;\n\n // /// \n // /// \u041d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0435 \u0447\u0438\u0441\u043b\u043e \u0442\u0435\u0441\u0442\u0430\n // /// \n // public int c;\n\n // /// \n // /// \u0421\u0442\u043e\u0438\u043c\u043e\u0441\u0442\u044c\n // /// \n // public int d;\n //}\n\n //struct ParamKey\n //{\n // public int n;\n // public int[] a;\n\n // public override bool Equals(object obj)\n // {\n // if (obj == null || GetType() != obj.GetType())\n // {\n // return false;\n // }\n\n // return GetHashCode() == ((ParamKey)obj).GetHashCode();\n // }\n\n // public override int GetHashCode()\n // {\n // int hash = n;\n\n // foreach (int e in a)\n // hash ^= e;\n\n // return hash;\n // }\n //}\n {\n static int n, m, d0, c0, i, j, k, maxCost;\n static int[] a, b, c, d;\n static int[,] dp;\n\n static void Main(string[] args)\n {\n string[] words = Console.ReadLine().Split(' ');\n\n n = int.Parse(words[0]);\n m = int.Parse(words[1]);\n c0 = int.Parse(words[2]);\n d0 = int.Parse(words[3]);\n\n a = new int[m + 1];\n b = new int[m + 1];\n c = new int[m + 1];\n d = new int[m + 1];\n\n c[0] = c0; d[0] = d0;\n\n for (i = 1; i <= m; ++i)\n {\n words = Console.ReadLine().Split(' ');\n\n a[i] = int.Parse(words[0]);\n b[i] = int.Parse(words[1]);\n c[i] = int.Parse(words[2]);\n d[i] = int.Parse(words[3]);\n }\n\n dp = new int[n + 1, m + 1];\n\n for (i = 1; i <= n; ++i)\n {\n for (j = 1; j <= m; ++j)\n {\n maxCost = 0;\n\n for (k = 0; k <= a[j] / b[j]; ++k)\n {\n if (i - c[j] * k >= 0)\n {\n if (dp[i - c[j] * k, j - 1] + d[j] * k > maxCost)\n maxCost = dp[i - c[j] * k, j - 1] + d[j] * k;\n }\n }\n\n dp[i, j] = maxCost;\n }\n }\n\n maxCost = 0;\n for (k = 0; k <= n; ++k)\n {\n if (dp[k, m] + ((n - k) / c0) * d0 > maxCost)\n maxCost = dp[k, m] + ((n - k) / c0) * d0;\n }\n\n Console.WriteLine(maxCost);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["dp"], "code_uid": "8f5afaacf15ea4e03609eee12e430513", "src_uid": "4e166b8b44427b1227e0f811161d3a6f", "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 }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "combinatorics"], "code_uid": "bc053d789d9ef68db807cddf0d370d40", "src_uid": "d3e3da5b6ba37c8ac5f22b18c140ce81", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.IO;\nusing System.Linq;\n\nnamespace Codeforces._272\n{\n public class Solver\n {\n public static void Main()\n {\n StreamWriter sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };\n new Solver().Solve(Console.In, sw);\n sw.Flush();\n }\n\n public void Solve(TextReader tr, TextWriter tw)\n {\n var tokens = tr.ReadLine().Split();\n var n = int.Parse(tokens[0]);\n var m = int.Parse(tokens[1]);\n\n var ab = new int[m, 2];\n for (int i = 0; i < m; ++i)\n {\n var p = tr.ReadLine().Split().Select(x => int.Parse(x) - 1).ToArray();\n ab[i, 0] = p[0];\n ab[i, 1] = p[1];\n }\n\n var res = Solve(n, ab);\n tw.WriteLine(res);\n }\n\n public string Solve(int n, int[,] ab)\n {\n var edges = Utils.CreateListArray(n);\n for (var i = 0; i < ab.GetLength(0); ++i)\n {\n edges[ab[i, 0]].Add(ab[i, 1]);\n edges[ab[i, 1]].Add(ab[i, 0]);\n }\n\n var res = new bool[n];\n\n for (var updated = true; updated;)\n {\n updated = false;\n for (int i = 0; i < n; ++i)\n {\n if (edges[i].Count(e => res[i] == res[e]) >= 2)\n {\n res[i] = !res[i];\n updated = true;\n }\n }\n }\n\n return new string(res.Select(x => x ? '1' : '0').ToArray());\n }\n }\n\n public static class Utils\n {\n public static List[] CreateListArray(int n)\n {\n var res = new List[n];\n for (int i = 0; i < n; ++i)\n {\n res[i] = new List();\n }\n return res;\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["constructive algorithms", "combinatorics", "graphs"], "code_uid": "8cd3604055271b2f99a695e473e774c8", "src_uid": "7017f2c81d5aed716b90e46480f96582", "difficulty": 2200.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\n\nnamespace CSharp\n{\n class _900B\n {\n public static void Main()\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 for (int i = 1; i <= b; i++)\n {\n a %= b;\n a *= 10;\n\n if (a / b == c)\n {\n Console.WriteLine(i);\n return;\n }\n }\n\n Console.WriteLine(-1);\n }\n }\n}", "lang_cluster": "C#", "tags": ["math", "number theory"], "code_uid": "396a8a8b2aa95920cf214a1bc52bb067", "src_uid": "0bc7bf67b96e2898cfd8d129ad486910", "difficulty": 1300.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 if (n == 0)\n return 0;\n if (n == 1)\n return 1;\n var l = ReadLong() - 1;\n var r = ReadLong() - 1;\n long cur = n;\n var info = new List();\n while(cur != 1)\n {\n var p = new Pair { Val = cur / 2, Rem = cur % 2 };\n info.Add(p);\n cur = cur / 2;\n }\n long count1 = 1L;\n long len = 1L;\n for (int i = info.Count - 1; i >= 0; i--)\n {\n len = len * 2 + 1;\n info[i].Len = len;\n count1 = count1 * 2 + info[i].Rem;\n info[i].Count1 = count1;\n }\n return Recursive(info, l, r, 0, 0);\n }\n\n long Recursive(List info, long l, long r, int depth, long myLeft)\n {\n var currentPair = info[depth];\n var myRight = myLeft + currentPair.Len - 1;\n if (myLeft >= l && myRight <= r)\n return currentPair.Count1;\n if (myLeft > r || myRight < l)\n return 0;\n if (depth == info.Count - 1)\n {\n long result = 0;\n if (myLeft >= l && myLeft <= r)\n result++;\n if (myRight >= l && myRight <= r)\n result++;\n if (myLeft + 1 >= l && myLeft + 1<= r)\n result += currentPair.Rem;\n return result;\n }\n var first = Recursive(info, l, r, depth + 1, myLeft);\n var sec = Recursive(info, l, r, depth + 1, myLeft + info[depth + 1].Len + 1);\n var mid = myLeft + currentPair.Len / 2;\n var res = first + (mid >= l && mid <= r ? currentPair.Rem : 0) + sec;\n return res;\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": ["dfs and similar", "divide and conquer", "constructive algorithms"], "code_uid": "d33afcecf572fa6b03730f26ebc929c6", "src_uid": "3ac61b1f8deee7911b1055c243f5eb6a", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text.RegularExpressions;\nusing System.IO;\n\nnamespace Rextester\n{\n public class Program\n {\n public static void Main(string[] args)\n {\n string s = Console.ReadLine();\n string []ast = s.Split(new char[]{' '});\n int a = int.Parse(ast[0]);\n int b = int.Parse(ast[1]);\n int c = int.Parse(ast[2]);\n int n = int.Parse(ast[3]);\n \n int otv = n - ((a - c) + (b - c) + c);\n if((otv > 0) && (n > c) && (a >= c) && (b >= c))\n Console.WriteLine(otv);\n else\n Console.WriteLine(\"-1\");\n } \n }\n}", "lang_cluster": "C#", "tags": ["implementation"], "code_uid": "4343a2fdd949eaeddba8eaba2a7c5336", "src_uid": "959d56affbe2ff5dd999a7e8729f60ce", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System; namespace _569C { class Program { const int MAX = 1180000; static void Main(string[] args) { string[] input = Console.ReadLine().Split(' '); int p = Int32.Parse(input[0]); int q = Int32.Parse(input[1]); int n1 = 0; int n2 = 0; int n = 1; int count = 0; for (int i = 1; i < MAX; i++) { if (isPrime(i) == true) n1++; if (IsPalindrome(i.ToString()) == true) n2++; if (n1 > n2 * p / q && count==0) { n = i - 1; count++; } if (count == 1 && n1 <= n2 * p / q) { count = 0; } } Console.WriteLine(n == MAX ? \"Palindromic tree is better than splay tree\" : n.ToString()); } static bool isPrime(int n) { if (n == 1) return false; if (n == 2) return true; if (n == 3) return true; if (n % 2 == 0) return false; if (n % 3 == 0) return false; int i = 5; int w = 2; while (i * i <= n) { if (n % i == 0) return false; i += w; w = 6 - w; } return true; } static string Reverse(string value) { char[] chars = value.ToCharArray(); Array.Reverse(chars); return new string(chars); } static bool IsPalindrome(string value) { return value == Reverse(value); } } }", "lang_cluster": "C#", "tags": ["brute force", "math", "binary search", "number theory"], "code_uid": "07362e7378b28ba279137c3ee3e439d5", "src_uid": "e6e760164882b9e194a17663625be27d", "difficulty": 1600.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().TrimEnd().Split(' ').Select(long.Parse).ToList();\n var n = data[0];\n var s = data[1];\n long l = 0;\n long r = n;\n while (l <= r)\n {\n long m = (l + r) / 2;\n if (!isBig(m,s)) l = m + 1; else r = m - 1;\n }\n\n Console.WriteLine(n - r);\n\n }\n\n }\n}", "lang_cluster": "C#", "tags": ["brute force", "math", "dp", "binary search"], "code_uid": "2bf6ed76ef66a8ac18538b2e60e96096", "src_uid": "9704e2ac6a158d5ced8fd1dc1edb356b", "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 _630M_Turn\n{\n class Program\n {\n static void Main(string[] args)\n {\n long x = long.Parse(Console.ReadLine());\n\n if (Math.Abs(x) > 360)\n x %= 360;\n if (x < 0)\n x += 360;\n if (x <= 45 || x >= 315 )\n Console.WriteLine(\"0\");\n else if (x > 45 && x <= 135)\n Console.WriteLine(\"1\");\n else if (x > 135 && x <= 225)\n Console.WriteLine(\"2\");\n else\n Console.WriteLine(\"3\");\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "geometry"], "code_uid": "0b7620a96934bd9b54b61ec29ca8b430", "src_uid": "509db9cb6156b692557ba874a09f150e", "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;\nusing System.Threading.Tasks;\n\nnamespace ConsoleApp1\n{\n\tclass Program\n\t{\n\t\tstatic void Main(string[] args)\n\t\t{\n\t\t\tstring[] str = Console.ReadLine().Split(new char[] { ' ' });\n\n\t\t\tint n = Convert.ToInt32(str[0]);\n\t\t\tint m = Convert.ToInt32(str[1]);\n\n\t\t\tlong tmp = Binpow(2, m) - 1;\n\t\t\ttmp = Binpow(tmp, n);\n\n\t\t\tConsole.WriteLine(tmp);\n\t\t\tConsole.ReadLine();\n\t\t}\n\n\t\tpublic static long Binpow(long a, int n)\n\t\t{\n\t\t\tif (n == 0)\n\t\t\t\treturn 1;\n\t\t\tif (n % 2 == 1)\n\t\t\t\treturn (Binpow(a, n - 1) * a) % 1000000007;\n\t\t\telse\n\t\t\t{\n\t\t\t\tlong b = Binpow(a, n / 2);\n\t\t\t\treturn (b * b) % 1000000007;\n\t\t\t}\n\t\t}\n\t}\n}\n\n", "lang_cluster": "C#", "tags": ["math", "combinatorics"], "code_uid": "4763d25219e1f9e850b789ed475e3623", "src_uid": "71029e5bf085b0f5f39d1835eb801891", "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": "4709ec674e75c0b98f7bd3cc22c56297", "src_uid": "65699ddec8d0db2f58b83a0f64de6f6f", "difficulty": 2200.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}", "lang_cluster": "C#", "tags": ["math"], "code_uid": "c27dc9e2c4fa8f870e6084864756f8a8", "src_uid": "e853733fb2ed87c56623ff9a5ac09c36", "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 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 d = int.Parse(token[1]);\n \n int[] x = new int[n];\n string[] token2 = Console.ReadLine().Split();\n \n for(int i=0;i list = new List();\n \n for(int i=0;i facs = new List { 1 };\n public static Modular Fac(int n)\n {\n for (int i = facs.Count; i <= n; ++i)\n {\n facs.Add((int)(Math.BigMul(facs.Last(), i) % M));\n }\n return facs[n];\n }\n public static Modular Ncr(int n, int r)\n {\n return (n < r) ? 0\n : (n == r) ? 1\n : Fac(n) / (Fac(r) * Fac(n - r));\n }\n public static explicit operator int(Modular a)\n {\n return (int)a.value;\n }\n}\n\nclass MyClass\n{\n public static void Solve()\n {\n var input = Console.ReadLine().Split().Select(int.Parse).ToArray();\n Modular n = input[0];\n Modular m = input[1];\n var k = input[2];\n if (input[0] == 1)\n {\n Console.WriteLine((int)Modular.Pow(n, k));\n return;\n }\n var dp = new Modular[k + 1];\n var poly = new Modular[k + 1];\n for (int i = 0; i < k + 1; i++)\n {\n poly[i] = 0;\n }\n poly[1] = 1;\n for (int i = 1; i < k + 1; i++)\n {\n var num = Modular.Pow(1 / m, i);\n for (int j = 0; j < i; j++)\n {\n num *= n - j;\n }\n for (int j = 1; j < i; j++)\n {\n num -= poly[j] * dp[j];\n }\n dp[i] = num;\n if (i == k)\n {\n break;\n }\n poly[i + 1] = 1;\n for (int j = i; j >= 1; j--)\n {\n poly[j] = -i * poly[j] + poly[j - 1];\n }\n }\n Console.WriteLine((int)dp[k]);\n }\n\n public static void Main()\n {\n var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };\n Console.SetOut(sw);\n Solve();\n Console.Out.Flush();\n }\n}", "lang_cluster": "C#", "tags": ["math", "dp", "combinatorics", "probabilities", "number theory"], "code_uid": "5e20c7d8ec34c94040b015112611135a", "src_uid": "e6b3e559b5fd4e05adf9f1cd1b22126b", "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 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 = ReadLines(n);\n\n int nt = 0, nb = 0;\n for (int i = 0; i < n; i++)\n for (int j = 0; j < m; j++)\n if (char.IsDigit(a[i][j]))\n nt = Math.Max(nt, a[i][j] - '0');\n else if (a[i][j] == 'B')\n nb++;\n if (nt == 0)\n {\n Write(0);\n return;\n }\n var price = ReadAndTransposeIntMatrix(nt)[0];\n\n var pos = new int[nt + nb][];\n nb = 0;\n int sr = 0, sc = 0;\n for (int i = 0; i < n; i++)\n for (int j = 0; j < m; j++)\n if (char.IsDigit(a[i][j]))\n pos[a[i][j] - '1'] = new[] { i, j };\n else if (a[i][j] == 'B')\n pos[nt + nb++] = new[] { i, j };\n else if (a[i][j] == 'S')\n {\n sr = i;\n sc = j;\n }\n\n var f = new bool[n,m,1 << nt + nb];\n f[sr, sc, 0] = true;\n var q = new Queue>();\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": "0dcc127a141248d0021d837bb8d382ce", "src_uid": "624a0d6cf305fcf67d3f1cdc1c5fef8d", "difficulty": 2600.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 char[] ch = { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n',\n 'o','p','q','r','s','t','u','v','w','x','y','z'};\n int [] am = new int[26];\n int n = int.Parse(Console.ReadLine());\n string str = Console.ReadLine();\n string ans = \"\";\n for (int i = 0; i < str.Length/2; i++)\n {\n if (str[i] != '?' && str[str.Length - i - 1] != '?')\n {\n if (str[i] != str[str.Length - i - 1])\n { Console.WriteLine(\"IMPOSSIBLE\"); return; }\n else ans += str[i];\n }\n else\n if (str[i] == '?' && str[str.Length - i - 1] == '?')\n {\n ans+='?';\n }\n else {\n if (str[i] == '?')\n ans += str[str.Length - i - 1];\n else ans += str[i];\n }\n\n }\n if (str.Length % 2 != 0)\n {\n ans += str[str.Length / 2];\n }\n List lst = new List();\n int quest=0;\n foreach (var i in ans)\n {\n if (i == '?') quest++;\n else if (!lst.Contains(i)) lst.Add(i);\n }\n if (lst.Count > n)\n {\n Console.WriteLine(\"IMPOSSIBLE\"); return;\n }\n string aa = \"\";\n if (quest != 0)\n {\n int kol = n - lst.Count();\n int curQ = 0;\n foreach (var i in ans)\n {\n if (i == '?')\n {\n if (quest <= kol)\n {\n bool b = false;\n for (int ii = 0; ii < n; ii++)\n {\n if (!lst.Contains(ch[ii]))\n {\n aa += ch[ii];\n lst.Add(ch[ii]);\n b = true;\n break;\n }\n\n }\n if (!b) aa += 'a';\n }\n else aa += \"a\";\n quest--;\n\n }\n else aa += i;\n\n }\n }\n else\n aa = ans;\n lst = new List();\n foreach (var i in aa)\n {\n bool b = false;\n if (!lst.Contains(i)) lst.Add(i);\n for (int ii = 0; ii < n; ii++)\n {\n if (i == ch[ii])\n {\n b = true;\n break;\n }\n }\n if(!b)\n {\n Console.WriteLine(\"IMPOSSIBLE\"); return;\n }\n }\n if (lst.Count != n)\n {\n Console.WriteLine(\"IMPOSSIBLE\"); return;\n }\n Console.Write(aa);\n if (str.Length % 2 != 0) { aa= aa.Substring(0, aa.Length - 1); }\n\n for (int i = aa.Length-1; i >= 0; i--)\n {\n Console.Write(aa[i]);\n }\n Console.WriteLine();\n \n\n }\n }\n \n}\n", "lang_cluster": "C#", "tags": ["expression parsing"], "code_uid": "90407af573a7d77a775413998c417e53", "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.Text;\n\nnamespace Cave_Painting\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 n = Next();\n long k = Next();\n\n var h = new HashSet();\n for (int i = 1; i <= k; i++)\n {\n if (!h.Add(n%i))\n return false;\n }\n\n return true;\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": ["brute force", "number theory"], "code_uid": "1cf208cf6dd1572993590fdd67169f29", "src_uid": "5271c707c9c72ef021a0baf762bf3eb2", "difficulty": 1600.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\n /// \n /// \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0443\u044e \u043f\u0435\u0440\u0435\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0443 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432. \u042d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u043d\u0435 \u043e\u0431\u044f\u0437\u0430\u043d\u044b \u0431\u044b\u0442\u044c \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u043c\u0438.\n /// \u0414\u043e\u043b\u0436\u043d\u043e \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f, \u0447\u0442\u043e \u043d\u0430 \u0432\u0445\u043e\u0434 \u043f\u043e\u0434\u0430\u0435\u0442\u0441\u044f \u043e\u0434\u043d\u0430 \u0438\u0437 \u043f\u0435\u0440\u0435\u0441\u0442\u0430\u043d\u043e\u0432\u043e\u043a.\n /// \u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 true, \u0435\u0441\u043b\u0438 \u0431\u044b\u043b\u0430 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0430 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0430\u044f \u043f\u0435\u0440\u0435\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430, \u0438\u043d\u0430\u0447\u0435 - false.\n /// \n bool NextPermutation(IList a)\n {\n var n = a.Count;\n for (int ind = n - 2; ind >= 0; ind--)\n if (a[ind] < a[ind + 1])\n for (int i = ind + 2; ; i++)\n if (i == n || a[ind] >= a[i])\n {\n swap(a, ind, i - 1);\n var m = (n - 1 - ind) >> 1;\n for (int j = 1; j <= m; j++)\n swap(a, ind + j, n - j);\n return true;\n }\n return false;\n }\n\n int tutu(int[,] a, List s, int from, int to)\n {\n if (a[from, to] == 0)\n {\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 l = tutu(a, s, from, i);\n var r = tutu(a, s, i + 1, to);\n var z = l + r;\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 void Solution()\n {\n var n = ri;\n var s = rs;\n var a = new List(n) { s[0] };\n for (int i = 1; i < n; i++)\n if (s[i - 1] != s[i])\n a.Add(s[i]);\n\n var b = new int[n, n];\n for (int i = 0; i < n; i++)\n b[i, i] = 1;\n wln(tutu(b, a, 0, a.Count - 1));\n\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 void swap(IList a, int from, int to) { var buf = a[from]; a[from] = a[to]; a[to] = buf; }\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 // \u0427\u0438\u0442\u0430\u0435\u0442 \u0441\u0442\u0440\u043e\u043a\u0443 \u0431\u0435\u0437 \u043f\u0440\u043e\u0431\u0435\u043b\u043e\u0432\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 List(n);\n for (int i = 0; i < n; i++)\n res.Add(ri);\n return res;\n }\n List rla(int n)\n {\n var res = new List(n);\n for (int i = 0; i < n; i++)\n res.Add(rl);\n return res;\n }\n List rda(int n)\n {\n var res = new List(n);\n for (int i = 0; i < n; i++)\n res.Add(rd);\n return res;\n }\n // \u0427\u0438\u0442\u0430\u0435\u0442 \u0441\u0442\u0440\u043e\u043a\u0438 \u0431\u0435\u0437 \u043f\u0440\u043e\u0431\u0435\u043b\u043e\u0432\n List rsa(int n)\n {\n var res = new List(n);\n for (int i = 0; i < n; i++)\n res.Add(rs);\n return res;\n }\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}\n", "lang_cluster": "C#", "tags": ["dp"], "code_uid": "779457e664513c8188696c43e9e9213e", "src_uid": "516a89f4d1ae867fc1151becd92471e6", "difficulty": 2000.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 n = ReadLong();\n var cr = ReadLongs().Select(x => x - 1).ToArray();\n var visited = new bool[n];\n var lens = new List();\n for (long i = 0; i < n; i++)\n {\n if (!visited[i])\n {\n var current = i;\n var len = 0;\n do\n {\n visited[current] = true;\n current = cr[current];\n len++;\n } while (!visited[current]);\n if (current != i)\n return -1;\n lens.Add(len);\n }\n }\n for (int i = 0; i < lens.Count; i++)\n {\n if (lens[i] % 2 == 0)\n lens[i] /= 2;\n }\n long res = 1;\n for (int i = 0; i < lens.Count; i++)\n {\n res = res * lens[i]/Nod(res, lens[i]);\n }\n return res;\n }\n }\n\n public long Nod(long a, long b)\n {\n if (b == 0)\n return a;\n return Nod(b, a % b);\n }\n\n List> GetVariants(int[][] groups, int current, long[] bs, long[] ws)\n {\n var result = new List>();\n long Wsum = 0;\n long Bsum = 0;\n for (int i = 0; i < groups[current].Length; i++)\n {\n var x = groups[current][i];\n result.Add(Tuple.Create(ws[x], bs[x]));\n Wsum += ws[x];\n Bsum += bs[x];\n }\n result.Add(Tuple.Create(Wsum, Bsum));\n return result;\n }\n\n long Pow(long b, long p)\n {\n if (p == 0)\n return 1;\n if (p == 1)\n return b;\n if (p % 2 == 0)\n return (Pow((b * b) % 10, p / 2)) % 10;\n return (b * Pow(b, p - 1)) % 10;\n }\n\n int GetLargestPrime(int n)\n {\n if (TestPrime(n))\n return n;\n\n var current = n % 2 == 0 ? n - 3 : n - 2;\n while (!TestPrime(current))\n {\n current -= 2;\n }\n return current;\n }\n\n bool TestPrime(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 class Node\n {\n public long Parent;\n public List Children;\n public int Index;\n }\n //int BS(long[][] cuts, int left, int right)\n //{\n // if (right - left == 1)\n // return left;\n // var half = (left + right) / 2;\n\n //}\n\n //void Check(long[][] cuts, long value)\n //{\n\n //}\n\n\n\n\n struct Segment\n {\n public Segment(long left, long rigth)\n {\n Left = left;\n Right = rigth;\n }\n\n public long Left;\n public long Right;\n public long Size() { return Right - Left; }\n public long Ships(long size) { return Size() / size; }\n public List GetPositions(long shipSize) {\n var result = new List();\n for (var i = Left + shipSize - 1; i < Right; i+=shipSize)\n {\n result.Add(i);\n }\n return result;\n }\n }\n\n struct Second\n {\n public Second(long count, long mana)\n {\n Mana = mana;\n Count = count;\n }\n\n public long Mana;\n public long Count;\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 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}", "lang_cluster": "C#", "tags": ["dfs and similar", "math"], "code_uid": "8573938bc20a44cc201b0e7025982b9e", "src_uid": "149221131a978298ac56b58438df46c9", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.IO;\nusing System.Linq;\nusing System.Text;\n\nnamespace INTERCALC\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 writer.WriteLine(nn.Max() ^ nn[n - 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": ["implementation"], "code_uid": "ae0b8ddcd1ad630d270113cc409603f0", "src_uid": "f45c769556ac3f408f5542fa71a67d98", "difficulty": 1800.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, K;\n public void Solve()\n {\n var sc = new Scanner();\n N = sc.NextInt();\n K = sc.NextInt();\n\n /*\n * n\u884cn\u5217\u3000\u30bf\u30a4\u30eb\u3000\u767dor\u9ed2\n * \u96a3\u63a5\u3059\u308b\u884c \u3059\u3079\u3066\u540c\u3058\u304b\u9055\u3046\u304b\u3064\n * k\u500b\u4ee5\u4e0a\u306e\u5358\u8272\u306e\u30bf\u30a4\u30eb\u306e\u9577\u65b9\u5f62\u304c\u5b58\u5728\u3057\u306a\u3044\u306a\u3089beautiful\n * \n * beautiful\u306a\u30d1\u30bf\u30fc\u30f3\u6570\n * \n */\n\n /*\n * \u6700\u5927\u306e\u9023\u7d9a\u304cx\u306e\u5217\n * \n * O(n^3)\u3067\u8abf\u3079\u308b\n * \n */\n\n // i\u307e\u3067\u898b\u308b\u3001\u73fe\u5728\u9023\u7d9aj \u6700\u5927\u9023\u7d9ak\n\n // i\u306f2\u3067\u5272\u3063\u305f\u3042\u307e\u308a\n var dp = new ModInt[2, N + 1, N + 1];\n dp[1, 1, 1] = 1;\n\n for (int i = 1; i < N; i++)\n {\n for (int j = 1; j <= i + 1; j++)\n {\n for (int k = 1; k <= i + 1; k++)\n {\n dp[(i + 1) & 1, j, k] = 0;\n }\n }\n for (int j = 1; j <= i; j++)\n {\n for (int k = j; k <= i; k++)\n {\n dp[(i + 1) & 1, j + 1, Math.Max(j + 1, k)] += dp[i & 1, j, k];\n dp[(i + 1) & 1, 1, k] += dp[i & 1, j, k];\n }\n }\n }\n\n ModInt[] t = new ModInt[N + 1];\n for (int x = 1; x <= N; x++)\n {\n for (int j = 1; j <= x; j++)\n {\n t[x] += dp[N & 1, j, x];\n }\n }\n ModInt ans = 0;\n\n for (int x = 1; x * x < K && x <= N; x++)\n {\n // \u6a2a\u6700\u5927x\u500b\u9023\u7d9a\n ModInt s = t[x];\n\n for (int y = x + 1; x * y < K && y <= N; y++)\n {\n // \u7e26\u6700\u5927y\u500b\u9023\u7d9a\n // x < y\n ModInt u = t[y];\n // \u7e26\u6a2a\u4ea4\u63db\u3001\u8272\u53cd\u8ee2\n ans += s * u * 4;\n }\n\n // \u7e26\u6a2ax\n // \u8272\u53cd\u8ee2\n ans += s * s * 2;\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 = (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": ["math", "dp", "combinatorics"], "code_uid": "1ea7f050f9307a47b8c1b7bf2766da6d", "src_uid": "77177b1a2faf0ba4ca1f4d77632b635b", "difficulty": 2100.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Linq;\n\nnamespace ConsoleProject\n{\n class Program\n {\n private static int[] ReadIntArray => Console.ReadLine().Split(' ').Select(int.Parse).ToArray();\n private static long[] ReadLongArray => Console.ReadLine().Split(' ').Select(long.Parse).ToArray();\n private static char[] ReadCharArray => Console.ReadLine().Split(' ').Select(char.Parse).ToArray();\n private static string[] ReadStringArray => Console.ReadLine().Split(' ').Select(str => str).ToArray();\n private static int ReadInt => int.Parse(Console.ReadLine());\n private static long ReadLong => long.Parse(Console.ReadLine());\n private static string ReadString => Console.ReadLine();\n struct Point\n {\n public string s;\n public int i;\n public Point(int i, string s)\n {\n this.i = i;\n this.s = s;\n }\n }\n static void Main()\n {\n long b = ReadLong;\n\n long a = 0;\n\n for (long i = 1; i <= Math.Sqrt(b); i++)\n {\n if (b % i == 0)\n {\n a += 2;\n }\n if (i * i == b) a--;\n }\n\n Console.WriteLine(a);\n\n Console.ReadLine();\n }\n private static long S(long v)\n {\n long sum = 0;\n while (v != 0)\n {\n sum += v % 10;\n v /= 10;\n }\n return sum;\n }\n private static long F(long v)\n {\n long sum = 0;\n while (v >= 10)\n {\n v /= 10;\n sum *= 10;\n sum += 9;\n }\n return sum;\n }\n }\n}", "lang_cluster": "C#", "tags": ["math", "number theory"], "code_uid": "c9e7b194a6ece05d9832c0321394b439", "src_uid": "7fc9e7d7e25ab97d8ebc10ed8ae38fd1", "difficulty": 1200.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 C\n{\n class Program\n {\n static void Main(string[] args)\n {\n TextReader sr = Console.In;\n //StreamReader sr = new StreamReader(\"3.txt\");\n int n = Convert.ToInt32(sr.ReadLine());\n string ss = sr.ReadLine();\n List str = new List();\n for (int ii = 0; ii < n; ii++)\n {\n str.Add(ss[ii]);\n }\n int i = 0;\n int res = 0;\n char b = 'z';\n while (true)\n {\n if (i == str.Count())\n {\n i = 0;\n b--;\n if (b < 'a') break;\n else continue;\n }\n if (str[i] == b)\n {\n if ((i > 0) && (str[i - 1] == (b - 1)))\n {\n str.RemoveAt(i);\n res++;\n }\n else if ((i < str.Count - 1) && (str[i + 1] == (b - 1)))\n {\n str.RemoveAt(i);\n res++;\n if (i > 0) i--;\n }\n else\n {\n i++;\n }\n }\n else\n {\n i++;\n }\n }\n Console.WriteLine(res.ToString());\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "greedy", "strings", "constructive algorithms"], "code_uid": "47f1ce505cf0ddd1eecc6f39c13ea3e7", "src_uid": "9ce37bc2d361f5bb8a0568fb479b8a38", "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;\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 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": "44165c0121853fcbadec71cc0b6bbaa0", "src_uid": "bc31a1d4a02a0011eb9f5c754501cd44", "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// using (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\n internal class Task\n {\n public void Solve(InputReader sr, TextWriter sw)\n {\n var input = sr.ReadArrayOfInt32();\n var n = input[0];\n var array = sr.ReadArrayOfInt32();\n var four = n;\n for (var i = 0; i < array.Length; i++) {\n var count = array[i] / 4;\n if (four >= count) {\n four -= count;\n array[i] = array[i] % 4;\n }\n else {\n count -= four;\n four = 0;\n array[i] = count * 4 + array[i] % 4;\n }\n }\n var twice = 2*n;\n var one = 0;\n if (four > 0) {\n one = four;\n twice += four;\n }\n Array.Sort(array, (x, y) => -(x % 2).CompareTo((y % 2)));\n for (var i = 0; i < array.Length; i++) {\n var a = array[i];\n if (a % 2 == 1) {\n var count = a / 2 + 1;\n if (one > 0) {\n one--;\n count--;\n }\n if (twice < count) {\n sw.WriteLine(\"NO\");\n return;\n }\n twice -= count;\n }\n else {\n var count = a / 2;\n if (twice > count) {\n twice -= count;\n }\n else {\n count -= twice;\n twice = 0;\n if (one < count * 2) {\n sw.WriteLine(\"NO\");\n return;\n }\n else {\n one -= count * 2;\n }\n }\n }\n }\n\n sw.WriteLine(\"YES\");\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 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", "greedy", "implementation"], "code_uid": "78aac55fb2fd51f5e49cbd0f022c8ff2", "src_uid": "d1f88a97714d6c13309c88fcf7d86821", "difficulty": 1900.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeff#define DEBUG\n#undef DEBUG\nusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.IO;\n\nnamespace Codeforces_A066\n{\n class A066\n {\n static void Main()\n {\n\n long k, ans, r1;\n string s;\n long[] a = new long[3];\n#if DEBUG\n StreamReader sr = new StreamReader(\"a66.txt\");\n s = sr.ReadLine();\n#else\n s = Console.ReadLine();\n#endif\n string[] st = s.Split(' ');\n a[0] = long.Parse(st[0].Trim());\n a[1] = long.Parse(st[1].Trim());\n a[2] = long.Parse(st[2].Trim());\n Array.Sort(a);\n k = long.Parse(st[3].Trim());\n\n if (k == 0) ans = 1;\n else\n if (k >= (a[0]-1) + (a[1]-1) + (a[2]-1)) ans = a[0] * a[1] * a[2];\n else\n {\n ans = 1;\n for (long i = 0; i < 3; i++)\n {\n r1 = Math.Min(k / (3 - i), a[i]-1);\n ans *= (r1+1);\n k -= r1;\n }\n }\n Console.WriteLine(ans);\n#if DEBUG\n Console.ReadKey();\n#endif\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "greedy"], "code_uid": "79d224036927f1c81bfbb9ecf26d94fe", "src_uid": "8787c5d46d7247d93d806264a8957639", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\nusing System.Collections.Generic;\n\nnamespace Problems\n{\n class Program\n {\n static void Main(string[] args)\n {\n int n, k;\n\n string[] input = Console.ReadLine().Split(' ');\n\n n = Convert.ToInt32(input[0]);\n k = Convert.ToInt32(input[1]);\n\n int[] a = new int[n];\n\n input = Console.ReadLine().Split(' ');\n\n for (int i = 0; i < n; i++)\n {\n a[i] = Convert.ToInt32(input[i]);\n }\n\n int min = int.MaxValue;\n\n if(k == 1) min = 0;\n\n for (int i = 0; i < n - 1; i++)\n {\n for (int j = i + 1; j < n; j++)\n {\n int target = a[i];\n int temp = a[j];\n int count1 = 0;\n int count2 = 0;\n List counts = new List();\n\n while (temp != target)\n {\n while (temp > target)\n {\n temp /= 2;\n count1++;\n }\n\n while (target > temp)\n {\n target /= 2;\n count2++;\n }\n }\n\n //Console.WriteLine(target + \" target\");\n\n /*counts.Add(count1);\n counts.Add(count2);*/\n\n for (int x = 0; x < n; x++)\n {\n int current = a[x];\n int count = 0;\n\n //Console.WriteLine(\"current \" + current + \" target \" + target);\n\n if(current < target) continue;\n\n while (current > target)\n {\n current /= 2;\n count++;\n }\n\n //Console.WriteLine(\"i \" + i + \" j \" + j + \" x \" + x + \" count \" + count);\n\n if(current == target)\n {\n counts.Add(count);\n }\n }\n\n //Console.WriteLine(\"count size \" + counts.Count);\n\n if(counts.Count >= k)\n {\n counts.Sort();\n int newCount = 0;\n\n for (int x = 0; x < k; x++)\n {\n //Console.WriteLine(\"Counts \" + counts[x] + \" i \" + i + \" j \" + j + \" x \" + x);\n newCount += counts[x];\n }\n\n min = Math.Min(min, newCount);\n }\n }\n }\n\n Console.WriteLine(min);\n }\n }\n}", "lang_cluster": "C#", "tags": ["brute force", "implementation"], "code_uid": "2c8983ec90d5ab9f00828369483be37b", "src_uid": "ed1a2ae733121af6486568e528fe2d84", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Globalization;\nusing System.IO;\nusing System.Text;\n\n#region code challenges entry point\n#if !SOLVER_ATWORKSPACE\nclass Program{static void Main(string[] args){using (var output = new CC.FormattedStreamWriter(Console.OpenStandardOutput())) using (var error = new CC.FormattedStreamWriter(Console.OpenStandardError())) using (var input = new CC.BufferedStreamReader(Console.OpenStandardInput()))new CC.Solver(input, output, error).Do();}}\n#endif\n#endregion\n\n#region code helpers boilerplate\nnamespace CC\n{ \n class BufferedStreamReader : StreamReader { const int QUEUE_INITSIZE = 10000; public BufferedStreamReader(String fileName): base(fileName) { } public BufferedStreamReader(Stream stream): base(stream) { } private Queue buffer = new Queue(QUEUE_INITSIZE); public override string ReadLine() { if (buffer.Count > 0) throw new InvalidOperationException(\"must read from buffer first\"); return base.ReadLine(); } public string ReadToken() { while (buffer.Count == 0) { base.ReadLine().Split(new[] { ' ', '\\t' }, StringSplitOptions.RemoveEmptyEntries).ToList().ForEach((t) => { buffer.Enqueue(t); }); } return buffer.Dequeue(); } public void ResetBuffer() { buffer = new Queue(QUEUE_INITSIZE); } }\n class FormattedStreamWriter : StreamWriter { public FormattedStreamWriter(Stream stream) : base(stream) { } public FormattedStreamWriter(string filePath) : base(filePath) { } public override IFormatProvider FormatProvider { get { return CultureInfo.InvariantCulture; } } }\n static class IOExtensions\n {\n public static string String(this BufferedStreamReader reader) { return reader.ReadToken(); }\n public static string[] StringArray(this BufferedStreamReader reader, int n) { var array = new string[n]; for (int i = 0; i < n; ++i) { array[i] = reader.ReadToken(); } return array; }\n public static int Int(this BufferedStreamReader reader) { return int.Parse(reader.ReadToken(), CultureInfo.InvariantCulture); }\n public static int[] IntArray(this BufferedStreamReader reader, int n) { var array = new int[n]; for (int i = 0; i < n; ++i) { array[i] = int.Parse(reader.ReadToken(), CultureInfo.InvariantCulture); } return array; }\n public static uint UnsignedInt(this BufferedStreamReader reader) { return uint.Parse(reader.ReadToken(), CultureInfo.InvariantCulture); }\n public static long Long(this BufferedStreamReader reader) { return long.Parse(reader.ReadToken(), CultureInfo.InvariantCulture); }\n public static long[] LongArray(this BufferedStreamReader reader, int n) { var array = new long[n]; for (int i = 0; i < n; ++i) { array[i] = long.Parse(reader.ReadToken(), CultureInfo.InvariantCulture); } return array; }\n public static ulong UnsignedLong(this BufferedStreamReader reader) { return ulong.Parse(reader.ReadToken(), CultureInfo.InvariantCulture); }\n public static double Double(this BufferedStreamReader reader) { return double.Parse(reader.ReadToken(), CultureInfo.InvariantCulture); }\n public static double[] DoubleArray(this BufferedStreamReader reader, int n) { var array = new double[n]; for (int i = 0; i < n; ++i) { array[i] = double.Parse(reader.ReadToken(), CultureInfo.InvariantCulture); } return array; }\n public static decimal Decimal(this BufferedStreamReader reader) { return decimal.Parse(reader.ReadToken(), CultureInfo.InvariantCulture); }\n public static decimal[] DecimalArray(this BufferedStreamReader reader, int n) { var array = new decimal[n]; for (int i = 0; i < n; ++i) { array[i] = decimal.Parse(reader.ReadToken(), CultureInfo.InvariantCulture); } return array; }\n public static void ArrayLine(this FormattedStreamWriter writer, T[] array, int n, string format = \"{0}\", string separator = \" \") { for (int i = 0; i < n; ++i) { if (i > 0) writer.Write(separator); writer.Write(format, array[i]); } writer.WriteLine(); }\n public static void ArrayLine(this FormattedStreamWriter writer, T[] array, string format = \"{0}\", string separator = \" \") { writer.ArrayLine(array, array.Length, format, separator); }\n }\n partial class Solver\n {\n protected readonly BufferedStreamReader read;\n protected readonly FormattedStreamWriter write;\n protected readonly FormattedStreamWriter error;\n public Solver(BufferedStreamReader read, FormattedStreamWriter write, FormattedStreamWriter error){this.read = read;this.write = write;this.error = error;}\n public static T[][] Create2DArray(int dim1, int dim2) { var res = new T[dim1][]; for (int i = 0; i < dim1; ++i) res[i] = new T[dim2]; return res; }\n public static T[][][] Create3DArray(int dim1, int dim2, int dim3) { var res = new T[dim1][][]; for (int i = 0; i < dim1; ++i) res[i] = Create2DArray(dim2, dim3); return res; }\n public static T[][][][] Create4DArray(int dim1, int dim2, int dim3, int dim4) { var res = new T[dim1][][][]; for (int i = 0; i < dim1; ++i) res[i] = Create3DArray(dim2, dim3, dim4); return res; }\n public void Do(){Run();}\n }\n static class Utils\n {\n public static void Swap(ref T one, ref T second) { T tmp = one; one = second; second = tmp; }\n }\n}\n#endregion\n\nnamespace CC\n{\n using System.Diagnostics;\n using System.Text;\n\n partial class Solver\n {\n public void Run()\n {\n var a = read.IntArray(14);\n var b = new int[14];\n long res = 0;\n for (int i = 0; i < 14; ++i)\n if (a[i] > 0)\n { \n Array.Copy(a, b, 14);\n b[i] = 0;\n for (int j = 0; j < 14; ++j)\n b[(i + 1 + j) % 14] += a[i] / 14 + ((a[i] % 14) > j ? 1: 0);\n long sum = 0;\n for (int j = 0; j < 14; ++j)\n sum += b[j] % 2 == 0 ? b[j] : 0;\n res = Math.Max(res, sum);\n }\n write.WriteLine(res);\n }\n }\n}", "lang_cluster": "C#", "tags": ["brute force", "implementation"], "code_uid": "efff3ab71a632725c6cff14ccae9fd39", "src_uid": "1ac11153e35509e755ea15f1d57d156b", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "C# 10", "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\nusing System.Numerics;\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 m = ReadInt();\r\n \r\n if (m == 1)\r\n Write(n - 1);\r\n else\r\n Write(1L * n * (m - 1));\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 * 1500);\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"], "code_uid": "0cf20b1a3f2a3721221fa1c36796c6f8", "src_uid": "a91aab4c0618d036c81022232814ef44", "difficulty": 800.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 \n void solve()\n {\n long l = nextInt();\n long r = nextInt();\n long p = 1;\n long res = 0;\n while (p < 1000000000000L)\n {\n p *= 10;\n long c = p - 1;\n long num;\n if (c / 2 > r)\n num = r;\n else if (c / 2 < l)\n num = l;\n else\n num = c / 2;\n if (num >= p / 10 && num < p)\n res = Math.Max(res, num * (c - num));\n }\n println(res);\n \n\n }\n long get(int x)\n {\n long y = 0;\n long p = 1;\n long temp = x;\n while (x > 0)\n {\n y += p * (9 - x % 10);\n x /= 10;\n p *= 10;\n }\n return temp * y;\n }\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 int nextInt()\n {\n return int.Parse(nextString());\n }\n long nextLong()\n {\n return long.Parse(nextString());\n }\n double nextDouble()\n {\n return double.Parse(nextString());\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"], "code_uid": "f5016f91f5fbc6b212111024d8285c3e", "src_uid": "2c4b2a162563242cb2f43f6209b59d5e", "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 B_Sum\n{\n public class Sum\n {\n static int GetNotation(string input)\n {\n int max = 0;\n foreach (char c in input)\n max = Math.Max(max, (int)c);\n return max - 47;\n }\n\n static int Calculate(int notation, int result_10)\n {\n int output = 0;\n int temp = result_10;\n\n do\n {\n output++;\n temp = temp / notation;\n } while (temp >= notation);\n output++;\n return output;\n\n }\n\n static int Convert_10(int notation, string x)\n {\n\n int count = 0;\n int output = 0;\n for (int i = x.Length - 1; i >= 0; i--)\n {\n int temp = ((int)x[i] - 48) * Pow(notation, count);\n count++;\n output += temp;\n }\n return output;\n }\n\n static int Pow(int x, int g)\n {\n if (g == 0) return 1;\n else return x * Pow(x, g - 1);\n }\n\n static public int MaxLength(string input)\n {\n int notation = GetNotation(input);\n string[] s = input.Split(' ');\n int x = Convert_10(notation, s[0]);\n int y = Convert_10(notation, s[1]);\n return Calculate(notation, x + y);\n }\n }\n class Program\n {\n \n static void Main(string[] args)\n {\n Sum X = new Sum();\n Console.WriteLine(Sum.MaxLength(Console.ReadLine()));\n //Console.WriteLine(Convert_10(9, \"78\"));\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math"], "code_uid": "5cdd740db3338b6e946741f8d0bbbc6c", "src_uid": "8ccfb9b1fef6a992177cc49bd56fab7b", "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.Text.RegularExpressions;\n\nnamespace ConsoleApplication1\n{\n class Program\n {\n public static Int64 powermod(Int64 b, Int64 n, Int64 m)\n {\n Int64 result = 1;\n while (n > 0)\n {\n if ((n & 1) == 1)\n {\n result = (result * b) % m;\n }\n b = (b * b) % m;\n n = n / 2;\n }\n return result;\n \n //return (result - 1) % m;\n }\n\n static void Main(string[] args)\n {\n Int64 n, m;\n string[] inp = Console.ReadLine().ToString().Split(' ');\n n = Convert.ToInt64(inp[0]);\n m = Convert.ToInt64(inp[1]);\n\n Int64 r = powermod(3, n, m);\n r = r == 0 ? m - 1 : r-1;\n Console.WriteLine(r);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math"], "code_uid": "5ccc0085a344c63b972ebde287db7525", "src_uid": "c62ad7c7d1ea7aec058d99223c57d33c", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "C# 8", "source_code": "\ufeffusing System;\r\nusing System.IO;\r\nusing System.Linq;\r\nusing System.Collections.Generic;\r\nusing System.Text;\r\nusing System.Numerics;\r\n\r\nnamespace cfgr14\r\n{\r\n class Program\r\n {\r\n static void Main(string[] args)\r\n {\r\n Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });\r\n if (File.Exists(\"input.txt\"))\r\n {\r\n Console.SetIn(new StreamReader(\"input.txt\"));\r\n }\r\n solve_cfgr14E();\r\n Console.Out.Flush();\r\n }\r\n\r\n public static long[] fact = new long [405];\r\n public static long[] inv = new long [405];\r\n public static long[,] choose = new long [405, 405];\r\n public static long[] pow2 = new long [405];\r\n public static long n;\r\n public static long mod;\r\n /*\r\n Editorial:\r\n \r\n */\r\n public static void solve_cfgr14E()\r\n {\r\n long[] nm = Array.ConvertAll(Console.ReadLine().Split(), long.Parse);\r\n n = nm[0];\r\n mod = nm[1];\r\n precompute();\r\n long[,] dp = new long[405, 405];\r\n dp[0, 0] = 1;\r\n for (int i = 0; i < n; i++)\r\n {\r\n for (int j = 0; j <= i; j++)\r\n {\r\n for (int k = 1; i + k <= n; k++)\r\n {\r\n dp[i + k + 1, j + k] += (dp[i, j] * pow2[k - 1]) % mod * choose[j + k, k];\r\n dp[i + k + 1, j + k] %= mod;\r\n }\r\n }\r\n }\r\n\r\n long ans = 0;\r\n for (int i = 0; i <= n; i++)\r\n {\r\n ans = (ans + dp[n + 1, i]) % mod;\r\n }\r\n Console.WriteLine(ans);\r\n }\r\n\r\n public static void precompute()\r\n {\r\n fact[0] = 1;\r\n inv[0] = 1;\r\n for (int i = 1; i <= n; i++)\r\n {\r\n fact[i] = (fact[i - 1] * i) % mod;\r\n inv[i] = binExp(fact[i], mod - 2);\r\n }\r\n\r\n for (int i = 0; i <= n; i++)\r\n {\r\n for (int j = 0; j <= i; j++)\r\n {\r\n choose[i, j] = ((fact[i] * inv[j]) % mod * inv[i - j]) % mod;\r\n }\r\n }\r\n\r\n for (int i = 0; i <= n; i++)\r\n {\r\n pow2[i] = binExp(2, i);\r\n }\r\n }\r\n\r\n public static long binExp(long a, long exp)\r\n {\r\n if (exp == 0)\r\n {\r\n return 1;\r\n }\r\n long tmp = binExp(a, exp / 2);\r\n tmp = (tmp * tmp) % mod;\r\n if (exp % 2 == 1)\r\n {\r\n tmp *= a;\r\n }\r\n return tmp % mod;\r\n }\r\n\r\n public static void solve_cfgr14C()\r\n {\r\n int t = Convert.ToInt32(Console.ReadLine());\r\n while(t-- > 0)\r\n {\r\n int[] nmx = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);\r\n int n = nmx[0];\r\n int m = nmx[1];\r\n int x = nmx[2];\r\n int[] h = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);\r\n Array.Sort(h);\r\n int[] cnt = new int[m];\r\n for (int i = 0; i < n; i++)\r\n {\r\n cnt[i % m] += h[i];\r\n }\r\n int min = int.MaxValue;\r\n int max = int.MinValue;\r\n bool ok = true;\r\n for (int i = 0; i < m; i++)\r\n {\r\n min = Math.Min(min, cnt[i]);\r\n max = Math.Max(max, cnt[i]);\r\n if (max - min > x)\r\n {\r\n ok = false;\r\n break;\r\n }\r\n }\r\n if (ok)\r\n {\r\n Console.WriteLine(\"YES\");\r\n for (int i = 0; i < n; i++)\r\n {\r\n Console.Write(\"{0} \", (i % m) + 1);\r\n }\r\n }\r\n else\r\n {\r\n Console.Write(\"NO\");\r\n }\r\n Console.WriteLine();\r\n }\r\n }\r\n\r\n public static void solve_cfgr14B()\r\n {\r\n int t = Convert.ToInt32(Console.ReadLine());\r\n while(t-- > 0)\r\n {\r\n int n = Convert.ToInt32(Console.ReadLine());\r\n bool ok = false;\r\n if (n > 1 && (n & (n - 1)) == 0)\r\n {\r\n ok = true;\r\n }\r\n else\r\n {\r\n for (int i = 2; i * i <= 1000000000; i++)\r\n {\r\n if (i % 2 != 0)\r\n {\r\n if (n % (i * i) == 0)\r\n {\r\n int r = n / (i * i);\r\n if (r > 1 && (r & (r - 1)) == 0)\r\n {\r\n ok = true;\r\n break;\r\n }\r\n }\r\n }\r\n }\r\n }\r\n Console.WriteLine(ok ? \"YES\" : \"NO\");\r\n }\r\n\r\n }\r\n\r\n public static void solve_cfgr14A()\r\n {\r\n int t = Convert.ToInt32(Console.ReadLine());\r\n while(t-- > 0)\r\n {\r\n int[] nx = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);\r\n int n = nx[0];\r\n int x = nx[1];\r\n int[] w = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);\r\n Array.Sort(w, (a, b) => b.CompareTo(a));\r\n int sum = 0;\r\n int posToChange = -1;\r\n for (int i = 0; i < n; i++)\r\n {\r\n sum += w[i];\r\n if (sum == x)\r\n {\r\n posToChange = i;\r\n }\r\n }\r\n if (sum != x)\r\n {\r\n Console.WriteLine(\"YES\");\r\n for (int i = 0; i < n; i++)\r\n {\r\n if (i == posToChange)\r\n {\r\n if (i + 1 < n)\r\n {\r\n int tmp = w[i];\r\n w[i] = w[i + 1];\r\n w[i + 1] = tmp;\r\n }\r\n }\r\n Console.Write(\"{0} \", w[i]);\r\n }\r\n }\r\n else\r\n {\r\n Console.Write(\"NO\");\r\n }\r\n Console.WriteLine();\r\n \r\n }\r\n }\r\n }\r\n}", "lang_cluster": "C#", "tags": ["math", "dp", "combinatorics"], "code_uid": "8c31cce6c7c1726b0d7e31e36aebe703", "src_uid": "4f0e0d1deef0761a46b64de3eb98e774", "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 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": ["constructive algorithms", "math", "combinatorics", "binary search", "greedy", "implementation"], "code_uid": "2c14d3b1b2045e47874434728acd226e", "src_uid": "e03c6d3bb8cf9119530668765691a346", "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 canada1\n{\n class Program\n {\n static void Main(string[] args)\n {\n\n string input = \"\";\n string[] inputElements = new string[3];\n input = Console.ReadLine();\n inputElements = input.Split(' ');\n\n int a = Convert.ToInt32(inputElements[0]);\n int b = Convert.ToInt32(inputElements[1]);\n int c = Convert.ToInt32(inputElements[2]);\n\n int first = (a * b) + (b * c) + (c * a);\n int second = a + b + c;\n\n Console.WriteLine(first - second + 1);\n }\n\n\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "implementation"], "code_uid": "aeca2fd5e212fdbf0e07b78b14d9d59b", "src_uid": "8ab25ed4955d978fe20f6872cb94b0da", "difficulty": 1200.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();\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.Item2] || p != param[que.Peek.Item2]) que.Pop();\n else\n {\n used[que.Peek.Item2] = 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();\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[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": "ac8f7c5e3cbaba7ea0e843b475516e76", "src_uid": "ad014bde729222db14f38caa521e4167", "difficulty": 2600.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\nclass Myon\n{\n static Scanner cin;\n public Myon() { }\n public static int Main()\n {\n //Console.SetOut(new Printer(Console.OpenStandardOutput()));\n cin = new Scanner();\n new Myon().calc();\n return 0;\n }\n\n\n\n int MAX = 400;\n int[] vy = { 1, 1, 0, -1, -1, -1, 0, 1 };\n int[] vx = { 0, 1, 1, 1, 0, -1, -1, -1}; \n\n public void calc()\n {\n int[,] field = new int[MAX, MAX];\n bool[,] check = new bool[MAX, MAX];\n field[MAX / 2, MAX / 2] = 1;\n\n int N = cin.nextInt();\n for (int i = 0; i < N; i++)\n {\n int t = cin.nextInt();\n //step\n for (int j = 0; j < t; j++)\n {\n int[,] nextfield = new int[MAX, MAX];\n for (int y = 0; y < MAX; y++)\n {\n for (int x = 0; x < MAX; x++)\n {\n if (field[y, x] == 0) continue;\n for (int k = 0; k < 8; k++)\n {\n if(((field[y,x] >> k) & 1) == 1)\n {\n nextfield[y + vy[k], x + vx[k]] |= 1 << k;\n check[y + vy[k], x + vx[k]] = true;\n }\n }\n\n }\n }\n field = nextfield;\n }\n\n //change\n for (int y = 0; y < MAX; y++)\n {\n for (int x = 0; x < MAX; x++)\n {\n if (field[y, x] == 0) continue;\n int first = field[y, x] & 1;\n int last = (field[y, x] >> 7) & 1;\n field[y, x] = (field[y, x] << 1) | (field[y, x] >> 1);\n field[y, x] &= 0xFF;\n field[y, x] |= last;\n field[y, x] |= first << 7;\n }\n }\n }\n int ans = 0;\n for (int y = 0; y < MAX; y++)\n {\n for (int x = 0; x < MAX; x++)\n {\n if (check[y, x]) ans++;\n }\n }\n Console.WriteLine(ans);\n\n }\n\n}\n\nclass Printer : StreamWriter\n{\n public override IFormatProvider FormatProvider { get { return CultureInfo.InvariantCulture; } }\n public Printer(Stream stream) : base(stream, new UTF8Encoding(false, true)) { }\n public Printer(Stream stream, Encoding encoding) : base(stream, encoding) { }\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 while (i >= s.Length)\n {\n string st = Console.ReadLine();\n while (st == \"\") st = Console.ReadLine();\n s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);\n i = 0;\n }\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": ["dfs and similar", "brute force", "dp", "data structures", "implementation"], "code_uid": "70293103b9fde16d484ff8147d19d087", "src_uid": "a96bc7f93fe9d9d4b78018b49bbc68d9", "difficulty": 1900.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 arr = Console.ReadLine().Split(' ');\r\n var n = Int32.Parse(arr[0]);\r\n var k = Int32.Parse(arr[1]);\r\n\r\n Console.WriteLine(GetVal(n,k));\r\n }\r\n\r\n\r\n const int MOD_VAL = 1000000007;\r\n \r\n private static int GetVal(int n, int k)\r\n {\r\n var res = 1;\r\n if(k >= n)\r\n {\r\n for(var i = 0;i=0;i--)\r\n {\r\n revals[i] = (int)((long)revals[i+1] * (i+1) % MOD_VAL);\r\n }\r\n return revals;\r\n }\r\n\r\n private static int[] GetFactorials(int n)\r\n {\r\n var factorials = new int[n+1];\r\n factorials[0] = 1;\r\n for(var i = 1;i<=n;i++)\r\n {\r\n factorials[i] = (int)((long)factorials[i-1] * i % MOD_VAL); \r\n }\r\n return factorials;\r\n }\r\n\r\n \r\n }\r\n}", "lang_cluster": "C#", "tags": ["math", "greedy", "constructive algorithms", "combinatorics"], "code_uid": "36eaf9569806e41f26d4f82ef5ddb25d", "src_uid": "dc7b887afcc2e95c4e90619ceda63071", "difficulty": 1900.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using System;\nusing System.Text;\nusing System.Collections.Generic;\n\nnamespace Codeforces_235_2\n{\n class Program\n {\n static void Main(string[] args)\n {\n int[] _bitcounts = new int[512];\n int pos1 = -1, pos2 = -1, i;\n for (i = 1; i < 512; i++, pos1++) {\n if (pos1 == pos2) {\n pos1 = 0;\n pos2 = i;\n }\n _bitcounts[i] = _bitcounts[pos1] + 1;\n }\n\n long n, m;\n string[] d = Console.ReadLine().Split(' ');\n n = long.Parse(d[0]);\n m = long.Parse(d[1]);\n\n int b, dictlen;\n long[] D = new long[18];\n int[] stat = new int[10];\n\n for (b = 0; 0 < n; ++b, n /= 10)\n {\n D[b] = n % 10;\n ++stat[D[b]];\n }\n\n long bb = 1L << b;\n long[,] dp = new long[bb, m];\n\n for (i = 0; i < b; ++i)\n if (0 < D[i]) dp[1 << i, D[i] % m] = 1;\n\n for (dictlen = 1; dictlen < b; ++dictlen)\n {\n for (long mask = 1; mask < bb; ++mask)\n if ((_bitcounts[mask >> 9] + _bitcounts[mask & 0x1FF]) == dictlen)\n {\n for (i = 0; i < b; ++i)\n {\n long mask2 = mask | (1L << i);\n if (mask2 != mask)\n for (int x = 0; x < m; ++x)\n dp[mask2, (x * 10 + D[i]) % m] += dp[mask, x];\n }\n }\n }\n\n long ret = dp[bb - 1, 0];\n for (i = 0; i < 10; ++i)\n while (1 < stat[i])\n ret /= stat[i]--;\n Console.WriteLine( ret );\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "dp", "combinatorics", "bitmasks", "number theory"], "code_uid": "0a392b5b646c30d79608c296b4272df1", "src_uid": "5eb90c23ffa3794fdddc5670c0373829", "difficulty": 2000.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, K;\n\n public void Solve()\n {\n var sc = new Scanner();\n N = sc.NextInt();\n K = sc.NextInt();\n\n /*\n * N*N\u30b0\u30ea\u30c3\u30c9\n *\n * \u5404\u307e\u3059\u306b\u306f 1~K\u66f8\u304b\u308c\u3066\u308b\n *\n * \u5404\u884c\u3001\u5217\u306e\u6700\u5c0f\u5024\u306f1\n *\n * \u4f55\u901a\u308a\u304b?\n */\n\n\n var c = new BinomialCoefficient(500);\n\n // i\u884c\u76ee\u307e\u3067\u898b\u308b\n // j\u5217\u306b1\u304c\u3042\u308b\n ModInt[,] dp = new ModInt[N + 1, N + 1];\n dp[0, 0] = 1;\n for (int i = 0; i < N; i++)\n {\n for (int j = 0; j <= N; j++)\n {\n var cur = dp[i, j];\n for (int k = j; k <= N; k++)\n {\n if (j == 0 && k == 0) continue;\n\n ModInt mul;\n if (j == k)\n {\n mul = (ModInt.Pow(K, j) - ModInt.Pow(K - 1, j)) * ModInt.Pow(K-1, N - j);\n }\n else\n {\n mul = ModInt.Pow(K, j) * c[N - j, k - j] * ModInt.Pow(K - 1, N - k);\n }\n\n dp[i + 1, k] += cur * mul;\n }\n }\n }\n\n Console.WriteLine(dp[N, 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\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": "50487c25230c426ecd690a11ffce6d23", "src_uid": "f67173c973c6f83e88bc0ddb0b9bfa93", "difficulty": 2300.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "using 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 Scanner cin;\n\n long[] dp;\n\n void calc()\n {\n cin = new Scanner();\n int N = cin.nextInt();\n int MAX = 100005;\n long MAX2 = (long)1e18 + 10;\n\n dp = new long[MAX];\n dp[0] = f0.Length;\n for (int i = 1; i < MAX; i++)\n {\n if (dp[i - 1] > MAX2 / 2)\n {\n dp[i] = MAX2;\n }\n else\n {\n dp[i] = dp[i - 1] * 2 + s0.Length + s1.Length + s2.Length;\n }\n \n }\n\n for (int i = 0; i < N; i++)\n {\n a = cin.nextInt();\n b = cin.nextLong() - 1;\n\n while (a != -1) dfs();\n Console.Write(c);\n \n }\n Console.WriteLine();\n }\n\n int a;\n long b;\n char c = '.';\n\n string f0 = \"What are you doing at the end of the world? Are you busy? Will you save us?\";\n string s0 = \"What are you doing while sending \\\"\";\n string s1 = \"\\\"? Are you busy? Will you send \\\"\";\n string s2 = \"\\\"?\";\n\n void dfs()\n {\n if (b >= dp[a])\n {\n c = '.'; a = -1;\n return;\n }\n if(a == 0)\n {\n c = f0[(int)b]; a = -1;\n return;\n }\n if (b < s0.Length)\n {\n c = s0[(int)b]; a = -1;\n return;\n }\n b -= s0.Length;\n if (b < dp[a - 1])\n {\n a--;\n return;\n }\n b -= dp[a - 1];\n if (b < s1.Length)\n {\n c = s1[(int)b]; a = -1;\n return;\n }\n b -= s1.Length;\n if (b < dp[a - 1])\n {\n a--;\n return;\n }\n b -= dp[a - 1];\n c = s2[(int)b];\n a = -1;\n return;\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": ["dfs and similar", "binary search"], "code_uid": "2540455673b064405b4744070672d186", "src_uid": "da09a893a33f2bf8fd00e321e16ab149", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "\ufeffusing System;\n\nnamespace \u041e\u0440\u0435\u0445\u0443\u0441_\u0438_\u043b\u0438\u0444\u0442\n{\n class Program\n {\n static void Main(string[] args)\n {\n int T = 0;\n int n = Int32.Parse(Console.ReadLine());\n int[] A = Array.ConvertAll(Console.ReadLine().Split(), Convert.ToInt32);\n for (int i = 0; i < n; i++) T += A[i] * i * 4;\n Console.WriteLine(T);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["brute force", "implementation"], "code_uid": "af4f36605298bd35710e12e556436ee6", "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;\nusing System.Globalization;\n\nnamespace Contest\n{\n class Program\n {\n static void Main(string[] args)\n {\n var input = Console.ReadLine().Split(' ').Select(s => int.Parse(s));\n var ps = input.Take(4);\n var a = input.Skip(4).First();\n var b = input.Skip(5).First();\n int count =0;\n for (int i = a; i <= b; i++)\n {\n var t = i;\n foreach (var x in ps)\n {\n t %= x;\n }\n if (t == i) count++;\n }\n Console.WriteLine(count);\n }\n }\n}", "lang_cluster": "C#", "tags": ["implementation", "number theory"], "code_uid": "2a61e6311bf02d7df8ffbb81b68149a0", "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.Threading.Tasks;\n\nnamespace ConsoleApp2\n{\n class Program\n {\n static void Main(string[] args)\n {\n int a ,b, c, d,m,n;\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 m = (a * 2) + (b) + (c);\n n = (d * 2) + (b) + (c);\n if ((a == 0 && d == 0 && c != 0) || m!= n)\n {\n Console.WriteLine(0); \n }\n else\n {\n Console.WriteLine(1);\n }\n \n\n\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["greedy", "implementation"], "code_uid": "0e15108b25be8992b3620c077849df88", "src_uid": "b99578086043537297d374dc01eeb6f8", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeffusing System;\nusing System.IO;\nusing System.Text;\n\nnamespace T_Shirt_Hunt\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 int x = Next();\n int y = Next();\n\n for (int i = x; i >= y; i -= 50)\n {\n if (Check(p, (i/50)%475))\n {\n writer.WriteLine(\"0\");\n writer.Flush();\n return;\n }\n }\n\n for (int w = 1;; w++)\n {\n if (Check(p, ((x + w*100 - 50)/50)%475) || Check(p, ((x + w*100)/50)%475))\n {\n writer.WriteLine(w);\n break;\n }\n }\n\n writer.Flush();\n }\n\n private static bool Check(int p, int i)\n {\n for (int j = 0; j < 25; j++)\n {\n i = (i*96 + 42)%475;\n if (26 + i == p)\n {\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": "3fc0bf11c609439cad4076a20b4f8851", "src_uid": "c9c22e03c70a94a745b451fc79e112fd", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "MS C#", "source_code": "\ufeff/*\n\u0423 \u0432\u0430\u0441 \u0435\u0441\u0442\u044c \u0434\u0432\u0430 \u0434\u0440\u0443\u0433\u0430. \u0412\u044b \u0445\u043e\u0442\u0438\u0442\u0435 \u043f\u043e\u0434\u0430\u0440\u0438\u0442\u044c \u043a\u0430\u0436\u0434\u043e\u043c\u0443 \u0434\u0440\u0443\u0433\u0443 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0446\u0435\u043b\u044b\u0445 \u043f\u043e\u043b\u043e\u0436\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u0447\u0438\u0441\u0435\u043b. \u041f\u0435\u0440\u0432\u043e\u043c\u0443 \u0434\u0440\u0443\u0433\u0443 \u0432\u044b \u0445\u043e\u0442\u0438\u0442\u0435 \u043f\u043e\u0434\u0430\u0440\u0438\u0442\u044c cnt1 \u0447\u0438\u0441\u0435\u043b, \u0432\u0442\u043e\u0440\u043e\u043c\u0443 \u2014 cnt2 \u0447\u0438\u0441\u0435\u043b. \u0411\u043e\u043b\u0435\u0435 \u0442\u043e\u0433\u043e, \u0432\u044b \u0445\u043e\u0442\u0438\u0442\u0435, \u0447\u0442\u043e\u0431\u044b \u0432\u0441\u0435 \u043f\u043e\u0434\u0430\u0440\u0435\u043d\u043d\u044b\u0435 \u0447\u0438\u0441\u043b\u0430 \u0431\u044b\u043b\u0438 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u043c\u0438, \u0432 \u0447\u0430\u0441\u0442\u043d\u043e\u0441\u0442\u0438, \u043d\u0438 \u043e\u0434\u043d\u043e \u0447\u0438\u0441\u043b\u043e \u043d\u0435 \u0434\u043e\u043b\u0436\u043d\u043e \u0434\u043e\u0441\u0442\u0430\u0442\u044c\u0441\u044f \u043e\u0431\u043e\u0438\u043c \u0434\u0440\u0443\u0437\u044c\u044f\u043c.\n\n\u041a\u0440\u043e\u043c\u0435 \u044d\u0442\u043e\u0433\u043e, \u043f\u0435\u0440\u0432\u044b\u0439 \u0434\u0440\u0443\u0433 \u043d\u0435 \u043b\u044e\u0431\u0438\u0442 \u0447\u0438\u0441\u043b\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0434\u0435\u043b\u044f\u0442\u0441\u044f \u0431\u0435\u0437 \u043e\u0441\u0442\u0430\u0442\u043a\u0430 \u043d\u0430 \u043f\u0440\u043e\u0441\u0442\u043e\u0435 \u0447\u0438\u0441\u043b\u043e x. \u0412\u0442\u043e\u0440\u043e\u0439 \u0434\u0440\u0443\u0433 \u043d\u0435 \u043b\u044e\u0431\u0438\u0442 \u0447\u0438\u0441\u043b\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0434\u0435\u043b\u044f\u0442\u0441\u044f \u0431\u0435\u0437 \u043e\u0441\u0442\u0430\u0442\u043a\u0430 \u043d\u0430 \u043f\u0440\u043e\u0441\u0442\u043e\u0435 \u0447\u0438\u0441\u043b\u043e y. \u041a\u043e\u043d\u0435\u0447\u043d\u043e, \u0432\u044b \u043d\u0435 \u0431\u0443\u0434\u0435\u0442\u0435 \u0434\u0430\u0440\u0438\u0442\u044c \u0434\u0440\u0443\u0437\u044c\u044f\u043c \u0447\u0438\u0441\u043b\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u043d\u0438 \u043d\u0435 \u043b\u044e\u0431\u044f\u0442.\n\n\u0412\u0430\u0448\u0430 \u0437\u0430\u0434\u0430\u0447\u0430 \u2014 \u043d\u0430\u0439\u0442\u0438 \u0442\u0430\u043a\u043e\u0435 \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u0447\u0438\u0441\u043b\u043e v, \u0442\u0430\u043a\u043e\u0435 \u0447\u0442\u043e \u0438\u0437 \u043d\u0430\u0431\u043e\u0440\u0430 \u0447\u0438\u0441\u0435\u043b 1,\u20092,\u2009...,\u2009v \u043c\u043e\u0436\u043d\u043e \u0441\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u043f\u043e\u0434\u0430\u0440\u043a\u0438 \u0434\u0440\u0443\u0437\u044c\u044f\u043c. \u0415\u0441\u0442\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0447\u0438\u0441\u043b\u0430 \u043c\u043e\u0436\u043d\u043e \u043d\u0435 \u0434\u0430\u0440\u0438\u0442\u044c \u043d\u0438\u043a\u043e\u043c\u0443 \u0438\u0437 \u043d\u0438\u0445.\n\n\u041f\u043e\u043b\u043e\u0436\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0435 \u0446\u0435\u043b\u043e\u0435 \u0447\u0438\u0441\u043b\u043e, \u0431\u043e\u043b\u044c\u0448\u0435\u0435 \u0435\u0434\u0438\u043d\u0438\u0446\u044b, \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043f\u0440\u043e\u0441\u0442\u044b\u043c, \u0435\u0441\u043b\u0438 \u043e\u043d\u043e \u043d\u0435 \u0434\u0435\u043b\u0438\u0442\u0441\u044f \u043d\u0430\u0446\u0435\u043b\u043e \u043d\u0438 \u043d\u0430 \u043e\u0434\u043d\u043e \u043f\u043e\u043b\u043e\u0436\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0435 \u0446\u0435\u043b\u043e\u0435 \u0447\u0438\u0441\u043b\u043e \u043a\u0440\u043e\u043c\u0435 \u0435\u0434\u0438\u043d\u0438\u0446\u044b \u0438 \u0441\u0435\u0431\u044f \u0441\u0430\u043c\u043e\u0433\u043e.\n\u0412\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435\n\n\u0412 \u043f\u0435\u0440\u0432\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0435 \u0437\u0430\u043f\u0438\u0441\u0430\u043d\u043e \u0447\u0435\u0442\u044b\u0440\u0435 \u0446\u0435\u043b\u044b\u0445 \u043f\u043e\u043b\u043e\u0436\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u0447\u0438\u0441\u043b\u0430 cnt1, cnt2, x, y (1\u2009\u2264\u2009cnt1,\u2009cnt2\u2009<\u2009109; cnt1\u2009+\u2009cnt2\u2009\u2264\u2009109; 2\u2009\u2264\u2009x\u2009<\u2009y\u2009\u2264\u20093\u00b7104) \u2014 \u043e\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0435 \u0432 \u0443\u0441\u043b\u043e\u0432\u0438\u0438 \u0447\u0438\u0441\u043b\u0430. \u0413\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u0443\u0435\u0442\u0441\u044f, \u0447\u0442\u043e \u0447\u0438\u0441\u043b\u0430 x, y \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043f\u0440\u043e\u0441\u0442\u044b\u043c\u0438 \u0447\u0438\u0441\u043b\u0430\u043c\u0438.\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 \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0435 \u0446\u0435\u043b\u043e\u0435 \u0447\u0438\u0441\u043b\u043e \u2014 \u043e\u0442\u0432\u0435\u0442 \u043d\u0430 \u0437\u0430\u0434\u0430\u0447\u0443.*/\nusing System;\n\nnamespace _483B\n{\n class Program\n {\n private static long HigherDividend(long x, long diveder)\n {\n if (x%diveder == 0)\n return x;\n if (x < diveder)\n return 0;\n var left = x - diveder;\n var right = x;\n var middle = (left + right)/2;\n while (middle%diveder != 0)\n {\n if (middle/diveder < x/diveder)\n left = middle;\n else\n right = middle;\n middle = (left + right)/2;\n }\n return middle;\n }\n\n static void Main(string[] args)\n {\n var input = Console.ReadLine().Split(' ');\n var cnt1 = long.Parse(input[0]);\n var cnt2 = long.Parse(input[1]);\n var x = long.Parse(input[2]);\n var y = long.Parse(input[3]);\n\n long count = 0;\n long barrier = cnt1 + cnt2;\n while (count != cnt1 + cnt2)\n {\n long bad = HigherDividend(barrier, x*y)/(x*y);\n long xCountCommon = HigherDividend(barrier, y) / y - bad;\n long yCountCommon = HigherDividend(barrier, x) / x - bad;\n long xCount = Math.Min(xCountCommon, cnt1);\n long yCount = Math.Min(yCountCommon, cnt2);\n if (xCount < xCountCommon)\n bad += xCountCommon - xCount;\n if (yCount < yCountCommon)\n bad += yCountCommon - yCount;\n long good = barrier - bad - xCount - yCount;\n count = good + xCount + yCount;\n barrier += cnt1 + cnt2 - count;\n }\n\n Console.Write(barrier);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "binary search"], "code_uid": "067740cfe061d9d39417bb65e47be995", "src_uid": "ff3c39b759a049580a6e96c66c904fdc", "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;\nusing System.Collections;\nusing System;\n\nnamespace tc_cf_c_sharp\n{\n class MyIO\n {\n TextReader reader;\n TextWriter writer=Console.Out;\n string[] tokens;\n int pointer;\n public MyIO(TextReader rd)\n {\n reader = rd;\n }\n public string NextLine()\n {\n try\n {\n return reader.ReadLine();\n }\n catch (IOException)\n {\n return null;\n }\n }\n public string NextString()\n {\n try\n {\n while (tokens == null || pointer >= tokens.Length)\n {\n tokens = NextLine().Split(new char[]{' '},System.StringSplitOptions.RemoveEmptyEntries);\n pointer = 0;\n }\n return tokens[pointer++];\n }\n catch (IOException)\n {\n return null;\n }\n }\n public int NextInt()\n {\n return int.Parse(NextString());\n }\n public long NextLong()\n {\n return long.Parse(NextString());\n }\n public double NextDouble()\n {\n return double.Parse(NextString());\n }\n public void Write(string format, params object[] args)\n {\n writer.Write(format, args);\n }\n public void WriteLine(string format, params object[] args)\n {\n writer.WriteLine(format, args);\n }\n }\n class Program\n {\n static long[, , ,] dp;\n const long mod = 100000000;\n static void Main(string[] args)\n {\n MyIO myio = new MyIO(Console.In);\n //MyIO myio = new MyIO(new StreamReader(File.OpenRead(@\"D:\\project\\tc cf c sharp\\tc cf c sharp\\in.txt\")));\n int n1 = myio.NextInt(), n2 = myio.NextInt(), k1 = myio.NextInt(), k2 = myio.NextInt();\n dp=new long [105,105,12,12];\n for (int i = 0; i < 105; i++) for (int j = 0; j < 105; j++) for (int k = 0; k < 12; k++) for (int l = 0; l < 12; l++)\n dp[i, j, k, l] = 0;\n dp[0,0,0,0] = 1;\n for (int i = 0; i <= n1; i++) for (int j = 0; j <= n2; j++) for (int k = 0; k <= k1; k++) for (int l = 0; l <= k2; l++)\n {\n dp[i, j, k, l] %= mod;\n dp[i + 1, j, k + 1, 0] += dp[i, j, k, l];\n dp[i, j + 1, 0, l + 1] += dp[i, j, k, l];\n }\n long res = 0;\n for (int k = 0; k <= k1; k++) for (int l = 0; l <= k2; l++) res += dp[n1, n2, k, l];\n res %= mod;\n myio.WriteLine(\"{0}\",res);\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["dp"], "code_uid": "42e0c26dc2ea26875bb6255c025478d3", "src_uid": "63aabef26fe008e4c6fc9336eb038289", "difficulty": 1700.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 static int countPowers(int p, int n) {\n int result = 0;\n int curr = 1;\n while (n / p >= curr) {\n ++result;\n curr *= p;\n if (n/curr >= curr) Used.Add(curr);\n }\n return result;\n }\n\n static HashSet Used = new HashSet();\n static Dictionary D = new Dictionary();\n\n static int bitmask(ref List p) {\n int result = 0;\n for (int i = 0; i < p.Count; ++i)\n result = 2 * result + p[i];\n return result;\n }\n\n static int fun(ref List p) {\n if (D.ContainsKey(bitmask(ref p))) {\n return D[bitmask(ref p)];\n }\n HashSet s = new HashSet();\n for (int i = 0; i < p.Count; ++i) if (p[i] == 1) {\n List n = new List(p);\n for (int j = 0; j < n.Count; ++j) if ((j + 1) % (i + 1) == 0) n[j] = 0;\n s.Add(fun(ref n));\n }\n int result = 0;\n while (s.Contains(result)) ++result;\n D[bitmask(ref p)] = result;\n return result;\n }\n\n static int getSprague(int len) {\n int[] ans = new int[] {0, 1,\n2,\n1,\n4,\n3,\n2,\n1,\n5,\n6,\n2,\n1,\n8,\n7,\n5,\n9,\n8,\n7,\n3,\n4,\n7,\n4,\n2,\n1,\n10,\n9,\n3,\n6,\n11,\n12};\n\n // SG for group of powers\n /*\n D.Clear();\n D[0] = 0;\n\n List p = new List();\n for (int i = 0; i < len; ++i) p.Add(1);\n //Console.WriteLine(len + \" \" + fun(ref p));\n return fun(ref p);\n */\n return ans[len];\n }\n\n public static void Main(string[] args) {\n StdIn std = new StdIn();\n\n int n = std.nextInt();\n int ans = 0;\n\n int totcnt = n;\n\n for (int i = 2; i * i <= n; ++i) if (!Used.Contains(i)) {\n int cnt = countPowers(i, n);\n totcnt -= cnt;\n ans ^= getSprague(cnt);\n }\n\n if (totcnt % 2 > 0) ans ^= 1;\n\n if (ans > 0) Console.WriteLine(\"Vasya\");\n else Console.WriteLine(\"Petya\");\n\n Console.ReadLine();\n }\n }\n}\n", "lang_cluster": "C#", "tags": ["dp", "games"], "code_uid": "952b8c5f9061d6d56b992822e897e000", "src_uid": "0e22093668319217b7946e62afe32195", "difficulty": 2300.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 long N = re.i();\n int K = re.i();\n long count = 0;\n for(int i=0;i<=K;i++){\n if(i == 0){\n count++;\n }\n else if(i == 2){\n count += N*(N-1)/2;\n }\n else if(i == 3){\n count += N*(N-1)*(N-2)/3;\n }\n else if(i == 4){\n count += N*(N-1)*(N-2)*(N-3)/24*9;\n }\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 '9');\r\n res = c - '0';\r\n while (true)\r\n {\r\n c = reader.Read();\r\n if (c < '0' || c > '9')\r\n return res;\r\n res *= 10;\r\n res += c - '0';\r\n }\r\n }\r\n }\r\n}", "lang_cluster": "C#", "tags": ["math", "dp", "combinatorics", "number theory"], "code_uid": "3137360508c00af97629995d91d7d3b3", "src_uid": "09be46206a151c237dc9912df7e0f057", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "Mono C#", "source_code": "using System;\npublic class Wool\n{\n public static void Main(string [] args)\n {\n int n, m,i;\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 (i = 0; i < m; ++i)\n {\n res = res * 2;\n res = res % d;\n }\n long ans = 1;\n for (i = 1; i <= n; ++i)\n ans = (ans * (res - i)) % d;\n Console.WriteLine(ans);\n Console.ReadLine();\n }\n}\n", "lang_cluster": "C#", "tags": ["math", "constructive algorithms", "combinatorics"], "code_uid": "d679e6daa378d3019769778503bf69ac", "src_uid": "fef4d9c94a93fcf6d536f33503b1d4b8", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": ".NET Core C#", "source_code": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing CompLib.Util;\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\n int[] g = new int[N * M];\n g[0] = sc.NextInt();\n X = sc.NextInt();\n Y = sc.NextInt();\n Z = sc.NextInt();\n for (int i = 1; i < N * M; i++)\n {\n g[i] = (int) (((long) g[i - 1] * X + Y) % Z);\n }\n\n var mq = new MinQueue[N];\n for (int i = 0; i < N; i++)\n {\n mq[i] = new MinQueue();\n }\n\n for (int j = 0; j < B - 1; j++)\n {\n for (int i = 0; i < N; i++)\n {\n mq[i].Enqueue(g[i * M + j]);\n }\n }\n\n long ans = 0;\n for (int j = B - 1; j < M; j++)\n {\n for (int i = 0; i < N; i++)\n {\n mq[i].Enqueue(g[i * M + j]);\n }\n\n var mq2 = new MinQueue();\n for (int i = 0; i < A - 1; i++)\n {\n mq2.Enqueue(mq[i].GetMin());\n }\n\n for (int i = A - 1; i < N; i++)\n {\n mq2.Enqueue(mq[i].GetMin());\n ans += mq2.GetMin();\n mq2.Dequeue();\n }\n\n for (int i = 0; i < N; i++)\n {\n mq[i].Dequeue();\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\nclass MinStack\n{\n private Stack<(int val, int min)> S;\n\n public MinStack()\n {\n S = new Stack<(int val, int min)>();\n }\n\n public int GetMin()\n {\n if (S.Count == 0) return int.MaxValue;\n return S.Peek().min;\n }\n\n public void Push(int val)\n {\n S.Push((val, Math.Min(val, GetMin())));\n }\n\n public int Pop()\n {\n return S.Pop().val;\n }\n\n public int Count\n {\n get { return S.Count; }\n }\n}\n\nclass MinQueue\n{\n public MinStack L, R;\n\n public MinQueue()\n {\n L = new MinStack();\n R = new MinStack();\n }\n\n public void Enqueue(int val)\n {\n R.Push(val);\n }\n\n public void Dequeue()\n {\n if (L.Count == 0)\n {\n while (R.Count > 0)\n {\n L.Push(R.Pop());\n }\n }\n\n L.Pop();\n }\n\n public int GetMin()\n {\n return Math.Min(L.GetMin(), R.GetMin());\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": ["two pointers", "data structures"], "code_uid": "49c92e375f1fc4e74ca935de6301b529", "src_uid": "4618fbffb2b9d321a6d22c11590a4773", "difficulty": 2100.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 lab11\n{\n using li = System.Int64;\n using mt = System.Int64;\n class Program\n {\n const int N = 100 + 5;\n public static li INF = 1000000000000000;\n static li[,] mt = new li[N, N];\n\n static int n;\n static int[] a = new int[N];\n static li T;\n static mt[,] d = new mt[N,N];\n static mt[,] dt = new mt[N,N];\n\n static void Main(string[] args)\n {\n int[] input = Console.ReadLine().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(p => int.Parse(p)).ToArray();\n n = input[0];\n T = input[1];\n input = Console.ReadLine().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(p => int.Parse(p)).ToArray();\n for (int i = 0; i < n; ++i)\n a[i] = input[i];\n for (int s = 0; s < n; ++s)\n {\n for (int i = 0; i < n; ++i)\n {\n if (a[i] < a[s])\n {\n d[s, i] = -INF;\n }\n else\n {\n d[s, i] = 1;\n for (int j = 0; j < i; ++j)\n if (a[j] <= a[i])\n d[s, i] = Math.Max(d[s, i], d[s, j] + 1);\n }\n }\n }\n binpow(d, T, dt);\n li res = 0;\n for (int i = 0; i < n; ++i)\n for (int j = 0; j < n; ++j)\n res = Math.Max(res, dt[i, j]);\n Console.WriteLine(res);\n }\n\n static void one(mt[,] a) \n {\n for (int i = 0; i < n; ++i)\n for (int j = 0; j < n; ++j)\n a[i,j] = 0;\n }\n\n static void copy(mt[,] a, mt[,] b) \n {\n for (int i = 0; i < n; ++i)\n for (int j = 0; j < n; ++j)\n b[i, j] = a[i, j];\n }\n\n static void mul(mt[,] a, mt[,] b, mt[,] c) \n {\n for (int i = 0; i < n; ++i)\n for (int j = 0; j < n; ++j) {\n c[i,j] = -INF;\n for (int k = 0; k < n; ++k)\n c[i,j] = Math.Max(c[i,j], a[i,k] + b[k,j]);\n }\n }\n\n static mt[,] t = new mt[N, N];\n static mt[,] r = new mt[N, N];\n\n static void binpow(mt[,] a, li b, mt[,] c) \n {\n copy(a, t);\n one(c);\n while (b != 0) {\n if ((b & 1) != 0) {\n mul(c, t, r);\n copy(r, c);\n }\n mul(t, t, r);\n copy(r, t);\n b >>= 1;\n }\n } \n }\n}\n", "lang_cluster": "C#", "tags": ["dp", "constructive algorithms"], "code_uid": "3a48e01c9f34062626d87bd7447a97e7", "src_uid": "26cf484fa4cb3dc2ab09adce7a3fc9b2", "difficulty": 1900.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;\nclass Program\n{\n class Point\n {\n public double x, y;\n public Point(double x, double y)\n {\n this.x = x;\n this.y = y;\n }\n }\n class Line\n {\n public double a, b, c;\n public Line(Point p1, Point p2)\n {\n a = p2.y - p1.y;\n b = p1.x - p2.x;\n c = a * p1.x + b * p1.y;\n }\n public Line()\n {\n\n }\n \n public Line prep( Point p)\n {\n Line res=new Line();\n res.a = -b;\n res.b = a;\n res.c = res.a * p.x + res.b * p.y;\n return res;\n \n }\n public Point Intersect(Line l)\n {\n Point res = new Point(0,0);\n double d = a * l.b - b * l.a;\n res.x = (l.b * c - b * l.c) / d;\n res.y = (a * l.c - l.a * c) / d;\n return res;\n }\n\n }\n double eps = 1e-9;\n void solve()\n {\n Point p = new Point(nextInt(), nextInt());\n Point v=new Point(nextInt(),nextInt());\n Point[]w=new Point[2];\n \n for (int i = 0; i < 2; i++)\n w[i] = new Point(nextInt(), nextInt());\n Point[] mir = new Point[2];\n for (int i = 0; i < 2; i++)\n mir[i] = new Point(nextInt(), nextInt());\n \n bool ok = false;\n if (good(p, v, w[0], w[1]) && (good(p,v,mir[0],mir[1]) || sign(cross(mir[0],mir[1],p))==0))\n {\n ok = true;\n }\n else if (sign(cross(mir[0], mir[1], p)) * sign(cross(mir[0], mir[1], v)) == 1)\n {\n Line lm = new Line(mir[0], mir[1]);\n Line pr = lm.prep(p);\n Point inter = lm.Intersect(pr);\n Point other = new Point(inter.x + (inter.x - p.x), inter.y + (inter.y - p.y));\n {\n Line l = new Line(other, v);\n Point x = l.Intersect(lm);\n if (good(x, p, w[0], w[1]) && good(x, v, w[0], w[1]) && on(mir[0], mir[1], x))\n ok = true;\n }\n\n }\n if (ok)\n println(\"YES\");\n else\n println(\"NO\");\n\n }\n\n private bool good(Point p1, Point p2, Point p3, Point p4)\n {\n double d1 = cross(p1, p2, p3);\n double d2 = cross(p1, p2, p4);\n double d3 = cross(p3, p4,p1);\n double d4 = cross(p3, p4, p2);\n int x1 = sign(d1);\n int x2 = sign(d2);\n int x3 = sign(d3);\n int x4 = sign(d4);\n if (x1 * x2 < 0 && x3 * x4 < 0)\n return false;\n if (x1 == 0)\n {\n if (on(p1, p2, p3))\n return false;\n }\n if (x2 == 0)\n {\n if (on(p1, p2, p4))\n return false;\n }\n if (x3 == 0)\n {\n if (on(p3, p4, p1))\n return false;\n }\n if (x4 == 0)\n {\n if (on(p3, p4, p2))\n return false;\n }\n \n return true;\n\n }\n\n private bool on(Point p1, Point p2, Point p3)\n {\n return on(p1.x, p2.x, p3.x) && on(p1.y, p2.y, p3.y);\n }\n\n private bool on(double x, double y, double z)\n {\n return z >= Math.Min(x, y) - eps && z <= Math.Max(x, y) + eps;\n }\n\n private int sign(double d1)\n {\n return Math.Abs(d1) < eps ? 0 : Math.Sign(d1);\n }\n\n private double cross(Point p1, Point p2, Point p3)\n {\n return (p2.x - p1.x) * (p3.y - p1.y) - (p3.x - p1.x) * (p2.y - p1.y);\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": ["geometry", "implementation"], "code_uid": "a0accae711d9d6fd482929f6ca2222c5", "src_uid": "7539a41268b68238d644795bccaa0c0f", "difficulty": 2400.0, "exec_outcome": "PASSED"}