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

Fixed submission:
import sys
import numpy as np
def sinput(): return sys.stdin.readline()
def iinput(): return int(sinput())
def imap(): return map(int, sinput().split())
def fmap(): return map(float, sinput().split())
def iarr(): return list(imap())
def farr(): return list(fmap())
def sarr(): return sinput().split()

n, a = imap()
x = np.array(iarr()) - a
MAX = 50*50+1

dp = np.zeros((n+1, 2*MAX+1)).astype(int)
dp[0][MAX] = 1
for i in range(n):
    for j in range(2*MAX):
        if j-x[i] < 0 or j-x[i] > 2*MAX:
            dp[i+1][j] = dp[i][j]
        else:
            dp[i+1][j] = dp[i][j] + dp[i][j-x[i]]
print(dp[n][MAX]-1)

Buggy submission (verdict: Runtime Error):
import itertools
import numpy as np
from math import factorial
n = list(map(int, input().split()))
x = np.array(list(map(int, input().split())))

x = x - n[1]
b = len(x) - np.count_nonzero(x)
x = [i for i in x if i != 0]
x = np.sort(x)

c = 0
for i in range(1, b + 1):
    c += factorial(b) / factorial(i) / factorial(b - i)

cnt = c
for i in range(2, n[0] + 1):
    a = np.array(list(itertools.combinations(x, i)))
    if sum(a[0]) > 0:
        break
    a = np.sum(a, axis = 1)
    cnt += (c + 1) * (len(a) - np.count_nonzero(a))
            
print(int(cnt))
Problem p04045 (python)

Fixed submission:
import numpy as np

n = list(map(int, input().split()))
d = np.array(list(map(int, input().split())))
a = len(str(n[0]))
x = np.zeros(a + 1)

for i in range(a + 1):
    x[i] = (n[0] % np.power(10, a - i + 1)) // np.power(10, a - i)

i = 0
while i != a:
    i += 1
    while np.any(d == x[i]):
        x[i] += 1
        if i != a:
            x[i + 1:] = 0
        if x[i] == 10:
            x[i - 1] += 1
            x[i:] = 0
            i -= 1

ans = 0
for i in range(a + 1):
    ans += x[i] * np.power(10, a - i)

print(int(ans))

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

n = list(map(int, input().split()))
d = np.array(list(map(int, input().split())))
a = len(str(n[0]))
x = np.zeros(a + 1)

for i in range(a + 1):
    x[i] = (n[0] % np.power(10, a - i + 1)) // np.power(10, a - i)

i = 0
while i += a:
    i += 1
    if np.any(d == x[0]) and x[0] != 0:
        i = 0
    while np.any(d == x[i]):
        x[i] += 1
        x[i + (i != a):] = 0
    if x[i] == 10:
        x[i - 1] += 1
        x[i:] = 0
        
ans = 0
for i in range(a + 1):
    ans += x[i] * np.power(10, a - i)

print(int(ans))

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

n = list(map(int, input().split()))
d = np.array(list(map(int, input().split())))
a = len(str(n[0]))
x = np.zeros(a + 1)

for i in range(a + 1):
    x[i] = (n[0] % np.power(10, a - i + 1)) // np.power(10, a - i)

i = 0
while i != a + 1:
    i += 1
    while np.any(d == x[i]):
        x[i] += 1
        x[i + (i != a):] = 0
    if x[i] == 10:
        x[i - 1] += 1
        x[i:] = 0
    if np.any(d == x[0]) and x[0] != 0:
        i = 0
        
ans = 0
for i in range(a + 1):
    ans += x[i] * np.power(10, a - i)

print(int(ans))

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

n = list(map(int, input().split()))
d = np.array(list(map(int, input().split())))
a = len(str(n[0]))
x = np.zeros(a + 1)

for i in range(a + 1):
    x[i] = (n[0] % np.power(10, a - i + 1)) // np.power(10, a - i)

