Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
n=int(input())

ans='No'

if n//100==7 or n//10==7 or n%10==7 (n//10)%10==7:
    ans='Yes'
else :
    ans='No'
print(ans)

Fixed submission:
n=input()

ans='No'

if '7' in n:
    ans='Yes'
print(ans)

Buggy python submission (verdict: Runtime Error):
n=int(input())

ans='No'

if n//100==7 or n//10==7 or n%10==7:
    ans='Yes'
elif :
    ans='No'
print(ans)

Fixed submission:
n=input()

ans='No'

if '7' in n:
    ans='Yes'
print(ans)
Buggy python submission (verdict: Runtime Error):
if n%2==0:
    ans=n/2
else:
    ans=n//2+1
print(ans)

Fixed submission:
#A
n=int(input())

if n%2==0:
    ans=int(n/2)
else:
    ans=n//2+1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
h= list(map(int,input().split()))
count=[0]*n

for t in range(n):
    for i in range(t,n-1):
        if h[i]>=h[i+1]:
            count[t]+=1
        else:
            break

print(max(count))


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

COU=0
m_max=0
for i in h:
    if i>COU:
        m=0
    else:
        m+=1
        if m>m_max:
            m_max=m
    
    COU=i
print(m_max)
Buggy python submission (verdict: Runtime Error):
n,m = map(int, input().split())
x= list(map(int,input().split()))

if n>=m:
    print('0')
    exit()

x.sort()

y=[0]*(m-1)
for i in range(m-1):
    y[i]=x[i+1]-x[i]
if n==1:
    print(sum(y))
    exit()
y.sort(reverse=True)
for i in range(n-1):
    del y[i]
print(sum(y))


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

if n>=m:
    print('0')
    exit()

x.sort()

y=[0]*(m-1)
for i in range(m-1):
    y[i]=x[i+1]-x[i]
if n==1:
    print(sum(y))
    exit()
y.sort(reverse=True)
for i in range(n-1):
    y[i]=0
print(sum(y))

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

if n>=m:
    print('0')
    exit()
x.sort()

y=[0]*(m-1)
for i in range(m-1):
    y[i]=x[i+1]-x[i]

y.sort(reverse=True)
for i in range(n-1):
    del y[i]
print(sum(y))

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

if n>=m:
    print('0')
    exit()

x.sort()

y=[0]*(m-1)
for i in range(m-1):
    y[i]=x[i+1]-x[i]
if n==1:
    print(sum(y))
    exit()
y.sort(reverse=True)
for i in range(n-1):
    y[i]=0
print(sum(y))

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

x.sort()

y=[0]*(m-1)
for i in range(m-1):
    y[i]=x[i+1]-x[i]

y.sort(reverse=True)
for i in range(n-1):
    del y[i]
print(sum(y))

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

if n>=m:
    print('0')
    exit()

x.sort()

y=[0]*(m-1)
for i in range(m-1):
    y[i]=x[i+1]-x[i]
if n==1:
    print(sum(y))
    exit()
y.sort(reverse=True)
for i in range(n-1):
    y[i]=0
print(sum(y))
Buggy python submission (verdict: Runtime Error):
N=int(input())
A=int(input())

if N%500 =< A :
    print("YES")
else :
    print("NO")

Fixed submission:
n=int(input())
a=int(input())

