Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
#x,t=list(map(int,input().split()))
x = int(input())
if x <= 1200:
    print("ABC")
else:
    prit("ARC")
    


Fixed submission:
#x,t=list(map(int,input().split()))
x = int(input())
if x < 1200:
    print("ABC")
else:
    print("ARC")
Buggy python submission (verdict: Runtime Error):

import math
import itertools
import statistics
#import numpy as np
import collections
#n = int(input())
k, s = list(map(int, input().split()))
#a = list(map(int, input().split()))
count = 0
for x in range(k+1):
    for y in range(s-x+1):
        z = s-x-y
        ans = x+y+z
        if ans==s and y <= k and z <= k:
            count += 1
print(count)


Fixed submission:
k, s = list(map(int, input().split()))
count = 0
for x in range(k+1):
    for y in range(min(k+1, s-x+1)):
        z = s-x-y
        ans = x+y+z
        if y <= k and z <= k:
            count += 1
print(count)

Buggy python submission (verdict: Time Limit Exceeded):

import math
import itertools
import statistics
#import numpy as np
import collections
#n = int(input())
k, s = list(map(int, input().split()))
#a = list(map(int, input().split()))
count = 0
for x in range(k+1):
    for y in range(s-x+1):
        z = s-x-y
        ans = x+y+z
        if ans==s and y <= k and z <= k:
            count += 1
print(count)


Fixed submission:
k, s = list(map(int, input().split()))
count = 0
for x in range(k+1):
    for y in range(min(k+1, s-x+1)):
        z = s-x-y
        ans = x+y+z
        if y <= k and z <= k:
            count += 1
print(count)

Buggy python submission (verdict: Time Limit Exceeded):

import math
import itertools
import statistics
#import numpy as np
import collections
#n = int(input())
k, s = list(map(int, input().split()))
#a = list(map(int, input().split()))
count = 0
for x in range(k+1):
    for y in range(s-x+1):
        z = s-x-y
        ans = x+y+z
        if ans==s and y <= k and z <= k:
            count += 1
print(count)


Fixed submission:
k, s = list(map(int, input().split()))
count = 0
for x in range(k+1):
    for y in range(min(k+1, s-x+1)):
        z = s-x-y
        ans = x+y+z
        if y <= k and z <= k:
            count += 1
print(count)
Buggy python submission (verdict: Runtime Error):
n = int(input())
# n, m = list(map(int, input().split()))
# Ch, Cw = list(map(int, input().split()))
# Dh, Dw = list(map(int, input().split()))
# data = [list(map(int, input().split())) for i in range(4)]
# n = int(input())
a = list(map(int, input().split()))
# r = list(map(int, input().split()))
# ab_sorted = sorted(ab, key=lambda x: x[0])
# data = [list(map(int, input().split())) for i in range(n)]
a.sort()
if n == 1:
    if a[0] == 0:
        print(1)
    else:
        print(0)

if n % 2 == 1:
    if a[0] == 0 and a[1] == 0:
        print(0)
        exit()
    ans = 1
    for i in range(1, n, 2):
        if not(a[i] == a[i+1] and a[i] == i+1):
            print(0)
            exit()
        else:
            ans *= 2
    print(ans)
else:
    ans = 1
    for i in range(0, n, 2):
        if not(a[i] == a[i+1] and a[i] == i+1):
            print(0)
            exit()
        else:
            ans *= 2
    print(ans)


Fixed submission:
n = int(input())
a = list(map(int, input().split()))
a.sort()
if n == 1:
    if a[0] == 0:
        print(1)
    else:
        print(0)
    exit()

mod = 10**9 + 7
if n % 2 == 1:
    if a[0] == 0 and a[1] == 0:
        print(0)
        exit()
    ans = 1
    for i in range(1, n, 2):
        if not(a[i] == a[i+1] and a[i] == i+1):
            print(0)
            exit()
        else:
            ans *= 2
    print(ans % mod)
