Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python
# -*- coding: utf-8 -*-

# AGC028：A - Two Abbreviations
import numpy as np


def main():
    n, m = [int(i) for i in raw_input().strip().split(' ')]
    s = raw_input().strip()
    t = raw_input().strip()
    l = np.lcm(n, m) # 45
    n1 = l/n # 45/15 = 3
    m1 = l/m # 45/9 = 5
    l1 = np.lcm(n1, m1) # lcm(3, 5) = 15

    # d  n  s  u  s  r  a  y  u  k  u  a  i  i  a  
    # d    u    j    r    u    n    u    m    a    
    for i in range(l/l1):
        if s[i*m1] != t[i*n1]:
            print '-1'
            return
    print str(l)


if __name__ == '__main__':
    main()


Fixed submission:
#!/usr/bin/env python
# -*- coding: utf-8 -*-

# AGC028：A - Two Abbreviations
# import numpy as np
import fractions
def lcm(a,b): return abs(a * b) / fractions.gcd(a,b) if a and b else 0

def main():
    n, m = [int(i) for i in raw_input().strip().split(' ')]
    s = raw_input().strip()
    t = raw_input().strip()
    # l = np.lcm(n, m) # 45
    l = lcm(n, m) # 45
    n1 = l/n # 45/15 = 3
    m1 = l/m # 45/9 = 5
    # l1 = np.lcm(n1, m1) # lcm(3, 5) = 15
    l1 = lcm(n1, m1) # lcm(3, 5) = 15

    # d  n  s  u  s  r  a  y  u  k  u  a  i  i  a  
    # d    u    j    r    u    n    u    m    a    
    for i in range(l/l1):
        if s[i*m1] != t[i*n1]:
            print '-1'
            return
    print str(l)


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
def christmasEve():
    N, K = map(int, input().split())
    h = [int(input()) for i in range(N)]
    strees = sorted(h)
    result=10**9
    for i in range(len(strees)):
        result = min(result, strees[i+K-1] - strees[i])
    print(result)

if __name__ == "__main__":
    christmasEve()

Fixed submission:
def christmasEve():
    N, K = map(int, input().split())
    h = [int(input()) for i in range(N)]
    strees = sorted(h)
    result=10**9
    for i in range(N-K+1):
        result = min(result, strees[i+K-1] - strees[i])
    print(result)

if __name__ == "__main__":
    christmasEve()
Buggy python submission (verdict: Runtime Error):
def sura_backsura():
    import collections

    N = int(input())
    a = [int(i) for i in input().split()]

    fp = collections.Counter(a[0::2]).most_common()
    sp = collections.Counter(a[1::2]).most_common()

    if fp[0] != sp[0]:
        count = N - fp[0][1] - sp[0][1]
    else:
        count = min(N - fp[0][1] - sp[1][1], N - fp[1][1] - sp[0][1])

    print(count)
    
if __name__ == "__main__":
    sura_backsura()

Fixed submission:
def sura_backsura():
    import collections

    N = int(input())
    a = [int(i) for i in input().split()]

    fp = collections.Counter(a[0::2]).most_common()
    sp = collections.Counter(a[1::2]).most_common()

    fp.append((0, 0))
    sp.append((0, 0))

    if fp[0] != sp[0]:
        count = N - fp[0][1] - sp[0][1]
    else:
        count = min(N - fp[0][1] - sp[1][1], N - fp[1][1] - sp[0][1])

    print(count)
    
if __name__ == "__main__":
    sura_backsura()
Buggy python submission (verdict: Time Limit Exceeded):
def SumofThreeIntegers():
    K, S = map(int, input().split())

    count = 0

    for x in range(K+1):
        for y in range(K+1):
            for z in range(K+1):
                if x+y+z == S and x<=K and y<=K and z<=K:
                    count += 1

    print(count)

if __name__ == "__main__":
    SumofThreeIntegers()

Fixed submission:
def SumofThreeIntegers():
    K, S = map(int, input().split())

    count = 0

    for x in range(K+1):
        for y in range(K+1):
            z = S - x - y
            if 0 <= z <= S and z <= K:
                count += 1
    print(count)

if __name__ == "__main__":
    SumofThreeIntegers()
Buggy python submission (verdict: Runtime Error):
import math
from functools import reduce

def gcd_list(numbers):
    return reduce(math.gcd, numbers)

