Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,sqrt
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7
#s=input().rstrip()

n,K=MI()
ls=sorted(LI(),reverse=True)
ans=0
for i in range(k):
    ans+=ls[i]
print(ans)

Fixed submission:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,sqrt
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7
#s=input().rstrip()

n,k=MI()
ls=sorted(LI(),reverse=True)
ans=0
for i in range(k):
    ans+=ls[i]
print(ans)
Buggy python submission (verdict: Runtime Error):
#dpでできないかな？
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi,factorial
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

n=I()
s=SI()
i=0
state=1
count=0
l=[];r=[]
for i in range(n):
    if state==1:
        if s[i]=="(":
            count+=1
        elif s[i]==")":
            l.append(count)
            state=-1
            count=1
    elif state==-1:
        if s[i]==")":
            count+=1
        elif s[i]=="(":
            r.append(count)
            state=1
            count=1
if s[-1]==")":
    r.append(count)
else:
    l.append(count)
    r.append(0)
'''print(l)
print(r)'''
minus,plus=0,0
for i in range(len(l)):
    if l[i]-r[i]<0:
        minus+=r[i]-l[i]
    else:
        plus+=l[i]-r[i]
for i in range(minus):
    print("(",end="")
print(s,end="")
for j in range(plus):
    print(")",end="")

Fixed submission:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
inf = 10**17
mod = 10**9 + 7

r,g,b=MI()
if (10*g+b)%4==0:
    print("YES")
else:
    print("NO")
Buggy python submission (verdict: Runtime Error):
# coding: utf-8
# hello worldと表示する
#dpでできないかな？
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

