Language: Java

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <limits.h>

#define REP(i,n) for(i=0;i<n;i++)

#define MAX 1000000
#define MOD 1000000007

long long fac[MAX], finv[MAX], inv[MAX];

//prototype declaration
int i_in();
long long ll_in();
double d_in();
char c_in();
void s_in(char *s);
void i_out(int i);
void ll_out(long long i);
void d_out(double i);
void c_out(char c);
void s_out(char *s);
int gcd(int a, int b);
int lcm(int a, int b);
long long ll_gcd(long long a, long long b);
long long ll_lcm(long long a, long long b);
void sort_asc(int *a);
void sort_desc(int *a);
int asc(const void *a, const void *b);
int desc(const void *a, const void *b);
void ll_sort_asc(long long *a);
void ll_sort_desc(long long *a);
int ll_asc(const void *a, const void *b);
int ll_desc(const void *a, const void *b);
double to_deg(double rad);
double distance(int xi, int yi, int xj, int yj);
void initComb();
long long comb(int n, int k);

//main function
int main() {
    char s[200000];
    int i, j, n;
    long long count = 0;
    s_in(s);
    for (i = strlen(s) - 1;i >= 3; i--) {
        n = 0;
        n += ((s[i] - '0') * pow(10, 0));
        n += ((s[i - 1] - '0') * pow(10, 1));
        n += ((s[i - 2] - '0') * pow(10, 2));
        for(j = i - 3; j >= 0; j--) {
            n += ((s[j] - '0') * pow(10, i - j));
            // i_out(n);
            if (n % 2019 == 0) count++;
        }
    }

    ll_out(count);
    return 0;
}

//body function
int i_in() {
    int i;
    scanf("%d", &i);
    return i;
}

long long ll_in() {
    long long i;
    scanf("%lld", &i);
    return i;
}

double d_in() {
    double i;
    scanf("%lf", &i);
    return i;
}

char c_in() {
    char c;
    scanf("%c", &c);
    return c;
}

void s_in(char *s) {
    scanf("%s", s);
}

void i_out(int i) {
    printf("%d\n", i);
}

void ll_out(long long i) {
    printf("%lld\n", i);
}

void d_out(double i) {
    printf("%lf\n", i);
}

void c_out(char c) {
    printf("%c\n", c);
}

void s_out(char *s) {
    printf("%s\n", s);
}

/*
    int型の最大公約数
*/

int gcd(int a, int b) {
    int r;

    if (a < b) {
        r = a;
        a = b;
        b = r;
    }

    r = a % b;
    while (r != 0) {
        a = b;
        b = r;
        r = a % b;
    }

    return b;
}

/*
    int型の最小公倍数
*/

int lcm(int a, int b) {
    int r = ll_gcd(a, b);
    a /= r;
    return a * b;
}

/*
    long long型の最大公約数
*/

long long ll_gcd(long long a, long long b) {
    long long r;

    if (a < b) {
        r = a;
        a = b;
        b = r;
    }

    r = a % b;
    while (r != 0) {
        a = b;
        b = r;
        r = a % b;
    }

    return b;
}

/*
    long long型の最小公倍数
*/

long long ll_lcm(long long a, long long b) {
    long long r = ll_gcd(a, b);
    a /= r;
    return a * b;
}

/*
    int型の昇順ソート
*/

void sort_asc(int *a) {
    qsort(a, sizeof(a)/sizeof(int), sizeof(int), asc);
}

/*
    int型の降順ソート
*/

void sort_desc(int *a) {
    qsort(a, sizeof(a)/sizeof(int), sizeof(int), desc);
}

/*
    int型の昇順用比較関数
*/

int asc(const void *a, const void *b) {
    return *(int *)a - *(int *)b;
}

/*
    int型の降順用比較関数
*/

int desc(const void *a, const void *b) {
    return *(int *)b - *(int *)a;
}

/*
    long long型の昇順ソート
*/

void ll_sort_asc(long long *a) {
    qsort(a, sizeof(a)/sizeof(long long), sizeof(long long), ll_asc);
}

/*
    long long型の降順ソート
*/

void ll_sort_desc(long long *a) {
    qsort(a, sizeof(a)/sizeof(long long), sizeof(long long), ll_desc);
}

/*
    long long型の昇順用比較関数
*/

int ll_asc(const void *a, const void *b) {
    long long *A = (long long *)a;
    long long *B = (long long *)b;
    if (*A > *B) return 1;
    else if (*A < *B) return -1;
    else return 0;
}

/*
    long long型の降順用比較関数
*/

