Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
n,k = map(int, input().split())
s = []
ans = 0
rangecounter = 0
for i in range(k-1):
  d = int(input())
  rangecounter += d
  for j in range(d):
    s.append(input().split())
for i in range(1,rangecounter):
  if s.count(i) == 0:
    ans += 1
print(ans)

Fixed submission:
n , k = map(int,input().split())
ans = [0] * n
for i in range(k):
  d = int(input())
  for j in list(map(int,input().split())):
    ans[j-1] = 1
print(ans.count(0))

Buggy python submission (verdict: Runtime Error):
n,k = map(int, input().split())
s = []
ans = 0
rangecounter = 0
for i in range(k-1):
  d = int(input())
  rangecounter += d
  for j in range(d):
    s.append(input().split())
for i in range(rangecounter):
  if s.count(i) == 0:
    ans += 1
print(ans)

Fixed submission:
n , k = map(int,input().split())
ans = [0] * n
for i in range(k):
  d = int(input())
  for j in list(map(int,input().split())):
    ans[j-1] = 1
print(ans.count(0))

Buggy python submission (verdict: Runtime Error):
n,k = map(int, input().split())
s = []
ans = 0
for i in range(k-1):
  d = int(input())
  for j in range(d):
    s.append(input().split())
for i in range(1,k):
  if s.count(i) == 0:
    ans += 1
print(ans)

Fixed submission:
n , k = map(int,input().split())
ans = [0] * n
for i in range(k):
  d = int(input())
  for j in list(map(int,input().split())):
    ans[j-1] = 1
print(ans.count(0))

Buggy python submission (verdict: Runtime Error):
n,k = map(int, input().split())
s = []
ans = 0
for i in range(k-1):
  d = int(input())
  for j in range(d):
    s.append(input().split())
for i in range(k-1):
  if s.count(i) == 0:
    ans += 1
print(ans)

Fixed submission:
n , k = map(int,input().split())
ans = [0] * n
for i in range(k):
  d = int(input())
  for j in list(map(int,input().split())):
    ans[j-1] = 1
print(ans.count(0))
Buggy python submission (verdict: Runtime Error):
x = int(input())
i = 0
while x-i % i != 0:
  i+= 1
a += i
b += x - i
print(a,b)

Fixed submission:
x = int(input())
for i in range(-500,500):
  for j in range(-500,500):
    a = pow(i,5)
    b = pow(j,5)
    if(x == a - b):
      print(i,j)
      exit(0)
Buggy python submission (verdict: Runtime Error):
k = int(input())
a,b = map(int,input().split())
for i in range(a,b):
  if i % k == 0:
    ans = 'OK'
    break
  else:
    ans = 'NG'
print(ans)

Fixed submission:
k = int(input())
a, b = map(int, input().split())
p = a % k
q = k - p
if (p == 0) or ((a + q) <= b):
    print('OK')
else:
    print('NG')

Buggy python submission (verdict: Runtime Error):
k = int(input())
a,b = map(int,input().split())
for i in range(a,b):
  if i % k == 0:
    ans = 'OK'
  else:
    ans = 'No'
print(ans)

Fixed submission:
k = int(input())
a, b = map(int, input().split())
p = a % k
q = k - p
if (p == 0) or ((a + q) <= b):
    print('OK')
else:
    print('NG')

Buggy python submission (verdict: Runtime Error):
k = int(input())
a,b = map(int,input().split())
for i in range(a,b):
  if i % k == 0:
    ans = 'OK'
    break
  else:
    ans = 'No'
print(ans)

Fixed submission:
k = int(input())
a, b = map(int, input().split())
p = a % k
q = k - p
if (p == 0) or ((a + q) <= b):
    print('OK')
else:
    print('NG')
Buggy python submission (verdict: Runtime Error):
a,b,n = map(int, input().split())
for i in range(b-1):
  tmp = (a*i) // b - a*(i // b)
  ans = 0
  ans = max(tmp,ans)
print(ans)

Fixed submission:
import math
a, b, n = map(int, input().split())
x = min(b-1, n)
print(math.floor(a*x/b)-a*math.floor(x/b))
Buggy python submission (verdict: Runtime Error):
n = int(input)
ans = len(set([input() for _ in range(n)]))
print(ans)

