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

Fixed submission:
N=int(input())
array=map(int,input().split())
A=[]
for i in array:
    A.append(i)

dict_num={i:0 for i in range(100050)}
Q=int(input())
matrix=[]
for i in range(Q):
    matrix.append(list(map(int,input().split())))

#全数値の合計計算
sum=0
#各数字の出現回数の計測
for i in range(N):
    dict_num[A[i]]+=1
    sum+=A[i]

#合計の再計算 & 数字の出現回数の再計算
for i in matrix:
    sum+=(i[1]-i[0])*dict_num[i[0]]
    dict_num[i[1]]+=dict_num[i[0]]
    dict_num[i[0]]=0
    print(sum)

Buggy submission (verdict: Runtime Error):
N=int(input())
array=map(int,input().split())
A=[]
for i in array:
    A.append(i)

dict_num={i:0 for i in range(100000)}

Q=int(input())
matrix=[]
for i in range(Q):
    matrix.append(list(map(int,input().split())))

#全数値の合計計算
sum=0
#各数字の出現回数の計測
for i in range(len(A)):
    dict_num[A[i]]+=1
    sum+=A[i]

#合計の再計算 & 数字の出現回数の再計算
for i in matrix:
    sum+=(i[1]-i[0])*dict_num[i[0]]
    dict_num[i[1]]+=dict_num[i[0]]
    dict_num[i[0]]=0
    print(sum)
Problem p02642 (python)

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

M=1000050

dp=[0 for i in range(M)]

ans=0
for x in A:
    if dp[x]!=0:
        dp[x]=2
        continue
    for i in range(x,M,x):
        dp[i]+=1

for x in A:
    if dp[x]==1:
        ans+=1

print(ans)

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

A=[]
array=sorted(array)
for i in array:
    A.append(i)

dp=[True for i in range(N)]

if A[0]==A[1]:
    dp[0]=False
for i in range(N):
    if dp[i] == False:
        continue
    for j in range(i+1,N):
        if A[j]%A[i]==0:
            dp[j]=False

num=0
for i in range(N):
    if dp[i] == True:
        num+=1

print(num)

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

A=[]
array=sorted(array)
for i in array:
    A.append(i)

dp=[True for i in range(N)]

if A[0]==A[1]:
    dp[0]=False
for i in range(N):
    for j in range(i+1,N):
        if A[j]%A[i]==0:
            dp[j]=False

num=0
for i in range(N):
    if dp[i] is True:
        num+=1

print(num)
Problem p02684 (python)

Fixed submission:
N,K=map(int,input().split())

array=map(int,input().split())

A=list(array)
A.insert(0,0)

visit=0
root=[]
visited=1
once=0
while True:
    if visit & (0b1<<visited):
        break
    root.append(visited)
    visit|=0b1<<visited
    once+=1
    visited=A[visited]

roop=root[root.index(visited):]
if K<once:
    print(root[K])
else:
    order=K-once
    print(roop[order%len(roop)])

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

array=map(int,input().split())

A=list(array)
A.insert(0,0)

visit=0
root=[]
visited=1
once=0
while True:
    if visit & (0b1<<visited):
        break
    root.append(visited)
    visit|=0b1<<visited
    once+=1
    visited=A[visited]

roop=root[root.index(visited):]
if K<=once:
    print(root[K])
else:
    order=K-once
    print(roop[order%len(roop)])

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

array=map(int,input().split())

A=list(array)
A.insert(0,0)

visit=0
root=[]
visited=1
once=0
while True:
    if visit & (0b1<<visited):
        break
    root.append(visited)
    visit|=0b1<<visited
    once+=1
    visited=A[visited]

roop=root[root.index(visited):]
print(roop)
if K<=once:
    print(root[K])
else:
    order=K-once
    print(roop[order%len(roop)])
Problem p02690 (python)

Fixed submission:
NUM=1000

X=int(input())

flg=False

for i in reversed(range(NUM)):
    for j in range(-1*NUM,NUM):
        res=(i**5)-(j**5)
        if res==X:
            ans_A=i
            ans_B=j
            flg=True
            break
    if flg:
        break

print(ans_A,ans_B)

Buggy submission (verdict: Runtime Error):
NUM=100

X=int(input())

flg=False

for i in reversed(range(NUM)):
    for j in range(-1*NUM,NUM):
        res=(i**5)-(j**5)
        if res==X:
            ans_A=i
            ans_B=j
            flg=True
            break
    if flg:
        break