int ll_desc(const void *a, const void *b) {
    long long *A = (long long *)a;
    long long *B = (long long *)b;
    if (*A < *B) return 1;
    else if (*A > *B) return -1;
    else return 0;
}

/*
    弧度法を度数法に
*/

double to_deg(double rad) {
    return rad * 180.0 / (atan(1.0) * 4.0);
}

/*
    二点間の距離
*/

double distance(int xi, int yi, int xj, int yj) {
    return hypot(xj - xi, yj - yi);
}

/*
    組み合わせ用配列の初期化
*/

void initComb() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

/*
    nCkの組み合わせ計算
*/

long long comb(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


Compiler output:
Main.java:1: error: illegal character: '#'
#include <stdio.h>
^
Main.java:1: error: class, interface, enum, or record expected
#include <stdio.h>
         ^
Main.java:2: error: illegal character: '#'
#include <stdlib.h>
^
Main.java:3: error: illegal character: '#'
#include <string.h>
^
Main.java:4: error: illegal character: '#'
#include <math.h>
^
Main.java:5: error: illegal character: '#'
#include <limits.h>
^
Main.java:7: error: illegal character: '#'
#define REP(i,n) for(i=0;i<n;i++)
^
Main.java:7: error: class, interface, enum, or record expected
#define REP(i,n) for(i=0;i<n;i++)
                         ^
Main.java:7: error: class, interface, enum, or record expected
#define REP(i,n) for(i=0;i<n;i++)
                             ^
Main.java:9: error: illegal character: '#'
#define MAX 1000000
^
Main.java:10: error: illegal character: '#'
#define MOD 1000000007
^
Main.java:15: error: unnamed classes are a preview feature and are disabled by default.
int i_in();
^
  (use --enable-preview to enable unnamed classes)
Main.java:16: error: class, interface, enum, or record expected
long long ll_in();
^
Main.java:19: error: <identifier> expected
void s_in(char *s);
              ^
Main.java:21: error: <identifier> expected
void ll_out(long long i);
                ^
Main.java:24: error: <identifier> expected
void s_out(char *s);
               ^
Main.java:27: error: class, interface, enum, or record expected
long long ll_gcd(long long a, long long b);
^
Main.java:28: error: class, interface, enum, or record expected
long long ll_lcm(long long a, long long b);
^
Main.java:29: error: <identifier> expected
void sort_asc(int *a);
                 ^
Main.java:30: error: <identifier> expected
void sort_desc(int *a);
                  ^
Main.java:31: error: illegal start of type
int asc(const void *a, const void *b);
        ^
Main.java:31: error: class, interface, enum, or record expected
int asc(const void *a, const void *b);
              ^
Main.java:32: error: illegal start of type
int desc(const void *a, const void *b);
         ^
Main.java:32: error: class, interface, enum, or record expected
int desc(const void *a, const void *b);
               ^
Main.java:33: error: <identifier> expected
void ll_sort_asc(long long *a);
                     ^
Main.java:34: error: <identifier> expected
void ll_sort_desc(long long *a);
                      ^
Main.java:35: error: illegal start of type
int ll_asc(const void *a, const void *b);
           ^
Main.java:35: error: class, interface, enum, or record expected
int ll_asc(const void *a, const void *b);
                 ^
Main.java:36: error: illegal start of type
int ll_desc(const void *a, const void *b);
            ^
Main.java:36: error: class, interface, enum, or record expected
int ll_desc(const void *a, const void *b);
                  ^
Main.java:40: error: class, interface, enum, or record expected
long long comb(int n, int k);
^
Main.java:46: error: not a statement
    long long count = 0;
    ^
Main.java:44: error: ']' expected
    char s[200000];
           ^
Main.java:46: error: ';' expected
    long long count = 0;
        ^
Main.java:67: error: illegal start of expression
    scanf("%d", &i);
                ^
Main.java:71: error: class, interface, enum, or record expected
long long ll_in() {
^
Main.java:73: error: class, interface, enum, or record expected
    scanf("%lld", &i);
    ^
Main.java:74: error: class, interface, enum, or record expected
    return i;
    ^
Main.java:75: error: class, interface, enum, or record expected
}
^
Main.java:79: error: class, interface, enum, or record expected
    scanf("%lf", &i);
    ^
Main.java:80: error: class, interface, enum, or record expected
    return i;
    ^
Main.java:81: error: class, interface, enum, or record expected
}
^
Main.java:85: error: class, interface, enum, or record expected
    scanf("%c", &c);
    ^
Main.java:86: error: class, interface, enum, or record expected
    return c;
    ^
