Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = input().split()
if n % 2 == 0 :
    le = [0] * n // 2
    lo = [0] * n // 2
    counte = 0
    counto = 0
    for i in range(n) :
        if i % 2 == 0 :
            lo[counto] = a[i]
            counto+=1
        else :
            le[counte] = a[i]
            counte +=1
    le.reverse()
    l = le + lo
    S = ' '.join(l)
    print(S)
else :
    l = [a[0]]
    for i in range(1,n) :
        if i % 2 == 1 :
            l.append(a[i])
        else :
            l.insert(0,a[i])
    S = ' '.join(l)
    print(S)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
ki=[]
gu=[]
for i in range(n):
  if i%2:
    ki.append(a[i])
  else:
    gu.append(a[i])
#print(ki,gu)
if n%2==0:
  ki.reverse()
  ki.extend(gu)
  print(*ki)
else:
  gu.reverse()
  gu.extend(ki)
  print(*gu)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = input().split()
if n % 2 == 0 :
    le = []
    lo = []
    for i in range(n) :
        if i % 2 == 0 :
            lo.append(a[i])
        else :
            le.append(a[i])
    le.reverse()
    l = le + lo
    S = ' '.join(l)
    print(S)
else :
    l = [a[0]]
    for i in range(1,n) :
        if i % 2 == 1 :
            l.append(a[i])
        else :
            l.insert(0,a[i])
    S = ' '.join(l)
    print(S)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
ki=[]
gu=[]
for i in range(n):
  if i%2:
    ki.append(a[i])
  else:
    gu.append(a[i])
#print(ki,gu)
if n%2==0:
  ki.reverse()
  ki.extend(gu)
  print(*ki)
else:
  gu.reverse()
  gu.extend(ki)
  print(*gu)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = input().split()
if n % 2 == 0 :
    le = []
    lo = []
    for i in range(n) :
        if i % 2 == 0 :
            lo.append(a[i])
        else :
            le.append(a[i])
    le.reverse()
    l = le + lo
    S = ' '.join(l)
    print(S)
else :
    l = [a[0]]
    for i in range(1,n) :
        if i % 2 == 1 :
            l.append(a[i])
        else :
            l.insert(0,a[i])
    S = ' '.join(l)
    print(S)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
ki=[]
gu=[]
for i in range(n):
  if i%2:
    ki.append(a[i])
  else:
    gu.append(a[i])
#print(ki,gu)
if n%2==0:
  ki.reverse()
  ki.extend(gu)
  print(*ki)
else:
  gu.reverse()
  gu.extend(ki)
  print(*gu)
Buggy python submission (verdict: Time Limit Exceeded):
N,M = [int(i) for i in input().split()]
k = max(N,M)
l = min(N,M)
N = k
M = l
mod = 10**9+7
def frac(N):
    ans = 1
    for i in range(2,N+1):
        k = i % mod
        ans *= k
    return ans
if N - M > 1:
    print(0)
    exit()
if N == M:
    F = frac(N)
    f = F * F % mod
    print((2*f) % mod)
    exit()
if N == M+1:
    F1 = frac(M)
    F2 = frac(N)
    print((F1*F2) % mod)
    exit()


Fixed submission:
N,M = [int(i) for i in input().split()]
k = max(N,M)
l = min(N,M)
N = k
M = l
mod = 10**9+7
def frac(N):
    ans = 1
    ans1 = 1
    ans2 = 1
    ans3 = 1
    for i in range(2,N+1):
        if i % 3 == 0:
            ans1 *=i
            ans1 %= mod
        if i % 3 == 1:
            ans2 *=i
            ans2 %= mod
        if i % 3 == 2:
            ans3 *=i
            ans3 %= mod
    ans = ans1*ans2*ans3 % mod
    return ans
if N - M > 1:
    print(0)
    exit()
if N == M:
    F = frac(N)
    f = F * F % mod
    print((2*f) % mod)
    exit()
if N == M+1:
    F1 = frac(M)
    F2 = frac(N)
    print((F1*F2) % mod)
    exit()

