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

Fixed submission:
def d():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    # print('A = {}'.format(A))
    warps = [1]
    w = {}

    for i in range(K):
        city = A[warps[-1] - 1]
        # print('city, warps = {}, {}'.format(city, warps))
        if city in w:
            lsi = warps.index(city)
            Kn = (K - lsi) % (len(warps) - lsi)
            print(warps[lsi + Kn])
            return
        else:
            warps.append(city)
            w[city] = city
    print(warps[-1])


def dd():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    v = []
    w = {}
    now = 0
    for i in range(K):
        print('i, v, w, now = {}, {}, {}, {}'.format(i, v, w, now))
        p = A[now]
        now = p-1
        if p in w:
            j = v.index(p)
            df = i-j
            Kn = (K-i-1) % df
            p = v[j+Kn]
            break
        else:
            v.append(p)
            w[p] = p
    print(p)


##########
if __name__ == "__main__":
    d()

Buggy submission (verdict: Runtime Error):
def d():
    N, K = map(int, input().split())
    # A = list(map(int, input().split()))
    print('A = {}'.format(A))
    warps = [1]

    for i in range(K):
        city = A[warps[-1] - 1]
        # print('city, warps = {}, {}'.format(city, warps))
        if city in warps:
            loop_start_index = warps.index(city)
            loop = warps[loop_start_index:]
            K -= loop_start_index
            print(loop[K % len(loop)])
            return
        else:
            warps.append(city)
    print(warps[-1])


##########
if __name__ == "__main__":
    d()

Buggy submission (verdict: Runtime Error):
def d():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    print('A = {}'.format(A))
    warps = [1]

    for i in range(K):
        city = A[warps[-1] - 1]
        print('city, warps = {}, {}'.format(city, warps))
        if city in warps:
            loop_start_index = warps.index(city)
            loop = warps[loop_start_index:]
            K -= loop_start_index
            print(loop[K % len(loop)])
            return
        else:
            warps.append(city)
    print(warps[-1])


##########
if __name__ == "__main__":
    d()
Problem p02705 (python)

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


##########
if __name__ == "__main__":
    a()

Buggy submission (verdict: Runtime Error):
def a():
    r = int(input())
    print(2 * 3.141592653589 * r)
##########
if __name__ == "__main__":
    b()
Problem p02756 (python)

Fixed submission:
def d():
    from collections import deque
    S = deque(str(input()))
    Q = int(input())
    rvs = False

    for i in range(Q):
        q = list(input().split())

        if q[0] == '1':
            rvs = not rvs
        elif q[0] == '2':
            if q[1] == '1':
                if rvs:
                    S.append(q[2])
                else:
                    S.appendleft(q[2])
            elif q[1] == '2':
                if rvs:
                    S.appendleft(q[2])
                else:
                    S.append(q[2])
            else:
                raise ValueError(
                    'F({}) is {}, which is invalid!'.format(i, q[1]))
        else:
            raise ValueError('T({}) is {}, which is invalid!'.format(i, q[0]))

    if rvs:
        ans = list(S)[::-1]
    else:
        ans = list(S)
    print(''.join(ans))


##########
if __name__ == "__main__":
    d()

Buggy submission (verdict: Runtime Error):
def switch(S):
    tmp = S[0]
    S[0] = S[-1]
    S[-1] = tmp
    return S


def d2():
    S = str(input())
    Q = int(input())

    for i in range(Q):
        # print(S)
        q = list(input().split())

        if q[0] == '1':
            S = switch(S)
        elif q[0] == '2':
            if q[1] == '1':
                S = q[2] + S
            elif q[1] == '2':
                S = S + q[2]
            else:
                raise ValueError(
                    'F({}) is {}, which is invalid!'.format(i, q[1]))
        else:
            raise ValueError('T({}) is {}, which is invalid!'.format(i, q[0]))

    print(''.join(S))


##########
d2()
Problem p03163 (python)

