Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
import sys

stdin = sys.stdin
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip() # ignore trailing spaces

def main():
    s = ns()
    ans = 0
    ssum = [0]
    for si in s:
        ssum += [(ssum[-1] + int(si))%3]
    for i in range(len(s)-3):
        for j in range(i+3,len(s)):
            if ssum[i] == ssum[j+1] and ((j !=len(s)-1 and int(s[i:j+1])%2019==0) or (j ==len(s)-1 and int(s[i:])%2019==0)):
                ans += 1
    print(ans) 
    return

if __name__ == '__main__':
    main()


Fixed submission:
# coding: utf-8
# Your code here!
import sys

stdin = sys.stdin
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip() # ignore trailing spaces

def comb(a,b):
    ans = 1
    for i in range(b):
        ans *= a - i
    for j in range(b):
        ans //= (j + 1)
    return ans

def main():
    s = ns()
    mod = 2019
    tmp1  = 1
    tmp2 = 0
    mod2019 = [1] + [0 for i in range(2018)]
    for i in range(len(s)-1, -1, -1):
        tmp2 = (tmp2 + tmp1*int(s[i]))%mod
        tmp1 = (tmp1*10)%mod
        mod2019[tmp2] += 1
    ans = 0
    for i in range(2019):
        ans += comb(mod2019[i],2)
    print(ans) 
    return

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip() # ignore trailing spaces

n, K = na()


eqi = [0 for i in range(K)]#eqi[i] = (gcd(A_1,A_2,...,A_N) = i となる組の数)

