Problem p02702 (python)

Fixed submission:
S = list(map(int, list(input())))[::-1]
N = len(S)
CNT = [0]*2019
CNT[0] = 1
num = 0
d = 0
for i in range(N):
    num += S[i]*pow(10, d, 2019)
    num %= 2019
    CNT[num] += 1
    d += 1
ans = 0 
for cnt in CNT:
    ans += (cnt*(cnt - 1)) // 2
print(ans)

Buggy submission (verdict: Runtime Error):
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1001001001;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
    string S;
    cin >> S;
    ll N = S.size();
    vector<int> CNT(2019, 0);
    CNT[0] = 1;
    ll base = pow(10, N);
    ll num = 0;

    rep(i, N) {
        base /= 10;
        num = num * 10 + (S[i] - '0');
        ++CNT[(num*base)%2019];
    }
    int ans = 0;
    for(auto cnt : CNT) {
        ans += (cnt * (cnt - 1)) / 2;
    }
    cout << ans << endl;
    return 0;
}

Buggy submission (verdict: Runtime Error):
cnt = 0
def s(start, end):
    global cnt
    if(start==len(S)-1):
        return 
    numS = int(S[start:end+1])
    if(numS%2019==0 and not(numS == 0)):
        print(numS)
        cnt += 1
    if(end==len(S)-1):
        end = start+1
        s(start+1, end)
        return
    
    s(start, end+1)

S = input()
s(0, 1)
print(cnt)

Buggy submission (verdict: Runtime Error):
cnt = 0
def s(start, end):
    global cnt
    if(start==len(S)-1):
        return 
    numS = int(S[start:end+1])
    if(numS%2019==0 and numS!=0):
        cnt += 1
    if(end==len(S)-1):
        end = start+1
        s(start+1, end)
        return
    s(start, end+1)

S = str(input())
s(0, 0)
print cnt

Buggy submission (verdict: Runtime Error):
cnt = 0
def s(start, end):
    global cnt
    if(start==len(S)-1):
        return 
    numS = int(S[start:end+1])
    if(numS%2019==0 and numS!=0):
        cnt += 1
    if(end==len(S)-1):
        end = start+1
        s(start+1, end)
        return
    s(start, end+1)

S = str(input())
s(0, 0)
print cnt

Buggy submission (verdict: Runtime Error):
cnt = 0
def s(start, end):
    global cnt
    if(start==len(S)-1):
        return 
        
    numS = int(S[start:end+1])
    if(numS%2019==0 and numS!=0):
        cnt += 1
    if(end==len(S)-1):
        end = start+1
        s(start+1, end)
        return
    s(start, end+1)

S = input()
s(0, 0)
print(cnt)

Buggy submission (verdict: Runtime Error):
cnt = 0
def s(start, end):
    global cnt
    if(start==len(S)-1):
        return 
    try:
        numS = int(S[start:end+1])
    except:
        numS = 0
    if(numS%2019==0 and numS!=0):
        print(numS)
        cnt += 1
    if(end==len(S)-1):
        end = start+2
        s(start+1, end)
        return
    s(start, end+1)

S = input()
s(0, 1)
print(cnt)

Buggy submission (verdict: Runtime Error):
cnt = 0
def s(start, end):
    global cnt
    if(start==len(S)-1):
        return 
    numS = int(S[start:end+1])
    if(numS%2019==0 and numS!=0):
        cnt += 1
    if(end==len(S)-1):
        end = start+2
        s(start+1, end)
        return
    s(start, end+1)

S = input()
s(0, 0)
print(cnt)

Buggy submission (verdict: Runtime Error):
cnt = 0
def s(start, end):
    global cnt
    if(start==len(S)-1):
        return 
    numS = int(S[start:end+1])
    if(numS%2019==0 and numS!=0):
        cnt += 1
    if(end==len(S)-1):
        end = start+2
        s(start+1, end)
        return
    s(start, end+1)
S = input()
s(0, 1)
print(cnt)