i = 0
while i != a + 1:
    i += 1
    if x[i] == 10:
        x[i - 1] += 1
        x[i:] = 0
        i = 0
    while np.any(d == x[i]):
        x[i] += 1
        x[i + (i != a):] = 0
    if np.any(d == x[0]) and x[0] != 0:
        i = 0
        
ans = 0
for i in range(a + 1):
    ans += x[i] * np.power(10, a - i)

print(int(ans))

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

n = list(map(int, input().split()))
d = np.array(list(map(int, input().split())))
a = len(str(n[0]))
x = np.zeros(a + 1)

for i in range(a + 1):
    x[i] = (n[0] % np.power(10, a - i + 1)) // np.power(10, a - i)

i = 1
while 1:
    while np.any(d == x[i]):
        x[i] += 1
        x[i + (i != a):] = 0
    if x[i] == 10:
        x[i - 1] += 1
        x[i:] = 0
        i = 0
    i += 1
    if np.any(d == x[0]) and x[0] != 0:
        i = 0
    if i == a:
        break
        
ans = 0
for i in range(a + 1):
    ans += x[i] * np.power(10, a - i)

print(int(ans))
Problem p02681 (python)

Fixed submission:
S = input()
T = input()
flag =0
for i in range(len(S)):
    if S[i] != T[i]:
        flag=1

if flag ==1:
    print("No")
else:
    print("Yes")

Buggy submission (verdict: Runtime Error):
N,K = map(int,input().split())
A = list(map(int,input().split()))
adj_list=[0]*N
for i in range(N):
    adj_list[i]=(A[i])
k=0
node = 1
c=[0]*N
count=1
flag=0
ROOP=[]
roopstart=0
while k<K:
    k+=1
    c[node-1]+=1
    node = adj_list[node-1]
    if c[node-1] ==1:
        if flag ==0:
            roopstart = k
            flag=1
        ROOP.append(node)
    if c[node-1] ==2:
        break
l = len(ROOP)

num = (K-l-roopstart) % (l)
print(ROOP[num])
Problem p02684 (python)

Fixed submission:
N,K = map(int,input().split())
A = list(map(int,input().split()))
adj_list=[0]*N
for i in range(N):
    adj_list[i]=(A[i])
k=0
node = 1
c=[0]*N
count=1
flag=0
ROOP=[]
roopstart=0
while k<K:
    k+=1
    c[node-1]+=1
    node = adj_list[node-1]
    if c[node-1] ==1:
        if flag ==0:
            roopstart = k
            flag=1
        ROOP.append(node)
    if c[node-1] ==2:
        break
l = len(ROOP)
if l != 0:
    num = (K-l-roopstart) % (l)
    print(ROOP[num])
else:
    print(node)

Buggy submission (verdict: Runtime Error):
N,K = map(int,input().split())
A = list(map(int,input().split()))
adj_list=[0]*N
for i in range(N):
    adj_list[i]=(A[i])
k=0
node = 1
c=[0]*N
count=1
flag=0
ROOP=[]
roopstart=0
while k<K:
    k+=1
    c[node-1]+=1
    node = adj_list[node-1]
    if c[node-1] ==1:
        if flag ==0:
            roopstart = k
            flag=1
        ROOP.append(node)
    if c[node-1] ==2:
        break
l = len(ROOP)

num = (K-l-roopstart) % (l)
print(ROOP[num])

Buggy submission (verdict: Runtime Error):
N,K = map(int,input().split())
sys.setrecursionlimit(20000000)
A = list(map(int,input().split()))
adj_list=[0]*N
for i in range(N):
    adj_list[i]=(A[i])
k=0
node = 1
c=[0]*N
count=1
flag=0
ROOP=[]
roopstart=0
while k<K:
    k+=1
    c[node-1]+=1
    node = adj_list[node-1]
    if c[node-1] ==1:
        if flag ==0:
            roopstart = k
            flag=1
        ROOP.append(node)
    if c[node-1] ==2:
        break
