Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, raw_input().split(' '))

ans = 0
for i in xrange(n-2):
    i += 1
    for j in xrange(7-2):
        j += 1
        s = 9*(7*i+j+1)

        if ((s % 11) == k):
            ans +=1
print ans


Fixed submission:
n, k = map(int, raw_input().split(' '))

m = n -2
ans = 5*int(m/11)
for i in xrange(m % 11):
    i += 1
    for j in xrange(7-2):
        j += 1
        s = 9*(7*i+j+1)

        if ((s % 11) == k):
            ans +=1
print ans

Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, raw_input().split(' '))

ans = 0
for i in xrange(n-2):
    i += 1
    for j in xrange(7-2):
        j += 1
        s = 0
        for ii in xrange(3):
            for jj in xrange(3):
                s += 7*(i+ii) + (j+jj) -7

        if ((s % 11) == k):
            ans +=1
print ans


Fixed submission:
n, k = map(int, raw_input().split(' '))

m = n -2
ans = 5*int(m/11)
for i in xrange(m % 11):
    i += 1
    for j in xrange(7-2):
        j += 1
        s = 9*(7*i+j+1)

        if ((s % 11) == k):
            ans +=1
print ans

Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, raw_input().split(' '))

ans = 0
for i in range(n-2):
    i += 1
    for j in range(7-2):
        j += 1
        s = 0
        for ii in range(3):
            for jj in range(3):
                s += 7*(i+ii) + (j+jj) -7

        if ((s % 11) == k):
            ans +=1
print ans


Fixed submission:
n, k = map(int, raw_input().split(' '))

m = n -2
ans = 5*int(m/11)
for i in xrange(m % 11):
    i += 1
    for j in xrange(7-2):
        j += 1
        s = 9*(7*i+j+1)

        if ((s % 11) == k):
            ans +=1
print ans
Buggy python submission (verdict: Runtime Error):
S = input()
  if S == "ARC":
     print("ABC")
  elif S == "ABC":
       print("ARC")


Fixed submission:
S = input()
if S == "ARC":
   print("ABC")
elif S == "ABC":
     print("ARC")

Buggy python submission (verdict: Runtime Error):
S = input()
  if S == int("ARC") :
     print("ABC")
  elif S == int('ABC'):
       print('ARC')


Fixed submission:
S = input()
if S == "ARC":
   print("ABC")
elif S == "ABC":
     print("ARC")

Buggy python submission (verdict: Runtime Error):
S = input()
  if S == 'ARC':
     print('ABC')
  elif S == 'ABC':
       print('ARC')

Fixed submission:
S = input()
if S == "ARC":
   print("ABC")
elif S == "ABC":
     print("ARC")

Buggy python submission (verdict: Runtime Error):
S = input()
if S = int('ARC')
   print('ABC')
if S = int('ABC')
   print('ARC')
       

Fixed submission:
S = input()
if S == "ARC":
   print("ABC")
elif S == "ABC":
     print("ARC")

Buggy python submission (verdict: Runtime Error):
if S = ABC
   print('ARC')
elif S = ARC
     print('ABC')

Fixed submission:
S = input()
if S == "ARC":
   print("ABC")
elif S == "ABC":
     print("ARC")
Buggy python submission (verdict: Time Limit Exceeded):
import math
k = int(input())
sum = 0
for i in range(1,k+1):
    for j in range(1,k+1):
        for l in range(1,k+1):
            sum+=math.gcd(math.gcd(i,j),l)
print(sum)

Fixed submission:
import math
k = int(input())
sum = 0
for i in range(1,k+1):
    for j in range(1,k+1):
        for l in range(1,k+1):
            sum+=math.gcd(math.gcd(i,j),l)
print(sum)
Buggy python submission (verdict: Runtime Error):
def calc(arr,dp,n,ind):
    if ind==n-1:
        return 0
    if ind>=n:
        return 99999999
    if dp[ind]!=-1:
        return dp[ind]
    left = abs(arr[ind]-arr[ind+1]) + calc(arr,dp,n,ind+1)
    right = 99999999
    if ind+2<n:
        right = abs(arr[ind]-arr[ind+2]) + calc(arr,dp,n,ind+2)
    dp[ind] = min(left,right)
    return dp[ind]
