Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
from itertools import permutations
import sys
try:
    from typing import List
except ImportError:
    pass


def solve(N: int, M: int, R: int, r: "List[int]", A: "List[int]", B: "List[int]", C: "List[int]"):
    inf = float("inf")
    md = [[inf] * N for _ in range(N)]
    for i in range(N):
        md[i][i] = 0
    for Ai, Bi, Ci in zip(A, B, C):
        Ai -= 1
        Bi -= 1
        md[Ai][Bi] = md[Bi][Ai] = Ci
    for k in range(N):
        for i in range(N):
            for j in range(N):
                md[i][j] = min(md[i][j], md[i][k] + md[k][j])

    def dist(path):
        return sum(md[p1 - 1][p2 - 1] for p1, p2 in zip(path, path[1:]))

    print(min(dist(path) for path in permutations(r)))


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    R = int(next(tokens))  # type: int
    r = [int(next(tokens)) for _ in range(R)]  # type: "List[int]"
    A = [int()] * (M)  # type: "List[int]"
    B = [int()] * (M)  # type: "List[int]"
    C = [int()] * (M)  # type: "List[int]"
    for i in range(M):
        A[i] = int(next(tokens))
        B[i] = int(next(tokens))
        C[i] = int(next(tokens))
    solve(N, M, R, r, A, B, C)


if __name__ == '__main__':
    main()


Fixed submission:
#!/usr/bin/env python3
from itertools import permutations
import sys
try:
    from typing import List
except ImportError:
    pass


def solve(N: int, M: int, R: int, r: "List[int]", A: "List[int]", B: "List[int]", C: "List[int]"):
    inf = float("inf")
    md = [[inf] * N for _ in range(N)]
    for i in range(N):
        md[i][i] = 0
    for Ai, Bi, Ci in zip(A, B, C):
        Ai -= 1
        Bi -= 1
        md[Ai][Bi] = md[Bi][Ai] = Ci
    for k in range(N):
        for i in range(N):
            for j in range(N):
                md[i][j] = min(md[i][j], md[i][k] + md[k][j])

    def dist(path):
        return sum(md[p1 - 1][p2 - 1] for p1, p2 in zip(path, path[1:]))

    print(min(dist(path) for path in permutations(r)))


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    R = int(next(tokens))  # type: int
    r = [int(next(tokens)) for _ in range(R)]  # type: "List[int]"
    A = [int()] * (M)  # type: "List[int]"
    B = [int()] * (M)  # type: "List[int]"
    C = [int()] * (M)  # type: "List[int]"
    for i in range(M):
        A[i] = int(next(tokens))
        B[i] = int(next(tokens))
        C[i] = int(next(tokens))
    solve(N, M, R, r, A, B, C)


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
d = {}


def f(s, n, m, a, js):
    if s in d:
        return d[s]
    cnt = [0] * m
    for i in xrange(n):
        cnt[a[i][js[i]]] += 1
    mc = max(cnt)
    d[s] = min(mc, min(
        f(s | {k}, n, m, a, [js[i] + (1 if a[i][js[i]] == k else 0) for i in xrange(n)])
        for k in xrange(m) if cnt[k] == mc
    ))
    return d[s]


def main():
    n, m = [int(x) for x in raw_input().split()]
    a = [[int(x) - 1 for x in raw_input().split()] for i in xrange(n)]
    d[frozenset(xrange(m))] = n
    return f(frozenset(), n, m, a, [0] * n)


if __name__ == '__main__':
    print(main())


Fixed submission:
def main():
    n, m = [int(x) for x in raw_input().split()]
    a = [[int(x) - 1 for x in raw_input().split()] for i in xrange(n)]
    ans = n
    for _ in xrange(m):
        cnt = [0] * m
        for ai in a:
            cnt[ai[0]] += 1
        c = max(xrange(m), key=lambda k: cnt[k])
        ans = min(ans, cnt[c])
        for ai in a:
            ai.remove(c)
    return ans


if __name__ == '__main__':
    print(main())
Buggy python submission (verdict: Runtime Error):
def ncr(n, r):
    ans = 1
    if r * 2 >= n:
        return ncr(n, n - r)
    for i in xrange(n - r + 1, n + 1):
        ans *= i
    for i in xrange(1, r + 1):
        ans //= i
    return ans


def main():
    n, p = [int(_) for _ in raw_input().split()]
    o = 0
    e = 0
    for ai in (int(_) for _ in raw_input().split()):
        if ai % 2 == 1:
            o += 1
        else:
            e += 1
    t = 2 ** e
    ans = 0
    for q in xrange(p, o + 1, 2):
        ans += t * ncr(o, q)
    return ans


