Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
n,m = map(int,input().split())
height = list(map(int,input().split()))
lst = [0]*n
for j in range(m):
    x,y = map(int,input().split())
    if height[x-1] >= height[y-1]:
      lst[y-1] = 1
    if height[x-1] <= height[y-1]:
      lst[x-1] = 1
print(lst.count(0))

Fixed submission:
s = input()
if s == "ABC":
  print("ARC")
else:
  print("ABC")

Buggy python submission (verdict: Runtime Error):
n,m = map(int,input().split())
height = list(map(int,input().split()))
lst = [0]*n
for j in range(m):
    x,y = map(int,input().split())
if height[x-1] >= height[y-1]:
    lst[y-1] = 1
if height[x-1] <= height[y-1]:
    lst[x-1] = 1
print(lst.count(0))

Fixed submission:
s = input()
if s == "ABC":
  print("ARC")
else:
  print("ABC")
Buggy python submission (verdict: Runtime Error):
n,k = map(int,input().split())
lst = []
for _ in range(k):
  d = int(input())
  lstx = [int(input()) for _ in range(d)]
  lst += lstx
setans = set(lst)
print(n - len(setans))

Fixed submission:
n,k = map(int,input().split())
lst = []
for _ in range(k):
  d = int(input())
  lstx = list(map(int,input().split()))
  lst += lstx
setans = set(lst)
print(n - len(setans))
Buggy python submission (verdict: Time Limit Exceeded):
from fractions import gcd
k = int(input())
sum = 0
for a in range(1,k+1):
  for b in range(1,k+1):
    for c in range(1,k+1):
      sum += gcd(gcd(a,b),c)
print(sum)      

Fixed submission:
from math import gcd
k = int(input())
sum = 0
lst = []
for a in range(1,k+1):
  for b in range(1,k+1):
      g = gcd(a,b)
      lst.append(g)
for c in range(1,k+1):
    for i in range(len(lst)):
        sum += gcd(lst[i],c)     
print(sum)

Buggy python submission (verdict: Time Limit Exceeded):
from fractions import gcd
k = int(input())
sum = 0
for a in range(1,k+1):
  for b in range(1,k+1):
    for c in range(1,k+1):
      sum += gcd(gcd(a,b),c)
print(sum)          
      

Fixed submission:
from math import gcd
k = int(input())
sum = 0
lst = []
for a in range(1,k+1):
  for b in range(1,k+1):
      g = gcd(a,b)
      lst.append(g)
for c in range(1,k+1):
    for i in range(len(lst)):
        sum += gcd(lst[i],c)     
print(sum)
Buggy python submission (verdict: Runtime Error):
n,k = map(int,input().split())
lst = list(map(int,input().split()))
lst.append(k+lst[0])
maxe = 0
for i in range(1,n+1):
    maxe =max(maxe,lst[i]-lst[i-1])
print(k-maxe)               

Fixed submission:
k,n = map(int,input().split())
lst = list(map(int,input().split()))
lst.append(k+lst[0])
maxe = 0
for i in range(1,n+1):
    maxe =max(maxe,lst[i]-lst[i-1])
print(k-maxe)
Buggy python submission (verdict: Time Limit Exceeded):
n,k,q = map(int,input().split())
lst = [int(input()) for _ in range(q)]
for i in range(1,n+1):
    score = k-q+lst.count(i)
    print("Yes" if score > 0 else "No")
    

Fixed submission:
n,k,q = map(int,input().split())
lst = [int(input()) for _ in range(q)]
score = [k-q]* n
for i in range(q):
    score[lst[i]-1] +=1
for k in range(n):
    print("Yes" if score[k] >0 else "No")
Buggy python submission (verdict: Runtime Error):
s = input()
s = s.replase('eraser', '')
s = s.replase('erase', '')
s = s.replase('dreamer', '')
s = s.replase('dream', '')

if l == '':
    print('YES')
else:
    print('NO')

Fixed submission:
l = input()
l = l.replace('eraser','')
l = l.replace('erase','')
l = l.replace('dreamer','')
l = l.replace('dream','')
 
