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

Fixed submission:
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

a = [0]
aa = 0
for i in range(1,N+1):
    aa += A[i-1]
    a.append(aa)
    
b = [0]
bb = 0
for i in range(1,M+1):
    bb += B[i-1]
    b.append(bb)
    
time0 = 1
ans = 0
j = M
for i in range(N+1):
    if a[i] > K:
        break
    else:
        while(j >= 0):
            if b[j] <= K - a[i]:
                ans = max(ans, i+j)
                break
            else:
                j -= 1
        
        
            
print(ans)

Buggy submission (verdict: Runtime Error):
import numpy as np
N, M, K = map(np.int64, input().split())
A = list(map(np.int64, input().split()))
B = list(map(np.int64, input().split()))

time0 = 0
cnt = 0
while(time0<=K):
    if len(A) == 0 and len(B) != 0:
        time0 += B.pop(0)
        cnt += 1
    elif len(B) == 0 and len(A) != 0:
        time0 += A.pop(0)
        cnt += 1
    elif len(A) == 0 and len(B) == 0:
        cnt += 1
        break
    else:
        if A[0] < B[0]:
            time0 += A.pop(0)
            cnt += 1
        elif A[0] > B[0]:
            time0 += B.pop(0)
            cnt += 1
        else:
            if A[1]<=B[1]:
                time0 += A.pop(0)
                cnt+=1
            else:
                time0 += B.pop(0)
                cnt+=1
            
cnt -= 1

print(cnt)
Problem p02676 (python)

Fixed submission:
K=int(input())
S=input()

if len(S)<=K:
  print(S)
else:
  print(S[:K]+"...")

Buggy submission (verdict: Runtime Error):
K=input()
S=input()

if len(S)>=K:
  print(s)
else:
  print(s[:K]+"...")
Problem p02577 (python)

Fixed submission:
import sys
import math
def Ii():return int(sys.stdin.readline().rstrip())
def Mi():return map(int,sys.stdin.readline().split())
def Li():return list(map(int,sys.stdin.readline().split()))

s = sys.stdin.readline().rstrip()
ans = 0
for i in s:
	ans += int(i)
	ans %= 9

print('Yes' if ans%9 == 0 else 'No')

Buggy submission (verdict: Runtime Error):
import sys
import math
def Ii():return int(sys.stdin.readline())
def Mi():return map(int,sys.stdin.readline().split())
def Li():return list(map(int,sys.stdin.readline().split()))

s = sys.stdin.readline()
ans = 0
for i in s:
  ans += int(i)
  ans %= 9

print('Yes' if ans%9 == 0 else 'No')

Buggy submission (verdict: Runtime Error):
import sys
import math
def Ii():return int(sys.stdin.readline())
def Mi():return map(int,sys.stdin.readline().split())
def Li():return list(map(int,sys.stdin.readline().split()))

s = sys.stdin.readline()
ans = 0
for i in s:
  ans += int(i)
  ans %= 9

print('Yes' if ans%9 == 0 else 'No')

Buggy submission (verdict: Runtime Error):
import sys
import math
def Ii():return int(sys.stdin.readline())
def Mi():return map(int,sys.stdin.readline().split())
def Li():return list(map(int,sys.stdin.readline().split()))

s = sys.stdin.readline()
ans = 0
for i in s:
  ans += int(i)
  ans %= 9

print('Yes' if ans%9 == 0 else 'No')
Problem p02623 (python)

Fixed submission:
n,m,k = list(map(int,input().split()))
A = list(map(int,input().split()))
B = list(map(int,input().split()))
b = sum(B)
ka = k
i = m
c = 0
re = 0
A.insert(0, 0)
for a in A:
  ka -= a
  if ka < 0:
    break
  while ka < b and i > 0:
    i -= 1
    b -= B[i]
  c += 1
  re = max(re, c+i)

  
print(re-1)

Buggy submission (verdict: Runtime Error):
n,m,k = list(map(int,input().split()))
A = list(map(int,input().split()))
B = list(map(int,input().split()))
b = sum(B)
ka = k
i = m
re = 0
for a in A:
  if ka < 0:
    break
  while ka < b and i > 0:
    b -= B[i]
    i -= 1
  ka -= a
  re += 1
  
print(re+i)
Problem p02682 (python)

