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

Fixed submission:
n = int(input())
 
def check(p):
  c = 0
  while p > 0:
    c += p % 10
    p //= 10
  return c
 
if n % check(n) == 0:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
n = int(input())

def check(p):
  c = 0
  while p > 0:
    c += p % 10
    p //= 10
  return c

if n % check(p) == 0:
  print("Yes")
else:
  print("No")
Problem p03360 (python)

Fixed submission:
a = [int(x) for x in input().split()]
k = int(input())
print(sum(a) - max(a) + max(a) * (2 ** k))

Buggy submission (verdict: Runtime Error):
a = [int(x) for x in input().split()]
k = int(input())
print(sum(a) + max(a) * (2 ** (K - 1)))
Problem p02760 (python)

Fixed submission:
a = [0]*3
for i in range(3):
  a[i] = list(map(int, input().split()))
n = int(input())
b = [0]*n
for i in range(n):
  b[i] = int(input())

  
  

  
  
for i in range(n):
  for j in range(3):
    for k in range(3):
      if a[j][k] == b[i]:
        a[j][k] = 0


for i in range(3):
  if sum(a[i]) == 0:
    print("Yes")
    exit()
    
for i in range(3):
  if a[0][i] + a[1][i] + a[2][i] == 0:
    print("Yes")
    exit()
if a[0][0] + a[1][1] + a[2][2] == 0:
  print("Yes")
  exit()
if a[0][2] + a[1][1] + a[2][0] == 0:
  print("Yes")
  exit()
print("No")

Buggy submission (verdict: Runtime Error):
import math
a = [0]*3
for i in range(3):
    a[i] = list(map(int,input().split()))
n = int(input())
b = [0]*n
for i in range(n):
    b[i] = int(input())

for i in range(n):
    for j in range(3):
        for k in range(3):
            if a[j][k]==b[i]:
                a[j][k]=0
for i in range(3):
    if sum(a[i]) == 0:
        print("Yes")
        exit()
for i in range(3):
    if a[0][i]+a[1][i]+a[2][i] == 0 :
        print("Yes")
        exit()
if a[0][0]+a[1][1]+a[2][2] == 0:
    print("Yes")
    exit()
if a[0][2] + a[1][1] +a[2][0] == 0:
    print("Yes")
    eixt()
print("No")
Problem p02574 (python)

Fixed submission:

import math
#素数列挙
def get_primes(limit):
    A = [i for i in range(2, limit+1)]
    P = []
    time = 0
    
    while True:
        prime = min(A)
        
        if prime > math.sqrt(limit):
            break
            
        P.append(prime)
            
        A = [i for i in A if i%prime!=0]

    P.extend(A)
          
    return P


def resolve():
    N = int(input())
    A = list(map(int,input().split()))
    sosus = set(get_primes(max(A)+1))
    dvd = set()



    val = A[0]
    for i in A:
        val = math.gcd(i,val)

    if val ==1:
        pass
    else:
        print('not coprime')
        return

    for i in A:
        tmp=[]
        for j in sosus:
            if j>i:
                break
            if i % j ==0:
                tmp.append(j)
                while i % j ==0:
                    i //=j
            if i ==1:
                break
            if i in sosus:
                
                tmp.append(i)
                i = 1
                break
        sosus.difference_update(tmp)
        
        if i != 1:
            break
    else:
        print('pairwise coprime')
        return

    print('setwise coprime')

resolve()

Buggy submission (verdict: Runtime Error):
def resolve():
    N = int(input())
    A = list(map(int,input().split()))
    sosus = set(get_primes(max(A)+1))
    dvd = set()



    val = A[0]
    for i in A:
        val = math.gcd(i,val)

    if val ==1:
        pass
    else:
        print('not coprime')
        return

    for i in A:
        tmp=[]
        for j in sosus:
            if j>i:
                break
            if i % j ==0:
                tmp.append(j)
                while i % j ==0:
                    i //=j
            if i ==1:
                break
        sosus.difference_update(tmp)
        
        if i != 1:
            break
    else:
        print('pairwise coprime')
        return

    print('setwise coprime')

resolve()
Problem p02683 (python)

