Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
n=int(input())
d = [[0] * 10 for i in range(10)]

ans = 0
for i in range(1,n+1):
    s=str(i)
    if s[0]=="0" or s[-1]=="0":
        continue
    else:
        d[int(s[0])][int(s[-1])] += 1

ans = 0
for i in range(1,10):
    for j in range(1,10):
        ans += d[i][j] * d[j][i]

print(ans)
n = int(input())

d = [[0] * 10 for i in range(10)]

ans = 0
for i in range(1,n + 1):
    s = str(i)
    if s[0] == "0" or s[-1] == "0":
        continue
    else:
        d[int(s[0])][int(s[-1])] += 1

ans = 0
for i in range(1,10):
    for j in range(1,10):
        ans += d[i][j] * d[j][i]

print(ans)

Fixed submission:
n=int(input())
d = [[0] * 10 for i in range(10)]

ans = 0
for i in range(1,n+1):
    s=str(i)
    if s[0]=="0" or s[-1]=="0":
        continue
    else:
        d[int(s[0])][int(s[-1])] += 1

ans = 0
for i in range(1,10):
    for j in range(1,10):
        ans += d[i][j] * d[j][i]

print(ans)
Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
acf,waf=[0]*n,[0]*n
ac,wa=0,0
for i in range(m):
    x,y=input().split()
    x=int(x)
    if y=='AC':
        if acf[x]==0:
            ac+=1
            wa+=waf[x-1]
            acf[x-1]+=1
    else:
        waf[x-1]+=1
print(ac,wa)


Fixed submission:
n,m=map(int,input().split())
acf,waf=[0]*n,[0]*n
ac,wa=0,0
for i in range(m):
    x,y=input().split()
    x=int(x)
    if y=='AC':
        if acf[x-1]==0:
            ac+=1
            wa+=waf[x-1]
            acf[x-1]+=1
    else:
        waf[x-1]+=1
print(ac,wa)
Buggy python submission (verdict: Runtime Error):
n,k=map(int,input().split())
r,s,p=map(int,input().split())
t=input()
p_list=[]
score=0
for i in range(len(t)):
    if i<k:
        if t[i]=='r':
            p_list.appned('p')
            score+=p
        elif t[i]=='s':
            p_list.appned('r')
            score+=r
        else:
            p_list.appned('s')
            score+=s
    else:
        if t[i]=='r':
            if t[i-k]=='p':
                if i+k>=len(t):
                    score+=0
                else:
                    p_list.appned(t[i+k])
            else:
                p_list.appned('p')
                score+=p
        elif t[i]=='s':
            if t[i-k]=='r':
                if i+k>=len(t):
                    score+=0
                else:
                    p_list.appned(t[i+k])
            else:
                p_list.appned('r')
                score+=r
        else:
            if t[i-k]=='s':
                if i+k>=len(t):
                    score+=0
                else:
                    p_list.appned(t[i+k])
            else:
                p_list.appned('s')
                score+=s
print(score)


Fixed submission:
n,k=map(int,input().split())
r,s,p=map(int,input().split())
t=input()
p_list=[]
score=0
for i in range(len(t)):
    if i<k:
        if t[i]=='r':
            p_list.append('p')
            score+=p
        elif t[i]=='s':
            p_list.append('r')
            score+=r
        else:
            p_list.append('s')
            score+=s
    else:
        if t[i]=='r':
            if p_list[i-k]=='p':
                if i+k>=len(t):
                    p_list.append('a')
                else:
                    p_list.append(t[i+k])
            else:
                p_list.append('p')
                score+=p
        elif t[i]=='s':
            if p_list[i-k]=='r':
                if i+k>=len(t):
                    p_list.append('a')
                else:
                    p_list.append(t[i+k])
            else:
                p_list.append('r')
                score+=r
        else:
            if p_list[i-k]=='s':
                if i+k>=len(t):
                    p_list.append('a')
                else:
                    p_list.append(t[i+k])
            else:
                p_list.append('s')
                score+=s
