Harryxun/GPT-100-sft-dataset huggingface dataset:
Problem p02909 (python)

Fixed submission:
#import math
#import bisect
#import numpy as np
#import itertools
#import copy
import sys

input = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    s = input().rstrip('\n')
    w = {'Sunny': 'Cloudy', 'Cloudy': 'Rainy', 'Rainy': 'Sunny'}
    print(w[s])

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
#import math
#import bisect
#import numpy as np
#import itertools
#import copy
import sys

input = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    s = input()
    w = {'Sunny': 'Cloudy', 'Cloudy': 'Rainy', 'Rainy': 'Sunny'}
    print(w[s])

if __name__ == '__main__':
    main()
Problem p03039 (python)

Fixed submission:
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def comb_mod(n, r):
    res = 1
    r = min(n - r, r)

    for i in range(r):
        res *= (n - i)
        res %= MOD
        res *= pow((r - i), MOD - 2, MOD)

    return res


def main():
    n, m, k = list(map(int, readline().split()))

    com = comb_mod(n * m - 2, k - 2)
    x = 0
    y = 0

    for i in range(n):
        right = n - 1 - i
        x += (right + 1) * right // 2
        x %= MOD

    for i in range(m):
        down = m - 1 - i
        y += (down + 1) * down // 2
        y %= MOD

    ans = 0
    ans += m ** 2 * x * com
    ans += n ** 2 * y * com
    ans %= MOD

    print(ans)


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def comb_mod(n, r):
    res = 1
    r = min(n - r, r)

    for i in range(r):
        res *= (n - i)
        res %= MOD
        res *= pow((r - i), -1, MOD)

    return res


def main():
    n, m, k = list(map(int, readline().split()))

    com = comb_mod(n * m - 2, k - 2)
    x = 0
    y = 0

    for i in range(n):
        right = n - 1 - i
        x += (right + 1) * right // 2
        x %= MOD

    for i in range(m):
        down = m - 1 - i
        y += (down + 1) * down // 2
        y %= MOD

    ans = 0
    ans += m ** 2 * x * com
    ans += n ** 2 * y * com
    ans %= MOD

    print(ans)


if __name__ == '__main__':
    main()
Problem p03074 (python)

Fixed submission:
import bisect
# from collections import Counter, defaultdict, deque, namedtuple
# import copy
# from heapq import heappush, heappop, heapify
# from fractions import gcd
import itertools
# from operator import attrgetter, itemgetter
# import math

import sys

# import numpy as np

ipti = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)

def main():
    n, k = list(map(int,ipti().split()))
    s = input()

    lg = [0] * (n+3)

    s_first = s[0]
    s_last =s[-1]

    idx = 0

    if s_first == "0":
        lg[0] = 0
        idx = 1

    s_groupby = itertools.groupby(s)

    for _, group in s_groupby:
        lg[idx] = len(list(group))
        idx += 1

    if s_last == "0":
        idx += 1

    rn = 2*k + 1

    if rn >= idx:
        print(n)
        sys.exit()

    temp = sum(lg[0:rn])
    ans = temp

    for i in range(2, idx-rn+1, 2):
        temp -= (lg[i-2] + lg[i-1])
        temp += (lg[i-2+rn] + lg[i-1+rn])
        ans = max(ans, temp)

    print(ans)

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import bisect
# from collections import Counter, defaultdict, deque, namedtuple
# import copy
# from heapq import heappush, heappop, heapify
# from fractions import gcd
import itertools
# from operator import attrgetter, itemgetter
# import math

import sys

# import numpy as np

ipti = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)

def main():
    n, k = list(map(int,ipti().split()))
    s = input()

    lg = [0] * (n+3)

    s_first = s[0]
    s_last =s[-1]

    idx = 0
    if s_first == "0":
        lg[0] = 0
        idx = 1

    s_groupby = itertools.groupby(s)

    for _, group in s_groupby:
        lg[idx] = len(list(group))
        idx += 1

    if s_last == "0":
        idx += 1

    rn = 2*k + 1
    if rn >= idx:
        print(n)
        sys.exit()

    temp = sum(lg[0:rn])
    ans = temp

    for i in range(2, idx, 2):
        temp -= (lg[i-2] + lg[i-1])
        temp += (lg[i-2+rn] + lg[i-1+rn])
        ans = max(ans, temp)

    print(ans)

