# ProconIO.jl -- Easy IO handler for competitive programming in Julia

**URL:** <https://discourse.julialang.org/t/proconio-jl-easy-io-handler-for-competitive-programming-in-julia/85391>\
**Category:** Package Announcements\
**Tags:** competition, io\
**Created:** [August 6, 2022, 11:28am UTC](https://discourse.julialang.org/t/proconio-jl-easy-io-handler-for-competitive-programming-in-julia/85391 "2022-08-06T11:28:49Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![lucifer1004](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lucifer1004/32/22311_2.png) [@lucifer1004](https://discourse.julialang.org/u/lucifer1004)\
**Post date:** [August 6, 2022, 11:28am UTC](https://discourse.julialang.org/t/proconio-jl-easy-io-handler-for-competitive-programming-in-julia/85391/1 "2022-08-06T11:28:49Z")

</div>

Inspired by [proconio-rs](https://github.com/statiolake/proconio-rs), I wrote [ProconIO.jl](https://github.com/lucifer1004/ProconIO.jl) to handle inputs for competitive programming contests.

The usage is similar to `proconio-rs`. You need to specify the variable name and its structure.

```julia
@input a = Int

```

Multiple variables need to be nested in a block.

```julia
@input begin
    a = Char
    b = Float32
    c = (Int, Char)
    d = String
    e = Bool
end

```

Arrays need to be specified in the form of `[type; shape]`.

```julia
@input begin
    a = [Int; 3]
    b = [Float32; (2, 3)]
end

```

Complex structures can also be handled.

```julia
@input a = [(Int, [Int; (2, 2)], Char); (2, 2)]

```

In CP, the size of arrays is usually specified by the input itself. This can be handled by using variables already read in.

Note that `ProconIO.jl` follows Julia’s column-major convention, instead of the row-major which is commonly used in CP. So you may need to swap the row and column indices when reading the array.

```julia
@input begin
    n = Int
    m = Int
    v = [Int; (m, n)]
end

```

If you prefer a row-major flavor, you can use a vector of vectors instead.

```julia
@input begin
    n = Int
    m = Int
    v = [[Int; m]; n]
end

```

Sometimes the input is a vector of variable-length vectors. This can be handled by leaving out the shape and reading it from the input instead. The following code reads in a vector of `n` variable-length vectors.

```julia
@input begin
    n = Int
    v = [[Int;]; n]
end

```

---

<div class="post-metadata">

**Author:** ![sylvaticus](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sylvaticus/32/203883_2.png) [@sylvaticus](https://discourse.julialang.org/u/sylvaticus)\
**Post date:** [August 6, 2022, 11:40am UTC](https://discourse.julialang.org/t/proconio-jl-easy-io-handler-for-competitive-programming-in-julia/85391/2 "2022-08-06T11:40:33Z")

</div>

Just as feedback, most likely it’s me not being used to the field, but you should consider that an announcement here reaches a diverce audience, so it could be more effective if some background is given… 🙂

---

<div class="post-metadata">

**Author:** ![lucifer1004](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lucifer1004/32/22311_2.png) [@lucifer1004](https://discourse.julialang.org/u/lucifer1004)\
**Post date:** [August 8, 2022, 1:24am UTC](https://discourse.julialang.org/t/proconio-jl-easy-io-handler-for-competitive-programming-in-julia/85391/3 "2022-08-08T01:24:45Z")

</div>

Typical scenarios can be platforms like [Codeforces](https://codeforces.com) or [AtCoder](https://atcoder.jp). (Although only the latter currently supports Julia.)
