Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
N=int(input())
num=0
for j in range(1,N+1,2):
	cnt=0
	for i in range(1,j+1):
#        print(i)
#        print(j)
        if j%i==0 :
            cnt=cnt+1
    if cnt==8 :
#        print(cnt)
        num+=1
#    print("---")
print(num)


Fixed submission:
N=int(input())
num=0
for j in range(1,N+1,2):
    cnt=0
    for i in range(1,j+1):
#        print(i)
#        print(j)
        if j%i==0 :
            cnt=cnt+1
    if cnt==8 :
#        print(cnt)
        num+=1
    cnt=0
#    print("---")
print(num)

Buggy python submission (verdict: Runtime Error):
N=int(input())
num=0
for j in range(1,N+1,2):
  cnt=0
    for i in range(1,j+1):
#        print(i)
#        print(j)
        if j%i==0 :
            cnt=cnt+1
    if cnt==8 :
#        print(cnt)
        num+=1
#    print("---")
print(num)


Fixed submission:
N=int(input())
num=0
for j in range(1,N+1,2):
    cnt=0
    for i in range(1,j+1):
#        print(i)
#        print(j)
        if j%i==0 :
            cnt=cnt+1
    if cnt==8 :
#        print(cnt)
        num+=1
    cnt=0
#    print("---")
print(num)
Buggy python submission (verdict: Runtime Error):
import math

N=int(input())
A=list(map(int,input().split()))

for i in range(N):
    A[i]-=i+1
A.sort()
a=N//2

def sad(A,a):
    sadness=0
    for i in range(N):
        sadness+=abs(A[i]-A[a])
    return sadness

if N//2==0:
    ans=min(sad(A,a),sad(A,a+1))
else:
    ans=sad(A,a)
print(ans)

Fixed submission:
import math

N=int(input())
A=list(map(int,input().split()))

for i in range(N):
    A[i]-=i+1
A.sort()
a=N//2

def sad(A,a):
    sadness=0
    for i in range(N):
        sadness+=abs(A[i]-A[a])
    return sadness

if N%2==0:
    ans=min(sad(A,a),sad(A,a+1))
else:
    ans=sad(A,a)
print(ans)

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

N=int(input())
A=list(map(int,input().split()))

for i in range(N):
    A[i]-=i+1
A.sort()
a=N//2

def sad(A,a):
    sadness=0
    for i in range(N):
        sadness+=abs(A[i]-A[a])
    return sadness

print(min(sad(A,a),sad(A,a+1)))

Fixed submission:
import math

N=int(input())
A=list(map(int,input().split()))

for i in range(N):
    A[i]-=i+1
A.sort()
a=N//2

def sad(A,a):
    sadness=0
    for i in range(N):
        sadness+=abs(A[i]-A[a])
    return sadness

if N%2==0:
    ans=min(sad(A,a),sad(A,a+1))
else:
    ans=sad(A,a)
print(ans)
Buggy python submission (verdict: Runtime Error):
import math

N,K=map(int,input().split())
A=[*map(int,input().split())]

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


Fixed submission:
import math

N,K=map(int,input().split())
A=list(map(int,input().split()))

ans=math.ceil((N-1)/(K-1))
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
X=list(map(int,input().split()))

num=[i+1 for i in range(N)]
l=zip(num,X)
l=sorted(l,key=lambda x:x[1])
indexlist=[]
for i in range(N):
    indexlist.append(l[i][0])
