Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
from math import degrees, atan

a, b, x = map(int, input().split())

vol = a * a * b

def A(a, b, x):
    return degrees(atan((a * b * b) / (2 * x)))

if 2 * x > vol:
    x -= vol / 2
    tmp = A(a, a, vol / 2 - x)
    result = 90 - tmp
else:
    result = A(a, b, x)

print(result)


Fixed submission:
from math import degrees, atan

a, b, x = map(int, input().split())

vol = a * a * b

def A(a, b, x):
    return degrees(atan((a * b * b) / (2 * x)))

if vol == x:
    result = 0
elif 2 * x > vol:
    x -= vol / 2
    tmp = A(a, a, vol / 2 - x)
    result = 90 - tmp
else:
    result = A(a, b, x)

print(result)

Buggy python submission (verdict: Runtime Error):
from math import degrees, atan

a, b, x = map(int, input().split())

half_vol = a * a * b / 2

def A(a, b, x):
    return degrees(atan((a * b * b) / (2 * x)))

if x > half_vol:
    x -= half_vol
    tmp = A(a, a, half_vol - x)
    result = 90 - tmp
else:
    result = A(a, b, x)

print(result)


Fixed submission:
from math import degrees, atan

a, b, x = map(int, input().split())

vol = a * a * b

def A(a, b, x):
    return degrees(atan((a * b * b) / (2 * x)))

if vol == x:
    result = 0
elif 2 * x > vol:
    x -= vol / 2
    tmp = A(a, a, vol / 2 - x)
    result = 90 - tmp
else:
    result = A(a, b, x)

print(result)
Buggy python submission (verdict: Runtime Error):
a,b,c,d = map(int,input().split())
while(True):
    c-=b
    if(c<=0):
        print("Yes")
        exit()
    a-=d:
    if(a<=0):
        print("No")
        exit()    

Fixed submission:
a,b,c,d = map(int,input().split())
while(True):
    c-=b
    if(c<=0):
        print("Yes")
        exit()
    a-=d
    if(a<=0):
        print("No")
        exit()
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
c = 0
s = []
for i in range(n):
  ss = input()
  if not ss in s:
    c+=1
    s.append(ss)
print(c)    

Fixed submission:
n = int(input())
c = 1
s = []
for i in range(n):
  ss = input()
  s.append(ss)
s.sort()  
for j in range(1,n):
  #print(s[i],s[i-1])
  if s[j] !=s[j-1]:
    c+=1 
print(c)
Buggy python submission (verdict: Runtime Error):
s = list(map(int,input()))
for i in s:
  if i == "7":
    print("Yes")
    return
print("No")  
    

Fixed submission:
s = list(input())
for i in s:
  if i == "7":
    print("Yes")
    exit()
print("No")
Buggy python submission (verdict: Time Limit Exceeded):
n,k = map(int,input().split())
i = 0
while(i==0):
  a = abs(n-k)
  if a<n:
    n = a
  else:
    print(n)
    exit()

Fixed submission:
n,k = map(int,input().split())
i = 0
while(i==0):
  #print(n,k)
  if n>k:
    a = n%k
    if a<n:
      n = a
  else:
    a = abs(k-n)
    if a<n:
      n = a
    else:
      print(n)
      exit()
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
n,k = map(int,input().split())
s = list(map(int,input().split()))
s = np.array(s)
ans = 0
for i in range(n-k+1):
  a = (np.sum(s[i:i+k])+k)/2
  if a > ans:
    ans = a
print(ans)  

Fixed submission:
import numpy as np
n,k = map(int,input().split())
s = list(map(int,input().split()))
s = np.array(s)
ans =  np.sum(s[:k])
a = ans
for i in range(n-k):
  a = a - s[i] + s[i+k]
  if a > ans:
    ans = a  
print((ans+k)/2)

Buggy python submission (verdict: Time Limit Exceeded):
n,k = map(int,input().split())
s = list(map(int,input().split()))
ans = 0
for i in range(n):
  a = (sum(s[i:i+k])+k)/2
  if a > ans:
    ans = a
