Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
ss=input()
l=[["R","G","B"],["R","B","G"],["G","R","B"],["G","B","R"],["B","R","G"],["B","G","R"]]
ans=0
for v in l:
    for i in range(n-2):
        if ss[i]==v[0]:
            for k in range(i+1,n-1):
                if ss[k]==v[1]:
                    ans+=ss[k+1:].count(v[2])
                    if (k+k-i <=n-1) and ss[k+k-i]==v[2]:
                        ans-=1
print(ans)

Fixed submission:
n=int(input())
s=input()
ans=s.count("R")*s.count("G")*s.count("B")  # 第１条件の全事象
for i in range(n-2):
    for j in range(i+1,n-1):
        k=j+j-i
        if k<n and s[k]!=s[i] and s[k]!=s[j] and s[i]!=s[j]: # 第1条件 かつ not第２条件
            ans-=1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
ss=input()
l=[["R","G","B"],["R","B","G"],["G","R","B"],["G","B","R"],["B","R","G"],["B","G","R"]]
ans=0
for v in l:
    for i in range(n-2):
        if ss[i]==v[0]:
            for k in range(i+1,n-1):
                if ss[k]==v[1]:
                    ans+=ss[k+1:].count(v[2])
                    if (k+k-i <=n-1) and ss[k+k-i]==v[2]:
                        ans-=1
print(ans)

Fixed submission:
n=int(input())
s=input()
ans=s.count("R")*s.count("G")*s.count("B")  # 第１条件の全事象
for i in range(n-2):
    for j in range(i+1,n-1):
        k=j+j-i
        if k<n and s[k]!=s[i] and s[k]!=s[j] and s[i]!=s[j]: # 第1条件 かつ not第２条件
            ans-=1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import itertools
n=int(input())
ss=input()
l=["R","G","B"]
ans=0
for v in itertools.permutations(l, 3):
    for i in range(n-2):
        if ss[i]==v[0]:
            for k in range(i+1,n-1):
                if ss[k]==v[1]:
                    ans+=ss[k+1:].count(v[2])
                    if (k+k-i <=n-1) and ss[k+k-i]==v[2]:
                        ans-=1
print(ans)

Fixed submission:
n=int(input())
s=input()
ans=s.count("R")*s.count("G")*s.count("B")  # 第１条件の全事象
for i in range(n-2):
    for j in range(i+1,n-1):
        k=j+j-i
        if k<n and s[k]!=s[i] and s[k]!=s[j] and s[i]!=s[j]: # 第1条件 かつ not第２条件
            ans-=1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import itertools
n=int(input())
ss=input()
l=["R","G","B"]
ans=0
for v in itertools.permutations(l, 3):
    for i in range(n-2):
        if ss[i]==v[0]:
            for k in range(i+1,n-1):
                if ss[k]==v[1]:
                    for p in range(k+1,n):
                        if (k-i!=p-k) and ss[p]==v[2]:
                            ans+=1
print(ans)

Fixed submission:
n=int(input())
s=input()
ans=s.count("R")*s.count("G")*s.count("B")  # 第１条件の全事象
for i in range(n-2):
    for j in range(i+1,n-1):
        k=j+j-i
        if k<n and s[k]!=s[i] and s[k]!=s[j] and s[i]!=s[j]: # 第1条件 かつ not第２条件
            ans-=1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n,k=map(int,input().split())
while n>k:
    n=abs(n-k)
print(n if abs(n-k)>n else abs(n-k))

Fixed submission:
n,k=map(int,input().split())
n=n%k
print(n if abs(n-k)>n else abs(n-k))
Buggy python submission (verdict: Runtime Error):
from scipy.special import comb
n,m=map(int,input().split())
print(int(comb(n+m,2)-n*m))

Fixed submission:
import math
n,m=map(int,input().split())
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
print(combinations_count(n+m,2)-n*m)
Buggy python submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
ans=0
b=[0]*n
for i in range(n):
    b[a[i]]+=1
for k in b:
    ans+=k*(k-1)//2
for i in range(n):
    print(ans-b[a[i]]+1)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
ans=0
b=[0]*(n+1)
for i in range(n):
    b[a[i]]+=1
for k in b:
    ans+=k*(k-1)//2
for i in range(n):
    print(ans-b[a[i]]+1)

Buggy python submission (verdict: Time Limit Exceeded):
import math
import collections
n=int(input())
a=list(map(int,input().split()))
for i in a:
    c=collections.Counter(a)
    ans=0
    c[i] -=1
    for k in c.values():
        if k != 1:
            ans +=k*(k-1)//2
    print(ans)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