Fixed submission:
def solve(N,W,wv):
    dp=[-1]*(W+1)
    dp[0]=0
    for i in range(N):
        cur_w=wv[i][0]
        cur_v=wv[i][1]
        for j in range(W-cur_w,-1,-1):
            if dp[j]==-1:
                continue
            if dp[j+cur_w]<dp[j]+cur_v:
                dp[j+cur_w]=dp[j]+cur_v
    return max(dp)


N,W=map(int,input().split())
wv=tuple(tuple(map(int,input().split())) for _ in range(N))
print(solve(N,W,wv))

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

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

    dp = np.zeros(W+1, dtype=np.int64)

    for _ in range(N):
    w, v = map(int, input().split())
    np.maximum(dp[:-w]+v, dp[w:], out=dp[w:])

    print(dp[-1])


##########
if __name__ == "__main__":
    e()
Problem p03164 (python)

Fixed submission:
def b():
    def solve(N, W, V, wv):
        dp = [10**10] * (V+1)
        dp[0] = 0

        for i in range(N):
            wi = wv[i][0]
            vi = wv[i][1]

            # 降順でやらないと複数回アイテムをカウントしちゃう（j1 + wi をやった後に j2 + wi をやると、 j1 + wi == j2 のときに2カウントになってしまう）
            for v in range(V - vi, -1, -1):
                if dp[v] == -1:
                    continue
                if dp[v+vi] > dp[v] + wi:
                    dp[v+vi] = dp[v] + wi

        light = [i for i, w in enumerate(dp) if w <= W]
        return light[-1]

    N, W = map(int, input().split())
    wv = []
    V = 0

    for i in range(N):
        w, v = map(int, input().split())
        wv.append([w, v])
        V += v

    print(solve(N, W, V, wv))

if __name__ == "__main__":
    b()

Buggy submission (verdict: Runtime Error):
def e():
    import numpy as np
 
    N, W = map(int, input().split())
 
    dp = np.zeros(W+1, dtype=np.int64)
 
    for _ in range(N):
        w, v = map(int, input().split())
        np.maximum(dp[:-w]+v, dp[w:], out=dp[w:])
 
    print(dp[-1])
 
 
##########
if __name__ == "__main__":
    e()

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

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

    dp = np.zeros(W+1, dtype=np.int64)

    for _ in range(N):
        w, v = map(int, input().split())
        # print('_, dp[:-w]+v, dp[w:], out=dp[w:] = {}, {}, {}, {}'.format(_, dp[:-w]+v, dp[w:], dp[w:]))
        np.maximum(dp[:-w]+v, dp[w:], out=dp[w:])

    print(dp[-1])


##########
if __name__ == "__main__":
    e()

Buggy submission (verdict: Runtime Error):
# はやい
def e():
    import numpy as np

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

    dp = np.zeros(W+1, dtype=np.int64)

    for _ in range(N):
        w, v = map(int, input().split())
        print('_, dp[:-w]+v, dp[w:], out=dp[w:] = {}, {}, {}, {}'.format(_,
                                                                         dp[:-w]+v, dp[w:], dp[w:]))
        np.maximum(dp[:-w]+v, dp[w:], out=dp[w:])

    print(dp[-1])


##########
if __name__ == "__main__":
    e()
Problem p02606 (python)