else:
    ans = 1
    for i in range(0, n, 2):
        if not(a[i] == a[i+1] and a[i] == i+1):
            print(0)
            exit()
        else:
            ans *= 2
    print(ans % mod)

Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
a.sort()
if a[0] == 0 and a[1] == 0:
    print(0)
    exit()
count = 1
ans = 1
for i in range(n-1):
    if a[i] == a[i+1]:
        count += 1
    else:
        ans *= count
        count = 1

    if count > 3:
        print(0)
        exit()
ans *= count
print(ans)


Fixed submission:
n = int(input())
a = list(map(int, input().split()))
a.sort()
if n == 1:
    if a[0] == 0:
        print(1)
    else:
        print(0)
    exit()

mod = 10**9 + 7
if n % 2 == 1:
    if a[0] == 0 and a[1] == 0:
        print(0)
        exit()
    ans = 1
    for i in range(1, n, 2):
        if not(a[i] == a[i+1] and a[i] == i+1):
            print(0)
            exit()
        else:
            ans *= 2
    print(ans % mod)
else:
    ans = 1
    for i in range(0, n, 2):
        if not(a[i] == a[i+1] and a[i] == i+1):
            print(0)
            exit()
        else:
            ans *= 2
    print(ans % mod)
Buggy python submission (verdict: Runtime Error):
s = input()
n = len(s)-1
ans = 0
for i in range(2**n):
    data = []
    for j in range(n):
        if((i >> j) & 1):
            data.append(1)
        else:
            data.append(0)
    num = s[0]
    x = []
    for i in range(n-1):
        if data[i] == 1:
            x.append(int(num))
            num = s[i+1]
        else:
            num += s[i+1]
    if data[-1] == 0:
        num += s[-1]
        x.append(int(num))
    else:
        x.append(int(num))
        x.append(int(s[-1]))
    ans += sum(x)
print(ans)


Fixed submission:
s = input()
n = len(s)-1
if n == 0:
    print(s)
    exit()

ans = 0
for i in range(2**n):
    data = []
    for j in range(n):
        if((i >> j) & 1):
            data.append(1)
        else:
            data.append(0)
    # print(data)
    num = s[0]
    x = []
    for i in range(n-1):
        if data[i] == 1:
            x.append(int(num))
            num = s[i+1]
        else:
            num += s[i+1]
    if data[-1] == 0:
        num += s[-1]
        x.append(int(num))
    else:
        x.append(int(num))
        x.append(int(s[-1]))
    ans += sum(x)
    # print(x)
print(ans)
Buggy python submission (verdict: Runtime Error):
n ＝ int(input())
sum=0
for i in range(1,n+1):
    sum+=i
print(sum)


Fixed submission:
n = int(input())
sum=0
for i in range(1,n+1):
    sum+=i
print(sum)

Buggy python submission (verdict: Runtime Error):
n ＝ input()
sum=0
for i in range(1,n+1):
    sum+=i
print(sum)

Fixed submission:
n = int(input())
sum=0
for i in range(1,n+1):
    sum+=i
print(sum)
Buggy python submission (verdict: Runtime Error):
import sys
def input(): return sys.stdin.readline().strip()

