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

from collections import Counter
counter=Counter(a)

# 番号nを取り除いた時の組み合わせをメモする
memo={}
def calc_combi_if_exclude(n):
    if n in memo:
        return memo[n]
    else:
        combi=0
        for num,cnt in counter.items():
            n_cnt=cnt
            if num==n:
                n_cnt-=1
            combi+=n_cnt*(n_cnt-1)//2
        memo[n]=combi
        return combi
    
for i in range(n):
    combi=0
    print(calc_combi_if_exclude(a[i]))

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

from collections import Counter
counter=Counter(a)

# すべての組み合わせを事前に計算しておく
combi_sum=0
for num,cnt in counter.items():
    combi_sum+=cnt*(cnt-1)//2

for i in range(n):
    print(combi_sum - counter[a[i]] + 1)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
n = int(input())
a = list(map(int, input().split()))
counter=Counter(a)
#print(a)
def calc_combi(n,m):
    a1=1
    a2=1
#    print(f'n={n} m={m}')
    for i in range(m):
        a1*=(n-i)
        a2*=(i+1)
#        print(f'a1={a1} a2={a2}')
    return a1//a2
#print(counter)
for i in range(n):
    combi=0
    for num,cnt in counter.items():
#        print(f'num={num} cnt={cnt}')
        n_cnt=cnt
        if num==a[i]:
            n_cnt-=1
        combi+=calc_combi(n_cnt ,2)
    print(combi)

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

from collections import Counter
counter=Counter(a)

# すべての組み合わせを事前に計算しておく
combi_sum=0
for num,cnt in counter.items():
    combi_sum+=cnt*(cnt-1)//2

for i in range(n):
    print(combi_sum - counter[a[i]] + 1)
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

K = int(input())
print([1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51][K+1])


Fixed submission:
# -*- coding: utf-8 -*-

K = int(input())
print([1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51][K-1])
Buggy python submission (verdict: Runtime Error):
from collections import deque
s = input()
q = int(input())
que = deque([s])
flg=False
for _ in range(q):
    a = list(input().split())
    if a[0]=='1':
        flg=not(flg)
#        s=s[::-1]
    else:
        if flg ^ a[1]!='1':
            que.append(a[2])
        else:
            que.appendleft(a[2])

ans = ''.join(que)

if flg:
    ans = ans[::-1]
print(ans)

Fixed submission:
from collections import deque
s = input()
q = int(input())
que = deque([s])
flg=False
for _ in range(q):
    a = list(input().split())
    if a[0]=='1':
        flg=not(flg)
#        s=s[::-1]
    else:
        if flg and a[1]=='1' or not flg and a[1]=='2':
            que.append(a[2])
        else:
            que.appendleft(a[2])

ans = ''.join(que)

if flg:
    ans = ans[::-1]
print(ans)

Buggy python submission (verdict: Runtime Error):
from collections import deque
s = input()
q = int(input())
que = deque([s])
flg=False
for _ in range(q):
    a = list(input().split())
    if a[0]=='1':
        flg=not(flg)
#        s=s[::-1]
    else:
        if flg ^ a[1]!='1':
            que.append(a[2])
        else:
            que.appendleft(a[2])

ans = ''.join(que)

if flg:
    ans = ans[::-1]
print(ans)

Fixed submission:
from collections import deque
s = input()
q = int(input())
que = deque([s])
flg=False
for _ in range(q):
    a = list(input().split())
    if a[0]=='1':
        flg=not(flg)
#        s=s[::-1]
    else:
        if flg and a[1]=='1' or not flg and a[1]=='2':
            que.append(a[2])
        else:
            que.appendleft(a[2])

ans = ''.join(que)

if flg:
    ans = ans[::-1]
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
q = int(input())
for _ in range(q):
    a = list(input().split())
    if a[0]=="1":
        s=s[::-1]
    else:
        if a[1]=='1':
            s=a[2]+s
        else:
            s=s+a[2]

print(s)

Fixed submission:
from collections import deque
s = input()
q = int(input())
que = deque([s])
flg=False
for _ in range(q):
    a = list(input().split())
    if a[0]=='1':
        flg=not(flg)
#        s=s[::-1]
    else:
        if flg and a[1]=='1' or not flg and a[1]=='2':
            que.append(a[2])
        else:
            que.appendleft(a[2])

ans = ''.join(que)

if flg:
    ans = ans[::-1]
print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
from collections import defaultdict
d=defaultdict(int)
for _ in range(n):
    d[input()]+=1