print("Yes") if n%500<=a else print("No")
Buggy python submission (verdict: Runtime Error):
if all(X//500<=A X%500<=(100*B+50*C) (X%500)%100<=C*50):
    print
    

Fixed submission:
#Coins
A=int(input())
B=int(input())
C=int(input())
X=int(input())

i=0
#j=0 ここに入れるとだめ
ans=0
while i <=A:
    X_aftera=X-500*i
    if X_aftera<0:
        break
    j=0
    while j<=B:
        X_afterb=X_aftera-100*j
        if X_afterb<0:
            break
        if X_afterb//50<=C:
            ans +=1
        j+=1
    i+=1
print(ans)
Buggy python submission (verdict: Runtime Error):
n,a,b = map(int, input().split())

s=0
for i in range(N+1):
    x = i
    m = 0
    while x:
        m += x % 10
        x //= 10
    if a <= m <= b:
        s += i
print(s)

Fixed submission:
#SomeSums
n,a,b = map(int, input().split())

s=0
for i in range(n+1):
    x = i
    m = 0
    while x:
        m += x % 10
        x //= 10
    if a <= m <= b:
        s += i
print(s)
Buggy python submission (verdict: Runtime Error):
n=int(input())
a= list(map(int,input().split()))

#for i in a:
#i=0
b=[0]*(10**5)
r=0
#while i<=n:
for i in a:
    b[i]+=1
    b[i+1]+=1
    b[i+2]+=1
t=max(b)
print(t)

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

#for i in a:
#i=0
b=[0]*(10**5+10)
r=0
#while i<=n:
for i in a:
    b[i]+=1
    b[i+1]+=1
    b[i+2]+=1

print(max(b))

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

#for i in a:
#i=0
b=[0]*(max(a)+2)
r=0
#while i<=n:
for i in a:
    b[i]+=1
    b[i+1]+=1
    b[i+2]+=1
print(max(b)-1)


    A=a.count(a[i]+1)
    M=a.count(a[i])
    C=a.count(a[i]-1)

    b[i]=A+M+C
i=0
def dfs(i,j):

    
    max(dfs(i+1,j),dfs(i,j+1))

print(max(b))


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

#for i in a:
#i=0
b=[0]*(10**5+10)
r=0
#while i<=n:
for i in a:
    b[i]+=1
    b[i+1]+=1
    b[i+2]+=1

print(max(b))

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

#for i in a:
#i=0
b=[0]*(max(a)+2)
r=0
#while i<=n:
for i in a:
    b[i]+=1
    b[i+1]+=1
    b[i+2]+=1
print(max(b-1))

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

#for i in a:
#i=0
b=[0]*(10**5+10)
r=0
#while i<=n:
for i in a:
    b[i]+=1
    b[i+1]+=1
    b[i+2]+=1

print(max(b))

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

#for i in a:
#i=0
b=[0]*n
r=0
#while i<=n:
for i in range(n):
    r=a[i]
    A=a.count(a[i]+1)
    M=a.count(a[i])
    C=a.count(a[i]-1)

    b[i]=A+M+C

print(max(b))


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

#for i in a:
#i=0
b=[0]*(10**5+10)
r=0
#while i<=n:
for i in a:
    b[i]+=1
    b[i+1]+=1
    b[i+2]+=1

print(max(b))

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

#for i in a:
#i=0
b=[0]*n
r=0
#while i<=n:
for i in a:
    r=a[i]
    A=a.count(i+1)
    M=a.count(i)
    C=a.count(i-1)

    b=A+M+C

print(max(b))


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

#for i in a:
#i=0
b=[0]*(10**5+10)
r=0
#while i<=n:
for i in a:
    b[i]+=1
    b[i+1]+=1
    b[i+2]+=1

print(max(b))

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

#for i in a:
#i=0
b=[0]*n
r=0
#while i<=n:
for i in range(n):
    r=a[i]
    A=a.count(a[i]+1)
    M=a.count(a[i])
    C=a.count(a[i]-1)

    b[i]=A+M+C

print(max(b))

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

#for i in a:
#i=0
b=[0]*(10**5+10)
r=0
#while i<=n:
for i in a:
    b[i]+=1
    b[i+1]+=1
    b[i+2]+=1

print(max(b))
Buggy python submission (verdict: Runtime Error):
#文字列大好き
n,l = map(int, input().split())
s=[input() for _ in range(n)]

s=s.sort()
print(''.join(s))
#ans=''
#for i in s:
#    ans=ans+i

#print(ans)

Fixed submission:
#! python3

N, L = [int(x) for x in input().strip().split(' ')]
S = []
for _ in range(N):
    S.append(input().strip())
S.sort()
print(''.join(S))
Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())
graph = [[] for _ in range(n+1)]
visited = [False for _ in range(n+1)]