if l == '':
    print('YES')
else:
    print('NO')
Buggy python submission (verdict: Time Limit Exceeded):
import sys
import bisect
readline = sys.stdin.readline
n = int(readline())
A = list(map(int,readline().split()))
A.sort()
ans =0
for i in range(1,n):
    for j in range(i+1,n):
        ans += i- bisect.bisect(A,A[j]-A[i],hi=i)
print(ans)

Fixed submission:
import sys
import bisect
readline = sys.stdin.readline
n = int(readline())
A = list(map(int,readline().split()))
memo1 = {}
memo2 = {}
A.sort()
memo1[A[0]+A[1]] =1
memo2[A[0]] =1
if A[1] in memo2:
    memo2[A[1]] +=1
else:
    memo2[A[1]] =1
ans = 0
for c in A[2:]:
    for l,amount in memo1.items():
        if c<l:
            ans +=amount
    for a,amount in memo2.items():
        ac = a+c
        if ac in memo1:
            memo1[ac] += memo2[a]
        else:
            memo1[ac] = memo2[a]
    if c in memo2:
        memo2[c] +=1
    else:
        memo2[c] =1

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
import bisect
readline = sys.stdin.readline
n = int(readline())
A = list(map(int,readline().split()))
A.sort()
ans =0
for i in range(1,n):
    for j in range(i+1,n):
        b = A[i]
        c = A[j]
        a = c -b
        ans += i- bisect.bisect(A[:i],a)
print(ans)

Fixed submission:
import sys
import bisect
readline = sys.stdin.readline
n = int(readline())
A = list(map(int,readline().split()))
memo1 = {}
memo2 = {}
A.sort()
memo1[A[0]+A[1]] =1
memo2[A[0]] =1
if A[1] in memo2:
    memo2[A[1]] +=1
else:
    memo2[A[1]] =1
ans = 0
for c in A[2:]:
    for l,amount in memo1.items():
        if c<l:
            ans +=amount
    for a,amount in memo2.items():
        ac = a+c
        if ac in memo1:
            memo1[ac] += memo2[a]
        else:
            memo1[ac] = memo2[a]
    if c in memo2:
        memo2[c] +=1
    else:
        memo2[c] =1

print(ans)
Buggy python submission (verdict: Runtime Error):
s = input()
i = 0
now = s[0]
ans = 1
while i <=len(s)-1:
    if i ==len(s) -1:
        break
    if len(now)==2:
        now = s[i+1]
        i += 1
        ans+=1
    if len(now)==1:
        if now != s[i+1]:
            now = s[i+1]
            i +=1
            ans+=1
        else:
            if i+2 <= len(s)-1:
                now = s[i+1:i+3]
                ans +=1
            i +=2
print(ans)

Fixed submission:
s = input()
i = 1
now = s[0]
ans = 1
while i <=len(s)-1:
    if i >=len(s):
        break
    if len(now)==2:
        now = s[i]
        i += 1
        ans+=1
        continue
    if len(now)==1:
        if now != s[i]:
            now = s[i]
            i +=1
            ans+=1
        else:
            if i+2 <= len(s):
                now = s[i:i+2]
                ans +=1
            i +=2
            continue
print(ans)

Buggy python submission (verdict: Runtime Error):
s = input()
i = 0
now = s[0]
ans = 1
while i <len(s)-1:
    if len(now)==2:
        now = s[i+1]
        i += 1
        ans+=1
    if len(now)==1:
        if now != s[i+1]:
            now = s[i+1]
            i +=1
            ans+=1
        else:
            if i+2 <= len(s)-1:
                now = s[i+1:i+3]
                ans +=1
            i +=2
print(ans)


