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

Fixed submission:
import fractions
from functools import reduce

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

def f(m, a):
    re = 0
    for i in a:
        re += m % i
    return re

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

m = lcm_list(a) - 1
print(f(m, a))

Buggy submission (verdict: Runtime Error):
import math

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

def f(m, a):
    re = 0
    for i in a:
        re += m % i
    return re

def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

m = lcm_list(a) - 1
print(f(m, a))

Buggy submission (verdict: Runtime Error):
import math
from functools import reduce

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

def f(m, a):
    re = 0
    for i in a:
        re += m % i
    return re

def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

m = lcm_list(a) - 1
print(f(m, a))
Problem p03456 (python)

Fixed submission:
import math
a, b = list(map(str,input().split()))
re = 'No'
concat = int(a + b)
# print(concat, math.sqrt(concat) ** 2, math.sqrt(concat))
if concat == int(math.sqrt(concat)) ** 2:
    re = 'Yes'
    
print(re)

Buggy submission (verdict: Runtime Error):
import math
n = input()
n = int(n.replace(' ', ''))

re = 'No'
for n == int(math.sqrt(n) ** 2):
    re = 'Yes'
        
print(re)
Problem p03565 (python)

Fixed submission:
SD = input()
T = input()

ans = ''

for i in range(0, len(SD) - len(T)+1):
    flg = True
    for j in range(len(T)):
        if SD[i+j] == '?' or SD[i+j] == T[j]:
            continue
        else:
            flg = False
    if flg == True:
        ans = SD[0:i] + T + SD[i+len(T):]
            
if ans:
    ans = ans.replace('?', 'a')
else:
    ans = 'UNRESTORABLE'
    
print(ans)

Buggy submission (verdict: Runtime Error):
SD = input()
T = input()

ans = ''

for i in range(0, len(SD) - len(T)+1):
    flg = True
    for j in range(len(T)):
        if SD[i+j] == '?' or SD[i+j] == T[j]:
            continue
        else:
            flg = False
    if flg == True:
        ans = SD[0:i] + T + S[i+len(T):]
            
if ans:
    ans = ans.replace('?', 'a')
else:
    ans = 'UNRESTORABLE'
    
print(ans)

Buggy submission (verdict: Runtime Error):
SD = input()
T = input()

ans = ''

for i in range(0, len(SD) - len(T)+1):
    flg = True
    for j in range(len(T)):
        if SD[i+j] == '?' or SD[i+j] == T[j]:
            continue
        else:
            flg = False
    if flg == True:
        ans = SD[:i] + T + S[i+len(T):]
            
if ans:
    ans = ans.replace('?', 'a')
else:
    ans = 'UNRESTORABLE'
    
print(ans)
Problem p03101 (python)

Fixed submission:
H,W=map(int,input().split())
h,w=map(int,input().split())
print(H*W-H*w-h*W+h*w)

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
lst=[list(map(int,input().split()))]
for i in range(n-1):
    a=list(map(int,input().split()))
    x=0
    for j in range(len(lst)):
        if x > m :break
        if lst[j][0] > a[0]:
            lst.insert(j,a)
            break
        x+=lst[j][1]
        
ans=0
num=0
for i in lst:
    if i[1]+num>=m:
        ans+=i[0]*(m-num)
        break
    ans+=i[0]*i[1]
    num+=i[1]
print(ans)

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
lst=[list(map(int,input().split()))]
for i in range(n-1):
    a=list(map(int,input().split()))
    x=0
    for j in range(len(lst)):
        if x > m :break
        if lst[j][0] > a[0]:
            lst.insert(j,a)
            break
        x+=lst[j][1]
        
ans=0
num=0
for i in lst:
    if i[1]+num>=m:
        ans+=i[0]*(m-num)
        break
    ans+=i[0]*i[1]
    num+=i[1]
print(ans,lst)
Problem p03160 (python)

Fixed submission:
n=int(input())
lst=list(map(int,input().split()))
dp=[0]*n
dp[1]=abs(lst[0]-lst[1])
for i in range(2,n):
    dp[i]=min(dp[i-1]+abs(lst[i]-lst[i-1]),dp[i-2]+abs(lst[i]-lst[i-2]))
