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

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

if len(set(S))==1:
    ans =(len(S)*K)//2

else:
    S_ans =  0
    cnt = 1
    for i in range(1,len(S)):
        if S[i] == S[i-1]:
            cnt += 1
            if i ==len(S)-1:
                S_ans += cnt//2
        else:
            S_ans += cnt//2
            cnt = 1
    ans =S_ans*K

    if S[0] == S[-1]:
        a, i =1, 1
        while S[0]==S[i]:
            a += 1
            i += 1
        b, i =1, 1
        while S[-1]==S[-1- i]:
            b += 1
            i += 1
        ans = ans - (a//2 +b//2 -(a+b)//2)*(K-1)        
    

print(ans)

Buggy submission (verdict: Runtime Error):
S =input()
K =int(input())

if len(set(S))==1:
    ans =(len(S)*K)//2

else:
    S_ans =  0
    cnt = 1
    for i in range(1,len(S)):
        if S[i] == S[i-1]:
            cnt += 1
            if i ==len(S)-1:
                S_ans += cnt//2
        else:
            S_ans += cnt//2
            cnt = 1
    ans =S_ans*K

    if S[0] == S[-1]:
        a, i =1, 1
        while S[0]==S[i]:
            a += 1
            i += 1
        b, i =1, 1
        while S[-1]==S[-1- i]:
            b += 1
            i += 1
    
    ans = ans - (a//2 +b//2 -(a+b)//2)*(K-1)        
    

print(ans)

Buggy submission (verdict: Runtime Error):
S =input()
K =int(input())
x =S*K

count =[]
while len(x)>0:
    if len(x)==1:
        count.append(1)
        x =x[:-1]
        break
    if x[-1] != x[-2]:
        count.append(1)
        x =x[:-1]
    else:
        k = 2
        while True:
            if len(x) == k :
                count.append(k)
                break
            if x[-1] == x[-1-k]:
                k +=1
            else:
                count.append(k)
                break
        x =x[:-k]       
#print(count[::-1])    
ans = sum(list(map(lambda x :x//2,count)))
print(ans)
Problem p02629 (python)

Fixed submission:
# coding: utf-8
# Your code here!
import math

N = int(input())
count = 0
count2 = 0

al=[chr(ord('a') + i) for i in range(26)]

thresh = [26**i for i in range(1,12)]
for i in range(1,len(thresh)):
 thresh[i] = thresh[i] + thresh[i-1]
 
for i in range(len(thresh)):
    if thresh[i] <N:
        continue
    else:
        char_num = i+1#何文字
        name_str = ['a' for i in range(char_num)]
        if char_num > 1:
            count = N-thresh[i-1]#char_numの何個目か
            #print('char_num', char_num)
            for i in range(char_num):
                count2 = int((count-1)/(26**(char_num-i-1)))
                if (count2 > 0)&(i!=(char_num-1)):
                    if count2 <= 25:
                        name_str[i] = al[count2]
                        count = count - ((26**(char_num-i-1))*count2)
                    else:
                        name_str[i] = al[count2-1]
                        count = count - ((26**(char_num-i-1))*count2)
        else:
            count = N
        if count > 0:
            name_str[-1] = al[count-1]
        break
    
    
out = ""
for i in name_str:
    out = out + i
print(out)

Buggy submission (verdict: Runtime Error):
# coding: utf-8
# Your code here!
import math

N = int(input())
count = 0
count2 = 0

al=[chr(ord('a') + i) for i in range(26)]

thresh = [26**i for i in range(1,12)]
for i in range(1,len(thresh)):
 thresh[i] = thresh[i] + thresh[i-1]

for i in range(len(thresh)):
    if thresh[i] <N:
        continue
    else:
        char_num = i+1#何文字
        name_str = ['a' for i in range(char_num)]
        if char_num > 1:
            count = N-thresh[i-1]#char_numの何個目か
            #print('char_num', char_num)
            for i in range(char_num):
                count2 = int(count/(26**(char_num-i-1)))
                if (count2 > 0)&(i!=(char_num-1)):
                    #print(count2)
                    name_str[i] = al[count2]
                    count = count - ((26**(char_num-i-1))*count2)
        else:
            count = N
        if count > 0:
            name_str[-1] = al[count-1]
        break
    
    
out = ""
for i in name_str:
    out = out + i
print(out)
Problem p02676 (python)

Fixed submission:
K = int(input())
S = input()
 
if len(S) <= K:
    print(S)
else:
    print(S[:K] + '...')

Buggy submission (verdict: Runtime Error):
import numpy as np
#, K = map(int, input().split())

K = int(input())
S = input()

if len(S) <= K:
    print(S)
else:
    print(S[:K] + '...')
Problem p02707 (python)

Fixed submission:
import numpy as np
 
 
if __name__ == '__main__':
    List = [list(map(int, input().split())) for i in range(2)]
    N = List[0][0]
    buka = np.array(List[1][:])
 
 
    l_out = np.zeros(N,dtype=int)
 
    for i in range(N-1):
        l_out[buka[i]-1] += 1
 
    for i in range(N):
        print(l_out[i])

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


if __name__ == '__main__':
    List = [list(map(int, input().split())) for i in range(2)]
    N = List[0][0]
    buka = np.array(List[1][:])


    l_out = np.zeros(N,dtype=int)

    for i in range(N):
        l_out[buka[i]-1] += 1

    for i in range(N):
        print(l_out[i])
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()))
X = B[A[0]-1]
for i in range(1,N):
  if A[i] == A[i-1]+1 :
    X += (B[(A[i]-1)]+C[(A[i-1]-1)])
  else:
    X += B[(A[i]-1)]
print(X)

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()))
X = 0
for i in range(N-1):
  if A[i] == A[i+1]-1 :
    X += (B[i]+C[i+1])
  else:
    X += B[i]
    break
X += B[N-1]  
print(X)

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()))
X = 0
for i in range(N-1):
  if A[i] == A[i+1]-1 :
    X += (B[i]+C[i+1])
  else:
    X += B[i]
