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
s998858126
p02268
u530663965
1513835249
Python
Python3
py
Runtime Error
0
0
1288
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/tmpcmtv7m1k/tmpm_hs5z4y.py", line 69, in <module> main() File "/tmp/tmpcmtv7m1k/tmpm_hs5z4y.py", line 8, in main S = get_input1() ^^^^^^^^^^^^ File "/tmp/tmpcmtv7m1k/tmpm_hs5z4y.py", line 35, in get_input1 n = int(input()) ^^^^^^^ EOFError: EOF when reading a line
s370512874
p02268
u530663965
1513835431
Python
Python3
py
Runtime Error
0
0
1317
import sys sys.setrecursionlimit(50000) 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/tmpmqm3gfd_/tmp0n68_46o.py", line 70, in <module> main() File "/tmp/tmpmqm3gfd_/tmp0n68_46o.py", line 9, in main S = get_input1() ^^^^^^^^^^^^ File "/tmp/tmpmqm3gfd_/tmp0n68_46o.py", line 36, in get_input1 n = int(input()) ^^^^^^^ EOFError: EOF when reading a line
s357909142
p02268
u749243807
1516971491
Python
Python3
py
Runtime Error
20
5604
745
first_set_count = int(input()); first_set = [int(n) for n in input().split()]; second_set_count = int(input()); second_set = [int(n) for n in input().split()]; def binary_search(num, s, start, end): if start == end: if s[start] == num: return True; else: return False; else: mid = (start + end) // 2; if s[mid] == num: return True; elif num > s[mid]: start = mid + 1; return binary_search(num, s, start, end); else: end = mid - 1; return binary_search(num, s, start, end); count = 0; for num in second_set: if binary_search(num, first_set, 0, len(first_set) - 1): count += 1; print(count);
Traceback (most recent call last): File "/tmp/tmpev1e5vle/tmpgewc68sc.py", line 1, in <module> first_set_count = int(input()); ^^^^^^^ EOFError: EOF when reading a line
s865847446
p02268
u530663965
1517878773
Python
Python3
py
Runtime Error
0
0
468
_ = input() li1 = [int(x) for x in input().split()] _ = input() li2 = [int(x) for x in input().split()] count = 0 for l in li2: if binary_search(li1, l): count += 1 print(count) def binary_search(li, x): if len(li) == 0: return False mid = len(li)//2 k = li[mid] if k == x: return True elif k > x: li = li[:mid] else: li = li[mid+1:] return binary_search(li, x)
Traceback (most recent call last): File "/tmp/tmpgujo5q_0/tmp4mouafvp.py", line 1, in <module> _ = input() ^^^^^^^ EOFError: EOF when reading a line
s367010688
p02268
u530663965
1517878808
Python
Python3
py
Runtime Error
0
0
468
_ = input() li1 = [int(x) for x in input().split()] _ = input() li2 = [int(x) for x in input().split()] count = 0 for l in li2: if binary_search(li1, l): count += 1 print(count) def binary_search(li, x): if len(li) == 0: return False mid = len(li)//2 k = li[mid] if k == x: return True elif k > x: li = li[:mid] else: li = li[mid+1:] return binary_search(li, x)
Traceback (most recent call last): File "/tmp/tmph61i_9pv/tmpkkb5enxr.py", line 1, in <module> _ = input() ^^^^^^^ EOFError: EOF when reading a line
s123981731
p02268
u530663965
1517878894
Python
Python3
py
Runtime Error
0
0
540
def main() _ = input() li1 = [int(x) for x in input().split()] _ = input() li2 = [int(x) for x in input().split()] count = 0 for l in li2: if binary_search(li1, l): count += 1 print(count) def binary_search(li, x): if len(li) == 0: return False mid = len(li)//2 k = li[mid] if k == x: return True elif k > x: li = li[:mid] else: li = li[mid+1:] return binary_search(li, x) if __name__='__main__': main()
File "/tmp/tmp0w0rt7l2/tmpf5dzw2_9.py", line 1 def main() ^ SyntaxError: expected ':'
s124227627
p02268
u530663965
1517878940
Python
Python3
py
Runtime Error
0
0
541
def main(): _ = input() li1 = [int(x) for x in input().split()] _ = input() li2 = [int(x) for x in input().split()] count = 0 for l in li2: if binary_search(li1, l): count += 1 print(count) def binary_search(li, x): if len(li) == 0: return False mid = len(li)//2 k = li[mid] if k == x: return True elif k > x: li = li[:mid] else: li = li[mid+1:] return binary_search(li, x) if __name__='__main__': main()
File "/tmp/tmp9zk1jpf2/tmp79nh8day.py", line 31 if __name__='__main__': ^^^^^^^^^^^^^^^^^^^ SyntaxError: invalid syntax. Maybe you meant '==' or ':=' instead of '='?
s729434483
p02268
u530663965
1517879073
Python
Python3
py
Runtime Error
0
0
615
def main(): n1 = input() if n1 > 100000: return li1 = [int(x) for x in input().split()] n2 = input() if n1 > 50000: return li2 = [int(x) for x in input().split()] count = 0 for l in li2: if binary_search(li1, l): count += 1 print(count) def binary_search(li, x): if len(li) == 0: return False mid = len(li)//2 k = li[mid] if k == x: return True elif k > x: li = li[:mid] else: li = li[mid+1:] return binary_search(li, x) if __name__=='__main__': main()
Traceback (most recent call last): File "/tmp/tmp25njqb_4/tmpkzgse86_.py", line 36, in <module> main() File "/tmp/tmp25njqb_4/tmpkzgse86_.py", line 2, in main n1 = input() ^^^^^^^ EOFError: EOF when reading a line
s093598053
p02268
u530663965
1517879244
Python
Python3
py
Runtime Error
0
0
704
def main(): n1 = int(input()) if n1 > 100000: return li1 = [int(x) for x in input().split()] if len(l1) > 10**9: return n2 = int(input()) if n1 > 50000: return li2 = [int(x) for x in input().split()] if len(l2) > 10**9: return count = 0 for l in li2: if binary_search(li1, l): count += 1 print(count) def binary_search(li, x): if len(li) == 0: return False mid = len(li)//2 k = li[mid] if k == x: return True elif k > x: li = li[:mid] else: li = li[mid+1:] return binary_search(li, x) if __name__=='__main__': main()
Traceback (most recent call last): File "/tmp/tmpmdrvr2pe/tmp7e799zek.py", line 40, in <module> main() File "/tmp/tmpmdrvr2pe/tmp7e799zek.py", line 2, in main n1 = int(input()) ^^^^^^^ EOFError: EOF when reading a line
s158936122
p02268
u117140447
1518695217
Python
Python3
py
Runtime Error
0
0
364
import sys data = [] for line in sys.stdin: data.append(line.split()) S = [] T = [] ans = [] S = data[1] T = data[3] for t in T: l = 0 r = len(S) while l < r : i = (l + r) / 2 if int(S[i]) < int(t) : l = i + 1 elif int(S[i]) > int(t): r = i else : print(int(t)) break
Traceback (most recent call last): File "/tmp/tmp6p89n7dn/tmpu8gkkgyd.py", line 9, in <module> S = data[1] ~~~~^^^ IndexError: list index out of range
s539737583
p02268
u117140447
1518696047
Python
Python3
py
Runtime Error
0
0
393
import sys data = [] for line in sys.stdin: data.append(line.split()) S = [] T = [] ans = [] S = data[1] T = data[3] count = 0 for t in T: l = 0 r = len(S) while l < r : i = (l + r) / 2 if int(S[i]) < int(t) : l = i + 1 elif int(S[i]) > int(t) : r = i else : count = count + 1 break print(count)
Traceback (most recent call last): File "/tmp/tmpemprxovb/tmp9w9airp_.py", line 9, in <module> S = data[1] ~~~~^^^ IndexError: list index out of range
s895843944
p02268
u117140447
1518696080
Python
Python3
py
Runtime Error
0
0
393
import sys data = [] for line in sys.stdin: data.append(line.split()) S = [] T = [] ans = [] S = data[1] T = data[3] count = 0 for t in T: l = 0 r = len(S) while l < r : i = (l + r) / 2 if int(S[i]) < int(t) : l = i + 1 elif int(S[i]) > int(t) : r = i else : count = count + 1 break print(count)
Traceback (most recent call last): File "/tmp/tmpznu4wmu7/tmp9c4f4cv7.py", line 9, in <module> S = data[1] ~~~~^^^ IndexError: list index out of range
s005011690
p02268
u779137493
1518702371
Python
Python3
py
Runtime Error
0
0
382
[n, k] = map(int, input().split(' ')) wi = list(map(int, [input() for i in range(n)])) def isAllocatable(p): kw, ki = 0, 1 for w in wi: if w > p: return False kw += w if kw <= p: continue ki += 1 if k < ki: return False kw = w return True l = 0 r = sum(wi) while l + 1 < r: p = int((l + r) / 2) if isAllocatable(p): r = p else: l = p print(r)
Traceback (most recent call last): File "/tmp/tmp5f8ydzjz/tmpwrwy1aar.py", line 1, in <module> [n, k] = map(int, input().split(' ')) ^^^^^^^ EOFError: EOF when reading a line
s630230657
p02268
u650712316
1518754639
Python
Python3
py
Runtime Error
0
0
1186
#coding: UTF-8 #@document_it import numpy as np def document_it(func): def new_function(*args,**kwargs): print('Running function:', func.__name__) print('Positional arguments:', args) print('Kewword arguments:', kwargs) result = func(*args,**kwargs) print('Result:', result) return result return new_function #@document_it def bsearch(v,list,l=None): if l == 0 or list == []: return False if l==None: l = len(list) import math T = math.ceil(math.log2(l)) t = 0 wid = l offset = 0 while t <= T: if wid == 0: return False pos = wid//2 + offset w = list[pos] if wid == 1: if v == w: return True else: return False else: if v == w: return True elif v < w: wid = wid//2 else: wid = wid//2 - 1 + wid%2 offset = pos + 1 t+=1 def exe(): n = int(input()) S = list(map(int,input().split())) q = int(input()) T = map(int,input().split()) ans = 0 for t in T: if bsearch(t,S,n): ans += 1 print(ans) if __name__ == '__main__': exe()
Traceback (most recent call last): File "/tmp/tmp_87rdlth/tmp2ovxti_2.py", line 63, in <module> exe() File "/tmp/tmp_87rdlth/tmp2ovxti_2.py", line 50, in exe n = int(input()) ^^^^^^^ EOFError: EOF when reading a line
s451842798
p02268
u305943158
1518965262
Python
Python3
py
Runtime Error
50
6504
485
def binarysearch(ary, num): if len(ary) == 1 and ary[0] != num: return -1 mid = len(ary) // 2 if num < ary[mid]: return binarysearch(ary[:mid], num) elif num > ary[mid]: return binarysearch(ary[mid+1:], num) else: return ary[mid] n = int(input()) s = list(map(lambda i: int(i), input().split(" "))) q = int(input()) t = list(map(lambda i: int(i), input().split(" "))) c = 0 for i in t: if binarysearch(s, i) != -1: c += 1 print(c)
Traceback (most recent call last): File "/tmp/tmp6fwx6viy/tmpazh91lvl.py", line 13, in <module> n = int(input()) ^^^^^^^ EOFError: EOF when reading a line
s774883624
p02268
u117140447
1519491051
Python
Python3
py
Runtime Error
0
0
923
import sys #二分探索法のアルゴリズム構成 #1.真ん中の要素を選ぶ処理 #2.真ん中のデータと目的のデータを比較する処理 #3.探索の範囲を半分に狭める処理 if __name__ == '__main__': data = [] count = 0 #外部ファイル読み込み for line in sys.stdin: data.append(line.split()) n = int(data[0][0]) s = list(map(int, data[1])) q = int(data[2][0]) t = list(map(int, data[3])) for i in range(0, q - 1): head = 0 tail = n while True: center = len(s) // 2 if s[center] == t[i] : count = count + 1 print(t[i]) break elif s[center] < t[i]: head = center + 1 else : tail = center - 1 s = s[head : tail + 1] if head >= tail : break
Traceback (most recent call last): File "/tmp/tmpw1wsnxf1/tmpo6hniskz.py", line 16, in <module> n = int(data[0][0]) ~~~~^^^ IndexError: list index out of range
s019731220
p02268
u117140447
1519491127
Python
Python3
py
Runtime Error
0
0
691
import sys if __name__ == '__main__': data = [] count = 0 for line in sys.stdin: data.append(line.split()) n = int(data[0][0]) s = list(map(int, data[1])) q = int(data[2][0]) t = list(map(int, data[3])) for i in range(0, q - 1): head = 0 tail = n while True: center = len(s) // 2 if s[center] == t[i] : count = count + 1 print(t[i]) break elif s[center] < t[i]: head = center + 1 else : tail = center - 1 s = s[head : tail + 1] if head >= tail : break
Traceback (most recent call last): File "/tmp/tmpfseqzbsu/tmpgrnwjykh.py", line 9, in <module> n = int(data[0][0]) ~~~~^^^ IndexError: list index out of range
s168236709
p02268
u117140447
1519491158
Python
Python3
py
Runtime Error
0
0
691
import sys if __name__ == '__main__': data = [] count = 0 for line in sys.stdin: data.append(line.split()) n = int(data[0][0]) s = list(map(int, data[1])) q = int(data[2][0]) t = list(map(int, data[3])) for i in range(0, q - 1): head = 0 tail = n while True: center = len(s) // 2 if s[center] == t[i] : count = count + 1 print(t[i]) break elif s[center] < t[i]: head = center + 1 else : tail = center - 1 s = s[head : tail + 1] if head >= tail : break
Traceback (most recent call last): File "/tmp/tmpndfv_7bi/tmpylhy4aa2.py", line 9, in <module> n = int(data[0][0]) ~~~~^^^ IndexError: list index out of range
s981228376
p02268
u117140447
1519491176
Python
Python3
py
Runtime Error
0
0
691
import sys if __name__ == '__main__': data = [] count = 0 for line in sys.stdin: data.append(line.split()) n = int(data[0][0]) s = list(map(int, data[1])) q = int(data[2][0]) t = list(map(int, data[3])) for i in range(0, q - 1): head = 0 tail = n while True: center = len(s) // 2 if s[center] == t[i] : count = count + 1 print(t[i]) break elif s[center] < t[i]: head = center + 1 else : tail = center - 1 s = s[head : tail + 1] if head >= tail : break
Traceback (most recent call last): File "/tmp/tmpwrygbu_f/tmpsc3199yz.py", line 9, in <module> n = int(data[0][0]) ~~~~^^^ IndexError: list index out of range
s470536722
p02268
u091332835
1522907426
Python
Python3
py
Runtime Error
0
0
350
N = int(input()) S = list(set(map(int, input().split()))) S.sort() Q = int(input()) T = list(map(int, input().split())) ans = 0 for i in range(Q): OK = 0 NG = N while abs(OK-NG)>1: mid = (OK+NG)//2 if S[mid]<=T[i]: OK = mid else: NG = mid if S[OK] == T[i]: ans += 1 print(ans)
Traceback (most recent call last): File "/tmp/tmpdh17qw73/tmp43g82vll.py", line 1, in <module> N = int(input()) ^^^^^^^ EOFError: EOF when reading a line
s716545650
p02268
u605879293
1523776174
Python
Python3
py
Runtime Error
0
0
515
def binarySearch(array, key): left = 0 right = len(array) while left < right: mid = (left + right) / 2 if key == array[mid]: return True elif key > array[mid]: left = mid + 1 elif key < array[mid]: right = mid else: print("ERROR") return False n = int(input()) s = [int(x) for x in input().split()] q = int(input()) t = [int(x) for x in input().split()] a = [x for x in t if binarySearch(s, x)] print(len(a))
Traceback (most recent call last): File "/tmp/tmpiz27d_cr/tmpzrh0851s.py", line 17, in <module> n = int(input()) ^^^^^^^ EOFError: EOF when reading a line
s709688793
p02268
u564105430
1525859334
Python
Python3
py
Runtime Error
0
0
330
n=int(input()) s=input().split() q=int(input()) t=input().split() cnt=0 left=0 right=n for i in range(t): while left<right: mid=(left+right)/2 if s[mid]==t[i]: return cnt+=1 elif s[mid]>t[i]: right=mid else: left=mid+1 print(cnt)
File "/tmp/tmp02v8labk/tmpr_3in3pf.py", line 13 return cnt+=1 ^^ SyntaxError: invalid syntax
s591723109
p02268
u564105430
1525859374
Python
Python3
py
Runtime Error
0
0
322
n=int(input()) s=input().split() q=int(input()) t=input().split() cnt=0 left=0 right=n for i in range(t): while left<right: mid=(left+right)/2 if s[mid]==t[i]: cnt+=1 elif s[mid]>t[i]: right=mid else: left=mid+1 print(cnt)
Traceback (most recent call last): File "/tmp/tmpnsd0ouxr/tmp3em2nx1k.py", line 1, in <module> n=int(input()) ^^^^^^^ EOFError: EOF when reading a line
s979037103
p02268
u398978447
1525860511
Python
Python3
py
Runtime Error
20
5632
298
import bisect S=int(input()) A=[int(i) for i in input().split()] T=int(input()) B=[int(i) for i in input().split()] l=0 r=len(B) c=(r+l)/2 n=0 for i in B: if i in A: n+=1 elif B[i-1]>c: l=c c=(r+l)/2 elif B[i-1]<c: r=c c=(r+l)/2 print(n)
Traceback (most recent call last): File "/tmp/tmpzng_hxrp/tmpo8ggd_qe.py", line 3, in <module> S=int(input()) ^^^^^^^ EOFError: EOF when reading a line
s891051767
p02268
u398978447
1525860638
Python
Python3
py
Runtime Error
20
5640
298
import bisect S=int(input()) A=[int(i) for i in input().split()] T=int(input()) B=[int(i) for i in input().split()] l=0 r=len(B) c=(r+l)/2 n=0 for i in B: if i in A: n+=1 elif A[i-1]>c: l=c c=(r+l)/2 elif A[i-1]<c: r=c c=(r+l)/2 print(n)
Traceback (most recent call last): File "/tmp/tmp0mc2eyhp/tmp3n1s6mhi.py", line 3, in <module> S=int(input()) ^^^^^^^ EOFError: EOF when reading a line
s644439872
p02268
u398978447
1525860884
Python
Python3
py
Runtime Error
0
0
302
import bisect S=int(input()) A=[float(i) for i in input().split()] T=int(input()) B=[float(i) for i in input().split()] l=0 r=len(B) c=(r+l)/2 n=0 for i in B: if i in A: n+=1 elif A[i-1]>c: l=c c=(r+l)/2 elif A[i-1]<c: r=c c=(r+l)/2 print(n)
Traceback (most recent call last): File "/tmp/tmp_rzlqm1n/tmpenjjpmky.py", line 3, in <module> S=int(input()) ^^^^^^^ EOFError: EOF when reading a line
s875190826
p02268
u398978447
1525861006
Python
Python3
py
Runtime Error
0
0
298
import bisect S=int(input()) A=[int(i) for i in input().split()] T=int(input()) B=[int(i) for i in input().split()] l=0 r=len(S) c=(r+l)/2 n=0 for i in B: if i in A: n+=1 elif A[i-1]>c: l=c c=(r+l)/2 elif A[i-1]<c: r=c c=(r+l)/2 print(n)
Traceback (most recent call last): File "/tmp/tmp143to7yk/tmppitconma.py", line 3, in <module> S=int(input()) ^^^^^^^ EOFError: EOF when reading a line
s657882048
p02268
u411881271
1525866560
Python
Python3
py
Runtime Error
0
0
478
sn = int(input()) S = [0 for i in range(sn)] S = input().split() for i in range(sn): S[i] = int(S[i]) tn = int(input()) T = [0 for i in range(tn)] T = input().split() for i in range(tn): T[i] = int(T[i]) A=[] cnt=0 for i in range(tn): key=T[i] left=0 right=sn while left<right: mid=(int)((left+right)/2) if S[mid]==key: if T[i] not in A: cnt+=1 A.append(key) break if S[mid]>key: right=mid if S[mid]<key: left=mid+1 print(cnt)
File "/tmp/tmp7glft844/tmpvd23ut7g.py", line 29 A.append(key) ^ IndentationError: unindent does not match any outer indentation level
s653066584
p02268
u411881271
1525866596
Python
Python3
py
Runtime Error
0
0
478
sn = int(input()) S = [0 for i in range(sn)] S = input().split() for i in range(sn): S[i] = int(S[i]) tn = int(input()) T = [0 for i in range(tn)] T = input().split() for i in range(tn): T[i] = int(T[i]) A=[] cnt=0 for i in range(tn): key=T[i] left=0 right=sn while left<right: mid=(int)((left+right)/2) if S[mid]==key: if T[i] not in A: cnt+=1 A.append(key) break if S[mid]>key: right=mid if S[mid]<key: left=mid+1 print(cnt)
File "/tmp/tmp7qcxhn7b/tmp40g2xivb.py", line 29 A.append(key) TabError: inconsistent use of tabs and spaces in indentation
s692895029
p02268
u609614788
1526034886
Python
Python3
py
Runtime Error
0
0
565
#include <iostream> #include <sstream> int main () { int n1,cnt=0; std::cin>>n1; int S[n1]; for(int i=0;i<n1;i++){ std::cin>>S[i]; } int n2; std::cin>>n2; int T[n2]; for(int i=0;i<n2;i++){ std::cin>>T[i]; } int left=0; int right=n1-1; int c,num; for(int i=0;i<n2;i++){ num=T[i]; left=0; right=n1-1; while(left<right){ c=int((left+right)/2.0); if(S[c]>num){ right=c; } if(S[c]<num){ left=c+1; } if(S[c]==num){ cnt++; } } } std::cout<<cnt<<'\n'; return 0; }
File "/tmp/tmpcjz_lcft/tmprw1gdubg.py", line 4 int main () { ^^^^ SyntaxError: invalid syntax
s262326161
p02268
u481571686
1526149935
Python
Python3
py
Runtime Error
0
0
390
S=[] T=[] S_num=int(input()) S=input().split() T_num=int(input()) T=input().split() cnt=0 for i in T: print(i) right=S_num-1 left=0 center=int((right+left)/2) while left<=center and right>=center: if S[center]==T[i]: cnt+=1 break elif S[center]>i: right=center-1 center=int((left+right)/2) elif S[center]<i: left=center+1 center=int((left+right)/2) print(cnt)
Traceback (most recent call last): File "/tmp/tmp96wb38_8/tmp3wrl5hke.py", line 3, in <module> S_num=int(input()) ^^^^^^^ EOFError: EOF when reading a line
s845433315
p02268
u481571686
1526150717
Python
Python3
py
Runtime Error
0
0
372
def binary_search(S,i,S_num) left=0 right= while left<right: center=int((left+right)/2) if S[center]==i: return True elif S[center]>i: right=center-1 elif S[center]<i: left=center+1 return False S=[] T=[] S_num=int(input()) S=input().split() T_num=int(input()) T=input().split() cnt=0 for i in T: if binary_search(S,i,S_num): cnt+=1 print(cnt)
File "/tmp/tmpi8x4zwsx/tmpaolu8dtr.py", line 1 def binary_search(S,i,S_num) ^ SyntaxError: expected ':'
s145443943
p02268
u861315468
1526156909
Python
Python3
py
Runtime Error
0
0
312
n=int(input()) a=input().split() m=int(input()) b=input().split() a=[int(i) for i in a] b=[int(i) for i in b] cnt=0 low=0 t=(low+high)/2 high=len(b) i=0 while(low<=high): if(b[i]==a[t]): i+=1 cnt+=1 break elif(i>a[t]): low=t+1 elif(i<a[t]): high=t-1 t=(low+high)/2 print(cnt)
Traceback (most recent call last): File "/tmp/tmp9j2wijss/tmp0gcuzn8l.py", line 1, in <module> n=int(input()) ^^^^^^^ EOFError: EOF when reading a line
s940700954
p02268
u564105430
1526193796
Python
Python3
py
Runtime Error
0
0
336
#16D8103010K Ko Okasaki #ALDS4_B n=int(input()) Q=input.split() q=int(input()) S=input.split() Q=list(map(int,Q)) S=list(map(int,S)) cnt=1 for i in range(q): left=0 right=n-1 while left<=right: mid=int((n-1)/2) if S[mid]==Q[i]: cnt+=1 break elif S[mid]>Q[i]: right=mid elif S[mid]<Q[i]: left=mid print(cnt)
Traceback (most recent call last): File "/tmp/tmpxpg0v719/tmp9l5istep.py", line 4, in <module> n=int(input()) ^^^^^^^ EOFError: EOF when reading a line
s532406274
p02268
u564105430
1526195091
Python
Python3
py
Runtime Error
0
0
298
n=int(input()) S=input().split() q=int(input()) T=input().split() S=list(map(int,S)) T=list(map(int,T)) cnt=0 for i in range(q): left=0 right=n-1 while left<right: mid=int((left+right)/2) if S[mid]==T[i]: cnt+=1 break elif S[mid]>T[i]: right=mid else: left=mid print(cnt
File "/tmp/tmpmex8wnav/tmpu34tqlmg.py", line 24 print(cnt ^ SyntaxError: '(' was never closed
s432930970
p02268
u398978447
1526292951
Python
Python3
py
Runtime Error
20
5636
295
import bisect S=int(input()) A=[int(i) for i in input().split()] T=int(input()) B=[int(i) for i in input().split()] l=0 r=len(A) c=(r+l)/2 n=0 for i in B: if i in A: n+=1 elif B[i]>c: l=c+1 c=(r+l)/2 elif B[i]<c: r=c c=(r+l)/2 print(n)
Traceback (most recent call last): File "/tmp/tmp9wbk03tw/tmpq5eox9f0.py", line 3, in <module> S=int(input()) ^^^^^^^ EOFError: EOF when reading a line
s226976432
p02268
u055885332
1526359982
Python
Python3
py
Runtime Error
0
0
376
#16D8101014F 久留米 竜之介 2018/5/14 n=int(input()) S=list(map(int.input().split())) q=int(input()) T=list(map(int,input().split())) point=0 #print(S) #print(T) for i in T: left=0 right=n while left < right: mid=int((left+right)/2) if S[mid] == i: point += 1 break elif i < S[mid]: right = mid else: left = mid + 1 #print(i,point) print(point)
Traceback (most recent call last): File "/tmp/tmp5w_xf1ax/tmpeovpy77h.py", line 2, in <module> n=int(input()) ^^^^^^^ EOFError: EOF when reading a line
s315350447
p02268
u252641015
1526366842
Python
Python3
py
Runtime Error
0
0
400
#include<iostream> #include<stdio.h> #include<algorithm> using namespace std; int A[1000000],n; int main(){ cin >> n; for(int i = 0;i < n;i++) scanf("%d",&A[i]); int q,k,sum = 0; cin >> q; for(int i = 0;i < q;i++){ scanf("%d",&k); if(*lower_bound(A,A+n,k) == k) sum++; } cout << sum << endl; return 0; }
File "/tmp/tmptod5qkrd/tmp9zzz03gp.py", line 4 using namespace std; ^^^^^^^^^ SyntaxError: invalid syntax
s123863856
p02268
u064320529
1526370699
Python
Python3
py
Runtime Error
0
0
520
include<iostream> #include<vector> std::vector<int> copy(std::vector<int> r,int s,int e){ std::vector<int> res; for(int i=s;i<e;i++){ res.push_back(r[i]); } return res; } bool binary_search(int v,std::vector<int> r){ if(r.size()==0)return false; if(r.size()==1){ if(v==r[0])return true; else return false; } int half=(int)(r.size()/2.0); if(r[half]==v)return true; if(r[half]>v)return binary_search(v,copy(r,0,half)); else return binary_search(v,copy(r,half+1,r.size())); } i
File "/tmp/tmpp0vrkuvj/tmpsxgkvjwk.py", line 1 include<iostream> ^ SyntaxError: invalid syntax
s431610617
p02268
u573915636
1526389556
Python
Python3
py
Runtime Error
0
0
150
c=0 n=int(input()) s=input().split() q=int(input()) t=input().split() for i in t: for j in s.sort(): if int(i)==int(j): c +=1 break print(c)
Traceback (most recent call last): File "/tmp/tmpbfjjadwn/tmpnhi7dvew.py", line 2, in <module> n=int(input()) ^^^^^^^ EOFError: EOF when reading a line
s665325630
p02268
u573915636
1526393306
Python
Python3
py
Runtime Error
0
0
150
c=0 n=int(input()) s=input().split() q=int(input()) t=input().split() for i in t: for j in s.sort(): if int(i)==int(j): c +=1 break print(c)
Traceback (most recent call last): File "/tmp/tmpikbhvvm2/tmp9scksl6h.py", line 2, in <module> n=int(input()) ^^^^^^^ EOFError: EOF when reading a line
s265691796
p02268
u573915636
1526393401
Python
Python3
py
Runtime Error
0
0
150
c=0 n=int(input()) s=input().split() q=int(input()) t=input().split() for i in t: for j in s.sort(): if int(i)==int(j): c +=1 break print(c)
Traceback (most recent call last): File "/tmp/tmp1u258h2g/tmpegrtz79x.py", line 2, in <module> n=int(input()) ^^^^^^^ EOFError: EOF when reading a line
s533682313
p02268
u573915636
1526393535
Python
Python3
py
Runtime Error
0
0
154
c=0 n=int(input()) s=input().split() q=int(input()) t=input().split() l=s.sort() for i in t: for j in l: if int(i)==int(j): c +=1 break print(c)
Traceback (most recent call last): File "/tmp/tmprr5lnsfy/tmpnqv1goky.py", line 2, in <module> n=int(input()) ^^^^^^^ EOFError: EOF when reading a line
s968462687
p02268
u573915636
1526394303
Python
Python3
py
Runtime Error
0
0
151
c=0 n=int(input()) s=input().split() q=int(input()) t=input().split() s.sort() for i in t: for j in s: if int(i)==int(j): c +=1 break print(c
File "/tmp/tmpb09wa5j0/tmp83gf53gn.py", line 12 print(c ^ SyntaxError: '(' was never closed
s055879910
p02268
u573915636
1526395854
Python
Python3
py
Runtime Error
0
0
105
c=0 n=int(input()) s=input().split() q=int(input()) t=input().split() s.sort() print(len(set(s)&set(t))
File "/tmp/tmpum31o66e/tmp80ln5dr4.py", line 8 print(len(set(s)&set(t)) ^ SyntaxError: '(' was never closed
s995304653
p02268
u733945366
1526406199
Python
Python
py
Runtime Error
0
0
268
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(q): for j in range(n): if T[i]==S[j]: cnt+=1 break elif S[j+1]==S[j]: break print(cnt)
Traceback (most recent call last): File "/tmp/tmpoqmvre59/tmpljpha1cr.py", line 3, in <module> n=int(input()) ^^^^^^^ EOFError: EOF when reading a line
s532908407
p02268
u733945366
1526407006
Python
Python3
py
Runtime Error
0
0
271
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(q): #T for j in range(n): #S if T[i]==S[j]: cnt+=1 break if S[j+1]==S[j]: j+=1 print(cnt)
Traceback (most recent call last): File "/tmp/tmpiy0iqfcl/tmpgas042ec.py", line 3, in <module> n=int(input()) ^^^^^^^ EOFError: EOF when reading a line
s951729018
p02268
u733945366
1526407042
Python
Python3
py
Runtime Error
0
0
278
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(q): #T for j in range(n): #S if T[i]==S[j]: cnt+=1 break elif S[j+1]==S[j]: j+=1 print(cnt)
Traceback (most recent call last): File "/tmp/tmp54hnskc0/tmpygsbqkhi.py", line 3, in <module> n=int(input()) ^^^^^^^ EOFError: EOF when reading a line
s249400623
p02268
u733945366
1526407364
Python
Python3
py
Runtime Error
0
0
277
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(q): #T for j in range(n): #S if T[j+1]==T[j]: j+=1 if T[i]==S[j]: cnt+=1 break print(cnt)
Traceback (most recent call last): File "/tmp/tmp_ko8nd7z/tmpf_wsxkp7.py", line 3, in <module> n=int(input()) ^^^^^^^ EOFError: EOF when reading a line
s994421949
p02268
u733945366
1526407454
Python
Python3
py
Runtime Error
0
0
277
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(q): #T for j in range(n): #S while S[j+1]==S[j]: j+=1 if T[i]==S[j]: cnt+=1 break print(cnt)
Traceback (most recent call last): File "/tmp/tmpk_5eewya/tmpa058i_9s.py", line 3, in <module> n=int(input()) ^^^^^^^ EOFError: EOF when reading a line
s594153298
p02268
u733945366
1526407471
Python
Python3
py
Runtime Error
0
0
271
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(q): for j in range(n): while S[j+1]==S[j]: j+=1 if T[i]==S[j]: cnt+=1 break print(cnt)
Traceback (most recent call last): File "/tmp/tmpxs_f6oig/tmpq99ymd0e.py", line 3, in <module> n=int(input()) ^^^^^^^ EOFError: EOF when reading a line
s078665139
p02268
u733945366
1526407538
Python
Python3
py
Runtime Error
0
0
276
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(q): for j in range(n): while S[j+1]==S[j]&&j<n: j+=1 if T[i]==S[j]: cnt+=1 break print(cnt)
File "/tmp/tmpxktwg6go/tmpl9p1_2ti.py", line 14 while S[j+1]==S[j]&&j<n: ^ SyntaxError: invalid syntax
s135729652
p02268
u733945366
1526407843
Python
Python3
py
Runtime Error
0
0
317
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]) for i in range(n-1): for j in range(i+1,n): if S[i]==S[j]: S.pop(j) cnt=0 for i in range(q): for j in range(n): if T[i]==S[j]: cnt+=1 break print(cnt)
Traceback (most recent call last): File "/tmp/tmpwna_rgoz/tmp4y3qj3mp.py", line 3, in <module> n=int(input()) ^^^^^^^ EOFError: EOF when reading a line
s265995218
p02268
u733945366
1526417157
Python
Python3
py
Runtime Error
0
0
312
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]) for i in range(n-1): for j in range(i+1,n): if S[i]==S[j]: S.pop(j) print(S) cnt=0 for i in range(q): for j in range(n): if T[i]==S[j]: cnt+=1 break
Traceback (most recent call last): File "/tmp/tmpi5ojlrd3/tmplj6jtn22.py", line 3, in <module> n=int(input()) ^^^^^^^ EOFError: EOF when reading a line
s146687360
p02268
u585373159
1526453052
Python
Python3
py
Runtime Error
0
0
446
n = int(input()) S = input().split() q = int(input()) T = input().split() cnt = 0 for i in range(len(S)): S[i]=int(S[i]) for i in range(len(T)): T[i]=int(T[i]) for i in range(len(S)): x=0 light=0 reft=n while left<right and x==0: mid=int((left+right)/2) if S[mid]==T[i]: cnt+=1 x+=1 elif T[i]<S[mid]: right=mid else: left=mid+1 print(cnt)
Traceback (most recent call last): File "/tmp/tmp3mftum8b/tmp27oe1ju3.py", line 2, in <module> n = int(input()) ^^^^^^^ EOFError: EOF when reading a line
s935027745
p02268
u585373159
1526453178
Python
Python3
py
Runtime Error
0
0
445
n = int(input()) S = input().split() q = int(input()) T = input().split() cnt = 0 for i in range(len(S)): S[i]=int(S[i]) for i in range(len(T)): T[i]=int(T[i]) for i in range(len(S)): x=0 left=0 right=n while left<right and x==0: mid=int((left+right)/2) if S[i]==T[mid]: cnt+=1 x+=1 elif S[i]<T[mid]: right=mid else: left=mid+1 print(cnt)
Traceback (most recent call last): File "/tmp/tmpcihka_fd/tmpqf1nztsm.py", line 1, in <module> n = int(input()) ^^^^^^^ EOFError: EOF when reading a line
s788930209
p02268
u585373159
1526453462
Python
Python3
py
Runtime Error
0
0
445
n = int(input()) S = input().split() q = int(input()) T = input().split() cnt = 0 for i in range(len(S)): S[i]=int(S[i]) for i in range(len(T)): T[i]=int(T[i]) for i in range(len(S)): x=0 left=0 right=n while left<right and x==0: mid=int((left+right)/2) if S[i]==T[mid]: cnt+=1 x+=1 elif S[i]<T[mid]: right=mid else: left=mid+1 print(cnt)
Traceback (most recent call last): File "/tmp/tmprf1o2a22/tmphkvettay.py", line 1, in <module> n = int(input()) ^^^^^^^ EOFError: EOF when reading a line
s817338840
p02268
u398978447
1526454893
Python
Python3
py
Runtime Error
0
0
476
import numpy as np import bisect def bs(A, n): l=0 r=len(A) while l<r: mid=int((l+r)/2) if A[mid]==n: return mid else: if n<A[mid]: r=mid else: l=mid+1 return -1 S=int(input()) A=[int(i) for i in input().split()] T=int(input()) B=[int(j) for j in input().split()] A.sort() cnt=0 for i in range(T): x=bs(A,B[i]) if x!=(-1): cnt=cnt+1 print(cnt)
Traceback (most recent call last): File "/tmp/tmpwrjwwmxo/tmp4_sw1wqm.py", line 19, in <module> S=int(input()) ^^^^^^^ EOFError: EOF when reading a line
s437123224
p02268
u684241248
1527517337
Python
Python3
py
Runtime Error
0
0
833
n = int(input()) S = [int(_) for _ in input().split()] q = int(input()) T = [int(_) for _ in input().split()] cnt = 0 # from copy import deepcopy # for t in T: # S_ = deepcopy(S) # while S_: # ind = len(S_) // 2 # if t == S_[ind]: # cnt += 1 # break # elif t < S_[ind]: # S_ = S_[:ind] # else: # S_ = S_[ind + 1:] def binary_search(ary, target): if ary: ind = len(S) // 2 if target == ary[ind]: return True elif target < ary[ind]: return binary_search(ary[:ind], target) else: return binary_search(ary[ind + 1:], target) else: return False for target in T: if binary_search(S, target): cnt += 1 if __name__ == '__main__': print(cnt)
Traceback (most recent call last): File "/tmp/tmp_1nqu3ue/tmpguyem8pe.py", line 1, in <module> n = int(input()) ^^^^^^^ EOFError: EOF when reading a line
s699738072
p02268
u298224238
1529918716
Python
Python3
py
Runtime Error
0
0
440
def binarySearch(key, arr, N): left = 0 right = N while left < right: mid = (left + right) // 2 if arr[mid] == key: return mid else if key < arr[mid]: right = mid else: left = mid + 1 N1 = int(input()) arr1 = [int(n) for n in input().split()] N2 = int(input()) arr2 = [int(n) for n in input().split()] print(sum([linearSearch(key, arr1) for key in arr2]))
File "/tmp/tmpwnjdof9w/tmpuklcddkm.py", line 8 else if key < arr[mid]: ^^ SyntaxError: expected ':'
s721639123
p02268
u298224238
1529918752
Python
Python3
py
Runtime Error
0
0
444
def binarySearch(key, arr, N): left = 0 right = N while left < right: mid = (left + right) // 2 if arr[mid] == key: return mid else if key < arr[mid]: right = mid else: left = mid + 1 N1 = int(input()) arr1 = [int(n) for n in input().split()] N2 = int(input()) arr2 = [int(n) for n in input().split()] print(sum([binarySearch(key, arr1, N1) for key in arr2]))
File "/tmp/tmpyrzfsaq0/tmp4fcz60dr.py", line 8 else if key < arr[mid]: ^^ SyntaxError: expected ':'
s091263991
p02268
u298224238
1529918781
Python
Python3
py
Runtime Error
0
0
441
def binarySearch(key, arr, N): left = 0 right = N while left < right: mid = (left + right) // 2 if arr[mid] == key: return mid elif key < arr[mid]: right = mid else: left = mid + 1 N1 = int(input()) arr1 = [int(n) for n in input().split()] N2 = int(input()) arr2 = [int(n) for n in input().split()] print(sum([binarySearch(key, arr1, N1) for key in arr2]))
Traceback (most recent call last): File "/tmp/tmppu2m6kjp/tmp8xr6pp4r.py", line 14, in <module> N1 = int(input()) ^^^^^^^ EOFError: EOF when reading a line
s165690712
p02268
u682153677
1530440649
Python
Python3
py
Runtime Error
0
0
109
# -*- coding: utf-8 -*- input() s = set(input().split()) input() t = set(input().split()) print(int(s & t))
Traceback (most recent call last): File "/tmp/tmps55jkmvp/tmp64i4nwv7.py", line 3, in <module> input() EOFError: EOF when reading a line
s343168177
p02268
u682153677
1530440692
Python
Python3
py
Runtime Error
0
0
109
# -*- coding: utf-8 -*- input() s = set(input().split()) input() t = set(input().split()) print(int(s & t))
Traceback (most recent call last): File "/tmp/tmpxk0iv5s8/tmpd23hqvng.py", line 3, in <module> input() EOFError: EOF when reading a line
s130724146
p02268
u633068244
1396098580
Python
Python
py
Runtime Error
0
0
81
a = [raw_input() for i in range(4)] print len(set(a[1].split())&set(a[3].split())
File "/tmp/tmp8ouj4fei/tmpmwufmcgu.py", line 2 print len(set(a[1].split())&set(a[3].split()) ^ SyntaxError: '(' was never closed
s528248073
p02269
u153665391
1531034471
Python
Python3
py
Runtime Error
0
0
246
N = int(input()) A = [input() for i in range(N)] D = {} for row in A: order, key = row.split() if order[0] == "i": D[value] = 1 else: if key in D.keys(): print("yes") else: print("no")
Traceback (most recent call last): File "/tmp/tmpmvrf_5_r/tmp9lxhneo4.py", line 1, in <module> N = int(input()) ^^^^^^^ EOFError: EOF when reading a line
s640421934
p02269
u153665391
1531035174
Python
Python3
py
Runtime Error
0
0
1273
N = int(input()) A = [input() for i in range(N)] M = 10465270 T = [] def convert_str_to_int(s): if s == "A": return 1 elif s == "C": return 2 elif s == "G": return 3 elif s == "T": return 4 else: return 0 def get_key(value: str) -> int: converted_value = "" for s in value: i = convert_str_to_int(s) converted_value += str(i) return int(converted_value) def h1(key: int) -> int: return key % M def h2(key: int) -> int: move_value = 1 + (key % (M-1)) return move_value def h(key:int, i:int) -> int: hash_value = (h1(key) + i+h2(key)) % M return hash_value def find(key: int) -> bool: i = 0 while True: j = h(key, i) if T[j] == key: return True elif T[j] == 0 or i >= M: return False else: i += 1 def insert(key: int) -> None: i = 0 while True: j = h(key, i) if T[j] == 0: T[j] = key return else: i += 1 for row in A: order, value = row.split() key = get_key(value) if order[0] == "i": insert(key) else: if find(key): print("yes") else: print("no")
Traceback (most recent call last): File "/tmp/tmp59uxyini/tmpuwbot2w2.py", line 1, in <module> N = int(input()) ^^^^^^^ EOFError: EOF when reading a line
s742960632
p02269
u153665391
1531035302
Python
Python3
py
Runtime Error
0
0
2562
N = int(input()) A = [input() for i in range(N)] M = 10465270 T = [] N = int(input()) A = [input() for i in range(N)] M = N * 10 T = [0 for i in range(M)] def convert_str_to_int(s): if s == "A": return 1 elif s == "C": return 2 elif s == "G": return 3 elif s == "T": return 4 else: return 0 def get_key(value: str) -> int: converted_value = "" for s in value: i = convert_str_to_int(s) converted_value += str(i) return int(converted_value) def h1(key: int) -> int: return key % M def h2(key: int) -> int: move_value = 1 + (key % (M-1)) return move_value def h(key:int, i:int) -> int: hash_value = (h1(key) + i+h2(key)) % M return hash_value def find(key: int) -> bool: i = 0 while True: j = h(key, i) if T[j] == key: return True elif T[j] == 0 or i >= M: return False else: i += 1 def insert(key: int) -> None: i = 0 while True: j = h(key, i) if T[j] == 0: T[j] = key return else: i += 1 for row in A: order, value = row.split() key = get_key(value) if order[0] == "i": insert(key) else: if find(key): print("yes") else: print("no") def convert_str_to_int(s): if s == "A": return 1 elif s == "C": return 2 elif s == "G": return 3 elif s == "T": return 4 else: return 0 def get_key(value: str) -> int: converted_value = "" for s in value: i = convert_str_to_int(s) converted_value += str(i) return int(converted_value) def h1(key: int) -> int: return key % M def h2(key: int) -> int: move_value = 1 + (key % (M-1)) return move_value def h(key:int, i:int) -> int: hash_value = (h1(key) + i+h2(key)) % M return hash_value def find(key: int) -> bool: i = 0 while True: j = h(key, i) if T[j] == key: return True elif T[j] == 0 or i >= M: return False else: i += 1 def insert(key: int) -> None: i = 0 while True: j = h(key, i) if T[j] == 0: T[j] = key return else: i += 1 for row in A: order, value = row.split() key = get_key(value) if order[0] == "i": insert(key) else: if find(key): print("yes") else: print("no")
Traceback (most recent call last): File "/tmp/tmpdwyhx6aj/tmpffn231wc.py", line 1, in <module> N = int(input()) ^^^^^^^ EOFError: EOF when reading a line
s554633728
p02269
u153665391
1531102749
Python
Python3
py
Runtime Error
0
0
631
N = int(input()) A = list(map(int, input().split())) Q = int(input()) M = list(map(int, input().split())) def exhastive_search(target, head, sum): for i in range(head, N): sum += A[i] print(sum) if target == sum: return True elif target > sum: if exhastive_search(target, i+1, sum): return True sum -= A[i] else: sum -= A[i] return False for target in M: sum = 0 result = "no" for i in range(N): if exhastive_search(target, i, sum): result = "yes" break print(result)
Traceback (most recent call last): File "/tmp/tmpp6ifoanm/tmpuf1wa9xk.py", line 1, in <module> N = int(input()) ^^^^^^^ EOFError: EOF when reading a line
s854467449
p02269
u153665391
1531102784
Python
Python3
py
Runtime Error
0
0
631
N = int(input()) A = list(map(int, input().split())) Q = int(input()) M = list(map(int, input().split())) def exhastive_search(target, head, sum): for i in range(head, N): sum += A[i] print(sum) if target == sum: return True elif target > sum: if exhastive_search(target, i+1, sum): return True sum -= A[i] else: sum -= A[i] return False for target in M: sum = 0 result = "no" for i in range(N): if exhastive_search(target, i, sum): result = "yes" break print(result)
Traceback (most recent call last): File "/tmp/tmpd7w_rn91/tmpvpm3oh3c.py", line 1, in <module> N = int(input()) ^^^^^^^ EOFError: EOF when reading a line
s055677727
p02269
u316584871
1531120655
Python
Python3
py
Runtime Error
0
0
257
n = int(input()) s = {} for i in range(n): order = list(map(str, input().split())) if (order[0][0] == 'i'): s.add(order[1]) else: if order[1] in s: print('yes') else: print('no')
Traceback (most recent call last): File "/tmp/tmp33ojwnqy/tmpf9vmc09c.py", line 1, in <module> n = int(input()) ^^^^^^^ EOFError: EOF when reading a line
s724705503
p02269
u623996423
1540974660
Python
Python3
py
Runtime Error
0
0
234
n = int(input()) dic = {} for i in range(n): x = input() if 'insert' in x: dic.append(x.strip('insert ')) else : if x.strip('find ') in dic: print('yes') else : print('no')
Traceback (most recent call last): File "/tmp/tmptsqppgz4/tmp8_bmgaob.py", line 1, in <module> n = int(input()) ^^^^^^^ EOFError: EOF when reading a line
s895680282
p02269
u623996423
1540975474
Python
Python3
py
Runtime Error
0
0
234
n = int(input()) dic = () for i in range(n): x = input() if 'insert' in x: dic.append(x.strip('insert ')) else : if x.strip('find ') in dic: print('yes') else : print('no')
Traceback (most recent call last): File "/tmp/tmp03l3snrr/tmp0gpckmi7.py", line 1, in <module> n = int(input()) ^^^^^^^ EOFError: EOF when reading a line
s802421899
p02269
u623996423
1540975474
Python
Python3
py
Runtime Error
0
0
234
n = int(input()) dic = () for i in range(n): x = input() if 'insert' in x: dic.append(x.strip('insert ')) else : if x.strip('find ') in dic: print('yes') else : print('no')
Traceback (most recent call last): File "/tmp/tmpggc9bxlc/tmpx7nmk53c.py", line 1, in <module> n = int(input()) ^^^^^^^ EOFError: EOF when reading a line
s031246236
p02269
u623996423
1540975506
Python
Python3
py
Runtime Error
0
0
231
n = int(input()) dic = () for i in range(n): x = input() if 'insert' in x: dic.add(x.strip('insert ')) else : if x.strip('find ') in dic: print('yes') else : print('no')
Traceback (most recent call last): File "/tmp/tmpeuwcwlsq/tmpo6nq8m8w.py", line 1, in <module> n = int(input()) ^^^^^^^ EOFError: EOF when reading a line
s561485525
p02269
u312681524
1545743200
Python
Python
py
Runtime Error
0
0
378
<?php $length = (int)trim(fgets(STDIN)); $dictionary=array(); for($i=0; $i<$length; ++$i){ list($action,$str) = explode(' ',trim(fgets(STDIN))); if($action=="insert"){ $dictionary[] = $str; } if($action=="find"){ if(in_array($str, $dictionary)){ echo 'yes'.PHP_EOL; } else { echo 'no'.PHP_EOL; } } }
File "/tmp/tmprtn5n1n8/tmpb92gff6s.py", line 1 <?php ^ SyntaxError: invalid syntax
s234696749
p02269
u024599888
1428571534
Python
Python
py
Runtime Error
0
0
466
if __name__ == "__main__": n = int(raw_input()) dic = [] num = 0 for i in range(n): t = raw_input().split() if t[0] == "insert": point = BinarySearch(dic, num, t[1]) if point != "FOUND": dic.insert(point, t[1]) num += 1 if t[0] == "find": if(BinarySearch(dic, num, t[1]) == "FOUND"): print("yes") else: print("no")
Traceback (most recent call last): File "/tmp/tmp7h7gvtdm/tmplm79pmgw.py", line 2, in <module> n = int(raw_input()) ^^^^^^^^^ NameError: name 'raw_input' is not defined
s491805411
p02269
u604774382
1433543665
Python
Python
py
Runtime Error
0
0
216
n = int( raw_input( ) ) dic = () for i in range( n ): cmd, word = raw_input( ).split( " " ) if "insert" == cmd: dic[ word ] = True elif "find" == cmd: if word in dic: print( "yes" ) else: print( "no" )
Traceback (most recent call last): File "/tmp/tmpbbymhatm/tmpffhk1dcd.py", line 1, in <module> n = int( raw_input( ) ) ^^^^^^^^^ NameError: name 'raw_input' is not defined
s466880825
p02269
u565801464
1435226533
Python
Python
py
Runtime Error
0
0
338
n = int(raw_input()) d = "" for i in range(n): p,q = map(str,raw_input().split()) if p == "insert": d = Insert(d,q) elif p == "find": rst = Find(d,q) print rst def Insert(d,v): d += v return d def Find(d,v): r = d.find(v) if(r >= 0): return "yes" else: return "no"
File "/tmp/tmpadlkmzeh/tmpw20ry4mu.py", line 9 print rst ^^^^^^^^^ SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
s715738254
p02269
u565801464
1435226695
Python
Python
py
Runtime Error
0
0
249
n = int(raw_input()) d = "" for i in range(n): p,q = map(str,raw_input().split()) if p == "insert": d += q elif p == "find": r = d.find(q) if(r >= 0): return "yes" else: return "no"
File "/tmp/tmpsfn75o71/tmp8d40rpjv.py", line 10 return "yes" ^^^^^^^^^^^^ SyntaxError: 'return' outside function
s055934495
p02269
u882992966
1441962837
Python
Python3
py
Runtime Error
0
0
585
import sys def search_combination(elements, target): if len(elements) == 0: if target == 0: return True else: return False return search_combination(elements[1:], target - elements[0]) or search_combination(elements[1:], target) if __name__ == "__main__": lines = sys.stdin.readlines() elements = [int(x) for x in lines[1].strip().split(" ")] targets = [int(x) for x in lines[3].strip().split(" ")] for target in targets: result = "yes" if search_combination(elements, target) else "no" print(result)
Traceback (most recent call last): File "/tmp/tmpb3_tsyw5/tmpd5bo3ln0.py", line 15, in <module> elements = [int(x) for x in lines[1].strip().split(" ")] ~~~~~^^^ IndexError: list index out of range
s982538080
p02269
u881590806
1448610129
Python
Python
py
Runtime Error
230
137280
642
n = int(raw_input().strip()) commands = [] for i in range(n): commands.append(raw_input().strip()) d = [False]*16777220 def hash(s): ret = 0 i = 0 for dg in s: if dg == 'A': ret += 1 * 10**i elif dg == 'C': ret += 2 * 10**i elif dg == 'G': ret += 3 * 10**i elif dg == 'T': ret += 4 * 10**i i += 1 return ret def insert(d,s): h = hash(s) d[h] = True def find(d,s): h = hash(s) if d[h]: print 'yes' else: print 'no' for c in commands: if c[0] == 'i': insert(d,c[7:]) else: find(d,c[5:])
File "/tmp/tmpcrgst50r/tmpe7j152on.py", line 30 if d[h]: print 'yes' ^^^^^^^^^^^ SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
s370746253
p02269
u072053884
1448855991
Python
Python3
py
Runtime Error
60
15416
999
class HashTable: def __init__(self, size = 1000003): self.size = size self.hash_table = [None] * size def _gen_key(self, val): h1 = hash(val) % self.size h2 = 1 + (hash(val) % (self.size - 1)) for i in range(h1, self.size, h2): if (self.hash_table[i] == None) or (self.hash_table[i] == val): return i def insert(self, val): key = self._gen_key(val) self.hash_table[key] = val def search(self, val): key = self._gen_key(val) if self.hash_table[key]: return True else: return False import sys n = int(sys.stdin.readline()) simple_dict = HashTable() ans = '' for i in range(n): operation = sys.stdin.readline() if operation[0] == 'i': simple_dict.insert(operation[7:]) else: if simple_dict.search(operation[5:]): ans += 'yes' else: ans += 'no' ans += '\n' print(ans, end = '')
Traceback (most recent call last): File "/tmp/tmp0uuchcfa/tmpuialkzbi.py", line 27, in <module> n = int(sys.stdin.readline()) ^^^^^^^^^^^^^^^^^^^^^^^^^ ValueError: invalid literal for int() with base 10: ''
s926104086
p02269
u072053884
1448863642
Python
Python3
py
Runtime Error
40
15412
999
class HashTable: def __init__(self, size = 1000003): self.size = size self.hash_table = [None] * size def _gen_key(self, val): h1 = hash(val) % self.size h2 = 1 + (hash(val) % (self.size - 1)) for i in range(h1, self.size, h2): if (self.hash_table[i] == None) or (self.hash_table[i] == val): return i def insert(self, val): key = self._gen_key(val) self.hash_table[key] = val def search(self, val): key = self._gen_key(val) if self.hash_table[key]: return True else: return False import sys n = int(sys.stdin.readline()) simple_dict = HashTable() ans = '' for i in range(n): operation = sys.stdin.readline() if operation[0] == 'i': simple_dict.insert(operation[7:]) else: if simple_dict.search(operation[5:]): ans += 'yes' else: ans += 'no' ans += '\n' print(ans, end = '')
Traceback (most recent call last): File "/tmp/tmpn5niorwo/tmpqv_cmtdt.py", line 27, in <module> n = int(sys.stdin.readline()) ^^^^^^^^^^^^^^^^^^^^^^^^^ ValueError: invalid literal for int() with base 10: ''
s598175507
p02269
u885889402
1452089742
Python
Python3
py
Runtime Error
0
0
238
dic = [] n = int(input()) for i in range(n): a = input() t=list(map(int,a.split())) if t[0] == "insert": dic.append(t[1]) else: if t[1] in dic: print("yes") else: print("no")
Traceback (most recent call last): File "/tmp/tmp0usyxz4s/tmpp1ygqh6a.py", line 2, in <module> n = int(input()) ^^^^^^^ EOFError: EOF when reading a line
s174257298
p02269
u619765879
1452094340
Python
Python
py
Runtime Error
0
0
291
count = 0 n = input() for i in range(n): com,str = [str, raw_input().split()] if com == 'insert': dic[count] = str count += 1 elif com == 'find': for j in range(count-1): if dic[j] == str: print 'yes' else: print 'no'
File "/tmp/tmpgfesnng5/tmp9ckps9d2.py", line 2 count = 0 IndentationError: unexpected indent
s678803257
p02269
u000228958
1452230544
Python
Python3
py
Runtime Error
0
0
464
def insert(S, string): S.append(string) def find(S, string): cnt = 0 for i in range(len(S)): cnt = cnt + 1 if S[i] == string: print 'yes' break elif cnt == len(S): print 'no' n = input() S = [] for i in range(n): tmp1, tmp2 = map(str,raw_input().split()) if tmp1 == 'insert': insert(S, tmp2) elif tmp1 == 'find': find(S, tmp2) else: print 'error!'
File "/tmp/tmp2uxlf1al/tmp795lk6uq.py", line 9 print 'yes' ^^^^^^^^^^^ SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
s631805510
p02269
u619765879
1452605570
Python
Python
py
Runtime Error
0
0
341
count = 0 n = input() for i in range(n-1): com, str = map(str, raw_input().split()) if com == 'insert': dic[count] = str count += 1 elif com == 'find': for j in range(count-1): if dic[j] == str: print 'yes' break elif j == count-1: print 'no' break
File "/tmp/tmpoi9vb5jn/tmp52oa1cbo.py", line 1 count = 0 IndentationError: unexpected indent
s003750420
p02269
u619765879
1452605917
Python
Python
py
Runtime Error
0
0
318
count = 0 n = input() dic = [] for i in range(n): com, str = map(str, raw_input().split()) if com == 'insert': dic[count] = str count += 1 elif com == 'find': for j in range(count-1): if dic[j] == str: print 'yes' break elif j == count-1: print 'no' break
File "/tmp/tmpj9pvej78/tmpluu47vad.py", line 13 print 'yes' ^^^^^^^^^^^ SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
s390223513
p02269
u619765879
1452606941
Python
Python
py
Runtime Error
0
0
274
n = input() dic = set() for i in range(n): com, st = map(str, raw_input().split()) if com == 'insert': dic.add(st) elif com == 'find': for j in dic: if j == st: print 'yes' break elif j == count-1: print 'no' break
File "/tmp/tmp6p89ykm0/tmpefho_ky2.py", line 11 print 'yes' ^^^^^^^^^^^ SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
s676704997
p02269
u567281053
1457361274
Python
Python
py
Runtime Error
0
0
873
import sys class dictionary: def __init__(self): self.lst = [None] * 444444444445 def insert(self, key): hash = self.toHash(key) self.lst[hash] = 1 def find(self, key): hash = self.toHash(key) if self.lst[hash] is not None: return True else: return False def toHash(self, key): key = key.replace("A", "1") key = key.replace("C", "2") key = key.replace("G", "3") key = key.replace("T", "4") return int(key) if __name__ == "__main__": dic = dictionary() lines = sys.stdin.readlines() del lines[0] for command in lines: key = command.split()[1] if command[0] == "i": dic.insert(key) else: if dic.find(key): print "yes" else: print "no"
File "/tmp/tmp2ai5legf/tmp9n1y3e8_.py", line 35 print "yes" ^^^^^^^^^^^ SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
s904175413
p02269
u763534154
1463999099
Python
Python3
py
Runtime Error
30
7804
1367
class Dict(object): m1 = 2 ** 9 - 1 m2 = 3 def __init__(self): self._dict = ["" for _ in range(self.m1)] def insert(self, k): i = 0 while True: ix = self._h(k, i) if self._dict[ix] == "": self._dict[ix] = k return else: i += 1 def find(self, k): i = 0 while True: ix = self._h(k, i) if self._dict[ix] == k: return ix elif self._dict[ix] == "": return -1 else: i += 1 def _h(self, k, i): return self._h1(k) + i * self._h2(k) def _h1(self, k): return k % self.m1 def _h2(self, k): return k % self.m2 + 1 def to_int(s): _s = s[::] ret = 0 i = 1 for e in _s: if e == 'A': ret += 1 * i elif e == 'C': ret += 2 * i elif e == 'G': ret += 3 * i elif e == 'T': ret += 4 * i i *= 4 return ret if __name__ == '__main__': n = int(input()) d = Dict() for _ in range(n): cmd, val = input().split() if cmd == "insert": d.insert(to_int(val)) else: ans = "yes" if d.find(to_int(val)) != -1 else "no" print(ans)
Traceback (most recent call last): File "/tmp/tmpbd5acxra/tmprkbj_6u5.py", line 62, in <module> n = int(input()) ^^^^^^^ EOFError: EOF when reading a line
s591772085
p02269
u763534154
1463999184
Python
Python3
py
Runtime Error
30
7792
1367
class Dict(object): m1 = 2 ** 9 - 1 m2 = 3 def __init__(self): self._dict = ["" for _ in range(self.m1)] def insert(self, k): i = 0 while True: ix = self._h(k, i) if self._dict[ix] == "": self._dict[ix] = k return else: i += 1 def find(self, k): i = 0 while True: ix = self._h(k, i) if self._dict[ix] == k: return ix elif self._dict[ix] == "": return -1 else: i += 1 def _h(self, k, i): return self._h1(k) + i * self._h2(k) def _h1(self, k): return k % self.m1 def _h2(self, k): return k % self.m2 + 1 def to_int(s): _s = s[::] ret = 0 i = 1 for e in _s: if e == 'A': ret += 1 * i elif e == 'C': ret += 2 * i elif e == 'G': ret += 3 * i elif e == 'T': ret += 4 * i i *= 4 return ret if __name__ == '__main__': n = int(input()) d = Dict() for _ in range(n): cmd, val = input().split() if cmd == "insert": d.insert(to_int(val)) else: ans = "yes" if d.find(to_int(val)) != -1 else "no" print(ans)
Traceback (most recent call last): File "/tmp/tmpls3x8gjb/tmpipvcppv1.py", line 62, in <module> n = int(input()) ^^^^^^^ EOFError: EOF when reading a line
s488468234
p02269
u763534154
1464004914
Python
Python3
py
Runtime Error
0
0
1413
m1 = 1046527 _dict = [""] * m1 def insert(k): i = 0 while True: ix = _h(k, i) if _dict[ix] == "": _dict[ix] = k return else: i += 1 def find(k): i = 0 while True: ix = _h(k, i) if _dict[ix] == k: return True elif _dict[ix] == "": return False else: i += 1 return False def _h(k, i): return ((k % m1) + i * (1 + k % (m1 - 1))) % m1 def getChar(ch): if ch == 'A': return 1 elif ch == 'C': return 2 elif ch == 'G': return 3 elif ch == 'T': return 4 else: return 0 def getKey(strings): Sum = 0 p = 1 for i in xrange(len(strings)): Sum += p * getChar(strings[i]) p *= 5 return Sum def to_int(s): ret = 0 i = 1 for j in range(len(s)): e = s[len(s) - j - 1] if e == 'A': ret += 1 * i elif e == 'C': ret += 2 * i elif e == 'G': ret += 3 * i elif e == 'T': ret += 4 * i i *= 5 return ret if __name__ == '__main__': n = int(input()) for _ in range(n): cmd, val = input().split() if cmd[0] == "i": insert(getKey(val)) else: ans = "yes" if find(getKey(val)) else "no" print(ans)
Traceback (most recent call last): File "/tmp/tmpfhu2djx8/tmptwbmgpxi.py", line 80, in <module> n = int(input()) ^^^^^^^ EOFError: EOF when reading a line
s128002161
p02269
u027872723
1464507451
Python
Python
py
Runtime Error
0
0
214
if __name__ == '__main__': n = int(input()) dic = set() for i in range(n): Cmd, Key = input().split() if Cmd == "insert": dic.add(Key) else: if Key in dic: print("yes") else: print("no")
Traceback (most recent call last): File "/tmp/tmp7zq63isr/tmp37fn84wx.py", line 2, in <module> n = int(input()) ^^^^^^^ EOFError: EOF when reading a line
s160770660
p02269
u918457647
1468918281
Python
Python3
py
Runtime Error
0
0
225
n = int(input()) d = [] if i in range(n): order = input().split() if order[0] == 'insert': d.append(order[1]) else: if order[1] in d: print("yes") else: print("no")
Traceback (most recent call last): File "/tmp/tmpvwyow1gv/tmpqkvowhcj.py", line 1, in <module> n = int(input()) ^^^^^^^ EOFError: EOF when reading a line
s876271555
p02269
u096922415
1469329827
Python
Python3
py
Runtime Error
20
7728
2439
# http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_4_C&lang=jp sample_input = list(range(3)) sample_input[0] = '''6 insert AAA insert AAC find AAA find CCC insert CCC find CCC''' sample_input[1] = '''13 insert AAA insert AAC insert AGA insert AGG insert TTT find AAA find CCC find CCC insert CCC find CCC insert T find TTT find T''' sample_input[2] = '''''' give_sample_input = None if give_sample_input is not None: sample_input_list = sample_input[give_sample_input].split('\n') def input(): return sample_input_list.pop(0) # main def convert_ACGT_to_int(acgt_str): result = 0 for char in acgt_str: result *= 5 if char == 'A': result += 1 elif char == 'C': result += 2 elif char == 'G': result += 3 elif char == 'T': result += 4 else: assert False return result def binary_search(increasing_list, elem): index_min = 0 index_max = len(increasing_list) - 1 while index_max - index_min >= 2: index_middle = int((index_min + index_max) / 2) if increasing_list[index_middle] == elem: return True elif increasing_list[index_middle] > elem: index_max = index_middle else: index_min = index_middle if increasing_list[index_min] == elem: return True elif increasing_list[index_max] == elem: return True else: return False class Dict (object): def __init__(self): self.data = [] pass def insert(self, item): self.data.append(item) for index in range(len(self.data)-1, 0, -1): if self.data[index] < self.data[index-1]: tmp = self.data[index] self.data[index] = self.data[index-1] self.data[index-1] = tmp else: break def find(self, item): return binary_search(self.data, item) dict = Dict() num_of_commands = int(input()) for n in range(num_of_commands): input_str = input() command, data = input_str.split(' ') if command == 'insert': dict.insert(convert_ACGT_to_int(data)) else: if dict.find(convert_ACGT_to_int(data)): print('yes') else: print('no')
Traceback (most recent call last): File "/tmp/tmp5wm9dyhj/tmp6lzl5_h6.py", line 92, in <module> num_of_commands = int(input()) ^^^^^^^ EOFError: EOF when reading a line
s251716563
p02269
u096922415
1469338119
Python
Python3
py
Runtime Error
0
0
3276
# http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_4_C&lang=jp sample_input = list(range(3)) sample_input[0] = '''6 insert AAA insert AAC find AAA find CCC insert CCC find CCC''' sample_input[1] = '''13 insert AAA insert AAC insert AGA insert AGG insert TTT find AAA find CCC find CCC insert CCC find CCC insert T find TTT find T''' sample_input[2] = '''20 find CTT find TAG insert AA insert CTC find G insert TGT find AAC find TTG insert AA insert TTG insert G insert A insert GG insert C insert TT find T insert C find GG find G insert CG''' give_sample_input = None if give_sample_input is not None: sample_input_list = sample_input[give_sample_input].split('\n') def input(): return sample_input_list.pop(0) # main from collections import deque def convert_ACGT_to_int(acgt_str): result = 0 for char in acgt_str: result *= 5 if char == 'A': result += 1 elif char == 'C': result += 2 elif char == 'G': result += 3 elif char == 'T': result += 4 else: assert False return result def binary_search(increasing_list, elem): index_min = 0 index_max = len(increasing_list) - 1 while index_max - index_min >= 2: index_middle = int((index_min + index_max) / 2) if increasing_list[index_middle] == elem: return (True, index_middle + 1) elif increasing_list[index_middle] > elem: index_max = index_middle else: index_min = index_middle if index_max >= index_min: if increasing_list[index_max] == elem: return (True, index_max + 1) elif increasing_list[index_min] == elem: return (True, index_min + 1) elif increasing_list[index_max] < elem: return (False, index_max + 1) elif increasing_list[index_min] > elem: return (False, index_min) elif increasing_list[index_min] < increasing_list[index_max]: return (False, index_max) elif increasing_list[index_min] == increasing_list[index_max]: val = increasing_list[index_min] if elem < val: return (False, index_min) else: return (False, index_max + 1) else: assert False if index_max < index_min: return (False, None) class Dict (object): def __init__(self): self.data = deque() pass def insert(self, item): index = binary_search(list(self.data), item)[1] if index is None: self.data.append(item) else: self.data.insert(index, item) def find(self, item): return binary_search(list(self.data), item)[0] dict = Dict() num_of_commands = int(input()) for n in range(num_of_commands): input_str = input() command, data = input_str.split(' ') if command == 'insert': dict.insert(convert_ACGT_to_int(data)) else: if dict.find(convert_ACGT_to_int(data)): print('yes') else: print('no')
Traceback (most recent call last): File "/tmp/tmpbeiml0k3/tmpi4kwxqhw.py", line 130, in <module> num_of_commands = int(input()) ^^^^^^^ EOFError: EOF when reading a line
s627900876
p02269
u096922415
1469338324
Python
Python3
py
Runtime Error
0
0
3443
# http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_4_C&lang=jp sample_input = list(range(4)) sample_input[0] = '''6 insert AAA insert AAC find AAA find CCC insert CCC find CCC''' sample_input[1] = '''13 insert AAA insert AAC insert AGA insert AGG insert TTT find AAA find CCC find CCC insert CCC find CCC insert T find TTT find T''' sample_input[2] = '''20 find CTT find TAG insert AA insert CTC find G insert TGT find AAC find TTG insert AA insert TTG insert G insert A insert GG insert C insert TT find T insert C find GG find G insert CG''' sample_input[3]='''15 insert AAA insert AAC insert AGA insert AGG insert TTT find AAA find CCC find CCC insert CCC find CCC find CC insert T find TTT find T find A''' give_sample_input = None if give_sample_input is not None: sample_input_list = sample_input[give_sample_input].split('\n') def input(): return sample_input_list.pop(0) # main from collections import deque def convert_ACGT_to_int(acgt_str): result = 0 for char in acgt_str: result *= 5 if char == 'A': result += 1 elif char == 'C': result += 2 elif char == 'G': result += 3 elif char == 'T': result += 4 else: assert False return result def binary_search(increasing_list, elem): index_min = 0 index_max = len(increasing_list) - 1 while index_max - index_min >= 2: index_middle = int((index_min + index_max) / 2) if increasing_list[index_middle] == elem: return (True, index_middle + 1) elif increasing_list[index_middle] > elem: index_max = index_middle else: index_min = index_middle if index_max >= index_min: if increasing_list[index_max] == elem: return (True, index_max + 1) elif increasing_list[index_min] == elem: return (True, index_min + 1) elif increasing_list[index_max] < elem: return (False, index_max + 1) elif increasing_list[index_min] > elem: return (False, index_min) elif increasing_list[index_min] < increasing_list[index_max]: return (False, index_max) elif increasing_list[index_min] == increasing_list[index_max]: val = increasing_list[index_min] if elem < val: return (False, index_min) else: return (False, index_max + 1) else: assert False if index_max < index_min: return (False, None) class Dict (object): def __init__(self): self.data = deque() pass def insert(self, item): index = binary_search(list(self.data), item)[1] if index is None: self.data.append(item) else: self.data.insert(index, item) def find(self, item): return binary_search(list(self.data), item)[0] dict = Dict() num_of_commands = int(input()) for n in range(num_of_commands): input_str = input() command, data = input_str.split(' ') if command == 'insert': dict.insert(convert_ACGT_to_int(data)) else: if dict.find(convert_ACGT_to_int(data)): print('yes') else: print('no')
Traceback (most recent call last): File "/tmp/tmpsfrw1hb2/tmpfh40_y5a.py", line 146, in <module> num_of_commands = int(input()) ^^^^^^^ EOFError: EOF when reading a line
s474912870
p02269
u096922415
1469338626
Python
Python3
py
Runtime Error
0
0
2517
from collections import deque def convert_ACGT_to_int(acgt_str): result = 0 for char in acgt_str: result *= 5 if char == 'A': result += 1 elif char == 'C': result += 2 elif char == 'G': result += 3 elif char == 'T': result += 4 else: assert False return result def binary_search(increasing_list, elem): index_min = 0 index_max = len(increasing_list) - 1 while index_max - index_min >= 2: index_middle = int((index_min + index_max) / 2) if increasing_list[index_middle] == elem: return (True, index_middle + 1) elif increasing_list[index_middle] > elem: index_max = index_middle else: index_min = index_middle if index_max >= index_min: if increasing_list[index_max] == elem: return (True, index_max + 1) elif increasing_list[index_min] == elem: return (True, index_min + 1) elif increasing_list[index_max] < elem: return (False, index_max + 1) elif increasing_list[index_min] > elem: return (False, index_min) elif increasing_list[index_min] < increasing_list[index_max]: return (False, index_max) elif increasing_list[index_min] == increasing_list[index_max]: val = increasing_list[index_min] if elem < val: return (False, index_min) else: return (False, index_max + 1) else: assert False if index_max < index_min: return (False, None) class Dict (object): def __init__(self): self.data = deque() pass def insert(self, item): index = binary_search(list(self.data), item)[1] if index is None: self.data.append(item) else: self.data.insert(index, item) def find(self, item): return binary_search(list(self.data), item)[0] dict = Dict() num_of_commands = int(input()) for n in range(num_of_commands): input_str = input() command, data = input_str.split(' ') if command == 'insert': dict.insert(convert_ACGT_to_int(data)) else: if dict.find(convert_ACGT_to_int(data)): print('yes') else: print('no')
Traceback (most recent call last): File "/tmp/tmpbzrgwl_6/tmpmlj3hjvy.py", line 78, in <module> num_of_commands = int(input()) ^^^^^^^ EOFError: EOF when reading a line