N = input()
line = list(map(int,input().split()))
ans = gcd_list(line)

print(ans)

Fixed submission:
def gcd(a,b):
    if b == 0:
        return a
    else:
        return gcd(b,a%b)

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

ans = line[0]

for i in range(1,n):
    ans = gcd(ans,line[i])

print(ans)

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

def gcd_list(numbers):
    return reduce(math.gcd, numbers)

N = int(input())
line = list(map(int,input().split()))
ans = gcd_list(line)

print(ans)

Fixed submission:
def gcd(a,b):
    if b == 0:
        return a
    else:
        return gcd(b,a%b)

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

ans = line[0]

for i in range(1,n):
    ans = gcd(ans,line[i])

print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
x = set(n)
cnt = 1

while True:
    
    cnt += 1
    
    if n%2 == 0:
        n //=2
        
    else:
        n = n * 3 + 1

    if n in x:
        print(cnt)
        break
    else:
        x.add(n)

Fixed submission:
n = int(input())
x = set()
cnt = 1
x.add(n)

while True:
    
    cnt += 1
    
    if n%2 == 0:
        n /=2
        
    else:
        n = n * 3 + 1

    if n in x:
        print(cnt)
        break
    else:
        x.add(n)

Buggy python submission (verdict: Runtime Error):
n = int(input())
x = set(n)
cnt = 1

while True:
    
    cnt += 1
    
    if n%2 == 0:
        n //=2
        
    else:
        n = n * 3 + 1

    if n in x:
        print(cnt)
        exit()
    else:
        x.add(n)

Fixed submission:
n = int(input())
x = set()
cnt = 1
x.add(n)

while True:
    
    cnt += 1
    
    if n%2 == 0:
        n /=2
        
    else:
        n = n * 3 + 1

    if n in x:
        print(cnt)
        break
    else:
        x.add(n)
Buggy python submission (verdict: Time Limit Exceeded):
N_K = list(map(int,input().split()))
H = list(map(int,input().split()))

N = N_K[0]
K = N_K[1]

dp= [2147483647] * (N)
dp[0] = 0

for i in range(1,len(H)):
    for j in range(1, K+ 1):

        if i < j:
            break
        
        dp[i] = min(dp[i],dp[i-j] + abs(H[i]-H[i-j]))
    
print(dp[N - 1])


Fixed submission:
import numpy as np

N_K = list(map(int,input().split()))
H = np.array(list(map(int,input().split())))

N = N_K[0]
K = N_K[1]

dp= np.zeros(N,dtype=np.int)

for i in range(1,len(H)):

    if i < K:
        dp[i] = np.min(dp[:i] + np.abs(H[i]-H[:i]))
    else:
        dp[i] = np.min(dp[i-K:i] + np.abs(H[i]-H[i-K:i]))
    
print(dp[N - 1])
Buggy python submission (verdict: Runtime Error):
n,m = map(int,input().split())

v = [-1] * (n + 1)
x = [[] for _ in range(n + 1)]

for _ in range(m):
    a,b = map(int,input().split())
    x[a].append(b)

def dfs(i):
    if v[i] != -1:
        return v[i]

    rt = 0
    for node in x[i]:
        tmp = dfs(node) + 1
        if rt < tmp:
            rt = tmp

    #メモ化再帰
    v[i] = rt
    return rt

ans = 0

for k in range(1,n+1):
    tmp2 = dfs(k)

    if tmp2 > ans:
        ans = tmp2

print(ans)

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

n,m = map(int,input().split())

v = [-1] * (n + 1)
x = [[] for _ in range(n + 1)]

for _ in range(m):
    a,b = map(int,input().split())
    x[a].append(b)

def dfs(i):
    if v[i] != -1:
        return v[i]

    rt = 0
    for node in x[i]:
        tmp = dfs(node) + 1
        if rt < tmp:
            rt = tmp

    #メモ化再帰
    v[i] = rt
    return rt

ans = 0

for k in range(1,n+1):
    tmp2 = dfs(k)

    if tmp2 > ans:
        ans = tmp2

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

def main():
    _ = input()
    monsters = [int(n) for n in input().split(" ")]
    max_gcd = reduce(math.gcd, monsters)
    print(max_gcd)

if __name__ == "__main__":
    main()

Fixed submission:
from functools import reduce