if __name__ == '__main__':
    main()
Problem p03372 (python)

Fixed submission:
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    n, c = list(map(int, readline().split()))

    x = [0] * (n + 1)
    v = [0] * (n + 1)

    for i in range(1, n + 1):
        x[i], v[i] = map(int, readline().split())

    right_cum = [0] * (n + 1)
    left_cum = [0] * (n + 1)

    for i in range(1, n + 1):
        right_cum[i] = right_cum[i - 1] + v[i]
        left_cum[i] = left_cum[i - 1] + v[n - i + 1]

    right_nutritive = [0] * (n + 1)
    left_nutritive = [0] * (n + 1)
    right_max_cum = [0] * (n + 1)
    left_max_cum = [0] * (n + 1)

    for i in range(1, n + 1):
        right_nutritive[i] = right_cum[i] - x[i]
        left_nutritive[i] = left_cum[i] - (c - x[n - i + 1])
        right_max_cum[i] = max(right_max_cum[i - 1], right_nutritive[i])
        left_max_cum[i] = max(left_max_cum[i - 1], left_nutritive[i])

    r_temp = max(right_nutritive)
    l_temp = max(left_nutritive)
    ans = max(r_temp, l_temp)

    for i in range(1, n + 1):
        rl = right_nutritive[i] - x[i] + left_max_cum[n - i]
        lr = left_nutritive[i] - (c - x[n - i + 1]) + right_max_cum[n - i]
        ans = max(ans, rl, lr)

    print(ans)


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    n, c = list(map(int, readline().split()))

    x = [0] * (n + 1)
    v = [0] * (n + 1)

    for i in range(1, n + 1):
        x[i], v[i] = map(int, readline().split())

    right_cum = [0] * (n + 1)
    left_cum = [0] * (n + 1)

    for i in range(1, n + 1):
        right_cum[i] = right_cum[i - 1] + v[i]
        left_cum[i] = left_cum[i - 1] + v[n - i + 1]

    right_nutritive = [0] * (n + 1)
    left_nutritive = [0] * (n + 1)
    right_max_cum = [0] * (n + 1)
    left_max_cum = [0] * (n + 1)

    for i in range(1, n + 1):
        right_nutritive[i] = right_cum[i] - x[i]
        left_nutritive[i] = left_cum[i] - (c - x[n - i + 1])
        right_max_cum[i] = max(right_max_cum[i - 1], right_nutritive[i])
        left_max_cum[i] = max(left_max_cum[i - 1], left_nutritive[i])

    ans = max(*right_nutritive, *left_nutritive)

    for i in range(1, n + 1):
        rl = right_nutritive[i] - x[i] + left_max_cum[n - i]
        lr = left_nutritive[i] - (c - x[n - i + 1]) + right_max_cum[n - i]
        ans = max(ans, rl, lr)

    print(ans)


if __name__ == '__main__':
    main()
Problem p03388 (python)

Fixed submission:
import sys

import bisect

# from collections import Counter, deque, defaultdict

# import copy
# from heapq import heappush, heappop, heapify
# from fractions import gcd
# import itertools
# from operator import attrgetter, itemgetter
import math

# import numpy as np

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    q = int(input())

    for i in range(q):
        a, b = list(map(int, readline().split()))

        if a > b:
            a, b = b, a

        if a == b or a + 1 == b:
            print(2 * a - 2)
        else:
            ab = a * b
            ok = 0
            ng = int(ab ** 0.5) + 1000000
            while abs(ng - ok) > 1:
                mid = (ok + ng) // 2
                if mid ** 2 < ab:
                    ok = mid
                else:
                    ng = mid
            c = ok

            if c * (c + 1) < ab:
                print(2 * c - 1)
            else:
                print(2 * c - 2)


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import sys

