Language: Java

use proconio::*;
use std::collections::HashMap;

fn main() {
    input! {
        n:i64,
        mut x:i64,
        m:i64,
    }

    let mut amari = HashMap::new();
    // 0番目はあまりが0(Key: あまり, Value 順番)
    amari.insert(-1i64, 0i64);
    let mut res = 0i64;
    let mut ruiseki = vec![0i64; 100005];

    let mut ikkai = 0i64;
    let mut start = -1i64;
    let mut junban = 0i64;
    let mut syuuki = -1i64;
    loop {
        junban += 1;
        ruiseki[junban as usize] = ruiseki[(junban - 1) as usize] + x;

        if amari.contains_key(&x) {
            syuuki = junban - amari.get(&x).unwrap();
            ikkai = ruiseki[junban as usize] - ruiseki[(junban - syuuki) as usize];
            start = *amari.get(&x).unwrap();
            break;
        } else {
            amari.insert(x, junban);
            x = (x * x) % m;

            if junban == n {
                println!("{}", ruiseki[n as usize]);
                return;
            }
        }
    }

    res = ruiseki[(start - 1) as usize];
    // m/周期と余りで良いので
    res += (n - start + 1) / syuuki * ikkai;

    for _ in 0..((n - start + 1) % syuuki) {
        res += x;
        x = (x * x) % m;
    }

    /*println!(
        "ruiseki: {:?}, syuuki : {}, ikkai : {}, nokori : {}",
        ruiseki,
        syuuki,
        ikkai,
        n % syuuki
    );
    */
    println!("{}", res);
}