n = int(input())
arr = [int(s) for s in input().split()]
dp = [-1]*n
print(calc(arr,dp,n,0))

Fixed submission:
n = int(input())
arr = [int(s) for s in input().split()]
dp = [-1]*n
dp[0] = 0
dp[1] = abs(arr[0]-arr[1])
for i in range(2,n):
    dp[i] = min(abs(arr[i-1]-arr[i])+dp[i-1],abs(arr[i-2]-arr[i])+dp[i-2])
print(dp[n-1])
Buggy python submission (verdict: Runtime Error):
lis = input().split()
N = int(lis[0])
M = int(lis[1])
H = input().split()
T = list(range(N+1))

for i in range(M):
    R = input().split()
    r1 = int(R[0])-1
    r2 = int(R[1])-1
    #print("r1=",r1,"r2=",r2)
    if int(H[r1]) >= int(H[r2]):
        if int(r2+1) in T:
            T.remove(int(r2+1))
    if int(H[r1]) < int(H[r2]):
        if int(r1+1) in T:
            T.remove(int(r1+1))

print(len(T) - 1)


Fixed submission:
a = input()
 
if a == "ABC":
  print("ARC")
if a == "ARC":
  print("ABC")

Buggy python submission (verdict: Runtime Error):
a = input()

if a == ABC:
  print("ARC")
else:
  print("ARC")

Fixed submission:
a = input()
 
if a == "ABC":
  print("ARC")
if a == "ARC":
  print("ABC")
Buggy python submission (verdict: Runtime Error):
a = input().split()

N = int(a[0])
M = int(a[1])


b = 0
c = []

while True:
  if b >= M:
  	break
  e = int(input())
  c.append(e)
  b += 1

d = 0
  
for i in c:
  d += int(i)

if d > N:
  print(-1)
else:
  print(N-d)

Fixed submission:
a = input().split()

N = int(a[0])


c = input().split()



d = 0
  
for i in c:
  d += int(i)

if d > N:
  print(-1)
else:
  print(N-d)

Buggy python submission (verdict: Runtime Error):
a = input().split()

N = int(a[0])
M = int(a[1])

b = 0
c = []

while True:
  if b >= M:
  	break
  e = input(int())
  c.append(e)
  b += 1

d = 0
  
for i in c:
  d += int(i)

if d > N:
  print(-1)
else:
  print(N-d)

Fixed submission:
a = input().split()

N = int(a[0])


c = input().split()



d = 0
  
for i in c:
  d += int(i)

if d > N:
  print(-1)
else:
  print(N-d)

Buggy python submission (verdict: Runtime Error):
a = input().split()

N = int(a[0])
M = int(a[1])

print(N)
print(M)

b = 0
c = []

while True:
  if b >= M:
  	break
  e = input(int())
  c.append(e)
  b += 1

d = 0
  
for i in c:
  d += int(i)

if d > N:
  print(-1)
else:
  print(N-d)

Fixed submission:
a = input().split()

N = int(a[0])


c = input().split()



d = 0
  
for i in c:
  d += int(i)

if d > N:
  print(-1)
else:
  print(N-d)

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

N = a[0]
M = a[1]

b = 0
c = []

while true:
  if b > M:
  	break
  e = input(int())
  c.append(e)
  b += 1

d = 0
  
for i in c:
  d += i

if d > N:
  print(-1)
else:
  print(N-d)


Fixed submission:
a = input().split()

N = int(a[0])


c = input().split()



d = 0
  
for i in c:
  d += int(i)

if d > N:
  print(-1)
else:
  print(N-d)