Fixed submission:
s = input()
i = 1
now = s[0]
ans = 1
while i <=len(s)-1:
    if i >=len(s):
        break
    if len(now)==2:
        now = s[i]
        i += 1
        ans+=1
        continue
    if len(now)==1:
        if now != s[i]:
            now = s[i]
            i +=1
            ans+=1
        else:
            if i+2 <= len(s):
                now = s[i:i+2]
                ans +=1
            i +=2
            continue
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
sl =[]
ans = 0
for i in range(n):
    s = sorted(input())
    ans+=sl.count(s)
    sl.append(s)
print(ans)


Fixed submission:
n = int(input())
sl ={}
ans = 0
for i in range(n):
    s = ''.join(sorted(input()))
    if s in sl:
        sl[s] +=1
    else:
        sl[s] =1
for i in sl.values():
    ans += i*(i-1)/2
print(int(ans))

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = [sorted(input()) for _ in  range(n)]

ans = 0
for i,moji in enumerate(s):
    for j in range(n-i-1):
        if moji == s[i+j+1]:
            ans +=1
print(ans)

Fixed submission:
n = int(input())
sl ={}
ans = 0
for i in range(n):
    s = ''.join(sorted(input()))
    if s in sl:
        sl[s] +=1
    else:
        sl[s] =1
for i in sl.values():
    ans += i*(i-1)/2
print(int(ans))
Buggy python submission (verdict: Runtime Error):

n= int(input())
hl = list(map(int,input().split(' ')))


hmax = 0
def hantei(n,x):
    global hmax
    if n == 1:
        print('Yes')
        exit()
        
    if x == n - 1:
        print('Yes')
        exit()
    if (hl[x] >= (hmax - 1)):
        hmax = max(hmax,hl[x])
        return hantei(n,x+1)
    else:
        return print('No')
    

hantei(n,0)

Fixed submission:

n= int(input())
hl = list(map(int,input().split(' ')))


hmax = 0
if n == 1:
    print('Yes')
    exit()

for i in range(n):
    if (hl[i] >= (hmax - 1)):
        hmax = max(hmax,hl[i])
        if i == n - 1:
        	print('Yes')
        	break
    else:
        print('No')
        break

Buggy python submission (verdict: Runtime Error):
n= int(input())
hlist = list(map(int,input().split(' ')))


def hantei(x):
    if x == n - 1:
        print('Yes')
        exit()
    
    if hlist[x]>(hlist[x+1]+1):
        print('No')
        exit()
    
    return hantei(x+1)

print(hantei(0))

Fixed submission:

n= int(input())
hl = list(map(int,input().split(' ')))


hmax = 0
if n == 1:
    print('Yes')
    exit()

for i in range(n):
    if (hl[i] >= (hmax - 1)):
        hmax = max(hmax,hl[i])
        if i == n - 1:
        	print('Yes')
        	break
    else:
        print('No')
        break
Buggy python submission (verdict: Time Limit Exceeded):

s = input()
n = len(s)
dp =[[0 for _ in range(13)] for _ in range(n+1)]
dp[0][0]=1

move = [[] for _ in range(13)]
for i in range(10):
    for j in range(13):
        move[(10*j+i)%13].append(j)

for i in range(n):
    if s[i]=="?":
        si = range(10)
        for mod,ex in enumerate(move):
            dp[i+1][mod] += sum([dp[i][x] for x in ex])
        
    else:
        si = int(s[i])
        for j in range(13):
            dp[i+1][(10*j+si)%13]+=dp[i][j]
    for j in range(13):
        dp[i+1][j] = dp[i+1][j]%(10**9+7)

print(dp[n][5])


Fixed submission:

s = input()
n = len(s)
dp1 =[0 for _ in range(13)]
dp1[0]=1


move = [[] for _ in range(13)]

for i in range(10):
    for j in range(13):
        move[(10*j+i)%13].append(j)



for i in range(n):
    dp2 =[0 for _ in range(13)]
    if s[i]=="?":
        si = range(10)
        for mod,ex in enumerate(move):
            dp2[mod] += sum([dp1[x] for x in ex])
    else:
        si = int(s[i])
        for j in range(13):
            dp2[(10*j+si)%13]+=dp1[j]
    dp1 = [x%(10**9+7) for x in dp2] 


