s_id
stringlengths
10
10
p_id
stringlengths
6
6
u_id
stringlengths
10
10
date
stringlengths
10
10
language
stringclasses
1 value
original_language
stringclasses
11 values
filename_ext
stringclasses
1 value
status
stringclasses
1 value
cpu_time
stringlengths
1
5
memory
stringlengths
1
7
code_size
stringlengths
1
6
code
stringlengths
1
539k
s880543787
p02267
u735204496
1505025154
Python
Python
py
Runtime Error
0
0
261
import sys n = int(sys.stdin.readline().strip()) S = map(int, sys.stdin.readline().strip().split(" ")) n = int(sys.stdin.readline().strip()) T = map(int, sys.stdin.readline().strip().split(" ")) res = [] for t in T: rse.append(S.count(t)) print sum(res)
s736084167
p02267
u146816547
1506141966
Python
Python
py
Runtime Error
0
0
175
n = int(raw_input()) S = map(int, raw_input(),split()) q = int(raw_input()) T = map(int, raw_input().split()) ans = 0 for i in T: if i in S: ans += 1 print ans
s100481415
p02267
u626266743
1510153762
Python
Python3
py
Runtime Error
0
0
110
n = int(input()) S = map(int, input().split()) q = int(input()) T = map(int, input().split()) print(len(S & T)
s853223428
p02267
u626266743
1510153795
Python
Python3
py
Runtime Error
0
0
111
n = int(input()) S = map(int, input().split()) q = int(input()) T = map(int, input().split()) print(len(S & T))
s518844283
p02267
u626266743
1510153949
Python
Python3
py
Runtime Error
0
0
123
n = int(input()) S = list(map(int, input().split())) q = int(input()) T = list(map(int, input().split())) print(len(S & T))
s034219898
p02267
u424457654
1510670483
Python
Python3
py
Runtime Error
0
0
114
n = int(input()) S = map(int, input(). split()) q = int(input()) T = map(int, input(). split()) print(len(S & T))
s125133120
p02267
u424457654
1510670563
Python
Python3
py
Runtime Error
0
0
126
n = int(input()) S = list(map(int, input(). split())) q = int(input()) T = list(map(int, input(). split())) print(len(S & T))
s877545574
p02267
u530663965
1513777648
Python
Python3
py
Runtime Error
0
0
950
import sys ERROR_INPUT = 'input is invalid' ERROR_INPUT_NOT_UNIQUE = 'input is not unique' def main(): S = get_input1() T = get_input2() count = 0 for t in T: for s in S: if t == s: count += 1 break print(count) def get_input1(): n = int(input()) if n > 10000: print(ERROR_INPUT) sys.exit(1) li = [] for x in input().split: if int(x) < 0 or int(x) > 10 ** 9: print(ERROR_INPUT) sys.exit(1) li.append(x) return li def get_input2(): n = int(input()) if n > 500: print(ERROR_INPUT) sys.exit(1) li = [] for x in input().split: if int(x) < 0 or int(x) > 10 ** 9: print(ERROR_INPUT) sys.exit(1) elif int(x) in li: print(ERROR_INPUT_NOT_UNIQUE) sys.exit(1) li.append(x) return li main()
s130793925
p02267
u564105430
1525858055
Python
Python3
py
Runtime Error
0
0
199
n=int(input()) s=input().split() q=int(input()) t=input().split() cnt=0 for i in range(q): for j in range(n): if s[i]==t[j]: cnt+=1 break print(cnt)
s199550187
p02267
u843517396
1525879652
Python
Python3
py
Runtime Error
0
0
441
#coding: Shift_JIS import numpy as np def set_array(a,n): str=input() array=str.split() for i in range(n): a[i]=int(array[i]) n=int(input()) S=np.zeros(n) set_array(S,n) q=int(input()) T=np.zeros(q) set_array(T,q) C=0 def linear_search(S,x): np.append(S,x) len=np.size(S) i=0 while(len>i): if S[i]==x: break; i=i+1 np.delete(S,-1) if i!=len: return 1; else: return 0; for v in T: C+=linear_search(S,v) print(C)
s059951571
p02267
u843517396
1525944247
Python
Python3
py
Runtime Error
0
0
441
#coding: Shift_JIS import numpy as np def set_array(a,n): str=input() array=str.split() for i in range(n): a[i]=int(array[i]) n=int(input()) S=np.zeros(n) set_array(S,n) q=int(input()) T=np.zeros(q) set_array(T,q) C=0 def linear_search(S,x): np.append(S,x) len=np.size(S) i=0 while(len>i): if S[i]==x: break; i=i+1 np.delete(S,-1) if i!=len: return 1; else: return 0; for v in T: C+=linear_search(S,v) print(C)
s012676796
p02267
u738669341
1526267837
Python
Python3
py
Runtime Error
0
0
131
n=int(input()) a=[] b=[] for i in range(1,n): a[i]=int(input()) x=int(input()) for i in range(1,x): b[i]=int(input())
s290493742
p02267
u687567104
1526308264
Python
Python
py
Runtime Error
0
0
421
#include<iostream> #include<vector> using namespace std; int main(void){ int n, q, num=0; long S[10001], T[501]; std::cin >> n; for(int i=0; i<n; i++){ std::cin >> S[i]; } std::cin >> q; for(int i=0; i<q; i++){ std::cin >> T[i]; } for(int i=0; i<n; i++){ for(int j=0; j<q; j++){ if(S[i] == T[j]){ num+=1; } } } cout(num); return 0; }
s550153907
p02267
u573915636
1526388598
Python
Python3
py
Runtime Error
0
0
134
c=0 n=int(input()) s=int(input().split()) nqint(input()) t=int(input().split()) for i in t: for j in s: if i==j: c +=1 print(c)
s208603604
p02267
u573915636
1526388662
Python
Python3
py
Runtime Error
0
0
134
c=0 n=int(input()) s=int(input().split()) nqint(input()) t=int(input().split()) for i in t: for j in s: if i==j: c +=1 print(c)
s062118002
p02267
u826549974
1526393139
Python
Python3
py
Runtime Error
0
0
231
n = int(input()) s = list(map(int,input().split())) q = int(input()) r = list(map(int,input().split())) cou = 0 for i in range(q): for j in range(n): if(s[i] == r[j]): cou += 1 break print(cou)
s798943021
p02267
u687567104
1526403196
Python
Python
py
Runtime Error
0
0
386
#include<iostream> #include<vector> using namespace std; int main(void){ int n, q, num=0; long S[10001], T[501]; std::cin >> n; for(int i=0; i<n; i++){ std::cin >> S[i]; } std::cin >> q; for(int i=0; i<q; i++){ std::cin >> T[i]; } for(int i=0; i<n; i++){ for(int j=0; j<q; j++){ if(S[i] == T[j]){ num+=1; } } } cout << num << "\n"; return 0; }
s861678874
p02267
u733945366
1526404596
Python
Python
py
Runtime Error
0
0
232
S=[] T=[] n=int(input()) s=input().split() for i in range(n): S.append(s[i]) q=int(input()) t=input().split() for j in range(q): T.append(t[j]) cnt=0 for i in range(n): for j in range(q): if S[i]==T[j]: cnt+=1 print(cnt)
s446350835
p02267
u733945366
1526404939
Python
Python
py
Runtime Error
0
0
232
S=[] T=[] n=int(input()) s=input().split() for i in range(n): S.append(s[i]) q=int(input()) t=input().split() for j in range(q): T.append(t[j]) cnt=0 for i in range(n): for j in range(q): if S[i]==T[j]: cnt+=1 print(cnt)
s979936355
p02267
u733945366
1526404969
Python
Python
py
Runtime Error
0
0
229
S=[] T=[] n=int(input()) s=input().split() for i in range(n): S.append(s[i]) q=int(input()) t=input().split() for j in range(q): T.append(t[j]) cnt=0 for i in range(n): for j in range(q): if S[i]==T[j]: cnt+=1 print(cnt)
s729686842
p02267
u728137020
1526417768
Python
Python3
py
Runtime Error
0
0
285
n=int(input()) lista=[0 for i in range(n)] lista=input().split() n2=int(input()) listb=[0 for i in range(n2)] listb=input().split() cnt=0 for i in range(n2): x=0 for j in range(n): if listb[i]==lista[j] and if x==0: x=1 cnt+=1 print(cnt)
s066823861
p02267
u196653484
1526435131
Python
Python3
py
Runtime Error
0
0
1062
#include <stdio.h> #include <stdlib.h> #include <ctype.h> #include <string.h> #define MAX 10000 int linear_search(int a, int b); void input(int a[]); int main(void) { int count=0; char null; int n,q; int S[MAX]; int T[MAX]; scanf("%d",&n); getchar(); input(S); scanf("%d",&q); input(T); getchar(); for(int i=0;i<n;i++) { for(int j=0;j<q;j++) { count+=linear_search(S[n],T[q]); } } printf("%d\n",count); return 0; } int linear_search(int a, int b) { if(a == b){return 1;} else{return 0;} } void input(int a[]) { char str[MAX]; int x; int j=0; fgets(str,MAX,stdin); int i=0; while(str[i]>=' ') { while(isspace(str[i])){i++;} if(isdigit(str[i])) { x=0; while(isdigit(str[i])) { x=10*x+(str[i]-'0'); i++; } a[j]=x; j++; } else { i++; } } }
s953432261
p02267
u298224238
1529916940
Python
Python3
py
Runtime Error
0
0
282
def linearSearch(key, list): for e in list: if key == e: return 1 return 0 N1 = int(input()) arr1 = [int(n) or n in input().split()] N2 = int(input()) arr2 = [int(n) or n in input().split()] print(sum([linearSearch(key, arr2) for key in arr])
s776329623
p02267
u298224238
1529918171
Python
Python3
py
Runtime Error
0
0
306
def linearSearch(key, list, N): list[N] = key i = 0 while l[i] != key: i += 1 return int(i != N) N1 = int(input()) arr1 = [int(n) for n in input().split() + [0]] N2 = int(input()) arr2 = [int(n) for n in input().split()] print(sum([linearSearch(key, arr1, N1) for key in arr2))
s164911689
p02267
u298224238
1529918187
Python
Python3
py
Runtime Error
0
0
306
def linearSearch(key, list, N): list[N] = key i = 0 while l[i] != key: i += 1 return int(i != N) N1 = int(input()) arr1 = [int(n) for n in input().split()] + [0] N2 = int(input()) arr2 = [int(n) for n in input().split()] print(sum([linearSearch(key, arr1, N1) for key in arr2))
s634851099
p02267
u298224238
1529918203
Python
Python3
py
Runtime Error
0
0
307
def linearSearch(key, list, N): list[N] = key i = 0 while l[i] != key: i += 1 return int(i != N) N1 = int(input()) arr1 = [int(n) for n in input().split()] + [0] N2 = int(input()) arr2 = [int(n) for n in input().split()] print(sum([linearSearch(key, arr1, N1) for key in arr2]))
s210380787
p02267
u298224238
1529991582
Python
Python3
py
Runtime Error
0
0
448
var input = require('fs').readFileSync('/dev/stdin', 'utf8'); var Arr = (input.trim()).split("\n"); var N1 = Number(Arr[0]) var arr1 = Arr[1].split(" ").map(Number); var arr2 = Arr[3].split(" ").map(Number); const linearSearch = (key, arr) => { let i = 0 arr[N1] = key; while (true) { if (arr[i] === key) break; i++; } return i === N1 ? 1 : 0; } console.log(arr2.map(e => linearSearch(e, arr1)).reduce((a, b) => a + b, 0));
s005655031
p02268
u153665391
1531022041
Python
Python3
py
Runtime Error
0
0
612
N = int(input()) S = list(map(int, input().split())) Q = int(input()) T = list(map(int, input().split())) def binary_search(target_num, head, tail): idx = int(head+tail) if target_num == S[idx]: return True elif target_num < S[idx]: if head == idx: return False binary_search(target_num, head, idx-1) else target_num > S[idx]: if tail == idx: return False binary_search(target_num, idx+1, tail) match_count = 0 for target_num in T: if binary_search(target_num, 0, len(T)-1): match_count += 1 print(str(match_count))
s075843318
p02268
u760378812
1540994429
Python
Python3
py
Runtime Error
0
0
846
#include <iostream> #include <string> #include <cstring> #include <fstream> #include <cmath> #include <iomanip> #include <cstdlib> #include <algorithm> #include <vector> #include <map> #include <deque> #include <map> #include <set> #include <queue> #include <stack> #include <list> #include <unordered_map> using namespace std; int main() { long n; long q; cin >> n; vector <long> s; vector <long> t; for (int i=0;i<n;i++){ long p; cin >> p; s.push_back(p); } cin >> q; for(int i=0;i<q;i++){ long p; cin >> p; t.push_back(p); } vector <long>::iterator idx; long ans = 0; for (int i=0;i<q;i++) { idx = lower_bound(s.begin(), s.end(),t[i]); if(*idx == t[i]){ ans += 1; } } cout << ans << endl; }
s689364991
p02268
u308033440
1545365299
Python
Python3
py
Runtime Error
0
0
994
import copy # 二分探索 def binearSearch(n, S, t): left = 0 right = n while left < right: mid = (left + right) / 2 if A[mid] == key: return mid elif key < A[mid]: right = mid else: left = mid + 1 return NOT_FOUND if __name__ == '__main__': # 入力 n = int(input()) # 数列Sに含まれる整数の個数 S = list(map(int,input().split())) # 整数を含む数列 q = int(input()) # 数列Tに含まれる異なる整数の個数 T = list(map(int,input().split())) # 異なる整数を含む数列 # 初期化 C = 0 # Tに含まれる整数の中でSに含まれるものの個数 # 数列T内の整数を1つずつチェック for i in range(q): isExist = linearSearch(n, copy.deepcopy(S), T[i]) # 存在してたらカウント if isExist : C = C + 1 # 出力 print(C)
s364027343
p02268
u312681524
1545726032
Python
Python
py
Runtime Error
0
0
919
<?php $lengthA = (int) fgets(STDIN); $stdinA = explode(" ",fgets(STDIN)); $lengthKey = (int) fgets(STDIN); $stdinKey = explode(" ",fgets(STDIN)); $count = 0; for($j=0; $j<$lengthKey; ++$j){ $result = BinarySearch($lengthA, $stdinA, $stdinKey[$j]); if($result == 1){ $count++; } } echo $count . PHP_EOL; function BinarySearch($N, $A, $key){ $left = 0; $right = $N; while ($left < $right){ //探索の範囲内の中央の要素を調べる $mid = ($left + $right) / 2; //目的のキーと中央の要素のキーが一致すれば探索を終了 if ((int)$A[$mid] == (int)$key){ return 1; } //前半部分を探索範囲とする if ($key < $A[$mid]){ $right = $mid; } //後半部分を探索範囲とする else{ $left = $mid + 1; } } return 0; } ?>
s307653989
p02268
u245286435
1423642645
Python
Python
py
Runtime Error
0
0
555
# import sys def binary_search(query, length, array): if length == 1: if query == array[0]: return 1 else: return 0 center = 2 / length if query > array[center]: return binary_search(query, length-(center+1), array[center+1:]) elif query < array[center]: return binary_search(query, center, array[:center]) else: return 1 n = int(raw_input()) S = map(int, raw_input().strip(" ").split(" ")) q = int(raw_input()) T = map(int, raw_input().strip(" ").split(" ")) count = 0 for t in T: count += binary_search(t, n, S) print count
s883533998
p02268
u245286435
1423642785
Python
Python
py
Runtime Error
50
4736
555
# import sys def binary_search(query, length, array): if length == 1: if query == array[0]: return 1 else: return 0 center = length / 2 if query > array[center]: return binary_search(query, length-(center+1), array[center+1:]) elif query < array[center]: return binary_search(query, center, array[:center]) else: return 1 n = int(raw_input()) S = map(int, raw_input().strip(" ").split(" ")) q = int(raw_input()) T = map(int, raw_input().strip(" ").split(" ")) count = 0 for t in T: count += binary_search(t, n, S) print count
s747834321
p02268
u879226672
1427089514
Python
Python
py
Runtime Error
0
0
453
def binary_search(A,n): # sequence A, item n l = len(A) if l==0: return False elif A[l/2] > n: return binary_search(A[:l/2],n) elif A[l/2] == n: return True elif A[l/2]<n: return binary_search(A[(l/2)+1:],n) n = int(raw_input()) S = set(map(int,raw_input().split())) q = int(raw_input()) T = map(int,raw_input().split()) C = 0 for k in T: if binary_search(S,k): C += 1 print C
s288822627
p02268
u879226672
1427089678
Python
Python
py
Runtime Error
0
0
458
def binary_search(A,n,l): # sequence A, item n, l len(A) if l==0: return False elif A[l/2] > n: return binary_search(A[:l/2],n) elif A[l/2] == n: return True elif A[l/2]<n: return binary_search(A[(l/2)+1:],n) n = int(raw_input()) S = map(int,raw_input().split()) q = int(raw_input()) T = map(int,raw_input().split()) l = len(S) C = 0 for k in T: if binary_search(S,k,l): C += 1 print C
s677232796
p02268
u689297737
1432458478
Python
Python
py
Runtime Error
20
4248
959
# http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_4_B # Binary Search # Result: import sys NO_ANSWER = -1 def binary_sarch(target, ary, start, end): if start == end: if target == ary[start]: return start else: return NO_ANSWER mid = (start + end) / 2 if target < ary[mid]: return binary_sarch(target, ary, start, mid - 1) elif target > ary[mid]: return binary_sarch(target, ary, mid + 1, end) else: # target == ary[mid] return mid ### main ary_s_len = int(sys.stdin.readline().rstrip()) ary_s = [int(x) for x in sys.stdin.readline().rstrip().split(' ')] ary_t_len = int(sys.stdin.readline().rstrip()) ary_t = [int(x) for x in sys.stdin.readline().rstrip().split(' ')] assert len(ary_s) == ary_s_len assert len(ary_t) == ary_t_len count = 0 for e in ary_t: idx = binary_sarch(e, ary_s, 0, ary_s_len - 1) if idx >= 0: count += 1 print count
s750461566
p02268
u604774382
1433368013
Python
Python3
py
Runtime Error
0
0
345
n = int( input( ) ) s = [ int( val ) for val in input( ).split( " " ) ] q = int( input( ) ) t = [ int( val ) for val in input( ).split( " " ) ] cnt = 0 cnt = 0 for ti in t: low = 0 high = n - 1 while low <= high: m = ( low+high )/2 if ti < s[m]: high = m - 1 elif s[m] < ti: low = m + 1 else: cnt += 1 break print( cnt )
s619049276
p02268
u271261336
1443524480
Python
Python
py
Runtime Error
0
0
106
n = input() S = map(int,raw_input().split()) m = input() T = map(int,raw_input().split()) print len(T & S)
s551240260
p02268
u271261336
1443526288
Python
Python
py
Runtime Error
0
0
386
n = input() S = set([int(s) for s in raw_input().split()]) m = input() T = set([int(s) for s in raw_input().split()]) r=[] def binarySearch(a=[],p=0): ll=0 ul=len(a) while(True): if ll>ul: return -1 ms=(int(ll)+int(ul))/2 if a[i]==p: r.append(p) elif a[i]>p: ul=i-1 else: ll=i+1 if __name__=="__main__": for i in T: binarySearch(S,i) print len(r)
s600635934
p02268
u271261336
1443530619
Python
Python
py
Runtime Error
0
0
104
n = input() S = map(int,raw_input().split()) m = input() T = map(int,raw_input().split()) print len(S&T)
s767281258
p02268
u271261336
1443530640
Python
Python
py
Runtime Error
0
0
108
n = input() S = set(int(),raw_input().split()) m = input() T = set(int(),raw_input().split()) print len(S&T)
s302220319
p02268
u488601719
1448248404
Python
Python3
py
Runtime Error
0
0
440
n = int(input()) S = map(int, input().split()) q = int(input()) T = map(int, input().split()) def binary_search(A, key): left = 0 right = n while left < right: mid = (left + right)/2 if A[mid] == key: return True elif key < A[mid]: right = mid else: left = mid + 1 return False cnt = 0 for i in T: if binary_search(S, i): cnt += 1 print(cnt)
s151077858
p02268
u963402991
1448946291
Python
Python3
py
Runtime Error
0
0
459
# -*- coding:utf-8 -*- def binarySearch(A, key): left, right = 0, n while left < right: mid = (left + right) / 2 if A[mid] == key: return True elif key < A[mid]: right = mid else: left = mid += 1 return False n = int(input()) S = [int(i) for i in range(n)] q = int(input()) T = [int(i) for i in range(q)] count = 0 for i in T: if (S,i): count += 1 print (count)
s792465042
p02268
u317901693
1450680647
Python
Python3
py
Runtime Error
0
0
375
from collections import deque iterator = [["NS", "S"], ["NT", "T"]] var = {} for i, j in iterator: var[i] = int(input()) var[j] = [int(k) for k in input().split()] var["S"] = sorted(var["S"]) var["T"] = sorted(var["T"]) dq = deque(var["S"]) res = 0 for T in var["T"]: if T in dq: res += 1 while(dq[0] <= T): dq.popleft() print(res)
s569527841
p02268
u885889402
1452047694
Python
Python3
py
Runtime Error
0
0
444
def gost(lis,ky): lens=len(lis) if lens <= 5: if ky in lis: return True else: return False if ky <= lis[lens//2]: return gost(lis[:lens],ky) else: return gost(lis[lens:],ky) n = int(input()) a = input() s=list(map(int,a.split())) q = int(input()) a = input() t=list(map(int,a.split())) i = 0 for it in t: if gost(s,it): i = i+1 print(i)
s522619546
p02268
u885889402
1452048156
Python
Python3
py
Runtime Error
0
0
448
def gost(lis,ky): lens=len(lis) if lens <= 5: if ky in lis: return True else: return False if ky <= lis[lens//2]: return gost(lis[:lens/2],ky) else: return gost(lis[lens/2:],ky) n = int(input()) a = input() s=list(map(int,a.split())) q = int(input()) a = input() t=list(map(int,a.split())) i = 0 for it in t: if gost(s,it): i = i+1 print(i)
s171058810
p02268
u885889402
1452076246
Python
Python3
py
Runtime Error
0
0
508
def gost(lis,ky): lens=len(lis) if lens <= 5: print("key = "+str(ky) print(lis) if ky in lis: return True else: return False if ky <= lis[(lens//2)-1]: return gost(lis[:(lens//2)],ky) else: return gost(lis[(lens//2):],ky) n = int(input()) a = input() s=list(map(int,a.split())) q = int(input()) a = input() t=list(map(int,a.split())) i = 0 for it in t: if gost(s,it): i = i+1 print(i)
s242134285
p02268
u000228958
1452086477
Python
Python3
py
Runtime Error
0
0
251
n = input() S = map(int, raw_input().split()) q = input() T = map(int, raw_input().split()) S.append(0) cnt = 0 for i in range(q): j = 0 S[n] = T[i] while S[j] != S[n]: j = j + 1 if j != n: cnt = cnt + 1 print cnt
s087438164
p02268
u000228958
1452086626
Python
Python3
py
Runtime Error
0
0
378
n = input() S = map(int, raw_input().split()) q = input() T = map(int, raw_input().split()) S.append(0) cnt = 0 for i in range(q): left = 0 right = n while left < right: mid = (left + right) / 2 if S[mid] == T[j]: cnt = cnt + 1 else if T[j] < S[mid]: right = mid else: left = mid + 1 print cnt
s277133359
p02268
u000228958
1452086652
Python
Python
py
Runtime Error
0
0
378
n = input() S = map(int, raw_input().split()) q = input() T = map(int, raw_input().split()) S.append(0) cnt = 0 for i in range(q): left = 0 right = n while left < right: mid = (left + right) / 2 if S[mid] == T[j]: cnt = cnt + 1 else if T[j] < S[mid]: right = mid else: left = mid + 1 print cnt
s337988011
p02268
u885889402
1452086675
Python
Python3
py
Runtime Error
0
0
519
def gost(lis,ky,r,l): lens=l-r+1 if lens <= 5: print("key = "+str(ky)) print(lis) if ky in lis[r:l]: return True else: return False if ky <= lis[(lens//2)-1]: return gost(lis,ky,r,r+(lens//2)) else: return gost(lis,ky,l-(lens//2),l) n = int(input()) a = input() s=list(map(int,a.split())) q = int(input()) a = input() t=list(map(int,a.split())) i = 0 for it in t: if gost(s,it): i = i+1 print(i)
s901272954
p02268
u885889402
1452086713
Python
Python3
py
Runtime Error
0
0
468
def gost(lis,ky,r,l): lens=l-r+1 if lens <= 5: if ky in lis[r:l]: return True else: return False if ky <= lis[(lens//2)-1]: return gost(lis,ky,r,r+(lens//2)) else: return gost(lis,ky,l-(lens//2),l) n = int(input()) a = input() s=list(map(int,a.split())) q = int(input()) a = input() t=list(map(int,a.split())) i = 0 for it in t: if gost(s,it): i = i+1 print(i)
s995117361
p02268
u885889402
1452086791
Python
Python3
py
Runtime Error
0
0
479
def gost(lis,ky,r,l): lens=l-r+1 if lens <= 5: if ky in lis[r:l]: return True else: return False if ky <= lis[(lens//2)-1]: return gost(lis,ky,r,r+(lens//2)) else: return gost(lis,ky,l-(lens//2),l) n = int(input()) a = input() s=list(map(int,a.split())) q = int(input()) a = input() t=list(map(int,a.split())) i = 0 for it in t: if gost(s,it,0,int(a)-1): i = i+1 print(i)
s030441574
p02268
u000228958
1452087052
Python
Python3
py
Runtime Error
0
0
367
n = input() S = map(int, raw_input().split()) q = input() T = map(int, raw_input().split()) S.append(0) cnt = 0 for j in range(q): left = 0 right = n while left < right: mid = (left + right) / 2 if S[mid] == T[j]: cnt = cnt + 1 else if T[j] < S[mid]: right = mid else: left = mid + 1
s689140391
p02268
u000228958
1452087070
Python
Python
py
Runtime Error
0
0
367
n = input() S = map(int, raw_input().split()) q = input() T = map(int, raw_input().split()) S.append(0) cnt = 0 for j in range(q): left = 0 right = n while left < right: mid = (left + right) / 2 if S[mid] == T[j]: cnt = cnt + 1 else if T[j] < S[mid]: right = mid else: left = mid + 1
s571702111
p02268
u000228958
1452087339
Python
Python
py
Runtime Error
0
0
378
n = input() S = map(int, raw_input().split()) q = input() T = map(int, raw_input().split()) S.append(0) cnt = 0 for j in range(q): left = 0 right = n while left < right: mid = (left + right) / 2 if S[mid] == T[j]: cnt = cnt + 1 else if T[j] < S[mid]: right = mid else: left = mid + 1 print cnt
s784912688
p02268
u000228958
1452087355
Python
Python3
py
Runtime Error
0
0
378
n = input() S = map(int, raw_input().split()) q = input() T = map(int, raw_input().split()) S.append(0) cnt = 0 for j in range(q): left = 0 right = n while left < right: mid = (left + right) / 2 if S[mid] == T[j]: cnt = cnt + 1 else if T[j] < S[mid]: right = mid else: left = mid + 1 print cnt
s256792336
p02268
u000228958
1452087412
Python
Python
py
Runtime Error
0
0
366
n = input() S = map(int, raw_input().split()) q = input() T = map(int, raw_input().split()) cnt = 0 for j in range(q): left = 0 right = n while left < right: mid = (left + right) / 2 if S[mid] == T[j]: cnt = cnt + 1 else if T[j] < S[mid]: right = mid else: left = mid + 1 print cnt
s271913924
p02268
u000228958
1452087433
Python
Python3
py
Runtime Error
0
0
366
n = input() S = map(int, raw_input().split()) q = input() T = map(int, raw_input().split()) cnt = 0 for j in range(q): left = 0 right = n while left < right: mid = (left + right) / 2 if S[mid] == T[j]: cnt = cnt + 1 else if T[j] < S[mid]: right = mid else: left = mid + 1 print cnt
s989289787
p02268
u797673668
1452434685
Python
Python3
py
Runtime Error
30
7684
424
n, s, q, t = int(input()), list(set(map(int, input().split()))), input(), set(map(int, input().split())) # print(sum(i in s for i in t)) def binary_search(i): global n, s l, r = 0, n while l < r: m = (l + r) // 2 sm = s[m] if sm == i: return 1 elif i < sm: r = m else: l = m + 1 return 0 print(sum(binary_search(i) for i in t))
s720800251
p02268
u567281053
1456679245
Python
Python
py
Runtime Error
40
6900
514
def binarySearch(key, lst): while len(lst) != 1: i = len(lst) / 2 if lst[i] > key: lst = lst[:i] elif lst[i] < key: lst = lst[i + 1:] else: return True if lst[0] == key: return True else: return False if __name__ == "__main__": input() S = map(int, raw_input().split()) input() T = map(int, raw_input().split()) n = 0 for t in T: if binarySearch(t, S): n += 1 print n
s250647200
p02268
u569960318
1465285649
Python
Python3
py
Runtime Error
0
0
457
ef binarySearch(S,t): if len(S) == 1: return S[0] == t m = len(S)//2 if S[m] == t: return True if S[m] > t: return binarySearch(S[:m],t) if len(S) > 2: return binarySearch(S[m+1:],t) return False if __name__=='__main__': n=int(input()) S=list(map(int,input().split())) q=int(input()) T=list(map(int,input().split())) cnt = 0 for t in T: cnt += binarySearch(S,t) print(cnt)
s516723142
p02268
u669873554
1468854090
Python
Python3
py
Runtime Error
0
0
546
count_n = int(input()) N = [] n = input() N = n.split() N = list(map(lambda x: int(x), N)).sort() count_p = int(input()) P = [] p = input() P = p.split() P = list(map(lambda x: int(x), P)).sort() def b(i, l): left = 0 right = len(l) while left < right: mid = int((left + right) / 2) if l[mid] > i: right = mid elif l[mid] < i: left = mid + 1 elif l[mid] == i: return True return False answer = 0 for n in N: if b(n, P): answer += 1 print (answer)
s808858773
p02268
u813534019
1476845315
Python
Python
py
Runtime Error
10
6288
505
input() slist = raw_input().split() input() tlist = raw_input().split() def func(v, low, high): mid = (low + high)/2 if mid >= len(slist): return False if v > slist[mid]: if low == high: return False return func(v, mid+1, high) elif v == slist[mid]: return True else: if low == high: return False return func(v, low, mid-1) count = 0 for t in tlist: count += func(t, 0, len(slist)-1) print count
s640415589
p02268
u159356473
1477296573
Python
Python3
py
Runtime Error
0
0
146
30 0 0 0 0 2 3 3 3 4 5 6 7 8 8 8 9 9 9 10 11 11 12 12 12 12 13 13 7000000 500000000 1000000000 16 2 0 5 11 3 16 4 6 1 10 7 14 15 7000000 9 5555555
s654947206
p02268
u022407960
1478017048
Python
Python
py
Runtime Error
0
0
783
# encoding: utf-8 class Solution: @staticmethod def binary_search(): array_length_1 = int(input()) array_1 = [int(x) for x in input().split()] array_length_2 = int(input()) array_2 = [int(x) for x in input().split()] # print(len(set(array_1).intersection(set(array_2)))) left, right, count = 0, array_length_1, 0 for each in array_2: while left < right: mid = (left + right) // 2 if array_1[mid] == each: count += 1 elif each < array_1[mid]: right = mid else: left = mid + 1 print(count) if __name__ == '__main__': solution = Solution() solution.binary_search()
s916288244
p02268
u811733736
1480580653
Python
Python3
py
Runtime Error
0
0
736
from bisect import bisect_left @lru_cache(maxsize=None) def index(a, x): ''' Locate the leftmost value exactly equal to x http: // docs.python.jp / 3.5 / library / bisect.html ''' i = bisect_left(a, x) if i != len(a) and a[i] == x: return i raise ValueError if __name__ == '__main__': # ??????????????\??? # S = [1, 2, 3, 4, 5] # T = [3, 4, 1] num = int(input()) S = [int(x) for x in input().split(' ')] num = int(input()) T = [int(x) for x in input().split(' ')] # ????´¢?????? found = 0 for t in T: try: index(S, t) except ValueError: pass else: found += 1 # ??????????????? print(found)
s978550100
p02268
u960191521
1480975288
Python
Python3
py
Runtime Error
0
0
1052
# coding: utf-8 import numpy as np n = int(input()) s = np.array(list(map(int, input().rstrip().split()))) q = int(input()) t = np.array(list(map(int, input().rstrip().split()))) # print("s:",s) count = 0 def binary_search(array, value): ''' array must be sorted''' # print("value:{}".format(value)) size = array.size start = 0 end = size - 1 found = False while True: middle = (start + end)//2 # print("s:{0}, e:{1}, m:{2}".format(start, end, middle)) v = array[middle] if v == value: # print("v[{}]={} == {}".format(middle, v, value)) return True elif start == end: # print("s:{} == e:{}".format(start, end)) return False elif v > value: # print("v[{}]={} > {}".format(middle, v, value)) end = middle elif v < value: # print("v[{}]={} < {}".format(middle, v, value)) start = middle + 1 for i in range(q): if binary_search(s, t[i]): count += 1 print(count)
s070393428
p02268
u416495268
1485486479
Python
Python3
py
Runtime Error
0
0
411
n = int(input()) S = list(map(int, input().split())) q = int(input()) T = list(map(int, input().split())) def binary_search(A, key): left = 0 right = n while left < right: mid = int((left + right)/2) if A[mid] == key: return True elif key < A[mid]: right = mid else: left = mid + 1 return False cnt = 0 for i in T: if binary_search(S, i): cnt += 1 print(cnt)
s224121517
p02268
u416495268
1485486538
Python
Python3
py
Runtime Error
0
0
405
n = int(input()) S = list(map(int, input().split())) q = int(input()) T = list(map(int, input().split())) def binary_search(A, key): left = 0 right = n while left < right: mid = int((left + right)/2) if A[mid] == key: return True elif key < A[mid]: right = mid else: left = mid + 1 return False t = 0 for i in T: if binary_search(S, i): t += 1 print(t)
s606176775
p02268
u416495268
1485486626
Python
Python3
py
Runtime Error
0
0
409
n = int(input()) S = [int(s) for s in input().split()] q = int(input()) T = [int(t) for t in input().split()] def binary_search(A, key): left = 0 right = n while left < right: mid = int((left + right)/2) if A[mid] == key: return True elif key < A[mid]: right = mid else: left = mid + 1 return False t = 0 for i in T: if binary_search(S, i): t += 1 print(t)
s669716980
p02268
u854976463
1487811943
Python
Python
py
Runtime Error
0
0
1353
def binsearch(order, key): n = len(order) / 2 if order[n] == key: return True, n elif order[n] > key: return binsearch(order[:n], key) else: return binsearch(order[n:], key) return False n = raw_input() l = map(int, raw_input().split()) n = raw_input() s = map(int, raw_input().split()) sum = 0 for i in s: isfind, pos = binsearch(l, i) if isfind: sum += 1 print sum
s036986650
p02268
u130834228
1490516783
Python
Python3
py
Runtime Error
0
0
79
n = input() S = input().split() q = input() T = input().split() print(len(S&T)
s939300886
p02268
u130834228
1490516802
Python
Python3
py
Runtime Error
0
0
80
n = input() S = input().split() q = input() T = input().split() print(len(S&T))
s541602365
p02268
u130834228
1490516827
Python
Python3
py
Runtime Error
0
0
80
n = input() S = input().split() q = input() T = input().split() print(len(S&T))
s093575465
p02268
u130834228
1490518325
Python
Python3
py
Runtime Error
0
0
402
n = input() S = set(input().split()) q = input() T = set(input().split()) #print(len(S&T)) #set:??????????????????????????? cnt = 0 for i in range(T): left = 0 right = n-1 while left < right: mid = (left+right) // 2 if S[mid] == i: cnt += 1 break elif S[mid] < i: left = mid+1 else: right = mid-1 print(cnt)
s906106472
p02268
u130834228
1490518351
Python
Python3
py
Runtime Error
0
0
396
n = input() S = (input().split()) q = input() T = (input().split()) #print(len(S&T)) #set:??????????????????????????? cnt = 0 for i in range(T): left = 0 right = n-1 while left < right: mid = (left+right) // 2 if S[mid] == i: cnt += 1 break elif S[mid] < i: left = mid+1 else: right = mid-1 print(cnt)
s981066531
p02268
u939814144
1495213103
Python
Python3
py
Runtime Error
0
0
155
def binary_search(): input() s = set(input().split()) input() t = set(input().split()) print(len(s & t)) if __name__ == '__main__': linear_search()
s723916905
p02268
u091533407
1498466613
Python
Python3
py
Runtime Error
50
8432
509
def binary_search(S, a): leng = len(S) mid = leng // 2 if S[mid] == a: return True elif leng < 2: return False elif S[mid] < a: return binary_search(S[mid+1:], a) else: return binary_search(S[:mid], a) if __name__=="__main__": n = int(input()) S = list(map(int, input().split())) q = int(input()) T = list(map(int, input().split())) ans = 0 for i in T: if binary_search(S, i): ans += 1 print(ans)
s798364831
p02268
u591467586
1499222832
Python
Python3
py
Runtime Error
0
0
442
n1 = int(input()) s = (input()).split() n2 = int(input()) t = (input()).split() m = [] for i in range(0, n2): left = 0 right = n1 key = int(t[i]) while left < right: mid = int((left + right)/2) if s[mid] == key: m.append(key) break elif key < s[mid]: right = mid else: left = mid + 1 print(len(m))
s887120723
p02268
u591467586
1499222892
Python
Python3
py
Runtime Error
0
0
442
n1 = int(input()) s = (input()).split() n2 = int(input()) t = (input()).split() m = [] for i in range(0, n2): left = 0 right = n1 key = int(t[i]) while left < right: mid = int((left + right)/2) if s[mid] == key: m.append(key) break elif key < s[mid]: right = mid else: left = mid + 1 print(len(m))
s016424852
p02268
u591467586
1499223075
Python
Python3
py
Runtime Error
0
0
452
n1 = int(input()) s = (input()).split() n2 = int(input()) t = (input()).split() m = [] for i in range(0, n2): left = 0 right = n1 key = int(t[i]) while left < right: mid = int((left + right)/2) if int(s[mid]) == key: m.append(key) break elif int(key) < s[mid]: right = mid else: left = mid + 1 print(len(m))
s258575548
p02268
u264972437
1500445744
Python
Python3
py
Runtime Error
0
0
339
def binarySeach(t): left,right = 0,n while right > left: mid = (left+right) // 2 if S[mid] == t: return True elif S[mid] > t: mid = right else: mid = left return False n = int(input()) S = [int(s) for s in input().split()] q = int(input()) T = [int(s) for s in input().split()] print(sum([binarySerch(t) for t in T]))
s957891311
p02268
u264972437
1500446018
Python
Python3
py
Runtime Error
0
0
339
def binarySeach(t): left,right = 0,n while right > left: mid = (left+right) // 2 if S[mid] == t: return True elif S[mid] > t: mid = right else: mid = left return False n = int(input()) S = [int(s) for s in input().split()] q = int(input()) T = [int(s) for s in input().split()] print(sum([binarySerch(t) for t in T]))
s282333815
p02268
u491916705
1502160337
Python
Python
py
Runtime Error
10
6468
771
n = int(raw_input()) if n > 1: s = map(int, raw_input().split()) else: s = int(raw_input()) q = int(raw_input()) if q > 1: t = map(int, raw_input().split()) else: t = [int(raw_input())] count = 0 for i in range(q): tmp = int(n/2) gap = 1./2 flag = 0 if t[i] < s[0] or t[i] > s[n-1]: continue else: while True: if s[tmp] < t[i]: tmp = tmp + int(n*gap) elif s[tmp] > t[i]: tmp = tmp - int(n*gap) else: count += 1 break if int(gap*n) == 1 and flag == 0: flag = 1 continue elif int(gap*n) < 1: break gap *= 1./2 print count
s012018280
p02268
u659034691
1503001032
Python
Python3
py
Runtime Error
20
7720
513
# your code goes here #binary n=int(input()) S=[int(i) for i in input().split()] q=int(input()) T=[int(i) for i in input().split()] C=0 for i in range(q): j=n//2 b=n//2+1 while T[i]!=S[j] and b>1: if b%2==1: b+=1 b//=2 if T[i]>S[j]: j+=b elif T[i]<S[j]: j-=b if T[i]==S[j]: C+=1 else: if T[i]>S[j]: j+=b else: j-=b if T[i]==S[j]: C+=1 # print(j) print(C)
s979563654
p02268
u659034691
1503001376
Python
Python3
py
Runtime Error
20
7748
511
# your code goes here #binary n=int(input()) S=[int(i) for i in input().split()] q=int(input()) T=[int(i) for i in input().split()] C=0 for i in range(q): j=n//2 b=n//2 while T[i]!=S[j] and b>1: if b%2==1: b+=1 b//=2 if T[i]>S[j]: j+=b elif T[i]<S[j]: j-=b if T[i]==S[j]: C+=1 else: if T[i]>S[j]: j+=b else: j-=b if T[i]==S[j]: C+=1 # print(j) print(C)
s646734042
p02268
u735204496
1505201202
Python
Python
py
Runtime Error
0
0
662
import sys def binary_search(array, num, left, right): if right < left: return False center = (right + left) / 2 if array[center] == num: return True elif array[center] < num: return binary_search(array, num, center + 1, right) elif array[center] > num: return binary_search(array, num, left, center) n = int(sys.stdin.readline().strip()) S = map(lambda x: int(x), sys.stdin.readline().strip().split(" ")) n = int(sys.stdin.readline().strip()) T = map(lambda x: int(x), sys.stdin.readline().strip().split(" ")) res = 0 for t in T: if binary_search(S, t, 0, len(S)): res += 1 print res
s241848548
p02268
u846136461
1510304316
Python
Python
py
Runtime Error
40
6896
530
n = raw_input() S = map(int, raw_input().split()) q = raw_input() T = map(int, raw_input().split()) def BinarySearch(list, num): #print list l = len(list) if l == 1 and list[0] != num: #print("*0") return 0 else: if list[l/2] == num: #print("*1") return 1 elif list[l/2] < num: #print("*2") return BinarySearch(list[l/2+1:], num) else: #print("*3") return BinarySearch(list[:l/2], num) cnt = 0 for i in T: #print("*4") #print BinarySearch(S, i) cnt += BinarySearch(S, i) #print cnt print cnt
s101533466
p02268
u262566745
1510546445
Python
Python3
py
Runtime Error
0
0
453
n = int(input()) S = map(int, input().split(" ")) q = int(input()) T = map(int, input().split(" ")) def binary_search(target, key): left = 0 right = len(S) while(left < right): mid = (left + right) // 2 if S[mid] == key: return True elif S[mid] < key: left = mid else: right = mid return False cnt = 0 for t in T: if binary_search(S, t): cnt += 1 print(cnt)
s082240058
p02268
u626266743
1510660477
Python
Python3
py
Runtime Error
0
0
122
n = int(input()) S = list(map(int, input().split())) q = int(input()) T = list(map(int, input().split())) print(len(S&T))
s484335373
p02268
u626266743
1510660516
Python
Python3
py
Runtime Error
0
0
110
n = int(input()) S = set(int, input().split()) q = int(input()) T = set(int, input().split()) print(len(S&T))
s547683412
p02268
u845643816
1510710087
Python
Python3
py
Runtime Error
0
0
383
n = int(input()) S = map(int, input().split()) q = int(input()) T = map(int, input().split()) count = 0 for key in T: left = 0 right = n while left < right mid = (right - left) // 2 if S[mid] == key: count = count + 1 break else if key < S[mid] right = mid else left = mid + 1 print(count)
s003251588
p02268
u845643816
1510710119
Python
Python3
py
Runtime Error
0
0
385
n = int(input()) S = map(int, input().split()) q = int(input()) T = map(int, input().split()) count = 0 for key in T: left = 0 right = n while left < right mid = (right - left) // 2 if S[mid] == key: count = count + 1 break else if key < S[mid]: right = mid else: left = mid + 1 print(count)
s248978974
p02268
u845643816
1510710131
Python
Python3
py
Runtime Error
0
0
386
n = int(input()) S = map(int, input().split()) q = int(input()) T = map(int, input().split()) count = 0 for key in T: left = 0 right = n while left < right: mid = (right - left) // 2 if S[mid] == key: count = count + 1 break else if key < S[mid]: right = mid else: left = mid + 1 print(count)
s855367625
p02268
u845643816
1510710181
Python
Python3
py
Runtime Error
0
0
383
n = int(input()) S = map(int, input().split()) q = int(input()) T = map(int, input().split()) count = 0 for key in T: left = 0 right = n while left < right: mid = (right - left) // 2 if S[mid] == key: count = count + 1 break elif key < S[mid]: right = mid else: left = mid + 1 print(count)
s071374058
p02268
u845643816
1510710286
Python
Python3
py
Runtime Error
0
0
381
n = int(input()) S = map(int, input().split()) q = int(input()) T = map(int, input().split()) count = 0 for key in T: left = 0 right = n while left < right: mid = (right - left) // 2 if S[mid] == key: count = count + 1 break if key < S[mid]: right = mid else: left = mid + 1 print(count)
s439255544
p02268
u845643816
1510710390
Python
Python3
py
Runtime Error
0
0
288
count = 0 for key in T: left = 0 right = n while left < right: mid = (right - left) // 2 if S[mid] == key: count = count + 1 break if key < S[mid]: right = mid else: left = mid + 1 print(count)
s990625665
p02268
u062548499
1513326805
Python
Python3
py
Runtime Error
0
0
604
n = input() S = map(int, raw_input().split()) q = input() T = map(int, raw_input().split()) def binary_search(lindex, rindex, key): while lindex <= rindex: if lindex == rindex: if S[lindex] == key: return True break midindex = (lindex + rindex) / 2 if S[midindex] == key: return True else: if S[midindex] < key: lindex = midindex + 1 else: rindex = midindex C = 0 for i in range(q): if (binary_search(0, n-1, T[i])): C += 1 print(C)
s399324078
p02268
u530663965
1513835202
Python
Python3
py
Runtime Error
0
0
1287
import sys ERROR_INPUT = 'input is invalid' ERROR_INPUT_NOT_UNIQUE = 'input is not unique' def main(): S = get_input1() T = get_input2() count = 0 for t in T: if binary_search(S, t, 0, len(S), len(S) // 2): print(t) count += 1 print(count) def binary_search(li, key, left, right, mid): if li[mid] == key: return True elif li[mid] < key: left = mid + 1 elif li[mid] > key: right = mid if left > right: return False mid = (left + right) / 2 return binary_search(li, key, left, right, mid) def get_input1(): n = int(input()) if n > 100000: print(ERROR_INPUT) sys.exit(1) li = [] for x in input().split(' '): if int(x) < 0 or int(x) > 10 ** 9: print(ERROR_INPUT) sys.exit(1) li.append(int(x)) return li def get_input2(): n = int(input()) if n > 50000: print(ERROR_INPUT) sys.exit(1) li = [] for x in input().split(' '): if int(x) < 0 or int(x) > 10 ** 9: print(ERROR_INPUT) sys.exit(1) elif int(x) in li: print(ERROR_INPUT_NOT_UNIQUE) sys.exit(1) li.append(int(x)) return li main()