Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
S = input()
T = input()

if S == T:
    print(Yes)
l = len(S)
L = list(S)
for i in range(l):
    a = L[0]
    del L[0]
    L.append(a)
    s = ''.join(L)
    if s == T:
        print('Yes')
        break
else:
    print('No')

Fixed submission:
S = input()
T = input()

if S == T:
    print('Yes')
else:
    l = len(S)
    L = list(S)
    for i in range(l):
        a = L[0]
        del L[0]
        L.append(a)
        s = ''.join(L)
        if s == T:
            print('Yes')
            break
    else:
        print('No')
Buggy python submission (verdict: Runtime Error):
S = input()
plus = count('+')
minus = count('-')
print( plus - minus )

Fixed submission:
S = input()
plus = S.count('+')
minus = S.count('-')
print( plus - minus )
Buggy python submission (verdict: Runtime Error):
A, B = map(int,input().split())
for i in range(A, B+1):
  str_i = str(i)
  if str_i[0] == str_i[4] and str_i[1] == str_i[2]:
    ans += 1
  else:
    continue

print(ans)

Fixed submission:
A, B = map(int,input().split())
ans = 0
for i in range(A, B+1):
  str_i = str(i)
  if str_i[0] == str_i[4] and str_i[1] == str_i[3]:
    ans += 1
  else:
    continue

print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
li_str = input().split()
li_int = []
for i in li_str:
    li_int.append(int(i))
count= 1
for i in li_int:
    if i == count:
        num = count
        count += 1
print(N - num)

Fixed submission:
N = int(input())
li_str = input().split()
li_int = []
for i in li_str:
    li_int.append(int(i))
count= 1
num =  N + 1
for i in li_int:
    if i == count:
        num = count
        count += 1
print(N - num)

Buggy python submission (verdict: Runtime Error):
N = int(input())
li_str = input().split()
li_int = []

for i in li_str:
    li_int.append(int(i))
count= 1
for i in li_int:
    if i == count:
        count += 1
        num = count
print(num)

Fixed submission:
N = int(input())
li_str = input().split()
li_int = []
for i in li_str:
    li_int.append(int(i))
count= 1
num =  N + 1
for i in li_int:
    if i == count:
        num = count
        count += 1
print(N - num)
Buggy python submission (verdict: Runtime Error):
N=int(input())
A=list(map(int, input().split()))
n=0
while all(a%2==0 for a in A):
    A=[a/2 for a in A]
    n+=1
print(n)

Fixed submission:
print(input().count('1'))
Buggy python submission (verdict: Time Limit Exceeded):
K,S=map(int, input().split())
n=0
for x in range(K+1):
    for y in range (K+1):
        for z in range(K+1):
            if x+y+z==S:
                n+=1
print(n)

Fixed submission:
K,S=map(int, input().split())
n=0
for x in range(K+1):
    for y in range (K+1):
        if 0<=S-x-y<=K:
                n+=1
print(n)

Buggy python submission (verdict: Time Limit Exceeded):
K,S=map(int, input().split())
n=0
for x in range(K+1):
    for y in range (K+1):
        for z in range(K+1):
            if x+y+z==S:
                n+=1
print(n)

Fixed submission:
K,S=map(int, input().split())
n=0
for x in range(K+1):
    for y in range (K+1):
        if 0<=S-x-y<=K:
                n+=1
print(n)
Buggy python submission (verdict: Runtime Error):
from itertools import groupby
s = input()
k = int(input())
l = [[k, len(list(g))] for k, g in groupby(s)]
ans = 0
ans2 = 0
for i in range(len(l)):
  if l[i][1] > 1:
    ans += l[i][1] // 2
if len(l) > 1:
  if l[0][0] == l[-1][0]:
    if l[0][1] % 2 == 1 and  l[-1][1] % 2 == 1 :
        ans2 = k - 1