Main.java:87: error: class, interface, enum, or record expected
}
^
Main.java:91: error: class, interface, enum, or record expected
}
^
Main.java:95: error: class, interface, enum, or record expected
}
^
Main.java:99: error: class, interface, enum, or record expected
}
^
Main.java:103: error: class, interface, enum, or record expected
}
^
Main.java:107: error: class, interface, enum, or record expected
}
^
Main.java:111: error: class, interface, enum, or record expected
}
^
Main.java:120: error: class, interface, enum, or record expected
    if (a < b) {
    ^
Main.java:122: error: class, interface, enum, or record expected
        a = b;
        ^
Main.java:123: error: class, interface, enum, or record expected
        b = r;
        ^
Main.java:124: error: class, interface, enum, or record expected
    }
    ^
Main.java:127: error: class, interface, enum, or record expected
    while (r != 0) {
    ^
Main.java:129: error: class, interface, enum, or record expected
        b = r;
        ^
Main.java:130: error: class, interface, enum, or record expected
        r = a % b;
        ^
Main.java:131: error: class, interface, enum, or record expected
    }
    ^
Main.java:134: error: class, interface, enum, or record expected
}
^
Main.java:142: error: class, interface, enum, or record expected
    a /= r;
    ^
Main.java:143: error: class, interface, enum, or record expected
    return a * b;
    ^
Main.java:144: error: class, interface, enum, or record expected
}
^
Main.java:153: error: class, interface, enum, or record expected
    if (a < b) {
    ^
Main.java:155: error: class, interface, enum, or record expected
        a = b;
        ^
Main.java:156: error: class, interface, enum, or record expected
        b = r;
        ^
Main.java:157: error: class, interface, enum, or record expected
    }
    ^
Main.java:160: error: class, interface, enum, or record expected
    while (r != 0) {
    ^
Main.java:162: error: class, interface, enum, or record expected
        b = r;
        ^
Main.java:163: error: class, interface, enum, or record expected
        r = a % b;
        ^
Main.java:164: error: class, interface, enum, or record expected
    }
    ^
Main.java:167: error: class, interface, enum, or record expected
}
^
Main.java:175: error: class, interface, enum, or record expected
    a /= r;
    ^
Main.java:176: error: class, interface, enum, or record expected
    return a * b;
    ^
Main.java:177: error: class, interface, enum, or record expected
}
^
Main.java:185: error: class, interface, enum, or record expected
}
^
Main.java:193: error: class, interface, enum, or record expected
}
^
Main.java:201: error: class, interface, enum, or record expected
}
^
Main.java:209: error: class, interface, enum, or record expected
}
^
Main.java:217: error: class, interface, enum, or record expected
}
^
Main.java:225: error: class, interface, enum, or record expected
}
^
Main.java:233: error: class, interface, enum, or record expected
    long long *B = (long long *)b;
    ^
Main.java:234: error: class, interface, enum, or record expected
    if (*A > *B) return 1;
    ^
Main.java:235: error: class, interface, enum, or record expected
    else if (*A < *B) return -1;
    ^
Main.java:236: error: class, interface, enum, or record expected
    else return 0;
    ^
Main.java:237: error: class, interface, enum, or record expected
}
^
Main.java:245: error: class, interface, enum, or record expected
    long long *B = (long long *)b;
    ^
Main.java:246: error: class, interface, enum, or record expected
    if (*A < *B) return 1;
    ^
Main.java:247: error: class, interface, enum, or record expected
    else if (*A > *B) return -1;
    ^
Main.java:248: error: class, interface, enum, or record expected
    else return 0;
    ^
Main.java:249: error: class, interface, enum, or record expected
}
^
Main.java:257: error: class, interface, enum, or record expected
}
^
Main.java:265: error: class, interface, enum, or record expected
}
^
Main.java:273: error: class, interface, enum, or record expected
    finv[0] = finv[1] = 1;
    ^
Main.java:274: error: class, interface, enum, or record expected
    inv[1] = 1;
    ^
Main.java:275: error: class, interface, enum, or record expected
    for (int i = 2; i < MAX; i++){
    ^
Main.java:275: error: class, interface, enum, or record expected
    for (int i = 2; i < MAX; i++){
                    ^
Main.java:275: error: class, interface, enum, or record expected
    for (int i = 2; i < MAX; i++){
                             ^
Main.java:277: error: class, interface, enum, or record expected
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        ^
Main.java:278: error: class, interface, enum, or record expected
        finv[i] = finv[i - 1] * inv[i] % MOD;
        ^
100 errors
only showing the first 100 errors, of 104 total; use -Xmaxerrs if you would like to see more