# import bisect

# from collections import Counter, deque, defaultdict

# import copy
# from heapq import heappush, heappop, heapify
# from fractions import gcd
# import itertools
# from operator import attrgetter, itemgetter
import math

# import numpy as np

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    q = int(input())

    for i in range(q):
        a, b = list(map(int, readline().split()))
        if a > b:
            a, b = b, a

        if a == b or a + 1 == b:
            print(2 * a - 2)
        else:
            ab = a * b
            sqab = math.floor(math.sqrt(ab))

        if sqab * (sqab + 1) >= ab:
            print(2 * sqab - 2)
        else:
            print(2 * sqab - 1)


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import sys

import bisect

from collections import Counter, deque, defaultdict

# import copy
# from heapq import heappush, heappop, heapify
# from fractions import gcd
# import itertools
# from operator import attrgetter, itemgetter
import math

# import numpy as np

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    q = int(input())

    for i in range(q):
        a, b = list(map(int, readline().split()))
        if a > b:
            a, b = b, a

        if a == b or a + 1 == b:
            print(2 * a - 2)
        else:
            ab = a * b
            sqab = math.floor(math.sqrt(ab))

        if sqab * (sqab + 1) >= ab:
            print(2 * sqab - 2)
        else:
            print(2 * sqab - 1)


if __name__ == '__main__':
    main()
Problem p03546 (python)

Fixed submission:
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    from collections import Counter
    import networkx as nx
    h, w = map(int, readline().split())
    G = nx.DiGraph()

    for i in range(10):
        costs = list(map(int, readline().split()))
        for j, cost in enumerate(costs):
            if i != j:
                G.add_edge(i, j, weight=cost)

    d = nx.algorithms.floyd_warshall(G)

    counter = Counter()
    for _ in range(h):
        nums = list(map(int, readline().split()))
        counter.update(nums)
    ans = 0
    for num in range(10):
        ans += counter[num] * d[num][1]

    print(ans)


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    from collections import Counter
    import networkx as nx
    h, w = map(int, readline().split())
    G = nx.DiGraph()

    for i in range(10):
        costs = list(map(int, readline().split()))
        for j, cost in enumerate(costs):
            if i != j:
                G.add_edge(i, j, weight=cost)

    d = nx.algorithms.floyd_warshall(G)

    counter = Counter()
    for _ in range(h):
        nums = list(map(int, readline().split()))
        counter.update(nums)
    ans = 0
    for num in range(10):
        ans += counter[num] * d[num][1]

    print(ans)


if __name__ == '__main__':
    main()
Problem p03673 (python)

Fixed submission:
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    n = int(readline())
    a = list(map(int, readline().split()))

    odd = a[0::2]
    even = a[1::2]

    if n % 2 == 0:
        res = even[::-1] + odd
        print(*res)
    else:
        res = odd[::-1] + even
        print(*res)


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    n = int(readline())
    a = list(map(int, readline().split()))

    odd = a[0::2]
    even = a[1::2]

    if n % 2 == 0:
        print(*even[::-1], *odd)
    else:
        print(*odd[::-1], *even)


if __name__ == '__main__':
    main()
Problem p03729 (python)

Fixed submission:
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    A, B, C = input().split()

    if A[-1] == B[0] and B[-1] == C[0]:
        print("YES")
    else:
        print("NO")


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    A, B, C = map(int, readline().split())

    if A[-1] == B[0] and B[-1] == C[0]:
        print("YES")
    else:
        print("NO")


if __name__ == '__main__':
    main()
Problem p03752 (python)

Fixed submission:
# import math
# import bisect
#import numpy as np
import itertools
import copy
import sys

input = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    n, k = list(map(int,input().split()))
    a = list(map(int,input().split()))

    cmb = list(itertools.combinations([i for i in range(1, n)], k-1))
    ans = INF

    if k > 1:
            for ele in cmb:
                prc = 0
                prev = a[0]
                acp = copy.copy(a)
                for idx in ele:
                    if acp[idx] - prev <= 0:
                        prc += prev - acp[idx] + 1
                        acp[idx] = prev + 1
                    prev = acp[idx]
                cnt = 1
                mh = acp[0]
                for i in range(1, n):
                    if mh < acp[i]:
                        cnt += 1
                        mh = acp[i]
                if cnt >= k:
                    ans = min(ans, prc)
    else:
        ans = 0

    print(ans)


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
# import math
# import bisect
#import numpy as np
import itertools
import copy
import sys

input = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    n, k = list(map(int,input().split()))
    a = list(map(int,input().split()))

    cmb = list(itertools.combinations([i for i in range(1, n)], k-1))
    ans = INF

    if k > 1:
            for ele in cmb:
                prc = 0
                prev = a[0]
                acp = a.copy()
                for idx in ele:
                    if acp[idx] - prev <= 0:
                        prc += prev - acp[idx] + 1
                        acp[idx] = prev + 1
                    prev = acp[idx]
                cnt = 1
                mh = acp[0]
                for i in range(1, n):
                    if mh < acp[i]:
                        cnt += 1
                        mh = acp[i]
                if cnt >= k:
                    ans = min(ans, prc)
    else:
        ans = 0

    print(ans)


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
# import math
# import bisect
import numpy as np
import itertools
# import copy
import sys

input = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    n, k = list(map(int,input().split()))
    a = list(map(int,input().split()))

    cmb = list(itertools.combinations([i for i in range(1, n)], k-1))
    ans = INF

    for ele in cmb:
        prc = 0
        prev = a[0]
        for idx in ele:
            cur = a[idx]
            if cur - prev <= 0:
                prc += prev - cur + 1
                cur = prev + 1
            prev = cur
        ans = min(ans, prc)

    print(ans)


if __name__ == '__main__':
    main()
Problem p02687 (python)

Fixed submission:
print('ABC' if input()[1] == 'R' else 'ARC')

Buggy submission (verdict: Runtime Error):
print('ABC' if input()[1] == 'R' else 'ARC)
Problem p02843 (python)

Fixed submission:
X = int(input())
n = X//100
X -= 100*n
print(0 if X > 5*n else 1)

Buggy submission (verdict: Runtime Error):
X = int(input())
s = str(X)
n = int(s[0])
x = int(s[1:])
print(0 if x > 5*n else 1)
Problem p02898 (python)

Fixed submission:
N, K = map(int, input().split())
h = map(int, input().split())
ans = 0
for i in h:
  if K <= i:
    ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
#include <stdio.h>

int main(void)
{
  int N, K;
  scanf("%d %d", &N, &K);
  ans = 0;
  for(int i = 0; i < N; i++){
    int h;
    scanf("%d", &h);
    if(K <= h)
    	ans++;
  }
  printf("%d", ans);
}
Problem p03854 (python)

Fixed submission:
import numpy as np

d = np.array([[0, 0, 0, 0, 0, 0],
            [2, 0, 9, 0, 0, 0],
            [0, 3, 0, 0, 0, 0],
            [0, 0, 4, 0, 0, 0],
            [0, 0, 0, 5, 0, 0],
            [0, 0, 0, 0, 6, 0],
            [2, 0, 7, 0, 0, 0],
            [0, 8, 0, 0, 0, 0],
            [2, 0, 9, 11, 0, 0],
            [0, 10, 0, 0, 0, 0],
            [0, 0, 0, 11, 0, 0],
            [0, 0, 0, 0, 0, 12],
            [0, 0, 13, 0, 0, 0],
            [2, 1, 9, 0, 0, 0]], dtype = 'int32')
s = 1
S = input()
N = len(S)
id = {'d': 0, 'r': 1, 'e': 2, 'a': 3, 'm': 4, 's': 5}
for c in S:
    s = d[s][id[c]] if c in id else 0
    if s == 0:
        break

print("YES" if s in {1, 6, 8, 13} else "NO")

Buggy submission (verdict: Runtime Error):
import numpy as np

d = np.array([[0, 0, 0, 0, 0, 0],
            [2, 0, 9, 0, 0, 0],
            [0, 3, 0, 0, 0, 0],
            [0, 0, 4, 0, 0, 0],
            [0, 0, 0, 5, 0, 0],
            [0, 0, 0, 0, 6, 0],
            [2, 0, 7, 0, 0, 0],
            [0, 8, 0, 0, 0, 0],
            [2, 0, 9, 11, 0, 0],
            [0, 10, 0, 0, 0, 0],
            [0, 0, 0, 11, 0, 0],
            [0, 0, 0, 0, 0, 12],
            [0, 0, 13, 0, 0, 0],
            [2, 1, 9, 0, 0, 0]], dtype = 'int32')
s = 1
for c in input():
    s = d[s][id[c]] if c in {'d': 0, 'r': 1, 'e': 2, 'a': 3, 'm': 4, 's': 5} else 0
    if s == 0:
        break
print("YES" if s in {1, 6, 8, 13} else "NO")
Problem p04045 (python)

Fixed submission:
N, K = map(int, input().split())

ok = [True]*10

d = [int(s) for s in input().split()]

for i in d:
    ok[i] = False

ans = 0
for i in range(N, 10*N+1):
    j = i
    while j > 0 and ok[j%10]:
        j //= 10
    if j == 0:
        ans = i
        break

print(ans)

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())

