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

Fixed submission:
N,x = map(int,input().split())
A = list(map(int,input().split()))	
ans=0
A.sort()
for i in A:
    x=x-i
    if x >= 0:
        ans=ans+1
if x > 0:
    ans= ans-1
print(ans)

Buggy submission (verdict: Runtime Error):
N,x = map(int,input().split())
A = list(map(int,input().split()))	
ans=0
A.sort()
for i in A:
    x=x-i
    if x < 0:
    
    else:
        ans=ans+1
print(ans)
Problem p03289 (python)

Fixed submission:
import re
S = list(input())
S2=''.join(S)
ans=0
cou=2
Ccou=0
A=S.count('A')
C=S.count('C')
jud = len(re.findall('[A-Z]', S2))
rep=len(S)-2
if S[0]=='A':
    ans=+1
rep=len(S)-2
for i in range(1,rep):
    if S[cou]=='C':
        Ccou=Ccou+1
    cou=cou+1
if Ccou == 1:
    ans=ans+1
if ans ==2 and A==1 and C==1 and jud==2:
    print("AC")
else:
    print("WA")

Buggy submission (verdict: Runtime Error):
import re
S = list(input())
ans=0
cou=2
Ccou=0
A=S.count('A')
C=S.count('C')
jud = len(re.findall('[a-z]', S))
rep=len(S)-2
if S[0]=='A':
    ans=+1
rep=len(S)-2
for i in range(1,rep):
    if S[cou]=='C':
        Ccou=Ccou+1
    cou=cou+1
if Ccou == 1:
    ans=ans+1
if ans ==2 and A==1 and C==1 and jud==2:
    print("AC")
else:
    print("WA")
Problem p03474 (python)

Fixed submission:

A,B =map(int,input().split())
hih=0
num=1
test=1
S=str(input())
S= list(S)
for s in S:
    if num==A+1 and s=="-":
        hih=1
    if num!=A+1 and s=="-":
        test=0
        
    
    num+=1
if hih==1 and test==1:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
A,B =map(int,input().split())
hih=0
num=1
JG=1
S=int(input())
S= list(str(S))
for s in S:
    if s=="-":
        hih=num 
    num+=1
for s in S:
    if s=="0" or s=="1" or s=="2" or s=="3" or s=="4" or s=="5" or s=="6" or s=="7" or s == "8" or s=="9":
    else:
        JG=0
if hih==A & JG==1:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
A,B =map(int,input().split())
hih=0
num=1
S=int(input())
S= list(str(S))
for s in S:
    if s=="-":
        hih=num
    num+=1
if hih==A:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
A,B =map(int,input().split())
hih=0
num=2
S=int(input())
S= list(str(S))
for s in S:
    if s=="-":
        hih=num
    num+=1
if hih==A:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
A,B =map(int,input().split())
hih=0
num=2
S=int(input())
S= list(str(S))
for s in S:
    if s=="-":
        hih=num
    num+=1
if hih==A:
    print(Yes)
else:
    print(No)
Problem p03624 (python)

Fixed submission:
S=list(input())
S= list(set(S))
J=[]
S.sort()
for i in range(97,123):
    A=chr(i)
    J.append(A)
for i in S:
    J.remove(i)
if len(J)==0:
    print('None')
else:
    print(J[0])

Buggy submission (verdict: Runtime Error):
S=list(input())
S= list(set(S))
J=[]
S.sort()
for i in range(97,123):
    A=chr(i)
    J.append(A)
for i in S:
    J.remove(i)
print(J[0])
Problem p03807 (python)

Fixed submission:
N=int(input())
A=list(map(int,input().split()))
Even = []
Odd = []
A.sort()
for a in A:
    if a % 2 == 0:
        Even.append(a)
    if a % 2 == 1:
        Odd.append(a)
if len(Odd) % 2 == 1:
    print('NO')
else:
    print('YES')

Buggy submission (verdict: Runtime Error):
N=int(input())
A=list(map(int,input().split()))
Even = []
Odd = []
A.sort()
for a in A:
    if a % 2 == 0:
        a.append(Even)
    if a % 2 == 1:
        a.append(Odd)
if len(Odd) % 2 == 1:
    print('NO')
else:
    print('YES')
Problem p03220 (python)

Fixed submission:
N = int(input())
T, A  = map(int, input().split())
hight_list = list(map(int, input().split()))
 