print(dp[n-1])

Buggy submission (verdict: Runtime Error):
n=int(input())
lst=list(map(int,input().split()))
dp=[0]*n
dp[1]=abs(lst[0]-lst[1])
for i in range(2,n):
    dp[i]=min(dp[i-1]+abs(lst[i]-lst[i-1]),dp[i-2]+abs(lst[i]-lst[i-2]))
print(dp[i-1])
Problem p03239 (python)

Fixed submission:
N,T=map(int,input().split())
ans=2000
for i in range(N):
    a=list(map(int,input().split()))
    if a[1]<=T:ans=min(ans,a[0])
print(ans if ans<2000 else "TLE")

Buggy submission (verdict: Runtime Error):
N,T=map(int,input().split())
s=2000
for i in range(N):
    a,b=map(int,input().split())
    if b<=T:s=min(s,a)
print(s if ans<2000 else "TLE")
Problem p03302 (python)

Fixed submission:
a,b=map(int,input().split())
if a+b==15:print("+")
elif a*b==15:print("*")
else:print("x")

Buggy submission (verdict: Runtime Error):
a,b=map(int,input().split())
if a+b=15:print("+")
elif a*b=15:print("*")
else:print("x")
Problem p03303 (python)

Fixed submission:
s=input()
n=int(input())
a=[]
for i in range(0,len(s),n):
	a.append(s[i])
print(*a,sep="")

Buggy submission (verdict: Runtime Error):
s=input()
n=input()
a=[]
for i in range(0,len(s),n):
	a.append(s[i])
print(*a,sep="")
Problem p03071 (python)

Fixed submission:
a, b = map(int, input().split())
if a > b :
  print(a + a -1)
elif a == b:
  print(a + b)
else:
  print(b + b - 1)

Buggy submission (verdict: Runtime Error):
a,b = map(int, input().split())
if a > b:
  print(2a - 1)
elif a == b:
  print(2a)
else:
  print(2b -1)

Buggy submission (verdict: Runtime Error):
a, b = map(int, input().split())
if a > b :
  print('a + a -1')
elif a = b:
  print('a + b')
else:
  print('b + b - 1')

Buggy submission (verdict: Runtime Error):
a, b = map(int, input().split())
if a >= b + 1:
  print(a + a -1)
elif a = b:
  print(a + b)
else:
  print(b + b - 1)
Problem p03085 (python)

Fixed submission:
b = input()
if b == 'A':
  print('T')
elif b == 'T':
  print('A')
elif b == 'C':
  print('G')
else:
  print('C')

Buggy submission (verdict: Runtime Error):
b = input()
if b = 'A':
  print'T'
elif b = 'T':
  print'A'
elif b = 'C':
  print'G'
else:
  print'C'
Problem p03352 (python)

Fixed submission:
X = int(input())

beki = 0
for p in range(2, 9):
    tmp = 0
    b = 1
    while tmp <= X:
        tmp = b**p
        if tmp > X:
            break
        beki = max(tmp, beki)
        b += 1

print(beki)

Buggy submission (verdict: Runtime Error):
x = input()
x = int(x)

answer = []
for p in range(2, x):

    for i in range(2, x):
        test = i**p
        if test > 1000:
            break
        if test > x:
            answer.append((i-1)**p)
            break
        elif test == x:
            answer.append(i**p)
            break

print(max(answer))

Buggy submission (verdict: Runtime Error):
x = input()
x = int(x)

answer = []
for p in range(2, 10):

    for i in range(1, x):
        if i**p > x:
            answer.append((i-1)**p)
            break
        elif pow(i, p) == x:
            answer.append(i**p)
            break

print(max(answer))
Problem p03373 (python)

Fixed submission:
a, b, c, x, y = map(int, input().split())

ans1 = a*x + b*y

if x >= y:
    ans2 = 2*c*y + a*(x-y)
    ans3 = 2*x*c
else:
    ans2 = 2*c*x + b*(y-x)
    ans3 = 2*y*c

print(min(min(ans1, ans2), ans3))