ans=0
b=[0]*(n+1)
for i in range(n):
    b[a[i]]+=1
for k in b:
    ans+=k*(k-1)//2
for i in range(n):
    print(ans-b[a[i]]+1)

Buggy python submission (verdict: Runtime Error):
import math
import collections
n=int(input())
a=list(map(int,input().split()))
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
for i in a:
    c=collections.Counter(a)
    ans=0
    c[i] -=1
    for k in c.values():
        if k != 1:
            ans +=combinations_count(k,2)
    print(ans)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
ans=0
b=[0]*(n+1)
for i in range(n):
    b[a[i]]+=1
for k in b:
    ans+=k*(k-1)//2
for i in range(n):
    print(ans-b[a[i]]+1)

Buggy python submission (verdict: Time Limit Exceeded):
import math
n=int(input())
a=list(map(int,input().split()))
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

for i in range(n):
    ans=0
    a1=a.copy()
    del a1[i]
    for k in  set(a1):
        if a1.count(k) != 1:
            ans+=combinations_count(a1.count(k),2)
    print(ans)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
ans=0
b=[0]*(n+1)
for i in range(n):
    b[a[i]]+=1
for k in b:
    ans+=k*(k-1)//2
for i in range(n):
    print(ans-b[a[i]]+1)
Buggy python submission (verdict: Runtime Error):
import sympy
a,b,c=map(int,input().split())
if a+b+sympy.sqrt(4*a*b)<c:
    print("Yes")
else:
    print("No")

Fixed submission:
from decimal import *
import math
a,b,c=map(int,input().split())
if a+b+(4*Decimal(a)*Decimal(b))**Decimal("0.5")<c:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
s_c=[list(map(str,input().split())) for _ in range(m)]

ans=["0"]*n
for i in s_c:
    ans[int(i[0])-1]=i[1]

if m>1:
    for i in range(m-1):
        for k in range(i+1,m):
            if s_c[i][0]==s_c[k][0] and s_c[i][1]!=s_c[k][1]:
                ans = -1
                break

if n>1:
    if ["1","0"] in s_c:
        ans = -1
    if ans[0]=="0":
        ans=-1

print(int("".join(ans)) if ans != -1 else -1)

Fixed submission:
n,m=map(int,input().split())
sc=[list(map(int,input().split())) for _ in range(m)]
ans=-1
for i in range(10**3):
    if (len(str(i))==n):
        flag=1
        for s,c in sc:
            if str(i)[s-1] != str(c):
                flag=0
        if flag==1:
            ans =i
            break
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n,a,b=map(int,input().split())

from operator import mul
from functools import reduce
def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

ab=cmb(n,a)+cmb(n,b)

cnt=0
nCr=1
for r in range(n):
    nCr_1 = nCr * (n - r) // (r + 1)
    nCr = nCr_1
    cnt+=nCr_1
print(cnt-ab)

Fixed submission:
n, a, b = map(int, input().split())
mod = 10**9 + 7
 
 
def nCr(n, r, mod):
    r = min(r, n-r)
    numer = denom = 1
    for i in range(1, r+1):
        numer = numer * (n+1-i) % mod
        denom = denom * i % mod
    return numer * pow(denom, mod-2, mod) % mod
 
 
print((pow(2, n, mod)-1-nCr(n, a, mod)-nCr(n, b, mod)) % mod)

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

from operator import mul
from functools import reduce
def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

ab=cmb(n,a)+cmb(n,b)

cnt=0
nCr=1
for r in range(n):
    nCr_1 = nCr * (n - r) // (r + 1)
    nCr = nCr_1
    cnt+=nCr_1
print(cnt-ab)

Fixed submission:
n, a, b = map(int, input().split())
mod = 10**9 + 7
 
 
def nCr(n, r, mod):
    r = min(r, n-r)
    numer = denom = 1
    for i in range(1, r+1):
        numer = numer * (n+1-i) % mod
        denom = denom * i % mod
    return numer * pow(denom, mod-2, mod) % mod
 
 
print((pow(2, n, mod)-1-nCr(n, a, mod)-nCr(n, b, mod)) % mod)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
n=int(input())
s=[input() for _ in range(n)]
d=Counter(s)
keys = [k for k,v in d.items() if v==max(d.values())]
print("\n".join(sorted(keys)))