print(ans_A,ans_B)

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

for i in range(100):
    for j in range(-100,100):
        ans=pow(i,5)-pow(j,5)
        if ans==X:
            ans_a=i
            ans_b=j

print(ans_a,ans_b)
Problem p02755 (python)

Fixed submission:
A,B=map(int,input().split())
 
ans=-1
for x in range(1000+1):
    if int(x*(8/100))==A and int(x*(10/100))==B:
        ans=x
        break

print(ans)

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

x_max=int((100/8)*(A+1))
x_min=int((100/8)*A)

if x_min==x_max:
    x=x_min
for i in range(x_min,x_max+1):
    if int(i*(1/10))==B:
        x=i
        break

if x<0 or 100<x:
    print("-1")
else:
    print(x)
Problem p02761 (python)

Fixed submission:
N,M=map(int,input().split())

pos=[]
for i in range(M):
    array=list(map(int,input().split()))
    pos.append(array)

flg=True
num=[-1 for i in range(N)]

for i in range(M):
    if num[pos[i][0]-1]==-1 or num[pos[i][0]-1]==pos[i][1]:
        if pos[i][0]-1!=0 or pos[i][1]!=0:
            num[pos[i][0]-1]=pos[i][1]
        else:
            if N==1:
                num[pos[i][0]-1]=pos[i][1]
            else:
                flg=False
    else:
        flg=False

for i in range(len(num)):
    if num[i]==-1:
        if i==0:
            if N==1:
                num[i]=0
            else:
                num[i]=1
        else:
            num[i]=0

ans=0
for i in range(N):
    ans+=num[i]*10**(N-i-1)

if flg:
    print(ans)
else:
    print("-1")

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

pos=[]
for i in range(M):
    array=list(map(int,input().split()))
    pos.append(array)

flg=True
num=[-1 for i in range(N)]

for i in range(M):
    if num[pos[i][0]-1]==-1 or num[pos[i][0]]==pos[i][1]:
        if i!=0 or pos[i][1]!=0:
            num[pos[i][0]-1]=pos[i][1]
        else:
            flg=False
    else:
        flg=False

for i in range(len(num)):
    if num[i]==-1:
        if i==0:
            num[i]=1
        else:
            num[i]=0

ans=0
for i in range(N):
    ans+=num[i]*10**(N-i-1)

if flg:
    print(ans)
else:
    print("-1")
Problem p02639 (python)

Fixed submission:
a,b,c,d,e = map(int, input().split())
lis = [a,b,c,d,e]
for i,n in enumerate(lis):
  if n==0:
    print(i+1)

Buggy submission (verdict: Runtime Error):
x,n = map(int, input().split())
p = list(map(int, input().split()))
if n == 0:
  print(x)
elif n == 1:
  if x == p:
    print(x-1)
  else:
    print(x)
else:
  p.sort()
  m = float("inf")
  if x<p[0] or p[n-1]<x:
    print(x)
  else:
    for y in [y for y in range(p[0]-1,p[n-1]) if not y in p]:
      if abs(x-y)<m:
        m = abs(x-y)
        ans_y = y
  print(ans_y)

Buggy submission (verdict: Runtime Error):
x,n = map(int, input().split())
p = list(map(int, input().split()))
if n == 0:
  print(x)
elif n == 1:
  if x == p:
    print(x-1)
  else:
    print(x)
else:
  p.sort()
  m = float("inf")
  if x<p[0] or p[n-1]<x:
    print(x)
  else:
    for y in [y for y in range(p[0]-1,p[n-1]) if not y in p]:
      if abs(x-y)<m:
        m = abs(x-y)
        ans_y = y
  print(ans_y)
Problem p02641 (python)

Fixed submission:
x,n = map(int, input().split())
ans_y = None
if n == 0:
  print(x)
elif n == 1:
  p = list(map(int, input().split()))
  if x == p[0]:
    print(x-1)
  else:
    print(x)
else:
  p = list(map(int, input().split()))
  p.sort()
  m = float("inf")
  if x<p[0] or p[n-1]<x:
    print(x)
  else:
    for y in [y for y in range(p[0]-1,p[n-1]+2) if not y in p]:
      if abs(x-y)<m:
        m = abs(x-y)
        ans_y = y
  if ans_y != None:
    print(ans_y)

