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

Fixed submission:
import collections

# 入力
N = int(input())
c = collections.Counter(list(map(int, input().split())))

# DPテーブルを初期化
dp = [[[0.0 for k in range(310)] for j in range(310)] for i in range(310)]


for k in range(0, c[3] + 1):
    for j in range(0, c[2]+c[3]-k + 1):
        for i in range(0, c[1]+c[2]+c[3]-j-k + 1):
            if i == j == k == 0:
                continue
            dp[i][j][k] = (N+i*dp[i - 1][j][k]+j *
                           dp[i + 1][j - 1][k]+k*dp[i][j + 1][k - 1])/(i+j+k)


# 答えを得て出力
print(dp[c[1]][c[2]][c[3]])

Buggy submission (verdict: Runtime Error):
import collections

# 入力
N = int(input())
c = collections.Counter(list(map(int, input().split())))

# DPテーブルを初期化
dp = [[[None for k in range(310)] for j in range(310)] for i in range(310)]
dp[0][0][0] = 0.0

for k in range(c[3] + 1):
    for j in range(c[2]+c[3]-k + 1):
        for i in range(c[1]+c[2]+c[3]-j-k + 1):
            if i == j == k == 0:
                continue
            dp[i][j][k] = (N+i*dp[i - 1][j][k]+j *
                           dp[i + 1][j - 1][k]+k*dp[i][j + 1][k - 1])/(i+j+k)


# 答えを得て出力
print(dp[c[1]][c[2]][c[3]])
Problem p03197 (python)

Fixed submission:
n=int(input())
a=[int(input()) for _ in range(n)]
if any(x%2==1 for x in a):
    print('first')
else:
    print('second')

Buggy submission (verdict: Runtime Error):

n=input()
a=[int(input()) for _ in range(n)]
if any(x%2==1 for x in a):
    print('first')
else:
    print('second')
Problem p03219 (python)

Fixed submission:
X, Y = map(int, input().split())
print(int(X + Y/2))

Buggy submission (verdict: Runtime Error):
X, Y = map(int, input())
print(X + Y/2)
Problem p03244 (python)

Fixed submission:
import collections

n=int(input())
v=list(map(int,input().split()))
v1=collections.Counter(v[0::2]).most_common()
v2=collections.Counter(v[1::2]).most_common()
v1.append((0,0))
v2.append((0,0))

if v1[0][0]!=v2[0][0]:
    ans=len(v) - v1[0][1] - v2[0][1]
else:
    ans=min(len(v) - v1[0][1] - v2[1][1],len(v) - v1[1][1] - v2[0][1])

print(ans)

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
# print('N:{}, K:{}'.format(N, K))

