Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
k,n = map(int,input(),split())
a = list(map(int,input().split()))
tm = a[0]
a.append(tm)
m = -9878789894545656
 
for i in range(n):
  m = max(m,a[i+1]-a[i])
  
print(k-m)

Fixed submission:
k,n = map(int,input().split())
a = list(map(int,input().split()))
tm = a[0]
a.append(tm)
m = -9878789894545656
 
for i in range(n-1):
  m = max(m,a[i+1]-a[i])
  
m = max(m,a[0]+k-a[n-1])
  
print(k-m)

Buggy python submission (verdict: Runtime Error):
k,n = map(int,input(),split())
a = list(map(int,input().split()))
tm = a[0]
a.append(tm)
m = 11414114514
 
for i in range(n):
  m = min(m,a[i+1]-a[i])
  
print(k-m)

Fixed submission:
k,n = map(int,input().split())
a = list(map(int,input().split()))
tm = a[0]
a.append(tm)
m = -9878789894545656
 
for i in range(n-1):
  m = max(m,a[i+1]-a[i])
  
m = max(m,a[0]+k-a[n-1])
  
print(k-m)

Buggy python submission (verdict: Runtime Error):
k,n = map(int,input(),split())
a = list(map(int,input().split()))
a.append(a[0])
m = 11414114514
 
for i in range(n):
  m = min(m,a[i+1]-a[i])
  
print(k-m)

Fixed submission:
k,n = map(int,input().split())
a = list(map(int,input().split()))
tm = a[0]
a.append(tm)
m = -9878789894545656
 
for i in range(n-1):
  m = max(m,a[i+1]-a[i])
  
m = max(m,a[0]+k-a[n-1])
  
print(k-m)

Buggy python submission (verdict: Runtime Error):
k,n = map(int,input(),split())
a = list(map(int,input().split()))
a += [a[0]]
m = 11414114514

for i in range(n):
  m = min(m,a[i]-a[i+1])
  
print(k-m)

Fixed submission:
k,n = map(int,input().split())
a = list(map(int,input().split()))
tm = a[0]
a.append(tm)
m = -9878789894545656
 
for i in range(n-1):
  m = max(m,a[i+1]-a[i])
  
m = max(m,a[0]+k-a[n-1])
  
print(k-m)
Buggy python submission (verdict: Runtime Error):
n,x,y = map(int,input().split())
k = [0]*(n)

for i in range(1,n):
  for j in range(i+1,n+1):
    ind = abs(x-i) + abs(j-y) + 1
    k[ind] += 1
      
for i in range(1,n):
  print(k[i])

Fixed submission:
n,x,y = map(int,input().split())
k = [0]*(n)

for i in range(1,n):
  for j in range(i+1,n+1):
    if i < x and j <= x:
      k[j-i] += 1
    elif i >= y and j > y:
      k[j-i] += 1
    elif x <= i < y and x<j<=y:
      ind = min(j-i,abs((i-x))+abs((y-j))+1)
      k[ind] += 1
    elif i < x and x<j<=y:
      ind = min(j-i,abs((x-i))+abs((y-j))+1)
      k[ind] += 1
    elif x<=i<y and y<j:
      ind = min(j-i,abs((i-x))+1+abs((j-y)))
      k[ind] += 1
    elif i< x and j > y:
      ind = (x-i) + 1 + (j-y)
      k[ind] += 1
      
for i in range(1,n):
  print(k[i])
Buggy python submission (verdict: Runtime Error):
a,b = map(int,input().split())
 
for i in range(1,10**10):
  if (int(i*0.08)/int(i*0.1)) == a/b:
    print(i)
    exit()
    

Fixed submission:
import math
a,b = map(int,input().split())
sup = math.floor((a+1)/0.08)

for i in range(1,sup):
  if math.floor(i*0.08)== a and math.floor(i*0.1) == b:
    print(i)
    exit()
    
print(-1)

Buggy python submission (verdict: Runtime Error):
a,b = map(int,input().split())
 
for i in range(10**10):
  if (int(i*0.08)/int(i*0.1)) == a/b:
    print(i)
    exit()

Fixed submission:
import math
a,b = map(int,input().split())
sup = math.floor((a+1)/0.08)