for i in range(K,0,-1):
    if i == 1:
        eqi[i-1] = K**n - sum(eqi)
        break
    #A_1,A_2,...,A_Nのすべてがiの倍数になる組の数
    tmp = (K//i)**n
    #A_1,A_2,...,A_Nのすべてがm*iの倍数になる組の数を引く(n = {2,3,4,...})
    for m in range(2,(K//i)+1):
        tmp -= eqi[m*i - 1]
    eqi[i-1] = tmp%(10**9 + 7)
ans = 0
for i in range(K):
    ans += ((i+1)*eqi[i])%(10**9 + 7)
print(ans%(10**9 + 7))


Fixed submission:
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip() # ignore trailing spaces

n, K = na()
mod = 1000000007

#n乗に**nを使うとTLEになる.powを使いましょう
eqi = [pow(K//(i+1), n, mod) for i in range(K)]#eqi[i] = (gcd(A_1,A_2,...,A_N) = i となる組の数)

for i in range(K,0,-1):
    if i == 1:
        eqi[i-1] -= sum(eqi[1:])
        break
    #A_1,A_2,...,A_Nのすべてがiの倍数になる組の数
    #tmp = (K//i)**n
    #A_1,A_2,...,A_Nのすべてがm*iの倍数になる組の数を引く(n = {2,3,4,...})
    for m in range(2,(K//i)+1):
        eqi[i-1] -= eqi[m*i - 1]
    eqi[i-1] %= mod
ans = 0
for i in range(K):
    ans += ((i+1)*eqi[i])%mod
print(ans%mod)
Buggy python submission (verdict: Runtime Error):
a,b,c = input()

print(c,a,b)

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

print(c,a,b)
Buggy python submission (verdict: Time Limit Exceeded):
"""
n = (m*k+1)*(k^l) となるm,lがあるか？

kはnの約数 or n%k==1が必要
"""
 
def is_f(k,n):
    while n%k==0:
        n /= k
    return n%k==1


n = int(input())

cnt = 0
for k in range(2,n+1):
    if n%k == 0 or n%k ==1:
        if is_f(k,n):
            cnt += 1
            
print(cnt)


Fixed submission:
"""
n = (m*k+1)*(k^l) となるm,lがあるか？

kは「nの約数 or n%k==1<=>kがn-1の約数」が必要
"""
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    # divisors.sort()
    return divisors
 
def is_f(k,n):
    while n%k==0:
        n /= k
    return n%k==1


n = int(input())

cnt = 0
num = tuple(make_divisors(n)[1:] + make_divisors(n-1)[1:])

for k in num:
    if is_f(k,n):
        cnt += 1

print(cnt)
Buggy python submission (verdict: Runtime Error):
x,y,a,b,c = map(int,input().split())
p_a = list(map(int,input().split()))
p_b = list(map(int,input().split()))
p_c = list(map(int,input().split()))
p_a.sort(reverse=True)
p_b.sort(reverse=True)
p_c.sort(reverse=True)
p_c += [0]

ans = p_a[:x] + p_b[:y]
ans.sort(reverse=True)
i = -1
p_c_sum = 0
while True:
    if ans[i] > p_c[0]:
        break
    else:
        ans[i] = 0
        i -= 1
        p_c_sum += p_c[0]
        p_c.pop(0)
print(sum(ans) + p_c_sum )

Fixed submission:
x,y,a,b,c = map(int,input().split())
p_a = list(map(int,input().split()))
p_b = list(map(int,input().split()))
p_c = list(map(int,input().split()))
p_a.sort(reverse=True)
p_b.sort(reverse=True)
#p_c.sort(reverse=True)

ans = p_a[:x] + p_b[:y] + p_c
ans.sort(reverse=True)
print(sum(ans[:x+y]))

Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8
# Your code here!

x,y,a,b,c = map(int,input().split())
p_a = list(map(int,input().split()))
p_b = list(map(int,input().split()))
p_c = list(map(int,input().split()))
p_a.sort(reverse=True)
p_b.sort(reverse=True)
p_c.sort(reverse=True)
p_c += [0]

ans = p_a[:x] + p_b[:y]
ans.sort(reverse=True)

while True:
    if ans[-1] > p_c[0]:
        break
    else:
        ans[-1] = p_c[0]
        p_c.pop(0)
        ans.sort(reverse=True)
print(sum(ans))

Fixed submission:
x,y,a,b,c = map(int,input().split())
p_a = list(map(int,input().split()))
p_b = list(map(int,input().split()))
p_c = list(map(int,input().split()))
p_a.sort(reverse=True)
p_b.sort(reverse=True)
#p_c.sort(reverse=True)

ans = p_a[:x] + p_b[:y] + p_c
ans.sort(reverse=True)
print(sum(ans[:x+y]))
Buggy python submission (verdict: Runtime Error):
# coding: utf-8
# Your code here!

n,m = map(int,input().split())
a = [-1 for i in range(n)]
flag = 1
for i in range(m):
    b,c = map(int,input().split())
    b -= 1
    if a[b] != -1 and a[b] != c:
        flag = 0
        print("-1")
        break
    else:
        a[b] = c

if flag == 1:
    if a[0] == 0:
        if n == 1:
            print(0)
        else:
            print(-1)
    else:
        if a[0] == -1:
            a[0] = 1:
        ans = 0
        for i in range(n):
            if a[i] != -1:
                ans += a[i] * (10**(n-1-i))
        print(ans)

Fixed submission:
# coding: utf-8
# Your code here!

n,m = map(int,input().split())
a = [-1 for i in range(n)]
flag = 1
for i in range(m):
    b,c = map(int,input().split())
    b -= 1
    if a[b] != -1 and a[b] != c:
        flag = 0
        print("-1")
        break
    else:
        a[b] = c

if flag == 1:
    if a[0] == 0:
        if n == 1:
            print(0)
        else:
            print(-1)
    else:
        if a[0] == -1:
            if n == 1:
                a[0] = 0
            else:
                a[0] = 1
        ans = 0
        for i in range(n):
            if a[i] != -1:
                ans += a[i] * (10**(n-1-i))
        print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import copy
n = int(input())
num = list(map(int,input().split()))

end = n
i = 0
while i < end-1:
    for j in range(end-1, i, -1):
        if num[j] > num [i]:
            num.pop(j)
    end = len(num)
    i += 1
    
print(end)

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

now = num[0]
cnt = 1
for i in range(1,n):
    if (now > num[i]):
        cnt+=1
        now = num[i]
    
print(cnt)

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

ans = [1 for i in range(n)]

for i in range(n):
    for j in range(i+1, n):
        if num[i] < num[j]:
            ans[j] = 0
            
print(sum(ans))

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

now = num[0]
cnt = 1
for i in range(1,n):
    if (now > num[i]):
        cnt+=1
        now = num[i]
    
print(cnt)
Buggy python submission (verdict: Time Limit Exceeded):
import sys

stdin = sys.stdin

ns = lambda: stdin.readline().rstrip() # ignore trailing spaces 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))

def sumitrust2019_d(a,b,c,s):
    a,b,c = map(str,[a,b,c])
    for idx_a in range(len(s)-2):
        if s[idx_a] == a:
            for idx_b in range(idx_a+1,len(s)-1):
                if s[idx_b] == b:
                    for idx_c in range(idx_b+1,len(s)):
                        if s[idx_c] == c:
                                return True
    else:
        return False

def main():
    n = ni()
    s = ns()
    ans = 0
    for a in range(10):
        for b in range(10):
            for c in range(10):
                if sumitrust2019_d(a,b,c,s):
                    ans += 1
    print(ans)
    return

if __name__ == '__main__':
    main()

Fixed submission:
import sys

stdin = sys.stdin

ns = lambda: stdin.readline().rstrip() # ignore trailing spaces 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))

def sumitrust2019_d(a,b,c,s):
    abc = list(map(str,[a,b,c]))
    now = 0
    for i in range(len(s)):
        if s[i] == abc[now]:
            now += 1
            if now == 3:
            	return True
    return False

def main():
    n = ni()
    s = ns()
    ans = 0
    for a in range(10):
        for b in range(10):
            for c in range(10):
                if sumitrust2019_d(a,b,c,s):
                    ans += 1
    print(ans)
    return

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
def is_prime(num):
    if num<2:
        return False
    if num==2 or num==3:
        return True
    for i in range(2,int(num**0.5)+1):
        if num%i==0:
            return False
    return True
 
def main():
    a,b=map(int,input().split())
    s,l=min(a,b),max(a,b)
    #sの約数のうち、素数を求める。
    s_sub=s
    #s_prime=[1]
    i=2
    ans=1
    while i<=s_sub:
        if s%i==0:
            if is_prime(i):
                if l%(i)==0:
                    ans+=1
                #s_prime.append(i)
                if is_prime(s//i):
                    if l%(s//i)==0:
                        ans+=1
                s_sub=s//i-1
        i+=1
        
    print(ans)
    
main()

Fixed submission:
def gcd(a, b):
	while b:
		a, b = b, a % b
	return a

def is_prime(num):
    if num<1:
        return False
    if num==1 or num==2 or num==3:
        return True
    for i in range(2,int(num**0.5)+1):
        if num%i==0:
            return False
    return True
 
def main():
    a,b=map(int,input().split())
    GCD=gcd(a,b)
    ans=0
    for i in range(1,int(GCD**0.5)+1):
        if GCD%i==0:
            if is_prime(i):
                ans+=1
            if i!=GCD and is_prime(GCD//i):
                ans+=1
    print(ans)
    
main()
Buggy python submission (verdict: Time Limit Exceeded):
n,m=map(int,input().split())
pricelist=list(map(int,input().split()))
for i in range(m):
    pricelist.sort(reverse=True)
    pricelist[0]//=2
print(sum(pricelist))

Fixed submission:
#ABC-141-D
def main():
    n,m=map(int,input().split(" "))
    s=list(map(int,input().split(" ")))
    
    s.sort(reverse=True)
    while m!=0:
        tmp=s[0]//2
        s[0]=tmp
        m-=1
        for j in range(1,n):
            if m==0:
                break
            else:
                if s[j]>=tmp:
                    s[j]=s[j]//2
                    m-=1
                else:
                    break
        s.sort(reverse=True)
        if s[0]==0:
            break
    print(sum(s))
    
main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
     n,m=map(int,input().split())
     a=list(map(int,input().split()))
     firstone=a[0]
     dp=[firstone//(2**i) for i in range(m+1)]
     dpp=dp
     for i in a[1:]:
          tmp=[i//(2**j) for j in range(0,m+1)]
          dp=[_ + tmp[0] for _ in dp]
          for j in range(m+1):
               tmp2=[dpp[k]+tmp[j-k] for k in range(j+1)]
               dp[j]=min([dp[j]]+tmp2)
          dpp=dp
     print(min(dp))
     
if __name__=='__main__':
     main()

Fixed submission:
#ABC-141-D
def main():
    n,m=map(int,input().split(" "))
    s=list(map(int,input().split(" ")))
    
    s.sort(reverse=True)
    while m!=0:
        tmp=s[0]//2
        s[0]=tmp
        m-=1
        for j in range(1,n):
            if m==0:
                break
            else:
                if s[j]>=tmp:
                    s[j]=s[j]//2
                    m-=1
                else:
                    break
        s.sort(reverse=True)
        if s[0]==0:
            break
    print(sum(s))
    
main()
Buggy python submission (verdict: Time Limit Exceeded):
def main():
     AlfaToNum={'a':2,'b':3,'c':5,'d':7,'e':11,'f':13,'g':17,'h':19,'i':23,'j':29,'k':31,'l':37,'m':41,'n':43,'o':47,'p':53,'q':59,'r':61,'s':67,'t':71,'u':73,'v':79,'w':83,'x':89,'y':97,'z':101}
     n=int(input())
     s=[]
     ans=0
     for i in range(n):
          si=input()
          cnt=1
          for j in si:
               cnt*=AlfaToNum[j]
          s.append(cnt)
     #print(s)
     for i in range(n):
          for j in range(i+1,n):
               if s[i]==s[j]:
                    ans+=1
     print(ans)
if __name__ == '__main__':
     main()

Fixed submission:
def main():
     AlfaToNum={'a':2,'b':3,'c':5,'d':7,'e':11,'f':13,'g':17,'h':19,'i':23,'j':29,'k':31,'l':37,'m':41,'n':43,'o':47,'p':53,'q':59,'r':61,'s':67,'t':71,'u':73,'v':79,'w':83,'x':89,'y':97,'z':101}
     n=int(input())
     s=[]
     ans=0
     for i in range(n):
          si=input()
          cnt=1
          for j in si:
               cnt*=AlfaToNum[j]
          s.append(cnt)
     #print(s)
     s.sort()
     cnt=1
     for i in range(n-1):
          if s[i]==s[i+1]:
               cnt+=1
          else:
               ans+=cnt*(cnt-1)//2
               cnt=1
     ans+=cnt*(cnt-1)//2
     print(ans)
if __name__ == '__main__':
     main()
Buggy python submission (verdict: Time Limit Exceeded):
def main():
     s=input()
     ans=[0 for i in range(len(s))]
     for i in range(len(s)):
          ini=s[i]
          now=i
          if ini=='R':
               move=1
          else:
               move=-1
          while s[now]==ini:
               now+=move
               
          if abs(now-i)%2==1:
               now-=move
          ans[now]+=1
     print(" ".join(list(map(str,ans))))
     
     
if __name__ == '__main__':
     main()

Fixed submission:
def main():
     dic={'R':+1,'L':-1}
     s=input()
     ans=[0 for i in range(len(s))]
     ini_pre=None
     for i in range(len(s)):
          if i==0 or ini!=s[i]:
               ini=s[i]
               now=i
               move=dic[ini]
               while s[now]==ini:
                    now+=move
               if abs(now-i)%2==1:
                    ans[now-move]+=1
               else:
                    ans[now]+=1
          elif ini==s[i]:
               if abs(now-i)%2==1:
                    ans[now-move]+=1
               else:
                    ans[now]+=1
     print(" ".join(list(map(str,ans))))
     
     
if __name__ == '__main__':
     main()
Buggy python submission (verdict: Runtime Error):
import math
n,k = map(int,input().split())

def f(i,k,n):
     if i<k:
          m = math.ceil(math.log2(k/i))
          return ((1/2)**m)/n
     else:
          return 1/n

ans = 0
for i in range(1,n+1):
     ans += f(i,k,n)

print(ans)

Fixed submission:
import math
n,k = map(int,input().split())

def f(i,k,n):
     if i<k:
          m = math.ceil(math.log2(k/i))
          return ((1/2)**m)/n
     else:
          return 1/n

ans = 0
for i in range(1,n+1):
     ans += f(i,k,n)

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
r,g,b,n = map(int,input().split())
f = [r,g,b]
f.sort()
r,g,b = f[2],f[1],f[0]

ans = 0
R = 0

while 1:
     G = 0
     if R*r>n:
          break
     while 1:
          if R*r+G*g>n:
               break
          if (n-R*r-G*g)%b == 0:
               ans += 1
          G += 1
     R += 1
     
print(ans)

Fixed submission:
r,g,b,n = map(int,input().split())
f = [r,g,b]
f.sort()
r,g,b = f[2],f[1],f[0]

ans = 0
R = 0

while 1:
     G = 0
     if R*r>n:
          break
     while 1:
          if R*r+G*g>n:
               break
          if (n-R*r-G*g)%b == 0:
               ans += 1
          G += 1
     R += 1
     
print(ans)

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

ans = 0
R = 0

while 1:
     G = 0
     if R*r>n:
          break
     while 1:
          if R*r+G*g>n:
               break
          if (n-R*r-G*g)%b == 0:
               ans += 1
          G += 1
     R += 1
     
print(ans)

Fixed submission:
r,g,b,n = map(int,input().split())
f = [r,g,b]
f.sort()
r,g,b = f[2],f[1],f[0]

ans = 0
R = 0

while 1:
     G = 0
     if R*r>n:
          break
     while 1:
          if R*r+G*g>n:
               break
          if (n-R*r-G*g)%b == 0:
               ans += 1
          G += 1
     R += 1
     
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import functools
def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a%b)

n = int(input())
a = list(map(int,input().split()))
ans = 1

def f(a,an):
     an = max(functools.reduce(gcd, a),an)
     return an
     
for i in range(n):
     ans = f(a[:i]+a[i+1:],ans)
print(ans)


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

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

b = [a[0]]
c = [a[-1]]

for i in range(1,n):
     j = n-1-i
     b.append(gcd(b[-1],a[i]))
     c.append(gcd(c[-1],a[j]))
     
ans = max(b[-2],c[-2])
for i in range(n):
     ans = max(ans,gcd(b[i],c[n-3-i]))
print(ans)

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

n = int(input())
a = list(map(int,input().split()))
ans = 1

def f(a,ans):
     ans = max(functools.reduce(math.gcd, a),ans)
     return ans
     
for i in range(n):
     ans = f(a[:i]+a[i+1:],ans)
print(ans)

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

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

b = [a[0]]
c = [a[-1]]

for i in range(1,n):
     j = n-1-i
     b.append(gcd(b[-1],a[i]))
     c.append(gcd(c[-1],a[j]))
     
ans = max(b[-2],c[-2])
for i in range(n):
     ans = max(ans,gcd(b[i],c[n-3-i]))
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = list(input())
ans = len(s)
if min(s.count("#"),s.count("."))==0:
     ans = 0
else:
     for i in range(n):
          ans = min(ans,s[:i].count("#")+s[i:].count("."))

print(ans)

Fixed submission:
n = int(input())
s = list(input())
anslist = [s.count(".")]
for i in range(0,n):
     ans = anslist[-1]
     if s[i] == "#":
          ans += 1
     else:
          ans -= 1
     anslist.append(ans)
print(min(anslist))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
l = list(map(int, input().split()))

ans = 1
for ll in l:
  ans *= ll
  
if ans > 10**18:
  print(-1)
else:
  print(ans)


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

ans = 1
for ll in l:
  ans *= ll
  if ans > 10**18 or ans==0:
    break
  
if ans > 10**18:
  print(-1)
else:
  print(ans)

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

ans = 1
for ll in l:
  ans = ans*ll
  
if ans > 10**18:
  print(-1)
else:
  print(ans)

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

ans = 1
for ll in l:
  ans *= ll
  if ans > 10**18 or ans==0:
    break
  
if ans > 10**18:
  print(-1)
else:
  print(ans)
Buggy python submission (verdict: Runtime Error):
import math
a, b = input().split()
a = int(a)
b = round(float(b),2)
 
print(int(a*b,2))

Fixed submission:
import math
a, b = input().split()
a = int(a)
b = int(round(float(b),3)*1000)

print((a*b)//1000)
Buggy python submission (verdict: Runtime Error):
N = int(input()[:-1])

if N in [2,4,5,7,9]:
  print("hon")
elif N in [0,1,6,8]:
  print("pon")
else:
  print("bon")

Fixed submission:
N = int(input()[-1])

if N in [2,4,5,7,9]:
  print("hon")
elif N in [0,1,6,8]:
  print("pon")
else:
  print("bon")
Buggy python submission (verdict: Runtime Error):
S, W = int(map, input().split())

if S>W:
  print("safe")
else:
  print("unsafe")

Fixed submission:
S, W = map(int, input().split())

if S>W:
  print("safe")
else:
  print("unsafe")
Buggy python submission (verdict: Runtime Error):
N = int(input())

h = itertools.combinations_with_replacement(list(range(1,N+1)), 3)

import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)

ans = 0
for n1, n2, n3 in h:
  if n1 == n2 == n3:
    ans += gcd(n1,n2,n3)
  else:
    ans += gcd(n1,n2,n3)*3
print(ans)

Fixed submission:
N = int(input())

import itertools
h = itertools.combinations_with_replacement(list(range(1,N+1)), 3)

import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)

ans = 0
for n1, n2, n3 in h:
  #print("{} {} {}".format(n1,n2,n3))
  if n1 == n2 == n3:
    ans += gcd(n1,n2,n3)
  elif n1 == n2 or n1 == n3 or n2 == n3:
    ans += gcd(n1,n2,n3)*3
  else:
    ans += gcd(n1,n2,n3)*6
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import collections
N = int(input())
As = list(map(int, input().split()))

c = collections.Counter(As)

sum_ = 0
for key, val in c.items():
  sum_ += (val*(val-1)/2)

sum_ = int(sum_)

dic = {}
for i in list(set(As)):
  dic[i] = As.count(i)-1
      
for i in range(N):
  print(sum_-dic[As[i]])

Fixed submission:
import collections
N = int(input())
As = list(map(int, input().split()))

c = collections.Counter(As)

sum_ = 0
for key, val in c.items():
  sum_ += (val*(val-1)/2)

sum_ = int(sum_)

for i in range(N):
  print(sum_-(c[As[i]]-1))

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

sum_ = 0
for i in range(N):
  for j in range(N):
    if (i<=j):
      continue
    if As[i] == As[j]:
      sum_ += 1

dic = {}
for i in list(set(As)):
  dic[i] = As.count(i)-1
      
for i in range(N):
  print(sum_-dic[As[i]])

Fixed submission:
import collections
N = int(input())
As = list(map(int, input().split()))

c = collections.Counter(As)

sum_ = 0
for key, val in c.items():
  sum_ += (val*(val-1)/2)

sum_ = int(sum_)

for i in range(N):
  print(sum_-(c[As[i]]-1))

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

sum_ = 0
for i in range(N):
  for j in range(N):
    if (i == j) | (i<=j):
      continue
    if As[i] == As[j]:
      sum_ += 1
      
for i in range(N):
  print(sum_-As.count(As[i])+1)

Fixed submission:
import collections
N = int(input())
As = list(map(int, input().split()))

c = collections.Counter(As)

sum_ = 0
for key, val in c.items():
  sum_ += (val*(val-1)/2)

sum_ = int(sum_)

for i in range(N):
  print(sum_-(c[As[i]]-1))
Buggy python submission (verdict: Time Limit Exceeded):
As, Bs, Ms = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

mm = [[0 for i in range(Bs)] for j in range(As)]
for i in range(Ms):
  a, b, c = map(int, input().split())
  if c > mm[a-1][b-1]:
    mm[a-1][b-1] = c

ans = 1000000
for i,a in enumerate(A):
  for j,b in enumerate(B):
    if ans > a+b-mm[i][j]:
      ans = a+b-mm[i][j]
print(ans)

Fixed submission:
As, Bs, Ms = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

bas = min(A) + min(B)

ans = bas
for i in range(Ms):
  a, b, c = map(int, input().split())
  if A[a-1]+B[b-1]-c < ans:
    ans = A[a-1]+B[b-1]-c

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
l = [int(input())]

count = 0
while True:
  if l == []:
    break
  if l[-1] == 1:
    l.pop(-1)
  else:
    temp = l[-1]//2
    l.pop(-1)
    l.append(temp)
    l.append(temp)
  count += 1

print(count)

Fixed submission:
N = int(input())

th = 1

while True:
  if N < th*2:
    break
  else:
    th *= 2

print(th*2-1)