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

Fixed submission:
n = int(input())
L = list(map(int,input().split()))
S = []
K = []
for i in range(n):
  S.append([L[i],i+1])
S.sort()
for i in range(n):
  K.append(S[i][1])
print(' '.join(map(str,K)))

Buggy submission (verdict: Runtime Error):
n = int(input())
L = list(map(int,input().split()))
S = []
for i in range(n):
  S.append([L[i],i+1])
S.sort()
for i in range(n):
  print(' '.join(S[i][1]))
Problem p02921 (python)

Fixed submission:
S = input()
T = input()
ans = 0
for i in range(3):
  if S[i] == T[i]:
    ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
dp = [0]*n
cnt = 0
L = []
flag = True
for i in range(n):
  T = []
  N = list(map(int,input().split()))
  for j in range(n-1):
    T.append((i+1,N[j]))
  L.append(T)
while dp != [n-1]*n:
  B = [0]*n
  act = 0
  for i in range(n):
    if B[i] == 0:
      B[i] = 1
      if dp[i] != n-1:
        miru = L[i][dp[i]][1]
        if dp[miru-1] == n-1:
          flag = False
          break
        else:
          if B[miru-1] != 1:
            if L[miru-1][dp[miru-1]][1] == i+1:
              dp[i] += 1
              dp[miru-1] += 1
              B[miru-1] = 1
              act += 1
  if act == 0:
    dp = [n-1]*n
    flag = False
  if cnt >= 100000:
      dp = [n-1]*n
  cnt += 1
if flag == False:
  print(-1)
else:
  print(cnt)
Problem p02937 (python)

Fixed submission:
import bisect
s = input()
t = input()
sub = s+s
dp = []
for i in range(len(s)):
    d = [10**15]*26
    dp.append(d)
index = [[] for i in range(26)]
for i in range(len(sub)):
    index[ord(sub[i])-97].append(i)
for i in range(len(s)):
    cur = s[i]
    for j in range(26):
        if len(index[j]) != 0:
            k = bisect.bisect_right(index[j], i)
            dp[i][j] = index[j][k]-i
if s[0] == t[0]:
    ans = 1
else:
    ans = dp[0][ord(t[0])-97]+1
if dp[0][ord(t[0])-97] != 10**15 and dp[0][ord(t[0])-97] >= len(s):
    next = dp[0][ord(t[0])-97]-len(s)
else:
    next = dp[0][ord(t[0])-97]
if next == 10**15:
    print(-1)
    exit()
else:
    flag = True
for i in range(1,len(t)):
    cur = next
    if dp[cur][ord(t[i])-97] == 10**15:
        flag = False
        break
    else:
        ans += dp[cur][ord(t[i])-97]
        if cur + dp[cur][ord(t[i])-97] >= len(s):
            next = cur + dp[cur][ord(t[i])-97] - len(s)
        else:
            next = cur + dp[cur][ord(t[i])-97]
if flag:
    print(ans)
else:
    print(-1)

Buggy submission (verdict: Runtime Error):
import bisect
s = input()
t = input()
sub = s+s
dp = []
for i in range(len(s)):
    d = [10**15]*26
    dp.append(d)
index = [[] for i in range(26)]
for i in range(len(sub)):
    index[ord(sub[i])-97].append(i)
for i in range(len(s)):
    cur = s[i]
    for j in range(26):
        if len(index[j]) != 0:
            k = bisect.bisect_left(index[j], i)
            dp[i][j] = index[j][k]-i
ans = dp[0][ord(t[0])-97]+1
next = dp[0][ord(t[0])-97]
flag = True
for i in range(1,len(t)):
    cur = next
    if dp[cur][ord(t[i])-97] == 10**15:
        flag = False
        break
    else:
        ans += dp[cur][ord(t[i])-97]
        if cur + dp[cur][ord(t[i])-97] >= len(s):
            next = cur + dp[cur][ord(t[i])-97] - len(s)
        else:
            next = cur + dp[cur][ord(t[i])-97]
if flag:
    print(ans)
else:
    print(-1)
Problem p02997 (python)

Fixed submission:
n,k = map(int,input().split())
if k > (n-1)*(n-2)/2:
    print(-1)
