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

Fixed submission:
import sys
sys.setrecursionlimit(10 ** 6)
n = int(input())
s = 'abcdefghijklmnopqrstuvwxyz'


def calc(x, i):
  target = x - 26 ** i
  if (target <= 0):
    return (x, i)
  else:
    return calc(target, i + 1)


target, index = calc(n, 1)
target -= 1
base26 = [0] * index
for i in range(index):
  tmp, target = divmod(target, 26 ** (index - i - 1))
  base26[i] = tmp
ans = ''
for i in base26:
  ans += s[i]
print(ans)

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10 ** 6)
n = int(input())
s = 'abcdefghijklmnopqrstuvwxyz'


def calc(x, i):
  target = x - 26 ** i
  if (target <= 0):
    return (x, i)
  else:
    return calc(target, i + 1)


target, index = calc(n, 1)
base26 = [0] * index
for i in range(index):
  tmp, target = divmod(target, 26 ** (index - i - 1))
  if (i == index - 1):
    base26[i] = tmp - 1
  else:
    base26[i] = tmp
ans = ''
for i in base26:
  ans += s[i]
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
s = 'abcdefghijklmnopqrstuvwxyz'


def calc(x, i):
  target = x - 26 ** i
  if (target < 0):
    return (x, i)
  else:
    return calc(target, i + 1)


def base10to(n, b):
  if(int(n/b)):
    return base10to(int(n/b), b) + str(n % b)
  return str(n % b)


target, index = calc(n, 1)
base26 = str(int(base10to(target, 26)) - 1)
ans = ''
head = index - len(base26)
for a in range(head):
  ans += 'a'
for c in base26:
    ans += s[int(c)]
print(ans)
Problem p02831 (python)

Fixed submission:
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a
    
