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

Fixed submission:
N = int(input())
hstr = input().split()
h = [int(n) for n in hstr]

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

dp[0] = 0
dp[1] = abs(h[0] - h[1])

for i in range(2, N):
    dif1 = abs(h[i] - h[i-1])
    dif2 = abs(h[i] - h[i-2])
    dp[i] = min(dp[i-1] + dif1, dp[i-2] + dif2)

print(dp[N-1])

Buggy submission (verdict: Runtime Error):
import math

N = int(input())
hstr = input().split()
h = [int(n) for n in hstr]

dp = [math.inf for i in range(N)]

dp[0] = 0
dp[1] = abs(h[0] - h[1])

for i in range(2, N):
    dif1 = abs(h[i] - h[i-1])
    dif2 = abs(h[i] - h[i-2])
    dp[i] = min(dp[i-1] + dif1, dp[i-2] + dif2)

print(dp[N-1])
Problem p03261 (python)

Fixed submission:
a = input()

def main():
    ed = []
    for i in range(int(a)):
        neww = input()
        if i != 0:
            if ed[i-1][-1] != neww[0] or neww in ed:
                return 'No'
        ed.append(neww)

    return 'Yes'
                

if __name__ == '__main__':
    print(main())

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

words = b.split('\n')
print(words)
def main():
    ed = []
    for i in range(int(a)-2):
        w1 = words[i]
        ed.append(w1)
        w2 = words[i+1]
        print(ed)
        if w1[-1] != w2[0] or w1 in ed:
            return 'No'
    return 'Yes'

if __name__ == '__main__':
    main()

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

words = b.split()

for i in range(len(words)-1):
    w1 = words[i]
    w2 = words[i+1]

    if w1[-1] != w2[0]:
        return 'No'

return 'Yes'
Problem p02865 (python)

Fixed submission:
n=int(input())
if n%2==0:
    Ans=n//2-1
else:
    Ans=n//2
print(Ans)

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

if min(Ds)!=0 or Ds.count(0)!=1:
    print(0)
else:
    Ans=[0]*(max(Ds)+1)
    Ans[0]=1
    for i in range(1, max(Ds)+1):
        Ans[i]=(Ans[i-1]*(Ds.count(i-1)**Ds.count(i)))

    print(Ans[max(Ds)])%998244353
Problem p02995 (python)

Fixed submission:
import fractions
def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)

A,B,C,D=map(int, input().split())

#CとDの最小公倍数
LCM=lcm(C,D)
#A未満でCで割れる個数
Ac=(A-1)//C
#範囲内でCで割れる個数
div_C=B//C-Ac
#A未満でDで割れる個数
Ad=(A-1)//D
#範囲内でDで割れる個数
div_D=B//D-Ad
#A未満でLCMで割れる個数
Alcm=(A-1)//LCM
#範囲内でLCMで割れる個数
div_CD=B//LCM-Alcm
#解答
Ans=(B-A+1)-div_C-div_D+div_CD
print(Ans)

Buggy submission (verdict: Runtime Error):
import math

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

A,B,C,D=map(int, input().split())
LCM=lcm(C,D)
Ac=(A-1)//C
div_C=B//C-Ac
Ad=(A-1)//D
div_D=B//D-Ad
Alcm=(A-1)//LCM
div_CD=B//LCM-Alcm
Ans=(B-A+1)-div_C-div_D+div_CD
print(Ans)

Buggy submission (verdict: Runtime Error):
import math
def lcm(x, y):
    return (x * y) // math.gcd(x, y)

A,B,C,D=map(int, input().split())

#CとDの最小公倍数
LCM=lcm(C,D)

#A未満でCで割れる個数
Ac=(A-1)//C

#範囲内でCで割れる個数
div_C=B//C-Ac

#A未満でDで割れる個数
Ad=(A-1)//D

#範囲内でDで割れる個数
div_D=B//D-Ad

#A未満でLCMで割れる個数
Alcm=(A-1)//LCM