print(score)
Buggy python submission (verdict: Runtime Error):
a=int(input())
n=list(map(int,input().split()))
mod=10**9+7
import numpy as np
a=np.array(a)
md = len(bin(max(a)))
ans = 0
for d in range(md):
    cnt1 = np.count_nonzero((a>>d)&1)
    ans += cnt1 * (n-cnt1) * (1<<d)
    ans %= mod

print(ans%mod)


Fixed submission:
n=int(input())
a=list(map(int,input().split()))
mod=10**9+7
import numpy as np
a=np.array(a)
md = len(bin(max(a)))
ans = 0
for d in range(md):
    cnt1 = np.count_nonzero((a>>d)&1)
    ans += cnt1 * (n-cnt1) * (1<<d)
    ans %= mod

print(ans%mod)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
s=0
for i in range(n):
    s+=i
print(s)


Fixed submission:
n=int(input())
s=n*(n-1)//2
print(s)
Buggy python submission (verdict: Runtime Error):
import math
k,a,b=map(int,input().split())
s=1:
if b-a<=2 or k-1<2:
    print(k+1)
else:
    t=max(0,math.ceil((k−(a−1))/2))
    ans=a
    k-=a-1
    if k%2==1:
        ans+=1
        k-=1
    ans+=(b-a)*k
    print(ans)


Fixed submission:
import math
k,a,b=map(int,input().split())
s=1
if b-a<=2 or k-1<2:
    print(k+1)