Buggy python submission (verdict: Runtime Error):
s='S'
if s[2]==s[3] and s[4]==s[5]:
  print('Yes")
else:
  print('No')

Fixed submission:
S=input()
if S[2]==S[3] and S[4]==S[5]:
  print('Yes')
else:
  print('No')

Buggy python submission (verdict: Runtime Error):
p=S
if p[3]==p[4] and p[5]=p[6]:
  print('Yes')
else:
  print('No')
  

Fixed submission:
S=input()
if S[2]==S[3] and S[4]==S[5]:
  print('Yes')
else:
  print('No')
Buggy python submission (verdict: Runtime Error):
X=input()
y=int(X)
while y<1000:
  y-=1000
  z+=1
result=z*2+y*1
str_result=str(result)
print('str_result')

Fixed submission:
X=input()
y=int(X)
z=0
while y>=500:
   y-=500
   z+=1
a=0
while y>=5:
    y-=5
    a+=1
   
result=z*1000+a*5
str_result=str(result)
print(str_result)
Buggy python submission (verdict: Runtime Error):
a=int(input())
b=int(input())
if (a*b)%2==0:
  print('Even')
else:
  print('Odd')


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

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


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

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

Fixed submission:
a, b = map(int, input().split())
if a*b%2==0:
  print('Even')
else:
  print('Odd')
Buggy python submission (verdict: Runtime Error):
s=list(input())
print(List.count("1"))

Fixed submission:
s=list(input())
print(s.count("1"))
Buggy python submission (verdict: Runtime Error):
N,M = int(a) for a in input().split()
print(N)
print(M)


Fixed submission:
input_str =  input().split()
N = int(input_str[0])
M = int(input_str[1])

if N == M:
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Time Limit Exceeded):
input_str = input().split()
N = int(input_str[0])
Y = int(input_str[1])

x_quo = Y//10000

flag = False
for x in range(min([x_quo,N]),-1,-1):
  Y_x = Y - 10000*x
  N_x = N - x
  y_quo = Y_x // 5000
  for y in range(min([y_quo,N_x]),-1,-1):
    Y_xy = Y_x - 5000*y
    N_xy = N_x - y
    z_quo = Y_xy // 1000
    for z in range(min([z_quo,N_xy]),-1,-1):
      if 10000*x + 5000*y + 1000*z == Y and x+y+z == N:
        flag = True;
        break;
    else:
      continue
    break
  else:
    continue
  break

if flag == True:
  print(str(x) + " " + str(y) + " " + str(z))
else:
  print("-1 -1 -1")

Fixed submission:
input_str = input().split()
N = int(input_str[0])
Y = int(input_str[1])

x_quo = Y//10000

flag = False
for x in range(min([x_quo,N]),-1,-1):
  Y_x = Y - 10000*x
  N_x = N - x
  y_quo = Y_x // 5000
  for y in range(min([y_quo,N_x]),-1,-1):
    z = N-x-y
    if 10000*x + 5000*y + 1000*z == Y and x+y+z == N:
      flag = True;
      break;
  else:
    continue
  break

if flag == True:
  print(str(x) + " " + str(y) + " " + str(z))
else:
  print("-1 -1 -1")

Buggy python submission (verdict: Time Limit Exceeded):
input_str = input().split()
N = int(input_str[0])
Y = int(input_str[1])

x_quo = Y//10000

flag = False
for x in range(0,min([x_quo+1,N+1])):
  Y_x = Y - 10000*x
  N_x = N - x
  y_quo = Y_x // 5000
  for y in range(0,min([y_quo+1,N_x+1])):
    Y_xy = Y_x - 5000*y
    N_xy = N_x - y
    z_quo = Y_xy // 1000
    for z in range(0,min([z_quo+1,N_xy+1])):
      if 10000*x + 5000*y + 1000*z == Y and x+y+z == N:
        flag = True;
        break;
    else:
      continue
    break
  else:
    continue
  break

if flag == True:
  print(str(x) + " " + str(y) + " " + str(z))
else:
  print("-1 -1 -1")

Fixed submission:
input_str = input().split()
N = int(input_str[0])
Y = int(input_str[1])

x_quo = Y//10000

flag = False
for x in range(min([x_quo,N]),-1,-1):
  Y_x = Y - 10000*x
  N_x = N - x
  y_quo = Y_x // 5000
  for y in range(min([y_quo,N_x]),-1,-1):
    z = N-x-y
    if 10000*x + 5000*y + 1000*z == Y and x+y+z == N:
      flag = True;
      break;
  else:
    continue
  break

