Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
H,W,D=map(int,input().split())
A=[list(map(int,input().split())) for _ in range(H)]
Q=int(input())
B=[list(map(int,input().split())) for _ in range(Q)]
C=[[]for i in range(H*W)]
for i in range(H):
  for j in range(W):
    a=A[i][j]
    C[a-1].append((j+1,i+1))

for a,b in B:
  cnt=0
  m=(b-a)//D
  for i in range(m):
    start=a+D*(i)
    goal=start+D
    s=C[start-1][0][0]
    t=C[start-1][0][1]
    u=C[goal-1][0][0]
    v=C[goal-1][0][1]
    cnt+=abs(s-u)+abs(t-v)
  print(cnt)

Fixed submission:
H,W,D=map(int,input().split())
A=[list(map(int,input().split())) for _ in range(H)]
Q=int(input())
B=[list(map(int,input().split())) for _ in range(Q)]
L,R=zip(*B)
C=[[]for i in range(H*W)]
for i in range(H):
  for j in range(W):
    a=A[i][j]
    C[a-1]=((j+1,i+1))
X=[0]*(H*W+1)
for i in range(D):
  x=H*W-D-i
  count=0
  while x>0:
    count+=abs(C[x-1][0]-C[x+D-1][0])+abs(C[x-1][1]-C[x+D-1][1])
    X[x]+=count
    x-=D
for i in range(Q):
  print(X[L[i]]-X[R[i]])
Buggy python submission (verdict: Runtime Error):
a,b = map(int,input(),split())
if (a*b) % 2 == 1:
  print('Odd')
else:
  print('Even')

Fixed submission:
a,b=map(int,input().split())
if (a*b)%2 == 1:
  print('Odd')
else:
  print('Even')

Buggy python submission (verdict: Runtime Error):
a , b = map(int,input(),split())
if (a*b)%2 == 1:
  print('Odd')
else:
  print('Even')

Fixed submission:
a,b=map(int,input().split())
if (a*b)%2 == 1:
  print('Odd')
else:
  print('Even')

Buggy python submission (verdict: Runtime Error):
a , b = map(int,input(),split())
if (a*b)% == 1:
  print('Odd')
else:
  print('Even')

Fixed submission:
a,b=map(int,input().split())
if (a*b)%2 == 1:
  print('Odd')
else:
  print('Even')

Buggy python submission (verdict: Runtime Error):
a,b = map(int,input(),split())
if a*b% == 1:
  print('Odd')
else:
  print('Even')

Fixed submission:
a,b=map(int,input().split())
if (a*b)%2 == 1:
  print('Odd')
else:
  print('Even')

Buggy python submission (verdict: Runtime Error):
map(int,input(),split())
if a*b% == 1:
  print('Odd')
else:
  print('Even')

Fixed submission:
a,b=map(int,input().split())
if (a*b)%2 == 1:
  print('Odd')
else:
  print('Even')

Buggy python submission (verdict: Runtime Error):
numa = int(a)
numb = int(b)
num = numa * numb
if num % 2 == 0:
    print("Even")
else:
    print("Odd")

Fixed submission:
a,b=map(int,input().split())
if (a*b)%2 == 1:
  print('Odd')
else:
  print('Even')

Buggy python submission (verdict: Runtime Error):
num = int(a)*int(b)
if num % 2 == 0:
    print("Even")
else:
    print("Odd")

Fixed submission:
a,b=map(int,input().split())
if (a*b)%2 == 1:
  print('Odd')
else:
  print('Even')

Buggy python submission (verdict: Runtime Error):
num = a*b
if num % 2 == 0:
    print("Even")
else:
    print("Odd")

Fixed submission:
a,b=map(int,input().split())
if (a*b)%2 == 1:
  print('Odd')
else:
  print('Even')

Buggy python submission (verdict: Runtime Error):
num = a*b
if num % 2 == 0:
    print "Even"
else:
    print "Odd"

