Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
x = int(input())

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors
  
divisors = make_divisors(x)

for d in divisors:
  b = -d
  f = False
  while True:
    if (b+d)**5 - b**5 == x:
      f = True
      break
    elif (b+d)**5 - b**5 > x and b > 0:
      break
    b += 1
  if f:
    print(b+d, b)
    break

Fixed submission:
x = int(input())

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors
  
divisors = make_divisors(x)

for d in divisors:
  b = - int(x**(1/5)) - 1
  f = False
  while True:
    if (b+d)**5 - b**5 == x:
      f = True
      break
    elif (b+d)**5 - b**5 > x and b > 0:
      break
    b += 1
  if f:
    print(b+d, b)
    break
Buggy python submission (verdict: Runtime Error):
from collections import deque
x, y, a, b, c = [int(i) for i in input().split()]
lp = sorted([int(i) for i in input().split()])
if len(lp) != x:
  del lp[:len(lp)-x]
lp = deque(lp)
lq = sorted([int(i) for i in input().split()])
if len(lq) != y:
  del lq[:len(lq)-y]
lq = deque(lq)
lr = sorted([int(i) for i in input().split()])
lr = deque(lr)


while True:
  if len(lr) == 0:
    break
  r_max = lr[len(lr)-1]
  p_min = lp[0]
  q_min = lq[0]
  if r_max <= p_min and r_max <= q_min:
    break
  elif r_max > q_min and p_min >= q_min:
    del lq[0]
    lq.append(lr.pop(-1))
  elif r_max > p_min and q_min >= p_min:
    del lp[0]
    lp.append(lr.pop(-1))


print(sum(lp) + sum(lq))

Fixed submission:
from collections import deque
x, y, a, b, c = [int(i) for i in input().split()]
lp = sorted([int(i) for i in input().split()])
if len(lp) != x:
  del lp[:len(lp)-x]
lp = deque(lp)
lq = sorted([int(i) for i in input().split()])
if len(lq) != y:
  del lq[:len(lq)-y]
lq = deque(lq)
lr = sorted([int(i) for i in input().split()])
lr = deque(lr)


while True:
  if len(lr) == 0:
    break
  r_max = lr[len(lr)-1]
  p_min = lp[0]
  q_min = lq[0]
  if r_max <= p_min and r_max <= q_min:
    break
  elif r_max > q_min and p_min >= q_min:
    del lq[0]
    lq.append(lr.pop())
  elif r_max > p_min and q_min >= p_min:
    del lp[0]
    lp.append(lr.pop())


print(sum(lp) + sum(lq))

Buggy python submission (verdict: Time Limit Exceeded):
x, y, a, b, c = [int(i) for i in input().split()]
lp = sorted([int(i) for i in input().split()])
if len(lp) != x:
  del lp[:len(lp)-x]
lq = sorted([int(i) for i in input().split()])
if len(lq) != y:
  del lq[:len(lq)-y]
lr = sorted([int(i) for i in input().split()])

while True:
  if len(lr) == 0:
    break
  r_max = lr[len(lr)-1]
  p_min = lp[0]
  q_min = lq[0]
  if r_max <= p_min and r_max <= q_min:
    break
  elif r_max > q_min and p_min >= q_min:
    del lq[0]
    lq.append(lr.pop(-1))
  elif r_max > p_min and q_min >= p_min:
    del lp[0]
    lp.append(lr.pop(-1))


print(sum(lp) + sum(lq))

Fixed submission:
from collections import deque
x, y, a, b, c = [int(i) for i in input().split()]
lp = sorted([int(i) for i in input().split()])
if len(lp) != x:
  del lp[:len(lp)-x]
lp = deque(lp)
lq = sorted([int(i) for i in input().split()])
if len(lq) != y:
  del lq[:len(lq)-y]
lq = deque(lq)
lr = sorted([int(i) for i in input().split()])
lr = deque(lr)