Fixed submission:
import sys
def Ii():return int(sys.stdin.buffer.read())
def Mi():return map(int,sys.stdin.buffer.readline().split())
def Li():return list(map(int,sys.stdin.buffer.readline().split()))
 
a,b,c,k = Mi()
if k <= a:
  print(k)
  exit(0)
ans = a
k -= a
if k > b:
  ans -= k-b
  
print(ans)

Buggy submission (verdict: Runtime Error):
def Ii():return int(sys.stdin.buffer.read())
def Mi():return map(int,sys.stdin.buffer.readline().split())
def Li():return list(map(int,sys.stdin.buffer.readline().split()))
 
a,b,c,k = Mi()
if k <= a:
  ans = k
  exit(0)
ans = a
k -= a
if k > b:
  ans -= k-b
  
print(ans)
Problem p02688 (python)

Fixed submission:
import sys
def Ii():return int(sys.stdin.buffer.readline())
def Mi():return map(int,sys.stdin.buffer.readline().split())
def Li():return list(map(int,sys.stdin.buffer.readline().split()))
 
n,k = Mi()
b = [1]*(n+1)
for i in range(k):
  d = Ii()
  a = Li()
  for j in a:
    b[j] = 0
    
print(sum(b)-1)

Buggy submission (verdict: Runtime Error):
import sys
def Ii():return int(sys.stdin.buffer.readline())
def Mi():return map(int,sys.stdin.buffer.readline().split())
def Li():return list(map(int,sys.stdin.buffer.readline().split()))

n,k = Mi()
b = [1]*n
for i in range(k):
  d = Ii()
  a = Li()
  for j in a:
    b[j] = 0
    
print(sum(b)-1)
Problem p02597 (python)

Fixed submission:
import math, sys

N=int(input())
S=input()
R_count=0
if "R" not in S:
    print(0)
    sys.exit()
if "W" not in S:
    print(0)
    sys.exit()
if "R" not in S[S.index("W"):]:
    print(0)
    sys.exit()
for i in range(N):
    if S[i]=="R":
        R_count+=1

S=S[:R_count]
ans=S.count("W")
print(ans)

Buggy submission (verdict: Runtime Error):
import math, sys

N=int(input())
S=input()
R_count=0
for i in range(N):
    if S[i]=="R":
        R_count+=1

ans=R_count
ind=S.index("R")
if ind>R_count:
    print(R_count)
    sys.exit()

#ans-=ind
S=S[ind:]
while S[0]=="R":
    S=S[1:]
    ans-=1
print(ans)
Problem p02753 (python)

Fixed submission:
letter=input()
if "A" not in letter:
  print("No")
elif "B" not in letter:
  print("No")
else:
  print("Yes")

Buggy submission (verdict: Runtime Error):
letter=list(input())
n=int(input())
for i in range(n):
    ope=input().split(" ")
    o1=int(ope[0])
    if o1 ==1:
        letter.reverse()
    else:
        o2,o3_s=int(ope[1]),ope[2]
        if o2==1:
            for j in range( 1,len(o3_s)+1):
                letter.insert(0,o3_s[len(o3_s)-j])
        else:
            for j in range(len(o3_s)):
                letter.append(o3_s[j])
print("".join(letter))

Buggy submission (verdict: Runtime Error):
letter=input()
n=int(input())
for i in range(n):
    ope=input().split(" ")
    o1=int(ope[0])
    if o1 ==1:
        letter="".join(list(reversed(letter)))
    else:
        o2,o3_s=int(ope[1]),ope[2]
        if o2==1:
            letter=o3_s+letter
        else:
            letter=letter+o3_s
print(letter)

Buggy submission (verdict: Runtime Error):
ans=-1
nums=input().split(" ")
t8,t10=int(nums[0]),int(nums[1])
value=max(round(t8*100/8),round(t10*100/10))+1
for i in range(value):
  v=value-i
  tax8=v*8/100
  tax10=v*10/100
  if tax8>=t8 and tax8<t8+1 and tax10>=t10 and tax10<t10+1:
    ans=v
  elif tax8<t8 or tax10<t10:
    break
print(ans)