# print("graph is : ", graph)
# print("visited is : ", visited)
def dfs(node):
    visited[node] = True
    ret = 0
    for child in graph[node]:
        if not visited[child]:
            ret += dfs(child)
    return ret + 1


for _ in range(m):
    a, b = map(int, input().split())
    graph[a].append(b)
    graph[b].append(a)

rets = []
for node in range(1, n+1):
    if not visited[node] :
        counts = dfs(node)
        rets.append(counts)
print(max(rets))


Fixed submission:
import sys
sys.setrecursionlimit(100000000)

n, m = map(int, input().split())
graph = [[] for _ in range(n+1)]
visited = [False for _ in range(n+1)]

# print("graph is : ", graph)
# print("visited is : ", visited)
def dfs(node):
    visited[node] = True
    ret = 0
    for child in graph[node]:
        if not visited[child]:
            ret += dfs(child)
    return ret + 1


for _ in range(m):
    a, b = map(int, input().split())
    graph[a].append(b)
    graph[b].append(a)

rets = []
for node in range(1, n+1):
    if not visited[node] :
        counts = dfs(node)
        rets.append(counts)
print(max(rets))
Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
A = []
A = list(map(int, input().split()))

medium = 1
for k in range(K):
    medium = medium*A[k]

for i in range(K,N):
    medium2 = medium/A[i-K]*A[i]
    if(medium < medium2):
        print("Yes")
    else:
        print("No") 
    medium = medium2

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

for i in range(K,N):
    if(A[i-K] < A[i]):
        print("Yes")
    else:
        print("No")
Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
list1 = [0]*N

for i in range(M):
    a, b = map(int, input().split())
    for j in range(a-1,b):
        list1[j] = list1[j]+1

count1 = 0
for i in range(len(list1)):
     if list1[i]==M:
        count1 +=1

print(count1)


Fixed submission:
N, M = map(int, input().split())
a1 = 0
b1 = N
for i in range(M):
    a, b = map(int, input().split())
    if a1 <= a:
        a1 =a
    if b1 >= b:
        b1 = b

ans = b1-a1+1
if ans <0:
    ans = 0
print(ans)
Buggy python submission (verdict: Runtime Error):
s = input()
counter = 0
if(s[0]=="1"):
    ++counter
