Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
n,k=map(int,input().split())
H=list(map(int,input().split()))
H.sort()
H.reverse()
for i in range(k):
    if len(H)>0:
        H.pop(0)
print(sum(H))

Fixed submission:
n,k=map(int,input().split())
H=list(map(int,input().split()))
H.sort()
if n>k:
    for i in range(k):
        H.pop(n-i-1)
    ans=sum(H)
else:
    ans=0
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):
    if P[i] == min(P[0:i+1]):
        ans += 1
        
print(ans)

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

num = 2*10**5+1
ans = 0
for i in range(n):
    if P[i] <= num:
        num = P[i]
        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):
        if P[i] <= P[j]:
            count += 1
    if count == i:
        ans += 1
        
print(ans)

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

num = 2*10**5+1
ans = 0
for i in range(n):
    if P[i] <= num:
        num = P[i]
        ans += 1
        
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
p=map(int,input().split())
p_list=list(p)
n_list=[]
for j in range(n):
    for i in range(j,n):
        if p_list[i]<=p_list[j]:
            n_list.append(i)
count=0
for i in range(n):
    if i+1==n_list.count(i):
        count+=1
print(count)

            

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

num = 2*10**5+1
ans = 0
for i in range(n):
    if P[i] <= num:
        num = P[i]
        ans += 1
        
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n,k,q=map(int,input().split())
A=[int(input()) for i in range(q)]

for i in range(n):
    a=A.count(i+1)
    ans=k-q+a
    if ans>0:
        print("Yes")
    else:
        print("No")

Fixed submission:
n,k,q=map(int,input().split())
A=[int(input()) for i in range(q)]
li=[k-q for i in range(n)]
for i in range(q):
    li[A[i]-1]=li[A[i]-1]+1
for i in range(n):
    if li[i]>0:
        print("Yes")
    else:
        print("No")

Buggy python submission (verdict: Time Limit Exceeded):
n,k,q=map(int,input().split())
A=[int(input()) for i in range(q)]
li=[k for i in range(n)]
for i in range(q):
    for j in range(n):
        if A[i]!=j+1:
            li[j]=li[j]-1
for i in range(n):
    if li[i]>0:
        print("Yes")
    else:
        print("No")

Fixed submission:
n,k,q=map(int,input().split())
A=[int(input()) for i in range(q)]
li=[k-q for i in range(n)]
for i in range(q):
    li[A[i]-1]=li[A[i]-1]+1
for i in range(n):
    if li[i]>0:
        print("Yes")
    else:
        print("No")
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
A=[]
for i in range(n):
    a=int(input())
    A.append(a)
M=max(A)
for i in range(n):
    if A[i]!=M:
        print(M)
    else:
        b=A.pop(i)
        print(max(A))
        A.insert(i,b)

Fixed submission:
n = int(input())
A = [int(input()) for i in range(n)]

M = max(A)
ind = A.index(M)
A[ind] = 0
M2 = max(A)


if M in A:
    for i in range(n):
        print(M)
else:
    for i in range(n):
        if A[i] == 0:
            print(M2)
        else:
            print(M)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
A=[]
for i in range(n):
    a=int(input())
    A.append(a)
for i in range(n):
    b=A.pop(i)
    print(max(A))
    A.insert(i,b)

Fixed submission:
n = int(input())
A = [int(input()) for i in range(n)]

M = max(A)
ind = A.index(M)
A[ind] = 0
M2 = max(A)


if M in A:
    for i in range(n):
        print(M)
else:
    for i in range(n):
        if A[i] == 0:
            print(M2)
        else:
            print(M)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a_li=[]
for i in range(n):
    a=int(input()) 
    a_li.append(a)
for i in range(n):
    b=max(a_li)
    if b>a_li[i]:
        ans=b
    else:
        if a_li.count(b)>1:
            ans=b
        else:
            a_li.remove(b)
            ans=max(a_li)
            a_li.insert(i,b)
    print(ans)
        
        

Fixed submission:
n = int(input())
A = [int(input()) for i in range(n)]

M = max(A)
ind = A.index(M)
A[ind] = 0
M2 = max(A)


if M in A:
    for i in range(n):
        print(M)
else:
    for i in range(n):
        if A[i] == 0:
            print(M2)
        else:
            print(M)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a_li=[]