Buggy submission (verdict: Runtime Error):
x,n = map(int, input().split())
p = list(map(int, input().split()))
p.sort()
m = float("inf")
if x<int(p[0]) or int(p[n-1])<x:
  print(x)
else:
  for y in [y for y in range(p[0]-1,p[n-1]) if not y in p]:
    if abs(x-y)<m:
      m = abs(x-y)
      ans_y = y
  print(ans_y)
Problem p02660 (python)

Fixed submission:
import collections
N = int(input())
# = map(int, input().split())
# = list(map(int, input().split()))
# = [int(input()) for i in range(N)]
# = [list(map(int, input().split())) for i in range(N)]
count = 0

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

c = collections.Counter(prime_factorize(N))
C = list(c.items())

if len(list(c.keys()))==1:
    for j in range(1, C[0][1]+1):
        if N%(C[0][0]**j) == 0:
            count += 1
            N /= C[0][0]**j

else:
    for i in range(len(C)):
        for j in range(1, C[i][1]+1):
            if N%(C[i][0]**j) == 0:
                count += 1
                N /= (C[i][0]**j)

print(count)

Buggy submission (verdict: Runtime Error):
import sympy

N = int(input())
# = map(int, input().split())
# = list(map(int, input().split()))
# = [int(input()) for i in range(N)]
# = [list(map(int, input().split())) for i in range(N)]

count = 0
z = sympy.divisors(N)

if N == 1:
    print(0)
    exit()

elif len(z) == 2:
    print(1)
    exit()

else:
    for i in range(1, len(z)):
        if N%z[i] == 0:
            count += 1
            N = N/z[i]

print(count)
Problem p02683 (python)

Fixed submission:
import itertools
import numpy as np

# = int(input())
N, M, X = map(int, input().split())
# = list(map(int, input().split()))
# = [int(input()) for i in range(N)]
CA = [list(map(int, input().split())) for i in range(N)]

cost = []

skill = list(zip(*CA))

for i in range(1, M+1):
    if sum(skill[i]) < X:
        print(-1)
        exit()

for i in range(1, N+1):
    for balls in list(itertools.combinations(CA, i)):
        test = np.zeros(M+1)
        for j in balls:
            jtest = np.asarray(j)
            test = test + jtest

        if min(test[1:])>=X:
            cost.append(test[0])

print(int(min(cost)))

Buggy submission (verdict: Runtime Error):
import itertools
import numpy as np

# = int(input())
N, M, X = map(int, input().split())
# = list(map(int, input().split()))
# = [int(input()) for i in range(N)]
CA = [list(map(int, input().split())) for i in range(N)]

cost = []

skill = list(zip(*CA))

for i in range(1, M+1):
    if sum(skill[i]) < X:
        print(-1)
        exit()

for i in range(1, N):
    for balls in list(itertools.combinations(CA, i)):
        test = np.zeros(M+1)
        for j in balls:
            jtest = np.asarray(j)
            test = test + jtest

        if min(test[1:])>=X:
            cost.append(test[0])

print(int(min(cost)))

Buggy submission (verdict: Runtime Error):
import itertools
import numpy as np

# = int(input())
N, M, X = map(int, input().split())
# = list(map(int, input().split()))
# = [int(input()) for i in range(N)]
CA = [list(map(int, input().split())) for i in range(N)]

cost = []

skill = list(zip(*CA))

for i in range(1, M+1):
    if sum(skill[i]) < X:
        print(-1)
        exit()

for i in range(N):
    for balls in list(itertools.combinations(CA, i)):
        test = np.zeros(M+1)
        for j in balls:
            jtest = np.array(j)
            test = test + jtest

        if min(test[1:])>=X:
            cost.append(test[0])

print(int(min(cost)))

Buggy submission (verdict: Runtime Error):
import itertools
import numpy as np

# = int(input())
N, M, X = map(int, input().split())
# = list(map(int, input().split()))
# = [int(input()) for i in range(N)]
CA = [list(map(int, input().split())) for i in range(N)]

cost = []

nums=[]
for i in range(1, M+1):
    nums.append(i)

skill = list(zip(*CA))

for i in range(1, M+1):
    if sum(skill[i]) < X:
        print(-1)
        exit()

for i in range(N):
    for balls in list(itertools.combinations(CA, i)):
        test = np.zeros(M+1)
        for j in balls:
            jtest = np.asarray(j)
            test = test + jtest

        if min(test[1:])>=X:
            cost.append(test[0])