Fixed submission:
a,b=map(int,input().split())
if (a*b)%2 == 1:
  print('Odd')
else:
  print('Even')

Buggy python submission (verdict: Runtime Error):
mod = ( a * b )%2

if mod == 0:
  print'Even'
else:
  print'Odd'

Fixed submission:
a,b=map(int,input().split())
if (a*b)%2 == 1:
  print('Odd')
else:
  print('Even')

Buggy python submission (verdict: Runtime Error):
c = a*b
if c%2 = 1:
  print('odd')
else:
  print('even')

Fixed submission:
a,b=map(int,input().split())
if (a*b)%2 == 1:
  print('Odd')
else:
  print('Even')

Buggy python submission (verdict: Runtime Error):
if (a*b)//2 == 1:
  print('odd')
else:
  print('even')

Fixed submission:
a,b=map(int,input().split())
if (a*b)%2 == 1:
  print('Odd')
else:
  print('Even')

Buggy python submission (verdict: Runtime Error):
if a * b //2 == 1:
  print('odd')
else:
  print('even')
  

Fixed submission:
a,b=map(int,input().split())
if (a*b)%2 == 1:
  print('Odd')
else:
  print('Even')
Buggy python submission (verdict: Runtime Error):
S = input()
print('2018'+s[4:])

Fixed submission:
S = input()
print('2018'+S[4:])
Buggy python submission (verdict: Runtime Error):
N,Y=map(int,input().split())
for x in range(N+1):
  for y in range(N+1-x):
    z=N-x-y
    if 10000*x+5000*y+1000*z == Y and 2000=>z=>0:
      print((x,y,z))
      exit()
      
print(-1,-1,-1)

Fixed submission:
N,Y=map(int,input().split())
for x in range(N+1):
    for y in range(N-x+1):
        z=N-x-y
        if 0<=z<=2000 and 10000*x+5000*y+1000*z==Y:
            print(x,y,z)
            exit()
print(-1,-1,-1)
Buggy python submission (verdict: Time Limit Exceeded):
N,H=map(int,input().split())
A=[list(map(int,input().split())) for i in range(N)]
B=[]
C=[]
for a,b in A:
  B.append(a)
  C.append(b)
D=sorted(B)[::-1]
F=[]
for i in C:
  if max(B)<i:
    F.append(i)
cnt=0
for i in F:
  H-=i
  cnt+=1
  if H<=0:
    print(cnt)
    exit()