Buggy python submission (verdict: Time Limit Exceeded):
N,M = [int(i) for i in input().split()]
k = max(N,M)
l = min(N,M)
N = k
M = l
mod = 10**9+7
def frac(N):
    ans = 1
    for i in range(2,N+1):
        k = i % mod
        ans *= k
    return ans
if N - M > 1:
    print(0)
    exit()
if N == M:
    F = frac(N)
    f = F * F % mod
    print((2*f) % mod)
    exit()
if N == M+1:
    F1 = frac(M)
    F2 = frac(N)
    print((F1*F2) % mod)
    exit()


Fixed submission:
N,M = [int(i) for i in input().split()]
k = max(N,M)
l = min(N,M)
N = k
M = l
mod = 10**9+7
def frac(N):
    ans = 1
    ans1 = 1
    ans2 = 1
    ans3 = 1
    for i in range(2,N+1):
        if i % 3 == 0:
            ans1 *=i
            ans1 %= mod
        if i % 3 == 1:
            ans2 *=i
            ans2 %= mod
        if i % 3 == 2:
            ans3 *=i
            ans3 %= mod
    ans = ans1*ans2*ans3 % mod
    return ans
if N - M > 1:
    print(0)
    exit()
if N == M:
    F = frac(N)
    f = F * F % mod
    print((2*f) % mod)
    exit()
if N == M+1:
    F1 = frac(M)
    F2 = frac(N)
    print((F1*F2) % mod)
    exit()
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
def kaijo(N) :
    ans = 1
    for i in range(1,N+1) :
        ans *=i
    return ans
mod = 1000000007
A = kaijo(N)
print(A%mod)

Fixed submission:
import math
print(math.factorial(int(input()))%int(1e9+7))
Buggy python submission (verdict: Runtime Error):
import sys
A = int(sys.argv[1])
B = int(sys.argv[2])
C = int(sys.argv[3])
if C - (A - B) >= 0:
    print(C - (A - B))
else:
    print(0)

Fixed submission:
A, B, C = map(int, input().split())
if C - (A - B) >= 0:
    print(C - (A - B))
else:
    print(0)
Buggy python submission (verdict: Runtime Error):
import itertool
a,b,c,d=int(input().split())
l=[a,b,c,d]
c=itertools.combinations(l,2)
ans=a*b
for i in c:
  if i[0]*i[1]>ans:
    ans=i[0]*i[1]
print(ans)

Fixed submission:
l=list(map(int, input().split()))
l1=[l[0],l[1]]
l2=[l[2],l[3]]
ans=l[0]*l[2]
for i in l1:
  for j in l2:
    if i*j>ans:
      ans=i*j
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
s=input()
n=len(s)
a=[0]*2019
a[0]=1
k=0
ans=0
for i in range(n):
  k=(k+int(s[n-1-i])*10**i)%2019
  a[k]+=1
for i in range(2019):
  ans+=a[i]*(a[i]-1)*0.5

print(int(ans))

Fixed submission:
s=input()
n=len(s)
a=[0]*2019
a[0]=1
k=0
ans=0
mod=1
for i in range(n-1,-1,-1):
  k=(k+int(s[i])*mod)%2019
  mod=(mod*10)%2019
  a[k]+=1
for i in a:
  ans+=i*(i-1)*0.5

print(int(ans))

Buggy python submission (verdict: Runtime Error):
s=int(input())
n=len(str(s))
a=[0]*2019
ans=0
k=s%2019
a[k]+=1
for i in range(n):
  s=int(s*0.1)
  k=s%2019
  a[k]+=1
for i in range(2019):
  ans+=a[i]*(a[i]-1)/2

print(int(ans))

Fixed submission:
s=input()
n=len(s)
a=[0]*2019
a[0]=1
k=0
ans=0
mod=1
for i in range(n-1,-1,-1):
  k=(k+int(s[i])*mod)%2019
  mod=(mod*10)%2019
  a[k]+=1
for i in a:
  ans+=i*(i-1)*0.5

print(int(ans))

Buggy python submission (verdict: Runtime Error):
s=int(input())
n=len(str(s))
a=[0]*2019
a[0]=1
ans=0
k=s%2019
a[k]+=1
for i in range(n):
  s=int(s*0.1)
  k=s%2019
  a[k]+=1