Fixed submission:
import itertools as itt
def resolve():
    N,M,X = map(int,input().split())
    CA = [list(map(int,input().split())) for i in range(N)]
    mxc = float('inf')
    for r in range(N+1):
        for cmb in itt.combinations(CA,r):
            cost = 0
            tbl = [0]*M
            for x in cmb:
                cost+=x[0]
                for i in range(M):
                    tbl[i]+= x[i+1]

            for i in tbl:
                if i < X:
                    break
            else:
                mxc = min(cost,mxc)
                
    if mxc == float('inf'):
        print(-1)
    else:
        print(mxc)



if __name__ == "__main__":
    resolve()

Buggy submission (verdict: Runtime Error):
def resolve():
    N,M,X = map(int,input().split())
    CA = [list(map(int,input().split())) for i in range(N)]
    mxc = float('inf')
    for r in range(N+1):
        for cmb in itt.combinations(CA,r):
            cost = 0
            tbl = [0]*M
            for x in cmb:
                cost+=x[0]
                for i in range(M):
                    tbl[i]+= x[i+1]

            for i in tbl:
                if i < X:
                    break
            else:
                mxc = min(cost,mxc)
                
    if mxc == float('inf'):
        print(-1)
    else:
        print(mxc)



if __name__ == "__main__":
    resolve()
Problem p02684 (python)

Fixed submission:
def resolve():
    N,K = map(int,input().split())
    A = [int(i)-1 for i in input().split()]
    visited =[False]*N
    steps = [K for i in range(N)]

    current = 0
    while True:

        if K == 0:
            print(current+1)
            return
        if not visited[current]:
            visited[current]=True
            steps[current]=K
            current=A[current]
            K-=1
        else:
            K= K % (steps[current]-K)
            break
    
    while K != 0:

        current= A[current]
        K-=1
    print(current+1)




if __name__ == "__main__":
    resolve()

Buggy submission (verdict: Runtime Error):
def resolve():
    N,K = map(int,input().split())
    A = [int(i)-1 for i in input().split()]
    visited =[False]*N
    steps = [K for i in range(N)]

    current = 0
    while True:

        if K == 0:
			print(current+1)
            return
        if not visited[current]:
            visited[current]=True
            steps[current]=K
            current=A[current]
            K-=1
        else:
            K= K % (steps[current]-K)
            break
    
    while K != 0:

        current= A[current]
        K-=1
    print(current+1)




if __name__ == "__main__":
    resolve()
Problem p02743 (python)

Fixed submission:
import decimal 



def resolve():
    a,b,c = [decimal.Decimal(i) for i in input().split()]

    if a.sqrt() + b.sqrt() < c.sqrt() :
        print("Yes")
    else:
        print("No")

if __name__ == "__main__":
    resolve()

Buggy submission (verdict: Runtime Error):
import decimal 



def resolve():
    a,b,c = [decimal.Decimal(i) for i in input().split()]

    if a.sqrt() + b.sqrt() < c.sqrt() :
        print("Yes")
    else:
        print("No")

if __name__ == "__main__":
    unittest.main()
Problem p02765 (python)

Fixed submission:
def resolve():
    N,R=map(int,input().split())
    print(R+max(0,10-N)*100)

if __name__ == "__main__":
    resolve()

Buggy submission (verdict: Runtime Error):


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)
    def test_入力例_1(self):
        input = """2 2919"""
        output = """3719"""
        self.assertIO(input, output)
    def test_入力例_2(self):
        input = """22 3051"""
        output = """3051"""
        self.assertIO(input, output)


def resolve():
    N,R=map(int,input().split())
    print(R+max(0,10-N)*100)

if __name__ == "__main__":
    resolve()
Problem p02787 (python)

Fixed submission:

def resolve():
    H,N=(int(i) for i in input().split())
    magics=[[int(i) for i in input().split()] for j in range(N)]
    mx=2**31
    dpt=[mx for i in range(H+1)]
    dpt[-1]=0
    for i in range(H,0,-1):
        
        current=dpt[i]
        if current> dpt[0]:
            continue
        for m in magics:
            dpt[max(0,i-m[0])]=min(dpt[max(0,i-m[0])],current+m[1])
    print(dpt[0])

if __name__ == "__main__":
    resolve()