Fixed submission:
l, r, d = map(int, input().split())
print(r // d - (l-1) // d)

Buggy submission (verdict: Runtime Error):
n = int(input())
x = input()
fl = {}


def popcount(n):
    s = str(format(n, "b"))
    return s.count("1")


def f(n):
    cnt = 0
    while n > 0:
        n = n % popcount(n)
        if str(n) in fl:
            cnt += fl[n]
            break
        cnt += 1

    fl[n] = cnt
    return cnt


def getX(m, i):
    s = (ord(x[i]) % 2 + 1) % 2
    s = x[:i] + str(s) + x[i + 1:]
    return int(s, 2)


for i in range(n):
    rx = getX(x, i)
    print(f(rx))
Problem p03545 (python)

Fixed submission:
a,b,c,d = map(lambda x: int(x), list(input()))

def get_str(i):
    if i >= 0:
        s = "+{}".format(i)
    else:
        s = "{}".format(i)
    return s

for i in range(1 << 3):
    ai, bi, ci, di = a, b, c, d
    if (i >> 2) % 2:
        bi = -b
    if (i >> 1) % 2:
        ci = -c
    if (i >> 0) % 2:
        di = -d

    if ai+bi+ci+di == 7:
        s = ""
        s += get_str(ai)
        s += get_str(bi)
        s += get_str(ci)
        s += get_str(di)
        s += "=7"
        print(s[1::])
        break

Buggy submission (verdict: Runtime Error):
a,b,c,d = map(lambda x: int(x), list(input()))

cnt = 0
def get_str(a):
    if a >= 0:
        s = "+{}".format(a)
    else:
        s = "{}".format(a)
    return s

for i in range(1 << 4 - 1):
    if (i >> 3) % 2 == 0:
        a = -a
    if (i >> 2) % 2 == 0:
        b = -b
    if (i >> 1) % 2 == 0:
        c = -c
    if (i >> 0) % 2 == 0:
        d = -d

    if a + b + c + d  == 7:
        s = ""
        s += get_str(a)
        s += get_str(b)
        s += get_str(c)
        s += get_str(d)
        s += "=7"
        if a >= 0:
            print(s[1::])
        else:
Problem p02600 (python)

Fixed submission:

def main():
    base = 400
    increment = 200
    X = int(input())
    for i in range(8):

        if base+increment*(i) <= X and X < base+increment*(i+1):
            print(8-i)


if __name__ == '__main__':
    main()

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

def main():
    N, K = (int(x) for x in input().split(" "))
    A = [int(x) for x in input().split(" ")]
    lastest_score = np.array(A[0:K]).prod()
    for i in range(1, N-K+1):
        current_score = np.array(A[i:i+K]).prod()
        if lastest_score < current_score:
            print("Yes")
        else:
            print("No")
        lastest_score = current_score


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

Fixed submission:
def prod(arr):
    s = 0
    for x in arr:
        s += x
    return s


def main():
    N, K = (int(x) for x in input().split(" "))
    A = [int(x) for x in input().split(" ")]
    lastest_score = prod(A[0:K])
    result = ["No"] * (N-K+1)
    for i in range(1, N-K+1):
        current_score = lastest_score - A[i-1] + A[i + K-1]
        if lastest_score < current_score:
            result[i] = "Yes"
        lastest_score = current_score
    [print(x) for x in result[1:]]


if __name__ == '__main__':
    main()

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


def main():
    N, K = (int(x) for x in input().split(" "))
    A = [int(x) for x in input().split(" ")]
    lastest_score = np.array(A[0:K]).prod()
    for i in range(1, N-K+1):
        current_score = np.array(A[i:i+K]).prod()
        if lastest_score < current_score:
            print("Yes")
        else:
            print("No")
        lastest_score = current_score


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

Fixed submission:
import sys
#from collections import deque
input = sys.stdin.buffer.readline

x, y, a, b, c = map(int, input().split())
p = sorted(list(map(int,input().split())),reverse=True)
q = sorted(list(map(int,input().split())),reverse=True)
r = sorted(list(map(int,input().split())),reverse=True)
ans = p[:x]
ans[x:x] = q[:y]
ans += r
ans = sorted(ans,reverse=True)
print(sum(ans[:x+y]))

Buggy submission (verdict: Runtime Error):
import sys
#from collections import deque
input = sys.stdin.buffer.readline

x, y, a, b, c = map(int, input().split())
p = sorted(list(map(int,input().split())),reverse=True)
q = sorted(list(map(int,input().split())),reverse=True)
r = sorted(list(map(int,input().split())),reverse=True)
ans = p[:x]
ans[x:x] = q[:y]
ans=sorted(ans)
#print(ans)
i = 0
result = 0
for A in ans:
    if A < r[i]:
        result += r[i]
        if i < c:
            i += 1
        continue
    result += A
print(result)

Buggy submission (verdict: Runtime Error):
import sys
#from collections import deque
input = sys.stdin.buffer.readline

x, y, a, b, c = map(int, input().split())
p = sorted(list(map(int,input().split())),reverse=True)
q = sorted(list(map(int,input().split())),reverse=True)
r = sorted(list(map(int,input().split())),reverse=True)
ans = p[:x]
ans[x:x] = q[:y]
ans=sorted(ans,reverse=True)
i = 0
result = 0
for A in ans:
    if A < r[i]:
        result += r[i]
        i += 1
        continue
    result += A
print(result)
Problem p02747 (python)

Fixed submission:
s=input()
f=1
i=0
if len(s)%2!=0:
    print("No")
    exit()
while i<len(s):
    if s[i]=="h" and s[i+1]=="i":
        i+=2
    else:
        f=0
        break
if f:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
s=input()
f=1
i=0
while i<len(s):
    if s[i]=="h" and s[i+1]=="i":
        i+=2
    else:
        f=0
        break
if f:
    print("Yes")
else:
    print("No")
Problem p02760 (python)

Fixed submission:
a=[list(map(int,input().split())) for _ in range(3)]
n=int(input())
b=[int(input()) for _ in range(n)]
maze=[["*" for i in range(3)] for _ in range(3)]
for i in range(n):
    for j in range(3):
        for k in range(3):
            if b[i]==a[j][k]:
                maze[j][k]="#"
for i in range(3):
    f=1
    for j in range(3):
        if maze[i][j]!="#":
            f=0
            break
    if f:
        print("Yes")
        exit()
for i in range(3):
    fc=1
    for j in range(3):
        if maze[j][i]!="#":
            fc=0
            break
    if fc:
        print("Yes")
        exit()
for i in range(3):
    fa=1
    if maze[i][i]!="#":
        fa=0
        break
if fa:
    print("Yes")
    exit()
for i in range(3):
    fe=1
    if maze[i][2-i]!="#":
        fe=0
        break
if fe:
    print("Yes")
    exit()
print("No")

Buggy submission (verdict: Runtime Error):
a=[list(map(int,input().split())) for _ in range(3)]
n=int(input())
b=[int(input()) for _ in range(n)]
maze=[["*" for i in range(3)] for _ in range(3)]
for i in range(3):
    for j in range(3):
        for k in range(n):
            if b[i]==a[j][k]:
                maze[j][k]="#"
for i in range(3):
    f=1
    for j in range(3):
        if maze[i][j]!="#":
            f=0
            break
    if f:
        print("Yes")
        exit()
for i in range(3):
    fc=1
    for j in range(3):
        if maze[j][i]!="#":
            fc=0
            break
    if fc:
        print("Yes")
        exit()
for i in range(3):
    fa=1
    if maze[i][i]!="#":
        fa=0
        break
if fa:
    print("Yes")
    exit()
for i in range(3):
    fe=1
    if maze[i][2-i]!="#":
        fe=0
        break
if fe:
    print("Yes")
    exit()
print("No")
Problem p02761 (python)

Fixed submission:
n,m=map(int,input().split())
z={}
f=1
maxs=0
ii=1
ss=1
if m==0 and n==1:
    print(0)
    exit()
elif m==0 and n==2:
    print(10)
    exit()
elif m==0 and n==3:
    print(100)
    exit()
for i in range(m):
    s,c=map(int,input().split())
    if n!=1 and s==1 and c==0:
        print(-1)
        exit()
    if ii==1:
        ii=c
    elif ii!=1:
        ii=min(c,ii)
    if s not in z:
        z[s]=ii
    elif z[s]==c:
        continue
    else:
        f=0
        continue
sorted(z.items(),key=lambda x:x[1])
if not f:
    print(-1)
    exit()
for i in range(1,n+1):
    if i in z:
        print(z[i],end="")
    elif i!=1:
        print(0,end="")
    else:
        print(1,end="")

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
z={}
f=1
maxs=0
ii=1
ss=1
if m==0 and n==1:
    print(0)
    exit()
elif m==0 and n==2:
  	print(10)
    exit()
elif m==0 and n==3:
  	print(100)
    exit()
for i in range(m):
    s,c=map(int,input().split())
    if n!=1 and s==1 and c==0:
        print(-1)
        exit()
    if ii==1:
        ii=c
    elif ii!=1:
        ii=min(c,ii)
    if s not in z:
        z[s]=ii
    elif z[s]==c:
        continue
    else:
        f=0
        continue
sorted(z.items(),key=lambda x:x[1])
if not f:
    print(-1)
    exit()
for i in range(1,n+1):
    if i in z:
        print(z[i],end="")
    elif i!=1:
        print(0,end="")
    else:
        print(1,end="")
Problem p02768 (python)

Fixed submission:
mod=10**9+7
import math

def co(n,r,mod):
    x=1
    y=1
    for i in range(1,r+1):
        x=(x*(n-i+1))%mod
        y=(y*i)%mod
    return (x*pow(y,mod-2,mod))%mod
    
n,a,b=map(int,input().split())
ans=pow(2,n,mod)-1-co(n,a,mod)-co(n,b,mod)
print(max(ans%mod,0))#ansにmod取らないと無理

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
mod=10**9+7
if abs(n-m)>1:
    print(0)
    exit()
a,b=[1,1]
for i in range(1,min(n,m)+1):
    a=(a*i)%mod
if n!=m:
    b*=max(n,m)*a
    print((a*b)%mod)
else:
    b=a
    print((2*a*b)%mod)
Problem p02802 (python)

Fixed submission:
n,m=map(int,input().split())
p=[];s=[]
if m==0:
    print(0,0)
    exit()
for i in range(m):
    x,y=input().split()
    p.append(int(x))
    s.append(y)
ac=0
wa=0
t=[0]*(n+1)
wf=[0]*(n+1)
for i in range(m):
    if t[p[i]]>=1:
        continue
    elif s[i]=="WA":
        wf[p[i]]+=1
    elif s[i]=="AC":
        t[p[i]]+=1
        ac+=1
        wa+=wf[p[i]]
print(ac,wa)

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
if m==0:
    print(0,0)
    exit()
l=[]
for i in range(m):
    x,y=input().split()
    l.append([int(x),y])
l=sorted(l,key=lambda x:x[0])
ac=0
wa=0
tmp=0
t=[0]*(n+1)

for i in range(m):
    if tmp==l[i][0]:
        continue
    if l[i][1]=="WA":
        wa+=1
    elif l[i][1]=="AC":
        ac+=1
        tmp=l[i][0]
print(ac,wa)
Problem p02814 (python)

Fixed submission:
from fractions import gcd
n,m = map(int,input().split())
a = list(map(lambda x: int(x)//2,input().split()))
def lcm(x,y):
    return x*y//gcd(x,y)
def f(x):
    cnt = 0
    while x%2 == 0:
        x //= 2
        cnt += 1
    return cnt
r = set([f(i) for i in a])
if len(r) != 1:
    print(0)
    exit()
T = 1
for i in range(n):
    T = lcm(T,a[i])
ans=-(-(m//T)//2)
c=T
print(ans)

Buggy submission (verdict: Runtime Error):
from math import gcd
n,m = map(int,input().split())
a = list(map(lambda x: int(x)//2,input().split()))
def lcm(x,y):
    return x*y//gcd(x,y)
T = 1
for i in range(n):
    T = lcm(T,a[i])
ans=-(-(m//T)//2)
c=T
print(ans)
Problem p02921 (python)

Fixed submission:
s,t=input(),input() 
print((s[0]==t[0])+(s[1]==t[1])+(s[2]==t[2]))

Buggy submission (verdict: Runtime Error):
n=int(input())
print((n*(n-1))/2)

Buggy submission (verdict: Runtime Error):
s,t=input(),input() print((s[0]==t[0])+(s[1]==t[1])+(s[2]==t[2]))
Problem p02924 (python)

Fixed submission:
from sys import stdin
n=int(stdin.readline().rstrip())
print((n*(n-1))//2)

Buggy submission (verdict: Runtime Error):
n=long(input())
print((n*(n-1))/2)
Problem p02936 (python)

Fixed submission:
import sys
sys.setrecursionlimit(10**6)
input = sys.stdin.buffer.readline
n,q = map(int, input().split())
e = [[] for i in range(n)]
for i in range(n-1):
    a,b = map(int, input().split())
    e[a-1].append(b-1)
    e[b-1].append(a-1)

ans = [0]*n

for i in range(q):
    p,x = map(int,input().split()) 
    ans[p-1] += x

def dfs(i = 0, r = -1):
    for j in e[i]:
        if j != r:
            ans[j] += ans[i]
            dfs(j, i)

dfs()

print(*ans)

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10**6)
n,q = map(int, input().split())
e = [[] for i in range(n)]
for i in range(n-1):
    a,b = map(int, input().split())
    e[a-1].append(b-1)
    e[b-1].append(a-1)
ans = [0]*n
for i in range(q):
    p,x = map(int,input().split()) 
	ans[p-1] += x

def dfs(i = 0, r = -1):
    for j in e[i]:
        if j != r:
            ans[j] += ans[i]
            dfs(j, i)
dfs()
print(*ans)
Problem p02996 (python)

Fixed submission:
#ABC131D
n=int(input())
l=[]
for i in range(n):
    a,b=map(int,input().split())
    l.append([a,b])
l=sorted(l,key=lambda x:x[1])
deadline=0
tmp=0
for i in range(n):
    tmp=l[i][1]
    deadline+=l[i][0]
    if tmp<deadline:
        print("No")
        exit()
print("Yes")

Buggy submission (verdict: Runtime Error):
#ABC131D
n=int(input())
l=[]
for i in range(n):
    a,b=map(int,input().split())
    l.append([a,b])
l=sorted(l,key=lambda x:x[1])
deadline=0
tmp=0
for i in range(n):
    tmp=l[i][1]
    deadline+=l[i][0]
    if tmp<deadline
        print("No")
        exit()
print("Yes")
Problem p03061 (python)

Fixed submission:
#ABC125C
from fractions import gcd
n=int(input())
a=list(map(int,input().split()))
l,r=[0]*(n+1),[0]*(n+1)
for i in range(n):
    l[i+1]=gcd(l[i],a[i])
for i in range(n,0,-1):
    r[i-1]=gcd(r[i],a[i-1])
ans=0
for i in range(n):
    ans=max(ans,gcd(l[i],r[i+1]))
print(ans)

Buggy submission (verdict: Runtime Error):
from fractions import gcd
from functools import reduce
n=int(input())
h=[int(a) for a in input().split()]
ans=0
for i in range(n):
  del h[i]
  ans=max(reduce(gcd,h),ans)
print(ans)
Problem p03244 (python)

Fixed submission:
#ABC111C
from collections import Counter
n=int(input())
v=list(map(int,input().split()))
a=Counter(v[::2]).most_common(2)+[(0,0)]
b=Counter(v[::-2]).most_common(2)+[(0,0)]
#most_common()の引数は頻度が高い数を何番目まで表示するか
#[(0,0)]を追加しないとvがすべて同じ場合範囲外指定してしまう
if a[0][0]!=b[0][0]:
    print(n-a[0][1]-b[0][1])
else:
    print(n-max(a[0][1]+b[1][1],a[1][1]+b[0][1]))

Buggy submission (verdict: Runtime Error):
#ABC111C
from collections import Counter
n=int(input())
v=list(map(int,input().split()))
a=Counter(v[::2]).most_common(2)
b=Counter(v[::-2]).most_common(2)
#most_common()の引数は頻度が高い数を何番目まで表示するか
if a[0][0]!=b[0][0]:
    print(n-a[0][1]-b[0][1])
else:
    print(n-max(a[0][1]+b[1][1],a[1][1]+b[0][1]))

Buggy submission (verdict: Runtime Error):
#ABC111C
from collections import Counter
n=int(input())
v=list(map(int,input().split()))
a=Counter(v[::2]).most_common(2)
b=Counter(v[1::2]).most_common(2)
#most_common()の引数は頻度が高い数を何番目まで表示するか
if a[0][0]!=b[0][0]:
    print(n-a[0][1]-b[0][1])
else:
    print(n-max(a[0][1]+b[1][1],a[1][1]+b[0][1]))
Problem p03262 (python)

Fixed submission:
from fractions import gcd
from functools import reduce
n,x=map(int,input().split())
h=[abs(x-int(a)) for a in input().split()]
print(reduce(gcd,h))

Buggy submission (verdict: Runtime Error):
from fractions import gcd
n,x=map(int,input().split())
h=[abs(x-int(a)) for a in input().split()]
print(reduce(gcd,h))

Buggy submission (verdict: Runtime Error):
import math
n,x=map(int,input().split())
h=list(map(int,input().split()))
tmp=abs(x-h[0])
for i in range(n):
    ans=math.gcd(abs(x-h[i]),tmp)
print(tmp)

Buggy submission (verdict: Runtime Error):
import math
n,x=map(int,input().split())
h=list(map(int,input().split()))
tmp=abs(x-h[0])
for i in range(n):
    ans=math.gcd(abs(x-h[i]),tmp)
print(tmp)

Buggy submission (verdict: Runtime Error):
import math
n,x=map(int,input().split())
h=[int(i) for i in input().split()]
tmp=abs(x-h[0])
for q in range(1,n-1):
    tmp=math.gcd(abs(x-h[q]),tmp)
print(tmp)

Buggy submission (verdict: Runtime Error):
import math
n,x=map(int,input().split())
h=[int(i) for i in input().split()]
tmp=abs(x-h[0])
for i in range(1,n-1):
    tmp=math.gcd(abs(x-h[i]),tmp)
print(tmp)
Problem p03339 (python)

Fixed submission:
n=int(input())
s=input()
wc=[0]
ec=[0]
for i in range(n):
    if s[i]=="W":
        wc.append(wc[i]+1)
        ec.append(ec[i])
    else:
        wc.append(wc[i])
        ec.append(ec[i]+1)
ans=10**6
for i in range(n+1):
    tmp=0
    
    tmp+=wc[i]
    tmp+=ec[n]-ec[i]
    ans=min(tmp,ans)
print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
s=input()
wc=[0]
ec=[0]
for i in range(n):
    if s[i]=="W":
        wc.append(wc[i]+1)
        ec.append(ec[i])
    else:
        wc.append(wc[i])
        ec.append(ec[i]+1)
ans=10**6
for i in range(n+1):
    tmp=0
    
    tmp+=wc[i]
    tmp+=ec[n]-ec[i+1]
    ans=min(tmp,ans)
print(ans)
Problem p03437 (python)

Fixed submission:
x,y=map(int,input().split())
if x%y==0:
  print(-1)
else:
  print(x)

Buggy submission (verdict: Runtime Error):
x,y=map(int,input().split()
l=[x,y]
l=sorted(l)
if l[1]%l[0]==0:
  print(-1)
else:
  print(x)

Buggy submission (verdict: Runtime Error):
import sys
x,y=map(int,input().split())
ans=1
i=1
while ans<=10**18:
  ans=i*x
  if ans%y=!0
    print(ans)
    sys.exit()
  i+=1
print(-1)

Buggy submission (verdict: Runtime Error):
import sys
x,y=map(int,input().split())
ans=1
i=1
while ans<=10**18:
  ans=i*x
  if ans%y!=0
    print(ans)
    sys.exit()
  i+=1
print(-1)