X += B[N-1]  
print(X)
Problem p02578 (python)

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

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

Fixed submission:
x=int(input())
if x>=30:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
X=int(input())
if x>=30:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
X=int(input())
if x>=30:
  print(Yes)
else:
  print(No)
Problem p03013 (python)

Fixed submission:
def m():
    MOD = 10 ** 9 + 7
    N, M = map(int, input().split())
    A = [int(input()) for _ in range(M)]
    dp = [0] * (N + 1)
    for a in A: dp[a] = -1
    if N == 1:
        if dp[1] != -1:
            return 1
        else:
            return 0
    if dp[1] != -1 and dp[2] != -1:
        dp[1] = 1
        dp[2] = 2
    elif dp[1] != -1 and dp[2] == -1:
        dp[1] = 1
    elif dp[1] == -1 and dp[2] != -1:
        dp[2] = 1
    else:
        return 0

    for i in range(3, N + 1):
        if dp[i] == -1:
            continue
        l = dp[i - 2] if dp[i - 2] != -1 else 0
        r = dp[i - 1] if dp[i - 1] != -1 else 0
        dp[i] = (l + r) % MOD
    return dp[N] % MOD


print(m())

Buggy submission (verdict: Runtime Error):
def m():
    MOD = 10 ** 9 + 7
    N, M = map(int, input().split())
    A = [int(input()) for _ in range(M)]
    dp = [0] * (N + 1)
    for a in A: dp[a] = -1
    if dp[1] != -1 and dp[2] != -1:
        dp[1] = 1
        dp[2] = 2
    elif dp[1] != -1 and dp[2] == -1:
        dp[1] = 1
    elif dp[1] == -1 and dp[2] != -1:
        dp[2] = 1
    else:
        return 0

    for i in range(3, N + 1):
        if dp[i] == -1:
            continue
        l = dp[i - 2] if dp[i - 2] != -1 else 0
        r = dp[i - 1] if dp[i - 1] != -1 else 0
        dp[i] = (l + r) % MOD
    return dp[N] % MOD


print(m())
Problem p03634 (python)

Fixed submission:
import sys
sys.setrecursionlimit(1000000)
 
def ans():
    def dfs(v, p, d):
        depth[v] = d
        for e, cost in tree[v]:
            if e == p:
                continue
            dfs(e, v, d + cost)
 
    n = int(input())
    tree = [[] for _ in range(n + 1)]
    depth = [0] * (n * 2)
    for _ in range(1, n):
        a, b, c = map(int, input().split())
        tree[a].append((b, c))
        tree[b].append((a, c))
 
    q, k = map(int, input().split())
    dfs(k, -1, 0)
    for _ in range(q):
        x, y = map(int, input().split())
        print(depth[x] + depth[y])
 
 
