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

Fixed submission:
n,k = [int(x) for x in input().split()]
res = 0
while n > 0:
  n //= k
  res += 1
print(res)

Buggy submission (verdict: Runtime Error):
n,k = [int(x) for x in input().split()]
res = 0
while n > 0:
  n // k
  c += 1
print(res)
Problem p02819 (python)

Fixed submission:
n = int(input())
 
def p(x):
  if x == 2:
    return True
  for i in range(2,x//2):
    if x % i == 0:
      return False
  return True
 
for i in range(n,2*n):
  if p(i):
    print(i)
    break

Buggy submission (verdict: Runtime Error):
n = int(input())
 
def p(x):
  if x == 2:
    return True
  for i in range(x//2):
    if x % i == 0:
      return False
  return True
 
for i in range(n,2*n):
  if p(i):
    print(i)
    break

Buggy submission (verdict: Runtime Error):
n = int(input())
 
def p(x):
  if x == 2:
    return True
  for i in range(x/2):
    if x % i == 0:
      return False
  return True
 
for i in range(n,2*n):
  if p(i):
    print(i)
    break

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

def p(x):
  if x == 2:
    return True
  for i in range(x/2):
    if x % i == 0:
      return False
  return True

for i in range(x,2*x):
  if p(i):
    print(i)
    break
Problem p02847 (python)

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

Buggy submission (verdict: Runtime Error):
s = input()
res = 0
if s == "SUN":
  res = 7
elif s == "MON":
  res = 6
elif s == "TUE":
  res = 5
elif s == "WED":
  res = 4
leif s == "THU":
  res = 3
elif s == "FRI":
  res = 2
elif s == "SAT":
  res = 1
print(res)
Problem p02859 (python)

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

Buggy submission (verdict: Runtime Error):
n = int(input())
print(r**2)
Problem p03041 (python)

Fixed submission:
n,k = [int(x) for x in input().split()]
s = input()
 
k -= 1
s = list(s)

if s[k] == "A":
  s[k] = "a"
elif s[k] == "B":
  s[k] = "b"
elif s[k] == "C":
  s[k] = "c"
 
print("".join(s))

Buggy submission (verdict: Runtime Error):
n,k = [int(x) for x in input().split()]
s = input()

k -= 1

if s[k] == "A":
  s[k] = "a"
elif s[k] == "B":
  s[k] = "b"
elif s[k] == "C":
  s[k] = "c"

print(s)
Problem p02676 (python)

Fixed submission:
def resolve():
    K= int(input())
    S = input()

    if len(S) <= K:
        print(S)
    else:
        print(S[:K]+"...")



if __name__ == "__main__":
    resolve()

Buggy submission (verdict: Runtime Error):
import math
def heikatu(A,B):
    if A % abs(B) ==0:
        return (A//abs(B),B//abs(B))
    if abs(B) % A == 0:
        return (1,B//A)
    
    c = 2
    while c <=math.sqrt(max(A,abs(B))):
        while A % c ==0 and B% c ==0:
            A //=c
            B//=c
        c+=1

    return (A,B)


def pow_r(x, n,mod=10**9+7):
    """
    O(log n)
    """
    if n == 0:  # exit case
        return 1
    if n % 2 == 0:  # standard case ① n is even
        return pow_r((x ** 2)%1000000007 , n // 2) % mod
    else:  # standard case ② n is odd
        return (x * pow_r((x ** 2)%1000000007, (n - 1) // 2) % mod) % mod



def resolve():
    N = int(input())

    kp = dict()
    km = dict()
    zero = [0,0]
    zerozero = 0
    for i in range(N):
        A,B = map(int,input().split())
        if A <0:
            A *= -1
            B *= -1
        if A == 0 and B == 0:
            zerozero+=1
            continue

        if A == 0:
            zero[0]+=1
            continue
        if B == 0:
            zero[1]+=1
            continue

        xx = heikatu(A,B)



        if B < 0:
            if not xx in km:
                km[xx]=0
            km[xx]+=1
        else:
            if not xx in kp:
                kp[xx]=0
            kp[xx]+=1

    tx = []
    if zero != [0,0]:
        tx.append(zero)

    for key in kp:
        A,B = key
        cou = kp[key]    
        if (B,-A) in km:
            tx.append([cou,km[(B,-A)]])
            km.pop((B,-A))
        else:
            tx.append([cou,0])
    for key in km:
        tx.append([0,km[key]])

    ans = 1
    mod = 1000000007
    for a,b in tx:
        xxx = 0
        if a != 0:
            xxx=(xxx+pow_r(2,a)) %mod
        if b != 0:
            xxx=(xxx+pow_r(2,a)) %mod
        if a !=0 and b!=0:
            xxx-=1
        ans = (ans*xxx) % mod

    ans = (ans+mod-1+zerozero) % mod 

    print(ans)       


        







resolve()
Problem p02570 (python)

Fixed submission:
x, y, z = [int(a) for a in input().split()]
if y*z>=x:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
x, y, z = int(input().split())
if y*z>=x:
  print("Yes")
else:
  print("No")
Problem p02624 (python)

Fixed submission:
N = int(input())
sum = 0
for i in range(1,N+1):
  sum+=i*(1+N//i)*(N//i)/2
print(int(sum))

Buggy submission (verdict: Runtime Error):
N = input()
N = int(N)
sum = 0
for i in range(N):
  sum+= (i+1)*(1+N//(i+1))(N//(i+1))/2
print(sum)

Buggy submission (verdict: Runtime Error):
N = input()
N = int(N)
sum = 0
for i in range(N):
  sum+= (i+1)*(1+N//(i+1))(N//2)/2
print(sum)

Buggy submission (verdict: Runtime Error):
N = int(input())
sum = 0
for i in range(N):
  sum+= i*(1+N//i)(N//2)/2
print(sum)

Buggy submission (verdict: Runtime Error):
N = input()
sum = 0
for i in range(N):
  sum+= i*(1+N//i)(N//2)/2
print(sum)
Problem p02699 (python)

Fixed submission:
import sys

sys.setrecursionlimit(10 ** 7)
rl = sys.stdin.readline


def solve():
    s, w = map(int, rl().split())
    if s > w:
        print('safe')
    else:
      print('unsafe')
    

if __name__ == '__main__':
    solve()

Buggy submission (verdict: Runtime Error):
import sys

sys.setrecursionlimit(10 ** 7)
rl = sys.stdin.readline


def solve():
    s, w = map(int, rl().split())
    if ans = s > w :
        print('safe')
　　else:
　　    print('unsafe')
    

if __name__ == '__main__':
    solve()
Problem p02831 (python)

Fixed submission:
from fractions import gcd

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

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

Buggy submission (verdict: Runtime Error):
from fractions import math

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

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

Buggy submission (verdict: Runtime Error):
import math

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

print(a * b // math.gcd(a, b))
Problem p02880 (python)

Fixed submission:
n = int(input())
for i in range(1, 10):
    if n % i == 0 and n // i < 10:
        print('Yes')
        exit()
print('No')

Buggy submission (verdict: Runtime Error):
a, b = list(map(int, input().split()))
if a >= 10 or b >= 10:
    print('-1')
else:
    print(a*b)
Problem p02571 (python)

Fixed submission:
s = input()
t = input()

ans = []
for i in range(len(s)-len(t)+1):
	count = 0
	for j in range(len(t)):
		if s[i+j] != t[j]:
			count += 1
	ans.append(count) 

print(min(ans))

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

ans = []
for i in range(len(s)-len(t)):
	count = 0
	for j in range(len(t)):
		if s[i+j] != t[j]:
			count += 1
	ans.append(count) 

print(min(ans))

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

ans = []
for i in range(len(s)-len(t)):
	count = 0
	for j in range(len(t)):
		if s[i+j] != t[j]:
			count += 1
	ans.append(count) 

print(min(ans))
Problem p02707 (python)

Fixed submission:
import numpy as np

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

worker = list(np.zeros(n, dtype=int))

for i in range(n-1):
    worker[A[i]-1] += 1

for i in range(n):
    print(worker[i])

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

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

worker = list(np.zeros(n, dtype=int))

for i in range(n-1):
    worker[A[i]-1] += 1

for i in range(n):
    print(worker[i])
Problem p02552 (python)

Fixed submission:
x = int(input())
print(1) if x == 0 else print(0)

Buggy submission (verdict: Runtime Error):
x = int(input())
print(int(not(x))

Buggy submission (verdict: Runtime Error):
print(int(not(input()))

Buggy submission (verdict: Runtime Error):
print(1) if x == 1 else print(0)
Problem p02831 (python)

Fixed submission:
import fractions
A,B = map(int,input().split())
gcd = fractions.gcd(A,B)
ans = (A*B)//gcd
print(ans)

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

Fixed submission:
X, Y = map(int,input().split())
def combination(n,r,mod=10**9+7):
    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

#y=2x以下かつy=(1/2)x以上の位置にいなくてはいけない
if (X+Y) % 3 != 0 or not (X<=2*Y and Y <=2*X):
    ans = 0
else:
    N = (X+Y)//3
    r = Y - N
    ans = combination(N,r)
print(ans)

Buggy submission (verdict: Runtime Error):
X, Y = map(int,input().split())
def combination(n,r,mod=10**9+7):
    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

#y=2x以下かつy=(1/2)x以上の位置にいなくてはいけない
if (X+Y) % 3 != 0 or not (X<=2*y and Y <=2*X):
    ans = 0
else:
    N = (X+Y)//3
    r = Y - N
    ans = combination(N,r)
print(ans)
Problem p02881 (python)

Fixed submission:
N = int(input())
#掛け算表は対称行列
#対角成分に移動するときが最短移動
def make_divisors(n):
    divisors = []
    for i in range(1,int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    divisors.sort(reverse=True)
    return divisors
div = make_divisors(N)
l = len(div) // 2
a = div[l]
b = N // a
ans = (a - 1) + (b - 1)
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
#掛け算表は対称行列
#対角成分に移動するときが最短移動
def make_divisors(n):
    divisors = []
    for i in range(1,int(n**0.5)+1):
        for n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    divisors.sort(reverse=True)
    return divisors
div = make_divisors(N)
a = div[0]
b = N // a
ans = (a - 1) + (b - 1)
print(ans)
Problem p02912 (python)

Fixed submission:
import heapq
import math
I = list(map(int,input().split()))
N = I[0]
M = I[1]
A = list(map(lambda x:-x,map(int,input().split())))
heapq.heapify(A)
for i in range(M):
    num = heapq.heappop(A)
    num = math.ceil(num / 2)
    heapq.heappush(A,num)

print(-sum(A))

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

print(-sum(A))

Buggy submission (verdict: Runtime Error):
I = list(map(int,input().split()))
N = I[0]
M = I[1]
A = list(map(int,input().split()))

for i in range(M):
    num = index(max(A))
    A[num] = A[num] / 2

B = map(int,A)
ans = sum(B)
print(ans)

Buggy submission (verdict: Runtime Error):
I = list(map(int,input().split()))
N = I[0]
M = I[1]
A = list(map(int,input().split()))

for i in range(M):
    num = index(max(A))
    A[num] = A[num] / 2

A = map(int,A)
ans = sum(A)
print(ans)
Problem p02951 (python)

Fixed submission:
ABC = list(map(int,input().split()))
A = ABC[0]
B = ABC[1]
C = ABC[2]
if (A>(B+C)):
    print(0)
else:
    D = A-B
    a = C - D
    print(a)

Buggy submission (verdict: Runtime Error):
N = int(input())
H = list(map(int,input.split()))
ANS = True
for i in range(1,N):
    if H[N-i] >= H[N-i-1]:
        continue
    else if (H[N-i] - H[N-i-1]) == -1:
        H[N-i-1] += 1
    else:
        ANS = False
        break
if ANS:
    print('Yes')
else:
    print('No')
Problem p02954 (python)

Fixed submission:
S = input()
N = len(S)
 
ans = [0] * N
 
index = 0
lcount = 0
rcount = 0
for i in range(N):
    if S[i] == 'R' and S[i + 1] == 'R':
        rcount += 1
    if S[i] == 'L' and S[i - 1] == 'L':
        lcount += 1
    if S[i] == 'R' and S[i + 1] == 'L':
        if lcount != 0:
            ans[index] += lcount // 2 + lcount % 2
            ans[index + 1] += lcount // 2
            lcount = 0
        index = i
        ans[i] = 1
        ans[i + 1] = 1
        if rcount != 0:
            ans[i] += rcount // 2
            ans[i + 1] += rcount // 2 + rcount % 2
            rcount = 0
        i += 1
if lcount != 0:
    ans[index] += lcount // 2 + lcount % 2
    ans[index + 1] += lcount // 2
    lcount = 0
    
for i in range(N):
    print(ans[i], end=" ")

Buggy submission (verdict: Runtime Error):
S = input()
N = len(S)
ans = [0] * N
index = 0
rcount = 0
lcount = 0
for i in range(N):
    if S[i] == 'R' and S[i+1] == 'R':
        rcount += 1
    if S[i] == 'L' and S[i+1] == 'L':
        lcount += 1
    if S[i] == 'R' and S[i+1] == 'L':
        if lcount != 0:
            ans[index] += lcount // 2 + lcount % 2
            ans[index + 1] += lcount // 2
            lcount = 0
        index = i
        ans[i] = 1
        ans[i+1] = 1
        if rcount != 0:
            ans[i] += rcount // 2
            ans[i+1] += rcount // 2 + rcount % 2
            rcount = 0
        i += 1
if lcount != 0:
    ans[index] += lcount // 2 + lcount % 2
    ans[index + 1] += lcount // 2
    lcount = 0

for i in range(N):
    print(ans[i])

Buggy submission (verdict: Runtime Error):
S = input()
N = len(S)
ans = [0] * N
index = 0
rcount = 0
lcount = 0
for i in range(N):
    if S[i] == 'R' and S[i+1] == 'R':
        rcount += 1
    if S[i] == 'L' and S[i+1] == 'L':
        lcount += 1
    if S[i] == 'R' and S[i+1] == 'L':
        if lcount != 0:
            ans[index] += lcount // 2 + lcount % 2
            ans[index + 1] += lcount // 2
            lcount = 0
        index = i
        ans[i] = 1
        ans[i+1] = 1
        if rcount != 0:
            ans[i] += rcount // 2
            ans[i+1] += rcount // 2 + rcount % 2
            rcount = 0
        i += 1
if lcount != 0:
    ans[index] += lcount // 2 + lcount % 2
    ans[index + 1] += lcount // 2
    lcount = 0

for i in range(N):
    print(ans[i],end= ' ')
Problem p03041 (python)

Fixed submission:
N, K = map(int,input().split())
S = input()
S1 = []
for i in range(N):
    if i == K-1:
        S1.append(S[i].lower())
    else:
        S1.append(S[i])
print(''.join(S1))

Buggy submission (verdict: Runtime Error):
N, K = map(int,input().split())
S = input()
if S[K-1] == 'A':
    S[K-1] = 'a'
elif S[K-1] == 'B':
    S[K-1] = 'b'
else:
    S[K-1] = 'c'
print(S)
Problem p03104 (python)

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

def oddsolve(a):
    return ((a+1)/2)%2
def solve(a):
    if (a%2==1):
        return oddsolve(a)
    else:
        return int(oddsolve(a+1)) ^ (a+1)
#print(type(oddsolve(A)))
#print(oddsolve(A))
print(int(solve(B)) ^ int(solve(A-1)))

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

def oddsolve(a):
    return ((a+1)/2)%2
def solve(a):
    if (a%2==1):
        return oddsolve(a)
    else:
        return int(oddsolve(a+1)) ^ (a+1)
#print(type(oddsolve(A)))
#print(oddsolve(A))
print(solve(B) ^ solve(A-1))
Problem p03127 (python)

Fixed submission:
def solve(m_list):
    m_val = m_list[0]
    for i in m_list:
        m_val = min(m_val,gcd(m_val,i))
    return m_val

def gcd(a,b):
    while b:
        a,b = b,a%b
    return a

def main():
    n = int(input())
    m_list = list(map(int,input().split()))

    ans = solve(m_list)
    print(ans)

main()

Buggy submission (verdict: Runtime Error):
def solve(m_list):
    m_val = m_list[0]
    for i in m_list:
        m_val = min(m_val,gcd(m_val,m))
    return m_val

def gcd(a,b):
    while b:
        a,b = b,a%b
    return a

def main():
    n = int(input())
    m_list = list(map(int,input().split()))

    ans = solve(m_list)
    print(ans)

main()

Buggy submission (verdict: Runtime Error):
def solve(m_list):
    m_val = m_list[0]
    for i in m_list:
        m_val = min(m_val,gcd(min_val,m))
    return m_val

def gcd(a,b):
    while b:
        a,b = b,a%b
    return a

def main():
    n = int(input())
    m_list = list(map(int,input().split()))

    ans = solve(m_list)
    print(ans)

main()

Buggy submission (verdict: Runtime Error):
def solve(m_list):
    m_val = m_list[0]
    for i in m_list:
        m_val = min(m_val,gcd(min_val,m))
    return min_val

def gcd(a,b):
    while b:
        a,b = b,a%b
    return a

def main():
    n = int(input())
    m_list = list(map(int,input().split()))

    ans = solve(m_list)
    print(ans)

main()

Buggy submission (verdict: Runtime Error):
def solve(m_list):
    m_val = m_list[0]
    for i in m_list:
        m_val = min(m_val,gcd(min_val,m))
    return min_val

def gcd(a,b):
    while b:
        a,b = b,a%b
    return a

def main():
    n = int(input())
    m_list = list(map(int,input().split()))

    ans = solve(m_list)
    print(ans)

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

Fixed submission:
N, K = map(int,input().split())
h = []
for i in range(N):
    x = int(input())
    h.append(x)

h.sort()
m = []
for i in range(N-K+1):
    m.append(h[i+K-1] - h[i])

print(min(m))

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

h.sort()
m = []
for i in range(N):
    m.append(h[i+K-1] - h[i])

print(min(m))
Problem p03329 (python)

Fixed submission:
N=int(input())
dp=[10**9 for i in range(N+1)]
dp[0]=0
for i in range(N+1):
    p=1
    while(p<=i):
        dp[i]=min(dp[i],dp[i-p]+1)
        p*=6
    p=1
    while(p<=i):
        dp[i]=min(dp[i],dp[i-p]+1)
        p*=9

print(dp[-1])

Buggy submission (verdict: Runtime Error):
N=int(input())
dp=[10**9 for i in range(N)]
dp[0]=0
for i in range(N+1):
    p=1
    while(1<=i):
        dp[i]=min(dp[i],dp[i-p]+1)
        p*=6
    p=1
    while(1<=i):
        dp[i]=min(dp[i],dp[i-p]+1)
        p*=9

print(dp[-1])
Problem p02623 (python)

Fixed submission:
n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
cum_a = []
total = 0
for i in range(n):
  total += a[i]
  if total > k:
    break
  cum_a.append(total)
  
cum_b = []
total = 0
for j in range(m):
  total += b[j]
  if total > k:
    break
  cum_b.append(total)
lim_a = len(cum_a)
lim_b = len(cum_b)
idx = 0
ans = lim_a
for l in range(1, lim_a + 1):
  while idx < lim_b:
    if k >= cum_a[-l] + cum_b[idx]:
      ans = max(ans, lim_a - l + idx + 2)
    else:
      break
    idx += 1
ans = max(ans, lim_b)
print(ans)

Buggy submission (verdict: Runtime Error):
n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
cum_a = []
total = 0
for i in range(n):
  total += a[i]
  if total > k:
    break
  cum_a.append(total)
  
cum_b = []
total = 0
for j in range(m):
  total += b[j]
  if total > k:
    break
  cum_b.append(total)
lim_a = len(cum_a)
lim_b = len(cum_b)
idx = 0
ans = lim_a
for l in range(1, lim_a + 1):
  for idx in range(lim_b):
    if k >= cum_a[-l] + cum[idx]:
      ans = max(ans, lim_a - l + idx + 2)
print(ans)

Buggy submission (verdict: Runtime Error):
n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
cum_a = []
total = 0
for i in range(n):
  total += a[i]
  if total > k:
    break
  cum_a.append(total)
  
cum_b = []
total = 0
for j in range(m):
  total += b[j]
  if total > k:
    break
  cum_b.append(total)
lim_a = len(cum_a)
lim_b = len(cum_b)
idx = 0
ans = lim_a
for l in range(1, lim_a + 1):
  while True:
    if k >= cum_a[-l] + cum_b[idx]:
      ans = lim_a - l + idx + 2
    else:
      idx += 1
    idx += 1
print(ans)
Problem p02659 (python)

Fixed submission:
a, b = input().split()
a = int(a)
b_list = [int(b[0]), int(b[2]), int(b[3])]
ans = 0
for i in range(3):
  ans += a * b_list[i] * 10**(2-i)
ans = ans // 100
print(ans)

Buggy submission (verdict: Runtime Error):
a, b = input().split()
a = int(a)
b = float(b)
c = int(100*b)
c = str(c)
ans = 0
for i in range(3):
  ans += a * int(c[i]) * 10**(2-i)
ans = ans // 100
print(ans)
Problem p02688 (python)

Fixed submission:
n, k = map(int, input().split())
total = []
for _ in range(k):
  d = int(input())
  A = list(map(int, input().split()))
  for a in A:
    total.append(a)
ans = n - len(set(total))
print(ans)

Buggy submission (verdict: Runtime Error):
n, k = map(int, input())
total = []
for _ in range(k):
  d = int(input())
  A = list(map(int, input().split()))
  for a in A:
    total.append(a)
ans = n - len(set(total))
print(ans)

Buggy submission (verdict: Runtime Error):
n, k = map(int, input())
total = set()
for _ in range(k):
  d = int(input())
  a = set(map(int, input().split()))
  for b in a:
    total.add(b)
ans = n - len(total)
print(ans)

Buggy submission (verdict: Runtime Error):
n, k = map(int, input())
total = set()
for _ in range(k):
  d = int(input())
  a = set(map(int, input().split()))
  total = total | a
ans = n - len(total)
print(ans)
Problem p02725 (python)

Fixed submission:
K, N = map(int, input().split())
A = list(map(int, input().split()))
A.append(A[0]+K)
max_d = A[1] - A[0]
for i in range(N):
  d = A[i+1] - A[i]
  if max_d < d:
    max_d = d
print(K - max_d)

Buggy submission (verdict: Runtime Error):
K, N = map(int, input().split())
A = list(map(int, input().split()))
A.append(A[0]+K)
max_d = A[1] - A[0]
for i in range(n):
  d = A[i+1] - A[i]
  if max_d < d:
    max_d = d
print(K - max_d)

Buggy submission (verdict: Runtime Error):
K, N = map(int, input().split())
A = list(map(int, input().split()))
A.append(A[0]+K)
max_d = A[1] - A[0]
for i in range(n-1):
  d = A[i+1] - A[i]
  if max_d < d:
    max_d = d
print(K - max_d)
Problem p02873 (python)

Fixed submission:
s = input()
right_cnt = 0
left_cnt = 0
total = 0
for i in range(len(s)):
  if s[i] == '<' and left_cnt == 0:
    right_cnt += 1
  elif s[i] == '<' and left_cnt > 0:
    k = max(right_cnt, left_cnt)
    l = min(right_cnt, left_cnt)
    total += (((k+1)*k) + (l*(l-1)))//2
    right_cnt = 1
    left_cnt = 0
  elif s[i] == '>':
    left_cnt += 1
k = max(right_cnt, left_cnt)
l = min(right_cnt, left_cnt)
total += (((k+1)*k) + (l*(l-1)))//2
print(total)

Buggy submission (verdict: Runtime Error):
s = input()
<_cnt = 0
>_cnt = 0
total = 0
for i in range(len(s)):
  if s[i] == '<' and >_cnt == 0:
    <_cnt += 1
  elif s[i] == '<' and >_cnt > 0:
    k = max(<_cnt, >_cnt)
    l = min(<_cnt, >_cnt)
    total += (((k+1)*k) + (l*(l-1)))//2
    <_cnt = 1
    >_cnt = 0
  elif s[i] == '>':
    >_cnt += 1
k = max(<_cnt, >_cnt)
l = min(<_cnt, >_cnt)
total += (((k+1)*k) + (l*(l-1)))//2
print(total)

Buggy submission (verdict: Runtime Error):
s = input()
<_cnt = 0
>_cnt = 0
total = 0
for i in range(len(s)):
  if s[i] == '<' and >_cnt == 0:
    <_cnt += 1
  elif s[i] == '<' and >_cnt > 0:
    k = max(<_cnt, >_cnt)
    l = min(<_cnt, >_cnt)
    total += (k+1)*k//2 + l*(l-1)//2
    <_cnt = 1
    >_cnt = 0
  elif s[i] == '>':
    >_cnt += 1
k = max(<_cnt, >_cnt)
l = min(<_cnt, >_cnt)
total += (k+1)*k//2 + l*(l-1)//2
print(total)

Buggy submission (verdict: Runtime Error):
s = input()
<_cnt = 0
>_cnt = 0
for i in range(len(s)):
  if s[i] == '<' and >_cnt == 0:
    <_cnt += 1
  elif s[i] == '<' and >_cnt > 0:
    k = max(<_cnt, >_cnt)
    l = min(<_cnt, >_cnt)
    total += (k+1)*k//2 + l*(l-1)//2
    <_cnt = 1
    >_cnt = 0
  elif s[i] == '>':
    >_cnt += 1
k = max(<_cnt, >_cnt)
l = min(<_cnt, >_cnt)
total += (k+1)*k//2 + l*(l-1)//2
print(total)
Problem p02916 (python)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
b_dic = {}
for i in range(1, N + 1):
  b_dic[i] = B[i - 1]
c_dic = {}
for i in range(1, N):
  c_dic[i] = C[i - 1]
count=0
br = -1
for a in A:
  count += b_dic[a]
  if br == a - 1:
    count += c_dic[br]
  br = a
print(count)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
b_dic = {}
for i in range(1, N + 1):
  b_dic[i] = B[i - 1]
c_dic = {}
for i in range(1, N):
  c_dic[i] = C[i - 1]
count=0
br = -1
for a in A:
  count += B[a]
  if br == a - 1:
    count += C[br]
  br = a
print(count)