if K % 2 == 0:
    print(((N-K//2)//K+1)**3+(N//K)**3)
else:
    print((N//K)**3)

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
# print('N:{}, K:{}'.format(N, K))

if K % 2 == 0:
    print(((N-K//2)//K+1)**3+(N//K)**3)
else:
    print((N//K)**3)

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
print('N:{}, K:{}'.format(N, K))

if K % 2 == 0:
    print(((N-K//2)//K+1)**3+(N//K)**3)
else:
    print((N//K)**3)

Buggy submission (verdict: Runtime Error):
import collections

n=int(input())
v=list(map(int,input().split()))
v1=collections.Counter(v[0::2])
v2=collections.Counter(v[1::2])

if len(set(v)) == 1:
    ans=len(v[1::2])
else:
    if len(v1.most_common())==1:
        v1.append((0,0))
    if len(v2.most_common())==1:
        v2.append((0,0))
    ans=min(len(v) - v1.most_common()[0][1] - v2.most_common()[0][1],len(v) - v1.most_common()[0][1] - v2.most_common()[1][1],len(v) - v1.most_common()[1][1] - v2.most_common()[0][1])

print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
v=list(map(int,input().split()))
v1=v[0::2]
v2=v[1::2]

print((len(v1)-v1.most_common()[0][1]) + (len(v2)-v2.most_common()[0][1]))
Problem p03262 (python)

Fixed submission:
from functools import reduce
from fractions import gcd

N,X=map(int,input().split())
x=[abs(int(i)-X) for i in input().split()]

print(reduce(gcd,x))

Buggy submission (verdict: Runtime Error):
from functools import reduce
from fractions import gcd

N,X=map(int,input().split())
x=[abs(i-X) for i in input().split()]

print(reduce(gcd,x))
Problem p03264 (python)

Fixed submission:
K = int(input())
print(((K+1)//2) * (K//2))

Buggy submission (verdict: Runtime Error):
K = input()
print(((K+1)//2) * (K//2))

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

print((K+1)//2 * K//2)
Problem p03282 (python)

Fixed submission:
import re

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

if not re.search(r'[^1]',S):
  print(1)
elif re.search(r'[^1]',S).start() >= K:
  print(1)
else:
  print(S[re.search(r'[^1]',S).start()])

Buggy submission (verdict: Runtime Error):
import re

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

if not re.search(r'[^1]',S).start():
  print(1)
elif re.search(r'[^1]',S).start() >= K:
  print(1)
else:
  print(S[re.search(r'[^1]',S).start()])

Buggy submission (verdict: Runtime Error):
import re

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

if re.search(r'[^1]',S).start() >= K:
  print(1)
else:
  print(S[re.search(r'[^1]',S).start()])

Buggy submission (verdict: Runtime Error):
import re

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

if re.search(r'[^1]',S).start() >= K:
  print(1)
else:
  print(S[re.search(r'[^1]',S).start()])

Buggy submission (verdict: Runtime Error):
import re

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

if re.search(r'[^1]',S).start() >= K:
  print(1)
else:
  print(S[re.search(r'[^1]',S).start()])
Problem p03285 (python)

Fixed submission:
N = int(input())
l=[]

for i in range(26):
    for j in range(16):
        l.append(i*4+j*7)

if N in l:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
N = int(intput())
l=[]

for i in range(26):
    for j in range(16):
        l.append(i*4+j*7):

if N in l:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
N = int(intput())

for i in range(26):
    for j in range(16):
        l.append(i*4+j*7):

if N in l:
    print('Yes')
else:
    print('No')
Problem p03309 (python)

Fixed submission:
N=int(input())
A=[int(i) for i in input().split()]
B=sorted([A[j]-j-1 for j in range(N)])

def median(seq):
    s = sorted(seq)
    if len(s) % 2 == 0:          # 要素が偶数個なら2つの平均
        return (s[len(s) // 2] + s[(len(s) // 2) - 1]) / 2
    else:
        return s[len(s) // 2]    # 要素が奇数個なら中央の値

b=median(B)

ans=0
for i in range(N):
    ans+=abs(A[i]-(b+i+1))

print(int(ans))

Buggy submission (verdict: Runtime Error):
N=int(input())
A=[int(i) for i in input().split()]
SA=sum(A)

sum=[(i**2+i)//2 for i in range(2*10**5)]

i=0
while sum[i]<SA:
    i+=1

# print(sum[:20])
# print(i)

ans1=0
ans2=0
for j in range(N):
    ans1+=abs(A[j]-(i-N+j))
    ans2+=abs(A[j]-(i-N+j+1))

print(min(ans1,ans2))
Problem p03316 (python)

Fixed submission:
N = input()

sn = 0
for i in N:
    sn += int(i)

if int(N)%sn ==0:
    print('Yes')
else:
    print('No')

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

sn = 0
for i in N:
    sn += i

if int(N)%sn ==0:
    print('Yes')
else:
    print('No')
Problem p03338 (python)

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

ans=0
for i in range(len(S)):
    a=set(S[:i])
    b=set(S[i:])
    if len(a&b)>ans:
    	ans=len(a&b)
print(ans)

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

ans=0
for i in range(len(S)):
    a=set(S[:i])
    b=set(S[i:])
    if a&b>ans:
    	ans=a&b
print(ans)
Problem p03352 (python)

Fixed submission:
X=int(input())
ans=1
for i in range(2,33):
    j=2
    while(i**j<=X):
        if i**j>ans:
            ans=i**j
        j+=1

print(ans)

Buggy submission (verdict: Runtime Error):
X=int(input())
ans=1
for i in range(2,33):
    j=2
    while(i**J<=X):
        if i**j>ans:
            ans=i**j
        j+=1

print(ans)
Problem p03362 (python)

Fixed submission:
import numpy as np
N = int(input())

U = 10**5
is_prime = np.full(U+1, True)
is_prime[:2] = False
for p in range(2, U+1):
    if p*p > U:
        break
    if is_prime[p]:
        is_prime[p*p::p] = False

ans = []
for c in range(11, 55556, 5):
    if is_prime[c]:
        ans.append(c)
        if len(ans) == N:
            print(*ans)
            exit()

Buggy submission (verdict: Runtime Error):
import itertools
import numpy as np
N = int(input())

U = 300000
is_prime = np.full(U+1, True)
is_prime[:2] = False
primes = set()
for p in range(2, U+1):
    if p*p > U:
        break
    if is_prime[p]:
        primes.add(p)
        is_prime[p*p::p] = False


ans = [2, 3, 5, 7, 11]
i = 13
while len(ans) < N:
    if i in primes:
        flg = True
        for p4 in itertools.combinations(ans, 4):
            if sum(p4)+i in primes:
                flg = False
        if flg:
            ans.append(i)
    i += 1
print(*ans)
Problem p03363 (python)

Fixed submission:
from collections import defaultdict
N = int(input())
A = [int(i) for i in input().split()]

d = defaultdict(int)

d[0] = 1
sum = 0
for i in range(N):
    sum += A[i]
    d[sum] += 1

ans = 0
for v in d.values():
    if v >= 2:
        ans += (v*(v-1))//2

print(ans)

Buggy submission (verdict: Runtime Error):
N, P = map(int, input().split())
odd = sum([int(i) % 2 for i in input().split()])
even = N-odd

if odd == 0:
    if P == 0:
        print(2**even)
    else:  # P==1
        print(0)
else:
    print(2**even * (2**odd//2))
Problem p03372 (python)

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

X = [0]
V = [0]
sV = [0]
Amax1 = [0]
Amax2 = [0]
for _ in range(N):
    x, v = map(int, input().split())
    X.append(x)
    V.append(v)
    sV.append(sV[-1]+v)
    Amax1.append(max(Amax1[-1], sV[-1]-x))
    Amax2.append(max(Amax2[-1], sV[-1]-2*x))
X.append(C)

ans = 0
for b in range(1, N+2):
    # O -> A -> B
    a1 = Amax2[b-1]+sV[-1]-sV[b-1]-(C-X[b])

    # O -> B -> A
    a2 = Amax1[b-1]+sV[-1]-sV[b-1]-2*(C-X[b])

    ans = max(ans, a1, a2)

print(ans)

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

X = [0]
V = [0]
sV = [0]
for _ in range(N):
    x, v = map(int, input().split())
    X.append(x)
    V.append(v)
    sV.append(sV[-1]+v)
X.append(C)

ans = 0
for a in range(N+1):
    for b in range(a+1, N+2):
        # O -> A -> B
        a1 = sV[a+1]+sV[-1]-sV[b-1]-2*X[a]-(C-X[b])

        # O -> B -> A
        a2 = sV[a+1]+sV[-1]-sV[b-1]-X[a]-2*(C-X[b])

        ans = max(ans, a1, a2)

print(ans)
Problem p03379 (python)

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

Y=sorted(X)

a1=Y[N//2-1]
a2=Y[N//2]

for i in range(N):
    if X[i]<=a1:
        print(a2)
    else:
        print(a1)

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

Y=sorted(X)

a1=Y[N//2]
a2=Y[N//2-1]

for i in range(N):
    if X[i]<=a1:
        print(a1)
    else:
        print(a2)

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

Y=sorted(X)

a1=Y[N//2]
a2=Y[N//2-1]

for i in range(N):
    if X[i]<=a1:
        print(a1)
    else:
        print(a2)
Problem p03437 (python)

Fixed submission:
X,Y=map(int,input().split())
if X%Y==0:
    print(-1)
    exit()
else:
    X2=X
    while X2<=10**18:
        X2+=X
        if X2%Y!=0:
            print(X2)
            exit()
print(-1)

Buggy submission (verdict: Runtime Error):
X,Y=map(input().split())
if X%Y==0:
    print(-1)
else:
    X2=X
    while X2>10**18:
        X2+=X
        if X2%Y!=0:
            print(X2)
            exit()
print(-1)
Problem p03502 (python)

Fixed submission:
N=input()
print('Yes' if int(N)%sum(int(i) for i in N)==0 else 'No')

Buggy submission (verdict: Runtime Error):
N=input()
print('Yes' if int(N)%sum(N)==0 else 'No')
Problem p03525 (python)

Fixed submission:
import collections
import copy
N = int(input())
D = [int(i) for i in input().split()]

C = collections.Counter(D)
if C.most_common()[0][1] >= 3:
    print(0)
    exit()

D1 = [0, 24]
m = []
for k, v in C.items():
    if v == 2:
        D1.append(k)
        D1.append(24-k)
    elif v == 1:
        m.append(k)

ans = 0
for i in range(2 ** len(m)):
    D0 = copy.deepcopy(D1)
    for j in range(len(m)):  # このループが一番のポイント
        if ((i >> j) & 1):  # 順に右にシフトさせ最下位bitのチェックを行う
            D0.append(24-m[j])
        else:
            D0.append(m[j])

    # print(D0)

    D0 = sorted(D0)
    c = 24
    for i in range(N+1):
        c = min(c, D0[i+1]-D0[i])
    ans = max(ans, c)

print(ans)

Buggy submission (verdict: Runtime Error):
import numpy as np
import collections
N = int(input())
D = [int(i) for i in input().split()]+[0, 24]

C = collections.Counter(D)
if C.most_common()[0][1] >= 3:
    print(0)
    exit()


ans = 0
for i in range(2 ** N):
    D0 = D
    for j in range(N):  # このループが一番のポイント
        if ((i >> j) & 1):  # 順に右にシフトさせ最下位bitのチェックを行う
            D0[j] = 24-D0[j]

        D0 = np.sort(np.array(D0))
        c = np.amin(np.diff(D0))
    ans = max(ans, c)

print(ans)
Problem p03557 (python)

Fixed submission:
import bisect

N=int(input())
A=sorted([int(i) for i in input().split()])
B=sorted([int(i) for i in input().split()])
C=sorted([int(i) for i in input().split()])

ans=0
for b in B:
  ans+=bisect.bisect_left(A,b)*(N-bisect.bisect_right(C,b))

print(ans)

Buggy submission (verdict: Runtime Error):
import bisect

input()
A=sorted([int(i) for i in input().split()])
B=sorted([int(i) for i in input().split()])
C=sorted([int(i) for i in input().split()])

ans=0
for b in B:
  ans+=bisect.bisect_left(A,b)*(N-bisect.bisect_right(C,b))

print(ans)

Buggy submission (verdict: Runtime Error):
import bisect

input()
A=sorted([int(i) for i in input().split()])
B=sorted([int(i) for i in input().split()])
C=sorted([int(i) for i in input().split()])

ans=0
for b in B:
  ans+=bisect.bisect_left(A,b)*bisect.bisect_right(C,b

print(ans)
Problem p03569 (python)

Fixed submission:
s = input()

# x を除いたときに回文になっていなければ達成不可能
if s.replace('x', '') != s.replace('x', '')[::-1]:
    print(-1)
    exit()

ans = 0

l = 0
r = len(s)-1

while l < r:
    if s[l] == s[r]:
        l += 1
        r -= 1
    elif s[l] == 'x':
        ans += 1
        l += 1
    elif s[r] == 'x':
        ans += 1
        r -= 1
    else:
        print('error')
        exit()
print(ans)

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

# x を除いたときに回文になっていなければ達成不可能
if s.replace('x', '') != s.replace('x', '')[::-1]:
    print(-1)
    exit()

ans = 0

l = 0
r = len(s)-1

while l != r:
    if s[l] == s[r]:
        l += 1
        r -= 1
    elif s[l] == 'x':
        ans += 1
        l += 1
    elif s[r] == 'x':
        ans += 1
        r -= 1
    else:
        print('error')
        exit()
print(ans)
Problem p03578 (python)

Fixed submission:
from collections import defaultdict

N=int(input())
d = defaultdict(int)
for D in input().split():
    d[int(D)]+=1
M=int(input())
T=[int(i) for i in input().split()]

for t in T:
    if d[t]>=1:
        d[t]-=1
    else:
        print('NO')
        exit()
print('YES')

Buggy submission (verdict: Runtime Error):
import bisect

N=int(input())
D=sorted([int(i) for i in input().split()])
M=int(input())
T=[int(i) for i in input().split()]

for t in T:
    bl=bisect.bisect_left(D,t)
    if D[bl]==t:
        del D[bl]
    else:
        print('NO')
        exit()
print('YES')
Problem p03583 (python)

Fixed submission:
N = int(input())
for h in range(1, 3501):
    for n in range(1, 3501):
        if 4*h*n-N*n-N*h!=0:
            w = N*h*n/(4*h*n-N*n-N*h)
            if w == int(w) and w >= 1:
                print(h, n, int(w))
                exit()

Buggy submission (verdict: Runtime Error):
N = int(input())
for h in range(1, 3501):
    for n in range(1, 3501):
        w = N*h*n/(4*h*n-N*n-N*h)
        if w == int(w) and w >= 1:
            print(h, n, int(w))
            exit()
Problem p03607 (python)

Fixed submission:
N=int(input())

from collections import defaultdict
d = defaultdict(int)

for _ in range(N):
    d[int(input())] += 1

ans=0
for i in d.values():
    if i%2==1:
        ans+=1

print(ans)

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

from collections import defaultdict
d = defaultdict(int)

for _ in range(N):
    d[int(input())] += 1

ams=0
for i in d.values():
    i%2==1:
    ans+=1

print(ans)
Problem p03625 (python)

Fixed submission:
N=int(input())

from collections import defaultdict
d = defaultdict(int)

for i in input().split():
    d[int(i)] += 1

d_sorted = sorted(d.items(), key=lambda x:x[0], reverse=True)

longest=0
for length, n in d_sorted:
    if n>=2 and longest!=0:
        print(longest*length)
        exit()
    elif n>=4 and longest==0:
        print(length**2)
        exit()
    elif n>=2 and longest==0:
        longest=length
print(0)

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

from collections import defaultdict
d = defaultdict(int)

for i in input().split():
    d[int(i)] += 1

d_sorted = sorted(d.items(), key=lambda x:x[0], reverse=True)

longest=0
for length, n in d_sorted:
    if n>=2 and longest!=0:
        print(longest*length)
        exit()
    elif n>=4 and logest==0:
        print(length**2)
        exit()
    elif n>=2 and longest==0:
        longest=length
print(0)
Problem p03636 (python)

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

Buggy submission (verdict: Runtime Error):
s=input()
print(s[0]+(len(s)-2)+s[-1])

Buggy submission (verdict: Runtime Error):
s=input()
print(s[0]+len(s)-2+s[-1])
Problem p03637 (python)

Fixed submission:
N=int(input())
d4=0
d2=0
for a in input().split():
    if int(a)%4==0:
        d4+=1
    elif int(a)%2==0:
        d2+=1


if N%2==1 and d2==0 and (N-1)//2<=d4:
    print('Yes')
elif 2*d4+d2>=N:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
N=int(input())
d4=0
d2=0
for a in input().split():
    if a%4==0:
        d4+=1
    elif a%2==0:
        d2+=1

if 2*d4+d2>=N:
    print('Yes')
else:
    print('No')
Problem p03651 (python)

Fixed submission:
import numpy as np
import fractions

gcd_ufunc = np.frompyfunc(fractions.gcd, 2, 1)

N, K = map(int, input().split())
A = [int(i) for i in input().split()]

G = gcd_ufunc.accumulate(A, dtype=np.object).astype(np.int)[-1]
M = max(A)

if K % G == 0 and K <= M:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')

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

N, K = map(int, input().split())
A = [int(i) for i in input().split()]

G = np.gcd.reduce(A)
M = max(A)

if K % G == 0 and K <= M:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')
Problem p03712 (python)

Fixed submission:
H,W=map(int,input().split())
print('#'*(W+2))
for _ in range(H):
    print('#'+input()+'#')
print('#'*(W+2))

Buggy submission (verdict: Runtime Error):
H,W=map(int,input().split())
print('#'*W+2)
for _ in range(H):
    print('#'+input()+'#')
print('#'*W+2)
Problem p03737 (python)

Fixed submission:
A,B,C=input().split()
print(''.join((A[0],B[0],C[0])).upper())

Buggy submission (verdict: Runtime Error):
A,B,C=input().split()
print(upper(A[0],B[0],C[0]),sep='')
Problem p03739 (python)

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

ans=10**20
for flg in (-1,1):
    c=0
    s=0
    for a in a_list:
        s+=a
        if s==0:
            c+=1
            s=flg
        if s//abs(s)!=flg:
            c+=abs(s)+1
            s=flg
        flg*=-1
    ans=min(ans,c)
print(ans)

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

c = 10**15
for i in range(2):
    A = L[i]
    if A[0] != 0:
        ans = 0
        S = A[0]
        f = A[0]//abs(A[0])
    else:
        ans = 1
        S = 1
        f = 1

    for a in A[1:]:
        S += a
        if S == 0:
            ans += 1
            S = -f
        else:
            if S/abs(S) != f*(-1):
                ans += abs(S)+1
                S = -f
        f *= -1
    c = min(ans, c)
print(c)

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

ff = -1
for i in range(n):
    if A[i] != 0:
        ff = i
        break

if A[0] != 0:
    ans = 0
    S = A[0]
    f = A[0]//abs(A[0])
else:
    if ff == -1:
        ans = 1
        S[0] = 1
        f = 1
    else:
        if ff % 2 == 0:
            ans = 1
            S[0] = 1
            f = 1
        else:
            ans = 1
            S[0] = -1
            f = -1

for a in A[1:]:
    S += a
    if S == 0:
        ans += 1
        S = -f
    else:
        if S/abs(S) != f*(-1):
            ans += abs(S)+1
            S = -f
    f *= -1
print(ans)
Problem p03759 (python)

Fixed submission:
a,b,c=map(int,input().split())
print('YES' if b-a==c-b else 'NO')

Buggy submission (verdict: Runtime Error):
a,b,c=map(int,input().split())
print('YES' if b-a=c-b else 'NO')
Problem p03800 (python)

Fixed submission:
N = int(input())
s = input()
s += s[0]

testcase = ((0, 0), (0, 1), (1, 0), (1, 1))  # 0: sheep, 1: wolf

for p0, n0 in testcase:
    p, n = p0, n0
    ans = []
    for i in range(1, N+1):
        ans.append(p)
        if n == 0 and s[i] == 'o':
            p, n = n, p
        elif n == 0 and s[i] == 'x':
            p, n = n, 1-p
        elif n == 1 and s[i] == 'o':
            p, n = n, 1-p
        elif n == 1 and s[i] == 'x':
            p, n = n, p
    if (p, n) == (p0, n0):
        a = ['S' if x == 0 else 'W' for x in ans]
        print(''.join(a))
        exit()
print(-1)

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

C = ('SS', 'SW', 'WS', 'WW')
for i in range(4):
    ans = list(C[i])
    for j in range(1, N):
        if (ans[-1] == 'S' and S[j] == 'o') or(ans[-1] == 'W' and S[j] == 'x'):
            ans.append(ans[-2])
        else:
            ans.append('S' if ans[-2] == 'W' else 'W')
    if ans[0] == ans[-1]:
        ans.remove(-1)
        if (ans[0] == 'S' and S[0] == 'o' and ans[-1] == ans[1]) or \
            (ans[0] == 'S' and S[0] == 'x' and ans[-1] != ans[1]) or \
                (ans[0] == 'W' and S[0] == 'o' and ans[-1] != ans[1]) or \
                (ans[0] == 'W' and S[0] == 'x' and ans[-1] == ans[1]):
            print(''.join(ans))
            exit()
print(-1)
Problem p03807 (python)

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

c = 0
for a in A:
    if a % 2 == 1:
        c += 1
if c % 2 == 0:
    print('YES')
else:
    print('NO')

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

c = 0
for a in A:
    if a % 2 = 1:
        c += 1
if c % 2 == 0:
    print('YES')
else:
    print('NO')
Problem p03818 (python)

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

if len(A) % 2 == 1:
    print(len(A))
else:
    print(len(A)-1)

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

if A % 2 == 1:
    print(len(A))
else:
    print(len(A)-1)
Problem p03944 (python)

Fixed submission:
xmax,ymax,N=map(int,input().split())
xmin=0
ymin=0

for i in range(N):
    x,y,a=map(int,input().split())
    if a==1:
        xmin=max(xmin,x)
    elif a==2:
        xmax=min(xmax,x)
    elif a==3:
        ymin=max(ymin,y)
    else:
        ymax=min(ymax,y)
print(max(0,(xmax-xmin))*max(0,(ymax-ymin)))

Buggy submission (verdict: Runtime Error):
xmax,ymax,N=map(int,input().split())
xmin=0
ymin=0

for i in range(N+1):
    x,y,a=map(int,input().split())
    if a==1:
        xmin=max(xmin,x)
    elif a==2:
        xmax=min(xmax,x)
    elif a==3:
        ymin=max(ymin,y)
    else:
        ymax=min(ymax,y)
print(max(0,(xmax-xmin)*(ymax-ymin)))
Problem p03964 (python)

Fixed submission:
import fractions

N=int(input())
t,a=1,1
for i in range(N):
    T,A=map(int,input().split())
    n=max(-(-a//A),-(-t//T))
    # n=max(fractions.ceil(a/A),fractions.ceil(t/T))
    t,a=n*T,n*A

print(t+a)

Buggy submission (verdict: Runtime Error):
import fractions

N=int(input())
t,a=1,1
for i in range(N):
    T,A=map(int,input().split())
    # n=max(-(-a//A),-(-t//T))
    n=max(fractions.ceil(a/A),fractions.ceil(t/T))
    t,a=n*T,n*A

print(t+a)

Buggy submission (verdict: Runtime Error):
import fractions

N=int(input())
t,a=1,1
for i in range(N):
    T,A=map(int,input().split())
    n=max(fractions.ceil(a/A),fractions.ceil(t/T))
    t,a=n*T,n*A

print(t+a)
Problem p03970 (python)

Fixed submission:
S1=input()
S2='CODEFESTIVAL2016'

ans=0
for i in range(len(S1)):
    if S1[i]!=S2[i]:
        ans+=1

print(ans)

Buggy submission (verdict: Runtime Error):
S1=input()
S2='CODEFESTIVAL2016'

ans=0
for i in len(S1):
    if S1[i]!=S2[i]:
        ans+=1

print(ans)

Buggy submission (verdict: Runtime Error):
S1=input()
S2='CODEFESTIVAL2016'

ans=0
for i in len(S):
    if S1[i]!=S2[i]:
        ans+=1

print(ans)