for i in range(n):
    a=int(input()) 
    a_li.append(a)
for i in range(n):
    b=a_li[i]
    a_li.pop(i)
    print(max(a_li))
    a_li.insert(i,b)

Fixed submission:
n = int(input())
A = [int(input()) for i in range(n)]

M = max(A)
ind = A.index(M)
A[ind] = 0
M2 = max(A)


if M in A:
    for i in range(n):
        print(M)
else:
    for i in range(n):
        if A[i] == 0:
            print(M2)
        else:
            print(M)
Buggy python submission (verdict: Time Limit Exceeded):
s=list(input())
count=0
for i in range(1,len(s)):
    if s[i-1]==s[i]:
        count+=1
        if s[i]=='0':
            s.pop(i)
            s.insert(i,'1')
        else:
            s.pop(i)
            s.insert(i,'0')
print(count)

Fixed submission:
s=list(input())
s1=[]
s2=[]

for i in range(len(s)):
    if i%2==0:
        s1.append('0')
        s2.append('1')
    else:
        s1.append('1')
        s2.append('0')
    
count1=0
count2=0
for i in range(len(s)):
    if s[i]!=s1[i]:
        count1+=1
    if s[i]!=s2[i]:
        count2+=1
        
print(min(count1,count2))
Buggy python submission (verdict: Runtime Error):
menew=[int(input()) for i in range(5)]
small=0
jo=10
for i in range(5):
    if menew[i]%10<jo and menew[i]%10!=0:
        jo=menew[i]%10
        small=menew[i]
menew.remove(small)
ans=0
for i in range(4):
    if menew[i]%10==0:
        p=0
    else:
        p=10-menew[i]%10
    ans+=menew[i]+p
    
ans+=small
print(ans)



Fixed submission:
menew=[int(input()) for i in range(5)]
small=0
jo=10

for i in range(5):
    if menew[i]%10<jo and menew[i]%10!=0:
        jo=menew[i]%10
        small=menew[i]
if small!=0:
    menew.remove(small)
    ans=0
    for i in range(4):
        if menew[i]%10==0:
            p=0
        else:
            p=10-menew[i]%10
        ans+=menew[i]+p
    ans+=small
    print(ans)
else:
    print(sum(menew))
Buggy python submission (verdict: Runtime Error):
n=int(input())

l=[]
for i in range(n):
  l.append(int(input()))

a=sum(l)-2*max(l)

if a<0 :
  print("Yes")
  
else:
  print("No")

Fixed submission:
N = int(input())
L=[int(x) for x in input().split()]
if sum(L)-max(L) > max(L):
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
N=int(input())
P=[int(input()) for n in range(N)]

a=-100
for i in range(N):
  if a<P[i]:
    a=P[i]

P.remove(a)

goukei=a/2
for j in range(N-1):
  goukei+=P[j]

print(int(goukei))

Fixed submission:
D=int(input())
if D==25:
  print("Christmas")
elif D==24:
  print("Christmas Eve")
elif D==23:
  print("Christmas Eve Eve")
elif D==22:
  print("Christmas Eve Eve Eve")

Buggy python submission (verdict: Runtime Error):
N=int(input())
P=[int(N) for N in input().split()]

a=-100
for i in range(N):
  if a<P[i]:
    a=P[i]

P.remove(a)

goukei=a/2
for j in range(N-1):
  goukei+=P[j]

print(int(goukei))

Fixed submission:
D=int(input())
if D==25:
  print("Christmas")
elif D==24:
  print("Christmas Eve")
elif D==23:
  print("Christmas Eve Eve")
elif D==22:
  print("Christmas Eve Eve Eve")

Buggy python submission (verdict: Runtime Error):
N=int(input())
P=[int(N) for N in input().split()]

a=-100
for i in range(N):
  if a<P[i]
    a=P[i]

P.remove(P[i])

goukei=a/2
for j in range(N-1):
  goukei+=P[j]

print(int(goukei))

Fixed submission:
D=int(input())
if D==25:
  print("Christmas")
elif D==24:
  print("Christmas Eve")
elif D==23:
  print("Christmas Eve Eve")
elif D==22:
  print("Christmas Eve Eve Eve")
Buggy python submission (verdict: Runtime Error):

X=int(input("age"))
if X=3 or X=5 or X=7:
  print("Yes")