print(dp1[5])

Buggy python submission (verdict: Time Limit Exceeded):

s = input()
n = len(s)
dp =[[0 for _ in range(13)] for _ in range(n+1)]
dp[0][0]=1


for i in range(n):
    if s[i]=="?":
        si = range(10)
    else:
        si = [int(s[i])]
    
    for sn in si:
        for j in range(13):
            dp[i+1][(10*j+sn)%13]+=dp[i][j]

print(dp[n][5]%(10**9+7))


Fixed submission:

s = input()
n = len(s)
dp1 =[0 for _ in range(13)]
dp1[0]=1


move = [[] for _ in range(13)]

for i in range(10):
    for j in range(13):
        move[(10*j+i)%13].append(j)



for i in range(n):
    dp2 =[0 for _ in range(13)]
    if s[i]=="?":
        si = range(10)
        for mod,ex in enumerate(move):
            dp2[mod] += sum([dp1[x] for x in ex])
    else:
        si = int(s[i])
        for j in range(13):
            dp2[(10*j+si)%13]+=dp1[j]
    dp1 = [x%(10**9+7) for x in dp2] 


print(dp1[5])
Buggy python submission (verdict: Runtime Error):
from collections import deque

n = int(input())
alist = deque()
for i in range(n):
    alist.append(int(input()))

amax = max(alist)
anslist = [amax]*n
if alist.count(amax)>=2:
    for i in anslist:
        print(i)
    exit()

if alist.count(amax)==1:
    maxindex = alist.index(amax)
    del alist[maxindex]
    anslist[maxindex]= max(alist)
    for i in anslist:
        print(i)
    exit()


Fixed submission:

n = int(input())
alist = []
for i in range(n):
    alist.append(int(input()))

amax = max(alist)
anslist = [amax]*n
if alist.count(amax)>=2:
    for i in anslist:
        print(i)
    exit()

if alist.count(amax)==1:
    maxindex = alist.index(amax)
    del alist[maxindex]
    anslist[maxindex]= max(alist)
    for i in anslist:
        print(i)
    exit()

Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque

n = int(input())
alist = deque()
for i in range(n):
    alist.append(int(input()))



anslist = deque()
for _ in range(n):
    ai = alist.popleft()
    anslist.append(max(alist))
    alist.append(ai)

for i in anslist:
    print(i)
    
    

Fixed submission:

n = int(input())
alist = []
for i in range(n):
    alist.append(int(input()))

amax = max(alist)
anslist = [amax]*n
if alist.count(amax)>=2:
    for i in anslist:
        print(i)
    exit()

if alist.count(amax)==1:
    maxindex = alist.index(amax)
    del alist[maxindex]
    anslist[maxindex]= max(alist)
    for i in anslist:
        print(i)
    exit()
Buggy python submission (verdict: Runtime Error):
n = int(input())
alist = list(map(int,input().split()))
anslist =[]
def act(i,nowlist):
    now = i+1
    ai =alist[i]
    s = 1
    multisum =0
    while now * s <= n:
        multisum += nowlist[now*s-1]
        s +=1
    if multisum%2 ==ai:
        anslist.append(0)
    if multisum%2 !=ai:
        anslist.append(1)
    if i == n-1:
        return 
    act(i+1,nowlist)
    
numlist = [0 for i in range(n)]
act(0,numlist)
print(anslist.count(1))
if anslist.count(1)>0:
    indexes = [i+1 for i, x in enumerate(anslist) if x == 1]
    [print(i,end=" ") for i in indexes]
        

Fixed submission:
n=int(input())
l=list(map(int,input().split()))
ans =[0 for _ in range(n)]
count=0
for i in range(n-1,-1,-1):
    if sum([ans[j]for j in range(i,n,i+1)])%2!=l[i]:
        ans[i]=1
        count +=1

print(count)
[print(i+1,end=" ") for i,x in enumerate(ans) if x==1]