Fixed submission:
from collections import Counter
n=int(input())
s=[input() for _ in range(n)]
d=Counter(s)
m=max(d.values())
keys = [k for k,v in d.items() if v==m]
print("\n".join(sorted(keys)))

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
d=dict()
for _ in range(n):
    a=input()
    if a in d:
        d[a]+=1
    else:
        d[a]=1
keys = [k for k,v in d.items() if v==max(d.values())]
print("\n".join(sorted(keys)))

Fixed submission:
from collections import Counter
n=int(input())
s=[input() for _ in range(n)]
d=Counter(s)
m=max(d.values())
keys = [k for k,v in d.items() if v==m]
print("\n".join(sorted(keys)))

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
d=dict()
for _ in range(n):
    a=input()
    if a in d:
        d[a]+=1
    else:
        d[a]=1
keys = sorted([k for k,v in d.items() if v==max(d.values())])
print("\n".join(keys))

Fixed submission:
from collections import Counter
n=int(input())
s=[input() for _ in range(n)]
d=Counter(s)
m=max(d.values())
keys = [k for k,v in d.items() if v==m]
print("\n".join(sorted(keys)))
Buggy python submission (verdict: Time Limit Exceeded):
n,k=map(int,input().split())
p=list(map(int,input().split()))
a=0

q=[sum(p[i:i+k]) for i in range(n-k+1)]

print((k+max(q))/2)

Fixed submission:
n,k=map(int,input().split())
p=list(map(int,input().split()))
a=0
for i in range(n-k+1):
    if i==0:
        xe=sum(p[0:k])
    else:
        xe=xe-p[i-1]+p[i+k-1]
    a=max(a,xe)
print((k+a)/2)

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

for i in range(n-k+1):
    a=max(a,sum(p[i:i+k]))

print((k+a)/2)

Fixed submission:
n,k=map(int,input().split())
p=list(map(int,input().split()))
a=0
for i in range(n-k+1):
    if i==0:
        xe=sum(p[0:k])
    else:
        xe=xe-p[i-1]+p[i+k-1]
    a=max(a,xe)
print((k+a)/2)

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

for i in range(n-k+1):
    if sum(p[i:i+k]) >= a:
        a=sum(p[i:i+k]) 
        b=i

print((k+a)/2)

Fixed submission:
n,k=map(int,input().split())
p=list(map(int,input().split()))
a=0
for i in range(n-k+1):
    if i==0:
        xe=sum(p[0:k])
    else:
        xe=xe-p[i-1]+p[i+k-1]
    a=max(a,xe)
print((k+a)/2)

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

for i in range(n-k+1):
    if sum(p[i:i+k]) >= a:
        a=sum(p[i:i+k]) 
        b=i

print(sum([(k+1)/2 for k in p[b:b+k]]))

Fixed submission:
n,k=map(int,input().split())
p=list(map(int,input().split()))
a=0
for i in range(n-k+1):
    if i==0:
        xe=sum(p[0:k])
    else:
        xe=xe-p[i-1]+p[i+k-1]
    a=max(a,xe)
print((k+a)/2)

Buggy python submission (verdict: Time Limit Exceeded):
n,k=map(int,input().split())
p=list(map(int,input().split()))
a=0
b=sum(p)/len(p)

for i in range(n-k+1):
    if sum(p[i:i+k])/k >= b:
        a = max(a,sum([(k+1)/2 for k in p[i:i+k]]))
print(a)

Fixed submission:
n,k=map(int,input().split())
p=list(map(int,input().split()))
a=0
for i in range(n-k+1):
    if i==0:
        xe=sum(p[0:k])
    else:
        xe=xe-p[i-1]+p[i+k-1]
    a=max(a,xe)
print((k+a)/2)

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

for i in range(n-k+1):
    a = max(a,sum([(k+1)/2 for k in p[i:i+k]]))

print(a)

Fixed submission:
n,k=map(int,input().split())
p=list(map(int,input().split()))
a=0
for i in range(n-k+1):
    if i==0:
        xe=sum(p[0:k])
    else:
        xe=xe-p[i-1]+p[i+k-1]
    a=max(a,xe)
print((k+a)/2)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
p=list(map(int,input().split()))
ans=0
for i in range(n):
    if p[i]==min(p[:i+1]):
        ans+=1
print(ans)

Fixed submission:
n=int(input())
p=list(map(int,input().split()))
ans=1
a=p[0]
for i in range(1,n):
    if p[i] <= a:
        ans+=1
        a=p[i]
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
l=sorted([list(map(int,input().split())) for _ in range(n)])
c=0
x=[0]*n