Buggy submission (verdict: Runtime Error):

def resolve():
    H,N=(int(i) for i in input().split())
    magics=[[int(i) for i in input().split()] for j in range(N)]
    mx=2**31
    dpt=[mx for i in range(H+1)]
    dpt[-1]=0
    for i in range(H,-1,-1):
        
        current=dpt[i]
        if current> dpt[0]:
            continue
        for m in magics:
            dpt[max(0,i-m[0])]=min(dpt[max(0,i-m[0])],current+m[1])
    print(dpt[0])

if __name__ == "__main__":
    unittest.main()
Problem p02882 (python)

Fixed submission:
import math

def resolve():
    a,b,x=map(int,input().split())
    xx=x/a
    
    if x==b*a**2:
        print(0)
    elif xx<a*b/2:
        ts=b**2/(xx)/2
        print(math.degrees(math.atan(ts)))
        
    elif xx==a*b/2:
        print(45)
    else:
        ts=a**2/(a*b-xx)/2
        print(90-math.degrees(math.atan(ts)))
if __name__ == "__main__":
    resolve()

Buggy submission (verdict: Runtime Error):
import math
from scipy import optimize

def f1(sita,b,x):
    return b**2/8*math.sin(sita)*(3-math.cos(sita))-x


def resolve():
    a,b,x=map(int,input().split())
    xx=x/a
    
    if x==b*a**2:
        print(0)
    elif xx<a*b/2:
        ts=b**2/(xx)/2
        print(math.degrees(ans[0]))
        
    elif xx==a*b/2:
        print(45)
    else:
        ts=a**2/(a*b-xx)/2
        print(90-math.degrees(math.atan(ts)))
        
if __name__ == "__main__":
    resolve()

Buggy submission (verdict: Runtime Error):
import math
from scipy import optimize


def resolve():
    a,b,x=map(int,input().split())
    xx=x/a
    
    if x==b*a**2:
        print(0)
    elif xx<a*b/2:
        ans = 90-optimize.fsolve(f1,math.pi/4,args=(b,xx),epsfcn=10**-18)
        print(math.degrees(ans[0]))
        
    elif xx==a*b/2:
        print(45)
    else:
        ts=a**2/(a*b-xx)/2
        print(90-math.degrees(math.atan(ts)))
        
if __name__ == "__main__":
    resolve()

Buggy submission (verdict: Runtime Error):
import math
from scipy import optimize


def f1(sita,b,x):
    return b**2/4*math.sin(2*sita)*(math.sin(2*sita)**2 + 1)-x


def resolve():
    a,b,x=map(int,input().split())
    xx=x/a
    if xx<a*b/2:
        ans = optimize.fsolve(f1,math.pi/2,args=(b,xx),epsfcn=10**-8)
        print(math.degrees(ans[0]))
        pass
    elif xx==a*b/2:
        print(45)
    else:
        ts=a**2/(a*b-xx)/2
        print(90-math.degrees(math.atan(ts)))
        pass

if __name__ == "__main__":
    resolve()
Problem p02924 (python)

Fixed submission:
n=int(input())

print(sum(range(n)))

Buggy submission (verdict: Runtime Error):
import sys
from io import StringIO
import unittest

class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)
    def test_入力例_1(self):
        input = """2"""
        output = """1"""
        self.assertIO(input, output)
    def test_入力例_2(self):
        input = """13"""
        output = """78"""
        self.assertIO(input, output)
    def test_入力例_3(self):
        input = """1"""
        output = """0"""
        self.assertIO(input, output)

if __name__ == "__main__":
    unittest.main()
Problem p03485 (python)

Fixed submission:
import math
print(math.ceil(sum([int(i) for i in input().split()])/2))

Buggy submission (verdict: Runtime Error):
import math
print(math.ceil(sum([int(i) for i in input.split()])/2))
Problem p02607 (python)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
ans = 0
for i in range(0,n,2):
  if a[i]&1:
    ans+=1
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
ans = 0
for i in range(0,n,2):
	if a[i]&1:
	ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
ans = 0
for i in range(0,n,2):
if a[i] % 2 != 0:
ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
ans = 0
for i in range(0,n,2):
if a[i]&1:
ans += 1
print(ans)
Problem p02612 (python)