if len(s) == 1:
  print(k // 2)
elif len(l) == 1:
  if l[0][1] % 2 == 1:
    print(((l[0][1] // 2) * k + (k - 1))
  else:
    print((l[0][1] // 2) * k)
else:
  print(ans * k + ans2)
    



Fixed submission:
from itertools import groupby
s = input()
k = int(input())
l = [[k, len(list(g))] for k, g in groupby(s)]
ans = 0
ans2 = 0
for i in range(len(l)):
  if l[i][1] > 1:
    ans += l[i][1] // 2
if len(l) > 1:
  if l[0][0] == l[-1][0]:
    if l[0][1] % 2 == 1 and  l[-1][1] % 2 == 1 :
        ans2 = k - 1
if len(s) == 1:
  print(k // 2)
elif len(l) == 1:
  #if l[0][1] % 2 == 1:
  #  print(((l[0][1] // 2) * k + (k - 1)))
  #else:
  print(len(s) * k // 2)
else:
  print(ans * k + ans2)
Buggy python submission (verdict: Runtime Error):
n,k=map(int,input().split())
h=list(map(int,input().split()))
h=filter(lambda x => k, h)
print(len(h))

Fixed submission:
n,k=map(int,input().split())
h=list(map(int,input().split()))
h=list(filter(lambda x:x >= k, h))
print(len(h))
Buggy python submission (verdict: Time Limit Exceeded):
n,k,q = map(int,input().split())
a = [0] * q
for i in range(q):
  a[i] = int(input())
for i in range(1,n +1):
  c = q - a.count(i)
  if k - c > 0 :
    print('Yes')
  else:
    print('No')

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

m = q - k + 1
for i in range(1,n +1):
  if b[i] >= m:
    print('Yes')
  else:
    print('No')
Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
a = sorted(list(map(int,input().split())),reverse=True)
t = [a.pop(0)//2]

for i in range(0,m - 1):
  l = t.index(max(t))
  if a[0] > t[l]:
    t.append(a.pop(0)//2)
  else:
    t[l] = t[l]//2
print(sum(t) + sum(a))



Fixed submission:
import heapq
import math
n,m=map(int,input().split())
a = list(map(int,input().split()))
h = []
for _a in a:
  heapq.heappush(h,-_a)
for i in range(m):
  heapq.heappush(h,math.ceil(heapq.heappop(h) / 2))
print(sum(h)*(-1))

Buggy python submission (verdict: Time Limit Exceeded):
n,m=map(int,input().split())
a = list(map(int,input().split()))
for i in range(1,m+1):
  l = a.index(max(a))
  a[l] = a[l] // 2
print(sum(a))



Fixed submission:
import heapq
import math
n,m=map(int,input().split())
a = list(map(int,input().split()))
h = []
for _a in a:
  heapq.heappush(h,-_a)
for i in range(m):
  heapq.heappush(h,math.ceil(heapq.heappop(h) / 2))
print(sum(h)*(-1))
Buggy python submission (verdict: Time Limit Exceeded):
a,b = map(int,input().split())

ans = 1
c = a
while True:
  if c < b:
    c = c -1 + a
    ans = ans + 1
  else:
    print(ans)


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

ans = 0
c = 1
while True:
  if c >= b:
    print(ans)
    break
  else:
    c = c -1 + a
    ans += 1
Buggy python submission (verdict: Runtime Error):
n = int(input())
ans = [0] * n
for i in range(1,n):
  ans[i - 1] = i   
print(sum(ans))

Fixed submission:
import math
n = int(input())
print(math.floor(((n-1)*(n-1+1))//2))

Buggy python submission (verdict: Runtime Error):
n = int(input())
ans = [0] * n
for i in range(1,n):
  ans[i] = i
   
print(sum(ans))
  
  

Fixed submission:
import math
n = int(input())
print(math.floor(((n-1)*(n-1+1))//2))

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
ans = 0
for i in range(1,n+1):
  if i != n:
    ans += i%(i+1)
  else:
    ans += i%1
print(ans)
  
  

Fixed submission:
import math
n = int(input())
print(math.floor(((n-1)*(n-1+1))//2))
Buggy python submission (verdict: Time Limit Exceeded):
import sys
n = int(input())
l = list(map(int, (input().split())))

for i in range(n):
    if len([ a for a in l if  l[0] -1 > a]) > 0:
        print('No')
        sys.exit()
    else:
        l = l[1::]
print('Yes')


Fixed submission:
import sys
n = int(input())
l = list(map(int, (input().split())))

max = l[0]
for i in range(n):
    if max - 1 > l[i]:
        print('No')
        sys.exit()
    elif l[i] > max:
        max = l[i]
print('Yes')

Buggy python submission (verdict: Time Limit Exceeded):
import sys
n = int(input())
l = list(map(int, (input().split())))

for i in range(n):
    if len([ a for a in l if  l[0] -1 > a]) > 0:
        print('No')
        sys.exit()
    else:
        l = l[i::]
print('Yes')


Fixed submission:
import sys
n = int(input())
l = list(map(int, (input().split())))

max = l[0]
for i in range(n):
    if max - 1 > l[i]:
        print('No')
        sys.exit()
    elif l[i] > max:
        max = l[i]
print('Yes')

Buggy python submission (verdict: Time Limit Exceeded):
import sys
n = int(input())
l = list(map(int, (input().split())))

for i in range(n):
    if len([ a for a in l[i::] if  l[i] -1 > a]) > 0:
        print('No')
        sys.exit()
print('Yes')


Fixed submission:
import sys
n = int(input())
l = list(map(int, (input().split())))

max = l[0]
for i in range(n):
    if max - 1 > l[i]:
        print('No')
        sys.exit()
    elif l[i] > max:
        max = l[i]
print('Yes')
Buggy python submission (verdict: Runtime Error):
import sys
import math
from fractions import gcd

a,b,c,d = (int(i) for i in input().split())

c1 = b // c - (a - 1) // c
d1 = b // d - (a - 1) // d
cd = (c * d) //math.gcd(c,d)
cd1 = b // cd - (a - 1) // cd



print((b - a + 1) - c1 - d1 + cd1)

Fixed submission:
import sys
import math
from fractions import gcd

a,b,c,d = (int(i) for i in input().split())

c1 = b // c - (a - 1) // c
d1 = b // d - (a - 1) // d
cd = (c * d) //gcd(c,d)
cd1 = b // cd - (a - 1) // cd



print((b - a + 1) - c1 - d1 + cd1)

Buggy python submission (verdict: Runtime Error):
import sys
import math

a,b,c,d = (int(i) for i in input().split())

c1 = b // c - (a - 1) // c
d1 = b // d - (a - 1) // d
cd = (c * d) //math.gcd(c,d)
cd1 = b // cd - (a - 1) // cd


print((b - a + 1) - c1 - d1 + cd1)

Fixed submission:
import sys
import math
from fractions import gcd

a,b,c,d = (int(i) for i in input().split())

c1 = b // c - (a - 1) // c
d1 = b // d - (a - 1) // d
cd = (c * d) //gcd(c,d)
cd1 = b // cd - (a - 1) // cd



print((b - a + 1) - c1 - d1 + cd1)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
import math

n,q = map(int, input().split())
s = input()
l = [0] * q
r = [0] * q
for i in range(q):
    l[i], r[i] = map(int, input().split())

for j in range(q):
    print( s[l[j] - 1:r[j]].count('AC'))


Fixed submission:
import sys
import math

n,q = map(int, input().split())
s = input()

left = [0] * n

for i in range(n):
    if i:
        if s[i-1:i+1] == 'AC':
            left[i] = left[i - 1] + 1
        else:
            left[i] = left[i - 1] 
for i in range(q):
    l, r = map(int, input().split())
    print(left[r - 1] - left[l - 1])
Buggy python submission (verdict: Time Limit Exceeded):
import sys
import math

#sys.setrecursionlimit(10000)

n,k = map(int, input().split())
h = sorted(list(map(int, (input() for i in range(n)))))

l = [0] * (n-1)
for i in range(n - 1):
    l[i] = h[i + 1] - h[i]

ans = max(l)
for j in range(len(l) - (k - 2)):
    ans = min(ans,sum(l[j:j + k - 1]))

print(ans)


Fixed submission:
import sys
import math

#sys.setrecursionlimit(10000)

n,k = map(int, input().split())
h = sorted(list(map(int, (input() for i in range(n)))))

ans = max(h)

for i in range(n - k + 1):
    ans = min(ans,h[i + k - 1] - h[i])
print(ans)

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

#sys.setrecursionlimit(10000)

n,k = map(int, input().split())
h = sorted(list(map(int, (input() for i in range(n)))))

l = []
for i in range(n - 1):
    l.append(h[i + 1] - h[i])

ans = max(l)
for j in range(len(l) - (k - 2)):
    ans = min(ans,sum(l[j:j + k - 1]))

print(ans)


Fixed submission:
import sys
import math

#sys.setrecursionlimit(10000)

n,k = map(int, input().split())
h = sorted(list(map(int, (input() for i in range(n)))))

ans = max(h)

for i in range(n - k + 1):
    ans = min(ans,h[i + k - 1] - h[i])
print(ans)
Buggy python submission (verdict: Runtime Error):
import sys

s=int(input())
k=int(input())

for i in range(len(s)):
  if s[i] != '1':
    print(s[i])
    break
  elif i == k - 1:
    break    
        

Fixed submission:
import sys
 
s=input()
k=int(input())
 
for i in range(len(s)):
  if s[i] != '1':
    print(s[i])
    break
  elif i == k - 1:
    print(1)
    break
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))
 
ans = 0
while True:
  e = [i for i in a if i % 2 == 0]
  #print(e)
  if len(e) != 0:
    e_max = max(e)
    a = [i / 2 if i == e_max else i * 3 for i in e]
    ans += 1
  else:
    break
print(ans)

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
 
ans = 0
e = [i for i in a if i % 2 == 0]
for i in e:
  sum = 0
  while True:
    i = i / 2
    sum += 1
    if i % 2 != 0:
      break
  ans += sum
print(ans)

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

ans = 0
while True:
  e_max = max([i for i in a if i % 2 == 0])
  if len(e_max) != 0:
    a = [i / 2 if i == e_max else i * 3 for i in a]
    ans += 1
print(ans)
  

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
 
ans = 0
e = [i for i in a if i % 2 == 0]
for i in e:
  sum = 0
  while True:
    i = i / 2
    sum += 1
    if i % 2 != 0:
      break
  ans += sum
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = input()

ans = n
for i in range(1,n):
  w = s[:i - 1].count('W')
  e = s[i:].count('E')
  ans = min(ans,w+e)
  
print(ans)

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

w = 0
e = s.count('E')
ans = s.count('E')
for i in range(n):
  if i:
    if s[i - 1] == 'W':
      w += 1
  if s[i] == 'E':
    e -= 1
  ans = min(ans,w + e)
    
print(ans)
Buggy python submission (verdict: Runtime Error):
import sys
h,w = map(int,input().split())
s = ['']*w
for i in range(h):
  s[i] = input()
 
for i in range(h):
  for j in range(w):
    if s[i][j] == '#':
      if j != w - 1:
        if s[i][j + 1] == '#':
          continue
      elif  j != 0:
        if s[i][j - 1] == '#':
          continue
      elif i != h - 1:
        if s[i + 1][j] == '#':
          continue
      elif i != 0:
        if s[i - 1][j] == '#':
          continue
      else:
        print('No')
        sys.exit()
print('Yes')

Fixed submission:
import sys
h,w = map(int,input().split())
s = ['']*h
for i in range(h):
  s[i] = input()
 
black = False
for i in range(h):
  for j in range(w):
    if s[i][j] == '#':
      if j != w - 1:
        if s[i][j + 1] == '#':
          continue
      if  j != 0:
        if s[i][j - 1] == '#':
          continue
      if i != h - 1:
        if s[i + 1][j] == '#':
          continue
      if i != 0:
        if s[i - 1][j] == '#':
          continue
      print('No')
      sys.exit()       
print('Yes')

Buggy python submission (verdict: Runtime Error):
import sys
h,w = map(int,input().split())
s = ['']*w
for i in range(h):
  s[i] = input()

for i in range(h):
  for j in range(w):
    if s[i][j] == '#':
      if j != w and s[i][j + 1] == '#':
        continue
      elif  j != 0 and s[i][j - 1] == '#':
        continue
      elif i != h and s[i + 1][j] == '#':
        continue
      elif i != 0 and s[i - 1][j] == '#':
        continue
      else:
        print('No')
        sys.exit()
print('Yes')
  

Fixed submission:
import sys
h,w = map(int,input().split())
s = ['']*h
for i in range(h):
  s[i] = input()
 
black = False
for i in range(h):
  for j in range(w):
    if s[i][j] == '#':
      if j != w - 1:
        if s[i][j + 1] == '#':
          continue
      if  j != 0:
        if s[i][j - 1] == '#':
          continue
      if i != h - 1:
        if s[i + 1][j] == '#':
          continue
      if i != 0:
        if s[i - 1][j] == '#':
          continue
      print('No')
      sys.exit()       
print('Yes')
Buggy python submission (verdict: Time Limit Exceeded):
import statistics
import math
import copy

n = int(input())
x = list(map(int,input().split()))

for i in range(n):
  tmp = copy.copy(x)
  tmp.pop(i)
  print(statistics.median(tmp))


Fixed submission:

n = int(input())
x = list(map(int,input().split()))
sort_x = sorted(x)

mid_1 = sort_x[n//2-1]
mid_2 = sort_x[n//2]

for i in range(n):
  
  if x[i] <= mid_1:
    print(mid_2)
  else:
    print(mid_1)

Buggy python submission (verdict: Runtime Error):
import statistics
import math

n = int(input())
x = list(map(int,input().split()))

for i in range(n):
  tmp = x
  print(statistics.median(x.pop(i)))

Fixed submission:

n = int(input())
x = list(map(int,input().split()))
sort_x = sorted(x)

mid_1 = sort_x[n//2-1]
mid_2 = sort_x[n//2]

for i in range(n):
  
  if x[i] <= mid_1:
    print(mid_2)
  else:
    print(mid_1)
Buggy python submission (verdict: Runtime Error):
import sys
input=sys.stdin.readline
mod=1e9+7

if __name__ == '__main__':
    N,M=list(map(int,input().split()))
    S=list(map(int,input().split()))
    T=list(map(int,input().split()))
    dp=[[0 for i in range(M+1)] for j in range(N+1)]
    for i in range(N+1):
        dp[i][0]=1
    for i in range(M+1):
        dp[0][i]=1


    for i in range(N):
        for j in range(M):
            dp[i + 1][j + 1] = dp[i + 1][j]+dp[i ][j + 1]-dp[i][j]
            if S[i]==T[j]:
                dp[i+1][j+1]+=dp[i][j]

    print(int(dp[N][M]%mod))


Fixed submission:
mod=1e9+7
import sys
input=sys.stdin.readline

if __name__ == '__main__':
    N,M=list(map(int,input().split()))
    S=list(map(int,input().split()))
    T=list(map(int,input().split()))
    sum=[[0 for i in range(M+1)] for j in range(N+1)]
    dp=[[0 for i in range(M+1)] for j in range(N+1)]

    for i in range(N):
        for j in range(M):
            if S[i]==T[j]:
                dp[i+1][j+1]+=sum[i][j]+1
                dp[i+1][j+1]%=mod
            else:
                dp[i + 1][j + 1] =0

            sum[i+1][j+1]=sum[i][j+1]+sum[i+1][j]-sum[i][j]+dp[i+1][j+1]
            sum[i + 1][j + 1]%=mod


    ans=sum[N][M]+1
    print(int(ans))
Buggy python submission (verdict: Runtime Error):
import math
n,k=list(map(int,input().split()))
c=list(map(int,input().split()))
m=math.inf
for i in range(n-k+1):
        l=c[i]
        r=c[i+k-1]
        m=min(m,abs(l)+abs(r-l),abs(r)+abs(r-l))

print(m)

Fixed submission:
N, K, *x = map(int, open(0).read().split())
ans = 1e9
for i in range(N - K + 1):
    l = x[i]
    r = x[i + K - 1]
    ans = min(ans, abs(l) + (r - l), abs(r) + (r - l))
    
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n,k=list(map(int,input().split()))
candles=list(map(int,input().split()))
rows=[]
minimum=[]
for i in range(n-k+1):
        new=candles[i:i+k]
        l_r=abs(new[0])+abs(new[-1]-new[0])
        r_l=abs(new[-1])+abs(new[-1]-new[0])
        minimum.append(min(l_r,r_l))

print(min(minimum))

Fixed submission:
N, K, *x = map(int, open(0).read().split())
ans = 1e9
for i in range(N - K + 1):
    l = x[i]
    r = x[i + K - 1]
    ans = min(ans, abs(l) + (r - l), abs(r) + (r - l))
    
print(ans)
Buggy python submission (verdict: Runtime Error):
from sympy import factorint

def judge(a):
    primes=factorint(a)
    if 2 in primes.keys():
        return primes[2]
    else:
        return 0

if __name__ == '__main__':
    N=int(input())
    A=list(map(int,input().split()))
    count=0
    for a in A:
        count+=judge(a)

    print(count)



    

Fixed submission:

def judge(a):
    ans=0
    while a%2==0:
        a/=2
        ans+=1
    return ans

if __name__ == '__main__':
    N=int(input())
    A=list(map(int,input().split()))
    count=0
    for a in A:
        count+=judge(a)

    print(count)
Buggy python submission (verdict: Time Limit Exceeded):


if __name__ == '__main__':
    N,M=list(map(int,input().split()))
    data=[list(map(int,input().split())) for i in range(N)]
    dp=[[None] for i in range(M+1) for j in range(N+1)]
    import itertools
    ans=0
    for combination in itertools.combinations(data,M):
        temp1=0
        temp2=0
        temp3=0
        for cake in combination:
            temp1+=cake[0]
            temp2+=cake[1]
            temp3+=cake[2]
        ans=max(abs(temp1)+abs(temp2)+abs(temp3),ans)
    print(ans)







Fixed submission:
power=[1,2]

if __name__ == '__main__':
    N,M=list(map(int,input().split()))
    data=[list(map(int,input().split())) for i in range(N)]
    ans=0
    for i in power:
        for j in power:
            for k in power:
                temp=[]
                for cake in data:
                    temp.append(cake[0]*(-1)**i+cake[1]*(-1)**j+cake[2]*(-1)**k)
                temp.sort()
                temp2=temp[-M:]
                ans=max(ans,sum(temp2))

    if M==0:
        print(0)
    else:
        print(ans)
Buggy python submission (verdict: Runtime Error):
import math

if __name__ == '__main__':
    N=int(input())
    power_nine=int(math.log(N,9)+1)
    power_six=int(math.log(N,6)+1)

    dp=[math.inf]*(N+1)
    for i in range(min(6,N+1)):
        dp[i]=i
    for i in range(N+1):
        for j in range(1,power_six):
            if i+6**j<=N:
                dp[i+6**j]=min(dp[i+6**j],dp[i]+1)
        for j in range(1, power_nine):
            if i + 9 ** j <= N:
                dp[i + 9 ** j] = min(dp[i + 9 ** j], dp[i] + 1)


    print(dp[N])




Fixed submission:

if __name__ == '__main__':
    N=int(input())

    dp=[100000000000]*(N+1)
    for i in range(min(6,N+1)):
        dp[i]=i
    for i in range(N+1):
        for j in range(1,7):
            if i+6**j<=N:
                dp[i+6**j]=min(dp[i+6**j],dp[i]+1)
        for j in range(1, 6):
            if i + 9 ** j <= N:
                dp[i + 9 ** j] = min(dp[i + 9 ** j], dp[i] + 1)


    print(dp[N])
Buggy python submission (verdict: Time Limit Exceeded):

if __name__ == '__main__':
    N=int(input())
    sheet=[]
    for i in range(N):
        temp=int(input())
        sheet.append(temp)

    sheet.sort()
    count=0
    for i in range(len(sheet)):
        number=sheet.count(sheet[i])
        if number%2==1:
            count+=1

    print(count)

Fixed submission:

if __name__ == '__main__':
    N=int(input())
    sheet=[]
    for i in range(N):
        temp=int(input())
        sheet.append(temp)
    sheet.sort()
    count=0
    i=0
    while i<N:
        s=sheet[i]
        j=i
        while i<N and sheet[i]==s:
            i+=1
        d=i-j
        if d%2==1:
            count+=1

    print(count)

Buggy python submission (verdict: Time Limit Exceeded):

if __name__ == '__main__':
    N=int(input())
    sheet=[]
    for i in range(N):
        temp=int(input())
        if temp not in sheet:
            sheet.append(temp)
        else:
            sheet.remove(temp)

    print(len(sheet))

Fixed submission:

if __name__ == '__main__':
    N=int(input())
    sheet=[]
    for i in range(N):
        temp=int(input())
        sheet.append(temp)
    sheet.sort()
    count=0
    i=0
    while i<N:
        s=sheet[i]
        j=i
        while i<N and sheet[i]==s:
            i+=1
        d=i-j
        if d%2==1:
            count+=1

    print(count)
Buggy python submission (verdict: Time Limit Exceeded):
if __name__ == '__main__':
    N,K=list(map(int,input().split()))
    L=[]
    for i in range(N):
        a,b=list(map(int,input().split()))
        for j in range(b):
            L.append(a)
    L.sort()
    print(L[K-1])

Fixed submission:
if __name__ == '__main__':
    N,K=list(map(int,input().split()))
    AB=[tuple(map(int,input().split())) for i in range(N)]
    AB.sort(key=lambda x:x[0])
    for a,b in AB:
        K-=b
        if K<=0:
            print(a)
            break