print(int(min(cost)))
Problem p02690 (python)

Fixed submission:
X = int(input())
# = map(int, input().split())
# = list(map(int, input().split()))
A = [i**5 for i in range(200)]
B = [i**5 for i in range(200)]
# = [list(map(int, input().split())) for i in range(N)]

for i in range(200):
    for j in range(200):
        if A[i] + B[j] == X:
            print(int(A[i]**(1/5)), int(B[j]**(1/5)*(-1)))
            exit()
        if A[i] - B[j] == X:
            print(int(A[i]**(1/5)), int(B[j]**(1/5)))
            exit()

Buggy submission (verdict: Runtime Error):
X = int(input())
# = map(int, input().split())
# = list(map(int, input().split()))
# = [int(input()) for i in range(N)]
# = [list(map(int, input().split())) for i in range(N)]

for i in range(100000):
    C = X + (i**5)
    if C**(1/5)%1 ==0:
        print(int(C**(1/5)), i)
        break
    C = X - (i**5)
    if C**(1/5)%1 ==0:
        print(int(C**(1/5)), -i)
        break

Buggy submission (verdict: Runtime Error):
import sys
X = int(input())
# = map(int, input().split())
# = list(map(int, input().split()))
# = [int(input()) for i in range(N)]
# = [list(map(int, input().split())) for i in range(N)]

for i in range(100000):
    C = X + (i**5)
    if C**(1/5)%1 ==0:
        print(int(C**(1/5)), i)
        sys.exit()
    C = X - (i**5)
    if C**(1/5)%1 ==0:
        print(int(C**(1/5)), -i)
        sys.exit()

Buggy submission (verdict: Runtime Error):
import sys
X = int(input())
# = map(int, input().split())
# = list(map(int, input().split()))
# = [int(input()) for i in range(N)]
# = [list(map(int, input().split())) for i in range(N)]

for i in range(1000000000):
    C = X + (i**5)
    if C**(1/5)%1 ==0:
        print(int(C**(1/5)), i)
        sys.exit()
    C = X - (i**5)
    if C**(1/5)%1 ==0:
        print(int(C**(1/5)), -i)
        sys.exit()
Problem p02696 (python)

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

if B-1>N:
    answer = (A*N/B)//1 - A*((N/B)//1)

else:
    answer = (A*(B-1)/B)//1 - A*(((B-1)/B)//1)

print(int(answer))

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

if B-1>N:
    answer = (A*N/B)//1 - A*((N/B)//1)

if A > B:
    answer = (A*(B-1)/B)//1 - A*(((B-1)/B)//1)

print(int(answer))
Problem p02742 (python)

Fixed submission:
H, W = map(int, input().split())

if H==1 or W==1:
  Answer =1

elif W%2 ==0:
  Answer = W/2*H
  
else:
  count = (W-1)/2 +1
  if H%2 ==0:
    Answer = count*H - H/2
  else:
    Answer = count*H - (H-1)/2

print(int(Answer))

Buggy submission (verdict: Runtime Error):
H, W = map(int, input().split())

List = list(range(W))
count = 0

for i in range(W):
    if List[i]%2 == 0:
      count +=1

if W%2 ==0:
  Answer = count*H
else:
  if H%2 ==0:
    Answer = count*H - H/2
  else:
    Answer = count*H - (H-1)/2

print(int(Answer))

Buggy submission (verdict: Runtime Error):
H, W = map(int, input().split())

List = list(range(W))
count = 0

for i in range(W):
    if List[i]%2 == 0:
      count +=1

if W%2 ==0:
  Answer = count*H
else:
  if H%2 ==0:
    Answer = count*H - H/2
  else:
    Answer = count*(H-1) - (H-1)/2 + count

print(int(Answer))

Buggy submission (verdict: Runtime Error):
H, W = map(int, input().split())

List = list(range(W))
count = 0

for i in range(W):
    if List[i]%2 == 0:
      count +=1

if W%2 ==0:
  Answer = count*H
else:
  if H%2 ==0:
    Answer = count*H - H/2
  else:
    Answer = count*(H-1) - (H-1)/2 + count

print(Answer)
Problem p02843 (python)

Fixed submission:
X = int(input())
number = X//100
teen = X%100

if teen <= 5*number:
    print(1)
else:
    print(0)

Buggy submission (verdict: Runtime Error):
X = int(input())
number = X//100
teen = X%100

elif teen <= 5*number:
    print(1)