ans()

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(100000)
 
def ans():
    def dfs(v, p, d):
        depth[v] = d
        for e, cost in tree[v]:
            if e == p:
                continue
            dfs(e, v, d + cost)
 
    n = int(input())
    tree = [[] for _ in range(n + 1)]
    depth = [0] * (n * 2)
    for _ in range(1, n):
        a, b, c = map(int, input().split())
        tree[a].append((b, c))
        tree[b].append((a, c))
 
    q, k = map(int, input().split())
    dfs(k, -1, 0)
    for _ in range(q):
        x, y = map(int, input().split())
        print(depth[x] + depth[y])
 
 
ans()

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10000)

def ans():
    def dfs(v, p, d):
        depth[v] = d
        for e, cost in tree[v]:
            if e == p:
                continue
            dfs(e, v, d + cost)

    n = int(input())
    tree = [[] for _ in range(n + 1)]
    depth = [0] * (n * 2)
    for _ in range(1, n):
        a, b, c = map(int, input().split())
        tree[a].append((b, c))
        tree[b].append((a, c))

    q, k = map(int, input().split())
    dfs(k, -1, 0)
    for _ in range(q):
        x, y = map(int, input().split())
        print(depth[x] + depth[y])


ans()

Buggy submission (verdict: Runtime Error):
def ans():
    def dfs(v, p, d):
        depth[v] = d
        for e, cost in tree[v]:
            if e == p:
                continue
            dfs(e, v, d + cost)
    n = int(input())
    tree = [[] for _ in range(n+1)]
    depth = [0] * (n * 2)
    for _ in range(1,n):
        a, b, c = map(int, input().split())
        tree[a].append((b,c))
        tree[b].append((a,c))

    q, k = map(int, input().split())
    dfs(k, -1, 0)
    for _ in range(q):
        x, y = map(int, input().split())
        print(depth[x] + depth[y])

ans()

Buggy submission (verdict: Runtime Error):
def ans():
    def dfs(v, p, d):
        depth[v] = d
        for e, cost in tree[v]:
            if e == p:
                continue
            dfs(e, v, d + cost)
    n = int(input())
    tree = [[] for _ in range(n+1)]
    depth = [0] * 100001
    for _ in range(1,n):
        a, b, c = map(int, input().split())
        tree[a].append((b,c))
        tree[b].append((a,c))

    q, k = map(int, input().split())
    dfs(k, -1, 0)
    for _ in range(q):
        x, y = map(int, input().split())
        print(depth[x] + depth[y])

ans()
Problem p02577 (python)

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

def main():
    input_num = input()
    sum_num = 0

    for i in range(len(input_num)):
        chushutsu = int(input_num[i])
        sum_num += chushutsu
    
    if sum_num % 9 == 0:
        print('Yes')

    else:
        print('No')

if __name__ == '__main__':
    main()

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

def main():
    input_num = int(input())
    flag = True
    sum_num = 0

    while flag:
        chushutsu = input_num % 10
        sum_num += chushutsu
        input_num = int((input_num - chushutsu) / 10)
        if input_num == 0:
            flag = False

    if sum_num % 9 == 0:
        print('Yes')

    else:
        print('No')

if __name__ == '__main__':
    main()

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

def main():
    input_num = int(input())
    flag = True
    sum_num = 0

    while flag:
        chushutsu = input_num % 10
        sum_num += chushutsu
        input_num = (input_num - chushutsu) / 10
        if input_num == 0:
            flag = False

    if sum_num % 9 == 0:
        print('Yes')

    else:
        print('No')

if __name__ == '__main__':
    main()

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

def main():
    flag = True
    input_num = int(input())
    pre_ans = []
    sum_num = 0

    while flag:
        chushutsu = input_num % 10
        sum_num += chushutsu
        input_num = (input_num - chushutsu) / 10
        if input_num == 0:
            flag = False

    if sum_num % 9 == 0:
        print('Yes')

    else:
        print('No')

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

Fixed submission:
N,A,B = map(int,input().split())
if A == 0:
    print(A)
    exit()
n = N // (A + B)
nn = N % (A + B)
if n != 0 and nn <= A:
    print(int(A*n + nn))
elif n != 0 and nn > A:
    print(int(A*(n+1)))