Buggy submission (verdict: Runtime Error):
cnt = 0
def s(start, end):
    global cnt
    if(start==len(S)-1):
        return 
    numS = int(S[start:end+1])
    if(numS%2019==0 and numS!=0):
        cnt += 1
    if(end==len(S)-1):
        end = start+2
        s(start+1, end)
        return
    s(start, end+1)

if __name__ == '__main__':
    S = input()
    s(0, 1)
    print(cnt)

Buggy submission (verdict: Runtime Error):
cnt = 0
def s(start, end):
    global cnt
    if(start==len(S)-1):
        return 
    numS = int(S[start:end+1])
    if(numS%2019==0 and numS!=0):
        print(numS)
        cnt += 1
    if(end==len(S)-1):
        end = start+2
        s(start+1, end)
        return
    s(start, end+1)

if __name__ == '__main__':
    S = input()
    s(0, 1)
    print(cnt)

Buggy submission (verdict: Runtime Error):
cnt = 0
def s(start, end):
    global cnt
    if(start==len(S)-1):
        return 
    try:
        numS = int(S[start:end+1])
    except:
        numS = 0
    if(numS%2019==0):
        cnt += 1
    if(end==len(S)-1):
        end = start+2
        s(start+1, end)
        return
    s(start, end+1)

if __name__ == '__main__':
    S = input()
    s(0, 1)
    print(cnt)

Buggy submission (verdict: Runtime Error):
cnt = 0
def s(start, end):
    global cnt
    if(start==len(S)-1):
        return 
    numS = int(S[start:end+1])
    if(numS%2019==0):
        cnt += 1
    if(end==len(S)-1):
        end = start+2
        s(start+1, end)
        return
    s(start, end+1)

if __name__ == '__main__':
    S = input()
    s(0, 1)
    print(cnt)

Buggy submission (verdict: Runtime Error):
cnt = 0
def s(start, end):
    global cnt
    if(start==len(S)-1):
        return cnt
    numS = int(S[start:end+1])
    if(numS%2019==0):
        cnt += 1
    if(end==len(S)-1):
        end = start+2
        s(start+1, end)
        return
    s(start, end+1)

if __name__ == '__main__':
    S = input()
    s(0, 1)
    print(cnt)

Buggy submission (verdict: Runtime Error):
cnt = 0
def s(start, end):
    print(start, end)
    global cnt
    if(start==len(S)-1):
        return cnt
    numS = int(S[start:end+1])
    if(numS%2019==0):
        cnt += 1
    if(end==len(S)-1):
        end = start+2
        s(start+1, end)
        return
    s(start, end+1)

if __name__ == '__main__':
    S = input()
    s(0, 1)
    print(cnt)

Buggy submission (verdict: Runtime Error):
cnt = 0
def s(start, end):
    global cnt
    if(start==len(S)-1):
        return cnt
    numS = int(S[start:end])
    if(numS%2019==0):
        cnt += 1
    if(end==len(S)-1):
        end = start+2
        s(start+1, end)
        return
    s(start, end+1)

if __name__ == '__main__':
    S = input()
    s(0, 1)
    print(cnt)

Buggy submission (verdict: Runtime Error):
cnt = 0
def s(start, end):
    global cnt
    if(start==len(S)-1):
        return cnt
    numS = int(S[start:end])
    if(numS%2019==0):
        cnt += 1
    if(end==len(S)-1):
        end = start+2
        s(start+1, end)
        return
    s(start, end+1)



if __name__ == '__main__':
    S = input()
    s(0, 1)
    print(cnt)

Buggy submission (verdict: Runtime Error):

cnt = 0

def s(start, end):
    global cnt
    if(start==len(S)-1):
        return cnt
    numS = int(S[start:end])
    if(numS%2019==0):
        cnt += 1
    if(end==len(S)-1):
        end = start+2
        s(start+1, end)
        return
    s(start, end+1)



if __name__ == '__main__':
    S = input()
    s(0, 1)
    print(cnt)