Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
import sys,copy,math,heapq,itertools as it,fractions,re,bisect,collections as coll

N, M = map(int, raw_input().split())
X = map(int, raw_input().split())

cnt = [0]*100005
for x in X:
    cnt[x%M] += 1

ans = 0
for i in xrange(M):
    if i == M - i:
        ans += cnt[i]/2
        print "=", cnt[i]
        cnt[i] %= 2
    else:
        m = min(cnt[i], cnt[M - i])
        print min(cnt[i], cnt[M - i])
        ans += m
        cnt[i] -= m
        cnt[M - i] -= m
for i in xrange(M):
    ans += cnt
print ans


Fixed submission:
# -*- coding: utf-8 -*-
import sys,copy,math,heapq,itertools as it,fractions,re,bisect,collections as coll

N, M = map(int, raw_input().split())
X = map(int, raw_input().split())

cnt = [0]*100005
for x in X:
    cnt[x] += 1

pair = [0]*M
for i in xrange(100005):
    pair[i%M] += cnt[i]/2
    cnt[i] %= 2

mod = [0]*M
for i in xrange(100005):
    mod[i%M] += cnt[i]

ans = sum(pair)
for i in xrange(M):
    if i == 0 or i == M - i:
        ans += mod[i]/2 
        mod[i] %= 2
    else:
        m = min(mod[i], mod[M - i])
        ans += m
        mod[i] -= m
        mod[M - i] -= m

for i in xrange(1, M):
    while pair[i] >= 1 and mod[M - i] >= 2:
        ans += 1
        pair[i] -= 1
        mod[M - i] -= 2


print ans
Buggy python submission (verdict: Runtime Error):
S = raw_input()
T = "CODEFESTIVAL2016"
ans = 0
for i in xrange(S):
    if S[i] != T[i]: ans += 1
print ans

Fixed submission:
S = raw_input()
T = "CODEFESTIVAL2016"
ans = 0
for i in xrange(len(S)):
    if S[i] != T[i]: ans += 1
print ans
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
import sys,copy,math,heapq,itertools as it,fractions,re,bisect,collections as coll

alpha = "abcdefghijklmnopqrstuvwxyz"

s = raw_input()
K = int(raw_input())
dic = dict([alpha[i], i] for i in xrange(len(alpha)))

ans = [] 
for si in s:
    d = 26 - dic[si] if si != "a" else 0
    if d <= K:
        ans.append("a")
        K -= d
    else:
        ans.append(si)

if K > 0:
    ans[-1] = alpha[dic[ans[-1]] + K]

print "".join(ans)


Fixed submission:
# -*- coding: utf-8 -*-
import sys,copy,math,heapq,itertools as it,fractions,re,bisect,collections as coll

alpha = "abcdefghijklmnopqrstuvwxyz"

s = raw_input()
K = int(raw_input())
dic = dict([alpha[i], i] for i in xrange(len(alpha)))

ans = [] 
for si in s:
    d = 26 - dic[si] if si != "a" else 0
    if d <= K:
        ans.append("a")
        K -= d
    else:
        ans.append(si)

if K > 0:
    ans[-1] = alpha[(dic[ans[-1]] + K) % 26]

print "".join(ans)
Buggy python submission (verdict: Runtime Error):
N, Q = map(int, input().split())
S = input()
lr = [0] * Q
for i in range(Q):
  lr[i] = list(map(int, input().split()))

b, t = 0, [0]*N
for i in range(1, N):
  if S[i-1:i+1] == 'AC':
    t[i] += 1
  else: t[i] = t[i-1]

for i in range(Q):
  print(t[lr[i][1]] - t[lr[i][0]])

Fixed submission:
N, Q = map(int, input().split())
S = input()
lr = [0] * Q
for i in range(Q):
  lr[i] = list(map(lambda x: int(x) - 1, input().split()))
 
b, t = 0, [0]*N
for i in range(1, N):
  if S[i-1] == 'A' and S[i] == 'C':
    t[i] = t[i-1] + 1
  else: t[i] = t[i-1]
 