Buggy python submission (verdict: Runtime Error):
n = int(input())
alist = list(map(int,input().split()))
anslist =[]
def act(i,nowlist):
    now = i+1
    ai =alist[i]
    s = 1
    multisum =0
    while now * s <= n:
        multisum += nowlist[now*s-1]
        s +=1
    if multisum%2 ==ai:
        anslist.append(0)
    if multisum%2 !=ai:
        anslist.append(1)
    if i == n-1:
        return 
    act(i+1,nowlist)
    
numlist = [0 for i in range(n)]
act(0,numlist)
print(anslist.count(1))
if anslist.count(1)>0:
    indexes = [i+1 for i, x in enumerate(anslist) if x == 1]
    [print(i,end=" ") for i in indexes]
        

Fixed submission:
n=int(input())
l=list(map(int,input().split()))
ans =[0 for _ in range(n)]
count=0
for i in range(n-1,-1,-1):
    if sum([ans[j]for j in range(i,n,i+1)])%2!=l[i]:
        ans[i]=1
        count +=1

print(count)
[print(i+1,end=" ") for i,x in enumerate(ans) if x==1]
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
a,b = map(int,input().split())
moda=np.mod(a,2019)
modb=np.mod(b,2019)
if (modb<=moda)or((b-a)>=2018):
    print(0)
    exit()

num =list(range(moda,modb+1))
ans = 10000
for i,l in enumerate(num):
    if i == len(num)-1:
        break
    for r in num[i+1:]:
        ans = min(np.mod(l*r,2019),ans)
print(ans)

Fixed submission:
import numpy as np
a,b = map(int,input().split())
moda=np.mod(a,2019)
modb=np.mod(b,2019)
if (modb<=moda)or((b-a)>=673):
    print(0)
    exit()

num =list(range(moda,modb+1))

ans = 10000
for i,l in enumerate(num):
    if i == len(num)-1:
        break
    for r in num[i+1:]:
        ans = min(np.mod(l*r,2019),ans)
print(ans)

Buggy python submission (verdict: Runtime Error):
import numpy as np
a,b = map(int,input().split())
moda=np.mod(a,2019)
modb=np.mod(b,2019)
if (modb<=moda)or((b-a)>=2018):
    print(0)
    exit()

num =list(range(moda,modb+1))
ans = 10000
for i,l in enumerate(num):
    if i == len(num)-1:
        break
    for r in num[i+1:]:
        ans = min(np.mod(l*r,2019),ans)
print(ans)

Fixed submission:
import numpy as np
a,b = map(int,input().split())
moda=np.mod(a,2019)
modb=np.mod(b,2019)
if (modb<=moda)or((b-a)>=673):
    print(0)
    exit()

num =list(range(moda,modb+1))

ans = 10000
for i,l in enumerate(num):
    if i == len(num)-1:
        break
    for r in num[i+1:]:
        ans = min(np.mod(l*r,2019),ans)
print(ans)
Buggy python submission (verdict: Runtime Error):
mod = 10**9 +7
n,m = map(int,input().split())
stairs = [1 for _ in range(n)]
memo = [0 for _ in range(n)]
for _ in range(m):
    a = int(input()) - 1
    stairs[a] = 0
memo[0] = stairs[0]
if stairs[1]:
    memo[1] = stairs[1] + memo[0]
for i in range(2,n):
    if stairs[i]:
        memo[i] = (memo[i-1] +memo[i-2])%mod
    else:
        memo[i] = 0
print(memo[n-1])

Fixed submission:
mod = 10**9 +7
n,m = map(int,input().split())
stairs = [1 for _ in range(n)]
memo = [0 for _ in range(n)]
for _ in range(m):
    a = int(input()) - 1
    stairs[a] = 0
memo[0] = stairs[0]
if n ==1:
    print(memo[0])
    exit()
if stairs[1]:
    memo[1] = stairs[1] + memo[0]
if n==2:
    print(memo[1])
    exit()
for i in range(2,n):
    if stairs[i]:
        memo[i] = (memo[i-1] +memo[i-2])%mod
    else:
        memo[i] = 0
