Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
import heapq

n,m  = map(int,input().split())
a = list(map(int, input().split()))
bcs = []
for _ in range(m):
    bcs.append(list(map(int, input().split())))

heapq.heapify(a)
bcs.sort(key=lambda x: x[1])

for bc in bcs:
    b = bc[0]
    c = bc[1]
    while b > 0:
        ta = heapq.heappop(a)
        if ta < c:
            heapq.heappush(a,c)
        else:
            heapq.heappush(a,ta)
            break
        b -= 1

print(sum(a))

Fixed submission:
import heapq

n,m  = map(int,input().split())
a = list(map(int, input().split()))
bcs = []
for _ in range(m):
    bcs.append(list(map(int, input().split())))

heapq.heapify(a)
bcs.sort(key=lambda x: x[1],reverse=True)

for bc in bcs:
    b = bc[0]
    c = bc[1]
    while b > 0:
        ta = heapq.heappop(a)
        if ta < c:
            heapq.heappush(a,c)
        else:
            heapq.heappush(a,ta)
            break
        b -= 1

print(sum(a))

Buggy python submission (verdict: Time Limit Exceeded):
import heapq

n,m  = map(int,input().split())
a = list(map(int, input().split()))
bcs = []
for _ in range(m):
    bcs.append(list(map(int, input().split())))

heapq.heapify(a)

for bc in bcs:
    b = bc[0]
    c = bc[1]
    while b > 0:
        ta = heapq.heappop(a)
        if ta < c:
            heapq.heappush(a,c)
        else:
            heapq.heappush(a,ta)
            break
        b -= 1

print(sum(a))

Fixed submission:
import heapq

n,m  = map(int,input().split())
a = list(map(int, input().split()))
bcs = []
for _ in range(m):
    bcs.append(list(map(int, input().split())))

heapq.heapify(a)
bcs.sort(key=lambda x: x[1],reverse=True)

for bc in bcs:
    b = bc[0]
    c = bc[1]
    while b > 0:
        ta = heapq.heappop(a)
        if ta < c:
            heapq.heappush(a,c)
        else:
            heapq.heappush(a,ta)
            break
        b -= 1

print(sum(a))
Buggy python submission (verdict: Time Limit Exceeded):
n =int(input())
s = input()
res = 10**6
for i in range(0,n+1):
    tres = s[:i].count("#") + s[i:].count(".")
    res = min(res,tres)

print(res)

Fixed submission:
n =int(input())
s = input()
tres = s.count(".")
res = tres
for c in s:
    if c == ".":
        tres -= 1
    else:
        tres += 1
    res = min(res,tres)        

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

s = input()
pat = r"[ACGT]+"
atgc = re.findall(pat, s)
ress = []
for i in atgc:
    ress.append(len(i))

print(max(ress))


Fixed submission:
import re

s = input()
n = len(s)
res = 0
for i in range(0, n):
    j = i
    tempres = 0
    while j < n and (s[j] == "A" or s[j] == "G" or s[j] == "C" or s[j] == "T"):
        j += 1
        tempres += 1
    res = max(res, tempres)

print(res)
Buggy python submission (verdict: Time Limit Exceeded):
import bisect
a,b,q = map(int,input().split())
INF = 10**18
s=[-INF]+[int(input()) for _ in range(a)]+[INF]
t=[-INF]+[int(input()) for _ in range(b)]+[INF]

def dis(x,p,q):
    return min(abs(x-s[p])+abs(s[p]-t[q]),abs(x-t[q])+abs(s[p]-t[q]))

def kai(x):
    res = INF
    s1 = bisect.bisect_right(s,x)
    ls = [s1,s1 - 1]
    t1 = bisect.bisect_right(t,x)
    lt = [t1,t1 - 1]
    for ss in ls:
        for st in lt:
            res = min(res,dis(x,ss,st))
    return res

for _ in range(q):
    x = int(input())
    print(kai(x))