ok = [True]*10;

d = [int(s) for s in input().split()]

for i in d:
    ok[i] = False

ans = 0
for i in range(N, 10*N+1):
    j = i
    while j > 0 and ok[j%10]:
        j /= 10
    if j == 0:
        ans = i
        break

print(ans)
Problem p02556 (python)

Fixed submission:
import sys, math
from functools import lru_cache
sys.setrecursionlimit(10**9)
MOD = 10**9+7

def input():
    return sys.stdin.readline()[:-1]

def mi():
    return map(int, input().split())

def ii():
    return int(input())

def i2(n):
    tmp = [list(mi()) for i in range(n)]
    return [list(i) for i in zip(*tmp)]

def main():
    N = ii()
    x, y = i2(N)

    Mw = max(x[i]+y[i] for i in range(N))
    mw = min(x[i]+y[i] for i in range(N))
    Mz = max(x[i]-y[i] for i in range(N))
    mz = min(x[i]-y[i] for i in range(N))

    print(max(Mz-mz, Mw-mw))
    


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import sys, math
from functools import lru_cache
sys.setrecursionlimit(10**9)
MOD = 10**9+7

def input():
    return sys.stdin.readline()[:-1]

def mi():
    return map(int, input().split())

def ii():
    return int(input())

def i2(n):
    tmp = [list(mi()) for i in range(n)]
    return [list(i) for i in zip(*tmp)]

def main():
    N = ii()
    x, y = i2(N)

    Mw = max(x[i]+y[i] for i in range(N))
    mw = min(x[i]+y[i] for i in range(N))
    Mz = max(abs(a[i]-y[i]) for i in range(N))
    mz = min(abs(x[i]-y[i]) for i in range(N))

    print(max(Mz-mz, Mw-mw))
    


if __name__ == '__main__':
    main()
Problem p02640 (python)

Fixed submission:
MOD = 10**9+7

def mi():
    return map(int, input().split())

def ii():
    return int(input())

def main():
    X, Y = list(mi())
    if 4*X-Y >= 0 and (4*X-Y)%2 == 0 and (4*X-Y)//2<= X:
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
MOD = 10**9+7

def mi():
    return map(int, input().split())

def ii():
    return int(input())

def main():
    X, Y = list(mi())
    if 4*X-Y >= 0 and (4*X-Y)%2 == 0 and a <= X:
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    main()
Problem p02647 (python)