for i in range(N):
    x=indexlist.index(i+1)
    if x<=N//2-1:
        ans=l[N//2][1]
    else:
        ans=l[N//2-1][1]
    print(ans)

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

# Xをソート(Xsort)
# 除く数字が中央より左の場合、答えは中央右(r)の数字
# 逆も然り
Xsort=sorted(X)
l=(N-1)//2
r=l+1
th=Xsort[l]
for i in range(N):
    if X[i]<=th:
        ans=Xsort[r]
    else:
        ans=Xsort[l]
    print(ans)

Buggy python submission (verdict: Runtime Error):
N=int(input())
X=[*map(int,input().split())]

num=[i+1 for i in range(N)]
l=zip(num,X)
l=sorted(l,key=lambda x:x[1])
indexlist=[]
for i in range(N):
    indexlist.append(l[i][0])
for i in range(N):
    x=indexlist.index(i+1)
    if x<=N//2-1:
        ans=l[N//2][1]
    else:
        ans=l[N//2-1][1]
    print(ans)

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

# Xをソート(Xsort)
# 除く数字が中央より左の場合、答えは中央右(r)の数字
# 逆も然り
Xsort=sorted(X)
l=(N-1)//2
r=l+1
th=Xsort[l]
for i in range(N):
    if X[i]<=th:
        ans=Xsort[r]
    else:
        ans=Xsort[l]
    print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import itertools

N=int(input())
march='MARCH'
S=[]
for _ in range(N):
    s=input()
    if s[0] in march:
        S.append(s)
cnt=0
if len(S)>=3:
    cnt=0
    combi=list(itertools.combinations(S,3))
    for i in combi:
        head=[]
        for j in range(3):
            head.append(i[j][0])
        if len(set(head))==3:
            cnt+=1
print(cnt)

Fixed submission:
import itertools

N=int(input())
march='MARCH'
S=[]
counter={'M':0,'A':0,'R':0,'C':0,'H':0}
for _ in range(N):
    s=input()
    if s[0] in march:
        counter[s[0]]+=1
        S.append(s)
ans=0
if len(S)>=3:
    select=list(itertools.combinations(march,3))
    for i in range(len(select)):
        key=[]
        key.append(select[i][0])
        key.append(select[i][1])
        key.append(select[i][2])
        ans+=counter[key[0]]*counter[key[1]]*counter[key[2]]
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
a=list(map(int,input().split()))

dic={}
keylist=list(set(a))
cnt=0
for i in range(len(keylist)):
    serchingnum=keylist[i]
    num=a.count(serchingnum)
    if num>=serchingnum:
        cnt+=num-serchingnum
    else:
        cnt+=num
print(cnt)


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

cnt=0
counterarr=[0 for _ in range(N)]
others=[]
for i in range(N):
    if a[i]-1<N:
        counterarr[a[i]-1]+=1
    else:
        others.append(a[i])
for i in range(N):
    shoudbe=i+1
    now=counterarr[i]
    if shoudbe>now:
        cnt+=now
    elif shoudbe<now:
        cnt+=now-shoudbe
cnt+=len(others)
print(cnt)
Buggy python submission (verdict: Runtime Error):
N=int(input())
F=[]
P=[]
for _ in range(N):
    F.append(list(map(int,input().split())))
for _ in range(N):
    P.append(list(map(int,input().split())))

m=2**10
gain=-10**8
for i in range(1,2**10):
    x=list(map(int,format(i,'b').zfill(10)))
    sumP=0
    for j in range(N):
        total=sum([a*b for a,b in zip(x,F[j])])
        sumP+=P[j][total]
    gain=max(gain,sumP)
print(gain)

Fixed submission:
SS=list(input())
T=list(input())

SS.reverse()
T.reverse()

flag=0
for i in range(len(SS)-len(T)+1):
    if flag==0:
        for j in range(len(T)):
            if SS[i+j]==T[j] or SS[i+j]=='?':
                if j==len(T)-1:
                    flag=1
                    for k in range(len(T)):
                        SS[i+k]=T[k]
                    break
            else:
                break
            #if flag==1:
            #    break

ans=''
SS.reverse()
if flag==1:
    for i in range(len(SS)):
        if SS[i]=='?':
            SS[i]='a'
        ans+=SS[i]
else:
    ans='UNRESTORABLE'
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=[]
for i in range(N):
    x=int(input())
    if x in A:
        A.remove(x)
    else:
        A.append(x)

print(len(A))

Fixed submission:
N=int(input())
A=set()
for i in range(N):
    x=int(input())
    if x in A:
        A.remove(x)
    else:
        A.add(x)

print(len(A))

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=[]
for i in range(N):
    A.append(int(input()))

A=sorted(A)
s=0
cnt=0
for _ in range(N):
    if s>=N:
    	break
    else:
        for i in range(s,N-1):	
            if A[i]==A[i+1]:
                cnt+=1
                s=i+2
                break
print(N-2*cnt)

Fixed submission:
N=int(input())
A=set()
for i in range(N):
    x=int(input())
    if x in A:
        A.remove(x)
    else:
        A.add(x)

print(len(A))

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=[]
for i in range(N):
    A.append(int(input()))

A=sorted(A)
s=0
cnt=0
while 1:
    if s>=N:
    	break
    else:
        for i in range(s,N-1):	
            if A[i]==A[i+1]:
                cnt+=1
                s=i+2
                break
print(N-2*cnt)

Fixed submission:
N=int(input())
A=set()
for i in range(N):
    x=int(input())
    if x in A:
        A.remove(x)
    else:
        A.add(x)

print(len(A))
Buggy python submission (verdict: Runtime Error):
N=int(input().strip())
p=map(int,input().split())

ans=0
flag=0
for i in range(len(p)):
    if i+1 == p[i]:
        if flag==0:
            ans+=1
        else: # if flag == 1
            flag=0
print(ans)

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

ans=0
flag=0
for i in range(len(p)):
    if i+1 == p[i]:
        if flag==0:
            ans+=1
            flag=1
        else: # if flag == 1
            flag=0
    else: # if i+1 != p[i] 
        flag=0

print(ans)
Buggy python submission (verdict: Runtime Error):
N=int(raw_input().strip())
A=map(int,raw_input().split())

A.sort()
Auni=list(set(A))
Auni.reverse()

num=[]
for i in Auni:
    num.append(A.count(i))

edge=[0,0]
for j in range(2):
    for i in range(len(num)):
        if num[i]>=2:
            num[i]=num[i]-2
            edge[j]=Auni[i]
            break
print edge[0]*edge[1]

Fixed submission:
x,a,b=map(float,raw_input().split())
AX=abs(a-x)
BX=abs(b-x)
if AX>BX:
    print "B"
else:
    print "A"
Buggy python submission (verdict: Runtime Error):
import math

N=int(input())
x=1
for i in range(N):
    t=int(input())
    x=(x*t)//math.gcd(x,t)
print(x)

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

N=int(input())
x=1
for i in range(N):
    t=int(input())
    x=(x*t)//gcd(x,t)
print(x)
Buggy python submission (verdict: Runtime Error):
import math

N,K=map(int,input().split())
A=list(map(int,input().split()))

A=list(set(A))
N=len(A)
A.sort()

g=A[0]
for i in range(N-1):
    g=math.gcd(g,A[i+1])

#tmp=0
#ans="POSSIBLE"
#for i in range(N):
#    tmp+=A[i]%g
if g==1 and K<=A[-1]:
    ans="POSSIBLE"
else:
    ans="IMPOSSIBLE"
if N==1:
    ans="POSSIBLE"
print(ans)

Fixed submission:
import fractions

N,K=map(int,input().split())
A=list(map(int,input().split()))

A=list(set(A))
N=len(A)
A.sort()

g=A[0]
for i in range(N-1):
    g=fractions.gcd(g,A[i+1])

if K%g==0 and K<=A[-1]:
    ans="POSSIBLE"
else:
    ans="IMPOSSIBLE"
print(ans)

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

A=list(set(A))
N=len(A)
A.sort()
tmp=0
for i in range(N-1):
    tmp+=A[i+1]%A[0]
if tmp>0 and K<=A[-1]:
    pass
else:
    ans="IMPOSSIBLE"
if N==1:
    ans="POSSIBLE"
print(ans)

Fixed submission:
import fractions

N,K=map(int,input().split())
A=list(map(int,input().split()))

A=list(set(A))
N=len(A)
A.sort()

g=A[0]
for i in range(N-1):
    g=fractions.gcd(g,A[i+1])

if K%g==0 and K<=A[-1]:
    ans="POSSIBLE"
else:
    ans="IMPOSSIBLE"
print(ans)
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python

N,K=map(int,raw_input().split())
l=map(int,raw_input().split())
l.sort()
print sum(l[len(l)-K:len(l)])

Fixed submission:
#!/usr/bin/env python

A,B=map(int,raw_input().split())
ans='Impossible'
if A%3==0:
    ans='Possible'
if B%3==0:
    ans='Possible'
if (A+B)%3==0:
    ans='Possible'

print ans
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))

b=[]
offset=0
if n%2==1:
    offset=1
for i in range(n):
    if (i+offset)%2==0:
        b.append(a[i])
    else:
        b.insert(0,a[i])
for i in b:
    print(i,end=" ")

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

b1=[]
b2=[]
offset=0
if n%2==1:
    offset=1
for i in range(n):
    if (i+offset)%2==0:
        b1.append(a[i])
    else:
        b2.append(a[i])
b2=list(reversed(b2))
b=b2+b1
for i in b:
    print(i,end=" ")
Buggy python submission (verdict: Time Limit Exceeded):
N,M=map(int,input().split())

div=10**9+7
n=1
m=1
diff=abs(N-M)
for i in range(1,N+1):
    n*=i%div
for i in range(1,M+1):
    m*=i%div

if diff>1:
    ans=0
elif diff==0:
    ans=(2*n*m)%div
elif diff==1:
    ans=(n*m)%div
print(ans)

Fixed submission:
N, M = map(int, input().split())
MOD = 10 ** 9 + 7
nn = 1
mm = 1
for i in range(1, N + 1):
  nn = (nn * i) % MOD
for j in range(1, M + 1):
  mm = (mm * j) % MOD
if abs(N - M) >= 2:
  ans = 0
elif abs(N - M) == 1:
  ans = (nn * mm) % MOD
else:
  ans = (2 * nn * mm) % MOD
print(ans)

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

div=10**9+7
n=1
m=1
diff=abs(N-M)
for i in range(N):
    n*=(i+1)%div
for i in range(M):
    m*=(i+1)%div

if diff>1:
    ans=0
elif diff==0:
    ans=(2*n*m)%div
elif diff==1:
    ans=(n*m)%div
print(ans)

Fixed submission:
N, M = map(int, input().split())
MOD = 10 ** 9 + 7
nn = 1
mm = 1
for i in range(1, N + 1):
  nn = (nn * i) % MOD
for j in range(1, M + 1):
  mm = (mm * j) % MOD
if abs(N - M) >= 2:
  ans = 0
elif abs(N - M) == 1:
  ans = (nn * mm) % MOD
else:
  ans = (2 * nn * mm) % MOD
print(ans)

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

div=10**9+7
tmp=1
K=min(N,M)
diff=abs(N-M)
for i in range(K):
    tmp*=(i+1)%div

if diff>3:
    ans=0
elif diff==0:
    ans=2*tmp*tmp%div
elif diff==1:
    ans=tmp*(tmp+K+1+1)%div
print(ans)

Fixed submission:
N, M = map(int, input().split())
MOD = 10 ** 9 + 7
nn = 1
mm = 1
for i in range(1, N + 1):
  nn = (nn * i) % MOD
for j in range(1, M + 1):
  mm = (mm * j) % MOD
if abs(N - M) >= 2:
  ans = 0
elif abs(N - M) == 1:
  ans = (nn * mm) % MOD
else:
  ans = (2 * nn * mm) % MOD
print(ans)

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

div=10**9+7
tmp=1
K=min(N,M)
diff=abs(N-M)
for i in range(K):
    tmp*=(i+1)%div
ans=max(0,(2-diff)*tmp*tmp*(1+K*diff))%div
print(ans)

Fixed submission:
N, M = map(int, input().split())
MOD = 10 ** 9 + 7
nn = 1
mm = 1
for i in range(1, N + 1):
  nn = (nn * i) % MOD
for j in range(1, M + 1):
  mm = (mm * j) % MOD
if abs(N - M) >= 2:
  ans = 0
elif abs(N - M) == 1:
  ans = (nn * mm) % MOD
else:
  ans = (2 * nn * mm) % MOD
print(ans)
Buggy python submission (verdict: Runtime Error):
# 誰か奇数になったら終了
# A==B==C になったら-1

A,B,C=map(int,input().split())
cnt=0
while A%2==0 and B%2==0 and C%2==0:
    if A==B==C:
        ans=-1
        break
    else:
        A,B,C=(B+C)//2,(C+A)//2,(A+B)//2
        cnt+=1
        ans=cnt
print(ans)

Fixed submission:
# 誰か奇数になったら終了
# A==B==C になったら-1

A,B,C=map(int,input().split())
cnt=0
ans=0
while A%2==0 and B%2==0 and C%2==0:
    if A==B==C:
        ans=-1
        break
    else:
        A,B,C=(B+C)//2,(C+A)//2,(A+B)//2
        cnt+=1
        ans=cnt
print(ans)
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python

n=int(raw_input().strip())
arr=map(int,raw_input().split())

b=0
cnt=0

for i in xrange(n-1):
    diff=arr[i+1]-arr[i]
    if b*diff<0:
        cnt+=1
        b=0
    elif d==0:
        b=diff
print cnt+1

Fixed submission:
#!/usr/bin/env python

n=int(raw_input().strip())
arr=map(int,raw_input().split())

b=0
cnt=0

for i in xrange(n-1):
    diff=arr[i+1]-arr[i]
    if b*diff<0:
        cnt+=1
        b=0
    elif b==0:
        b=diff
print cnt+1
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python

a,b,c=int(raw_input().split())

if c-b==b-a:
    print 'YES'
else:
    print 'NO'

Fixed submission:
#!/usr/bin/env python

a,b,c=map(int,raw_input().split())

if c-b==b-a:
    print 'YES'
else:
    print 'NO'
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python

import math

n=int(raw_input().strip())
N=int(math.ceil(math.sqrt(float(n))))
a=[]
for i in range(1,N+1):
    if n%i==0:
        a.append(i)
A=max(a)
B=int(n/A)
A_keta=len(map(int,str(A)))
B_keta=len(map(int,str(B)))
F=max(A_keta,B_keta)
print F


Fixed submission:
A,B=map(int,raw_input().split())
print (A+B)%24
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python

from sys import stdin

N,C,K=map(int,raw_input(),split(" "))
T=map(int,stdin.read().split())

T.sort()
t_star=t[0]
b_star=0
cnt=0
for b,t in enumerate(T):
    if t-t_star>K or b-b_star+1==C:
        cnt+=1
        t_star=t
        b_star=b

print cnt

Fixed submission:
#!/usr/bin/env python

from sys import stdin

N,C,K=map(int,raw_input().split())
T=map(int,stdin.read().split())

T.sort()
t_star=T[0]
b_star=0
cnt=0
for b,t in enumerate(T):
    if t-t_star>K or b-b_star+1>C:
        cnt+=1
        t_star=t
        b_star=b

print cnt+1
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python

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

if m<=2*n:
    print n+(m-2*n)/4
else:
    print m/2

Fixed submission:
#!/usr/bin/env python

x=0
y=0
n=int(raw_input().strip())
x=800*n
y=n/15*200
print x-y

Buggy python submission (verdict: Runtime Error):
800*N-15%N*200


Fixed submission:
#!/usr/bin/env python

x=0
y=0
n=int(raw_input().strip())
x=800*n
y=n/15*200
print x-y
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python

n=int(raw_input().strip())

power=1
for i in range(1,n+1):
    power=power*i

print power%(10**9+7)

Fixed submission:
N = input()
ans = 1
for i in range(1, N + 1):
	ans = (ans * i) % (1e9 + 7)
print int(ans)
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python
from itertools import permutations
N,M=map(int,raw_input().split())
path=[]
all_list=[]
count=0
 
for i in range(M):
    path.append(map(int,raw_input().split()))

NN=N*(N-1)/2
all_list=map(list,permutations(range(1,NN+1),2))
for i in range(len(all_list)):
    for j in range(M):
        if all_list[i]==path[j]:
            count=count+1
 
print count

Fixed submission:
#!/usr/bin/env python

numbers = raw_input().split()

A = int(numbers[0])
B = int(numbers[1])

if A == B :
   print "Draw"
elif A == 1:
   print "Alice"
elif B == 1:
   print "Bob"
elif A > B:
   print "Alice"
elif B > A:
   print "Bob"

Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python

N,M=map(int,input().split())
path=[]
all_list=[]
count=0

for i in range(M):
    path.append(map(int,raw_input().split()))

NN=N*(N-1)/2
all_list=map(list,permutations(range(NN),2))
for i in all_list[i]:
    for j in path[j]:
        if all_list[i]==path[j]:
            count=count+1

print count

Fixed submission:
#!/usr/bin/env python

numbers = raw_input().split()

A = int(numbers[0])
B = int(numbers[1])

if A == B :
   print "Draw"
elif A == 1:
   print "Alice"
elif B == 1:
   print "Bob"
elif A > B:
   print "Alice"
elif B > A:
   print "Bob"

Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python

N,M=input().split()
path=[]
all_list=[]
count=0

for i in range(M):
    path.append(map(int,raw_input().split()))

NN=N*(N-1)/2
all_list=map(list,permutations(range(NN),2))
for i in all_list[i]:
    for j in path[j]:
        if all_list[i]==path[j]:
            count=count+1

print count

Fixed submission:
#!/usr/bin/env python

numbers = raw_input().split()

A = int(numbers[0])
B = int(numbers[1])

if A == B :
   print "Draw"
elif A == 1:
   print "Alice"
elif B == 1:
   print "Bob"
elif A > B:
   print "Alice"
elif B > A:
   print "Bob"
Buggy python submission (verdict: Time Limit Exceeded):
import math

N=int(input())
A=[]
B=[]
for _ in range(N):
    a,b=map(int,input().split())
    A.append(a)
    B.append(b)

A.reverse()
B.reverse()
#print("initial A B")
#print(A)
#print(B)
cnt=0
for i in range(N):
    tmp=math.ceil(A[i]/B[i])*B[i]-A[i]
    for j in range(i,N):
        A[j]+=tmp
    cnt+=tmp
    #print("tmp,cnt,A",tmp,cnt,A)
print(cnt)

Fixed submission:
import math

N=int(input())
A=[]
B=[]
for _ in range(N):
    a,b=map(int,input().split())
    A.append(a)
    B.append(b)

A.reverse()
B.reverse()
cnt=0
for i in range(N):
    A[i]+=cnt
    tmp=math.ceil(A[i]/B[i])*B[i]-A[i]
    cnt+=tmp
print(cnt)
Buggy python submission (verdict: Time Limit Exceeded):
import itertools

K,S=map(int,input().split())
combi=[]
num=0
for i in range(K+1):
    for j in range(K+1):
        if 0<=S-i-j<=K:
            combi=[i,j,S-i-j]
            #print(combi)
            #print(set(itertools.permutations(combi)))
            num+=1
print(num)

Fixed submission:
K,S=map(int,input().split())
num=0
for i in range(K+1):
    for j in range(K+1):
        if 0<=S-i-j<=K:
            num+=1
print(num)

Buggy python submission (verdict: Time Limit Exceeded):
import itertools

K,S=map(int,input().split())
combi=[]
num=0
for i in range(K+1):
    for j in range(i,K+1):
        for k in range(j,K+1):
            if i+j+k==S:
                combi=[i,j,k]
                #print(combi)
                #print(set(itertools.permutations(combi)))
                t=set(itertools.permutations(combi))
                #print(len(t))
                num+=len(t)
print(num)

Fixed submission:
K,S=map(int,input().split())
num=0
for i in range(K+1):
    for j in range(K+1):
        if 0<=S-i-j<=K:
            num+=1
print(num)

Buggy python submission (verdict: Time Limit Exceeded):
import itertools

K,S=map(int,input().split())
a=list(range(K+1))
#print(a)
combi=list(itertools.product(a,repeat=3))
#print(combi)
print([sum(combi[i]) for i in range(len(combi))].count(S))

Fixed submission:
K,S=map(int,input().split())
num=0
for i in range(K+1):
    for j in range(K+1):
        if 0<=S-i-j<=K:
            num+=1
print(num)
Buggy python submission (verdict: Runtime Error):
print(1/int(input))

Fixed submission:
ans = int(input())
if ans == 1: print(ans)
elif ans % 2 == 1:
    print( (int(ans/2)+1)/ans )
elif ans % 2 ==0:
    print((int(ans/2))/ans)
Buggy python submission (verdict: Runtime Error):
N,Q = map(int, input().split())
S = input()
count = [0]*8
ans = []
for i in range(1,N):
    count[i] += count[i-1]
    if S[i-1:i+1]=='AC' : count[i] += 1
for i in range(Q):
    l,r = map(int, input().split())
    ans.append(count[r-1]-count[l-1])
for i in  ans:
    print(i)

Fixed submission:
N,Q = map(int, input().split())
S = input()
count = [0]*N
ans = []
for i in range(1,N):
    count[i] += count[i-1]
    if S[i-1:i+1]=='AC' : count[i] += 1
for i in range(Q):
    l,r = map(int, input().split())
    ans.append(count[r-1]-count[l-1])
for i in  ans:
    print(i)

Buggy python submission (verdict: Runtime Error):
N,Q = map(int, input().split())
S = input()
count = [0]*8
for i in range(1,N):
    count[i] += count[i-1]
    if S[i-1:i+1]=='AC' : count[i] += 1
for i in range(Q):
    l,r = map(int, input().split())
    print(count[r-1]-count[l-1])

Fixed submission:
N,Q = map(int, input().split())
S = input()
count = [0]*N
ans = []
for i in range(1,N):
    count[i] += count[i-1]
    if S[i-1:i+1]=='AC' : count[i] += 1
for i in range(Q):
    l,r = map(int, input().split())
    ans.append(count[r-1]-count[l-1])
for i in  ans:
    print(i)
Buggy python submission (verdict: Runtime Error):
n,m,c=map(int,input().split())
b=list(map(int,input().split()))
B=np.array(b)
count=0
for i in range(n):
    A=np.array(list(map(int,input().split())))
    S=np.dot(B,A) + c
    if(S>0):
        count+=1
print(count)

Fixed submission:
N, M, C = map(int, input().split())
B = list(map(int, input().split()))
count=0
for i in range(N):
    A = list(map(int, input().split()))
    SUM=0
    for j in range(M):
        SUM += A[j]*B[j]
    if SUM+C > 0:count += 1
print(count)
Buggy python submission (verdict: Runtime Error):
a,b,c = map(int,input().split())
print(int(a*b/2)

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