num = (K-len(ROOP)-roopstart) % (len(ROOP))
print(ROOP[num])

Buggy submission (verdict: Runtime Error):
N,K = map(int,input().split())
sys.setrecursionlimit(20000000)
A = list(map(int,input().split()))
adj_list=[0]*N
for i in range(N):
    adj_list[i]=(A[i])
k=0
node = 1
c=[0]*N
count=1
flag=0
ROOP=[]
roopstart=0
while k<K:
    k+=1
    c[node-1]+=1
    node = adj_list[node-1]
    if c[node-1] ==1:
        if flag ==0:
            roopstart = k
            flag=1
        ROOP.append(node)
    if c[node-1] ==2:
        break
num = (K-len(ROOP)-roopstart) % (len(ROOP))
print(ROOP[num])
Problem p02713 (python)

Fixed submission:
import math
k = int(input())
ans = 0
for i in range(1, k + 1):
    for j in range(1, k + 1):
        gcd1 = math.gcd(i, j)
        for l in range(1, k + 1):
            gcd2 = math.gcd(gcd1, l)
            ans += gcd2
print(ans)

Buggy submission (verdict: Runtime Error):
mport math
k = int(input())
ans = 0
for i in range(1, k + 1):
    for j in range(1, k + 1):
        gcd1 = math.gcd(i, j)
        for l in range(1, k + 1):
            gcd2 = math.gcd(gcd1, l)
            ans += gcd2
print(ans)
Problem p02741 (python)

Fixed submission:
k=input()
K=int(k)
array=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(array[K-1])

Buggy submission (verdict: Runtime Error):
import math
N = list(map(int,input().strip().split()))
sqrtA = math.sqrt(N[0])
sqrtB = math.sqrt(N[1])
sqrtC = math.sqrt(N[2])
def fl(x):
    digits = 10
    form = '%.'+str(digits-1)+'e'
    return float((form % x))

if fl(sqrtA) + fl(sqrtB) < fl(sqrtC):
    print("Yes")
if fl(sqrtA) + fl(sqrtB) >= fl(sqrtC):
    print("No")
Problem p02844 (python)

Fixed submission:
n = int(input())
s = input()
ans =0
for i in range(10):
    if str(i) in s:
        t = s[s.index(str(i))+1:]
        for j in range(10):
            if str(j) in t:
                u = t[t.index(str(j))+1:]
                for k in range(10):
                    if str(k) in u:
                        ans += 1
print(ans)

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


ans =0

for i in range(10):
    if str(i) in s:
        t = s[s.index(str(i))+1:]
        for j in range(10):
            if str(j) in s:
                u = t[t.index(str(j))+1:]
                for k in range(10):
                    if str(k) in u:
                        ans += 1
print(ans)

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


ans =0

for i in range(10):
    if str(i) in s:
        t = s[s.index(str(i))+1:]
        for j in range(10):
            if str(j) in s:
                u = t[t.index(str(j))+1:]
                for k in range(10):
                    if str(k) in u:
                        ans += 1
print(ans)

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


ans =0

for i in range(10):
    if str(i) in s:
        t = s[s.index(str(i))+1:]
        for j in range(10):
            if str(j) in s:
                u = t[t.index(str(j))+1:]
                for k in range(10):
                    if str(k) in u:
                        ans += 1
print(ans)
Problem p03290 (python)

Fixed submission:
d,g = map(int,input().split())
pc = [list(map(int,input().split())) for i in range(d)]

ans = float("inf")