def gcd(a, b):
    x = max(a, b)
    y = min(a, b)
    if x % y == 0:
        return y
    else:
        while x % y != 0:
            z = x % y
            x = y 
            y = z
        else:
            return z

def main():
    _ = input()
    monsters = [int(n) for n in input().split(" ")]
    max_gcd = reduce(gcd, monsters)
    print(max_gcd)

if __name__ == "__main__":
    main()

Buggy python submission (verdict: Runtime Error):
def main():
    _ = input()
    monsters = [int(n) for n in input().split(" ")]
    max_gcd = reduce(math.gcd, monsters)
    print(max_gcd)

if __name__ == "__main__":
    main()

Fixed submission:
from functools import reduce

def gcd(a, b):
    x = max(a, b)
    y = min(a, b)
    if x % y == 0:
        return y
    else:
        while x % y != 0:
            z = x % y
            x = y 
            y = z
        else:
            return z

def main():
    _ = input()
    monsters = [int(n) for n in input().split(" ")]
    max_gcd = reduce(gcd, monsters)
    print(max_gcd)

if __name__ == "__main__":
    main()

Buggy python submission (verdict: Runtime Error):
def decice_winner(a, b):
    if a > b and b != 0:
        return b
    else:
        return a
def calc_min(a, b):
    while True:
        if a <= 1 or b <=1:
            return decice_winner(a, b)
        elif a > b and a / b > 0 :
            a = a % b
        elif b > a and b / a > 0:
            b = b % a
        else:
            return decice_winner(a, b)

def main():
    _ = input()
    monsters = list(set([int(n) for n in input().split(" ")]))
    min1 = min(monsters)
    monsters.remove(min1)
    monsters = list(set([n % min1 for n in monsters]))
    monsters.remove(0)
    if len(monsters) == 0:
        print(min1)
    else:
        min2 = min(monsters)
        print(calc_min(min1, min2))

if __name__ == "__main__":
    main()

Fixed submission:
from functools import reduce

def gcd(a, b):
    x = max(a, b)
    y = min(a, b)
    if x % y == 0:
        return y
    else:
        while x % y != 0:
            z = x % y
            x = y 
            y = z
        else:
            return z

def main():
    _ = input()
    monsters = [int(n) for n in input().split(" ")]
    max_gcd = reduce(gcd, monsters)
    print(max_gcd)

if __name__ == "__main__":
    main()
Buggy python submission (verdict: Time Limit Exceeded):
import sys
import math

def dp(costs, K):
    table = [0]
    for i in range(1, len(costs)):
        min_cost = table[i-1] + abs(costs[i-1] - costs[i])
        for j in range(2, K + 1):
            jump = i - j
            if(jump >= 0):
                step = table[jump] + abs(costs[jump] - costs[i])
                min_cost = min([min_cost, step])
            else: 
                break
        table.append(min_cost)
    return table[-1]
        
def main():
    for index in range(2):
        line = input()
        if index == 0:
            K = int(line.split(" ")[1])
            continue
        costs = [int(s) for s in line.split(" ")]
        print(dp(costs, K))

if __name__ == "__main__":
    main()

Fixed submission:
import sys
import math

def dp(costs, K):
    table = [0]
    for i in range(1, len(costs)):
        min_cost = table[i-1] + abs(costs[i-1] - costs[i])
        for j in range(2, K + 1):
            jump = i - j
            if(jump >= 0):
                step = table[jump] + abs(costs[jump] - costs[i])
                min_cost = min([min_cost, step])
            else: 
                break
        table.append(min_cost)
    return table[-1]
        
def main():
    for index in range(2):
        line = input()
        if index == 0:
            K = int(line.split(" ")[1])
            continue
        costs = [int(s) for s in line.split(" ")]
        print(dp(costs, K))

if __name__ == "__main__":
    main()

Buggy python submission (verdict: Runtime Error):
import typing 
import sys
import math

def dp(costs: typing.List[int], K: int) -> int:
    table = [0]
    for i in range(1, len(costs)):
        min_cost = table[i-1] + abs(costs[i-1] - costs[i])
        for j in range(2, K + 1):
            jump = i - j
            if(jump >= 0):
                step = table[jump] + abs(costs[jump] - costs[i])
                min_cost = min([min_cost, step])
            else: 
                break
        table.append(min_cost)
    return table[-1]
        
