# BETWEEN - Editorial

**URL:** <https://discuss.codechef.com/t/between-editorial/126059>\
**Category:** editorial\
**Tags:** editorial, start261\
**Created:** [October 21, 2026, 4:30pm UTC](https://discuss.codechef.com/t/between-editorial/126059 "2026-10-21T16:30:53Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![iceknight1093](https://www.codechef.com/sites/all/themes/abessive/images/user_default_thumb.jpg) [@iceknight1093](https://discuss.codechef.com/u/iceknight1093)\
**Post date:** [October 21, 2026, 4:30pm UTC](https://discuss.codechef.com/t/between-editorial/126059/1 "2026-10-21T16:30:53Z")

</div>

# PROBLEM LINK:

[Practice](https://www.codechef.com/problems/BETWEEN)  
[Contest: Division 1](https://www.codechef.com/START261A/problems/BETWEEN)  
[Contest: Division 2](https://www.codechef.com/START261B/problems/BETWEEN)  
[Contest: Division 3](https://www.codechef.com/START261C/problems/BETWEEN)  
[Contest: Division 4](https://www.codechef.com/START261D/problems/BETWEEN)

_ **Author:** _ [am\_aadvik](https://www.codechef.com/users/am_aadvik)  
_ **Tester:** _ [iceknight1093](https://www.codechef.com/users/iceknight1093)  
_ **Editorialist:** _ [iceknight1093](https://www.codechef.com/users/iceknight1093)

# DIFFICULTY:

TBD

# PREREQUISITES:

None

# PROBLEM:

Your team is ranked X and your rival’s is Y.  
How many teams are strictly between you?

# EXPLANATION:

If X \lt Y, there are Y-X-1 teams between your ranks.

If X \gt Y, there are X-Y-1 teams between you.

This can be combined to write |X-Y|-1.

# TIME COMPLEXITY:

\mathcal{O}(1) per testcase.

# CODE:

> **Editorialist's code (PyPy3)**
>
> ```python
> x, y = map(int, input().split())
> print(abs(x-y)-1)
> 
> ```