Fixed submission:
N = int(input())
if N%1000 == 0:
	print(0)
else:
	print((N//1000 + 1)*1000-N)

Buggy submission (verdict: Runtime Error):
N=int(iput())
print(N%1000)
Problem p03323 (python)

Fixed submission:
a,b = map(int, input().split())
if a>=9 or b>=9:
  print(':(')
else:
  print('Yay!')

Buggy submission (verdict: Runtime Error):
a,b = int(input().split())
if a>=9 or b>=9:
  print(':(')
else:
  print('Yay!')

Buggy submission (verdict: Runtime Error):
a,b = map(int, intput().split())
if a>=9 or b>=9:
  print(':(')
else:
  print('Yay!')

Buggy submission (verdict: Runtime Error):
a,b = int(intput().split())
if a>=9 or b>=9:
  print(':(')
else:
  print('Yay!')
Problem p02717 (python)

Fixed submission:
import sys

sys.setrecursionlimit(10 ** 7)
r1 = sys.stdin.readline


def solve():
    x, y, z = map(int, r1().split())
    print(z, x, y)
    


if __name__ == '__main__':
    solve()

Buggy submission (verdict: Runtime Error):
import sys

sys.setrecursionlimit(10 ** 7)
rl = sys.stdin.readline


def solve():
    x, y, z = map(int, rl().sprit())
    print(z, x, y)
    

if __name__ == '__main__':
    solve()
Problem p02861 (python)

Fixed submission:
from math import factorial
from itertools import permutations

n = int(input())
x, y = [0] * n, [0] * n
for i in range(n):
    x[i], y[i] = map(int, input().split())

dist_sum = 0
for route in permutations(range(n), n):
    for j in range(1, n):
        dist = (x[route[j]] - x[route[j - 1]]) ** 2
        dist += (y[route[j]] - y[route[j - 1]]) ** 2
        dist = dist ** 0.5
        dist_sum += dist
ans = dist_sum / factorial(n)
print(ans)

Buggy submission (verdict: Runtime Error):
from math import factorial
from itertools import permutations

n = int(input())
x, y = [0] * n, [0] * 
for i in range(n):
    x[i], y[i] = map(int, input().split())

dist_sum = 0
for route in permutations(range(n), n):
    for j in range(1, n):
        dist = (x[route[j]] - x[route[j - 1]]) ** 2
        dist += (y[route[j]] - y[route[j - 1]]) ** 2
        dist = dist ** 0.5
        dist_sum += dist
ans = dist_sum / factorial(n)
print(ans)
Problem p02755 (python)

Fixed submission:
A,B = map(int,input().split())

ans = -1

for i in range(10000,-1,-1):
    tax1 = int(i * 0.08)
    tax2 = int(i * 0.10)
    if tax1 == A and tax2 == B:
        ans = i

print(ans)

Buggy submission (verdict: Runtime Error):
import sys

A,B = map(float,input().split())

val_1 = A / 0.08
val_2 = B / 0.10

i = 1

if int(val_1) == int(val_2):
    print(int(val_1))
    sys.exit()
else:
    if val_1 > val_2:
        while val_1 != val_2:
            val_2 = (B + 0.1*i)/0.1
            i += 1
            if val_1 < val_2:
				print(-1)
				sys.exit()
		print(int(val_1))
	elif val_1 < val_2:
        while val_1 != val_2:
            val_1 = (A + 0.1*i)/0.1
            i += 1
            if val_1 > val_2:
                print(-1)
                sys.exit()
        print(int(val_1))

Buggy submission (verdict: Runtime Error):
import sys

A,B = map(float,input().split())

val_1 = A / 0.08
val_2 = B / 0.10

i = 1

if int(val_1) == int(val_2):
    print(int(val_1))
    sys.exit()

else:
    while val_1 != val_2:
	val_2 = (B + 0.1*i)/0.1
	i += 1
	if val_1 < val_2:
            print(-1)
            sys.exit()

print(int(val_1))
Problem p02761 (python)

Fixed submission:
import sys

n,m = map(int, input().split())
num = [0]*n
count = [0]*n

for _ in range(m):
    b,c = map(int, input().split())
    if num[b-1] != c and count[b-1] > 0:
        print(-1)
        sys.exit()
    count[b-1]+=1
    num[b-1] = c    

if n == 3 and num[0] == 0 and count[0] == 0:
    num[0] = 1
elif n == 3 and num[0] == 0 and count[0]>0:
    print(-1)
    sys.exit()
elif n == 2 and num[0] == 0 and count[0] == 0:
    num[0] = 1
elif n == 2 and num[0] == 0 and count[0] >  0:
    print(-1)
    sys.exit()

ans = ""
for i in range(n):
    ans+=str(num[i])
print(ans)

Buggy submission (verdict: Runtime Error):
bingo = []
for _ in range(3):
    bingo.append(list(map(int,input().split())))

cl = [[0,0,0],[0,0,0],[0,0,0]]

n = int(input())
st = set()
for _ in range(n):
    st.add(int(input()))

for _ in range(len(st)):
    for i in range(3):
        for j in range(3):
            if bingo[i][j] in st:
                cl[i][j] = 1

if sum(cl[0]) == 3 or sum(cl[1]) == 3 or sum(cl[2]) == 3:
    print('Yes')
elif sum(cl[:][0]) == 3 or sum(cl[:][1]) == 3 or sum(cl[:][2]) == 3:
    print('Yes')
elif cl[0][0]+cl[1][1]+cl[2][2] == 3 or cl[0][2]+cl[1][1]+cl[0][2] == 3:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
bingo = []
for _ in range(3):
    bingo.append(list(map(int,input().split())))

cl = [[0,0,0],[0,0,0],[0,0,0]]

n = int(input())
st = set()
for _ in range(n):
    st.add(int(input()))

for _ in range(len(st)):
    for i in range(3):
        for j in range(3):
            if bingo[i][j] in st:
                cl[i][j] = 1

if sum(cl[0]) == 3 or sum(cl[1]) == 3 or sum(cl[2]) == 3:
    print('Yes')
elif sum(cl[:][0]) == 3 or sum(cl[:][1]) == 3 or sum(cl[:][2]) == 3:
    print('Yes')
elif cl[0][0]+cl[1][1]+cl[2][2] == 3 or cl[0][2]+cl[1][1]+cl[0][2] == 3:
    print('Yes')
else:
    print('No')
Problem p03281 (python)

Fixed submission:
n = int(input())

def solve(num):
    cnt = 0
    for i in range(1,num+1):
        if num % i == 0:
            cnt += 1
    return cnt

ans = 0
for i in range(1,n+1):
    if i % 2 == 0:
        continue
    if solve(i) == 8:
        ans += 1

print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())

def solve(num):
    cnt = 0
    for i in range(1,num+1):
        if num % i == 0:
            cnt += 1
    return cnt

ans = 0
for i in range(1,n+1):
    if i % 2 == 0:
        continue
    if solve(i) == 8:
        ans += 1

print(ans
Problem p03337 (python)

Fixed submission:
a, b = map(int, raw_input().split())
print max(a * b, a - b, a + b)

Buggy submission (verdict: Runtime Error):
a, b = map(int, raw_input().split())
print max(a * b, a - b, a + b)
Problem p03386 (python)

Fixed submission:
a, b, k = map(int, raw_input().split())
if (b - a + 1)/2 >= k:
	for i in range(a, a + k):
		print i
	for i in range(b - k + 1,b + 1):
		print i
else :
	for i in range(a, b + 1):
		print i

Buggy submission (verdict: Runtime Error):
a, b, k = map(int, raw_input().split())
list = []
for i in range(a, b+1):
	list += [i]
list.sort()
if (b - a + 1)/2 > k:
	for i in range(0, k):
		print list[i]
	for i in range(b-a-k+1,b-a+1):
		print list[i]
else :
	for i in range(0, b-a+1):
		print list[i]

Buggy submission (verdict: Runtime Error):
a, b, k = map(int, raw_input().split())
list = []
for i in range(a, b+1):
	list += [i]
list.sort()
for i in range(0, k):
	print list[i]
for i in range(b-a-k+1,b-a+1):
	print list[i]
Problem p02573 (python)

Fixed submission:
import sys
sys.setrecursionlimit(10**6)
N,M = map(int,input().split())

class Union_Find():

    def __init__(self,n):
        self.n = n
        self.root = [-1]*(n+1)
        self.rank = [0]*(n+1)

    def find_root(self,x):
        if self.root[x]<0:
            return x
        else:
            self.root[x] = self.find_root(self.root[x])
            return self.root[x]

    def unite(self,x,y):
        x = self.find_root(x)
        y = self.find_root(y)

        if x==y:
            return
        elif self.rank[x]>self.rank[y]:
            self.root[x]+=self.root[y]
            self.root[y]=x
        else:
            self.root[y]+=self.root[x]
            self.root[x]=y

            if self.rank[x]==self.rank[y]:
                self.rank[y]+=1

    def same(self,x,y):
        return self.find_root(x)==self.find_root(y)

    def cnt(self,x):
        return -self.root[self.find_root(x)]

G=Union_Find(N)
ans=0
for i in range(M):
    a,b=map(int,input().split())
    G.unite(a,b)

for i in range(1,N+1):
    ans = max(ans,G.cnt(i))
print(ans)

Buggy submission (verdict: Runtime Error):
N,M = map(int,input().split())
G = [[] for i in range(N)]
for i in range(M):
    a,b = map(int,input().split())
    a-=1
    b-=1
    G[a].append(b)
    G[b].append(a)

chk = [0 for i in range(N)]
L = [0 for i in range(N)]
def search(G,v,cnt,L,chk):
    chk[v]=1
    L[v]=cnt
    for tmp in G[v]:
        if chk[tmp]!=0:
            continue
        search(G,tmp,cnt,L,chk)

cnt = 0
for i in range(N):
    if chk[i]!=0:
        continue
    cnt += 1
    search(G,i,cnt,L,chk)

ans = 0

for c in range(cnt):
    res = 0
    for i in range(N):
        if (c+1)==L[i]:
            res +=1
    ans =max(ans,res)

print(ans)
Problem p02612 (python)

Fixed submission:
N=int(input())
S=str(N)
s = ""
if N <1000:
    ans = 1000 - N
    print(ans)
    exit()
for i in range(3):
    s = S[len(S)-1-i] + s

n = int(s)
ans = 1000 - n
if ans == 1000:
    ans = 0

print(ans)

Buggy submission (verdict: Runtime Error):
N=int(input())
S=str(N)
s = ""
for i in range(3):
    s = S[len(S)-1-i] + s

n = int(s)
ans = 1000 - n
if ans == 1000:
    ans = 0

print(ans)
Problem p02702 (python)

Fixed submission:
S=input()
N=len(S)
#「連続する区間」についての問題では、”累積和的なもの”をとるのが定石である。
#Sの連続する区間が、右からa文字分から、右からb文字分を取り除いたものであるとき
#その区間の整数が2019の倍数になるということは、s[a]とs[b]を2019で割ったあまりが等しい
#十分条件であることは分かったが、必要条件であるのか
#結論として必要条件でもある
#なぜなら2019と10は互いに素であるからである。

T=[]
T.append(0)
tmp=""
d=[0 for _ in range(2019)]
d[0]=1
r=0
t=1
for i in range(N):
    s=S[N-1-i]
    r+=int(s)*t
    r%=2019
    t*=10
    t%=2019 
    d[r]+=1

ans=0

print(sum(i*(i-1)//2 for i in d))

Buggy submission (verdict: Runtime Error):
S=input()
N=len(S)

U=[]
for i in range(N):
    U.append(S[i:])
ans=0
for i in range(N):
    l=U[len(U)-1-i]
    cnt=5
    while(1):
        if (cnt)>len(l):
            break
        tmp=l[:cnt]
        if int(tmp)%2019==0:
            ans+=1
        cnt+=1

print(ans)

Buggy submission (verdict: Runtime Error):
S=input()
N=len(S)

U=[]
for i in range(N):
    U.append(S[i:])
ans=0
for i in range(N):
    l=U[len(U)-1-i]
    cnt=4
    while(1):
        if cnt>=len(l):
            break
        tmp=l[:cnt+1]
        if int(tmp)%2019==0:
            ans+=1
        cnt+=1

print(ans)