def main():
    for index in range(2):
        line = input()
        if index == 0:
            K = int(line.split(" ")[1])
            continue
        costs = [int(s) for s in line.split(" ")]
        print(dp(costs, K))

if __name__ == "__main__":
    main()

Fixed submission:
import sys
import math

def dp(costs, K):
    table = [0]
    for i in range(1, len(costs)):
        min_cost = table[i-1] + abs(costs[i-1] - costs[i])
        for j in range(2, K + 1):
            jump = i - j
            if(jump >= 0):
                step = table[jump] + abs(costs[jump] - costs[i])
                min_cost = min([min_cost, step])
            else: 
                break
        table.append(min_cost)
    return table[-1]
        
def main():
    for index in range(2):
        line = input()
        if index == 0:
            K = int(line.split(" ")[1])
            continue
        costs = [int(s) for s in line.split(" ")]
        print(dp(costs, K))

if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
import sys

(sn, sm) = sys.stdin.readline().split()
n = int(sn)
m = int(sm)

flg = [0 for j in range(m)]
for i in range(n):
  sa = sys.stdin.readline().split()
  if len(sa) > 1:
	  for saj in sa[1:]:
    	aj = int(saj)
    	flg[aj - 1] += 1

suma = 0
for sumaj in flg:
  if sumaj == n:
    suma += 1
print(suma)

Fixed submission:
import sys

(sn, sm) = sys.stdin.readline().split()
n = int(sn)
m = int(sm)

flg = [0 for j in range(m)]
for i in range(n):
  sa = sys.stdin.readline().split()
  if len(sa) > 1:
    for saj in sa[1:]:
      aj = int(saj)
      flg[aj - 1] += 1

suma = 0
for sumaj in flg:
  if sumaj == n:
    suma += 1
print(suma)

Buggy python submission (verdict: Runtime Error):
import sys

(sn, sm) = sys.stdin.readline().split()
n = int(sn)
m = int(sm)

flg = [0 for j in range(m)]
for i in range(n):
  sa = sys.stdin.readline().split()
  if len(sa) > 1:
	  for saj in sa[1:]
    	aj = int(saj)
    	flg[aj - 1] += 1

suma = 0
for sumaj in flg:
  if sumaj == n:
    suma += 1
print(suma)

Fixed submission:
import sys

(sn, sm) = sys.stdin.readline().split()
n = int(sn)
m = int(sm)

flg = [0 for j in range(m)]
for i in range(n):
  sa = sys.stdin.readline().split()
  if len(sa) > 1:
    for saj in sa[1:]:
      aj = int(saj)
      flg[aj - 1] += 1

suma = 0
for sumaj in flg:
  if sumaj == n:
    suma += 1
print(suma)

Buggy python submission (verdict: Runtime Error):
import sys

(sn, sm) = sys.stdin.readline().split()
n = int(sn)
m = int(sm)

flg = [0 for j in range(m)]
for i in range(n):
  sa = sys.stdin.readline().split()
  for saj in sa[1:]
    aj = int(saj)
    flg[aj - 1] += 1

suma = 0
for sumaj in flg:
  if sumaj == n:
    suma += 1
print(suma)

Fixed submission:
import sys

(sn, sm) = sys.stdin.readline().split()
n = int(sn)
m = int(sm)

flg = [0 for j in range(m)]
for i in range(n):
  sa = sys.stdin.readline().split()
  if len(sa) > 1:
    for saj in sa[1:]:
      aj = int(saj)
      flg[aj - 1] += 1

suma = 0
for sumaj in flg:
  if sumaj == n:
    suma += 1
print(suma)

Buggy python submission (verdict: Runtime Error):
import sys

(sn, sm) = sys.stdin.readline().split()
n = int(sn)
m = int(sm)

flg = [0 for j in range(m)]
for i in range(n):
  sa = sys.stdin.readline().split()
  for saj in sa:
    aj = int(saj)
    flg[aj - 1] += 1

suma = 0
for sumaj in range(flg):
  if sumaj == n:
    suma += 1
print(suma)

Fixed submission:
import sys

(sn, sm) = sys.stdin.readline().split()
n = int(sn)
m = int(sm)

flg = [0 for j in range(m)]
for i in range(n):
  sa = sys.stdin.readline().split()
  if len(sa) > 1:
    for saj in sa[1:]:
      aj = int(saj)
      flg[aj - 1] += 1