def main():
    n, x, m = map(int, input().split())
    if x == 0:
        print(0)
        return
    if x == 1:
        print(n)
        return

    d = {}
    d_idx = {}
    d_unit = {}
    idx = 0
    pow_x = x
    unit = 0
    while idx < n and pow_x not in d:
        d[pow_x] = idx
        d_idx[idx] = pow_x
        unit += pow_x
        d_unit[idx] = unit

        pow_x *= pow_x
        pow_x %= m
        idx += 1
    # x^{2^idx} = 1

    if idx == n - 1:
        print(unit)
        return
    pre_idx = d[pow_x]
    pre_unit = d_unit[pre_idx] - d_idx[pre_idx]
    iter_unit = unit - pre_unit
    ans = pre_unit + iter_unit * ((n - pre_idx) // (idx - pre_idx))
    for i in range((n - pre_idx) % (idx - pre_idx)):
        ans += d_idx[i + pre_idx]
    print(ans)

if __name__ == "__main__":
    main()


Fixed submission:
import sys
def input(): return sys.stdin.readline().strip()

def main():
    n, x, m = map(int, input().split())
    if x == 0:
        print(0)
        return
    if x == 1:
        print(n)
        return

    d = {}
    d_idx = {}
    d_unit = {}
    idx = 0
    pow_x = x
    unit = 0
    while idx < n and pow_x not in d:
        d[pow_x] = idx
        d_idx[idx] = pow_x
        unit += pow_x
        d_unit[idx] = unit

        pow_x *= pow_x
        pow_x %= m
        idx += 1
    # x^{2^idx} = 1

    if idx == n:
        print(unit)
        return
    pre_idx = d[pow_x]
    pre_unit = d_unit[pre_idx] - d_idx[pre_idx]
    iter_unit = unit - pre_unit
    ans = pre_unit + iter_unit * ((n - pre_idx) // (idx - pre_idx))
    for i in range((n - pre_idx) % (idx - pre_idx)):
        ans += d_idx[i + pre_idx]
    print(ans)

if __name__ == "__main__":
    main()
Buggy python submission (verdict: Time Limit Exceeded):
import sys
def input(): return sys.stdin.readline().strip()

def main():
    H, W, M = map(int, input().split())
    bomb = set()
    yoko = [0] * W
    tate = [0] * H
    for _ in range(M):
        h, w = map(int, input().split())
        bomb.add((h-1, w-1))
        yoko[w - 1] += 1
        tate[h - 1] += 1

    idx_yoko = [(yoko[i], i) for i in range(W)]
    idx_tate = [(tate[i], i) for i in range(H)]
    idx_yoko.sort(reverse=True, key=lambda x: (x[0], x[1]))
    idx_tate.sort(reverse=True, key=lambda x: (x[0], x[1]))
    ans = 0
    for p in range(min(5000, W)):
        for q in range(min(5000, H)):
            yoko_bomb, idx_w = idx_yoko[p]
            tate_bomb, idx_h = idx_tate[q]
            get_bomb = yoko_bomb + tate_bomb
            if (idx_h, idx_w) in bomb: get_bomb -= 1
            ans = max(ans, get_bomb)
    print(ans)



if __name__ == "__main__":
    main()


Fixed submission:
import sys
def input(): return sys.stdin.readline().strip()

def main():
    H, W, M = map(int, input().split())
    bomb = set()
    yoko = [0] * W
    tate = [0] * H
    for _ in range(M):
        h, w = map(int, input().split())
        bomb.add((h-1, w-1))
        yoko[w - 1] += 1
        tate[h - 1] += 1

    idx_yoko = [(yoko[i], i) for i in range(W)]
    idx_tate = [(tate[i], i) for i in range(H)]
    idx_yoko.sort(reverse=True, key=lambda x: (x[0], x[1]))
    idx_tate.sort(reverse=True, key=lambda x: (x[0], x[1]))
    ans = 0

    yoko_bomb, idx_w = idx_yoko[0]
    tate_bomb_max = idx_tate[0][0]
    for tate_bomb, idx_h in idx_tate:
        if tate_bomb != tate_bomb_max: break
        if (idx_h, idx_w) not in bomb:
            print(yoko_bomb + tate_bomb)
            return

    tate_bomb, idx_h = idx_tate[0]
    yoko_bomb_max = idx_yoko[0][0]
    for yoko_bomb, idx_w in idx_yoko:
        if yoko_bomb != yoko_bomb_max: break
        if (idx_h, idx_w) not in bomb:
            print(yoko_bomb + tate_bomb)
            return

    print(yoko_bomb_max + tate_bomb_max - 1)
    

if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
import sys
def input(): return sys.stdin.readline().strip()
import numpy as np


def main():
    x = input()
    if ord(x) <= 90: print("A")
    else: print("a")

if __name__ == "__main__":
    main()


Fixed submission:
import sys
def input(): return sys.stdin.readline().strip()


def main():
    x = input()
    if ord(x) <= 90: print("A")
    else: print("a")

if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
import sys
def input(): return sys.stdin.readline().strip()
import numpy as np


def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    A.sort()
    print(sum(A[:K]))


if __name__ == "__main__":
    main()


Fixed submission:
import sys
def input(): return sys.stdin.readline().strip()


def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    A.sort()
    print(sum(A[:K]))


if __name__ == "__main__":
    main()
Buggy python submission (verdict: Time Limit Exceeded):
N, S = map(int, input().split())
A = list(map(int, input().split()))
d = sum(A)
mod = 998244353

"""
多項式係数を使った数え上げでリベンジしてみる。
maspyさんのを参考に実装する。

やってみてわかったけど、実装自体はdpでやったのとほぼ同じ。
多項式係数を使う方法は実質flexibleなdpということ？
"""

f = [0] * (1 + d) # f[i] = (coefficient of degree i)
ans = 0

for i in range(N):
    g = [0] * (1 + d) # g = (1 + f) * (1 + x^{A[i]})
    f[0] += 1
    for j in range(1 + d):
        if j - A[i] < 0:
            g[j] = f[j]
        else:
            g[j] = f[j] + f[j - A[i]]
    ans += g[S]
    ans %= mod
    f = g

print(ans)


Fixed submission:
N, S = map(int, input().split())
A = [0] + list(map(int, input().split()))
mod = 998244353

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

"""
dp[i][j] = (i個までの数を使ってj点とる組み合わせ)
としたはいいが、f(L, R)をf(1,L)とf(1, R)に分解できずに爆死したのが敗因。

各(L, R)に対してdpするとTLEになるから手詰まりになると思ったわけだけど、
上のdpテーブルを各iに対して使い回しつつ、新たなdpテーブル[1, 0, 0, ...]を
作成して「元のdpテーブルに加算しておけば」dpテーブル一個で1番目スタート、2番目スタート、
..., L番目スタートのdpテーブル全てを考えられる！
（解説放送前半を参考）
"""

# i == 0の時
dp[0] = 1
ans = 0

# i >= 1の時
for i in range(1, N + 1):
    for j in range(S + 1):
        if j - A[i] < 0:
            dp2[j] = dp[j]
        else:
            dp2[j] = dp[j] + dp[j - A[i]]
    ans += dp2[S]
    ans %= mod

    dp = dp2 # deepcopyしなくてもこれで十分なはずだし、ポインタ渡しなので高速？
    dp[0] += 1
    dp2 = [0] * (S + 1)

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from copy import deepcopy

N, S = map(int, input().split())
A = [0] + list(map(int, input().split()))
mod = 998244353

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

"""
dp[i][j] = (i個までの数を使ってj点とる組み合わせ)
としたはいいが、f(L, R)をf(1,L)とf(1, R)に分解できずに爆死したのが敗因。

各(L, R)に対してdpするとTLEになるから手詰まりになると思ったわけだけど、
上のdpテーブルを各iに対して使い回しつつ、新たなdpテーブル[1, 0, 0, ...]を
作成して「元のdpテーブルに加算しておけば」dpテーブル一個で1番目スタート、2番目スタート、
..., L番目スタートのdpテーブル全てを考えられる！
（解説放送前半を参考）
"""

# i == 0の時
dp[0] = 1
ans = 0

# i >= 1の時
for i in range(1, N + 1):
    for j in range(S + 1):
        if j - A[i] < 0:
            dp2[j] = dp[j]
        else:
            dp2[j] = dp[j] + dp[j - A[i]]
    ans += dp2[S]
    ans %= mod

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

print(ans)


Fixed submission:
N, S = map(int, input().split())
A = [0] + list(map(int, input().split()))
mod = 998244353

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

"""
dp[i][j] = (i個までの数を使ってj点とる組み合わせ)
としたはいいが、f(L, R)をf(1,L)とf(1, R)に分解できずに爆死したのが敗因。

各(L, R)に対してdpするとTLEになるから手詰まりになると思ったわけだけど、
上のdpテーブルを各iに対して使い回しつつ、新たなdpテーブル[1, 0, 0, ...]を
作成して「元のdpテーブルに加算しておけば」dpテーブル一個で1番目スタート、2番目スタート、
..., L番目スタートのdpテーブル全てを考えられる！
（解説放送前半を参考）
"""

# i == 0の時
dp[0] = 1
ans = 0

# i >= 1の時
for i in range(1, N + 1):
    for j in range(S + 1):
        if j - A[i] < 0:
            dp2[j] = dp[j]
        else:
            dp2[j] = dp[j] + dp[j - A[i]]
    ans += dp2[S]
    ans %= mod

    dp = dp2 # deepcopyしなくてもこれで十分なはずだし、ポインタ渡しなので高速？
    dp[0] += 1
    dp2 = [0] * (S + 1)

print(ans)
Buggy python submission (verdict: Runtime Error):
A, B, C = map(int, input().split())
if A == B and B != C:
    print("Yes)
elif B == C and C != A:
    print("Yes")
elif C == A and A != B:
    print("Yes")
else:
    print("No")

Fixed submission:
A, B, C = map(int, input().split())
if A == B and B != C:
    print("Yes")
elif B == C and C != A:
    print("Yes")
elif C == A and A != B:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
N = int(input())
K = int(input())

l = len(str(N))
a = N // 10**(l - 1)
b = N // 10**(l - 2)
c = N // 10**(l - 3)

d = b - 10 * a
e = c - 100 * a - 10 * d

if K == 1:
    ans = 9 * (l - 1) + a
    print(ans)
elif K == 2:
    if l == 1:
        print(0)
    else:
        ans = 81 * (l - 1) * (l - 2) // 2
        ans += (a - 1) * 9 * (l - 1) + 9 * (l - 2) + d
        print(ans)
else:
    if l == 1 or l == 2:
        print(0)
    else:
        ans = 729 * (l - 1) * (l - 2) * (l - 3) // 6
        ans += (a - 1) * 81 * (l - 1) * (l - 2) // 2
        ans += 81 * (l - 2) * (l - 3) // 2
        if d != 0:
            ans += (d - 1) * 9 * (l - 2)
        ans += (l - 3) * 9 + e

print(ans)

Fixed submission:
N = int(input())
K = int(input())
memo = {}

def F(N, K):
    """
    F(N, K) = (1以上N以下で0でない桁がちょうどK個なものの個数)
    Nを一の桁から見ていくことで再帰で求める
    （例）F(314,3) = F(31,2)*4 + F(30,2)*5 + F(31,3)
                      = {F(3,1) + F(2,1)*8 + F(3,2)} * 4
                            + {F(2,1)*9 + F(3,2)} * 5
                            + {F(3,2) + F(2,2)*8 + F(3,3)}
                      = ...
    """
    r = int(str(N)[-1])
    M = (N - r) // 10
    if K == 0 and N >= 0:
        return 1
    elif K == 0 and N <= -1:
        return 0
    elif N <= 0:
        return 0
    else:
        return F(M, K-1) * r + F(M-1, K-1) * (9-r) + F(M, K)

print(F(N, K))
Buggy python submission (verdict: Time Limit Exceeded):
import heapq

N, M = map(int, input().split())
A = list(map(int, input().split()))
for i, a in enumerate(A):
    A[i] = -a
A.sort()
h = []
"""
Contain in lst the pair (a+b, a, b) such that a+b gets smaller monotonically
At this stage we identify (a, b) with (b, a)
"""
for i in range(N):
    a = -A[i]
    for j in range(i, N):
        b = -A[j]
        heapq.heappush(h, (-a-b, a, b))

happy = 0
times = 0
while times < M:
    s, a, b = heapq.heappop(h)
    if a == b:
        happy -= s
        times += 1
    else:
        if times < M - 1:
            happy -= s * 2
            times += 2
        else:
            happy -= s
            times += 1

print(happy)


Fixed submission:
import sys
from bisect import bisect_left, bisect_right
import itertools

N, M = map(int, input().split())
A = list(map(int, input().split()))
A.sort()
#print("A={}".format(A))
"""
この問題の前半は、合計の幸福度Xが上位M個未満に入るかを判定する。
    -> Xに関する二分探索をすることで、上位から丁度M番目の幸福度がわかる！

これを判定するために、左手の握手先をfix(A[i]とする)して、
右手の幸福度が(X - A[i])以上であるものの個数を数える。
"""

def within(X, M):
    """
    幸福度がX以上上がるような握手の組がM個未満ならTrue、そうでなければFalseを返す
    """
    pair = 0
    for i in range(N):
        idx = bisect_left(A, X - A[i])
        pair += N - idx
    if pair < M:
        #print("pair={}<M".format(pair))
        return True
    else:
        #print("pair={}>=M".format(pair))
        return False

"""
Xに関する二分探索をおこなった結果、
leftXはwithin(leftX, M) == Trueになる最小のX
"""
leftX = 0
rightX = A[-1] * 2 + 1
while leftX != rightX:
    middleX = (leftX + rightX) // 2
    #print("mid={}".format(middleX))
    if within(middleX, M):
        rightX = middleX
    else:
        leftX = middleX + 1
#print("leftX={}".format(leftX))

"""
これより後半、幸福度の総和を求める。
前半同様に左手をfixした上で、両手の幸福度の合計がleftX以上になるときの幸福度を加算していく。
単純に右手に関してfor文を回して加算するとTLEなので、
右手の幸福度に関しては先に累積和を求めておく。
"""
S = list(itertools.accumulate(A))
#print("S={}".format(S))
happy = 0
times = 0
for i in range(N):
    idx = bisect_left(A, leftX - A[i])
    times += N - idx
    #print("When i={}, idx={}, times={}".format(i, idx, times))
    if idx != 0:
        happy += A[i] * (N - idx) + (S[-1] - S[idx - 1])
    else:
        happy += A[i] * (N - idx) + S[-1]
    #print("happy={}".format(happy))
happy += (leftX - 1) * (M - times)

print(happy)
Buggy python submission (verdict: Runtime Error):
import sys, math
from collections import defaultdict
from copy import deepcopy
import itertools
input = sys.stdin.readline
# 文字列の場合は普通のinput()を使うか下を使う
# input = sys.stdin.readline().rstrip()


A, B = map(int, input().split())
gcd = math.gcd(A, B)
ans = A * B // gcd
print(ans)

Fixed submission:
import sys, fractions
from collections import defaultdict
from copy import deepcopy
import itertools
input = sys.stdin.readline
# 文字列の場合は普通のinput()を使うか下を使う
# input = sys.stdin.readline().rstrip()


A, B = map(int, input().split())
gcd = fractions.gcd(A, B)
ans = A * B // gcd
print(ans)
Buggy python submission (verdict: Runtime Error):
import sys, math
from collections import defaultdict
from copy import deepcopy
import itertools
input = sys.stdin.readline
# 文字列の場合は普通のinput()を使うか下を使う
# input = sys.stdin.readline().rstrip()


N = int(input())
if N % 2 == 1:
    print(0)
else:
    k = N // 2
    a = int(math.log(k, 5))
    ans = 0
    for i in range(1, a + 1):
        ans += k // (5 ** i)
    print(ans)

Fixed submission:
import sys
from collections import defaultdict
from copy import deepcopy
import itertools
input = sys.stdin.readline
# 文字列の場合は普通のinput()を使うか下を使う
# input = sys.stdin.readline().rstrip()


def log(k, b):
    a = 0
    while b ** a <= k:
        a += 1
    return a - 1



N = int(input())
if N % 2 == 1:
    print(0)
else:
    k = N // 2
    a = log(k, 5)
    ans = 0
    for i in range(1, a + 1):
        ans += k // (5 ** i)
    print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import sys, math
from collections import defaultdict, deque
from copy import deepcopy
import itertools
# 文字列の場合は普通のinput()を使うか下を使う
# input = sys.stdin.readline().rstrip()

N = int(input())
S = input()
q = deque([])
q_new = deque([])
d = {}
for i in range(10):
    for j in range(10):
        for k in range(10):
            q.append((i, j, k))
            d[(i, j, k)] = 0

ans = 0
for x in S:
    x = int(x)
    while q:
        (i, j, k) = q.popleft()
        n = d[(i, j, k)]
        if n == 2 and k == x:
            ans += 1
        else:
            if n == 0 and i == x:
                d[(i, j, k)] += 1
            elif n == 1 and j == x:
                d[(i, j, k)] += 1
            q_new.append((i, j, k))
        
    q = q_new
    q_new = deque([])
print(ans)

Fixed submission:
import sys, math
from collections import defaultdict, deque
from copy import deepcopy
import itertools
# 文字列の場合は普通のinput()を使うか下を使う
# input = sys.stdin.readline().rstrip()

N = int(input())
S = input()
q = deque([])
q_new = deque([])
d = defaultdict(list)
for i in range(10):
    for j in range(10):
        for k in range(10):
            d[i].append([k, j, i])

ans = 0
for x in S:
    x = int(x)
    q = deepcopy(d[x])
    d[x] = []
    for key in q:
        l = len(key)
        if l == 3:
            d[key[1]].append(key[:2])
        elif l == 2:
            d[key[0]].append(key[:1])
        elif l == 1:
            ans += 1

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import sys, math
from collections import defaultdict
from copy import deepcopy
import itertools
# 文字列の場合は普通のinput()を使うか下を使う
# input = sys.stdin.readline().rstrip()

N = int(input())
S = input()
d = {}
key = set([])
for i in range(10):
    for j in range(10):
        for k in range(10):
            d[(i, j, k)] = 0
            key.add((i, j, k))

ans = 0
for x in S:
    x = int(x)
    for key_num in key:
        i, j, k = key_num
        n = d[key_num]
        if n == 0 and i == x:
            d[key_num] += 1
        elif n == 1 and j == x:
            d[key_num] += 1
        elif n == 2 and k == x:
            d[key_num] += 1
            ans += 1
print(ans)

Fixed submission:
import sys, math
from collections import defaultdict, deque
from copy import deepcopy
import itertools
# 文字列の場合は普通のinput()を使うか下を使う
# input = sys.stdin.readline().rstrip()

N = int(input())
S = input()
q = deque([])
q_new = deque([])
d = defaultdict(list)
for i in range(10):
    for j in range(10):
        for k in range(10):
            d[i].append([k, j, i])

ans = 0
for x in S:
    x = int(x)
    q = deepcopy(d[x])
    d[x] = []
    for key in q:
        l = len(key)
        if l == 3:
            d[key[1]].append(key[:2])
        elif l == 2:
            d[key[0]].append(key[:1])
        elif l == 1:
            ans += 1

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

a, b, x = map(int, input().split())
V = a * a * b // 2

if V >= x:
    #print('V >= x')
    l = (2 * x) / (a * b)
    theta = 90 - degrees(atan(l / b))
else:
    h = ((2 * x) / (a * a)) - b
    theta = 90 - degrees(atan(a / (b - h)))

print(theta)

Fixed submission:
from math import atan, degrees

a, b, x = map(int, input().split())
V = a * a * b // 2

if V >= x:
    #print('V >= x')
    l = (2 * x) / (a * b)
    theta = 90 - degrees(atan(l / b))
else:
    h = ((2 * x) / (a * a)) - b
    if b != h:
        theta = 90 - degrees(atan(a / (b - h)))
    else:
        theta = 0

print(theta)