Buggy submission (verdict: Runtime Error):
a, b, c, x, y = map(int, input().split())

ans1 = a*x + b*y

if x > y:
    ans2 = 2*c*y + a*(x-y)
    ans3 = 2*x*c
else:
    ans2 = 2*c*x + b*(y-x))
    ans3 = 2*c*y

print(min(ans1, ans2), ans3)
Problem p03543 (python)

Fixed submission:
N = int(input())

thu = N // 1000
cto = (N - 1000*thu) // 100
ten = (N - 1000*thu - 100*cto) // 10
one = N % 10
if (one == ten == cto) or (ten == cto == thu) or (one ==ten == cto == thu):
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
a, b, c, d = map(int, input().split())

if abs(a - c) <= d:
    print("Yes")
    exit()

if abs(a - b) <= d and abs(b - c) <= d:
    print("Yes")
    exit()

print("No")
Problem p03544 (python)

Fixed submission:
N = int(input())

L = []
L.append(2)
L.append(1)
if N == 1:
    print(L[1])
else:
    for i in range(2, N+1):
        L.append(L[i-1] + L[i-2])
    print(L[N])

Buggy submission (verdict: Runtime Error):
x = input()
x = int(x)

answer = []
for p in range(2, 7):

    for i in range(1, x):
        test = i**p
        if test > x:
            answer.append((i-1)**p)
            break
        elif test == x:
            answer.append(i**p)
            break

print(max(answer))
Problem p03071 (python)

Fixed submission:
a,b = map(int,input().split())
coin = 0
if a>b:
    coin = 2*a-1
elif a ==b:
    coin = 2*a
elif b>a:
    coin =2*b-1
print(coin)

Buggy submission (verdict: Runtime Error):
a,b = map(int,input().split())
coin = 0
    if a>b:
        coin = 2a-1
    elif a ==b:
        coin = 2a
    elif b>a:
        coin =2b-1
print(coin)
Problem p03160 (python)

Fixed submission:
n = int(input())
h = [int(x) for x in input().split()]
inf = float('inf')
dp = [inf] * n  # initialize dp
dp[0] = 0
for i in range(1, n):
    if i == 1:
        dp[i] = abs(h[i] - h[i-1])
    elif (dp[i-1] + abs(h[i] - h[i-1])) < (dp[i-2] + abs(h[i] - h[i-2])):
        dp[i] = dp[i-1] + abs(h[i] - h[i-1])
    else:
        dp[i] = dp[i-2] + abs(h[i] - h[i-2])
print(dp[-1])

Buggy submission (verdict: Runtime Error):
n, K = map(int, input().split())
h = [int(x) for x in input().split()]
inf = float('inf')
dp = [inf] * n  # initialize dp
dp[0] = 0
for i in range(1, n):
    for k in range(1, K+1):
        if i - k >= 0:
            dp[i] = min(dp[i-k] + abs(h[i] - h[i-k]), dp[i])
        else:
            break
print(dp[-1])
Problem p03071 (python)

Fixed submission:
a,b = map(int,input().split())
if a < b:
  a,b = b,a
if a == b:
  print(a*2)
else:
  print(a*2-1)

Buggy submission (verdict: Runtime Error):
a = int(input())
b = int(input())
if a < b:
  swap(a,b)
if a == b:
  print(a*2)
else:
  print(a*2-1)

Buggy submission (verdict: Runtime Error):
a = input()
b = input()
if a < b:
  swap(a,b)
if a == b:
  print(a*2)
else:
  print(a*2-1)
Problem p03448 (python)

Fixed submission:
a = int(input())
b = int(input())
c = int(input())
x = int(input())

count = 0