for i in range(1,sup):
  if math.floor(i*0.08)== a and math.floor(i*0.1) == b:
    print(i)
    exit()
    
print(-1)

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

for i in range(10**10):
  if (int(i*0.08)/int(i*0.1) == a/b):
    print(i)
    exit()

Fixed submission:
import math
a,b = map(int,input().split())
sup = math.floor((a+1)/0.08)

for i in range(1,sup):
  if math.floor(i*0.08)== a and math.floor(i*0.1) == b:
    print(i)
    exit()
    
print(-1)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque

s = deque(list(input()))
q = int(input())

for i in range(q):
  a = list(input().split())
  if a[0] == '1':
    s.reverse()
  elif a[0] == '2':
    if a[1] == '1':
      s.appendleft(a[2])
    elif a[1] == '2':
      s.append(a[2])
      
print(''.join(s))

Fixed submission:
from collections import deque
count = 0
s = deque(list(input()))
q = int(input())

for i in range(q):
  a = list(input().split())
  if a[0] == '1':
    count += 1
    continue
    
  if count%2 == 0:
    if a[0] == '2':
      if a[1] == '1':
        s.appendleft(a[2])
      elif a[1] == '2':
        s.append(a[2])
        
  if count%2 == 1:
    if a[0] == '2':
      if a[1] == '1':
        s.append(a[2])
      elif a[1] == '2':
        s.appendleft(a[2])
      
ans = ''.join(s)
print(ans if count%2 == 0 else ''.join(list(reversed(ans))))
Buggy python submission (verdict: Runtime Error):
n,m = map(int,input().split())
s = []
c = []
if m == 0:
  if n==1:
    print(0)
    exit()
  elif n==2:
    print(10)
    exit()
  else:
    print(100)
    exit()


for i in range(m):
  S,C =  map(int,input().split())
  s.append(S)
  c.append(C)
  
num = [1] + [0]*(n-1)
ans = ''
 
for i in range(m):
  if n != 1 and s[i] == 1 and c[i] == 0:
    print(-1)
    exit()
  elif n == 1 and s[i] == 1 and c[i] == 0:
    print(-1)
    exit()
for i in range(m-1):
  for j in range(i+1,m):
    if s[i] == s[j] and c[i] != c[j]:
      print(-1)
      exit()
      
for i in range(m):
  num[s[i]-1] = c[i]
  
for i in range(n):
  ans += str(num[i])
  
print(ans)

Fixed submission:
n = int(input())
print(n//2 + 1 if n%2 != 0 else n//2)
Buggy python submission (verdict: Runtime Error):
a = [list(map(int,input().split())) for i in range(3)]
n = int(input())
b = [int(input()) for i in range(n)]

for i in range(3):
    for j in range(3):
      for k in b:
        if k == a[i][j]:
          a[i][j] = 101
          break
      
if a[1] == [101,101,101] or a[2] == [101,101,101] or a[3] == [101,101,101]:
  print('Yes')
  exit()
elif (a[1][1]==101 and a[2][1] ==101 and a[3][1] == 101) or (a[1][2]==101 and a[2][2] ==101 and a[3][2] == 101) and (a[1][3]==101 and a[2][3] ==101 and a[3][3] == 101):
  print('Yes')
  exit()
elif (a[1][1]==101 and a[2][2] ==101 and a[3][3] == 101) or (a[1][3]==101 and a[2][2] ==101 and a[3][1] == 101):
  print('Yes')
  exit()
else:
  print('No')

Fixed submission:
a = [list(map(int,input().split())) for i in range(3)]
n = int(input())
b = [int(input()) for i in range(n)]
 
for i in b:
  for j in range(3):
    for k in range(3):
      if i == a[j][k]:
        a[j][k] = 0
        
for i in range(3):
  if sum(a[i]) == 0:
    print('Yes')
    exit()
    
if a[0][0]+a[1][0]+a[2][0] == 0 or a[0][1]+a[1][1]+a[2][1] == 0 or a[0][2]+a[1][2]+a[2][2] == 0:
  print('Yes')
elif a[0][0]+a[1][1]+a[2][2] == 0 or a[0][2]+a[1][1]+a[2][0] == 0:
  print('Yes')
else:
  print('No')
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))
se = set(n)