def d_min(a,b):
    return a-b
def d_max(a,b):
    return a+b

for i in range(n-1):
    if x[i] != 0:
        continue
    for k in range(1,n-i):
        if d_max(*l[i]) > d_min(*l[i+k]):
            c+=1
            x[i+1]+=1
print(n-c)

Fixed submission:
n=int(input())
r=[]
cnt=1

for _ in range(n):
    x,l=map(int,input().split())
    s=x-l
    t=x+l
    r.append([s,t])
    
r=sorted(r,key=lambda x: x[1])
t0=r[0][1]

for s,t in r[1:]:
    if t0<=s:
        cnt+=1
        t0=t

print(cnt)
Buggy python submission (verdict: Runtime Error):
n,m = map(int,input().split())
a=[0]*n
w=[0]*n
ac=0
wa=0
for _ in range(m):
    p,s=input().split()
    p=int(p)-1
    if a[p]==0:
        if s=="AC":
            a[p]=1
            ac+=1
            wc+=w[p]
        else:
            w[p]+=1
print(ac,wc)

Fixed submission:
n,m = map(int,input().split())
a=[0]*n
w=[0]*n
ac=0
wc=0
for _ in range(m):
    p,s=input().split()
    p=int(p)-1
    if a[p]==0:
        if s=="AC":
            a[p]=1
            ac+=1
            wc+=w[p]
        else:
            w[p]+=1
print(ac,wc)
Buggy python submission (verdict: Runtime Error):
import math
try:
    A,B = map(int,input().split())
    def lcm(x, y):
        return (x * y) // math.gcd(x, y)
    print(lcm(A,B))
except EOFError:
    pass

Fixed submission:
import fractions
try:
    A,B = map(int,input().split())
    def lcm(x, y):
        return (x * y) // fractions.gcd(x, y)
    print(lcm(A,B))
except EOFError:
    pass

Buggy python submission (verdict: Runtime Error):
import math
A,B = map(int,input().split())
def lcm(x, y):
    return (x * y) // math.gcd(x, y)
print(lcm(A,B))

Fixed submission:
import fractions
try:
    A,B = map(int,input().split())
    def lcm(x, y):
        return (x * y) // fractions.gcd(x, y)
    print(lcm(A,B))
except EOFError:
    pass
Buggy python submission (verdict: Runtime Error):
N = int(input())
l = (map(int,input().split()))
num = len(l)
l_first = min(l)
l_min = min(l)
x = l.index(l_min)

for _ in range(N):
    l = l[x:]
    if l_min+1 in l:
        l_min +=1
        x = l.index(l_min)
    else:
        break

if l_first == l_min:
    print(-1)
else:
    print(num-(l_min-l_first+1))

Fixed submission:
N = int(input())
l = list(map(int,input().split()))
a = 1
for i in l:
    if a == i:
        a += 1
if a == 1:
    print(-1)
else:
    print(N-a+1)
Buggy python submission (verdict: Time Limit Exceeded):
import itertools
n=int(input())
s=input()
p = itertools.combinations(range(n),3)
l=[]
for a,b,c in p:
    x=s[a]+s[b]+s[c]
    l.append(x)
print(len(set(l)))

Fixed submission:
n=int(input())
s=input()
ans=0
for i in range(1000):
    num=str(i).zfill(3)
    if s.find(num[0])==-1:
        continue
    s1=s[s.find(num[0])+1:]
    if s1.find(num[1])==-1:
        continue
    s2=s1[s1.find(num[1])+1:]
    if s2.find(num[2])==-1:
        continue
    ans+=1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
s=input()
l=[]
for i in range(n-2):
    for k in range(i+1,n-1):
        for j in list(set(s[k+1:])):
            l.append(s[i]+s[k]+j)
print(len(set(l)))

Fixed submission:
n=int(input())
s=input()
ans=0
for i in range(1000):
    num=str(i).zfill(3)
    if s.find(num[0])==-1:
        continue
    s1=s[s.find(num[0])+1:]
    if s1.find(num[1])==-1:
        continue
    s2=s1[s1.find(num[1])+1:]
    if s2.find(num[2])==-1:
        continue
    ans+=1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
s=input()
l=[]
for i in range(n-2):
    for k in range(i+1,n-1):
        for j in list(set(s[k+1:])):
            l.append(s[i]+s[k]+j)
print(len(set(l)))