print(ans)  

Fixed submission:
import numpy as np
n,k = map(int,input().split())
s = list(map(int,input().split()))
s = np.array(s)
ans =  np.sum(s[:k])
a = ans
for i in range(n-k):
  a = a - s[i] + s[i+k]
  if a > ans:
    ans = a  
print((ans+k)/2)
Buggy python submission (verdict: Runtime Error):
n, m = map(int,input().split())
cor, war = 0,0
c = [[0,0] for k in range(n)] #[ACしたか,WA数]
for i in range(m):
  p,s = list(input().split())
  p = int(p)
  if s == "AC" and c[p][0] == 0: #初めてのACなら正答数を増やしてフラグを立て、ペナルティを誤答数分増やす
    cor += 1
    c[p][0] = 1
    war += c[p][1]
  if s == "WA" and c[p][0] == 0: #ACしていない状態でのWA数を記録
    c[p][1] += 1
print(cor,war)    
    

Fixed submission:
n, m = map(int,input().split())
cor, war = 0,0
c = [[0,0] for k in range(n)] #[ACしたか,WA数]
for i in range(m):
  p,s = list(input().split())
  p = int(p)-1
  if s == "AC" and c[p][0] == 0: #初めてのACなら正答数を増やしてフラグを立て、ペナルティを誤答数分増やす
    cor += 1
    c[p][0] = 1
    war += c[p][1]
  if s == "WA" and c[p][0] == 0: #ACしていない状態でのWA数を記録
    c[p][1] += 1
print(cor,war)
Buggy python submission (verdict: Runtime Error):
a,b,k = map(int,input().split())
if a>=k:
  print(str(a-k) + str(b))