if flag == True:
  print(str(x) + " " + str(y) + " " + str(z))
else:
  print("-1 -1 -1")
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))
b = [0]*n
for i in range(n):
    b[i]= i-a[0]-a[i]
d = defaultdict(int)
for i in range(1,n):
    d[b[i]] += 1
ans = 0
x = 0
for i in range(n-1):
    ans+=d[x]
    d[b[i+1]]-=1
    x -= -1+(a[i]-a[i+1])
print(ans)

Fixed submission:
from collections import defaultdict
n = int(input())
a = list(map(int,input().split()))
b = [0]*n
for i in range(n):
    b[i]= i-a[0]-a[i]
d = defaultdict(int)
for i in range(1,n):
    d[b[i]] += 1
ans = 0
x = 0
for i in range(n-1):
    ans+=d[x]
    d[b[i+1]]-=1
    x -= -1+(a[i]-a[i+1])
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int,input().split()))
b = []
for i in range(n):
    b.append([a[i],i])
b.sort()
b = b[::-1]
#print(b)
dp = [[0]* (n+1) for i in range(n+1)]
cnt = 0
for i,j in b:
    for k in range(cnt+1):
        dp[cnt-k][k+1] = max(dp[cnt-k][k] + abs(n-1-j-k)*i,dp[cnt-k][k+1])
        dp[cnt-k+1][k] = max(dp[cnt-k][k] + abs(j-(cnt-k))*i,dp[cnt-k+1][k])
    cnt+=1
ans = 0
for k in range(n):
    ans = max(ans,dp[n+1-k-1][k])
print(ans)

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
b = []
for i in range(n):
    b.append([a[i],i])
b.sort()
b = b[::-1]
#print(b)
dp = [[0]* (n+1) for i in range(n+1)]
cnt = 0
for i,j in b:
    for k in range(cnt+1):
        dp[cnt-k][k+1] = max(dp[cnt-k][k] + abs(n-1-j-k)*i,dp[cnt-k][k+1])
        dp[cnt-k+1][k] = max(dp[cnt-k][k] + abs(j-(cnt-k))*i,dp[cnt-k+1][k])
    cnt+=1
ans = 0
for k in range(n):
    ans = max(ans,dp[n+1-k-1][k])
print(ans)
Buggy python submission (verdict: Runtime Error):
from sys import stdin
lines = stdin.readlines()
 
C = str(lines[0])
 
print(chr(ord(C) + 1))

Fixed submission:

C = str(input())

print(chr(ord(C) + 1))

Buggy python submission (verdict: Runtime Error):
from sys import stdin
lines = stdin.readlines()
 
C = str(lines[0])
 
print(chr(ord(C) + 1))

Fixed submission:

C = str(input())

print(chr(ord(C) + 1))

Buggy python submission (verdict: Runtime Error):
from sys import stdin
lines = stdin.readlines()
 
C = lines[0]

print(chr(ord(C) + 1))

Fixed submission:

C = str(input())

print(chr(ord(C) + 1))
Buggy python submission (verdict: Runtime Error):
import sys
if argv[1] == 'Sunny':
  echo "Cloudy"
elif argv[1] == 'Cloudy':
  echo "Rainy"
elif argv[1] == 'Rainy' :
  echo "Sunny"
else:

Fixed submission:
s = input()
if s=='Sunny':
  print('Cloudy')
elif s=='Rainy':
  print('Sunny')
else:
  print('Rainy')
Buggy python submission (verdict: Runtime Error):
S, W = map(int, input().split())
if S <= w:
	print("unsafe")
else:
    print("safe")

Fixed submission:
S, W = map(int, input().split())
if S > W:
    print('safe')
else:
    print('unsafe')

Buggy python submission (verdict: Runtime Error):
S, W = map(int, input().split())
if S <= W 
	print("unsafe")
else:
    print("safe")

Fixed submission:
S, W = map(int, input().split())
if S > W:
    print('safe')