if __name__ == '__main__':
    print(main())


Fixed submission:
def ncr(n, r):
    ans = 1
    if r * 2 > n:
        return ncr(n, n - r)
    for i in xrange(n - r + 1, n + 1):
        ans *= i
    for i in xrange(1, r + 1):
        ans //= i
    return ans


def main():
    n, p = [int(_) for _ in raw_input().split()]
    o = 0
    e = 0
    for ai in (int(_) for _ in raw_input().split()):
        if ai % 2 == 1:
            o += 1
        else:
            e += 1
    t = 2 ** e
    ans = 0
    for q in xrange(p, o + 1, 2):
        ans += t * ncr(o, q)
    return ans


if __name__ == '__main__':
    print(main())
Buggy python submission (verdict: Runtime Error):
def main():

    def nim(i, parent=None):
        ret = 0
        for j in edges[i]:
            if j == parent:
                continue
            ret ^= nim(j, i) + 1
        return ret

    n = int(raw_input())
    edges = [[] for i in xrange(n)]
    for i in xrange(n - 1):
        x, y = [int(_) - 1 for _ in raw_input().split()]
        edges[x].append(y)
        edges[y].append(x)
    if nim(0) == 0:
        return "Bob"
    else:
        return "Alice"


if __name__ == '__main__':
    print(main())


Fixed submission:
import sys
sys.setrecursionlimit(700000)


def main():

    def nim(i, parent=None):
        ret = 0
        for j in edges[i]:
            if j == parent:
                continue
            ret ^= nim(j, i) + 1
        return ret

    n = int(raw_input())
    edges = [[] for i in xrange(n)]
    for i in xrange(n - 1):
        x, y = [int(_) - 1 for _ in raw_input().split()]
        edges[x].append(y)
        edges[y].append(x)
    if nim(0) == 0:
        return "Bob"
    else:
        return "Alice"


if __name__ == '__main__':
    print(main())
Buggy python submission (verdict: Runtime Error):
n, m = [int(x) for x in raw_input().split()]

t = [[] for i in xrange(m)]

for i in xrange(m):
    a, b = [int(x) - 1 for x in raw_input().split()]
    t[a].append(b)
    t[b].append(a)

pre = [a]
pos = [b]
visited = {a, b}

while 1:
    for ne in t[pre[-1]]:
        if ne not in visited:
            visited.add(ne)
            pre.append(ne)
            break
    else:
        break


while 1:
    for ne in t[pos[-1]]:
        if ne not in visited:
            visited.add(ne)
            pos.append(ne)
            break
    else:
        break

print(len(pre) + len(pos))
print(" ".join(str(x + 1) for x in reversed(pre)) + " " + " ".join(str(x + 1) for x in pos))


Fixed submission:
n, m = [int(x) for x in raw_input().split()]

t = [[] for i in xrange(n)]

for i in xrange(m):
    a, b = [int(x) - 1 for x in raw_input().split()]
    t[a].append(b)
    t[b].append(a)

pre = [a]
pos = [b]
visited = {a, b}

while 1:
    for ne in t[pre[-1]]:
        if ne not in visited:
            visited.add(ne)
            pre.append(ne)
            break
    else:
        break


while 1:
    for ne in t[pos[-1]]:
        if ne not in visited:
            visited.add(ne)
            pos.append(ne)
            break
    else:
        break

print(len(pre) + len(pos))
print(" ".join(str(x + 1) for x in reversed(pre)) + " " + " ".join(str(x + 1) for x in pos))
Buggy python submission (verdict: Runtime Error):
"U" * h + "R" * (w + 1) + "D" * (h + 1) + "L" * (w + 1)

Fixed submission:
sx, sy, tx, ty = [int(x) for x in raw_input().split()]

w = tx - sx
h = ty - sy

c = "U" * h + "R" * (w + 1) + "D" * (h + 1) + "L" * w
print c + "LULU" + c
Buggy python submission (verdict: Runtime Error):
n,k=raw_input().split();u=sorted({chr(x)for x in range(48,59)}-set(raw_input().split()));z=u[0];n=list(n)
i=next(i for i,d in enumerate(n)if d not in u)
n[i:]=[next(e for e in u if e>n[i])]+[z]*(len(n)-i-1)
for j in range(i-1,-1,-1):
 if n[j+1]<':':break
 n[j:j+2]=[next(e for e in u if e>n[j]),z]