for i in range(2019):
  ans+=a[i]*(a[i]-1)/2

print(int(ans))

Fixed submission:
s=input()
n=len(s)
a=[0]*2019
a[0]=1
k=0
ans=0
mod=1
for i in range(n-1,-1,-1):
  k=(k+int(s[i])*mod)%2019
  mod=(mod*10)%2019
  a[k]+=1
for i in a:
  ans+=i*(i-1)*0.5

print(int(ans))

Buggy python submission (verdict: Time Limit Exceeded):
s=int(input())
n=len(str(s))
a=[0]*2019
a[0]=1
ans=0
for i in range(n):
  k=(s%10**(n-i))%2019
  a[k]+=1
for i in range(2019):
  ans+=a[i]*(a[i]-1)/2

print(int(ans))

Fixed submission:
s=input()
n=len(s)
a=[0]*2019
a[0]=1
k=0
ans=0
mod=1
for i in range(n-1,-1,-1):
  k=(k+int(s[i])*mod)%2019
  mod=(mod*10)%2019
  a[k]+=1
for i in a:
  ans+=i*(i-1)*0.5

print(int(ans))

Buggy python submission (verdict: Runtime Error):
import math
s=int(input())
n=len(str(s))
ans=0
if n>=4:
  for i in range(n-3):
    for j in range(i+3,n):
      k=math.floor((s%10**(n-i))/10**(n-j-1))
      if k%2019==0:
        ans+=1
print(ans)

Fixed submission:
s=input()
n=len(s)
a=[0]*2019
a[0]=1
k=0
ans=0
mod=1
for i in range(n-1,-1,-1):
  k=(k+int(s[i])*mod)%2019
  mod=(mod*10)%2019
  a[k]+=1
for i in a:
  ans+=i*(i-1)*0.5

print(int(ans))
Buggy python submission (verdict: Runtime Error):
def cmb(n):
	if n<=1:
		return 0
	else:
		return int(n*(n-1)*0.5)
N = int(input())
A = [int(x) for x in input().split()]
ans=[0]*N
lists={}
k=0
for i in range(N):
  if not A[i] in lists:
    l=cmb(A.count(A[i]))
    m=cmb(A.count(A[i])-1)-l
    k+=l
    lists[A[i]]=m
    ans[i]=m
  else:
    ans[i]=lists[A[i]]
    
for i in range(N):
  ans[i]+=k
  print(ans[i])

Fixed submission:
a,b=map(int,input().split())
ans=0
if a>=2:
  ans+=a*(a-1)*0.5
if b>=2:
  ans+=b*(b-1)*0.5
ans=int(ans)
print(ans)
Buggy python submission (verdict: Runtime Error):
H=int(input())
a=1
ans=1
while True:
  if a>H:
    break
   ans=ans+a
  a=a*2

print(ans)

Fixed submission:
H=int(input())
a=1
ans=0
while True:
  if a>H:
    break
  ans=ans+a
  a=a*2
 
print(ans)
Buggy python submission (verdict: Runtime Error):
N,M=int(input())
if N==M:
  ans="Yes"
else:
  ans="No"
print("ans")

Fixed submission:
N,M=map(int,input().split())
if N==M:
  ans="Yes"
else:
  ans="No"
print(ans)
Buggy python submission (verdict: Runtime Error):
N,K=map(int,input().split())
h=list(map(int,input().split()))
ans=0
for i in N:
  if h[i]>=K:
    ans+=1
print(ans)

Fixed submission:
N,K=map(int,input().split())
h=list(map(int,input().split()))
ans=0
for i in range(N):
  if h[i]>=K:
    ans+=1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
A,B=map(int,input().split())
def cf(x1,x2):
    cf=[]
    cf.append(1)
    for i in range(2,min(x1,x2)+1):
        if x1 % i == 0 and x2 % i == 0:
            cf.append(i)
    return cf
def gcd(a, b):
  while b!=0:
    a, b = b, a % b
  return a 

mod=cf(A,B)
ans=0
ans_list=[]
ans_list.append(1)
if len(mod)==1 :
  ans=1
