Language: C++

use std::ops::{Index, IndexMut};
use std::cmp::{Ordering};
use std::collections::BinaryHeap;
use std::cmp::{min, max};
// use std::clone::Clone;

fn getline() -> String{
    let mut res = String::new();
    std::io::stdin().read_line(&mut res).ok();
    res
}

macro_rules! split {
    ($x: expr) => {
        ($x).trim().split(' ').collect()
    }
}

macro_rules! parse {
    ($x: expr) => {
        ($x).parse().unwrap()
    }
}

macro_rules! debug {
    ($x: expr) => {
        println!("{}: {}", stringify!($x), $x)
    }
}

fn printvec<T>(v: &Vec<T>) where T: std::fmt::Display {
    for (i,e) in v.into_iter().enumerate() {
        if i != 0 {
            print!(" ");
        }
        print!("{}", e);
    }
    println!();
}

fn main() {
    
    let s = getline();
    let iv: Vec<_> = split!(s);
    let n: i64 = parse!(iv[0]);
    let s = getline();
    let iv: Vec<_> = split!(s);
    let a: Vec<i64> = iv.into_iter().map(|x| parse!(x)).collect();
    
    let mut f = true;
    for e in &a {
        if *e >= n {
            f = false;
            break;
        }
    }
    if f {
        println!("{}",0);
        return;
    }
    let mut l: i64 = 0;
    let mut r: i64 = 1e16 as i64;
    
    let check = |x: i64| {
        let mut res = false;
        for i in 0..n*2 {
            let m = x+i;
            let sum: i64 = a.clone().into_iter().map(|x| max((x-(n-1-m)+n)/(n+1),0)).sum();
            res = res || sum <= m; 
        }
        res
    };
    
    while r-l > 1 {
        let m = (l+r)/2;
        let sum: i64 = a.clone().into_iter().map(|x| max((x-(n-1-m)+n)/(n+1),0)).sum();
        // debug!(l); debug!(r); debug!(m); debug!(sum);
        if !check(m) {
            l = m;
        } else {
            r = m;
        }
    }
    // for m in 0..20 {
    //     let sum: i64 = a.clone().into_iter().map(|x| max((x-(n-1-m)+n)/(n+1),0)).sum();
    //     debug!(m); debug!(sum <= m);
    // }
    let mut ans = -100;
    for i in 0..n*2 {
        let m = r+i;
        let sum: i64 = a.clone().into_iter().map(|x| max((x-(n-1-m)+n)/(n+1),0)).sum();
        if sum <= m {
            ans = r+i;
            break;
        }
    }
    println!("{}",ans);

}



Compiler output:
a.cc:66:18: error: too many decimal points in number
   66 |         for i in 0..n*2 {
      |                  ^~~~
a.cc:89:14: error: too many decimal points in number
   89 |     for i in 0..n*2 {
      |              ^~~~
a.cc:1:1: error: 'use' does not name a type
    1 | use std::ops::{Index, IndexMut};
      | ^~~
a.cc:2:1: error: 'use' does not name a type
    2 | use std::cmp::{Ordering};
      | ^~~
a.cc:3:1: error: 'use' does not name a type
    3 | use std::collections::BinaryHeap;
      | ^~~
a.cc:4:1: error: 'use' does not name a type
    4 | use std::cmp::{min, max};
      | ^~~
a.cc:7:1: error: 'fn' does not name a type
    7 | fn getline() -> String{
      | ^~
a.cc:13:1: error: 'macro_rules' does not name a type
   13 | macro_rules! split {
      | ^~~~~~~~~~~
a.cc:19:1: error: 'macro_rules' does not name a type
   19 | macro_rules! parse {
      | ^~~~~~~~~~~
a.cc:25:1: error: 'macro_rules' does not name a type
   25 | macro_rules! debug {
      | ^~~~~~~~~~~
a.cc:31:1: error: 'fn' does not name a type
   31 | fn printvec<T>(v: &Vec<T>) where T: std::fmt::Display {
      | ^~
a.cc:41:1: error: 'fn' does not name a type
   41 | fn main() {
      | ^~