Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
import sys
#入力S
S = input()

#入力T
T = input()
ran_T = range(len(T))
#print(len(T))
#print(range(len(T)))
count = 0

for i in ran_T:
    if list(S)[i] != list(T)[i]:
        count += 1

print(count)


Fixed submission:
#入力S
S = input()

#入力T
T = input()
ran_T = range(len(T))
#print(len(T))
#print(range(len(T)))
count = 0

for a, b in zip(S, T):
    if a != b:
        count += 1

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

#入力する値の個数N
N = input()

#入力される値 A
A = list(map(int, input().split()))

#print(N)
#print(A)
ans = 1
if 0 in A:
    print("-1")
    sys.exit()


for i in A:
    #print(i)
    ans *= i
    #print(ans)
    if ans > 10**18:
        print("-1")
        sys.exit()

print(ans)

Fixed submission:
#入力される値A B
A, B = map(int, input().split())

#出力される値
print(A*B)
Buggy python submission (verdict: Runtime Error):
N, M = list(map(int, input().split()))

H = list(map(int, input().split()))

ans = [1]*N

for i in range(M):
    A, B = list(map(int, input().split()))
    if H[A-1] > H[B-1]:
        ans[B-1] = 0
    elif H[A-1] < H[B-1]:
        ans[A-1] = 0
    else:
        ans[A-1] = 0
        ans[B-1] = 0

print(sum(ans))

Fixed submission:
import sys
S = input()

if S == "ABC":
    print("ARC")
    sys.exit()
else:
    print("ABC")
    sys.exit()
Buggy python submission (verdict: Runtime Error):
a, b, c = map(int, input().split())
s = [a, b, c]
#print(s)


counter = s.count(1)
print(counter)

Fixed submission:
a = input()

print(a.count("1"))
Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8
# Your code here!
# 幅優先探索（行きがけ）
import collections
import sys
import copy
import re
import math


def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())


def main():
    N = I()
    AArray = LI()
    MOD = 1000000007

    ans = 0

    for i in range(N-1):
        a = AArray[i]
        asum = sum(AArray[i+1:])
        asum %= MOD
        ans += a*asum % MOD
    ans %= MOD

    print(ans)


if __name__ == '__main__':
    main()


Fixed submission:
# coding: utf-8
# Your code here!
# 幅優先探索（行きがけ）
import collections
import sys
import copy
import re
import math


def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())


def main():
    N = I()
    AArray = LI()
    MOD = 1000000007
    aSum = sum(AArray)
    nowAsum = 0
    ans = 0

    for i in range(N-1):
        a = AArray[i]
        nowAsum += a
        asum = aSum-nowAsum
        asum %= MOD
        ans += a*asum % MOD
    ans %= MOD

    print(ans)


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8
# Your code here!
# 幅優先探索（行きがけ）
import collections
import sys
import copy
import re
import math
import itertools


def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())


def main():
    H, W, M = LI()

    HList = [0]*H
    WList = [0]*W
    graph = [[0 for _ in range(W)] for _ in range(H)]

    for m in range(M):
        h, w = LI()
        HList[h-1] += 1
        WList[w-1] += 1
        graph[h-1][w-1] += 1

    Hmax = max(HList)
    Wmax = max(WList)

    HIndex = [i for i, v in enumerate(HList) if v == Hmax]
    WIndex = [i for i, v in enumerate(WList) if v == Wmax]

    ans = Hmax + Wmax
    for h in HIndex:
        for w in WIndex:
            if graph[h][w] == 0:
                print(ans)
                return

    print(ans-1)


if __name__ == '__main__':
    main()


Fixed submission:
# coding: utf-8
# Your code here!
# 幅優先探索（行きがけ）
import collections
import sys
import copy
import re
import math
import itertools


def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())


def main():
    H, W, M = LI()

    HList = [0]*H
    WList = [0]*W
    graph = set()
    for m in range(M):
        h, w = LI()
        HList[h-1] += 1
        WList[w-1] += 1
        graph.add((h-1, w-1))

    Hmax = max(HList)
    Wmax = max(WList)

    HIndex = [i for i, v in enumerate(HList) if v == Hmax]
    WIndex = [i for i, v in enumerate(WList) if v == Wmax]

    ans = Hmax + Wmax
    for h in HIndex:
        for w in WIndex:
            if not (h, w) in graph:
                print(ans)
                return

    print(ans-1)


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
# 幅優先探索（行きがけ）
import collections
import sys
import math