else:
  for i in range(1,len(mod)):
    t=0
    for v in range(len(ans_list)):
      t+=1
      if gcd(mod[i],ans_list[v])!=1 :
        break
      if t==len(ans_list):
        ans_list.append(mod[i])
ans=len(ans_list)
print(ans)

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

import math

def tn(n):
  m=n
  factor=[]
  tmp=int(math.sqrt(n))+1
  for num in range(2,tmp):
    t=0
    while n%num==0:
      n//=num
      if t==0:
        factor.append(num)
        t=1
  if factor==[]:
    factor.append(m)
  factor.append(1)
  factor.append(n)
  return factor

listA=tn(A)
listB=tn(B)
anslist=set(listA) & set(listB)
ans=len(anslist)
print(ans)
Buggy python submission (verdict: Runtime Error):
N,M=map(int,input().split())
A=list(map(int,input().split()))
A.sort(reverse=True)
t=0
while True:
  maxi=A[0]
  if len(A)>1 :
    maxi_2=A[1]
    t+=1
    maxi=maxi//2
    if t==M :
      A[0]=maxi
      break
    elif maxi_2>maxi :
      A[0]=maxi_2
      A[1]=maxi
      for i in range(1,N):
        if A[i]<A[i+1]:
          A[i]=A[i+1]
          A[i+1]=maxi
        else:
          break     
      continue
    else:
      continue
  else :
    maxi=maxi//(2**M)
    A[0]=maxi
    break

amount=sum(A)
print(amount)

Fixed submission:
s=input()

if s=="Sunny":
  a="Cloudy"
elif s=="Cloudy":
  a="Rainy"
else:
  a="Sunny"
  
print(a)

Buggy python submission (verdict: Runtime Error):
L=list(map(int,input().split()))
N=L[0]
K=L[1]
Q=L[2]
point=[K-Q]*N
for i in range(Q):
  ans=int(input())
  point[ans-1]+=1
for i in range(N):
  if point[i]>0 :
    print("Yes")
  else:
    print("No")

Fixed submission:
s=input()

if s=="Sunny":
  a="Cloudy"
elif s=="Cloudy":
  a="Rainy"
else:
  a="Sunny"
  
print(a)
Buggy python submission (verdict: Time Limit Exceeded):
   
L=list(map(int,input().split()))
N=L[0]
K=L[1]
Q=L[2]
S=[]
for i in range(Q):
  S.append(int(input()))
S.sort()
for i in range(N):
  num_ans=S.count(i+1)
  point=K-Q+num_ans
  if point>0 :
    print("Yes")
  else:
    print("No")
  S=S[num_ans:]

Fixed submission:
L=list(map(int,input().split()))
N=L[0]
K=L[1]
Q=L[2]
point=[K-Q]*N
for i in range(Q):
  ans=int(input())
  point[ans-1]+=1
for i in range(N):
  if point[i]>0 :
    print("Yes")
  else:
    print("No")

Buggy python submission (verdict: Time Limit Exceeded):
L=list(map(int,input().split()))
N=L[0]
K=L[1]
Q=L[2]
S=[]
for i in range(Q):
  S.append(int(input()))
point=[0]*N
num_ans=[0]*N
for i in range(N):
  num_ans[i]=S.count(i+1)
  point[i]=K-Q+num_ans[i]
  if point[i]>0 :
    print("Yes")
  else:
    print("No")

Fixed submission:
L=list(map(int,input().split()))
N=L[0]
K=L[1]
Q=L[2]
point=[K-Q]*N
for i in range(Q):
  ans=int(input())
  point[ans-1]+=1
for i in range(N):
  if point[i]>0 :
    print("Yes")
  else:
    print("No")
Buggy python submission (verdict: Runtime Error):
N,Q=map(int,input().split())
a=[0]*(N-1)
b=[0]*(N-1)
p=[0]*Q
x=[0]*Q
for i in range(N-1):
  a[i],b[i]=map(int,input().split())
for i in range(Q):
  p[i],x[i]=map(int,input().split())
v=[0]*N
 
