Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
N, K = [int(i) for i in input().split()]
p = [int(i) for i in input().split()]
    
    
s = [0] * (N-K)

for i in range(N-K):
    s[i] = 0
    for j in range(K):         
      s[i] += p[i+j]# /2+0.5

print( (max(s))/2+0.5*K)

Fixed submission:
N, K = [int(i) for i in input().split()]
p = [int(i) for i in input().split()]
    
    
#s = [0] * (N-K)

s = 0
for j in range(K):
    s += p[j]

sm = s

for i in range(N-K):
 #   s[i] = 0
    s = s + p[K+i]- p[i]
    if s > sm:
        sm = s

print( sm/2+0.5*K)

Buggy python submission (verdict: Runtime Error):
N, K = [int(i) for i in input().split()]
p = [int(i) for i in input().split()]
    
    
    
s = [0] * (N-K)

for i in range(N-K):
    s[i] = 0
    for j in range(K):         
      s[i] += p[i+j]/2+0.5

print(max(s))


Fixed submission:
N, K = [int(i) for i in input().split()]
p = [int(i) for i in input().split()]
    
    
#s = [0] * (N-K)

s = 0
for j in range(K):
    s += p[j]

sm = s

for i in range(N-K):
 #   s[i] = 0
    s = s + p[K+i]- p[i]
    if s > sm:
        sm = s

print( sm/2+0.5*K)
Buggy python submission (verdict: Runtime Error):

import math

a =  int(input())
b =  int(input())
c =  int(input())
d =  int(input())
e =  int(input())
x = []
s = 0

if a % 10 != 0:
  x.append(a % 10)
  if min(x) == a % 10:
      s = math.ceil(a/10)*10

if b % 10 != 0:
  x.append(b % 10)
  if min(x) == b % 10:
      s = math.ceil(b/10)*10

if c % 10 != 0:
  x.append(c % 10)
  if min(x) == c % 10:
      s = math.ceil(c/10)*10


if d % 10 != 0:
  x.append(d % 10)
  if min(x) == d % 10:
      s = math.ceil(d/10)*10


if e % 10 != 0:
  x.append(e % 10)
  if min(x) == e % 10:
      s = math.ceil(e/10)*10

s = 0

if min(x) !=0:
  s = 10

print(math.ceil(a/10)*10 +  math.ceil(b/10)*10 +  math.ceil(c/10)*10 +  math.ceil(d/10)*10 +  math.ceil(e/10)*10 + min(x) -s )




Fixed submission:
import math
import numpy as np

a =  int(input())
b =  int(input())
c =  int(input())
d =  int(input())
e =  int(input())
x = []
s = 0

if a % 10 != 0:
  x.append(a % 10)

if b % 10 != 0:
  x.append(b % 10)

if c % 10 != 0:
  x.append(c % 10)


if d % 10 != 0:
  x.append(d % 10)


if e % 10 != 0:
  x.append(e % 10)

s = 0

if len(x) != 0:
  if np.amin(x) !=0:
    s = 10
  y = np.amin(x)
else:
  s = 0
  y = 0

print(math.ceil(a/10)*10 +  math.ceil(b/10)*10 +  math.ceil(c/10)*10 +  math.ceil(d/10)*10 +  math.ceil(e/10)*10 +  y -s )

Buggy python submission (verdict: Runtime Error):
import math

a =  int(input())
b =  int(input())
c =  int(input())
d =  int(input())
e =  int(input())
x = []
if a % 10 != 0:
  x.append(a % 10)

if b % 10 != 0:
  x.append(b % 10)

if c % 10 != 0:
  x.append(c % 10)

if d % 10 != 0:
  x.append(d % 10)

if e % 10 != 0:
  x.append(e % 10)

print(math.ceil(a/10)*10 +  math.ceil(b/10)*10 +  math.ceil(c/10)*10 +  math.ceil(d/10)*10 +  math.ceil(e/10)*10 + min(x))



Fixed submission:
import math
import numpy as np

a =  int(input())
b =  int(input())
c =  int(input())
d =  int(input())
e =  int(input())
x = []
s = 0