def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())


def main():
    N = I()
    if N <= 5:
        for i in range(N):
            print(0)
        return

    def yy(x, y, z):
        return x**2+y**2+z**2+x*y+y*z+z*x

    for i in range(5):
        print(0)

    for i in range(6, N+1):
        cn = 0
        for j in range(1, math.floor(math.sqrt(i)+1)):
            if j**2 >= i:
                break
            for k in range(1, j+1):
                if j**2+k**2+j*k >= i:
                    break
                for l in range(1, k+1):
                    y = yy(j, k, l)
                    if y > i:
                        break
                    if y == i:
                        if j == k == l:
                            cn += 1
                        elif j != k != l:
                            cn += 6
                        else:
                            cn += 3
        print(cn)


if __name__ == '__main__':
    main()


Fixed submission:
# 幅優先探索（行きがけ）
import collections
import sys
import math


def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())


def main():
    N = I()
    if N <= 5:
        for i in range(N):
            print(0)
        return

    def yy(x, y, z):
        return x**2+y**2+z**2+x*y+y*z+z*x

    for i in range(5):
        print(0)

    for i in range(6, N+1):
        cn = 0
        n = math.floor(math.sqrt(i)+1)
        start = math.floor(math.sqrt(i/6))
        for j in range(start, n):
            if j**2 >= i-4:
                break
            for k in range(1, j+1):
                if j**2+k**2+j*k >= i-2:
                    break
                for l in range(1, k+1):
                    y = yy(j, k, l)
                    if y > i:
                        break
                    if y == i:
                        if j == k == l:
                            cn += 1
                        elif j != k != l:
                            cn += 6
                        else:
                            cn += 3
        print(cn)


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
# 幅優先探索（行きがけ）
import collections
import sys
import copy
import re
import math


def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())


def main():
    N = I()

    num = 0

    for i in range(1, N+1):
        y = math.floor(N/i)
        num += int((y*(y+1)*i)/2)

    print(num)


if __name__ == '__main__':
    main()


Fixed submission:
# 幅優先探索（行きがけ）
import collections
import sys
import copy


def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())


def main():
    N = I()

    num = 0

    for i in range(1, N+1):
        y = N//i
        num += int((y*(y+1)*i)/2)

    print(num)


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
import itertools

import math


def main():
    A, B = map(int, input().split())

    print(math.floor(A*B))


if __name__ == '__main__':
    main()


Fixed submission:
from math import floor, ceil
import decimal


def main():

    A, B = map(float, input().split())
    B = round(B, 2)
    A = int(A)
    A = decimal.Decimal(str(A))
    B = decimal.Decimal(str(B))
    AB = A*B
    AB = floor(AB)
    print(AB)


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
def main():
    N, M = list(map(int, input().split()))
    ks = [[int(arg) for arg in input().split()] for _ in range(M)]
    p = list(map(int, input().split()))
    comb = 0

    for i in range(2**N):
        flag = False
        for j in range(N):
            denki = []
            if ((i >> j) & 1):  # 順に右にシフトさせ最下位bitのチェックを行う
                denki.append(j+1)  # フラグが立っていたら num に数字を詰める
            for k in range(M):
                KS = ks[k]
                k = KS[0]
                kosuu = 0
                for l in range(1, k+1):
                    if KS[l] in denki:
                        kosuu += 1
                if kosuu % 2 != p[k]:
                    flag = False
                    break
                else:
                    flag = True
            if flag:
                comb += 1

    print(comb)


if __name__ == '__main__':
    main()


Fixed submission:
def main():
    N, M = list(map(int, input().split()))
    ks = [[int(arg) for arg in input().split()] for _ in range(M)]
    p = list(map(int, input().split()))
    comb = 0

    for i in range(2**N):
        flag = False
        denki = []
        for j in range(N):

            if ((i >> j) & 1):  # 順に右にシフトさせ最下位bitのチェックを行う
                denki.append(j+1)  # フラグが立っていたら num に数字を詰める
        for k in range(M):
            KS = ks[k]
            idk = KS[0]
            kosuu = 0
            for l in range(1, idk+1):
                if KS[l] in denki:
                    kosuu += 1
            if kosuu % 2 != p[k]:
                flag = False
                break
            else:
                flag = True
        if flag:
            comb += 1

    print(comb)


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
N=int(input())
y=0
for j in range(1,N):
    for k in range(1,N): 
        if (N-k)%j==0:
            y=y+1