for i in range(Q):
  box=[]
  box.append(p[i])
  for k in range(N-1):
    if a[k] in box :
      box.append(b[k])
  for l in range(len(box)):
    num=box[l]-1
    v[num]+=x[i]
 
for h in range(N):
  print(v[h], end=" ")

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

if a<3200 :
  s='red'

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

c=a+b
if c<a-b :
  c=a-b
if c<ab :
  c=ab
print(c)

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

c=a+b
if c<a-b :
  c=a-b
if c<a*b :
  c=a*b
print(c)
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
word=[]
for i in range(N):
  word.append(input())
  
alphalist=[]
alpha=[[] for i in range(N)]
for i in range(N):
  word0=word[i]
  for v in range(10):
    alpha[i].append(word0[v])
  alpha[i].sort()
  alphalist.append(alpha[i])


number=0
for i in range(N):
  freq=alphalist.count(alphalist[i])
  if freq!=1:
    number0=(freq*(freq-1))/2
    number0=number0/freq
    number+=number0
  
print(int(number))

Fixed submission:
n = int(input())
s = [input()for _ in range(n)]

for i in range(n):
    s[i] = ''.join(sorted(s[i]))

s.sort()

ans = 0
count = 0

for i in range(1, n):
    if count == 0:
        if s[i] == s[i-1]:
            count = 2
    else:
        if s[i] == s[i-1]:
            count += 1
        else:
            ans += count * (count - 1) // 2
            count = 0

ans += count * (count - 1) // 2

print(ans)

Buggy python submission (verdict: Runtime Error):
N=int(input())
word=[]
for i in range(N):
  word.append(input())
  
alphalist=["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"]
numlist=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101]


alphalist=[]
alpha=[[] for i in range(N)]
for i in range(N):
  word0=word[i]
  for v in range(10):
    alpha[i].append(word0[i])
  alpha[i].sort()
  alphalist.append(alpha[i])


number=0
for i in range(N):
  freq=alphalist.count(alphalist[i])
  if freq!=1:
    number0=(freq*(freq-1))/2
    number0=number0/freq
    number+=number0
  
print(int(number))

Fixed submission:
n = int(input())
s = [input()for _ in range(n)]

for i in range(n):
    s[i] = ''.join(sorted(s[i]))

s.sort()

ans = 0
count = 0

for i in range(1, n):
    if count == 0:
        if s[i] == s[i-1]:
            count = 2
    else:
        if s[i] == s[i-1]:
            count += 1
        else:
            ans += count * (count - 1) // 2
            count = 0

ans += count * (count - 1) // 2

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
word=[]
for i in range(N):
  word.append(input())
  
alphalist=["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"]
numlist=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101]


numberlist=[]
for i in range(N):
  wordnum0=1
  word0=word[i]
  for v in range(10):
    for k in range(26):
      if word0[v]==alphalist[k] :
        wordnum0*=numlist[k]
        break
  numberlist.append(wordnum0)

number=0
for i in range(N):
  freq=numberlist.count(numberlist[i])
  if freq!=1:
    number0=(freq*(freq-1))/2
    number0=number0/freq
    number+=number0
  
print(int(number))

Fixed submission:
n = int(input())
s = [input()for _ in range(n)]

for i in range(n):
    s[i] = ''.join(sorted(s[i]))

s.sort()

ans = 0
count = 0

for i in range(1, n):
    if count == 0:
        if s[i] == s[i-1]:
            count = 2
    else:
        if s[i] == s[i-1]:
            count += 1
        else:
            ans += count * (count - 1) // 2
            count = 0

ans += count * (count - 1) // 2

print(ans)
Buggy python submission (verdict: Runtime Error):
s = input()

cnt = 0
L = []
for i in s:
    if i == "R":
        cnt += 1
    else:
        L.append(cnt)
        cnt = 0

print(max(L))


Fixed submission:
s = input()

cnt = 0
L = []
for i in s:
    if i == "R":
        cnt += 1
    else:
        L.append(cnt)
        cnt = 0
L.append(cnt)
print(max(L))
Buggy python submission (verdict: Runtime Error):
import math 
n = int(input())
print(math.ceil(n/ 1000) * 1000 - n)