elif n == 0 and N >= A:
    print(A)
elif n == 0 and N < A:
    print(N)

Buggy submission (verdict: Runtime Error):
import math
A,B = map(int,input().split())
a = A / 0.08
b = B / 0.1
if math.floor(a * 0.1) == B:
    ans = int(a)
elif math.floor(b * 0.08) == A:
    ans = int(b)
else:
    print(-1)
    exit()
if (math.floor((ans-1)*0.08) == A) and (math.floor((ans-1)*0.1) == B):
    ans = ans - 1
else:
    print(ans)
Problem p02819 (python)

Fixed submission:
X = int(input())
prime = None
while True:
    for i in range(2, X):
        if X % i == 0:
            break
    else:
        prime = X
    if prime != None:
        break
    else:
        X += 1

print(prime)

Buggy submission (verdict: Runtime Error):
X = int(input())
X = X + 1
while True:
    for i in range(0, X):
        if X % i == 0:
            prime = X
            break
        else:
            X += 1
print(X)
Problem p02578 (python)

Fixed submission:
n = input()
m = input().split()
m = [int(i) for i in m]
mx = max(m)
ind = m.index(mx)
 
c = 0
j = len(m)
for i in reversed(m[ind:]):
    if i < mx:
        d = mx - i
        c += d
        
ind_i = 0
for i in m[1:ind]:
    #print(i)
    if m[ind_i] > i:
        num = m[ind_i] - i
        m[ind_i+1] += num
        c+= num
    
    ind_i += 1
    
print(c)

Buggy submission (verdict: Runtime Error):
n = input()
m = input()
m = list(m)
m = [int(i) for i in m]
mx = max(m)
ind = m.index(mx)

c = 0
j = len(m)
for i in reversed(m[ind:]):
    if i < mx:
        d = mx - i
        c += d
ind_i = 0
for i in m[1:ind]:
    if m[ind_i] > i:
        num = m[ind_i] - i
        c+= num
    ind_i += 1
    
print(c)
Problem p02594 (python)

Fixed submission:
n = int(input())
 
if n >= 30:
  print("Yes")
else:
  print("No")

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

if n >= 30:
  print("Yes")
else:
  print("No")

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

if n >= 30:
  print("Yes")
else:
  print("No")
Problem p02659 (python)

Fixed submission:
from decimal import Decimal, getcontext
import math
n = input().split()

def cal(a,b):
  if '.' in list(a):
    c = Decimal(a)
  else:
    c = int(a)
  
  if '.' in list(b):
    d = Decimal(b)
  else:
    d = int(b)
    
  return c*d


print(math.floor(cal(n[0],n[1])))

Buggy submission (verdict: Runtime Error):

n = input().split()

ans = int(n[0])*int(n[1])

print(math.floor(ans))
Problem p02701 (python)

Fixed submission:
n = int(input())
l = [input() for i in range(n)]
 
l = set(l)
l = list(l)
print(len(l))

Buggy submission (verdict: Runtime Error):
n = int(input())
l = [input() for i in range(n)]

l = set(l)
l = list(l)
print(sum(l))
Problem p02707 (python)

Fixed submission:
n = int(input())
m = input().split()
m = [int(i) for i in m]
 
l =[]
for i in range(n):
  l.append(0)
for i in m:
  ind = i-1
  l[ind] += 1
for i in l:
  print(i)

Buggy submission (verdict: Runtime Error):
n = int(input())
m = input().split()
m = [int(i) for i in m]
 
for i in range(n):
  l.append(0)
for i in m:
  ind = i-1
  l[ind] += 1
for i in l:
  print(i)

Buggy submission (verdict: Runtime Error):
n = int(input())
m = input().split()
m = [int(i) for i in m]
 
for i in range(n):
  l.append(0)
for i in m:
  ind = i-1
  l[ind] += 1
for i in l:
  print(i)

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

for i in range(n):
  l.append(0)

for i in m:
  ind = i-1
  l[ind] += 1

for i in l:
    print(i)
Problem p02577 (python)

Fixed submission:
N = input()

num = 0

for n in N:
  num += int(n)
  
if num % 9 == 0:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
N = input()
N_len = len(N)
num = 0

for i in range(N_len):
  num += int(N(i))
  
if (num % 9 == 0):
  print("yes")
else:
  print("no")
Problem p02595 (python)

Fixed submission:
import math

input_ = input().split()