suma = 0
for sumaj in flg:
  if sumaj == n:
    suma += 1
print(suma)
Buggy python submission (verdict: Runtime Error):
def divisor(A, B):
    if A==1:
        return A + B
    if B==1:
        return B-A
    if B % A == 0:
        return A + B
    return B - A
  
  A, B = map(int, input().split(" "))
  print(divisor(A, B))

Fixed submission:
def divisor(A, B):
    if A==1:
        return A + B
    if B==1:
        return B-A
    if B % A == 0:
        return A + B
    return B - A

A, B = map(int, input().split(" "))
print(divisor(A, B))

Buggy python submission (verdict: Runtime Error):
a, b = map(int, input().split())
if b%a==0:;print(a+b)
else:;print(b-a)

Fixed submission:
a, b = map(int, input().split())
if b%a==0:
    print(a+b)
else:
    print(b-a)
Buggy python submission (verdict: Runtime Error):
def inpul(): return list(map(int, input().split()))

 from fractions import Fraction
from functools import reduce

#最大公約数
def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)

N = inpul()
a = inpul()

ans = gcd_list(a)
print(ans)


Fixed submission:
def inpul(): return list(map(int, input().split()))

import fractions
from functools import reduce

#最大公約数
def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)

N = inpul()
a = inpul()

ans = gcd_list(a)
print(ans)

Buggy python submission (verdict: Runtime Error):
def inpul(): return list(map(int, input().split()))

import math
from functools import reduce

#最大公約数
def gcd_list(numbers):
    return reduce(math.gcd, numbers)

N = inpul()
a = inpul()

ans = gcd_list(a)
print(ans)

Fixed submission:
def inpul(): return list(map(int, input().split()))

import fractions
from functools import reduce

#最大公約数
def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)

N = inpul()
a = inpul()

ans = gcd_list(a)
print(ans)

Buggy python submission (verdict: Runtime Error):
import math
from functools import reduce
def inpul(): return list(map(int, input().split()))

#最大公約数
def gcd_list(numbers):
    return reduce(math.gcd, numbers)
  
N = inpul()
a = inpul()

ans = gcd_list(a)


Fixed submission:
def inpul(): return list(map(int, input().split()))

import fractions
from functools import reduce

#最大公約数
def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)

N = inpul()
a = inpul()

ans = gcd_list(a)
print(ans)
Buggy python submission (verdict: Runtime Error):
#python3.4
import math
def inpul(): return list(map(int, input().split()))

N, M = inpul()
A = inpul()

c = [0,2,5,5,4,5,6,3,7,6]
f = [-1]*10010

f[0] = 0
for i in range(1, N+1):
	for x in a:
		if i-c[x] >= 0:
			f[i] = max(f[i], f[i-c[x]]*10+x)
print(f[n])

Fixed submission:
#python3.4
import math
def inpul(): return list(map(int, input().split()))

N, M = inpul()
A = inpul()

c = [0,2,5,5,4,5,6,3,7,6]
f = [-1]*10010

f[0] = 0
for i in range(1, N+1):
	for x in A:
		if i-c[x] >= 0:
			f[i] = max(f[i], f[i-c[x]]*10+x)
print(f[N])
Buggy python submission (verdict: Runtime Error):
#python3.4
def inpul(): return list(map(int, input().split()))

N, M = inpul()
X = inpul()

if(N >= M):
    print(0)
else:
  new_list = sorted(X)
  diff_list = [new_list[i+1] - new_list[i] for i in range(M-1)]
  new_dif_list = sorted(diff_list, reverse = True)

  if(N  >= 2):
    for i in range(N-1):
        new_dif_list.pop(0)

print(sum(new_dif_list))


Fixed submission:
#python3.4
def inpul(): return list(map(int, input().split()))

N, M = inpul()
X = inpul()
new_list = sorted(X)
diff_list = [new_list[i+1] - new_list[i] for i in range(M-1)]
new_dif_list = sorted(diff_list, reverse = True)

if(N >= M):
    print(0)

else:
  if(N  >= 2):
      for i in range(N-1):
        new_dif_list.pop(0)

  print(sum(new_dif_list))

Buggy python submission (verdict: Runtime Error):
#python3.4
def inpul(): return list(map(int, input().split()))