print(y)

Fixed submission:
x=input()
if x[-1]==("s"):
    print(x+"es")
elif x[-1]!=("s"):
    print(x+"s")
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3
import sys
import networkx as nx

def solve(N: int, M: int, A: "List[int]", B: "List[int]"):
    G = nx.Graph()

    for i in range(1, N+1):
        G.add_node(i)

    for i in range(M):
        G.add_edge(A[i], B[i])

    if nx.is_connected(G):
        print(0)
    else:
        print(nx.number_connected_components(G)-1)
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    A = [int()] * (M)  # type: "List[int]"
    B = [int()] * (M)  # type: "List[int]"
    for i in range(M):
        A[i] = int(next(tokens))
        B[i] = int(next(tokens))
    solve(N, M, A, B)

if __name__ == '__main__':
    main()


Fixed submission:
#!/usr/bin/env python3
import sys
import networkx as nx

def solve(N: int, M: int, A: "List[int]", B: "List[int]"):
    G = nx.Graph()

    for i in range(1, N+1):
        G.add_node(i)

    for i in range(M):
        G.add_edge(A[i], B[i])

    if nx.is_connected(G):
        print(0)
    else:
        print(nx.number_connected_components(G)-1)
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    A = [int()] * (M)  # type: "List[int]"
    B = [int()] * (M)  # type: "List[int]"
    for i in range(M):
        A[i] = int(next(tokens))
        B[i] = int(next(tokens))
    solve(N, M, A, B)

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
import sys

MOD = 1000000007  # type: int


def solve(N: int, A: "List[int]"):
    ans = 0
    for i, ai in enumerate(A):
        for j, aj in enumerate(A[i+1:]):
            ans += (ai * aj) % MOD
    
    print(ans % MOD)
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, A)

if __name__ == '__main__':
    main()


Fixed submission:
#!/usr/bin/env python3
import sys

MOD = 1000000007  # type: int


def solve(N: int, A: "List[int]"):
    ans = 0

    B = [sum(A[1:])]
    for i, a in enumerate(A[1:-1]):
        B.append(B[i] - a)

    for i, ai in enumerate(A[:-1]):
        ans += (ai * B[i]) % MOD
    
    print(ans % MOD)
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, A)

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
import sys

def solve(N: int, A: "List[int]"):
    ans = 1
    for a in A:
        ans = ans * a

    if ans > 10**18:
        print(-1)
    else:
        print(ans)
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, A)

if __name__ == '__main__':
    main()


Fixed submission:
#!/usr/bin/env python3
import sys

def solve(N: int, A: "List[int]"):
    A.sort()
    ans =1
    for a in A:
        ans = ans * a

        if ans > 10**18:
            print(-1)
            return
    
    print(ans)
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, A)

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
import sys
import itertools as it

d = {}
def _gcd(a,b):
    a, b = max(a,b), min(a,b)
    while b:
        if d.get((a, b), False):
            return d[(a, b)]
        else:
            a, b = b, a%b

    d[(a, b)] = a
    return a

# def _gcd(a,b):
#     a, b = max(a,b), min(a,b)
#     if b == 0:
#         d[(a, b)] = a
#         return a
#     elif d.get((a, b), False):
#         return d[(a, b)]
#     else:
#         ans = _gcd(b, a%b)
#         d[(a, b)] = ans
#         return ans

def gcd(a,b,c):
    return _gcd(a, _gcd(b,c))

def solve(K: int):
    ans = 0
    r = range(1, K+1)
    for (a,b,c) in it.product(r,r,r):
        ans += gcd(a,b,c)
    print(ans)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    K = int(next(tokens))  # type: int
    solve(K)

if __name__ == '__main__':
    main()


Fixed submission:
#!/usr/bin/env python3
import sys
import itertools as it
import numpy as np
from collections import Counter
d = {}
def _gcd(a,b):
    a, b = max(a,b), min(a,b)
    while b:
        if d.get((a, b), False):
            return d[(a, b)]
        else:
            a, b = b, a%b

    d[(a, b)] = a
    return a

# def _gcd(a,b):
#     a, b = max(a,b), min(a,b)
#     if b == 0:
#         d[(a, b)] = a
#         return a
#     elif d.get((a, b), False):
#         return d[(a, b)]
#     else:
#         ans = _gcd(b, a%b)
#         d[(a, b)] = ans
#         return ans