else:
  print("No")

Fixed submission:
x = int(input())

if x==7 or x==5 or x==3 :
    print("YES")

else :
    print("NO")

Buggy python submission (verdict: Runtime Error):
1<=X<=9
X=int(input("age"))
if X=3 or X=5 or X=7:
  print("Yes")
else:
  print("No")

Fixed submission:
x = int(input())

if x==7 or x==5 or x==3 :
    print("YES")

else :
    print("NO")

Buggy python submission (verdict: Runtime Error):
1<=X<=9
X=input("age")
if X=3 or X=5 or X=7:
  print("Yes")
else:
  print("No")

Fixed submission:
x = int(input())

if x==7 or x==5 or x==3 :
    print("YES")

else :
    print("NO")

Buggy python submission (verdict: Runtime Error):
X=input("年齢を1から9歳までで入力してください")
if X=3 or X=5 or X=7:
	print("Yes")
    
else:
  print("No")

Fixed submission:
x = int(input())

if x==7 or x==5 or x==3 :
    print("YES")

else :
    print("NO")
Buggy python submission (verdict: Runtime Error):
a,b=(int(x) for x in input().split())

if a//2==0 and b//2==0:
  print(“YES”)

else:
  (“NO”)

Fixed submission:
a,b = (int(x) for x in input().split())

if a%2==1 and b%2==1 :
    print("Yes")

else :
    print("No")
Buggy python submission (verdict: Runtime Error):
a,b=int(input())
if a<=8 and b<=8:
    print("Yay!")
else:
    print(":(")

Fixed submission:
a,b=map(int,input().split())
if a<=8 and b<=8:
    print("Yay!")
else:
    print(":(")
Buggy python submission (verdict: Time Limit Exceeded):
from heapq import heappop, heappush

X, Y, Z, K = [int(s) for s in input().split()]
A = [int(s) for s in input().split()]
B = [int(s) for s in input().split()]
C = [int(s) for s in input().split()]
h = []
for i in range(X):
    for j in range(Y):
        for k in range(Z):
            heappush(h, -(A[i] + B[j] + C[k]))
for _ in range(K):
    print(-heappop(h))


Fixed submission:
from heapq import heappop, heappush

X, Y, Z, K = [int(s) for s in input().split()]
A = [int(s) for s in input().split()]
B = [int(s) for s in input().split()]
C = [int(s) for s in input().split()]
A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)
counted = set()
h = [(-(A[0] + B[0] + C[0]), 0, 0, 0)]
for _ in range(K):
    s, i, j, k = heappop(h)
    print(-s)
    if X > i+1 and (i+1, j, k) not in counted:
        heappush(h, (-(A[i+1] + B[j] + C[k]), i+1, j, k))
        counted.add((i+1, j, k))
    if Y > j+1 and (i, j+1, k) not in counted:
        heappush(h, (-(A[i] + B[j+1] + C[k]), i, j+1, k))
        counted.add((i, j+1, k))
    if Z > k+1 and (i, j, k+1) not in counted:
        heappush(h, (-(A[i] + B[j] + C[k+1]), i, j, k+1))
        counted.add((i, j, k+1))
Buggy python submission (verdict: Time Limit Exceeded):
N, Q = [int(s) for s in input().split()]
S = input()
AC = []
for i in range(N-1):
    if S[i:i+2] == 'AC':
        AC.append(i)
for i in range(Q):
    l, r = [int(s)-1 for s in input().split()]
    n_AC = 0
    for j in AC:
        if j >= l and j+1 <=r:
            n_AC += 1
    print(n_AC)

Fixed submission:
N, Q = [int(s) for s in input().split()]
S = input()
AC = [0]
for i in range(N-1):
    if S[i:i+2] == 'AC':
        AC.append(AC[-1] + 1)
    else:
        AC.append(AC[-1])
for i in range(Q):
    l, r = [int(s)-1 for s in input().split()]
    print(AC[r] - AC[l])
Buggy python submission (verdict: Runtime Error):
def find_seq(stones, start, index, table):
    if start in table:
        return table[start]
    else:
        sequence = 1
        for i in range(start, len(stones)):
            stone = stones[i]
            if len(index[stone]) > 1:
                for j in index[stone]:
                    if j > i:
                        sequence += find_seq(stones, j+1, index, table)
        table[start] = sequence
        return sequence