for i in range(min(a,x//500)+1): #iは0,1,2...,x//500
    remains = x - 500 * i
    for j in range(min(b,remains//100)+1):
        Remains = remains - 100 * j
        for k in range(min(c,Remains//50)+1):
            fifty = Remains - 50 * k
            if fifty == 0:
                count = count + 1
            else: continue

print(count)

Buggy submission (verdict: Runtime Error):
a = int(input())
b = int(input())
c = int(input())
x = int(input())

count = 0

for i in range(x/c):
    y = x - 50*i
    if y = 0:
        count = count + 1
    else:
        z = y // 2
        count = count + z

print(count)

Buggy submission (verdict: Runtime Error):
a = int(input())
b = int(input())
c = int(input())
x = int(input())

print(x)

roop1 = x // a
count = 0

for i in roop1:
    roop2 = (x - 500*i) // b
    for j in roop2:
        roop3 = (x - 500*i - 100*j) // c
        count = count + 1

print(count)

Buggy submission (verdict: Runtime Error):
a = int(input())
b = int(input())
c = int(input())
x = int(input())

print(x)

roop1 = x // a
count = 0

for i in roop1:
    roop2 = (x - 500*i) // b
    for j in roop2:
        roop3 = (x - 500*i - 100*j) // c
        count = count + 1

print(count)
Problem p03071 (python)

Fixed submission:
AB = input().split()
A,B=int(AB[0]), int(AB[1])
if max(A,B)-min(A,B) >= 1:
  print(2*max(A,B)-1)
else:
  print(A+B)

Buggy submission (verdict: Runtime Error):
AB = int(input().split())
A,B=AB[0], AB[1]
if max(A,B)-min(A,B) >= 1:
  print(2*max(A,B)-1)
else:
  print(A+B)

Buggy submission (verdict: Runtime Error):
A,B = int(input()), int(input())
if max(A,B)-min(A,B) >= 1:
  print(2*max(A,B)-1)
else:
  print(A+B)
Problem p03076 (python)

Fixed submission:
A,B,C,D,E=int(input()),int(input()),int(input()),int(input()),int(input())
orders = {'A': A, 'B': B, 'C': C, 'D': D, 'E': E}
orders = sorted(orders.items(), key=lambda item: (10 if item[1] % 10 == 0 else item[1] % 10), reverse=True)
res = 0
while orders:
  if res % 10 != 0:
    res += (10 - res % 10)
  order = orders.pop(0)
  res += order[1]
print(res)

Buggy submission (verdict: Runtime Error):
A,B,C,D,E=int(input()),int(input()),int(input()),int(input()),int(input())
orders = {'A': A, 'B': B, 'C': C, 'D': D, 'E': E}
orders = sorted(orders.items(), key=lambda item: item[1] % 10, reverse=True)
res = 0
while orders:
  if res % 10 != 0:
    res += (10 - res % 10)
  order = orders.pop(0)
  res += order
print(res)
Problem p03071 (python)

Fixed submission:
def main():
    l = list(map(int, input().split()))
    if max(l) != min(l):
        print((max(l) * 2) - 1)
    else:
        print(max(l) * 2)
    

if __name__ == "__main__":
  main()

Buggy submission (verdict: Runtime Error):
class CreateList:
    def __init__(self, flg, cnt):
        self.flg = flg
        self.cnt = cnt
        
        

def main():
    
    n, k = map(int, input().split())
    s = list(map(int, input()))
    
    slist = []      #Sを使いやすいように加工した配列
    bkflg = s[0]    #一つ前の連続する値が「1」か「0」かを持ってるやつ
    scnt = 0        #「1」「0」の連続する数
    ecnt = 0        #終了判定のカウンター
    
    #配列作成
    for i in s:
        ecnt += 1
        
        #同じ数字が続く場合はカウントアップ
        if i == bkflg:
           scnt += 1
        
        #数字が変わったら配列にこれまでの合計数を入れてカウンターを初期化
        else:
            slist.append(CreateList(bkflg, scnt))
            scnt = 1
            bkflg = i
        
        #最後の1回が拾えないのでここで強引に配列に突っ込む
        if ecnt == len(s):
            slist.append(CreateList(bkflg, scnt))
    
    #本ちゃんで使う勇者たち
    maxsum = 0      #最大合計値の変数
    skipcnt = k     #連続する「0」を「1」としてカウント出来る回数
    cursor = 0      #Sの配列変数の開始位置
    cursorsum = 0   #一時的な「1」の合計数
    tmpcnt = 0      #一時的なカーソル位置
    
    #本ちゃんスタート
    while tmpcnt <= len(slist) - 1:
        #Sの配列を左からスライドしながら数字を拾ってくので、最初にカウンターとカーソル位置を初期化
        tmpcnt = cursor
        skipcnt = k
        cursorsum = 0
        
        #ここで「1」の合計をSの配列の左からスライドさせながらカウントしていく
        while tmpcnt <= len(slist) - 1:
            if slist[tmpcnt].flg == 0:
                if skipcnt == 0:
                    break
                else:
                    skipcnt -= 1
            
            cursorsum = cursorsum + slist[tmpcnt].cnt
            tmpcnt += 1
        
        #これまでの最大合計数を拾う
        if maxsum < cursorsum:
            maxsum = cursorsum
        
        cursor += 1
        
    print(maxsum)
    
    
if __name__ == "__main__":
    main()
Problem p03071 (python)

Fixed submission:
a, b = map(int, input().split())
coin = 0
for i in range(2):
    if a > b:
        coin += a
        a -= 1
    else:
        coin += b
        b -= 1

print(coin)

Buggy submission (verdict: Runtime Error):
a,b=map(int,input().split())
print(max(max(a,b)-1,min(a,b))+e)

Buggy submission (verdict: Runtime Error):
print(max(max(a,b)-1,min(a,b))+e)
Problem p03076 (python)

Fixed submission:
a2, b, c, d, e= [int(input()) for i in range(5)]
a=[a2,b,c,d,e]
sum = 0;
res = 0; 
temp = 0;
num = 0;
for i in range(5):
  if(a[i]%10==0):
    sum+=a[i]
  else:
    temp = (int(a[i]/10) +1)*10-a[i];
    #print(temp)
    if temp>res:
      sum = sum + res 
      res =temp
      sum+=a[i]
     # print(sum)
    else:
      sum = sum+a[i]+temp
      #print(sum)
print(int(sum))

Buggy submission (verdict: Runtime Error):
a = [int(i) for i in input().split()] 
sum = 0;
res = 0; 
temp = 0;
num = 0;
for i in range(5):
  if(a[i]%10==0):
    sum+=a[i]
  else:
    temp = (a[i]%10 +1)*10-a[i];
    if temp>res:
      sum = sum + res 
      res =temp
      sum+=a[i]
    else:
      sum = sum+a[i]+temp
print(sum)
Problem p03078 (python)

Fixed submission:
import heapq
 
_x, _y, _z, k = map(int, input().split())
aa = list(reversed(sorted(map(int, input().split()))))
bb = list(reversed(sorted(map(int, input().split()))))
cc = list(reversed(sorted(map(int, input().split()))))
 
ar = []
history = set()
 
 
def push(x, y, z):
    if (x, y, z) in history:
        pass
    else:
        v = aa[x] + bb[y] + cc[z]
        heapq.heappush(ar, (-v, x, y, z))
        history.add((x, y, z))
 
 
def pop():
    (v, x, y, z) = heapq.heappop(ar)
    return (-v, x, y, z)
 
 
push(0, 0, 0)
for _ in range(k):
    (total, x, y, z) = pop()
    print(total)
    if x + 1 < len(aa):
        push(x + 1, y, z)
    if y + 1 < len(bb):
        push(x, y + 1, z)
    if z + 1 < len(cc):
        push(x, y, z + 1)

Buggy submission (verdict: Runtime Error):
import heapq
 
_x, _y, _z, k = map(int, input().split())
aa = list(reversed(sorted(map(int, input().split()))))
bb = list(reversed(sorted(map(int, input().split()))))
cc = list(reversed(sorted(map(int, input().split()))))

ab=[]
for i in range(_x):
  for j in range(_y):
    ab.append(aa[i]+bb[j])

ab.sort()
hq=[]
for z in range(_z):
  for l in range(_x*_y):
    temp = cc[z] + ab[l] 
    if len(hq) < k:
      heapq.heappush(hq,temp)
    else:
      heapq.heapreplace[hq,temp]
hq.sort()
for i in range(k):
  print(hq[k-1-i])

Buggy submission (verdict: Runtime Error):
import heapq
 
_x, _y, _z, k = map(int, input().split())
aa = list(reversed(sorted(map(int, input().split()))))
bb = list(reversed(sorted(map(int, input().split()))))
cc = list(reversed(sorted(map(int, input().split()))))

ab=[]
for i in range(_x):
  for j in range(_y):
    ab.append(aa[i]+bb[j])

ab.sort()
hq=[]
for z in range(_z):
  for l in range(_x*_y):
    temp = cc[z] + ab[l] 
    if len(hq) < k:
      heapq.heappush(hq,temp)
    else:
      heapq.heapreplace[hq,temp]
for i in range(k):
  print(hq[k-1-i])

Buggy submission (verdict: Runtime Error):
import heapq
 
_x, _y, _z, k = map(int, input().split())
aa = list(reversed(sorted(map(int, input().split()))))
bb = list(reversed(sorted(map(int, input().split()))))
cc = list(reversed(sorted(map(int, input().split()))))

ab=[]
for i in range(_x):
  for j in range(_y):
    ab.append(aa[i]+bb[j])

ab.sort()
hq=[]
for z in range(_z):
  for l in range(_x*_y):
    temp = cc[z] + ab[l] 
    if len(hq) < k:
      heapq.heappush(hq,temp)
    else:
      heapq.heapreplace[hq,temp]
for i in range(k):
  print(hq[k-i])

Buggy submission (verdict: Runtime Error):
import heapq
 
_x, _y, _z, k = map(int, input().split())
aa = list(reversed(sorted(map(int, input().split()))))
bb = list(reversed(sorted(map(int, input().split()))))
cc = list(reversed(sorted(map(int, input().split()))))

ab=[]
for i in range(_x):
  for j in range(_y):
    ab.append(aa[i]+bb[j])

ab.sort()
hq=[]
for z in range(_z):
  for l in range(_x*_y):
    temp = cc[z] + ab[l] 
    if hq.size() < k:
      heapq.push(hq,temp)
    else:
      heapq.heapreplace[hq,temp]
for i in range(k):
  print(hq[k-i])
Problem p03244 (python)

Fixed submission:
def main():
    N = int(input())
    v = list(map(int, input().split()))
    v_ki = v[1:N:2].copy()
    val_ki = [i+1 for i in range(10**5)]
    count_ki = [0] * (10**5)
    v_gu = v[0:N:2].copy()
    val_gu = [i+1 for i in range(10**5)]
    count_gu = [0] * (10**5)
    for i in range(N//2):
        count_ki[v_ki[i]-1] += 1
        count_gu[v_gu[i]-1] += 1
    
    ki = list(zip(count_ki, val_ki))
    ki.sort()
    gu = list(zip(count_gu, val_gu))
    gu.sort()
    if ki[-1][1] != gu[-1][1]:
        return N-ki[-1][0]-gu[-1][0]
    else:
        return min(N-ki[-2][0]-gu[-1][0], N-ki[-1][0]-gu[-2][0])

if __name__ == "__main__":
    print(main())

Buggy submission (verdict: Runtime Error):
def main():
    N = int(input())
    v = list(map(int, input().split()))
    v_ki = v[1:N:2].copy()
    val_ki = [i+1 for i in range(10**5)]
    count_ki = [0] * (10**5)
    v_gu = v[0:N:2].copy()
    val_gu = [i+1 for i in range(10**5)]
    count_gu = [0] * (10**5)
    for i in range(N//2):
        count_ki[v_ki[i]] += 1
        count_gu[v_gu[i]] += 1
    
    ki = list(zip(count_ki, val_ki))
    ki.sort()
    ki_len = len(ki)
    gu = list(zip(count_gu, val_gu))
    gu.sort()
    gu_len = len(gu)
    if ki[-1][1] != gu[-1][1]:
        return N-ki[-1][0]-gu[-1][0]
    else:
        return min(N-ki[-2][0]-gu[-1][0], N-ki[-1][0]-gu[-2][0])

if __name__ == "__main__":
    print(main())

Buggy submission (verdict: Runtime Error):
def main():
    N = int(input())
    v = list(map(int, input().split()))
    v_ki = v[1:N:2].copy()
    val_ki = [i+1 for i in range(10**5)]
    count_ki = [0] * (10**5)
    v_gu = v[0:N:2].copy()
    val_gu = [i+1 for i in range(10**5)]
    count_gu = [0] * (10**5)
    for i in range(N//2):
        count_ki[v_ki[i]] += 1
        count_gu[v_gu[i]] += 1
    
    ki = list(zip(count_ki, val_ki))
    ki.sort()
    ki_len = len(ki)
    gu = list(zip(count_gu, val_gu))
    gu.sort()
    gu_len = len(gu)
    if ki[-1][1] != gu[-1][1]:
        return N-(ki[-1][0])-(gu[-1][0])
    elif ki_len == gu_len:
        return N//2
    else:
        return min(N-(ki[-2][0])-(gu[-1][0]), N-(ki[-1][0])-(gu[-2][0]))

if __name__ == "__main__":
    print(main())
Problem p03469 (python)

Fixed submission:
S = input()

print("2018" + S[4:])

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

# Y = 10000*x + 5000*y + 1000*z
# N = x + y + z
flag = 0
x = 0
y = 0
z = 0

if Y % 1000 != 0:
   flag = 1
elif Y > 10000*N:
   flag = 1
elif Y % 10000 == 0:
   x = Y//10000
else :
   x = Y//10000
   while True:
      for y in range(N-x+1):
         z = N-x-y
         if Y == 10000*x + 5000*y + 1000*z:
            flag = -1
            break
      if flag == -1:
         break
      elif x ==0:
         flag = 1
         break
      x = x-1
      
            

if flag == 1:
   print("-1 -1 -1")

else :
   print(str(x)+" "+str(y)+" "+str(z))
Problem p03480 (python)

Fixed submission:
def main():
    S = input()
    S_l = len(S)
    T = []

    for i in range(S_l-1):
        if S[i] != S[i+1]:
            T.append(max([i+1, S_l-i-1]))

    if T != []:
        return min(T)
    else:
        return S_l

if __name__ == '__main__':
    print(main())

Buggy submission (verdict: Runtime Error):
def sokutei(s):
    b = [1,]
    for t in range(1, len(s)):
        if s[t] == s[t-1]:
            b[-1] += 1
        else:
            b.append(1)
    return max(b)

def main():
    S = input()
    B = sokutei(S)

    for K in range(len(S), 1, -1):
        a = [1,]
        for i in range(len(S) - K):
            s = ""
            for j in range(len(S)):
                if j<i or j>(i+K):
                    s += S[j]
                else:
                    if S[j]=="1":
                        s += "0"
                    else:
                        s += "1"
            a.append(sokutei(s))
        if B < max(a):
            return K+1
    return K

if __name__ == '__main__':
    print(main())
Problem p03557 (python)

Fixed submission:
def main():
    N = int(input())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))
    C = list(map(int, input().split()))
    A.sort()
    B.sort()
    C.sort()

    count = 0
    Ai = -1
    Ci = -1
    for i in range(N):
        if Ai<N-1:
            while A[Ai+1]<B[i]:
                Ai += 1
                if Ai == N-1:
                    break
        if Ci<N-1:
            while C[Ci+1]<=B[i]:
                Ci += 1
                if Ci==N-1:
                    break
        count += (Ai+1) * (N-(Ci+1))

    return count

if __name__ == '__main__':
    print(main())

Buggy submission (verdict: Runtime Error):
def main():
    N = int(input())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))
    C = list(map(int, input().split()))
    A.sort()
    B.sort()
    C.sort()

    count = 0
    Ai = -1
    Ci = -1
    for i in range(N):
        if Ai<N-1:
            while A[Ai+1]<B[i]:
                Ai += 1
                if Ai == N-1:
                    break
        if Ci<N:
            while C[Ci+1]<=B[i]:
                Ci += 1
                if Ci==N-1:
                    break
        count += (Ai+1) * (N-(Ci+1))

    return count

if __name__ == '__main__':
    print(main())