Fixed submission:
import bisect
a,b,q = map(int,input().split())
INF = 10**18
s=[-INF]+[int(input()) for _ in range(a)]+[INF]
t=[-INF]+[int(input()) for _ in range(b)]+[INF]

def kai(x):
    res = INF
    s1 = bisect.bisect_right(s,x)
    ls = [s1,s1 - 1]
    t1 = bisect.bisect_right(t,x)
    lt = [t1,t1 - 1]
    for ss in ls:
        for st in lt:
            res = min(res,abs(x-s[ss])+abs(s[ss]-t[st]),abs(x-t[st])+abs(s[ss]-t[st]))
    return res

lx = [int(input()) for _ in range(q)]
for x in lx:
    print(kai(x))
Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
a=list(map(int,input().split()))
mm=[0,2,5,5,4,5,6,3,7,6]

dp=[0]
m = [mm[i] for i in range(10) if i in a]
for i in range(1,n+1):
    tres=[-10**10]
    for sm in m:
        if i - sm >= 0:
            tres.append(dp[i-sm]+1)
    dp.append(max(tres))
k=dp[n]
res = []
a.sort(reverse=True)
while n > 0:
    for sa in a:
        if dp[n-mm[sa]]==dp[n]-1:
            res.append(sa)
            n -= mm[sa]
            break

print("".join(map(str,res)))

Fixed submission:
n,m=map(int,input().split())
a=list(map(int,input().split()))
mm=[0,2,5,5,4,5,6,3,7,6]

dp=[0]
m = [mm[i] for i in range(10) if i in a]
for i in range(1,n+1):
    tres=[-10**10]
    for sm in m:
        if i - sm >= 0:
            tres.append(dp[i-sm]+1)
    dp.append(max(tres))
k=dp[n]
res = []
a.sort(reverse=True)
while n > 0:
    for sa in a:
        if n-mm[sa] >= 0 and dp[n-mm[sa]]==dp[n]-1:
            res.append(sa)
            n -= mm[sa]
            break

print("".join(map(str,res)))

Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
a=list(map(int,input().split()))
mm=[0,2,5,5,4,5,6,3,7,6]

dp=[0]
m = [mm[i] for i in range(n) if i in a]
for i in range(1,n+1):
    tres=[-10**10]
    for sm in m:
        if i - sm >= 0:
            tres.append(dp[i-sm]+1)
    dp.append(max(tres))
k=dp[n]
res = []
a.sort(reverse=True)
while n > 0:
    for sa in a:
        if dp[n-mm[sa]]==dp[n]-1:
            res.append(sa)
            n -= mm[sa]
            break

print("".join(map(str,res)))

Fixed submission:
n,m=map(int,input().split())
a=list(map(int,input().split()))
mm=[0,2,5,5,4,5,6,3,7,6]

dp=[0]
m = [mm[i] for i in range(10) if i in a]
for i in range(1,n+1):
    tres=[-10**10]
    for sm in m:
        if i - sm >= 0:
            tres.append(dp[i-sm]+1)
    dp.append(max(tres))
k=dp[n]
res = []
a.sort(reverse=True)
while n > 0:
    for sa in a:
        if n-mm[sa] >= 0 and dp[n-mm[sa]]==dp[n]-1:
            res.append(sa)
            n -= mm[sa]
            break

print("".join(map(str,res)))

Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
a=list(map(int,input().split()))
mm=[0,2,5,5,4,5,6,3,7,6]

dp=[0]
m = [mm[i] for i in range(n) if i in a]
for i in range(1,n+1):
    tres=[-10**10]
    for sm in m:
        if i - sm >= 0:
            tres.append(dp[i-sm]+1)
    dp.append(max(tres))
k=dp[n]
res = []
a.sort(reverse=True)
for i in range(k):
    for sa in a:
        if dp[n-mm[sa]]==dp[n]-1:
            res.append(sa)
            n -= mm[sa]
            break