L=[(v,k) for (k,v) in d.items()]
L.sort(reverse=True)
max_cnt=L[0][0]
#print('*'*30)
ans=[]
for l in L:
    if l[0]==max_cnt:
        ans.append(l[1])
    else :
        break

for a in ans:
    print(ans)

Fixed submission:
n = int(input())
from collections import defaultdict
d=defaultdict(int)

max_cnt=-1
for _ in range(n):
    s=input()
    d[s]+=1
    max_cnt=max(max_cnt, d[s])


ans=sorted([k for (k,v) in d.items() if v==max_cnt])
    
for a in ans:
    print(a)
Buggy python submission (verdict: Runtime Error):
p = list(map(int, input().split()))

def exp(x):
    return (1+x)/2

import numpy as np
cums=np.cumsum([0] + [exp(i) for i in p])

ans=0
for i in range(n-k+1):
    ans=max(ans, cums[i+k]-cums[i])

print(ans)

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

def exp(x):
    return (1+x)/2

total=sum([exp(i) for i in p[:k]])
ans=total
bk=ans
for i in range(1, n-k+1):
    start=i-1
    end=start+k
    total=bk-exp(p[start])+exp(p[end])
    ans=max(ans, total)
    bk=total
    
print(ans)
Buggy python submission (verdict: Runtime Error):
n,k,s = list(map(int, input().split()))
if s<10**9:
    ans=[s]*k+[s+1]*(n-k)
else:
    ans=[s]*k+[1]*(n-k)
print(*ans)

Fixed submission:
h = int(input())
w = int(input())
n = int(input())

q,r = divmod(n, max(h,w))
print(q + int(bool(r)))
Buggy python submission (verdict: Runtime Error):
s,t = list(map(int, input().split()))
print(s+t)

Fixed submission:
s,t = input().split()
print(t+s)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
def f(x):
    b = '0' * 64 + bin(x)[2:]
    b = b[::-1]
    b = b[:64]
    return list(map(int, list(b)))

bit_count = [0] * 64
for i in a:
    b = f(i)
    for j in range(64):
        bit_count[j] += b[j]

ans = 0
for i in range(64):
    bc = bit_count[i]
    ans += (2**i) * bc * (n - bc)
    ans %= 10**9 + 7

print(ans)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
def f(x):
    b = '0' * 64 + bin(x)[2:]
    b = b[::-1]
    b = b[:64]
    return list(map(int, list(b)))

bit_count = [0] * 64
for i in a:
    b = f(i)
    for j in range(64):
        bit_count[j] += b[j]

ans = 0
for i in range(64):
    bc = bit_count[i]
    ans += (2**i) * bc * (n - bc)
    ans %= 10**9 + 7

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
from itertools import combinations

n = int(input())
s = input()

print(len(set([a+b+c for a,b,c in combinations(s, 3)])))

Fixed submission:
from collections import defaultdict
import bisect
from itertools import product

n = int(input())
s = input()

# {文字:その文字の出現位置}の辞書を構築
d = defaultdict(list)
for i in range(n):
    d[s[i]].append(i)

def canCreate(x,y,z):
    pos = 0
    for c in map(str, [x,y,z]):
        pos = bisect.bisect_left(d[c], pos)
        if pos == len(d[c]):
            return False
        pos = d[c][pos] + 1
    return True

ans = sum([canCreate(x, y, z) for x,y,z in product(range(10), repeat=3)])

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import re
n = int(input())
s = input()

