{"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.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": "MS C#", "source_code": "using 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 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;\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": "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": "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": "\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": "MS C#", "source_code": "using 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": "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": "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;\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": "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": "using System;\nusing System.Collections.Generic;\nusing System.Text;\nusing System.IO;\nnamespace С_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.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": "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": "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.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;\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": "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": "MS C#", "source_code": "using 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": "using 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": "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": "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": "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": "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": "Mono C#", "source_code": "using 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": "MS C#", "source_code": "using 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.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": "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": "MS C#", "source_code": "#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": "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 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": "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;\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": "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": "C# 10", "source_code": "using 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// (づ°ω°)づミe★゜・。。・゜゜・。。・゜☆゜・。。・゜゜・。。・゜\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": "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": "MS C#", "source_code": "/*\nУ вас есть два друга. Вы хотите подарить каждому другу некоторое количество целых положительных чисел. Первому другу вы хотите подарить cnt1 чисел, второму — cnt2 чисел. Более того, вы хотите, чтобы все подаренные числа были различными, в частности, ни одно число не должно достаться обоим друзьям.\n\nКроме этого, первый друг не любит числа, которые делятся без остатка на простое число x. Второй друг не любит числа, которые делятся без остатка на простое число y. Конечно, вы не будете дарить друзьям числа, которые они не любят.\n\nВаша задача — найти такое минимальное число v, такое что из набора чисел 1, 2, ..., v можно составить подарки друзьям. Естественно, некоторые числа можно не дарить никому из них.\n\nПоложительное целое число, большее единицы, называется простым, если оно не делится нацело ни на одно положительное целое число кроме единицы и себя самого.\nВходные данные\n\nВ первой строке записано четыре целых положительных числа cnt1, cnt2, x, y (1 ≤ cnt1, cnt2 < 109; cnt1 + cnt2 ≤ 109; 2 ≤ x < y ≤ 3·104) — описанные в условии числа. Гарантируется, что числа x, y являются простыми числами.\nВыходные данные\n\nВыведите единственное целое число — ответ на задачу.*/\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": "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"}