for i in range(Q):
  print(t[lr[i][1]] - t[lr[i][0]])

Buggy python submission (verdict: Time Limit Exceeded):
N, Q = map(int, input().split())
S = input()
lr = [0] * Q
for i in range(Q):
  lr[i] = list(map(int, input().split()))

b, t = 0, [0]*N
v = S.find('AC', b)
while v != -1:
    t[v] = 1
    b += 2
    v = S.find('AC', b)

for i in range(Q):
  st = lr[i][0] - 1
  if S[st] == 'C':
    k = sum(t[st:lr[i][1]]) - 1
  else:
    k = sum(t[st:lr[i][1]])
  print(k)

Fixed submission:
N, Q = map(int, input().split())
S = input()
lr = [0] * Q
for i in range(Q):
  lr[i] = list(map(lambda x: int(x) - 1, input().split()))
 
b, t = 0, [0]*N
for i in range(1, N):
  if S[i-1] == 'A' and S[i] == 'C':
    t[i] = t[i-1] + 1
  else: t[i] = t[i-1]
 
for i in range(Q):
  print(t[lr[i][1]] - t[lr[i][0]])
Buggy python submission (verdict: Runtime Error):
import numpy
N, M, C = map(int, input().split())
b = numpy.array([i for i in map(int, input().split())])                                                        
A = numpy.array([[0]*M]*N)
for i in range(N):
    A[i] = [i for i in map(int, input().split())]

print(sum((numpy.matmul(A, b) + C) > 0))

Fixed submission:
N, M, C = map(int, input().split())
b = [i for i in map(int, input().split())]
A = [0]*N
for i in range(N):
    A[i] = [i for i in map(int, input().split())]

count = 0 
for r in range(N):
    tmp = 0 
    for c in range(M):
        tmp += A[r][c] * b[c]
    tmp += C
    if tmp > 0: count += 1                                                                                     
    
print(count)
Buggy python submission (verdict: Time Limit Exceeded):
a, b = map(int, input().split())                                                                               

ans = 0 
for i in range(a, b+1):
    ans ^= i
print(ans)

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

ans = 0 
def f(n):
    if n % 2 == 1:
        num_pairs = (n + 1) // 2
        return num_pairs % 2 
    else:
        num_pairs = (n + 1) // 2
        return (num_pairs % 2) ^ n 

print(f(a-1) ^ f(b))
Buggy python submission (verdict: Runtime Error):
class UnionFind():
    def __init__(self, n):
        self.__parent = [i for i in range(n)]
        self.size = [1 for _ in range(n)]

    def union(self, x, y):
        pX, pY = self.find(x), self.find(y)
        if pX != pY:
            if pX < pY:
                self.__parent[pY] = pX
                self.size[pX] += self.size[pY]
            else:
                self.__parent[pX] = pY
                self.size[pY] += self.size[pX]                                                                 

    def find(self, x):
        if self.__parent[x] != x:
            self.__parent[x] = self.find(self.__parent[x])
        return self.__parent[x]

N, M = map(int, input().split())
bridge = [tuple(map(lambda x: int(x) - 1, input().split())) for _ in range(M)]
uf = UnionFind(N)
num_disconnect = int(N*(N-1)/2)
ans = []
for a, b in reversed(bridge):
    ans.append(num_disconnect)
    pA, pB = uf.find(a), uf.find(b)
    if pA != pB:
        num_disconnect -= uf.size[pA] * uf.size[pB]
    uf.union(a, b)

for i in reversed(ans): print(i) 

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