print("".join(map(str,res)))

Fixed submission:
n,m=map(int,input().split())
a=list(map(int,input().split()))
mm=[0,2,5,5,4,5,6,3,7,6]

dp=[0]
m = [mm[i] for i in range(10) if i in a]
for i in range(1,n+1):
    tres=[-10**10]
    for sm in m:
        if i - sm >= 0:
            tres.append(dp[i-sm]+1)
    dp.append(max(tres))
k=dp[n]
res = []
a.sort(reverse=True)
while n > 0:
    for sa in a:
        if n-mm[sa] >= 0 and dp[n-mm[sa]]==dp[n]-1:
            res.append(sa)
            n -= mm[sa]
            break

print("".join(map(str,res)))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))
dp = [[-1]*N for _ in range(N)]
for i in range(N):
    dp[i][i] = 0


def main(l, r):
    if dp[l][r] != -1:
        return dp[l][r]
    ret = 10**15
    for i in range(l, r):
        ret = min(ret, main(l, i)+main(i+1, r))
    ret += sum(A[l:r+1])
    dp[l][r] = ret
    return ret


print(main(0, N-1))

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
dp = [[-1]*N for _ in range(N)]
for i in range(N):
    dp[i][i] = 0


def main(l, r):
    if dp[l][r] != -1:
        return dp[l][r]
    ret = 10**15
    for i in range(l, r):
        ret = min(ret, main(l, i)+main(i+1, r))
    ret += sum(A[l:r+1])
    dp[l][r] = ret
    return ret


print(main(0, N-1))
Buggy python submission (verdict: Time Limit Exceeded):
n,x = map(int,input().split())

def barger(n):
    if n == 0 :
        return "1"
    else:
        return "0" + barger(n-1) + "1" + barger(n-1) + "0"

print(barger(n)[:x].count("1"))

Fixed submission:
n,x = map(int,input().split())
p=[1]
s=[1]
for i in range(50):
    p.append(p[i]*2+1)
    s.append(s[i]*2+3)

def burger(n,x):
    if n ==0:
        return 1
    elif x == 1:
        return 0
    elif x<=1+s[n-1]:
        return burger(n-1,x-1)
    elif x == 2+s[n-1]:
        return p[n-1] + 1
    elif x <= 2 + s[n-1] * 2:
        return p[n-1] + 1 + burger(n-1,x-s[n-1]-2)
    elif x <= 3 + s[n-1] * 2:
        return 1 + p[n-1] * 2
    else:
        print("ERROR")