else:
    print(0)
Problem p02922 (python)

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

if B ==1:
  print(0)

else:
  for i in range(19):
    if B <= A + (A-1)*i:
      print(i + 1)
      break

Buggy submission (verdict: Runtime Error):
A = int(input())
B = int(input())

for i in range(25):
  if B <= A + (A-1)*i:
    print(i + 1)
    break

Buggy submission (verdict: Runtime Error):
A = int(input())
B = int(input())
int i = 0

for i in range(25):
  if B <= A + (A-1)*i:
    print(i + 1)
    break
  else:
Problem p03076 (python)

Fixed submission:
import math

A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())
# = map(int, input().split())
# = list(map(int, input().split()))
# = [list(map(int, input().split())) for i in range(N)]
List = [A, B, C, D, E]
Time = []
Cost = []
answer = 0

for i in range(5):
    Time.append(List[i]%10)
    Cost.append(math.ceil(List[i]/10)*10)

for i in range(5):
    answer += Cost[i]

if Time.count(0)==5:
    print(answer)

else:
    Time = list(set(Time))
    if Time[0] == 0:
        Time.remove(0)

    answer = answer - (10-min(Time))

    print(answer)

Buggy submission (verdict: Runtime Error):
import math

A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())
# = map(int, input().split())
# = list(map(int, input().split()))
# = [list(map(int, input().split())) for i in range(N)]
List = [A, B, C, D, E]
Time = []
Cost = []
answer = 0

for i in range(5):
    Time.append(List[i]%10)
    Cost.append(math.ceil(List[i]/10)*10)

for i in range(5):
    answer += Cost[i]

Time = list(set(Time))
if Time[0] == 0:
    Time.remove(0)

answer = answer - (10-min(Time))

print(answer)
Problem p03624 (python)

Fixed submission:
import string

S = list(map(str, input()))
s = sorted(set(S))
count = 0

alphabet = string.ascii_lowercase

if len(s) == len(alphabet):
    print("None")

else:
    for i in range(len(s)):
        if s[i] != alphabet[i]:
            print(alphabet[i])
            break
        else:
            count += 1

if count == len(s):
    print(alphabet[len(s)])

Buggy submission (verdict: Runtime Error):
import string

S = list(map(str, input()))
s = sorted(set(S))

alphabet = string.ascii_lowercase

if len(s) == len(alphabet):
    print("None")

else:
    for i in range(30):
        if s[i] != alphabet[i]:
            print(alphabet[i])
            break

Buggy submission (verdict: Runtime Error):
import string

S = list(map(str, input()))

s = sorted(set(S))

alphabet = string.ascii_lowercase

if len(s) == len(alphabet):
    print("None")
else:

    for i in range(53):
        if s[i] != alphabet[i]:
            print(alphabet[i])
            break
Problem p02658 (python)

Fixed submission:
n=int(input())
p=list(map(int, input().split()))
i=0
ans=1
flag=0
k=1e18
while(n>i):
	if(p[i]==0):
		flag=1
	i+=1
if(flag==1):
	print(0)
else:
	flag=0
	i=0			
	while(n>i):
		ans*=p[i]
		if(ans>k):
			flag=1
			break
		i+=1		
	if( flag==1):
		print(-1)
	else:
		print(ans)

Buggy submission (verdict: Runtime Error):
#include <bits/stdc++.h>
using namespace std; 
typedef long long int  ll;
#pragma GCC optimize("O3")
#define pb push_back

int32_t main()  {
    ios::sync_with_stdio(false);
    cin.tie(0);
	int n ;
	cin >> n ;
	ll ans = 1;
	ll k = 1000000000000000000;
	int fl =0;
	while ( n--)
	{
		ll in ;
		cin >> in;
		ans=ans*in;
		if(ans>k) {
			fl=1;}
		if(in==0){
			ans=0;
		}
		if(ans!=0)	
		if((k/ans)>in) {
			fl=1;
		}	
	}
	if(	fl==1 and ans!=0)
	cout<<-1<<endl;
	else
	cout << ans;
}
Problem p02603 (python)

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

money = 1000
for x, y in zip(a[:-1], a[1:]):
    if x < y:
        stocks = money // x
    else:
        stocks = 0
    money += (y - x) * stocks

print(money)

Buggy submission (verdict: Runtime Error):
orz
Problem p02639 (python)

Fixed submission:
x = list(map(int, input().split()))
print(15 - sum(x))