else:
    print('unsafe')
Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
A = list(map(int, input().split())

print(max(N - sum(A), - 1))         
         

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

print(max(N - sum(A), -1))
Buggy python submission (verdict: Runtime Error):
import collection
N = int(input())
A = list(map(int, input().split()))
count = collections.Counter(A)
for n in range(N):
  print(count[n + 1])
  

Fixed submission:
import collections
N = int(input())
A = list(map(int, input().split()))
count = collections.Counter(A)
for n in range(N):
  print(count[n+1])
Buggy python submission (verdict: Runtime Error):
if N[0] == '7' or N[1] == '7' or N[2] == '7':
  print("Yes")
else:
  print("No")

Fixed submission:
N = input()
if N[0] == '7' or N[1] == '7' or N[2] == '7':
  print("Yes")
else:
  print("No")

Buggy python submission (verdict: Runtime Error):
if N[0] == "7" or N[1] == "7" or N[2] == "7":
  print("Yes")
else:
  print("No")

Fixed submission:
N = input()
if N[0] == '7' or N[1] == '7' or N[2] == '7':
  print("Yes")
else:
  print("No")

Buggy python submission (verdict: Runtime Error):
if N[0] == "7" or N[1] == "7" or N[2] == "7":
	print("Yes")
else:
    print("No")

Fixed submission:
N = input()
if N[0] == '7' or N[1] == '7' or N[2] == '7':
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Runtime Error):
temp=A
A=B
B=temp

temp=A
A=C
C=temp

print(A,B,C)

Fixed submission:
A,B,C=input().split()
temp=A
A=B
B=temp

temp=A
A=C
C=temp

print(A,B,C)
Buggy python submission (verdict: Runtime Error):
X = int(input())

a = [int( i/2)*((-1)**i) for i in range(1, 1000)]
b = [int( i/2)*((-1)**i) for i in range(1, 1000)]

"""
* Aが正ならBは負または、Aより小さい正
* Aが負ならBは負
* X/(a+b)は、1以上の整数
"""

find = False
if X == 0:
  print(0)
else:  
  for a_ in a:
    for b_ in b:
      if a_ + b_ == 0:
        continue
      if a_ >= 0:
        if b_ >= 0 or b_ > a_:
          continue
      if a_ < 0:
        if b_ >= 0:
          continue
        
      if X%(a_+b_) != 0:
        continue
      
      if (a_**5) - (b_**5) == X:
        print(f"{a_} {b_}")
        find = True
        break
    if find:
      break


Fixed submission:
c = input()
print("ABC" if c == "ARC" else "ARC")

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

a = [int( i/2)*((-1)**i) for i in range(1, 10000)]
b = [int( i/2)*((-1)**i) for i in range(1, 10000)]

"""
* Aが正ならBは負または、Aより小さい正
* Aが負ならBは負
* X/(a+b)は、1以上の整数
"""

find = False
if X == 0:
  print(0)
else:  
  for a_ in a:
    for b_ in b:
      if a_ + b_ == 0:
        continue
      if a_ >= 0:
        if b_ >= 0 or b_ > a_:
          continue
      if a_ < 0:
        if b_ >= 0:
          continue
        
      if X%(a_+b_) != 0:
        continue
      
      if (a_**5) - (b_**5) == X:
        print(f"{a_} {b_}")
        find = True
        break
    if find:
      break


Fixed submission:
c = input()
print("ABC" if c == "ARC" else "ARC")
Buggy python submission (verdict: Runtime Error):
a = list(map(int, input().split()))
strs=[]
for i in range(a[0]):
    strs.append(input())
print("".join(sorted(strs)))

Fixed submission:
abc = list(map(int,input().split()))
print("YES" if sum(abc) == 17 and abc.count(5) else "NO")

Buggy python submission (verdict: Runtime Error):
a = list(map(int, input().split()))
strs=[]
for i in range(a[0]):
	strs.append(input())
print("".join(sorted(strs)))


Fixed submission:
abc = list(map(int,input().split()))
print("YES" if sum(abc) == 17 and abc.count(5) else "NO")

Buggy python submission (verdict: Runtime Error):
a = list(map(int, input().split()))
strs=[]
for i in range(a[0]):
	strs.push(input())
print("".join(sorted(strs)))