if len(se) == len(a):
  print('YES')
else:
  print('NO')

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
se = set(a)
 
if len(se) == len(a):
  print('YES')
else:
  print('NO')
Buggy python submission (verdict: Time Limit Exceeded):
h,n = map(int,input().split())
a = list(map(int,input().split()))
 
for i in range(len(a)):
  h -= max(a)
  a.remove(max(a))
  if h <= 0:
    print('Yes')
    exit()
    
print('No')


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

if sum(a) >= h:
  print('Yes')
else:
  print('No')
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
p = list(map(int,input().split()))
ans = 1
d = [1] + [0]*(n-1)
for i in range(1,n):
  if (p[i] <= p[i-1] and d[i-1] == 1):
    ans += 1
    d[i] = 1
  elif (d[i-1] ==0 and min(sorted(p[:i+1])) == p[:i+1][-1]):
    ans += 1
    d[i] = 1
    
print(ans)

Fixed submission:
n = int(input())
p = list(map(int,input().split()))
ans = 0
m= 10**10

for i in range(n):
  tmp = m
  m = min(m,p[i])
  if tmp != m:
    ans += 1
    
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
p = list(map(int,input().split()))
ans = 1
 
for i in range(1,n):
  if min(sorted(p[:i+1])) == p[:i+1][-1]:
    ans += 1
    
print(ans)

Fixed submission:
n = int(input())
p = list(map(int,input().split()))
ans = 0
m= 10**10

for i in range(n):
  tmp = m
  m = min(m,p[i])
  if tmp != m:
    ans += 1
    
print(ans)

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

for i in range(n):
  count = 0
  for j in range(i+1):
    if p[i] <= p[j]:
      count += 1
  if count == i+1:
    ans += 1
    
print(ans)
  

Fixed submission:
n = int(input())
p = list(map(int,input().split()))
ans = 0
m= 10**10

for i in range(n):
  tmp = m
  m = min(m,p[i])
  if tmp != m:
    ans += 1
    
print(ans)
Buggy python submission (verdict: Runtime Error):
n=int(input())
p=tuple(map(int,input().split()))
q=tuple(map(int,input().split()))
temp=[0]*n
for i in range(0,n):
  temp[i]=i+1