#範囲内でLCMで割れる個数
div_CD=B//LCM-Alcm

#解答
Ans=(B-A+1)-div_C-div_D+div_CD
print(Ans)

Buggy submission (verdict: Runtime Error):
import math
def lcm(x, y):
    return (x * y) // math.gcd(x, y)

A,B,C,D=map(int, input().split())

#CとDの最小公倍数
LCM=lcm(C,D)

#A未満でCで割れる個数
Ac=(A-1)//C

#範囲内でCで割れる個数
div_C=B//C-Ac

#A未満でDで割れる個数
Ad=(A-1)//D

#範囲内でDで割れる個数
div_D=B//D-Ad

#A未満でLCMで割れる個数
Alcm=(A-1)//LCM

#範囲内でLCMで割れる個数
div_CD=B//LCM-Alcm

#解答
Ans=(B-A+1)-div_C-div_D+div_CD
print(Ans)
Problem p03037 (python)

Fixed submission:
N,M=map(int,input().split())
Key=[0]*(N+1)
for i in range(M):
    L,R = map(int,input().split())
    Key[L-1] += 1
    Key[R] -= 1
for i in range(N):
    Key[i+1] += Key[i] # 累積和
print(Key.count(M))

Buggy submission (verdict: Runtime Error):
N,M=map(int,input().split())
Key=[0]*(N+1)
for i in range(M):
    L,R = map(int,input().split())
    Key[L-1] += 1
    Key[R] -= 1
for i in range(N):
    Key[i+1] += Key[i] # 累積和
print(Key)
print(Key.count(m))
Problem p03244 (python)

Fixed submission:
import collections

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

vs_odd=vs[::2]
c_odd=collections.Counter(vs_odd) 
C1=c_odd.most_common()
C1.append((0,0))
common1=C1[0][1] #最頻値の個数
common1sec=C1[1][1] #第2頻値

vs_even=vs[1::2]
c_even=collections.Counter(vs_even) 
C2=c_even.most_common()
C2.append((0,0))
common2=C2[0][1] #最頻値の個数
common2sec=C2[1][1] #第2頻値

Ans1=len(vs_odd)-common1
Ans2=len(vs_even)-common2
Ans3=len(vs_odd)-common1sec
Ans4=len(vs_even)-common2sec

if c_odd.most_common()[0][0] == c_even.most_common()[0][0]:
    #最頻値が同じ場合
    print(min(Ans1+Ans4, Ans2+Ans3))
else:
    print(Ans1+Ans2)

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

Vo=V[::2]
Ve=V[1::2]

oddmost = collections.Counter(Vo).most_common()[0][1]
oddsec = collections.Counter(Vo).most_common()[1][1]
evenmost = collections.Counter(Ve).most_common()[0][1]
evensec = collections.Counter(Ve).most_common()[1][1]

if oddmost!=evenmost:
    print(len(V)-oddmost-evenmost)
else:
    print(min(len(V)-oddmost-evensec, len(V)-evenmost-oddsec))
Problem p03274 (python)

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

Distance=[]
for i in range(N-K+1):
        Distance.append(abs(Candles[i]-Candles[i+K-1])+min(abs(Candles[i]),abs(Candles[i+K-1])))
print(min(Distance))

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

Distance=[]
for i in range(N-K):
        Distance.append(abs(Candles[i]-Candles[i+K-1])+min(abs(Candles[i]),abs(Candles[i+K-1])))
print(min(Distance))
Problem p03407 (python)

Fixed submission:
a,b,c=map(int,input().split())
print('Yes' if a+b>=c else 'No')

Buggy submission (verdict: Runtime Error):
S = [input() for _ in range(int(input()))]
T = [input() for _ in range(int(input()))]
ans = 0
for s in set(S):
    score = S.count(s) - T.count(s)
    if score > ans:
        ans = score
print(ans)
Problem p03448 (python)

Fixed submission:
a, b, c, x =[int(input()) for i in range(4)]
ans = 0
for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            if i * 500 + j * 100 + k * 50 == x:
                ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