ans=0
for i in range(1000):
    reg = '{}.*{}.*{}'.format(i//100, i%100//10, i%10)
    if re.search(reg, s):
        ans += 1

print(ans)

Fixed submission:
from collections import defaultdict
import bisect
from itertools import product

n = int(input())
s = input()

# {文字:その文字の出現位置}の辞書を構築
d = defaultdict(list)
for i in range(n):
    d[s[i]].append(i)

def canCreate(x,y,z):
    pos = 0
    for c in map(str, [x,y,z]):
        pos = bisect.bisect_left(d[c], pos)
        if pos == len(d[c]):
            return False
        pos = d[c][pos] + 1
    return True

ans = sum([canCreate(x, y, z) for x,y,z in product(range(10), repeat=3)])

print(ans)
Buggy python submission (verdict: Runtime Error):
s = input()
k = int(input())
def seqcnt(s):
    cnt=1
    ans=0
    bk=''
    for c in s+' ':
        print(f'bk={bk} c={c}')
        if bk==c:
            cnt+=1
        else:
            ans+=(cnt)//2
            cnt=1
        bk=c
    return ans

cnt=seqcnt(s)
cnt2=seqcnt(s*2)    
print(f'cnt={cnt} cnt2={cnt2}')
if len(set(list(s)))==1:
    if len(s)%2==0:
        print(cnt*k)
    else:
        print(cnt*(k//2)+(cnt2-cnt)*(k-k//2))
else:
    print(cnt+(cnt2-cnt)*(k-1))

Fixed submission:
s = input()
k = int(input())
def seqcnt(s):
    cnt=1
    ans=0
    bk=''
    for c in s+' ':
        if bk==c:
            cnt+=1
        else:
            ans+=(cnt)//2
            cnt=1
        bk=c
    return ans

cnt=seqcnt(s)
cnt2=seqcnt(s*2)    
if len(set(list(s)))==1:
    print(len(s)*k//2)
else:
    print(cnt+(cnt2-cnt)*(k-1))
Buggy python submission (verdict: Time Limit Exceeded):
import sys
from collections import defaultdict
sys.setrecursionlimit(10**9)

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

graph = defaultdict(list)
for _ in range(n-1):
    p,c = list(map(int, input().split()))
    graph[p].append(c)
    graph[c].append(p)

counter = defaultdict(int)
for _ in range(q):
    i,c = list(map(int, input().split()))
    counter[i] += c

ans = [0] * (n + 1)
visit = [False] * (n + 1)
def dfs(node, total_counter):
    visit[node] = True
    total_counter += counter.get(node, 0)
    
    for child in graph[node]:
        if not visit[child]:
            dfs(child, total_counter)
    ans[node] = total_counter

dfs(1, 0)

print(*ans[1:])

Fixed submission:
import sys
from collections import defaultdict
sys.setrecursionlimit(10**9)

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

graph = defaultdict(list)
for _ in range(n-1):
    p,c = list(map(int, input().split()))
    graph[p].append(c)
    graph[c].append(p)

counter = defaultdict(int)
for _ in range(q):
    i,c = list(map(int, input().split()))
    counter[i] += c

ans = [0] * (n + 1)
visit = [False] * (n + 1)
def dfs(node, total_counter):
    visit[node] = True
    total_counter += counter.get(node, 0)
    
    for child in graph[node]:
        if not visit[child]:
            dfs(child, total_counter)
    ans[node] = total_counter

dfs(1, 0)

print(*ans[1:])
Buggy python submission (verdict: Runtime Error):
n,a,b = list(map(int, input.split()))

print(min(n*a, b))


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

print(min(n*a, b))
Buggy python submission (verdict: Time Limit Exceeded):
def mod2019(x):
    return x%2019

L,R = list(map(int, input().split()))
a=list(set([mod2019(i) for i in range(L,R+1)]))
ans=2019
for i in range(len(a)):
    for j in range(i+1, len(a)):
        ans = min(ans, mod2019(a[i]*a[j]))
print(ans)

Fixed submission:
def mod2019(x, y):
    return (x%2019 * y%2019 ) % 2019

L,R = list(map(int, input().split()))
ans=2019
s=set()
for i in range(L,R+1):
    if i%2019 in s:
        break
    s.add(i%2019)
l = list(s)
for i in range(len(l)):
    for j in range(i+1, len(l)):
#        print(i, j, l[i], l[j], mod2019(l[i], l[j]))
        ans=min(ans, mod2019(l[i], l[j]))
    
print(ans)
Buggy python submission (verdict: Runtime Error):
MOD=10**10+7
n,m = list(map(int, input().split()))
a = set([int(input()) for _ in range(m)])

dp = [0] * (n+1)

if 1 in a and 2 in a:
    print(0)
    exit()
elif 1 in a:
    dp[2]=1
    dp[3]=2
    start=4
elif 2 in a:
    dp[1]=1
    dp[3]=2
    start=4
else:
    dp[1]=1
    dp[2]=2
    start=3
    
for step in range(start, n+1):
    if dp[step-1]==0 and dp[step-2]==0:
        break
    if step not in a:
        dp[step] = (dp[step-1] + dp[step-2])%MOD
print(dp[-1])

Fixed submission:
MOD=10**9+7
n,m = list(map(int, input().split()))
a = set([int(input()) for _ in range(m)])

dp = [0] * (n+1)

dp[0] = 1
dp[1] = int(1 not in a)
for step in range(2, n+1):
    if dp[step-1]==0 and dp[step-2]==0:
        break
    if step not in a:
        dp[step] = (dp[step-1] + dp[step-2])%MOD
    else:
        dp[step] = 0
        
print(dp[-1])
Buggy python submission (verdict: Time Limit Exceeded):
h,w = list(map(int, input().split()))
b = [input() + '#' for _ in range(h)]
b.append('#' * (w + 1))
ans = [[0]*w for _ in range(h)]

for r in range(h):
    c = 0
    while c < w:
        if b[r][c] == '#':
            c += 1
        else:
            st = c
            while b[r][c] == '.':
                c += 1
            for i in range(st, c):
                ans[r][i] += (c - st)

for c in range(w):
    r = 0
    while r < h:
        if b[r][c] == '#':
            r += 1
        else:
            st = r
            while b[r][c] == '.':
                r += 1
            for i in range(st, r):
                ans[i][c] += (r - st)

import itertools
print(max(itertools.chain.from_iterable(ans))-1)


Fixed submission:
h,w = list(map(int, input().split()))
b = [input() + '#' for _ in range(h)]
b.append('#' * (w + 1))
ans = [[0]*w for _ in range(h)]

for r in range(h):
    c = 0
    while c < w:
        if b[r][c] == '#':
            c += 1
        else:
            st = c
            while b[r][c] == '.':
                c += 1
            for i in range(st, c):
                ans[r][i] += (c - st)

for c in range(w):
    r = 0
    while r < h:
        if b[r][c] == '#':
            r += 1
        else:
            st = r
            while b[r][c] == '.':
                r += 1
            for i in range(st, r):
                ans[i][c] += (r - st)

import itertools
print(max(itertools.chain.from_iterable(ans))-1)
Buggy python submission (verdict: Time Limit Exceeded):
import heapq
push, pop = heapq.heappush, heapq.heappop

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

heapq.heapify(a)
for _ in range(m):
    b,c = list(map(int, input().split()))
    for _ in range(b):
        p = pop(a)
        if p < c:
            push(a, c)
        else:
            # キューに戻す
            push(a, p)
            break
print(sum(a))

Fixed submission:
import heapq
push, pop = heapq.heappush, heapq.heappop

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

def modify():
    heapq.heapify(a)
    
    bc = [list(map(int, input().split())) for _ in range(m)]
    bc.sort(key=lambda x:x[1], reverse=True)
    
    for b,c in bc:
        for _ in range(b):
            p = pop(a)
            if p < c:
                push(a, c)
            else:
                # キューに戻す
                push(a, p)
                return

modify()            
print(sum(a))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
v = list(map(int, input().split()))
c = list(map(int, input().split()))
ans=-10*18
for i in range(1<<n):
    mask=[(i>>j)&1 for j in range(n)]
    X=0
    Y=0
    for k, m in enumerate(mask):
        if m==1:
            X+=v[k]
            Y+=c[k]
    ans=max(ans, X-Y)
    
print(ans)

Fixed submission:
n = int(input())
v = list(map(int, input().split()))
c = list(map(int, input().split()))
ans=-10*18
for i in range(1<<n):
    mask=[(i>>j)&1 for j in range(n)]
    X=0
    Y=0
    for k, m in enumerate(mask):
        if m==1:
            X+=v[k]
            Y+=c[k]
    ans=max(ans, X-Y)
    
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N,Q = list(map(int, input().split()))
s = input()

import re
pos = [m.end() for m in re.finditer(r'AC', s)]

def cnt(at):
    ret=0
    for p in pos:
        if p>at:
            break
        ret+=1
    return ret

ans=[]    
for _ in range(Q):
    l,r = list(map(int, input().split()))
    ans.append(cnt(r)-cnt(l))

print(*ans, sep='\n')

Fixed submission:
import re
import itertools

N,Q = list(map(int, input().split()))
s = input()

pos = [m.end() for m in re.finditer(r'AC', s)]

dp = [0] * (N+1)
for p in pos:
    dp[p] = 1
dp = list(itertools.accumulate(dp))

ans=[]    
for _ in range(Q):
    l,r = list(map(int, input().split()))
    ans.append(dp[r]-dp[l])

print(*ans, sep='\n')

Buggy python submission (verdict: Time Limit Exceeded):
n,q = list(map(int, input().split()))
s = input()
questions = [list(map(int, input().split())) for _ in range(q)]

for l,r in questions:
    sub = s[l-1:r]
    print(sub.count('AC'))


Fixed submission:
import re
import itertools

N,Q = list(map(int, input().split()))
s = input()

pos = [m.end() for m in re.finditer(r'AC', s)]

dp = [0] * (N+1)
for p in pos:
    dp[p] = 1
dp = list(itertools.accumulate(dp))

ans=[]    
for _ in range(Q):
    l,r = list(map(int, input().split()))
    ans.append(dp[r]-dp[l])

print(*ans, sep='\n')
Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
S = input()
s=S
ans=0
while True:
    s=s.replace('10','')
    s=s.replace('01','')

    cnt10=s.count('10')
    cnt01=s.count('01')
       
    if cnt10==0 and cnt01==0:
        break
print(len(S)-len(s))

Fixed submission:
# -*- coding: utf-8 -*-
s = input()
print(len(s)-abs(s.count('0')-s.count('1')))
Buggy python submission (verdict: Time Limit Exceeded):
n,k = list(map(int, input().split()))
h = list(map(int, input().split()))

dp = [0] * n

dp[0]=0
for i in range(1, n):
    dp[i] = min([dp[j]+abs(h[i]-h[j]) for j in range(max(i-k, 0), i)])

print(dp[n-1])

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

dp = [0] * n

dp[0]=0
for i in range(1, n):
    dp[i] = min([dp[j]+abs(h[i]-h[j]) for j in range(max(i-k, 0), i)])

print(dp[n-1])
Buggy python submission (verdict: Runtime Error):
n,m = list(map(int, input().split()))
s = input()
t = input()
import math

# 良い文字列が作れるなら、答えはLCM(n, m)となる
lcm = n * m // math.gcd(n, m)

x = ['*'] * lcm
for i,c in enumerate(s):
    # (pos, char)
    x[lcm//n*i] = c

for i,c in enumerate(t):
    # (pos, char)
    pos, char = lcm//m*i, c
    if x[pos] != '*' and x[pos] != char:
        print(-1)
        exit()

print(lcm)

Fixed submission:
n,m = list(map(int, input().split()))
s = input()
t = input()
import math

# 良い文字列が作れるなら、答えはLCM(n, m)となる
lcm = n * m // math.gcd(n, m)

x = {}
for i,c in enumerate(s):
    # (pos, char)
    x[lcm//n*i] = c

for i,c in enumerate(t):
    # (pos, char)
    pos, char = lcm//m*i, c
    if pos in x and x[pos] != char:
        print(-1)
        exit()

print(lcm)

Buggy python submission (verdict: Runtime Error):
n,m = list(map(int, input().split()))
s = input()
t = input()
import math

# 良い文字列が作れるなら、答えはLCM(n, m)となる
lcm = n * m // math.gcd(n, m)

S = len(s)
T = len(t)
x = ['*'] * lcm
for i,c in enumerate(s):
    # (pos, char)
    x[lcm//S*i] = c

for i,c in enumerate(t):
    # (pos, char)
    pos, char = lcm//T*i, c
    if x[pos] != '*' and x[pos] != char:
        print(-1)
        exit()

print(lcm)

Fixed submission:
n,m = list(map(int, input().split()))
s = input()
t = input()
import math

# 良い文字列が作れるなら、答えはLCM(n, m)となる
lcm = n * m // math.gcd(n, m)

x = {}
for i,c in enumerate(s):
    # (pos, char)
    x[lcm//n*i] = c

for i,c in enumerate(t):
    # (pos, char)
    pos, char = lcm//m*i, c
    if pos in x and x[pos] != char:
        print(-1)
        exit()

print(lcm)
Buggy python submission (verdict: Runtime Error):
X = int(input())
tab = set([])
for i in range(1,X+1):
    for j in range(2,X+1):
        if i**j <= X:
            tab.add(i**j)
        else:
            break
print(max([i for i in tab]))

Fixed submission:
X = int(input())
tab = set([])
for i in range(1,1000):
    for j in range(2,1000):
        if i**j <= 1000:
            tab.add(i**j)
        else:
            break

print(max([i for i in tab if i <= X]))

Buggy python submission (verdict: Runtime Error):
X = int(input())
tab = set([])
for i in range(1,X+1):
    for j in range(2,X+1):
        if i**j <= X:
            tab.add(i**j)
        else:
            break
print(max([i for i in tab]))

Fixed submission:
X = int(input())
tab = set([])
for i in range(1,1000):
    for j in range(2,1000):
        if i**j <= 1000:
            tab.add(i**j)
        else:
            break

print(max([i for i in tab if i <= X]))
Buggy python submission (verdict: Runtime Error):
N, X = list(map(int, input().split()))
m = []
for i in N:
    m.append(i)
    
ans = len(m)

X -= sum(m)
ans += X//min(m)

Fixed submission:
# -*- coding: utf-8 -*-
N, X = list(map(int, input().split()))
m = []
for i in range(N):
    m.append(int(input()))
    
ans = len(m)

X -= sum(m)
ans += X//min(m)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
a,b,k = list(map(int, input().split()))
ans = range(a, b+1)
for i in ans:
    if a + k <= i <= b - k:
        continue
    print(i)

Fixed submission:
a,b,k = list(map(int, input().split()))
ans = []
for i in range(k):
    n = a + i
    if n > b:
        break
    ans.append(n)

st = b - k + 1
st = max(st, ans[-1]+1)
for i in range(st, b+1):
    ans.append(i)

print(*ans, sep='\n')
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
n = int(input())
a = int(input())

print('Yes' if n%500 =< a else 'No')

Fixed submission:
# -*- coding: utf-8 -*-
n = int(input())
a = int(input())

print('Yes' if n%500 <= a else 'No')
Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
n = int(input())
a = list(map(int, input().split()))

a_set = set(a)
a_map = {i:a.count(i) for i in a_set}
print(sum([cnt-i if i < cnt else cnt for i, cnt in a_map.items() if i != cnt]))
    


Fixed submission:
from collections import defaultdict
n = int(input())
a = list(map(int, input().split()))

a_map=defaultdict(int)
for i in a:
    a_map[i] += 1
print(sum([cnt-i if i < cnt else cnt for i, cnt in a_map.items() if i != cnt]))
Buggy python submission (verdict: Runtime Error):
n = int(input())
t = [int(input()) for _ in range(n)]

import math
n = t[0]
for a,b in zip(t, t[1:]):
    g = math.gcd(n, b)
    n = a*b//g
print(n)

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

import fractions
n = t[0]
for a,b in zip(t, t[1:]):
    g = fractions.gcd(n, b)
    n = n*b//g
print(n)
Buggy python submission (verdict: Time Limit Exceeded):
m,n = list(map(int, input().split()))
MOD=10**9+7
if abs(m-n) > 1:
    print(0)
    exit()

def fact(x):
    ans=1
    for i in range(2, x+1):
        ans*=i%MOD
    return ans

if m>n:
    n,m = m,n
    
f = fact(m)
if m==n:
    print(f * f * 2 % MOD)
else:
    print(f * f * n % MOD)

Fixed submission:
m,n = list(map(int, input().split()))
MOD=10**9+7
if abs(m-n) > 1:
    print(0)
    exit()

def fact(x):
    ans=1
    for i in range(2, x+1):
        ans=ans%MOD*i
    return ans

if m>n:
    n,m = m,n
    
f = fact(m)
if m==n:
    print(f * f * 2 % MOD)
else:
    print(f * f * n % MOD)

Buggy python submission (verdict: Time Limit Exceeded):
m,n = list(map(int, input().split()))
MOD=10**9+7
if abs(m-n) > 1:
    print(0)
    exit()

def fact(x, mod):
    ans=1
    for i in range(2, x+1):
        ans*=i%mod
    return ans

if m>n:
    n,m = m,n
    
f = fact(m,MOD)
if m==n:
    print(f * f * 2 % MOD)
else:
    print(f * f * n % MOD)

Fixed submission:
m,n = list(map(int, input().split()))
MOD=10**9+7
if abs(m-n) > 1:
    print(0)
    exit()

def fact(x):
    ans=1
    for i in range(2, x+1):
        ans=ans%MOD*i
    return ans

if m>n:
    n,m = m,n
    
f = fact(m)
if m==n:
    print(f * f * 2 % MOD)
else:
    print(f * f * n % MOD)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
DIV=10**9+7
s=1
for i in range(1,n+1):
    s*=i
print(s%DIV)

Fixed submission:
n = int(input())
DIV=10**9+7
s=1
for i in range(1,n+1):
    s=(s*i)%int(DIV)
print(s)
Buggy python submission (verdict: Runtime Error):
N,K = list(map(int, input().split()))
D = set(input().split())

# シミュレーションでいける
for ans in range(N,10000):
    if all(d not in D for d in str(ans)):
        print(ans)
        exit()

raise AssertionError('バグってる')    

Fixed submission:
N,K = list(map(int, input().split()))
D = set(input().split())

# シミュレーションでいける
for ans in range(N,100000):
    if all(d not in D for d in str(ans)):
        print(ans)
        exit()

raise AssertionError('バグってる')