ans = 10000
ans_ind = 0
 
for i in range(N):
  temp = T - 0.006 * hight_list[i]
  diff = abs(temp - A)
  if  diff < ans:
    ans = diff
    ans_ind = i
    
print(ans_ind+1)

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

ans = 10000
ans_ind

for i in range(N):
  temp = T - 0.006 * hight_list[i]
  diff = abs(temp - A)
  if  diff < ans:
    ans = diff
    ans_ind = i
    
print(i+1)
Problem p03308 (python)

Fixed submission:
N = int(input())
num_lists = list(map(int, input().split()))
max_num = max(num_lists)
min_num = min(num_lists)
ans = max_num - min_num
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
num_lists = list(map(int, input().split))
max_num = max(num_lists)
min_num = min(num_lists)
ans = max_num - min_num
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
num_lists = list(map(int, input().split))
ans = - 1

for i in num_lists:
  for j in num_lists:
    diff = abs(i - j)
    if diff > ans:
      ans = diff

print(ans)

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

for i in num_lists:
  for j in num_lists:
    diff = abs(i - j)
    if diff > ans:
      ans = diff

print(ans)
Problem p03370 (python)

Fixed submission:
N, X = map(int, input().split())
m = [int(input()) for i in range(N)]
 
print(N + (X-sum(m))//min(m))

Buggy submission (verdict: Runtime Error):
N, X = map(int,input().split())
powder_list = [int(input()) for i in range(n)]
min_powder = min(powder_list)
ans = N
X -= sum(powder_list)
num = X//min_powder
print(ans + num )

Buggy submission (verdict: Runtime Error):
N, X = map(int,input().split())
powder_list = [int(input()) for i in range(n)]
min_powder = min(powder_list)
ans = N
X -= sum(powder_list)
print(ans + X//min_powder)

Buggy submission (verdict: Runtime Error):
N, X = map(int,input().split())
powder_list = [int(input()) for i in range(n)]
min_powder = min(powder_list)
ans = N
X -= sum(powder_list)
print(ans + X//d)
Problem p03434 (python)

Fixed submission:
N = int(input())
 
card = list(map(int, input().split()))
card.sort(reverse=True)
 
Alice = 0
Bob = 0
for i in range(N):
  if i % 2 == 0:
    Alice += card[i]
  else:
    Bob += card[i]
    
print(Alice - Bob)

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

card = list(map(int, input().split()))
sorted_card = card.sort(reverse=True)

Alice = 0
Bob = 0
for i in range(N):
  if i % 2 == 0:
    Alice += sorted_card[i]
  else:
    Bob += sorted_card[i]
    
print(Alice - Bob)

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

card = list(map(int, input().split())).sort(reverse= True)

Alice = 0
Bob = 0
for i in range(N):
  if i % 2 == 0:
    Alice += card[i]
  else:
    Bob += card[i]
    
print(Alice - Bob)
Problem p03469 (python)

Fixed submission:
s = input()

print("2018/01/" + s[-2:])

Buggy submission (verdict: Runtime Error):
s = input()
s[3] = "8"
print(s)

Buggy submission (verdict: Runtime Error):
s = input
s[3] = "8"
print(s)

Buggy submission (verdict: Runtime Error):
a = input()

a[3] = 8
print(a)

Buggy submission (verdict: Runtime Error):
a, b = input().split()

a[3] = 8
print(a+b)

Buggy submission (verdict: Runtime Error):
a, b input().split()

a[3] = 8
print(a+b)
Problem p04043 (python)

Fixed submission:
X, Y, Z = map(int, input().split())
 
num_5 = 0
num_7 = 0
 
if X == 5:
  num_5 += 1
if Y == 5:
  num_5 += 1
if Z == 5:
  num_5 += 1
  
if X == 7:
  num_7 += 1
if Y == 7:
  num_7 += 1
if Z == 7:
  num_7 += 1
  
if num_5 == 2 and num_7 == 1:
    print("YES")
else:
    print("NO")

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

num_5 = 0
num_7 = 0

if X == 5:
  num_5 += 1
if Y == 5:
  num_5 += 1
if Z == 5:
  num_5 += 1
  
if X == 7:
  num_7 += 1
if Y == 7:
  num_7 += 1
if Z == 7:
  num_7 += 1

if num_5 == 2 && num_7 == 1:
    print("YES")
else:
    print("NO")
Problem p04044 (python)

Fixed submission:
N,L =map(int,input().split())
s=sorted([input() for i in range(N)])
print(*s,sep="")

Buggy submission (verdict: Runtime Error):
N, L = map(int, input().split())
s = [input() for i in range(n)]
s = sorted(s)
print(*s, sep="")

Buggy submission (verdict: Runtime Error):
N, L = map(int, input().split())
s = [input() for i in range(n)].sort()
print(*s, sep="")
Problem p03469 (python)

Fixed submission:
#codinf:UTF-8
s = input()
print(s.replace("2017","2018"))

Buggy submission (verdict: Runtime Error):
#codinf:UTF-8
s = input()
print(s.replace("2017","2018")
Problem p03485 (python)

Fixed submission:
# coding:UTF-8
import math
work = input().split(" ")
a = int(work[0])
b = int(work[1])
print(math.ceil((a+b)/2))

Buggy submission (verdict: Runtime Error):
# coding:UTF-8
import math
work = input().split(" ")
a = int(work[0])
b = int(wokr[1])
print(math.ceil((a+b)/2))
Problem p03636 (python)

Fixed submission:
#coding:UTF-8
s = input()
print(s[0] + str(len(s)-2) + s[-1])

Buggy submission (verdict: Runtime Error):
#coding:UTF-8
s = input()
print(s[0] + (len(s)-2) + s[-1])
Problem p03644 (python)

Fixed submission:
#coding:UTF-8
num = int(input())
max=0
for i in range(1,num+1):
  count=0
  work=i
  while work%2==0:
    work=work//2
    count = count+1
#    print("i:{} count:{} max:{}".format(i,count,max))
  if max<count:
    max=count
    ans=i
if(max==0):
  print(1)
else:
  print(ans)

Buggy submission (verdict: Runtime Error):
#coding:UTF-8
num = int(input())
max=0
for i in range(1,num+1):
  count=0
  work=i
  while work%2==0:
    work=work//2
    count = count+1
#    print("i:{} count:{} max:{}".format(i,count,max))
  if max<count:
    max=count
    ans=i
if(max==0):
  print(1)
print(ans)

Buggy submission (verdict: Runtime Error):
#coding:UTF-8
num = int(input())
max=0
for i in range(1,num+1):
  count=0
  work=i
  while work%2==0:
    work=work//2
    count = count+1
#    print("i:{} count:{} max:{}".format(i,count,max))
  if max<count:
    max=count
    ans=i
print(ans)

Buggy submission (verdict: Runtime Error):
#coding:UTF-8
num = int(input())
max=0
for i in range(1,num+1):
  count=0
  work=i
  while work%2==0:
    work=work//2
    count = count+1
#    print("i:{} count:{} max:{}".format(i,count,max))
  if max<count:
    max=count
    ans=i
print(ans)
Problem p03693 (python)

Fixed submission:
#coding:UTF-8
work = input().split(" ")
r = int(work[0])
b = int(work[1])
g = int(work[2])
num = r*100 + b*10 +g
if(num % 4 == 0):
  print("YES")
else:
  print("NO")

Buggy submission (verdict: Runtime Error):
#coding:UTF-8
work = input().split(" ")
r = int(work[0])
b = int(work[1])
g = int(work[2])
num = r*100 + b*10 +c
if(num % 4 == 0):
  print("YES")
else:
  print("NO")
Problem p03260 (python)

Fixed submission:
a, b = map(int, input().split())
X = a*b
if X == 2 or X ==4 or X==6:
	print('No')
else:
	print('Yes')

Buggy submission (verdict: Runtime Error):
d = {}

i = int(input())

for m in range(i):
	word = input()
	d[m] = word
for n in range(1, i):
	h = n - 1
	a = d[h]
	b = d[n]
	if a[-1] == b[0]:
		continue
	else:
		print('No')
		exit()
for x in range (i - 1):
	for j in range (x + 1, i):
		if d[x] == d[j]:
			print('No')
			exit()
print('Yes')
Problem p03324 (python)

Fixed submission:
import sys 
import math

a, b = map(int, input().split(" "))
if b == 100:
    print(100**a*b+100**a)
else:
    print(100**a*b)

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

a, b = map(int, input().split(" "))
if N == 100:
     print(100**a*b+1)
else:
    print(100**a*b)
Problem p03813 (python)

Fixed submission:
x = int(input())

print ('ABC' if x < 1200 else 'ARC')

Buggy submission (verdict: Runtime Error):
string = input()

z_idx = len(string) - string[::-1].index('Z') - 1

a_idx = string.index('A')

print (z_idx - a_idx + 1)
Problem p03837 (python)

Fixed submission:
N,M=map(int,input().split())
Islands=[[10**9]*N for i in range(N)]
Edge=[]
S=0
for i in range(M):
  a,b,c=map(int,input().split())
  Islands[a-1][b-1]=c
  Islands[b-1][a-1]=c
  Edge.append([a-1,b-1,c])
for k in range(N):
  for i in range(N):
    for j in range(N):
      Islands[i][j]=min(Islands[i][j],Islands[i][k]+Islands[k][j])

ans=0
for a,b,c in Edge:
  if Islands[a][b]!=c:
    ans+=1
print(ans)

Buggy submission (verdict: Runtime Error):
N,M=map(int,input().split())
Islands=[[] for i in range(N)]
Edge=[]
S=0
for i in range(M):
  a,b,c=map(int,input().split())
  Islands[a-1].append([b-1,c])
  Islands[b-1].append([a-1,c])
  Edge.append([a-1,b-1])
for m in range(M):
  a=Edge[m][0]
  b=Edge[m][1]
  for i in Islands[a]:
    if i[0]==b:
      c_m=i[1]
  List=[[a,-1]]
  for l in List:
    c=(-1)*(l[-1]+1)
    if l[-2]==b:
      if c_m>c:
        S+=1
        break
    else:        
      for n in Islands[l[-2]]:
        if n[0] in l:
          pass
        else:
          c+=n[1]
          del l[-1]
          List.append(l+[n[0],(-1)*(c+1)])
          
print(S)
Problem p03964 (python)

Fixed submission:
def ceil(x,y):
    if x%y == 0:
        return x//y
    else:
        return x//y + 1

n = int(input())
x,y = 1,1

for _ in range(n):
    t,a  = map(int,input().split())
    temp = max(ceil(x,t),ceil(y,a))
    x = t*temp
    y = a*temp

print(x+y)

Buggy submission (verdict: Runtime Error):
def ceil(x,y):
    if x%y == 0:
        return x//y
    if x%y == 1:
        return x//y + 1

n = int(input())
x,y = 1,1

for _ in range(n):
    t,a  = map(int,input().split())
    temp = max(ceil(x,t),ceil(y,a))
    x = t*temp
    y = a*temp

print(x+y)
Problem p03263 (python)

Fixed submission:
# -*- coding: utf-8 -*-

H,W = map(int, input().split())
a = [list(map(int, input().split())) for i in range(H)]
a_eo = [[a[i][j] % 2 for j in range(W)] for i in range(H)]

N = 0
move = ""
for i in range(H):
    for j in range(W):
        if a_eo[i][j] == 1:
            if j < W-1 and 1 in a_eo[i][j+1:]:
                a[i][j] -= 1
                a[i][j+1] += 1
                a_eo[i][j] = 0
                a_eo[i][j+1] = (a_eo[i][j+1] + 1) % 2
                N += 1
                move += "%d %d %d %d\n" % (i+1, j+1, i+1, j+1+1)
            elif i < H-1 and 1 not in a_eo[i][j+1:]:
                a[i][j] -= 1
                a[i+1][j] += 1
                a_eo[i][j] = 0
                a_eo[i+1][j] = (a_eo[i+1][j] + 1) % 2
                N += 1
                move += "%d %d %d %d\n" % (i+1, j+1, i+1+1, j+1)
            else:
                break

print("%d\n" % N + move)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

H,W = map(int, input().split())
a = [list(map(int, input().split())) for i in range(H)]
a_eo = [[a[i][j] % 2 for j in range(W)] for i in range(H)]

N = 0
move = ""
for i in range(H):
    for j in range(W):
        if a_eo[i][j] == 1:
            if j < W-1 and 1 in a_eo[i][j+1:]:
                a[i][j] -= 1
                a[i][j+1] += 1
                a_eo[i][j] = 0
                a_eo[i][j+1] = (a_eo[i][j+1] + 1) % 2
                N += 1
                move += "%d %d %d %d\n" % (i+1, j+1, i+1, j+1+1)
            elif i < H-1 and 1 not in a_eo[i][j+1:]:
                a[i][j] -= 1
                a[i+1][j] += 1
                a_eo[i][j] = 0
                a_eo[i+1][j] = (a_eo[i][j+1] + 1) % 2
                N += 1
                move += "%d %d %d %d\n" % (i+1, j+1, i+1+1, j+1)
            else:
                break

print("%d\n" % N + move)
Problem p03274 (python)

Fixed submission:
N,K = map(int, input().split())
x = list(map(int, input().split()))
ans=min([min(abs(x[i])+abs(x[i]-x[i+K-1]),abs(x[i+K-1])+abs(x[i+K-1]-x[i])) for i in range(N-K+1)])
print(ans)

Buggy submission (verdict: Runtime Error):
N,K = map(int, input().split())
x = list(map(int, input().split()))
ans = 10**8 * 2
for i in range(N-K):
    l = x[i]
    r = x[i+K-1]
    if l*r >= 0:
        time = max(abs(l), abs(r))
    else:
        time = min(abs(l)*2+abs(r), abs(l)+abs(r)*2)
    if time < ans:
        ans = time
print(time)
Problem p03428 (python)

Fixed submission:
import math
import sys
def cross(a, b):
	return a[0]*b[1]-a[1]*b[0]
def dot(a, b):
	return a[0]*b[0]+a[1]*b[1]
def counterclockwise(a, b):
	return cross(a, b)<0
def sub(a, b):
	return [a[0]-b[0], a[1]-b[1]]
n=input()
p=[map(int, raw_input().split()) for i in range(n)]
index={tuple(p[i]): i for i in range(n)}
p.sort()
hull=[p[0]]
min_size=1
for i in range(1, n):
	while len(hull)>min_size and not counterclockwise(sub(p[i], hull[-1]), sub(hull[-1], hull[-2])):
		del hull[-1]
	hull.append(p[i])
assert hull[-1]==p[-1]
min_size=len(hull)
for i in range(n-2, -1, -1):
	while len(hull)>min_size and not counterclockwise(sub(p[i], hull[-1]), sub(hull[-1], hull[-2])):
		del hull[-1]
	hull.append(p[i])
assert hull[0]==hull[-1]==p[0]
del hull[-1]
result=[0.0]*n
print>>sys.stderr, hull
for i in range(len(hull)):
	a=sub(hull[(i+1)%len(hull)], hull[i])
	b=sub(hull[i], hull[i-1])
	value=dot(a, b)/math.sqrt(dot(a, a))/math.sqrt(dot(b, b))
	value=min(max(value, -1.0), 1.0)
	angle=math.acos(value)
	result[index[tuple(hull[i])]]=angle
for i in range(n):
	print result[i]/math.pi/2, 
print

Buggy submission (verdict: Runtime Error):
import math
import sys
def cross(a, b):
	return a[0]*b[1]-a[1]*b[0]
def dot(a, b):
	return a[0]*b[0]+a[1]*b[1]
def counterclockwise(a, b):
	return cross(a, b)<0
def sub(a, b):
	return [a[0]-b[0], a[1]-b[1]]
n=input()
p=[map(int, raw_input().split()) for i in range(n)]
index={tuple(p[i]): i for i in range(n)}
p.sort()
hull=[p[0]]
min_size=1
for i in range(1, n):
	while len(hull)>min_size and not counterclockwise(sub(p[i], hull[-1]), sub(hull[-1], hull[-2])):
		del hull[-1]
	hull.append(p[i])
assert hull[-1]==p[-1]
min_size=len(hull)
for i in range(n-2, -1, -1):
	while len(hull)>min_size and not counterclockwise(sub(p[i], hull[-1]), sub(hull[-1], hull[-2])):
		del hull[-1]
	hull.append(p[i])
assert hull[0]==hull[-1]==p[0]
del hull[-1]
result=[0.0]*n
print>>sys.stderr, hull
for i in range(len(hull)):
	a=sub(hull[(i+1)%len(hull)], hull[i])
	b=sub(hull[i], hull[i-1])
	angle=math.acos(dot(a, b)/math.sqrt(dot(a, a))/math.sqrt(dot(b, b)))
	result[index[tuple(hull[i])]]=angle
for i in range(n):
	print result[i]/math.pi/2, 
print
Problem p03654 (python)

Fixed submission:
import sys
n=input()
sys.setrecursionlimit(n+1000)
adj=[[] for i in range(n+1)]
for i in range(n-1):
	a, b, c=map(int, raw_input().split())
	adj[a].append((b, c))
	adj[b].append((a, c))
size=[0]*(n+1)
def dfs(cur, father):
	size[cur]=1
	for to, weight in adj[cur]:
		if to!=father:
			dfs(to, cur)
			size[cur]+=size[to]
dfs(1, 0)
center=1
while True:
	change=False
	for to, weight in adj[center]:
		if size[to]<size[center] and size[to]*2>=n:
			center=to
			change=True
			break
	if not change:
		break
print>>sys.stderr, center
dfs(center, 0)
result=0
for cur in range(1, n+1):
	for to, weight in adj[cur]:
		if size[to]<size[cur]:
			result+=size[to]*weight
result*=2
print>>sys.stderr, result
for to, weight in adj[center]:
	assert size[to]*2<=n
	if size[to]*2==n:
		print>>sys.stderr, "special"
		print result-weight
		exit()
min_weight=1000000000
for to, weight in adj[center]:
	min_weight=min(min_weight, weight)
print result-min_weight

Buggy submission (verdict: Runtime Error):
import sys
n=input()
adj=[[] for i in range(n+1)]
for i in range(n-1):
	a, b, c=map(int, raw_input().split())
	adj[a].append((b, c))
	adj[b].append((a, c))
size=[0]*(n+1)
def dfs(cur, father):
	size[cur]=1
	for to, weight in adj[cur]:
		if to!=father:
			dfs(to, cur)
			size[cur]+=size[to]
dfs(1, 0)
center=1
while True:
	change=False
	for to, weight in adj[center]:
		if size[to]<size[center] and size[to]*2>=n:
			center=to
			change=True
			break
	if not change:
		break
print>>sys.stderr, center
dfs(center, 0)
result=0
for cur in range(1, n+1):
	for to, weight in adj[cur]:
		if size[to]<size[cur]:
			result+=size[to]*weight
result*=2
print>>sys.stderr, result
for to, weight in adj[center]:
	assert size[to]*2<=n
	if size[to]*2==n:
		print>>sys.stderr, "special"
		print result-weight
		exit()
min_weight=1000000000
for to, weight in adj[center]:
	min_weight=min(min_weight, weight)
print result-min_weight
Problem p03708 (python)

Fixed submission:
a=bin(input()+(1<<60))[2:]
b=bin(input()+(1<<60))[2:]
if a==b:
	print 1
	exit()
while a[0]==b[0]:
	a=a[1:]
	b=b[1:]
assert a[0]=="0" and b[0]=="1"
result=int("1"+"0"*(len(a)-1), 2)-int(a, 2)
b=b[1:]
while b and b[0]=="0":
	b=b[1:]
if not b:
	b=0
else:
	b=(1<<len(b))-1
if b>=int(a, 2):
	result+=(1<<(len(a)-1))
else:
	result=result*2+b+1
print result

Buggy submission (verdict: Runtime Error):
a=bin(input()+(1<<60))[2:]
b=bin(input()+(1<<60))[2:]
while a[0]==b[0]:
	a=a[1:]
	b=b[1:]
assert a[0]=="0" and b[0]=="1"
result=int("1"+"0"*(len(a)-1), 2)-int(a, 2)
b=b[1:]
while b and b[0]=="0":
	b=b[1:]
if not b:
	result=result*2+1
else:
	b="1"*len(b)
	if int(b, 2)>=int(a, 2):
		result+=(1<<(len(a)-1))
	else:
		result=result*2+int(b, 2)+1
print result
Problem p03787 (python)

Fixed submission:
import sys
n, m=map(int, raw_input().split())
sys.setrecursionlimit(n+1000)
adj=[[] for i in range(n+1)]
for i in range(m):
	u, v=map(int, raw_input().split())
	adj[u].append(v)
	adj[v].append(u)
isolated_cnt=0
bipartite_cnt=0
other_cnt=0
color=[0]*(n+1)
def dfs(cur):
	global ok
	for to in adj[cur]:
		if not color[to]:
			color[to]=3-color[cur]
			dfs(to)
		else:
			if color[to]!=3-color[cur]:
				ok=False
for i in range(1, n+1):
	if adj[i]:
		if not color[i]:
			color[i]=1
			ok=True
			dfs(i)
			if ok:
				bipartite_cnt+=1
			else:
				other_cnt+=1
	else:
		isolated_cnt+=1
print>>sys.stderr, isolated_cnt, bipartite_cnt, other_cnt
print isolated_cnt*n*2-isolated_cnt*isolated_cnt+bipartite_cnt*(bipartite_cnt*2+other_cnt)+other_cnt*(bipartite_cnt+other_cnt)

Buggy submission (verdict: Runtime Error):
import sys
n, m=map(int, raw_input().split())
adj=[[] for i in range(n+1)]
for i in range(m):
	u, v=map(int, raw_input().split())
	adj[u].append(v)
	adj[v].append(u)
isolated_cnt=0
bipartite_cnt=0
other_cnt=0
color=[0]*(n+1)
def dfs(cur):
	for to in adj[cur]:
		if not color[to]:
			color[to]=3-color[cur]
			if not dfs(to):
				return False
		else:
			if color[to]!=3-color[cur]:
				return False
	return True
for i in range(1, n+1):
	if adj[i]:
		if not color[i]:
			color[i]=1
			if dfs(i):
				bipartite_cnt+=1
			else:
				other_cnt+=1
	else:
		isolated_cnt+=1
print>>sys.stderr, isolated_cnt, bipartite_cnt, other_cnt
print isolated_cnt*n*2-isolated_cnt*isolated_cnt+bipartite_cnt*(bipartite_cnt*2+other_cnt)+other_cnt*(bipartite_cnt+other_cnt)
Problem p03240 (python)

Fixed submission:
N = int(input())

xyhs = []
for n in range(N):
	x, y, h = map(int, input().split())
	xyhs.append((x,y,h))

xyhs.sort(key=lambda x:x[2], reverse = True)

for cx in range(101):
	for cy in range(101):
		x, y, h = xyhs[0]
		H = h + abs(x - cx) + abs(y - cy)
				
		for xyh in xyhs[1:]:
			x, y, h = xyh

			if h == 0:
				if H > abs(x - cx) + abs(y - cy):
					break
			else:
				if H != h + abs(x - cx) + abs(y - cy):
					break
		else:
			if H < 1:
				H = 1
			print(cx, cy, H)
			exit()

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

xyhs = []
for n in range(N):
	x, y, h = map(int, input().split())
	xyhs.append((x,y,h))

if n == 1:
	x, y, h = xyhs[0]
	print(cx, cy, h)
	exit()

for cx in range(101):
	for cy in range(101):
		x, y, h = xyhs[0]
		H = h + abs(x - cx) + abs(y - cy)

		for xyh in xyhs[1:]:
			x, y, h = xyh
			if H != h + abs(x - cx) + abs(y - cy):
				break
		else:
			if H < 1:
				H = 1
			print(cx, cy, H)
			exit()

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

xyhs = []
for n in range(N):
	x, y, h = map(int, input().split())
	xyhs.append((x,y,h))

if n == 1:
	x, y, h = xyhs[0]
	print(cx, cy, H)
	exit()
			
for cx in range(101):
	for cy in range(101):
		x, y, h = xyhs[0]
		H = h + abs(x - cx) + abs(y - cy)

		for xyh in xyhs[1:]:
			x, y, h = xyh
			if H != h + abs(x - cx) + abs(y - cy):
				break
		else:
			if H < 1:
				H = 1
			print(cx, cy, H)
			exit()
Problem p03227 (python)

Fixed submission:
a = str(input())
if (len(a)==2):
    print(a)
else:
    print(a[::-1])

Buggy submission (verdict: Runtime Error):
args = str(input())
args = args.split(" ")
a = int(args[0])
b = int(args[1])
k = int(args[2])

turn = 0
for i in range(k):
    if (turn==0):
        if (a>0):
            if (a % 2 == 1):
                a = a - 1
        if (a>0):
            g = a/2
            a = a - g
            b = b + g
        turn=1
    elif (turn==1):
        if (b>0):
            if (b % 2 == 1):
                b = b -1
        if (b>0):
            g = b/2
            b = b - g
            a = a + g
        turn=0

print(int(a),int(b))