a, b, c, x =[int(input()) for i in range(4)])
ans = 0
for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            if i * 500 + j * 100 + k * 50 == x:
                ans += 1
print(ans)
Problem p03471 (python)

Fixed submission:
n,y=map(int, input().split())
for p in range(n+1):
    for q in range(n-p+1):
        if 10000*p+5000*q+1000*(n-p-q)==y:
                print(p,q,n-p-q)
                exit()
print("-1 -1 -1")

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

res10000=-1
res5000=-1
res1000=-1

for a in range(0,N+1):
    for b in range(0,N-a+1):
        total=a*10000+b*5000+(N-a-b)*1000
        if total == Y:
            res10000=a
            res5000=b
            res1000=N-a-b
            
print(res10000,res5000,res1000))
Problem p03477 (python)

Fixed submission:
a,b,c,d=map(int, input().split())
print('Balanced' if  a+b==c+d else 'Left' if a+b>c+d else 'Right')

Buggy submission (verdict: Runtime Error):
n,a,b=map(int, input().split())
some=[]
for i in range(1,n+1):
    if a<=sum(map(int, list(str(i))))<=b:
        some.append(i)
print(sum(some))

Buggy submission (verdict: Runtime Error):
a,b,c,d=map(int, input().split())
print('Balanced' if  a+b==c+d 'Left' if a+b>c+d else 'Right')

Buggy submission (verdict: Runtime Error):
a,b,c,d=map(int, input().split())
print('Balanced' if  a+b==c+d 'Left' a+b>c+d else 'Right')
Problem p03478 (python)

Fixed submission:
n,a,b=map(int, input().split())
some=[]
for i in range(1,n+1):
    if a<=sum(map(int, list(str(i))))<=b:
        some.append(i)
print(sum(some))

Buggy submission (verdict: Runtime Error):
n,a,b=map(int, input().split())
n,a,b=map(int, input().split())
some=[]
for i in range(1,n+1):
    if a<=sum(map(int, list(str(i))))<=b:
        some.append(i)
print(sum(some))
Problem p03636 (python)

Fixed submission:
s=str(input())
n=str(len(s)-2)
print(s[0]+str(n)+s[-1])

Buggy submission (verdict: Runtime Error):
n,k,x,y=[int(input()) for i in range(4)]
print(k*x+y*(n-k))

Buggy submission (verdict: Runtime Error):
a,b,c=input(); print(a+str(len(b))+c)
Problem p03997 (python)

