s_id string | p_id string | u_id string | date string | language string | original_language string | filename_ext string | status string | cpu_time string | memory string | code_size string | code string | error string | stdout string |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
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) | File "/tmp/tmp8v3vjnf7/tmpms1f6txl.py", line 13
print sum(res)
^^^^^^^^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
| |
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 | File "/tmp/tmp1nq28vsy/tmptu_k6l1p.py", line 13
print ans
^^^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
| |
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) | File "/tmp/tmpvcfn09p8/tmpuwjpvwy8.py", line 5
print(len(S & T)
^
SyntaxError: '(' was never closed
| |
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)) | Traceback (most recent call last):
File "/tmp/tmpcbjpc2em/tmp05od3wq7.py", line 1, in <module>
n = int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
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)) | Traceback (most recent call last):
File "/tmp/tmpun3w4luw/tmpfm4n63pc.py", line 1, in <module>
n = int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
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)) | Traceback (most recent call last):
File "/tmp/tmpe5jix9jo/tmpqxv1_t6j.py", line 1, in <module>
n = int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
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)) | Traceback (most recent call last):
File "/tmp/tmpslrb9w4s/tmp71qkksat.py", line 1, in <module>
n = int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
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() | Traceback (most recent call last):
File "/tmp/tmpftv6_7hc/tmp0ugkq8o8.py", line 56, in <module>
main()
File "/tmp/tmpftv6_7hc/tmp0ugkq8o8.py", line 8, in main
S = get_input1()
^^^^^^^^^^^^
File "/tmp/tmpftv6_7hc/tmp0ugkq8o8.py", line 22, in get_input1
n = int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
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)
| Traceback (most recent call last):
File "/tmp/tmphksuo8xb/tmpoypcyvfu.py", line 1, in <module>
n=int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
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)
| Traceback (most recent call last):
File "/tmp/tmp3pik2md4/tmp_iky1llu.py", line 11, in <module>
n=int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
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)
| Traceback (most recent call last):
File "/tmp/tmpbnxb6ios/tmpb7b1rbsm.py", line 11, in <module>
n=int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
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())
| Traceback (most recent call last):
File "/tmp/tmp6r5r2d_5/tmpb7due8cz.py", line 1, in <module>
n=int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
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;
}
| File "/tmp/tmpzias8760/tmpbnj599kx.py", line 3
using namespace std;
^^^^^^^^^
SyntaxError: invalid syntax
| |
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)
| Traceback (most recent call last):
File "/tmp/tmpyuucqtwl/tmpze5efwe0.py", line 2, in <module>
n=int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
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)
| Traceback (most recent call last):
File "/tmp/tmpm99rxbh1/tmpbiag00gg.py", line 2, in <module>
n=int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
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)
| Traceback (most recent call last):
File "/tmp/tmpnjs320mx/tmpldbh33bs.py", line 1, in <module>
n = int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
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;
}
| File "/tmp/tmplm88x7yx/tmp6d86xp30.py", line 3
using namespace std;
^^^^^^^^^
SyntaxError: invalid syntax
| |
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)
| Traceback (most recent call last):
File "/tmp/tmppk8nl1t9/tmpolz19h63.py", line 3, in <module>
n=int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
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)
| Traceback (most recent call last):
File "/tmp/tmp04ooey49/tmp3_nxj70t.py", line 3, in <module>
n=int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
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)
| Traceback (most recent call last):
File "/tmp/tmpq1_r3w7k/tmpsynac8ny.py", line 3, in <module>
n=int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
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)
| File "/tmp/tmpduak0h_2/tmp3zq5n7v9.py", line 13
if listb[i]==lista[j] and if x==0:
^^
SyntaxError: invalid syntax
| |
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++;
}
}
}
| File "/tmp/tmpkfr7p6ww/tmpiyoaggpe.py", line 7
int linear_search(int a, int b);
^^^^^^^^^^^^^
SyntaxError: invalid syntax
| |
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])
| File "/tmp/tmpp4nb0fp2/tmp2pgodiud.py", line 13
print(sum([linearSearch(key, arr2) for key in arr])
^
SyntaxError: '(' was never closed
| |
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))
| File "/tmp/tmpcsebqwm_/tmpek6whc8f.py", line 14
print(sum([linearSearch(key, arr1, N1) for key in arr2))
^
SyntaxError: closing parenthesis ')' does not match opening parenthesis '['
| |
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))
| File "/tmp/tmp6wth8llh/tmpm2gxq_3s.py", line 14
print(sum([linearSearch(key, arr1, N1) for key in arr2))
^
SyntaxError: closing parenthesis ')' does not match opening parenthesis '['
| |
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]))
| Traceback (most recent call last):
File "/tmp/tmpc_54u2rw/tmp6x8nk3v9.py", line 9, in <module>
N1 = int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
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));
| File "/tmp/tmpta609p_6/tmppw8jzje4.py", line 1
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
^^^^^
SyntaxError: invalid syntax
| |
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))
| File "/tmp/tmpff_ubmae/tmpog_0wly7.py", line 14
else target_num > S[idx]:
^^^^^^^^^^
SyntaxError: expected ':'
| |
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;
}
| File "/tmp/tmpoiz9c6tv/tmp47069q94.py", line 19
using namespace std;
^^^^^^^^^
SyntaxError: invalid syntax
| |
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)
| File "/tmp/tmp_ho98zes/tmpcivnbeoo.py", line 22
n = int(input()) # 数列Sに含まれる整数の個数
^
SyntaxError: invalid non-printable character U+3000
| |
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;
}
?>
| File "/tmp/tmplyaszpau/tmpdm0z_2vo.py", line 1
<?php
^
SyntaxError: invalid syntax
| |
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 | File "/tmp/tmpa1rimte8/tmpwsh_ltnk.py", line 29
print count
^^^^^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
| |
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 | File "/tmp/tmp5mx1yn8w/tmpw7lr9y4_.py", line 29
print count
^^^^^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
| |
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 | File "/tmp/tmpvmuntcno/tmpsxqdl_0g.py", line 23
print C
^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
| |
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 | File "/tmp/tmp2sxwsqni/tmpiyrnt603.py", line 23
print C
^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
| |
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 | File "/tmp/tmp7r2l796a/tmpd2guwd0d.py", line 37
print count
^^^^^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
| |
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 ) | Traceback (most recent call last):
File "/tmp/tmp4f0q0o_c/tmpomjm8cwm.py", line 1, in <module>
n = int( input( ) )
^^^^^^^^
EOFError: EOF when reading a line
| |
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) | File "/tmp/tmpulo2yxr0/tmpsu3seizv.py", line 5
print len(T & S)
^^^^^^^^^^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
| |
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) | File "/tmp/tmp80sxwo2w/tmpx9j75w3h.py", line 32
print len(r)
^^^^^^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
| |
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) | File "/tmp/tmpes0jeitf/tmphof5z5wg.py", line 5
print len(S&T)
^^^^^^^^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
| |
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) | File "/tmp/tmpumoushy6/tmpymnlircm.py", line 5
print len(S&T)
^^^^^^^^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
| |
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) | Traceback (most recent call last):
File "/tmp/tmpvn7wxwzf/tmpfr66doly.py", line 1, in <module>
n = int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
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) | File "/tmp/tmpe1cy0s9k/tmpq1dx5ize.py", line 13
left = mid += 1
^^
SyntaxError: invalid syntax
| |
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) | Traceback (most recent call last):
File "/tmp/tmpy8j4b9k4/tmpxnb3riur.py", line 7, in <module>
var[i] = int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
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) | Traceback (most recent call last):
File "/tmp/tmpni2agg9g/tmp0uk7oxz1.py", line 17, in <module>
n = int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
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) | Traceback (most recent call last):
File "/tmp/tmpdzz6hkw9/tmpftnlm_6e.py", line 17, in <module>
n = int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
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) | File "/tmp/tmp9e_2n4a1/tmp3r3cyks2.py", line 6
print("key = "+str(ky)
^
SyntaxError: '(' was never closed
| |
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 | File "/tmp/tmpmf8g62la/tmp6bk3s636.py", line 20
print cnt
^^^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
| |
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 | File "/tmp/tmpu_oir36l/tmp6yamhb49.py", line 18
else if T[j] < S[mid]:
^^
SyntaxError: expected ':'
| |
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 | File "/tmp/tmpchwq72sp/tmpwiluhj51.py", line 18
else if T[j] < S[mid]:
^^
SyntaxError: expected ':'
| |
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) | Traceback (most recent call last):
File "/tmp/tmpslzv_6_i/tmpnr6ucsc8.py", line 19, in <module>
n = int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
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) | Traceback (most recent call last):
File "/tmp/tmpm13xhccf/tmpur13rtzh.py", line 17, in <module>
n = int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
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) | Traceback (most recent call last):
File "/tmp/tmp8rq5q0x9/tmptn3edicf.py", line 17, in <module>
n = int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
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 | File "/tmp/tmpollohtsj/tmpu77b71o6.py", line 18
else if T[j] < S[mid]:
^^
SyntaxError: expected ':'
| |
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 | File "/tmp/tmpl5ywha0i/tmpem_dbxy1.py", line 18
else if T[j] < S[mid]:
^^
SyntaxError: expected ':'
| |
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 | File "/tmp/tmp_dstf3bf/tmpn8fmhlnp.py", line 18
else if T[j] < S[mid]:
^^
SyntaxError: expected ':'
| |
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 | File "/tmp/tmpdf0vgivl/tmp4uxhhmvt.py", line 18
else if T[j] < S[mid]:
^^
SyntaxError: expected ':'
| |
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 | File "/tmp/tmppnnucx2g/tmpvcqby6bw.py", line 17
else if T[j] < S[mid]:
^^
SyntaxError: expected ':'
| |
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 | File "/tmp/tmpm985xcz2/tmp04p0g10e.py", line 17
else if T[j] < S[mid]:
^^
SyntaxError: expected ':'
| |
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)) | Traceback (most recent call last):
File "/tmp/tmps7sno3rl/tmptwcs7qrm.py", line 1, in <module>
n, s, q, t = int(input()), list(set(map(int, input().split()))), input(), set(map(int, input().split()))
^^^^^^^
EOFError: EOF when reading a line
| |
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 | File "/tmp/tmpm8gfts3j/tmpedflx3ra.py", line 26
print n
^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
| |
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) | File "/tmp/tmpugkdgjvt/tmpoq1t22ql.py", line 1
ef binarySearch(S,t):
^^^^^^^^^^^^
SyntaxError: invalid syntax
| |
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) | Traceback (most recent call last):
File "/tmp/tmpviabxo8j/tmpaqr2pxke.py", line 1, in <module>
count_n = int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
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 | File "/tmp/tmp0_q2aep9/tmpo8evfuu9.py", line 28
print count
^^^^^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
| |
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 | File "/tmp/tmpwyz9axlt/tmprhybevlf.py", line 2
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
^
SyntaxError: invalid syntax
| |
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() | Traceback (most recent call last):
File "/tmp/tmpbi5g4u1x/tmptawm2_yf.py", line 29, in <module>
solution.binary_search()
File "/tmp/tmpbi5g4u1x/tmptawm2_yf.py", line 7, in binary_search
array_length_1 = int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
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) | Traceback (most recent call last):
File "/tmp/tmpw9uvkvbo/tmpeoxzzeub.py", line 3, in <module>
@lru_cache(maxsize=None)
^^^^^^^^^
NameError: name 'lru_cache' is not defined
| |
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) | Traceback (most recent call last):
File "/tmp/tmp655vlela/tmpho4xqotx.py", line 3, in <module>
n = int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
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) | File "/tmp/tmpr98mrbnh/tmp7agbzd23.py", line 7
left = 0
^
IndentationError: expected an indented block after function definition on line 6
| |
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) | File "/tmp/tmpiwfskhaa/tmp5jeqpx5a.py", line 7
left = 0
^
IndentationError: expected an indented block after function definition on line 6
| |
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) | File "/tmp/tmp2p0w5hvk/tmpmwjxsxih.py", line 7
left = 0
^
IndentationError: expected an indented block after function definition on line 6
| |
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 | File "/tmp/tmpjyiijxgn/tmp8yb1qebm.py", line 22
print sum
^^^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
| |
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) | File "/tmp/tmp_azsdm71/tmp403rhlap.py", line 6
print(len(S&T)
^
SyntaxError: '(' was never closed
| |
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)) | Traceback (most recent call last):
File "/tmp/tmpqzpewcdp/tmpacptrb15.py", line 1, in <module>
n = input()
^^^^^^^
EOFError: EOF when reading a line
| |
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)) | Traceback (most recent call last):
File "/tmp/tmphsyqmkjr/tmpyz9ifgww.py", line 1, in <module>
n = input()
^^^^^^^
EOFError: EOF when reading a line
| |
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) | Traceback (most recent call last):
File "/tmp/tmpb39e6lcr/tmpq2r1dtkp.py", line 1, in <module>
n = input()
^^^^^^^
EOFError: EOF when reading a line
| |
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) | Traceback (most recent call last):
File "/tmp/tmplqfdrd2y/tmp_qkd4_co.py", line 1, in <module>
n = input()
^^^^^^^
EOFError: EOF when reading a line
| |
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() | Traceback (most recent call last):
File "/tmp/tmppnrt0who/tmphso2teo3.py", line 9, in <module>
linear_search()
^^^^^^^^^^^^^
NameError: name 'linear_search' is not defined. Did you mean: 'binary_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) | Traceback (most recent call last):
File "/tmp/tmpzh4w5ggp/tmpggkz_bj1.py", line 14, in <module>
n = int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
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)) | Traceback (most recent call last):
File "/tmp/tmpxhe1wgth/tmpx4v7gx1y.py", line 1, in <module>
n1 = int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
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)) | Traceback (most recent call last):
File "/tmp/tmppsz2d9a8/tmpjnf29uyh.py", line 1, in <module>
n1 = int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
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)) | Traceback (most recent call last):
File "/tmp/tmp2x3oiyi5/tmpv5vifd0_.py", line 1, in <module>
n1 = int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
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])) | Traceback (most recent call last):
File "/tmp/tmpmd9waq2o/tmp6o6qeiwn.py", line 13, in <module>
n = int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
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])) | Traceback (most recent call last):
File "/tmp/tmpswdhz1mw/tmpmg6je40j.py", line 13, in <module>
n = int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
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 | File "/tmp/tmp_c302az0/tmphp57vt4q.py", line 36
print count
^^^^^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
| |
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) | Traceback (most recent call last):
File "/tmp/tmpqbrrn6tl/tmptnypbklf.py", line 3, in <module>
n=int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
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) | Traceback (most recent call last):
File "/tmp/tmplwsj9kxs/tmpl7sp9h1u.py", line 3, in <module>
n=int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
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
| File "/tmp/tmpdw3mgtq5/tmprr4n_cm4.py", line 25
print res
^^^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
| |
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 | File "/tmp/tmpnuui0stu/tmphmqdadv4.py", line 30
print cnt
^^^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
| |
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) | Traceback (most recent call last):
File "/tmp/tmpgmluniyu/tmp465lpg3t.py", line 1, in <module>
n = int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
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)) | Traceback (most recent call last):
File "/tmp/tmpy1q6zxp3/tmppf0act2b.py", line 1, in <module>
n = int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
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)) | Traceback (most recent call last):
File "/tmp/tmps24e79lo/tmpq5l5gpd0.py", line 1, in <module>
n = int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
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) | File "/tmp/tmpk1m4nm50/tmpvhf9s_12.py", line 10
while left < right
^
SyntaxError: expected ':'
| |
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) | File "/tmp/tmpiz4rt_5q/tmpnvea_vw5.py", line 10
while left < right
^
SyntaxError: expected ':'
| |
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) | File "/tmp/tmp3cb1d3gw/tmpjf33ibw_.py", line 15
else if key < S[mid]:
^^
SyntaxError: expected ':'
| |
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) | Traceback (most recent call last):
File "/tmp/tmpfioet73v/tmpbc_yyxzw.py", line 1, in <module>
n = int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
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) | Traceback (most recent call last):
File "/tmp/tmpljxc3qii/tmp3_ub6cao.py", line 1, in <module>
n = int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
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) | Traceback (most recent call last):
File "/tmp/tmpgg7lw54w/tmp6jv8pwsj.py", line 4, in <module>
for key in T:
^
NameError: name 'T' is not defined
| |
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) | Traceback (most recent call last):
File "/tmp/tmp3v2vw4b3/tmp4w9z7crq.py", line 1, in <module>
n = input()
^^^^^^^
EOFError: EOF when reading a line
| |
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() | Traceback (most recent call last):
File "/tmp/tmpkniiot87/tmpf36a0g94.py", line 69, in <module>
main()
File "/tmp/tmpkniiot87/tmpf36a0g94.py", line 8, in main
S = get_input1()
^^^^^^^^^^^^
File "/tmp/tmpkniiot87/tmpf36a0g94.py", line 35, in get_input1
n = int(input())
^^^^^^^
EOFError: EOF when reading a line
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.