Buggy submission (verdict: Runtime Error):
from bisect import bisect_left, bisect_right

n = int(input())
a = list(map(int, input().split()))
a.sort()
m = a[-1]
c = [0] * (m + 1)

for ai in a:
    for i in range(ai, m + 1, ai):
        if bisect_right(a, i) - bisect_left(a, i) == 1:
            c[i] += 1

print(c.count(1))
Problem p02850 (python)

Fixed submission:
import sys
sys.setrecursionlimit(10 ** 6)

n = int(input())
links = [[] for _ in range(n)]
colors = [0] * (n - 1)

for i in range(n - 1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    links[a].append((b, i))

def dfs(a, color):
    c = 1
    for b, i in links[a]:
        if c == color:
            c += 1
        colors[i] = c
        dfs(b, c)
        c += 1


dfs(0, 0)
print(max(colors))
for color in colors:
    print(color)

Buggy submission (verdict: Runtime Error):
n = int(input())
links = [[] for _ in range(n)]
colors = [0] * (n - 1)

for i in range(n - 1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    links[a].append((b, i))

def dfs(a, color):
    c = 1
    for b, i in links[a]:
        if c == color:
            c += 1
        colors[i] = c
        dfs(b, c)
        c += 1


dfs(0, 0)
print(max(colors))
for color in colors:
    print(color)
Problem p02971 (python)

Fixed submission:
n = int(input())
a = [int(input()) for _ in range(n)]

b = sorted(a, reverse=True)
max1 = b[0]
max2 = b[1]

for ai in a:
    if ai != max1:
        print(max1)
    else:
        print(max2)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
b = [0] * n

for i in reversed(range(n)):
    for j in range(i + 1, n, i + 1):
        x = 1
        k = j
        while k < n:
            x ^= b[k - 1]
            k += j
        if x == a[i]:
            b[i] = 1

print(sum(b))
for i in range(n):
    if b[i] == 1:
        print(i + 1)
Problem p03138 (python)

Fixed submission:
#!/usr/bin/python3

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

lenbin = len(bin(max(max(a), k))) - 2
bitcnt = [0] * lenbin

for i in range(lenbin):
    for ai in a:
        if ai & (1 << i):
            bitcnt[i] += 1

x = 0
for i in range(lenbin - 1, -1, -1):
    if bitcnt[i] <= n // 2 and x + (1 << i) <= k:
        x += (1 << i)

ans = 0
for ai in a:
    ans += (x ^ ai)

print(ans)

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

lenbin = len(bin(max(max(a), k))) - 2
bitcnt = [0] * lenbin

for i in range(lenbin):
    for ai in a:
        if ai & (1 << i):
            bitcnt[i] += 1

x = 0
for i in range(n - 1, -1, -1):
    if bitcnt[i] <= n // 2 and x + (1 << i) <= k:
        x += (1 << i)

ans = 0
for ai in a:
    ans += (x ^ ai)

print(ans)
Problem p03328 (python)

Fixed submission:
a, b = map(int, input().split())
h = [sum(range(i + 1)) for i in range(1, 1000)]
print(h[b - a - 2] - a)

Buggy submission (verdict: Runtime Error):
a, b = map(int, input().split())
h = [sum(range(i)) for i in range(1, 1000)]
print(h[b - a] - b)
Problem p02639 (python)

Fixed submission:
#n = int(input())
#n, k = map(int, input().split())
l = list(map(int, input().split()))
#s = input()

for i in range(len(l)):
    if l[i] == 0:
        print (i+1)

Buggy submission (verdict: Runtime Error):
#n = int(input())
x, y = map(int, input().split())
#l = list(map(int, input().split()))
#s = input()
ans = "Yes"
for i in range(x+1):
    if 2*i+4*x == y:
        ans = "No"

print(ans)
Problem p02918 (python)

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

l = []

i = 0
last = "H"
cnt = 0
for i in range(len(s)-1):
    if (s[i] == s[i+1]):
        cnt+=1


print(min(n-1, cnt+2*k))

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

l = []

i = 0
last = "H"
cnt = 1
while 1:
    if (i>=len(s)):
        break
    if (last == s[i]):
        cnt +=1
    else:
        l.append(cnt)
        cnt = 1
        last = s[i]
    i+=1

t = sorted(l, reverse=True)
ans = 0
for i in range(k+1):
    ans+=t[i]

print(ans)