Compiler output:
Main.java:1: error: class, interface, enum, or record expected
use proconio::*;
^
Main.java:2: error: class, interface, enum, or record expected
use std::collections::HashMap;
^
Main.java:5: error: not a statement
    input! {
    ^
Main.java:6: error: not a statement
        n:i64,
          ^
Main.java:7: error: not a statement
        mut x:i64,
              ^
Main.java:8: error: not a statement
        m:i64,
          ^
Main.java:13: error: not a statement
    amari.insert(-1i64, 0i64);
                   ^
Main.java:13: error: not a statement
    amari.insert(-1i64, 0i64);
                         ^
Main.java:14: error: not a statement
    let mut res = 0i64;
                   ^
Main.java:15: error: not a statement
    let mut ruiseki = vec![0i64; 100005];
                            ^
Main.java:15: error: not a statement
    let mut ruiseki = vec![0i64; 100005];
                                 ^
Main.java:17: error: not a statement
    let mut ikkai = 0i64;
                     ^
Main.java:18: error: not a statement
    let mut start = -1i64;
                      ^
Main.java:19: error: not a statement
    let mut junban = 0i64;
                      ^
Main.java:20: error: not a statement
    let mut syuuki = -1i64;
                       ^
Main.java:21: error: not a statement
    loop {
    ^
Main.java:23: error: not a statement
        ruiseki[junban as usize] = ruiseki[(junban - 1) as usize] + x;
               ^
Main.java:23: error: not a statement
        ruiseki[junban as usize] = ruiseki[(junban - 1) as usize] + x;
                                          ^
Main.java:23: error: not a statement
        ruiseki[junban as usize] = ruiseki[(junban - 1) as usize] + x;
                                                                    ^
Main.java:27: error: not a statement
            ikkai = ruiseki[junban as usize] - ruiseki[(junban - syuuki) as usize];
                                                      ^
Main.java:35: error: not a statement
                println!("{}", ruiseki[n as usize]);
                ^
Main.java:35: error: not a statement
                println!("{}", ruiseki[n as usize]);
                                      ^
Main.java:45: error: as of release 9, '_' is a keyword, and may not be used as an identifier
    for _ in 0..((n - start + 1) % syuuki) {
        ^
Main.java:58: error: not a statement
    println!("{}", res);
    ^
Main.java:58: error: not a statement
    println!("{}", res);
                   ^
Main.java:4: error: unnamed classes are a preview feature and are disabled by default.
fn main() {
^
  (use --enable-preview to enable unnamed classes)
Main.java:5: error: ';' expected
    input! {
         ^
Main.java:6: error: ';' expected
        n:i64,
             ^
Main.java:7: error: ';' expected
        mut x:i64,
             ^
Main.java:7: error: ';' expected
        mut x:i64,
                 ^
Main.java:8: error: ';' expected
        m:i64,
             ^
Main.java:11: error: ';' expected
    let mut amari = HashMap::new();
           ^
Main.java:11: error: ';' expected
    let mut amari = HashMap::new();
                                ^
Main.java:13: error: ';' expected
    amari.insert(-1i64, 0i64);
                      ^
Main.java:13: error: ';' expected
    amari.insert(-1i64, 0i64);
                            ^
Main.java:14: error: ';' expected
    let mut res = 0i64;
           ^
Main.java:15: error: ';' expected
    let mut ruiseki = vec![0i64; 100005];
           ^
Main.java:15: error: ';' expected
    let mut ruiseki = vec![0i64; 100005];
                         ^
Main.java:15: error: ';' expected
    let mut ruiseki = vec![0i64; 100005];
                                       ^
Main.java:17: error: ';' expected
    let mut ikkai = 0i64;
           ^
Main.java:18: error: ';' expected
    let mut start = -1i64;
           ^
Main.java:19: error: ';' expected
    let mut junban = 0i64;
           ^
Main.java:20: error: ';' expected
    let mut syuuki = -1i64;
           ^
Main.java:21: error: ';' expected
    loop {
        ^
Main.java:23: error: ']' expected
        ruiseki[junban as usize] = ruiseki[(junban - 1) as usize] + x;
                      ^
Main.java:23: error: ';' expected
        ruiseki[junban as usize] = ruiseki[(junban - 1) as usize] + x;
                               ^
Main.java:23: error: ']' expected
        ruiseki[junban as usize] = ruiseki[(junban - 1) as usize] + x;
                                                       ^
Main.java:23: error: ';' expected
        ruiseki[junban as usize] = ruiseki[(junban - 1) as usize] + x;
                                                                ^
Main.java:25: error: '(' expected
        if amari.contains_key(&x) {
          ^
Main.java:25: error: illegal start of expression
        if amari.contains_key(&x) {
                              ^
Main.java:25: error: ')' expected
        if amari.contains_key(&x) {
                                 ^
Main.java:26: error: illegal start of expression
            syuuki = junban - amari.get(&x).unwrap();
                                        ^
Main.java:27: error: ']' expected
            ikkai = ruiseki[junban as usize] - ruiseki[(junban - syuuki) as usize];
                                  ^
Main.java:27: error: ';' expected
            ikkai = ruiseki[junban as usize] - ruiseki[(junban - syuuki) as usize];
                                           ^
Main.java:27: error: ']' expected
            ikkai = ruiseki[junban as usize] - ruiseki[(junban - syuuki) as usize];
                                                                        ^
Main.java:27: error: ';' expected
            ikkai = ruiseki[junban as usize] - ruiseki[(junban - syuuki) as usize];
                                                                                 ^
Main.java:28: error: illegal start of expression
            start = *amari.get(&x).unwrap();
                    ^
Main.java:28: error: illegal start of expression
            start = *amari.get(&x).unwrap();
                               ^
Main.java:34: error: '(' expected
            if junban == n {
              ^
Main.java:34: error: ')' expected
            if junban == n {
                          ^
Main.java:35: error: ';' expected
                println!("{}", ruiseki[n as usize]);
                       ^
Main.java:35: error: ']' expected
                println!("{}", ruiseki[n as usize]);
                                        ^
Main.java:35: error: ';' expected
                println!("{}", ruiseki[n as usize]);
                                                 ^
Main.java:41: error: ']' expected
    res = ruiseki[(start - 1) as usize];
                             ^
Main.java:41: error: ';' expected
    res = ruiseki[(start - 1) as usize];
                                      ^
Main.java:45: error: '(' expected
    for _ in 0..((n - start + 1) % syuuki) {
       ^
Main.java:45: error: ';' expected
    for _ in 0..((n - start + 1) % syuuki) {
            ^
Main.java:45: error: <identifier> expected
    for _ in 0..((n - start + 1) % syuuki) {
                ^
Main.java:45: error: ';' expected
    for _ in 0..((n - start + 1) % syuuki) {
                                          ^
Main.java:45: error: illegal start of expression
    for _ in 0..((n - start + 1) % syuuki) {
                                           ^
Main.java:58: error: ';' expected
    println!("{}", res);
           ^
Main.java:58: error: ';' expected
    println!("{}", res);
                      ^
72 errors