A, B = map(int, input().split())
print(A * B // gcd(A, B))

Buggy submission (verdict: Runtime Error):
import math
A, B = map(int, input().split())
print(A * B // math.gcd(A, B))
Problem p02832 (python)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
i = 0
ans = 0
while i < N:
    if (A[i] == ans+1):
        ans += 1
    i += 1
if ans == 0:
    ans = N + 1
print(N - ans)

Buggy submission (verdict: Runtime Error):
A = list(map(int, input().split()))
i = 0
ans = 0
while i < N:
    if (A[i] == ans+1):
        ans += 1
    i += 1
if ans == 0:
    ans = N + 1
print(N - ans)
Problem p02873 (python)

Fixed submission:
S = input()
n = len(S)
S = S + " "
ans = 0
l = 0
r = 0
temp = 0

if S[0] == '<':
    temp = 0
else:
    for i in range(n):
        if S[i] == '>' and S[i + 1] == ('<'):
            temp = i+1
            break
        if i == n - 1:
            print((n + 1) * n // 2)
            exit()
ans += (temp) * (temp + 1) // 2
i = max(temp, 0)

while(i < n):
    while (i < n and S[i] == '<'):
        l += 1
        i += 1
    while (i < n and S[i] == '>'):
        r += 1
        i += 1
    l, r = min(l, r), max(l, r)
    ans += l * (l - 1) // 2 + r * (r + 1) // 2
    l = 0
    r = 0

l, r = min(l, r), max(l, r)
ans += l * (l - 1) // 2 + r * (r + 1) // 2
print(ans)

Buggy submission (verdict: Runtime Error):
S = input()
n = len(S)
S = S + " "
ans = 0
l = 0
r = 0
for i in range(n - 1):
    if S[i] == '>' and S[i + 1] == ('<'):
        temp = i
        break
if S[0] == '<':
    temp = -1
ans += (temp + 1) * (temp + 2) // 2
i = max(temp, 0)

while(i < n):
    while (i < n and S[i] == '<'):
        l += 1
        i += 1
    while (i < n and S[i] == '>'):
        r += 1
        i += 1
    l, r = min(l, r), max(l, r)
    ans += l * (l - 1) // 2 + r * (r + 1) // 2
    l = 0
    r = 0

l, r = min(l, r), max(l, r)
ans += l * (l - 1) // 2 + r * (r + 1) // 2
print(ans)

Buggy submission (verdict: Runtime Error):
S = input()
n = len(S)
ans = 0
l = 0
r = 0
for i in range(n - 1):
    if S[i] == '>' and S[i + 1] == ('<'):
        temp = i
        break
if S[0] == '<':
    temp = -1
ans += (temp+1) * (temp + 2) // 2
i = max(temp, 0)
while(i < n):
    while (i < n and S[i] == '<'):
        l += 1
        i += 1
    while (i < n and S[i] == '>'):
        r += 1
        i += 1
    l, r = min(l, r), max(l, r)
    ans += l * (l - 1) // 2 + r * (r + 1) // 2
    l = 0
    r = 0

print(ans)

Buggy submission (verdict: Runtime Error):
S = input()
n = len(S)
ans = 0
l = 0
r = 0
for i in range(n - 1):
    if S[i] == '>' and S[i + 1] == ('<'):
        temp = i
        break
if S[0] == '<':
    temp = 0
ans += temp * (temp + 1) // 2
i = temp

while(i < n):
    while (i < n and S[i] == '<'):
        l += 1
        i += 1
    while (i < n and S[i] == '>'):
        r += 1
        i += 1
    l, r = min(l, r), max(l, r)
    ans += l * (l - 1) // 2 + r * (r + 1) // 2
    l = 0
    r = 0

print(ans)
Problem p02912 (python)

Fixed submission:
N, M = map(int, input().split())  # 品物の数、割引券の枚数
A = list(map(int, input().split()))  # 品物の値段
A.sort(reverse=True)
i = 0
for _ in range(M):
    A[i] = A[i] // 2
    if i <= N - 2 and A[i] < A[i + 1] and A[0] < A[i+1]:
        i += 1
    else:
        A.sort(reverse=True)
        i = 0
print(str(sum(A)))

Buggy submission (verdict: Runtime Error):
import heapq
N, M = map(int, input())
A = list(map(lambda x: int(-x), input().split()))
heapq.heapify(A)
for i in range(M):
    tmp = heapq.heappop(A[0])
    heapq.heappush(tmp // 2)
print(str(sum(A)))

Buggy submission (verdict: Runtime Error):
import numpy as np
N, M = map(int, input().split())  # 品物の数、割引券の枚数
A = np.array(list(map(int, input().split())))  # 品物の値段
for _ in range(M):
    tmp = A.argmax()
    A[tmp] = A[tmp] // 2
print(str(sum(A)))

Buggy submission (verdict: Runtime Error):
import numpy as np
N, M = map(int, input().split())  # 品物の数、割引券の枚数
A = np.array(list(map(int, input().split())))  # 品物の値段
for _ in range(M):
    A[A.argmax()] = np.max(A) // 2
print(str(sum(A)))
Problem p02915 (python)

Fixed submission:
N = int(input())
print(str(N ** 3))

Buggy submission (verdict: Runtime Error):
print(str(int(input())^^3))
Problem p02990 (python)

Fixed submission:
def comb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod
mod = 10**9+7 #出力の制限
N = 10**4
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

n, k = map(int, input().split())
i = 1
for i in range(1, k+1):
  if n - k + 1 >= i:
    print((comb(n - k + 1, i, mod) * comb(k-1, i-1, mod) ) % mod)
  else:
    print(0)

Buggy submission (verdict: Runtime Error):
from scipy.special import comb
n, k = map(int, input().split())
d = 10 ** 9 + 7
i = 1
while n - k + 1 >= i and k >= i:
  print(((comb(n - k + 1, i, exact=True) % d) * (comb(k-1, i-1, exact=True) % d)) % d)
  i += 1
Problem p03835 (python)

Fixed submission:
#! /Library/Frameworks/Python.framework/Versions/3.7/bin/python3
K, S = map(int, input().split())
count = 0
for x in range(K+1):
    for y in range(K+1):
        z = S - x - y
        if z <= K and z >= 0:
            count += 1
print(str(count))

Buggy submission (verdict: Runtime Error):
#! /Library/Frameworks/Python.framework/Versions/3.7/bin/python3
from math import factorial
K, S = map(int, input().split())
S = S if K * 3 / 2 > S else K * 3 - S
count = int(factorial(S+2) / factorial(2) / factorial(S+2 - 2))
print(str(count))

Buggy submission (verdict: Runtime Error):
#! /Library/Frameworks/Python.framework/Versions/3.7/bin/python3
from scipy.special import comb
K, S = map(int, input().split())
S = S if K * 3 / 2 - S > 0 else K * 3 - S
count = comb(S + 2, 2, exact=True)
print(str(count))
Problem p02701 (python)

Fixed submission:
N = int(input())
a_list=[]
for i in range(N):
  a_list.append(input())
  
a_set = set(a_list)

a_num = len(a_set)

print(a_num)

Buggy submission (verdict: Runtime Error):
N = int(input())
a_list
for i in range(N):
  a_list.append(input())
  
a_ = set(a_list)

a_num = len(a_)

print(a_num)

Buggy submission (verdict: Runtime Error):
N = int(input())

a_list = []

for i in range(N):
  a_list.append(list(input()))
  
a_num = len(set(a_list))

print(a_num)
Problem p02725 (python)

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

  
A_m = []
 
for i in range(1,N):
  A_m.append(A[i]-A[i-1])
  
A_m.append(K-A[N-1]+A[0])
  
print(sum(A_m)-max(A_m))

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

A = []

for i in range(N):
  A.append(int(input()))
  
A_m = []

for i in range(1,N):
  A_m.append(A[i]-A[i-1])
  
A_m.append(K-A[N-1]+A[0])
  
print(sum(A_m)-max(A_m))

Buggy submission (verdict: Runtime Error):
K,N = map(int,input().split())
A = []
for i in range(N):
  A.append(int(input()))
A_m=[]

for i in range(1,N):
    A_m.append(int(A[i] - A[i-1]))
  

if abs(A[N-1]-A[0]) > 10:
  A_m.append(A[0]-A[N-1] +20)
else:
  A_m.append(A[N-1]-A[0])
  
X = sum(A_m) - max(A_m)

print(X)
Problem p02689 (python)

Fixed submission:
n, m = map(int, input().split())
h = list(map(int, input().split()))

ma = [0]*n
for _ in range(m):
    a, b = map(int, input().split())
    ma[a-1] = max(h[b-1], ma[a-1])
    ma[b-1] = max(h[a-1], ma[b-1])

ans = 0
for i in range(n):
    if h[i]>ma[i]:
        ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
h = list(map(int, input().split()))
num = [0]*n
chk = [0]*n
for _ in range(m):
    a, b = map(int, input().split())
    num[a-1] += 1
    num[b-1] += 1
    if h[a-1]>h[b-1]:
        chk[a-1] += 1
    elif h[b-1]>h[a-1]:
        chk[b-1] += 1
ans = 0
for i in range(m):
    if num[i]==chk[i]:
        ans += 1
print(ans)
Problem p02729 (python)

Fixed submission:
n, m = map(int, input().split())

a = (n * (n - 1)) // 2 + (m * (m - 1)) // 2

print(a)

Buggy submission (verdict: Runtime Error):
import collections

n = int(input())
a = list(map(int, input().split()))

c = collections.Counter(a)

ans = 0

for i in c.values():
    ans += i * (i - 1) // 2

for i in range(n):
    print(ans - c[a[i]] + 1)
Problem p02785 (python)

Fixed submission:
import math

n, k = [int(x) for x in input().split()]

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

if n <= k:
    print("0")
else:
    s_n = sorted(h_n)

    print(sum(s_n[:n-k]))

Buggy submission (verdict: Runtime Error):
import math

n, k = [int(x) for x in input().split()]

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

if n <= k:
    print("0")

s_n = sorted(h_n)

log_sum = math.log(sum(s_n[:n - k]))

print(round(math.exp(log_sum)))

Buggy submission (verdict: Runtime Error):
import math

n, k = [int(x) for x in input().split()]

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

if n <= k:
    print("0")

s_n = sorted(h_n)

log_sum = math.log(sum(s_n[:n - k]))

print(math.exp(log_sum))
Problem p02829 (python)

Fixed submission:
a = int(input())
b = int(input())

if (a != 3) and (b != 3):
    print("3")
elif (a != 2) and (b != 2):
    print("2")
else:
    print("1")

Buggy submission (verdict: Runtime Error):
a = int(input())
b = int(input())

if (a not 3) and (b not 3):
    print("3")
elif (a not 2) and (b not 2):
    print("2")
else:
    print("1")
Problem p02831 (python)

Fixed submission:
import fractions

a, b = map(int, input().split())

print((a * b) // fractions.gcd(a, b))

Buggy submission (verdict: Runtime Error):
import math

a, b = map(int, input().split())

print((a * b) // math.gcd(a, b))

Buggy submission (verdict: Runtime Error):
import math


def lcm(x, y):
    return (x * y) // math.gcd(x, y)


a, b = map(int, input().split())

print(lcm(a, b))

Buggy submission (verdict: Runtime Error):
import math


def lcm(x, y):
    return (x * y) // math.gcd(x, y)


a, b = map(int, input().split())

print(lcm(a, b))
Problem p02847 (python)

Fixed submission:
s = input()

if s == "SUN":
    print("7")
elif s == "MON":
    print("6")
elif s == "TUE":
    print("5")
elif s == "WED":
    print("4")
elif s == "THU":
    print("3")
elif s == "FRI":
    print("2")
elif s == "SAT":
    print("1")

Buggy submission (verdict: Runtime Error):
import math

a, b, x = map(int, input().split())

for i in range(int(x/a-1),10000000000000000000):
    if x < (a*i+b*int(math.log10(i)+1)):
        break

if i > 1:
    print(a*(i-1)+b*int(math.log10(i-1)+1))
elif i == 1:
    print(0)
Problem p02859 (python)

Fixed submission:
a = int(input())
print(a**2)

Buggy submission (verdict: Runtime Error):
n = int(input())
s = input()

if n % 2 == 1:
    print("No")
else:
    s_1 = s[:n/2]
    s_2 = s[n/2:n]
    if s_1 != s_2:
        print("No")
    else:
        print("Yes")

Buggy submission (verdict: Runtime Error):
n = int(input())
s = input()

if n % 2 == 1:
    print("No")
else:
    s_1 = s[:int(len(s)/2)]
    s_2 = s[int(len(s)/2):n]

    if s_1 != s_2:
        print("No")
    else:
        print("Yes")

Buggy submission (verdict: Runtime Error):
n = int(input())
s = input()

if n % 2 == 1:
    print("No")
else:
    s_1 = s[:int(n/2)]
    s_2 = s[int(n/2):n]

    if s_1 != s_2:
        print("No")
    else:
        print("Yes")
Problem p02860 (python)

Fixed submission:
n = int(input())
s = input()

if n % 2 == 1:
    print("No")
else:
    c = int(n/2)
    s_1 = s[:c]
    s_2 = s[c:n]

    if s_1 != s_2:
        print("No")
    else:
        print("Yes")

Buggy submission (verdict: Runtime Error):
n = int(input())
s = input()

if n % 2 == 1:
    print("No")
else:
    s_1 = s[:n/2]
    s_2 = s[n/2:n]
    if s_1 != s_2:
        print("No")
    else:
        print("Yes")

Buggy submission (verdict: Runtime Error):
n = int(input())
s = input()

if n % 2 == 1:
    print("No")
else:
    if s[:n/2] != s[n/2:n]:
        print("No")
    else:
        print("Yes")
Problem p02862 (python)

Fixed submission:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

MOD = 10**9 + 7


def combination(n: int, r: int, mod=MOD):
    n1 = n+1
    r = min(r, n-r)
    numer = denom = 1
    for i in range(1, r+1):
        numer = numer * (n1-i) % mod
        denom = denom * i % mod
    return numer * pow(denom, mod-2, mod) % mod


x, y = map(int, read().split())

if ((x + y) % 3 != 0):
    print("0")
else:
    a = (2*y - x) // 3
    b = (x - a) // 2

    if a < 0 or b < 0:
        print(0)
    else:
        print(combination(a+b, a))

Buggy submission (verdict: Runtime Error):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines


def c(n, k):
    from math import factorial

    ans = factorial(n) / factorial(k) / factorial(n - k)

    return ans % mod


mod = 10**9 + 7

x, y = map(int, read().split())

if y > x:
    temp = y
    y = x
    x = temp

if ((x + y) % 3 != 0) or x > y * 2:
    print("0")
else:
    n = ((x + y) // 3)
    k = ((n - abs(x - y)) // 2)
    ans = c(n, k)
    print(ans)

Buggy submission (verdict: Runtime Error):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

x, y = map(int, read().split())


def c(n, k):
    return 1 if(k <= 0 or n <= k) else c(n-1, k-1) + c(n-1, k)


if y > x:
    temp = y
    y = x
    x = temp

if ((x + y) % 3 != 0) or x > y * 2:
    print("0")
else:
    n = ((x + y) // 3)
    k = ((n - abs(x - y)) // 2)
    print(c(n, k))
Problem p02912 (python)

Fixed submission:
import heapq

n, m = map(int, input().split())
a = list(map(lambda x: int(x) * (-1), input().split()))

heapq.heapify(a)

for _ in range(m):
    tmp_min = heapq.heappop(a)
    heapq.heappush(a, (-1) * (-tmp_min // 2))

print(-sum(a))

Buggy submission (verdict: Runtime Error):
import math

n, m = [int(x) for x in input().split()]
a = list(map(int, input().split()))

a = sorted(a, reverse=True)

for i in range(m):
    a[0] = math.floor(a[0] / 2)
    if a[0] < a[1]:
        a = sorted(a, reverse=True)

print(sum(a))
Problem p03011 (python)

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

a_n = sorted(a_n)

print(a_n[0] + a_n[1])

Buggy submission (verdict: Runtime Error):
div = 1000000007

n, m = map(int, input().split())
a = [int(input()) for i in range(m)]

f = [0] * (n + 1)
f[0] = 1

if 1 not in a:
    f[1] = 1

for i in range(2, n + 1):
    if i in a:
        continue
    f[i] = (f[i - 1] + f[i - 2]) % div

print(f[-1])
Problem p03013 (python)

Fixed submission:
def main():
    N, M, *a = map(int, open(0).read().split())
    div = 1000000007
    broken = set(a)
 
    comb_list = [0] * (N + 1)
    comb_list[0] = 1
    if 1 not in broken:
        comb_list[1] = 1
 
    for i in range(2, N + 1):
        if i in broken:
            continue
        comb_list[i] = (comb_list[i - 1] + comb_list[i - 2]) % div
 
    print(comb_list[-1])
 
 
if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
a = [int(input()) for i in range(m)]

f = [0] * (n + 1)

f[0] = 1

if a[0] == 1:
    f[1] = 0
else:
    f[1] = 1

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

print(f[n] % 1000000007)

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
a = [int(input()) for i in range(m)]

f = [0] * (n + 1)

f[0] = 1

if a[0] == 1:
    f[1] = 0
else:
    f[1] = 1

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

print(f[n] % 1000000007)

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

a = [0] * m

for i in range(m):
    a[i] = int(input())

div = 10 ** 9 + 7
f = [0] * n

f[0] = 1
f[1] = 2

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

print(f[n - 1])
Problem p02682 (python)

Fixed submission:
a, b, c, k = [int(tmp) for tmp in input().split()]
if k <= a :
  print(k)
elif k <= a+b :
  print(a)
else :
  print(a-(k-a-b))

Buggy submission (verdict: Runtime Error):
a, b, c, d = [int(tmp) for tmp in input().split()]
if k <= a :
  print(k)
elif k <= a+b :
  print(a)
else :
  print(a-(k-a-b))
Problem p02571 (python)

Fixed submission:
S = input()
T = input()

def diff(a, b):
    return sum(aa != bb for aa, bb in zip(a, b))

answer = min( diff(S[i: i+len(T)], T) for i in range(len(S)-len(T)+1) )
print(answer)

Buggy submission (verdict: Runtime Error):
S = input()
T = input()

def diff(a, b):
    return sum(aa != bb for aa, bb in zip(a, b))

answer = min( diff(S[i: i+len(T)], T) for i in range(len(S)-len(T)) )
print(answer)
Problem p02622 (python)

Fixed submission:
S = input()
T = input()
print(sum(s != t for s, t in zip(S, T)))

Buggy submission (verdict: Runtime Error):
S = input()
T = input()
print(sum(s != t for s, t in zip(S, T))
Problem p03137 (python)

Fixed submission:
import sys
N,M = [int(x) for x in input().split()]
X = [int(x) for x in input().split()]
if N >= M:
    print(0)
    sys.exit()
X = sorted(X)
dis = [0 for x in range(M-1)]
for i in range(M-1):
    dis[i] = X[i+1] - X[i]
dis.sort()
dis.reverse()
for i in range(N-1):
    dis[i] = 0
print(sum(dis))

Buggy submission (verdict: Runtime Error):
N,M = [int(x) for x in input().split()]
X = [int(x) for x in input().split()]
X = sorted(X)
dis = [0 for x in range(M-1)]
for i in range(M-1):
    dis[i] = X[i+1] - X[i]
dis.sort()
dis.reverse()
for i in range(N-1):
    dis[i] = 0
print(sum(dis))
Problem p02571 (python)

Fixed submission:
S = input()
T = input()

result = float('inf')
for i in range(len(S) - len(T) + 1):
    t = 0
    for j in range(len(T)):
        if S[i + j] != T[j]:
            t += 1
    result = min(result, t)
print(result)

Buggy submission (verdict: Runtime Error):

input = sys.stdin.readline

S = input()
T = input()

result = float('inf')
for i in range(len(S) - len(T) + 1):
    t = 0
    for j in range(len(T)):
        if S[i + j] != T[j]:
            t += 1
    result = min(result, t)
print(result)
Problem p02547 (python)

Fixed submission:
def main():
	N = int(input())
	z = []
	for i in range(N):
		d1, d2 = [int(d) for d in input().split(" ")]
		if d1 == d2:
			z.append(1)
		else:
			z.append(0)
	zc = []
	now = 2
	c = 0
	for i in range(len(z)):
		if i == 0:
			now = z[i]
			c += 1
		elif now == z[i]:
			c += 1
		elif now == 1 and z[i] == 0:
			zc.append(c)
			c = 1
			now = z[i]
		elif now == 0 and z[i] == 1:
			c = 1
			now = z[i]
	else:
		if now == 1:
			zc.append(c)

	print("Yes") if len(zc) > 0 and max(zc) >= 3 else print("No")

main()

Buggy submission (verdict: Runtime Error):
def main():
	N = int(input())
	z = []
	for i in range(N):
		d1, d2 = [int(d) for d in input().split(" ")]
		if d1 == d2:
			z.append(1)
		else:
			z.append(0)
	zc = []
	now = 2
	c = 0
	for i in range(len(z)):
		if i == 0:
			now = z[i]
			c += 1
		elif now == z[i]:
			c += 1
		elif now == 1 and z[i] == 0:
			zc.append(c)
			c = 1
			now = z[i]
		elif now == 0 and z[i] == 1:
			c = 1
			now = z[i]
	else:
		if now == 1:
			zc.append(c)

	print("Yes") if max(zc) >= 3 else print("No")

main()
Problem p02550 (python)

Fixed submission:
def main():
	N, X, M = [int(a) for a in input().split(" ")]
	used_r = [0] * M
	r = [-1, X]
	used_r[X] = 1
	loop_start_elm = -1
	loop_start_n_2 = -1
	for i in range(M):
		A = r[-1]
		B = (A * A) % M
		if used_r[B] == 0:
			r.append(B)
			used_r[B] = 1
		else:
			loop_start_elm = B
			loop_start_n_2 = i + 2
			break
	loop_start_n = r.index(B)

	s1 = sum(r[:loop_start_n]) + 1
	s2 = sum(r[loop_start_n:loop_start_n_2])
	loop_len = loop_start_n_2 - loop_start_n
	loop_n = int((N - loop_start_n + 1) / loop_len)
	rest_n = (N - loop_start_n + 1) % loop_len
	s3 = sum(r[loop_start_n:(loop_start_n + rest_n)])
	print(s1 + s2 * loop_n + s3)

main()

Buggy submission (verdict: Runtime Error):
def main():
	N, X, M = [int(a) for a in input().split(" ")]
	used_r = [0] * (M - 1)
	r = [-1, X]
	used_r[X] = 1
	loop_start_elm = -1
	loop_start_n_2 = -1
	for i in range(M):
		A = r[-1]
		B = (A * A) % M
		if used_r[B] == 0:
			r.append(B)
			used_r[B] = 1
		else:
			loop_start_elm = B
			loop_start_n_2 = i + 2
			break
	loop_start_n = r.index(B)

	s1 = sum(r[:loop_start_n]) + 1
	s2 = sum(r[loop_start_n:loop_start_n_2])
	loop_len = loop_start_n_2 - loop_start_n
	loop_n = int((N - loop_start_n + 1) / loop_len)
	rest_n = (N - loop_start_n + 1) % loop_len
	s3 = sum(r[loop_start_n:(loop_start_n + rest_n)])
	print(s1 + s2 * loop_n + s3)

main()
Problem p02777 (python)

Fixed submission:
str = input().split(" ")
S = str[0]
T = str[1]
num = input().split(" ")
NS = int(num[0])
NT = int(num[1])
U = input()

if S == U:
  print(NS - 1, end=" ")
  print(NT)
else:
  print(NS, end=" ")
  print(NT - 1)

Buggy submission (verdict: Runtime Error):
str = input().split(" ")
S = str[0]
T = str[1]
num = input().split(" ")
NS = int(num[0])
NT = int(num[1])
U = input()

if S == U:
  print(str(NS - 1) + " " + str(NT))
else:
  print(str(NS) + " " + str(NT - 1))
Problem p02881 (python)

Fixed submission:
import math
def main():
  N = int(input())
  s = 0
  if N % 2 == 0:
    s = 2 + N // 2

  for i in range(3, math.ceil(math.sqrt(N)) + 3):
    if N % i == 0 and (not s or s > i + N // i):
      s = i + N // i

  if not s:
    s = N + 1

  print(s-2)
  
main()

Buggy submission (verdict: Runtime Error):
import math
N = int(input())
s = 0
if N % 2 == 0:
  s = 2 + N // 2

for i in range(3, int(math.sqrt(N), 2):
  if N % i == 0 and s > i + N // i:
    s = i + N // i

print(s-2)
Problem p02916 (python)

Fixed submission:
N = int(input())
A = list(map(lambda a: int(a), input().split(" ")))
B = list(map(lambda b: int(b), input().split(" ")))
C = list(map(lambda c: int(c), input().split(" ")))
 
satis = 0
 
for i in range(len(A)):
  satis += B[A[i] - 1]
  if i >= 1 and A[i] - A[i-1] == 1:
    satis += C[A[i - 1] - 1]
 
print(satis)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(lambda a: int(a), input().split(" ")))
B = list(map(lambda b: int(b), input().split(" ")))
C = list(map(lambda c: int(c), input().split(" ")))

satis = 0

for i in range(len(A)):
  satis += B[A[i]]
  if i >= 1 and A[i] - A[i-1] == 1:
    satis += C[i-1]

print(satis)
Problem p03011 (python)

Fixed submission:
ary = list(map(lambda n: int(n), input().split(" ")))
ary.sort()

print(ary[0] + ary[1])

Buggy submission (verdict: Runtime Error):
ary = list(map(lambda n: int(n), input().split(" "))).sort(reverse=True)

print(ary[0] + ary[1])