else:
    ans = []
    for i in range(1,n):
        ans.append([1,i+1])
    L = []
    for i in range(2,n+1):
        for j in range(i+1, n+1):
            L.append([i,j])
    for i in range((n-1)*(n-2)//2-k):
        ans.append(L[i])
    print(len(ans))
    for i in range(len(ans)):
        print(ans[i][0], ans[i][1])

Buggy submission (verdict: Runtime Error):
import collections
n,k = map(int,input().split())
if k > n+1 and k != (n-1)*(n-2)//2:
    print(-1)
elif k == 0:
    if n == 2:
        print(1,2)
    else:
        print(-1)  
else:
    if k == (n-1)*(n-2)//2:
        print(n-1)
        for i in range(2,n+1):
            print(1,i)
    else:
        L = collections.deque()
        for i in range(3,n):
            L.append([1,i])
        for i in range(2,n-1):
            for j in range(i+2,n+1):
                L.append([i,j])
        for i in range(k):
            L.popleft()
        if k != n+1:
            print(len(L)+n)
            for i in range(len(L)):
                print(L[i][0],L[i][1])
            for i in range(n-1):
                print(i+1,i+2)
            for i in range(1):
                print(n,1)
Problem p03032 (python)

Fixed submission:
n,k = map(int,input().split())
V = list(map(int,input().split()))
ans = 0
T = []
for i in range(k+1):
    if i <= n:
        for a in range(i+1):
            L = V[0:a]+V[n-i+a:n]
            L.sort()
            cur = sum(L)
            for b in range(k-i):
                if b < len(L):
                    if L[b] < 0:
                        cur -= L[b]
            if cur > ans:
                ans = cur
    else:
        L = V
        L.sort()
        cur = sum(L)
        for b in range(k-i):
            if b < len(L):
                if L[b] < 0:
                    cur -= L[b]
        if cur > ans:
            ans = cur
print(ans)

Buggy submission (verdict: Runtime Error):
n,k = map(int,input().split())
V = list(map(int,input().split()))
ans = 0
T = []
for i in range(k+1):
    if i <= n:
        for a in range(i+1):
            L = V[0:a]+V[n-i+a:n]
            L.sort()
            cur = sum(L)
            for b in range(k-i):
                if b < len(L):
                    if L[b] < 0:
                        cur -= L[b]
            if cur > ans:
                ans = cur
    else:
        L = V
        L.sort()
        cur = sum(L)
        for b in range(k-n):
            if L[b] < 0:
                cur -= L[b]
        if cur > ans:
            ans = cur
print(ans)
Problem p03089 (python)

Fixed submission:
N = int(input())
B = list(map(int,input().split()))
TF = [False]*N
L = []
s = 0
lenstr = N-1
for i in range(N):
  cnt = 0
  tr = 0
  for j in range(N-1,-1,-1):
    if TF[j] == False:
      if lenstr-cnt-tr+i <= N-1:
        if B[lenstr-cnt-tr+i] == lenstr-cnt+1:
          TF[lenstr-cnt-tr+i] = True
          L.append(lenstr-cnt+1)
          lenstr -= 1
          break
        else:
          cnt += 1
      else:
          print(-1)
          exit()
    else:
      tr += 1
if len(L) == N:
  for i in range(N):
    print(L[N-i-1])
else:
  print(-1)

Buggy submission (verdict: Runtime Error):
N = int(input())
B = list(map(int,input().split()))
TF = [False]*N
L = []
s = 0
lenstr = N-1
for i in range(N):
  cnt = 0
  tr = 0
  for j in range(N-1,-1,-1):
    if TF[j] == False:
      if B[lenstr-cnt-tr+i] == lenstr-cnt+1:
        TF[lenstr-cnt-tr+i] = True
        L.append(lenstr-cnt+1)
        lenstr -= 1
        break
      else:
        cnt += 1
    else:
      tr += 1
if len(L) == N:
  for i in range(N):
    print(L[N-i-1])
else:
  print(-1)
Problem p03112 (python)

Fixed submission:
import bisect
A,B,Q = map(int,input().split())
a = []
b = []
x = []
for i in range(A):
  a.append(int(input()))
for j in range(B):
  b.append(int(input()))
for k in range(Q):
  x.append(int(input()))
a.insert(0,-(10**15))
a.append(10**15)
b.insert(0,-(10**15))
b.append(10**15)
for k in range(Q):  
  p = bisect.bisect_left(a,x[k])
  q = bisect.bisect_left(b,x[k])
  teraleft_right = [a[p-1],a[p]]
  jinjyaleft_right = [b[q-1],b[q]]
  minlist = []
  for i in range(2):
    for j in range(2):
      minlist.append(abs(x[k]-teraleft_right[i])+abs(teraleft_right[i]-jinjyaleft_right[j]))
      minlist.append(abs(x[k]-jinjyaleft_right[i])+abs(jinjyaleft_right[i]-teraleft_right[j]))
  minlist.sort() 
  print(minlist[0])

Buggy submission (verdict: Runtime Error):
import bisect
import math
A,B,Q = map(int,input().split())
a = []
b = []
x = []
for i in range(A):
  a.append(int(input()))
for j in range(B):
  b.append(int(input()))
for k in range(Q):
  x.append(int(input()))
a.insert(0,-(10**15))
a.append(10**15)
b.insert(0,-(10**15))
b.append(10**15)
for k in range(Q):  
  terafirst = 0
  jinjyafirst = 0
  p = bisect.bisect_left(a,x[k])
  q = bisect.bisect_left(b,x[k])
  terafirst = min(abs(x[k]-a[p-1]),abs(x[k]-a[p]))
  if abs(x[k]-a[p-1])<abs(x[k]-a[p]):
    r = bisect.bisect_left(b,a[p-1])
    terafirst += min(abs(b[r-1]-a[p-1]),abs(b[r]-a[p-1]))
  else:
    s = bisect.bisect_left(b,a[p])
    terafirst += min(abs(b[s-1]-a[p]),abs(b[s]-a[p]))
      
  jinjyafirst = min(abs(x[k]-b[q-1]),abs(x[k]-b[q]))
  if abs(x[k]-b[q-1])<abs(x[k]-b[q]):
    t = bisect.bisect_left(a,b[p-1])
    jinjyafirst += min(abs(a[t-1]-b[q-1]),abs(a[t]-b[q-1]))
  else:
    u = bisect.bisect_left(a,b[q])
    jinjyafirst += min(abs(a[u-1]-b[q]),abs(a[u]-b[q]))
  print(min(terafirst,jinjyafirst))
Problem p03128 (python)

Fixed submission:
n,m = map(int,input().split())
A = list(map(int,input().split()))
L = [2,5,5,4,5,6,3,7,6]
dp = [-float('inf')]*(n+1)
dp[0] = 0
for i in range(1,n+1):
    for j in range(m):
        if i-L[A[j]-1] < 0:
            None
        else:
            dp[i] = max(dp[i-L[A[j]-1]]+1, dp[i])
A.sort()
A.reverse()
cur = n
ans = ''
while cur != 0:
    for i in range(m):
        temp = A[i]
        if cur-L[temp-1] >= 0:
            if dp[cur-L[temp-1]] == dp[cur]-1:
                ans = ans+str(temp)
                cur -= L[temp-1]
                break
print(ans)

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
A = list(map(int,input().split()))
L = [2,5,5,4,5,6,3,7,6]
dp = [-float('inf')]*(n+1)
dp[0] = 0
for i in range(1,n+1):
    for j in range(m):
        if i-L[A[j]-1] < 0:
            None
        else:
            dp[i] = max(dp[i-L[A[j]-1]]+1, dp[i])
A.sort()
A.reverse()
cur = n
ans = ''
while cur != 0:
    for i in range(m):
        temp = A[i]
        if dp[cur-L[temp-1]] == dp[cur]-1:
            ans = ans+str(temp)
            cur -= L[temp-1]
            break
print(ans)

Buggy submission (verdict: Runtime Error):
N,M = map(int,input().split())
A = list(map(int,input().split()))
A.sort()
A.reverse()
match = [2,5,5,4,5,6,3,7,6]
dp = [0]*(N+1)
for i in range(N+1):
  kouho = 0
  for j in range(M):
    if i-match[A[j]-1] >= 0:
      if kouho < dp[i-match[A[j]-1]]+1:
        kouho = dp[i-match[A[j]-1]]+1
  dp[i] = kouho
ans = ''
while N > 0:
  for i in range(M):
    if dp[N-match[A[i]-1]] == dp[N]-1:
      if dp[N]-1 != 0:
        ans += str(A[i])
        N -= match[A[i]-1]
        break
      else:
        for k in range(M):
          if match[A[k]-1] == N:
            ans += str(A[k])
            N = 0
            break
print(ans)

Buggy submission (verdict: Runtime Error):
N,M = map(int,input().split())
A = list(map(int,input().split()))
A.sort()
A.reverse()
match = [2,5,5,4,5,6,3,7,6]
dp = [0]*(N+1)
for i in range(N+1):
  kouho = 0
  for j in range(M):
    if i-match[A[j]-1] >= 0:
      if kouho < dp[i-match[A[j]-1]]+1:
        kouho = dp[i-match[A[j]-1]]+1
  dp[i] = kouho
ans = ''
while N > 0:
  for i in range(M):
    if dp[N-match[A[i]-1]] == dp[N]-1:
      if dp[N]-1 != 0:
        ans += str(A[i])
        N -= match[A[i]-1]
        break
      else:
        for k in range(M):
          if match[A[k]-1] == N:
            ans += str(A[k])
            N = 0
            break
print(ans)

Buggy submission (verdict: Runtime Error):
N,M = map(int,input().split())
A = list(map(int,input().split()))
A.sort()
A.reverse()
match = [2,5,5,4,5,6,3,7,6]
dp = [0]*(N+1)
for i in range(N+1):
  L = []
  for j in range(M):
    if i-match[A[j]-1] >= 0:
      L.append(dp[i-match[A[j]-1]]+1)
  L.sort()
  if len(L) >= 1:
    dp[i] = L[len(L)-1]
ans = ''
while N > 0:
  for i in range(M):
    if dp[N-match[A[i]-1]] == dp[N]-1:
      if dp[N]-1 != 0:
        ans += str(A[i])
        N -= match[A[i]-1]
        break
      else:
        for k in range(M):
          if match[A[k]-1] == N:
            ans += str(A[k])
            N = 0
            break
print(ans)
Problem p03241 (python)

Fixed submission:
import math

N,M = map(int,input().split())
A = M//N
L = []
for i in range(1,int(math.sqrt(M))+1):
  if (M%i == 0 and i <= A):
    L.append(i)
    if (M//i <= A):
      L.append(M//i)
print(max(L))

Buggy submission (verdict: Runtime Error):
import math

N,M = map(int,input().split())
A = M//N
L = []
for i in range(1,int(math.sqrt(M))):
  if (M%i == 0 and i <= A):
    L.append(i)
    if (M//i <= A):
      L.append(M//i)
print(max(L))

Buggy submission (verdict: Runtime Error):
import math

N,M = map(int,input().split())
A = M//N
L = []
flag = False
if (A <= 10**8):
  for i in range(1,A+1):
    if (M%(A+1-i) == 0):
      flag = True
      break
  if flag:
    print(A+1-i)
else:
  for i in range(1,math.sqrt(A)):
    if (M%i == 0):
      L.append(i)
  print(max(L))
Problem p03254 (python)

Fixed submission:
N,x = map(int,input().split())
A = list(map(int,input().split()))
A.sort()
p = sum(A)
k = 0
if (x == p):
  print(N)
elif (x > p):
  print(N-1)
else:
  i = 0
  for i in range(N):
    if (x - A[i] >= 0):
      x -= A[i]
      k += 1
      i += 1
    else:
      break      
  print(k)

Buggy submission (verdict: Runtime Error):
N,x = map(int,input().split())
A = list(map(int,input().split()))
A.sort()
p = sum(A)
if (x == p):
  print(N)
elif (x > p):
  print(N-1)
else:
  k = 0
  i = 0
  for i in range(N):
    if (x - A[i] >= 0):
      x -= A[i]
      k += 1
      i += 1
    else:
      break
print(k)
Problem p03262 (python)

Fixed submission:
N,X = map(int,input().split())
L = list(map(int,input().split()))
for i in range(N):
  L[i] = abs(L[i]-X)
L.sort()
L.reverse()
def gcd(a,b):
  if b == 0:
    return a
  else:
    return gcd(b,a%b)
def listgcd(L):
  p = L[0]
  for i in range(1,N):
    p = gcd(p,L[i])
  return p
if len(L) >= 2:
  print(listgcd(L))
else:
  print(L[0])

Buggy submission (verdict: Runtime Error):
N,X = map(int,input().split())
x = list(map(int,input().split()))
x.sort()
L = []

if (len(x) == 1):
  print(abs(X-x[0]))
else:
  L.append(abs(X-x[0]))
  for k in range(len(x)):
    p = abs(X-x[k])
    if (p < L[0]):
      del L[0]
      L.append(p)
print(L[0])

Buggy submission (verdict: Runtime Error):
N,X = map(int,input().split())
x = list(map(int,input().split()))
x.sort()
L = []
if (len(x) == 1):
  print(abs(X-x[0]))
else:
  for k in range(len(x)):
    L.append(abs(X-x[k]))
    L.sort()
print(L[0])
Problem p03282 (python)

Fixed submission:
S = input()
K = int(input())
for i in range(K):
  if (int(S[i]) != 1):
    print(S[i])
    exit()
print(1)

Buggy submission (verdict: Runtime Error):
S = input()
K = int(input())
if (S.count('1') == len(S)):
  print('1')
else:
  p = 0
  if (len(S) == 1):
    print(S[0])
    exit()
  else:  
    while (S[p] == S[p+1] == '1'):
      p += 1
if (p+1 >= K):
  print('1')
else:
  if (p == 0):
    if (S[0] == '1'):
      print(S[1])
    else:
      print(S[0])
  else:
    print(S[p+1])

Buggy submission (verdict: Runtime Error):
S = input()
K = int(input())
if (S.count('1') == len(S)):
  print('1')
else:
  p = 0
  while (S[p] == S[p+1] == '1'):
    p += 1
if (p+1 >= K):
  print('1')
else:
  if (p == 0):
    if (S[0] == '1'):
      print(S[1])
    else:
      print(S[0])
  else:
    print(S[p+1])
Problem p03292 (python)

Fixed submission:
A = list(map(int,input().split()))
A.sort()
print(A[2]-A[0])

Buggy submission (verdict: Runtime Error):
A = list(map(int,input().split))
A.sort()
print(A[2]-A[0])

Buggy submission (verdict: Runtime Error):
A = list(map(int,input().split))
A.sort
print(A[2]-A[0])
Problem p03393 (python)

Fixed submission:
import sys
s = input()
L = []
alp = [chr(ord('a') + i) for i in range(26)]
TF = [False]*26
for i in range(len(s)):
  if not s[i] in L:
    L.append(s[i])
    TF[ord(s[i])-97] = True
if len(L) != 26:
  for i in range(26):
    if TF[i] == False:
      k = alp[i]
      break
  print(s+k)
else:
  right = s[-1]
  for i in reversed(range(len(s))):
    k = s[i]
    if k < right:
      for j in range(ord(k),ord(k)+26):
        if chr(j) in s[i+1:]:
          print(s[:i]+chr(j))
          break
      sys.exit()
    else:
      right = max(k,right)
  print(-1)

Buggy submission (verdict: Runtime Error):
s = input()
L = []
alp = [chr(ord('a') + i) for i in range(26)]
TF = [False]*26
for i in range(len(s)):
  if not s[i] in L:
    L.append(s[i])
    TF[ord(s[i])-97] = True
if len(L) != 26:
  for i in range(26):
    if TF[i] == False:
      k = alp[i]
      break
  print(s+k)
else:
  if s == 'zyxwvutsrqponmlkjihgfedcba':
    print(-1)
  elif s == 'abcdefghijklmnopqrstuvwxyz':
    print('b')
  else:
    P = []
    for i in range(25,-1,-1):
      if s[i] > s[i-1]:
        break
      else:
        P.append(s[i-1])
        P.append(s[i])
    P.sort()
    print(s[0:i-1]+P[0])

Buggy submission (verdict: Runtime Error):
s = input()
L = []
alp = [chr(ord('a') + i) for i in range(26)]
TF = [False]*26
for i in range(len(s)):
  if not s[i] in L:
    L.append(s[i])
    TF[ord(s[i])-97] = True
if len(L) != 26:
  for i in range(26):
    if TF[i] == False:
      k = alp[i]
      break
  print(s+k)
else:
  if s == 'zyxwvutsrqponmlkjihgfedcba':
    print(-1)
  elif s == 'abcdefghijklmnopqrstuvwxyz':
    print('b')
  else:
    for i in range(25):
      if ord(s[i+1])-ord(s[i]) != 1:
        break
    print(s[0:i]+alp[ord(s[i])-97+1])
Problem p03436 (python)

Fixed submission:
from collections import deque
R,C = map(int,input().split())
sy,sx = 1,1  #スタートの座標
gy,gx = R,C  #ゴールの座標
L = []
for i in range(R):
  L.append(list(input()))   #迷路の情報を受け取る
dy_dx = [[1,0],[-1,0],[0,1],[0,-1]]   #移動
black = 0
for i in range(R):
  for j in range(C):
    if L[i][j] == '#':
      black += 1
que = deque([[sy-1,sx-1]])   #queには次に見るべき座標が入る。括弧が二重になっていることに留意
L[sy-1][sx-1] = 0  #スタートの座標（迷路上）の情報を0に
while len(que) > 0:  #queが空でないときは
  cur = que.popleft()   #queの一番左を見る
  for i in range(4):  #現在見ているマスの上下左右をチェック
    if 0 <= cur[0]+dy_dx[i][0] <= R-1 and 0 <= cur[1]+dy_dx[i][1] <= C-1:  #移動した後も迷路内にあるかの確認
      if L[cur[0]+dy_dx[i][0]][cur[1]+dy_dx[i][1]] == '.':  #まだ見ていない通路であれば
        L[cur[0]+dy_dx[i][0]][cur[1]+dy_dx[i][1]] = L[cur[0]][cur[1]]+1  #現在見ているマスの手数+1を入れる
        que.append([cur[0]+dy_dx[i][0],cur[1]+dy_dx[i][1]])   #queの末尾に今チェックした座標を入れる
if L[gy-1][gx-1] == '#':
  print(-1)
elif L[gy-1][gx-1] == '.':
  print(-1)
else:
  print(R*C-L[gy-1][gx-1]-1-black)

Buggy submission (verdict: Runtime Error):
from collections import deque
R,C = map(int,input().split())
sy,sx = 1,1  #スタートの座標
gy,gx = R,C  #ゴールの座標
L = []
for i in range(R):
  L.append(list(input()))   #迷路の情報を受け取る
dy_dx = [[1,0],[-1,0],[0,1],[0,-1]]   #移動
que = deque([[sy-1,sx-1]])   #queには次に見るべき座標が入る。括弧が二重になっていることに留意
L[sy-1][sx-1] = 0  #スタートの座標（迷路上）の情報を0に
while len(que) > 0:  #queが空でないときは
  cur = que.popleft()   #queの一番左を見る
  for i in range(4):  #現在見ているマスの上下左右をチェック
    if 0 <= cur[0]+dy_dx[i][0] <= R-1 and 0 <= cur[1]+dy_dx[i][1] <= C-1:  #移動した後も迷路内にあるかの確認
      if L[cur[0]+dy_dx[i][0]][cur[1]+dy_dx[i][1]] == '.':  #まだ見ていない通路であれば
        L[cur[0]+dy_dx[i][0]][cur[1]+dy_dx[i][1]] = L[cur[0]][cur[1]]+1  #現在見ているマスの手数+1を入れる
        que.append([cur[0]+dy_dx[i][0],cur[1]+dy_dx[i][1]])   #queの末尾に今チェックした座標を入れる
black = 0
for i in range(R):
  for j in range(C):
    if L[i][j] == '#':
      black += 1
print(R*C-L[gy-1][gx-1]-1-black)
Problem p03473 (python)

Fixed submission:
M = int(input())
print(48-M)

Buggy submission (verdict: Runtime Error):
M = int(input())
print(48-N)
Problem p03478 (python)

Fixed submission:
N,A,B = map(int,input().split())
L = []
for i in range(1,N+1):
  k = str(i)
  s = 0
  for j in range(len(k)):
    s += int(k[j])
  if (A <= s <= B):
    L.append(i)
print(sum(L))

Buggy submission (verdict: Runtime Error):
A,B = map(int,input().split())
S = input()
L = [0,1,2,3,4,5,6,7,8,9]
for i in (range(A) and range(A+1,A+B+1)):
  if (S[i] in L):
    if (S[A] == '-'):
      print('Yes')
  else:
    print('No')

Buggy submission (verdict: Runtime Error):
N,A,B = map(int,input().split())
L = []
for i in range(1,N+1):
  k = str(i)
  for j in range(len(k)):
    S = sum(int(k[j]))
    if (A <= S <= B):
      L.append(i)
print(sum(S))
Problem p03486 (python)

Fixed submission:
s = list(input())
t = list(input())

s.sort()
t.sort()
t.reverse()

if (s < t):
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
s = list(input())
t = list(input())
 
p = s.sort()
q = t.sort()
r = q.reverse()
 
if (p < r):
  print('Yes')
else:
  print('No')
Problem p03504 (python)

Fixed submission:
n,c = map(int,input().split())
L = [[] for i in range(c)]
for i in range(n):
    s,t,k = map(int,input().split())
    L[k-1].append([s,t])
for i in range(c):
    L[i].sort()
for i in range(c):
    d = [0]*(10**5+1)
    T = []
    for j in range(len(L[i])):
        d[L[i][j][0]] += 1
        d[L[i][j][1]] -= 1
    for j in range(10**5):
        d[j+1] += d[j]
    cur = 0
    start = 0
    end = 0
    for j in range(10**5+1):
        if d[j] == 1 and cur == 0:
            start = j
            cur = 1
        elif d[j] == 0 and cur == 1:
            end = j
            cur = 0
            T.append([start*2-1, end*2])
    L[i] = T
dp = [0]*(10**5)*3
ans = 0
for i in range(c):
    for j in range(len(L[i])):
        dp[L[i][j][0]] += 1
        dp[L[i][j][1]] -= 1
for j in range(1,(10**5)*3):
    dp[j] = dp[j-1]+dp[j]
    ans = max(ans, dp[j])
print(ans)

Buggy submission (verdict: Runtime Error):
n,c = map(int,input().split())
L = [[] for i in range(c)]
for i in range(n):
    s,t,k = map(int,input().split())
    L[k-1].append([s,t])
for i in range(c):
    L[i].sort()
for i in range(c):
    d = [0]*(10**5+1)
    T = []
    for j in range(len(L[i])):
        d[L[i][j][0]] += 1
        d[L[i][j][1]] -= 1
    for j in range(10**5):
        d[j+1] += d[j]
    cur = 0
    start = 0
    end = 0
    for j in range(10**5+1):
        if d[j] == 1 and cur == 0:
            start = j
            cur = 1
        elif d[j] == 0 and cur == 1:
            end = j
            cur = 0
            T.append([start*2-1, end*2])
    L[i] = T
dp = [0]*(10**5)*2+3
ans = 0
for i in range(c):
    for j in range(len(L[i])):
        dp[L[i][j][0]] += 1
        dp[L[i][j][1]] -= 1
for j in range(1,(10**5)*2+3):
    dp[j] = dp[j-1]+dp[j]
    ans = max(ans, dp[j])
print(ans)
Problem p03607 (python)

Fixed submission:
N = int(input())
A = [int(input()) for i in range(N)]
A.sort()
j = 1
J = 1
ans = 0
for j in range(1,len(A)):
  if (A[j-1] == A[j]):
    J += 1
  else:
    if (J%2 != 0):
      ans += 1
      J = 1
    else:
      J = 1
if (J%2 != 0):
  ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = [int(input()) for i in range(N)]
L = [0 for i in range(10*9)]
for j in range(N):
  L[A[j]] += 1
ans = 0
for k in range(len(L)):
  if (L[k] == 0):
    None
  elif (L[k]%2 == 0):
    None
  else:
    ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
L = [int(input()) for i in range(N)]
L.sort()
k = 1
for i in range(len(L)):
  if (L[i] == L[i+1]):
    k -= 1
  else:
    k += 1
print(k)
Problem p03609 (python)

Fixed submission:
x,t = map(int,input().split())
if (x >= t):
  print(x-t)
else:
  print(0)

Buggy submission (verdict: Runtime Error):
X,t = map(int,input().split())
if (x >= t):
  print(x-t)
else:
  print(0)
Problem p03659 (python)

Fixed submission:
N = int(input())
L = list(map(int,input().split()))
S = sum(L)
k = 0
ans = abs(2*sum(L[0:1])-S)
for i in range(0,N-1):
  k += L[i]
  ans = min(ans,abs(2*k-S))
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
L = list(map(int,input().split()))
S = sum(L)
A = []
for i in range(1,N):
  p = abs(2*sum(L[0:i])-S)
    A.append(p)
print(min(A))