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

Fixed submission:
if __name__ == "__main__":
    s = input()
    data = list(s)
    while len(data):
        data.pop()
        if len(data) % 2 == 0:
            half = int(len(data) / 2)
            if data[:half] == data[half:]:
                print(len(data))
                break

Buggy submission (verdict: Runtime Error):
if __name__ == "__main__":
    s = input()
    data = list(s)
    while len(data):
         data.pop()
         if len(data) % 2 == 0:
             if data[:len(data) / 2] == data[len(data) / 2 + 1:]:
                 print(len(data) / 2)
                 break
Problem p02969 (python)

Fixed submission:
a = int(input())
print(3*(a**2))

Buggy submission (verdict: Runtime Error):
N = int(input())
a = map(int, input().split())
a = [0] + list(a)
b = [0] * (N+1)
result_str = ''

for i in range(N, 0, -1):
  i_sum = sum(b[i::i])
  if i_sum % 2 != a[i]:
    b[i] = 1
    result_str = '{} '.format(i) + result_str

print(sum(b))
print(result_str[:-1])

Buggy submission (verdict: Runtime Error):
N = int(input())
a = map(int, input().split())
a = [0] + list(a)
b = [0 for i in range(N+1)]
result_str = ''

for i in range(N, 0, -1):
  i_sum = 0
  for j in range(1, N // i + 1):
    i_sum += b[j*i]
  if i_sum % 2 != a[i]:
    b[i] = 1
    result_str = '{}　'.format(i) + result_str

print(sum(b))
if sum(b) != 0:
    print(result_str[:-1])
Problem p02969 (python)

Fixed submission:



def fun(r):
  a = 3 * r**2
  return a

r = int(input())
print(fun(r))

Buggy submission (verdict: Runtime Error):

r = int(input())
print(fun(r))

def fun(r):
  a = 3 * r**2
  return a
Problem p03633 (python)

Fixed submission:
from fractions import gcd

N = int(input())
T = [int(input()) for i in range(N)]
ans = T[0]
def lcm(a, b):
    g = gcd(a, b)
    return a * b // g

for i in range(1, N):
    ans = lcm(ans, T[i])
print(ans)

Buggy submission (verdict: Runtime Error):
from math import gcd

N = int(input())
T = [int(input()) for i in range(N)]
ans = T[0]
def lcm(a, b):
    g = gcd(a, b)
    return a * b // g

for i in range(1, N):
    ans = lcm(ans, T[i])
print(ans)
Problem p02969 (python)

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

Buggy submission (verdict: Runtime Error):
n,d=input().split()
n=int(n)
d=int(d)
a=d*2+1
if n%a==0:
    print(n//a)
else:
    print(n//a+1)
Problem p02969 (python)

Fixed submission:
r = input()
a = int(r)
print(3*a*a)

Buggy submission (verdict: Runtime Error):
N = input()
D = input()
n = int(N)
d = int(D)
k = (n+2*d)/(2*d+1)
print(k)

Buggy submission (verdict: Runtime Error):
r = input()
r = int(a)
print(3*r*r)
Problem p03161 (python)

Fixed submission:
def main():
    n, k = map(int, input().split())
    heights = list(map(int, input().split()))

    dp = [float('inf') for i in range(n)]
    dp[0] = 0
    for i in range(1, n):
        dp[i] = min(dp[j] + abs(heights[i] - heights[j]) for j in range(max(i - k, 0), i))
        # for j in range(1, k + 1):
        #     if i - j < 0:
        #         break
        #     dp[i] = min(dp[i], dp[i - j] + abs(heights[i] - heights[i - j]))

    print(dp[n - 1])


if __name__ == '__main__':
    main()

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

    dp = [float('inf') for i in range(n)]
    dp[0] = 0
    for i in range(1, n):
        # dp[i] = min(dp[j] + abs(heights[i] - heights[j]) for j in range(max(i - k, 0), i))
        dp[i] = min(dp[i - j] + abs(heights[i] - heights[i - j]) for j in range(1, k + 1))

    print(dp[n - 1])


if __name__ == '__main__':
    main()

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

    dp = [float('inf') for i in range(n)]
    dp[0] = 0
    for i in range(1, n):
        dp[i] = min(dp[j] + abs(heights[i] - heights[j]) for j in range(max(i - k, 0), i))
        # for j in range(1, k + 1):
        #     if i - j < 0:
        #         break
        #     dp[i] = min(dp[i], dp[i - j] + abs(heights[i] - heights[i - j]))

    print(dp[n - 1])


if __name__ == '__main__':
    main()
def main():
    n, k = map(int, input().split())
    heights = list(map(int, input().split()))

    dp = [float('inf') for i in range(n)]
    dp[0] = 0
    for i in range(0, n):
        for j in range(1, k + 1):
            if i + j == len(heights):
                break
            dp[i + j] = min(dp[i + j], dp[i] + abs(heights[i] - heights[i + j]))

    print(dp[n - 1])


if __name__ == '__main__':
    main()

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

    dp = [float('inf') for i in range(n)]
    dp[0] = 0
    for i in range(1, n):
        for j in range(1, k + 1):
            # if i - j < 0:
            #     break
            dp[i] = min(dp[i + j], dp[i] + abs(heights[i] - heights[i + j]))

    print(dp[n - 1])


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

Fixed submission:

def knapsack01iter(n, W, weights, values, dp):
    for i in range(1,n+1):
        for j in range(0, W+1):
            if j < weights[i-1]: # if knapsack cannot fit item i
                dp[i][j] = dp[i-1][j]
            elif j >= weights[i-1]: # knapsack can fit item i
                dp[i][j] = max(dp[i-1][j], dp[i-1][j-weights[i-1]]+values[i-1])
    
    return dp[-1][-1]
    
    
n,W = [int(x) for x in input().split()]
weights = []
values = []
for i in range(n):
    l = [int(x) for x in input().split()]
    weights += [l[0]]
    values += [l[1]]

# repeatableKnapsack(n, W, weights, values)

# dp = [[-1 for _ in range(W+1)] for _ in range(n+1)]
# res = knapsack01rec(n, W, weights, values, dp, n, W)
# print(dp)
dp = [[0 for _ in range(W+1)] for _ in range(n+1)]
res = knapsack01iter(n, W, weights, values, dp)
# print(dp)
print(res)

Buggy submission (verdict: Runtime Error):
def knapsack01rec(n, W, weights, values, dp, i, j):
    # i = up until item i, j = up until weight j
    if i == 0 or j <= 0:
        return 0

    if dp[i][j] != -1:
        return dp[i][j]

    if weights[i-1] > j:
        # weights[i] doesn't fit in knapsack
        dp[i][j] = knapsack01rec(n, W, weights, values, dp, i-1, j)
    else:
        dp[i][j] = max(
            knapsack01rec(n, W, weights, values, dp, i-1, j),
            knapsack01rec(n, W, weights, values, dp, i-1, j-weights[i-1]) + values[i-1])
    return dp[i][j]

dp = [[-1 for _ in range(W+1)] for _ in range(n+1)]
res = knapsack01rec(n, W, weights, values, dp, n, W)

print(res)
Problem p02993 (python)

Fixed submission:
S=raw_input()
f=False
for i in range(len(S)-1):
    if S[i]==S[i+1]:f=True
if f:
    print("Bad")
else:
    print("Good")

Buggy submission (verdict: Runtime Error):
S=raw_input()
f=False
for i in range(len(S)-1):
    if S[i]==S[i+1]:f=True
if f:
    print("Bad")
else:
    print("Good")
Problem p03112 (python)

Fixed submission:
#coding:utf-8
import bisect,sys
A,B,Q=map(int,raw_input().split())
s=[0]*A
t=[0]*B
for i in range(A):    
    s[i]=int(sys.stdin.readline())
for i in range(B):
    t[i]=int(sys.stdin.readline())
buf=[]
def f(x):
    sl=bisect.bisect_left(s,x)-1
    sr=sl+1
    tl=bisect.bisect_left(t,x)-1
    tr=tl+1
    ans=float("inf")
    if sl!=-1 and tl!=-1:
        A=max(s[sl],t[tl])
        B=min(s[sl],t[tl])
        L=abs(x-A)+abs(A-B)
        ans=min(ans,L)
    if sl!=-1 and tr!=len(t):
        L=abs(x-s[sl])*2 + abs(t[tr]-x)        
        ans=min(ans,L)
        ans=min(ans,abs(x-s[sl])+abs(t[tr]-x)*2)
    if tl!=-1 and sr!=len(s):
        ans=min(ans,abs(x-t[tl])*2+abs(s[sr]-x))
        ans=min(ans,abs(x-t[tl])+abs(s[sr]-x)*2)
    if tr!=len(t) and sr!=len(s):
        A=min(s[sr],t[tr])
        B=max(s[sr],t[tr])
        L=abs(A-x)+abs(B-A)
        ans=min(ans,L)
    return str(ans)

I=[0]*Q
for i in xrange(Q):
    I[i]=int(sys.stdin.readline())
r=map(f,I)
print("\n".join(r))

Buggy submission (verdict: Runtime Error):
#coding:utf-8
import bisect,math
import multiprocessing
A,B,Q=map(int,raw_input().split())
s=[0]*A
t=[0]*B
for i in range(A):
    s[i]=input()
for a in range(B):
    t[i]=input()
buf=[]
def f(x):
    sl=bisect.bisect_left(s,x)-1
    sr=bisect.bisect_left(s,x)
    tl=bisect.bisect_left(t,x)-1
    tr=bisect.bisect_left(t,x)
    ans=float("inf")
    if sl!=-1 and tl!=-1:
        A=max(s[sl],t[tl])
        B=min(s[sl],t[tl])
        L=abs(x-A)+abs(A-B)
        ans=min(ans,L)
    if sl!=-1 and tr!=len(t):
        L=abs(x-s[sl])*2 + abs(t[tr]-x)        
        ans=min(ans,L)
        ans=min(ans,abs(x-s[sl])+abs(t[tr]-x)*2)
    if tl!=-1 and sr!=len(s):
        ans=min(ans,abs(x-t[tl])*2+abs(s[sr]-x))
        ans=min(ans,abs(x-t[tl])+abs(s[sr]-x)*2)
    if tr!=len(t) and sr!=len(s):
        A=min(s[sr],t[tr])
        B=max(s[sr],t[tr])
        L=abs(A-x)+abs(B-A)
        ans=min(ans,L)
    return str(ans)

I=[0]*Q
for i in xrange(Q):
    I[i]=input()
r=map(f,I)
print("\n".join(r))

Buggy submission (verdict: Runtime Error):
#coding:utf-8
import bisect,math
import multiprocessing
A,B,Q=map(int,raw_input().split())
s=[]
t=[]
for a in range(A):
    s.append(input())
for a in range(B):
    t.append(input())
buf=[]    
def f(x):
    sl=bisect.bisect_left(s,x)-1
    sr=bisect.bisect_left(s,x)
    tl=bisect.bisect_left(t,x)-1
    tr=bisect.bisect_left(t,x)
    ans=float("inf")
    if sl!=-1 and tl!=-1:
        A=max(s[sl],t[tl])
        B=min(s[sl],t[tl])
        L=abs(x-A)+abs(A-B)
        ans=min(ans,L)
    if sl!=-1 and tr!=len(t):
        L=abs(x-s[sl])*2 + abs(t[tr]-x)        
        ans=min(ans,L)
        ans=min(ans,abs(x-s[sl])+abs(t[tr]-x)*2)
    if tl!=-1 and sr!=len(s):
        ans=min(ans,abs(x-t[tl])*2+abs(s[sr]-x))
        ans=min(ans,abs(x-t[tl])+abs(s[sr]-x)*2)
    if tr!=len(t) and sr!=len(s):
        A=min(s[sr],t[tr])
        B=max(s[sr],t[tr])
        L=abs(A-x)+abs(B-A)
        ans=min(ans,L)
    return str(ans)

p=multiprocessing.Pool(8)
I=[]
for _ in xrange(Q):
    I.append(input())
r=p.map(f,I)
print("\n".join(r))
Problem p03129 (python)

Fixed submission:
#coding:utf-8

I=raw_input()
n,k=map(int, I.split(" "))

def f(n):
    if n<3:return 0
    if n==3:return 2
    if n%2==0:return f(n-1)
    return f(n-1)+1

if f(n)>=k or k==1:
    print("YES")
else:
    print("NO")

Buggy submission (verdict: Runtime Error):
#coding:utf-8

I=raw_input()
n,k=map(int, I.split(" "))

def f(n):
    if n==3:return 2
    if n%2==0:return f(n-1)
    return f(n-1)+1

if f(n)>=k:
    print("YES")
else:
    print("NO")
Problem p03436 (python)

Fixed submission:
import Queue
def main():
    H,W=map(int,raw_input().split())
    s=[raw_input() for i in range(H)]
    q=Queue.Queue()
    visited=[[False]*W for _ in range(H)]
    dist=[[1145141919810]*W for _ in range(H)]
    visited[0][0]=True
    dist[0][0]=0
    dx=[1,0,-1,0]
    dy=[0,1,0,-1]
    q.put((0,0))

    while not q.empty():
        x,y=q.get()
        for i in range(4):  
            xx=x+dx[i]
            yy=y+dy[i]
            if (not 0<=xx<H) or (not 0<=yy<W): continue
            if s[xx][yy] == "#" :continue
            if visited[xx][yy]:continue
            visited[xx][yy]=True
            dist[xx][yy]=dist[x][y]+1
            q.put((xx,yy))
    if not visited[H-1][W-1]:
        print(-1)
        return
    use=[[False]*W for _ in range(H)]
    use[H-1][W-1]=True
    use[0][0]=True
    (x,y)=(H-1, W-1)
    while (x,y) != (0,0):
        use[x][y]=True
        mpos=(-1,-1)
        mval=1145141919
        for i in range(4):
            xx=x+dx[i]
            yy=y+dy[i]
            if (not 0<=xx<H) or (not 0<=yy<W): continue     
            if dist[xx][yy] < mval:
                mpos=(xx,yy)
                mval=dist[xx][yy]
        x,y=mpos
    cnt=0
    for x in range(H):
        for y in range(W):
            if s[x][y] == "." and not use[x][y]: cnt+=1
    print(cnt)
main()

Buggy submission (verdict: Runtime Error):
import Queue
def main():
H,W=map(int,raw_input().split())
    s=[raw_input() for i in range(H)]
    print(s)
    q=Queue.Queue()
    visited=[[False]*W for _ in range(H)]
    dist=[[1145141919810]*W for _ in range(H)]
    visited[0][0]=True
    dist[0][0]=0
    dx=[1,0,-1,0]
    dy=[0,1,0,-1]
    q.put((0,0))

    while not q.empty():
        x,y=q.get()
        for i in range(4):  
            xx=x+dx[i]
            yy=y+dy[i]
            if (not 0<=xx<H) or (not 0<=yy<W): continue
            if s[xx][yy] == "#" :continue
            if visited[xx][yy]:continue
            visited[xx][yy]=True
            dist[xx][yy]=dist[x][y]+1
            q.put((xx,yy))
    if dist[H-1][W-1]:
        print(-1)
        return
    use=[[False]*W for _ in range(H)]
    use[H-1][W-1]=True
    use[0][0]=True
    (x,y)=(H-1, W-1)
    while (x,y) != (0,0):
        use[x][y]=True
        mpos=(-1,-1)
        mval=1145141919
        for i in range(4):
            xx=x+dx[i]
            yy=y+dy[i]
            if (not 0<=xx<H) or (not 0<=yy<W): continue     
            if dist[xx][yy] < mval:
                mpos=(xx,yy)
                mval=dist[xx][yy]
        x,y=mpos
    cnt=0
    for x in range(H):
        for y in range(W):
            if s[x][y] == "." and not use[x][y]: cnt+=1
    print(cnt)
Problem p03696 (python)

Fixed submission:
#coding:utf-8
N=input()
S=raw_input()

st=[]
for s in S:
    if len(st) >= 1:
        a=st.pop()
        if a == '(' and s == ')':
            continue
        st.append(a)
    st.append(s)
migi=0
hidari=0
for s in st:
    if s == ")":migi+=1
    else: hidari+=1
print "("*migi + S + ")"*hidari

Buggy submission (verdict: Runtime Error):
#coding:utf-8
N=input()
S=raw_input()

st=[]
for s in S:
    if len(st) >= 1:
        a=st.pop()
        if a == '(' and s == ')':
            continue
        st.append(a)
    st.append(s)
migi=0
hidari=0
for s in st:
    if s == ")":migi+=1
    else: hidari+=1
print "("*migi + S + ")"*hidari
Problem p02969 (python)

Fixed submission:
r = int(input())
print(3*r**2)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = [0] + list(map(int, input().split()))
for i in range(n // 2, 0, -1):
    a[i] = sum(a[i::i]) % 2
print(sum(a))
print(*(i for i, b in enumerate(a) if b))
Problem p02981 (python)

Fixed submission:
#ABC133-A
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(input())
def S(): return list(input())
n,a,b=IL()
print(min(a*n,b))

Buggy submission (verdict: Runtime Error):
n,a,b=IL()
print(min(a*n,b))
Problem p02982 (python)

Fixed submission:
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(input())
def S(): return list(input())
n,d=IL()
X=[IL() for i in range(n)]
c=0
for i in range(n-1):
    for j in range(i+1,n):
        dis=0
        for k in range(d):
            dis+=(X[i][k]-X[j][k])**2
        if int(dis**0.5)==dis**0.5:
            c+=1
print(c)

Buggy submission (verdict: Runtime Error):
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(input())
def S(): return list(input())
n,d=IL()
X=[IL() for i in range(n)]
c=0
for i in range(n-1):
    for j in range(i+1,n):
        dis=0
        for k in range(d):
            dis+=(X[i][k]-X[j][k])**2
        if int(dis**0.5)=dis**0.5:
            c+=1
print(c)
Problem p03106 (python)

Fixed submission:
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(input())
def S(): return list(input())
a,b,k=IL()
c=[1]
for i in range(2,min(a,b)+1):
    if a%i==0 and b%i==0:
        c.append(i)
print(c[-k])

Buggy submission (verdict: Runtime Error):
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(input())
def S(): return list(input())
a,b,k=IL()
c=[]
for i in range(1,max(a,b)):
    if a%i==0 and b%i==0:
        c.append(i)
print(c[-k])
Problem p03148 (python)

Fixed submission:
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(input())
def S(): return input()
n,k=IL()
top=dict()
sub=[]
for i in range(n):
    t,d=IL()
    if t in top:
        sub.append(min(top[t],d))
        top[t]=max(top[t],d)
    else:
        top[t]=d

top=sorted(top.items(),key=lambda x:-x[1])
sub.sort(reverse=True)

rtop=[top[0][1]]
rsub=[0]
for i in range(1,len(top)):
    rtop.append(rtop[-1]+top[i][1])
for i in range(len(sub)):
    rsub.append(rsub[-1]+sub[i])

ans=0
for i in range(k):
    if i<len(rtop) and 0<=k-i-1<len(rsub):
        ans=max(ans,rtop[i]+rsub[k-i-1]+(i+1)**2)
print(ans)

Buggy submission (verdict: Runtime Error):
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(input())
def S(): return input()
n,k=IL()
top=dict()
sub=[]
for i in range(n):
    t,d=IL()
    if t in top:
        sub.append(min(top[t],d))
        top[t]=max(top[t],d)
    else:
        top[t]=d

top=sorted(top.items(),key=lambda x:-x[1])
sub.sort(reverse=True)

rtop=[top[0][1]]
rsub=[sub[0]]
for i in range(1,len(top)):
    rtop.append(rtop[-1]+top[i][1])
for i in range(1,len(sub)):
    rsub.append(rsub[-1]+sub[i])

ans=0
for i in range(k):
    if i<len(rtop) and 0<=k-i-2<len(rsub):
        ans=max(ans,rtop[i]+rsub[k-i-2]+(i+1)**2)
print(ans)

Buggy submission (verdict: Runtime Error):
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(input())
def S(): return input()
import heapq
n,k=IL()
nl=dict()
for i in range(n+1):
    nl[i]=0
l=[]
ans=[]
f=[]
el=[]
heapq.heapify(el)
s=0
for i in range(n):
    t,d=IL()
    l.append([d,t])
l.sort(reverse=True)
for i in range(k):
    t=l.pop(0)
    el.heappush(t)
    nl[t[1]]+=1
    s+=t[0]
    if t[1] not in f:
        f.append(t[1])
u=len(f)
ans.append(s+u*u)
for i in range(u,k+1):
    if len(l)==0:
        break
    while True:
        t=el.heappop(0)
        if nl[t[1]]!=1:
            nl[t[1]]-=1
            s-=nl[t[0]]
            break
    while len(l)>0:
        t=l.pop(0)
        if nl[t[1]]==0:
            nl[t[1]]+=1
            s+=t[0]
            el.heappush(t)
            break
    ans.append(s+(u+i+1)**2)
    if len(l)==0:
        break
print(max(ans))
Problem p03150 (python)

Fixed submission:
s=list(input())
k=["k","e","y","e","n","c","e"]
ans="NO"
c=0
if len(s)>=7:
    while c<7:
        if s[c]!=k[c]:
            break
        c+=1
    if c==7:
        ans="YES"
    for i in range(7-c):
        if s[-i-1]!=k[-i-1]:
            break
    else:
        ans="YES"
print(ans)

Buggy submission (verdict: Runtime Error):
s=list(input())
k=["k","e","y","e","n","c","e"]
ans="NO"
c=0
if len(s)>=7:
    while True:
        if s[c]!=k[c]:
            break
        c+=1
    if c==7:
        ans="YES"
    for i in range(7-c):
        if s[-i-1]!=k[-i-1]:
            break
    else:
        ans="YES"
print(ans)

Buggy submission (verdict: Runtime Error):
s=list(input())
k=["k","e","y","e","n","c","e"]
ans="NO"
if len(s)>=7:
    while c<7:
        if s[i]!=k[i]:
            break
        c+=1
    for i in range(7-c):
        if s[-i-1]!=k[-i-1]:
            break
    else:
        ans="YES"
print(ans)

Buggy submission (verdict: Runtime Error):
s=input()
k="keyence"
c=0
for i in range(len(s)):
    if s[i]==k[c]:
        c+=1
if c==7:
    print("YES")
else:
    print("NO")
Problem p03213 (python)

Fixed submission:
n=int(input())
f=[]
w=[0,0,0,0,0]
for i in range(2,n+1):
    c=0
    r=int(i**0.5)
    for j in range(2,r+2):
        while i%j==0:
            c+=1
            i=i//j
        if c!=0:
            f.append([j,c])
            c=0
    if i!=1:
        f.append([i,1])
f.sort()
d=[]
ans=0
if n!=1:
    cou=f[0][1]
    for i in range(1,len(f)):
        if f[i][0]==f[i-1][0]:
            cou+=f[i][1]
        else:
            d.append(cou)
            cou=1
    d.append(cou)

    for i in d:
        for j,num in enumerate([2,4,14,24,74]):
            if i>=num:
                w[j]+=1
    ans=w[4]+w[3]*(w[0]-1)+w[2]*(w[1]-1)+w[1]*(w[1]-1)*(w[0]-2)//2
print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
f=[]
w=[0,0,0,0,0]
for i in range(2,n+1):
    c=0
    r=int(i**0.5)
    for j in range(2,r+2):
        while i%j==0:
            c+=1
            i=i//j
        if c!=0:
            f.append([j,c])
            c=0
    if i!=1:
        f.append([i,1])
f.sort()
d=[]
ans=0
cou=f[0][1]
for i in range(1,len(f)):
    if f[i][0]==f[i-1][0]:
        cou+=f[i][1]
    else:
        d.append(cou)
        cou=1
d.append(cou)

for i in d:
    for j,num in enumerate([2,4,14,24,74]):
        if i>=num:
            w[j]+=1
print(w[4]+w[3]*(w[0]-1)+w[2]*(w[1]-1)+w[1]*(w[1]-1)*(w[0]-2)//2)

Buggy submission (verdict: Runtime Error):
n=int(input())
f=[]
w=[0,0,0,0,0]
for i in range(2,n+1):
    c=0
    r=int(i**0.5)
    for j in range(2,r+2):
        while i%j==0:
            c+=1
            i=i//j
        if c!=0:
            f.append([j,c])
            c=0
    if i!=1:
        f.append([i,1])
f.sort()
d=[]
ans=0
cou=f[0][1]
for i in range(1,len(f)):
    if f[i][0]==f[i-1][0]:
        cou+=f[i][1]
    else:
        d.append(cou)
        cou=1
d.append(cou)

for i in d:
    for j,num in enumerate([2,4,14,24,74]):
        if i>=num:
            w[j]+=1
print(w)
print(w[4]+w[3]*(w[0]-1)+w[2]*(w[1]-1)+w[1]*(w[1]-1)*(w[0]-2)//2)

Buggy submission (verdict: Runtime Error):
n=int(input())
f=[]
for i in range(2,n+1):
    c=0
    r=int(i**0.5)
    for j in range(2,r+2):
        while i%j==0:
            c+=1
            i=i//j
        if c!=0:
            f.append([j,c])
            c=0
    if i!=1:
        f.append([i,1])
f.sort()
d=[]
ans=0
cou=f[0][1]
for i in range(1,len(f)):
    if f[i][0]==f[i-1][0]:
        cou+=f[i][1]
    else:
        d.append(cou)
        cou=1
d.append(cou)

a74=0
for i in d:
    if i>=74:
        a74+=1
ans+=a74


a2=0
a24=0
for i in d:
    if i>=24:
        a24+=1
    if i>=2 and i<24:
        a2+=1
ans+=a2*a24
if a24>=2:
    ans+=a24*(a24-1)//2

    
a2,a4=0,0
for i in d:
    if i>=4:
        a4+=1
    elif i>=2:
        a2+=1
if a4>=2 and a2>=1:
    ans+=a4*(a4-1)//2*a2
if a4>=3:
    ans+=a4*(a4-1)*(a4-2)//2

    
a4,a14=0,0
for i in d:
    if i>=14:
        a14+=1
    if i>=4 and i<14:
        a4+=1
ans+=a4*a14
if a14>=2:
    ans+=a14*(a14-1)//2

print(ans)
Problem p03219 (python)

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

Buggy submission (verdict: Runtime Error):
x=int(input())
y=int(input())
print(x+y//2)
Problem p03262 (python)

Fixed submission:
import fractions
import functools
n,x=map(int,input().split())
xl=list(map(int,input().split()))
a=[]
for i in range(n):
    a.append(abs(xl[i]-x))
ans=functools.reduce(fractions.gcd,a)
print(ans)

Buggy submission (verdict: Runtime Error):
import math
import functools
n,x=map(int,input().split())
xl=list(map(int,input().split()))
a=[]
for i in range(n):
    a.append(abs(xl[i]-x))
ans=functools.reduce(math.gcd,a)
print(ans)
Problem p03280 (python)

Fixed submission:
a,b=map(int,input().split())
ans=a*b-a-b+1
print(ans)

Buggy submission (verdict: Runtime Error):
a=int(input())
b=int(input())
ans=a*b-a-b+1
print(ans)

Buggy submission (verdict: Runtime Error):
a=int(input())
b=int(input())
print(a*b-a-b+1)

Buggy submission (verdict: Runtime Error):
a=int(input())
b=int(input())
print(a*b-a-b+1)
Problem p03294 (python)

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

Buggy submission (verdict: Runtime Error):
n=input()
a=list(map(int,input().split()))
print(sum(a)-n)
Problem p03503 (python)

Fixed submission:
#080-C 
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(input())
def S(): return list(input())
n=I()
F=[int(input().replace(" ",""), 2) for _ in range(n)]
P=[IL() for i in range(n)]
ans=-pow(10,10)
for i in range(1,pow(2,10)):
    t=0
    for f,p in zip(F,P):
        t+=p[bin(f&i).count("1")]
    ans=max(ans,t)
print(ans)

Buggy submission (verdict: Runtime Error):
#080-C 
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(input())
def S(): return list(input())
n=IL()
F=[int(input().replace(" ",""), 2) for _ in range(n)]
P=[IL() for i in range(n)]
ans=-pow(10,10)
for i in range(1,pow(2,10)):
    t=0
    for f,p in zip(F,P):
        t+=p[bin(f&i).count("1")]
    ans=max(ans,t)
print(ans)