Fixed submission:
n, k = map(int, input().split())
l = sorted(list(map(int, input().split())))

ans = 0
for i in range(k):
    ans += l[i]

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

ans = 1
for i in a:
    ans *= i

if ans > 10 ** 18:
    print("-1")
else:
    print(ans)

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

if 0 in a:
    print(0)
    exit()

ans = 1
for i in a:
    ans *= i
    if ans > 10 ** 18:
        print("-1")
        exit()

print(ans)

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

ans = a[0]
for i in a[1:]:
    ans *= i

if ans > 10 ** 18:
    print("-1")
else:
    print(ans)

  

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

if 0 in a:
    print(0)
    exit()

ans = 1
for i in a:
    ans *= i
    if ans > 10 ** 18:
        print("-1")
        exit()

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
a, b, c, k = map(int, input().split())

ans = 0

for i in range(k):
    if a >= 1:
        ans += 1
        a -= 1
    elif b >= 1:
        b -= 1
        pass
    else:
        ans -= 1
print(ans)


Fixed submission:
a, b, c, k = map(int, input().split())

if k <= a:
    print(k)
elif k - a > b:
    print(-1 * ((k - a) - b) + a)
else:
    print(a)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
for i in range(n):
    print(a.count(i + 1))


Fixed submission:
n = int(input())
a = list(map(int, input().split()))
b = [0 for i in range(n)]

for i in a:
    b[i - 1] += 1

for i in b:
    print(i)
Buggy python submission (verdict: Time Limit Exceeded):
def gcd(a, b):
    if a % b == 0: return b
    return gcd(b, a % b)

n = int(input())
ans = 0
for i in range(1, n + 1):
    for j in range(1, n + 1):
        for k in range(1, n + 1):
            ans += gcd(gcd(i, j), k)

print(ans)


Fixed submission:
from math import gcd

n = int(input())
ans = 0
for i in range(1, n + 1):
    for j in range(1, n + 1):
        for k in range(1, n + 1):
            ans += gcd(gcd(i, j), k)
            
print(ans)
Buggy python submission (verdict: Runtime Error):
n, k = map(int, input().split())

def gcd(a, b):
    if a % b == 0:
        return b
    return gcd(b, a % b)

cnt = gcd(n, k)

if n == 1 or k == 1:
    print(0)
else:
    a = max((n % k, k % n))
    print(min(a, gcd(n, k)))


Fixed submission:
n, k = map(int, input().split())
print(min(k - n % k, n % k))
Buggy python submission (verdict: Runtime Error):
import math
n = int(input())
a = list(map(int, input().split()))


for i in range(len(a)):
    rem_k = a[:i] + a[i + 1:]
    # print(len(set(rem_k))) # 同一が2個以上のものを抽出してset
    cho = []
    for j in rem_k:
        if rem_k.count(j) >= 2:
            cho.append(j)
    # print(rem_k)
    for i in cho:
        if rem_k.count(i) - 2 < 0:
            ans = 0
        else:
            ans =  math.factorial(rem_k.count(i)) // (math.factorial(rem_k.count(i) - 2) * math.factorial(2))

    print(ans)


Fixed submission:
from collections import Counter

n = int(input())
l = list(map(int, input().split()))
cl = Counter(l)


cnt = 0
for v in cl.values():
    cnt += v * (v - 1) // 2 