Buggy submission (verdict: Runtime Error):
ans=-1
nums=input().split(" ")
t8,t10=int(nums[0]),int(nums[1])
value_f=int(max(round(t8*100/8),round(t10*100/10))+1)
while True:
  tax8,tax10=value_f*8/100,value_f*10/100
  if tax8>=t8 and tax8<t8+1 and tax10>=t10 and tax10<t10+1:
    ans=value_f
  elif tax8<t8 or tax10<t10:
    print(ans)
    break
  value_f-=1
  if value_f<0:
    break

Buggy submission (verdict: Runtime Error):
import math
ans=-1
nums=input().split(" ")
t8,t10=int(nums[0]),int(nums[1])
value_f=max(round(t8*100/8),round(t10*100/10))+1
while value_f>=0:
	tax8,tax10=value_f*8/100,value_f*10/100
	if tax8>=t8 and tax8<t8+1 and tax10>=t10 and tax10<t10+1:
		ans=value_f
	elif tax8<t8 or tax10<t10:
		print(ans)
		break
	value_f-=1

Buggy submission (verdict: Runtime Error):
import math
ans=-1
nums=input().split(" ")
t8,t10=int(nums[0]),int(nums[1])
value_f=max(math.ceil(t8*100/8),math.ceil(t10*10))
while value_f>=0:
	tax8,tax10=math.floor(value_f*0.08),math.floor(value_f*0.1)
	if tax8==t8 and tax10==t10:
		ans=value_f
	elif tax8<t8 or tax10<t10:
		print(ans)
		break
	value_f-=1

Buggy submission (verdict: Runtime Error):
import math
ans=-1
nums=input().split(" ")
t8,t10=int(nums[0]),int(nums[1])
value=t8*100/8
value_f=math.ceil(value*1.2)
while True:
	tax8,tax10=math.floor(value_f*0.08),math.floor(value_f*0.1)
	if tax8== t8 and tax10==t10:
		ans=value_f
		value_f-=1
	elif tax8<t8 or tax10<t10:
		print(ans)
		break
	else:
		value_f-=1
	if value_f==0:
		print(ans)
		break
Problem p02759 (python)

Fixed submission:
print( int( (int(input()) + 1 )/2 ) )

Buggy submission (verdict: Runtime Error):
import itertools as it
dic={}
bing=[[1 for i in range(3)] for j in range(3)]
for i in range(3):
    f=list(map(int,input().split()))
    for each in f:
        dic.update({each:(i,f.index(each))})
n=int(input())
for i in range(n):
    m=int(input())
    if m in dic.keys():
      place=dic[m]
      bing[place[0]][place[1]]=0
flag=False
code="000102101112202122"
code=code+code[::-1]
code=code+"001122021120"

for i in range(8):
    code_sep=code[6*i:6*i+6]
    p=0
    for j in range(3):
        cords=code_sep[2*j:2*j+2]
        p+=bing[int(cords[0])][int(cords[1])]
    if p==0:
        flag=True
        break
    
print("yes")if flag else print("No")

Buggy submission (verdict: Runtime Error):
print(int((int(input()+1))/2))
Problem p02773 (python)

Fixed submission:
dic = {}
ans = []
a = 0

N = int( input() )
for i in range( N ):
  let = input()
  if let not in dic:
    dic.update( { let : 1 } )
  else:
    num=dic[ let ]
    dic[ let ] = num + 1
dic_sorted = sorted(dic.items(), key=lambda x:x[1],reverse=True)
for each in dic_sorted:
  if each[1] >= a:
    ans.append(each[0])
    a=each[1]
  else:
    break
ans.sort()
for each in ans:
  print(each)

Buggy submission (verdict: Runtime Error):
dic = {}
ans = []
a = 0

N = int( input() )
for i in range( N ):
  let = input()
  if let not in dic:
    dic.update( { let : 1 } )
  else:
    num=dic[ let ]
    dic[ let ] = num + 1
dic_sorted = sorted(dic.items(), key=lambda x:x[1])
for each in dic_sorted.keys():
  if dic_sorted[ each ] >= a:
    ans+=1
    a=dic_sorted[ each ]
  else:
    break
ans.sort()
for each in ans:
  print(each)

Buggy submission (verdict: Runtime Error):
N=int(inpu())
ans=[]
dic={}
for i in range(N):
  let=input()
  if let in dic.keys:
    dic.update({let:1})
  else:
    dic.update({let:dic[let]+1})