else:
 if n[0]>'9':n=[u[1 if'1'>z else 0]]+[z]*len(n)
print"".join(n)

Fixed submission:
n,k=raw_input().split();u=sorted({chr(x)for x in range(48,59)}-set(raw_input().split()));z=u[0];n=list(n)
for i,d in enumerate(n):
 if d in u:continue
 n[i:]=[next(e for e in u if e>d)]+[z]*(len(n)-i-1)
 for j in range(i-1,-1,-1):
  if n[j+1]<':':break
  n[j:j+2]=[next(e for e in u if e>n[j]),z]
 else:
  if n[0]>'9':n=[u[1 if'1'>z else 0]]+[z]*len(n)
print"".join(n)

Buggy python submission (verdict: Runtime Error):
n,k=raw_input().split()
u=sorted({chr(x)for x in range(48,59)}-set(raw_input().split()))
n=list(n)
for i,d in enumerate(n):
 if d not in u:
  n[i:]=[next(e for e in u if e>d)]+[u[0]]*(len(n)-i-1)
  for j in range(i-1,-1,-1):
   if n[j+1]!=':':break
   n[j:j+2]=[next(e for e in u if e>n[j+1]),u[0]]
  else:
   if n[0]==':':n=[u[1 if'1'>u[0]else 0]]+[u[0]]*len(n)
print"".join(n)

Fixed submission:
n,k=raw_input().split();u=sorted({chr(x)for x in range(48,59)}-set(raw_input().split()));z=u[0];n=list(n)
for i,d in enumerate(n):
 if d in u:continue
 n[i:]=[next(e for e in u if e>d)]+[z]*(len(n)-i-1)
 for j in range(i-1,-1,-1):
  if n[j+1]<':':break
  n[j:j+2]=[next(e for e in u if e>n[j]),z]
 else:
  if n[0]>'9':n=[u[1 if'1'>z else 0]]+[z]*len(n)
print"".join(n)

Buggy python submission (verdict: Runtime Error):
n,k=raw_input().split()
u=sorted({chr(x)for x in range(48,59)}-set(raw_input().split()))
n=list(n)
for i,d in enumerate(n):
 if d not in u:
  n[i:]=[next(e for e in u if e>d)]+[u[0]]*(len(n)-i-1)
  for j in range(i-1,-1,-1):
   if n[j+1]!=':':break
   n[j:j+2]=[next(e for e in u if e>n[j+1]),u[0]]
  else:n=[u[1 if'1'>u[0]else 0]]+[u[0]]*len(n)
print"".join(n)

Fixed submission:
n,k=raw_input().split();u=sorted({chr(x)for x in range(48,59)}-set(raw_input().split()));z=u[0];n=list(n)
for i,d in enumerate(n):
 if d in u:continue
 n[i:]=[next(e for e in u if e>d)]+[z]*(len(n)-i-1)
 for j in range(i-1,-1,-1):
  if n[j+1]<':':break
  n[j:j+2]=[next(e for e in u if e>n[j]),z]
 else:
  if n[0]>'9':n=[u[1 if'1'>z else 0]]+[z]*len(n)
print"".join(n)

Buggy python submission (verdict: Runtime Error):
n,k=raw_input().split()
u=sorted({str(x)for x in range(10)}-set(raw_input().split()))
n=list(n)
for i,d in enumerate(n):
 if d not in u:n[i:]=[next(e for e in u if e>d)]+[u[0]]*(len(n)-i-1)
print"".join(n)

Fixed submission:
n,k=raw_input().split();u=sorted({chr(x)for x in range(48,59)}-set(raw_input().split()));z=u[0];n=list(n)
for i,d in enumerate(n):
 if d in u:continue
 n[i:]=[next(e for e in u if e>d)]+[z]*(len(n)-i-1)
 for j in range(i-1,-1,-1):
  if n[j+1]<':':break
  n[j:j+2]=[next(e for e in u if e>n[j]),z]
 else:
  if n[0]>'9':n=[u[1 if'1'>z else 0]]+[z]*len(n)
print"".join(n)
Buggy python submission (verdict: Runtime Error):
import math
N=int(input())
C=0
 
for l in range(N):
    for n in range(N):
        for m in range(N):
            if l==0 or m==0 or n==0:
                C+=1
            else:
                C+=math.gcd(math.gcd(l+1,m+1),n+1)
 