Fixed submission:
abc = list(map(int,input().split()))
print("YES" if sum(abc) == 17 and abc.count(5) else "NO")

Buggy python submission (verdict: Runtime Error):
n, l = map(int, input().split())
strs=[]
for i in range(n):
	strs.push(input())
print("".join(sorted(strs)))

Fixed submission:
abc = list(map(int,input().split()))
print("YES" if sum(abc) == 17 and abc.count(5) else "NO")

Buggy python submission (verdict: Runtime Error):
abc = map(int,input().split())
print("YES" if sum(abc) == 17 and abc.count(5) else "NO")

Fixed submission:
abc = list(map(int,input().split()))
print("YES" if sum(abc) == 17 and abc.count(5) else "NO")

Buggy python submission (verdict: Runtime Error):
abc = map(int,input().split())
"YES" if sum(abc) == 17 and abc.count(5) else "NO"

Fixed submission:
abc = list(map(int,input().split()))
print("YES" if sum(abc) == 17 and abc.count(5) else "NO")
Buggy python submission (verdict: Time Limit Exceeded):
import sys
import array

if __name__ == "__main__":
    N = int(sys.stdin.readline().strip())
    A = array.array('i', [int(a) for a in sys.stdin.readline().strip().split(" ")])

    count_pair = 0
    for i in range(N):
        a = A[i]
        for j in range(i + 1, N):
            if (j - i) == (A[j] + a):
                count_pair += 1
    
    print(count_pair)


Fixed submission:
import sys
import array

if __name__ == "__main__":
    N = int(sys.stdin.readline().strip())
    A = array.array('i', [int(a) for a in sys.stdin.readline().strip().split(" ")])

    count_pair = 0
    L = {}
    R = {}

    for i in range(N):
        l = A[i] + (i + 1)
        r = (i + 1) - A[i]

        if l in L:
            L[l].append(i+1)
        else:
            L[l] = [i+1]

        if r in R:
            R[r].append(i+1)
        else:
            R[r] = [i+1]

    print(sum([len(L[m]) * len(R[m]) for m in list(set(L.keys()) & set(R.keys()))]))

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

if __name__ == "__main__":
    N = int(sys.stdin.readline().strip())
    A = [int(a) for a in sys.stdin.readline().strip().split(" ")]

    count_pair = 0
    for i in range(N):
        for j in range(i + 1, N):
            if (j - i) == (A[j] + A[i]):
                count_pair += 1
    
    print(count_pair)

Fixed submission:
import sys
import array

if __name__ == "__main__":
    N = int(sys.stdin.readline().strip())
    A = array.array('i', [int(a) for a in sys.stdin.readline().strip().split(" ")])

    count_pair = 0
    L = {}
    R = {}

    for i in range(N):
        l = A[i] + (i + 1)
        r = (i + 1) - A[i]

        if l in L:
            L[l].append(i+1)
        else:
            L[l] = [i+1]

        if r in R:
            R[r].append(i+1)
        else:
            R[r] = [i+1]

    print(sum([len(L[m]) * len(R[m]) for m in list(set(L.keys()) & set(R.keys()))]))
Buggy python submission (verdict: Runtime Error):
x=int(input())
for i in range(-1000,1000):
  for j in range(-1000,1000):
    if i**5-j**5==x:
      print(i,j)
      exit()

Fixed submission:
s=input()
if s=="ABC":
  print("ARC")
else:
  print("ABC")
Buggy python submission (verdict: Time Limit Exceeded):
n,m=map(int,input().split())
h=list(map(int,input().split()))
p=[i for i in range(1,n+1)]
for i in range(m):
  a=list(map(int,input().split()))
  if h[a[0]-1]<=h[a[1]-1]:
    if a[0] in p:
      p.remove(a[0])
  if h[a[0]-1]>=h[a[1]-1]:
    if a[1] in p:
      p.remove(a[1])
print(len(p))

Fixed submission:
n,m=map(int,input().split())
h=list(map(int,input().split()))
p=[i for i in range(1,n+1)]
q=[]
for i in range(m):
  a=list(map(int,input().split()))
  if h[a[0]-1]<=h[a[1]-1]:
    q.append(a[0])
  if h[a[0]-1]>=h[a[1]-1]:
    q.append(a[1])