else:
    ans=a
    k-=a-1
    if k%2==1:
        ans+=1
        k-=1
    ans+=(b-a)*(k//2)
    print(ans)
Buggy python submission (verdict: Runtime Error):
n=int(input())
h=list(map(int,input().split()))
f=[0]*n
cnt=0
while 1:
    flag=0
    for i in range(n):
        if h[i]!=f[i]:
            f[i]+=1
            flag=1
        elif h[i]==f[i] and flag==1:
            cnt+=1
            flag=0
    if flag:==1
        cnt+=1

    if h == f:
        break

print(cnt)


Fixed submission:
n=int(input())
h=list(map(int,input().split()))
f=[0]*n
cnt=0
while 1:
    flag=0
    for i in range(n):
        if h[i]!=f[i]:
            f[i]+=1
            flag=1
        elif h[i]==f[i] and flag==1:
            cnt+=1
            flag=0
    if flag==1:
        cnt+=1

    if h==f:
        break

print(cnt)
Buggy python submission (verdict: Runtime Error):
from collections import Counter

n=int(input())
s=list(map(int,input().split()))
e=Counter(s[0::2])
o=Counter(s[1::2])
e[0]=0
o[0]=0
e1,e2=e.most_common(2)
o1,o2=o.most_common(2)
if e1[0]!=o1[0]:
    print(n-(e1[1]+o1[1]))
else:
    print(n-max(e1[1]+o2[1],e2[1]+o1[1]))z

Fixed submission:
from collections import Counter

n=int(input())
s=list(map(int,input().split()))
e=Counter(s[0::2])
o=Counter(s[1::2])
e[0]=0
o[0]=0
e1,e2=e.most_common(2)
o1,o2=o.most_common(2)
if e1[0]!=o1[0]:
    print(n-(e1[1]+o1[1]))
else:
    print(n-max(e1[1]+o2[1],e2[1]+o1[1]))
Buggy python submission (verdict: Time Limit Exceeded):
m=int(input())
n=input()
mm=len(n)
ans=-1
for i in range(mm):
    x=n[0:i].count('W')
    y=n[i+1:].count('E')
    if mm>x+y:
        mm=x+y
        ans=i
print(mm)


Fixed submission:
n=int(input())
s=input()
cnt=s[1:].count('E')
ans=cnt
for i in range(1,n):
    if s[i] == 'E':
        cnt-=1
    if s[i-1] == 'W':
        cnt += 1
    ans = min(ans,cnt)
print(ans)
Buggy python submission (verdict: Runtime Error):
n=int(input())
x=list(map(int,input().split()))
y=sorted(x)
l=y[n//2-1]
r=y[n//2]
for a in x:
  print(L if a >= R else R) 


Fixed submission:
n=int(input())
x=list(map(int,input().split()))
y=sorted(x)
l=y[n//2-1]
r=y[n//2]
for a in x:
  print(l if a >= r else r)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
x=list(map(int,input().split()))
for i in range(n):
    z=x.pop(i)
    y=sorted(x)
    print(y[n//2-1])
    x.insert(i,z)
    


Fixed submission:
n=int(input())
x=list(map(int,input().split()))
y=sorted(x)
l=y[n//2-1]
r=y[n//2]
for a in x:
  print(l if a >= r else r)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))
for i in range(n):
    sum=0
    c=0
    for j in range(n):
        if i==j:
            continue
        else:
            d=abs(c-a[j])
            sum+=d
            c=a[j]
    sum+=abs(c)
    print(sum)


Fixed submission:
n=int(input())
x=list(map(int,input().split()))
a=[]
a.append(0)
for i in range(n):
    a.append(x[i])
a.append(0)
sum=0
for i in range(n+1):
    sum+=abs(a[i]-a[i+1])
for i in range(1,n+1):
    s=abs(a[i-1]-a[i+1])
    s1=abs(a[i-1]-a[i])
    s2=abs(a[i]-a[i+1])
    print(sum+s-(s1+s2))
Buggy python submission (verdict: Runtime Error):
a,b,c,d=list(map(int,input().split()))
x=a+b
y=c+d
if x>y:
  print("Left")
 elif x<y:
  print("Right")
 else:
  print("Balanced")


Fixed submission:
a,b,c,d=list(map(int,input().split()))
x=a+b
y=c+d
if x>y:
  print("Left")
elif x<y:
  print("Right")
else:
  print("Balanced")

Buggy python submission (verdict: Runtime Error):
a,b,c,d=map(int,input().split())
x=a+b
y=c+d
if x>y:
  print("Left")
 elif x<y:
  print("Right")
 else:
  print("Balanced")

Fixed submission:
a,b,c,d=list(map(int,input().split()))
x=a+b
y=c+d
if x>y:
  print("Left")
elif x<y:
  print("Right")
else:
  print("Balanced")
Buggy python submission (verdict: Runtime Error):
n,k=map(int,input().split())
a=list(map(int,input().split()))
s=[0 for i in range(n)]
z=set(a)
y=len(z)
for x in a:
    s[x]+=1
b=sorted(s)
f=0
ans=0
for x in b:
    if x!=0:
        f+=1
        ans+=x
    if f>=y-k:
      	break
print(ans)


Fixed submission:
n,k=map(int,input().split())
a=list(map(int,input().split()))
s=[0 for i in range(n)]
z=set(a)
y=len(z)
for x in a:
    s[x-1]+=1
b=sorted(s)
f=0
ans=0
for x in b:
    if x!=0:
        f+=1
        ans+=x
    if f>=y-k:
      	break
print(ans)

Buggy python submission (verdict: Runtime Error):
n,k=int(input()),int(input())
a=list(map(int,input().split()))
s=set(a)
if len(s)<=k:
    print(0)
else:
    print(len(s)-k)


Fixed submission:
n,k=map(int,input().split())
a=list(map(int,input().split()))
s=[0 for i in range(n)]
z=set(a)
y=len(z)
for x in a:
    s[x-1]+=1
b=sorted(s)
f=0
ans=0
for x in b:
    if x!=0:
        f+=1
        ans+=x
    if f>=y-k:
      	break
print(ans)
Buggy python submission (verdict: Runtime Error):
n=int(input())
m=map(int,input().split())
a=[0 for i in range(1000000)]
x=0
y=0
for i in m:
    a[i]+=1
for i in range(len(a)):
    if a[i]>=2:
        x=y
        y=i

ans=x*y
print(ans)


Fixed submission:
n=int(input())
a=map(int,input().split())
a=sorted(a)
a=list(reversed(a))
h,w=0,0
tmp=0
f=0
for x in a:
    if tmp==x:
        if w!=0:
            h=x
            break
        else:
            w=x
            tmp=0
            continue
    tmp=x
print(w*h)

Buggy python submission (verdict: Runtime Error):
n=int(input())
m=map(int,input().split())
a=[0 for i in range(100001)]
x=0
y=0
for i in m:
    a[i]+=1
for i in range(len(a)):
    if a[i]>=2:
        x=y
        y=i

ans=x*y
print(ans)


Fixed submission:
n=int(input())
a=map(int,input().split())
a=sorted(a)
a=list(reversed(a))
h,w=0,0
tmp=0
f=0
for x in a:
    if tmp==x:
        if w!=0:
            h=x
            break
        else:
            w=x
            tmp=0
            continue
    tmp=x
print(w*h)

Buggy python submission (verdict: Runtime Error):
n=int(input())
m=map(int,input().split())
a=[0 for i in range(100000)]
x=0
y=0
for i in m:
    a[i]+=1
for i in range(len(a)):
    if a[i]>=2:
        x=y
        y=i

ans=x*y
print(ans)


Fixed submission:
n=int(input())
a=map(int,input().split())
a=sorted(a)
a=list(reversed(a))
h,w=0,0
tmp=0
f=0
for x in a:
    if tmp==x:
        if w!=0:
            h=x
            break
        else:
            w=x
            tmp=0
            continue
    tmp=x
print(w*h)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))
b = []
for i in a:
    b.append(i)
    b.reverse()

for i in b:
    print(i)


Fixed submission:
n=int(input())
a=list(map(int,input().split()))
a=a[::-1]
b=[0]*n
x,y=0,1
t=True
for z in a:
    if t:
        b[x]=z
        x+=1
        t=False
    else:
        b[-y]=z
        y+=1
        t=True
print(*b)
Buggy python submission (verdict: Time Limit Exceeded):
def kaijo(x):
    v=1
    for i in range(1,x+1):
        v*=i
    return v


n,m=map(int,input().split())
mod=10**9+7
if abs(n-m)>=2:
    ans=0
else:
    if n==m:
        s=kaijo(n)
        ans=2*s*s
    else:
        if n>m:
            s=kaijo(m)
            ans=s*s*n
        else:
            s=kaijo(n)
            ans=s*s*m

print(ans%mod)


Fixed submission:
def kaijo(x):
    v=1
    for i in range(1,x+1):
        v*=i
    return v


n,m=map(int,input().split())
mod=10**9+7
if abs(n-m)>=2:
    ans=0
else:
    ans=1
    for i in range(1,n+1):
        ans*=i
        ans%=mod
    for i in range(1,m+1):
        ans*=i
        ans%=mod
    if n==m:
        ans*=2
        ans%=mod

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
def kaijo(x):
    v=1
    for i in range(1,x+1):
        v*=i
    return v


n,m=map(int,input().split())
mod=10**9+7
if abs(n-m)>=2:
    ans=0
else:
    if n==m:
        s=kaijo(n)
        ans=2*s*s
    else:
        if n>m:
            s=kaijo(m)
            ans=s*s*n
        else:
            s=kaijo(n)
            ans=s*s*m

print(ans%mod)


Fixed submission:
def kaijo(x):
    v=1
    for i in range(1,x+1):
        v*=i
    return v


n,m=map(int,input().split())
mod=10**9+7
if abs(n-m)>=2:
    ans=0
else:
    ans=1
    for i in range(1,n+1):
        ans*=i
        ans%=mod
    for i in range(1,m+1):
        ans*=i
        ans%=mod
    if n==m:
        ans*=2
        ans%=mod

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
def kaijo(x):
    v=1
    for i in range(1,x+1):
        v*=i
    return v


n,m=map(int,input().split())
mod=10**9+7
if abs(n-m)>=2:
    ans=0
else:
    if n==m:
        ans=2*kaijo(n)*kaijo(m)
    else:
        ans=kaijo(n)*kaijo(m)
print(ans%mod)


Fixed submission:
def kaijo(x):
    v=1
    for i in range(1,x+1):
        v*=i
    return v


n,m=map(int,input().split())
mod=10**9+7
if abs(n-m)>=2:
    ans=0
else:
    ans=1
    for i in range(1,n+1):
        ans*=i
        ans%=mod
    for i in range(1,m+1):
        ans*=i
        ans%=mod
    if n==m:
        ans*=2
        ans%=mod

print(ans)
Buggy python submission (verdict: Runtime Error):
n=int(input())
a=[int(i) for i in input().split()]

cnt=[0]*8
count=0
for i in range(n):
    if a[i]>=1 and a[i]<=399:
        cnt[0]=1
    elif a[i]>=400 and a[i]<=799:
        cnt[1]=1
    elif a[i]>=800 and a[i]<=1199:
        cnt[2]=1
    elif a[i]>=1200 and a[i]<=1599:
        cnt[3]=1
    elif a[i]>=1600 and a[i]<=1999:
        cnt[4]=1
    elif a[i]>=2000 and a[i]<=2399:
        cnt[5]=1
    elif a[i]>=2400 and a[i]<=2799:
        cnt[6]=1
    elif a[i]>=2800 and a[i]<=3199:
        cnt[7]=1
    else:
        count+=1
min_ans=sum(cnt)
if min_ans==0 and count>=1:
    min_ans=1
    count-=1

print(str(min_ans)+' '+str(min_ans+count)


Fixed submission:
n=int(input())
a=[int(i) for i in input().split()]

cnt=[0]*8
count=0
for i in range(n):
    if a[i]>=1 and a[i]<=399:
        cnt[0]=1
    elif a[i]>=400 and a[i]<=799:
        cnt[1]=1
    elif a[i]>=800 and a[i]<=1199:
        cnt[2]=1
    elif a[i]>=1200 and a[i]<=1599:
        cnt[3]=1
    elif a[i]>=1600 and a[i]<=1999:
        cnt[4]=1
    elif a[i]>=2000 and a[i]<=2399:
        cnt[5]=1
    elif a[i]>=2400 and a[i]<=2799:
        cnt[6]=1
    elif a[i]>=2800 and a[i]<=3199:
        cnt[7]=1
    else:
        count+=1
min_ans=sum(cnt)

if count==0:
    min1=min_ans
elif min_ans==0:
    min1=1
else:
    min1=max(1,min_ans)
max1=min_ans+count
print(min1,max1)
Buggy python submission (verdict: Time Limit Exceeded):
n,m=map(int,input().split())
ans=0
for i in range(n):
    if m>=2:
        m-=2
        ans+=1
    else:
        break

while m>=4:
    ans+=1
    m-=4
print(ans)


Fixed submission:
n,m=map(int,input().split())
ans=0
if 2*n<=m:
    ans+=n
    m-=2*n
    ans+=(m//4)
else:
    ans+=m//2
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())

res = [[] for i in range(26)]

for i in range(N) :
  s = input()
  s_later = s[1:]
  first = ord(s[0]) - ord('a')
  ##res_temp = res
  if(s in res[first]) :
    continue
  else :
    res[first].append(s)
    
    
ans = 0
for i in range(26) :
  ans += len(res[i])

print(ans)

Fixed submission:
N = int(input())

mydict = {}

for i in range(N) :
  s = input()
  if(s in mydict) :
    continue
  else :
    mydict[s] = 1
    
    
print(len(mydict))

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())

res = []
for i in range(N) :
  s = input()
  if(s in res) :
    continue
  else :
    res.append(s)
    
    
print(len(res))

Fixed submission:
N = int(input())

mydict = {}

for i in range(N) :
  s = input()
  if(s in mydict) :
    continue
  else :
    mydict[s] = 1
    
    
print(len(mydict))
Buggy python submission (verdict: Time Limit Exceeded):
X, Y, A, B, C = list(map(int, input().split()))
R = list(map(int, input().split()))
G = list(map(int, input().split()))
C = list(map(int, input().split()))

R.sort()
R.reverse()
G.sort()
G.reverse()
C.sort()
C.reverse()

R = R[:X]
G = G[:Y]

temp = 0
  
for i in range(len(C)) :
  if((X==0) and (Y==0)) :
    break
  if(X==0) :
    last = G[Y-1]
    Y -= 1
    
  else :
    if(Y==0) :
      last = R[X-1]
      X -= 1
    else :
      if(R[X-1] < G[Y-1]) :
        last = R[X-1]
        X -= 1
      else :
        last = G[Y-1]
        Y -= 1

  if(C[i] < last) :
    if(i == 0) :
      answer = sum(R[:X]) + sum(G[:Y]) + last
    else :
      break
  else :
    answer = sum(R[:X]) + sum(G[:Y]) + sum(C[:i+1])
    
print(answer)

Fixed submission:
X, Y, A, B, C = list(map(int, input().split()))
R = list(map(int, input().split()))
G = list(map(int, input().split()))
C = list(map(int, input().split()))

R.sort()
R.reverse()
G.sort()
G.reverse()
C.sort()
C.reverse()

R = R[:X]
G = G[:Y]

temp = 0
  
for i in range(len(C)) :
  if((X==0) and (Y==0)) :
    i = i-1
    break
  if(X==0) :
    last = G[Y-1]
    Y -= 1
    
  else :
    if(Y==0) :
      last = R[X-1]
      X -= 1
    else :
      if(R[X-1] < G[Y-1]) :
        last = R[X-1]
        X -= 1
      else :
        last = G[Y-1]
        Y -= 1

  if(C[i] < last) :
      break
  else :
    last = C[i]
    
print(sum(R[:X])+sum(G[:Y])+sum(C[:i])+last)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))

num_list = [0 for i in range(N)]


for n in A :
  num_list[n-1] += 1

for k in range(N) :
  ans = 0
  num_list[A[k]-1] -= 1
  for nums in num_list :
    if(nums != 0) :
      ans += int(nums*(nums-1)/2)
  print(ans)
  num_list[A[k]-1] += 1

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

num_list = [0 for i in range(N)]


for n in A :
  num_list[n-1] += 1
  
calc_list = list(map(lambda x : max(0, int(x*(x-1)/2)), num_list))
s = sum(calc_list)

for k in range(N) :
  print(s - num_list[A[k]-1] + 1)
Buggy python submission (verdict: Time Limit Exceeded):
n, a, b = list(map(int, input().split()))
MAX = 510000
MOD = 1000000007

fac = [0 for i in range(MAX)]
finv = [0 for i in range(MAX)]
inv = [0 for i in range(MAX)]
com = [0 for i in range(MAX)]

def cominit() :
  fac[0] = fac[1] = 1
  finv[0] = finv[1] = 1
  inv[1] = 1
  com[1] = n
  for i in range(2, MAX) :
    fac[i] = fac[i-1] * i % MOD
    inv[i] = MOD - inv[MOD%i] * int(MOD / i) % MOD
    finv[i] = finv[i-1] * inv[i] % MOD
    com[i] = com[i-1] * (n-(i-1)) * inv[i] % MOD
    
  return fac, finv, inv, com
 
"""
def combination(n, r, inv) :
  ans = 1
  if(n < r) : 
    return 0
  if((n < 0) or (r < 0)) :
    return 0
  for i in range(0, r) :
    return (fac[n] * (finv[r] * finv[n-r] % MOD) % MOD) 
 """

def two_n_mod(n) :
  ans = 1
  while(n > 32) :
    ans = ans * 2**32 % MOD
    n -= 32
  return ans * 2**n % MOD

temp = cominit()
##print(two_n_mod(1000000000))
print((two_n_mod(n) - 1 - com[a] - com[b]) % MOD)



Fixed submission:
n, a, b = list(map(int, input().split()))
MAX = 510000
MOD = 1000000007


fac = [0 for i in range(MAX)]
finv = [0 for i in range(MAX)]
inv = [0 for i in range(MAX)]
com = [0 for i in range(MAX)]
power = [2 for i in range(32)]

for i in range(1, 32) :
  power[i] = power[i-1] * power[i-1] % MOD

def cominit() :
  fac[0] = fac[1] = 1
  finv[0] = finv[1] = 1
  inv[1] = 1
  com[1] = n
  for i in range(2, MAX) :
    fac[i] = fac[i-1] * i % MOD
    inv[i] = MOD - inv[MOD%i] * int(MOD / i) % MOD
    finv[i] = finv[i-1] * inv[i] % MOD
    com[i] = com[i-1] * (n-(i-1)) * inv[i] % MOD
    
  return fac, finv, inv, com


def two_n_mod(n) :
  ans = 1
  temp_i = 0
  temp = [0 for i in range(32)]
    
  for i in range(32) :
    temp[i] += n%2
    n = int(n/2)
  ans = (2**n) % MOD
  for i in range(32) :
    ans = ans * (power[i] ** temp[i]) % MOD
  return ans

temp = cominit()
##print(two_n_mod(1000000000))
##print(2**n % MOD)
print((two_n_mod(n) - 1 - com[a] - com[b]) % MOD)
Buggy python submission (verdict: Time Limit Exceeded):
n = input()
a = input()
a = list(map(int, a.split()))

def merge(l) :
  length = len(l)
  
  if(length <= 1) :
    return 0, l
  
  flag, left = merge(l[0:int(length/2)])
  if(flag == 1) :
    return 1, l
  flag, right = merge(l[int(length/2):length])
  if(flag == 1) :
    return 1, l
  
  total = []
  while(True) :
    if(len(left) == 0) :
      total.extend(right)
      return 0, total
    if(len(right) == 0) :
      total.extend(left)
      return 0, total
    if(left[0] == right[0]) :
      return 1, l
    if(left[0] < right[0]) :
      total.append(left.pop(0))
    else :
      total.append(right.pop(0))
        
flag, temp = merge(a)
if(flag == 1) :
  print("NO")
else :
  print("YES")

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

def merge(l) :
  length = len(l)
  
  if(length <= 1) :
    return 0, l
  
  flag, left = merge(l[0:int(length/2)])
  if(flag == 1) :
    return 1, l
  flag, right = merge(l[int(length/2):length])
  if(flag == 1) :
    return 1, l
  
  total = []
  while(True) :
    if(len(left) == 0) :
      total.extend(right)
      return 0, total
    if(len(right) == 0) :
      total.extend(left)
      return 0, total
    if(left[0] == right[0]) :
      return 1, l
    if(left[0] < right[0]) :
      total.append(left.pop(0))
    else :
      total.append(right.pop(0))
        
a.sort()
for i in range(0, len(a)-1) :
  if(a[i] == a[i+1]) :
    print("NO")
    exit()

print("YES")
Buggy python submission (verdict: Time Limit Exceeded):
import sys
k = int(input())
if k %2 == 0:
    print(-1)
    sys.exit()

num = 0

for i in range(k+1):
    num += 7*(10**i)
    if num %k == 0:
        print(i+1)
        sys.exit()
print(-1)


Fixed submission:
import sys
k = int(input())

num = 0
for i in range(k + 1):
    num = (num*10+7)%k
    if num == 0:
        print(i + 1)
        sys.exit()
print(-1)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
k = int(input())
if k %2 == 0:
    print(-1)
    sys.exit()

num = 0

if k == 999983:
    print(999982)
    sys.exit()

for i in range(k):
    num += 7*(10**i)
    if num %k == 0:
        print(i+1)
        sys.exit()
print(-1)

Fixed submission:
import sys
k = int(input())

num = 0
for i in range(k + 1):
    num = (num*10+7)%k
    if num == 0:
        print(i + 1)
        sys.exit()
print(-1)
Buggy python submission (verdict: Time Limit Exceeded):
import math
n = int(input())
ans = 0

for a in range(1,n+1):
    for b in range(1,n+1):
        for c in range(1,n+1):
            ans += math.gcd(a,math.gcd(b,c))
print(ans)

Fixed submission:
import math
from functools import reduce

n = int(input())
ans = 0

def gcd(*numbers):
    return reduce(math.gcd, numbers)

for a in range(1,n+1):
    for b in range(1,n+1):
        for c in range(1,n+1):
            ans += gcd(a,b,c)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import math
from functools import reduce

n = int(input())
ans = 0

def gcd(*numbers):
    return reduce(math.gcd, numbers)

for a in range(1,n+1):
    for b in range(1,n+1):
        for c in range(1,n+1):
            ans += gcd(a,b,c)
print(ans)

Fixed submission:
import math
from functools import reduce

n = int(input())
ans = 0

def gcd(*numbers):
    return reduce(math.gcd, numbers)

for a in range(1,n+1):
    for b in range(1,n+1):
        for c in range(1,n+1):
            ans += gcd(a,b,c)
print(ans)