N = int(input_[0])
D = float(input_[1])

num = 0

for i in range(N):
  x_i,y_i = map(float,input().split())
  
  if(math.sqrt(x_i**2 + y_i**2) <= D):
    num += 1
    
print(num)

Buggy submission (verdict: Runtime Error):
import math

input_ = input().split()

N = int(input_[0])
D = float(input_[1])

num = 0

for i in range(N):
  x_i,y_i = map(float,input().split())
  
  if(math.sqrt(x_i**2 + y_i**2p) <= D):
    num += 1
    
print(num)
Problem p02712 (python)

Fixed submission:
n=int(input())
ans = 0
for i in range(1,n+1):
    if i % 3 != 0 and i % 5 != 0:
        ans += i
print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
ans = 0
for i in range(1,i+1):
    if i % 3 != 0 and i % 5 != 0:
        ans += i
print(ans)
Problem p02777 (python)

Fixed submission:
s,t=map(str,input().split())
a,b=map(int,input().split())
u=input()
if u == s:
    a -= 1
else:
    b -= 1
print(a,b)

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


Msum=0
for i in range(n-k+1):
    tmp=sum(p[i:i+k])
    Msum = max(tmp,Msum)

print((Msum+k)/2)
Problem p02779 (python)

Fixed submission:
n=int(input())
a=[int(i) for i in input().split()]

aSet=set(a)
if len(a) == len(aSet):
    print("YES")
else:
    print("NO")

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


Msum=0
for i in range(n-k+1):
    tmp=sum(p[i:i+k])
    Msum = max(tmp,Msum)

print((Msum+k)/2)
Problem p02577 (python)

Fixed submission:
a=int(input())%9
if a==0:
  print('Yes')
else:
  print('No')

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

if str(a)[-1]=='0':
  print('Yes')
else:
  print('NO')

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

if str(b)[-1]=='0':
  print('Yes')
else:
  print('NO')

Buggy submission (verdict: Runtime Error):
a=input()
b=int(a)/9
if str(b)[-1]=='0':
  print('Yes')
else:
  print('NO')
Problem p02676 (python)

Fixed submission:
a=int(input())
b=input()
i=0
while i<a and i<len(b):
    print(end=str(b[i]))
    i=i+1
if len(b)>a:
    print(end='...')

Buggy submission (verdict: Runtime Error):
a=int(input())
b=input()
i=0
while i<a:
    print(end=str(b[i]))
    i=i+1
if len(b)>a:
    print(end='...')
Problem p02595 (python)

Fixed submission:
N, D = map(int,input().split())
Z = 0
for i in range(N):
    X, Y = map(int, input().split())
    A = ((X**2 + Y**2)**0.5)
    if A <= D:
        Z = Z + 1
print(Z)

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

for i in range(N):
    X, Y = map(int, input().split())
    A = ((X**2 + Y**2)**0.5)
    if A <= D:
        Z = Z + 1
print(Z)
Problem p02699 (python)

Fixed submission:
S, W = map(int,input().split())
print('unsafe' if S <= W else 'safe')

Buggy submission (verdict: Runtime Error):
A,B,C,D = map(int,input().split())
while True:
  C = C - B
  if C <= 0:
    break
  A = A - D
  if A <= 0:
    break
print('Yes' if A >= C else 'No')

Buggy submission (verdict: Runtime Error):
S, W = map(int,input().split())
input('unsafe' if S <= W else 'safe')
Problem p02707 (python)

Fixed submission:
N = int(input())
a = list(map(int, input().split()))
li = [0] * N

for i in range(N-1):
    li[a[i]-1] = li[a[i]-1] + 1

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

Buggy submission (verdict: Runtime Error):
N = int(input())
a = list(input().split())
for i in range(N):
  	s = str(i+1)
    print(a.count(s))
Problem p02860 (python)

Fixed submission:
N = int(input())
S = input()

if N % 2 == 0:
    num = int(N/2)
    string = S[:num]
    strstr = string + string
    if S == strstr:
        print("Yes")
    else:
        print("No")
else:
    print("No")

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