if a % 10 != 0:
  x.append(a % 10)

if b % 10 != 0:
  x.append(b % 10)

if c % 10 != 0:
  x.append(c % 10)


if d % 10 != 0:
  x.append(d % 10)


if e % 10 != 0:
  x.append(e % 10)

s = 0

if len(x) != 0:
  if np.amin(x) !=0:
    s = 10
  y = np.amin(x)
else:
  s = 0
  y = 0

print(math.ceil(a/10)*10 +  math.ceil(b/10)*10 +  math.ceil(c/10)*10 +  math.ceil(d/10)*10 +  math.ceil(e/10)*10 +  y -s )
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

N, M  = [int(i) for i in input().split()]
A = []
for i in range(N):
    A.append([int(i) for i in input().split()])

A = np.array(A)
B = A[:,1]
A = A[:,0]

#print(N)
#print(M)
#print(A)
#print(B)
x = 0
cost = 0

while x < M:
    i = np.argmin(A)
    
    if x + B[i] <= M:
        cost += A[i] * B[i]
        x += B[i]
        A = np.delete(A, i)
        B= np.delete(B, i)
        #print(A)
        #print(B)
#        print(cost)
#        print(x)
    else:
        #print(A[i])
        #print(M-x)
        cost += A[i] * (M-x)
        x += (M-x)
        #print(cost)
        #print(x)


print(cost)

Fixed submission:
import numpy as np

N, M  = [int(i) for i in input().split()]
A = []
for i in range(N):
    A.append([int(i) for i in input().split()])

A = np.array(A)
B = A[:,1]
A = A[:,0]

#print(N)
#print(M)
#print(A)
#print(B)
x = 0
cost = 0

p = np.argsort(A)
A = A[p]
B = B[p]
#print(A)
#print(B)

i = 0
#print(A)
#print(B)

while x < M:
    # i = np.argmin(A)
        #A = np.delete(A, i)
        #B= np.delete(B, i)
    
    if x + B[i] <= M:
        cost += A[i] * B[i]
        x += B[i]
        i += 1
        #print(A)
        #print(B)
    else:
        cost += A[i] * (M-x)
        x += (M-x)
        i += 1
        #print(A)
        #print(B)


print(cost)
Buggy python submission (verdict: Runtime Error):
import re

m = re.match('.*k.*e.*y.*e.*n.*c.*e.*')
if m:
  print("YES")
else:
  print("NO")



Fixed submission:
import re

a = input()

if re.match('^([a-zA-Z]*?)keyence$', a):
  print("YES")
else:
  if re.match('^k([a-zA-Z]*?)eyence$', a):
    print("YES")
  else:
    if re.match('^ke([a-zA-Z]*?)yence$', a):
      print("YES")
    else:
      if re.match('^key([a-zA-Z]*?)ence$', a):
        print("YES")
      else:
        if re.match('^keye([a-zA-Z]*?)nce$', a):
          print("YES")
        else:
          if re.match('^keyen([a-zA-Z]*?)ce$', a):
            print("YES")
          else:
            if re.match('^keyenc([a-zA-Z]*?)e$', a):
              print("YES")
            else:
              if re.match('^keyence([a-zA-Z]*?)$', a):
                print("YES")
              else:
                print("NO")
Buggy python submission (verdict: Time Limit Exceeded):
X,K,D = map(int,input().split()) 
mlist = []
for i in range(K+1):
    t = X + i*D - (K-i)*D
    if t < 0 :
        t = -t
    mlist.append(t)
print(min(mlist))

Fixed submission:
X,K,D = map(int,input().split()) 
X = abs(X)
if X >= K*D:
    print(X-K*D)