print(burger(n,x))
Buggy python submission (verdict: Runtime Error):
import math
def main():
    n,m = map(int,input().split())

    start = min(m//n,math.sqrt(m))

    for i in range(start,0,-1):
        if m%i==0:
            print(i)
            break

main()

Fixed submission:
def main():
    n,m = map(int,input().split())

    start = m//n

    for i in range(start,0,-1):
        if m%i==0:
            print(i)
            break

main()

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

start = m//n

for i in range(start,0,-1):
    if m%i==0:
        print(i)
        break

Fixed submission:
def main():
    n,m = map(int,input().split())

    start = m//n

    for i in range(start,0,-1):
        if m%i==0:
            print(i)
            break

main()
Buggy python submission (verdict: Time Limit Exceeded):
n,k = map(int,input().split())
x = list(map(int,input().split()))
res = 10**10
for i in range(n-k+1):
    kx = x[i:i+k]
    l=kx[0]
    r = kx[-1]
    lrsmall = min(abs(l),abs(r))
    res = min(r-l+lrsmall,res)
print(res)

Fixed submission:
n,k = map(int,input().split())
x = list(map(int,input().split()))
kx = x[0:k]
l=kx[0]
r = kx[-1]
lrsmall = min(abs(l),abs(r))
res = r-l+lrsmall
for i in range(1,n-k+1):
    del kx[0]
    kx.append(x[i+k-1])
    l=kx[0]
    r = kx[-1]
    lrsmall = min(abs(l),abs(r))
    res = min(r-l+lrsmall,res)
print(res)
Buggy python submission (verdict: Runtime Error):
s=input()
flag = "AC"
if s[0] != "A":
    flag = "WA"
if not "C" in s[2:-1]:
    flag = "WA"
ls = [c for c in s]
ls.remove("A")
ls.remove("C")
for c in ls:
    if c.isupper():
        flag = "WA"
print(flag)

Fixed submission:
s=input()
flag = "AC"
if s[0] != "A":
    flag = "WA"
else:
    if not "C" in s[2:-1]:
        flag = "WA"
    else:
        ls = [c for c in s]
        ls.remove("A")
        ls.remove("C")
        for c in ls:
            if c.isupper():
                flag = "WA"
print(flag)
Buggy python submission (verdict: Runtime Error):
import math
n=int(input())
a=list(map(int,input().split()))

for i in range(n):
    a[i] -= i+1

# ave = sum(a)/n
# ave1= math.ceil(ave)
# ave2= math.floor(ave)


# print(min(sum([abs(a[i]-ave1) for i in range(n)]),sum([abs(a[i]-ave2) for i in range(n)])))

a.sort()
med1=a[n//2-1]
med2=a[n//2-2]
med3=a[n//2]

print(min(sum([abs(a[i]-med1) for i in range(n)]),sum([abs(a[i]-med2) for i in range(n)]),sum([abs(a[i]-med3) for i in range(n)])))

Fixed submission:
import math
n=int(input())
a=list(map(int,input().split()))

for i in range(n):
    a[i] -= i+1

# ave = sum(a)/n
# ave1= math.ceil(ave)
# ave2= math.floor(ave)


# print(min(sum([abs(a[i]-ave1) for i in range(n)]),sum([abs(a[i]-ave2) for i in range(n)])))

a.sort()
med1=a[n//2-1]
med3=a[n//2]

print(min(sum([abs(a[i]-med1) for i in range(n)]),sum([abs(a[i]-med3) for i in range(n)])))
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
s=input()
res = 10**9
for i in range(n):
    tres = s[:i].count("W")+s[i+1:].count("E")
    res = min(tres,res)
print(res)

Fixed submission:
n=int(input())
s=input()
res = s[1:].count("E")
tres = res
for i in range(1,n):
    if s[i] == "E":
        tres -= 1
    if s[i-1] == "W":
        tres += 1
    res = min(res,tres)
print(res)
Buggy python submission (verdict: Runtime Error):
import math
r=[]
q=int(input())
for _ in range(q):
    a,b=map(int,input().split())
    p=a*b
    t = math.floor(math.sqrt(p-1))
    res = t*2-1
    if (p-1)//t ==t:res -= 1
    if a==b:res+=1
    r.append(res)

print("\n".join(map(str,r)))

Fixed submission:
import math
import decimal

def hantei(f,p):
    if f*f<p :
        return True
    return False


def nibun2(l,r,p):
    if r == l:
        return l
    f = (l+r+1)//2
    if hantei(f,p):
        return nibun2(f,r,p)
    else:
        return nibun2(l,f-1,p)

r=[]
q=int(input())
for _ in range(q):
    a,b=map(int,input().split())
    p=a*b
    if p ==1:res = 0
    else:
        t = nibun2(0,10**20,p)
        res = t*2-1
        if (p-1)//t ==t:res -= 1
        if a==b:res+=1
    r.append(res)

print("\n".join(map(str,r)))
Buggy python submission (verdict: Runtime Error):
h,w,d=map(int,input().split())
a = [list(map(int,input().split())) for _ in range(h)]

dx = [0 for _ in range(h*w+5)]
dy = [0 for _ in range(h*w+5)]

for i in range(h):
    for j in range(w):
        dx[a[i][j]] = i
        dy[a[i][j]] = j

dfromd = [[0 for _ in range((h*w+5)//d)] for _ in range(h*w+5)]

for i in range(h*w-d+3):
    for j in range(1,(h*w+5)//d):
        if i+d*j <= h*w+3:
            dfromd[i][j] = dfromd[i][j-1] + abs(dx[i+d*j]-dx[i+d*(j-1)])+abs(dy[i+d*j]-dy[i+d*(j-1)])

q = int(input())
for _ in range(q):
    l,r=map(int,input().split())
    print(dfromd[l][(r-l)//d])

Fixed submission:
h,w,d=map(int,input().split())
a = [list(map(int,input().split())) for _ in range(h)]

dx = [0 for _ in range(h*w+5)]
dy = [0 for _ in range(h*w+5)]

for i in range(h):
    for j in range(w):
        dx[a[i][j]] = i
        dy[a[i][j]] = j

dfromd = [0 for _ in range(h*w+1)]

for i in range(d+1,h*w+1):
        dfromd[i] = dfromd[i-d]+abs(dx[i-d]-dx[i])+abs(dy[i-d]-dy[i])

q = int(input())
for _ in range(q):
    l,r=map(int,input().split())
    print(dfromd[r]-dfromd[l])

Buggy python submission (verdict: Time Limit Exceeded):
h,w,d=map(int,input().split())
a = [list(map(int,input().split())) for _ in range(h)]

dx = [0 for _ in range(h*w+5)]
dy = [0 for _ in range(h*w+5)]

for i in range(h):
    for j in range(w):
        dx[a[i][j]] = i
        dy[a[i][j]] = j

dfromd = [0 for _ in range(h*w+5)]

for i in range(h*w-d+3):
    dfromd[i] = abs(dx[i+d]-dx[i])+abs(dy[i+d]-dy[i])

q = int(input())
for _ in range(q):
    l,r=map(int,input().split())
    res = 0
    while l < r:
        res += dfromd[l]
        l += d
    print(res)

Fixed submission:
h,w,d=map(int,input().split())
a = [list(map(int,input().split())) for _ in range(h)]

dx = [0 for _ in range(h*w+5)]
dy = [0 for _ in range(h*w+5)]

for i in range(h):
    for j in range(w):
        dx[a[i][j]] = i
        dy[a[i][j]] = j

dfromd = [0 for _ in range(h*w+1)]

for i in range(d+1,h*w+1):
        dfromd[i] = dfromd[i-d]+abs(dx[i-d]-dx[i])+abs(dy[i-d]-dy[i])

q = int(input())
for _ in range(q):
    l,r=map(int,input().split())
    print(dfromd[r]-dfromd[l])
Buggy python submission (verdict: Time Limit Exceeded):
import sys
sys.setrecursionlimit(10**7)

n,m=map(int,input().split())
g=[[] for _ in range(n)]
for _ in range(m):
    l,r,d=map(int,input().split())
    g[l-1].append([r-1,d])
    g[r-1].append([l-1,d*(-1)])
f=[False for _ in range(n)]

def dfs(s,x):
    f[s] = x
    for sg in g[s]:
        if type(f[sg[0]]) == bool:
            if not dfs(sg[0],sg[1]+x):
                return False
        else:
            if f[sg[0]] - f[s] != sg[1]:
                return False
    return True

def main():
    for i in range(n):
        if type(f[i]) == bool:
            if not dfs(i,1):
                return "No"
    return "Yes"

print(main())

Fixed submission:
import sys
sys.setrecursionlimit(10**7)

n,m=map(int,input().split())
g=[[] for _ in range(n)]
for _ in range(m):
    l,r,d=map(int,input().split())
    g[l-1].append([r-1,d])
    g[r-1].append([l-1,d*(-1)])
f=[False for _ in range(n)]

def dfs(s,x):
    f[s] = x
    for sg in g[s]:
        if type(f[sg[0]]) == bool:
            if not dfs(sg[0],sg[1]+x):
                return False
        else:
            if f[sg[0]] - f[s] != sg[1]:
                return False
    return True

def main():
    for i in range(n):
        if type(f[i]) == bool:
            if not dfs(i,1):
                return "No"
    return "Yes"

print(main())

Buggy python submission (verdict: Time Limit Exceeded):
import sys
sys.setrecursionlimit(10**7)

n,m=map(int,input().split())
g=[[] for _ in range(n)]
for _ in range(m):
    l,r,d=map(int,input().split())
    g[l-1].append([r-1,d])
    g[r-1].append([l-1,d*(-1)])
INF = 10**10
f=[INF for _ in range(n)]

def dfs(s,x):
    f[s] = x
    for sg in g[s]:
        if f[sg[0]] == INF:
            if not dfs(sg[0],sg[1]+x):
                return False
        else:
            if f[sg[0]] - f[s] != sg[1]:
                return False
    return True

def main():
    for i in range(n):
        if f[i] == INF:
            if not dfs(i,0):
                return "No"
    return "Yes"

print(main())

Fixed submission:
import sys
sys.setrecursionlimit(10**7)

n,m=map(int,input().split())
g=[[] for _ in range(n)]
for _ in range(m):
    l,r,d=map(int,input().split())
    g[l-1].append([r-1,d])
    g[r-1].append([l-1,d*(-1)])
f=[False for _ in range(n)]

def dfs(s,x):
    f[s] = x
    for sg in g[s]:
        if type(f[sg[0]]) == bool:
            if not dfs(sg[0],sg[1]+x):
                return False
        else:
            if f[sg[0]] - f[s] != sg[1]:
                return False
    return True

def main():
    for i in range(n):
        if type(f[i]) == bool:
            if not dfs(i,1):
                return "No"
    return "Yes"

print(main())
Buggy python submission (verdict: Time Limit Exceeded):
import math

q= int(input())
lrs = [list(map(int,input().split())) for l in range(q)]

def is_prime(n):
    if n == 1: return False

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False

    return True

primes = [0]
for i in range(1,10**5+3):
    if is_prime(i):
        primes.append(1)
    else:
        primes.append(0)

like20 = [0]
for i in range(1,10**5+3):
    if primes[i] == 1 and primes[(i+1) // 2] == 1:
        like20.append(1)
    else:
        like20.append(0)

for lr in lrs:
    l = lr[0]
    r = lr[1]
    print(sum(like20[l:r+1]))
    

Fixed submission:
import math

q= int(input())
lrs = [list(map(int,input().split())) for l in range(q)]

def is_prime(n):
    if n == 1: return False

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False

    return True

primes = [0]
for i in range(1,10**5+3):
    if is_prime(i):
        primes.append(1)
    else:
        primes.append(0)

like20 = [0]
for i in range(1,10**5+3):
    if primes[i] == 1 and primes[(i+1) // 2] == 1:
        like20.append(like20[i-1]+1)
    else:
        like20.append(like20[i-1])

for lr in lrs:
    print(like20[lr[1]] - like20[lr[0]-1])

Buggy python submission (verdict: Time Limit Exceeded):
import math

q= int(input())
lrs = [list(map(int,input().split())) for l in range(q)]

def is_prime(n):
    if n == 1: return False

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False

    return True

primes = [0]
for i in range(1,10**5+3):
    if is_prime(i):
        primes.append(1)
    else:
        primes.append(0)

like20 = [0]
for i in range(1,10**5+3):
    if primes[i] == 1 and primes[(i+1) // 2] == 1:
        like20.append(1)
    else:
        like20.append(0)

for lr in lrs:
    l = lr[0]
    r = lr[1]
    print(like20[l:r+1].count(1))
    

Fixed submission:
import math

q= int(input())
lrs = [list(map(int,input().split())) for l in range(q)]

def is_prime(n):
    if n == 1: return False

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False

    return True

primes = [0]
for i in range(1,10**5+3):
    if is_prime(i):
        primes.append(1)
    else:
        primes.append(0)

like20 = [0]
for i in range(1,10**5+3):
    if primes[i] == 1 and primes[(i+1) // 2] == 1:
        like20.append(like20[i-1]+1)
    else:
        like20.append(like20[i-1])

for lr in lrs:
    print(like20[lr[1]] - like20[lr[0]-1])
Buggy python submission (verdict: Runtime Error):
n,Z,W=map(int,input().split())
a=list(map(int,input().split()))
res = max(abs(a[-1]-W),abs(a[-1]-a[-2]))
print(res)

Fixed submission:
n,Z,W=map(int,input().split())
a=list(map(int,input().split()))
res = abs(a[-1]-W)
if len(a) > 1:
    res = max(res,abs(a[-1]-a[-2]))
print(res)
Buggy python submission (verdict: Runtime Error):
n,a=map(int,input().split())
print(n*n-a)

Fixed submission:
n=int(input())
a=int(input())
print(n*n-a)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
l=[]
for _ in range(n):
    a = int(input())
    if a in l:
        l.remove(a)
    else:
        l.append(a)
print(len(l))

Fixed submission:
import collections
n=int(input())
a=[int(input()) for _ in range(n)]
ca = collections.Counter(a)
cak = list(ca.values())
res = [i for i in cak if i % 2 ==1]
print(len(res))
Buggy python submission (verdict: Time Limit Exceeded):
import itertools

n,m,R=map(int,input().split())
r=list(map(int,input().split()))
INF = 10**10
d=[[INF for i in range(n)] for i in range(n)]

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

for k in range(n):
    for i in range(n):
        for j in range(n):
            d[i][j] = min(d[i][j] ,d[i][k] +d[k][j])

for i in range(R):
    r[i] -= 1

res = INF
for rp in itertools.permutations(r):
    tres = 0
    for i in range(R-1):
        tres += d[rp[i]][rp[i+1]]
    res = min(res,tres)

print(res)

Fixed submission:
import itertools

n,m,R=map(int,input().split())
r=list(map(int,input().split()))
INF = 10**10
d=[[INF for i in range(n)] for i in range(n)]

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

for k in range(n):
    for i in range(n):
        for j in range(n):
            d[i][j] = min(d[i][j] ,d[i][k] +d[k][j])

for i in range(R):
    r[i] -= 1

res = INF
for rp in itertools.permutations(r):
    tres = 0
    for i in range(R-1):
        tres += d[rp[i]][rp[i+1]]
    res = min(res,tres)

print(res)
Buggy python submission (verdict: Runtime Error):
n = int(input())
s1=input()
s2=input()
mod = 10**9+7
l = []
for i in range(0,n-1):
    if s1[i] != s1[i+1]:
        if s1[i] != s2[i]:
            l.append(0)
        else:
            l.append(1)
if s1[n-1]==s2[n-1]: l.append(1)
if l[0]:
    res = 3
else:
    res = 6

for i in range(1,len(l)):
    if l[i-1] and l[i]:
        res *= 2
    elif l[i-1] and  not l[i]:
        res *= 2
    elif not l[i-1] and not l[i]:
        res *= 3

print(res % mod)

Fixed submission:
n = int(input())
s1=input()
s2=input()
mod = 10**9+7
l = []
for i in range(0,n-1):
    if s1[i] != s1[i+1]:
        if s1[i] != s2[i]:
            l.append(0)
        else:
            l.append(1)
if s1[n-1]==s2[n-1]:
    l.append(1)
else:
    l.append(0)
if l[0]:
    res = 3
else:
    res = 6

for i in range(1,len(l)):
    if l[i-1] and l[i]:
        res *= 2
    elif l[i-1] and  not l[i]:
        res *= 2
    elif not l[i-1] and not l[i]:
        res *= 3

print(res % mod)