N = int(input())
stones = []
index = {}
last = None
n_stone = 0
for i in range(N):
    stone = int(input())
    if stone != last:
        stones.append(stone)
        last = stone
        if stone in index:
            index[stone].append(n_stone)
        else:
            index[stone] = [n_stone]
        n_stone += 1
table = {}
sequence = find_seq(stones, 0, index, table)
#print(index, table)
print(sequence)

Fixed submission:
from collections import defaultdict

N = int(input())
stones = []
last = None
n_stone = 0
for i in range(N):
    stone = int(input())
    if stone != last:
        stones.append(stone)
        last = stone

count = defaultdict(int)
seq = 1
for i, c in enumerate(stones):
      prev = count[c]
      count[c] = prev + seq
      seq += prev

print(seq % (10**9 + 7))
Buggy python submission (verdict: Time Limit Exceeded):
A, B = [int(s) for s in input().split(' ')]
result = 0
for i in range(A, B+1):
    result ^= i
print(result)


Fixed submission:
def XOR(n):
    if n % 4 == 1:
        return 1
    if n % 4 == 2:
        return n + 1
    if n % 4 == 3:
        return 0
    if n % 4 == 0:
        return n

A, B = [int(s) for s in input().split(' ')]
if A == B:
    print(A)
else:
    print(XOR(A-1) ^ XOR(B))
Buggy python submission (verdict: Time Limit Exceeded):
A,B,N=input().split()
A=int(A)
B=int(B)
N=int(N)

ans=0
for x in range(N+1):
    ans=max(ans,int(A*x/B)-(A*int(x/B)))

print(ans)

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

if N<B:
    print(int(A*N/B))
else:
    print(int(A*(B-1)/B))
Buggy python submission (verdict: Time Limit Exceeded):
import itertools

N, M = map(int, input().split())

#N人の参加者から、M組選ぶ
#これをNセット実施。
#組合わせの距離が重複しなければ、成立


#全ての組み合わせは、
arr=list(itertools.permutations(range(1,N+1), M*2))


#全てのパターンで検証
#成立すればそこで出力
for i in range(len(arr)):
    #チェックリスト初期化
    check_list=[0]*N
    for j in range(M):
        #一人目
        ent1=arr[i][j]
        #二人目
        ent2=arr[i][M*2-j-1]
        #二人の距離は
        dist1=max(ent1,ent2)-min(ent1,ent2)-1
        dist2=N-max(ent1,ent2)+min(ent1,ent2)-1
        #被ってないか評価
        if check_list[dist1]==0:#まだ使われていない距離
            check_list[dist1]=1
        else:
            break
        if check_list[dist2]==0:#まだ使われていない距離
            check_list[dist2]=1
        else:
            break
    else:#全てのMを被り無しで選べたら、出力
        for k in range(M):
            print(str(arr[i][k])+' '+str(arr[i][M*2-k-1]))
        break

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

#N人の参加者から、M組選ぶ
#これをNセット実施。
#組合わせの距離が重複しなければ、成立


#参加者を半分に分け、
#前半を距離奇数、後半を距離偶数にする

#参加者を半分に分ける
div_point=int((N/2))
#前半グループを奇数にする
if div_point%2==0:
    div_point-=1
#後半グループは更に半分に分ける
re_point=div_point+int((N-div_point)/2)

#組を作る
i=0 #初期化
while 1<div_point-i*2 and i<re_point and i<M:#前半グループ・・・距離が奇数になるように組み分け
    ent1=i+1 #前半グループ：一人目
    ent2=div_point-i #前半グループ：二人目
    print(str(ent1) + ' ' + str(ent2))
    i+=1
for j in range(M-i):#後半グループ
    ent1=re_point-j #後半グループ：一人目
    ent2=re_point+j+1 #後半グループ：二人目
    print(str(ent1) + ' ' + str(ent2))
Buggy python submission (verdict: Runtime Error):
A = input()
B = input()

A=int(A)
B=int(B)

if  A*B % 2 == 0:
	print("Even")
else:
	print("Odd")

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

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

if  N[0]*N[1] % 2 == 0:
	print("Even")
else:
	print("Odd")
Buggy python submission (verdict: Time Limit Exceeded):
N=input()
N=int(N)