for bit in range(1<<d):
    count = 0
    sum = 0
    nokori = set(range(1,d+1))

    for i in range(d):
        if bit & (1<<i):
            sum +=pc[i][0]*(i+1)*100+pc[i][1]
            count +=pc[i][0]
            nokori.discard(i+1)



    if sum < g:
        use = max(nokori)
        n = min(pc[use-1][0],-(-(g-sum)//(use*100)))
        count += n
        sum += n*use *100

    if sum >= g:
        ans = min(ans,count)
print(ans)

Buggy submission (verdict: Runtime Error):
D,G = map(int,input().split())
P=[]
C=[]
for _ in range(D):
    p,c = map(int,input().split())
    P.append(p)
    C.append(c)
anss=2**10
for i in range(1 << D):
    ans = 0
    summ = 0
    nokori = set(range(1,D+1))
    for j in range(D):
        if 1 & (i >> j):
            summ += P[j]*100*(j+1)+C[j]
            ans += P[j]
            nokori.discard(j+1)
    if summ < G:
        use = max(nokori)
        n = min(P[use-1],-((G-summ)//(100*use)))
        ans += n
        summ += n* use* 100

    if summ < G:
        summ+=C[use-1]

    if summ >= G:
        anss =min(ans,anss)
        
print(anss
Problem p03476 (python)

Fixed submission:
import math
Q = int(input())#numの数の個数
Query = []
maxn=0
for _ in range(Q):
    l,r = map(int,input().split())
    Query.append((l,r))
    maxn = max(maxn,r)
N = maxn
num = [0]*(N+2)#部分和を計算したい数列
def souwa(left,right,ruisekiwa):#0based,numの[left,right)間の総和を計算
   return ruisekiwa[right]-ruisekiwa[left]
def using_sqrt(N):#入力 対象の整数,出力,素数ならば1,合成数ならば1
    flag = 0
    for i in range(2,math.floor(math.sqrt(N))+1):
        if N % i == 0:
            flag = 1
            break
        else:
            continue
    if flag == 1:
        return 0
    else:
        return 1

for i in range(1,N+2,2):
    if using_sqrt(i)==1 and using_sqrt((i+1)//2)==1:
        num[i] = 1
ruisekiwa = [0]*(N+2)
ruisekiwa[0] = 0
num[1] =0
for i in range(1,N+2):#累積和の前処理
    ruisekiwa[i]=num[i-1]+ruisekiwa[i-1]

for q in Query:
    print(souwa(q[0],q[1]+1,ruisekiwa))

Buggy submission (verdict: Runtime Error):
import math
Q = int(input())#numの数の個数
Query = []
maxn=0
for _ in range(Q):
    l,r = map(int,input().split())
    Query.append((l,r))
    maxn = max(maxn,r)
N = maxn
num = [0]*(N+2)#部分和を計算したい数列
def souwa(left,right,ruisekiwa):#0based,numの[left,right)間の総和を計算
   return ruisekiwa[right]-ruisekiwa[left]
def using_sqrt(N):#入力 対象の整数,出力,素数ならば1,合成数ならば1
    flag = 0
    for i in range(2,math.floor(math.sqrt(N))+1):
        if N % i == 0:
            flag = 1
            break
        else:
            continue
    if flag == 1:
        return 0
    else:
        return 1

for i in range(1,N+2,2):
    if using_sqrt(i)==1 and using_sqrt((i+1)//2)==1:
        num[i] = 1
ruisekiwa = [0]*(N+2)
ruisekiwa[0] = 0
num[1] =0
for i in range(1,N+2):#累積和の前処理
    ruisekiwa[i]=num[i-1]+ruisekiwa[i-1]

for q in Query:
    print(souwa(q[0],q[1]+1,ruisekiwa)
Problem p03565 (python)

Fixed submission:
s = list(input())
t = list(input())

count = 0
n = 0
ans = []
flag = 0
n=len(s)-len(t)
while n >=0:
    count = 0
    for m in range(len(t)):
        if s[n+m] == "?" or s[n+m]==t[m]:
            count += 1
        else:
            break
    if count == len(t):
        flag = 1
        break
    else:
        n -= 1

if flag == 1:
    for i in range(len(s)):
        if s[i] == "?":
            s[i] = "a"
    for i in range(m+1):
        s[n+i] =t[i]
    
    for _ in s:
        print(*_,end="")

else:
    print("UNRESTORABLE")

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

count = 0
n = 0
ans = []
flag = 0
while n <len(s)-len(t)+1:
    count = 0
    for m in range(len(t)):
        if s[n+m] == "?" or s[n+m]==t[m]:
            count += 1
    if count == len(t):
        flag = 1
        ans = s[0:n+m+1]
        break
    n += 1
#print(n,m)
if flag == 1:
    for i in range(n):
        if ans[i] == "?":
            ans[i] = "a"
    for i in range(m+1):
        ans[n+i] =t[i]
    for _ in ans:
        #print(*_,end="")
else:
    print("UNRESTORABLE")
Problem p03795 (python)

Fixed submission:
N=int(input())

x=N*800
y=200*(N//15)
print(x-y)

Buggy submission (verdict: Runtime Error):
S = list(map(int,input().split()))
N=S[0]
M=S[1]
N1=0
M1=0
count = 0

if 2*N<=M:
    count = N
    N1=0
    M1=M-2*N
    count+=M1//4
elif M<2*N:
    count += M//2
print(count)

Buggy submission (verdict: Runtime Error):
S = list(map(int,input().split()))
N=S[0]
M=S[1]
N1=0
M1=0
count = 0
if N<2*M:
    count = N
    N1=0
    M1=M-2*N
    count+=M1//4
else:
    count += M//2
print(count)

Buggy submission (verdict: Runtime Error):
S = list(map(int,input().split()))
N=S[0]
M=S[1]
N1=0
M1=0
count = 0
if N<2*M:
    count += N
    N1=0
    M1=M-2*N
else:
    count += M//2
    N1 =N-M//2
    M1 =M-(M//2)*2
    
for i in range(N1):
    if N1 ==0 or M1<=1:
        break
    N1=N1-1
    M1=M1-2
    count += 1
if N1==0:
    for i in range(M1):
        if M1>=4:
            M1 -= 4
            count += 1
        if M1<4:
            break
print(count)
Problem p03844 (python)

Fixed submission:
L = list(input().split())
A=int(L[0])
B=int(L[2])
if L[1]=="+":
    print(A+B)
elif L[1]=="-":
    print(A-B)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int,input().split()))
C = [0]*N
a=0
def line(A,N):
    for i in range(N):
        C[A[i]] += 1
    if C[0] == 1:
        if N % 2==1:
            return pow(2,(N-1)//2)
        else:
            return 0
    for i in range(N):
        if C[i] != 2 and C[i]>=1:
            return 0
        elif C[i]==0:
            continue
    return pow(2,(N-1)//2)
a=line(A,N)
print(a%(pow(10,9)+7))

Buggy submission (verdict: Runtime Error):
N = int(input())
T = list(map(int,input().split()))
M = int(input())
grid = []
for i in range(M):
    data = list(map(int,input().split()))
    grid.append(data)
fsum = sum(T)

for i in range(M):
    dsum = 0
    dsum = fsum - T[i] + grid[i][1]
    print(dsum)
Problem p03845 (python)

Fixed submission:
N = int(input())
T = list(map(int,input().split()))
M = int(input())
grid = []

for i in range(M):
    data = list(map(int,input().split()))
    grid.append(data)
fsum = sum(T)
for i in range(M):
##    print("gridi0="+str(grid[i][0]))
##    print("grioi1="+str(grid[i][1]))
##    print("T="+str(T[grid[i][0]-1]))
    dsum = fsum - T[grid[i][0]-1] + grid[i][1]
    print(dsum)

Buggy submission (verdict: Runtime Error):
N = int(input())
T = list(map(int,input().split()))
M = int(input())
grid = []
for i in range(M):
    data = list(map(int,input().split()))
    grid.append(data)
fsum = sum(T)

for i in range(M):
    dsum = 0
    dsum = fsum - T[i] + grid[i][1]
    print(dsum)
Problem p02920 (python)

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

S.sort()

parent = [S.pop()]
rest = S
for _ in range(N):
	n_parent = []
	n_rest = []

	for p in parent[::-1]:
		while rest:
			x = rest.pop()
			if x < p:
				n_parent.append(x)
				break
			else:
				n_rest.append(x)
	parent += n_parent
	parent.sort()
	rest = rest + n_rest[::-1]

if len(parent) == (2**N):
	print("Yes")
else:
	print('No')

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

S.sort()

parent = [S.pop()]
rest = S
for _ in range(N):
	n_parent = []
	n_rest = []

	for p in parent[::-1]:
		while rest:
			x = rest.pop()
			if x < p:
				n_parent.append(x)
				break
			else:
				n_rest.append(x)
	parent += n_parent
	parent.sort()
	rest = rest + n_rest[::-1]

if len(parent) == (2**N):
	pritn("Yes")
else:
	print('No')

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

S.sort()

parent = [S.pop()]
rest = S
for _ in range(N):
	n_parent = []
	n_rest = []

	for p in parent[::-1]:
		while rest:
			x = rest.pop()
			if x < p:
				next_parent.append(x)
				break
			else:
				next_rest.append(x)
	parent += next_parent
	parent.sort()
	rest = rest + next_rest[::-1]

if len(parent) == (2**N):
	pritn("Yes")
else:
	print('No')
Problem p02945 (python)

Fixed submission:
a, b = map(int, input().split())
 
m = a+b
if m<a*b:
    m = a*b
if m<a-b:
    m=a-b
print(m)

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

m = a+b
if m<a*b:
  m = a*b:
if m<a-b:
  m=a-b
print(m)
Problem p03280 (python)

Fixed submission:
a, b = map(int, input().split())

print(a*b-a-b+1)

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

print(a*b-a-b+1)
Problem p03284 (python)

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

if n%k!=0:
	print(1)
else:
	print(0)

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

if n%k!=0:
	print(1)
else:
	pritn(0)

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

if n%k!=0:
	print(0)
else:
	pritn(1)

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

if n%k==0:
	print(0)
else:
	pritn(1)

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

if n%0==0:
	print(0)
else:
	print(1)
Problem p03292 (python)

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

A.sort()
print(abs(A[1]-A[0])+ abs(A[2]-A[1]))

Buggy submission (verdict: Runtime Error):
// B103.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
	int a[3];
	cin >> a[2] >> a[1] >> a[0];
	sort(a, a + 3);
	cout << abs(a[0] - a[1]) + abs(a[1] - a[2]) << endl;

	return 0;
}
Problem p03293 (python)

Fixed submission:
S = list(input())
T = list(input())

for i in range(len(S)):
	tmp = S[i:] + S[:i]
	if T == tmp:
		print('Yes')
		exit()
print('No')

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

for i in range(len(S)):
	tmp = S[i:] + [:i]
	if T == tmp:
		print('Yes')
		break
print('No')

Buggy submission (verdict: Runtime Error):
import collections

S = list(input())
T = list(input())

for i in range(len(S)):
	tmp = S[i:] + [:i]
	if T == tmp:
		print('Yes')
		break
print('No')
Problem p02741 (python)

Fixed submission:
li=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
k=int(input())
print(li[k-1])

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

print(li[k-1])
Problem p03146 (python)

Fixed submission:
s=int(input())
a=[]
a.append(s)

while 1:
    if s%2==0:
        s=s/2
        a.append(s)
    else:
        s=3*s+1
        a.append(s)
    if len(a)!=len(set(a)):
        print(len(a))
        exit()

Buggy submission (verdict: Runtime Error):
a=[]
a.append(s)

while 1:
    if s%2==0:
        s=s/2
        a.append(s)
    else:
        s=3*s+1
        a.append(s)
    if len(a)!=len(set(a)):
        print(len(a))
        exit()
Problem p03244 (python)

Fixed submission:
import collections
n=int(input())
v=list(map(int,input().split()))

li1=[]
li2=[]

for i in range(n):
    if i%2==0:
        li1.append(v[i])
    else:
        li2.append(v[i])

li1=collections.Counter(li1).most_common()
li2=collections.Counter(li2).most_common()

if li1[0][0]!=li2[0][0]:
    print(n-li1[0][1]-li2[0][1])
else:
    if len(li1)==1 and len(li2)==1:
        print(n//2)
    elif len(li1)==1:
        print(n-li1[0][1]-li2[1][1])
    elif len(li2)==1:
        print(n-li1[1][1]-li2[0][1])
    else:
        print(min(n-li1[0][1]-li2[1][1],n-li1[1][1]-li2[0][1]))

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

li1=[]
li2=[]

for i in range(n):
    if i%2==0:
        li1.append(v[i])
    else:
        li2.append(v[i])

li1=collections.Counter(li1).most_common()
li2=collections.Counter(li2).most_common()

if li1[0][0]!=li2[0][0]:
    print(n-li1[0][1]-li2[0][1])
else:
    if len(li1)==1 and len(li2)==1:
        print(n//2)
    elif len(li1)==1:
        print(n-li1[0][1]-li2[1][1])
    elif len(li2)==1:
        print(n-li1[1][1]-li2[0][1])
    else:
        print(min(n-li1[0][1]-li2[1][1]),n-li1[1][1]-li2[0][1])
Problem p03361 (python)

Fixed submission:
h,w=map(int,input().split())
s=[]
s.append("."*(w+2))

for i in range(h):
    s.append("."+input()+".")
    
s.append("."*(w+2))

for i in range(1,h+1):
    for j in range(1,w+1):
        #print(i,j)
        if s[i][j]=="#":
            if s[i][j+1]=="#" or s[i][j-1]=="#" or s[i+1][j]=="#" or s[i-1][j]=="#":
                pass
            else:
                print("No")
                exit()
        

print("Yes")

Buggy submission (verdict: Runtime Error):
h,w=map(int,input().split())
s=[]
s.append("."*(h+2))

for i in range(w):
    s.append("."+input()+".")
    
s.append("."*(h+2))

for i in range(1,w+1):
    for j in range(1,h+1):
        #print(i,j)
        if s[i][j]=="#":
            if s[i][j+1]=="#" or s[i][j-1]=="#" or s[i+1][j]=="#" or s[i-1][j]=="#":
                pass
            else:
                print("No")
                exit()
        

print("Yes")
Problem p03543 (python)

Fixed submission:
n=input()

if n[0]==n[1]==n[2] or n[1]==n[2]==n[3]:
    print("Yes")
else:
    print("No")

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

if n[0]==n[1]==n[2] or n[1]==n[2]==n[3] or n[2]==n[3]==n[4] or n[0]==n[1]==n[2]==n[3]:
    print("Yes")
else:
    print("No")
Problem p03578 (python)

Fixed submission:
import collections

n=int(input())
d=list(map(int,input().split()))
d=collections.Counter(d)
m=int(input())
t=list(map(int,input().split()))
t=collections.Counter(t)


for i in t:
    if t[i]>d[i]:
        print("NO")
        exit()
print("YES")

Buggy submission (verdict: Runtime Error):
import collections

n=int(input())
d=list(map(int,input().split()))
li=collections.Counter(d)
m=int(input())
t=list(map(int,input().split()))
co=[0]*200001

for i in t:
    if (li[i]-co[i])>0:
        co[i]+=1
    else:
        print("NO")
        exit()

print("YES")
Problem p03633 (python)

Fixed submission:
import fractions

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

n=int(input())
ans=0
ans=int(input())
if n==1:
    print(ans)
    exit()

for i in range(n-1):
    t=int(input())
    ans=lcm(ans,t)

print(ans)

Buggy submission (verdict: Runtime Error):
import math

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

n=int(input())
ans=0
ans=int(input())
if n==1:
    print(ans)
    exit()

for i in range(n-1):
    t=int(input())
    ans=lcm(ans,t)

print(ans)