print(cnt-((-H)//D[0]))
    

Fixed submission:
N,H=map(int,input().split())
A=[list(map(int,input().split())) for i in range(N)]
B=[]
C=[]
for a,b in A:
  B.append(a)
  C.append(b)
D=sorted(B)[::-1]
b=D[0]
F=[]
for i in C:
  if b<i:
    F.append(i)
G=sorted(F)[::-1]
cnt=0
for i in G:
  H-=i
  cnt+=1
  if H<=0:
    print(cnt)
    exit()
print(cnt-((-H)//b))
Buggy python submission (verdict: Time Limit Exceeded):
Q=int(input())
A=[list(map(int,input().split())) for i in range(Q)]
B,C=zip(*A)
a=max(max(B),max(C))
def get_primenumber(N):
  prime_list=[2]
  for num in range(3,N+1,2):
    if all(num%prime != 0 for prime in prime_list):
      prime_list.append(num)
  return prime_list

X=get_primenumber(a)
P=[False]*(a+1)
L=[False]*(a+1)
for i in X:
  P[i]=True
for i in X:
  if P[(i+1)//2]:
    L[i]=True
C=[]
c=0
for i in range(a+1):
  if L[i]:
    c+=1
  C.append(c)
for s,t in A:
  print(C[t]-C[s-1])

Fixed submission:
Q=int(input())
A=[list(map(int,input().split())) for i in range(Q)]
B,C=zip(*A)
a=max(max(B),max(C))
def get_primenumber(N):
  prime_list=[2]
  for num in range(3,N+1,2):
    if all(num%prime != 0 for prime in prime_list):
      prime_list.append(num)
  return prime_list

X=get_primenumber(a)
P=[False]*(a+1)
L=[False]*(a+1)
for i in X:
  P[i]=True
for i in X:
  if P[(i+1)//2]:
    L[i]=True
C=[]
c=0
for i in range(a+1):
  if L[i]:
    c+=1
  C.append(c)
for s,t in A:
  print(C[t]-C[s-1])

Buggy python submission (verdict: Time Limit Exceeded):
Q=int(input())
L=[list(map(int,input().split())) for i in range(Q)]
A,B=zip(*L)
a=max(max(A),max(B))
def get_primenumber(N):
  #素数リスト
  prime_list = [2]
    #3からNまでの数字を一つずつ取り出す
  for num in range(3,N+1,2):
    #取り出した数字が素数リストの要素で割れなければ素数リストに追加する
    if all( num % prime != 0 for prime in prime_list):
      prime_list.append(num)
  return prime_list
X=get_primenumber(a)

def F(n):
  ans=0
  Z=get_primenumber(n)
  for i in Z:
    if (i+1)//2 in Z:
      ans+=1
  return ans

for s,t in L:
  print(F(t)-F(s-1))

Fixed submission:
Q=int(input())
A=[list(map(int,input().split())) for i in range(Q)]
B,C=zip(*A)
a=max(max(B),max(C))
def get_primenumber(N):
  prime_list=[2]
  for num in range(3,N+1,2):
    if all(num%prime != 0 for prime in prime_list):
      prime_list.append(num)
  return prime_list

X=get_primenumber(a)
P=[False]*(a+1)
L=[False]*(a+1)
for i in X:
  P[i]=True
for i in X:
  if P[(i+1)//2]:
    L[i]=True
C=[]
c=0
for i in range(a+1):
  if L[i]:
    c+=1
  C.append(c)
for s,t in A:
  print(C[t]-C[s-1])
Buggy python submission (verdict: Runtime Error):
A,B,C,D=map(int, input().split())
if A+B>C+D:
  print('Left')
elif A+B>C+D::
  print('Right')
else:
  print('Balanced')

Fixed submission:
A,B,C,D=map(int, input().split())
if A+B>C+D:
  print('Left')
elif A+B<C+D:
  print('Right')
else:
  print('Balanced')
Buggy python submission (verdict: Runtime Error):
N,K=map(int,input().split())
A=list(map(int,input().split()))
U=len(set(A))

S=[]
for i in range(1,N+1):
  S.append(A.count(i))

T=sorted(S)[::-1]

if U > K:
  ans = 0
  for j in range(0,K):
    ans+= T[j]
print(N-ans)

if U <= K:
  print(0)

Fixed submission:
N,K=map(int,input().split())
A=list(map(int,input().split()))
U=len(set(A))

import collections

if U > K:
  c = collections.Counter(A)
  d = c.most_common(K)
  print(N-(sum(x[1] for x in d)))
else:
  print(0)

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

S=[]
for i in range(1,N+1):
  S.append(A.count(i))

T=sorted(S)[::-1]

if U > K:
  ans = 0
  for j in range(0,K):
    ans+= T[j]
print(N-ans)

if U <= K:
  print(0)

Fixed submission:
N,K=map(int,input().split())
A=list(map(int,input().split()))
U=len(set(A))

import collections

if U > K:
  c = collections.Counter(A)
  d = c.most_common(K)
  print(N-(sum(x[1] for x in d)))
else:
  print(0)
Buggy python submission (verdict: Runtime Error):
n,a,b=map(int,input().split)
print(min(n*a,b))

Fixed submission:
n,a,b=map(int,input().split())
print(min(n*a,b))
Buggy python submission (verdict: Runtime Error):
A=list(map(int, input().split()))
if N==1:
  print(abs(A[-1]-W))
else:
  a=abs(A[-1]-W)
  b=abs(A[-2]-A[-1])
  print(max(a,b))

Fixed submission:
N,Z,W=map(int,input().split())
A=list(map(int, input().split()))
if N==1:
  print(abs(A[-1]-W))
else:
  a=abs(A[-1]-W)
  b=abs(A[-2]-A[-1])
  print(max(a,b))

Buggy python submission (verdict: Runtime Error):
N,Z,W=map(int,input().split())
A=list(map(int, input().split()))
if N==1:
  print(abs(A[-1]-W))
elif N==2:
  print(abs(A[-1]-W),abs(A[0]-A[-1]))
else:
  a=abs(A[-1]-W)
  b=abs(max(A[:N-1])-A[-1])
  print(max(a,b)

Fixed submission:
N,Z,W=map(int,input().split())
A=list(map(int, input().split()))
if N==1:
  print(abs(A[-1]-W))
else:
  a=abs(A[-1]-W)
  b=abs(A[-2]-A[-1])
  print(max(a,b))
Buggy python submission (verdict: Time Limit Exceeded):
N,K=map(int,input().split())
A=[list(map(int, input().split())) for i in range(N)]
B,C=zip(*A)
S=10**36
for left in B:
  for right in B:
    for up in C:
      for down in C:
        if left<right and down<up:
          cnt=0
          for x,y in A:
            if left<=x<=right and down<=y<=up:
              cnt+=1
          if cnt>=K:
            S=min(S,(right-left)*(up-down))
print(S)            

Fixed submission:
N,K=map(int,input().split())
A=[list(map(int, input().split())) for i in range(N)]
B,C=zip(*A)
S=10**36
for left in B:
  for right in B:
    for up in C:
      for down in C:
        if left<right and down<up:
          cnt=0
          for x,y in A:
            if left<=x<=right and down<=y<=up:
              cnt+=1
          if cnt>=K:
            S=min(S,(right-left)*(up-down))
print(S)
Buggy python submission (verdict: Runtime Error):
N=int(input())
D=list(map(int, input().split()))
M=int(input())
T=list(map(int, input().split()))
if N<M:
  print('NO')
  exit()
A={}
B={}
for i in D:
  if i not in A:
    A[i]=0
  A[i]+=1
  
for i in T:
  if i not in B:
    B[i]=0
  B[i]+=1
  
for i in B.keys():
  if not A[i]:
    print('NO')
    exit()
  if A[i]<B[i]:
    print('NO')
    exit()
print('YES')

Fixed submission:
N=int(input())
D=list(map(int, input().split()))
M=int(input())
T=list(map(int, input().split()))
if N<M:
  print('NO')
  exit()
  
A={}
B={}
for i in D:
  if i not in A:
    A[i]=0
  A[i]+=1
  
for i in T:
  if i not in B:
    B[i]=0
  B[i]+=1
  
for i in B.keys():
  if not i in A:
    print('NO')
    exit()
  if A[i]<B[i]:
    print('NO')
    exit()
print('YES')
Buggy python submission (verdict: Runtime Error):
A, B, C, D, E, F = map(int, input().split(' '))
maxconc = 0.0
maxwater = 100*A
maxsugar = 0

for i in range(F//(100*A)+1):
  for j in range((F-100*A*i)//(100*B)+1):
    if i == 0 and j == 0:
      continue
    S =min(E*(A*i+B*j),F-100*(A*i+B*j))
    
    sugar=0
    for c in range(S//C+1):
      d = (S-c*C)//D
      sugar = max(sugar,c*C+d*D)
    conc = sugar / (sugar +100*(A*i+B*j))
    if conc > maxconc:
      maxconc = conc 
      maxwater = 100*(A*i+B*j)
      maxsugar = sugar
print('{0} {1}'.format(maxwater+maxsugar,maxsugar))    

Fixed submission:
a=int(input())
b=int(input())
print(a*a-b)

Buggy python submission (verdict: Runtime Error):
A, B, C, D, E, F = map(int, input().split(' '))

max_sugar = 0
max_water = 100*A
max_conc = 0.0
A_limit = F // (100*A)
for i in range(A_limit + 1):
    B_limit = (F-100*A*i) // (100*B)
    for j in range(B_limit + 1):
        if i == 0 and j == 0:
            continue
        sugar_limit = min(E * (A*i+B*j), F-100*(A*i+B*j))

        sugar_ = 0
        for c in range(sugar_limit//C + 1):
            d = (sugar_limit-c*C)//D
            temp_sugar = c*C + d*D
            sugar_ = max(sugar_, temp_sugar)
        temp_conc = sugar_/(sugar_+100*(A*i+B*j))
        if temp_conc > max_conc:
            max_conc = temp_conc
            max_water = 100*(A*i + B*j)
            max_sugar = sugar_
print('{0} {1}'.format(max_water+max_sugar, max_sugar))

Fixed submission:
a=int(input())
b=int(input())
print(a*a-b)
Buggy python submission (verdict: Time Limit Exceeded):
N,M,R=map(int,input().split())
r=list(map(int,input().split()))
A=[list(map(int,input().split())) for i in range(M)]
d=[[float("inf")]*N for i in range(N)]

for a,b,c in A:
  d[a-1][b-1]=c
  d[b-1][a-1]=c 
  
for k in range(N):
  for i in range(N):
    for j in range(N):
      d[i][j]=min(d[i][j],d[i][k]+d[k][j])
      
import itertools 
ans=10**5*8
for i in itertools.permutations(range(R),R):
  D=0
  for j in range(R-1):
    D+=d[r[i[j]]-1][r[i[j+1]]-1]
  ans=min(D,ans)
print(ans)

Fixed submission:
from subprocess import call
call(('pypy3','-c',"""N,M,R=map(int,input().split())
r=list(map(int,input().split()))
A=[list(map(int,input().split())) for i in range(M)]
d=[[float("inf")]*N for i in range(N)]

for a,b,c in A:
  d[a-1][b-1]=c
  d[b-1][a-1]=c 
  
for k in range(N):
  for i in range(N):
    for j in range(N):
      d[i][j]=min(d[i][j],d[i][k]+d[k][j])
      
import itertools 
ans=1000000000
for i in itertools.permutations(range(R),R):
  D=0
  for j in range(R-1):
    D+=d[r[i[j]]-1][r[i[j+1]]-1]
  ans=min(D,ans)
print(ans)
"""))
Buggy python submission (verdict: Runtime Error):
L = index()
print(L[::2]) 

Fixed submission:
L = input()
print(L[::2])
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
a=list(map(int,input().split()))
total = [a.count(i)+a.count(i-1)+a.count(i+1) for i in a]
print(max(total))

Fixed submission:
n = int(input())
count = [0] * 100002
a = list(map(int, input().split()))
for i in a:
    count[i-1] += 1
    count[i] += 1
    count[i+1] += 1

print(max(count))
Buggy python submission (verdict: Runtime Error):
N=int(input())
A=list(map(int,input().split()))
cnt=0
for i in range(N):
  if i+1==A[i]:
    a=A[i]
    b=A[i+1]
    A[i]=b
    A[i+1]=a
    cnt+=1
print(cnt)

Fixed submission:
N=int(input())
A=list(map(int,input().split()))
cnt=0
for i in range(N-1):
  if i+1==A[i]:
    a=A[i]
    b=A[i+1]
    A[i]=b
    A[i+1]=a
    cnt+=1
if A[-1]==N:
  cnt+=1
print(cnt)
Buggy python submission (verdict: Runtime Error):
A=input()
cnt={chr(code): 0 for code in range(ord('a'),ord('z')+1)}
for i in A:
  cnt[i]+=1

from math import factorial
def c(n,r):
  return factorial(n)/factorial(r)/factorial(n - r)
a=len(A)
if a==1:
  print(1)
  exit()
b=0
for i in cnt.values():
  if i>=2:
    b+=i*(i-1)//2
ans=int(c(a,2)-b)
print(ans+1)

Fixed submission:
A=input()
cnt={chr(code): 0 for code in range(ord('a'),ord('z')+1)}
for i in A:
  cnt[i]+=1

a=len(A)
if a==1:
  print(1)
  exit()
b=0
for i in cnt.values():
  if i>=2:
    b+=i*(i-1)//2
ans=a*(a-1)//2-b
print(ans+1)

Buggy python submission (verdict: Runtime Error):
A=input()
cnt={chr(code): 0 for code in range(ord('a'),ord('z')+1)}
for i in A:
  cnt[i]+=1

from math import factorial
def c(n,r):
  return factorial(n)/factorial(r)/factorial(n - r)
a=len(A)
b=0
for i in cnt.values():
  if i>=2:
    b+=i*(i-1)//2
ans=int(c(a,2)-b)
print(ans+1)

Fixed submission:
A=input()
cnt={chr(code): 0 for code in range(ord('a'),ord('z')+1)}
for i in A:
  cnt[i]+=1

a=len(A)
if a==1:
  print(1)
  exit()
b=0
for i in cnt.values():
  if i>=2:
    b+=i*(i-1)//2
ans=a*(a-1)//2-b
print(ans+1)
Buggy python submission (verdict: Runtime Error):
s = input()
print( s[:2] + str(len(s)-2) + s[len(s-1):] )

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

Buggy python submission (verdict: Runtime Error):
S = input()
L = len(s)
print( S[:2]+str(L-2) +S[(L-1):] )

Fixed submission:
s = input()
print( s[0] + str(len(s)-2) + s[-1] )
Buggy python submission (verdict: Runtime Error):
N=int(input())
print('ABC'+N)

Fixed submission:
N=int(input())
print('ABC',N,sep='')
Buggy python submission (verdict: Runtime Error):
n = 0
while 2**n <= (int(input())):
  n += 1
print(2**(n-1))
  

Fixed submission:
a = int(input())
n = 0
while 2**n <= a:
  n += 1
print(2**(n-1))

Buggy python submission (verdict: Runtime Error):
n = 0
while 2**n <= int(input()):
  n += 1
print(2**(n-1))
  

Fixed submission:
a = int(input())
n = 0
while 2**n <= a:
  n += 1
print(2**(n-1))
Buggy python submission (verdict: Time Limit Exceeded):
N,M=map(int,input().split())
A=[list(map(int,input().split())) for i in range(M)]
D=[[]for i in range(N)]
for i in range(M):
  D[A[i][0]-1].append(A[i][1]-1)
  D[A[i][1]-1].append(A[i][0]-1)
for i in D[-1]:
  for j in D[0]:
    if i==j:
      print('POSSIBLE')
      exit()
print('IMPOSSIBLE')  

Fixed submission:
N,M=map(int,input().split())
A=[list(map(int,input().split())) for i in range(M)]
D=[[]for i in range(N)]
for i in range(M):
  D[A[i][0]-1].append(A[i][1]-1)
  D[A[i][1]-1].append(A[i][0]-1)
a=len(D[-1])
b=len(D[0])
c=len(set(D[-1]+D[0]))
if a+b==c:
  print('IMPOSSIBLE')
else:
  print('POSSIBLE')

Buggy python submission (verdict: Time Limit Exceeded):
N,M=map(int,input().split())
A=[list(map(int,input().split())) for i in range(M)]
D=[[]for i in range(N)]
for i in range(M):
  D[A[i][0]-1].append(A[i][1]-1)
  D[A[i][1]-1].append(A[i][0]-1)
for i in D[-1]:
  for j in D[0]:
    if i==j:
      print('POSSIBLE')
      exit()
print('IMPOSSIBLE')      

Fixed submission:
N,M=map(int,input().split())
A=[list(map(int,input().split())) for i in range(M)]
D=[[]for i in range(N)]
for i in range(M):
  D[A[i][0]-1].append(A[i][1]-1)
  D[A[i][1]-1].append(A[i][0]-1)
a=len(D[-1])
b=len(D[0])
c=len(set(D[-1]+D[0]))
if a+b==c:
  print('IMPOSSIBLE')
else:
  print('POSSIBLE')
Buggy python submission (verdict: Runtime Error):
n=int(input())
A=list(map(int, input().split()))
B=sorted(A)
for i in range(n+1):
  if B[i]!=i+1:
    a=i
    break
d=[i for i, x in enumerate(A) if x==a]
x=d[0]
y=d[1]

def cmb(n,r,mod):
    if (r<0 or r>n):
      return 0
    r=min(r,n-r)
    return g1[n]*g2[r]*g2[n-r]%mod

mod=10**9+7 #出力の制限
N=10**5
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)

for i in range(1,n+2):
  print(cmb(n+1,i,mod)-cmb(x+(n-y),i-1,mod))  

Fixed submission:
n=int(input())
A=list(map(int, input().split()))
B=sorted(A)
for i in range(n+1):
  if B[i]!=i+1:
    a=i
    break
d=[i for i, x in enumerate(A) if x==a]
x=d[0]
y=d[1]

def cmb(n,r,mod):
    if (r<0 or r>n):
      return 0
    r=min(r,n-r)
    return g1[n]*g2[r]*g2[n-r]%mod

mod=10**9+7 #出力の制限
N=10**5+10
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)

for i in range(1,n+2):
  ans=cmb(n+1,i,mod)-cmb(x+(n-y),i-1,mod)
  if ans<0:
    print(mod+ans)
  else:
    print(ans)

Buggy python submission (verdict: Runtime Error):
n=int(input())
A=list(map(int, input().split()))
B=sorted(A)
for i in range(n+1):
  if B[i]!=i+1:
    a=i
    break
d=[i for i, x in enumerate(A) if x==a]
x=d[0]
y=d[1]

def cmb(n,r,mod):
    if (r<0 or r>n):
      return 0
    r=min(r,n-r)
    return g1[n]*g2[r]*g2[n-r]%mod

mod=10**9+7 #出力の制限
N=10**4
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)

for i in range(1,n+2):
  print(cmb(n+1,i,mod)-cmb(x+(n-y),i-1,mod))  

Fixed submission:
n=int(input())
A=list(map(int, input().split()))
B=sorted(A)
for i in range(n+1):
  if B[i]!=i+1:
    a=i
    break
d=[i for i, x in enumerate(A) if x==a]
x=d[0]
y=d[1]

def cmb(n,r,mod):
    if (r<0 or r>n):
      return 0
    r=min(r,n-r)
    return g1[n]*g2[r]*g2[n-r]%mod

mod=10**9+7 #出力の制限
N=10**5+10
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)

for i in range(1,n+2):
  ans=cmb(n+1,i,mod)-cmb(x+(n-y),i-1,mod)
  if ans<0:
    print(mod+ans)
  else:
    print(ans)
Buggy python submission (verdict: Runtime Error):
N,A,B=map(int, input().split())
D=list(map(int, input().split()))
D=sorted(D)[::-1]
import math
from math import comb
print(sum(D[:A])/A)
ans=0
if D[0]==D[-1]:
  n=D.count(D[A-1])
  k=V[:A].count(D[A-1])
  print(comb(n,k))
else:
  ans=0
  n=D.count(D[A-1])
  for i in range(A,min(n,B)+1):
    ans+=comb(n,i)
  print(ans)

Fixed submission:
N,A,B=map(int, input().split())
D=list(map(int, input().split()))
D=sorted(D)[::-1]
import math
from math import comb
print(sum(D[:A])/A)
ans=0
if D[0]!=D[A-1]:
  n=D.count(D[A-1])
  k=D[:A].count(D[A-1])
  print(comb(n,k))
else:
  ans=0
  n=D.count(D[A-1])
  for i in range(A,min(n,B)+1):
    ans+=comb(n,i)
  print(ans)

Buggy python submission (verdict: Runtime Error):
N,A,B=map(int, input().split())
D=list(map(int, input().split()))
D=sorted(D)[::-1]
import math
import bisect
print(sum(D[:A])/A)
ans=0
if D==[D[0]]*N:
  for i in range(A,B+1):
    ans+=math.factorial(N)//(math.factorial(i)*math.factorial(N-i))
else:
  a=D.count(D[a-1])
  if a>1:
    b=D[:A].count(D[a-1])
    print(math.factorial(a)//(math.factorial(b)*math.factorial(a-b)))
  else:
    print(1)

Fixed submission:
N,A,B=map(int, input().split())
D=list(map(int, input().split()))
D=sorted(D)[::-1]
import math
from math import comb
print(sum(D[:A])/A)
ans=0
if D[0]!=D[A-1]:
  n=D.count(D[A-1])
  k=D[:A].count(D[A-1])
  print(comb(n,k))
else:
  ans=0
  n=D.count(D[A-1])
  for i in range(A,min(n,B)+1):
    ans+=comb(n,i)
  print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
Ans=1
for i in range(1,N+1):
  Ans*=(i%(10**9+7))
print(Ans%(10**9+7))

Fixed submission:
N=int(input())
Ans=1
for i in range(1,N+1):
  Ans*=i
  Ans%=(10**9+7)

print(Ans)

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
Ans=1
for i in range(1,N+1):
  Ans*=i
print(Ans%(10**9+7))

Fixed submission:
N=int(input())
Ans=1
for i in range(1,N+1):
  Ans*=i
  Ans%=(10**9+7)

print(Ans)
Buggy python submission (verdict: Runtime Error):
s = input()
A= s.index('A')
for r in s[::-1]:
    Z = r.index('Z') 
print(s-Amin-Zmax+2)

Fixed submission:
s = input()

CA = s.index('A')
CZ = s.rindex('Z') 


print(CZ-CA+1)

Buggy python submission (verdict: Runtime Error):
s = input()
Amin = s.index('A')
for r in s[::-1]:
Zmax = r.index('Z') 
print(s-Amin-Zmax+2)

Fixed submission:
s = input()

CA = s.index('A')
CZ = s.rindex('Z') 


print(CZ-CA+1)
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
Z=[list(map(int,input().split())) for i in range(N)]
A,B=zip(*Z)
A=list(A[::-1])
B=list(B[::-1])
ans=0
for i in range(N):
  A[i]+=ans
  while A[i]%B[i]!=0:
    ans+=1
    A[i]+=1
print(ans)

Fixed submission:
N=int(input())
Z=[list(map(int,input().split())) for i in range(N)]
A,B=zip(*Z)
A=list(A[::-1])
B=list(B[::-1])
ans=0
for i in range(N):
  A[i]+=ans
  if A[i]%B[i]!=0:
    a=B[i]-(A[i]%B[i])
    ans+=a
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
Z=[list(map(int,input().split())) for i in range(N)]
A,B=zip(*Z)
A=list(A[::-1])
B=list(B[::-1])
ans=0
for i in range(N):
  A[i]+=ans
  while A[i]%B[i]!=0:
    ans+=1
    A[i]+=1
print(ans)

Fixed submission:
N=int(input())
Z=[list(map(int,input().split())) for i in range(N)]
A,B=zip(*Z)
A=list(A[::-1])
B=list(B[::-1])
ans=0
for i in range(N):
  A[i]+=ans
  if A[i]%B[i]!=0:
    a=B[i]-(A[i]%B[i])
    ans+=a
print(ans)