from itertools import permutations
templ=list(permutations(temp,n) #長さnのtmpの順列リストを取る　どうやら昇順で取ってくれるらしい
for i in range(0,len(templ)):
  if templ[i]==p:
    a=i#そのまま大きさになる
  if templ[i]==q:
    b=i
print(abs(a-b))

Fixed submission:
n=int(input())
p=tuple(map(int,input().split()))
q=tuple(map(int,input().split()))
temp=[0]*n
for i in range(0,n):
  temp[i]=i+1
from itertools import permutations
templ=list(permutations(temp,n))#長さnのtmpの順列リストを取る　どうやら昇順で取ってくれるらし
     
for i in range(0,len(templ)):
  if templ[i]==p:
    a=i#大きさの差を取るので，ずれは問題なし
  if templ[i]==q:
    b=i
print(abs(a-b))
Buggy python submission (verdict: Time Limit Exceeded):
x = int(input())
tmp = 0

for i in range(x,10**111):
  for j in range(2,(i//2)+2):
    tmp += 1
    if i%j == 0:
      break
    elif tmp == (i//2):
      print(i)
      exit()
      

Fixed submission:
x = int(input())
tmp = 0

if x == 2:
  print(2)
  exit()
for i in range(x,10**111):
  for j in range(2,(i//2)+2):
    tmp += 1
    if i%j == 0:
      break
    elif tmp == (i//2):
      print(i)
      exit()
Buggy python submission (verdict: Runtime Error):
import math

n = int(input())
ans = 0
if n== 0:
  print(0)
  exit()
m = math.floor(math.log(n//2,5))

if n%2 == 1:
  print(0)
else:
  for j in range(1,m+1):
    ans += n//((5**j)*2)
    
    
  print(ans)

Fixed submission:
import math

n = int(input())
ans = 0
if n== 0:
  print(0)
  exit()
m = math.floor(math.log(n,5))

if n%2 == 1:
  print(0)
else:
  for j in range(1,m+1):
    ans += n//((5**j)*2)
    
    
  print(ans)

Buggy python submission (verdict: Runtime Error):
import math

n = int(input())
ans = 0
m = math.floor(math.log(n,5))

if n%2 == 1:
  print(0)
else:
  for j in range(1,m+1):
    ans += n//((5**j)*2)
    
    
  print(ans)

Fixed submission:
import math

n = int(input())
ans = 0
if n== 0:
  print(0)
  exit()
m = math.floor(math.log(n,5))

if n%2 == 1:
  print(0)
else:
  for j in range(1,m+1):
    ans += n//((5**j)*2)
    
    
  print(ans)
Buggy python submission (verdict: Runtime Error):
s = input()
l = ['SUN','MON','TUE','WED','THU','FRI','SAT'] 
 
for i in range(7):
  if l[i] == s
    print(7-i)

Fixed submission:
s =input()
l = ['SUN','MON','TUE','WED','THU','FRI','SAT'] 
 
for i in range(7):
  if l[i] == s:
    print(7-i)

Buggy python submission (verdict: Runtime Error):
s = input()
l = ['SUN','MON','TUE','WED','THU','FRI','SAT'] 

for i in rangr(7):
  if l[i] ==s
    print(7-i)

Fixed submission:
s =input()
l = ['SUN','MON','TUE','WED','THU','FRI','SAT'] 
 
for i in range(7):
  if l[i] == s:
    print(7-i)
Buggy python submission (verdict: Runtime Error):
n = int(input())
s = input()
S = ''
list = [A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z]*2

for i in range(len(s)):
  S += list[list.index('i') + n]
  
print(S)


Fixed submission:
n = int(input())
s = input()
S = ''
list = ['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z']*2
 
for i in s:
  S += list[list.index(i) + n]
  
print(S)
Buggy python submission (verdict: Runtime Error):
import itertools
import math

n = int(input())
lis = [x for x in range(1,n+1)]  #順列とる数列
xy = [list(map(int,input().split())) for i in range(n)]　#座標をメモ
permutations_lis = itertools.permutations(lis)　#順列とって
l = list(permutations_lis)#全順列のリストを作る
ans = 0

for onecase in l: 
  s = 0
  for j in range(n-1):
    s += math.sqrt((xy[onecase[j]-1][0]-xy[onecase[j+1]-1][0])**2 + (xy[onecase[j]-1][1]-xy[onecase[j+1]-1][1])**2)
  ans += s
  
print(ans/math.factorial(n))

Fixed submission:
import itertools
import math

n = int(input())
lis = [x for x in range(1,n+1)] 
xy = [list(map(int,input().split())) for i in range(n)]
permutations_lis = itertools.permutations(lis)
l = list(permutations_lis)
ans = 0

for onecase in l: 
  s = 0
  for j in range(n-1):
    s += math.sqrt((xy[onecase[j]-1][0]-xy[onecase[j+1]-1][0])**2 + (xy[onecase[j]-1][1]-xy[onecase[j+1]-1][1])**2)
  ans += s
  
print(ans/math.factorial(n))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
tmp = 1
 
for i in range(1,10**10):
  if n%i == 0:
    if i <= n//i:
      tmp  = i
    else:
      break
  elif tmp == 1 and i >= n/i:
    break
    
   
    
      
print(tmp + (n//tmp) -2)

Fixed submission:
n = int(input())
tmp = 1
 
for i in range(1,10**6+1):
  if n%i == 0 and i<= n//i:
    tmp = i
   
      
print(tmp + (n//tmp) -2)
Buggy python submission (verdict: Time Limit Exceeded):
import itertools

n = int(input())
l = list(map(int,input().split()))
count = 0

for i,j,k in itertools.combinations(l, 3):
  if i < j+k and j < i+k and k< j+i:
    count += 1
    
print(count)

Fixed submission:
n=int(input())
l=list(map(int,input().split()))
 
import bisect
 
ans=0
l.sort()
 
for i in range(n):
    a=l[i]#一番短い棒を確定
    for j in range(i+1,n):
        b=l[j]#二番目に短い棒を確定
        ind=bisect.bisect_left(l,a+b)#二辺の和と同じだったら耐えないので，left
        ans+=max(0,ind-(j+1))#三角形の成立条件と，一番長い棒であることを考える

print(ans)

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

n = int(input())
l = list(map(int,input().split()))
count = 0

for i,j,k in itertools.combinations(l, 3):
  if i < j+k and j < i+k and k< j+i:
    count += 1
    
print(count)

Fixed submission:
n=int(input())
l=list(map(int,input().split()))
 
import bisect
 
ans=0
l.sort()
 
for i in range(n):
    a=l[i]#一番短い棒を確定
    for j in range(i+1,n):
        b=l[j]#二番目に短い棒を確定
        ind=bisect.bisect_left(l,a+b)#二辺の和と同じだったら耐えないので，left
        ans+=max(0,ind-(j+1))#三角形の成立条件と，一番長い棒であることを考える

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n,k,q = map(int,input().split())
a = [input() for i in range(q)]
K = [k]*n

for i in range(q):
  tmp = a[i]
  for j in range(len(K)):
    K[j] -= 1
  K[int(tmp)-1] = K[int(tmp)-1]+1
  
for k in range(len(K)):
  if K[k] > 0:
    print("Yes")
  else:
    print("No")

Fixed submission:
n,k,q = map(int,input().split())
a = [input() for i in range(q)]
K = [k]*n
limit = 0

for i in range(q):
  tmp = a[i]
  K[int(tmp)-1] = K[int(tmp)-1]+1
  limit += 1
  
for k in range(len(K)):
  if K[k] > limit:
    print("Yes")
  else:
    print("No")
Buggy python submission (verdict: Runtime Error):
n = int(input())
 
print(int((n+1)*n/2 - n))


Fixed submission:
s = input()
t = input()
c = 0

if s[0] == t[0]:
  c += 1

if s[1] == t[1]:
  c += 1

if s[2] == t[2]:
  c += 1
    
print(c)
Buggy python submission (verdict: Runtime Error):
n = int(input())
h = list(map(int,input().split()))
c = 0
d = 0

for j in range(n-1):
  for i in range(n-1):
    if h[j+i] >= h[j+i+1]:
      c += 1
    else:
      d = max(d,c)
      c = 0
      break
      
print(d)

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

for j in range(n-1):
  if h[j] >= h[j+1]:
    c += 1
  else:
    d = max(c,d)
    c = 0

d = max(c,d)
print(d)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
sum = 0

for i in range(1,n):
  sum += i
  
print(sum)

Fixed submission:
n = int(input())
 
print(int(n*(n-1)//2))
Buggy python submission (verdict: Runtime Error):
n = int(input())
m = list(map(int,input().split()))
o = []
c  = 0
for i in m:
  o.append(1/m[c])
  c += 1
s = sum(o)
print(1/s)

Fixed submission:
a = int(input())
s = input()
if a >=3200:
  print(s)
else:
  print("red")

Buggy python submission (verdict: Runtime Error):
n = int(input())
m = list(map(int,input().split()))
o = []
c  = 0
for i in m:
  o.append(1/m[c])
  c += 1
s = sum(o)
print(1/s)

Fixed submission:
a = int(input())
s = input()
if a >=3200:
  print(s)
else:
  print("red")

Buggy python submission (verdict: Runtime Error):
n = int(input())
m = list(map(int,input().split()))
o = []
for i in m:
  o.append(float(1/m[i]))
p = sum(o) 
print(1/p)

Fixed submission:
a = int(input())
s = input()
if a >=3200:
  print(s)
else:
  print("red")

Buggy python submission (verdict: Runtime Error):
n = int(input())
m = list(map(int,input().split()))
o = []
for i in m:
  o.append(float(1/a[i]))
p = sum(o) 
print(1/p)

Fixed submission:
a = int(input())
s = input()
if a >=3200:
  print(s)
else:
  print("red")
Buggy python submission (verdict: Runtime Error):
n = int(input())
m = list(map(int,input().split()))
o = []
for i in m:
  o.append(1/a[i])
p = sum(o) 
print(1/p)

Fixed submission:
n = int(input())
m = list(map(int,input().split()))
o = []
c  = 0
for i in m:
  o.append(1/m[c])
  c += 1
s = sum(o)
print(1/s)
Buggy python submission (verdict: Runtime Error):
a = input()
b = int(a[0]) + int(a[2])
c = int(a[0]) - int(a[2])
d = int(a[0]) * int(a[2])
if b >= c and b >= d:
  print(b)
elif c >= b and c >= d:
  print(c)
else:
  print(d)

Fixed submission:
a,b = map(int,input().split())
print(max(a+b,a-b,a*b))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = [input() for i in range(n)]
c = 0
 
for i in range(n-1):
  S1 = sorted(s[i])
  for j in range(i+1,n):
    if S1 == sorted(s[j]):
      c += 1
 
print(c)

Fixed submission:
n = int(input())
s = [input() for i in range(n)]
d = {}
c = 0

for i in s:
  tmp = "".join(sorted(i))
  if tmp not in d:
    d[tmp] = 0
  else:
    d[tmp] += 1
  c += d[tmp]
  
print(c)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = [input() for i in range(n)]
c = 0

for i in range(n-1):
  for j in range(i+1,n):
    if sorted(s[i]) == sorted(s[j]):
      c += 1

print(c)

Fixed submission:
n = int(input())
s = [input() for i in range(n)]
d = {}
c = 0

for i in s:
  tmp = "".join(sorted(i))
  if tmp not in d:
    d[tmp] = 0
  else:
    d[tmp] += 1
  c += d[tmp]
  
print(c)
Buggy python submission (verdict: Runtime Error):
n = int(input())
h = list(map(int,input().split()))
submax = 0

for i in range(n-1):
  for j in range(i+1,n):
    if h[i] - h[j] >= 2:
      submax = 1
      break
  if submax == 1:
    break

if submax == 1:
  print("No")
else:
  print("Yes")

Fixed submission:
a,b,c = map(int,input().split())
yoyuu = a-b
nokori = c- yoyuu

if nokori < 0:
  print(0)
else:
  print(nokori)
Buggy python submission (verdict: Runtime Error):
n = input()
l = []
for i in range(1,int(n)+1):
  if len(i)%2 != 0:
    l.append(i)

print(len(l))

Fixed submission:
n = input()
l = []
for i in range(1,int(n)+1):
  if len(str(i))%2 != 0:
    l.append(i)

print(len(l))
Buggy python submission (verdict: Runtime Error):
n = int(input())
p = list(map(int,input().split()))
N = list(range(1,n+1))
c = []
a = 0
for i in N:
  if N[i-1] != p[i-1]:
    a += 1
if a == 2 or a==0:
  print("YES")
else:
  print("NO")

Fixed submission:
a,b = map(int,input().split())
ans = (a+b)/2
 
if ans == int(ans):
  print(int(ans))
else:
  print('IMPOSSIBLE')
Buggy python submission (verdict: Runtime Error):
n = int(input())
p = list(map(int,input().split()))
N = list(range(1,n+1))
for i in N:
  if N[i-1] != p[i-1]:
    j = i
    break
if N[p[i-1]] == p[i-1]:
  print("YES")
else:
  print("NO")

Fixed submission:
n = int(input())
p = list(map(int,input().split()))
N = list(range(1,n+1))
c = []
a = 0
for i in N:
  if N[i-1] != p[i-1]:
    a += 1
if a == 2 or a==0:
  print("YES")
else:
  print("NO")

Buggy python submission (verdict: Runtime Error):
n = int(input())
p = list(map(int,input().split()))
N = list(range(1,n+1))
for i in N:
  if N[i-1] != p[i-1]:
    break
if N[p[i-1]] == p[i-1]:
  print("YES")
else:
  print("NO")

Fixed submission:
n = int(input())
p = list(map(int,input().split()))
N = list(range(1,n+1))
c = []
a = 0
for i in N:
  if N[i-1] != p[i-1]:
    a += 1
if a == 2 or a==0:
  print("YES")
else:
  print("NO")

Buggy python submission (verdict: Runtime Error):
n = int(input())
p = list(map(int,input().split()))
N = list(range(1,n+1))
for i in N:
  if N[i-1] != p[i-1]:
    break
if N[i-1] == p[N[i-1]]:
  print("YES")
else:
  print("NO")

Fixed submission:
n = int(input())
p = list(map(int,input().split()))
N = list(range(1,n+1))
c = []
a = 0
for i in N:
  if N[i-1] != p[i-1]:
    a += 1
if a == 2 or a==0:
  print("YES")
else:
  print("NO")
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
c = 0

for i in range(n):
  c += min(a[i],b[i])
  tmp = min(a[i+1],b[i]-min(a[i],b[i]))
  c += tmp
  if tmp == a[i+1]:
    del a[i+1]
    a.insert(i+1,0)
  else:
    del a[i+1]
    a.insert(i+1,a[i+1]+a[i]-b[i])

print(c)

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

for i in range(n):
  if a[i] >= b[i]:
    c += b[i]
  else:
    c += a[i]
    c += min(a[i+1],b[i]-a[i])
    if a[i+1] >= b[i]-a[i]:
      a[i+1] = a[i+1] - (b[i] - a[i])
    else:
      a[i+1] = 0
     
print(c)
Buggy python submission (verdict: Runtime Error):
n,d = map(int,input().split())
w = [list(map(int,input().split())) for a in range(n)]
c = 0
 
for i in range(n-1):
  for j in range(i+1,n+1):
    b = 0
    for m in range(d):
      b += (w[i][m]-w[j][m])**2
    if (b**0.5)　== float(int(b**0.5)):
      c += 1
      
print(c)

Fixed submission:
n,a,b = map(int,input().split())
print(min(a*n,b))

Buggy python submission (verdict: Runtime Error):
n,d = map(int,input().split())
x = [list(map(int,input().split())) for a in range(n)]
c = 0
 
for i in range(n-1):
  for j in range(i+1,n):
    b = 0
    for m in range(d):
      b += (x[i][m])-x[j][m])**2
    if (b**0.5)　== float(int(b**0.5)):
      c += 1
      
print(c)

Fixed submission:
n,a,b = map(int,input().split())
print(min(a*n,b))

Buggy python submission (verdict: Runtime Error):
n,d = map(int,input().split())
x = [list(map(int,input().split())) for a in range(n)]
c = 0
 
for i in range(n-1):
  for j in range(i+1,n+1):
    b = 0
    for m in range(d):
      b += (int(x[i][m])-int(x[j][m]))**2
    if (b**0.5)　== float(int(b**0.5)):
      c += 1
      
print(c)

Fixed submission:
n,a,b = map(int,input().split())
print(min(a*n,b))

Buggy python submission (verdict: Runtime Error):
n,d = map(int,input().split())
x = [list(map(int,input().split())) for a in range(n)]
c = 0
 
for i in range(n-1):
  for j in range(i+1,n+1):
    b = 0
    for m in range(d):
      b += (int(x[i][m])-int(x[j][m]))**2
    if (b**0.5)　== float(int(b**0.5)):
      c += 1
      
print(c)

Fixed submission:
n,a,b = map(int,input().split())
print(min(a*n,b))
Buggy python submission (verdict: Runtime Error):
n,l = map(int,input().split())
li = []
for i in range(1,n+1):
  li.append(abs(l+i-1))
m = min(li)
if l+i-1 >= 0:
  print(int((n*(l-1)+(n*(n+1)/2)-l-i+1)))
else:
  print(int((n*(l-1)+(n*(n+1)/2)+l+i-1)))

Fixed submission:
s = input()
for i in range(3):
  if s[i] == s[i+1]:
    print('Bad')
    exit()
    
print('Good')
Buggy python submission (verdict: Time Limit Exceeded):
a,b,c,d = map(int,input().split())
tmp = 0

for i in range(a,b+1):
  if i%c != 0 and i%d != 0:
    tmp += 1
    
print(tmp)

Fixed submission:
from fractions import gcd
a,b,c,d = map(int,input().split())
e = (c*d)//gcd(c,d)

print((b-a+1) - (b//c - (a-1)//c) - (b//d - (a-1)//d) + (b//e - (a-1)//e))
Buggy python submission (verdict: Runtime Error):
n,x = map(int,input().split())
l = list(map(int,input().split()))
c = 1
D = 0
li = []
for i in range(1,n+1):
  D += l[i]
  if D <= x:
    c += 1
print(c)

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

if x<a:
  print(0)
else:
  print(10)