N, M = inpul()
X = inpul()

if(N >= M):
    print(0)

new_list = sorted(X)
diff_list = [new_list[i+1] - new_list[i] for i in range(M-1)]
new_dif_list = sorted(diff_list, reverse = True)
else:
  if(N  >= 2):
      for i in range(N-1):
          new_dif_list.pop(0)

  print(sum(new_dif_list))


Fixed submission:
#python3.4
def inpul(): return list(map(int, input().split()))

N, M = inpul()
X = inpul()
new_list = sorted(X)
diff_list = [new_list[i+1] - new_list[i] for i in range(M-1)]
new_dif_list = sorted(diff_list, reverse = True)

if(N >= M):
    print(0)

else:
  if(N  >= 2):
      for i in range(N-1):
        new_dif_list.pop(0)

  print(sum(new_dif_list))

Buggy python submission (verdict: Runtime Error):
#python3.4
def inpul(): return list(map(int, input().split()))

N, M = inpul()
X = inpul()

if(N >= M):
    print(0)

new_list = sorted(X)
diff_list = [new_list[i+1] - new_list[i] for i in range(M-1)]
new_dif_list = sorted(diff_list, reverse = True)

if(N  >= 2):
    for i in range(N-1):
        new_dif_list.pop(0)

print(sum(new_dif_list))


Fixed submission:
#python3.4
def inpul(): return list(map(int, input().split()))

N, M = inpul()
X = inpul()
new_list = sorted(X)
diff_list = [new_list[i+1] - new_list[i] for i in range(M-1)]
new_dif_list = sorted(diff_list, reverse = True)

if(N >= M):
    print(0)

else:
  if(N  >= 2):
      for i in range(N-1):
        new_dif_list.pop(0)

  print(sum(new_dif_list))

Buggy python submission (verdict: Runtime Error):
#python3.4
def inpul(): return list(map(int, input().split()))

N, M = inpul()
X = inpul()

if(N >= M):
    print(0)

new_list = sorted(X)
diff_list = [new_list[i+1] - new_list[i] for i in range(M-1)]
new_dif_list = sorted(diff_list, reverse = True)

if(N  >= 2):
    for i in range(N-1):
      new_dif_list.pop(0)

print(sum(new_dif_list))


Fixed submission:
#python3.4
def inpul(): return list(map(int, input().split()))

N, M = inpul()
X = inpul()
new_list = sorted(X)
diff_list = [new_list[i+1] - new_list[i] for i in range(M-1)]
new_dif_list = sorted(diff_list, reverse = True)

if(N >= M):
    print(0)

else:
  if(N  >= 2):
      for i in range(N-1):
        new_dif_list.pop(0)

  print(sum(new_dif_list))
Buggy python submission (verdict: Time Limit Exceeded):
#python3.4
def inpul(): return list(map(int, input().split()))
import math

N, K = inpul()
A = inpul()

f = 0
f_ans = 0
try:
    serch_int_index = int(math.log2(K))
    serch_int = 2 ** serch_int_index

except Exception as e:
    serch_int = 0

for num in range(serch_int, K+1):
    for item_A in A:
        f = f + (num ^ item_A)
    if(f > f_ans):
        f_ans = f
    f = 0
print(f_ans)


Fixed submission:
n,k = list(map(int, input().split()))
a=list(map(int, input().split()))
x=0
ans = 0
for i in range(45,-1,-1):
  c=0
  for p in a:
    if (p >> i) & 1:
      c += 1
  if n - c > c and x + (1<<i) <= k:
    ans += (n-c) * (1<<i)
    x += 1<<i
  else:
    ans += c * (1<<i)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
#python3.4
def inpul(): return list(map(int, input().split()))

N, K = inpul()
A = inpul()

f = 0
f_ans = 0
for num in range(K+1):
    for item_A in A:
        f = f + (num ^ item_A)
    if(f > f_ans):
        f_ans = f
    f = 0
print(f_ans)


Fixed submission:
n,k = list(map(int, input().split()))
a=list(map(int, input().split()))
x=0
ans = 0
for i in range(45,-1,-1):
  c=0
  for p in a:
    if (p >> i) & 1:
      c += 1
  if n - c > c and x + (1<<i) <= k:
    ans += (n-c) * (1<<i)
    x += 1<<i
  else:
    ans += c * (1<<i)
print(ans)