def gcd(a,b,c):
    return _gcd(a, _gcd(b,c))

def solve(K: int):
    # val_arr = np.zeros(201,201)
    # cnt_arr = np.zeros(201,201)
    r = range(1, K+1)

    arr = []
    for (a,b) in it.product(r,r):
        arr.append(_gcd(a,b))
        # val_arr[a,b] += _gcd(a,b)
        # cnt_arr[a,b] += 1

    ans = 0
    cnt_dict = Counter(arr)
    for i in r:
        for key, cnt in cnt_dict.items():
            ans += _gcd(i,key)*cnt

    print(ans)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    K = int(next(tokens))  # type: int
    solve(K)

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3
import sys
from collections import deque

def get_digits(i):
    last_digit = int(str(i)[-1])
    if last_digit in list(range(1,9)):
        return [last_digit-1, last_digit, last_digit+1]
    elif last_digit == 0:
        return [last_digit, last_digit+1]
    elif last_digit == 9:
        return [last_digit-1, last_digit]

def solve(K: int):
    deq1 = deque()
    deq2 = deque()
    lunlun_list = []

    for i in range(1,10):
        deq1.append(i)
        lunlun_list.append(i)

    while  len(lunlun_list) <= 10 ** 5:
        num = deq1.popleft()
        digits = get_digits(num)
        for new_digit in digits:
            new_num = int(str(num)+str(new_digit))
            lunlun_list.append(new_num)
            deq2.append(new_num)

        if len(deq1) == 0:
            deq1 = deq2.copy()
            deq2 = deque()

    print(lunlun_list[K-1])


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    K = int(next(tokens))  # type: int
    solve(K)

if __name__ == '__main__':
    main()


Fixed submission:
#!/usr/bin/env python3
import sys
from collections import deque
from copy import copy

def get_digits(i):
    last_digit = int(str(i)[-1])
    if last_digit in list(range(1,9)):
        return [last_digit-1, last_digit, last_digit+1]
    elif last_digit == 0:
        return [last_digit, last_digit+1]
    elif last_digit == 9:
        return [last_digit-1, last_digit]

def solve(K: int):
    deq1 = deque()
    deq2 = deque()
    lunlun_list = []

    for i in range(1,10):
        deq1.append(i)
        lunlun_list.append(i)

    while  len(lunlun_list) <= 10 ** 5:
        num = deq1.popleft()
        digits = get_digits(num)
        for new_digit in digits:
            new_num = int(str(num)+str(new_digit))
            lunlun_list.append(new_num)
            deq2.append(new_num)

        if len(deq1) == 0:
            deq1 = copy(deq2)
            deq2 = deque()

    print(lunlun_list[K-1])


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    K = int(next(tokens))  # type: int
    solve(K)

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    # Failed to predict input format
    S = [c for c in input()]
    Q = int(input())
    direction = 1

    for _ in range(Q):
        query = input().split()
        t = int(query[0])

        if t == 1:
            direction = direction *  -1

        elif t == 2:
            f = int(query[1])
            c = query[2]
            if f == 1:
                # add to front
                if direction == 1:
                    S = [c] + S
                # add to back
                if direction == -1:
                    S = S + [c]
            elif f == 2:
                # add to back
                if direction == 1:
                    S = S + [c]
                # add to front
                if direction == -1:
                    S = [c] + S
    if direction == -1:
        S = S[::-1]

    print(''.join(S))
    pass

if __name__ == '__main__':
    main()

Fixed submission:
#!/usr/bin/env python3
from collections import deque

# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    # Failed to predict input format
    S = deque(input())
    Q = int(input())
    direction = 1

    for _ in range(Q):
        query = input().split()
        t = int(query[0])

        if t == 1:
            direction = direction *  -1

        elif t == 2:
            f = int(query[1])
            c = query[2]
            if f == 1:
                # add to front
                if direction == 1:
                   S.appendleft(c)
                # add to back
                if direction == -1:
                   S.append(c)
            elif f == 2:
                # add to back
                if direction == 1:
                   S.append(c)
                # add to front
                if direction == -1:
                   S.appendleft(c)
    S = list(S)
    if direction == -1:
        S = S[::-1]

    print(''.join(S))
    pass

if __name__ == '__main__':
    main()