while True:
  if len(lr) == 0:
    break
  r_max = lr[len(lr)-1]
  p_min = lp[0]
  q_min = lq[0]
  if r_max <= p_min and r_max <= q_min:
    break
  elif r_max > q_min and p_min >= q_min:
    del lq[0]
    lq.append(lr.pop())
  elif r_max > p_min and q_min >= p_min:
    del lp[0]
    lp.append(lr.pop())


print(sum(lp) + sum(lq))
Buggy python submission (verdict: Time Limit Exceeded):
n, a, b = [int(i) for i in input().split()]

def cmb(n, r, mod):
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7 #出力の制限
N = n+1
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

total = 2**n - 1

at = cmb(n,a,mod)
bt = cmb(n,b,mod)

result = total - at - bt
result %= mod
if result < 0:
  result += mod
print(result)

Fixed submission:
n, a, b = [int(i) for i in input().split()]
mod = 10**9 + 7

total = (2**n - 1) % mod
def modinv(a, mod=10**9+7):
    return pow(a, mod-2, mod)
def combination(n, r, mod=10**9+7):
    r = min(r, n-r)
    res = 1
    for i in range(r):
        res = res * (n - i) * modinv(i+1, mod) % mod
    return res

at = combination(n,a)
bt = combination(n,b)

result = total - at - bt
result %= mod
if result < 0:
  result += mod
print(result)
Buggy python submission (verdict: Runtime Error):
# coding: utf-8
# Your code here!
n_str = input()
k = int(input())

def k1(n_str):
	n_str = str(int(n_str))
	n_len = len(n_str)
	return 9*(n_len-1) + int(n_str[0])

def k2(n_str):
    s = 0
    n_str = str(int(n_str))
    n_len = len(n_str)
    if n_len < 2:
        return 0
    s += k2('9'*(n_len - 1))
    s += k1('9'*(n_len - 1)) * (int(n_str[0]) - 1)
    s += k1(n_str[1:])
    return s
                      
def k3(n_str):
    s = 0
    n_str = str(int(n_str))
    n_len = len(n_str)
    if n_len < 3:
        return 0
    s += k3('9'*(n_len - 1))
    s += k2('9'*(n_len - 1)) * (int(n_str[0]) - 1)
    s += k2(n_str[1:])
    return s

if k == 1:
    print(k1(n_str))
elif k == 2:
    print(k2(n_str))
elif k == 3:
    print(k3(n_str))
                      

                      

Fixed submission:
s1, s2 = input().split()
a1, a2 = [int(i) for i in input().split()]
s = input()

if s1 == s:
  print(a1 - 1, a2)
elif s2 == s:
  print(a1, a2 - 1)
else:
  print(a1, a2)

Buggy python submission (verdict: Runtime Error):
n, k = [int(i) for i in input().split(' ')]
input_list = [int(i) for i in input().split(' ')]
 
maximum = sum(input_list[:k])
s = sum(input_list[:k])
for i in range(1, n-k+1):
  s = s - input_list[i-1] + input_list[i+k-1]
  maximum = max(maximum, s)

print( (maximum + k) / 2 )

Fixed submission:
s1, s2 = input().split()
a1, a2 = [int(i) for i in input().split()]
s = input()

if s1 == s:
  print(a1 - 1, a2)
elif s2 == s:
  print(a1, a2 - 1)
else:
  print(a1, a2)
Buggy python submission (verdict: Runtime Error):
input_length = int(input())
length = len(list(set([int(i) for i in input.split(' ')]))) 

if length == input_length:
  print('YES')
else:
  print('NO')

Fixed submission:
input_length = int(input())
length = len(list(set([int(i) for i in input().split(' ')]))) 
 
if length == input_length:
  print('YES')
else:
  print('NO')
Buggy python submission (verdict: Time Limit Exceeded):
n, k = [int(i) for i in input().split(' ')]
input_list = [int(i) for i in input().split(' ')]
 
maximum = 0
for i in range(n-k+1):
  maximum = max(maximum, sum(input_list[i:i+k]))

print( (maximum + k) / 2 )

Fixed submission:
n, k = [int(i) for i in input().split(' ')]
input_list = [int(i) for i in input().split(' ')]
 