print(C

Fixed submission:
import math
N=int(input())
C=0
 
for l in range(N):
    for n in range(N):
        for m in range(N):
            if l==0 or m==0 or n==0:
                C+=1
            else:
                C+=math.gcd(math.gcd(l+1,m+1),n+1)
 
print(C)

Buggy python submission (verdict: Time Limit Exceeded):
import math
N=int(input())
C=0

for l in range(N):
    for n in range(N):
        for m in range(N):
            if l==0 or m==0 or n==0:
                C+=1
            else:
                C+=math.gcd(math.gcd(l+1,m+1),n+1)

print(C)

Fixed submission:
import math
N=int(input())
C=0
 
for l in range(N):
    for n in range(N):
        for m in range(N):
            if l==0 or m==0 or n==0:
                C+=1
            else:
                C+=math.gcd(math.gcd(l+1,m+1),n+1)
 
print(C)

Buggy python submission (verdict: Time Limit Exceeded):
import math
N=int(input())
C=0

for l in range(N):
    for m in range(N):
        for n in range(N):
            C+=math.gcd(math.gcd(l+1,m+1),n+1)

print(C)

Fixed submission:
import math
N=int(input())
C=0
 
for l in range(N):
    for n in range(N):
        for m in range(N):
            if l==0 or m==0 or n==0:
                C+=1
            else:
                C+=math.gcd(math.gcd(l+1,m+1),n+1)
 
print(C)
Buggy python submission (verdict: Runtime Error):
L=int(input())
L1=(L//3)
L2=L%3
while L2>=10**-16:
    L1+=(L2/3)
    L2=(L2/3)

print(L1**3)

Fixed submission:
N,M=map(int,input().split())
print(int((N*(N-1)/2)+(M*(M-1)/2)))
Buggy python submission (verdict: Runtime Error):
N,A,B=map(int,input().split())
if  A==0:
    print(0)
elif N==A+B:
    print(A)
elif N<=A:
    print(N)
else N>A+B:
    print(N-B)

Fixed submission:
N,A,B=map(int,input().split())
print(N//(A+B)*A+min(N%(A+B),A))
Buggy python submission (verdict: Runtime Error):
N=int(input())
A=list(input())
cnt=0

for n in range(N):
    if A[n]=="A":
        if A[n+1]=="B":
            if A[n+2]=="C":
                cnt+=1
            else:
                continue
        else:
            continue
    else:
        continue

print(cnt)


Fixed submission:
N=int(input())
A=list(input())
cnt=0

for n in range(N):
    if n==N-1 or n==N-2:
        continue
    elif A[n]=="A":
        if A[n+1]=="B":
            if A[n+2]=="C":
                cnt+=1
            else:
                continue
        else:
            continue
    else:
        continue

print(cnt)

Buggy python submission (verdict: Runtime Error):
N=int(input())
A=list(input())
cnt=0

for n in range(N):
    if A[n]=="A":
        if A[n+1]=="B":
            if A[n+2]=="C":
                cnt+=1
            else:
                continue
        else:
            continue
    else:
        continue

print(cnt)


Fixed submission:
N=int(input())
A=list(input())
cnt=0

for n in range(N):
    if n==N-1 or n==N-2:
        continue
    elif A[n]=="A":
        if A[n+1]=="B":
            if A[n+2]=="C":
                cnt+=1
            else:
                continue
        else:
            continue
    else:
        continue

print(cnt)
Buggy python submission (verdict: Runtime Error):
A,B=map(int,input().split())
input(max(2*A-1,2*B-1,A+B))

Fixed submission:
A,B=map(int,input().split())
print(max(2*A-1,2*B-1,A+B))

Buggy python submission (verdict: Runtime Error):
A,B=map(int,input().split())
input(max(2*A-1,2*B-1,A+B))

Fixed submission:
A,B=map(int,input().split())
print(max(2*A-1,2*B-1,A+B))

Buggy python submission (verdict: Runtime Error):
A,B=map(int,input().split())
input(max(2*A-1,2*B-1,A+B))

Fixed submission:
A,B=map(int,input().split())
print(max(2*A-1,2*B-1,A+B))
Buggy python submission (verdict: Runtime Error):
# C
import math
#A:短針,B:長針,H:短針の位置,M:長針の位置
A,B,H,M = map(int,input().split(' '))

#radian = degree/180*PI
rad = abs(H/6*math.pi-M/30*math.pi)
rad = min(rad,360-rad)
print('{:.15f}'.format(A*A + B*B - 2*A*B*math.cos(rad))**0.5)

Fixed submission:
# C
import math
#A:短針,B:長針,H:短針の位置,M:長針の位置
A,B,H,M = map(int,input().split(' '))
rad = abs((H*30+M/2)-M*6)
rad = math.radians(min(rad,360-rad))
print('{:.20f}'.format((A**2 + B**2 - 2*A*B*math.cos(rad))**0.5))
Buggy python submission (verdict: Runtime Error):
#coding :utf-8

A,B,C,K=map(int,input().split())

ans=sum(([1]*A+[0]*B+[-1]*C)[:K])

print(ans)

Fixed submission:
#coding :utf-8
A,B,C,K=map(int,input().split())
cnt=0
if K-A > 0:
  cnt=A
  if K-A-B >0:
    cnt=cnt-(K-A-B)
    print(cnt)
  else:
    print(cnt)
else:
  print(K)
Buggy python submission (verdict: Runtime Error):
#coding :utf-8
import numpy as np

N,M,X=map(int,input().split())
a=[]
for i in range(N):
    a.append(list(map(int,input().split())))

suma=sum(a[0][])
print(suma,a)

Fixed submission:
#coding :utf-8

N,M,X=map(int,input().split())

C=[]
A=[]
for i in range(N):
  t=list(map(int,input().split()))
  C.append(t[0])
  A.append(t[1:])
result=-1

for i in range(1<<N):
  t=[0]*M
  c=0
  for j in range(N):
    if ((i>>j) & 1==0):
      continue
    c+=C[j]
    for k in range(M):
      t[k]+=A[j][k]
    
  
  if all(x>=X for x in t):
    if result==-1:
      result=c
    else:
      result=min(result,c)

print(result)
Buggy python submission (verdict: Runtime Error):
# coding: utf-8
H,W=map(int,input().split())

if H==1 or W==1:
  print(1)
else:
  if H*W%2==0:
    print(int(H*W/2))
  else:
    print(int(H*W/2+0.5))
  
 

Fixed submission:
# coding: utf-8
N=int(input())

l=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

print(l[N-1])
Buggy python submission (verdict: Time Limit Exceeded):
#coding utf-8

N,A,B=map(int,input().split())
data=[]
while len(data) < N:
  for r in range(A):
    data.append(1)
  for b in range(B):
    data.append(2)

list=data[0:N]
print(list.count(1))

Fixed submission:
N, A, B = map(int, input().split())
ans = N // (A + B) * A
rem = N % (A + B)
ans += min(rem, A)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
#coding utf-8

N,A,B=map(int,input().split())
data=[]
for i in range(N):
  for r in range(A):
    data.append(1)
  for b in range(B):
    data.append(2)

list=data[0:N]
print(list.count(1))

Fixed submission:
N, A, B = map(int, input().split())
ans = N // (A + B) * A
rem = N % (A + B)
ans += min(rem, A)
print(ans)
Buggy python submission (verdict: Runtime Error):
a,b,c=map(int,input().split())
s=set(a,b,c)
if len(s)==2:
    print("Yes")
else:
    print("No")

Fixed submission:
l = list(map(int, input().split()))
s = set(l)
if len(s) == 2:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
n=int(input())
s=len(str(n))
if s%2==0:
    s=s-1
    x=''
    for i in range(s-1):
        if i%2==0:
            x+='9'
        else:
            x+='0'
    x+='9'
    print(x)
else:
    z=s-2
    x = ''
    for i in range(z - 1):
        if i % 2 == 0:
            x += '9'
        else:
            x += '0'
    x += '9'
    x=int(x)
    x+=n-int('9'*(z+1))
    print(x)

Fixed submission:
n=int(input())
s=len(str(n))
if n<10:
    print(n)
else:
    if s%2==0:
        s=s-1
        x=''
        for i in range(s-1):
            if i%2==0:
                x+='9'
            else:
                x+='0'
        x+='9'
        print(x)
    else:
        z=s-2
        x = ''
        for i in range(z - 1):
            if i % 2 == 0:
                x += '9'
            else:
                x += '0'
        x += '9'
        x=int(x)
        x+=n-int('9'*(z+1))
        print(x)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
l=[]
for i in range(n):
    x=int(input())
    l.append(x)
for i in range(n):
    x=l[i]
    l.pop(i)
    y=max(l)
    l.insert(i,x)
    print(y)

Fixed submission:
n=int(input())
l=[]
for i in range(n):
    x=int(input())
    l.append(x)
x=sorted(l)
for i in range(n):
    if l[i]==x[-1]:
        print(x[-2])
    else:
        print(x[-1])
Buggy python submission (verdict: Time Limit Exceeded):
if __name__ == '__main__':
    NK=input().split(" ")
    N=int(NK[0])
    K=int(NK[1])
    res=1
    n=0
    tem=[1]
    temp=1
    A=list(map(int,input().split(" ")))
    dic={}
    for i in range(0,N):
        dic[i+1]=A[i]
    for i in range(N):
        res=dic[res]
        n+=1
        if (res in tem):
            temp=res
            break
        tem.append(res)
    if K<=N:
        res=1
        for i in range(K):
            res=dic[res]
        print(res)
    else:
        m=0
        tem=[res]
        for i in range(N):
            res=dic[res]
            m+=1
            if (res in tem):
                temp=res
                break
            tem.append(res)
        # if n==N:
        #     res=dic[K%N]
        # else:
        for i in range(0, (K-n)%m):
            res=dic[res]
        print(res)

Fixed submission:
n, k = map(int, input().split())
a = list(map(int, input().split()))
test_pos = 1
sub = 0
loop = 0
city = [0 for i in range(n)]
while True:
    test_pos = a[test_pos-1]
    city[test_pos-1] += 1
    sub += 1
    if city[test_pos-1] == 2:
        loop_start = test_pos
        break

while True:
    test_pos = a[test_pos-1]
    loop += 1
    if test_pos == loop_start:
        break
if k > sub:
    k -= sub
    k %= loop
    pos = loop_start
    for i in range(k):
        pos = a[pos-1]
    print(pos)
else:
    pos = 1
    for i in range(k):
        pos = a[pos - 1]
    print(pos)
Buggy python submission (verdict: Time Limit Exceeded):
def gacha():
    N=int(input())
    string=[]
    result_list=[]
    for i in range(0,N):
        s=input()
        string.append(s)
    for i in string:
        if i not in result_list:
            result_list.append(i)
    print(len(result_list))

if __name__=="__main__":
    gacha()

Fixed submission:
def gacha():
    N=int(input())
    string=[]
    for i in range(0,N):
        s=input()
        string.append(s)
    result=list(set(string))
    print(len(result))

if __name__=="__main__":
    gacha()
Buggy python submission (verdict: Time Limit Exceeded):
n = input()
cnt = 0
for i in range(0,len(n)-3):
    for j in range(i+3,len(n)):
        if int(n[i:j+1])%2019 == 0:
            cnt += 1
print(cnt)

Fixed submission:
num = [0 for i in range(2019)]
num[0] = 1
count = 0
s = input()
now = 0
p = 1
for i in range(len(s) - 1, -1, -1):
    now = (now + int(s[i]) * p) % 2019
    count += num[now]
    num[now] += 1
    p = p * 10 % 2019
print(count)
Buggy python submission (verdict: Runtime Error):
if __name__ == '__main__':
    x=list(map(int,input().split(" ")))
    y = list(map(int, input().split(" ")))
    num=0
    for i in y:
        num+=i
    if x[0]<y:
        print(-1)
    else: print(x[0]-y)

Fixed submission:
N, M = map(int, input().split(' '))
a = list(map(int, input().split(' ')))
sum_a = 0
for i in a:
    sum_a += i
if sum_a > N:
    print(-1)
else:
    print(N - sum_a)
Buggy python submission (verdict: Time Limit Exceeded):
def management():
    N=int(input())
    static_list=list(map(int,input().split()))
    result_list=[]
    for i in range(0,N):
        result_list.append(0)
    for i in range(0,len(static_list)):
        for j in range(0,N):
            if static_list[i]==j+1:
                result_list[j]=result_list[j]+1
    for i in range(0,N):
        print(result_list[i])


if __name__=="__main__":
    management()


Fixed submission:
N = int(input())
a = list(map(int, input().split(' ')))
b = [0 for i in range(N)]
for i in a:
    b[i-1] += 1
for i in b:
    print(i)
Buggy python submission (verdict: Time Limit Exceeded):
def sovle(x, y):
    while(x>=y):
        x=x-y
    if(x>y-x):
        return y-x
    else:return x



if __name__ == '__main__':
    nums = list(map(int, input().split(" ")))
    print(sovle(nums[0], nums[1]))

Fixed submission:
def sovle(x, y):
    while(x>=y):
        x=x-x//y*y
    if(x>y-x):
        return y-x
    else:return x



if __name__ == '__main__':
    nums = list(map(int, input().split(" ")))
    print(sovle(nums[0], nums[1]))