Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
import sys
 
stdin = sys.stdin
inf = 1 << 60
mod = 1000000007
 
ni = lambda: int(ns())
nin = lambda x: [ni() for _ in range(x)]
na = lambda: list(map(int, stdin.readline().split()))
nan = lambda x: [na() for _ in range(x)]
ns = lambda: stdin.readline().rstrip()
nsn = lambda x: [ns() for _ in range(x)]
nas = lambda: stdin.readline().split()

a, b = na()

def is_prime(n):
    if n < 2:
        return False
    i = 2
    while i * i <= n:
        if n % i == 0:
            return False
        i += 1
    return True

def primes(n):
    p = []
    i = 1
    while i * i <= n:
        if is_prime(i) or i == 1:
            p.append(i)
        if is_prime(n // i):
            p.append(n // i)
        i += 1
    return p

def p_fact(n):
    f = []
    for i in primes(n):
        if n % i == 0:
            f.append(i)
    return f

c, d = p_fact(a), p_fact(b)
e = [i if i in d else 1 for i in c]
f = set(e)
print(len(f))

Fixed submission:
import sys
 
stdin = sys.stdin
inf = 1 << 60
mod = 1000000007
 
ni = lambda: int(ns())
nin = lambda x: [ni() for _ in range(x)]
na = lambda: list(map(int, stdin.readline().split()))
nan = lambda x: [na() for _ in range(x)]
ns = lambda: stdin.readline().rstrip()
nsn = lambda x: [ns() for _ in range(x)]
nas = lambda: stdin.readline().split()

from collections import defaultdict

a, b = na()

def prime_fact(n):
    f = defaultdict(int)
    i = 2
    while i * i <= n:
        while n % i == 0:
            f[i] += 1
            n //= i
        i += 1
    if n != 1:
        f[n] += 1

    return f

c, d = prime_fact(a), prime_fact(b)
e = [i if i in d.keys() else 1 for i in c.keys()]
e.append(1)
f = set(e)
print(len(f))
Buggy python submission (verdict: Runtime Error):
import sys

stdin = sys.stdin

mod = 1000000007
inf = 1 << 60

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()
nas = lambda: stdin.readline().split()

n = ni()
w = na()

ans = inf
d = [0] * (n + 1)
b = [0] * (n + 1)
for i in range(1, n + 1):
	d[i] = w[i - 1] + d[i - 1]
	b[i] = w[n - i] + b[i - 1]
b.reverse()
for i in range(1, n):
	ans = min(ans, abs(d[i] - b[i]))

print(ans

Fixed submission:
import sys

stdin = sys.stdin

mod = 1000000007
inf = 1 << 60

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()
nas = lambda: stdin.readline().split()

n = ni()
w = na()

ans = inf
d = [0] * (n + 1)
b = [0] * (n + 1)
for i in range(1, n + 1):
	d[i] = w[i - 1] + d[i - 1]
	b[i] = w[n - i] + b[i - 1]
b.reverse()
for i in range(1, n):
	ans = min(ans, abs(d[i] - b[i]))

print(ans)
Buggy python submission (verdict: Runtime Error):
import sys

stdin = sys.stdin
inf = 1 << 60
mod = 1000000007

sys.setrecursionlimit(10 ** 7)

ni      = lambda: int(ns())
nin     = lambda y: [ni() for _ in range(y)]
na      = lambda: list(map(int, stdin.readline().split()))
nan     = lambda y: [na() for _ in range(y)]
nf      = lambda: float(ns())
nfn     = lambda y: [nf() for _ in range(y)]
nfa     = lambda: list(map(float, stdin.readline().split()))
nfan    = lambda y: [nfa() for _ in range(y)]
ns      = lambda: stdin.readline().rstrip()
nsn     = lambda y: [ns() for _ in range(y)]
ncl     = lambda y: [list(ns()) for _ in range(y)]
nas     = lambda: stdin.readline().split()

n, m = na()
a = na()
cb = []
for i in range(m):
    b, c = na()
    cb.append([c, b])

a.sort()
cb.sort(reverse=True)

cur = 0
for i in range(n):
    c, b = cb[cur]
    if a[i] < c:
        a[i] = c
        b -= 1
        if b == 0:
            cur += 1
        cb[cur][1] = b
    else:
        break

print(sum(a))

Fixed submission:
import sys

stdin = sys.stdin
inf = 1 << 60
mod = 1000000007

sys.setrecursionlimit(10 ** 7)

ni      = lambda: int(ns())
nin     = lambda y: [ni() for _ in range(y)]
na      = lambda: list(map(int, stdin.readline().split()))
nan     = lambda y: [na() for _ in range(y)]
nf      = lambda: float(ns())
nfn     = lambda y: [nf() for _ in range(y)]
nfa     = lambda: list(map(float, stdin.readline().split()))
nfan    = lambda y: [nfa() for _ in range(y)]
ns      = lambda: stdin.readline().rstrip()
nsn     = lambda y: [ns() for _ in range(y)]
ncl     = lambda y: [list(ns()) for _ in range(y)]
nas     = lambda: stdin.readline().split()

n, m = na()
a = na()
cb = []
for i in range(m):
    b, c = na()
    cb.append([c, b])

a.sort()
cb.sort(reverse=True)

cur = 0
for i in range(n):
    if cur >= len(cb):
        break
    c, b = cb[cur]
    if a[i] < c:
        a[i] = c
        b -= 1
        cb[cur][1] = b
        if b == 0:
            cur += 1
    else:
        break

print(sum(a))
Buggy python submission (verdict: Time Limit Exceeded):
import sys

stdin = sys.stdin

mod = 1000000007
inf = 1 << 60

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()
nas = lambda: stdin.readline().split()

n, k = na()
h = na()

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

print(dp[n - 1])

Fixed submission:
import sys
 
stdin = sys.stdin
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()
nas = lambda: stdin.readline().split()

n, k = na()
h = na()

inf = 1 << 60
dp = [inf for i in range(n)]
dp[0] = 0

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

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()
nas = lambda: stdin.readline().split()

n, k = na()
h = na()

inf = 1 << 60
dp = [inf for i in range(n)]
dp[0] = 0

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

Fixed submission:
import sys
 
stdin = sys.stdin
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()
nas = lambda: stdin.readline().split()

n, k = na()
h = na()

inf = 1 << 60
dp = [inf for i in range(n)]
dp[0] = 0

for i in range(n):
    p = min(i + k + 1, n)
    for j in range(i + 1, p):
        dp[j] = min(dp[j], dp[i] + abs(h[i] - h[j]))
print(dp[n - 1])
Buggy python submission (verdict: Runtime Error):
import sys

stdin = sys.stdin
inf = 1 << 60
mod = 1000000007

ni      = lambda: int(ns())
nin     = lambda y: [ni() for _ in range(y)]
na      = lambda: list(map(int, stdin.readline().split()))
nan     = lambda y: [na() for _ in range(y)]
nf      = lambda: float(ns())
nfn     = lambda y: [nf() for _ in range(y)]
nfa     = lambda: list(map(float, stdin.readline().split()))
nfan    = lambda y: [nfa() for _ in range(y)]
ns      = lambda: stdin.readline().rstrip()
nsn     = lambda y: [ns() for _ in range(y)]
ncl     = lambda y: [list(ns()) for _ in range(y)]
nas     = lambda: stdin.readline().split()

n, m = na()
xy = nan(m)

g = [[] for _ in range(n)]
for i in range(m):
    x, y = xy[i]
    x -= 1
    y -= 1
    g[x].append(y)

dp = [-1] * (n + 1)

def dfs(v):
    if dp[v] != -1:
        return dp[v]
    res = 0
    for nv in g[v]:
        res = max(res, dfs(nv) + 1)
    dp[v] = res
    return dp[v]

ans = 0
for v in range(n):
    ans = max(ans, dfs(v))

print(ans)

Fixed submission:
import sys

stdin = sys.stdin
inf = 1 << 60
mod = 1000000007

ni      = lambda: int(ns())
nin     = lambda y: [ni() for _ in range(y)]
na      = lambda: list(map(int, stdin.readline().split()))
nan     = lambda y: [na() for _ in range(y)]
nf      = lambda: float(ns())
nfn     = lambda y: [nf() for _ in range(y)]
nfa     = lambda: list(map(float, stdin.readline().split()))
nfan    = lambda y: [nfa() for _ in range(y)]
ns      = lambda: stdin.readline().rstrip()
nsn     = lambda y: [ns() for _ in range(y)]
ncl     = lambda y: [list(ns()) for _ in range(y)]
nas     = lambda: stdin.readline().split()

sys.setrecursionlimit(10 ** 6)

n, m = na()
xy = nan(m)

g = [[] for _ in range(n)]
for i in range(m):
    x, y = xy[i]
    x -= 1
    y -= 1
    g[x].append(y)

dp = [-1] * (n + 1)

def dfs(v):
    if dp[v] != -1:
        return dp[v]
    res = 0
    for nv in g[v]:
        res = max(res, dfs(nv) + 1)
    dp[v] = res
    return dp[v]

ans = 0
for v in range(n):
    ans = max(ans, dfs(v))

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import sys

stdin = sys.stdin
inf = 1 << 60
mod = 1000000007

ni      = lambda: int(ns())
nin     = lambda y: [ni() for _ in range(y)]
na      = lambda: list(map(int, stdin.readline().split()))
nan     = lambda y: [na() for _ in range(y)]
nf      = lambda: float(ns())
nfn     = lambda y: [nf() for _ in range(y)]
nfa     = lambda: list(map(float, stdin.readline().split()))
nfan    = lambda y: [nfa() for _ in range(y)]
ns      = lambda: stdin.readline().rstrip()
nsn     = lambda y: [ns() for _ in range(y)]
ncl     = lambda y: [list(ns()) for _ in range(y)]
nas     = lambda: stdin.readline().split()

n = ni()
p = nfa()

dp = [[0] * (n + 1) for _ in range(n + 1)]
dp[0][0] = 1.0
for i in range(n):
    for j in range(i + 1):
        dp[i + 1][j + 1] += dp[i][j] * p[i]
        dp[i + 1][j] += dp[i][j] * (1.0 - p[i])

ans = sum([dp[n][j] for j in range(n // 2 + 1, n + 1)])
print(ans)

Fixed submission:
import sys

stdin = sys.stdin
inf = 1 << 60
mod = 1000000007

ni      = lambda: int(ns())
nin     = lambda y: [ni() for _ in range(y)]
na      = lambda: list(map(int, stdin.readline().split()))
nan     = lambda y: [na() for _ in range(y)]
nf      = lambda: float(ns())
nfn     = lambda y: [nf() for _ in range(y)]
nfa     = lambda: list(map(float, stdin.readline().split()))
nfan    = lambda y: [nfa() for _ in range(y)]
ns      = lambda: stdin.readline().rstrip()
nsn     = lambda y: [ns() for _ in range(y)]
ncl     = lambda y: [list(ns()) for _ in range(y)]
nas     = lambda: stdin.readline().split()

n = ni()
p = nfa()

dp = [[0] * (n + 1) for _ in range(n + 1)]
dp[0][0] = 1.0
for i in range(n):
    for j in range(i + 1):
        dp[i + 1][j + 1] += dp[i][j] * p[i]
        dp[i + 1][j] += dp[i][j] * (1.0 - p[i])

ans = sum([dp[n][j] for j in range(n // 2 + 1, n + 1)])
print(ans)
Buggy python submission (verdict: Runtime Error):
import sys

stdin = sys.stdin

mod = 1000000007

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()
nas = lambda: stdin.readline().split()

from collections import defaultdict

n = ni()
a = na()

d = defaultdict(int)
b = defaultdict(int)

for i in range(1, n + 1):
	if i % 2 == 0:
		d[a[i - 1]] += 1
	else:
		b[a[i - 1]] += 1

d_mkey, d_mval = [0] * 2
b_mkey, b_mval = [0] * 2

for k, v in d.items():
	if d_mval < v:
		d_mkey = k
		d_mval = v

for k, v in b.items():
	if b_mval < v:
		b_mkey = k
		b_mval = v

if d_mkey != b_mkey:
	print(n - d_mval - b_mval)
else:
	p = list(d.values())
	q = list(b.values())
	p.sort()
	q.sort()
	pv = p[len(p) - 2]
	qv = p[len(q) - 2]
	if pv <= qv:
		print((n - d_mval) + (n // 2 - qv))
	else:
		print((n - b_mval) + (n // 2 - pv))


Fixed submission:
import sys

stdin = sys.stdin

mod = 1000000007
inf = 1 << 60

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()
nas = lambda: stdin.readline().split()

from collections import Counter
from itertools import product

n = ni()
a = na()

even = Counter(a[::2])
odd = Counter(a[1::2])

even[-1] = 0
odd[-2] = 0

e = even.most_common(2)
o = odd.most_common(2)

ans = n
for (k1, v1), (k2, v2) in product(e, o):
    if k1 == k2:
        continue
    x = (n - v1 - v2)
    if ans > x:
        ans = x

print(ans)
Buggy python submission (verdict: Runtime Error):
import sys
 
stdin = sys.stdin
inf = 1 << 60
mod = 1000000007
 
ni = lambda: int(ns())
nin = lambda x: [ni() for _ in range(x)]
na = lambda: list(map(int, stdin.readline().split()))
nan = lambda x: [na() for _ in range(x)]
ns = lambda: stdin.readline().rstrip()
nsn = lambda x: [ns() for _ in range(x)]
nas = lambda: stdin.readline().split()

n = ni()
i = ni()

print(n - i + 1)

Fixed submission:
import sys
 
stdin = sys.stdin
inf = 1 << 60
mod = 1000000007
 
ni = lambda: int(ns())
nin = lambda x: [ni() for _ in range(x)]
na = lambda: list(map(int, stdin.readline().split()))
nan = lambda x: [na() for _ in range(x)]
ns = lambda: stdin.readline().rstrip()
nsn = lambda x: [ns() for _ in range(x)]
nas = lambda: stdin.readline().split()

n, i = na()

print(n - i + 1)
Buggy python submission (verdict: Runtime Error):
import sys

stdin = sys.stdin

mod = 1000000007

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()
nas = lambda: stdin.readline().split()

def gcd(m, n):
	if n == 0:
		return m
	return gcd(n, m % n)

def lcm(m, n):
	return m * n // gcd(m, n)

n = ni()
a = na()

l = a[0]
for i in range(n):
	l = lcm(l, a[i])

l -= 1
ans = 0
for i in range(n):
	ans += l % a[i]

print(ans

Fixed submission:
import sys

stdin = sys.stdin

mod = 1000000007

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()
nas = lambda: stdin.readline().split()

def gcd(m, n):
	if n == 0:
		return m
	return gcd(n, m % n)

def lcm(m, n):
	return m * n // gcd(m, n)

n = ni()
a = na()

l = a[0]
for i in range(n):
	l = lcm(l, a[i])

l -= 1
ans = 0
for i in range(n):
	ans += l % a[i]

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
# Author: cr4zjh0bp
# Created: Sat Mar 14 14:07:54 UTC 2020
import sys
 
stdin = sys.stdin
inf = 1 << 60
mod = 1000000007
 
ni = lambda: int(ns())
nin = lambda y: [ni() for _ in range(y)]
na = lambda: list(map(int, stdin.readline().split()))
nan = lambda y: [na() for _ in range(y)]
nf = lambda: float(ns())
nfn = lambda y: [nf() for _ in range(y)]
nfa = lambda: list(map(float, stdin.readline().split()))
nfan = lambda y: [nfa() for _ in range(y)]
ns = lambda: stdin.readline().rstrip()
nsn = lambda y: [ns() for _ in range(y)]
ncl = lambda y: [list(ns()) for _ in range(y)]
nas = lambda: stdin.readline().split()

N = ni()
m = 3500 // 4

def f():
    ans = []
    for h in range(3501):
        for n in range(3501):
            c = h * n * N
            d = 4 * h * n - N * n - N * h
            if d > 0 and c % d == 0:
                ans = [h, n, c // d]
                return ans

print(*f())

Fixed submission:
# Author: cr4zjh0bp
# Created: Sat Mar 14 14:07:54 UTC 2020
import sys
 
stdin = sys.stdin
inf = 1 << 60
mod = 1000000007
 
ni = lambda: int(ns())
nin = lambda y: [ni() for _ in range(y)]
na = lambda: list(map(int, stdin.readline().split()))
nan = lambda y: [na() for _ in range(y)]
nf = lambda: float(ns())
nfn = lambda y: [nf() for _ in range(y)]
nfa = lambda: list(map(float, stdin.readline().split()))
nfan = lambda y: [nfa() for _ in range(y)]
ns = lambda: stdin.readline().rstrip()
nsn = lambda y: [ns() for _ in range(y)]
ncl = lambda y: [list(ns()) for _ in range(y)]
nas = lambda: stdin.readline().split()

N = ni()
m = 3500 // 4

def f():
    ans = []
    for h in range(3501):
        for n in range(3501):
            c = h * n * N
            d = 4 * h * n - N * n - N * h
            if d > 0 and c % d == 0:
                ans = [h, n, c // d]
                return ans

print(*f())
Buggy python submission (verdict: Time Limit Exceeded):
# Author: cr4zjh0bp
# Created: Tue Mar 17 19:50:06 UTC 2020
import sys
 
stdin = sys.stdin
inf = 1 << 60
mod = 1000000007
 
ni      = lambda: int(ns())
nin     = lambda y: [ni() for _ in range(y)]
na      = lambda: list(map(int, stdin.readline().split()))
nan     = lambda y: [na() for _ in range(y)]
nf      = lambda: float(ns())
nfn     = lambda y: [nf() for _ in range(y)]
nfa     = lambda: list(map(float, stdin.readline().split()))
nfan    = lambda y: [nfa() for _ in range(y)]
ns      = lambda: stdin.readline().rstrip()
nsn     = lambda y: [ns() for _ in range(y)]
ncl     = lambda y: [list(ns()) for _ in range(y)]
nas     = lambda: stdin.readline().split()

from itertools import permutations

n, m, R = na()
r = na()
abc = nan(m)
adj = [[0] * n for _ in range(n)]
for i in range(m):
    a, b, c = abc[i]
    a -= 1
    b -= 1
    adj[a][b] = c

dist = [[inf] * n for _ in range(n)]
for i in range(n):
    for j in range(n):
        if i == j:
            dist[i][j] = 0
        elif adj[i][j]:
            dist[i][j] = adj[i][j]

for i in range(n):
    for j in range(n):
        for k in range(n):
            dist[j][k] = min(dist[j][k], dist[i][j] + dist[i][k])

ans = inf
for p in permutations(r):
    res = 0
    for i in range(R - 1):
        f, t = p[i] - 1, p[i + 1] - 1
        res += dist[f][t]
    ans = min(ans, res)

print(ans)

Fixed submission:
# Author: cr4zjh0bp
# Created: Tue Mar 17 19:50:06 UTC 2020
import sys
 
stdin = sys.stdin
inf = 1 << 60
mod = 1000000007
 
ni      = lambda: int(ns())
nin     = lambda y: [ni() for _ in range(y)]
na      = lambda: list(map(int, stdin.readline().split()))
nan     = lambda y: [na() for _ in range(y)]
nf      = lambda: float(ns())
nfn     = lambda y: [nf() for _ in range(y)]
nfa     = lambda: list(map(float, stdin.readline().split()))
nfan    = lambda y: [nfa() for _ in range(y)]
ns      = lambda: stdin.readline().rstrip()
nsn     = lambda y: [ns() for _ in range(y)]
ncl     = lambda y: [list(ns()) for _ in range(y)]
nas     = lambda: stdin.readline().split()

from itertools import permutations

n, m, R = na()
r = na()
abc = nan(m)
adj = [[0 for _ in range(n)] for _ in range(n)]
for i in range(m):
    a, b, c = abc[i]
    a -= 1
    b -= 1
    adj[a][b] = c
    adj[b][a] = c

dist = [[inf for _ in range(n)] for _ in range(n)]
for i in range(n):
    for j in range(n):
        if i == j:
            dist[i][j] = 0
        elif adj[i][j]:
            dist[i][j] = adj[i][j]

for i in range(n):
    for j in range(n):
        for k in range(n):
            dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k])

ans = inf
for p in permutations(r):
    res = 0
    for i in range(R - 1):
        f, t = p[i] - 1, p[i + 1] - 1
        res += dist[f][t]
    ans = min(ans, res)

print(ans)
Buggy python submission (verdict: Runtime Error):
# Author: cr4zjh0bp
# Created: Tue Mar 24 00:01:43 UTC 2020
import sys
 
stdin = sys.stdin
inf = 1 << 60
mod = 1000000007
 
ni      = lambda: int(ns())
nin     = lambda y: [ni() for _ in range(y)]
na      = lambda: list(map(int, stdin.readline().split()))
nan     = lambda y: [na() for _ in range(y)]
nf      = lambda: float(ns())
nfn     = lambda y: [nf() for _ in range(y)]
nfa     = lambda: list(map(float, stdin.readline().split()))
nfan    = lambda y: [nfa() for _ in range(y)]
ns      = lambda: stdin.readline().rstrip()
nsn     = lambda y: [ns() for _ in range(y)]
ncl     = lambda y: [list(ns()) for _ in range(y)]
nas     = lambda: stdin.readline().split()

from collections import Counter

n = ni()
a = na()
c = Counter(a)
m = list(c.items())
m.sort(reverse=True)
xy = [0] * 2
i = 0
flag = False
for k, v in m:
    if v >= 4:
        if i != 0:
            print(xy[0] * k)
        else:
            print(k * K)
        flag = True
        break
    elif v >= 2:
        xy[i] = k
        i += 1
        if i == 2:
            print(xy[0] * xy[1])
            flag = True
            break
if not flag:
    print(0)

Fixed submission:
# Author: cr4zjh0bp
# Created: Tue Mar 24 00:01:43 UTC 2020
import sys
 
stdin = sys.stdin
inf = 1 << 60
mod = 1000000007
 
ni      = lambda: int(ns())
nin     = lambda y: [ni() for _ in range(y)]
na      = lambda: list(map(int, stdin.readline().split()))
nan     = lambda y: [na() for _ in range(y)]
nf      = lambda: float(ns())
nfn     = lambda y: [nf() for _ in range(y)]
nfa     = lambda: list(map(float, stdin.readline().split()))
nfan    = lambda y: [nfa() for _ in range(y)]
ns      = lambda: stdin.readline().rstrip()
nsn     = lambda y: [ns() for _ in range(y)]
ncl     = lambda y: [list(ns()) for _ in range(y)]
nas     = lambda: stdin.readline().split()

from collections import Counter

n = ni()
a = na()
c = Counter(a)
m = list(c.items())
m.sort(reverse=True)
xy = [0] * 2
i = 0
flag = False
for k, v in m:
    if v >= 4:
        if i != 0:
            print(xy[0] * k)
        else:
            print(k * k)
        flag = True
        break
    elif v >= 2:
        xy[i] = k
        i += 1
        if i == 2:
            print(xy[0] * xy[1])
            flag = True
            break
if not flag:
    print(0)
Buggy python submission (verdict: Runtime Error):
# Author: cr4zjh0bp
# Created: Mon Mar 23 15:10:04 UTC 2020
import sys
 
stdin = sys.stdin
inf = 1 << 60
mod = 1000000007
 
ni      = lambda: int(ns())
nin     = lambda y: [ni() for _ in range(y)]
na      = lambda: list(map(int, stdin.readline().split()))
nan     = lambda y: [na() for _ in range(y)]
nf      = lambda: float(ns())
nfn     = lambda y: [nf() for _ in range(y)]
nfa     = lambda: list(map(float, stdin.readline().split()))
nfan    = lambda y: [nfa() for _ in range(y)]
ns      = lambda: stdin.readline().rstrip()
nsn     = lambda y: [ns() for _ in range(y)]
ncl     = lambda y: [list(ns()) for _ in range(y)]
nas     = lambda: stdin.readline().split()

import numpy as np

n, k = na()
a = np.array(na())

g = np.gcd.reduce(a)
m = np.amax(a)
if g == 1 and k <= m:
    print("Yes")
elif k % g == 0 and k <= m:
    print("Yes")
else:
    print("No")

Fixed submission:
# Author: cr4zjh0bp
# Created: Sun Mar 22 17:06:57 UTC 2020
import sys
 
stdin = sys.stdin
inf = 1 << 60
mod = 1000000007
 
ni      = lambda: int(ns())
nin     = lambda y: [ni() for _ in range(y)]
na      = lambda: list(map(int, stdin.readline().split()))
nan     = lambda y: [na() for _ in range(y)]
nf      = lambda: float(ns())
nfn     = lambda y: [nf() for _ in range(y)]
nfa     = lambda: list(map(float, stdin.readline().split()))
nfan    = lambda y: [nfa() for _ in range(y)]
ns      = lambda: stdin.readline().rstrip()
nsn     = lambda y: [ns() for _ in range(y)]
ncl     = lambda y: [list(ns()) for _ in range(y)]
nas     = lambda: stdin.readline().split()

n, k = na()
a = na()

def gcd(m, n):
    if n == 0:
        return m
    else:
        return gcd(n, m % n)

g = a[0]
for i in range(n):
    g = gcd(g, a[i])

m = max(a)
if g == 1 and k <= m:
    print("POSSIBLE")
elif k % g == 0 and k <= m:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")
Buggy python submission (verdict: Time Limit Exceeded):
# Author: cr4zjh0bp
# Created: Sun Mar 22 23:25:40 UTC 2020
import sys
 
stdin = sys.stdin
inf = 1 << 60
mod = 1000000007
 
ni      = lambda: int(ns())
nin     = lambda y: [ni() for _ in range(y)]
na      = lambda: list(map(int, stdin.readline().split()))
nan     = lambda y: [na() for _ in range(y)]
nf      = lambda: float(ns())
nfn     = lambda y: [nf() for _ in range(y)]
nfa     = lambda: list(map(float, stdin.readline().split()))
nfan    = lambda y: [nfa() for _ in range(y)]
ns      = lambda: stdin.readline().rstrip()
nsn     = lambda y: [ns() for _ in range(y)]
ncl     = lambda y: [list(ns()) for _ in range(y)]
nas     = lambda: stdin.readline().split()

n = ni()
a = nin(n)

ans = 0
flag = True
i = 0
p = 0
while i != 1:
    if p == a[i] - 1:
        flag = False
        break
    p = i
    i = a[i] - 1
    ans += 1

print(ans if flag else -1)

Fixed submission:
# Author: cr4zjh0bp
# Created: Sun Mar 22 23:25:40 UTC 2020
import sys
 
stdin = sys.stdin
inf = 1 << 60
mod = 1000000007
 
ni      = lambda: int(ns())
nin     = lambda y: [ni() for _ in range(y)]
na      = lambda: list(map(int, stdin.readline().split()))
nan     = lambda y: [na() for _ in range(y)]
nf      = lambda: float(ns())
nfn     = lambda y: [nf() for _ in range(y)]
nfa     = lambda: list(map(float, stdin.readline().split()))
nfan    = lambda y: [nfa() for _ in range(y)]
ns      = lambda: stdin.readline().rstrip()
nsn     = lambda y: [ns() for _ in range(y)]
ncl     = lambda y: [list(ns()) for _ in range(y)]
nas     = lambda: stdin.readline().split()

n = ni()
a = nin(n)

i = 0
ans = 0
flag = True
while i != 1:
    if ans > n:
        flag = False
        break
    i = a[i] - 1
    ans += 1

print(ans if flag else -1)