Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
A, B, C, D = map(int, input().split())
MOD = 998244353

dp = [[0] * (D + 2) for _ in range(C + 2)]
dp[A][B] = 1

for h in range(A, C + 1):
    for w in range(B, D + 1):
        d = dp[h][w] % MOD
        dp[h + 1][w] += d * w
        dp[h][w + 1] += d * h
        dp[h + 1][w + 1] -= d * w * h % MOD
print(dp[C][D] % MOD)


Fixed submission:
A, B, C, D = map(int, input().split())
MOD = 998244353

dp = [[0] * (D + 2) for _ in range(C + 2)]
dp[A][B] = 1

for h in range(A, C + 1):
    for w in range(B, D + 1):
        d = dp[h][w] % MOD
        dp[h + 1][w] += d * w
        dp[h][w + 1] += d * h
        dp[h + 1][w + 1] -= d * w * h % MOD
print(dp[C][D] % MOD)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter

def sol():
    N = int(input())
    A = list(map(int, input().split()))
    P = set(A)
    cnt = Counter(A)

    def divisors(n):
        divisors = []
        R = int(n**(0.5)) + 1
        for i in range(1, R):
            if n % i == 0:
                divisors.append(i)
                if i != n // i:
                    divisors.append(n // i)
        return divisors

    ans = 0
    for a in P:
        if cnt[a] > 1:
            continue
        for d in divisors(a):
            if d != a and d in P:
                break
        else:
            ans += 1

    print(ans)

sol()

Fixed submission:
from collections import Counter
N = int(input())
A = list(map(int, input().split()))
cntA = Counter(A)

A.sort()
V = set()

ans = 0
mx = max(A)
for a in A:
    if a in V:
        continue
    if cntA[a] == 1:
        ans += 1

    p = a
    while p <= mx:
        V.add(p)
        p += a

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter

def sol():
    N = int(input())
    A = list(map(int, input().split()))
    P = set(A)
    cnt = Counter(A)

    def divisors(n):
        divisors = []
        R = int(n**(0.5)) + 1
        for i in range(1, R):
            if n % i == 0:
                divisors.append(i)
                if i != n // i:
                    divisors.append(n // i)
        return divisors

    ans = 0
    for a in A:
        if cnt[a] > 1:
            continue
        for d in divisors(a):
            if d != a and d in P:
                break
        else:
            ans += 1

    print(ans)

sol()

Fixed submission:
from collections import Counter
N = int(input())
A = list(map(int, input().split()))
cntA = Counter(A)

A.sort()
V = set()

ans = 0
mx = max(A)
for a in A:
    if a in V:
        continue
    if cntA[a] == 1:
        ans += 1

    p = a
    while p <= mx:
        V.add(p)
        p += a

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter

N = int(input())
A = list(map(int, input().split()))
P = set(A)
cnt = Counter(A)

def divisors(n):
    divisors = []
    R = int(n**(0.5)) + 1
    for i in range(1, R):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n // i)
    # divisors.sort(reverse=True)  # ソート
    return divisors

ans = 0
for a in A:
    if cnt[a] > 1:
        continue
    for d in divisors(a):
        if d != a and d in P:
            break
    else:
        ans += 1

print(ans)


Fixed submission:
from collections import Counter
N = int(input())
A = list(map(int, input().split()))
cntA = Counter(A)

A.sort()
V = set()

ans = 0
mx = max(A)
for a in A:
    if a in V:
        continue
    if cntA[a] == 1:
        ans += 1

    p = a
    while p <= mx:
        V.add(p)
        p += a

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

for _ in range(K):
    B = [0] * (N + 1)
    for i, a in enumerate(A):
        B[max(0, i - a)] += 1
        B[min(N, i + a + 1)] -= 1
    for i in range(N):
        B[i + 1] += B[i]
    A = B[:N]

    if min(A) >= N:
        break

print(*A)



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

for _ in range(K):
    B = [0] * (N + 1)
    for i, a in enumerate(A):
        B[max(0, i - a)] += 1
        B[min(N, i + a + 1)] -= 1
    for i in range(N):
        B[i + 1] += B[i]
    A = B[:N]

    if min(A) >= N:
        break

print(*A)
Buggy python submission (verdict: Time Limit Exceeded):
N, S = map(int, input().split())
A = list(map(int, input().split()))
MOD = 998244353

dp = [0] * (S + 1)
dp[0] = 1

for a in A:
    newDp = [d * 2 % MOD for d in dp]

    for s in range(S + 1):
        if s + a <= S:
            newDp[s + a] += dp[s]

    dp = newDp

print(dp[S] % MOD)


Fixed submission:
N, S = map(int, input().split())
A = list(map(int, input().split()))
MOD = 998244353

dp = [0] * (S + 1)
dp[0] = 1

for a in A:
    newDp = [d * 2 % MOD for d in dp]

    for s in range(S + 1):
        if s + a <= S:
            newDp[s + a] += dp[s]

    dp = newDp

print(dp[S] % MOD)
Buggy python submission (verdict: Runtime Error):
import sys
import numpy as np

def main(A):
    return 0

def cc_export():
    from numba.pycc import CC
    cc = CC('my_module')
    cc.export('main', 'i8(i8[:])')(main)
    cc.compile()

if sys.argv[-1] == 'ONLINE_JUDGE':
    cc_export()
    exit(0)
if sys.argv[-1] != 'LOCAL':
    from my_module import main

A = np.ones(10, dtype=np.int32)
ans = main(A)
print(ans)


Fixed submission:
from functools import lru_cache
import sys
sys.setrecursionlimit(10**7)

T = int(input())
INF = 10**18

for _ in range(T):
    N, A, B, C, D = map(int, input().split())
    V = set()

    @lru_cache(maxsize=None)
    def search(now):
        if now == 0:
            return 0

        ret = INF
        for div, cost in zip((2, 3, 5), (A, B, C)):
            q, r = divmod(now, div)
            ret = min(
                ret,
                search(q) + cost + r * D,
                search(q + 1) + cost + (div - r) * D if q + 1 < now else INF,
                now * D
            )
        return ret

    print(search(N))

Buggy python submission (verdict: Runtime Error):
import sys
import numpy as np

def main(A):
    return 0

def cc_export():
    from numba.pycc import CC
    cc = CC('my_module')
    cc.export('main', 'i8(i8[:])')(main)
    cc.compile()

if sys.argv[-1] == 'ONLINE_JUDGE':
    cc_export()
    exit(0)
if sys.argv[-1] != 'LOCAL':
    from my_module import solve

A = np.ones(10, dtype=np.int32)
ans = main(A)
print(ans)


Fixed submission:
from functools import lru_cache
import sys
sys.setrecursionlimit(10**7)

T = int(input())
INF = 10**18

for _ in range(T):
    N, A, B, C, D = map(int, input().split())
    V = set()

    @lru_cache(maxsize=None)
    def search(now):
        if now == 0:
            return 0

        ret = INF
        for div, cost in zip((2, 3, 5), (A, B, C)):
            q, r = divmod(now, div)
            ret = min(
                ret,
                search(q) + cost + r * D,
                search(q + 1) + cost + (div - r) * D if q + 1 < now else INF,
                now * D
            )
        return ret

    print(search(N))

Buggy python submission (verdict: Runtime Error):
import sys
import numpy as np

if sys.argv[-1] == 'ONLINE_JUDGE':
    cc_export()
    exit(0)
if sys.argv[-1] != 'LOCAL':
    from my_module import solve

def cc_export():
    from numba.pycc import CC
    cc = CC('my_module')
    cc.export('main', 'i8(i8[:])')(main)
    cc.compile()

def main(A):
    return 0

A = np.ones(10, dtype=np.int32)
ans = main(A)
print(ans)


Fixed submission:
from functools import lru_cache
import sys
sys.setrecursionlimit(10**7)

T = int(input())
INF = 10**18

for _ in range(T):
    N, A, B, C, D = map(int, input().split())
    V = set()

    @lru_cache(maxsize=None)
    def search(now):
        if now == 0:
            return 0

        ret = INF
        for div, cost in zip((2, 3, 5), (A, B, C)):
            q, r = divmod(now, div)
            ret = min(
                ret,
                search(q) + cost + r * D,
                search(q + 1) + cost + (div - r) * D if q + 1 < now else INF,
                now * D
            )
        return ret

    print(search(N))
Buggy python submission (verdict: Runtime Error):
from collections import Counter
import sys
input = sys.stdin.buffer.readline

N = int(input())

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

def make(a, b):
    s = 1 if a * b >= 0 else -1
    a, b = abs(a), abs(b)

    g = gcd(a, b)
    a //= g
    b //= g

    return (a, b, s)

ABS = Counter([make(*map(int, input().split())) for _ in range(N)])
K = list(ABS.keys())

ans = 1
MOD = 10**9 + 7

for a, b, s in K:
    p = ABS[(a, b, s)]
    n = ABS[(b, a, -s)]

    ABS[(a, b, s)] = 0
    ABS[(b, a, -s)] = 0

    cnt = pow(2, p, MOD) + pow(2, n, MOD) - 1
    ans = (ans * cnt) % MOD

print((ans - 1) % MOD)


Fixed submission:
from collections import Counter
import sys
input = sys.stdin.buffer.readline

N = int(input())

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

def make(a, b):
    if a == b == 0:
        return (0, 0, 0)
    if a == 0:
        return (0, 1, 0)
    if b == 0:
        return (1, 0, 0)

    s = 1 if a * b > 0 else -1
    a, b = abs(a), abs(b)

    g = gcd(a, b)
    a //= g
    b //= g

    return (a, b, s)

ABS = Counter([make(*map(int, input().split())) for _ in range(N)])

ans = 1
MOD = 10**9 + 7

for a, b, s in list(ABS.keys()):
    if a == b == 0:
        continue
    p = ABS[(a, b, s)]
    n = ABS[(b, a, -s)]

    ABS[(a, b, s)] = 0
    ABS[(b, a, -s)] = 0

    cnt = pow(2, p, MOD) + pow(2, n, MOD) - 1
    ans = (ans * cnt) % MOD

ans += ABS[(0, 0, 0)]

print((ans - 1) % MOD)

Buggy python submission (verdict: Runtime Error):
from collections import Counter
import sys
input = sys.stdin.buffer.readline

N = int(input())

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

def make(a, b):
    s = 1 if a * b >= 0 else -1
    a, b = abs(a), abs(b)

    g = gcd(a, b)
    a //= g
    b //= g

    return (a, b, s)

ABS = Counter([make(*map(int, input().split())) for _ in range(N)])

ans = 1
MOD = 10**9 + 7

for a, b, s in list(ABS.keys()):
    p = ABS[(a, b, s)]
    n = ABS[(b, a, -s)]

    ABS[(a, b, s)] = 0
    ABS[(b, a, -s)] = 0

    cnt = pow(2, p, MOD) + pow(2, n, MOD) - 1
    ans = (ans * cnt) % MOD

print((ans - 1) % MOD)


Fixed submission:
from collections import Counter
import sys
input = sys.stdin.buffer.readline

N = int(input())

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

def make(a, b):
    if a == b == 0:
        return (0, 0, 0)
    if a == 0:
        return (0, 1, 0)
    if b == 0:
        return (1, 0, 0)

    s = 1 if a * b > 0 else -1
    a, b = abs(a), abs(b)

    g = gcd(a, b)
    a //= g
    b //= g

    return (a, b, s)

ABS = Counter([make(*map(int, input().split())) for _ in range(N)])

ans = 1
MOD = 10**9 + 7

for a, b, s in list(ABS.keys()):
    if a == b == 0:
        continue
    p = ABS[(a, b, s)]
    n = ABS[(b, a, -s)]

    ABS[(a, b, s)] = 0
    ABS[(b, a, -s)] = 0

    cnt = pow(2, p, MOD) + pow(2, n, MOD) - 1
    ans = (ans * cnt) % MOD

ans += ABS[(0, 0, 0)]

print((ans - 1) % MOD)
Buggy python submission (verdict: Runtime Error):
from itertools import combinations

N, A, B, C = map(int, input().split())
S = [input() for _ in range(N)]

cnt = {'A': A, 'B': B, 'C': C}

def out(T):
    now = {'A': 0, 'B': 0, 'C': 0}
    for s in T:
        now[s] += 1

    ans = []
    for i, s in enumerate(S):
        if min(now.values()) < 0:
            return False
        if now[s[0]] > now[s[1]]:
            ans.append(s[1])
            now[s[0]] -= 1
            now[s[1]] += 1
            continue
        if now[s[0]] < now[s[1]]:
            ans.append(s[0])
            now[s[0]] += 1
            now[s[1]] -= 1
            continue
        if i == N - 1:
            ans.append(s[0])
            continue
        nx = S[i + 1]
        if nx == s:
            ans.append(s[0])
            now[s[0]] += 1
            now[s[1]] -= 1
            continue
        k = list(set(list(s)) & set(list(nx)))
        k = k[0]
        ans.append(k)
        now[k] += 1
        k = s.replace(k, '')
        now[k] -= 1

    if min(now.values()) < 0:
        return []
    return ans

for s in combinations(['', '', 'A', 'B', 'C'], r=3):
    s = ''.join(s)

    for t in s:
        if cnt[t] == 0:
            break
    else:
        ans = out(s)
        if len(ans) == 0:
            continue
        print('Yes')
        print(*ans, sep='\n')
        exit()

print('No')


Fixed submission:
from itertools import combinations

N, A, B, C = map(int, input().split())
S = [input() for _ in range(N)]

cnt = {'A': A, 'B': B, 'C': C}

def out(T):
    now = {'A': A, 'B': B, 'C': C}

    ans = []
    for i, s in enumerate(S):
        u, v = s[0], s[1]
        if now[u] == now[v] == 0:
            return []
        if now[u] > now[v]:
            ans.append(v)
            now[u] -= 1
            now[v] += 1
            continue
        if now[u] < now[v]:
            ans.append(u)
            now[u] += 1
            now[v] -= 1
            continue
        if i == N - 1:
            ans.append(u)
            continue

        nx = S[i + 1]
        if u in nx:
            ans.append(u)
            now[u] += 1
            now[v] -= 1
            continue
        if v in nx:
            ans.append(v)
            now[v] += 1
            now[u] -= 1
            continue

    return ans

ans = out('')
if len(ans) == 0:
    print('No')
    exit()
print('Yes')
print(*ans, sep='\n')

# for s in combinations(['', '', 'A', 'B', 'C'], r=3):
#     s = ''.join(s)
#     for t in s:
#         if cnt[t] == 0:
#             break
#     else:
#         ans = out(s)
#         if len(ans) == 0:
#             continue
#         print('Yes')
#         print(*ans, sep='\n')
#         exit()

# print('No')
Buggy python submission (verdict: Runtime Error):
from bisect import bisect_right

N = int(input())
A = list(map(int, input().split()))

edges = [[] for _ in range(N)]
for _ in range(N - 1):
    fr, to = map(lambda a: int(a) - 1, input().split())
    edges[fr].append(to)
    edges[to].append(fr)

ans = [0] * N
L = [-10**18]

def search(now, pr):
    a = A[now]
    i = bisect_right(L, a)
    isAppended = False
    prevValue = -1

    if i == len(L):
        L.append(a)
        isAppended = True
    else:
        prevValue = L[i]
        L[i] = a

    ans[now] = len(L) - 1

    for to in edges[now]:
        if to == pr:
            continue
        search(to, now)

    if isAppended:
        L.pop()
    else:
        L[i] = prevValue

search(0, -1)
print(*ans, sep='\n')


Fixed submission:
from bisect import bisect_left
import sys
sys.setrecursionlimit(10 ** 7)

N = int(input())
A = list(map(int, input().split()))

edges = [[] for _ in range(N)]
for _ in range(N - 1):
    fr, to = map(lambda a: int(a) - 1, input().split())
    edges[fr].append(to)
    edges[to].append(fr)

ans = [0] * N
L = [-10**18]

def search(now, pr):
    a = A[now]
    i = bisect_left(L, a)
    isAppended = False
    prevValue = -1

    if i == len(L):
        L.append(a)
        isAppended = True
    else:
        prevValue = L[i]
        if L[i] > a:
            L[i] = a

    ans[now] = len(L) - 1

    for to in edges[now]:
        if to == pr:
            continue
        search(to, now)

    if isAppended:
        L.pop()
    else:
        L[i] = prevValue

search(0, -1)
print(*ans, sep='\n')
Buggy python submission (verdict: Time Limit Exceeded):
from heapq import heappush, heappop

N, M, S = map(int, input().split())
mxCost = 0

edges = [[] for _ in range(N)]
for _ in range(M):
    fr, to, cost, dist = map(int, input().split())
    mxCost = max(mxCost, cost)
    fr -= 1
    to -= 1
    edges[fr].append((to, dist, cost))
    edges[to].append((fr, dist, cost))

for i in range(N):
    C, D = map(int, input().split())
    edges[i].append((i, D, -C))

que = [(0, S, 0)]
mxCost *= (N - 1)
minDsit = [[10**18] * (mxCost + 1) for _ in range(N)]
minDsit[0][0] = 0

while que:
    dist, s, now = heappop(que)

    for to, d, c in edges[now]:
        cost = min(mxCost, s - c)
        if cost < 0 or minDsit[to][cost] <= dist + d:
            continue
        minDsit[to][cost] = dist + d
        que.append((dist + d, cost, to))

for dist in minDsit[1:]:
    print(min(dist))


Fixed submission:
from heapq import heappush, heappop

N, M, S = map(int, input().split())
mxCost = 0

edges = [[] for _ in range(N)]
for _ in range(M):
    fr, to, cost, dist = map(int, input().split())
    mxCost = max(mxCost, cost)
    fr -= 1
    to -= 1
    edges[fr].append((to, dist, cost))
    edges[to].append((fr, dist, cost))

for i in range(N):
    C, D = map(int, input().split())
    edges[i].append((i, D, -C))

que = [(0, S, 0)]
mxCost *= (N - 1)
minDsit = [[10**18] * (mxCost + 1) for _ in range(N)]
minDsit[0][0] = 0

while que:
    dist, s, now = heappop(que)

    for to, d, c in edges[now]:
        cost = min(mxCost, s - c)
        if cost < 0 or minDsit[to][cost] <= dist + d:
            continue
        minDsit[to][cost] = dist + d
        que.append((dist + d, cost, to))

for dist in minDsit[1:]:
    print(min(dist))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [(a, i) for i, a in enumerate(map(int, input().split()), start=1)]
A.sort(reverse=True)

dp = [[0] * (N + 1) for _ in range(N + 1)]

for s, (a, i) in enumerate(A):
    for l in range(s + 1):
        r = s - l
        dp[l + 1][r] = max(dp[l + 1][r], dp[l][r] + a * (i - (l + 1)))
        dp[l][r + 1] = max(dp[l][r + 1], dp[l][r] + a * (N - r - i))

ans = max([max(d) for d in dp])
print(ans)


Fixed submission:
N = int(input())
A = [(a, i) for i, a in enumerate(map(int, input().split()), start=1)]
A.sort(reverse=True)

dp = [[0] * (N + 1) for _ in range(N + 1)]

for s, (a, i) in enumerate(A):
    for l in range(s + 1):
        r = s - l
        dp[l + 1][r] = max(dp[l + 1][r], dp[l][r] + a * (i - (l + 1)))
        dp[l][r + 1] = max(dp[l][r + 1], dp[l][r] + a * (N - r - i))

ans = max([max(d) for d in dp])
print(ans)
Buggy python submission (verdict: Runtime Error):
from math import gcd

print(gcd(120, 24))

Fixed submission:
N = int(input())

def isOk(k):
    n = N
    while n % k == 0:
        n //= k
    return n % k == 1

if N <= 10**6:
    ans = 0
    for i in range(2, N + 1):
        if isOk(i):
            ans += 1
    print(ans)
    exit()

ans = 0
V = set()
for i in range(2, int(N**0.5) + 10):
    if isOk(i):
        ans += 1
        V.add(i)

# 約数の全列挙
def 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(reverse=True)  # ソート
    return divisors

divN = divisors(N - 1)

ans += len([d for d in divN if not d in V])
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
while True:
  a = 1


Fixed submission:
K, N = map(int, input().split())
A = list(map(int, input().split()))
B = [abs(x - y) for x, y in zip(A[1:], A)]
B += [K - A[-1] + A[0]]

print(sum(B) - max(B))
Buggy python submission (verdict: Runtime Error):
a = b

Fixed submission:
N, X, Y = map(int, input().split())

def dist(fr, to):
    return min(
        to - fr,
        abs(to - Y) + 1 + abs(fr - X),
        abs(fr - Y) + 1 + abs(to - X)
    )

cnt = [0] * N

ans = 0
for fr in range(1, N + 1):
    for to in range(fr + 1, N + 1):
        cnt[dist(fr, to)] += 1

print(*(cnt[1:]), sep='\n')
Buggy python submission (verdict: Time Limit Exceeded):
H, W, K = map(int, input().split())

S = [input() for _ in range(H)]

def calc(L):
    M = len(L)
    cnt = [0] * M
    ret = 0

    for w in range(W):
        for i, (t, b) in enumerate(zip(L, L[1:])):
            for j in range(t, b):
                if S[j][w] == '1':
                    cnt[i] += 1
        if max(cnt) > K:
            cnt = [0] * M
            for i, (t, b) in enumerate(zip(L, L[1:])):
                for j in range(t, b):
                    if S[j][w] == '1':
                        cnt[i] += 1
            ret += 1

    return ret

ans = H * W
for mask in range(1 << (H - 1)):
    L = [0] + [d + 1 for d in range(H - 1) if (mask & (1 << d)) > 0] + [H]
    ans = min(ans, len(L) - 2 + calc(L))
print(ans)



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

S = [list(map(int, input())) for _ in range(H)]
accS = [[0] * (W + 1) for _ in range(H + 1)]

for h in range(H):
    for w in range(W):
        accS[h + 1][w + 1] = accS[h + 1][w] + accS[h][w + 1] - accS[h][w] + S[h][w]

def isOk(L, left, right):
    for top, bot in zip(L, L[1:]):
        if accS[bot][right] - accS[bot][left] - accS[top][right] + accS[top][left] > K:
            return False
    return True

ans = 10**18

for mask in range(1 << H):
    L = [0] + [d + 1 for d in range(H - 1) if (mask & (1 << d)) > 0] + [H]

    cnt = len(L) - 2
    left = 0
    while left < W:
        if not isOk(L, left, left + 1):
            cnt = 10**18
            break

        right = left + 1
        while right < W and isOk(L, left, right + 1):
            right += 1

        cnt += 1
        left = right

    ans = min(ans, cnt - 1)

print(ans)
Buggy python submission (verdict: Runtime Error):
import random
print(random.randint() % 2)

Fixed submission:
N = int(input())
A = list(map(lambda a: int(a) - 1, input()))

prd = 1
if all(a % 2 == 0 for a in A):
    prd = 2
    A = [a // 2 for a in A]

ans = 0
for i in range(N):
    if (N - 1) & i == i:
        ans ^= A[i] % 2

print(prd * ans)

Buggy python submission (verdict: Runtime Error):
import random
print(random.randint() % 2)

Fixed submission:
N = int(input())
A = list(map(lambda a: int(a) - 1, input()))

prd = 1
if all(a % 2 == 0 for a in A):
    prd = 2
    A = [a // 2 for a in A]

ans = 0
for i in range(N):
    if (N - 1) & i == i:
        ans ^= A[i] % 2

print(prd * ans)
Buggy python submission (verdict: Time Limit Exceeded):
A, B, C = map(int, input().split())

def intSqrt(n):
    M = int(n**0.5)

    while (M + 1)**2 <= n:
        M += 1

    for _ in range(4000):
        n *= 100
        M *= 10
        for add in range(0, 10)[:: -1]:
            if (M + add)**2 <= n:
                M += add
                break

    return M

if intSqrt(A) + intSqrt(B) < intSqrt(C):
    print('Yes')
else:
    print('No')


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

def intSqrt(n):
    M = int(n**0.5)

    while (M + 1)**2 <= n:
        M += 1

    for _ in range(300):
        n *= 100
        M *= 10
        for add in range(0, 10)[:: -1]:
            if (M + add)**2 <= n:
                M += add
                break

    return M

A, B, C = intSqrt(A), intSqrt(B), intSqrt(C)

if abs(A + B - C) < 10 or A + B >= C:
    print('No')
else:
    print('Yes')

Buggy python submission (verdict: Time Limit Exceeded):
A, B, C = map(int, input().split())

def intSqrt(n):
    M = int(n**0.5)

    while (M + 1)**2 <= n:
        M += 1

    for _ in range(10000):
        n *= 100
        M *= 10
        for add in range(0, 10)[:: -1]:
            if (M + add) * (M + add) <= n:
                M += add
                break

    return M

if intSqrt(A) + intSqrt(B) < intSqrt(C):
    print('Yes')
else:
    print('No')


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

def intSqrt(n):
    M = int(n**0.5)

    while (M + 1)**2 <= n:
        M += 1

    for _ in range(300):
        n *= 100
        M *= 10
        for add in range(0, 10)[:: -1]:
            if (M + add)**2 <= n:
                M += add
                break

    return M

A, B, C = intSqrt(A), intSqrt(B), intSqrt(C)

if abs(A + B - C) < 10 or A + B >= C:
    print('No')
else:
    print('Yes')