Harryxun/GPT-100-sft-dataset huggingface dataset:
Problem p03436 (python)

Fixed submission:
import collections
import sys
INF = 10**18
h,w = map(int,input().split())
li = [list(input()) for i in range(h)]
sx,sy,gx,gy = 0,0,h-1,w-1

def bfs(sy,sx):
    #頂点をINFで初期化
    d = [[INF]*w for i in range(h)]
    #移動４方向のベクトル
    dx = [1,0,-1,0]
    dy = [0,1,0,-1]
    #スタート地点をキューにいれ、頂点を０にする
    que = collections.deque([])
    que.append((sy,sx))
    d[sy][sx] = 0
    #キューが空になるまでループ（行ける要素がなくなるまで）
    while que:
        # キューの先頭を取り出す
        p = que.popleft()
        # 取り出してきた状態がゴールなら探索をやめる
        # 移動4方向をループ
        for i in range(4):
            nx = p[1] + dx[i]
            ny = p[0] + dy[i]

            #壁との判定とすでに訪れたかどうかをチェック
            if 0<=nx and nx < w and 0 <= ny and ny < h:
                if li[ny][nx] != "#" and d[ny][nx] == INF:
                    #移動できる点なのでキューについか
                    que.append((ny,nx))
                    #前の点+1で移動できる
                    d[ny][nx] = d[p[0]][p[1]] + 1
    return d[-1][-1]
a = bfs(0,0)-1
if a + 1 == INF:
    print(-1)
    sys.exit()
maxgrid = h*w
cnt = 0
for i in range(h):
    for j in range(w):
        if li[i][j] == "#":
            cnt+=1
ans = maxgrid - cnt - a -2
print(ans)

Buggy submission (verdict: Runtime Error):
import collections
INF = 10**18
h,w = map(int,input().split())
li = [list(input()) for i in range(h)]
sx,sy,gx,gy = 0,0,h-1,w-1

def bfs(sy,sx):
    #頂点をINFで初期化
    d = [[INF]*w for i in range(h)]
    #移動４方向のベクトル
    dx = [1,0,-1,0]
    dy = [0,1,0,-1]
    #スタート地点をキューにいれ、頂点を０にする
    que = collections.deque([])
    que.append((sy,sx))
    d[sy][sx] = 0
    #キューが空になるまでループ（行ける要素がなくなるまで）
    while que:
        # キューの先頭を取り出す
        p = que.popleft()
        # 取り出してきた状態がゴールなら探索をやめる
        # 移動4方向をループ
        for i in range(4):
            nx = p[1] + dx[i]
            ny = p[0] + dy[i]

            #壁との判定とすでに訪れたかどうかをチェック
            if 0<=nx and nx < w and 0 <= ny and ny < h:
                if li[ny][nx] != "#" and d[ny][nx] == INF:
                    #移動できる点なのでキューについか
                    que.append((ny,nx))
                    #前の点+1で移動できる
                    d[ny][nx] = d[p[0]][p[1]] + 1
    return d[-1][-1]
a = bfs(0,0)-1
if a + 1 == INF:
    print(-1)
    sys.exit()
maxgrid = h*w
cnt = 0
for i in range(h):
    for j in range(w):
        if li[i][j] == "#":
            cnt+=1
ans = maxgrid - cnt - a -2
print(ans)
Problem p03611 (python)

Fixed submission:
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections

n = int(input())
a = sorted(list(map(int,input().split())))
c = collections.Counter(a)
item = []
for key,Value in c.items():
    item.append([key,Value])
koho = []
if len(item) == 1:
    print(item[0][1])
    sys.exit()
if item[1][0] - item[0][0] == 1:
    cnt = item[1][1] + item[0][1]
else:
    cnt = item[0][1]
koho.append(cnt)
cnt = 0
for i in range(1,len(item)-1):
    cnt = 0
    if item[i][0] - item[i-1][0] == 1:
        cnt += item[i-1][1] + item[i][1]
    if item[i+1][0] - item[i][0] == 1:
        cnt += item[i+1][1]
    koho.append(cnt)
cnt = 0
if item[-1][0] - item[-2][0] == 1:
    cnt += item[-1][1] + item[-2][1]
else:
    cnt += item[-1][1]
koho.append(cnt)
print(max(koho))

Buggy submission (verdict: Runtime Error):
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections

n = int(input())
a = sorted(list(map(int,input().split())))
c = collections.Counter(a)
if n == 1:
    print(1)
    sys.exit()
item = []
for key,Value in c.items():
    item.append([key,Value])
koho = []
if item[1][0] - item[0][0] == 1:
    cnt = item[1][1] + item[0][1]
else:
    cnt = item[0][1]
koho.append(cnt)
cnt = 0
for i in range(1,n-2):
    cnt = 0
    if item[i][0] - item[i-1][0] == 1:
        cnt += item[i-1][1] + item[i][1]
    if item[i+1][0] - item[i][0] == 1:
        cnt += item[i+1][1]
    koho.append(cnt)
cnt = 0
if item[-1][0] - item[-2][0] == 1:
    cnt += item[-1][1] + item[-2][1]
else:
    cnt += item[-1][1]
koho.append(cnt)
print(max(koho))
Problem p03760 (python)

Fixed submission:
import collections
import sys
import numpy as np
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
MOD = 10**9+7
import itertools
import math

o = input()
e = input()
ans = ""
for i in range(len(e)):
    ans += o[i] + e[i]
if len(o)>len(e):
    ans += o[-1]
print(ans)

Buggy submission (verdict: Runtime Error):
import collections
import sys
import numpy as np
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
MOD = 10**9+7
import itertools
import math

o = input()
e = input()
ans = ""
for i in range(len(o)):
    ans += o[i]+e[i]
print(ans)

Buggy submission (verdict: Runtime Error):
import collections
import sys
import numpy as np
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
MOD = 10**9+7
import itertools
import math

o = input()
e = input()
ans = ""
for i in range(len(o) + len(e)):
    if i%2 == 0:
        ans += o[i]
    else:
        ans += e[i]
print(ans)
Problem p03826 (python)

Fixed submission:
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
MOD = 10**9 + 7

a,b,c,d = map(int,input().split())
print(max(a*b,c*d))

Buggy submission (verdict: Runtime Error):
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
MOD = 10**9 + 7

a,b,c.d = map(int,input().split())
print(max(a*b,c*d))
Problem p03846 (python)

Fixed submission:
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
MOD = 10**9+7
n = int(input())
a = list(map(int,input().split()))

if n%2 == 0:
    c = collections.Counter(a)
    item = []
    for key,value in c.items():
        item.append([key,value])
    item.sort()
    ans = 1
    for i in range(len(item)):
        if 2*i + 1 == item[i][0]:
            if item[i][1] == 2:
                ans *= 2
                ans %=MOD
            else:
                print(0)
                sys.exit()
        else:
            print(0)
            sys.exit()
    print(ans%MOD)
else:
    c = collections.Counter(a)
    ans = 1
    item = []
    for key,value in c.items():
        item.append([key,value])
    item.sort()
    for i in range(1,len(item)):
        if 2*i == item[i][0]:
            if item[i][1] == 2:
                ans *= 2
                ans %=MOD
            else:
                print(0)
                sys.exit()
        else:
            print(0)
            sys.exit()
    if item[0][0] == 0 and item[0][1] == 1:
        print(ans%MOD)
    else:
        print(0)

Buggy submission (verdict: Runtime Error):
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections

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

if n%2 == 0:
    c = collections.Counter(a)
    item = []
    for key,value in c.items():
        item.append([key,value])
    item.sort()
    ans = 1
    for i in range(len(item)):
        if 2*i + 1 == item[i][0]:
            if item[i][1] == 2:
                ans *= 2
                ans %=MOD
            else:
                print(0)
                sys.exit()
        else:
            print(0)
            sys.exit()
    print(ans%MOD)
else:
    c = collections.Counter(a)
    ans = 1
    item = []
    for key,value in c.items():
        item.append([key,value])
    item.sort()
    for i in range(1,len(item)):
        if 2*i == item[i][0]:
            if item[i][1] == 2:
                ans *= 2
                ans %=MOD
            else:
                print(0)
                sys.exit()
        else:
            print(0)
            sys.exit()
    if item[0][0] == 0 and item[0][1] == 1:
        print(ans%MOD)
    else:
        print(0)
Problem p04030 (python)

Fixed submission:
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
MOD = 10**9+7