p=1

for i in range(1,N+1):
    p=p*i

print(p%((10**9)+7))

Fixed submission:
import math

N=input()
N=int(N)

print(math.factorial(N)%((10**9)+7))
Buggy python submission (verdict: Time Limit Exceeded):
import math

A, B = map(int, input().split())

ans = -1

for i in range(1, 100000000):
    if math.floor(i * 0.08) == A and math.floor(i * 0.1) == B:
        ans = i
        break
print(ans)

Fixed submission:
import math

A, B = map(int, input().split())

ans = -1

for i in range(1, 1000000):
    if math.floor(i * 0.08) == A and math.floor(i * 0.1) == B:
        ans = i
        break
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
H, N = map(int, input().split())

magic = [list(map(int, input().split())) for _ in range(N)]
inf = float('inf')
dp = [inf] * (H + 1)
dp[0] = 0
for i in range(H):
    if dp[i] == inf:
        continue
    currCost = dp[i]
    for dmg, cost in magic:
        totalDmg = i + dmg
        if totalDmg > H:
            totalDmg = H
        totalCost = currCost + cost
        if totalCost < dp[totalDmg]:
            dp[totalDmg] = totalCost
print(dp[H])

Fixed submission:
H, N = map(int, input().split())

magic = [list(map(int, input().split())) for _ in range(N)]
inf = float('inf')
dp = [inf] * (H + 1)
dp[0] = 0
for i in range(H):
    if dp[i] == inf:
        continue
    currCost = dp[i]
    for dmg, cost in magic:
        totalDmg = i + dmg
        if totalDmg > H:
            totalDmg = H
        totalCost = currCost + cost
        if totalCost < dp[totalDmg]:
            dp[totalDmg] = totalCost
print(dp[H])
Buggy python submission (verdict: Time Limit Exceeded):
import fractions

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

def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)

num = nums[0]
for i in range(N - 1):
    num = lcm(num, nums[i + 1])