elif a+b>=k:
  print(str(0) + str(a+b-k)
elsem
        print(0 0)

Fixed submission:
a,b,k = map(int,input().split())
if a>=k:
  print(str(a-k) + " " + str(b))
elif a+b>=k:
  print("0 " + str(a+b-k))
else:
  print("0 0")
Buggy python submission (verdict: Runtime Error):
import math
x,y = map(int,input().split())
print((x * y) // math.gcd(x, y))

Fixed submission:
from fractions import gcd
x,y = map(int,input().split())
print((x * y) // gcd(x, y))
Buggy python submission (verdict: Time Limit Exceeded):
from numpy import array
n,k,q = map(int,input().split())
s = array([k]*n)
str = array([-1]*n)
for i in range(q):
  s+=str
  num = int(input())
  s[num-1]+=1  
for j in s:
  if j<=0:
    print("No")
  else:
    print("Yes")

Fixed submission:
from numpy import array
n,k,q = map(int,input().split())
s = array([k-q]*n)
for i in range(q):
  num = int(input())
  s[num-1]+=1  
for j in s:
  if j<=0:
    print("No")
  else:
    print("Yes")
Buggy python submission (verdict: Runtime Error):
s = list(input())
s.sort()
if s[0]==s[1] and  s[2]==s[3]:
  print(Yes)
else:
  print("No")

Fixed submission:
s = list(input())
s.sort()
if s[0]==s[1] and  s[2]==s[3] and s[0]!=s[2]:
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Runtime Error):
a,b = map(int,input().split())
ans = max(a,b)
if min(a,b)>max(a.b)-1:
  ans+=min(a,b)
else:
  ans+=max(a,b)-1
print(ans)  


Fixed submission:
a,b = map(int,input().split())
ans = max(a,b)
if min(a,b)>max(a,b)-1:
  ans+=min(a,b)
else:
  ans+=max(a,b)-1
print(ans)
Buggy python submission (verdict: Runtime Error):
a,b,k = map(int,input().split(" "))
c = [1]
for i in range(1,max(a,b)):
  if a % i == 0 and b % i == 0 and i!=1:
    c.append(i)
c.sort(reverse=True)
print(c[k-1])

Fixed submission:
a,b,k = map(int,input().split(" "))
c = [1]
for i in range(1,max(a,b)+1):
  if a % i == 0 and b % i == 0 and i!=1:
    c.append(i)
c.sort(reverse=True)
print(c[k-1])

Buggy python submission (verdict: Runtime Error):
a,b,k = map(int,input().split(" "))
c = []
for i in range(1,max(a,b)):
  if a % i == 0 and b % i == 0:
    c.append(i)
c.sort(reverse=True)
print(c[k-1])

Fixed submission:
a,b,k = map(int,input().split(" "))
c = [1]
for i in range(1,max(a,b)+1):
  if a % i == 0 and b % i == 0 and i!=1:
    c.append(i)
c.sort(reverse=True)
print(c[k-1])
Buggy python submission (verdict: Runtime Error):
s = list(map(int, input()))
c = 0
count = 0
while(c==0):
  for i in range(len(s)):
    if sum(s) == len(s) or sum(s) == 0:
      c=1
      break
    if i == len(s)-1:
      break
    if len(s) == 2 and sum(s) == 1:
      count+=2
      c=1
      break  
    if s[i] + s[i+1] == 1:
      del s[i]
      del s[i]
      count += 2
      if len(s) == i+1:
        break

print(count)    
  

Fixed submission:
s = list(map(int, input()))
c1,c0=0,0
for i in s:
  if i==1:
    c1+=1
  if i==0:
    c0+=1  
print(len(s)-abs(c1-c0))
Buggy python submission (verdict: Time Limit Exceeded):
k,a,b=map(int,input().split(" "))
x=1
count=0
if a>b or b-a<2:
  print(k+1)
  exit()
while(count<k):
  if x<a and k-count>=a-x:
    count+=a-x
    x=a
  if count+2>k:
    x+=1
    break
  else:
    x=x-a+b
    count+=2
print(x)


Fixed submission:
k,a,b=map(int,input().split(" "))
x=1
count=0
if a>b or b-a<2:
  print(k+1)
  exit()
if x<a and k-count>=a-x:
  count+=a-x
  x=a
c,ex=divmod((k-count),2)
x+=(b-a)*c
if ex==1:
  x+=1
print(int(x))
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
s=[list(map(int,input().split(" "))) for k in range(n)]
ex=[]
for i in range(1,n):
  j=i
  while s[j][0]+s[j][1]>s[j-1][0]+s[j-1][1]:
    ex=s[j]
    s[j]=s[j-1]
    s[j-1]=ex
    j-=1
    if j==0:
      break
c=0
for l in range(n):
  if l%2==0:
    c+=s[l][0]
  else:
    c-=s[l][1]
print(c)    

Fixed submission:
n=int(input())
s=[list(map(int,input().split(" "))) for k in range(n)]
aa=sorted(s,key=lambda x:x[0]+x[1],reverse=True)
c=0
for l in range(n):
  if l%2==0:
    c+=aa[l][0]
  else:
    c-=aa[l][1]
print(c)
Buggy python submission (verdict: Time Limit Exceeded):
k,s=map(int,input().split(" "))
c=0
for i in range(k+1):
  for j in range(k+1):
    if i+j>s:
      break
    for l in range(k+1):
      if i+j+l==s:
        c+=1
      if i+j+l>s:
        break
print(c)       

Fixed submission:
k,s=map(int,input().split(" "))
c=0
for i in range(k+1):
  for j in range(k+1):
    if s-i-j<=k and s-i-j>=0:
      c+=1

print(c)

Buggy python submission (verdict: Time Limit Exceeded):
k,s=map(int,input().split(" "))
c=0
for i in range(k+1):
  for j in range(k+1):
    for l in range(k+1):
      if i+j+l==s:
        c+=1
      if i+j+l>s:
        break
print(c)

Fixed submission:
k,s=map(int,input().split(" "))
c=0
for i in range(k+1):
  for j in range(k+1):
    if s-i-j<=k and s-i-j>=0:
      c+=1

print(c)

Buggy python submission (verdict: Time Limit Exceeded):
k,s=map(int,input().split(" "))
c=0
for i in range(k+1):
  for j in range(k+1):
    for l in range(k+1):
      if i+j+l==s:
        c+=1
print(c)        

Fixed submission:
k,s=map(int,input().split(" "))
c=0
for i in range(k+1):
  for j in range(k+1):
    if s-i-j<=k and s-i-j>=0:
      c+=1

print(c)
Buggy python submission (verdict: Runtime Error):
h = input()
cnt = 0
while h > 0:
	h = h // 2
	cnt = cnt + 1

print(pow(2, cnt) - 1)

Fixed submission:
h = int(input())
cnt = 0
while h > 0:
  h = h // 2
  cnt = cnt + 1
     
print(int(pow(2, cnt) - 1))
Buggy python submission (verdict: Runtime Error):
import numpy as np

n, m, c = [int(x) for x in input().split(' ')]
b = np.asarray([int(x) for x in input().split(' ')])

a = np.ndarray((n, 3), dtype=np.int32)
for i in range(n):
    a[i] = [int(x) for x in input().split(' ')]


s = np.sum(a * b, axis=1)
print(np.sum(s + c > 0))


Fixed submission:
n, m, c = [int(x) for x in input().split(' ')]
b = [int(x) for x in input().split(' ')]

count = 0
for i in range(n):
    a = [int(x) for x in input().split(' ')]
    ab = sum(x * y for (x, y) in zip(a, b))
    if ab + c > 0:
        count += 1
        
print(count)
Buggy python submission (verdict: Runtime Error):
h, w = [int(s) for s in input().split(' ')]
 
s = []
for i in range(h):
    s.append([s == '.' for s in input()])
 
inf = 10000
dx = [1, 0, -1, 0]
dy = [0, 1, 0, -1]

queue = [(0, 0)]
p = []
for i in range(h):
    p.append([inf] * w)
p[0][0] = 1
 
while len(queue) > 0:
    x, y = queue.pop()
    for i in range(4):
        xx = x + dx[i]
        yy = y + dy[i]
        if 0 <= xx and xx < w and 0 <= yy and yy < h:
        	if s[yy][xx] and p[yy][xx] > p[y][x] + 1:
            	p[yy][xx] = p[y][x] + 1
           		queue.insert(0, (xx, yy))
           
if p[h-1][w-1] == inf:
    print('-1')
else:
    print(sum(sum(x) for x in s) - p[h-1][w-1])

Fixed submission:
h, w = [int(s) for s in input().split(' ')]
 
s = []
for i in range(h):
    s.append([s == '.' for s in input()])

inf = 10000
dx = [1, 0, -1, 0]
dy = [0, 1, 0, -1]
q = [(0, 0)]
p = []
for i in range(h):
    p.append([inf] * w)
p[0][0] = 1

while len(q) > 0:
    x, y = q.pop()
    for i in range(4):
        xx = x + dx[i]
        yy = y + dy[i]
        if 0 <= xx and xx < w and 0 <= yy and yy < h and s[yy][xx] and (p[yy][xx] > p[y][x] + 1):
           p[yy][xx] = p[y][x] + 1
           q.insert(0, (xx, yy))
if p[h-1][w-1] == inf:
    print('-1')
else:
    print(sum(sum(x) for x in s) - p[h-1][w-1])

Buggy python submission (verdict: Runtime Error):
h, w = [int(s) for s in input().split(' ')]
 
s = []
for i in range(h):
    s.append(input())
 
inf = 10000
dx = [1, 0, -1, 0]
dy = [0, 1, 0, -1]
queue = [(0, 0)]
d = []
for i in range(h):
    d.append([inf] * w)
d[0][0] = 1
 
while len(queue) > 0:
    x, y = queue.pop()
    for i in range(4):
        xx = x + dx[i]
        yy = y + dy[i]
        if 0 <= xx and xx < w and 0 <= yy and yy < h and s[yy][xx] == '.' and d[yy][xx] > d[y][x] + 1:
           d[yy][xx] = d[y][x] + 1
           queue.insert(0, (xx, yy))
if d[h-1][w-1] == inf:
    print('-1')
else:
    print(sum(sum(x) for x in s) - d[h-1][w-1])

Fixed submission:
h, w = [int(s) for s in input().split(' ')]
 
s = []
for i in range(h):
    s.append([s == '.' for s in input()])

inf = 10000
dx = [1, 0, -1, 0]
dy = [0, 1, 0, -1]
q = [(0, 0)]
p = []
for i in range(h):
    p.append([inf] * w)
p[0][0] = 1

while len(q) > 0:
    x, y = q.pop()
    for i in range(4):
        xx = x + dx[i]
        yy = y + dy[i]
        if 0 <= xx and xx < w and 0 <= yy and yy < h and s[yy][xx] and (p[yy][xx] > p[y][x] + 1):
           p[yy][xx] = p[y][x] + 1
           q.insert(0, (xx, yy))
if p[h-1][w-1] == inf:
    print('-1')
else:
    print(sum(sum(x) for x in s) - p[h-1][w-1])
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
get = []
count = 0
for i in range(n):
    prize = input()
    if prize in get:
        continue
    get.append(prize)
    count += 1
print(count)

Fixed submission:
n = int(input())
get = []
for i in range(n):
    prize = input()
    get.append(prize)
get = list(set(get))
print(len(get))
Buggy python submission (verdict: Time Limit Exceeded):
import itertools

n = int(input())
l = list(itertools.combinations_with_replacement([0, 1], n))[::-1]
ll = [[-1 for i in range(n)] for j in range(n)]
for i in range(n):
    a = int(input())
    for j in range(a):
        x, y = map(int, input().split())
        ll[i][x-1] = y

for i in range(len(l)):
    l2 = list(set(itertools.permutations(l[i])))
    for lst in l2:
        flag = False
        for j in range(n):
            for k in range(n):
                if ll[j][k] == -1: continue
                if lst[j] == 1:
                    if lst[k] != ll[j][k]:
                        flag = True
                        break
                elif lst[j] == 0:
                    if lst[k] == ll[j][k]:
                        flag = True
                        break
            if flag:
                break
        if not flag:
            print(lst.count(1))
            exit()
print(0)


Fixed submission:
from itertools import product
N=int(input())
XYs = []
for i in range(N):
    A = int(input())
    XYs.append([tuple(map(int, input().split())) for _ in range(A)])

n=0
for ts in product(*[[1, 0] for _ in range(N)]):
    for i, t in enumerate(ts):
        if t:
            if not all(ts[x-1] == y for x, y in XYs[i]):
                break
    else:
        n=max(n,sum(ts))
print(n)

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

n = int(input())
l = list(itertools.combinations_with_replacement([0, 1], n))[::-1]
ll = [[-1 for i in range(n)] for j in range(n)]
for i in range(n):
    a = int(input())
    for j in range(a):
        x, y = map(int, input().split())
        ll[i][x-1] = y

for i in range(len(l)):
    l2 = list(set(itertools.permutations(l[i])))
    for lst in l2:
        flag = False
        for j in range(n):
            for k in range(n):
                if ll[j][k] == -1: continue
                if lst[j] == 1:
                    if lst[k] != ll[j][k]:
                        flag = True
                        break
                elif lst[j] == 0:
                    if lst[k] == ll[j][k]:
                        flag = True
                        break
            if flag:
                break
        if not flag:
            print(lst.count(1))
            exit()
print(0)


Fixed submission:
from itertools import product
N=int(input())
XYs = []
for i in range(N):
    A = int(input())
    XYs.append([tuple(map(int, input().split())) for _ in range(A)])

n=0
for ts in product(*[[1, 0] for _ in range(N)]):
    for i, t in enumerate(ts):
        if t:
            if not all(ts[x-1] == y for x, y in XYs[i]):
                break
    else:
        n=max(n,sum(ts))
print(n)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
sys.setrecursionlimit(10**7)

def dfs(x, y):
    cnt = 0
    if x == xn and y == yn:
        return 1
    if x+1 > xn or y+1 > yn:
        return 0
    cnt += dfs(x+1,y+2)
    cnt += dfs(x+2,y+1)
    return cnt


xn,yn=map(int, input().split())
print(dfs(0,0)%(10**9+7))


Fixed submission:
from numpy.linalg import solve


def COM(n, r):
    fac = [1, 1]
    finv = [1, 1]
    inv = [0, 1]
    for i in range(2, MAX):
        fac.append(fac[i - 1] * i % MOD)
        inv.append(-inv[MOD % i] * (MOD // i))
        finv.append(finv[i - 1] * inv[i] % MOD)
    if n < r:
        return 0
    if n < 0 or r < 0:
        return 0
    return fac[n] * (finv[r] * finv[n - r] % MOD) % MOD


MOD = 10 ** 9 + 7
MAX = 10**6
x, y = map(int, input().split())
if (x + y) % 3 != 0:
    print(0)
    exit(0)
l = solve([[2, 1], [1, 2]], [x, y])
if l[0] < 0 or l[1] < 0:
    print(0)
    exit(0)
print(COM(int(l[0]+l[1]), int(l[0])))
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
l=sorted([int(i)for i in input().split()])
sum=0
for i in range(n-2):
    for j in range(i+1, n-1):
        for k in range(j+1, n):
            if l[i]+l[j]>l[k]:
                sum+=1
            else:
                break
print(sum)

Fixed submission:
import bisect

n = int(input())
l = [int(i) for i in input().split()]
l.sort()

cnt = 0
for a in range(n):
    for b in range(a+1, n):
        c = bisect.bisect_left(l, l[a] + l[b])
        if c > b:
            cnt += c - b - 1
print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
from itertools import combinations
n=int(input())
l=[int(i)for i in input().split()]
l2=list(combinations(l, 3))
sum=0
for i in range(len(l2)):
    a=l2[i][0]
    b=l2[i][1]
    c=l2[i][2]
    if(a<b+c and b<c+a and c<a+b):
        sum+=1
print(sum)

Fixed submission:
import bisect

n = int(input())
l = [int(i) for i in input().split()]
l.sort()

cnt = 0
for a in range(n):
    for b in range(a+1, n):
        c = bisect.bisect_left(l, l[a] + l[b])
        if c > b:
            cnt += c - b - 1
print(cnt)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = [int(i) for i in input().split()]
for i in range(1, n + 1):
  if i != n:
    print(a.index(i) + 1, end=" ")
  else:
    print(a.index(i) + 1)


Fixed submission:
n = int(input())
a = [int(i) - 1 for i in input().split()]
ans = [-1 for _ in range(n)]
for i in range(n):
  ans[a[i]] = i
for i in range(n):
  print(ans[i] + 1, end=" ")
Buggy python submission (verdict: Time Limit Exceeded):
n,m=map(int,input().split())
a=[int(i) for i in input().split()]
for i in range(m):
  A=max(a)
  ind=a.index(A)
  a[ind]=A//2
print(sum(a))

Fixed submission:
import heapq

n, m = map(int, input().split())
a = [int(i) * (-1) for i in input().split()]
heapq.heapify(a)
for _ in range(m):
    heapq.heappush(a, heapq.heappop(a) * (-1) // 2 * (-1))
print(-sum(a))

Buggy python submission (verdict: Runtime Error):
import copy
n,m=map(int, input().split())
a=sorted([int(i) for i in input().split()],reverse=True)
if n==1:
    print(a[0]//(2**m))
    exit()
def solve(cnt, coupon, now):
    ans = 10 ** 10
    if cnt==m:
        tmp=0
        for i in range(n):
            tmp+=a[i]//(2**coupon[i])
        return tmp
    nowcp=coupon
    for i in range(1,m-cnt+1):
        temp=copy.copy(nowcp)
        temp[now]=i
        ans=min(ans,solve(cnt+i,temp, now+1))
    return ans
print(solve(0,[0 for _ in range(n)], 0))

Fixed submission:
import heapq

n, m = map(int, input().split())
a = [int(i) * (-1) for i in input().split()]
heapq.heapify(a)
for _ in range(m):
    heapq.heappush(a, heapq.heappop(a) * (-1) // 2 * (-1))
print(-sum(a))
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=0
for i in range(1,n):
    a+=i
print(a)

Fixed submission:
n=int(input())
print((n-1)*n//2)
Buggy python submission (verdict: Runtime Error):
n=int(input())
a=[int(i)for i in input().split())]
x=0
for i in a:
    x+=1/i
print(1/x)

Fixed submission:
n=int(input())
a=[int(i)for i in input().split()]
x=0
for i in a:
    x+=1/i
print(1/x)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
L=[sorted(list(input()))for i in range(n)]
x=0
while L!=[]:
    a=L.count(L[0])
    if a!=1:
        x+=a*(a-1)//2
    L=[l for l in L if l!=L[0]]
print(x)

Fixed submission:
import collections
n=int(input())
L=["".join(sorted(input()))for _ in range(n)]
C=collections.Counter(L)
a=0
for i in set(L):
    n=C[i]
    a+=n*(n-1)//2
print(a)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
L=[sorted(list(input()))for i in range(n)]
c=0
for i in range(n):
    for j in range(i+1,n):
        if L[i]==L[j]:
            c+=1
print(c)

Fixed submission:
import collections
n=int(input())
L=["".join(sorted(input()))for _ in range(n)]
C=collections.Counter(L)
a=0
for i in set(L):
    n=C[i]
    a+=n*(n-1)//2
print(a)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
H=[int(i) for i in input().split()]
for i in range(n):
    if i!=0:
        H=H[:-1]
    if max(H)-H[-1]>1:
        print("No")
        exit(0)
print("Yes")

Fixed submission:
n=int(input())
H=[int(i) for i in input().split()]
for i in range(n-1,0,-1):
    if H[i]<H[i-1]:
        H[i-1]-=1
        if H[i]<H[i-1]:
            print("No")
            exit()
print("Yes")

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
H=[int(i) for i in input().split()]
for i in range(n):
    if i!=0:
        H=H[:-1]
    if max(H)-H[-1]>1:
        print("No")
        exit(0)
print("Yes")

Fixed submission:
n=int(input())
H=[int(i) for i in input().split()]
for i in range(n-1,0,-1):
    if H[i]<H[i-1]:
        H[i-1]-=1
        if H[i]<H[i-1]:
            print("No")
            exit()
print("Yes")

Buggy python submission (verdict: Runtime Error):
n=int(input())
H=[int(i) for i in input().split()]
for i in range(n):
    if i!=0:
        H=H[:-1]
    if max(H)-H(-1)>1:
        print("No")
        exit(0)
print("Yes")

Fixed submission:
n=int(input())
H=[int(i) for i in input().split()]
for i in range(n-1,0,-1):
    if H[i]<H[i-1]:
        H[i-1]-=1
        if H[i]<H[i-1]:
            print("No")
            exit()
print("Yes")

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
H=[int(i) for i in input().split()]
for i in range(n):
    if i!=0:
        H=H[:-1]
    if max(list(map(lambda x:x-H[-1],H)))>1:
        print("No")
        exit(0)
print("Yes")

Fixed submission:
n=int(input())
H=[int(i) for i in input().split()]
for i in range(n-1,0,-1):
    if H[i]<H[i-1]:
        H[i-1]-=1
        if H[i]<H[i-1]:
            print("No")
            exit()
print("Yes")
Buggy python submission (verdict: Runtime Error):
s=int(input())
l=[]
while s>0:
  l.append(s%100)
  s//=100
print("AMBIGUOUS" if 1<=l[0]<=12 and 1<=l[1]<=12 else "YYMM" if 1<=l[0]<=12 else "MMYY" if 1<=l[1]<=12 else "NA")

Fixed submission:
s=input()
a=int(s[:2])
b=int(s[2:])
print("AMBIGUOUS" if 1<=a<=12 and 1<=b<=12 else "YYMM" if 1<=b<=12 else "MMYY" if 1<=a<=12 else "NA")