else:
    if (K-X//D) % 2 == 1:
        print(D-(X-X//D*D))
    else:
        print(X-X//D*D)
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = 0
for i in range(1,10):
    if n % i != 0:
        continue
    else:
        if n / i <= 9:
            a += 1
            break
        else:
            continue
if a == 1:
    print('Yes')
else:
    print('No')

Fixed submission:
a,b = map(int,input().split())

if a > 9 or b > 9:
    print('-1')
else:
	print(a*b)

Buggy python submission (verdict: Runtime Error):
n = int(input())
a = 0
for i in range(1,10):
    if n % i != 0:
        continue
    else:
        if n / i <= 9:
            a += 1
            break
        else:
            continue
if a == 1:
	print('Yes')
else:
	print('No')

Fixed submission:
a,b = map(int,input().split())

if a > 9 or b > 9:
    print('-1')
else:
	print(a*b)

Buggy python submission (verdict: Runtime Error):
n = int(input())
a = 0
for i in range(1,10):
	if n % i != 0:
        continue
    else:
        if n / i <= 9:
            a += 1
            break
        else:
            continue
if a == 1:
	print('Yes')
else:
	print('No')

Fixed submission:
a,b = map(int,input().split())

if a > 9 or b > 9:
    print('-1')
else:
	print(a*b)
Buggy python submission (verdict: Runtime Error):
import math
b,a = map(int,input().split())
print(math.ceil((b-1)/(a-1)))

Fixed submission:
import math
A, B = map(int, input().split())
print(1+math.ceil((B-A)/(A-1)))

Buggy python submission (verdict: Runtime Error):
import math
a,b = map(int,input().split)
print(math.ceil((b-1)/(a-1)))

Fixed submission:
import math
A, B = map(int, input().split())
print(1+math.ceil((B-A)/(A-1)))
Buggy python submission (verdict: Runtime Error):
S = input()
 
ans = 0
c = []
 
for i in range(len(S)):
  if S[i] =="R":
    ans += 1
  else:
    c.append(ans)
    ans = 0
 
 
print(max(c))

Fixed submission:
S = input()
 
ans = 0
c = []
 
for i in range(len(S)):
    if S[i] =="R":
        ans += 1
    else:
        c.append(ans)
        ans = 0

c.append(ans)
 
print(max(c))

Buggy python submission (verdict: Runtime Error):
S = input()
 
ans = 0
c = []
 
for i in range(len(S)):
  if S[i] =="R":
    ans += 1
  else:
    c.append(ans)
    ans = 0

 
print(max(c))


Fixed submission:
S = input()
 
ans = 0
c = []
 
for i in range(len(S)):
    if S[i] =="R":
        ans += 1
    else:
        c.append(ans)
        ans = 0

c.append(ans)
 
print(max(c))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = input()

ans = 0
for i in range(N):
    i = i + 1
    for j in range(N-i):
        j = i + j + 1
        if S[i-1] == S[j-1]:
            continue
        for k in range(N-j):
            k = k + j + 1
            if S[j-1] != S[k-1] and S[i-1] != S[k-1]:
                if j-i != k-j:
                    ans += 1

print(ans)

Fixed submission:
N = int(input())
S = input()
T = [0]*3

for i in range(N):
    if S[i] == "R":
        T[0] += 1
    elif S[i] == "G":
        T[1] += 1
    else:
        T[2] += 1
ans = T[0]*T[1]*T[2]
t = N // 2

for i in range(t):
    i = i+1
    j = 0
    while j + 2*i < N:
        if S[j] != S[j + i] and S[j] != S[j + 2*i] and S[j+i] != S[j + 2*i]:
            ans -= 1
        j += 1

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = input()

ans = 0
for i in range(N):
    i = i + 1
    for j in range(N-i):
        j = i + j + 1
        for k in range(N-j):
            k = k + j + 1
            if S[i-1] != S[j-1] and S[j-1] != S[k-1] and S[i-1] != S[k-1]:
                if j-i != k-j:
                    ans += 1


print(ans)

Fixed submission:
N = int(input())
S = input()
T = [0]*3

for i in range(N):
    if S[i] == "R":
        T[0] += 1
    elif S[i] == "G":
        T[1] += 1
    else:
        T[2] += 1
ans = T[0]*T[1]*T[2]
t = N // 2

for i in range(t):
    i = i+1
    j = 0
    while j + 2*i < N:
        if S[j] != S[j + i] and S[j] != S[j + 2*i] and S[j+i] != S[j + 2*i]:
            ans -= 1
        j += 1

print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = [int(_) for _ in input().split()]
T = []

for i in range(N):
    flag = 0
    for j in range(len(T)):
        if A[i] == T[j][0]:
            T[j][1] += 1
            flag = 1
            break
    if flag == 0:
        T.append([A[i],1])
T2 = []
for i in range(len(T)):
    T2.append(T[i][1])

def hoge(List):
    ans = 0
    for i in range(len(List)):
        ans += (List[i]-1)*List[i]//2
    return ans

for i in range(N):
    for j in range(len(T)):
        if T[j][0] == A[i]:
            T2[j] -= 1
            print(hoge(T2))
            T2[j] += 1
            break

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

print(int((N*(N-1)/2)+(M*(M-1)/2)))
Buggy python submission (verdict: Runtime Error):
import math

N, M = map(int, input().split())
S = input()
T = input()

def lcm(x, y):
    return int((x * y) / math.gcd(x, y))

d = math.gcd(N,M)
l = lcm(N,M)

s = [0 for i in range(0,d)]
t = [0 for i in range(0,d)]

a = int(l/M)
b = int(l/N)

for i in range(0,d):
    s[i] = S[i*a]
    t[i] = T[i*b]

if s == t:
    print(l)
else:
    print(-1)

Fixed submission:
N, M = map(int, input().split())
S = input()
T = input()

def gcd(m,n):
    x = max(m,n)
    y = min(m,n)
    if x%y == 0:
        return y
    else:
        while x%y != 0:
            z = x%y
            x = y
            y = z
        else:
            return z

def lcm(m,n):
    return int(m * n /gcd(m,n))

d = gcd(N,M)
l = lcm(N,M)

s = [0 for i in range(0,d)]
t = [0 for i in range(0,d)]

a = int(l/M)
b = int(l/N)

for i in range(0,d):
    s[i] = S[i*a]
    t[i] = T[i*b]

if s == t:
    print(l)
else:
    print(-1)

Buggy python submission (verdict: Runtime Error):
import math

N, M = map(int, input().split())
S = input()
T = input()

def lcm(x, y):
    return (x * y) // math.gcd(x, y)

d = math.gcd(N,M)
l = lcm(N,M)

s = [0 for i in range(0,d)]
t = [0 for i in range(0,d)]

a = l//M
b = l//N

for i in range(0,d):
    s[i] = S[i*a]
    t[i] = T[i*b]

if s == t:
    print(l)
else:
    print(-1)

Fixed submission:
N, M = map(int, input().split())
S = input()
T = input()

def gcd(m,n):
    x = max(m,n)
    y = min(m,n)
    if x%y == 0:
        return y
    else:
        while x%y != 0:
            z = x%y
            x = y
            y = z
        else:
            return z

def lcm(m,n):
    return int(m * n /gcd(m,n))

d = gcd(N,M)
l = lcm(N,M)

s = [0 for i in range(0,d)]
t = [0 for i in range(0,d)]

a = int(l/M)
b = int(l/N)

for i in range(0,d):
    s[i] = S[i*a]
    t[i] = T[i*b]

if s == t:
    print(l)
else:
    print(-1)

Buggy python submission (verdict: Runtime Error):
import math

N, M = map(int, input().split())
S = input()
T = input()

def lcm(x, y):
    return (x * y) // math.gcd(x, y)

d = math.gcd(N,M)
l = lcm(N,M)

s = [0 for i in range(0,d)]
t = [0 for i in range(0,d)]

for i in range(0,d):
    s[i] = S[i*(l//M)]
    t[i] = T[i*(l//N)]

if s == t:
    print(l)
else:
    print(-1)

Fixed submission:
N, M = map(int, input().split())
S = input()
T = input()

def gcd(m,n):
    x = max(m,n)
    y = min(m,n)
    if x%y == 0:
        return y
    else:
        while x%y != 0:
            z = x%y
            x = y
            y = z
        else:
            return z

def lcm(m,n):
    return int(m * n /gcd(m,n))

d = gcd(N,M)
l = lcm(N,M)

s = [0 for i in range(0,d)]
t = [0 for i in range(0,d)]

a = int(l/M)
b = int(l/N)

for i in range(0,d):
    s[i] = S[i*a]
    t[i] = T[i*b]

if s == t:
    print(l)
else:
    print(-1)
Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())

v = 0
t = (2*N) // K

for i in range(1,t+1):
    if (K*i) % 2 == 0:
        if i % 2 == 1:
            for j in range(1,t+1,2):
                if (K*j) % 2 == 0:
                    for k in range(1,t+1,2):
                        if (K*k) % 2 == 0:
                            v += 1
        else:
            for j in range(2,t+1,2):
                if (K*j) % 2 == 0:
                    for k in range(2,t+1,2):
                        if (K*k) % 2 == 0:
                            v += 1
print(v)

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

v = 0
t = (2*N) // K
s = N // K

if K % 2 == 0:
    if t % 2 == 0:
        v = 2*((t/2)**3)
    else:
        v = (((t+1)/2)**3) + (((t-1)/2)**3)
else:
    v = s**3

v = int(v)
print(v)

Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())

v = 0

for i in range(1,N+1):
    for j in range(1,N+1):
        for k in range(1,N+1):
            if (i+j) % K == 0 and (j+k) % K == 0 and (k+i) % K == 0:
                v += 1

print(v)

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

v = 0
t = (2*N) // K
s = N // K

if K % 2 == 0:
    if t % 2 == 0:
        v = 2*((t/2)**3)
    else:
        v = (((t+1)/2)**3) + (((t-1)/2)**3)
else:
    v = s**3

v = int(v)
print(v)
Buggy python submission (verdict: Time Limit Exceeded):
# Problem C - Repsept
# input
K = int(input())

# initialization
seven = 7
ans = 1

# count
if K%2==0 and K%5==0:
    ans = -1
elif K==1:
    ans = 1
else:
    tmp_list = [0]*(10**6+1)
    while not seven%K==0: # 割り切れない限り
        seven = seven*10 + 7
        seven = seven % K
        ans += 1


# output
print(ans)


Fixed submission:
# Problem C - Repsept
# input
K = int(input())

# initialization
seven = 7
ans = 1

# count
if K%2==0 or K%5==0:
    ans = -1
elif K==1:
    ans = 1
else:
    tmp_list = [0]*(10**6+1)
    while not seven%K==0: # 割り切れない限り
        seven = seven*10 + 7
        seven = seven % K
        ans += 1


# output
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
# Problem C - Marks
# input
N, K = map(int, input().split())
a_nums = list(map(int, input().split()))

# initialization
cumulative_sum = 1
for i in range(K):
    cumulative_sum *= a_nums[i]
cumulative_list = [0] * N
cumulative_list[K-1] = cumulative_sum

# cumulative sum calc
for i in range(K, N):
    cumulative_sum = cumulative_sum // a_nums[i-K]
    cumulative_sum = cumulative_sum * a_nums[i]
    cumulative_list[i] = cumulative_sum

# check
for i in range(K, N):
    if cumulative_list[i]>cumulative_list[i-1]:
        print("Yes")
    else:
        print("No")


Fixed submission:
# Problem C - Marks
# input
N, K = map(int, input().split())
a_nums = list(map(int, input().split()))

# initialization
cumulative_sum = 1
for i in range(K):
    cumulative_sum += a_nums[i]
cumulative_list = [0] * N
cumulative_list[K-1] = cumulative_sum

# cumulative sum calc
for i in range(K, N):
    cumulative_sum = cumulative_sum - a_nums[i-K]
    cumulative_sum = cumulative_sum + a_nums[i]
    cumulative_list[i] = cumulative_sum
    if cumulative_list[i]>cumulative_list[i-1]:
        print("Yes")
    else:
        print("No")
Buggy python submission (verdict: Runtime Error):
# Problem D - Chat in a Circle

# input
N = int(input())
a_nums = list(map(int, input().split()))

# initialization
a_nums = sorted(a_nums, reverse=True) # sort
a_max = max(a_nums)
a_count_list = [0]*(a_max + 1)
a_count_list[a_nums[0]] += 1
point = 0
max_i = a_nums[0]

# count
for i in range(1, N):
    a = a_nums[i]
    while max_i>0 and a_count_list[max_i]==0:
        max_i -= 1
    a_count_list[max_i] -= 1
    point += max_i # add point
    a_count_list[a] += 2

# output
print(point)


Fixed submission:
# Problem D - Chat in a Circle

from collections import deque

# input
N = int(input())
a_nums = list(map(int, input().split()))

# initialization
a_nums = sorted(a_nums, reverse=True)
point_list = deque([a_nums[0]])
point = 0

# count
for i in range(1, N):
    a = a_nums[i]
    point += point_list.popleft()
    point_list.append(a)
    point_list.append(a)

# output
print(point)
Buggy python submission (verdict: Time Limit Exceeded):
# Problem D - Double Dots

# input
N, M = map(int, input().split())
graph_list = {}
for i in range(M):
    a, b = map(int, input().split())
    if a in graph_list:
        graph_list[a].append(b)
    else:
        graph_list[a] = [b]

    if b in graph_list:
        graph_list[b].append(a)
    else:
        graph_list[b] = [a]

# initialization
visit_list = [0]*N
distance_list = [float("INF")]*N
distance_list[0] = 0
visit_queue = [1]
queue_count = 1

# bfs search
while queue_count>0:
    v = visit_queue.pop()
    queue_count -= 1

    graph = graph_list[v]
    for n in graph:
        if distance_list[v-1]+1<distance_list[n-1]:
            distance_list[n-1] = distance_list[v-1] + 1
            visit_list[n-1] = v
            visit_queue.append(n)
            queue_count += 1

# output
print("Yes")
for i in range(1, N):
    print(visit_list[i])


Fixed submission:
# Problem D - Double Dots

from collections import deque

# input
N, M = map(int, input().split())
graph_list = {}
for i in range(M):
    a, b = map(int, input().split())
    if a in graph_list:
        graph_list[a].append(b)
    else:
        graph_list[a] = [b]

    if b in graph_list:
        graph_list[b].append(a)
    else:
        graph_list[b] = [a]

# initialization
visit_list = [0]*N
distance_list = [float("INF")]*N
distance_list[0] = 0
visit_queue = deque([1])
queue_count = 1

# bfs search
while queue_count>0:
    v = visit_queue.popleft()
    queue_count -= 1

    graph = graph_list[v]
    for n in graph:
        if distance_list[v-1]+1<distance_list[n-1]:
            distance_list[n-1] = distance_list[v-1] + 1
            visit_list[n-1] = v
            visit_queue.append(n)
            queue_count += 1

# output
print("Yes")
for i in range(1, N):
    print(visit_list[i])
Buggy python submission (verdict: Runtime Error):
# Problem E - This Message Will Self-Destruct in 5s

# input
N = int(input())
a_nums = list(map(int, input().split()))

# initialization
tmp_1 = [0]*(10**6)
ans = 0

# count
for i in range(1, N+1):
    tmp_1[i + a_nums[i-1]] += 1

# count 2
for j in range(1, N+1):
    if j-a_nums[j-1]>=0:
        ans +=  tmp_1[j-a_nums[j-1]]

# output
print(ans)


Fixed submission:
# Problem E - This Message Will Self-Destruct

# input
N = int(input())
a_nums = list(map(int, input().split()))

# initialization
num_dic = {}
ans = 0

# count
for i in range(1, N+1):
    a = a_nums[i-1] + i
    if not a in num_dic:
        num_dic[a] = 1
    else:
        num_dic[a] += 1

# count 2
for j in range(1, N+1):
    b = j - a_nums[j-1]
    if b in num_dic:
        ans += num_dic[b]

# output
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
# Problem D - Multiple of 2019

from collections import Counter

# input
S = input()
s_len = len(S)

# initialization
ans = 0
mod_list = [0]*(s_len + 1)

# mod count
for i in range(1, s_len+1):
    tmp_num = int(S[s_len-i:])
    mod_list[i] = tmp_num % 2019

# output
mod_counter = Counter(mod_list)
for k in mod_counter.keys():
    m_c = mod_counter[k]
    if m_c>=2:
        ans += m_c * (m_c-1) // 2
print(ans)


Fixed submission:
# Problem D - Multiple of 2019

# input
S = list(input())
N = len(S)

# initialization
ans = 0

# count
nums_2019 = [0]*2019
nums_2019[0] = 1
s = 0
for i in range(N-1, -1, -1):
    s += int(S[i]) * pow(10, N - i - 1, 2019)
    nums_2019[s%2019] += 1

for i in range(2019):
    if nums_2019[i]>=2:
        ans += nums_2019[i] * (nums_2019[i]-1) // 2

# output
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
# input
N = int(input())
S = list(input())

# initialization
ans = 0

for i in range(N-2):
    for j in range(i+1, N-1):
        for k in range(j+1, N):
            if not S[i]==S[j] and not S[i]==S[k] and not S[k]==S[j] and not j-i==k-j:
                ans += 1

# output
print(ans)


Fixed submission:
# Problem D - RGB Triplets

# input
N = int(input())
S = list(input())

# initialization
r_count = 0
g_count = 0
b_count = 0
exception_count = 0

# a, b, c count
for i in range(N):
    if S[i]=='R':
        r_count += 1
    elif S[i]=='G':
        g_count += 1
    elif S[i]=='B':
        b_count += 1
ans_1 = r_count * g_count * b_count

# exception count
for i in range(N-2):
    for j in range(i+1,N-1):
        k = 2 * j - i
        if k>=N:
            continue
        if not S[i]==S[j] and not S[j]==S[k] and not S[i]==S[k]:
            exception_count += 1

# output
ans = ans_1 - exception_count
print(ans)
Buggy python submission (verdict: Runtime Error):
# Problem D - Line++

# input
N, X, Y = map(int, input().split())

# initialization
INF = N
kyori_graph = [[INF]*N for i in range(N)]
kosu_list = [0]*(N-1)

# graph search
for i in range(N):
    for j in range(i+1, N):
        # グラフの更新
        kyori_graph[i][j] = min(abs(j-i), abs(X-1-i)+1+abs(j-(Y-1)))
        # abs((Y-1)-i)+1+abs(j-(X-1))

# 個数の数え上げ
for i in range(N):
    for j in range(i+1, N):
        kyori = kyori_graph[i][j]
        kosu_list[kyori-1] += 1

# output
for k in kosu_list:
    print(k)


Fixed submission:
S = list(input())

if S[2]==S[3] and S[4]==S[5]:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Time Limit Exceeded):
# Problem D - Line++

# input
N, X, Y = map(int, input().split())

# initialization
graph = [[float('INF')]*(N+1) for i in range(N+1)]
for i in range(1, N):
    graph[i][i+1] = 1
graph[X][Y] = 1
kyori = [0]*N

# dp
for i in range(1, N):
    for j in range(i+1, N+1):
        if j<=X:
            graph[i][j] = min(graph[i][j], abs(j - i))
        else:
            graph[i][j] = min(graph[i][j], abs(j - i), abs(X - i)+1+abs(j - Y))

# kyori count
for i in range(1, N+1):
    for j in range(i+1, N+1):
        if not graph[i][j]==float('INF'):
            kyori[graph[i][j]] += 1

# output
for i in range(1, N):
    print(kyori[i])


Fixed submission:
# Problem D - Line++

# input
N, X, Y = map(int, input().split())

# initialization
INF = N
kyori_graph = [[INF]*N for i in range(N)]
kosu_list = [0]*(N-1)
for i in range(N):
    for j in range(i+1, N):
        if j==i+1:
            kyori_graph[i][j] = 1
        else:
            kyori_graph[i][j] = INF
kyori_graph[X-1][Y-1] = 1

# graph search
for i in range(N):
    for j in range(i+1, N):
        # グラフの更新
        kyori_graph[i][j] = min(abs(j-i), abs(X-1-i)+1+abs(j-(Y-1)), abs((Y-1)-i)+1+abs(j-(X-1)))

# 個数の数え上げ
for i in range(N):
    for j in range(i+1, N):
        kyori = kyori_graph[i][j]
        kosu_list[kyori-1] += 1

# output
for k in kosu_list:
    print(k)