input
stringlengths
20
127k
target
stringlengths
20
119k
problem_id
stringlengths
6
6
n, m = list(map(int, input().split())) work = [tuple(map(int, input().split())) for _ in range(n)] work.sort(key = lambda x: (x[1], -x[0]), reverse = True) do = [0] * (m+1) money = 0 for a, b in work: if a > m: continue while do[a] != 0: a += 1 if a > m: break ...
import bisect as bi n, m = list(map(int, input().split())) work = [tuple(map(int, input().split())) for _ in range(n)] work.sort(key = lambda x: (x[1], -x[0]), reverse = True) ava = list(range(0, m+1)) money = 0 for a, b in work: if a > m: continue l = bi.bisect_left(ava, a) if l >= len(av...
p02948
import sys from heapq import heappush, heappop input = sys.stdin.readline def main(): N, M = list(map(int, input().split())) jobs = {} for _ in range(N): A, B = list(map(int, input().split())) if A > M: continue if A in list(jobs.keys()): jobs[A] ...
import sys from heapq import heappush, heappop input = sys.stdin.readline def main(): N, M = list(map(int, input().split())) jobs = {} for _ in range(N): A, B = list(map(int, input().split())) if A > M: continue if A in list(jobs.keys()): jobs[A] ...
p02948
# ABC137 D - Summer Vacation import heapq as hp n,m=list(map(int,input().split())) AB=[[] for i in range(m+1)] l=[] for i in range(n): a,b=list(map(int,input().split())) if a<=m: AB[a].append(-b) ans=0 hp.heapify(l) for ab in AB: for x in ab: hp.heappush(l,x) if len(l)>0: ...
import heapq as hp n,m=list(map(int,input().split())) AB=[[] for i in range(m+1)] for i in range(n): a,b=list(map(int,input().split())) if a<=m: AB[a].append(-b) ans=0 l=[] hp.heapify(l) for ab in AB: for t in ab: hp.heappush(l,t) if len(l)>0: ans-=hp.heappop(l) print(ans)
p02948
import heapq n,m=list(map(int, input().split())) a=[list(map(int, input().split())) for i in range(n)] a.sort(key=lambda x: x[1],reverse=True) x=[1 for i in range(m)] ans=0 count=0 q=[] for i in range(1,m+1): for j in range(n): if a[j][0]==i: heapq.heappush(q,-a[j][1]) i...
import heapq n,m=list(map(int, input().split())) a=[list(map(int, input().split())) for i in range(n)] a.sort() x=[1 for i in range(m)] ans=0 q=[] cnt=0 for i in range(1,m+1): for j in range(cnt,n): if a[j][0]==i: heapq.heappush(q,-a[j][1]) cnt+=1 else: ...
p02948
from collections import deque import sys def input(): return sys.stdin.readline()[:-1] N, M = list(map(int, input().split())) C = {} for _ in range(N): A,B = list(map(int, input().split())) if not A in C: C[A] = [] C[A].append(B) for i in C: C[i] = deque(sorted(C[i])[::-1]) ...
import heapq N, M = list(map(int, input().split())) C = {} for _ in range(N): A,B = list(map(int, input().split())) if A in C: C[A].append(B) else: C[A] = [] C[A].append(B) for i in C: C[i] = sorted(C[i])[::-1] answer = 0 tmp = [] heapq.heapify(tmp) for i in ra...
p02948
# ABC-137-D import heapq import bisect N, M = list(map(int, input().split())) AB = []#Aでソートをかけて利用する。 BA = []#Bでソートをかけてheapqで利用する。 heapq.heapify(BA) for _ in range(N): A, B = list(map(int, input().split())) AB.append((A, B)) AB = sorted(AB) ans = 0 check_M = 1 while check_M <= M: r = bi...
# ABC-137-D import heapq N, M = list(map(int, input().split())) day_value = [[] for _ in range(M+1)] for _ in range(N): A, B = list(map(int, input().split())) if A <= M: day_value[A].append(B) ans = 0 check_M = 1 BA = [] heapq.heapify(BA) while check_M <= M: for item in day_valu...
p02948
import sys import heapq input = sys.stdin.readline n, m = list(map(int, input().split())) sum = 0 # Aiが最小のものから順に選ぶ # 重複するときは最大金額を選び残りはAiを+1する # Ai>Mのものは最初から除外 # 受け取りにA日かかるということはM-A+1日目までに受けなければならない # index = M-A(day) # element = B(reword) schedule = [[] for _ in range(m+1)] for _ in range(n): day...
import sys from heapq import heappop, heappush input = sys.stdin.readline n, m = list(map(int, input().split())) # Ai>Mのものは最初から除外 # Aiが最小のものから順に選ぶ # index = A(day-1), element = B(reword) schedule = [[] for _ in range(m)] for _ in range(n): day, reword = list(map(int, input().split())) if day > m: ...
p02948
def dfs(l, r): if (l, r) in cache: return cache[(l, r)] if l == r: return 0 return min(dfs(l, m) + dfs(m + 1, r) + L[l][1] * L[m][0] * L[m + 1][1] * L[m + 1][0] for m in range(l, r)) cache = {} L = [list(map(int, input().split())) for _ in range(eval(input()))] print(dfs(0, len...
def dfs(l, r): if l == r: return 0 if (l, r) in cache: return cache[(l, r)] cache[(l, r)] = min(dfs(l, m) + dfs(m + 1, r) + L[l][0] * L[m][1] * L[m + 1][0] * L[r][1] for m in range(l, r)) return cache[(l, r)] cache = {} L = [list(map(int, input().split())) for _ in range(eval(i...
p00145
from functools import reduce def f(a,b): return [Card[a][0], Card[b][1]] n = int(input()) Card = [[] for _ in [0]*n] Cost = {} for i in range(n): Card[i] = list(map(int, input().split())) Cost[(i, i)] = 0 for i in range(1, n): for j in range(0, n-i): a = j+i Cost[(j, a)] = min([reduce(lambda a,b...
from functools import reduce n = int(input()) Card = [[] for _ in [0]*n] Cost = {} for i in range(n): Card[i] = list(map(int, input().split())) Cost[(i, i)] = 0 for i in range(1, n): for j in range(0, n-i): a = j+i Cost[(j, a)] = min([reduce(lambda a,b: a*b, [Card[j][0],Card[k][1],Card[k+1][0],Ca...
p00145
from functools import reduce n = int(input()) Card = [[] for _ in [0]*n] Cost = {} for i in range(n): Card[i] = list(map(int, input().split())) Cost[(i, i)] = 0 for i in range(1, n): for j in range(0, n-i): a = j+i Cost[(j, a)] = min([reduce(lambda a,b: a*b, [Card[j][0],Card[k][1],Card[k+1][0],Ca...
n = int(input()) Card = [[] for _ in [0]*n] Cost = {} for i in range(n): Card[i] = list(map(int, input().split())) Cost[(i, i)] = 0 for i in range(1, n): for j in range(0, n-i): a = j+i Cost[(j, a)] = min([Card[j][0] * Card[k][1] * Card[k+1][0] * Card[a][1] + Cost[(j, k)] + Cost[(k+1, a)] for k i...
p00145
from collections import Counter n, k = list(map(int, input().split())) l = list(map(int, input().split())) dic = Counter(l) ans = 0 kv = list(dic.items()) kv = sorted(kv, key=lambda x: x[1]) while len(kv) > k: ans += kv[0][1] del kv[0] print(ans)
from collections import Counter n, k = list(map(int, input().split())) dic = Counter(list(map(int, input().split()))) kv = list(dic.items()) kv = sorted(kv, key=lambda x: x[1]) ans = 0 cnt = 0 while len(kv)-cnt > k: ans += kv[cnt][1] cnt+=1 print(ans)
p03497
# ARC086C - Not so Diverse n, k = list(map(int, input().rstrip().split())) lst = sorted(list(map(int, input().rstrip().split()))) dic = {} for i in lst: if i not in dic: dic[i] = 1 else: dic[i] += 1 cnt = sorted([i for i in list(dic.values())], reverse=True) ans = 0 for i in range(l...
# ARC086C - Not so Diverse (ABC081C) n, k = list(map(int, input().rstrip().split())) lst = sorted(list(map(int, input().rstrip().split()))) dic = {} for i in lst: if i not in dic: dic[i] = 1 else: dic[i] += 1 cnt = sorted([i for i in list(dic.values())], reverse=True) print((n - sum(...
p03497
# ARC086C - Not so Diverse (ABC081C) from collections import Counter def main(): _, k, *a = list(map(int, open(0).read().split())) print((sum(sorted(list(Counter(a).values()), reverse=True)[k:]))) if __name__ == "__main__": main()
# ABC081C - Not so Diverse (ARC086C) from collections import Counter def main(): n, k = list(map(int, input().rstrip().split())) A = sorted(list(Counter(input().split()).values()), reverse=True) print((sum(A[k:]))) if __name__ == "__main__": main()
p03497
import collections n, k = list(map(int, input().split())) a = list(map(int, input().split())) b = collections.Counter(a) cnt = 0 c = b.most_common()[::-1] while len(c) > k: cnt += c[0][1] c.pop(0) print (cnt)
import collections n, k = list(map(int, input().split())) a = list(map(int, input().split())) b = collections.Counter(a) cnt = 0 c = b.most_common() s = 0 for i in range(len(c)): cnt += 1 if cnt > k: for j in range(i,len(c)): s += c[j][1] break print (s)
p03497
n, k = list(map(int, input().split())) L = list(map(int, input().split())) d = {} for a in L: if a not in d: d[a] = 1 else: d[a] += 1 l = [] for v in list(d.values()): l.append(v) if len(l) <= k: print((0)) else: ans = float('inf') for i in range(2 ** len(l)): ...
n, k = list(map(int, input().split())) L = list(map(int, input().split())) d = {} for a in L: if a not in d: d[a] = 1 else: d[a] += 1 l = [] for v in list(d.values()): l.append(v) l.sort(reverse=True) print((n - sum(l[:k])))
p03497
import os,re,sys,operator,math from collections import Counter,deque from operator import itemgetter from itertools import accumulate,combinations,groupby from sys import stdin,setrecursionlimit from copy import deepcopy import heapq setrecursionlimit(10**6) n,k=list(map(int,stdin.readline().rstrip().split())...
from collections import Counter n,k=list(map(int,input().split())) a=[int(i) for i in input().split()] c=Counter(a).most_common() c.sort(key=lambda x: x[1]) #print(c) l=len(c) print((sum(c[i][1] for i in range(l-k))))
p03497
import collections n, k = list(map(int, input().split())) a = list(map(int, input().split())) c = collections.Counter(a) vs = [] for v in list(c.values()): vs.append(v) vs.sort() i = 0 if len(vs) <= k: print(i) exit() else: while len(vs) > k: i += vs[0] vs = vs[1:] else: pri...
import collections n, k = list(map(int, input().split())) a = list(map(int, input().split())) c = collections.Counter(a) vs = [] for v in list(c.values()): vs.append(v) vs.sort(reverse=True) i = 0 if len(vs) <= k: print(i) exit() else: while len(vs) > k: i += vs[-1] vs.pop() else...
p03497
from collections import Counter n, m = list(map(int, input().split())) dic = Counter(list(map(int, input().split()))) lis = sorted(list(dic.items()), key=lambda x: x[1], reverse=True) res = 0 for i, x in enumerate(lis): if i < m: continue else: res += x[1] print(res)
from collections import Counter n, m = list(map(int, input().split())) dic = Counter(list(map(int, input().split()))) lis = sorted(list(dic.items()), key=lambda x: x[1], reverse=True) res = 0 for i in range(min(m, len(lis))): res += lis[i][1] print((n - res))
p03497
N, K=list(map(int, input().split())) A=list(map(int, input().split())) sa=set(A) if len(sa)<=K: print((0)) else: # 書き換える要素の種類数 sub=len(sa)-K # 少ないやつを書き換えたい a=list(sa) numl=[] for i in a: numl.append(A.count(i)) numl.sort() print((sum(numl[:sub])))
N, K=list(map(int, input().split())) A=list(map(int, input().split())) sa=set(A) if len(sa)<=K: print((0)) else: # 書き換える要素の種類数 sub=len(sa)-K # 少ないやつを書き換えたい A.sort() A.append(A[-1]) a=[0]*len(sa) j=0 for i in range(N): a[j]+=1 if A[i]!=A[i+1]: j+=1 a.sort() print...
p03497
n, k = list(map(int,input().split())) a = list(map(int,input().split())) aset = set(a) count = [] n = len(aset) for i in aset: count.append([i,a.count(i)]) if n <= k: print((0)) else: c = n - k count.sort(key=lambda x: x[1]) ans = 0 for i in range(c): ans += count[i][1] ...
n, k = list(map(int,input().split())) a = list(map(int,input().split())) a.sort() count = [] c = 1 for i in range(n-1): if a[i] != a[i+1]: count.append(c) c = 1 else: c += 1 if i == n - 2: count.append(c) l = len(count) #print(a) #print(count) c = 0 if l ...
p03497
n, k = list(map(int, input().split())) a = list(map(int, input().split())) ball = {} for i in a: if i in list(ball.keys()): ball[i] += 1 else: ball[i] = 1 ball = sorted(list(ball.items()), key=lambda x: -x[1]) ans = 0 if len(ball) > k: for i in range(k): ans += ball...
n, k = list(map(int, input().split())) a = list(map(int, input().split())) ball = {} for i in a: if i in ball: ball[i] += 1 else: ball[i] = 1 ball = sorted(list(ball.items()), key=lambda x: -x[1]) ans = 0 if len(ball) > k: for i in range(k): ans += ball[i][1] a...
p03497
import sys n, k = list(map(int, input().split())) A = list(map(int, input().split())) A_set = set(A) if len(A_set) <= k: print((0)) sys.exit() A_count = [0]*len(A_set) for i, a in enumerate(A_set): A_count[i] = A.count(a) A_count.sort() num = len(A_set) - k s = 0 for i in range(num): s...
n, k = list(map(int, input().split())) A = list(map(int, input().split())) num = [0]*n for a in A: num[a-1] += 1 num.sort(reverse=True) cnt = 0 for i in range(k): cnt += num[i] ans = n - cnt print(ans)
p03497
n, k = list(map(int, input().split())) a = list(map(int, input().split())) import collections count_dict = collections.Counter(a) # print(count_dict.most_common()) ans = 0 for i in range(len(count_dict) - k): ans += count_dict.most_common()[len(count_dict)-i-1][1] print(ans)
n, k = list(map(int, input().split())) a = list(map(int, input().split())) import collections count_dict = collections.Counter(a) # print(count_dict.most_common()) ans = 0 unique = count_dict.most_common() for i in range(len(count_dict) - k): ans += unique[len(count_dict)-i-1][1] print(ans)
p03497
n, k = list(map(int, input().split())) A = list(map(int, input().split())) array = [] ans = 0 for i in set(A): array.append(A.count(i)) array.sort() if len(set(A)) > k: num = len(array) - k for i in range(num): ans += array[i] print(ans)
n, k = list(map(int, input().split())) A = list(map(int, input().split())) array = {} ans = 0 for a in A: if a in list(array.keys()): array[a] += 1 else: array[a] = 1 array = sorted(array.values()) if len(set(A)) > k: num = len(array) - k for i in range(num): a...
p03497
from collections import Counter n,k = list(map(int,input().split())) a = [int(i) for i in input().split()] counts = dict(Counter(a)) count = 0 while len(counts) > k: mins = min(counts.values()) count += mins del counts[min(counts,key=counts.get)] print(count)
from collections import Counter n,k = list(map(int,input().split())) a = [int(i) for i in input().split()] counts = dict(Counter(a)) counts = list(counts.values()) counts.sort() count = 0 dev = len(counts)-k for i in range(dev): count += counts[i] print(count)
p03497
import collections import sys input = sys.stdin.readline N,K = list(map(int, input().split())) A = list(map(int, input().split())) List = {} for i in A: if List.get(i,None)==None: List[i]=1 else: List[i]+=1 List_sorted = sorted(list(List.items()), key=lambda x:x[1]) tmp=0 Num=le...
import heapq N,K=list(map(int,input().split())) A=list(map(int,input().split())) l=[0]*max(A) ans=0 for item in A: l[item-1]+=1 heapq.heapify(l) while len(l)>K: ans+=heapq.heappop(l) print(ans)
p03497
import collections N,K = list(map(int,input().split())) A = list(map(int,input().split())) c = collections.Counter(A).most_common()[::-1] k = len(c) if k<=K:print((0)) else: print((sum([e[1] for e in c[:k-K]])))
from collections import Counter N,K = list(map(int,input().split())) A = list(map(int,input().split())) C = Counter(A).most_common() if len(C)<=K: print((0)) else: ans = 0 for c in C[:K]: ans+=c[1] print((N-ans))
p03497
from collections import defaultdict N, K = list(map(int, input().split())) A = list(map(int ,input().split())) d = defaultdict(int) for i in A: d[i] += 1 d_ = sorted(list(d.items()), key=lambda x:x[1], reverse=True) n =len(d_) ans = 0 if n <= K: print((0)) exit() else: for i in range(K,...
from collections import Counter N, K = list(map(int, input().split())) A = list(map(int ,input().split())) d = Counter(A) d_ = sorted(list(d.items()), key=lambda x:x[1], reverse=True) n =len(d_) ans = 0 if n <= K: print((0)) exit() else: for i in range(K,n): ans += d_[i][1] print(an...
p03497
n, k = list(map(int, input().split())) a = list(map(int, input().split())) s = set(a) if len(s) < k: print(0) exit() d = sorted([(i, a.count(i)) for i in s], key = lambda x: x[1]) cnt = 0 for i in d[:len(s) - k]: cnt += i[1] print(cnt)
n, k = list(map(int, input().split())) a = list(map(int, input().split())) s = set(a) if len(s) < k: print(0) exit() d = dict() for i in a: if i in d: d[i] += 1 else: d[i] = 1 cnt = 0 for i in sorted(d.values())[:len(s) - k]: cnt += i print(cnt)
p03497
s, t = list(map(int, input().split())) u = list(map(int,input().split())) from collections import Counter v = Counter(u) w = 0 for i in range(s): if len(v) <= t: print(w) break else: w += min(v.values()) del v[min(v, key = v.get)]
from collections import Counter n,k = list(map(int,input().split())) L = list( map(int,input().split())) l = len(L) L = Counter(L) L = sorted(list(L.most_common(k))) ans = 0 for i in range(len(L)): ans += L[i][1] print((l - ans))
p03497
n,m=list(map(int,input().split())) l=list(map(int,input().split())) l1=[] l2=[] c=0 for i in l: if i in l1: l2[l1.index(i)]+=1 else: l1.append(i) l2.append(1) if m>=len(l2): print((0)) else: l2=sorted(l2) for i in range(len(l2)-m): c+=l2[i] print(c)
n,m=list(map(int,input().split())) l=list(map(int,input().split())) d={} c=0 for i in l: if i in d: d[i]+=1 else: d[i]=1 l1=list(d.values()) if m>=len(l1): print((0)) else: l1=sorted(l1) for i in range(len(l1)-m): c+=l1[i] print(c)
p03497
N, K = list(map(int,input().split())) A = list(map(int,input().split())) a = list(set((A))) check = len(a) dff = check - K if dff <= 0: print((0)) exit(0) ans_list = [] for i in range(check): ans = 0 checker = a[i] for j in range(len(A)): if checker == A[j]: ans += 1 ans_list.ap...
N, K = list(map(int,input().split())) A = list(map(int,input().split())) a = list(set((A))) check = len(a) dff = check - K if dff <= 0: print((0)) exit(0) ans_list = [0]*check A.sort() index = 0 for i in range(len(A)): if i >= 1 and A[i] != A[i-1]: index += 1 ans_list[index] += 1 ans_li...
p03497
import collections,sys def LI(): return list(map(int,sys.stdin.readline().rstrip().split())) N,K = LI() A = collections.Counter(LI()) count_A = sorted([v for v in list(A.values())]) surplus = max(0,len(A)-K) print((sum(count_A[:surplus])))
import collections,sys def LI(): return list(map(int,sys.stdin.readline().rstrip().split())) N,K = LI() A = collections.Counter(LI()) value_A = sorted(A.values()) surplus = max(0,len(A)-K) print((sum(value_A[:surplus])))
p03497
from collections import defaultdict n, k = list(map(int, input().split())) a = list(map(int, input().split())) d = defaultdict(int) for x in a: d[x] += 1 new_d = sorted(list(d.items()), key=lambda x: x[1]) ans = 0 cnt = 0 for x in new_d: if(cnt < len(new_d) - k): ans += x[1] cnt += 1 el...
from collections import Counter n,k=list(map(int,input().split())) a=list(map(int,input().split())) c=Counter(a) v=list(c.values()) n=len(v) if n>k: ans=sum(sorted(v)[:n-k]) print(ans) else: print((0))
p03497
from collections import Counter N, K = [int(i) for i in input().split()] A = [int(i) for i in input().split()] print((sum(v for _, v in Counter(A).most_common()[K:])))
from collections import * N,K=list(map(int,input().split())) print((sum(v for _,v in Counter(list(map(int,input().split()))).most_common()[K:])))
p03497
from collections import * N,K=list(map(int,input().split())) print((sum(v for _,v in Counter(list(map(int,input().split()))).most_common()[K:])))
from collections import Counter N, K = [int(i) for i in input().split()] A = [int(i) for i in input().split()] print((sum(sorted(list(Counter(A).values()), reverse=True)[K:])))
p03497
from collections import Counter N,K = (int(i) for i in input().split()) A = [int(i) for i in input().split()] if len(set(A)) <= K: print((0)) exit() d = [a for a in list(Counter(A).values())] tmp = 0 for i in range(K): tmp += max(d) d.remove(max(d)) print((len(A)-tmp))
from collections import Counter N,K = (int(i) for i in input().split()) d = Counter([int(i) for i in input().split()]) if len(d) <= K: print((0)) exit() tmp = 0 for _,p in d.most_common(K): tmp += p print((N-tmp))
p03497
n, k = list(map(int, input().split())) A = list(map(int, input().split())) from collections import Counter C = Counter(A).most_common() dif = len(C) - k if dif <= 0: print((0)) else: s = 0 for i in range(dif): s += C[-(i + 1)][1] print(s)
n, k = list(map(int, input().split())) A = list(map(int, input().split())) from collections import Counter C = Counter(A) dif = len(C) - k if dif <= 0: print((0)) else: print((sum(sorted(C.values())[:dif])))
p03497
N,K = list(map(int,input().split())) A = list(map(int,input().split())) C = {} for i in range(N): if A[i] not in C: C[A[i]] = 0 C[A[i]] += 1 C = sorted(list(C.items()),key=lambda x:x[1],reverse=True) n = len(C) if n<=K: cnt = 0 else: cnt = 0 for i in range(K,n): cnt += ...
N,K = list(map(int,input().split())) A = list(map(int,input().split())) C = {} for i in range(N): a = A[i] if a not in C: C[a] = 0 C[a] += 1 C = sorted(list(C.items()),key=lambda x:x[1],reverse=True) if len(C)<=K: print((0)) else: cnt = 0 for i in range(K,len(C)): c...
p03497
n, k = list(map(int, input().split())) balls = list(map(int, input().split())) amo = [] kinds = set(balls) amo = sorted([balls.count(i) for i in kinds]) print((sum(amo[:max(0, len(kinds)-k)])))
n, k = list(map(int, input().split())) balls = sorted(input().split()) kinds = len(set(balls)) amo = [1] * kinds balls.append(0) j = 0 for i in range(n): if balls[i] == balls[i+1]: amo[j] += 1 else: j += 1 amo.sort() print((sum(amo[:max(0, kinds-k)])))
p03497
import collections N, K = list(map(int,input().split())) A = list(map(int,input().split())) cA = collections.Counter(A) ans = 0 if len(cA) > K: for x in range(len(cA)-K): ans += list(reversed(cA.most_common()))[x][1] else: ans = 0 print(ans)
import collections N, K = list(map(int,input().split())) A = list(map(int,input().split())) cA = collections.Counter(A) ans = 0 if len(cA) > K: _, counts = list(zip(*cA.most_common()[::-1])) ans =sum(counts[:len(cA)-K]) else: ans = 0 print(ans)
p03497
from collections import Counter N, K = list(map(int, input().split())) A = list(map(int, input().split())) c = Counter(A).most_common()[::-1] ans = 0 while len(c) > K: res = c.pop(0) ans += res[1] print(ans)
from collections import Counter N, K = list(map(int, input().split())) A = list(map(int, input().split())) c = Counter(A).most_common()[::-1] ans = 0 if len(c) > K: for i in range(len(c) - K): ans += c[i][1] print(ans)
p03497
from collections import Counter n, k = list(map(int, input().split())) *a, = list(map(int, input().split())) c = Counter(a) kv = sorted(list(c.items()), key=lambda x: x[1], reverse=True) if n <= k: print((0)) else: ans = n for i in range(k): try: ans -= kv[i][1] e...
n, k = list(map(int, input().split())) A = list(map(int, input().split())) d = {} for a in A: if a in list(d.keys()): d[a] += 1 else: d[a] = 1 ls = sorted(d.values()) ans = 0 for v in ls[:len(ls)-k]: ans += v print(ans)
p03497
from collections import Counter n, k = list(map(int, input().split())) *a, = list(map(int, input().split())) c = Counter(a) kv = sorted(list(c.items()), key=lambda x: x[1], reverse=True) if n <= k: print((0)) else: ls = c.most_common(k) ans = n for k, v in ls: ans -= v prin...
from collections import Counter n, k = list(map(int, input().split())) *a, = list(map(int, input().split())) c = Counter(a) if n <= k: print((0)) else: ls = c.most_common(k) ans = n for k, v in ls: ans -= v print(ans)
p03497
from collections import Counter n,k = list(map(int,input().split())) a = list(map(int,input().split())) a = Counter(a) a = a.most_common() p = len(a) ans = 0 for i in range(-1,-n-1,-1): if p <=k:break ans += a[i][1] p-=1 print(ans)
n,K = list(map(int,input().split())) a = list(map(int,input().split())) cnt = {} for x in a: if x not in cnt:cnt[x] = 1 else:cnt[x] +=1 res = [] for k in cnt: v = cnt[k] res.append(v) res.sort() ans = 0 for i in range(len(res)): if len(res) - i <=K: print(ans) ...
p03497
import collections as c N,K,*A= list(map(int,open(0).read().split())) ans=0 C=c.Counter(A) C=sorted(C.values()) colors = len(C) for i in range(colors): if len(C)<=K: break _c = C.pop(0) ans+=_c print(ans)
import collections as c N,K,*A= list(map(int,open(0).read().split())) ans=0 C=c.Counter(A) C=sorted(C.values()) #Aprint(C) for i in range(len(C)-K): ans+=C[i] print(ans)
p03497
def main(): from collections import Counter n,k,*a = list(map(int,open(0).read().split())) a = Counter(a) ans = 0 for i in range(max(0,len(a)-k)): ans += a.most_common()[-1-i][1] print(ans) main()
n,k,*a = list(map(int,open(0).read().split())) b = {} for i in a: if i in b: b[i] += 1 else: b[i] = 1 ans = 0 a = sorted(list(b.values())) for i in range(max(0,len(a)-k)): ans += a[i] print(ans)
p03497
from collections import Counter N, K = list(map(int, input().split())) A = sorted((v, k) for k, v in list(Counter(list(map(int, input().split()))).items())) print((sum(v for v, k in A[: max(0, len(A) - K)])))
from collections import Counter N, K = list(map(int, input().split())) A = list(map(int, input().split())) A_cntr = Counter(A) print((sum(sorted(v for v in list(A_cntr.values()))[:-K])))
p03497
from collections import Counter N, K = list(map(int, input().split())) counter = Counter(list(map(int, input().split()))) ans = 0 if len(list(counter.keys())) > K: for i in range(len(list(counter.keys())) - K): ans += counter.most_common()[0 - i - 1][1] print(ans)
import collections N, K = list(map(int, input().split())) arr = list(map(int, input().split())) ans = 0 cnt = collections.defaultdict(int) for num in arr: cnt[num] += 1 vals = sorted(cnt.values()) if len(cnt) > K: for i in range(len(cnt) - K): ans += vals[i] print(ans)
p03497
n,k=list(map(int,input().split())) a=list(map(int,input().split())) import collections counter=collections.Counter(a) v=sorted(counter.values()) print((sum(v[:len(v)-k])))
n,k=list(map(int,input().split())) a=list(map(int,input().split())) import collections v=sorted(collections.Counter(a).values()) print((sum(v[:len(v)-k])))
p03497
import collections n,k=list(map(int,input().split())) A=list(map(int,input().split())) c=collections.Counter(A) tot=0 for i in range(min(k,len(set(A)))): tot+=c.most_common()[i][1] print((n-tot))
import collections n,k=list(map(int,input().split())) A=list(map(int,input().split())) c=collections.Counter(A) tot=0 for i in c.most_common(min(k,len(set(A)))): tot+=i[1] print((n-tot))
p03497
N, K = list(map(int, input().split())) A = list(map(int, input().split())) cnt = {} for a in A: if a not in cnt: cnt[a] = 0 cnt[a] += 1 cnt = sorted(list(cnt.items()), key=lambda x: x[1]) ans = 0 while len(cnt) > K: ans += cnt[0][1] cnt = cnt[1:] print(ans)
N, K = list(map(int, input().split())) A = list(map(int, input().split())) cnt = {} for a in A: if a not in cnt: cnt[a] = 0 cnt[a] += 1 cnt = sorted(list(cnt.items()), key=lambda x: x[1]) ans = 0 for i in range(len(cnt)): if len(cnt) - i <= K: break ans += cnt[i][1] ...
p03497
n, k = list(map(int, input().split())) *a, = list(map(int, input().split())) d = {} for i in a: d[i] = d.get(i, 0)+1 a.sort(key=lambda x: d[x]) b = sorted(set(a), key=a.index) cnt = len(b) ans = 0 for i in b: if cnt <= k: break ans += d[i] cnt -= 1 print(ans)
n, k = list(map(int, input().split())) *a, = list(map(int, input().split())) d = {} for i in a: d[i] = d.get(i, 0)+1 cnt = len(d) ans = 0 for _, i in sorted(list(d.items()), key=lambda x: x[1]): if cnt <= k: break ans += i cnt -= 1 print(ans)
p03497
def insert(S, string): S.add(string) def find(S, string): cnt = 0 for i in range(len(S)): cnt = cnt + 1 if string in S: print('yes') break elif cnt == len(S): print('no') if cnt == 0: print('no') n = eval(input()) S ...
def insert(S, string): S.add(string) def find(S, string): if string in S: print('yes') else: print('no') n = eval(input()) S = set() for i in range(n): tmp1, tmp2 = list(map(str, input().split())) if tmp1 == 'insert': insert(S, tmp2) elif tmp1 == 'fi...
p02269
n = eval(input()) dic = [] for i in range(n): order = input().split() if order[0][0] == 'i': dic.append(order[1]) else: print("yes" if order[1] in dic else "no")
n = eval(input()) dic = set([]) for i in range(n): order = input().split() if order[0][0] == 'i': dic.add(order[1]) else: print("yes" if order[1] in dic else "no")
p02269
n = int(eval(input())) a = [] for i in range(n): x,m = list(map(str,input().split())) if x[0] =='i':a.append(m) elif x[0] =='f': if m in a: print('yes') else: print('no')
n = int(eval(input())) a = {} for i in range(n): x,m = input().split() if x[0] =='i':a[m] = 0 else: if m in a: print('yes') else: print('no')
p02269
#!/usr/bin/env python # -*- coding: utf-8 -*- import sys def h1(key): return key % m def h2(key): return 1 + (key % (m - 1)) def h(key, i): return (h1(key) + i * h2(key)) % m def insert(key): i = 0 while True: j = h(key, i) if T[j] == 'NULL': ...
#!/usr/bin/env python # -*- coding: utf-8 -*- import sys def h1(key): return key % m def h2(key): return 1 + (key % (m - 1)) def h(key, i): return (h1(key) + i * h2(key)) % m def insert(key): i = 0 while True: j = h(key, i) if not T[j]: T...
p02269
M = 10 ** 6 + 3 HASH_MAP = [None for i in range(M)] def hash1(key): return key % M def hash2(key): return 1 + (key % M-1) def my_hash(key, i): return (hash1(key)+i*hash2(key)) % M def make_num(s): return len(s) + ord(s[0]) + ord(s[-1]) def insert(key): i = 0 key_n...
def main(): n = int(eval(input())) s_set = set() for i in range(n): order = input().split() if order[0] == "insert": s_set.add(order[1]) else: if order[1] in s_set: print("yes") else: print("no") if...
p02269
dic = {"A":[], "C":[], "G":[], "T":[]} for i in range(int(eval(input()))): cmd, arg = input().split() if cmd == "insert": dic[arg[0]].append(arg) else: if arg in dic[arg[0]]: print("yes") else: print("no")
dic = {} for i in range(int(eval(input()))): cmd, arg = input().split() if cmd == "insert": dic[arg] = 0 else: if arg in dic: print("yes") else: print("no")
p02269
#! python3 # dictionary.py # ハッシュ法, チェイン法, 開番地法, etc # オープンアドレス法で実装する M = 113131 def getkey(text): dic = {'A': 1, 'T': 2, 'G': 3, 'C': 4} sum = 0 p = 1 for c in text: sum += p*dic[c] p *= 5 return sum def h1(key): return key % M def h2(key): return 1...
#! python3 # dictionary.py # ハッシュ法, チェイン法, 開番地法, etc # オープンアドレス法で実装する M = 8193173 def getkey(text): dic = {'A': 1, 'T': 2, 'G': 3, 'C': 4} sum = 0 p = 1 for c in text: sum += p*dic[c] p *= 5 return sum def h1(key): return key % M def h2(key): return ...
p02269
#! python3 # dictionary.py # ハッシュ法, チェイン法, 開番地法, etc # オープンアドレス法で実装する M = 8193173 def getkey(text): dic = {'A': 1, 'T': 2, 'G': 3, 'C': 4} sum = 0 p = 1 for c in text: sum += p*dic[c] p *= 5 return sum def h1(key): return key % M def h2(key): return ...
M = 15140366 def getkey(text): dic = {'A': 1, 'T': 2, 'G': 3, 'C': 4} sum = 0 p = 1 for c in text: sum += p*dic[c] p *= 5 return sum def h1(key): return key % M def h2(key): return 1 + (key %(M-1)) def h3(key, i): return (h1(key) + i*h2(key)) % M ...
p02269
import hashlib M = 15140366 def getkey(text): dic = {'A': 1, 'T': 2, 'G': 3, 'C': 4} sum = 0 p = 1 for c in text: sum += p*dic[c] p *= 5 return sum dict = {} def find(text): global dict # key = getkey(text) i = 0 while i < M: h = hashlib.md...
M = 15140366 def h1(key): return key % M def h2(key): return 1 + (key %(M-1)) def h3(key, i): return (h1(key) + i*h2(key)) % M word_dic = {'A': 1, 'T': 2, 'G': 3, 'C': 4} def getkey(text): sum = 0 p = 1 for c in text: sum += p*word_dic[c] p *= 5 return sum...
p02269
M = 15140366 def h1(key): return key % M def h2(key): return 1 + (key %(M-1)) def h3(key, i): return (h1(key) + i*h2(key)) % M word_dic = {'A': 1, 'T': 2, 'G': 3, 'C': 4} def getkey(text): sum = 0 p = 1 for c in text: sum += p*word_dic[c] p *= 5 return sum...
M = 2056197 def h1(key): return key % M def h2(key): return 1 + (key %(M-1)) def h3(key, i): return (h1(key) + i*h2(key)) % M word_dic = {'A': 1, 'T': 2, 'G': 3, 'C': 4} def getkey(text): sum = 0 p = 1 for c in text: sum += p*word_dic[c] p *= 5 return sum ...
p02269
M = 1046527 def h1(key): return key % M def h2(key): return 1 + (key %(M-1)) def h3(key, i): return (h1(key) + i*h2(key)) % M word_dic = {'A': 1, 'T': 2, 'G': 3, 'C': 4} def getkey(text): sum = 0 p = 1 for c in text: sum += p*word_dic[c] p *= 5 return sum ...
import sys M = 1046527 def h1(key): return key % M def h2(key): return 1 + (key %(M-1)) def h3(key, i): return (h1(key) + i*h2(key)) % M word_dic = {'A': 1, 'T': 2, 'G': 3, 'C': 4} def getkey(text): sum = 0 p = 1 for c in text: sum += p*word_dic[c] p *= 5 ...
p02269
from collections import deque n = int(eval(input())) dict = deque() for i in range(n): order = input().split() if order[0] == "insert": dict.append(order[1]) else: if order[1] in dict: print("yes") else: print("no")
from collections import deque n = int(eval(input())) dict = {} for i in range(n): order = input().split() if order[0] == "insert": dict[order[1]] = i else: if order[1] in dict: print("yes") else: print("no")
p02269
#!/usr/bin/env python # -*- coding:utf-8 -*- #from __future__ import print_function import time import sys import io import re import math #start = time.clock() #i = 0 a,b=[],[] check = re.compile('insert') n=eval(input()) #while True: for x in range(n): (i,f)=list(map(str, input().split())) if ...
#!/usr/bin/env python # -*- coding:utf-8 -*- #from __future__ import print_function import time import sys import io import re import math #start = time.clock() #i = 0 #check = 'insert' n=eval(input()) a=set() for x in range(n): (i,f)=list(map(str, input().split())) if i=='insert': a.add...
p02269
import sys d={} for e in sys.stdin.readlines()[1:]: c,g=e.split() if'i'==c[0]:d[g]=0 else:print((['no','yes'][g in d]))
import sys d={} for e in sys.stdin.readlines()[1:]: if'i'==e[0]:d[e[7:]]=0 else:print((['no','yes'][e[5:]in d]))
p02269
import sys d={} for e in sys.stdin.readlines()[1:]: if'f'==e[0]:print(('yes'if e[5:]in d else'no')) else:d[e[7:]]=0
import sys def m(): d={} for e in sys.stdin.readlines()[1:]: if'f'==e[0]:print(('yes'if e[5:]in d else'no')) else:d[e[7:]]=0 if'__main__'==__name__:m()
p02269
import sys def m(): d={} for e in sys.stdin.readlines()[1:]: if'f'==e[0]:print(('yes'if e[5:]in d else'no')) else:d[e[7:]]=0 if'__main__'==__name__:m()
import sys def m(): d={};eval(input()) for e in sys.stdin: if'f'==e[0]:print(('yes'if e[5:]in d else'no')) else:d[e[7:]]=0 if'__main__'==__name__:m()
p02269
import sys def m(): d={};eval(input()) for e in sys.stdin: if'f'==e[0]:print(('yes'if e[5:]in d else'no')) else:d[e[7:]]=0 if'__main__'==__name__:m()
import sys def m(): d={};eval(input()) for e in sys.stdin: if'f'==e[0]:print((['no','yes'][e[5:]in d])) else:d[e[7:]]=0 if'__main__'==__name__:m()
p02269
import sys def m(): d={0};eval(input()) for e in sys.stdin: if'f'==e[0]:print((['no','yes'][e[5:]in d])) else:d|={e[7:]} if'__main__'==__name__:m()
import sys def m(): d={};eval(input()) for e in sys.stdin: if'f'==e[0]:print((['no','yes'][e[5:]in d])) else:d[e[7:]]=0 if'__main__'==__name__:m()
p02269
#!/usr/bin/env python # -*- coding: utf-8 -*- """ ??\????????????????????????????°?????????????????????????????£?????????????????????? insert str: ????????? str ?????????????????? find str: ????????? str ?????????????????´??? 'yes'??¨????????????????????´??? 'no'??¨??????????????? ????????????????????????????...
import sys def main(): """ MAIN """ num = int(input().strip()) istr = sys.stdin.read() cmds = list(istr.splitlines()) D = {} for i in cmds: if i[0] == "i": D[i[7:]] = 1 elif i[0] == "f": if i[5:] in D: print("yes") ...
p02269
N = int(eval(input())) d = {} for i in [None]*N: a, b = input().split() if a == "insert": d[b] = 1 else: print(("yes" if b in d else "no"))
class Dictionary(object): def __init__(self, size): self.size = size self.a = [None]*size def hash(self, x): key = hash(x) % self.size while self.a[key] and self.a[key] != x: key = (key + 10**9+7) % self.size return key def insert(self, x): ...
p02269
# -*- coding: utf-8 -*- """ Created on Mon Apr 30 13:14:10 2018 ALDS1-4c simple implementation @author: maezawa """ n = int(eval(input())) a = [] for s in range(n): cmd, word = input().split() if cmd == 'insert': a.append(word) else: if word in a: print('yes') ...
# -*- coding: utf-8 -*- """ Created on Mon Apr 30 13:14:10 2018 ALDS1-4c implementation with dictionary @author: maezawa """ n = int(eval(input())) a = dict([]) for s in range(n): cmd, word = input().split() if cmd == 'insert': a[word]='' else: if word in a: prin...
p02269
command_num = int(eval(input())) dict = [] for i in range(command_num): in_command, in_str = input().rstrip().split(" ") if in_command == "insert": dict.append(in_str) elif in_command == "find": if dict.count(in_str) > 0: print("yes") else: p...
command_num = int(eval(input())) dict = set([]) for i in range(command_num): in_command, in_str = input().rstrip().split(" ") if in_command == "insert": dict.add(in_str) elif in_command == "find": if in_str in dict: print("yes") else: print("...
p02269
def find(data, s): l = 0 r = len(data) while l < r: ind = (l + r) // 2 if data[ind] == s: return True elif data[ind] < s: l = ind + 1 else: r = ind return False def insert(data, s): if len(data) == 0: data....
n = int(eval(input())) data = set() for _ in range(n): command = input().split() if command[0] == "insert": data.add(command[1]) elif command[0] == "find": if command[1] in data: print("yes") else: print("no")
p02269
class my_dict: def __init__(self): self.d = [] def insert(self, x): if (x not in self.d): self.d.append(x) def find(self, x): if (x in self.d): return 'yes' else: return 'no' def main(): n = int(eval(input())) ...
def main(): n = int(eval(input())) d = set([]) for i in range(n): command, string = input().split() if (command == 'insert'): d.add(string) elif (command == 'find'): if string in d: print('yes') else: ...
p02269
def h1(key): return key % m def h2(key): return 1 + key % (m - 1) def h(key, i): return h1(key + i * h2(key)) % m def insert(T, key): i = 0 while True: j = h(key, i) if T[j] is None: T[j] = key return j else: i += ...
t = set() m = int(eval(input())) for i in range(m): cmd, key = input().split() if cmd == "insert": t.add(key) else: if key in t: print("yes") else: print("no")
p02269
import sys readline = sys.stdin.readline li = [] for _ in range(int(readline())): c, s = readline().split() if c == "insert": li.append(s) elif c == "find": print(("yes" if s in li else "no"))
import sys readline = sys.stdin.readline SET = set() for _ in range(int(readline())): c, s = readline().split() if c == "insert": SET.add(s) elif c == "find": print(("yes" if s in SET else "no"))
p02269
import sys readline = sys.stdin.readline SET = set() for _ in range(int(readline())): c, s = readline().split() if c == "insert": SET.add(s) elif c == "find": print(("yes" if s in SET else "no"))
import sys readline = sys.stdin.readline SET = set() eval(input()) for s in sys.stdin: if s[0] == "i": SET.add(s[7:]) elif s[0] == "f": print(("yes" if s[5:] in SET else "no"))
p02269
n = int(input()) dict = [] for i in range(n): command, word = input().split() if command == 'insert': dict.append(word) else: try: dict.index(word) print('yes') except: print('no') pass
n = int(input()) def makeHash(letter): if letter == 'A': return 1 elif letter == 'C': return 2 elif letter == 'G': return 3 elif letter == 'T': return 4 return 0 dict = {} for i in range(n): command, word = input().split() key = 0 if com...
p02269
if __name__ == '__main__': try: n = int(input()) except: print('the first input must be integer value!') exit() genoms = [] answers = [] for _ in range(n): values = input().split() order = values[0] genom = values[1] if order == "...
if __name__ == '__main__': try: n = int(input()) except: print('the first input must be integer value!') exit() genoms = set([]) answers = [] for _ in range(n): values = input().split() order = values[0] genom = values[1] if order...
p02269
n = int(eval(input())) s = set() for i in range(n): c, m = input().split() if c[0] == 'i': s.add(m) elif c[0] == 'f': if m in s: print('yes') else: print('no')
n = int(input()) l = [] s = {} for i in range(n): c, m = input().split() if c[0] == 'i': s[m] = 0 elif c[0] == 'f': if m in s: l.append('yes') else: l.append('no') print(*l,sep='\n')
p02269
from collections import deque n = int(eval(input())) l = deque() for i in range(n): cmd = input().split() if cmd[0] == 'insert': l.append(cmd[1]) if cmd[0] == 'find': if cmd[1] in set(l): print('yes') else: print('no')
n = int(eval(input())) l = set() for i in range(n): cmd = input().split() if cmd[0] == 'insert': l.add(cmd[1]) if cmd[0] == 'find': if cmd[1] in l: print('yes') else: print('no')
p02269
n = int(eval(input())) class Hash: def __init__(self): self.m = 1000003 self.T = [None] * self.m def insert(self, key): i = 0 while True: j = self.h(key, i) if self.T[j] == None: self.T[j] = key break ...
n = int(eval(input())) h = {} for i in range(n): op, st = input().split() if op == 'insert': h[st] = 'yes' else: print((h.get(st, 'no')))
p02269
import sys def main(): _ = int(eval(input())) imps = sys.stdin.readlines() db = [] for imp in imps: command = imp.split(' ') if command[0] == 'insert': db.append(command[1]) else: if command[1] in db: print('yes') ...
import sys n = int(eval(input())) dic = {} input_ = sys.stdin.readlines() for i in input_: c, s = i.split() if c == 'insert': dic[s] = 0 else: if s in dic: print('yes') else: print('no')
p02269
from collections import deque n = int(eval(input())) l = deque() for _ in range(n): ss = input().split() order, string = ss[0], ss[1] if order == "insert": l.append(string) else: print(('yes' if string in l else 'no'))
n = int(eval(input())) l = {} for _ in range(n): ss = input().split() order, string = ss[0], ss[1] if order == "insert": l[string] = 1 else: print(('yes' if string in l else 'no'))
p02269
n = int(eval(input())) strs = [] for i in range(n): s = input().split() if(s[0] == 'insert'): if(s[1] not in strs): strs.append(s[1]) else: if(s[1] in strs): print('yes') else: print('no')
n = int(eval(input())) strs = {} for i in range(n): s = input().split() if(s[0] == 'insert'): if(s[1] not in strs): strs[s[1]] = '' else: if(s[1] in strs): print('yes') else: print('no')
p02269
from collections import deque D = deque() N = int(eval(input())) for i in range(N): c, s = input().split() if c == "insert": D.append(s) elif c == "find": if (s in D): print("yes") else: print("no")
from collections import deque D = set() N = int(eval(input())) for i in range(N): c, s = input().split() if c == "insert": D.add(s) elif c == "find": if (s in D): print("yes") else: print("no")
p02269
import sys class HashTable: def __init__(self): self.table = [None] * 4 self.flag = False class Dictionary: def __init__(self): self.hashTable = HashTable() def insert(self, key): table = self.hashTable for c in key: hash = self.toHash(c) ...
import sys class HashTable: def __init__(self): self.table = [None] * 4 self.flag = False class Dictionary: def __init__(self): self.hashTable = HashTable() def insert(self, key): table = self.hashTable for c in key: hash = self.toHash(c) ...
p02269
n = int(eval(input())) M = 1046527 a = [0 for i in range(M)] for i in range(n): s = input().split(" ") num = 0 p = 1 for j in range(len(s[1])): if s[1][j] == "A": num += p * 1 elif s[1][j] == "C": num += p * 2 elif s[1][j] == "G": ...
n = int(eval(input())) dic = set() for i in range(n): Cmd, Key = input().split(" ") if Cmd == "insert": dic.add(Key) else: if Key in dic: print("yes") else: print("no")
p02269
n = int( eval(input( )) ) dic = {} output = [] for i in range( n ): cmd, word = input( ).split( " " ) if "insert" == cmd: dic[ word ] = True elif "find" == cmd: if not dic.get( word ): output.append( "no" ) else: output.append( "yes" ) print(( "\n".join( output ) ))
n = int( input( ) ) dic = {} for i in range( n ): cmd, word = input( ).split( " " ) if "insert" == cmd: dic[ word ] = True elif "find" == cmd: if not dic.get( word ): print( "no" ) else: print( "yes" )
p02269
n = int( input( ) ) dic = {} for i in range( n ): cmd, word = input( ).split( " " ) if "insert" == cmd: dic[ word ] = True elif "find" == cmd: if not dic.get( word ): print( "no" ) else: print( "yes" )
n = int( input( ) ) dic = {} for i in range( n ): cmd, word = input( ).split( " " ) if "insert" == cmd: dic[ word ] = True elif "find" == cmd: if word in dic: print( "yes" ) else: print( "no" )
p02269
def binarySearch(array, key): left = 0 right = len(array) while left < right: mid = int((left + right) / 2) if key == array[mid]: return True elif key > array[mid]: left = mid + 1 elif key < array[mid]: right = mid else: ...
n = int(eval(input())) d = {} for i in range(n): cmd, string = input().split() if cmd == "insert": d[string] = True else: try: if d[string]: print("yes") except: print("no")
p02269
#! /usr/bin/env python # -*- coding: utf-8 -*- ''' ?????? ''' class Dictionary(object): """ Dictionary """ def __init__(self): self.dict = [] def insert(self, x): self.dict.append(x) def find(self, x): if x in self.dict: print('yes') el...
#! /usr/bin/env python # -*- coding: utf-8 -*- ''' ?????? ''' class Dictionary(object): """ Dictionary """ def __init__(self): self.dict = {} def insert(self, x): self.dict[x] = 0 def find(self, x): if x in list(self.dict.keys()): print('yes') ...
p02269
class Dictionary: def __init__(self): self.dic = [] def insert(self, key): self.dic.append(key) def find(self, key): return key in self.dic dic = Dictionary() n = int(eval(input())) for i in range(n): cmd = input().split() if cmd[0] == "insert": dic.inse...
dic = set() n = int(eval(input())) for i in range(n): cmd, val = input().split() if cmd == "insert": dic.add(val) elif cmd == "find": print(("yes" if val in dic else "no")) else: print("wrong command")
p02269
dict = {"A":1,"C":2,"G":3,"T":4} def a2n(a): ans = 0 for i in range(len(a)): ans += dict[a[i]]*4**i return ans n = int(input()) ls = [0 for i in range(6710886)] for i in range(n): inp = input() if inp[0] == "i": ls[a2n(inp[7:])] = 1 else: print("yes" if ls[a2n(inp[5:])] ...
dict = {"A":1,"C":2,"G":3,"T":4} def a2n(a): ans = 0 for i in range(len(a)): ans += dict[a[i]]*4**i return ans n = int(input()) ls = [0 for i in range(3000000)] for i in range(n): inp = input() if inp[0] == "i": ls[a2n(inp[7:])] = 1 else: print("yes" if ls[a2n(inp[5:])] ...
p02269
dict = {"A":1,"C":2,"G":3,"T":4} def a2n(a): ans = 0 for i in range(len(a)): ans += dict[a[i]]*4**i return ans n = int(input()) ls = [0 for i in range(3000000)] for i in range(n): inp = input() if inp[0] == "i": ls[a2n(inp[7:])] = 1 else: print("yes" if ls[a2n(inp[5:])] ...
n = int(input()) ls = {} for i in range(n): inp = input() if inp[0] == "i": ls[inp[7:]] = 1 else: try: if ls[inp[5:]] == 1: print("yes") except: print("no")
p02269
# -*- coding: utf-8 -*- class HashTable(list): def __init__(self, length): list.__init__(self) self.length = length self[:] = [None] * length def h1(self, key): return key % self.length def h2(self, key): return 1 + (key % (self.length - 1)) def ...
# -*- coding: utf-8 -*- class HashTable(list): def __init__(self, length): list.__init__(self) self.length = length self[:] = [None] * length def h1(self, key): return key % self.length def h2(self, key): return 1 + (key % (self.length - 1)) def ...
p02269
# -*- coding: utf-8 -*- class HashTable(list): def __init__(self, length): list.__init__(self) self.length = length self[:] = [None] * length def h1(self, key): return key % self.length def h2(self, key): return 1 + (key % (self.length - 1)) def ...
# -*- coding: utf-8 -*- class HashTable(list): def __init__(self, length): list.__init__(self) self.length = length self[:] = [None] * length def h1(self, key): return key % self.length def h2(self, key): return 1 + (key % (self.length - 1)) def ...
p02269