print(sum([num // i for i in nums]) % (10 ** 9 + 7))

Fixed submission:
import fractions

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

def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)

num = nums[0]
for i in range(N - 1):
    num = lcm(num, nums[i + 1])
print(sum([num // i for i in nums]) % (10 ** 9 + 7))

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

N = int(input())
nums = list(map(int, input().split()))
nums.sort()

def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)

num = nums[0]
for i in range(N - 1):
    num = lcm(num, nums[i + 1])
# print(num)
print(sum([num // i for i in nums]) % (10 ** 9 + 7))



Fixed submission:
import fractions

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

def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)

num = nums[0]
for i in range(N - 1):
    num = lcm(num, nums[i + 1])
print(sum([num // i for i in nums]) % (10 ** 9 + 7))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
nums = list(map(int, input().split()))
nums.sort()
# 1 2 3 4
ans = 0
for a in range(N - 2):
    for b in range(a + 1, N - 1):
        for c in range(b + 1, N):
            if nums[a] + nums[b] > nums[c]:
                ans += 1
            else:
                break
print(ans)

Fixed submission:
import bisect

N = int(input())
nums = list(map(int, input().split()))
nums.sort()
ans = 0
for a in range(N - 2):
    for b in range(a + 1, N - 1):
        ind = bisect.bisect_left(nums, nums[a] + nums[b])
        ans += ind - 1 - b
print(ans)

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

N = int(input())
nums = list(map(int, input().split()))
ans = 0
nums = itertools.combinations(nums, 3)
for num in nums:
    a = num[0] < num[1] + num[2]
    b = num[1] < num[2] + num[0]
    c = num[2] < num[0] + num[1]
    if a and b and c:
        ans += 1
print(ans)

Fixed submission:
import bisect

N = int(input())
nums = list(map(int, input().split()))
nums.sort()
ans = 0
for a in range(N - 2):
    for b in range(a + 1, N - 1):
        ind = bisect.bisect_left(nums, nums[a] + nums[b])
        ans += ind - 1 - b
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
nums = list(map(int, input().split()))

import numpy as np

ans = []
for i in range(N):
    tmp = np.argmin(nums)
    ans.append(tmp+1)
    nums[tmp] = 10**10
print(*ans)

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

ans = [0] * N 

for i, num in zip(range(1, N+1), nums):
    ans[num-1] = i
print(*ans)
Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
nums = list(map(int, input().split()))
tik = 0
while tik < M:
    nums.sort(reverse=True)
    num = nums[0] // 2
    for i in range(N):
        if tik == M:
            break
        if nums[i] > num:
            nums[i] = nums[i] // 2
            tik += 1
        else:
            break
print(sum(nums))

Fixed submission:
N, M = map(int, input().split())
nums = list(map(int, input().split()))
tik = 0
while tik < M:
    nums.sort(reverse=True)
    nums[0] = nums[0] // 2 
    tik += 1
    if tik == M:
        break
    for i in range(1,N):
        if tik == M:
            break
        if nums[i] > nums[0]:
            nums[i] = nums[i] // 2
            tik += 1
        else:
            break
print(sum(nums))

Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
nums = list(map(int, input().split()))
tik = 0
while tik < M:
    nums.sort(reverse=True)
    num = nums[0] // 2
    for i in range(N):
        if tik == M:
            break
        if nums[i] > num:
            nums[i] = nums[i] // 2
            tik += 1
        else:
            break
print(sum(nums))

Fixed submission:
N, M = map(int, input().split())
nums = list(map(int, input().split()))
tik = 0
while tik < M:
    nums.sort(reverse=True)
    nums[0] = nums[0] // 2 
    tik += 1
    if tik == M:
        break
    for i in range(1,N):
        if tik == M:
            break
        if nums[i] > nums[0]:
            nums[i] = nums[i] // 2
            tik += 1
        else:
            break
print(sum(nums))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
nums = [i for i in range(1,N+1)]
new = nums[1:] + nums[:1]
ans = 0
for x,y in zip(nums,new):
    ans += x % y
print(ans)

Fixed submission:
N = int(input())
print(N * (N-1) // 2)
Buggy python submission (verdict: Time Limit Exceeded):
import collections

N = int(input())
ans = [collections.Counter(list(input())) for _ in range(N)]
count = 0
for i in range(N):
    for j in range(i+1,N):
        if ans[i] == ans[j]:
            count += 1

print(count)


Fixed submission:
N = int(input())
words = {}

ans = 0
for _ in range(N):
    w = list(input())
    w.sort()
    w = "".join(w)
    if w not in words:
        words[w] = 1
    else:
        ans += words[w]
        words[w] += 1
print(ans)

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

def P(n, r):
    return math.factorial(n)//math.factorial(n-r)

def C(n, r):
    return P(n, r)//math.factorial(r)

N = int(input())

nums = ["".join(str(list(collections.Counter(list(input())).values()))) for _ in range(N)]
ans = 0
for i in collections.Counter(nums).values():
    ans += C(i, 2)
print(ans)

Fixed submission:
N = int(input())
words = {}

ans = 0
for _ in range(N):
    w = list(input())
    w.sort()
    w = "".join(w)
    if w not in words:
        words[w] = 1
    else:
        ans += words[w]
        words[w] += 1
print(ans)

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

N = int(input())
ans = [collections.Counter(list(input())) for _ in range(N)]
count = 0
for i in range(N):
    for j in range(i+1,N):
        if ans[i] == ans[j]:
            count += 1

print(count)

Fixed submission:
N = int(input())
words = {}

ans = 0
for _ in range(N):
    w = list(input())
    w.sort()
    w = "".join(w)
    if w not in words:
        words[w] = 1
    else:
        ans += words[w]
        words[w] += 1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())

nums = [int(input()) for i in range(N)]
maxNum = max(nums)
for i in range(N):
    if nums[i] == maxNum:
        print(max(nums[:i] + nums[i+1:]))
    else:
        print(maxNum)

Fixed submission:
N = int(input())

nums = [int(input()) for i in range(N)]
first = sorted(nums)[-1]
second = sorted(nums)[-2]

for i in range(N):
    if nums[i] == first:
        print(second)
    else:
        print(first)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())

nums = []
for i in range(N):
    nums.append(int(input()))

for i in range(N):
    print(max(nums[i+1:]+nums[:i]))

Fixed submission:
N = int(input())

nums = [int(input()) for i in range(N)]
first = sorted(nums)[-1]
second = sorted(nums)[-2]

for i in range(N):
    if nums[i] == first:
        print(second)
    else:
        print(first)