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

Fixed submission:
import numpy
N = int(input())
i = int(numpy.sqrt(2*N))

if i * (i+1) == 2 * N:
    print('Yes')
    print(i+1)
    S = [[] for k in range(i+1)]
    k = 1
    for now in range(0, i+1):
        for now2 in range(now+1, i+1):
            S[now].append(k)
            S[now2].append(k)
            k += 1
    for j in range(i+1):
        print(i, end = ' ')
        values = map(str, S[j])
        print(' '.join(values))
else:
    print('No')

Buggy submission (verdict: Runtime Error):
import numpy as np
N = int(input())
i = int(np.sqrt(2*N))

if i * (i+1) == 2 * N:
    print('Yes')
    print(i+1)
    S = [[] for k in range(i+1)]
    now = 0
    for k in range(1, N+1):
        l = now % (i+1)
        m = (now + 1) % (i+1)
        S[l].append(k)
        S[m].append(k)
        now = m
    for j in range(i+1):
        print(i, end = ' ')
        for n in range(i):
            if n < i-1:
                print(S[j][n], end = ' ')
            else:
                print(S[j][n])
else:
    print('No')

Buggy submission (verdict: Runtime Error):
mport math
N = int(input())
i = int(math.sqrt(2*N))

if i * (i+1) == 2 * N:
    print('Yes')
    print(i+1)
    S = [[] for k in range(i+1)]
    now = 0
    for k in range(1, N+1):
        l = now % (i+1)
        m = (now + 1) % (i+1)
        S[l].append(k)
        S[m].append(k)
        now = m
    for j in range(i+1):
        print(i, end = ' ')
        for n in range(i):
            if n < i-1:
                print(S[j][n], end = ' ')
            else:
                print(S[j][n])
else:
    print('No')

Buggy submission (verdict: Runtime Error):
N = int(input())
flag = False
for i in range(1,N):
    if i * (i+1) == 2 * N:
        flag = True
        print('Yes')
        break
if not flag:
    print('No')
else:
    print(i+1)
    S = [[] for k in range(i+1)]
    now = 0
    for k in range(1, N+1):
        l = now % (i+1)
        m = (now + 1) % (i+1)
        S[l].append(k)
        S[m].append(k)
        now = m
    for j in range(i+1):
        print(i, end = ' ')
        for n in range(i):
            if n < i-1:
                print(S[j][n], end = ' ')
            else:
                print(S[j][n])
Problem p03680 (python)

Fixed submission:
N = int(input())
a = [int(input()) for i in range(N)]
ch = [0] * (10**5 + 1)
numB = 1
ch[1] = numB
c = 1
while True:
    numB = a[numB-1]
    if numB == 2:
        print(c)
        break
    if ch[numB] == 1:
        print(-1)
        break
    c += 1
    ch[numB] = 1

Buggy submission (verdict: Runtime Error):
N = int(input())
a = [int(input()) for i in range(N)]
ch = [0] * (10**5 + 1)
if a[0] == 1 or a[1]  == 2:
    print(-1)
ch[1] = numB
c = 1
while True:
    numB = a[numB-1]
    if numB == 2:
        print(c)
        break
    if ch[numB] == 1:
        print(-1)
        break
    c += 1
    ch[numB] = 1

Buggy submission (verdict: Runtime Error):
N = int(input())
a = [int(input()) for i in range(N)]
ch = [0] * 10**5
ch[1] = 1

if a[0] == 1 or a[1]  == 2:
    print(-1)

numB = 1
c = 1
while True:
    numB = a[numB-1]
    if numB == 2:
        print(c)
        break
    if ch[numB] == 1:
        print(-1)
        break
    c += 1
    ch[numB] = 1
Problem p03773 (python)

Fixed submission:
A, B = map(int, input().split())
print((A + B) % 24)

Buggy submission (verdict: Runtime Error):
import numpy as np
N, M = map(int, input().split())
list_coStu = []
list_coChe = []
for i in range(N):
    list_coStu.append(list(map(int, input().split())))
for i in range(M):
    list_coChe.append(list(map(int, input().split())))