Fixed submission:
n=int(input())
s=input()
ans=0
for i in range(1000):
    num=str(i).zfill(3)
    if s.find(num[0])==-1:
        continue
    s1=s[s.find(num[0])+1:]
    if s1.find(num[1])==-1:
        continue
    s2=s1[s1.find(num[1])+1:]
    if s2.find(num[2])==-1:
        continue
    ans+=1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
s=input()
l=[]
for i in range(n-2):
    for k in range(i+1,n-1):
        for j in range(k+1,n):
            l.append(s[i]+s[k]+s[j])
print(len(set(l)))

Fixed submission:
n=int(input())
s=input()
ans=0
for i in range(1000):
    num=str(i).zfill(3)
    if s.find(num[0])==-1:
        continue
    s1=s[s.find(num[0])+1:]
    if s1.find(num[1])==-1:
        continue
    s2=s1[s1.find(num[1])+1:]
    if s2.find(num[2])==-1:
        continue
    ans+=1
print(ans)
Buggy python submission (verdict: Runtime Error):
import bisect
N = input()
L_list = list(map(int,input().split()))
L_list.sort()
ans = 0

for i in range(N-1):
  for j in range(i+1,N-1):
    x = bisect.bisect_left(L_list,L_list[i]+L_list[j])
    ans += x-j-1
print(ans)

Fixed submission:
import bisect
N = int(input())
L_list = list(map(int,input().split()))
L_list.sort()
ans = 0

for i in range(N-1):
  for j in range(i+1,N-1):
    x = bisect.bisect_left(L_list,L_list[i]+L_list[j])
    ans += x-j-1
print(ans)

Buggy python submission (verdict: Runtime Error):
import bisect
N = input()
L_list = list(map(int,input().split()))
ans = 0

for i in range(N-1):
  for j in range(i+1,N-1):
    x = bisect.bisect_left(L_list,L_list[i]+L_list[j])
    ans += x-j-1
print(ans)

Fixed submission:
import bisect
N = int(input())
L_list = list(map(int,input().split()))
L_list.sort()
ans = 0

for i in range(N-1):
  for j in range(i+1,N-1):
    x = bisect.bisect_left(L_list,L_list[i]+L_list[j])
    ans += x-j-1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import itertools
 
N = input()
l_list = list(map(int,input().split()))
ans = 0
 
for v in itertools.combinations(l_list, 3):
  v = sorted(v,reverse=True)
  max_len = v[0]
  lens = v[1:]
  if max_len < sum(lens):
    ans += 1

print(ans)

Fixed submission:
import bisect
N = int(input())
L_list = list(map(int,input().split()))
L_list.sort()
ans = 0

for i in range(N-1):
  for j in range(i+1,N-1):
    x = bisect.bisect_left(L_list,L_list[i]+L_list[j])
    ans += x-j-1
print(ans)
Buggy python submission (verdict: Runtime Error):
S = str(input())
dic_wet = {1:"Sunny",2:"Cloudy",3:"Rainy"}
for k , v in dic_wet.items():
    if v == S:
        print(dic_wet[(k+1) % 3])

Fixed submission:
S = str(input())
L = ["Sunny","Cloudy","Rainy"]
print(L[(L.index(S)+1)%3])

Buggy python submission (verdict: Runtime Error):
S = str(input())
dic_wet = {1:"Sunny",2:"Cloudy",3:"Rainy"}
for k , v in dic_wet.items():
    if v == S:
        print(dic_wet[(k+1) % 3])

Fixed submission:
S = str(input())
L = ["Sunny","Cloudy","Rainy"]
print(L[(L.index(S)+1)%3])
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
s=[input() for _ in range(n)]
s=["".join(sorted(i)) for i in s]
cnt=0
for i in range(n):
    cnt+=s[i+1:].count(s[i])
print(cnt)

Fixed submission:
n=int(input())
d=dict()
for i in range(n):
    s="".join(sorted(input()))
    if s in d:
        d[s]+=1
    else:
        d[s]=1
ans=0
for k in d.values():
    ans+=k*(k-1)//2
print(ans)
Buggy python submission (verdict: Runtime Error):

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

if sorted(p_list) == p_list:
    print("YES")
    sys.exit()

sum = 0
    
for i,j in zip(p_list,sorted(p_list)):
    if i != j:
        sum += 1

if sum == 2:
    print("YES")
else:
    print("NO")

Fixed submission:
import sys

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