Fixed submission:
a,b,h=[int(input()) for i in range(3)];print((a+b)*h//2)

Buggy submission (verdict: Runtime Error):
a,b,h=map(int, input().split());print((a+b)*h//2)

Buggy submission (verdict: Runtime Error):
a,b,h=map(int, input().split());print((a+b)*h//2)

Buggy submission (verdict: Runtime Error):
a,b,h=map(int, input().split());print((a+b)*h/2)
Problem p03005 (python)

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

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

if K==1:
    print(0)
else:
    print(N-K)

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

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

if K=1:
    print(0)
else:
    print(N-K)
Problem p03087 (python)

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

AC_list = [0]*(N+1)
for i in range(N):
    if S[i:i+2] == "AC":
        AC_list[i+1] = AC_list[i]+1
    else:
        AC_list[i+1] = AC_list[i]

for i in range(Q):
    l, r = map(int,input().split())
    print(AC_list[r-1]-AC_list[l-1])

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

AC_list = [0]*N
for i in range(N):
    if S[i:i+2] == "AC":
        AC_list[i] = AC_list[i-1]+1
    else:
        AC_list[i] = AC_list[i-1]

for i in range(Q):
    l, r = map(int,input().split())
    print(ans[r-1]-ans[l-2])
Problem p03000 (python)

Fixed submission:
n,x=list(map(int,input().split()))
l=list(map(int,input().split()))
i=0
p=0
while i<n:
    p=p+l[i]
    if p>x:
        break
    i+=1
print(i+1)

Buggy submission (verdict: Runtime Error):
n,x=list(map(int,input().split()))
l=list(map(int,input().split()))
i=0
p=0
while p<=x or i<n:
    p=p+l[i]
    i+=1
print(i)

Buggy submission (verdict: Runtime Error):
n,x=list(map(int,input().split()))
l=list(map(int,input().split()))
i=0
p=0
while p<=x:
    p=p+l[i]
    i+=1
print(i)
Problem p03061 (python)

Fixed submission:
def gcd(a,b):
    if b==0:
        return max(a,b)
    else:
        if a%b == 0:
            return(b)
        else:
            return gcd(b,a%b)
n = int(input())
a = list(map(int,input().split()))
l=[0 for i in range(n)]
r=[0 for i in range(n)]
e=[0 for i in range(n)]
for i in range(1,n):
    l[i]=gcd(l[i-1],a[i-1])
    r[i]=gcd(r[i-1],a[n-i])
for i in range(n):
    e[i] = gcd(l[i],r[n-1-i])
print(max(e))

Buggy submission (verdict: Runtime Error):
def gcd(a,b):
    if b==0:
        return max(a,b)
    else:
        if a%b == 0:
            return(b)
        else:
            return gcd(b,a%b)
n = int(input())
a = list(map(int,input().split()))
l=[0 for i in range(n+1)]
r=[0 for i in range(n+1)]

for i in range(1,n):
    l[i]=gcd(l[i-1],a[i-1])
    r[i]=gcd(r[i-1],a[n-i])
for i in range(n):
    e[i] = gcd(l[i],r[n-1-i])
print(max(e))
Problem p03168 (python)

Fixed submission:
n = int(input())
p = list(map(float, input().split()))
q=[]
q.append([1])
for i in range(n):
    q[0].append(0)
prod = 1.0
for i in range(1,n+1):
    prod*=p[i-1]
    q.append([prod])

for i in range(1,n+1):
    for j in range(1,n+1):
        try:
            q[i].append(p[i-1]*q[i-1][j] + (1-p[i-1])*q[i-1][j-1])
        except:
            print(i)
            print(j)
        #print(q)
ans = 0.0
for i in range(0,(n-1)//2+1):
    ans+=q[n][i]
print(ans)

Buggy submission (verdict: Runtime Error):
#include<bits/stdc++.h>
using namespace std;
 
#define ll long long
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define pu push
#define pp pop_back
#define in insert
#define MOD 1000000007
#define endl "\n"
#define sz(a) (int)((a).size())
#define all(x) (x).begin(), (x).end()
#define trace(x) cerr << #x << ": " << x << " " << endl;
#define prv(a) for(auto x : a) cout << x << ' ';cout << '\n';
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define OTP(s) cout<<s<<endl;
#define FOR(i,j,k,l) for(int i=j;i<k;i+=l)
#define REP(i,j) FOR(i,0,j,1)
inline ll add(ll a, ll b){a += b; if(a >= MOD)a -= MOD; return a;}
inline ll sub(ll a, ll b){a -= b; if(a < 0)a += MOD; return a;}
inline ll mul(ll a, ll b){return (ll)((ll) a * b %MOD);}
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;

ll min(ll a,ll b)
{
    return a>b?b:a;
}
ll max(ll a,ll b)
{
    return a>b?a:b;
}

ll n;
double q[3000][3000];
double p[10000];
int main()
{
    IOS
    cin>>n;
    REP(i,n)
    {
        cin>>p[i+1];
    }
    double prod=1;

    q[0][0]=1;
    FOR(i,1,n+1,1)
    {
        prod*=0;
        q[0][i]=prod;
    }
    prod=1;
    REP(i,n)
    {
        prod*=p[i+1];
        q[i+1][0] = prod;
    }
    FOR(i,1,n+1,1)
    {
        FOR(j,1,i+1,1)
        {
            q[i][j] = p[i]*q[i-1][j] + (1-p[i])*q[i-1][j-1];
        }
    }
    // REP(i,n+1)
    // {
    //     REP(j,n+1)
    //     {
    //         cout<<q[i][j]<<" ";
    //     }
    //     cout<<endl;
    // }
    double ans = 0;
    REP(i,(n-1)/2+1)
    {
        ans+=q[n][i];
    }
    cout<<fixed<<setprecision(12)<<ans<<endl;
}
Problem p03168 (python)

Fixed submission:
n = int(input())
p = [float(x) for x in input().split()]
dp = []
for i in range(n+1):
    tp = []
    for j in range(n+1):
        tp.append(0)
    dp.append(tp)
dp[0][1] =  p[0]
dp[0][0] = 1-p[0]
for i  in range(n):
    if i<=0:
        continue
    dp[i][0] = dp[i-1][0]*(1-p[i])
    for j in range(i+1):
        dp[i][j+1] = dp[i-1][j]*p[i]
        dp[i][j+1] += dp[i-1][j+1]*(1-p[i])

k = int(n/2)+1
ans = 0
#print(dp)
for j in range(k, n+1):
    ans += dp[n-1][j]
print(ans)

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


n = int(input())
p = [float(x) for x in input().split()]
dp = np.zeros((n+1,n+1))
dp[0][1] =  p[0]
dp[0][0] = 1-p[0]
for i  in range(n):
    if i<=0:
        continue
    dp[i][0] = dp[i-1][0]*(1-p[i])
    for j in range(i+1):
        dp[i][j+1] = dp[i-1][j]*p[i]
        dp[i][j+1] += dp[i-1][j+1]*(1-p[i])

k = int(n/2)+1
ans = 0
#print(dp)
for j in range(k, n+1):
    ans += dp[n-1][j]
print(ans)
Problem p04029 (python)

Fixed submission:
def candy():
  n=int(input())
  a=0
  for i in range (1,n+1):
    a=a+i

  print(a)
    

candy()

Buggy submission (verdict: Runtime Error):
def candy():
   n=int(input())
    a=0
    for i in range (0,n)
       a=a+1
    print(a)
    
candy(10)
Problem p04030 (python)

Fixed submission:
def key():
    a=input()
    b=''
    for i in range(0,len(a)):
        if a[i]=='0':
            b+='0'
        elif a[i]=='1':
            b+='1'
        elif a[i]=='B':
            if len(b)==0:
                continue
            else:
                b=b[0:-1]
    print(b)

key()

Buggy submission (verdict: Runtime Error):
def key():
    a=input()
    b=input()
    c=input()
    d=input()
    key=[a,b,c,d]
    if key[0]=='b':
        print('')
    elif key[0]=='0':
        print('0')
    else:
        print('1')
    if key[1]=='b':
        key.pop()
    elif key[1]=='0':
        print('0')
    else:
        print('1')
    if key[2]=='b':
        key.pop()
    elif key[2]=='0':
        print('0')
    else:
        print('1')
    if key[3]=='b':
        key.pop()
    elif key[3]=='0':
        print('0')
    else:
        print('1')

key()

Buggy submission (verdict: Runtime Error):
def sig():
    key=[input()]   q
    a=key[0]
    if a =='0':
       key.append('0')
    elif a=='1':
       key.append('1')
    else:
       key.append('')
    for i in key:
        b=key[i]
        if b =='0':
           key.append('0')
        elif b=='1':   
           key.append('1')
        else:
            key.pop(i-1)

    print(key)

sig()
Problem p03308 (python)

Fixed submission:
N = int(input())

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

amax = (max(a))
amin = (min(a))

res = abs(amax-amin)
print (res)

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

amax = (max(a))
amin = (min(a))

res = abs(amax-amin)
print (res)

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

amax = (max(a))
amin = (min(a))

res = abs(amax-amin)
print res
Problem p03160 (python)

Fixed submission:
def ch_min(a, b):
    if (a > b):
        a = b
    return a


if __name__ == "__main__":
    N = int(input())
    h = list(map(int, input().split()))
    INF = 10 ** 10
    dp = [INF] * 100010
    dp[0] = 0
    for i in range(1, N):
        dp[i] = ch_min(dp[i], dp[i - 1] + abs(h[i] - h[i - 1]))
        if (i > 1):
            dp[i] = ch_min(dp[i], dp[i - 2] + abs(h[i] - h[i - 2]))
    print(dp[N - 1])

Buggy submission (verdict: Runtime Error):
def ch_min(a, b):
    if (a > b):
        a = b
    return a


if __name__ == "__main__":
    N = int(input())
    h = list(map(int, input().split()))
    INF = 10 ** 10
    dp = [INF] * 100010
    dp[0] = 0
    for i in range(N):
        dp[i + 1] = ch_min(dp[i + 1], dp[i] + abs(h[i] - h[i + 1]))
        dp[i + 2] = ch_min(dp[i + 2], dp[i] + abs(h[i] - h[i + 2]))
    print(dp[N - 1])
Problem p03161 (python)

Fixed submission:
import numpy as np
N, K = map(int, input().split())
H = np.array(list(map(int, input().split())) + [0] * (K + 2), np.int32)
INF = 10 ** 9
dp = np.array([INF] * (N + K + 2), np.int32)
dp[0] = 0

for i in range(N):
    dp[i + 1:i + K + 1] = np.minimum(dp[i + 1:i + K + 1],
                                     dp[i] + np.abs(H[i + 1:i + K + 1] - H[i]))
print(dp[N - 1])

Buggy submission (verdict: Runtime Error):
def ch_min(a, b):
    if (a > b):
        a = b
    return a


if __name__ == "__main__":
    N, K = map(int, input().split())
    h = list(map(int, input().split()))
    print(f'h = {h}')
    INF = 10 ** 10
    dp = [INF] * (10 ** 5 + 10)
    dp[0] = 0
    for i in range(N):
        for k in range(1, K + 1):
            if (i - k >= 0):
                dp[i] = ch_min(dp[i], dp[i - k] + abs(h[i] - h[i - k]))
    print(dp[N - 1])
Problem p03163 (python)

Fixed submission:
import numpy as np
import sys


def main():
    input = sys.stdin.readline
    n, W = map(int, input().split())
    w, v = [0] * n, [0] * n
    for i in range(n):
        w[i], v[i] = map(int, input().split())
    ndp = np.zeros(W + 1, dtype=np.int64)
    for w, v in zip(w, v):
        np.maximum(ndp[:-w] + v, ndp[w:], out=ndp[w:])
    print(ndp[-1])


if __name__ == "__main__":
    main()

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


def DP(i, X, w, v):
    global memo
    if (X < 0):
        return -10 ** 9
    if (memo[i, X] != -10 ** 9):
        return memo[i, X]
    result = max(DP(i + 1, X, w, v),
                 DP(i + 1, X - w[i], w, v) + v[i])
    memo[i, X] = result
    return result


def main():
    input = sys.stdin.readline
    N, W = map(int, input().split())
    w = [0] * N
    v = [0] * N
    for i in range(N):
        w[i], v[i] = map(int, input().split())
    MINUS_INF = -10 ** 9
    memo = np.full((N + 1, W + 1), MINUS_INF, dtype=np.int64)
    memo[N, :] = 0
    answer = DP(0, W, w, v)
    print(answer)


if __name__ == "__main__":
    main()

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


def DP(i, X, w, v):
    global memo
    if (X < 0):
        return -10 ** 9
    if (memo[i, X] != -10 ** 9):
        return memo[i, X]
    result = max(DP(i + 1, X, w, v),
                 DP(i + 1, X - w[i], w, v) + v[i])
    memo[i, X] = result
    return result


input = sys.stdin.readline
N, W = map(int, input().split())
w = [0] * N
v = [0] * N
for i in range(N):
    w[i], v[i] = map(int, input().split())
MINUS_INF = -10 ** 9
memo = np.full((N + 1, W + 1), MINUS_INF, dtype=np.int64)
memo[N, :] = 0
answer = DP(0, W, w, v)
print(answer)

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


def DP(i, X, w, v):
    global memo
    if (X < 0):
        return -10 ** 9
#    if (memo[i, X] != -10 ** 9):
#        return memo[i, X]
#       print('you used memo!')
    result = max(DP(i + 1, X, w, v),
                 DP(i + 1, X - w[i], w, v) + v[i])
    memo[i, X] = result
    return result


N, W = map(int, input().split())
w = [0] * N
v = [0] * N
for i in range(N):
    w[i], v[i] = map(int, input().split())
MINUS_INF = -10 ** 9
memo = np.full((N + 1, W + 1), MINUS_INF, dtype=np.int64)
memo[N, :] = 0
answer = DP(0, W, w, v)
print(answer)
Problem p03680 (python)

Fixed submission:
N = int(input())
a = [int(input()) for i in range(N)]
isFound = False
ai = 1
for i in range(1, N + 1):
    ai = a[ai - 1]
#    print(f'a{i} = {ai}')
    if (ai == 2):
        isFound = True
        print(i)
        break
if (isFound is False):
    print(-1)

Buggy submission (verdict: Runtime Error):
import sys
inputs = list(map(int, sys.stdin))
N = inputs[0]
a = inputs[1:N]
isFound = False
ai = 1
for i in range(1, N + 1):
    ai = a[ai - 1]
#    print(f'a{i} = {ai}')
    if (ai == 2):
        isFound = True
        print(i)
        break
if (isFound is False):
    print(-1)

Buggy submission (verdict: Runtime Error):
import sys
Input = list(map(int, sys.stdin))
N = Input[0]
a = Input[1:N]
isFound = False
ai = 1
for i in range(1, N + 1):
    ai = a[ai - 1]
#    print(f'a{i} = {ai}')
    if (ai == 2):
        isFound = True
        print(i)
        break
if (isFound is False):
    print(-1)
Problem p03963 (python)

Fixed submission:
N, K = map(int, input().split())
print(K * (K - 1) ** (N - 1))

Buggy submission (verdict: Runtime Error):
N, K input().split()
print(K * (K - 1) ** (N - 1))
Problem p02886 (python)

Fixed submission:
n = int(input())
d = list(map(int,input().split()))
 
dd = 0
for i in range(n):
  for j in range((i+1),n):
    if i==j:
      continue
    dd += (d[i]*d[j])
print(dd)

Buggy submission (verdict: Runtime Error):
n = int(input())
d = list(map(int,input().split()))
 
dd = 0
for i in range(n):
  for j in range((i+1),n):
    if i==j:
      continue
    dd += (d[i]*d[j])
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
d = list(map(int,input().split()))
 
dd = 0
for i in range(n):
	for j in range((i+1),n):
		if i==j:
			continue
		dd += (d[i]*d[j])
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
d = list(map(int,input().split()))
 
dd = 0
for i in range(n):
  for j in range((i+1),n):
    if i==j:
      continue
    dd += (d[i]*d[j])
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
d = list(map(int,input().split()))
 
dd = 0
for i in range(n):
  for j in range((i+1),n):
    if i==j:
      continue
    dd += (d[i]*d[j])
print(ans)

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

ans = 0
for i in range(n):
  for j in range((i+1),n):
    if i==j:
      continue
     ans += (d[i]*d[j])
print(ans)
Problem p02887 (python)

Fixed submission:
n = int(input())
s = input()
cnt = 1
for i in range(n-1):
  if(s[i]!=s[i+1]):
    cnt = cnt+1
print(cnt)

Buggy submission (verdict: Runtime Error):
n = int(input())
s = input()
cnt = 1
for i in rage(n-1):
  if(s[i]!=s[i+1]):
    cnt = cnt+1
print(cnt)