#calc distance

for iS in range(len(list_coStu)):
    coStu = np.array(list_coStu[iS])
    min_iC = 0
    d = 4 * 10**8 + 1
    for iC in range(len(list_coChe)):
        coChe = np.array(list_coChe[iC])
        dif = coChe - coStu
        dist = np.sum(np.abs(dif))
        if dist < d:
            min_iC = iC
            d = dist
    print(min_iC + 1)
Problem p03826 (python)

Fixed submission:
A, B, C, D = map(int, input().split())
print(max(A*B,C*D))

Buggy submission (verdict: Runtime Error):
N = int(input())
S = input()
x = 0
max_x = 0
for c in S:
    if c == 'I': x += 1
    else: x -= 1
    max_x = max(max_x, x)
print(max_x)
Problem p02786 (python)

Fixed submission:
def a(H):
    global ans
    global dic
    if H // 2 in dic:
        add = 2 * ans + 1
        ans = add
        dic[H] = add
    else:
        a(H//2)
        a(H//2)

H = int(input())
dic = {}
dic[1] = 1
ans = 1
if H != 1:
    a(H)
print(ans)

Buggy submission (verdict: Runtime Error):
def a(H):
    global ans
    global dic
    if H // 2 in dic:
        add = 2 * ans + 1
        ans = add
        dic[H] = add
    else:
        a(H//2)
        a(H//2)

H = int(input())
dic = {}
dic[1] = 1
ans = 1
a(H)
print(ans)

Buggy submission (verdict: Runtime Error):

def a(H):
    global ans
    global dic
    if H // 2 in dic:
        add = 2 * ans + 1
        ans = add
        dic[H] = add
    else:
        a(H//2)
        a(H//2)



H = int(input())
dic = {}
dic[1] = 1
ans = 1
a(H)
print(ans)
Problem p02882 (python)

Fixed submission:
import math
a,b,x = map(int,input().split())
full = a*a*b
ans = 0
if x == full:
    ans = 0
elif x<=full/2:
    c = (2*x)/(a*b)
    d = math.sqrt(b**2+c**2)
    cosB = (c**2+d**2-b**2)/(2*c*d)
    acosB = math.degrees(math.acos(cosB))
    ans = acosB
else:
    c = 2*x/a**2-b
    c2 = b-c
    d = math.sqrt(a**2+c2**2)
    cosA = (c2**2+d**2-a**2)/(2*c2*d)
    acosA = math.degrees(math.acos(cosA))
    ans = 90-acosA
print(ans)

Buggy submission (verdict: Runtime Error):
import math
a,b,x = map(int,input().split())
c = (2*x)/(a*b)
if c <= a:
    d = math.sqrt(b**2+c**2)
    cosB = (c**2+d**2-b**2)/(2*c*d)
    acosB = math.degrees(math.acos(cosB))
    ans = acosB
else:
    c = 2*x/a**2-b
    c2 = b-c
    d = math.sqrt(a**2+c2**2)
    cosA = (c2**2+d**2-a**2)/(2*c2*d)
    acosA = math.degrees(math.acos(cosA))
    ans = 90-acosA
print(ans)

Buggy submission (verdict: Runtime Error):
import math
a,b,x = map(int,input().split())
c = (2*x)/(a*b)
if c <= a:
    d_squared = b**2+c**2
    d = math.sqrt(b**2+c**2)
    cosB = (c**2+d_squared-b**2)/(2*c*d)
    acosB = math.degrees(math.acos(cosB))
    ans = acosB
else:
    c = 2*x/a**2-b
    c2 = b-c
    d_squared = a**2+c2**2
    d = math.sqrt(a**2+c2**2)
    cosA = (c2**2+d_squared-a**2)/(2*c2*d)
    acosA = math.degrees(math.acos(cosA))
    ans = acosA
    ans = 90-acosA
print(ans)

Buggy submission (verdict: Runtime Error):
import math
a,b,x = map(int,input().split())
c = (2*x)/(a*b)
if c <= a:
    d_squared = b**2+c**2
    d = math.sqrt(b**2+c**2)
    cosB = (c**2+d_squared-b**2)/(2*c*d)
    acosB = math.degrees(math.acos(cosB))
    ans = acosB
else:
    c = 2*x/a**2-b
    c2 = b-c
    d_squared = a**2+c2**2
    d = math.sqrt(a**2+c2**2)
    cosA = (c2**2+d_squared-a**2)/(2*c2*d)
    acosA = math.degrees(math.acos(cosA))
    ans = acosA
    ans = 90-acosA
print(ans)
Problem p03074 (python)

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

nums = []
now = 1
count = 0
for i in range(len(S)):
    if S[i] == str(now):
        count += 1
    else:
        nums.append(count)
        now = 1 - now
        count = 1
if count != 0:
    nums.append(count)
if len(nums) % 2 == 0:
    nums.append(0)

add = 2 * K + 1

sum = [0] * (len(nums)+1)

for i in range(len(nums)):
    sum[i+1] = sum[i] + nums[i]
ans = 0
for i in range(0, len(nums), 2):
    left = i
    right = min(i + add, len(nums))
    tmp = sum[right] - sum[left]
    ans = max(tmp, ans)

print(ans)

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

nums = []
now = 1
count = 0
for i in range(len(S)):
    if S[i] == str(now):
        count += 1
    else:
        nums.append(count)
        now = 1 - now
        count = 1
if count != 0:
    nums.append(count)
if len(nums) % 2 == 0:
    nums.append(0)  # ? 1を足すのでは？？

add = 2 * K + 1

sum = []
sum.append(0)
for i in range(len(nums)+1):
    sum.append(sum[i] + nums[i])

ans = 0

for i in range(len(nums),2):
    left = i
    right = min(i + add, len(nums))
    tmp = sum[right] - sum[left] 
    ans = max(tmp, ans)

print(ans)

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

nums = []
now = 1
count = 0
for i in range(len(S)):
    if S[i] == str(now):
        count += 1
    else:
        nums.append(count)
        now = 1 - now
        count = 1
if count != 0:
    nums.append(count)
if len(nums) % 2 == 0:
    nums.append(0)  # ? 1を足すのでは？？

add = 2 * k + 1

sum = []
sum.append(0)
for i in range(len(nums) + 1):
    sum[i+1] = sum[i] + nums[i]

ans = 0

for i in range(len(nums),2):
    left = i
    right = min(i + add, len(nums))
    tmp = sum[right] - sum[left] 
    ans = max(tmp, ans)

print(ans)

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

nums = []
now = 1
count = 0
for i in range(len(S)):
    if S[i] == str(now):
        count += 1
    else:
        nums.append(count)
        now = 1 - now
        count = 1
if count != 0:
    nums.append(count)
if len(nums) % 2 == 0:
    nums.append(0)  # ? 1を足すのでは？？

add = 2 * k + 1

sum = []
sum.append(0)
for i in range(len(nums) + 1):
    sum[i+1] = sum[i] + nums[i]

ans = 0

for i in range(len(nums) / 2):
    left = i
    right = min(i + add, len(nums))
    tmp = sum[right] - sum[left]
    ans = max(tmp, ans)

print(ans)
Problem p03962 (python)

Fixed submission:
a,b,c = map(int,input().split())
print(len(set([a,b,c])))

Buggy submission (verdict: Runtime Error):
a,b,c = map(int,input().split())
print(len(set(a,b,c)))
Problem p03998 (python)

Fixed submission:
from collections import deque

SA = input()
SB = input()
SC = input()

count_a = len(SA)
count_b = len(SB)
count_c = len(SC)

da = deque()
db = deque()
dc = deque()

for i in range(len(SA)):
    da.append(SA[i])
for j in range(len(SB)):
    db.append(SB[j])
for k in range(len(SC)):
    dc.append(SC[k])

turn = 0
times = count_a+count_b+count_c
for i in range(times):
    if turn == 0:
        if count_a== 0:
            print("A")
            exit()
        a = da.popleft()
        count_a -= 1
        if a == "a":
            continue
        elif a =="b":
            turn = 1
            continue
        else:
            turn = 2
            continue
    elif turn == 1:
        if count_b == 0:
            print("B")
            exit()
        b = db.popleft()
        count_b -= 1
        if b == "b":
            continue
        elif b =="a":
            turn = 0
            continue
        else:
            turn = 2
            continue
    elif turn == 2:
        if count_c == 0:
            print("C")
            exit()
        c = dc.popleft()
        count_c -=1
        if c == "c":
            continue
        elif c == "a":
            turn = 0
            continue
        else:
            turn = 1
            continue

Buggy submission (verdict: Runtime Error):
import sys
sys.stdin = open("./sample_data.txt")
input = sys.stdin.readline

######################################

from collections import deque

SA = input()
SB = input()
SC = input()

count_a = len(SA)-1
count_b = len(SB)-1
count_c = len(SC)-1

da = deque()
db = deque()
dc = deque()

for i in range(len(SA)-1):
    da.append(SA[i])
for j in range(len(SB)-1):
    db.append(SB[j])
for k in range(len(SC)-1):
    dc.append(SC[k])

turn = 0
times = count_a+count_b+count_c
for i in range(times):
    if turn == 0:
        if count_a== 0:
            print("A")
            exit()
        a = da.popleft()
        count_a -= 1
        if a == "a":
            continue
        else:
            turn = 1
            continue
    elif turn == 1:
        if count_b == 0:
            print("B")
            exit()
        b = db.popleft()
        count_b -= 1
        if b == "b":
            continue
        else:
            turn = 2
            continue
    elif turn == 2:
        if count_c == 0:
            print("C")
            exit()
        c = dc.popleft()
        count_c -=1
        if c == "c":
            continue
        else:
            turn = 0
Problem p02947 (python)

Fixed submission:
N = int(input())
A=[]
S={}
for i in range(N):
    a = list(input())
    a.sort()
    b = ''.join(a)
    if b not in S:
        S[b] = 1
    else:
        S[b] += 1


count=0
for i in S.values():
    if i==1:
        continue
    count += i*(i-1)//2
print(count)

Buggy submission (verdict: Runtime Error):
import numpy as np
import math
N = int(input())
A = [input() for i in range(N)]
a = []*N
for i in A:
    b = list(i)
    b.sort()
    a.append(b)

a.sort()
c = list(map(list, set(map(tuple, a))))
d=[]
for i in c:
    d.append(a.count(i))
count=0
for i in d:
    count += math.factorial(i) // (math.factorial(i - 2) * math.factorial(2))

print(count)
Problem p02983 (python)

Fixed submission:
L,R = map(int,input().split())
ans = (L*(L+1))%2019
if R-L >= 2019:
    print(0)
    exit()
else:
    for i in range(L,R):
        for j in range(L+1,R+1):
            if ans > (i*j)%2019:
                ans = (i*j)%2019
print(ans)

Buggy submission (verdict: Runtime Error):
import numpy as np
L,R = map(int,input().split())
ans = L*(L+1)%2019

np1 = np.array(range(L,R+1))
np2 = np.multiply.outer(np1,np1)
np3 = np2%2019
np3[0,0] = 2019
np3[R-L-1,R-L-1]=2019
print(np.amin(np3))

Buggy submission (verdict: Runtime Error):
import numpy as np
L,R = map(int,input().split())
ans = L*(L+1)%2019

np1 = np.array(range(L,R))
np2 = np.multiply.outer(np1,np1)
np3 = np2%2019
np3[0,0] = 2019
np3[R-L-1,R-L-1]=2019
print(np.amin(np3))
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())

a = int(B//C) - int((A-1)//C)
b = int(B//D) - int((A-1)//D)
c = int(B//lcm(C,D)) - int((A-1)//lcm(C, D))

count = B - (A - 1) - (a + b - c)
print(count)

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())

a = int(B/C) - int((A-1)/C)
b = int(B/D) - int((A-1)/D)
c = int(B/lcm(C,D)) - int((A-1)/lcm(C, D))

print ( B - (A - 1) - (a + b - c))
Problem p03455 (python)

Fixed submission:
a, b = map(int, input().split())
if (a*b)%2==0:
  print("Even")
else:
  print("Odd")

Buggy submission (verdict: Runtime Error):
a, b = map(int, input().split())
if (a*b%2)==0:
  return print("Even")
else:
  return print("Odd")

Buggy submission (verdict: Runtime Error):
a = int(input())
b = int(input())
if (a*b)%2==0:
  print("Even")
else:
  print("Odd")
Problem p03493 (python)

Fixed submission:
a = str(input())
b=0
if a[0]=="1":
  b+=1
if a[1]=="1":
  b+=1
if a[2]=="1":
  b+=1
print(b)

Buggy submission (verdict: Runtime Error):
a = map(str, input().split())
b=0
if a[0]="1":
  b+=1
else if a[1]="1":
  b+=1
else if a[2]="1":
  b+=1
print(b)
Problem p02975 (python)

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

eachbit=[0]*32
for i in range(N):
    bin_str = format(A[i],'032b')
#    print(bin_str)
    for j in range(1,33):
        if bin_str[-j] == '1':
            eachbit[j-1] += 1

#print(eachbit)
even = True
for e in eachbit:
    if e % 2 != 0:
        even = False

if even:
    print('Yes')
else:
    print('No')

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

eachbit=[0]*30
for i in range(N):
    bin_str = format(A[i],'030b')
#    print(bin_str)
    for j in range(31):
        if bin_str[-j] == '1':
            eachbit[j] += 1

even = True
for e in eachbit:
    if e % 2 != 0:
        even = False

if even:
    print('Yes')
else:
    print('No')
Problem p02995 (python)

Fixed submission:
import fractions
A,B,C,D=map(int,input().split())

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

BdivC=B//C
BdivD=B//D
BdivCD=B//(lcm(C,D))
AdivC=(A-1)//C
AdivD=(A-1)//D
AdivCD=(A-1)//(lcm(C,D))

ans=B-(A-1)-(BdivC-AdivC+BdivD-AdivD-BdivCD+AdivCD)

print(ans)

Buggy submission (verdict: Runtime Error):
import math
A,B,C,D=map(int,input().split())

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

BdivC=B//C
BdivD=B//D
BdivCD=B//(lcm(C,D))
AdivC=(A-1)//C
AdivD=(A-1)//D
AdivCD=(A-1)//(lcm(C,D))

"""
print(BdivC)
print(BdivD)
print(AdivC)
print(AdivD)
print(BdivCD)
print(AdivCD)
"""

ans=B-(A-1)-(BdivC-AdivC+BdivD-AdivD-BdivCD+AdivCD)

print(ans)
Problem p03136 (python)

Fixed submission:
input_angle = int(input())
input_length = input()

_length = input_length.split(' ')
length = [int(l) for l in _length]
length.sort()
sum = 0

for i in range(input_angle-1):
  sum += int(length[i])
  
if int(length[-1]) < sum:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
input_angle = int(input())
input_length = input()

_length = input_length.split(' ')
length = [int(l) for l in _length]
length.sort()
sum = 0

for i in range(input_angle-1):
  sum += int(length[i])
  
if int(length[-1]) < sum:
  print('Yes')
else:

Buggy submission (verdict: Runtime Error):
input_angle = int(input())
input_length = input()

_length = input_length.split(' ')
length = [int(l) for l in _length]
length.sort()
sum = 0

for i in range(input_angle-1):
  sum += int(length[i])
  
if int(length[-1]) < sum:
  print('Yes')
else:

Buggy submission (verdict: Runtime Error):
input_angle = int(input())
input_length = input()

_length = input_length.split(' ')
length = [int(l) for l in _length]
length.sort()
sum = 0

for i in range(input_angle-2):
  sum += int(length[i])
  
if int(length[-1]) < sum:
  print('Yes')
else:

Buggy submission (verdict: Runtime Error):
input_angle = int(input())
input_length = int(input())

length = input_length.split(' ')
length.sort()
sum = 0

for i in range(input_angle-1):
  sum += length[i]
  
if sum > length[-1]:
  print('Yes')
else:
  print('No')
Problem p02882 (python)

Fixed submission:
import numpy as np

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

xlim = a*b/2*a
if x<xlim:
    theta = np.arctan(a*b*b/2/x)/np.pi*180
else:
    theta = np.arctan(2*(a*a*b-x)/a**3)/np.pi*180

print(theta)

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

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

xlim = a*b/2*a
if x<xlim:
    theta = np.arctan(a*b*b/2/x)/np.pi*180
else:
    theta = np.arctan(2*(a*a*b-x)/a**3)/np.pi*180

print(theta)
Problem p02972 (python)

Fixed submission:

n = int(input())
a = list(map(int, input().split()))
b = [0]*n
cnt = 0
ans = 0
seq = []
for i in reversed(range(1,n+1)):
    sumi = sum(b[i-1:n:i])
    if sumi % 2 == a[i-1]:
        continue
    else:
        b[i-1] = 1
        seq.append(i)
        cnt += 1
    
if ans == -1:
    print(-1)
else:
    print(cnt)
    print(' '.join(list(map(str, seq))))

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

n2 = math.ceil(n/2)
cnt = 0
ans = 0
seq = []
for i in reversed(range(n2)):
    sumi = sum([a[j] for j in range(i,n,i+1)])
    if sumi%2 != a[i-1]:
        a[i*n//i-1] += 1
        seq.append(i*n//i)
        if a[i*n//i-1] > 1:
            ans = -1
            break
        else:
            cnt += 1
    
if ans == -1:
    print(-1)
else:
    print(cnt)
    print(' '.join(list(map(str, seq))))
Problem p03069 (python)

Fixed submission:
n = int(input())
s = str(input())
#n = len(s)

bl = s.count('#')
wh = s.count('.')
cnt = wh
mincnt = cnt
for i in range(n):
    if s[i] == '#':
        cnt += 1
    else:
        cnt -= 1
    mincnt = min(mincnt, cnt)

print(mincnt)

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

cnt = 0
i = 0
while True:
    if s[i] == '.':
        break
    i += 1

if i == n:
    pass
else:
    for j in range(i, n):
        if s[j] == '#':
            cnt += 1

print(cnt)
Problem p03087 (python)

Fixed submission:
n, q = list(map(int, input().split()))
s = input()

#def f(i):
#    cnt = 0
#    for j in range(i-1):
#        #print(s[j:j+2])
#        if s[j:j+2] == 'AC':
#            cnt += 1
#    return cnt

ftab = [0]*(n+1)
cnt = 0

for i in range(n-1):
    if s[i:i+2] == 'AC':
        cnt += 1
    ftab[i+2] = cnt

for _ in range(q):
    l, r = list(map(int, input().split()))
    #print(s[l-1:r])
    print(ftab[r] - ftab[l])

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

def f(i):
    cnt = 0
    for j in range(i-1):
        #print(s[j:j+2])
        if s[j:j+2] == 'AC':
            cnt += 1
    return cnt

for _ in range(q):
    l, r = list(map(int, input().split()))
    #print(s[l-1:r])
    print(f(r) - f(l))
Problem p03140 (python)

Fixed submission:
n = int(input())
a = input()
b = input()
c = input()
cnt2 = 0
cnt3 = 0
for i in range(n):
  nsame = len(set([a[i], b[i], c[i]]))
  if nsame == 2:
    cnt2 += 1
  elif nsame == 1:
    cnt3 += 1
ans = 2*n - cnt2 - 2*cnt3
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = input()
b = input()
c = input()
cnt2 = 0
cnt3 = 0
for i in range(n):
  nsame = len(set([a[i], b[i], c[i]]))
    if nsame == 2:
      cnt2 += 1
    elif nsame == 1:
      cnt3 += 1
ans = 2*n - cnt2 - 2*cnt3
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = input()
b = input()
c = input()
cnt2 = 0
cnt3 = 0
for i in range(n):
  nsame = len(set([a[i], b[i], c[i]])):
    if nsame == 2:
      cnt2 += 1
    elif nsame == 1:
      cnt3 += 1
ans = 2*n - cnt2 - 2*cnt3
print(ans)
Problem p03141 (python)

Fixed submission:
n = int(input())
a = []
for i in range(n):
  ai, bi = list(map(int, input().split()))
  a.append((ai, bi, ai+bi))
a.sort(key = lambda x: x[2], reverse=True)
tak = 0
aok = 0
for i in range(n):
  if i%2 == 0:
    tak += a[i][0]
  else:
    aok += a[i][1]
print(tak - aok)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = []
for i in range(n):
  ai, bi = list(map(int, input()))
  a.append((ai, bi, ai+bi))
a.sort(key = lambda x: x[2], reverse=True)
tak = 0
aok = 0
for i in range(n):
  if i%2 == 0:
    tak += a[i][0]
  else:
    aok += a[i][1]
print(tak - aok)
Problem p03156 (python)

Fixed submission:
n = int(input())
a, b = list(map(int, input().split()))
p = list(map(int, input().split()))
cnta = 0
cntb = 0
cntc = 0
for pi in p:
  if pi <= a:
    cnta += 1
  elif pi <= b:
    cntb += 1
  else:
    cntc += 1
ans = min([cnta, cntb, cntc])
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
a, b = list(map(int, input().split()))
p = list(map(int, input().split()))
cnta = 0
cntb = 0
cnt c = 0
for pi in p:
  if pi <= a:
    cnta += 1
  elif pi <= b:
    cntb += 1
  else:
    cntc += 1
ans = min(cnta, cntb, cntc)
print(ans)
Problem p03160 (python)

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

dp = [10**9+1]*n
dp[0] = 0
dp[1] = dp[0] + abs(a[1]-a[0])

for i in range(2, n):
    dp[i] = min([dp[i-1]+abs(a[i]-a[i-1]), dp[i-2]+abs(a[i]-a[i-2])])

print(dp[n-1])

Buggy submission (verdict: Runtime Error):
n = int(input())
dp = [0]*(n+1)
a = list(map(int, input().split()))
  
dp[1] = abs(a[1]-a[0])
for i in range(2,n+1):
  dp[i] =  min(dp[i-2]+abs(a[i]-a[i-2]), dp[i-1]+abs(a[i]-a[i-1]))
print(dp[n])

Buggy submission (verdict: Runtime Error):
n = int(input())
dp = [0]*(n+1)
a = []
for _ in range(n):
  a.append(int(input()))
  
dp[1] = abs(a[1]-a[0])
for i in range(2,n+1):
  dp[i] =  min(dp[i-2]+abs(a[i]-a[i-2]), dp[i-1]+abs(a[i]-a[i-1]))
print(dp[n])
Problem p03163 (python)

Fixed submission:
import itertools as itr

n, wmax = list(map(int, input().split()))
w = [0]*(n+1)
v = [0]*(n+1)
for i in range(1, n+1):
    wi, vi = list(map(int, input().split()))
    w[i] = wi
    v[i] = vi
    
dp = [[0]*(wmax+1) for _ in range(n+1)]

for i, wi in itr.product(range(1, n+1), range(1, wmax+1)):
    if wi-w[i] >= 0:
        dp[i][wi] = max(dp[i-1][wi], dp[i-1][wi-w[i]]+v[i])
    else:
        dp[i][wi] = dp[i-1][wi]
            
print(dp[n][wmax])

Buggy submission (verdict: Runtime Error):
import itertools as itr
n, w = list(map(int, input().split()))
warr = [0]*(n+1)
varr = [0]*(n+1)
for i in range(n):
    wi, vi = list(map(int, input().split()))
    warr[i+1] = wi
    varr[i+1] = vi
    
dp = [[0]*(w+1) for _ in range(n+1)]

for i, j in itr.products(range(1,n+1), range(1,w+1)):
        jw = j-warr[i]
        if jw <0:
            dp[i][j] = dp[i-1][j]
            continue
        dp[i][j] = max(dp[i-1][jw] + varr[i], dp[i-1][j])
        
print(dp[n][w])