s = input()
q = []
for i in range(len(s)):
    if s[i] == "0":
        q.append(0)
    elif s[i] == "1":
        q.append(1)
    elif s[i] == "B" and len(q)!=0:
        q.pop()
ans = ""
for i in range(len(q)):
    ans += str(q[i])
print(ans)

Buggy submission (verdict: Runtime Error):
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
MOD = 10**9+7

s = input()
q = [""]
for i in range(len(s)):
    if s[i] == "0":
        q.append(0)
    elif s[i] == "1":
        q.append(1)
    else:
        q.pop()
ans = ""
for i in range(len(q)):
    ans += str(q[i])
print(ans)

Buggy submission (verdict: Runtime Error):
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
MOD = 10**9+7

s = input()
q = []
for i in range(len(s)):
    if s[i] == "0":
        q.append(0)
    elif s[i] == "1":
        q.append(1)
    else:
        q.pop()
ans = ""
for i in range(len(q)):
    ans += str(q[i])
print(ans)
Problem p04045 (python)

Fixed submission:
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
MOD = 10**9+7
MAX = 10**18
MIN = -10**18

n,k= map(int,input().split())
d = list(map(int,input().split()))
able = [True]*10
for i in range(k):
    able[d[i]] = False
use = []
for i in range(len(able)):
    if able[i] == True:
        use.append(i)
flag = False
while True:
    s = str(n)
    for i in range(len(s)):
        c = int(s[i])
        if c in use:
            flag = True
        else:
            flag = False
            break
    if flag:
        print(n)
        sys.exit()
    n += 1

Buggy submission (verdict: Runtime Error):
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
MOD = 10**9+7
MAX = 10**18
MIN = -10**18

n,k= map(int,input().split())
d = list(map(int,input().split()))
able = [True]*10
for i in range(k):
    able[d[i]] = False
use = []
for i in range(len(able)):
    if able[i] == True:
        use.append(i)
while True:
    ans = ""
    s = str(n)
    for i in range(len(s)):
        c = int(s[i])
        for j in range(len(use)):
            if c<=use[j]:
                ans += str(use[j])
                break
    if int(ans)>=n:
        break
    else:
        n += 1
print(ans)
Problem p02628 (python)

Fixed submission:
N, K = [int(v) for v in input().split()]
P = [int(v) for v in input().split()]

print(sum(sorted(P)[:K]))

Buggy submission (verdict: Runtime Error):
N, K = int(input()), int(input())
P = [int(v) for v in input().split()]

print(sum(sorted(P)[:K]))
Problem p02657 (python)

Fixed submission:
A, B = [int(v) for v in input().split()]
print(A * B)

Buggy submission (verdict: Runtime Error):
print(int(input()) * int(input()))
Problem p02783 (python)

Fixed submission:
ri = lambda S: [int(v) for v in S.split()]
def rii(): return ri(input())

H, A = rii()