print(memo[n-1])
Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int,input().split())
cards = [1 for _ in range(n)]
for _ in range(m):
    l,r= map(lambda x: int(x) - 1,input().split())
    if 0 < l:    
        cards[:l] = [0 for _ in range(l)]
    if r < n-1:
        cards[r+1:] = [0 for _ in range(n-1 -r)]
print(sum(cards))

Fixed submission:
n, m = map(int,input().split())
cards = [1 for _ in range(n)]
L = 0
R = n-1
for _ in range(m):
    l,r= map(lambda x: int(x) - 1,input().split())
    L = max(L,l)
    R = min(R,r)
    
print(max(0,R-L+1))

Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int,input().split())
cards = [1 for _ in range(n)]
for _ in range(m):
    l,r= map(lambda x: int(x) - 1,input().split())
    if 0 < l:    
        for i in range(l):
            cards[i] = 0
    if r < n-1:
        for i in range(r+1,n):
            cards[i] = 0
print(sum(cards))

Fixed submission:
n, m = map(int,input().split())
cards = [1 for _ in range(n)]
L = 0
R = n-1
for _ in range(m):
    l,r= map(lambda x: int(x) - 1,input().split())
    L = max(L,l)
    R = min(R,r)
    
print(max(0,R-L+1))
Buggy python submission (verdict: Runtime Error):
strs = []
inter1 = {}
for _ in range(n):
    strs.append(input())

for char in strs[0]:
    if char in inter1:
        inter1[char] +=1
    else:
        inter1[char] = 1
        
for i in range(1,n):
    inter2 = {}
    for char in strs[i]:
        if (char in inter1):
            if char in inter2:
                if inter2[char] < inter1[char]:
                    inter2[char] +=1
            else:
                inter2[char] =1 
    inter1 = inter2

inter = sorted(inter1.items())
ans = ''
for char,i in inter:
    for _ in range(i):
        ans +=char
print(ans)

Fixed submission:
n = int(input())
strs = []
inter1 = {}
for _ in range(n):
    strs.append(input())

for char in strs[0]:
    if char in inter1:
        inter1[char] +=1
    else:
        inter1[char] = 1
        
for i in range(1,n):
    inter2 = {}
    for char in strs[i]:
        if (char in inter1):
            if char in inter2:
                if inter2[char] < inter1[char]:
                    inter2[char] +=1
            else:
                inter2[char] =1 
    inter1 = inter2

inter = sorted(inter1.items())
ans = ''
for char,i in inter:
    for _ in range(i):
        ans +=char
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
now = (0,0)

for _ in range(n):
    t,a = map(int,input().split())

    i=1
    while True:
        if t*i>=now[0] and a*i>=now[1]:
            now = (t*i,a*i)
            break
        i +=1

print(sum(now))

Fixed submission:
n = int(input())
nt  =0
na = 0
for _ in range(n):
    t,a = map(int,input().split())
    if nt==0 and na==0:
        nt =t
        na =a
        continue
    if na <= nt*(a/t):
        mod = nt%t
        if not mod==0:
            mod = t - mod
            nt = nt + mod
            na = a*nt//t
        else:
           nt = nt
           na = a*nt//t
    else:
        mod = na%a
        if not mod==0:
            mod = a - mod
            na = na + mod
            nt = t*na//a
        else:
           na = na
           nt = na*t//a 
        

print(na+nt)
Buggy python submission (verdict: Time Limit Exceeded):
import math

A = 1
N = int(input())
array = input().split()
for i in range(N):
	A = (A * int(array[i]))
if A > math.pow(10,18):
	print(-1)
else:
  print(A)



Fixed submission:
import math
 
A = 1
N = int(input())
array = input().split()
flag = True
for i in range(N):
	A = (A * int(array[i]))
	if A > math.pow(10,18):
		flag = False
		break

if flag:
  print(A)
else:
  if '0' in array:
    print(0)
  else:
    print(-1)
Buggy python submission (verdict: Runtime Error):
X, N = input().split()
p = list(map(int, input().split()))

