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

Fixed submission:
N=int(input())
A=list(map(int,input().split()))
counter=1
res=0
for i in range(len(A)-1):
    if (A[i+1]<A[i] and res>0) or (A[i+1]>A[i] and res<0):
        counter+=1
        res=0
    elif A[i+1]!=A[i]:
        res=A[i+1]-A[i]


print(counter)

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

while len(A)>1:
    if A[0]=A[1]:
        A=A[1:]
    else:
        res=(A[1]>A[0])
        for i in range(len(A)-1):
            if (A[i+1]<A[i] and res) or (A[i+1]>A[i] and not res):
                A=A[i+1:]
                counter+=1
                break


print(counter)

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

while len(A)>1:
    res=(A[1]>=A[0])
    for i in range(len(A)):
        if (A[i+1]<A[i] and res) or (A[i+1]>A[i] and not res):
            A=A[i+1:]
            counter+=1
            break

print(counter)

Buggy submission (verdict: Runtime Error):
N=int(input())
A=list(map(int,input().split()))
counter=1
res=(A[1]>=A[0])
if N==1:
    print(1)
else:
    for i in range(N-1):
        if A[i+1]<A[i] and res:
            res=False
            counter+=1
        elif A[i+1]>A[i] and not res:
            res=True
            counter+=1
    print(counter)
Problem p02688 (python)

Fixed submission:
def main():
    ans = []
    N, K = map(int, input().split())

    for i in range(K):
        d = int(input())
        a = map(int, input().split())
        for j in a:
            ans.append(j)

    count = 0
    for i in range(1, N + 1):
        if not i in ans:
            count += 1

    print(count)
    return

main()

Buggy submission (verdict: Runtime Error):
def main():
    count = 0
    ans = []
    N, K = map(int, input().split())
    for _ in range(K):
        d = int(input())
        a = [input() for _ in range(d)]
        ans.append(a)
    for _ in range(1, N + 1):
        if _ not in ans:
            count += 1

    print(count)
    return

main()
Problem p02699 (python)

Fixed submission:
s, w = map(int, input().split())
if s > w:
    print('safe')
else:
    print('unsafe')

Buggy submission (verdict: Runtime Error):
a, b, c, d = map(int, input().split())
while True:
    c = c - b
    if c <= 0:
        print('Yes')
        break
    a = a - d
    if a <= 0:
        print('No')
        break
Problem p02688 (python)

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

S = [0 for i in range(N)]

for i in range(K):
  d = int(input())
  A = list(map(int,input().split()))
  for j in range(d):
    S[A[j]-1]+=1
    
ans = 0
for i in range(N):
  if S[i]==0:
    ans+=1
    
print(ans)

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

S = [0 for i in range(N)]
for i in range(K):
  d = int(input())
  A = list(map(int,input().split()))
  for j in range(d):
    S[d]+=1
ans = 0
for i in range(N):
  if S[i]==0:
    ans+=1
print(ans)
Problem p02862 (python)

Fixed submission:
import math
#import numpy as np 

#参照
#https://qiita.com/derodero24/items/91b6468e66923a87f39f#%E7%95%AA%E5%A4%96%E7%B7%A8
def cmb(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 = 5*10**6
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 )