if b//a >= c: print(c)
else: print(b//a)
Buggy python submission (verdict: Runtime Error):
n=input()
h = list(map(int,input().split()))
h1 = h[0]
hi = h[-1]
hi2 = h[-2]
count = 0
ans = [count + 1 for t in h if t >= h1]
if hi2 > hi and hi2 >= h1:
    ans -= 1
print(count)

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

Buggy python submission (verdict: Runtime Error):
n=input()
h = list(map(int,input().split()))
h1 = h[0]
hi = h[-1]
hi2 = h[-2]
count = 0
for takasa in h:
    if takasa >= h1:
        count+= 1
if hi2 > hi and hi2 >= h1:
    count -= 1
print(count)

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

Buggy python submission (verdict: Runtime Error):
n=input()
h = list(map(int,input().split()))
h1 = h[0]
hi = h[-1]
hi2 = h[-2]
count = 0
for takasa in h:
    if takasa >= h1:
        count+= 1
if hi2 > hi and hi2 >= h1:
    count -= 1
print(count)

Fixed submission:
a,b = map(int,(input().split()))
if a == b:
    ans = a*2
    print(ans)
else:
    big = max(a,b)
    ans = big + (big-1)
    print(ans)
Buggy python submission (verdict: Runtime Error):
x = input()
for ans in x:
    if ans < 1200:
        print("ABC")
    else:
        print("ARC")

Fixed submission:
x = int(input())
if x < 1200:
    print("ABC")
else:
    print("ARC")

Buggy python submission (verdict: Runtime Error):
x = (input())
for ans in x:
    if ans < 1200:
        print("ABC")
    else:
        print("ARC")

Fixed submission:
x = int(input())
if x < 1200:
    print("ABC")
else:
    print("ARC")
Buggy python submission (verdict: Runtime Error):
a,b,c = map(int, input().split())
if a=b+c or b=a+c or c=a+b:
    print("Yes")
else:
    print("No")


Fixed submission:
a,b,c = sorted(map(int, input().split()))
if a+b==c:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
a,b,c = map(int,input().split())
s = set{a,b,c}
print(len(s))

Fixed submission:
s = map(int,input().split())
ans = set(s)
print(len(ans))

Buggy python submission (verdict: Runtime Error):
a,b,c = map(int,input().split())
print(len(set{a,b,c}))

Fixed submission:
s = map(int,input().split())
ans = set(s)
print(len(ans))

Buggy python submission (verdict: Runtime Error):
a,b,c = map(int,input().split())
ans = len(set(a,b,c))
print(ans)

Fixed submission:
s = map(int,input().split())
ans = set(s)
print(len(ans))
Buggy python submission (verdict: Runtime Error):
print(map(lambda x:x*(x+1)/2,input())

Fixed submission:
x = int(input())
print(int(x*(x+1)/2))
Buggy python submission (verdict: Time Limit Exceeded):
length, quests = map(int, input().rstrip().split())
string = input()
positions = []

for i in range(len(string) - 1):
    if string[i] == "A" and string[i+1] == "C":
        positions.append(1)
    else:
        positions.append(0)

for i in range(quests):
    left, right = map(int, input().rstrip().split())
    count = 0
    for j in range(left-1, right-1):
        if positions[j] == 1 and right + 1 != len(positions) and j + 1 != right:
            count += 1
    print(count)


Fixed submission:
length, quests = map(int, input().rstrip().split())
string = input()
totals = [0]

count = 0
for i in range(1, len(string)):
    if string[i-1] == "A" and string[i] == "C":
        count += 1
    totals.append(count)

for i in range(quests):
    left, right = map(int, input().rstrip().split())
    print(totals[right-1] - totals[left-1])

Buggy python submission (verdict: Time Limit Exceeded):
length, quests = map(int, input().rstrip().split())
string = input()

for i in range(quests):
    left, right = map(int, input().rstrip().split())
    substring = string[left-1:right]
    j = 0
    count = 0
    while j < len(substring) - 1:
        if substring[j] == 'A' and substring[j + 1] == 'C':
            count += 1
            j += 2
        else:
            j += 1
    print(count)


Fixed submission:
length, quests = map(int, input().rstrip().split())
string = input()
totals = [0]

count = 0
for i in range(1, len(string)):
    if string[i-1] == "A" and string[i] == "C":
        count += 1
    totals.append(count)

for i in range(quests):
    left, right = map(int, input().rstrip().split())
    print(totals[right-1] - totals[left-1])
Buggy python submission (verdict: Runtime Error):
a = int(input())
b = input()
c = input()
d = input()
e = int(input())
k = int(input())

if e - a =< k:
	print('Yay!')
else:
	print(':(')

Fixed submission:
a = int(input())
b = input()
c = input()
d = input()
e = int(input())
k = int(input())

if e - a <= k:
	print('Yay!')
else:
	print(':(')
Buggy python submission (verdict: Runtime Error):
if __name__ == '__main__':
  
	num = input()

	if int(num[0]) * int(num[1]) % 2 ==0:
		print("No")
	else:
  		print("Yes")

Fixed submission:
if __name__ == '__main__':
  
	num = input().split()

	if int(num[0]) * int(num[1]) % 2 ==0:
		print("No")
	else:
  		print("Yes")

Buggy python submission (verdict: Runtime Error):
num = input().split()

if num[0] * num[1] % 2 == 0 :
  print("No")
else:
  print("Yes")

Fixed submission:
if __name__ == '__main__':
  
	num = input().split()

	if int(num[0]) * int(num[1]) % 2 ==0:
		print("No")
	else:
  		print("Yes")
Buggy python submission (verdict: Runtime Error):
N=int(input())
if N==1:
    print("Hello World")
else:
    A,B=map(int,input().split())
    print(A+B)


Fixed submission:
N=int(input())
if N==1:
    print("Hello World")
else:
    A=int(input())
    B=int(input())
    print(A+B)

Buggy python submission (verdict: Runtime Error):
N=int(input())
if N=1:
    print("Hello World")
else:
    A,B=map(int,input().split())
    print(A+B)

Fixed submission:
N=int(input())
if N==1:
    print("Hello World")
else:
    A=int(input())
    B=int(input())
    print(A+B)
Buggy python submission (verdict: Runtime Error):
import math
print(2**int(log2(int(input()))))

Fixed submission:
import math
print(2**int(math.log2(int(input()))))

Buggy python submission (verdict: Runtime Error):
print(2**int(log2(int(input()))))

Fixed submission:
import math
print(2**int(math.log2(int(input()))))
Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())

_a, _b = map(int, input().split())
dict_paths = {}
dict_paths[_a] = _b

for i in range(M - 1) :
    a, b = map(int, input().split())
    
    interleave_flg = False

    for k in dict_paths.keys() :
        k_tmp, k_val_tmp = k, dict_paths[k]
        
        # complete intersect
        if a >= k and b <= dict_paths[k] :
            dict_paths.pop(k)
            dict_paths[a] = b
            interleave_flg = True
            
        # nothing required
        elif a <= k and b >= dict_paths[k] :
            interleave_flg = True
            
        # left partial
        elif a < k and b > k and b <= dict_paths[k] :
            dict_paths.pop(k)
            dict_paths[a] = k_val_tmp
            interleave_flg = True
            
        # right partial
        elif a > k and a < dict_paths[k] and b >= dict_paths[k] :
            dict_paths.pop(k)
            dict_paths[k] = b
            interleave_flg = True
    
    if interleave_flg == False :
        dict_paths[a] = b
            
print(len(dict_paths))
        
    

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

paths = []

for i in range(M) :
    _a, _b = map(int, input().split())
    paths.append((_a, _b))

st = sorted(paths, key = lambda x : x[1])
cnt = 0
prev_b = -1

for i in st :
    if cnt == 0 :
        cnt += 1
        prev_b = i[1]
    else :
        if i[0] >= prev_b :
            cnt += 1
            prev_b = i[1]
    
print(cnt)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
a = list(map(int, input().split(" ")))

min_sum = -1
i_atmin = -1

# for i in range(0, 2*(10**5) + 2) :
i = 0
while(1) : 
    sum_over = 0
    sum_over_minus = 0
    
    for j in range(N) :
        sum_over += abs(a[j] - (i + j))
        
    for j in range(N) :
        sum_over_minus += abs(a[j] - (j - i))
        
    if min_sum != -1 and min(sum_over, sum_over_minus) > min_sum :
        break
        
    if min_sum == -1 or min(sum_over, sum_over_minus) < min_sum :
        min_sum = min(sum_over, sum_over_minus)
        
    i += 1
        
print(min_sum)

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

B = [y - x - 1 for x, y in enumerate(a)]
B_s = sorted(B)

# if odd 
if N % 2 == 1 :  
    median = [B_s[int(N / 2)]]
else :
    median = [B_s[int(N / 2)], B_s[int(N / 2) + 1]]

min_sum = None 

for m in median :
    sum_over = 0
    
    for i, j in enumerate(a) :
        sum_over += abs(j - (m + i + 1))

    if min_sum == None or sum_over < min_sum :
        min_sum = sum_over
        
print(min_sum)
Buggy python submission (verdict: Runtime Error):
N, K = map(int, input().split())
a = list(map(int, input().split()))

amin = min(a)

if len(myarr) == myarr.count(amin) :
    print("0")
else :
    if K == 1 : 
        print(N - myarr.count(amin))
    else :
        if (N - a.count(amin)) % (K - 1) == 0 :
            print((N - a.count(amin)) // (K - 1))
        else :
            print((N - a.count(amin)) // (K - 1) + 1)

Fixed submission:
import math

N, K = map(int, input().split(" "))
a = map(int, input().split(" "))

# print(int((N - 1)/(K - 1)))

print(math.ceil((N - 1) / (K - 1)))

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

amin = min(a)

if len(myarr) == myarr.count(amin) :
    print("0")
else :
    if K == 1 : 
        print(N - myarr.count(amin))
    else :
        if (N - a.count(amin)) % (K - 1) == 0 :
            print((N - a.count(amin)) // (K - 1))
        else :
            print((N - a.count(amin)) // (K - 1) + 1)

Fixed submission:
import math

N, K = map(int, input().split(" "))
a = map(int, input().split(" "))

# print(int((N - 1)/(K - 1)))

print(math.ceil((N - 1) / (K - 1)))
Buggy python submission (verdict: Runtime Error):
n = map(int, input())
alist = list(map(int, input().split(" ")))

def do_sunuke(l, cnt) : 
    reslist = []
    flg_div2 = 0

    for a in l :
        if a % 2 == 0 and flg_div2 == 0 :
            reslist.append(int(a/2))
            flg_div2 = 1
        else :
            reslist.append(a)

    if flg_div2 == 0 :
        return cnt
    else : 
        return do_sunuke(reslist, cnt + 1)
    
print(do_sunuke(alist, 0))

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

def two_factor(n) :
    cnt = 0

    while n % 2 == 0:
        n /= 2
        cnt += 1

    return cnt 
    
fact_cnt = 0
for a in alist :
    fact_cnt += two_factor(a)
    
print(fact_cnt)

Buggy python submission (verdict: Runtime Error):
# input 
n = map(int, input())
a = map(int, input().split(" "))

# make list 
curlist = list(a)

# du recurse
def sunukeList(curlist, cnt) :
    print("DBG : ", curlist)
    reslist = []
    flg_div2 = 0
    flg_did3 = 0

    for i in curlist :    
        # if divisible by two then divide
        if i%2 == 0 and flg_div2 == 0: 
            reslist.append(int(i/2))
            flg_div2 = 1
        else :
            reslist.append(i*3)
            flg_did3 = 1

    if flg_div2 == 0 :
        print(cnt)
    else :
        sunukeList(reslist, cnt + 1)
        
# calc
sunukeList(curlist, 0)


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

def two_factor(n) :
    cnt = 0

    while n % 2 == 0:
        n /= 2
        cnt += 1

    return cnt 
    
fact_cnt = 0
for a in alist :
    fact_cnt += two_factor(a)
    
print(fact_cnt)
Buggy python submission (verdict: Time Limit Exceeded):
N, Y = map(int, input().split(" "))

s1, s2, s3 = 10, 5, 1
ok_flg = False

if Y % 1000 != 0 :
    print("-1 -1 -1")    
else :
    y_small = int(Y / 1000)
    for i in range(N + 1) :
        if y_small - i * s1 <= (N - i) * s2 :
            for j in range(N - i + 1) :
                if y_small - i*s1 - j*s2 <= (N - i - j)*s3 :
                    for k in range(N - i - j + 1) :
                        # print("DBG : ", i, j, k, s1, s2, s3)
                        if i + j + k == N and i*s1 + j*s2 + k*s3 == y_small :
                            print(i, j, k)
                            ok_flg = True
                            break
                    if ok_flg == True :
                        break
            if ok_flg == True :
                break

    if ok_flg == False :
        print("-1 -1 -1")

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

s1, s2, s3 = 10, 5, 1
ok_flg = False

if Y % 1000 != 0 :
    print("-1 -1 -1")    
else :
    y_small = int(Y / 1000)
    for i in range(N + 1) :
        if y_small - i * s1 <= (N - i) * s2 :
            for j in range(N - i + 1) :
                if i + j <= N and i*s1 + j*s2 + (N - i - j)*s3 == y_small :
                    print(i, j, N - i - j)
                    ok_flg = True
                    break
                if ok_flg == True :
                    break
            if ok_flg == True :
                break
    if ok_flg == False :
        print("-1 -1 -1")

Buggy python submission (verdict: Time Limit Exceeded):
N, Y = map(int, input().split(" "))

s1, s2, s3 = 10000, 5000, 1000
ok_flg = False

for i in range(N + 1) :
    if Y - i * s1 <= (N - i) * s2 :
        for j in range(N - i + 1) :
            if Y - i*s1 - j*s2 <= (N - i - j)*s3 :
                for k in range(N - i - j + 1) :
                    # print("DBG : ", i, j, k, s1, s2, s3)
                    if i + j + k == N and i*s1 + j*s2 + k*s3 == Y :
                        print(i, j, k)
                        ok_flg = True
                        break
                if ok_flg == True :
                    break
        if ok_flg == True :
            break
        
if ok_flg == False :
    print("-1 -1 -1")

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

s1, s2, s3 = 10, 5, 1
ok_flg = False

if Y % 1000 != 0 :
    print("-1 -1 -1")    
else :
    y_small = int(Y / 1000)
    for i in range(N + 1) :
        if y_small - i * s1 <= (N - i) * s2 :
            for j in range(N - i + 1) :
                if i + j <= N and i*s1 + j*s2 + (N - i - j)*s3 == y_small :
                    print(i, j, N - i - j)
                    ok_flg = True
                    break
                if ok_flg == True :
                    break
            if ok_flg == True :
                break
    if ok_flg == False :
        print("-1 -1 -1")
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())

a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
c = [int(x) for x in input().split()]

lc, uc = {}, {}

for i in b :
    cnt_l, cnt_u = 0, 0
    
    for j in a :
        if j < i :
            cnt_l += 1
            
    lc[i] = cnt_l
    
    for j in c :
        if j > i :
            cnt_u += 1
            
    uc[i] = cnt_u
    
combs = 0
for i in b :
    combs += lc[i] * uc[i]
    
print(combs)
            

Fixed submission:
N = int(input())
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
c = [int(x) for x in input().split()]

a_s, b_s, c_s = sorted(a), sorted(b), sorted(c)

a_idx, c_idx = 0, 0
small_at, big_at = [], []
small_cnt, big_cnt = 0, 0

for i in b_s :
    while a_idx < N and a_s[a_idx] < i :
        a_idx += 1
        small_cnt += 1
        
    while c_idx < N and c_s[c_idx] <= i :
        c_idx += 1
        big_cnt += 1
        
    small_at.append(small_cnt)
    big_at.append(big_cnt)
    
sum_comb = 0 
for i in range(N) :
    sum_comb += small_at[i] * (N - big_at[i])

print(sum_comb)