score_sorted = sorted(score.items(), key=lambda x:x[1])
a=0
for each in score_sorted.keys():
  if score_sorted[each]>=a:
    ans+=each
    a=score_sorted[each]
  else:
    break
ans.sort()
for each in ans:
  print(each)
Problem p02847 (python)

Fixed submission:
days = {"SUN":0, "MON":1,"TUE":2, "WED":3, "THU":4,"FRI":5,"SAT":6}
week = raw_input()
t = 7 - days[week] 
print(t)

Buggy submission (verdict: Runtime Error):
days = {"SUN:0", "MON:1"," TUE:2", "WED:3", "THU:4","FRI:5","SAT:6"}
week = raw_input()
t = 7 - days[week] 
print(t)
Problem p02862 (python)

Fixed submission:
def sq(a, b, mod):  # aのb乗を剰余
    if b == 0:
        return 1
    elif b % 2 == 0:
        return sq(a, b // 2, mod)**2 % mod
    else:
        return sq(a, b - 1, mod) * a % mod
  
def egcd(a, b):
    if a == 0:
        return b, 0, 1
    else:
        g, y, x = egcd(b % a, a)
        return g, x - (b // a) * y, y

def modinv(a, m):
    g, x, y = egcd(a, m)
    if g != 1:
        raise Exception('modular inverse does not exist')
    else:
        return x % m

def nCk(n,k,mod):
  prev=1
  for i in range(1,min(k,n-k)+1):
    v=(prev * (n+1-i) % mod * modinv(i, mod) % mod)
    prev=v
  return prev

x,y=map(int,input().split())
mod=10**9+7

if (x+y)%3!=0:
  print(0)
else:
  n=(x+y)//3
  k=(2*x-y)//3
  if k<0 or k>n:
    print(0)
  else:
    print(nCk(n,k,mod))

Buggy submission (verdict: Runtime Error):
 def sq(a, b, mod):  # aのb乗を剰余
    if b == 0:
        return 1
    elif b % 2 == 0:
        return sq(a, b // 2, mod)**2 % mod
    else:
        return sq(a, b - 1, mod) * a % mod
  
def egcd(a, b):
    if a == 0:
        return b, 0, 1
    else:
        g, y, x = egcd(b % a, a)
        return g, x - (b // a) * y, y

def modinv(a, m):
    g, x, y = egcd(a, m)
    if g != 1:
        raise Exception('modular inverse does not exist')
    else:
        return x % m

def nCk(n,k,mod):
  prev=1
  for i in range(1,min(k,n-k)+1):
    v=(prev * (n+1-i) % mod * modinv(i, mod) % mod)
    prev=v
  return prev

x,y=map(int,input().split())
mod=10**9+7

if (x+y)%3!=0:
  print(0)
else:
  n=int((x+y)/3)
  k=int((2*x-y)/3)
  print(nCk(n,k,mod))

Buggy submission (verdict: Runtime Error):
import math
a,b=map(int,input().split())
if (a+b)%3!=0:
  print(0)
else:
  n=(a+b)//3
  r=(2*b-a)//3
  def nCr(n,r):
    mod=10**9+7
    def exgcd(a,b):
      u0,u1,v0,v1=1,0,0,1
      while b!=0:
        q,a,b=a//b,b,a%b
        u0,u1=u1,u0-q*u1
        v0,v1=v1,v0-q*v1
      return u0
    def inv_mod(a,n):
      return exgcd(a,n)%n
    ans=((math.factorial(n))*(inv_mod(math.factorial(n-r),mod))*(inv_mod(math.factorial(r),mod)))%mod
    return ans
  print(nCr(n,r))
Problem p02891 (python)

Fixed submission:
S=list(str(input()))
s=set(S)
K=int(input())
num=0
i=0
lst=[]
def dp(i,lst):
  if i==len(S)-1:
    return lst
  if S[i]!=S[i+1]:
    return dp(i+1,lst)
  j=i+1
  while j<=len(S)-1  and S[i]==S[j]:
    j+=1
  lst.append(list(S[i:j]))
  return dp(j-1,lst)

if 2<=len(s):
  L=dp(i,lst)
  for i in range(len(L)):
    num+=(len(L[i])//2)
  if num==0:
    if S[0]!=S[-1]:
      print(0)
    else:
      print(K-1)
  elif L[-1][-1]==S[0] and len(L[-1])%2==len(L[0])%2==1:
    print(num+(K-1)*(num+1))
  else:
    print(num*K)
else:
  print((len(S)*K)//2)

Buggy submission (verdict: Runtime Error):
S=list(str(input()))
s=set(S)
K=int(input())
num=0
i=0
lst=[]
def dp(i,lst):
  if i==len(S)-1:
    return lst
  if S[i]!=S[i+1]:
    return dp(i+1,lst)
  j=i+1
  while j<=len(S)-1  and S[i]==S[j]:
    j+=1
  lst.append(list(S[i:j]))
  return dp(j-1,lst)
if len(s)>=2:
  L=dp(i,lst)
  for i in range(len(L)):
    num+=(len(L[i])//2)
  if L[-1][-1]==S[0] and len(L[-1])%2==1:
    print(num+(K-1)*(num+1))
  else:
    print(num*K)
else:
  print((len(S)*K)//2)
Problem p03038 (python)

Fixed submission:
import heapq
import sys
N,M=map(int,input().split())
A=sorted(list(map(int,input().split())))
lst=[[0,0] for _ in range(M)]
h=[]
for i in range(M):
  lst[i]=list(map(int,input().split()))
  heapq.heappush(h,[-1*lst[i][1],lst[i][0]])
i=0
while len(h)!=0:
    v=heapq.heappop(h)
    v1,v2=-1*v[0],v[1]
    while i<=N-1 and A[i]<v1 and v2!=0:
        A[i]=v1
        i+=1
        v2-=1
    if v2>=1:
        print(sum(A))
        sys.exit()
print(sum(A))

Buggy submission (verdict: Runtime Error):
import heapq
import sys
N,M=map(int,input().split())
A=sorted(list(map(int,input().split())))
lst=[[0,0] for _ in range(M)]
h=[]
for i in range(M):
  lst[i]=list(map(int,input().split()))
  heapq.heappush(h,[-1*lst[i][1],lst[i][0]])
i=0
while len(h)!=0:
    v=heapq.heappop(h)
    v1,v2=-1*v[0],v[1]
    if A[i]>=v1:
      print(sum(A))
      sys.exit()
    while i<=N-1 and A[i]<v1 and v2!=0:
        A[i]=v1
        i+=1
        v2-=1
    if v2>=1:
        print(sum(A))
        sys.exit()
print(sum(A))

Buggy submission (verdict: Runtime Error):
import heapq
import sys
N,M=map(int,input().split())
A=sorted(list(map(int,input().split())))
lst=[[0,0] for _ in range(M)]
h=[]
for i in range(M):
  lst[i]=list(map(int,input().split()))
  heapq.heappush(h,[-1*lst[i][1],lst[i][0]])
i=0
while len(h)!=0:
    v=heapq.heappop(h)
    v1,v2=-1*v[0],v[1]
    if A[i]>=v1:
      print(sum(A))
      sys.exit()
    while A[i]<v1 and v2!=0:
        A[i]=v1
        i+=1
        v2-=1
    if v2>=1:
        print(sum(A))
        sys.exit()
print(sum(A))

Buggy submission (verdict: Runtime Error):
import heapq
import sys
N,M=map(int,input().split())
A=sorted(list(map(int,input().split())))
lst=[[0,0] for _ in range(M)]
h=[]
for i in range(M):
  lst[i]=list(map(int,input().split()))
  heapq.heappush(h,[-1*lst[i][1],lst[i][0]])

tmp=0
while len(h)!=0:
  v=heapq.heappop(h)
  v1,v2=-1*v[0],v[1]
  if A[0]>v1:
    print(sum(A))
    sys.exit()
  else:
    while v2!=0 and A[0]<v1:
      A.pop(0)
      tmp+=v1
      v2-=1
    if v2>=1:
      print(sum(A)+tmp)
      sys.exit()
print(sum(A)+tmp)
Problem p03045 (python)

Fixed submission:
class UnionFind:
    def __init__(self, n):
        self.n = n
        self.p = [e for e in range(n)]
        self.rank = [0] * n
        self.size = [1] * n

    def same(self, u, v):
        return self.find_set(u) == self.find_set(v)

    def unite(self, u, v):
        u = self.find_set(u)
        v = self.find_set(v)

        if u == v:
            return

        if self.rank[u] > self.rank[v]:
            self.p[v] = u
            self.size[u] += self.size[v]
        else:
            self.p[u] = v
            self.size[v] += self.size[u]
            if self.rank[u] == self.rank[v]:
                self.rank[v] += 1

    def find_set(self, u):
        if u != self.p[u]:
            self.p[u] = self.find_set(self.p[u])

        return self.p[u]

    def update_p(self):
        for u in range(self.n):
            self.find_set(u)

    def get_size(self, u):
        return self.size[self.find_set(u)]


n, m = map(int, input().split())
xyz = [list(map(int, input().split())) for _ in range(m)]

uf = UnionFind(n)

for x, y, _ in xyz:
    x -= 1
    y -= 1
    uf.unite(x, y)

uf.update_p()
ans = len(set(uf.p))
print(ans)

Buggy submission (verdict: Runtime Error):
N,M=map(int,input().split())

class UnionFind:
  def __init__(self, n):
    self.n = n
    self.parents = [i for i in range(n)]
 
  def find(self, x):
    if self.parents[x]==x:
      return x
    self.parents[x] = self.find(self.parents[x])
    return self.parents[x]
 
  def union(self, x, y):
    x = self.find(x)
    y = self.find(y)
    if x == y:
      return
    if self.size(x) < self.size(y):
      x, y = y, x
    self.parents[x] += self.parents[y]
    self.parents[y] = x
    
  def size(self, x):
    return self.parents[self.find(x)]
  
  def cnt(self):
    par=self.parents
    return len(set(par))

uf=UnionFind(N)
for i in range(M):
  x,y,z=map(int,input().split())
  uf.union(x-1,y-1)
print(uf.cnt())
Problem p03104 (python)

Fixed submission:
A,B=map(int,input().split())

def int_to_bit(N):
  lst=[]
  ans=''
  if N==0:
    return 0
  while N!=1 and N!=0:
    lst.append(str(N%2))
    N//=2
  for i in range(1,len(lst)+1):
    ans+=lst[-i]
  if N==0:
    pass
  else:
    ans='1'+ans
  return int(ans)

def bit_to_int(N):
  N=str(N)
  ans=0
  for i in range(len(N)):
    ans+=int(N[i])*2**(len(N)-1-i)
  return ans

def XOR(a,b):
  a,b=min(a,b),max(a,b)
  a,b=str(a),str(b)
  length=len(a)
  lst=[]
  ans=''
  for i in range(1,length+1):
    if a[-i]==b[-i]=='1' or a[-i]==b[-i]=='0':
      lst.append('0')
    else:
      lst.append('1')
  for i in range(1,length+1):        
    ans+=lst[-i]
  if length==len(b):
    pass
  else:
    add=b[0:len(b)-length]
    ans=add+ans
  return bit_to_int(ans)

if A%2==0 and B%2==0:
  v=(B-A)//2
  if v%2==0:
    print(B)
  else:
    print(XOR(1,int_to_bit(B)))
elif A%2==0 and B%2==1:
  v=(B-A+1)//2
  if v%2==0:
    print(0)
  else:
    print(1)
elif A%2==1 and B%2==0:
  v=(B-1-A)//2
  if v%2==0:
    print(XOR(int_to_bit(A),int_to_bit(B)))
  else:
    print(XOR(1,int_to_bit(XOR(int_to_bit(A),int_to_bit(B)))))
else:
  v=(B-A)//2
  if v%2==0:
    print(A)
  else:
    print(XOR(int_to_bit(A),1))

Buggy submission (verdict: Runtime Error):
A,B=map(int,input().split())

def int_to_bit(N):
  lst=[]
  ans=''
  while N!=1 and N!=0:
    lst.append(str(N%2))
    N//=2
  for i in range(1,len(lst)+1):
    ans+=lst[-i]
  if N==0:
    pass
  else:
    ans='1'+ans
  return int(ans)

def bit_to_int(N):
  N=str(N)
  ans=0
  for i in range(len(N)):
    ans+=int(N[i])*2**(len(N)-1-i)
  return ans

def XOR(a,b):
  a,b=min(a,b),max(a,b)
  a,b=str(a),str(b)
  length=len(a)
  lst=[]
  ans=''
  for i in range(1,length+1):
    if a[-i]==b[-i]=='1' or a[-i]==b[-i]=='0':
      lst.append('0')
    else:
      lst.append('1')
  for i in range(1,length+1):        # ここ下手
    ans+=lst[-i]
  if length==len(b):
    pass
  else:
    add=b[0:len(b)-length]
    ans=add+ans
  return ans

List=[A+i for i in range(B-A+1)]
while len(List)>1:
  v1=int_to_bit(List[0])
  v2=int_to_bit(List[1])
  v=bit_to_int(XOR(v1,v2))        # ここ下手
  List.pop(0)
  List.pop(0)
  List.insert(0,v)
  
print(List[0])
Problem p03208 (python)

Fixed submission:
N,K=map(int,input().split())
h=[]
for i in range(N):
  h.append(int(input()))
h=sorted(h,reverse=True)
tmp=10**10
for i in range(N-K+1):
  tmp=min(tmp,h[i]-h[i+K-1])
print(tmp)

Buggy submission (verdict: Runtime Error):
N,K=map(int,input().split())
h=[]
for i in range(N):
  h.append(int(input()))
h=sorted(h,reverse=True)
tmp=10**10
for i in range(K):
  tmp=min(tmp,h[i]-h[i+K-1])
print(tmp)
Problem p03317 (python)

Fixed submission:
N,K=map(int,input().split())
if (N-1)%(K-1)==0:
  print((N-1)//(K-1))
else:
  print((N-1)//(K-1)+1)

Buggy submission (verdict: Runtime Error):
 N,K=map(int,input().split())
a=list(map(int,input().split()))
index=a.index(1)
l=index
r=index
cnt=0
if index<=(N//2-1 if N%2==0 else N//2):
  while l!=0:
    if cnt==0:
      if l-K+1<0:
        r=K-1
    l=max(0,l-K+1)
    cnt+=1
  while r!=N-1:
    r=min(N-1,r+K-1)
    cnt+=1
  print(cnt)
else:
  while r!=N-1:
    if cnt==0:
      if r+K-1>N-1:
        l=N-K
    r=min(N-1,r+K-1)
    cnt+=1
  while l!=0:
    l=max(0,l-K+1)
    cnt+=1
  print(cnt)
Problem p02676 (python)

Fixed submission:
k=int(input())
s=str(input())

if len(s)<=k:
  print(s)
else:
    print(s[0:k]+"...")

Buggy submission (verdict: Runtime Error):
k=int(input())
s=str(input())

if len(s)<=k:
  print(s)
  else:
    print(s[0:k]+"...")

Buggy submission (verdict: Runtime Error):
k=int(input())
s=str(input())
if len(s)<=k:
  print(k)
  else:
    print(s.replace(s[K:len(s)],"..."))

Buggy submission (verdict: Runtime Error):
if len(S)<=K:
  print(K)
else:
  print(S.replace(S[K:len(S)],"..."))
Problem p02688 (python)

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

count=[0]*(n)

for i in range(k):
  d=int(input())
  a=list(map(int, input().split()))
  for x in a:
    count[x-1]+=1
print(count.count(0))

Buggy submission (verdict: Runtime Error):
n,k = map(int, input().split())

count=[0]*(n+1)

for i in range(n):
  d=int(input())
  a=list(map(int, input().split()))
  ans=0
  for i in range(len(a)):
         count[i]+=1
print(count.count(0))
Problem p02627 (python)

Fixed submission:
alpha=input()
if(alpha.isupper()):
  print("A")
else:
  print("a")

Buggy submission (verdict: Runtime Error):
alph=input()
if(alpha.isupper()):
  print("A")
else:
  print("a")
Problem p02777 (python)

Fixed submission:
s,t=input().split()
a,b=map(int,input().split())
u=input()
if(u==s):
    print(a-1,b)
elif(u==t):
    print(a,b-1)

Buggy submission (verdict: Runtime Error):
s=input()
t=input()
a=int(input())
b=int(input())
u=input()
if(u==s):
    print(a-1,b)
elif(u==t):
    print(a,b-1)