Fixed submission:
n = int(input())
ans = len(set([input() for _ in range(n)]))
print(ans)

Buggy python submission (verdict: Runtime Error):
n = int(input())
s = [input() for i in range(n-1)]
a = []
index = a.find(s[i])
for i in range(n-1):
	if index = -1:
         a.append(i)
print(len(s[i])


Fixed submission:
n = int(input())
ans = len(set([input() for _ in range(n)]))
print(ans)
Buggy python submission (verdict: Runtime Error):
mod = 10**9+7
n, k = map(int, input().split())

ans = 0

for i in range(k, n+1):
    ans += i*(n-i+1)
    ans %= MOD

print(ans)



Fixed submission:
mod = 10**9+7
n, k = map(int, input().split())

ans = 0

for i in range(k, n+1):
    ans += i*(n-i+1)+1

print(ans%mod+1)
Buggy python submission (verdict: Runtime Error):
List = [int(input()) for i in range(n)]
if(List.index(7)) print('Yes'):
  else: print('No')

Fixed submission:
a, b, c = input()  # 1234を整数(int)型ではなく、文字列(str)型で変数に格納する
if(a=="7" or b=="7" or c=="7"): print("Yes")
elif( a=="7" and b=="7"): print("Yes")
elif( c=="7" and b=="7"): print("Yes")
elif( c=="7" and a=="7"): print("Yes")
elif(a=="7" and b=="7" and c=="7"): print("Yes")
else:print("No")
Buggy python submission (verdict: Runtime Error):

n = int(input())
s = input()

kumikazu = s.count('R')*s.count('B')*s.count('G')

for i in range(n-2):
    for j in range(i+1,n-1):
        k = 2*j-i
        if k >= n:
          if (s[i] != s[j]) and (s[i] != s[k]) and (s[j] != s[k]):
            kumikazu -= 1

Fixed submission:
n = int(input())
s = input()

kumikazu = s.count('R')*s.count('B')*s.count('G')

for i in range(n-2):
    for j in range(i+1, n-1):
        k = 2*j-i
        if k >= n:
          break
        if (s[i] != s[j]) and (s[i] != s[k]) and (s[j] != s[k]):
                kumikazu -= 1
print(kumikazu)
Buggy python submission (verdict: Runtime Error):
n = int(input())
int i = 0
List = [input() for i in range(n)]
print(sorted(List))

Fixed submission:
n = int(input())
s = [input() for _ in range(n)]

dic={}
for i in range(n):
    if s[i] not in dic:
        dic[s[i]]=1
    else:
        dic[s[i]]+=1

largest=max(dic.values())
ans=list()

for key in dic.keys():
    if dic[key]==largest:
        ans.append(key)

ans.sort()
for answers in ans:
    print(answers)
Buggy python submission (verdict: Runtime Error):
n = int (input())
a = [input() for _ in range(n)]
if ( a(i) != a(i+1) ):
  print('Yes')
else:
  print('No')


Fixed submission:
n = int(input())
a = set(map(int, input().split()))
ans = "YES"
if len(a) != n: #setは重複させないから。
  ans = "NO"
  
print(ans)

Buggy python submission (verdict: Runtime Error):
n = int (input())
a = [input() for _ in range(n)]
if ( a(i) != a(i+1) ):
  print("Yes")
else:
  print("No")


Fixed submission:
n = int(input())
a = set(map(int, input().split()))
ans = "YES"
if len(a) != n: #setは重複させないから。
  ans = "NO"
  
print(ans)

Buggy python submission (verdict: Runtime Error):
n = int (input())
a = [input() for _ in range(n)]
if ( a(i) != a(i+1) ):
  print("Yes)
else:
  print("No")


Fixed submission:
n = int(input())
a = set(map(int, input().split()))
ans = "YES"
if len(a) != n: #setは重複させないから。
  ans = "NO"
  
print(ans)
Buggy python submission (verdict: Runtime Error):
a, b = map(int, input().split())
ans = 6
print(ans-(a+b))

Fixed submission:
a = int(input())
b = int(input())
ans = 6
print(ans-(a+b))
Buggy python submission (verdict: Time Limit Exceeded):
a, b = map(int, input().split())
okashi = 1
max = 10**9
for i in range(0,max):
  if okashi%a == 0 and okashi%b == 0:
    break
  else:
    okashi +=1
print(okashi)
    

Fixed submission:
a, b = map(int, input().split())
okashi = 1
max = 10**9
for i in range(0,max):
  if(a * okashi) % b == 0:
      break
  else:
    okashi +=1
print(a*okashi)
Buggy python submission (verdict: Runtime Error):
s = input()
ans = 0
for i in range(0,len(s)):
  if s[i] != s[len(s)-i-1]
    ans += 1
print(ans)

Fixed submission:
s = input()
ans = 0
for i in range(0,len(s)):
  if s[i] != s[len(s)-i-1]:
    ans += 1
print(int(ans/2))
Buggy python submission (verdict: Runtime Error):
n = int(input())
words = []
for i in range(n):
	a = int(input())
	w = []
	for _ in range(a):
		x, y = map(int, input().split())
		w.append([x-1, y])
	words.append(w)


ans = 0
for bit in range(1<<n):　#2のn乗まで捜査
	ok = True
	is_honest = [(bit>>i) & 1 for i in range(n)]
	#bitをiずらして末尾が1のひとは正直
	for i in range(n):
		if not is_honest[i]:
			continue
		for x, y in words[i]:
			if is_honest[x] != y:
				ok = False
	if ok:
		ans = max(ans, sum(is_honest))
print(ans)


Fixed submission:
n = int(input())
words = []
for i in range(n):
	a = int(input())
	w = []
	for _ in range(a):
		x, y = map(int, input().split())
		w.append([x-1, y])
	words.append(w)


ans = 0
for bit in range(1<<n):
  #2のn乗まで捜査
	ok = True
	is_honest = [(bit>>i) & 1 for i in range(n)]
	#bitをiずらして末尾が1のひとは正直
	for i in range(n):
		if not is_honest[i]:
			continue
		for x, y in words[i]:
			if is_honest[x] != y:
				ok = False
	if ok:
		ans = max(ans, sum(is_honest))
print(ans)

Buggy python submission (verdict: Runtime Error):
import sys
def input():
	return sys.stdin.readline()[:-1]
n = int(input())
words = []
for i in range(n):
	a = int(input())
	w = []
	for _ in range(a):
		x, y = map(int, input().split())
		w.append([x-1, y])
	words.append(w)


ans = 0
for bit in range(1<<n):　#2のn乗まで捜査
	ok = True
	is_honest = [(bit>>i) & 1 for i in range(n)]
	#bitをiずらして末尾が1のひとは正直
	for i in range(n):
		if not is_honest[i]:
			continue
		for x, y in words[i]:
			if is_honest[x] != y:
				ok = False
	if ok:
		ans = max(ans, sum(is_honest))
print(ans)


Fixed submission:
n = int(input())
words = []
for i in range(n):
	a = int(input())
	w = []
	for _ in range(a):
		x, y = map(int, input().split())
		w.append([x-1, y])
	words.append(w)


ans = 0
for bit in range(1<<n):
  #2のn乗まで捜査
	ok = True
	is_honest = [(bit>>i) & 1 for i in range(n)]
	#bitをiずらして末尾が1のひとは正直
	for i in range(n):
		if not is_honest[i]:
			continue
		for x, y in words[i]:
			if is_honest[x] != y:
				ok = False
	if ok:
		ans = max(ans, sum(is_honest))
print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
s = inuput()
alfha = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
ans = ''
for i in s:
  a += alfha[(alfha.index(i)+n) % 26]
print(ans)

Fixed submission:
n = int(input())
s = input()
alfha = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
ans = ''
for i in s:
  ans += alfha[(alfha.index(i)+n) % 26]
print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
s = input()
t = n/2
for i in range(n-1):
  if s[:int(n/2)]==s[int(n/2):]:
	  ans = ('Yes')
  else:
	  ans = ('No')
print(ans)

Fixed submission:
n = int(input())
s = input()

if n % 2 != 0: 
  print('No')
elif s[:int(n/2)] == s[int(n/2):]: 
  print('Yes')
else: 
  print('No')

Buggy python submission (verdict: Runtime Error):
n = int(input())
s = input()
t = n/2
for i in range(n-1):
  if s[:int(n/2)]==s[int(n/2):]:　#コロンで分断
	  ans = ('Yes')
  else:
	  ans = ('No')
print(ans)

Fixed submission:
n = int(input())
s = input()

if n % 2 != 0: 
  print('No')
elif s[:int(n/2)] == s[int(n/2):]: 
  print('Yes')
else: 
  print('No')
Buggy python submission (verdict: Runtime Error):
n,k,q = map(int,input().split())
A = []
for i range in(q):
  a = int(input())
  A.append(a)
point = [k - q]*n

for i range(q):
  tmp = A[i] - 1
  point[tmp] += 1

for i in range(n):
    if point[i] > 0:
        print("Yes")
    else:
        print("No")


Fixed submission:
n,k,q = map(int,input().split())
A = []
for i in range (q):
  a = int(input())
  A.append(a)
point = [k - q]*n

for i in range(q):
  tmp = A[i] - 1
  point[tmp] += 1

for i in range(n):
    if point[i] > 0:
        print("Yes")
    else:
        print("No")
Buggy python submission (verdict: Runtime Error):
a,b = map(int, input().split())

ans = 0
A = 1
while A < b:
  ans += 1
  s += (a - 1)
print(ans)


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

ans = 0
A = 1
while A < b:
  ans += 1
  A += (a - 1)
print(ans)

Buggy python submission (verdict: Runtime Error):
a,b = map(int, input().split())

ans = 0
A  = 1
while A < b:
  ans += 1
  s += a - 1
print(ans)


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

ans = 0
A = 1
while A < b:
  ans += 1
  A += (a - 1)
print(ans)
Buggy python submission (verdict: Runtime Error):
a,b,c = map(int,input().split())
if(b+c >= a):
print(b+c-a)
else:
  print(0)

Fixed submission:
a,b,c = map(int,input().split())
if(b+c >= a):
  print(b+c-a)
else:
  print(0)
Buggy python submission (verdict: Runtime Error):
a,b = map(int,input().split)
if((a + b) % 2 == 0):
    print((a + b) / 2)
else:
    print('IMPOSSIBLE')

Fixed submission:
a,b = map(int,input().split())
if((a + b) % 2 == 0):
    print((a + b) // 2)
else:
    print('IMPOSSIBLE')
Buggy python submission (verdict: Runtime Error):
List = list(map(int, input().split()))
ans = 'YES'
for i in List:
  if(List[i] != List[i+1]):
    ans = 'NO'
    break
print(ans)

Fixed submission:
n = int(input())
s = list(map(int,input().split()))
t = 0
for i in range(n):
  s.append(i)

for i in range(n):
  if(s[i] == i + 1):
    t += 0
  else:
    t += 1
if(t == 0 or t == 2):
  print('YES')
else:
  print('NO')
Buggy python submission (verdict: Runtime Error):
n, d = map(int, input().split())
  while((2 * (d + i) + 1) * 2 >= n):
print((2 * d + n) / (2 * d + 1))



Fixed submission:
n, d = map(int, input().split())
print((2 * d + n) // (2 * d + 1))
Buggy python submission (verdict: Time Limit Exceeded):
l,r = map(int,input().split())
ans = 100000000000000000
for i in range(l,r):
  for j in range(l+1,r+1):
    ans = min(ans,(i*j) % 2019)
    if((i*j) % 2019 == 0):
      break
print(ans)

Fixed submission:
l,r = map(int,input().split())
if r-l >= 2019:
    print(0)
else:
    r1 = r % 2019
    l1 = l % 2019
    if l1 > r1:
        print(0)
    else:
        ans = 2019
        for i in range(l1, r1):
            for j in range(i + 1, r1 + 1):
                ans = min(ans, (i*j) % 2019)
        print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
l,r = map(int,input().split())
ans = 100000000000000000
for i in range(l,r):
  for j in range(l+1,r+1):
    ans = min(ans,(i*j) % 2019)
print(ans) 

Fixed submission:
l,r = map(int,input().split())
if r-l >= 2019:
    print(0)
else:
    r1 = r % 2019
    l1 = l % 2019
    if l1 > r1:
        print(0)
    else:
        ans = 2019
        for i in range(l1, r1):
            for j in range(i + 1, r1 + 1):
                ans = min(ans, (i*j) % 2019)
        print(ans)
Buggy python submission (verdict: Runtime Error):
s = input()
ans =='Yes'
if(s[0] == s[1] and s[2] == s[3]):
  ans =='Yes'
elif(s[0] == s[3] and s[1] == s[2]):
  ans =='Yes'
elif(s[0] == s[2] and s[1] == s[3]):
  ans =='Yes'
else:
  ans =='No'

if(s[0] == s[1] and s[1] == s[2] and s[2] == s[3]):
  ans =='No'
print(ans)


Fixed submission:
s = input()
ans ='Yes'
if(s[0] == s[1] and s[2] == s[3]):
  ans ='Yes'
elif(s[0] == s[3] and s[1] == s[2]):
  ans ='Yes'
elif(s[0] == s[2] and s[1] == s[3]):
  ans ='Yes'
else:
  ans ='No'

if(s[0] == s[1] and s[1] == s[2] and s[2] == s[3]):
  ans ='No'
print(ans)
Buggy python submission (verdict: Runtime Error):
n , l = map(int, input().split())
L = []

for i in range(n):
    L.append(i+l)

if L[0] > 0:
    print(sum(L[1:]))
elif L[0] <=0 and L[-1] >= 0:
    print(sum(L))
else:
    print(sum([:-1]))


Fixed submission:
n , l = map(int, input().split())
L = []

for i in range(n):
    L.append(i+l)

if L[0] > 0:
    print(sum(L[1:]))
elif L[0] <=0 and L[-1] >= 0:
    print(sum(L))
else:
    print(sum(L[:-1]))

Buggy python submission (verdict: Runtime Error):
n,l = map(int, input().split())
L = [0]*n
#l+i-1
for i in range(n):
  L[i] += l+i

if(l < 0 and n + l < 0):
  print(sum(L) - L[n-1])
elif(l =< 0 and n + l >= 0):
  print(sum(L))
else:
  print(sum(L) - L[0])


Fixed submission:
n , l = map(int, input().split())
L = []

for i in range(n):
    L.append(i+l)

if L[0] > 0:
    print(sum(L[1:]))
elif L[0] <=0 and L[-1] >= 0:
    print(sum(L))
else:
    print(sum(L[:-1]))
Buggy python submission (verdict: Runtime Error):
n = int(input())
H = list(map(int, input().split()))
ans = 0
for i in range(n):
  if(H[0] <= H[i] and H[1] <= H[i] and H[i-1] <= H[i]):
    ans += 1
print(ans)


Fixed submission:
n = int(input())
H = list(map(int, input().split()))
ans = 0
t = 0

for i in range(n):
  t = max(t,H[i])
  if(t == H[i]):
    ans += 1
print(ans)
Buggy python submission (verdict: Runtime Error):
d = int(input())
if(d == 22):
  print(Christmas Eve Eve Eve)
elif(d == 23):
  print(Christmas Eve Eve)
elif(d == 24):
  print(Christmas Eve)
else:
  print(Christmas)


Fixed submission:
d = int(input())
if(d == 22):
  print('Christmas Eve Eve Eve')
elif(d == 23):
  print('Christmas Eve Eve')
elif(d == 24):
  print('Christmas Eve')
else:
  print('Christmas')
Buggy python submission (verdict: Runtime Error):
n=input()
if(n%2==0):
print(n)
else:
  print(2＊n)


Fixed submission:
n = int(input())
if n%2==0:
    print(n)
else:
    print(2*n)
Buggy python submission (verdict: Runtime Error):
a = int(input().split())
b = int(input().split())
h = int(input().split())
print(((a+b)*h)//2)

Fixed submission:
a = int(input())
b = int(input())
h = int(input())
print(((a+b)*h)//2)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int, input().split()))
q=int(input())
bc=[]

for i in range (q):
    bc.append(list(map(int, input().split())))
num=[0]*(10**5+1)
for i in range(n):
    x=a[i]
    num[x]+=1


for k in range (q):
    b=bc[k][0]
    c=bc[k][1]
    num[c]+=num[b]
    num[b]=0
    kk=0
    for l in range(10**5+1):
        kk+=l*num[l]
    print(kk)

Fixed submission:
n=int(input())
a=list(map(int, input().split()))
q=int(input())
bc=[]

for i in range (q):
    bc.append(list(map(int, input().split())))
num=[0]*(10**5+1)
for i in range(n):
    x=a[i]
    num[x]+=1

kk=0
for l in range(10**5+1):
    kk+=l*num[l]

for k in range (q):
    b=bc[k][0]
    c=bc[k][1]
    kk+=c*num[b]-b*num[b]
    num[c]+=num[b]
    num[b]=0
    print(kk)
Buggy python submission (verdict: Runtime Error):
x,n=list(map(int, input().split()))
if n!=0:
    p=list(map(int, input().split()))
d=0
t=0
while t==0:
    if (x-d) not in p:
        print (x-d)
        t=1
    elif (x+d) not in p:
        print (x+d)
        t=1
    else:
        d+=1



Fixed submission:
x,n=list(map(int, input().split()))
if n!=0:
    p=list(map(int, input().split()))
d=0
t=0
if n==0:
    print(x)
if n!=0:
    while t==0:
        if (x-d) not in p:
            print (x-d)
            t=1
        elif (x+d) not in p:
            print (x+d)
            t=1
        else:
            d+=1
Buggy python submission (verdict: Runtime Error):
n=int(input())
a=list(map(int, input().split()))
b=[0]*n
c=[0]*n
for i in range(n):
    b[i]=a[i]+i
    c[i]=i-a[i]
bs=sorted(b)
cs=sorted(c)
lx=[1+10**10]*n
ly=[2+10**10]*n
rx=[3+10**10]*n
ry=[4+10**10]*n

lx[0]=1
ly[0]=bs[0]
rx[0]=1
ry[0]=cs[0]

d=0
e=0
for j in range (1,n):
    if bs[j]==bs[j-1]:
        lx[d]+=1
    else:
        d+=1
        lx[d]=1
        ly[d]=bs[j]
        
for k in range (1,n):
    if cs[k]==cs[k-1]:
        rx[e]+=1
    else:
        e+=1
        rx[e]=1
        ry[e]=cs[k]
x=0
ans=0
for l in range(d):
    while ry[x]<=ly[l]:
        if ry[x]==ly[l]:
            ans+=(lx[l]*rx[x])
            x+=1
        else:
            x+=1
print(ans)


Fixed submission:
n=int(input())
a=list(map(int, input().split()))
b=[0]*n
c=[0]*n
for i in range(n):
    b[i]=a[i]+i
    c[i]=i-a[i]
bs=sorted(b)
cs=sorted(c)
lx=[1+10**10]*n
ly=[2+10**10]*n
rx=[3+10**10]*n
ry=[4+10**10]*n

lx[0]=1
ly[0]=bs[0]
rx[0]=1
ry[0]=cs[0]

d=0
e=0
for j in range (1,n):
    if bs[j]==bs[j-1]:
        lx[d]+=1
    else:
        d+=1
        lx[d]=1
        ly[d]=bs[j]
        
for k in range (1,n):
    if cs[k]==cs[k-1]:
        rx[e]+=1
    else:
        e+=1
        rx[e]=1
        ry[e]=cs[k]
x=0
ans=0
for l in range(d):
    while ry[x]<=ly[l] and x<n-1:
        if ry[x]==ly[l]:
            ans+=(lx[l]*rx[x])
            x+=1
        else:
            x+=1
print(ans)
Buggy python submission (verdict: Runtime Error):
s=str(input())
n=len(s)
k=[0]*(n+1)
for i in range (1,n+1):
    k[i]=int(s[i-1])
t=[0]*(n+1)
t[0]=0  
for i in range(1,n+1):
    t[i]=(10*t[i-1]+k[i])%2019

p=1
q=[0]*448
for z in range(0,448):
    q[z]=p%2019
    p=10*q[z]

d=[0]*n   
for j in range(1,n+1):
    f=j%448
    d[j-1]=q[n-f]*t[j]%2019
ds=sorted(d)
ct=0
ans=0
if ds[0]==0:
    ct=1
    ans=1
for i in range(n-1):
    if ds[i+1]==ds[i]:
        ct+=1
        ans+=ct
    else:
        ct=0
print(ans)



Fixed submission:
s=str(input())
n=len(s)
k=[0]*(n+1)
for i in range (1,n+1):
    k[i]=int(s[i-1])
t=[0]*(n+1)
t[0]=0  
for i in range(1,n+1):
    t[i]=(10*t[i-1]+k[i])%2019

p=1
q=[0]*448
for z in range(0,448):
    q[z]=p%2019
    p=10*q[z]

d=[0]*n   
for j in range(1,n+1):
    f=(n-j)%448
    d[j-1]=q[f]*t[j]%2019
ds=sorted(d)
ct=0
ans=0
if ds[0]==0:
    ct=1
    ans=1
for i in range(n-1):
    if ds[i+1]==ds[i]:
        ct+=1
        ans+=ct
    else:
        ct=0
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
s=str(input())
n=len(s)
k=[0]*(n+1)
for i in range (1,n+1):
    k[i]=int(s[i-1])
t=[0]*(n+1)
t[0]=0  
for i in range(1,n+1):
    t[i]=(10*t[i-1]+k[i])%2019

p=1
q=[0]*448
for z in range(0,448):
    q[z]=p%2019
    p=10*q[z]

d=0    
for j in range(n+1):
    for l in range (j):
        f=(j-l)%448
        if (t[l]*q[f]-t[j])%2019==0:
            d+=1
            
print(d)

Fixed submission:
s=str(input())
n=len(s)
k=[0]*(n+1)
for i in range (1,n+1):
    k[i]=int(s[i-1])
t=[0]*(n+1)
t[0]=0  
for i in range(1,n+1):
    t[i]=(10*t[i-1]+k[i])%2019

p=1
q=[0]*448
for z in range(0,448):
    q[z]=p%2019
    p=10*q[z]

d=[0]*n   
for j in range(1,n+1):
    f=(n-j)%448
    d[j-1]=q[f]*t[j]%2019
ds=sorted(d)
ct=0
ans=0
if ds[0]==0:
    ct=1
    ans=1
for i in range(n-1):
    if ds[i+1]==ds[i]:
        ct+=1
        ans+=ct
    else:
        ct=0
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
s=str(input())
n=len(s)
k=[0]*(n+1)
for i in range (1,n+1):
    k[i]=int(s[i-1])
t=[0]*(n+1)
t[0]=0  
for i in range(1,n+1):
    t[i]=(10*t[i-1]+k[i])%2019

p=1
q=[0]*200000
for z in range(0,200000):
    q[z]=p%2019
    p=10*q[z]

d=0    
for j in range(n+1):
    for l in range (j):
        f=j-l
        if (t[l]*q[f]-t[j])%2019==0:
            d+=1
            
print(d)


Fixed submission:
s=str(input())
n=len(s)
k=[0]*(n+1)
for i in range (1,n+1):
    k[i]=int(s[i-1])
t=[0]*(n+1)
t[0]=0  
for i in range(1,n+1):
    t[i]=(10*t[i-1]+k[i])%2019

p=1
q=[0]*448
for z in range(0,448):
    q[z]=p%2019
    p=10*q[z]

d=[0]*n   
for j in range(1,n+1):
    f=(n-j)%448
    d[j-1]=q[f]*t[j]%2019
ds=sorted(d)
ct=0
ans=0
if ds[0]==0:
    ct=1
    ans=1
for i in range(n-1):
    if ds[i+1]==ds[i]:
        ct+=1
        ans+=ct
    else:
        ct=0
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
k=int(input())
import math
d=0
for a in range(1,k+1):
    for b in range (1,k+1):
        for c in range (1,k+1):
            f=math.gcd(a,b)
            g=math.gcd(f,c)
            d+=g
print(d)

Fixed submission:
k=int(input())
import math
d=0
for a in range(1,k+1):
    for b in range (1,k+1):
        f=math.gcd(a,b)
        for c in range (1,k+1):
            g=math.gcd(f,c)
            d+=g
print(d)