Harryxun/GPT-100-sft-dataset huggingface dataset:
Problem p03545 (python)

Fixed submission:
# input
L = [int(x) for x in list(input())]
ans = 0

if L[0] + L[1] + L[2] + L[3] == 7:
    print("%d+%d+%d+%d=7" % (L[0], L[1], L[2], L[3]))
else:
    if L[0] - L[1] + L[2] + L[3] == 7:
        print("%d-%d+%d+%d=7" % (L[0], L[1], L[2], L[3]))
    else:
        if L[0] + L[1] - L[2] + L[3] == 7:
            print("%d+%d-%d+%d=7" % (L[0], L[1], L[2], L[3]))
        else:
            if L[0] + L[1] + L[2] - L[3] == 7:
                print("%d+%d+%d-%d=7" % (L[0], L[1], L[2], L[3]))
            else:
                if L[0] - L[1] - L[2] + L[3] == 7:
                    print("%d-%d-%d+%d=7" % (L[0], L[1], L[2], L[3]))
                else:
                    if L[0] - L[1] + L[2] - L[3] == 7:
                        print("%d-%d+%d-%d=7" % (L[0], L[1], L[2], L[3]))
                    else:
                        if L[0] + L[1] - L[2] - L[3] == 7:
                            print("%d+%d-%d-%d=7" % (L[0], L[1], L[2], L[3]))
                        else:
                            if L[0] - L[1] - L[2] - L[3] == 7:
                                print("%d-%d-%d-%d=7" % (L[0], L[1], L[2], L[3]))

Buggy submission (verdict: Runtime Error):
# input
N = int(input())
L = [int(x) for x in list(str(N))]
ans = 0

if L[0] + L[1] + L[2] + L[3] == 7:
    print("%d+%d+%d+%d=7" % (L[0], L[1], L[2], L[3]))
else:
    if L[0] - L[1] + L[2] + L[3] == 7:
        print("%d-%d+%d+%d=7" % (L[0], L[1], L[2], L[3]))
    else:
        if L[0] + L[1] - L[2] + L[3] == 7:
            print("%d+%d-%d+%d=7" % (L[0], L[1], L[2], L[3]))
        else:
            if L[0] + L[1] + L[2] - L[3] == 7:
                print("%d+%d+%d-%d=7" % (L[0], L[1], L[2], L[3]))
            else:
                if L[0] - L[1] - L[2] + L[3] == 7:
                    print("%d-%d-%d+%d=7" % (L[0], L[1], L[2], L[3]))
                else:
                    if L[0] - L[1] + L[2] - L[3] == 7:
                        print("%d-%d+%d-%d=7" % (L[0], L[1], L[2], L[3]))
                    else:
                        if L[0] + L[1] - L[2] - L[3] == 7:
                            print("%d+%d-%d-%d=7" % (L[0], L[1], L[2], L[3]))
                        else:
                            if L[0] - L[1] - L[2] - L[3] == 7:
                                print("%d-%d-%d-%d=7" % (L[0], L[1], L[2], L[3]))
Problem p03598 (python)

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

ans = 0

for i in range(N):
    if X[i] >= K - X[i]:
        ans += 2 * (K - X[i])
    else:
        ans += 2 * X[i]

print(ans)

Buggy submission (verdict: Runtime Error):
# input
N_lst = [int(x) for x in list(input())]

if N_lst[0] == 9 or N_lst[1] == 9:
    print('Yes')
else:
    print('No')
Problem p03605 (python)

Fixed submission:
# input
N_lst = [int(x) for x in list(input())]