n=I()
lis=LI()
dic=[0 for i in range(9)]
for i in range(n):
    if lis[i]//400==8:
        dic[8]+=1
    else:
        if dic[lis[i]//400]==0:
            dic[lis[i]//400]=1
        
#print(dic)
#print(sum(dic[0:8]))
if sum(dic[0:8])==0:
    mn=1
    mx=dic[-1]
else:
    mn=sum(dic[0:8])
    mx=sum(dic[0:8])+dic[-1]
print(mn,mx)

Fixed submission:
# coding: utf-8
# hello worldと表示する
#dpでできないかな？
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

n=I()
lis=LI()
dic=[0 for i in range(9)]
for i in range(n):
    if lis[i]//400>=8:
        dic[8]+=1
    else:
        if dic[lis[i]//400]==0:
            dic[lis[i]//400]=1
        
#print(dic)
#print(sum(dic[0:8]))
if sum(dic[0:8])==0:
    mn=1
    mx=dic[-1]
else:
    mn=sum(dic[0:8])
    mx=sum(dic[0:8])+dic[-1]
print(mn,mx)
Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
inf = 10**17
mod = 10**9 + 7

x,y=MI()
if x+y>=10:
    print("error")
else:
    print(a+b)

Fixed submission:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
inf = 10**17
mod = 10**9 + 7

x,y=MI()
if x+y>=10:
    print("error")
else:
    print(x+y)
Buggy python submission (verdict: Runtime Error):
w,h,n=MI()
rect=[0,w,0,h]
for i in range(n):
    a,b,c=MI()
    if c<=2:
        rect[c-1]=a
    else:
        rect[c-1]=b
#print(rect)
print(max(0,rect[3]-rect[2])*max(0,rect[1]-rect[0]))

Fixed submission:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7
#s=input().rstrip()

w,h,n=MI()
rect=[0,w,0,h]
for i in range(n):
    a,b,c=MI()
    if c==1:
        rect[0]=max(a,rect[0])
    elif c==2:
        rect[1]=min(a,rect[1])
    elif c==3:
        rect[2]=max(b,rect[2])
    else:
        rect[3]=min(b,rect[3])
print(max(0,rect[3]-rect[2])*max(0,rect[1]-rect[0]))
Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
inf = 10**17
mod = 10**9 + 7


a,b,h=MI()
ans=(a+b)*h//2
print(ans)

Fixed submission:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
inf = 10**17
mod = 10**9 + 7


a=I()
b=I()
h=I()
ans=(a+b)*h//2
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
#float型を許すな
#numpyはpythonで
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi,factorial
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

n=I()
ans=0
lis=[I() for i in range(n)]
ind =[0 for i in range(n)]
for i in range(n):
    if lis[i]==0:
        ind[i]=-1
    ans+=lis[i]//2
    lis[i]=lis[i]%2
points=[]
for i in range(n):
    if lis[i]==1:
        points.append(i)
for i in range(len(points)-1):
    x=points[i]
    y=points[i+1]
    count=0
    #print(y)
    #print(x)
    for j in range(x,y+1):
        if ind[j]==0:
            count+=1
    if count==y-x+1:
        points[i+1]=-1
        ans+=1
print(ans)





        
        
    
    
        
    
    


Fixed submission:
#float型を許すな
#numpyはpythonで
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi,factorial
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

n=I()
ans=0
lis=[I() for i in range(n)]
ind =[0 for i in range(n)]
for i in range(n):
    if lis[i]==0:
        ind[i]=-1
    ans+=lis[i]//2
    lis[i]=lis[i]%2
points=[]
for i in range(n):
    if lis[i]==1:
        points.append(i)
#print(points)
#for i in range(len(points)-1):
z=0
while z<len(points)-1:
    x=points[z]
    y=points[z+1]
    count=0
    #print(y)
    #print(x)
    for j in range(x,y+1):
        if ind[j]==0:
            count+=1
    if count==y-x+1:
        z+=1
        ans+=1
    z+=1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
cnt = 0

def divisor(n):
    i = 1
    res = set()
    while i * i <= n:
        if n % i == 0:
            res.add(i)
            res.add(n // i)
        i += 1
    return res


for c in range(1,n+1):
    k = n - c
    #print(k)
    if k >= 0:
        #print(divisor(k))
        l = len(divisor(k))
        cnt +=l

print(cnt)

Fixed submission:
n = int(input())

cnt = 0
for a in range(1,n+1):
    if n%a != 0:
        cnt +=n//a
    else:
        cnt +=n//a-1
    #print(a,n//a,cnt)
print(cnt)
Buggy python submission (verdict: Runtime Error):
a,b,c d = map(int,input().split())

print(max(a*c,b*d,b*c,a*d))

Fixed submission:
a,b,c ,d = map(int,input().split())
     
print(max(a*c,b*d,b*c,a*d))

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

print(max(a*c,b*d,b*c,a*d,0))

Fixed submission:
a,b,c ,d = map(int,input().split())
     
print(max(a*c,b*d,b*c,a*d))
Buggy python submission (verdict: Runtime Error):
n = int(input())
MOD = 10**9 + 7
ans = pow(10,n,MOD) - 2*pow(9.n,MOD) - pow(8,n,MOD)
print(ans%MOD)

Fixed submission:
n = int(input())
MOD = 10**9 + 7
ans = pow(10,n,MOD) - 2*pow(9,n,MOD) + pow(8,n,MOD)
print(ans%MOD)
Buggy python submission (verdict: Time Limit Exceeded):
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

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

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

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

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

n,m = map(int,input().split())
L = [[0]*n for i in range(n)]
li = [i+1 for i in range(n)]
uf = UnionFind(n)

for i in range(m):
    a,b = map(int,input().split())
    L[a-1][b-1] = 1
    L[b-1][a-1] = 1
    uf.union(a-1,b-1)

ans = 0
for i in range(n):
    ans = max(ans,uf.size(i))
print(ans)

Fixed submission:
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

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

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

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

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

n,m = map(int,input().split())

uf = UnionFind(n)

for i in range(m):
    a,b = map(int,input().split())
    uf.union(a-1,b-1)

ans = 0
for i in range(n):
    ans = max(ans,uf.size(i))
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())

k = 7
m = k%n
if m == 0:
    print(1)
    exit()
cnt = 1

for i in range(1,n+1):
    k = 7*10**i + k
    #print(k)
    m = k%n
    #print(m)
    if m == 0:
        print(i+1)
        exit()
print(-1)

Fixed submission:
n = int(input())

k = 7
m = k%n
if m == 0:
    print(1)
    exit()
cnt = 1

for i in range(1,n+1):
    k = (10*k + 7)%n
    m = k%n
    if m == 0:
        print(i+1)
        exit()
print(-1)
Buggy python submission (verdict: Runtime Error):
n,m,k = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
for i in range(1,n):
    a[i] += a[i-1]
for i in range(1,m):
    b[i] += b[i-1]
a = [0]+a
b = [0]+b

ans = 0
ALL = 0
j = m
B = b[j-1]

for i in range(n+1):
    ALL = a[i]
    if ALL > k:
        continue
    else:
        while k-ALL <= B :
            B =b[j-1]
            j -=1

    ans = max(ans,i+j)
print(ans)

Fixed submission:
n,m,k = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
for i in range(1,n):
    a[i] += a[i-1]
for i in range(1,m):
    b[i] += b[i-1]
a = [0]+a
b = [0]+b

ans = 0
ALL = 0
from bisect import bisect
for i in range(n+1):
    ALL = a[i]
    if ALL > k:
        continue
    else:
        idx = bisect(b,k-ALL)
    #print(i,ALL,idx)
        ans = max(ans,i+idx-1)
print(ans)

Buggy python submission (verdict: Runtime Error):
n,m,k = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
for i in range(1,n):
    a[i] += a[i-1]
for i in range(1,m):
    b[i] += b[i-1]
a = [0]+a
b = [0]+b

ans = 0
ALL = 0
from bisect import bisect
for i in range(n+1):
    ALL = a[i]
    if ALL > k:
        continue
    else:idx = bisect(b,k-ALL)
    #print(i,ALL,idx)
        ans = max(ans,i+idx-1)
print(ans)

Fixed submission:
n,m,k = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
for i in range(1,n):
    a[i] += a[i-1]
for i in range(1,m):
    b[i] += b[i-1]
a = [0]+a
b = [0]+b

ans = 0
ALL = 0
from bisect import bisect
for i in range(n+1):
    ALL = a[i]
    if ALL > k:
        continue
    else:
        idx = bisect(b,k-ALL)
    #print(i,ALL,idx)
        ans = max(ans,i+idx-1)
print(ans)
Buggy python submission (verdict: Runtime Error):
a,b = map(int,input().split())
c = b*100
print(a*c//100)

Fixed submission:
a,b = input().split()
a = int(a)
b = b.replace(".","")
print(a*int(b)//100)
Buggy python submission (verdict: Runtime Error):
s = input()

if s == "ABC":
    print("ARC")
elif s = "ARC":
    print("ABC")

Fixed submission:
s = input()

if s == "ABC":
    print("ARC")
elif s == "ARC":
    print("ABC")
Buggy python submission (verdict: Runtime Error):
def divisor(n):
    L = []
    for i in range(1,int(n**0.5)+1):
        if n%i == 0:
            L.append(i)
            L.append(n//i)
    return L
    
n = int(input())
li = sorted(divisor(n))

for i in range(len(li)):
    a = (n - (li[i])**5)**0.2
    a1 = (n - (li[i])**5)**0.2
    b1 = (n-a**5)**0.2

    a1 = round(a1)
    b1 = round(b1)
    if a1**5 - b1**5 == n:
        print(a1,b1)
        exit()
    elif a1**5 + b1**5 == n:
        print(a1,-b1)
        exit()

Fixed submission:
n = int(input())
for i in range(1,121):
    for j in range(-121,121):
        if i**5 - j**5 == n:
            print(i,j)
            exit()
Buggy python submission (verdict: Runtime Error):
S,W = map(int,input()split())
#L = list(map(int,input()split()))
if W >= S:
    print("unsafe")
else:
    print("safe ")

Fixed submission:
S,W = map(int,input().split())
#L = list(map(int,input()split()))
if W >= S:
    print("unsafe")
else:
    print("safe ")
Buggy python submission (verdict: Time Limit Exceeded):
a = input()
a = list(a)

s = 0
r = 1
l = 0
cnt = 0
while l <=len(a)-3:
    s = a[l]
    r =l
    while int(s)%2019 != 0 and r<=len(a)-2:
        #print(l,r)
        s +=a[r+1]
        if int(s)%2019 == 0:
            cnt +=1
        #print(s,cnt,l,r)   
        r += 1
    l +=1
print(cnt)

Fixed submission:
s = input()[::-1]

mod = 2019
ans = 0
d = 0
L = [0]
memo = [0]
for i in s:
    S =str(i)
    tmp = int(S)*pow(10,d,mod)%mod
    tmp = L[-1] + tmp
    L.append(tmp%mod)
    d +=1

from collections import Counter
L = Counter(L)

for v in L.values():
    ans +=v*(v-1)//2
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
a = input()
a = list(a)

s = 0
r = 1
cnt = 0
for l in range(len(a)):
    s = a[l]
    r =l
    while int(s)%2019 != 0 and r<=len(a)-2:
        #print(l,r)
        s +=a[r+1]
        if int(s)%2019 == 0:
            cnt +=1
        #print(s,cnt,l,r)   
        r += 1
    #r +=1
print(cnt)



Fixed submission:
s = input()[::-1]

mod = 2019
ans = 0
d = 0
L = [0]
memo = [0]
for i in s:
    S =str(i)
    tmp = int(S)*pow(10,d,mod)%mod
    tmp = L[-1] + tmp
    L.append(tmp%mod)
    d +=1

from collections import Counter
L = Counter(L)

for v in L.values():
    ans +=v*(v-1)//2
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
a = input()
a = list(a)

s = a[0]
r = 1
cnt = 0
for l in range(len(a)):
    r =1
    s= a[l:l+r]
    s = "".join(s)

    while int(s)%2019 != 0 and r<=len(a)-1:
        s= a[l:l+r]
        s = "".join(s)
        if int(s)%2019 == 0:
            cnt +=1
            
        r += 1
    if l == r:
        r +=1
print(cnt)


Fixed submission:
s = input()[::-1]

mod = 2019
ans = 0
d = 0
L = [0]
memo = [0]
for i in s:
    S =str(i)
    tmp = int(S)*pow(10,d,mod)%mod
    tmp = L[-1] + tmp
    L.append(tmp%mod)
    d +=1

from collections import Counter
L = Counter(L)

for v in L.values():
    ans +=v*(v-1)//2
print(ans)
Buggy python submission (verdict: Runtime Error):
r = int(input())
print(2*r*3. 141592653)

Fixed submission:
r = int(input())
print(2*r*3.141592653)
Buggy python submission (verdict: Time Limit Exceeded):
k = int(input())
k = [int(x)+1 for x in range(k)]
#print(k)
from fractions import gcd
from itertools import product,combinations
from functools import reduce
num = 0

for v in product(k,repeat =3):
    v = (list(v))
    
    a = reduce(gcd,v)
    num +=a
    #print(v,num)
print(num)

Fixed submission:
k = int(input())
import math
num = 0
for i in range(1,k+1):
    for j in range(1,k+1):
        a = math.gcd(i,j)
        for l in range(1,k+1):
            b = math.gcd(a,l)
            num += b
print(num)

Buggy python submission (verdict: Time Limit Exceeded):
k = int(input())
k = [int(x)+1 for x in range(k)]
#print(k)
from fractions import gcd
from itertools import product,combinations
from functools import reduce
num = 0

for v in product(k,repeat =3):
    v = (list(v))
    
    a = reduce(gcd,v)
    num +=a
    #print(v,num)
print(num)

Fixed submission:
k = int(input())
import math
num = 0
for i in range(1,k+1):
    for j in range(1,k+1):
        a = math.gcd(i,j)
        for l in range(1,k+1):
            b = math.gcd(a,l)
            num += b
print(num)