print((H + A - 1) // A)

Buggy submission (verdict: Runtime Error):
ri = lambda S: [int(v) for v in S.split()]
def rii(): return ri(input())

H, A = rii()

print((H // A)
Problem p02641 (python)

Fixed submission:
X, N = list(map(int, input().split()))
p = list(map(int, input().split()))

i = 0
while True:
    if X - i not in (p):
        print(X-i)
        exit()
    if X + i not in (p):
        print(X+i)
        exit()
    i += 1

Buggy submission (verdict: Runtime Error):
X,N=map(int,input().split())
if N==0:
  print(X)
  exit()
p=sorted(map(int,input().split()))
p = [i for i in range(min(p),max(p)+1) if i not in p]
if X in p:
  print(X)
else:
  p = list(set(p))
  p.append(X)
  p.sort()
  index_num = p.index(X)
  if 0 < index_num < len(p)-2:
    num1=index_num+1
    num2=index_num-1
    num1_abs=abs(p[index_num]-p[num1])
    num2_abs=abs(p[inedx_num]-p[num2])
    if num1_abs < num2_abs:
      print(p[num1])
    else:
      print(p[num2])
  elif index_num==0:
    num1=index_num+1
    print(p[num1])
  elif index_num == len(p)-1:
    num2=index_num-1
    print(p[num2])
Problem p02885 (python)

Fixed submission:
A, B = map(int, input().split())
print(0 if A - (B*2) < 0 else A - (B*2))

Buggy submission (verdict: Runtime Error):
A, B = map(int, input().split())
print(0 if A - (B*2) < 0 else A - (B*2))A
Problem p02924 (python)

Fixed submission:
n=int(input());print(n*(n-1)//2)

Buggy submission (verdict: Runtime Error):
n=int(input())
N=[0]*(n+1)
result=0
for i in range(1,n+1):
  N[i]=i
for i in range(2,len(N)):
  result+=N[i-1]%N[i]
print(result)

Buggy submission (verdict: Runtime Error):
n1=[*range(1,int(input())+1)]
n2=n1[1:]+[n1[0]]
count=0
for i in range(len(n1)):
  count+=n1[i]%n2[i]
print(count)
Problem p03125 (python)

Fixed submission:
A, B = map(int, input().split())
print(A+B if B%A==0 else B-A)

Buggy submission (verdict: Runtime Error):
def check(A):
  check_result = []
  for i in range(1, len(A)):
    check_result.append(list(set(A[i-1])&set(A[i])))
  if len(check_result) != len(A):
    return check_result
  return False

N, M = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(N)]
for i in range(len(A)):
  A[i].pop(0)
while True:
  check_result = check(A)
  if check_result:
    A = check_result
  else:
    if not A[0]:
      print(0)
      break
    else:
      print(len(A[0]))
      break
Problem p03261 (python)

Fixed submission:
import sys
N = int(input())
W = [input() for _ in range(N)]
if len(set(W)) == len(W):
  for i in range(1, len(W)):
    if W[i-1][-1] != W[i][0]:
      print('No')
      sys.exit()
else:
  print('No')
  sys.exit()
print('Yes')

Buggy submission (verdict: Runtime Error):
n=[input() for _ in range(int(input()))];if len(set(n))!=len(n): print('No');exit()
print('NYoe s'[all([1 if n[i-1][-1]==n[i][0] else 0 for i in range(1,len(n))])::2])
Problem p03353 (python)

Fixed submission:
s=input()
k=int(input())
n=len(s)
r=[]
for right in range(0,n):
  for left in range(right+1, right+k+1):
    r.append(s[right:left])
print(sorted(set(r))[k-1])

Buggy submission (verdict: Runtime Error):
S = input()
K = int(input())
result = []
result.append(S)
for i in range(len(S)):
  for j in range(i+1, len(S)):
    result.append(S[i:j])
result = list(set(result))
result.sort()
print(result[K-1])
Problem p03386 (python)

Fixed submission:
A,B,K = map(int, input().split())
[print(i) for i in sorted(list(set([i for i in range(A,A+K)] + [i for i in reversed(range(B-K+1, B+1))]))) if A <= i <= B]

Buggy submission (verdict: Runtime Error):
a,b,k=map(int,input().split());n=[*range(a,b+1)]
try:
  n=sorted(set(n[:k]+n[-k:]));print(*n,sep='\n')
except:
  print(*n,sep='\n')

Buggy submission (verdict: Runtime Error):
a,b,k=map(int,input().split());
try:
  n=[*range(a,b+1)]
  n=sorted(set(n[:k]+n[-k:]));print(*n,sep='\n')
except:
  print(*n,sep='\n')

Buggy submission (verdict: Runtime Error):
a,b,k=map(int,input().split());n=[*range(a,b+1)]
n=sorted(set(n[:k]+n[-k:]));print(*n,sep='\n')
Problem p03605 (python)

Fixed submission:
print(['No','Yes']['9' in input()])

Buggy submission (verdict: Runtime Error):
print(['No','Yes'][input().count('9')])
Problem p03624 (python)

Fixed submission:
import string
word=sorted(set((input()))^set(string.ascii_lowercase))
print(word and word[0] or 'None')

Buggy submission (verdict: Runtime Error):
import string
S=sorted(set((input())))
count = 0
for i in string.ascii_lowercase:
  if i!=S[count]:
    print(i)
    break
  count += 1
else:
  print('None')
Problem p03730 (python)

Fixed submission:
a,b,c=map(int,input().split())
for i in range(a,b*a+1,a):
  if i%b==c: print('YES');break
else:
  print('NO')

Buggy submission (verdict: Runtime Error):
a,b,c=map(int,input().split())
num = a
if (a % 2 == 1 and c % 2 == 0) or (a % 2 == 0 and c % 2 == 1):
  print('NO')
else:
  pritn('YES')
Problem p03759 (python)

Fixed submission:
a,b,c=map(int,input().split());print(['NO','YES'][b-a==c-b])

Buggy submission (verdict: Runtime Error):
a,b,c=map(int,input().split());print(['NO','YES'][b-a==c-b])A
Problem p03761 (python)

Fixed submission:
import collections as c
n=[c.Counter(input()) for _ in range(int(input()))];r=n[0]
for i in range(1,len(n)): r=r&n[i]
print(*sorted([i*j for i,j in r.items()]),sep='')

Buggy submission (verdict: Runtime Error):
n=int(input())
word=[sorted(input()) for _ in range(n)]
result=[]
word_result=[]
for i in range(len(word)-1):
  result.append(set(word[i])&set(word[i+1]))
if min(result):
  for i in min(result):
    word_result.append(i*word[0].count(i))
else:
  print('')
  exit()
print(''.join(sorted(word_result)))

Buggy submission (verdict: Runtime Error):
n=int(input())
word=[sorted(input()) for _ in range(n)]
result=[]
word_result=[]
for i in range(len(word)-1):
  result.append(set(word[i])&set(word[i+1]))
if min(result):
  for i in min(result):
    word_result.append(i*word[0].count(i))
print(''.join(sorted(word_result)))
Problem p04030 (python)

Fixed submission:
s=input()
result = []
for i in s:
  if i=='0':
    result.append('0')
  elif i=='1':
    result.append('1')
  elif i=='B':
    if not result:
      continue
    result.pop()
print(''.join(result))

Buggy submission (verdict: Runtime Error):
s=input()
b=False
result = []
for i in s:
  if i=='B':
    if not b:
      result.pop()
      b=True
  else:
    b=False
    result.append(i)
print(''.join(result))
Problem p02642 (python)

Fixed submission:
n = int(input())
dat = list(map(int, input().split()))

import collections
buf = collections.Counter(dat)
dat = []
dat = list(buf.keys())

dat.sort()

res = 0

used = [False] * (1000100)

for i in range(len(dat)):
    ok = True

    if used[dat[i]]:
        ok = False
    if buf[dat[i]] != 1:
        ok = False

    c = 0
    v = -1
    while True:
        c += 1
        v = dat[i] * c
        if v > 1000010:
            break
        used[v] = True

    used[dat[i]] = True

    if ok:
        res += 1
#print(used[:10])
print(res)

Buggy submission (verdict: Runtime Error):
n = int(input())
dat = list(map(int, input().split()))
res = 0
import collections
buf = collections.Counter(dat)
dat = []
for k in buf:
    if buf[k] == 1:
        dat.append(k)
dat.sort()
#print(dat)
res = 0
used = [False] * (1000100)

for i in range(len(dat)):
    ok = True

    if used[dat[i]]:
        ok = False
    c = 0
    v = -1
    while v <= 1000010:
        c += 1
        v = dat[i] * c
        used[v] = True


    used[dat[i]] = True
    if ok:
        res += 1
print(res)
Problem p02719 (python)

Fixed submission:
n, k = map(int, input().split())
if n == 0 or n == k:
    print(0)
else:
    a = abs(n % k)
    b = abs(a - k)
    print(min(a, b))

Buggy submission (verdict: Runtime Error):
n, k = map(int, input().split())
if n == 0:
    print(0)
else:
    x = abs(n - k)
    a = n % x
    b = abs(a - k)
    print(min(a, b))

Buggy submission (verdict: Runtime Error):
n, k = map(int, input().split())
x = abs(n - k)
a = n % x
b = abs(a - k)
print(min(a, b))
Problem p02801 (python)

Fixed submission:
c = input()
print(chr(ord(c[0]) + 1))

Buggy submission (verdict: Runtime Error):
from collections import deque

def solve(S, s):
    if S[s[0]][s[1]] != ".":
        return -1
    queue = deque([s])
    visited = [[-1 for _ in range(W)] for _ in range(H)]
    visited[s[0]][s[1]] = 0
    while queue:
        y, x = queue.popleft()
        for j, k in ([1, 0], [-1, 0], [0, 1], [0, -1]):
            new_y, new_x = y + j, x + k
            if new_x in range(W) and new_y in range(H) and S[new_y][new_x] == "." and visited[new_y][new_x] == -1:
                visited[new_y][new_x] = visited[y][x] + 1
                queue.append([new_y, new_x])
    #    for v in visited:
    #        print(v)
    return max(max(visited))

H, W = map(int, input().split())
S = [input() for _ in range(H)]
ans = -1
for i in range(W):
    for l in range(H):
        ans = max(ans, solve(S, [i, l]))
print(ans)
Problem p02802 (python)

Fixed submission:
n, m = map(int, input().split())
is_ac = [False] * 200050
count_wa = [0] * 100050
numok = 0
numwa = 0
for i in range(m):
    p, s = input().split()
    p = int(p)
    if is_ac[p]: # すでに正解
        continue
    else: # 未正解
        if s == "AC":
            numok += 1
            is_ac[p] = True
        else:
            count_wa[p] += 1
for i in range(100040):
    if is_ac[i]:
        numwa += count_wa[i]
print("{0} {1}".format(numok, numwa))

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
is_ac = [False] * 10050
numok = 0
numwa = 0
for i in range(m):
    p, s = input().split()
    p = int(p)
    if is_ac[p]: # すでに正解
        continue
    else: # 未正解
        if s == "AC":
            numok += 1
            is_ac[p] = True
        else:
            numwa += 1
print("{0} {1}".format(numok, numwa))
Problem p02939 (python)

Fixed submission:
s = input()
p = ""
c = ""
res = 0
for i in range(len(s)):
    c += s[i]
    if p != c:
        p = c
        c = ""
        res += 1
print(res)

Buggy submission (verdict: Runtime Error):
import math
n = int(input())
a = math.ceil(n/9)
b = n % 9 #
print(str(b) * a)
Problem p02953 (python)

Fixed submission:
n = int(input())
dat = list(map(int, input().split()))
cur = dat[0]
can = True
for i in range(1, n):
    if dat[i] > cur:
        cur = dat[i] - 1
        continue
    if dat[i] == cur:
        continue
    can = False
print("Yes" if can else "No")

Buggy submission (verdict: Runtime Error):
    n = int(input())
    dat = list(map(int, input().split()))
    cur = dat[0]
    can = True
    for i in range(1, n):
        if dat[i] > cur:
            cur = dat[i] - 1
            continue
        if dat[i] == cur:
            continue
        can = False
    print("Yes" if can else "No")
Problem p02973 (python)

Fixed submission:
def bisect_right(a, x, lo=0, hi=None):
    if lo < 0:
        raise ValueError('lo must be non-negative')
    if hi is None:
        hi = len(a)
    while lo < hi:
        mid = (lo + hi) // 2
        if x > a[mid]:
            hi = mid
        else:
            lo = mid + 1
    return lo

import collections
n = int(input())
dat = []
for i in range(n):
    dat.append(int(input()))
res = collections.deque([])

res.append(dat[0])
import bisect

for i in range(1, n):
    a = bisect_right(res, dat[i])
    #print("2 : {0}".format(a))

    if a == len(res):
        res.append(dat[i])
    else:
        res[a] = dat[i]
print(len(res))
#print(res)

Buggy submission (verdict: Runtime Error):
n = int(input())
dat = []
for i in range(n):
    dat.append(int(input()))
res = []
res.append(0 - dat[0])

import bisect

for i in range(1, n):
    print(res)
    a = bisect.bisect_right(res, 0 - dat[i])
    print("a={0}".format(a))

    if a == len(res):
        res.append( (0 - dat[i]) )
    else:
        res[a] = (0 - dat[i])

print(len(res))

Buggy submission (verdict: Runtime Error):
import collections
n = int(input())
dat = []
for i in range(n):
    dat.append(int(input()))
mi = 10000000000000
res = collections.deque([])
res.append(dat[0])
import bisect
for i in range(1, n):
    a = bisect.bisect_left(res, dat[i])
    if a == 0:
        bisect.insort_left(res, dat[i])
    else:
        res[a-1] = dat[i]
print(len(res))

Buggy submission (verdict: Runtime Error):
import collections
n = int(input())
dat = []
for i in range(n):
    dat.append(int(input()))
mi = 10000000000000
res = collections.deque([])
res.append(dat[0])
import bisect
for i in range(1, n):
    a = bisect.bisect_left(res, dat[i])
    if a == 0:
        bisect.insort_left(res, dat[i])
    else:
        res[a-1] = dat[i]
print(len(res))