maximum = sum(input_list[:k])
s = sum(input_list[:k])
for i in range(1, n-k+1):
  s = s - input_list[i-1] + input_list[i+k-1]
  maximum = max(maximum, s)

print( (maximum + k) / 2 )
Buggy python submission (verdict: Runtime Error):
print((int(input())-1//2)

Fixed submission:
print((int(input())-1)//2)
Buggy python submission (verdict: Runtime Error):
N,K=map(int,input().split())
h=[int(input()) for i in range(N)]
h.sort()
m=1000000
for i in range(N-K+1):
    m=min(m,max(h[i:K+1])-min(h[i:K+1]))
print(m)

Fixed submission:
N,K=map(int,input().split())
h=[int(input()) for i in range(N)]
h.sort()
m=100000000000000
for i in range(N-K+1):
    m=min(m,h[i+K-1]-h[i])
print(m)
Buggy python submission (verdict: Runtime Error):
x,a,b=map(int,input().split())
if abs(x-a) < abs(x-b):
    print("A")
else:
    pring("B")

Fixed submission:
x,a,b=list(map(int,input().split()))
if abs(x-a) < abs(x-b):
    print("A")
else:
    print("B")
Buggy python submission (verdict: Runtime Error):
a,b,c,d=map((int,input().split()))
start=min(a,b)
end=min(c,d)
print(end-start if end-start > 0 else 0)

Fixed submission:
a,b,c,d=map(int,input().split())
start=max(a,c)
end=min(b,d)
print(end-start if end-start > 0 else 0)
Buggy python submission (verdict: Runtime Error):
s=input()
print(s[0] + str(len(s-2))+ s[-1])

Fixed submission:
s=input()
print(s[0] + str(len(s)-2)+ s[-1])
Buggy python submission (verdict: Runtime Error):
N = input()
t = 1;
while(t <= N):
    t *= 2
print(t)

Fixed submission:
N = int(input())
t = 1;
while(t * 2 <= N):
    t *= 2
print(t)
Buggy python submission (verdict: Runtime Error):
a,b,c=input().split()
print "YES" if a[-1] == b[0] and b[-1] == c[0] else "NO"

Fixed submission:
a,b,c=input().split()
print("YES" if a[-1] == b[0] and b[-1] == c[0] else "NO")

Buggy python submission (verdict: Runtime Error):
a,b,c=input().split()
print "YES" if a[-1] == b[0] && b[-1] == c[0] else "NO"

Fixed submission:
a,b,c=input().split()
print("YES" if a[-1] == b[0] and b[-1] == c[0] else "NO")

Buggy python submission (verdict: Runtime Error):
a,b,c=input().split()
print "YES" if a.last() == b.first() && b.last() == c.first() else "NO"

Fixed submission:
a,b,c=input().split()
print("YES" if a[-1] == b[0] and b[-1] == c[0] else "NO")

Buggy python submission (verdict: Runtime Error):
a,b,c=map(int(),split())
print "YES" if a.last() == b.first() && b.last() == c.first() else "NO"

Fixed submission:
a,b,c=input().split()
print("YES" if a[-1] == b[0] and b[-1] == c[0] else "NO")
Buggy python submission (verdict: Runtime Error):
w,a,b=map(int,input())
print(b-(a+w) if b>a else a-(b+w) if b<a else 0)

Fixed submission:
w,a,b=map(int,input().split())
print(b-(a+w) if b>a+w else a-(b+w) if b+w<a else 0)
Buggy python submission (verdict: Runtime Error):
import math;
a,b,c,d=map(int,input().split())
print(math.max(a*b,c*d))

Fixed submission:
import math;
a,b,c,d=map(int,input().split())
print(max(a*b,c*d))
Buggy python submission (verdict: Runtime Error):
k,s=map(int,input().split())
ans=0
for x in range(k+1):
  for y in range(k+1):
    z=s-x+y
    ans += 1 if z>=0 and z<=k
print(ans)

Fixed submission:
k,s=map(int,input().split())
ans=0
for x in range(k+1):
  for y in range(k+1):
    z=s-x-y
    ans += 1 if z>=0 and z<=k else 0
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
k,s=map(int,input().split())
ans=0
for x in range(k+1):
  if x>s:break
  for y in range(k+1):
    if x+y>s:break
    for z in range(k+1):
      if x+y+z > s:break
      if x+y+z == s:ans+=1
        
print(ans)

Fixed submission:
k,s=map(int,input().split())
ans=0
for x in range(k+1):
  for y in range(k+1):
    z=s-x-y
    ans += 1 if z>=0 and z<=k else 0
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
k,s=map(int,input().split())
ans=0
for x in range(k+1):
  for y in range(k+1):
    for z in range(k+1):
      if x+y+z > s:break
      if x+y+z == s:ans+=1
        
print(ans)

Fixed submission:
k,s=map(int,input().split())
ans=0
for x in range(k+1):
  for y in range(k+1):
    z=s-x-y
    ans += 1 if z>=0 and z<=k else 0
print(ans)
Buggy python submission (verdict: Runtime Error):
h,w=map(int,input().split())
c=list(h)
for i in range(h):
  c[i]=input()
  
for i in range(h):
  print(c[i])
  print(c[i])

Fixed submission:
h,w=map(int,input().split())
c=[input() for i in range(h)]
  
for i in range(h):
  print(c[i])
  print(c[i])
Buggy python submission (verdict: Runtime Error):
for k in range(50):
 D=int(input())
 c = list(map(int,input().split()))
 s=[[0 for e in range(26)] for f in range(D)]
 for i in range(D):
  s[i]=list(map(int,input().split()))
 last=[0]*26
 ans=0
 point=[0]*D
 for i in range(D):
  saidai=-(10**10)
  kouho=1
  for j in range(26):
   if s[i][j]+c[j]*((i+1)-last[j])>=saidai:
    kouho=j+1
    saidai=s[i][j]+c[j]*((i+1)-last[j])
  print(kouho)

Fixed submission:
D=int(input())
c = list(map(int,input().split()))
s=[[0 for e in range(26)] for f in range(D)]
for i in range(D):
 s[i]=list(map(int,input().split()))
last=[0]*26
ans=0
point=[0]*D
for i in range(D):
 saidai=-(10**10)
 kouho=0
 for j in range(26):
  if s[i][j]+c[j]*((i+1)-last[j])>=saidai:
   kouho=j+1
   saidai=s[i][j]+c[j]*((i+1)-last[j])
 print(kouho)
Buggy python submission (verdict: Runtime Error):
from collections import defaultdict
from fractions import Fraction
import sys
input = sys.stdin.readline
N=int(input())
mod=10**9+7
dic=defaultdict(int)
c=0
d=0
e=0
for i in range(N):
 A,B = map(int,input().split())
 if A==0 or B==0:
  e+=1
 else:
  dic[Fraction(A,B)]+=1
ans=1
for k in dic:
 if -1/k in dic:
  ans*=(pow(2,dic[k],mod)+pow(2,dic[-1/k],mod) -1)
  ans%=mod
  dic[k]=0
  dic[-1/k]=0
 else:
  ans*=pow(2,dic[k],mod)
  ans%=mod
ans*=(pow(2,c,mod)+pow(2,d,mod)-1)
print((ans-1+e)%mod)


Fixed submission:
N=int(input())
if N%10==3:
 print("bon")
elif N%10==0 or N%10==1 or N%10==6 or N%10==8:
 print("pon")
else:
 print("hon")
Buggy python submission (verdict: Time Limit Exceeded):
N,K=map(int,input().split())
T=str(bin(K))
S=len(T)-2
A = list(map(int,input().split()))
lst=[[0 for e in range(N+1)] for f in range(S)]
for i in range(1,N+1):
 lst[0][i]=A[i-1]
for j in range(1,S):
 for i in range(1,N+1):
  lst[j][i]=lst[j-1][lst[j-1][i]]
ans=1
for k in range(S):
 if int(T[k+2])==1:
  ans=lst[S-1-k][ans]
print(ans)

Fixed submission:
N,K=map(int,input().split())
T=str(bin(K))
S=len(T)-2
A = list(map(int,input().split()))
lst=[[0 for e in range(N+1)] for f in range(S)]
for i in range(1,N+1):
 lst[0][i]=A[i-1]
for j in range(1,S):
 for i in range(1,N+1):
  lst[j][i]=lst[j-1][lst[j-1][i]]
ans=[[e for e in range(N+1)] for f in range(S+1)]
for k in range(S):
 if int(T[k+2])==1:
  for l in range(1,N+1):
   ans[k+1][l]=lst[S-1-k][ans[k][l]]
 else:
  for l in range(1,N+1):
   ans[k+1][l]=ans[k][l]
print(ans[S][1])

Buggy python submission (verdict: Runtime Error):
N,K=map(int,input().split())
A=list(map(int,input().split()))
B=[0]*(N+1)
B[0]=1
kaisuu=1
C=[-1]*(N+1)
C[0]=0
roo=0
rooa=0
while kaisuu>=0:
 B[kaisuu]=A[B[kaisuu-1]-1]
 if C[B[kaisuu]-1]>=0:
  roo=kaisuu-C[B[kaisuu]-1]
  rooa=C[B[kaisuu]-1]
  break
 else:
  C[B[kaisuu]-1]=kaisuu
  kaisuu+=1
if K<=rooa:
 print(lst[K])
else:
 d= (K-rooa)%roo
 print(B[rooa+d])

Fixed submission:
N,K=map(int,input().split())
T=str(bin(K))
S=len(T)-2
A = list(map(int,input().split()))
lst=[[0 for e in range(N+1)] for f in range(S)]
for i in range(1,N+1):
 lst[0][i]=A[i-1]
for j in range(1,S):
 for i in range(1,N+1):
  lst[j][i]=lst[j-1][lst[j-1][i]]
ans=[[e for e in range(N+1)] for f in range(S+1)]
for k in range(S):
 if int(T[k+2])==1:
  for l in range(1,N+1):
   ans[k+1][l]=lst[S-1-k][ans[k][l]]
 else:
  for l in range(1,N+1):
   ans[k+1][l]=ans[k][l]
print(ans[S][1])
Buggy python submission (verdict: Runtime Error):
X=int(input())
for a in range(101):
 for b in range(201):
  if a**5-(b-100)**5==X:
   x=str(a)
   y=str(b-100)
L=[x,y]
L=' '.join(L)
print(L)


Fixed submission:
X=int(input())
for a in range(201):
 for b in range(401):
  if a**5-(b-200)**5==X:
   x=str(a)
   y=str(b-200)
L=[x,y]
L=' '.join(L)
print(L)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
rev=0
ST=""
EN=""
S=input()
Q=int(input())
for i in [0]*Q:
 A=list(input().split())
 if int(A[0])==1 :
  rev+=1
 else:
  if (int(A[1])+rev)%2==1:
   ST+=A[2]
  else:
   EN+=A[2]
if rev%2==0:
 print(ST[::-1].strip()+S.strip()+EN.strip())
else:
 print(EN[::-1].strip()+S[::-1].strip()+ST.strip())


Fixed submission:
import sys
input = sys.stdin.readline
rev=0
ST=""
EN=""
S=input()
Q=int(input())
for i in [0]*Q:
 A=list(input().split())
 if int(A[0])==1 :
  rev+=1
 else:
  if (int(A[1])+rev)%2==1:
   ST+=A[2]
  else:
   EN+=A[2]
if rev%2==0:
 print(ST[::-1].strip()+S.strip()+EN.strip())
else:
 print(EN[::-1].strip()+S[::-1].strip()+ST.strip())
Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
if self.parents[x] < 0:
   return x
  else:
   self.parents[x] = self.find(self.parents[x])
   return self.parents[x]

 def union(self, x, y):
  x = self.find(x)
  y = self.find(y)

  if x == y:
   return

  if self.parents[x] > self.parents[y]:
   x, y = y, x

  self.parents[x] += self.parents[y]
  self.parents[y] = x

 def size(self, x):
  return -self.parents[self.find(x)]
 def same(self, x, y):
  return self.find(x) == self.find(y)

N,M,K = map(int,input().split())
uf = UnionFind(N)
lst=[0]*(N)
ans=[0]*(N)
for i in range(M):
 A,B=map(int,input().split())
 uf.union(A-1,B-1)
 lst[A-1]+=1
 lst[B-1]+=1
for i in range(K):
 A,B=map(int,input().split())
 if uf.same(A-1,B-1):
  lst[A-1]+=1
  lst[B-1]+=1
for i in range(N):
 ans[i]=uf.size(i)-lst[i]-1
L=[str(a) for a in ans]
L=' '.join(L)
print(L)


Fixed submission:
class UnionFind():
 def __init__(self, n):
  self.n = n
  self.parents = [-1] * n

 def find(self, x):
  if self.parents[x] < 0:
   return x
  else:
   self.parents[x] = self.find(self.parents[x])
   return self.parents[x]

 def union(self, x, y):
  x = self.find(x)
  y = self.find(y)

  if x == y:
   return

  if self.parents[x] > self.parents[y]:
   x, y = y, x

  self.parents[x] += self.parents[y]
  self.parents[y] = x

 def size(self, x):
  return -self.parents[self.find(x)]
 def same(self, x, y):
  return self.find(x) == self.find(y)

N,M,K = map(int,input().split())
uf = UnionFind(N)
lst=[0]*(N)
ans=[0]*(N)
for i in range(M):
 A,B=map(int,input().split())
 uf.union(A-1,B-1)
 lst[A-1]+=1
 lst[B-1]+=1
for i in range(K):
 A,B=map(int,input().split())
 if uf.same(A-1,B-1):
  lst[A-1]+=1
  lst[B-1]+=1
for i in range(N):
 ans[i]=uf.size(i)-lst[i]-1
L=[str(a) for a in ans]
L=' '.join(L)
print(L)
Buggy python submission (verdict: Time Limit Exceeded):
def pow(x, n):
    ans = 1
    while n:
        if n % 2:
            ans *= x
        x *= x
        n >>= 1
    return ans

def powmod(x, n,mod):
  ans = 1
  while n:
      if n % 2:
          ans *= x
          ans %= mod
      x *= x
      n >>= 1
  return ans

def cmbmod(n, r,mod):
  a=mod-2
  b=1
  for i in range(r):
   b*=(i+1)
   b%=mod
  ans1 = 1
  while a:
      if a % 2:
          ans1 *= b
          ans1 %= mod
      b *= b
      n >>= 1
  ans2 = 1
  for i in range(n-r):
   ans2 *= (i+r+1)
   ans2%=mod
  return (ans1*ans2)%mod

def cmbmod(n, r,mod):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])
            result %= mod
    return result

n,a,b=map(int,input().split())
print((powmod(2, n,10**9+7)-cmbmod(n,a,10**9+7)-cmbmod(n,b,10**9+7)-1)%(10**9+7))


Fixed submission:
def powmod(x, n,mod):
  if n == 0:
   return 1
  K = 1
  while n > 1:
   if n % 2 != 0:
    K = K * x%mod
    x = x ** 2%mod
    n = (n - 1) // 2
   else:
    x = x ** 2%mod
    n = n // 2%mod

  return K * x # 指数を割り続け n が 1 に至ったら終了

def cmbmod(n, r,mod):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result = result*int(numerator[k])%mod
    return result

n,a,b=map(int,input().split())

c=powmod(2, n,10**9+7)
d=cmbmod(n,a,10**9+7)
e=cmbmod(n,b,10**9+7)
print((c-d-e-1)%(10**9+7))
Buggy python submission (verdict: Time Limit Exceeded):
def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

N,K=map(int,input().split())
k=min(K,N-1)
x=0
A=[0]*(k+1)
B=[0]*(k+1)
for i in range(k+1):
 B[i]=cmb(N-1,i)%(10**9+7)
 A[i]=cmb(N,i)%(10**9+7)
for i in range(k+1):
 x+=(A[i]*B[i])%(10**9+7)
print(x%(10**9+7))


Fixed submission:
mod=10**9+7
comb1=1
comb2=1
N,K=map(int,input().split())
k=min(K,N-1)
x=0
for i in range(k):
 comb1=(comb1*(N-i)*pow(i+1,mod-2,mod))%(mod)
 comb2=(comb2*(N-1-i)*pow(i+1,mod-2,mod))%(mod)
 x+=(comb1*comb2)%(mod)
print((x+1)%(mod))

Buggy python submission (verdict: Runtime Error):
def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

N,K=map(int,input().split())
k=min(K,N-1)
x=0
A=[0]*(k+1)
B=[0]*(k+1)
for i in range(k+1):
 B[i]=cmb(N-1,i)%(10**9+7)
 A[i]=cmb(N,i)%(10**9+7)
for i in range(k+1):
 x+=(A[i]*b[i])%(10**9+7)
print(x%(10**9+7))


Fixed submission:
mod=10**9+7
comb1=1
comb2=1
N,K=map(int,input().split())
k=min(K,N-1)
x=0
for i in range(k):
 comb1=(comb1*(N-i)*pow(i+1,mod-2,mod))%(mod)
 comb2=(comb2*(N-1-i)*pow(i+1,mod-2,mod))%(mod)
 x+=(comb1*comb2)%(mod)
print((x+1)%(mod))
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
N=int(input())
A=[0]*N
B=[0]*N
j=0
for i in [0]*N:
 h=input()
 if h in A:
  B[A.index(h)]+=1
 else:
  A[j]=h
  B[j]=1
  j+=1
d=max(B)
C=[]
for i in range(N):
 if B[i]==d:
  C.append(A[i])
C.sort()
for i in range(len(C)):
 print(C[i],end='')

Fixed submission:
N=int(input())
dic={}
for i in range(N):
 a=input()
 if a in dic:
  dic[a]+=1
 else:
  dic[a]=1
c=max(dic.values())
keys = [k for k, v in dic.items() if v == c]
keys.sort()
for j in range(len(keys)):
 print(keys[j])

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
N=int(input())
A=[]
B=[]
for i in [0]*N:
 h=input()
 if h in A:
  B[A.index(h)]+=1
 else:
  A.append(h)
  B.append(1)
d=max(B)
C=[]
for i in range(len(B)):
 if B[i]==d:
  C.append(A[i])
C.sort()
for i in range(len(C)):
 print(C[i],end='')


Fixed submission:
N=int(input())
dic={}
for i in range(N):
 a=input()
 if a in dic:
  dic[a]+=1
 else:
  dic[a]=1
c=max(dic.values())
keys = [k for k, v in dic.items() if v == c]
keys.sort()
for j in range(len(keys)):
 print(keys[j])
Buggy python submission (verdict: Time Limit Exceeded):
N,K= map(int,input().split())
P=list(map(int,input().split()))
mx=0
for i in range(K):
 mx+=(P[i]+1)/2
if N>K:
 for j in range(N-K):
  f=0
  for i in range(j+1,K+j+1):
   f+=(P[i]+1)/2
  mx=max(mx,f)
print(mx)

Fixed submission:
N,K= map(int,input().split())
P=list(map(int,input().split()))
mx=0
for i in range(K):
 mx+=(P[i]+1)/2
 now=mx
if N>K:
 for j in range(N-K):
  now=now+((P[K+j]+1)/2)-((P[j]+1)/2)
  mx=max(mx,now)
print(mx)
Buggy python submission (verdict: Runtime Error):
def nibun_right(a, x):
 lo, hi = 0, len(a)
 while lo < hi:
  mid = (lo+hi)//2
  if x < a[mid][0]: hi = mid
  else: lo = mid+1
 return lo
N,D,A=map(int,input().split())
lst=[0]*N
for i in range(N):
 lst[i]=list(map(int,input().split()))
lst.sort()
ans=0
print(ans)


Fixed submission:
h,a=map(int,input().split())
b=int((h-1)/a)+1
print(b)