if N_lst[0] == 9 or N_lst[1] == 9:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
# input
N_lst = [int(x) for x in list(input()]

if N_lst[0] == 9 or N_lst[1] == 9:
    print('Yes')
else:
    print('No')
Problem p03606 (python)

Fixed submission:
# input
N = int(input())
L = [list(map(int, input().split())) for _ in range(N)]

ans = 0

for i in range(N):
    ans += L[i][1] - L[i][0] + 1

print(ans)

Buggy submission (verdict: Runtime Error):
# input
N = int(input())
L = [list(map(int, input().split()))]

ans = 0

for i in range(N):
    ans += L[i][1] - L[i][0] + 1

print(ans)
Problem p03610 (python)

Fixed submission:
import math

# input
s = input()

ans = ''

for i in range(math.ceil(len(s) / 2)):
    ans = ans + s[2 * i]

print(ans)

Buggy submission (verdict: Runtime Error):
import math

# input
s = input()

ans = ''

for i in range(math.ceil(len(s) // 2):
    ans = ans + s[2 * i]

print(ans)

Buggy submission (verdict: Runtime Error):
# input
s = input()

ans = ''

for i in range(len(s) // 2 + 1):
    ans = ans + s[2 * i]

print(ans)
Problem p03636 (python)

Fixed submission:
# input
s = input()

ans = s[0] + str(len(s) - 2) + s[len(s) - 1]

print(ans)

Buggy submission (verdict: Runtime Error):
# input
s = input()

ans = s[0] + str(len(s) - 2) + s[len(str) - 1]

print(ans)
Problem p03637 (python)

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

# 4の倍数, 4の倍数でない偶数, 奇数の数
i, j, k = 0, 0, 0

for n in range(N):
    if a[n] % 4 == 0:
        i += 1
    elif a[n] % 2 == 0:
        j += 1
    else:
        k += 1

if k >= i + 2:
    print('No')
elif k == i + 1 and j >= 1:
    print('No')
else:
    print('Yes')

Buggy submission (verdict: Runtime Error):
# input
N = int(input())
a = [int(input()) for _ in range(N)]

# 4の倍数, 奇数の数
i, j = 0, 0

for i in range(N):
    if a[i] % 4 == 0:
        i += 1
    elif a[i] % 2 == 1:
        j += 1

if j >= i + 2:
    print('No')
else:
    print('Yes')
Problem p03695 (python)

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

count = [0, 0, 0, 0, 0, 0, 0, 0, 0]

for i in range(N):
    if A[i] < 400:
        count[0] = 1
    elif A[i] < 800:
        count[1] = 1
    elif A[i] < 1200:
        count[2] = 1
    elif A[i] < 1600:
        count[3] = 1
    elif A[i] < 2000:
        count[4] = 1
    elif A[i] < 2400:
        count[5] = 1
    elif A[i] < 2800:
        count[6] = 1
    elif A[i] < 3200:
        count[7] = 1
    else:
        count[8] += 1

color_max = sum(count)
if count[8] == 0:
    color_min = sum(count)
else:
    color_min = sum(count[:7]) + 1

print(color_min, color_max)

Buggy submission (verdict: Runtime Error):
# input
N = int(input())
A = list(map(int, input().split()))

count = [0, 0, 0, 0, 0, 0, 0, 0, 0]

for i in range(N):
    if A[i] < 400:
        count[0] = 1
    elif A[i] < 800:
        count[1] = 1
    elif A[i] < 1200:
        count[2] = 1
    elif A[i] < 1600:
        count[3] = 1
    elif A[i] < 2000:
        count[4] = 1
    elif A[i] < 2400:
        count[5] = 1
    elif A[i] < 2800:
        count[6] = 1
    elif A[i] < 3200:
        count[7] = 1
    else:
        count[8] += 1

color_max = sum(count)
if count[8] == 0:
    count_min = sum(count)
else:
    count_min = sum(count[:7]) + 1

print(count_min, count_max)
Problem p03720 (python)

Fixed submission:
# input
N, M = map(int, input().split())
R = [list(map(int, input().split())) for _ in range(M)]

for i in range(1, N + 1):
    ans = 0
    for j in range(M):
        if i in R[j]:
            ans += 1
    print(ans)

Buggy submission (verdict: Runtime Error):
# input
N, M = map(int, input().split())
R = [list(map(int, input().split())) for _ in range(M)]

for i in range(N):
    ans = 0
    for j in range(1, M + 1):
        if i in R[j]:
            ans += 1
    print(ans)
Problem p03721 (python)

Fixed submission:
# input
N, K = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(N)]

A = sorted(A)

count = 0

for i in range(N):
    count += A[i][1]
    if count >= K:
        print(A[i][0])
        break

Buggy submission (verdict: Runtime Error):
# input
N, K = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(M)]

count = 0

for i in range(N):
    count += A[i][1]
    if count >= K:
        print(A[i][0])
        break
Problem p03739 (python)

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

# 偶数番目が＋
A_even = A[:]
S_even = 0
ans_even = 0
for i in range(n):
    if (S_even + A_even[i]) * ((-1) ** (i - 1)) > 0:
        S_even += A_even[i]
        continue
    A_even[i] = (-1) ** (i - 1) - S_even
    ans_even += abs(A[i] - A_even[i])
    S_even = (-1) ** (i - 1)

# 奇数番目が＋
A_odd = A[:]
S_odd = 0
ans_odd = 0
for i in range(n):
    if (S_odd + A_odd[i]) * ((-1) ** i) > 0:
        S_odd += A_odd[i]
        continue
    A_odd[i] = (-1) ** i - S_odd
    ans_odd += abs(A[i] - A_odd[i])
    S_odd = (-1) ** i

ans = int(min(ans_even, ans_odd))

print(ans)

Buggy submission (verdict: Runtime Error):
# input
n = int(input())
A = list(map(int, input().split()))

# 偶数番目が＋
A_even = A
S_even = 0
ans_even = 0
for i in range(n):
    if (S + A_even[i]) * ((-1) ** (i - 1)) > 0:
        continue
    ans_even += S + A_even[i] + 1
    A_even[i] = (-1) ** (i - 1) - S
    S = (-1) ** (i - 1)

# 奇数番目が＋
A_odd = A
S_odd = 0
ans_odd = 0
for i in range(n):
    if (S + A_odd[i]) * ((-1) ** i) > 0:
        continue
    ans_odd += S + A_odd[i] + 1
    A_odd[i] = (-1) ** i - S
    S = (-1) ** i

ans = min(ans_even, ans_odd)

print(ans)
Problem p03760 (python)

Fixed submission:
# input
O = input()
E = input()

password = [0 for _ in range(len(O) + len(E))]

for i in range(len(O)):
    password[2 * i] = O[i]

for i in range(len(E)):
    password[2 * i + 1] = E[i]

password_str = ''.join(password)
print(password_str)

Buggy submission (verdict: Runtime Error):
# input
O = input()
E = input()

password = [0 for _ in range(len(O) + len(E))]

for i in range(len(O)):
    password[2 * i] = O[i]

for i in range(len(E)):
    password[2 * i + 1] = E[i]

password_str = ''.join(str_list)
print(password_str)
Problem p03814 (python)

Fixed submission:
# input
s = input()

i = 0

while s[i] != 'A':
    i += 1

j = len(s) - 1

while s[j] != 'Z':
    j -= 1

ans = j - i + 1
print(ans)

Buggy submission (verdict: Runtime Error):
# input
s = input()

i = 0

while s[i] != 'a':
    i += 1

j = len(s) - 1

while s[j] != 'z':
    j -= 1

ans = j - i + 1
print(ans)
Problem p03828 (python)

Fixed submission:
import math

# input
N = int(input())

# エラトステネスの篩で素数を列挙（table[q] = 0: qは素数, table[i] = j: iはjを素因数に持つ）
def prime_factor_table(n):
    table = [0] * (n + 1)
    
    for i in range(2, n + 1):
        if table[i] == 0:
            for j in range(i + i, n + 1, i):
                table[j] = i
    
    return table

def prime_factor(n, prime_factor_table):
    prime_count = dict()

    while prime_factor_table[n] != 0:
        if prime_factor_table[n] in prime_count.keys():
            prime_count[prime_factor_table[n]] += 1
        else:
            prime_count[prime_factor_table[n]] = 1
        n = int(n/prime_factor_table[n])
    if n in prime_count.keys():
        prime_count[n] += 1
    else:
        prime_count[n] = 1
    return prime_count

Ps = dict()
P_1000 = prime_factor_table(1000)
ans = 1

for i in range(2, N + 1):
    P_i = prime_factor(i, P_1000)
    for k in P_i.keys():
        if k in Ps.keys():
            Ps[k] += P_i[k]
        else:
            Ps[k] = P_i[k]

for k in Ps.keys():
    ans = (ans * (Ps[k] + 1)) % (10 ** 9 + 7)

print(ans)

Buggy submission (verdict: Runtime Error):
import math

# input
N = int(input())

N_f = math.factorial(N)

ans = 0

for i in range(1, math.ceil(math.sqrt(N_f))):
    if N_f % i == 0:
        ans += 1
        if N_f != i ** 2:
            ans += 1

ans = ans % (10 ** 9 + 7)

print(ans)
Problem p03836 (python)

Fixed submission:
# input
sx, sy, tx, ty = map(int, input().split())

for i in range(ty - sy):
    print('U', end = "")

for i in range(tx - sx):
    print('R', end = "")

for i in range(ty - sy):
    print('D', end = "")

for i in range(tx - sx):
    print('L', end = "")

print('L', end = "")

for i in range(ty - sy + 1):
    print('U', end = "")

for i in range(tx - sx + 1):
    print('R', end = "")

print('D', end = "")

print('R', end = "")

for i in range(ty - sy + 1):
    print('D', end = "")

for i in range(tx - sx + 1):
    print('L', end = "")

print('U')

Buggy submission (verdict: Runtime Error):
# input
sx, sy, tx, ty = map(int, input().split())

for i in range(tx - sx):
    print('R')

for i in range(ty - sy):
    print('U')

for i in range(tx - sx):
    print('L')

for i in range(ty - sy):
    print('D')

print('L')

for i in range(ty - sy + 1):
    print('U')

for i in range(tx - sx + 1):
    print('R')

print('D')

print('R')

for i in range(ty - sy + 1):
    print('D')

for i in range('tx - sx + 1'):
    print('L')

print('U')
Problem p03845 (python)

Fixed submission:
# input
N = int(input())
T = list(map(int, input().split()))
M = int(input())
P = [list(map(int, input().split())) for _ in range(M)]

for i in range(M):
    temp = T[P[i][0] - 1]
    T[P[i][0] - 1] = P[i][1]
    print(sum(T))
    T[P[i][0] - 1] = temp

Buggy submission (verdict: Runtime Error):
# input
N = int(input())
T = list(map(int, input().split()))
M = int(input())
P = [list(map(int, input().split())) for _ in range(M)]

for i in range(M):
    T[P[i][0]] -= P[i][1]
    print(sum(T))
    T[P[i][0]] += P[i][1]
Problem p03964 (python)

Fixed submission:
import math

# input
N = int(input())
TA = [list(map(int, input().split())) for _ in range(N)]


T = 1 # 高橋くんの最小得票数
A = 1 # 青木くんの最小得票数
ans = 2

for i in range(0, N):
    #m = max(math.ceil(T / TA[i][0]), math.ceil(A / TA[i][1]))
    m = max(-(-T // TA[i][0]), -(-A // TA[i][1]))
    T = TA[i][0] * m
    A = TA[i][1] * m
    ans = T + A

print(ans)

Buggy submission (verdict: Runtime Error):
from functools import reduce
import math

# input
N = int(input())
TA = [list(map(int, input().split())) for _ in range(N)]

# 最小公倍数
def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)

ans = 1
for i in range(N):
    if TA[i][0] + TA[i][1] >= ans:
        ans = TA[i][0] + TA[i][1]
    else:
        ans = lcm_base(ans, TA[i][0] + TA[i][1])

print(ans)
Problem p03998 (python)

Fixed submission:
# input
S = [list(input()) for _ in range(3)]

P_curr = 0

while S[P_curr] != []:
    if S[P_curr][0] == 'a':
        del S[P_curr][0]
        P_curr = 0
    elif S[P_curr][0] == 'b':
        del S[P_curr][0]
        P_curr = 1
    elif S[P_curr][0] == 'c':
        del S[P_curr][0]
        P_curr = 2

if P_curr == 0:
    print('A')
if P_curr == 1:
    print('B')
if P_curr == 2:
    print('C')

Buggy submission (verdict: Runtime Error):
# input
S = [list(input()) for _ in range(3)]

P_curr = 0

while S[P_curr] != []
    if S[P_curr][0] == 'a':
        P_curr = 0
    if S[P_curr][0] == 'b':
        P_curr = 1
    if S[P_curr][0] == 'c':
        P_curr = 2
    del S[P_curr][0]

if P_curr == 0:
    print('A')
if P_curr == 1:
    print('B')
if P_curr == 2:
    print('C')
Problem p04013 (python)

Fixed submission:
import collections

# input
n, a = map(int, input().split())
X = [int(i) - a for i in input().split()]

sums = collections.Counter([0, X[0]])
# Xから1枚以上選んで作ることが可能な和:作り方の場合の数
# 1枚も選ばない＝0:1通り
# X[0]のみ選ぶ＝X[0]:1通り

for i in X[1:]: # 選べるカードを増やしていく (X[0] ~ X[i] から選ぶ)
    sums2 = collections.Counter()
    for s, c in sums.items():
        sums2[s + i] += c # X[0] ~ X[i - 1] で作れる和に X[i] を足す
    sums += sums2

print(sums[0] - 1) # 1枚も選ばないのはルール違反

Buggy submission (verdict: Runtime Error):
import collections

# input
n, a = map(int, input().split())
X = [int(i) - a for i in input().split()]

S = collections.Counter([0, X[0]])
# Xから1枚以上選んで作ることが可能な和:作り方の場合の数
# 1枚も選ばない＝0:1通り
# X[0]のみ選ぶ＝X[0]:1通り

for i in X[1:]: # 選べるカードを増やしていく (X[0] ~ X[i] から選ぶ)
    S_temp = collections.Counter()
    for s, c in S.items():
        S_temp[s + i] += c # X[0] ~ X[i - 1] で作れる和に X[i] を足す
    sums += sums2

print(S[0] - 1) # 1枚も選ばないのはルール違反
Problem p04043 (python)

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

ans1 = 0
ans2 = 0

for i in range(len(A)):
    if A[i] == 5:
        ans1 += 1
    if A[i] == 7:
        ans2 += 1

if ans1 == 2 and ans2 == 1:
    print('YES')
else:
    print('NO')

Buggy submission (verdict: Runtime Error):
# input
A = map(int, input().split())

ans1 = 0
ans2 = 0

for i in range(len(A)):
    if A[i] == 5:
        ans1 += 1
    if A[i] == 7:
        ans2 += 1

if ans1 == 2 and ans2 == 1:
    print('YES')
else:
    print('NO')

Buggy submission (verdict: Runtime Error):
# input
A = map(int, input().split())

ans1 = 0
ans2 = 0

for i in range(len(A)):
    if A[i] == 5:
        ans1 += 1
    if A[i] == 7:
        ans2 += 1

if ans1 == 2 and ans2 == 1:
    print('YES')
else:
    print("NO")
Problem p04044 (python)

Fixed submission:
# input
n, l = map(int, input().split())
S = sorted([input() for _ in range(n)])

ans = ''

for i in range(n):
    ans += S[i]

print(ans)

Buggy submission (verdict: Runtime Error):
# input
n, l = map(int, input().split())
S = sorted([input() for _ in range(N)])

ans = ''

for i in range(N):
    ans += S[i]

print(ans)
Problem p03146 (python)

Fixed submission:
def func(n):
    if n % 2 == 0:
        return n / 2
    else:
        return 3*n + 1

s = int(input())
data = set()
data.add(s)
for i in range(1000010):
    l = len(data)
    val = func(s)
    data.add(val)
    if l == len(data):
        print(i+2)
        break
    s = val

Buggy submission (verdict: Runtime Error):
def func(long n):
    if n % 2 == 0:
        return n / 2
    else:
        return 3*n + 1

s = int(input())

data = set()
data.add(s)
for i in range(1000010):
    l = len(data)
    val = func(s)
    data.add(val)
    if l == len(data):
        print(i+2)
        break
    s = val

Buggy submission (verdict: Runtime Error):
def func(long n):
    if n % 2 == 0:
        return n / 2
    else:
        return 3*n + 1

s = int(input())

data = set(s)

for i in range(1000010):
    l = len(data)
    val = func(s)
    data.add(val)
    if l == len(data):
        print(i+2)
        break
    s = val
Problem p03145 (python)

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


if __name__ == '__main__':
    # スペース区切りの整数の入力
    b, c, d = map(int, input().split())
    # b, c = map(int, input().split())
    print(int(b * c / 2.0))

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-


if __name__ == '__main__':
    # スペース区切りの整数の入力
    b, c = map(int, input().split())
    # b, c = map(int, input().split())
    print(b * c / 2.0)
Problem p03125 (python)

Fixed submission:
a = input()
b = a.split()
A = int(b[0])
B = int(b[1])
if B%A == 0:
    print(A+B)
else:
    print(B-A)

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

#initialization
nmatch = np.array([0,2,5,5,4,5,6,3,7,6])
N,M = map(int,input().split())
dp = [-1]*(N+1) # contains the number of digits it can make
dp[0] = 0
ff = np.array(list(map(int,input().split()))).reshape(-1,1)
fg = nmatch[ff].reshape(-1,1)
Atemp = np.concatenate([ff,fg],axis=1)
index0 = np.argsort(Atemp[:,0])
index1 = np.argsort(Atemp[:,1])
A = Atemp[index1] #sorted by the number of matches: ascending
B = Atemp[index0]
B = B[::-1] #sorted by the number: descending
for i in range(1,N+1):
    for k in range(M):
        j = A[k,1]
        i_old = i - j #available matches
        if (i-j) < 0:
            break
        if (i-j) == 0 and dp[i] == -1:
            dp[i] = 1
        if dp[i_old] != -1 and dp[i_old]+1 > dp[i]:
            dp[i] = dp[i_old] + 1
#print(dp)
ndigits = dp[N]
j = N
final_number = ''
for l in range(ndigits,0,-1):
    index = 0
    while True:
        temp_j = j - B[index,1]
        if temp_j < 0:
            index += 1
            continue
        if dp[temp_j] + 1 == dp[j]:
            final_number += str(B[index,0])
            j = temp_j
            break
        else:
            index += 1
        if index > M:
            break
print(int(final_number))
Problem p03206 (python)

Fixed submission:
a = int(input())
list = [22,23,24,25]
message = ['Christmas Eve Eve Eve','Christmas Eve Eve', 'Christmas Eve', 'Christmas']
index = list.index(a)
print(message[index])

Buggy submission (verdict: Runtime Error):
    a = int(input())
    list = [22,23,24,25]
    message = ['Christmas Eve Eve Eve','Christmas Eve Eve', 'Christmas Eve', 'Christmas']
    index = list.index(a)
    print(message[index])

Buggy submission (verdict: Runtime Error):
a = int(input())
list = [22,23,24,25]
message = ['Christmas Eve Eve Eve','Christmas Eve Eve', 'Christmas Eve', 'Christmas']
index = list.index(a)
print(message[a])
Problem p03231 (python)

Fixed submission:
#!/usr/bin/env python
# -*- coding: utf-8 -*-

# AGC028：A - Two Abbreviations
# import numpy as np
import fractions
def lcm(a,b): return abs(a * b) / fractions.gcd(a,b) if a and b else 0

def main():
    n, m = [int(i) for i in raw_input().strip().split(' ')]
    s = raw_input().strip()
    t = raw_input().strip()
    # l = np.lcm(n, m) # 45
    l = lcm(n, m) # 45
    n1 = l/n # 45/15 = 3
    m1 = l/m # 45/9 = 5
    # l1 = np.lcm(n1, m1) # lcm(3, 5) = 15
    l1 = lcm(n1, m1) # lcm(3, 5) = 15

    # d  n  s  u  s  r  a  y  u  k  u  a  i  i  a  
    # d    u    j    r    u    n    u    m    a    
    for i in range(l/l1):
        if s[i*m1] != t[i*n1]:
            print '-1'
            return
    print str(l)


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python
# -*- coding: utf-8 -*-

# AGC028：A - Two Abbreviations
import numpy as np


def main():
    n, m = [int(i) for i in raw_input().strip().split(' ')]
    s = raw_input().strip()
    t = raw_input().strip()
    l = np.lcm(n, m) # 45
    n1 = l/n # 45/15 = 3
    m1 = l/m # 45/9 = 5
    l1 = np.lcm(n1, m1) # lcm(3, 5) = 15

    # d  n  s  u  s  r  a  y  u  k  u  a  i  i  a  
    # d    u    j    r    u    n    u    m    a    
    for i in range(l/l1):
        if s[i*m1] != t[i*n1]:
            print '-1'
            return
    print str(l)


if __name__ == '__main__':
    main()
Problem p03244 (python)

Fixed submission:
def sura_backsura():
    import collections

    N = int(input())
    a = [int(i) for i in input().split()]

    fp = collections.Counter(a[0::2]).most_common()
    sp = collections.Counter(a[1::2]).most_common()

    fp.append((0, 0))
    sp.append((0, 0))

    if fp[0] != sp[0]:
        count = N - fp[0][1] - sp[0][1]
    else:
        count = min(N - fp[0][1] - sp[1][1], N - fp[1][1] - sp[0][1])

    print(count)
    
if __name__ == "__main__":
    sura_backsura()

Buggy submission (verdict: Runtime Error):
def sura_backsura():
    import collections

    N = int(input())
    a = [int(i) for i in input().split()]

    fp = collections.Counter(a[0::2]).most_common()
    sp = collections.Counter(a[1::2]).most_common()

    if fp[0] != sp[0]:
        count = N - fp[0][1] - sp[0][1]
    else:
        count = min(N - fp[0][1] - sp[1][1], N - fp[1][1] - sp[0][1])

    print(count)
    
if __name__ == "__main__":
    sura_backsura()
Problem p03146 (python)

Fixed submission:
n = int(input())
x = set()
cnt = 1
x.add(n)

while True:
    
    cnt += 1
    
    if n%2 == 0:
        n /=2
        
    else:
        n = n * 3 + 1

    if n in x:
        print(cnt)
        break
    else:
        x.add(n)

Buggy submission (verdict: Runtime Error):
n = int(input())
x = set(n)
cnt = 1

while True:
    
    cnt += 1
    
    if n%2 == 0:
        n //=2
        
    else:
        n = n * 3 + 1

    if n in x:
        print(cnt)
        break
    else:
        x.add(n)

Buggy submission (verdict: Runtime Error):
n = int(input())
x = set(n)
cnt = 1

while True:
    
    cnt += 1
    
    if n%2 == 0:
        n //=2
        
    else:
        n = n * 3 + 1

    if n in x:
        print(cnt)
        exit()
    else:
        x.add(n)
Problem p03166 (python)

Fixed submission:
import sys
sys.setrecursionlimit(10**5)

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

v = [-1] * (n + 1)
x = [[] for _ in range(n + 1)]

for _ in range(m):
    a,b = map(int,input().split())
    x[a].append(b)

def dfs(i):
    if v[i] != -1:
        return v[i]

    rt = 0
    for node in x[i]:
        tmp = dfs(node) + 1
        if rt < tmp:
            rt = tmp

    #メモ化再帰
    v[i] = rt
    return rt

ans = 0

for k in range(1,n+1):
    tmp2 = dfs(k)

    if tmp2 > ans:
        ans = tmp2

print(ans)

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())

v = [-1] * (n + 1)
x = [[] for _ in range(n + 1)]

for _ in range(m):
    a,b = map(int,input().split())
    x[a].append(b)

def dfs(i):
    if v[i] != -1:
        return v[i]

    rt = 0
    for node in x[i]:
        tmp = dfs(node) + 1
        if rt < tmp:
            rt = tmp

    #メモ化再帰
    v[i] = rt
    return rt

ans = 0

for k in range(1,n+1):
    tmp2 = dfs(k)

    if tmp2 > ans:
        ans = tmp2

print(ans)