if(s[1]=="1):
    ++counter
if(s[2]=="1):
    ++counter

print(counter)


Fixed submission:
s = input()
s = [int(i) for i in s]
ans = sum(s)
print(ans)
Buggy python submission (verdict: Runtime Error):
X = list(map(int, input().split()))

print(max{X[0]*X[1], X[1]*X[2], X[2]*X[3], X[3]*X[0], X[0]*X[2],
         X[1]*X[3]})

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

print(max(X[1]*X[2], X[3]*X[0], X[0]*X[2],X[1]*X[3]))
Buggy python submission (verdict: Runtime Error):
N = int(input())

num = N*(N-1)*(10**(N-2))/ (10**9 +7)
print(num)

Fixed submission:
N = int(input())

num = 10**N - 2*(9**N) + 8**N
print(num % (10**9 + 7))

Buggy python submission (verdict: Runtime Error):
N = int(input())

num = (N*(N-1)*10**(N-2)) / (10**9 +7)
print(num)

Fixed submission:
N = int(input())

num = 10**N - 2*(9**N) + 8**N
print(num % (10**9 + 7))
Buggy python submission (verdict: Runtime Error):
D,T,S = input(int()),input(int()), input(int())

if S*T >=D:
  print('Yes')
else:
  print('No')

Fixed submission:
D,T,S = input().split()

D = int(D)
T = int(T)
S = int(S)


if S*T >=D:
  print('Yes')
else:
  print('No')

Buggy python submission (verdict: Runtime Error):
D=input(int())
T=input(int())
S=input(int())

if S*T >=D:
  print('Yes')
else:
  print('No')

Fixed submission:
D,T,S = input().split()

D = int(D)
T = int(T)
S = int(S)


if S*T >=D:
  print('Yes')
else:
  print('No')

Buggy python submission (verdict: Runtime Error):
D=input(int())
T=input(int())
S=input(int())

if S*T >=D:
  print('Yes')
else:
        print('No')

Fixed submission:
D,T,S = input().split()

D = int(D)
T = int(T)
S = int(S)


if S*T >=D:
  print('Yes')
else:
  print('No')

Buggy python submission (verdict: Runtime Error):
D=input(int())
T=input(int())
S=input(int())

if S*T >=D:
  print('Yes)
else:
        print('No')

Fixed submission:
D,T,S = input().split()

D = int(D)
T = int(T)
S = int(S)


if S*T >=D:
  print('Yes')
else:
  print('No')
Buggy python submission (verdict: Runtime Error):
N,X,T = input(int()).split()


if N % X != 0:
  A = ((N // X) + 1 ) * T
else:
  A = (N/X) * T
print(int(A))

Fixed submission:
N,X,T = input().split()

N = int(N)
X = int(X)
T = int(T)

if N % X != 0:
  A = ((N // X) + 1 ) * T
else:
  A = (N/X) * T
print(int(A))

Buggy python submission (verdict: Runtime Error):
N,X,T = input().split()


A = ((N // X) + 1 ) * T
print(int(A))

Fixed submission:
N,X,T = input().split()

N = int(N)
X = int(X)
T = int(T)

if N % X != 0:
  A = ((N // X) + 1 ) * T
else:
  A = (N/X) * T
print(int(A))

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

A = ((N // X) + 1 ) * T
print(int(A))

Fixed submission:
N,X,T = input().split()

N = int(N)
X = int(X)
T = int(T)

if N % X != 0:
  A = ((N // X) + 1 ) * T
else:
  A = (N/X) * T
print(int(A))

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

A = ((N // X) + 1 ) * T
print(A)

Fixed submission:
N,X,T = input().split()

N = int(N)
X = int(X)
T = int(T)

if N % X != 0:
  A = ((N // X) + 1 ) * T
else:
  A = (N/X) * T
print(int(A))
Buggy python submission (verdict: Runtime Error):
N = input()

N = str(N)

sum = 0
for i in range(0, len(N)):
  sum += N[i]

if sum % 9 ==0:
  print('Yes')
else:
  print('No')

Fixed submission:
N = int(input())

if N % 9 ==0:
  print('Yes')
else:
  print('No')

Buggy python submission (verdict: Runtime Error):
N = input(int())

N = str(N)

sum = 0
for i in len(N):
  sum += N[i]

if sum % 9 ==0:
  print('Yes')
else:
  print('No')

Fixed submission:
N = int(input())

if N % 9 ==0:
  print('Yes')
else:
  print('No')
Buggy python submission (verdict: Runtime Error):
N = input()

if N[len(N) - 1] == "s":
    N += "es"
else:
    N += "s"
print(N)
N = input()

if N[len(N) - 1] == "s":
    N += "es"
else:
    N += "s"
print(N)


Fixed submission:
N = input()

if N[len(N) - 1] == "s":
    N += "es"
else:
    N += "s"
print(N)
Buggy python submission (verdict: Time Limit Exceeded):
a = input()
k, s = a.split(' ')
K = int(k)
S = int(s)
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:
                ans += 1

print(ans)

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

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
a = input()
k, s = a.split(' ')
K = int(k)
S = int(s)
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:
                ans += 1

print(ans)

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

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

x = reduce(lambda x, y: x ^ y, A)
print(*[x ^ a for a in A])


Fixed submission:
from functools import reduce

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

x = reduce(lambda x, y: x ^ y, A)
print(*[x ^ a for a in A])
Buggy python submission (verdict: Time Limit Exceeded):
from collections import defaultdict

S = input()

D = defaultdict(int)
D[0] += 1
x = 0
d = 1
for s in reversed(S):
  x = (x + int(s) * d) % 2019
  D[x] += 1
  d *= 10

print(sum(x * (x-1) // 2 for x in D.values()))

Fixed submission:
from collections import defaultdict

S = input()

D = defaultdict(int)
D[0] += 1
x = 0
d = 1
for s in reversed(S):
  x = (x + int(s) * d) % 2019
  D[x] += 1
  d = (d * 10) % 2019

print(sum(x * (x-1) // 2 for x in D.values()))

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

S = input()

D = defaultdict(set)
for x in range(2019, 10**8, 2019):
  y = str(x)
  D[y[0:4]].add(y)

L = deque()
D1 = defaultdict(set)
D2 = {}
for i in range(len(S)-3):
  ii = i
  R = ''
  while ii < len(S):
    y = R + S[ii:ii+4-len(R)]
    for d in D[y]:
      if R + S[ii:ii+len(d)-len(R)] == d:
        L.appendleft(i)
        D1[i].add(ii+len(d)-len(R))
        D2[ii+len(d)-len(R)] = i
        break
    else:
      X = int(R + S[ii:ii+8-len(R)])
      ii += 8-len(R)
      R = str(X % 2019)
      continue
    break

for x in L:
  if x in D2:
    D1[D2[x]] += D1[x]
print(sum(len(x) for x in D1.values()))

Fixed submission:
from collections import defaultdict

S = input()

D = defaultdict(int)
D[0] += 1
x = 0
d = 1
for s in reversed(S):
  x = (x + int(s) * d) % 2019
  D[x] += 1
  d = (d * 10) % 2019

print(sum(x * (x-1) // 2 for x in D.values()))

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

S = input()

L = deque()
D1 = defaultdict(set)
D2 = {}
for i in range(len(S)-3):
  ii = i
  j = i + 4
  r = 0
  while j <= len(S):
    X = r + int(S[ii:j])
    r = X % 2019
    ii = j
    if r == 0:
      L.append(i)
      D1[i].add(j)
      D2[j] = i
      break
    elif r < 2:
      j += 4
      r *= 10000
    elif r < 20:
      j += 3
      r *= 1000
    elif r < 201:
      j += 2
      r *= 100
    else:
      j += 1
      r *= 10

for x in reversed(L):
  if x in D2:
    D1[D2[x]] += D1[x]
print(sum(len(x) for x in D1.values()))

Fixed submission:
from collections import defaultdict

S = input()

D = defaultdict(int)
D[0] += 1
x = 0
d = 1
for s in reversed(S):
  x = (x + int(s) * d) % 2019
  D[x] += 1
  d = (d * 10) % 2019

print(sum(x * (x-1) // 2 for x in D.values()))

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

S = input()

L = deque()
D1 = defaultdict(set)
D2 = {}
for i in range(len(S)-3):
  for j in range(i+4, len(S)+1):
    X = int(S[i:j])
    r = X % 2019
    if r == 0:
      L.append(i)
      D1[i].add(j)
      D2[j] = i
      break

for x in reversed(L):
  if x in D2:
    D1[D2[x]] += D1[x]
print(sum(len(x) for x in D1.values()))

Fixed submission:
from collections import defaultdict

S = input()

D = defaultdict(int)
D[0] += 1
x = 0
d = 1
for s in reversed(S):
  x = (x + int(s) * d) % 2019
  D[x] += 1
  d = (d * 10) % 2019

print(sum(x * (x-1) // 2 for x in D.values()))
Buggy python submission (verdict: Time Limit Exceeded):
from itertools import combinations

N, X, Y = map(int, input().split())

for k in range(1, N):
    count = 0
    for i, j in combinations(range(1, N+1), 2):
        if min(j - i, abs(X-i)+1+abs(Y-j)) == k:
            count += 1
    print(count)


Fixed submission:
from collections import Counter
from itertools import combinations

N, X, Y = map(int, input().split())

C = Counter(min(j - i, abs(X - 1 - i) + 1 + abs(Y - 1 - j)) for i, j in combinations(range(N), 2))

for i in range(1, N):
  print(C[i])

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

for k in range(1, N):
    count = 0
    for i, j in combinations(range(1, N+1), 2):
        if min(j - i, abs(X-i)+1+abs(Y-j)) == k:
            count += 1
    print(count)


Fixed submission:
from collections import Counter
from itertools import combinations

N, X, Y = map(int, input().split())

C = Counter(min(j - i, abs(X - 1 - i) + 1 + abs(Y - 1 - j)) for i, j in combinations(range(N), 2))

for i in range(1, N):
  print(C[i])
Buggy python submission (verdict: Time Limit Exceeded):
from operator import mul
from functools import reduce

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

r1 = min(a, n - a)
r2 = min(b, n - b)

if r1 > r2:
  r1, r2 = r2, r1

numer1 = reduce(mul, range(n, n - r1, -1), 1)
denom1 = reduce(mul, range(1, r1 + 1), 1)
numer2 = reduce(mul, range(n - r1, n - r2, -1), numer1)
denom2 = reduce(mul, range(r1 + 1, r2 + 1), denom1)

print((2 ** n - 1 - numer1 // denom1 - numer2 // denom2) % (10 ** 9 + 7))


Fixed submission:
from operator import mul
from functools import reduce

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

mod = 10 ** 9 + 7

def mul(a, b):
    return ((a % mod) * (b % mod)) % mod

def power(x, y):
    if   y == 0     :
      return 1
    elif y == 1     :
      return x % mod
    elif y % 2 == 0 :
      return power(x, y//2)**2 % mod
    else            :
      return power(x, y//2)**2 * x % mod

def div(a, b):
    return mul(a, power(b, mod-2))

r1 = min(a, n - a)
r2 = min(b, n - b)

if r1 > r2:
  r1, r2 = r2, r1

numer1 = reduce(mul, range(n, n - r1, -1), 1)
denom1 = reduce(mul, range(1, r1 + 1), 1)
numer2 = reduce(mul, range(n - r1, n - r2, -1), numer1)
denom2 = reduce(mul, range(r1 + 1, r2 + 1), denom1)

print((power(2, n) - 1 - div(numer1, denom1) - div(numer2, denom2)) % (10 ** 9 + 7))

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

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

def combinations_count(n, r):
  if n < r:
    return 0
  r = min(r, n - r)
  numer = reduce(mul, range(n, n - r, -1), 1)
  denom = reduce(mul, range(1, r + 1), 1)
  return numer // denom

print((2**n - 1 - combinations_count(n, a) - combinations_count(n, b)) % (10 ** 9 + 7))


Fixed submission:
from operator import mul
from functools import reduce

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

mod = 10 ** 9 + 7

def mul(a, b):
    return ((a % mod) * (b % mod)) % mod

def power(x, y):
    if   y == 0     :
      return 1
    elif y == 1     :
      return x % mod
    elif y % 2 == 0 :
      return power(x, y//2)**2 % mod
    else            :
      return power(x, y//2)**2 * x % mod

def div(a, b):
    return mul(a, power(b, mod-2))

r1 = min(a, n - a)
r2 = min(b, n - b)

if r1 > r2:
  r1, r2 = r2, r1

numer1 = reduce(mul, range(n, n - r1, -1), 1)
denom1 = reduce(mul, range(1, r1 + 1), 1)
numer2 = reduce(mul, range(n - r1, n - r2, -1), numer1)
denom2 = reduce(mul, range(r1 + 1, r2 + 1), denom1)

print((power(2, n) - 1 - div(numer1, denom1) - div(numer2, denom2)) % (10 ** 9 + 7))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
XL = sorted(list(map(int, input().split())) for _ in range(N))

X = [xl[0] for xl in XL]
L = [xl[1] for xl in XL]

i = 0
count = N
while i < count - 1:
  if X[i] + L[i] > X[i+1] - L[i+1]:
    if X[i] + L[i] < X[i+1] + L[i+1]:
      del X[i+1]
      del L[i+1]
    else:
      del X[i]
      del L[i]
    count -= 1
  else:
    i += 1
print(count)

Fixed submission:
N = int(input())
XL = sorted(list(map(int, input().split())) for _ in range(N))

i, j = 0, 1
count = N
while j < N:
  if XL[i][0] + XL[i][1] > XL[j][0] - XL[j][1]:
    if XL[i][0] + XL[i][1] < XL[j][0] + XL[j][1]:
      j += 1
    else:
      i, j = j, j + 1
    count -= 1
  else:
    i, j = j, j + 1
print(count)
Buggy python submission (verdict: Time Limit Exceeded):
from math import factorial

x, y = map(int, input().split())

if (x + y) % 3 or (x > y * 2) or (x * 2 < y):
  print(0)
else:
  a = (x + y) // 3
  b = (a - abs(x - y)) // 2
  c = 1
  for x in range(a, a-b, -1):
    c *= x
  print(c // factorial(b) % (10**9+7))

Fixed submission:
x, y = map(int, input().split())

if (x + y) % 3 or (x > y * 2) or (x * 2 < y):
  print(0)
else:
  MOD = 10 ** 9 + 7
  MAX = 10 ** 6

  fac = [1] * MAX
  inv = [1] * MAX
  finv = [1] * MAX
  for i in range(2, MAX):
    fac[i] = fac[i - 1] * i % MOD
    inv[i] = (- inv[MOD % i] * (MOD // i)) % MOD
    finv[i] = finv[i - 1] * inv[i] % MOD

  def com(n, k):
    if n < 0 or k < 0:
      return 0
    if n < k:
      return 0
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD

  a = (x + y) // 3
  b = (a - abs(x - y)) // 2
  print(com(a, b))
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

A = sorted(enumerate(A), key=lambda x: x[1])
B = sorted(enumerate(B), key=lambda x: x[1])

flag = False
for i in range(N):
  if A[i][1] > B[i][1]:
    print('No')
    braek
  elif A[i][0] == B[i][0]:
    flag = True
  elif i > 0 and A[i][1] <= B[i-1][1]:
    flag = True
else:
  if flag:
    print('Yes')
  else:
    print('No')

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

A = sorted(enumerate(A), key=lambda x: x[1])
B = sorted(enumerate(B), key=lambda x: x[1])

flag = False
for i in range(N):
  if A[i][1] > B[i][1]:
    print('No')
    break
  elif i > 0 and A[i][1] <= B[i-1][1]:
    flag = True
else:
  if flag:
    print('Yes')
  else:
    D = dict((a[0], b[0]) for a, b in zip(A, B))
    count = 0
    x = D[0]
    while x != 0:
      x = D[x]
      count += 1
    print('Yes' if count < N-1 else 'No')
Buggy python submission (verdict: Runtime Error):
N, *p = list(map(int, input().split()))
print(p)
count = 0
for i in range(N):
  if p[i] != i + 1:
    count += 1

if count <= 2:
  print('YES')
else:
  print('NO')

Fixed submission:
N, *P = list(map(int, open(0).read().split()))
count = sum(p != i + 1 for i, p in enumerate(P))

print('YES' if count <= 2 else 'NO')