for i in l:
    v = cl[i]
    ans = cnt - (v * (v - 1) // 2) + (v - 1) * (v - 2) // 2
    print(ans)
Buggy python submission (verdict: Runtime Error):
n, a, b = map(int, input().split())

s = ""
while True:
    s += "b" * a +  "r" * b
    if len(s) >= n:
        break

print(s[:n].count("b"))




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

r = n % (a + b)
ans = n // (a + b) * a + min(r, a)
print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
l = list(map(int, input().split()))

k = round(sum(l) / n)
ans = 0
for i in l:
    ans += (k - i) ** 2

print(ans)


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

if n >= 10:
    print(r)
else:
    print(r + (100 * (10 - n)))
Buggy python submission (verdict: Runtime Error):
S = input()
ans = 0
if len(S) % 2 == 0:
    a = S[:len(S) // 2]
    b = S[len(S) // 2:]

    for i in range(len(a)):
        if a[i] != b[-i - 1]
            ans += 1

else:
    mid = len(S) // 2
    a = S[:mid]
    b = S[mid:]
    for i in range(len(a)):
        if a[i] != b[-i - 1]:
            ans += 1

print(ans)

Fixed submission:
S = input()
ans = 0
if len(S) % 2 == 0:
    a = S[:len(S) // 2]
    b = S[len(S) // 2:]

    for i in range(len(a)):
        if a[i] != b[-i - 1]:
            ans += 1

else:
    mid = len(S) // 2
    a = S[:mid]
    b = S[mid:]
    for i in range(len(a)):
        if a[i] != b[-i - 1]:
            ans += 1

print(ans)
Buggy python submission (verdict: Runtime Error):
S = input()

sorted_S = sorted(S)

if S[0] == S[1] and S[2] == S[3] ans S[1] != S[2]:
	print("Yes")
else:
	print("No")



Fixed submission:
S = input()

sorted_S = sorted(S)

if sorted_S[0] == sorted_S[1] and sorted_S[2] == sorted_S[3] and sorted_S[1] != sorted_S[2]:
	print("Yes")
else:
	print("No")
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
l = list(map(int, input().split()))
k = max(l)

ans = 0
for i in range(k + 1):
    ar = 0
    ab = 0
    for j in l:
        if j >= i:
          ar += 1
        else:
            ab += 1
    if ar == ab:
        ans += 1
print(ans)


Fixed submission:
n = int(input())
l = list(map(int, input().split()))
k = max(l)

a = sorted(l)
print(a[n // 2] - a[n // 2 - 1])
Buggy python submission (verdict: Runtime Error):
S = input()

L = []
cnt = 0
for i in S:
  if i == "A" or i == "C" or i == "G" or i == "T":
    cnt += 1
  else:
    L.append(cnt)
    cnt = 0
    
print(max(L))

Fixed submission:
S = input()

L = []
cnt = 0
for i in S:
  if i == "A" or i == "C" or i == "G" or i == "T":
    cnt += 1
  else:
    L.append(cnt)
    cnt = 0

L.append(cnt)

if len(L) == 0:
	print(0)
else:
	print(max(L))
Buggy python submission (verdict: Runtime Error):
N, Q = list(map(int, input().split()))
s = input()
lr = [list(map(int, input().split())) for i in range(Q)]

L = [0] * (N + 1)

for i in range(len(s)):
  if s[i] == "A" and s[i + 1] == "C":
      L[i + 1] = 1 + L[i]
  else:
      L[i + 1] = L[i]


for i in range(Q):
    print(L[lr[i][1] - 1] - L[lr[i][0] - 1])

Fixed submission:
N, Q = list(map(int, input().split()))
s = input()
lr = [list(map(int, input().split())) for i in range(Q)]

L = [0] * (N + 1)

for i in range(N - 1):
  if s[i] == "A" and s[i + 1] == "C":
      L[i + 1] = 1 + L[i]
  else:
      L[i + 1] = L[i]


for i in range(Q):
    print(L[lr[i][1] - 1] - L[lr[i][0] - 1])
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
cnt = 0
for i in range(1, N + 1):
    a = list(str(i))
    if "1" in a or "2" in a or "4" in a or "6" in a or "8" in a or "9" in a or "0" in a:
        continue
    if a.count("3") >= 1 and a.count("5") >= 1and a.count("7") >= 1:
        cnt += 1
    
print(cnt)

Fixed submission:
import itertools

N = int(input())
P = []

for i in range(len(str(N))): 
     P+= list(itertools.product(["7", "5", "3"], repeat = i + 1))

ans = 0
for i in P:
    if "7" not in i or "5" not in i or "3" not in i:
        continue
    a = int("".join(i))
    if a <= N:
        ans += 1
print(ans)
Buggy python submission (verdict: Runtime Error):
A = int(input())
B = int(input())

print(A * B - (A + B) + 1)

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

print(A * B - (A + B) + 1)