p=set(p)
q=set(q)
print(len(p-q))
Buggy python submission (verdict: Runtime Error):
n,k=map(int,input().split())
a=[0]*200099
for i in range(200099):
  a[i]=i
s=1
for i in range(n,k-1,-1):
  s+=sum(a[i:n+1])-sum(a[0:n-i+1])+1
print(s)

Fixed submission:
n=int(input())
print(3.1415926*n*2)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))
b=[0]*(max(a)-min(a)+1)
for i in range(n):
  b[a[i]-min(a)]+=1

def cc(x):
  return x*(x-1)//2

l=len(b)
sum=0

for i in range(l):
  sum+=cc(b[i])
  
for i in range(n):
  k=b[a[i]-min(a)]
  if k<=1:
    print(sum)
  else:
    print(sum-cc(k)+cc(k-1))

Fixed submission:
N = int(input())
K = list(map(int, input().split()))
C = [0]*(N+1)
for k in K:
    C[k] += 1
Sc = 0
for c in C:
    Sc += c*(c-1)//2
for k in K:
    print(Sc-(C[k]-1))

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))
b=[0]*(max(a)-min(a)+1)
for i in range(n):
  b[a[i]-min(a)]+=1

def cc(x):
  return x*(x-1)//2

l=len(b)
sum=0

for i in range(l):
  sum+=cc(b[i])
  
for i in range(n):
  k=b[a[i]-min(a)]
  if k<=1:
    print(sum)
  else:
    print(sum-cc(k)+cc(k-1))

Fixed submission:
N = int(input())
K = list(map(int, input().split()))
C = [0]*(N+1)
for k in K:
    C[k] += 1
Sc = 0
for c in C:
    Sc += c*(c-1)//2
for k in K:
    print(Sc-(C[k]-1))
Buggy python submission (verdict: Time Limit Exceeded):
s=input()
n=int(input())
cnt=0
for i in range(n):
  a=list(input())
  if a[0]=="1":
    cnt+=1
  else:
    if cnt%2==0 and a[2]=="1":
      s=a[4]+s
 
    elif cnt%2==0 and a[2]=="2":
      s=s+a[4]
     
    elif cnt%2==1 and a[2]=="1":
      s=s+a[4][::-1]

    elif cnt%2==1 and a[2]=="2":
      s=a[4][::-1]+s
    
if cnt%2==0:
  print(s)
else:
  print(s[::-1])

Fixed submission:
from collections import deque
S=list(input())
Q=int(input())
query=[]
reverseflg=False
S=deque(S)

for i in range(Q):
  query.append(list(input().split()))

for q in range(Q):
  if query[q][0]=="1":
    reverseflg= not reverseflg
  
  if query[q][0]=="2":
    if query[q][1]=="1":
      if reverseflg== False:
        S.appendleft(query[q][2])
      else:
        S.append(query[q][2])
    
    else:
      if reverseflg== False:
        S.append(query[q][2])
      else:
        S.appendleft(query[q][2])

if reverseflg==True:
  S.reverse()
  
print(''.join(S))

Buggy python submission (verdict: Time Limit Exceeded):
s=input()
n=int(input())
for i in range(n):
  a=list(input())
  if a[0]=="1":
    s=s[::-1]
  else:
    if a[2]=="1":
      s=a[4]+s
    else:
      s=s+a[4]
print(s)

Fixed submission:
from collections import deque
S=list(input())
Q=int(input())
query=[]
reverseflg=False
S=deque(S)

for i in range(Q):
  query.append(list(input().split()))

for q in range(Q):
  if query[q][0]=="1":
    reverseflg= not reverseflg
  
  if query[q][0]=="2":
    if query[q][1]=="1":
      if reverseflg== False:
        S.appendleft(query[q][2])
      else:
        S.append(query[q][2])
    
    else:
      if reverseflg== False:
        S.append(query[q][2])
      else:
        S.appendleft(query[q][2])

if reverseflg==True:
  S.reverse()
  
print(''.join(S))