Fixed submission:
from itertools import accumulate

def mi():
    return map(int, input().split())

def main():
    N, K = mi()
    A = list(mi())

    for _ in range(K):
        l = [0]*N
        for i in range(N):
            left = max(i-A[i], 0)
            right = min(i+A[i]+1, N)
            l[left] += 1
            if right < N:
                l[right] -= 1
        if A != list(accumulate(l)):
            A = list(accumulate(l))
        else:
            break
    print(' '.join(list(map(str, A))))

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
from itertools import accumulate

def mi():
    return map(int, input().split())

def main():
    N, K = mi()
    A = list(mi())

    for _ in range(K):
        l = [0]*N
        for i in range(N):
            left = max(i-A[i], 0)
            right = min(i+A[i]+1, N)
            l[left] += 1
            if right < N:
                l[right] -= 1
        if A != list(accumulate(l)):
            A = accumulate(l)
        else:
            break
    print(' '.join(list(map(str, A))))

if __name__ == '__main__':
    main()
Problem p02702 (python)

Fixed submission:
import sys

input = sys.stdin.readline

S = input().rstrip()
n = len(S)
l = [0]*2019
d = 10

t = int(S[n-1])
l[t%2019] += 1

l[0] += 1

for i in range(n-2, -1, -1):
    t += int(S[i])*d%2019
    l[t%2019] += 1 
    d *= 10
    d %= 2019

ans = 0

for i in l:
    ans += i*(i-1)//2

print(ans)

Buggy submission (verdict: Runtime Error):
S = input()
n = len(S)
a = [0]*n
l = [0]*2019

a[0] = int(S)
l[a[0]%2019] += 1

for i in range(n):
    a[i+1] = a[i] - int(S[i])*pow(10, n-i-1)
    l[a[i+1]%2019] += 1

print(sum(map(lambda x: x*(x-1)//2, l)))

Buggy submission (verdict: Runtime Error):
n = len(S)
a = [0]*n
l = [0]*2019

a[0] = int(S)
l[a[0]%2019] += 1

for i in range(n):
    a[i+1] = a[i] - int(S[i])*pow(10, n-i-1)
    l[a[i+1]%2019] += 1

print(sum(map(lambda x: x*(x-1)//2, l)))
Problem p02761 (python)

Fixed submission:
N, M = map(int, input().split())
if M:
    sc = [map(int, input().split()) for _ in range(M)]
    s, c = [list(i) for i in zip(*sc)]

    def isOK(num):
        str_num = str(num)
        l = len(str_num)
        if l != N:
            return False
        for i in range(M):
            if str_num[s[i]-1] != str(c[i]):
                return False

        return True

    ans = -1

    for i in range(10**N):
        if isOK(i):
            ans = i
            break

    print(ans)
else:
    print(10**(N-1) if N != 1 else 0)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
sc = [map(int, input().split()) for _ in range(M)]
s, c = [list(i) for i in zip(*sc)]

def isOK(num):
    str_num = str(num)
    l = len(str_num)
    if l != N:
        return False
    for i in range(M):
        if str_num[s[i]-1] != str(c[i]):
            return False

    return True

ans = -1

for i in range(10**N):
    if isOK(i):
        ans = i
        break

print(ans)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
sc = [map(int, input().split()) for _ in range(M)]
s, c = [list(i) for i in zip(*sc)]

def isOK(num):
    l = len(str(num))
    if l != N:
        return False
    for i in range(M):
        if str(num)[s[i]-1] != str(c[i]):
            return False

    return True

ans = -1

for i in range(1000):
    if isOK(i):
        ans = i
        break

print(ans)
Problem p02812 (python)

Fixed submission:
N= int(input())
S = input()
print(S.count('ABC'))

Buggy submission (verdict: Runtime Error):
10
ZABCDBABCQ
---
2
===
19
THREEONEFOURONEFIVE
---
0
===
33
ABCCABCBABCCABACBCBBABCBCBCBCABCB
---
5
===