try:

    if sorted(p_list) == p_list:
        print("YES")
        sys.exit()

    sum = 0

    for i,j in zip(p_list,sorted(p_list)):
        if i != j:
            sum += 1

    if sum == 2:
        print("YES")
    else:
        print("NO")

except EOFError:
    pass
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [int(input()) for _ in range(N)]
A_max = max(A)
for i in range(N):
    if A[i] != A_max:
        print(A_max)
    else:
        B = A.copy()
        del B[i]
        print(max(B))

Fixed submission:
N = int(input())
A = [int(input()) for _ in range(N)]
B = sorted(A,reverse=True)
for i in range(N):
    if A[i] == B[0]:
        print(B[1])
    else:
        print(B[0])

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [int(input()) for _ in range(N)]
A_max = max(A)
for i in range(N):
    if A[i] != max(A):
        print(max(A))
    else:
        B = A.copy()
        del B[i]
        print(max(B))

Fixed submission:
N = int(input())
A = [int(input()) for _ in range(N)]
B = sorted(A,reverse=True)
for i in range(N):
    if A[i] == B[0]:
        print(B[1])
    else:
        print(B[0])

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [int(input()) for _ in range(N)]
for i in range(N):
    B = A.copy()
    del B[i]
    print(max(B))
    del B

Fixed submission:
N = int(input())
A = [int(input()) for _ in range(N)]
B = sorted(A,reverse=True)
for i in range(N):
    if A[i] == B[0]:
        print(B[1])
    else:
        print(B[0])

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [int(input()) for _ in range(N)]
for i in range(N):
    B = A.copy()
    del B[i]
    print(max(B))

Fixed submission:
N = int(input())
A = [int(input()) for _ in range(N)]
B = sorted(A,reverse=True)
for i in range(N):
    if A[i] == B[0]:
        print(B[1])
    else:
        print(B[0])
Buggy python submission (verdict: Runtime Error):
n=int(input())
a=sorted(list(map(int,input(.split()))))
p=a[n//2-1]
q=a[n//2]
print(q-p)

Fixed submission:
k=int(input())
d=sorted(list(map(int,input().split())))
ans=0
for i in range(d[int(len(d)/2)-1]+1,d[int(len(d)/2)]+1):
    ans+=1
print(ans)
Buggy python submission (verdict: Runtime Error):
N,L = map(int,input().split())
l = list(map(lambda x : L+x+1 , range(1,N+1)))
print(sum(l)-min(l,key=min))

Fixed submission:
N,L = map(int,input().split())
l = list(map(lambda x : L+x-1 , range(1,N+1)))
print(sum(l)-min(l,key=abs))

Buggy python submission (verdict: Runtime Error):
N,L = map(int,input().split())
a_list = []
for i in range(N):
    diff = abs(((L-1)*(N-1)-i))
    a_list.append(diff)
    
print(sum(list(N+1))-((L-1)*(N-1) - min(a_list)))

Fixed submission:
N,L = map(int,input().split())
l = list(map(lambda x : L+x-1 , range(1,N+1)))
print(sum(l)-min(l,key=abs))
Buggy python submission (verdict: Runtime Error):
print(180*(int(input()-2))

Fixed submission:
print(180*(int(input())-2))

Buggy python submission (verdict: Runtime Error):
print(180*(n-2))

Fixed submission:
print(180*(int(input())-2))
Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
l=[list(map(int,input().split())) for _ in range(m)]
ans=0
for i in range(1,N+1):
    if all([i in range(l[k][0],l[k][1]+1) for k in range(m)]):
        ans+=1
print(ans)

Fixed submission:
n,m=map(int,input().split())
l=[list(map(int,input().split())) for _ in range(m)]
a=0
z=10**5
for i in range(m):
    a=max(a,l[i][0])
    z=min(z,l[i][1])
if a<=z:
    print(z-a+1)
else:
    print(0)

Buggy python submission (verdict: Time Limit Exceeded):
n,m=map(int,input().split())
l=[list(map(int,input().split())) for _ in range(m)]
ans=0
for i in range(l[0][0],l[0][1]+1):
    if all([i in range(l[k][0],l[k][1]+1) for k in range(1,m)]):
        ans+=1
print(ans)

Fixed submission:
n,m=map(int,input().split())
l=[list(map(int,input().split())) for _ in range(m)]
a=0
z=10**5
for i in range(m):
    a=max(a,l[i][0])
    z=min(z,l[i][1])
if a<=z:
    print(z-a+1)
else:
    print(0)