X,Y =map(int,input().split())
#x,y = np.sum(1/3*(np.array([[ 2., -1.],[-1.,  2.]])*np.array([X,Y])),axis=1).astype(np.int32)
#print(x)
x = int(X-(X+Y)//3)
y = int(Y-(X+Y)//3)
if (X+Y)%3==0 and x>=0 and y>=0:
    print(cmb(x+y,x,mod))
else:
    print(0)

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

def cmb(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**6
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 )


X,Y =map(int,input().split())
x,y = np.sum(1/3.0*(np.array([[ 2., -1.],[-1.,  2.]])*np.array([X,Y])),axis=1).astype(np.int32)
#print(x)
##x = int(X-(X+Y)//3)
#y = int(Y-(X+Y)//3)
if (X+Y)%3==0 and x>=0 and y>=0:
    print(cmb(x+y,x,mod))
else:
    print(0)

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

def cmb(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**6
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 )


X,Y =map(int,input().split())
x,y = np.sum(1/3.0*(np.array([[ 2., -1.],[-1.,  2.]])*np.array([X,Y])),axis=1).astype(np.int32)
print(x)
##x = int(X-(X+Y)//3)
#y = int(Y-(X+Y)//3)
if (X+Y)%3==0 and x>=0 and y>=0:
    print(int(cmb(x+y,x,mod)))
else:
    print(0)
Problem p02990 (python)

Fixed submission:
from scipy.misc import comb

N,K = map(int,input().split())
m=1000000007

for i in range(1,K+1):
    B = comb(K-1, i-1, exact=True)
    R = comb(N-K+1, i, exact=True)
    print((B%m *R%m)%m)

Buggy submission (verdict: Runtime Error):
from scipy.misc import comb

N,K = map(int,input().split())

for i in range(1,K+1):
    B = comb(K-1, i-1, exact=True)
    R = comb(N-K+1, i, exact=True)
    print((B%m *R%m)%m)
Problem p03041 (python)

Fixed submission:
N,K= map(int,input().split())
S = input()
s=str("")
for i in range(len(S)):
    
    if i == K-1:
        #print(i,S[i].lower())
        s=s+S[i].lower()
    else:
        #print(i,S[i])
        s=s+S[i]
print(s)

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

sa = ""
for i in range(len(S)):
  if S[i] == S[int(K)]:
    sa = sa + str(S[i].lower())
  else:
    sa = sa + str(S[i])
print(sa)
Problem p02629 (python)

Fixed submission:
n=int(input())
n-=1
a='abcdefghijklmnopqrstuvwxyz'
a=list(a)
ans=''
for i in range(1,20):
    if n<26**i:
        for j in range(i):
            ans+=a[n%26]
            n//=26
        break
    else:
        n-=26**i
print(ans[::-1])

Buggy submission (verdict: Runtime Error):
n=int(input())
a='Xabcdefghijklmnopqrstuvwxyz'
a=list(a)
j=11
ans=''
while True:
    while n<=26**j:
        j-=1
    temp=a[n//26**j]
    ans+=temp
    n%=26**j
    j-=1
    if j==-1:
        break
print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
a='Xabcdefghijklmnopqrstuvwxyz'
a=list(a)
j=11
ans=''
while True:
    while n<26**j:
        j-=1
    temp=a[n//26**j]
    ans+=temp
    n%=26**j
    j-=1
    if j==-1:
        break
print(ans)
Problem p02766 (python)

Fixed submission:
n,k=map(int,input().split())
cnt=0
i=1
 
while True:
    p=n//k**i
    if p==0:
        print(i)
        break
    else:
        i+=1

Buggy submission (verdict: Runtime Error):
#include<bits/stdc++.h>
using namespace std;
typedef long long int INT;

INT pow(int n,int k)
{
    INT a=1;
    for (int i=1;i<=k;i++){
        a*=n;
    }
    return a;
}

int main()
{
    INT n;
    int k;
    cin>>n>>k;
    int i=0;
    while(1){
        if(n<pow(k,i)){
            cout<<i<<endl;
            break;
        }
        ++i;
    }
}
Problem p02862 (python)

Fixed submission:
x,y=map(int,input().split())
mod=10**9+7

a=(2*x-y)//3
b=(2*y-x)//3



if a!=(2*x-y)/3 or b!=(2*y-x)/3:
    print(0)
elif a<0 or b<0:
    print(0)
else:
    max=a+b+10
    fac=[0]*max
    finv=[0]*max
    inv=[0]*max

    fac[0]=fac[1]=1
    finv[0]=finv[1]=1
    inv[1]=1
    for i in range(2,max):
        fac[i]=fac[i-1]*i%mod
        inv[i]=mod-inv[mod%i]*(mod//i)%mod
        finv[i]=finv[i-1]*inv[i]%mod

    ans=fac[a+b]*(finv[a]*finv[b]%mod)%mod
    print(ans)

Buggy submission (verdict: Runtime Error):
x,y=map(int,input().split())
mod=10**9+7

a=(2*x-y)//3
b=(2*y-x)//3



if a!=(2*x-y)/3 or b!=(2*y-x)/3:
    print(0)
else:
    max=a+b+10
    fac=[0]*max
    finv=[0]*max
    inv=[0]*max

    fac[0]=fac[1]=1
    finv[0]=finv[1]=1
    inv[1]=1
    for i in range(2,max):
        fac[i]=fac[i-1]*i%mod
        inv[i]=mod-inv[mod%i]*(mod//i)%mod
        finv[i]=finv[i-1]*inv[i]%mod

    ans=fac[a+b]*(finv[a]*finv[b]%mod)%mod
    print(ans)

Buggy submission (verdict: Runtime Error):
x,y=map(int,input().split())
mod=10**9+7

a=(2*x-y)//3
b=(2*y-x)//3



if a!=(2*x-y)/3 or b!=(2*y-x)/3:
    print(0)
else:
    max=a+b+1
    fac=[0]*max
    finv=[0]*max
    inv=[0]*max

    fac[0]=fac[1]=1
    finv[0]=finv[1]=1
    inv[1]=1
    for i in range(2,max):
        fac[i]=fac[i-1]*i%mod
        inv[i]=mod-inv[mod%i]*(mod//i)%mod
        finv[i]=finv[i-1]*inv[i]%mod

    ans=fac[a+b]*(finv[a]*finv[b]%mod)%mod
    print(ans)
Problem p02572 (python)

Fixed submission:
n = int(input())

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

S = sum(a)

S2 = sum(map(lambda x: x * x, a ))

ans = (S * S - S2) // 2 % 1000000007
print(ans)

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

a = (list(map(int, input().split())))
dx = 10 ** 9 + 7

a = [i % dx for i in a if i != 0]

ans = 0
alist = []
for i in range(n):
    for j in range(i+1, n):
        alist.append((a[i] * a[j]) % dx)

for i in range(len(alist)):
    ans += alist[i]
    ans %= dx

ans %= dx
print(ans)
Problem p02699 (python)

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

s = q[0]
w = q[1]

if (s <= w):
    print("unsafe")
else:
    print("safe")

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

t = [q[0], q[1]]
a = [q[2], q[3]]

while True:
    a[0] = a[0] - t[1]
    if (a[0] <= 0):
        print("Yes")
        break

    t[0] = t[0] - a[1]
    if (t[0] <= 0):
        print("No")
        break
Problem p02570 (python)

Fixed submission:
d, t, s = map(int, input().split())

if d / s > t:
  print('No')
else:
  print('Yes')

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

total = 0
for i in range(n - 1):
  temp = []
  for j in range(i + 1, n):
    temp.append((a[i]*a[j]) % (10**9 + 7))
  total += sum(temp) % (10**9 + 7)

print(total % (10**9 + 7))
Problem p03137 (python)

Fixed submission:
import sys
n,m=map(int,input().split())
x =list(map(int,input().split()))

ans=0
if n>=m:
    ans=0
else:
    x.sort()
    diff=[0]*(m-1)

    for i in range(m-1):
        diff[i]=x[i+1]-x[i]

    diff.sort()

    ans=0
    
    for i in range(m-n):
        ans+=diff[i]

print(ans)

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

ans=0
if m==1:
    ans=0
else:


    x.sort()

    diff=[0]*(m-1)

    for i in range(m-1):
        diff[i]=x[i+1]-x[i]

    diff.sort()

    ans=0
    if n<=m:
        for i in range(m-n):
            ans+=diff[i]
    else:
        for i in range(diff.size()):
            ans+=diff[i]

print(ans)

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

if m==1:
    print(0)
    sys.exit()

x.sort()

diff=[0]*(m-1)

for i in range(m-1):
    diff[i]=x[i+1]-x[i]

diff.sort()

ans=0
if n<=m:
    for i in range(m-n):
        ans+=diff[i]
else:
    for i in range(diff.size()):
        ans+=diff[i]

print(ans)
Problem p03745 (python)

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

ans=1
x=y=0
c=A[0]

for i in range(1,N):
    if c < A[i]:
        x=1
    elif c>A[i]:
        y=1
    
    if x==1 and y==1:
        ans+=1
        x=y=0
    
    c=A[i]

print(ans)

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

turn=A[1]-A[0]
ans=1

if N>2:
    for i in range(1,N-1):
        judge=turn * (A[i+1]-A[i])

        if judge<0:
            ans+=1
            turn=0
        else:
            turn=A[i+1]-A[i]

print(ans)

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

turn=A[1]-A[0]
ans=1
for i in range(1,N-1):
    judge=turn * (A[i+1]-A[i])

    if judge<0:
        ans+=1
        turn=0
    else:
        turn=A[i+1]-A[i]

print(ans)
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))
Problem p02623 (python)

Fixed submission:
import bisect
n , m , k = map(int, input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
ax = [0]*(n+1)
bx = [0]*(m+1)
for i in range(1,n+1):
    ax[i]=ax[i-1]+a[i-1]
for i in range(1,m+1):
    bx[i]=bx[i-1]+b[i-1]

c = bisect.bisect_right(ax,k)
ma = 0
for i in range(c):
    d = bisect.bisect_right(bx,k-ax[i])
    ma = max(ma,i+d-1)
print(ma)

Buggy submission (verdict: Runtime Error):
n , m , k = map(int, input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
su = 0
at=0
bt=0
ans=0
while su <= k:
    if a[at]<=b[bt]:
        su+=a[at]
        ans+=1
        at+=1
    else:
        su+=b[bt]
        ans+=1
        bt+=1
print(ans-1)
Problem p02661 (python)

Fixed submission:
n = int(input())
al=[]
bl=[]
for i in range(n):
    a , b = map(int, input().split())
    al.append(a)
    bl.append(b)
al.sort()
bl.sort()
if n%2==1:
    mi = al[n//2]
    ma = bl[n//2]
    print(int(ma-mi)+1)
else:
    mi = (al[n//2-1]+al[n//2])/2
    ma = (bl[n//2-1]+bl[n//2])/2
    print(int((ma-mi)*2+1))

Buggy submission (verdict: Runtime Error):
n = int(input())
N = 10**9
x = [0]*(N+1)
x1= [0]*N
x2= [0]*N
for i in range(n):
    a , b = map(int, input().split())
    x[a-1]+=1
    x[b]-=1

for i in range(1,N):
    x[i]=x[i]+x[i-1]

for i in range(1,N):
    x1[i]=x1[i]+x1[i-1]

x.reverse()
for i in range(1,N):
    x2[i]=x2[i]+x2[i-1]

ans =0
if n % 2 == 1:
    for i in range(N):
        if x1[i]+x2[i]>n//2:
            ans +=1
    print(ans)
else:
    for i in range(N):
        if x1[i]+x2[i]>n//2:
            ans +=1
    print(ans*2+1)

Buggy submission (verdict: Runtime Error):
n = int(input())
N = 10**9
x = [0]*(N+1)
x1= [0]*N
x2= [0]*N
for i in range(n):
    a , b = map(int, input().split())
    x[a-1]+=1
    x[b]-=1

for i in range(1,N):
    x[i]=x[i]+x[i-1]

for i in range(1,N):
    x1[i]=x1[i]+x1[i-1]

x.reverse()
for i in range(1,N):
    s2[i]=x2[i]+x2[i-1]

ans =0
if n % 2 == 1:
    for i in range(N):
        if x1[i]+x2[i]>n//2:
            ans +=1
    print(ans)
else:
    for i in range(N):
        if x1[i]+x2[i]>n//2:
            ans +=1
    print(ans*2+1)
Problem p02685 (python)

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

N = 998244353

factorial = [1]
inverse = [1]
for i in range(1, n+2):
    factorial.append(factorial[-1] * i % N)
    inverse.append(pow(factorial[-1], N - 2, N))

def combi(n, r):
    if n < r or r < 0:
        return 0
    elif r == 0:
        return 1
    return factorial[n] * inverse[r] * inverse[n - r] % N

ans=0
if k<n//2:
    for i in range(k+1):
        ans+=m*combi(n-1,i)*pow(m-1,n-1-i,N)%N
        ans%=N
    print(ans)
else:
    for i in range(k+1,n):
        ans+=m*combi(n-1,i)*pow(m-1,n-1-i,N)%N
        ans%=N
    ans = pow(m,n,N)-ans
    if ans < 0:
        ans +=N
    print(ans)

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

N = 998244353

def fac(n,r,N):
    ans=1
    for i in range(r):
        ans=ans*(n-i)%N
    return ans

def combi(n,r,N):
    r= min(r, n-r)
    ans = fac(n,r,N)*pow(fac(r,r,N),N-2,N)%N
    return ans

ans=0
if k<n//2:
    for i in range(k+1):
        ans+=m*combi(n-1,i,N)*pow(m-1,n-1-i,N)%N
        ans%=N
    print(ans)
else:
    for i in range(k+1,n+1):
        ans+=m*combi(n-1,i,N)*pow(m-1,n-1-i,N)%N
        ans%=N
    ans = pow(m,n,N)-ans
    if ans < 0:
        ans +=N
    print(ans)
Problem p02762 (python)

Fixed submission:
import sys
sys.setrecursionlimit(10**7)
n , m , k = map(int, input().split())
r = [[] for i in range(n)]
bk = [[] for i in range(n)]
for i in range(m):
    a , b = map(int, input().split())
    r[a-1].append(b-1)
    r[b-1].append(a-1)
for i in range(k):
    c , d = map(int, input().split())
    bk[c-1].append(d-1)
    bk[d-1].append(c-1)


v=[0]*n
l=[0]*n
w=[0]*n

def dfs(now,c):
    global ln
    if v[now]==1:
        return
    v[now]=1
    ln+=1
    w[now]=c
    l[c]=ln
    for i in r[now]:
        dfs(i,c)
    return

for i in range(n):
    ln=0
    dfs(i,i)

ans =[]
for i in range(n):
    d=0
    for j in bk[i]:
        if w[j]==w[i]:
            d+=1
    ans.append(str(l[w[i]]-1-d-len(r[i])))
print(' '.join(ans))

Buggy submission (verdict: Runtime Error):
n , m , k = map(int, input().split())
r = [[] for i in range(n)]
bk = [[] for i in range(n)]
for i in range(m):
    a , b = map(int, input().split())
    r[a-1].append(b-1)
    r[b-1].append(a-1)
for i in range(k):
    c , d = map(int, input().split())
    bk[c-1].append(d-1)
    bk[d-1].append(c-1)


v=[0]*n
l=[0]*n
w=[0]*n

def dfs(now,c):
    global ln
    if v[now]==1:
        return
    v[now]=1
    ln+=1
    w[now]=c
    l[c]=ln
    for i in r[now]:
        dfs(i,c)
    return

for i in range(n):
    ln=0
    dfs(i,i)

ans =[]
for i in range(n):
    d=0
    for j in bk[i]:
        if w[j]==w[i]:
            d+=1
    ans.append(str(l[w[i]]-1-d-len(r[i])))
print(' '.join(ans))
Problem p02773 (python)

Fixed submission:
import collections

n = int(input())
s = [input() for i in range(n)]
t = collections.Counter(s)
tm = t.most_common()
x = [tm[i][0] for i in range(len(tm)) if tm[i][1]==tm[0][1]]
x.sort()
for i in range(len(x)):
    print(x[i])

Buggy submission (verdict: Runtime Error):
import collections

n = int(input())
s = [input() for i in range(n)]
t = collections.Counter(s)
d = 0
i = 0
x = []
while d==0:
    x.append(t.most_common()[i][0])
    if len(t.most_common())>1:
        d=t.most_common()[i][1]-t.most_common()[i+1][1]
        i+=1
    else:
        d=1
x.sort()
for i in range(len(x)):
    print(x[i])

Buggy submission (verdict: Runtime Error):
import collections

n = int(input())
s = [input() for i in range(n)]
t = collections.Counter(s)
d = 0
i = 0
x = []
while d==0:
    x.append(t.most_common()[i][0])
    if len(t.most_common())>1:
        d=t.most_common()[i][1]-t.most_common()[i+1][1]
        i+=1
    else:
        d=1
x.sort()
for i in range(len(x)):
    print(x[i])
Problem p02792 (python)

Fixed submission:
n = int(input())
s0=list(str(n))
ans=0

if len(s0)==1:
    print(n)
    exit()

if len(s0)==2:
    for i in range(1,n+1):
        s1=list(str(i))
        if s1[-1]=='0':
            continue
        if s1[0]==s1[-1]:
            ans+=1
        if int(s1[-1])*10+int(s1[0])<=n:
            ans+=1
    print(ans)
    exit()

for i in range(1,n+1):
    s1=list(str(i))
    if s1[-1]=='0':
        continue
    if s1[0]==s1[-1]:
        ans+=1
    for j in range(2,len(s0)):#nより小さい桁数のものを足す
        ans+=10**(j-2)
    if int(s0[0])>int(s1[-1]):#nより入れ替えた数の最高位数が小さいとき、全て足す
        ans+=10**(len(s0)-2)
    elif s0[0]==s1[-1]:#nと入れ替えた数の最高位数が同じ時
        ans+=int(''.join(s0[1:len(s0)-1]))+1
        if int(s0[-1])<int(s1[0]):
            ans-=1
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
s0=list(str(n))
ans=0

if len(s0)==1:
    print(n)
    exit()

for i in range(1,n+1):
    s1=list(str(i))
    if s1[-1]=='0':
        continue
    if s1[0]==s1[-1]:
        ans+=1
    for j in range(2,len(s0)):#nより小さい桁数のものを足す
        ans+=10**(j-2)
    if int(s0[0])>int(s1[-1]):#nより入れ替えた数の最高位数が小さいとき、全て足す
        ans+=10**(len(s0)-2)
    elif s0[0]==s1[-1]:#nと入れ替えた数の最高位数が同じ時
        ans+=int(''.join(s0[1:len(s0)-1]))+1
        if int(s0[-1])<int(s1[0]):
            ans-=1
print(ans)
Problem p03038 (python)

Fixed submission:
n , m = map(int, input().split())
a = list(map(int,input().split()))
a.sort()
bc=[]
for i in range(m):
    b , c = map(int, input().split())
    bc.append((b,c))
bc.sort(key = lambda x : x[1],reverse=True)

t=0
for i in range(m):
    b,c=bc[i]
    if t>=n:
        break
    if a[t]>=c:
        break
    for j in range(b):
        if a[t]<c:
            a[t]=c
            if t<n-1:
                t+=1
        else:
            break
print(sum(a))

Buggy submission (verdict: Runtime Error):
n , m = map(int, input().split())
a = list(map(int,input().split()))
a.sort()
bc=[]
for i in range(m):
    b , c = map(int, input().split())
    bc.append((b,c))
bc.sort(key = lambda x : x[1],reverse=True)

t=0
for i in range(m):
    b,c=bc[i]
    if a[t]>=c:
        break
    for j in range(b):
        if a[t]<c:
            a[t]=c
            t+=1
        else:
            break
print(sum(a))

Buggy submission (verdict: Runtime Error):
n , m = map(int, input().split())
a = list(map(int,input().split()))
a.sort()
x=[]
for i in range(m):
    b , c = map(int, input().split())
    x+=[c]*b
x.sort(reverse=True)
t=n
if a[n-1]<x[n-1]:
    a=x[:n]
else:
    for i in range(n):
        if a[i]>=x[i]:
            t=i
            break
    a=x[:t]+a[t:]
print(sum(a))

Buggy submission (verdict: Runtime Error):
n , m = map(int, input().split())
a = list(map(int,input().split()))
a.sort()
x=[]
for i in range(m):
    b , c = map(int, input().split())
    x+=[c]*b
x.sort(reverse=True)
for i in range(n):
    if a[i]>=x[i]:
        t=i
        break
a=x[:t]+a[t:]
print(sum(a))
Problem p02723 (python)

Fixed submission:
S = input()

if S[2] == S[3] and S[4] == S[5]:
    print('Yes')
else:
    print('No')

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

num1000 = X // 500
r500 = X % 500
num5 = r500 // 5

print(num1000 * 1000 + num5 * 5)
Problem p02693 (python)

Fixed submission:
k = int(input())
a,b = map(int,input().split())
if a % k == 0:
  print('OK')
elif b // k - a// k > 0:
  print('OK')
elif a == b and a % k == 0:
  print('OK')
else:
  print('NG')

Buggy submission (verdict: Runtime Error):
m = int(input())
a,b = map(int,input().split())
if b // k - a// k > 0:
  print('OK')
else:
  print('NG')
Problem p02753 (python)

Fixed submission:
S = input()
if S[0] == S[1] and S[0] == S[2]:
    print('No')
else:
    print('Yes')

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

Q = int(input())

A = np.array([S])

for i in range(Q):
    s = input().split()
    if len(s) == 1:
        A = np.flip(A)
    else:
        if s[1] == '1':
            A = np.insert(A,0,np.array([s[2]]))
        else:
            A = np.append(A,np.array([s[2]]))

print('%s' % ''.join(A))
Problem p02570 (python)

Fixed submission:
D ,T, S   = map(int,input().split()) 
if (D )/ S <= T :
    print('Yes')
else:
    print('No')

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

for i in range(len(S)-len(T)+1):
    count = 0
    for j in range(len(T)):
        if T[i+j] != S[j]:
            count += 1
        min_count =min(count,min_count)
        if min_count = 0:
            print(min_count)
            break

print(min_count)
Problem p02571 (python)

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

for i in range(len(S)-len(T)+1):
    con = 0
    for j in range(len(T)):
        if S[i+j] != T[j]:
            con += 1
            
    mint =min(con,mint)
    
    if mint == 0:
        break


print(mint)

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

for i in range(len(S)-len(T)+1):
    con = 0
    for j in range(len(T)):
        if S[i+j] != T[j]:
            con += 1
            
    mint =min(con,mint)
    
    if min_count == 0:
        break


print(mint)