Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
from sys import stdin
n,k = map(int,stdin.readline().split())
a = []
for i in xrange(n):
 a.append(map(int,stdin.readline().split()))
def solve(i,j):
 cnt = 0
 minx = min(a[i][0],a[j][0])
 maxx =  max(a[i][0],a[j][0])
 miny = min(a[i][1],a[j][1])
 maxy = max(a[i][1],a[j][1])
 #print "solving",i,j,minx,maxx,miny,maxy
 for m in xrange(n):
  if a[m][0]>=minx and a[m][0]<=maxx and a[m][1]>=miny and a[m][1]<=maxy:
   cnt+=1
 #print "has",cnt
 if cnt>=k:
  return (maxx-minx)*(maxy-miny)
 return 10**100
ans = 10**50
for i in xrange(n):
 for j in xrange(i+1,n):
  ans = min(ans,solve(i,j))
print ans

Fixed submission:
from sys import stdin
a,b,c = map(int,stdin.readline().split())
print a^b^c

Buggy python submission (verdict: Runtime Error):
from sys import stdin
n,k = map(int,stdin.readline().split())
a = []
for i in xrange(n):
 a.append(map(int,stdin.readline().split()))
def solve(i,j):
 cnt = 0
 minx = min(a[i][0],a[j][0])
 maxx =  max(a[i][0],a[j][0])
 miny = min(a[i][1],a[j][1])
 maxy = max(a[i][1],a[j][1])
 for m in xrange(n):
  if a[i][0]>=minx and a[i][0]<=maxx and a[i][1]>=miny and a[i][1]<=maxy:
   cnt+=1
 if cnt>=k:
  return (maxx-minx+1)*(maxy-miny+1)
 return 10**100
ans = 10**50
for i in xrange(n):
 for j in xrange(i+1,n):
  ans = min(ans,solve(i,j))
print ans

Fixed submission:
from sys import stdin
a,b,c = map(int,stdin.readline().split())
print a^b^c
Buggy python submission (verdict: Runtime Error):
from sys import stdin
ans = 'No'
n,m,k = map(int,stdin.readline().split())
for i in xrange(n+1):
 for j in xrange(m+1):
  if i*m - b*j==k:
   ans = 'Yes'
print ans

Fixed submission:
from sys import stdin
s = stdin.readline().strip()
ans = 'No'
if s.startswith('YAKI'):
 ans = 'Yes'
print ans
Buggy python submission (verdict: Runtime Error):
from sys import stdin
ans = 'No'
n,m,k = map(int,stdin.readline().split())
for i in xrange(n+1):
 for j in xrange(m+1):
  if i*m - b*j==k:
   ans = 'Yes'
print ans

Fixed submission:
from sys import stdin
ans = 'No'
n,m,k = map(int,stdin.readline().split())
for i in xrange(n+1):
    for j in xrange(m+1):
        if i*m - 2*j*i + j*n==k:
            ans = 'Yes'
print ans

Buggy python submission (verdict: Runtime Error):
from sys import stdin
ans = 'No'
n,m,k = map(int,stdin.readline())
for i in xrange(n+1):
 for j in xrange(m+1):
  if i*m - b*j==k:
   ans = 'Yes'
print ans

Fixed submission:
from sys import stdin
ans = 'No'
n,m,k = map(int,stdin.readline().split())
for i in xrange(n+1):
    for j in xrange(m+1):
        if i*m - 2*j*i + j*n==k:
            ans = 'Yes'
print ans
Buggy python submission (verdict: Runtime Error):
from sys import  stdin
n = in(stdin.readline())
a = int(stdin.readline())
print n*n-a

Fixed submission:
from sys import  stdin
n = int(stdin.readline())
a = int(stdin.readline())
print n*n-a
Buggy python submission (verdict: Runtime Error):
from sys import stdin
di = {}
n = int(stdin.readline())
a = map(int,stdin.readline().split())
for i in a:
 di[i] = di.get(i,0) + 1
 di[i-1] = di.get(i-1,0) + 1
 di[i+1] = di.get(i+1,0) + 1
ans = -5
print di
for i in di:
 if di[i] > di.get(ans,0):
  ans = 
print di[ans]