if N % 2 == 0:
    num = int(N/2 + 1）
    string = S[:num]
    strstr = string + string
    if S == strstr:
        print("Yes")
    else:
        print("No")
else:
    print("No")

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

if N % 2 == 0:
  str = S[:N/2+1]
  strstr = str + str
  if S == str:
      print("Yes")
  else:
      print("No")
else:
  print("No")
Problem p03038 (python)

Fixed submission:
N, M = map(int,input().split())
A = list(map(int,input().split()))
A.sort()
bc = []
bc = [list(map(int,input().split())) for _ in range(M)]
bc.sort(key=lambda x:x[1],reverse=True)
ai = 0
for b,c in bc:
  cc = b
  while ai<N and cc >0:
    if A[ai] < c:
      A[ai] = c
      cc -= 1
    ai +=1
    if ai == N:
        break
print(sum(A))

Buggy submission (verdict: Runtime Error):
N, M = map(int,input().split())
A = list(map(int,input().split()))
A.sort()
bc = []
sum_A = 0
for _ in range(M):
  BC = list(map(int,input().split()))
  for _ in range(BC[0]):
    bc.append(BC[1])
bc.sort(reverse=True)
for i in range(len(bc)):
  if A[i] < bc[i]:
    sum_A += bc[i]
  else:
    sum_A += A[i]
print(sum_A)

Buggy submission (verdict: Runtime Error):
N, M = map(int,input().split())
A = list(map(int,input().split()))
A.sort()
bc = []
for _ in range(M):
  BC = list(map(int,input().split()))
  for _ in range(BC[0]):
    bc.append(BC[1])
bc.sort(reverse=True)
for i in range(len(bc)):
  if A[i] < bc[i]:
    A[i] = bc[i]
print(sum(A))
Problem p02682 (python)

Fixed submission:
i = input().split()

a = i[0]
b = i[1]
c = i[2]
d = i[3]

if int(d) <= int(a):
  print(int(d))
elif int(d) - int(a) <= int(b):
    print(int(a))
else:
  print(int(a) - (int(d) - int(a) -int(b)))

Buggy submission (verdict: Runtime Error):
i = input().split()

a = i[0]
b = i[1]
c = i[2]
d = i[3]

if int(d) <= int(a):
  print(int(d))
  elif int(d) - int(a) <= int(b):
    print(int(a))
else:
  print(int(a) - (int(d) - int(a) -int(b)))
Problem p02623 (python)

Fixed submission:
n, m, k = map(int, input().split())
a = list(map(int, input().split())) # list()でリスト化、それを変数に代入。
b = list(map(int, input().split())) # list()でリスト化、それを変数に代入。
kazu = 0
c_a = 0
c_b = 0
time = 0

a = [0]+a
b = [0]+b

for i in range(1,n+1):
    a[i]= a[i-1]+a[i]
for i in range(1,m+1):
    b[i]= b[i-1]+b[i]

for i in range(0,n+1):
    for j in range(max(0,kazu-i+1),m+1):
        time = a[i] + b[j]
        if time > k:
            break
        kazu = i + j

print(kazu)

Buggy submission (verdict: Runtime Error):
n, m, k = map(int, input().split())
a = list(map(int, input().split())) # list()でリスト化、それを変数に代入。
b = list(map(int, input().split())) # list()でリスト化、それを変数に代入。
ans = 0
kazu = 0
c_a = 0
c_b = 0
time = 0
'''
a.append(10**9 + 1)
b.append(10**9 + 1)


while True:
    if time + min(a[c_a],b[c_b])>k:
        break
    if a[c_a]>b[c_b]:
        time += b[c_b]
        c_b += 1
    elif a[c_a]<b[c_b]:
        time += a[c_a]
        c_a += 1

    ans += 1
'''
a = [0]+a
b = [0]+b

for i in range(1,n+1):
    a[i]= a[i-1]+a[i]
for i in range(1,m+1):
    b[i]= b[i-1]+b[i]

for i in range(0,n+1):
    for j in range(min(0,kazu-i+1),m+1):
        time = a[i] + b[j]
        if time > k:
            break
        kazu = i + j

print(kazu)
Problem p02701 (python)

Fixed submission:
n = int(input())
s = {input() for i in range(n)}#縦に入力されたものをリストに

print(len(s))

Buggy submission (verdict: Runtime Error):
n = int(input())
array = [input()]
ans = 1

for i in range(1, n-1):
    tmp = input()
    j = i
    while True:
        j -= 1
        if j==0 or tmp >= array[j-1]:
            break
    if tmp != array[j-1]:
        ans += 1
        array.insert(j, tmp)
print(ans)