ans = 0
for i in range(1, 102):
    if abs(X - i) < abs(ans - i) and i not in p and i != X:
        ans = i

print(ans)


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

ans = 0
for i in range(1, 102):
    if abs(X - i) < abs(X - ans) and i not in p:
        ans = i
print(ans)

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

ans = 0
for i in range(1, 102):
    if abs(X - i) < abs(ans - i) and i not in p and i != X:
        ans = i

print(ans)


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

ans = 0
for i in range(1, 102):
    if abs(X - i) < abs(X - ans) and i not in p:
        ans = i
print(ans)
Buggy python submission (verdict: Runtime Error):
t1 = ['0', '1'] * 25000
t2 = ['1', '0'] * 25000

s = input()
sl = list(s)

a1 = 0
a2 = 0

for i in range(len(sl)):
    if sl[i] != t1[i]:
        a1 += 1
    if sl[i] != t2[i]:
        a2 += 1

print(min(a1, a2))


Fixed submission:
t1 = ['0', '1'] * 50000
t2 = ['1', '0'] * 50000

s = input()
sl = list(s)

a1 = 0
a2 = 0

for i in range(len(sl)):
    if sl[i] != t1[i]:
        a1 += 1
    if sl[i] != t2[i]:
        a2 += 1

print(min(a1, a2))
Buggy python submission (verdict: Time Limit Exceeded):
N,K,Q = map(int, raw_input().split())
P = [K]*N
for i in range(Q):
    A = int(raw_input())
    P[A-1] += 1
    P = [p-1 for p in P]
    #print P

for p in P:
    if p > 0:
        print "Yes"
    else:
        print "No"

Fixed submission:
N,K,Q = map(int, raw_input().split())
P = [K]*N
for i in range(Q):
    A = int(raw_input())
    P[A-1] += 1
    
P = [p-Q for p in P]

for p in P:
    if p > 0:
        print "Yes"
    else:
        print "No"

Buggy python submission (verdict: Time Limit Exceeded):
N,K,Q = map(int, raw_input().split())
P = [K]*N
for i in range(Q):
    A = int(raw_input())
    P[A-1] += 1
    P = map(lambda x:x-1, P)
    #print P

for p in P:
    #print p
    if p > 0:
        print "Yes"
    else:
        print "No"

Fixed submission:
N,K,Q = map(int, raw_input().split())
P = [K]*N
for i in range(Q):
    A = int(raw_input())
    P[A-1] += 1
    
P = [p-Q for p in P]

for p in P:
    if p > 0:
        print "Yes"
    else:
        print "No"
Buggy python submission (verdict: Time Limit Exceeded):
import math

N = int(raw_input())
S = [raw_input() for _ in range(N)]
D = {}
for s in S:
    k = "".join(sorted(s))
    if k not in D:
        D[k] = []
    D[k].append(s)

ans = 0
for k,v in D.items():
    n = len(v)
    if n > 1:
        ans += math.factorial(n) / (2 * math.factorial(n-2))
print ans

Fixed submission:
import math

N = int(raw_input())
S = [raw_input() for _ in range(N)]
D = {}
for s in S:
    k = "".join(sorted(s))
    if k not in D:
        D[k] = []
    D[k].append(s)

ans = 0
for k,v in D.items():
    n = len(v)
    if n > 1:
        ans += math.factorial(n) / (2 * math.factorial(n-2))
print ans
Buggy python submission (verdict: Runtime Error):
N,X = list(map(int, input().split()))
L = list(map(int, input().split()))
D = [0]*(N+2)
for i in range(N):
    D[i+1] = D[i] + L[i]
#print (D)
count = 0
for i in range(len(D)):
    if D[i] <= X:
        count += 1
print count

Fixed submission:
N,X = list(map(int, input().split()))
L = list(map(int, input().split()))
D = [0]*(N+2)
for i in range(N):
    D[i+1] = D[i] + L[i]
#print (D)
count = 0
for i in range(len(D)):
    if D[i] <= X:
        count += 1
print (count-1)