Fixed submission:
from sys import stdin
di = {}
n = int(stdin.readline())
a = map(int,stdin.readline().split())
for i in a:
 di[i] = di.get(i,0) + 1
 di[i-1] = di.get(i-1,0) + 1
 di[i+1] = di.get(i+1,0) + 1
ans = -5
for i in di:
 if di[i] > di.get(ans,0):
  ans = i
print di[ans]
Buggy python submission (verdict: Runtime Error):
from sys import stdin
n,m = map(int,stdin.readline().split())
ans = 'IMPOSSIBLE'
di = set()
for i in xrange(m):
 x,y = map(int,stdin.readline().split())
 di.add((min(x,y),max(x,y))
for i in xrange(2,n):
 fir = (1,i)
 sec = (i,n)
 if fir in di and sec in di:
  ans = 'POSSIBLE'; break
print ans

Fixed submission:
from sys import stdin
n,m = map(int,stdin.readline().split())
ans = 'IMPOSSIBLE'
di = set()
for i in xrange(m):
 x,y = map(int,stdin.readline().split())
 di.add((min(x,y),max(x,y)))
for i in xrange(2,n):
 fir = (1,i)
 sec = (i,n)
 if fir in di and sec in di:
  ans = 'POSSIBLE'; break
print ans
Buggy python submission (verdict: Runtime Error):
from sys import stdin
ma = 10**18
n = int(stdin.readline())
a = map(int,stdin.readline().split())
x = 0
s = sum(n)
for i in a[:-1]:
 x+= i
 ma  = min(ma, abs(s-2*x) )
print ma

Fixed submission:
from sys import stdin
ma = 10**18
n = int(stdin.readline())
a = map(int,stdin.readline().split())
x = 0
s = sum(a)
for i in a[:-1]:
 x+= i
 ma  = min(ma, abs(s-2*x) )
print ma

Buggy python submission (verdict: Runtime Error):
from sys import stdin
ma = 10**18
n = int(stdin.readline().split())
a = map(int,stdin.readline().split())
x = 0
s = sum(n)
for i in a[:-1]:
 x+= i
 ma  = min(ma, abs(s-2*x) )
print ma

Fixed submission:
from sys import stdin
ma = 10**18
n = int(stdin.readline())
a = map(int,stdin.readline().split())
x = 0
s = sum(a)
for i in a[:-1]:
 x+= i
 ma  = min(ma, abs(s-2*x) )
print ma
Buggy python submission (verdict: Runtime Error):
from sys import stdin
a = map(int,stdin.readline().split())
a.sort()
print a[0] + a[[1]

Fixed submission:
from sys import stdin
a = map(int,stdin.readline().split())
a.sort()
print a[0] + a[1]
Buggy python submission (verdict: Runtime Error):
from sys import stdin
s = stdin.readline().strip()
n = len(s)
n-=2
while True:
 if s[n/2]== s[n/2+1:n]:
  break
 n-=2
print n

Fixed submission:
from sys import stdin
s = stdin.readline().strip()
n = len(s)
n-=2
while True:
 if s[:n/2]== s[n/2:n]:
  break
 n-=2
print n
Buggy python submission (verdict: Runtime Error):
from sys import stdin 
a = [0]
n = int(stdin.readline())
for _ in xrange(n):
 a.append(int(stdin.readline())
ans = -1
cur = 0
x = 1
s = set()
while True:
 if x in s:
  break
 if x==2:
  ans = cur
  break
 s.add(x)
 cur+=1
 x = a[x]
print ans

Fixed submission:
from sys import stdin 
a = [0]
n = int(stdin.readline())
for _ in xrange(n):
 a.append(int(stdin.readline()))
ans = -1
cur = 0
x = 1
s = set()
while True:
 if x in s:
  break
 if x==2:
  ans = cur
  break
 s.add(x)
 cur+=1
 x = a[x]
print ans
Buggy python submission (verdict: Runtime Error):
from sys import stdin
n = int(stdin.readline())
a  = map(int,stdin.readline().split())
ans = set()
co = 0
for i in a:
 if i < 3200:
  ans.add(i/400)
 else:
  co += 1
print  max(1,len(ans)),len(ans) + co

Fixed submission:
from sys import stdin
ans = 'NO'
r,g,b = map(int,stdin.readline().split())
if (r*100 + g *10 + b) %4==0:
 ans = 'YES'
print ans
Buggy python submission (verdict: Runtime Error):
from sys import stdin
a = int(stdin.readline())
b = int(stdin.readline())
ans = 'GREATER'
if a < b:
 ans = 'LESS'
elilf a==b:
 ans = 'EQUAL'
print ans

Fixed submission:
from sys import stdin
a = int(stdin.readline())
b = int(stdin.readline())
ans = 'GREATER'
if a < b:
 ans = 'LESS'
elif a==b:
 ans = 'EQUAL'
print ans
Buggy python submission (verdict: Runtime Error):
    from sys import stdin
    n = int(stdin.readline())
    a = []
    for _ in xrange(n):
        s = stdin.readline().strip()
        di = {}
        for i in s:
            di[i] = di.get(i,0) + 1
        a.append(di)       
    ans = ''
    b = 'abcdefghijklmnopqrstuvwxyz'
    for i in b:
        x = 10**5
        for yy in a:
            x = min(x, yy.get(i,0))
        ans += x*i
    print ans    

Fixed submission:
from sys import stdin
n = int(stdin.readline())
a = []
for _ in xrange(n):
    s = stdin.readline().strip()
    di = {}
    for i in s:
        di[i] = di.get(i,0) + 1
    a.append(di)       
ans = ''
b = 'abcdefghijklmnopqrstuvwxyz'
for i in b:
    x = 10**5
    for yy in a:
        x = min(x, yy.get(i,0))
    ans += x*i
print ans
Buggy python submission (verdict: Runtime Error):
    from sys import stdin
    n,m = map(int,stdin.readline().split())
    a = map(int,stdin.readline().split())
    b = map(int,stdin.readline().split())
    a.sort()
    b.sort()
    x = []
    y = []
    for i in xrange(1,n):
        x.append(a[i] - a[i-1])
    for i in xrange(1,m):
        y.append(b[i] - b[i-1])   
    fir = 0
    sec = 0
    n = len(x)
    m = len(y)
    for i in xrange(n):
        fir += (i+1) * (n-i)*x[i]
    for i in xrange(m):
        sec += (i+1) * (m-i) * y[i]
    mod = 10**9 + 7
    print (fir * sec)%mod

Fixed submission:
from sys import stdin
n,m = map(int,stdin.readline().split())
a = map(int,stdin.readline().split())
b = map(int,stdin.readline().split())
a.sort()
b.sort()
x = []
y = []
for i in xrange(1,n):
    x.append(a[i] - a[i-1])
for i in xrange(1,m):
    y.append(b[i] - b[i-1])   
fir = 0
sec = 0
n = len(x)
m = len(y)
for i in xrange(n):
    fir += (i+1) * (n-i)*x[i]
for i in xrange(m):
    sec += (i+1) * (m-i) * y[i]
mod = 10**9 + 7
print (fir * sec)%mod
Buggy python submission (verdict: Runtime Error):
from sys import stdin
a = 'CODEFESTIVAL2016'
l = len(a)
b = stdin.readline().strip()
ans = 0
for i in xrange(l):
 if a[l]!=b[l]:
  ans+=1
print ans

Fixed submission:
from sys import stdin
a = 'CODEFESTIVAL2016'
l = len(a)
b = stdin.readline().strip()
ans = 0
for i in xrange(l):
 if a[i]!=b[i]:
  ans+=1
print ans
Buggy python submission (verdict: Time Limit Exceeded):
# cook your code here
from sys import stdin
a = stdin.readline().strip()
l = len(a)
for i in xrange(l):
    a = a.replace('ST','')
print len(a)    

Fixed submission:
# cook your code here
from sys import stdin
a = stdin.readline().strip()
l = len(a)
s = 0
t = 0
i = l-1
while i>=0:
    if a[i]=='T':
        t+=1 
    else:
        if t>0:
            t-=1 
        else:
            s+=1
    i-=1 
print s+t
Buggy python submission (verdict: Runtime Error):
the_string = raw_input()
COLS, ROWS = the_string.split()
two_string = raw_input()
co, ro = two_string.split()


Mylist= [[0 for cols in range(int(COLS))] for rows in range(int(ROWS))]

for cols in range(int(co)):
        for rows in range(int(ROWS)):
                Mylist[rows][cols]=1

for rows in range(int(ro)):
        for cols in range(int(COLS)):
                Mylist[rows][cols]=1

d = sum(row.count(0) for row in Mylist)

print(d)

Fixed submission:
the_string = raw_input()
COLS, ROWS = the_string.split()
two_string = raw_input()
co, ro = two_string.split()


Mylist= [[0 for cols in range(int(COLS))] for rows in range(int(ROWS))]

for cols in range(int(co)):
        for rows in range(int(ROWS)):
                Mylist[rows][cols]=1

for rows in range(int(ro)):
        for cols in range(int(COLS)):
                Mylist[rows][cols]=1

d = sum(row.count(0) for row in Mylist)

print(d)
Buggy python submission (verdict: Runtime Error):
def divde(argv):

    dlist=[]
    i = 1
    for i in range (1,int(argv)+1):
        if(int(argv)%i==0):
            dlist.append(i)
    return dlist

def compare(A,B):
    D =[]
    for i in range (len(A)):
        for j in range(len(B)):
            if A[i]==B[j]:
                D.append(B[j])
    return D

if __name__ == "__main__":
    string = input()
    a, b, c = string.split()

    A = []
    A = divde(a)
    B = []
    B = divde(int(b))
    D = []
    D = compare(A,B)

    D.reverse()

    q = D.index(int(c))
    print(q+1)

Fixed submission:
def divde(argv):

    dlist=[]
    i = 1
    for i in range (1,int(argv)+1):
        if(int(argv)%i==0):
            dlist.append(i)
    return dlist

def compare(A,B):
    D =[]
    for i in range (len(A)):
        for j in range(len(B)):
            if A[i]==B[j]:
                D.append(B[j])
    return D

if __name__ == "__main__":
    string = input()
    a, b, c = string.split()

    A = []
    A = divde(a)
    B = []
    B = divde(int(b))
    D = []
    D = compare(A,B)

    D.reverse()

    q = int(c)-1
    print(D[q])

Buggy python submission (verdict: Runtime Error):
def divde(argv):

    dlist=[]
    i = 1
    for i in range (1,int(argv)+1):
        if(int(argv)%i==0):
            dlist.append(i)
    return dlist

def compare(A,B):
    D =[]
    for i in range (len(A)):
        for j in range(len(B)):
            if A[i]==B[j]:
                D.append(B[j])
    return D

if __name__ == "__main__":
    string = input()
    a, b, c = string.split()

    A = []
    A = divde(a)
    B = []
    B = divde(int(b))
    D = []
    D = compare(A,B)

    D.reverse()

    q = D.index(int(c))
    print(q+1)

Fixed submission:
def divde(argv):

    dlist=[]
    i = 1
    for i in range (1,int(argv)+1):
        if(int(argv)%i==0):
            dlist.append(i)
    return dlist

def compare(A,B):
    D =[]
    for i in range (len(A)):
        for j in range(len(B)):
            if A[i]==B[j]:
                D.append(B[j])
    return D

if __name__ == "__main__":
    string = input()
    a, b, c = string.split()

    A = []
    A = divde(a)
    B = []
    B = divde(int(b))
    D = []
    D = compare(A,B)

    D.reverse()

    q = int(c)-1
    print(D[q])
Buggy python submission (verdict: Runtime Error):
l = list(map(int, input().split()))
l1 = []
a, b, c = l[0], l[1], l[2]
m = min(a,b)

for i in range(1, m+1):
  if a%i==0 and b%i==0:
    l1.append(i)

print(sorted(set(l1))[c-1])

Fixed submission:
l = list(map(int, input().split()))
a, b, c = l[0], l[1], l[2]

if b/a>c:
  print(c)
else:
  print(int(b/a))

Buggy python submission (verdict: Runtime Error):
l = list(map(int, input().split()))
l1 = []
a, b, c = l[0], l[1], l[2]
m = min(a,b)

for i in range(1, m+1):
  if a%i==0 and b%i==0:
    l1.append(i)

print(sorted(set(l1))[c-1])

Fixed submission:
l = list(map(int, input().split()))
a, b, c = l[0], l[1], l[2]

if b/a>c:
  print(c)
else:
  print(int(b/a))
Buggy python submission (verdict: Runtime Error):
    a, b = map(int, input().split())
    c, d = map(int, input().split())
    if (a*b)==(c*d):
     print((a*b)-(c*d))
    elif (a*b) > (c*d):
     print(c*d)

Fixed submission:
a, b = map(int, input().split())
c, d = map(int, input().split())
print((a-c)*(b-d))

Buggy python submission (verdict: Runtime Error):
a, b = map(int, input().split())
c, d = map(int, input().split())
if (a*b)==(c*d):
 print((a*b)-(c*d))
else if (a*b) > (c*d):
 print(c*d)

Fixed submission:
a, b = map(int, input().split())
c, d = map(int, input().split())
print((a-c)*(b-d))

Buggy python submission (verdict: Runtime Error):
a, b = map(int, input().split())
c, d = map(int, input().split())
if (a*b)==(c*d):
 print((a*b)-(c*d))
else if (a*b) > (c*d):
 print((c*d))

Fixed submission:
a, b = map(int, input().split())
c, d = map(int, input().split())
print((a-c)*(b-d))

Buggy python submission (verdict: Runtime Error):
a, b = map(int, input().split())
c, d = map(int, input().split())
if (a*b)==(c*d):
 print("0")
else if (a*b ) > (c*d):
  print(c*d)

Fixed submission:
a, b = map(int, input().split())
c, d = map(int, input().split())
print((a-c)*(b-d))

Buggy python submission (verdict: Runtime Error):
a, b = map(int, input().split())
c, d = map(int, input().split())
if (a*b)==(c*d):
 print((a*b)-(c*d))
else if (a*b ) > (c*d):
  print((c*d))

Fixed submission:
a, b = map(int, input().split())
c, d = map(int, input().split())
print((a-c)*(b-d))

Buggy python submission (verdict: Runtime Error):
a, b = map(int, input().split())
c, d = map(int, input().split())
if (a*b)==(c*d):
 print((a*b)-(c*d))
elseif (a*b ) > (c*d):
  print((c*d))

Fixed submission:
a, b = map(int, input().split())
c, d = map(int, input().split())
print((a-c)*(b-d))

Buggy python submission (verdict: Runtime Error):
a, b = map(int, input().split())
c, d = map(int, input().split())
[print("0") if (a*b)=(c*d) else print(c*d)]

Fixed submission:
a, b = map(int, input().split())
c, d = map(int, input().split())
print((a-c)*(b-d))
Buggy python submission (verdict: Runtime Error):
import bisect
a, b, q = list(map(int, input().split()))
s = [int(input()) for _ in range(a)]
t = [int(input()) for _ in range(b)]
x = [int(input()) for _ in range(q)]
s.sort()
t.sort()
for i in x:
    si = bisect.bisect(s, i)
    ti = bisect.bisect(t, i)
    sl = s[si-1] if si > 0 else s[0]
    sr = s[si] if si < a else s[-1]
    tl = t[ti-1] if ti > 0 else t[0]
    tr = t[ti] if ti < a else t[-1]
    print(min(
        abs(i-sl)+abs(sl-tl),
        abs(i-sl)+abs(sl-tr),
        abs(i-sr)+abs(sr-tl),
        abs(i-sr)+abs(sr-tl),
        abs(i-tl)+abs(sl-tl),
        abs(i-tl)+abs(sr-tl),
        abs(i-tr)+abs(sl-tr),
        abs(i-tr)+abs(sr-tr),
    ))

Fixed submission:
import bisect
a, b, q = list(map(int, input().split()))
s = [int(input()) for _ in range(a)]
t = [int(input()) for _ in range(b)]
x = [int(input()) for _ in range(q)]
s.sort()
t.sort()
for i in x:
    si = bisect.bisect(s, i)
    ti = bisect.bisect(t, i)
    sl = s[si-1] if si > 0 else s[0]
    sr = s[si] if si < a else s[-1]
    tl = t[ti-1] if ti > 0 else t[0]
    tr = t[ti] if ti < b else t[-1]
    print(min(
        abs(i-sl)+abs(sl-tl),
        abs(i-sl)+abs(sl-tr),
        abs(i-sr)+abs(sr-tl),
        abs(i-sr)+abs(sr-tr),
        abs(i-tl)+abs(sl-tl),
        abs(i-tl)+abs(sr-tl),
        abs(i-tr)+abs(sl-tr),
        abs(i-tr)+abs(sr-tr),
    ))
Buggy python submission (verdict: Runtime Error):
a, b = [int(x) for x in input().split()]

return a * b - a - b + 1

Fixed submission:
a, b = [int(x) for x in input().split()]
 
print(a * b - a - b + 1)
Buggy python submission (verdict: Runtime Error):
def main():
    _ = input()
    a_list = map(int, input().split())
    b_list = map(int, input().split())
    diffs = map(lambda a, b: b - a, a_list, b_list)
    total = 0
    count = 0
    for diff in diffs:
        if diff > 0:
            count += diff // 2
            total += diff % 2
        else:
            count += -diff
            total += diff
    if count <= total:
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main()


Fixed submission:
import itertools


def main():
    x, y = map(int, input().split())
    if x % y == 0:
        result = -1
    else:
        result = next(filter(lambda i: i % y != 0, map(lambda i: i * x, itertools.count(1))))
    print(result)


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Runtime Error):
def main():
    _ = input()
    a_list = map(int, input().split())
    b_list = map(int, input().split())
    diffs = map(lambda a, b: b - a, a_list, b_list)
    total = 0
    count = 0
    for diff in diffs:
        if diff > 0:
            count += (diff + 1) // 2
            total += diff % 2
        else:
            count += -diff
            total += diff
    if count >= total:
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main()


Fixed submission:
import itertools


def main():
    x, y = map(int, input().split())
    if x % y == 0:
        result = -1
    else:
        result = next(filter(lambda i: i % y != 0, map(lambda i: i * x, itertools.count(1))))
    print(result)


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
usr_input = input()
lst = usr_input.split()

a = int(lst[0])
b = int(lst[1])
c = int(lst[2])

devider_a=[]
devider_b=[]
for i in range(1,a,1):
    if a%i == 0:
        devider_a.append(i)

for i in range(1,b,1):
    if b % i == 0:
        devider_b.append(i)

common_devider = []
for element in devider_a:
    for value in devider_b:
        if element==value:
            common_devider.append(value)

print(common_devider[c-1])


Fixed submission:
usr_input = input()
lst = usr_input.split()

a = int(lst[0])
b = int(lst[1])
c = int(lst[2])

if b//a < c:
    print(b//a)
else:
    print(c)
Buggy python submission (verdict: Runtime Error):
n,m = [int(x) for x in input().split()]
l = [list(map(int,input().split())) for _ in range(n)]
l.sort()
cost = 0
for x in range(n):
    if m == 0:
        exit()
    if l[x][1] <= m:
        cost += l[x][0]*l[x][1]
    else:
        cost += l[x][0]*m
    m -= l[x][1]
print(cost)

Fixed submission:
H,W = [int(x) for x in input().split()]
h,w = [int(x) for x in input().split()]
print((H-h)*(W-w))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
i = 1
for n in range(N):
    i = i*(n+1)
print(i%(10**9+7))

Fixed submission:
N = int(input())
i = 1
for n in range(N):
    i = i*(n+1)%(10**9+7)
print(i)
Buggy python submission (verdict: Runtime Error):
n = int(input())

if n < int("1" + "9"*(len(str(n))-1)):
	s = 9*(len(str(n))-1)
else:
	for i in range(1,10)[::-1]:
		if n > int(str(i) + "9"*(len(str(n))-1)):
			s = i + 9*(len(str(n))-1)
			break

print(s)

Fixed submission:
n = int(input())

for i in range(10)[::-1]:
	if n >= int(str(i) + '9'*(len(str(n))-1)):
		print(i + 9*(len(str(n))-1))
		break
Buggy python submission (verdict: Runtime Error):
A, B = [int(i) for i in raw_input().split()]
print(reduce((lambda x,y:(x|y)-(x&y)),range(A,B+1)))

Fixed submission:
A, B = [int(i) for i in raw_input().split()]


def func(n, m):
	return int((n + 1) / (2 ** m)) * 2 ** (m - 1) + max(0, (n + 1) % (2 ** m) - 2 ** (m - 1))

print sum((func(B, i) - func(A-1, i)) % 2 * 2 ** (i - 1) for i in range(1, 64))
Buggy python submission (verdict: Runtime Error):
question="C"
input=raw_input
if question=="A":
	t=input()
	t=t.replace("9","n")
	t=t.replace("1","o")
	t=t.replace("n","1")
	t=t.replace("o","9")
	print(t)
if question=="B":
	s=int(input())
	t=[111,222,333,444,555,666,777,888,999]
	t=filter(lambda x:x>=s,t)[0]
	print(t)
if question=="C":
	N=int(input())
	a=map(int,input().split())
	A=Amoto=a[0:][::2]
	B=Bmoto=a[1:][::2]
	def f(x):
		a=[(i, x.count(i)) for i in set(x)]
		a=sorted(a,key=lambda x:-x[1])
		return a
	A=f(A)
	B=f(B)
	if A[0][1]<B[0][1]:
		A,B=B,A
	A=A[0][0]
	B.append((0,0))
	B=filter(lambda x:(x[0]!=A),B)[0][0]
	print N-Amoto.count(A)-Bmoto.count(B)
if question=="D":
	pass
if question=="E":
	pass

Fixed submission:
question="A"
input=raw_input
if question=="A":
	t=input()
	t=t.replace("9","n")
	t=t.replace("1","o")
	t=t.replace("n","1")
	t=t.replace("o","9")
	print(t)
if question=="B":
	pass
if question=="C":
	pass
if question=="D":
	pass
if question=="E":
	pass

Buggy python submission (verdict: Runtime Error):
question="C"
input=raw_input
if question=="A":
	t=input()
	t=t.replace("9","n")
	t=t.replace("1","o")
	t=t.replace("n","1")
	t=t.replace("o","9")
	print(t)
if question=="B":
	s=int(input())
	t=[111,222,333,444,555,666,777,888,999]
	t=filter(lambda x:x>=s,t)[0]
	print(t)
if question=="C":
	input()
	a=input().split()
	A=Amoto=a[0:][::2]
	B=Bmoto=a[1:][::2]
	def f(x):
		a=[(i, x.count(i)) for i in set(x)]
		a=sorted(a,key=lambda x:-x[1])
		return a
	A=f(A)
	B=f(B)
	if A[0][1]<B[0][1]:
		A,B=B,A
	A=A[0][0]
	B.append(("X",0))
	B=filter(lambda x:(x[0]!=A),B)[0][0]
	print sum(i!=A for i in Amoto) + sum(i!=B for i in Bmoto)
if question=="D":
	pass
if question=="E":
	pass

Fixed submission:
question="A"
input=raw_input
if question=="A":
	t=input()
	t=t.replace("9","n")
	t=t.replace("1","o")
	t=t.replace("n","1")
	t=t.replace("o","9")
	print(t)
if question=="B":
	pass
if question=="C":
	pass
if question=="D":
	pass
if question=="E":
	pass
Buggy python submission (verdict: Runtime Error):
#入力
N = int(input())
A = int(input())
B = int(input())

#Nの範囲内の数値をリストに格納
N_list = list(range(1, N+1))

#条件に合うNの値を格納するリストを作成
N_match = []


#以下の処理をNの範囲で繰り返す
for n in N_list:
    
    #最後の処理（※）のためにnを別の値に代入しておく
    i = n

    #各桁の数値を求める
    #余りを格納するリストを作成
    R_list = []

    while True:
    
        #1の位の数値を算出しリストに順に格納
        R = n%10   
        R_list.append(R)    
    
        #10で割ることで、1の位を削る
        n = int(n/10)
    
        #1の位を削った時、N==0となった場合処理終了
        if n==0:
            break
    
    
    #あるnにおける各桁の和を算出
    R_sum = sum(R_list)
    
    #（※）条件に合致した時、その時のnをリストに格納
    if A<=R_sum<=B:
        N_match.append(i)
               
print(sum(N_match))

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

#Nの範囲内の数値をリストに格納
N_list = list(range(1, N+1))

#条件に合うNの値を格納するリストを作成
N_match = []


#以下の処理をNの範囲で繰り返す
for n in N_list:
    
    #最後の処理（※）のためにnを別の値に代入しておく
    i = n

    #各桁の数値を求める
    #余りを格納するリストを作成
    R_list = []

    while True:
    
        #1の位の数値を算出しリストに順に格納
        R = n%10   
        R_list.append(R)    
    
        #10で割ることで、1の位を削る
        n = int(n/10)
    
        #1の位を削った時、N==0となった場合処理終了
        if n==0:
            break
    
    
    #あるnにおける各桁の和を算出
    R_sum = sum(R_list)
    
    #（※）条件に合致した時、その時のnをリストに格納
    if A<=R_sum<=B:
        N_match.append(i)
               
print(sum(N_match))