ENG  RUSTimus Online Judge
Online Judge
Online contests
About Online Judge
Frequently asked questions
Site news
Problem set
Submit solution
Judge status
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests

How to write C# solutions

Programs written in C# language are compiled on the server with .NET 8.0 (.NET SDK 8.0.100 x64, C# 12). The compiler is invoked with the following arguments:

dotnet.exe csc.dll -optimize+ -define:ONLINE_JUDGE %1

The default stack size is set to 1 MB.

Examples of solving problems

This is a sample solution for the A + B problem in the C# language:

var tokens = Console.ReadLine().Split();
var a = int.Parse(tokens[0]);
var b = int.Parse(tokens[1]);
Console.WriteLine(a + b);

Here is an example of a simple solution for the Reverse root problem in the C# language. It demonstrates some language features but it’s not the most efficient one. With character by character input you can get much less working time and memory usage.

System.Globalization.CultureInfo.DefaultThreadCurrentCulture =

var result = Console.In.ReadToEnd()
   .Where(s => s != "")

foreach (var d in result)


The standard input/output methods like Console.ReadLine, String.Split and Console.WriteLine are not always sufficient. In some problems it’s necessary to manually implement fast input reading or output formatting.

In some problems numbers are not necessarily separated with a single space. Instead of


use this code

Console.ReadLine().Split().Where(s => s != "")

Do not forget that the program can have any default culture. This is important when you need to read or write floating-point numbers: decimal separator can be configured in the system equal to either “.” or “,”. Currently the separator is set to “.” on the server, but it may be changed in the future. In order not to face culture problems pass invariant culture to all parse/formatting operation or set default culture for whole program:

System.Globalization.CultureInfo.DefaultThreadCurrentCulture =

Version history

Name From To Language Runtime
C# .NET 2.0 December 31, 2006 February 8, 2009 C# 2.0 .NET Framework 2.0
C# .NET 3.5 February 8, 2009 August 4, 2010 C# 3.0 .NET Framework 3.5
C# .NET 4.0 August 4, 2010 September 21, 2015 C# 4.0 .NET Framework 4.0
VB .NET 4.0 February 18, 2013 September 1, 2017 VB 10.0 .NET Framework 4.0
C# .NET 4.5 September 21, 2015 September 1, 2017 C# 5.0 .NET Framework 4.5
C# .NET 4.7 September 1, 2017 September 1, 2019 C# 7.1 .NET Framework 4.7
C# .NET 4.7.2 September 1, 2019 September 1, 2020 C# 7.1 .NET Framework 4.7.2
C# .NET Core 3.1 September 1, 2020 January, 22 2024 C# 8.0 .NET Core 3.1.4
C# .NET 8 January, 22 2024 C# 12.0 .NET 8.0.0